fix: bug#10821
This commit is contained in:
parent
dc0fc31503
commit
1c0812f8d5
|
@ -148,7 +148,7 @@
|
|||
<script setup lang="ts">
|
||||
import Guide from '../components/Guide.vue';
|
||||
import LineChart from '../components/LineChart.vue';
|
||||
import moment from 'moment';
|
||||
import dayjs from 'dayjs';
|
||||
import { queryFlow } from '@/api/iot-card/home';
|
||||
import TimeSelect from '@/views/iot-card/components/TimeSelect.vue';
|
||||
import { Empty } from 'ant-design-vue';
|
||||
|
@ -200,16 +200,16 @@ const getData = (
|
|||
*/
|
||||
const getDataTotal = () => {
|
||||
const dTime = [
|
||||
moment(new Date()).startOf('day').valueOf(),
|
||||
moment(new Date()).endOf('day').valueOf(),
|
||||
dayjs(new Date()).startOf('day').valueOf(),
|
||||
dayjs(new Date()).endOf('day').valueOf(),
|
||||
];
|
||||
const mTime = [
|
||||
moment().startOf('month').valueOf(),
|
||||
moment().endOf('month').valueOf(),
|
||||
dayjs().startOf('month').valueOf(),
|
||||
dayjs().endOf('month').valueOf(),
|
||||
];
|
||||
const yTime = [
|
||||
moment().startOf('year').valueOf(),
|
||||
moment().endOf('year').valueOf(),
|
||||
dayjs().startOf('year').valueOf(),
|
||||
dayjs().endOf('year').valueOf(),
|
||||
];
|
||||
getData(dTime[0], dTime[1]).then((resp) => {
|
||||
dayTotal.value = resp.data
|
||||
|
@ -238,9 +238,10 @@ const getDataTotal = () => {
|
|||
const getEcharts = (data: any) => {
|
||||
let startTime = data.start;
|
||||
let endTime = data.end;
|
||||
if (data.type === 'week' || data.type === 'month') {
|
||||
startTime = moment(data.start).startOf('days').valueOf();
|
||||
endTime = moment(data.end).startOf('days').valueOf();
|
||||
|
||||
if (data.type !== 'day') {
|
||||
startTime = dayjs(data.start).startOf('days').valueOf();
|
||||
endTime = dayjs(data.end).startOf('days').valueOf();
|
||||
}
|
||||
getData(startTime, endTime).then((resp) => {
|
||||
flowData.value = resp.sortArray;
|
||||
|
|
|
@ -70,10 +70,11 @@ const rangeVal = ref<[string, string]>();
|
|||
|
||||
const rangeChange = (val: any) => {
|
||||
radioValue.value = undefined;
|
||||
const differenceTime = dayjs(val[1]).valueOf() - dayjs(val[0]).valueOf()
|
||||
emit('change', {
|
||||
start: dayjs(val[0]).valueOf(),
|
||||
end: dayjs(val[1]).valueOf(),
|
||||
type: undefined,
|
||||
type: differenceTime > (24 * 60 * 60 * 1000) ? undefined : 'day',
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -103,6 +104,7 @@ const handleBtnChange = (val?: string) => {
|
|||
dayjs(startTime).format('YYYY-MM-DD HH:mm:ss'),
|
||||
dayjs(endTime).format('YYYY-MM-DD HH:mm:ss'),
|
||||
];
|
||||
console.log(startTime, endTime)
|
||||
emit('change', {
|
||||
start: startTime,
|
||||
end: endTime,
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
<template>
|
||||
<slot />
|
||||
</template>
|
||||
|
||||
<script setup lang='ts' name='ActionCheckItem'>
|
||||
import { ActionsType } from '@/views/rule-engine/Scene/typings'
|
||||
import { useSceneStore } from '@/store/scene';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { queryProductList } from '@/api/device/product'
|
||||
import { query as deviceQuery } from '@/api/device/instance'
|
||||
import { list as noticeConfigList } from '@/api/notice/config'
|
||||
import { list as noticeTemplateList } from '@/api/notice/template'
|
||||
import { Form } from 'jetlinks-ui-components'
|
||||
const sceneStore = useSceneStore();
|
||||
const { data: _data } = storeToRefs(sceneStore);
|
||||
|
||||
const formItemContext = Form.useInjectFormItemContext()
|
||||
|
||||
const props = defineProps({
|
||||
branchesName: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
thenName: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
name: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
});
|
||||
|
||||
const rules = [{
|
||||
validator(_: any, v?: ActionsType) {
|
||||
console.log('validator',v)
|
||||
if (v?.executor === 'device') {
|
||||
if(!v.device?.productId || !v.device?.selectorValues) {
|
||||
return Promise.reject(new Error('该数据已发生变更,请重新配置'))
|
||||
}
|
||||
}
|
||||
return Promise.resolve()
|
||||
}
|
||||
}]
|
||||
|
||||
const formTouchOff = () => {
|
||||
formItemContext.onFieldChange()
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验当前执行动作的设备或者产品是否删除
|
||||
*/
|
||||
const checkDeviceDelete = async () => {
|
||||
const item = _data.value.branches![props.branchesName].then[props.thenName].actions[props.name].device
|
||||
const proResp = await queryProductList({ terms: [{ terms: [{ column: 'id', termType: 'eq', value: item!.productId }]}]})
|
||||
if (proResp.success && (proResp.result as any)?.total === 0) { // 产品已删除
|
||||
_data.value.branches![props.branchesName].then[props.thenName].actions[props.name].device!.productId = undefined
|
||||
formTouchOff()
|
||||
return
|
||||
}
|
||||
const deviceList = item!.selectorValues?.map(item => item.value) || []
|
||||
const deviceResp = await deviceQuery({ terms: [{ terms: [{ column: 'id', termType: 'in', value: deviceList.toString() }]}]})
|
||||
if (deviceResp.success && (deviceResp.result as any)?.total < (item!.selectorValues?.length || 0)) { // 某一个设备被删除
|
||||
_data.value.branches![props.branchesName].then[props.thenName].actions[props.name].device!.selectorValues = undefined
|
||||
formTouchOff()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验当前执行动作的通知配置、消息模板是否删除
|
||||
*/
|
||||
const checkNoticeDelete = async () => {
|
||||
const item = _data.value.branches![props.branchesName].then[props.thenName].actions[props.name].notify
|
||||
const configResp = await noticeConfigList({ terms: [{ terms: [{ column: 'id', termType: 'eq', value: item!.notifierId }]}]})
|
||||
if (configResp.success && (configResp.result as any)?.total === 0) {
|
||||
_data.value.branches![props.branchesName].then[props.thenName].actions[props.name].notify!.notifierId = ''
|
||||
formTouchOff()
|
||||
return
|
||||
}
|
||||
const templateResp = await noticeTemplateList({ terms: [{ terms: [{ column: 'id', termType: 'eq', value: item!.templateId }]}]})
|
||||
if (templateResp.success && (templateResp.result as any)?.total === 0) {
|
||||
_data.value.branches![props.branchesName].then[props.thenName].actions[props.name].notify!.templateId = ''
|
||||
formTouchOff()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
nextTick(() => {
|
||||
const _executor = _data.value.branches![props.branchesName].then[props.thenName].actions[props.name]?.executor
|
||||
if (_executor === 'device') {
|
||||
checkDeviceDelete()
|
||||
} else if (_executor === 'notify') {
|
||||
checkNoticeDelete
|
||||
}
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
|
@ -1,6 +1,11 @@
|
|||
<template>
|
||||
<div class="actions-item-warp">
|
||||
<j-form-item
|
||||
:name='["branches", branchesName, "then", thenName, "actions", name]'
|
||||
:rules='rules'
|
||||
>
|
||||
<div class="actions-item">
|
||||
<CheckItem v-bind='props'>
|
||||
<div class="item-options-warp">
|
||||
<div class="item-options-type" @click="onAdd">
|
||||
<img
|
||||
|
@ -327,7 +332,9 @@
|
|||
<AIcon type="DeleteOutlined" />
|
||||
</div>
|
||||
</j-popconfirm>
|
||||
</CheckItem>
|
||||
</div>
|
||||
</j-form-item>
|
||||
<template v-if="!isLast && type === 'serial'">
|
||||
<div
|
||||
:class="[
|
||||
|
@ -399,6 +406,8 @@ import { iconMap, itemNotifyIconMap, typeIconMap } from './util';
|
|||
import FilterGroup from './FilterGroup.vue';
|
||||
import { randomString } from '@/utils/utils'
|
||||
import { EventEmitter, EventEmitterKeys } from '@/views/rule-engine/Scene/Save/util'
|
||||
import CheckItem from './CheckItem.vue'
|
||||
import { Form } from 'jetlinks-ui-components'
|
||||
|
||||
const sceneStore = useSceneStore();
|
||||
const { data: _data } = storeToRefs(sceneStore);
|
||||
|
@ -443,7 +452,7 @@ const eventEmitterKey = EventEmitterKeys({
|
|||
branchGroup: props.thenName,
|
||||
action: props.name
|
||||
})
|
||||
|
||||
const formItemContext = Form.useInjectFormItemContext()
|
||||
const termsOptions = computed(() => {
|
||||
if (!props.parallel) {
|
||||
// 串行
|
||||
|
@ -543,6 +552,56 @@ const onPropsCancel = () => {
|
|||
actionType.value = '';
|
||||
};
|
||||
|
||||
const rules = [{
|
||||
validator(_: any, v?: ActionsType) {
|
||||
console.log('validator',v)
|
||||
if (v?.executor === 'device') {
|
||||
if(!v.device?.productId || !v.device?.selectorValues) {
|
||||
return Promise.reject(new Error('该数据已发生变更,请重新配置'))
|
||||
}
|
||||
}
|
||||
return Promise.resolve()
|
||||
}
|
||||
}]
|
||||
|
||||
const formTouchOff = () => {
|
||||
console.log('formTouchOff')
|
||||
formItemContext.onFieldChange()
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验当前执行动作的设备或者产品是否删除
|
||||
*/
|
||||
const checkDeviceDelete = async () => {
|
||||
const item = _data.value.branches![props.branchesName].then[props.thenName].actions[props.name].device
|
||||
const proResp = await queryProductList({ terms: [{ terms: [{ column: 'id', termType: 'eq', value: item!.productId }]}]})
|
||||
if (proResp.success && (proResp.result as any)?.total === 0) { // 产品已删除
|
||||
_data.value.branches![props.branchesName].then[props.thenName].actions[props.name].device!.productId = undefined
|
||||
formTouchOff()
|
||||
return
|
||||
}
|
||||
const deviceList = item!.selectorValues?.map(item => item.value) || []
|
||||
const deviceResp = await deviceQuery({ terms: [{ terms: [{ column: 'id', termType: 'in', value: deviceList.toString() }]}]})
|
||||
if (deviceResp.success && (deviceResp.result as any)?.total < (item!.selectorValues?.length || 0)) { // 某一个设备被删除
|
||||
_data.value.branches![props.branchesName].then[props.thenName].actions[props.name].device!.selectorValues = undefined
|
||||
formTouchOff()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验当前执行动作的通知配置、消息模板是否删除
|
||||
*/
|
||||
const checkNoticeDelete = () => {
|
||||
|
||||
}
|
||||
|
||||
nextTick(() => {
|
||||
if (_data.value.branches![props.branchesName].then[props.thenName].actions[props.name]?.executor === 'device') {
|
||||
checkDeviceDelete()
|
||||
}
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
@ -571,7 +630,7 @@ const onPropsCancel = () => {
|
|||
|
||||
.actions-item {
|
||||
position: relative;
|
||||
margin-bottom: 24px;
|
||||
//margin-bottom: 24px;
|
||||
padding: 16px;
|
||||
border: 1px dashed #999;
|
||||
border-radius: 2px;
|
||||
|
|
|
@ -73,6 +73,19 @@ const thenName = computed(() => {
|
|||
return _data.value.branches![props.branchesName].then.findIndex(item => item.parallel === props.parallel)
|
||||
})
|
||||
|
||||
|
||||
const rules = [{
|
||||
validator(_: any, v?: ActionsType) {
|
||||
console.log('validator',v)
|
||||
if (v?.executor === 'device') {
|
||||
if(!v.device?.productId || !v.device?.selectorValues) {
|
||||
return Promise.reject(new Error('该数据已发生变更,请重新配置'))
|
||||
}
|
||||
}
|
||||
return Promise.resolve()
|
||||
}
|
||||
}]
|
||||
|
||||
const onAdd = () => {
|
||||
visible.value = true;
|
||||
};
|
||||
|
|
|
@ -151,6 +151,7 @@ const onAdd = (actionItem: any, _parallel: boolean) => {
|
|||
}
|
||||
formItemContext.onFieldChange()
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style lang='less' scoped>
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
<template>
|
||||
<j-menu class='scene-dropdown-menus' @click='click' :selectedKeys='[myValue]'>
|
||||
<j-menu-item v-for='item in myOptions' :key='item.value' :title='item.label'>
|
||||
{{ item.label }}
|
||||
<Ellipsis >
|
||||
{{ item.label }}
|
||||
</Ellipsis>
|
||||
</j-menu-item>
|
||||
</j-menu>
|
||||
</template>
|
||||
|
|
Loading…
Reference in New Issue