diff --git a/src/store/department.ts b/src/store/department.ts index 3bcbbb9b..4ae0b2a4 100644 --- a/src/store/department.ts +++ b/src/store/department.ts @@ -4,6 +4,7 @@ import { defineStore } from "pinia"; type DepartmentStateType = { productId: string; optType: string | undefined; + crossPageKeys: string[]; } export const useDepartmentStore = defineStore({ @@ -13,14 +14,20 @@ export const useDepartmentStore = defineStore({ // 设备资产分配弹窗操作类型: // 1. optType === 'handle': 手动点击资产分配按钮; // 2. optType === ': 产品资产分配后, 自动弹出设备资产分配 - optType: '' + optType: '', + crossPageKeys: [], // 表格跨页多选的keys }), actions: { setProductId(value: string) { - this.productId = value + this.productId = value; }, setType(value: string | undefined) { - this.optType = value + this.optType = value; + }, + setSelectedKeys(value: string[], type?: string) { + // 分页保留选中项 + // this.crossPageKeys = type === 'pagination' ? [...new Set([...this.crossPageKeys, ...value])] : value; + this.crossPageKeys = [...new Set([...this.crossPageKeys, ...value])]; } } }) \ No newline at end of file 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/device/DashBoard/index.vue b/src/views/device/DashBoard/index.vue index d406b886..3e50ea87 100644 --- a/src/views/device/DashBoard/index.vue +++ b/src/views/device/DashBoard/index.vue @@ -439,7 +439,7 @@ const setDevMesChartOption = ( // // }, // }, { - name: '占比', + name: '消息量', data: y, // data: percentageY, type: 'line', 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 @@ - + @@ -83,7 +83,7 @@ /> - + @@ -142,9 +143,6 @@ const visible = ref(false); */ const modalForm = reactive({ host: '0.0.0.0', - port: '', - publicHost: '', - publicPort: null, }); /** * 校验官网地址 diff --git a/src/views/init-home/Menu/index.vue b/src/views/init-home/Menu/index.vue index 2f7aa748..2100fd9c 100644 --- a/src/views/init-home/Menu/index.vue +++ b/src/views/init-home/Menu/index.vue @@ -13,68 +13,80 @@ \ 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 @@ - + - + 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/Department/user/components/AddBindUserDialog.vue b/src/views/system/Department/user/components/AddBindUserDialog.vue index a197a3a5..45bbe673 100644 --- a/src/views/system/Department/user/components/AddBindUserDialog.vue +++ b/src/views/system/Department/user/components/AddBindUserDialog.vue @@ -33,6 +33,7 @@ :pagination="{ showSizeChanger: true, pageSizeOptions: ['10', '20', '50', '100'], + change: handlePageChange, }" /> @@ -42,6 +43,9 @@