From ee7c4e11f7a0557fbb9e9861af11e8007940086d Mon Sep 17 00:00:00 2001 From: 100011797 <2642441182@qq.com> Date: Mon, 27 Mar 2023 17:04:08 +0800 Subject: [PATCH 1/6] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=E8=81=94=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Instance/Detail/Running/Event/index.vue | 14 +-- .../Detail/Running/Property/Indicators.vue | 13 +- .../action/Device/actions/FunctionItem.vue | 2 +- .../action/Device/actions/WriteProperty.vue | 11 +- .../Save/action/Device/actions/index.vue | 61 ++++++--- .../Scene/Save/action/Device/device/Tag.vue | 9 +- .../Scene/Save/action/Device/device/index.vue | 101 +++++++++------ .../Scene/Save/action/Device/index.vue | 117 ++++++------------ .../Scene/Save/action/Device/typings.d.ts | 40 +++--- .../Scene/Save/action/ListItem/Item.vue | 20 +-- .../Save/action/Modal/ActionTypeComponent.vue | 4 + .../system/DataSource/Management/index.vue | 38 +++--- yarn.lock | 4 +- 13 files changed, 224 insertions(+), 210 deletions(-) diff --git a/src/views/device/Instance/Detail/Running/Event/index.vue b/src/views/device/Instance/Detail/Running/Event/index.vue index 0152b8af..e263430e 100644 --- a/src/views/device/Instance/Detail/Running/Event/index.vue +++ b/src/views/device/Instance/Detail/Running/Event/index.vue @@ -1,5 +1,5 @@ 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..2e4c3bcb 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,12 +22,13 @@ 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 = [ @@ -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/Tag.vue b/src/views/rule-engine/Scene/Save/action/Device/device/Tag.vue index 8f8b701e..e1d4f346 100644 --- a/src/views/rule-engine/Scene/Save/action/Device/device/Tag.vue +++ b/src/views/rule-engine/Scene/Save/action/Device/device/Tag.vue @@ -177,15 +177,8 @@ const onValueChange = () => { value: item.value, }; }); - const arr = _data.map((item: any) => { - return { - column: item.name, - type: item.type, - value: item.value, - }; - }); emits('update:value', [{ value: newValue, name: '标签' }]); - emits('change', [{ value: newValue, name: '标签' }], arr); + emits('change', [{ value: newValue, name: '标签' }], _data); }; 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..7abb6074 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/yarn.lock b/yarn.lock index 35ef0063..cd047e8c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3700,8 +3700,8 @@ jetlinks-store@^0.0.3: jetlinks-ui-components@^1.0.5: version "1.0.5" - resolved "http://47.108.170.157:9013/jetlinks-ui-components/-/jetlinks-ui-components-1.0.5.tgz#593185f6313895485b59e9a79bc920c63374d84d" - integrity sha512-dkSOmatSPLHlV91YdTcHWO2wfwriUIZKEuLd5bJF2GsO9SvDMyJ2YJ4n/3fkklOoL5albhY37iX2Ot3A+7QYwA== + resolved "http://47.108.170.157:9013/jetlinks-ui-components/-/jetlinks-ui-components-1.0.5.tgz#6a3cc76cd6d98319e070da597bfcf146fa12d375" + integrity sha512-ASPqiWprK2v4/zQIYxOytjkVFgx+AkBaD5Klg2ik88y9uDAW/Ylvqa91v149znihU1y8Q2Nm2PXvUSJFD7HPpw== dependencies: "@vueuse/core" "^9.12.0" ant-design-vue "^3.2.15" From 324d78a213abe95bd497b822823218a5c96faa61 Mon Sep 17 00:00:00 2001 From: 100011797 <2642441182@qq.com> Date: Mon, 27 Mar 2023 17:48:47 +0800 Subject: [PATCH 2/6] =?UTF-8?q?fix:=20=E5=8C=97=E5=90=91=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DuerOS/Detail/command/index.vue | 1 + src/views/Northbound/DuerOS/Detail/index.vue | 36 +++++++++++++++++-- .../Save/action/Device/actions/index.vue | 6 ++-- .../Save/action/Device/device/Device.vue | 21 ++++++++--- .../Scene/Save/action/Device/index.vue | 1 - .../Save/action/Modal/ActionTypeComponent.vue | 4 --- 6 files changed, 54 insertions(+), 15 deletions(-) diff --git a/src/views/Northbound/DuerOS/Detail/command/index.vue b/src/views/Northbound/DuerOS/Detail/command/index.vue index 8d22a8f4..87b86321 100644 --- a/src/views/Northbound/DuerOS/Detail/command/index.vue +++ b/src/views/Northbound/DuerOS/Detail/command/index.vue @@ -208,6 +208,7 @@ const onPropertyChange = (val: string) => { (item: any) => item.id === val, ); property.value = _item || {}; + modelRef.message.value = undefined } }; diff --git a/src/views/Northbound/DuerOS/Detail/index.vue b/src/views/Northbound/DuerOS/Detail/index.vue index c52e19fa..00e6a690 100644 --- a/src/views/Northbound/DuerOS/Detail/index.vue +++ b/src/views/Northbound/DuerOS/Detail/index.vue @@ -214,6 +214,12 @@ item.actionType " show-search + @change=" + () => + onActionTypeChange( + index, + ) + " > { actionActiveKey.value = _key; }; +const onActionTypeChange = (_index: number) => { + modelRef.actionMappings[_index].command = { + messageType: undefined, + message: { + properties: undefined, + functionId: undefined, + inputs: [], + value: undefined + }, + }; +}; + const addItem = () => { actionActiveKey.value.push(String(modelRef.actionMappings.length)); modelRef.actionMappings.push({ @@ -527,6 +545,20 @@ const productChange = (value: string) => { modelRef.propertyMappings = modelRef.propertyMappings.map((item) => { return { source: item.source, target: [] }; }); + modelRef.actionMappings = modelRef.actionMappings.map((item) => { + return { + ...item, + command: { + messageType: undefined, + message: { + properties: undefined, + functionId: undefined, + inputs: [], + value: undefined, + }, + }, + }; + }); const item = productList.value.find((item) => item.id === value); if (item) { modelRef.productName = item.name; @@ -571,7 +603,7 @@ const getTypes = async () => { }; const getDuerOSProperties = (val: string) => { - console.log(val) + console.log(val); const arr = modelRef.propertyMappings.map((item) => item?.source) || []; const checked = _.cloneDeep(arr); const _index = checked.findIndex((i) => i === val); @@ -673,7 +705,7 @@ watch( _data.applianceType = _data?.applianceType?.value; } Object.assign(modelRef, _data); - console.log(modelRef.propertyMappings) + console.log(modelRef.propertyMappings); } }, { immediate: true, deep: true }, 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 2e4c3bcb..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 @@ -34,7 +34,7 @@ @@ -176,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( 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 @@ \ No newline at end of file diff --git a/src/views/init-home/data/RoleData.ts b/src/views/init-home/data/RoleData.ts index 41ca3184..c4821759 100644 --- a/src/views/init-home/data/RoleData.ts +++ b/src/views/init-home/data/RoleData.ts @@ -29,6 +29,21 @@ export const RoleData = { export default { [ROLEKEYS.device]: [ + { + assetAccesses: [], + code: "device/DashBoard", + createTime: 1679906031144, + granted: true, + icon: "icon-keshihua", + id:"68a02c9efa9fb4885c89b007f97d074d", + level:3, + name:"仪表盘", + owner: "iot", + parentId :"b6327c3ff01b49c9a7a96101606dc27a", + path:"WXaI-KCgA-gBU0", + sortIndex:1, + url:"/iot/device/DashBoard", + }, { id: '1-3-2', parentId: '1-3', diff --git a/src/views/init-home/data/interface.ts b/src/views/init-home/data/interface.ts index ae9a01f7..7728eac5 100644 --- a/src/views/init-home/data/interface.ts +++ b/src/views/init-home/data/interface.ts @@ -3,9 +3,9 @@ import type { UploadChangeParam, UploadProps } from 'ant-design-vue'; /** 初始化数据提交表单 */ export interface modalState { host: string; // 本地地址 - port: string; // 本地端口 - publicHost: string; // 公网地址 - publicPort: number | null; // 公网端口 + port?: string; // 本地端口 + publicHost?: string; // 公网地址 + publicPort?: number | null; // 公网端口 } diff --git a/src/views/init-home/index.vue b/src/views/init-home/index.vue index 2ce6da21..53d43f6a 100644 --- a/src/views/init-home/index.vue +++ b/src/views/init-home/index.vue @@ -18,14 +18,14 @@ - + - +