diff --git a/src/components/ValueItem/index.vue b/src/components/ValueItem/index.vue index cef5feda..0b5c4b1d 100644 --- a/src/components/ValueItem/index.vue +++ b/src/components/ValueItem/index.vue @@ -78,6 +78,7 @@ /> , default: '' + }, + placeholder: { + type: String, + default: () => '', } }); // type Props = { diff --git a/src/views/Northbound/DuerOS/Detail/command/EditTable.vue b/src/views/Northbound/DuerOS/Detail/command/EditTable.vue index 011f67ec..355aad62 100644 --- a/src/views/Northbound/DuerOS/Detail/command/EditTable.vue +++ b/src/views/Northbound/DuerOS/Detail/command/EditTable.vue @@ -14,7 +14,7 @@ :name="['dataSource', index, 'value']" :rules="[ { - required: true, + required: record.required, message: record.type === 'enum' || record.type === 'boolean' diff --git a/src/views/Northbound/DuerOS/Detail/command/index.vue b/src/views/Northbound/DuerOS/Detail/command/index.vue index 0fda44f2..126b970e 100644 --- a/src/views/Northbound/DuerOS/Detail/command/index.vue +++ b/src/views/Northbound/DuerOS/Detail/command/index.vue @@ -56,7 +56,7 @@ placeholder="请选择属性" v-model:value="modelRef.message.properties" show-search - @change="onPropertyChange" + @change="(val) => onPropertyChange(val, false)" > { (item: any) => item.id === val, ); property.value = _item || {}; - if(!flag){ - modelRef.message.value = undefined - } + } + if(!flag){ + modelRef.message.value = undefined } }; @@ -249,6 +250,7 @@ const funcChange = (val: string) => { name: item.name, value: undefined, valueType: item?.valueType?.type, + required: item?.expands?.required }; }); modelRef.message.inputs = list; @@ -265,7 +267,6 @@ const saveBtn = () => resolve(false); }); } - console.log(_data) emit('update:modelValue', _data) resolve(_data); }) diff --git a/src/views/Northbound/DuerOS/Detail/index.vue b/src/views/Northbound/DuerOS/Detail/index.vue index 1e988743..8ef98fff 100644 --- a/src/views/Northbound/DuerOS/Detail/index.vue +++ b/src/views/Northbound/DuerOS/Detail/index.vue @@ -42,6 +42,10 @@ required: true, message: '请选择产品', }, + // { + // validator: _validator, + // trigger: 'change', + // }, ]" > - + - + { const delItem = (index: number) => { modelRef.actionMappings.splice(index, 1); + if (!modelRef.actionMappings.length) { + addItem(); + } }; const addPropertyItem = () => { propertyActiveKey.value.push(String(modelRef.propertyMappings.length)); modelRef.propertyMappings.push({ source: undefined, - target: [], + target: undefined, }); }; const delPropertyItem = (index: number) => { modelRef.propertyMappings.splice(index, 1); + if (!modelRef.propertyMappings.length) { + addPropertyItem(); + } }; const productChange = (value: string) => { - modelRef.propertyMappings = modelRef.propertyMappings.map((item) => { - return { source: item.source, target: [] }; + modelRef.propertyMappings = modelRef.propertyMappings?.map((item) => { + return { source: item.source, target: undefined }; }); - modelRef.actionMappings = modelRef.actionMappings.map((item) => { + modelRef.actionMappings = modelRef.actionMappings?.map((item) => { return { ...item, command: { @@ -608,10 +639,10 @@ const productChange = (value: string) => { }; const typeChange = () => { - modelRef.propertyMappings = modelRef.propertyMappings.map((item) => { + modelRef.propertyMappings = modelRef.propertyMappings?.map((item) => { return { source: undefined, target: item.target }; }); - modelRef.actionMappings = modelRef.actionMappings.map((item) => { + modelRef.actionMappings = modelRef.actionMappings?.map((item) => { return { ...item, action: undefined }; }); }; @@ -645,49 +676,60 @@ const getTypes = async () => { }; const getDuerOSProperties = (val: string) => { - console.log(val); - const arr = modelRef.propertyMappings.map((item) => item?.source) || []; + const arr = modelRef.propertyMappings?.map((item) => item?.source) || []; const checked = _.cloneDeep(arr); const _index = checked.findIndex((i) => i === val); // 去掉重复的 checked.splice(_index, 1); const targetList = findApplianceType.value?.properties; const list = targetList?.filter( - (i: { id: string }) => !checked.includes(i?.id as any), + (i: { id: string }) => !checked?.includes(i?.id as any), ); return list || []; }; const getProductProperties = (val: string[]) => { const items = - modelRef.propertyMappings.map((item: { target: string[] }) => - item?.target.map((j) => j), - ) || []; - const checked = _.flatMap(items); + modelRef.propertyMappings?.map((item: any) => item?.target) || []; + const checked = items.filter((i) => i); const _checked: any[] = []; - checked.map((_item) => { - if (!val.includes(_item)) { + checked?.map((_item) => { + if (!val?.includes(_item)) { _checked.push(_item); } }); const sourceList = findProductMetadata.value?.properties; const list = sourceList?.filter( - (i: { id: string }) => !_checked.includes(i.id), + (i: { id: string }) => !_checked?.includes(i.id), ); return list || []; }; const getTypesActions = (val: string) => { - const items = modelRef.actionMappings.map((item) => item?.action) || []; + const items = modelRef.actionMappings?.map((item) => item?.action) || []; const checked = _.cloneDeep(items); const _index = checked.findIndex((i) => i === val); checked.splice(_index, 1); const actionsList = findApplianceType.value?.actions || []; const list = actionsList?.filter( - (i: { id: string; name: string }) => !checked.includes(i?.id as any), + (i: { id: string; name: string }) => !checked?.includes(i?.id as any), ); return list || []; }; + +// const _validator = (_rule: any, value: string): Promise => +// new Promise((resolve, reject) => { +// const _item = productList.value.find((item) => item.id === value); +// if (!_item) { +// return reject('该产品已被删除'); +// } +// return resolve(''); +// }); + +watchEffect(() => { + console.log(modelRef.id) +}) + const saveBtn = async () => { const tasks: any[] = []; for (let i = 0; i < command.value.length; i++) { @@ -704,6 +746,16 @@ const saveBtn = async () => { .then(async (data: any) => { if (tasks.every((item) => item) && data) { loading.value = true; + data.propertyMappings = data.propertyMappings?.map( + (it: any) => { + return { + source: it.source, + target: Array.isArray(it?.target) + ? it?.target + : [it?.target], + }; + }, + ); const resp = await savePatch(data).finally(() => { loading.value = false; }); @@ -715,12 +767,12 @@ const saveBtn = async () => { } }) .catch((err: any) => { - const _arr = err.errorFields.map((item: any) => item.name); - _arr.map((item: string | any[]) => { + const _arr = err.errorFields?.map((item: any) => item.name); + _arr?.map((item: string | any[]) => { if (item.length >= 3) { if ( item[0] === 'propertyMappings' && - !propertyActiveKey.value.includes(item[1]) + !propertyActiveKey.value?.includes(item[1]) ) { propertyActiveKey.value.push(item[1]); } @@ -738,16 +790,16 @@ watch( () => route.params?.id, async (newId) => { if (newId) { - getProduct(newId as string); + await getProduct(newId as string); getTypes(); if (newId === ':id') return; const resp = await detail(newId as string); const _data: any = resp.result; + const _obj = cloneDeep(_data); if (_data) { - _data.applianceType = _data?.applianceType?.value; + _obj.applianceType = _obj?.applianceType?.value; } - Object.assign(modelRef, _data); - console.log(modelRef.propertyMappings); + Object.assign(modelRef, _obj); } }, { immediate: true, deep: true }, diff --git a/src/views/init-home/data/baseMenu.ts b/src/views/init-home/data/baseMenu.ts index 9b7df810..15c8bf14 100644 --- a/src/views/init-home/data/baseMenu.ts +++ b/src/views/init-home/data/baseMenu.ts @@ -26,7 +26,7 @@ export const USER_CENTER_MENU_DATA = { permissions: [ { permission: 'user', - action: ['update-self-pwd'] + actions: ['update-self-pwd'] }, { permission: 'system_config', diff --git a/src/views/system/NoticeRule/components/Auth/index.vue b/src/views/system/NoticeRule/components/Auth/index.vue index d7dba70b..f987ffb4 100644 --- a/src/views/system/NoticeRule/components/Auth/index.vue +++ b/src/views/system/NoticeRule/components/Auth/index.vue @@ -6,7 +6,7 @@ @cancel="emit('close')" @ok="onSave" > - + diff --git a/src/views/system/NoticeRule/components/Item/index.vue b/src/views/system/NoticeRule/components/Item/index.vue index e073e842..3db85024 100644 --- a/src/views/system/NoticeRule/components/Item/index.vue +++ b/src/views/system/NoticeRule/components/Item/index.vue @@ -304,12 +304,12 @@ const onAction = (e: boolean) => { role: { idList: [], }, - permissions: [ + permissions: props.provider === 'alarm' ? [ { id: 'alarm-config', actions: ['query'], }, - ], + ] : [], }, }, ], diff --git a/src/views/system/Platforms/Api/components/ChooseApi.vue b/src/views/system/Platforms/Api/components/ChooseApi.vue index 440fe864..4211e3d9 100644 --- a/src/views/system/Platforms/Api/components/ChooseApi.vue +++ b/src/views/system/Platforms/Api/components/ChooseApi.vue @@ -8,6 +8,7 @@ noPagination model="TABLE" > +