diff --git a/src/api/data-collect/collector.ts b/src/api/data-collect/collector.ts index 6c1ed981..8f91b4f8 100644 --- a/src/api/data-collect/collector.ts +++ b/src/api/data-collect/collector.ts @@ -4,7 +4,10 @@ export const queryCollector = (data: any) => server.post(`/data-collect/collector/_query/no-paging?paging=false`, data); export const queryChannelNoPaging = () => - server.post(`/data-collect/channel/_query/no-paging`, { paging: false }); + server.post(`/data-collect/channel/_query/no-paging`, { + paging: false, + sorts: [{ name: 'createTime', order: 'desc' }], + }); export const save = (data: any) => server.post(`/data-collect/collector`, data); diff --git a/src/components/Ellipsis/index.vue b/src/components/Ellipsis/index.vue deleted file mode 100644 index 56f62a82..00000000 --- a/src/components/Ellipsis/index.vue +++ /dev/null @@ -1,170 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/components/Metadata/VirtualRuleParam/index.vue b/src/components/Metadata/VirtualRuleParam/index.vue index 5452a0e5..751a1033 100644 --- a/src/components/Metadata/VirtualRuleParam/index.vue +++ b/src/components/Metadata/VirtualRuleParam/index.vue @@ -1,4 +1,7 @@ diff --git a/src/views/rule-engine/Scene/Save/action/Device/actions/WriteProperty.vue b/src/views/rule-engine/Scene/Save/action/Device/actions/WriteProperty.vue index d6533ba7..066e9287 100644 --- a/src/views/rule-engine/Scene/Save/action/Device/actions/WriteProperty.vue +++ b/src/views/rule-engine/Scene/Save/action/Device/actions/WriteProperty.vue @@ -41,7 +41,7 @@ @select="onValueChange" > @@ -112,7 +112,6 @@ const filterParamsData = (type?: string, data?: any[]): any[] => { item.children = _children; return _children.length ? true : false; } else if (item.type === type) { - // optionMap.current.set(item.id, item); return true; } return false; @@ -132,12 +131,12 @@ const handleOptions = computed(() => { if (_type === 'boolean') { return [ { - label: _item.trueText, - value: _item.trueValue, + label: _item.trueText || true, + value: _item.trueValue || true, }, { - label: _item.falseText, - value: _item.falseValue, + label: _item.falseText || false, + value: _item.falseValue || false, }, ]; } diff --git a/src/views/rule-engine/Scene/Save/action/Device/actions/index.vue b/src/views/rule-engine/Scene/Save/action/Device/actions/index.vue index e6004fd6..5266196e 100644 --- a/src/views/rule-engine/Scene/Save/action/Device/actions/index.vue +++ b/src/views/rule-engine/Scene/Save/action/Device/actions/index.vue @@ -22,18 +22,19 @@ showSearch placeholder="请选择功能" v-model:value="modelRef.message.functionId" - @select="functionSelect" + @change="functionSelect" > {{ item?.name }} @@ -54,6 +55,7 @@ showSearch placeholder="请选择属性" v-model:value="modelRef.message.properties[0]" + @change="propertySelect" > {{ item?.name }} @@ -130,8 +133,14 @@ const props = defineProps({ type: Number, default: 0, }, + productDetail: { + type: Object, + default: () => {}, + }, }); +const emit = defineEmits(['change']); + const formRef = ref(); const modelRef = reactive({ @@ -146,8 +155,19 @@ const modelRef = reactive({ const writeFormRef = ref(); -const functionSelect = () => { +const functionSelect = (val: any, options?: any) => { modelRef.message.inputs = []; + emit('change', { + propertiesName: options?.label, + propertiesValue: modelRef.propertiesValue, + }); +}; + +const propertySelect = (val: any, options?: any) => { + emit('change', { + propertiesName: options?.label, + propertiesValue: modelRef.propertiesValue, + }); }; const functionRules = [ @@ -156,11 +176,11 @@ const functionRules = [ if (!value?.length && functions.value.length) { return Promise.reject('请输入功能值'); } else { - const hasValue = value.find( + const hasValue = value?.find( (item: { name: string; value: any }) => !item.value, ); if (hasValue) { - const functionItem = functions.value.find( + const functionItem = functions.value?.find( (item: any) => item.id === hasValue.name, ); return Promise.reject( @@ -239,11 +259,11 @@ const onMessageTypeChange = (val: string) => { }; watch( - () => props.values, + () => props.productDetail, (newVal) => { - if (newVal?.productDetail?.id) { - if (newVal?.selector === 'fixed') { - const id = newVal?.selectorValues?.[0]?.value; + if (newVal?.id) { + if (props.values?.selector === 'fixed') { + const id = props.values?.selectorValues?.[0]?.value; if (id) { detail(id).then((resp) => { if (resp.status === 200) { @@ -254,9 +274,7 @@ watch( }); } } else { - metadata.value = JSON.parse( - newVal?.productDetail?.metadata || '{}', - ); + metadata.value = JSON.parse(newVal?.metadata || '{}'); } } }, @@ -282,6 +300,13 @@ watch( const onWriteChange = (val: string) => { modelRef.propertiesValue = val; + emit('change', { + propertiesName: + deviceMessageType.value === 'INVOKE_FUNCTION' + ? _function.value?.name + : _property.value?.name, + propertiesValue: modelRef.propertiesValue, + }); }; const onFormSave = () => { @@ -295,19 +320,19 @@ const onFormSave = () => { reject(false); } } - // 处理三种情况的值的格式 - const obj = { + resolve({ message: { ...modelRef.message, ..._data.message, - propertiesName: - deviceMessageType.value === 'INVOKE_FUNCTION' - ? _function.value?.name - : _property.value?.name, - propertiesValue: modelRef.propertiesValue, }, - }; - resolve(obj); + }); + emit('change', { + propertiesName: + deviceMessageType.value === 'INVOKE_FUNCTION' + ? _function.value?.name + : _property.value?.name, + propertiesValue: modelRef.propertiesValue, + }); }) .catch((err: any) => { reject(err); diff --git a/src/views/rule-engine/Scene/Save/action/Device/device/Device.vue b/src/views/rule-engine/Scene/Save/action/Device/device/Device.vue index 418e943c..a4d72697 100644 --- a/src/views/rule-engine/Scene/Save/action/Device/device/Device.vue +++ b/src/views/rule-engine/Scene/Save/action/Device/device/Device.vue @@ -66,7 +66,7 @@ diff --git a/src/views/rule-engine/Scene/Save/action/Device/device/index.vue b/src/views/rule-engine/Scene/Save/action/Device/device/index.vue index 6963427d..13bf7a9e 100644 --- a/src/views/rule-engine/Scene/Save/action/Device/device/index.vue +++ b/src/views/rule-engine/Scene/Save/action/Device/device/index.vue @@ -13,18 +13,12 @@ @change="onSelectorChange" /> - - {}, + }, }); // save保存deviceDetail @@ -122,9 +120,7 @@ const modelRef = reactive({ selectorValues: undefined, deviceId: '', source: '', - relationName: '', upperKey: '', - message: undefined, }); const list = ref([]); @@ -166,10 +162,11 @@ const filterTree = (nodes: any[]) => { if ( it.children.find( (item: any) => - item.id.indexOf('deviceId' || 'device_id' || 'device_Id') > - -1, + item?.id?.indexOf( + 'deviceId' || 'device_id' || 'device_Id', + ) > -1, ) && - !it.children.find((item: any) => item.id.indexOf('boolean') > -1) + !it.children.find((item: any) => item?.id.indexOf('boolean') > -1) ) { return true; } @@ -197,7 +194,7 @@ const sourceChangeEvent = async () => { const productId = data.value?.branches?.[props.branchesName].then?.[props.thenName] ?.actions?.[props.name > 0 ? props.name - 1 : 0]?.device?.productId; - if (productId === props.values?.productDetail?.id) { + if (productId === props?.productDetail?.id) { const _data = await getParams(_params, unref(data)); builtInList.value = handleParamsData(filterTree(_data), 'id'); } else { @@ -205,7 +202,7 @@ const sourceChangeEvent = async () => { } }; -const filterType = async () => { +const filterType = async (newVal: any) => { const _list = TypeList.filter((item) => item.value === 'fixed'); if (unref(data)?.trigger?.type === 'device') { //关系 @@ -221,10 +218,9 @@ const filterType = async () => { _list.push(...array); } //标签 - const tag = JSON.parse( - props.values.productDetail?.metadata || '{}', - )?.tags; + const tag = JSON.parse(newVal?.metadata || '{}')?.tags; if (tag && tag.length !== 0) { + tagList.value = tag || []; const array = TypeList.filter((item) => item.value === 'tag'); _list.push(...array); } @@ -251,23 +247,23 @@ const filterType = async () => { } }; -const onSelectorChange = () => { +const onSelectorChange = (val: string) => { modelRef.selectorValues = undefined; + modelRef.selector = val; }; const onDeviceChange = (_detail: any) => { if (_detail) { if (_detail.id) { - modelRef.deviceId = _detail.id; + modelRef.deviceId = _detail?.id; modelRef.selectorValues = [ { value: _detail.id, name: _detail.name }, ] as any; - modelRef.message = {} as any; } else { modelRef.deviceId = ''; modelRef.selectorValues = [] as any; } - emits('save', unref(modelRef), _detail); + emits('save', unref(modelRef), { name: _detail.name }); } }; @@ -276,8 +272,7 @@ const onRelationChange = (val: any, options: any) => { modelRef.source = 'upper'; modelRef.selectorValues = val; modelRef.upperKey = 'scene.deviceId'; - modelRef.relationName = options.label; - emits('save', unref(modelRef), {}); + emits('save', unref(modelRef), { relationName: options.label }); }; const onTagChange = (val: any[], arr: any[]) => { @@ -285,27 +280,61 @@ const onTagChange = (val: any[], arr: any[]) => { modelRef.deviceId = 'deviceId'; modelRef.source = 'fixed'; } - emits('save', unref(modelRef), {}, arr ? { tagList: arr } : {}); + const tagName = arr.map((i, _index) => { + return `${_index !== 0 && _index !== (arr || []).length && i.type}${ + i.name + }为${i.value}`; + }); + emits( + 'save', + unref(modelRef), + {}, + arr ? { tagName: tagName.join('') } : {}, + ); }; const onVariableChange = (val: any, node: any) => { modelRef.deviceId = val; modelRef.selectorValues = [{ value: val, name: node.description }] as any; - emits('save', unref(modelRef), node); + emits('save', unref(modelRef), { name: node.description }); }; -watchEffect(() => { - Object.assign(modelRef, props.values); -}); +watch( + () => props.values, + (newVal) => { + Object.assign(modelRef, newVal); + }, + { + immediate: true, + deep: true, + }, +); watch( - () => props.values.productDetail, + () => props.productDetail, async (newVal) => { await sourceChangeEvent(); if (newVal) { - const metadata = JSON.parse(newVal?.metadata || '{}'); - tagList.value = metadata?.tags || []; - filterType(); + filterType(newVal); + } + }, + { + immediate: true, + deep: true, + }, +); + +watch( + () => [props.values, builtInList.value], + ([newVal1, newVal2]) => { + if (newVal2 && newVal2.length) { + const param = newVal1?.selectorValues?.[0]?.value; + const isVariable = (newVal2 || [])?.find((item: any) => { + return item.children.find((i: any) => i.id === param); + }); + if (isVariable) { + modelRef.selector = 'variable'; + } } }, { @@ -319,14 +348,14 @@ const onFormSave = () => { formRef.value .validate() .then(async (_data: any) => { - if(modelRef.selector === 'fixed'){ - if(!modelRef?.selectorValues?.[0]?.value){ - onlyMessage('请选择设备', 'error') + if (modelRef.selector === 'fixed') { + if (!modelRef?.selectorValues?.[0]?.value) { + onlyMessage('请选择设备', 'error'); reject(false); } else { resolve({ ..._data, - selectorValues: modelRef.selectorValues + selectorValues: modelRef.selectorValues, }); } } else { diff --git a/src/views/rule-engine/Scene/Save/action/Device/index.vue b/src/views/rule-engine/Scene/Save/action/Device/index.vue index de9c3580..488a1c00 100644 --- a/src/views/rule-engine/Scene/Save/action/Device/index.vue +++ b/src/views/rule-engine/Scene/Save/action/Device/index.vue @@ -23,7 +23,7 @@ diff --git a/src/views/system/Menu/Setting/index.vue b/src/views/system/Menu/Setting/index.vue index 9634b5b5..bf7bcea4 100644 --- a/src/views/system/Menu/Setting/index.vue +++ b/src/views/system/Menu/Setting/index.vue @@ -3,84 +3,84 @@
- 基于系统源代码中的菜单数据,配置系统菜单。 + 单击可切换菜单未选中/选中状态;操作父级菜单时,对应子菜单状态将默认与其同步,可以单独操作调整;支持拖拽菜单调整展示顺序。 +
-
- 系统菜单 - - +
+ - - -
-
- - - + +
+
+ 保存 + + 保存后当前系统菜单数据将被覆盖,确认操作? +