diff --git a/src/components/ValueItem/index.vue b/src/components/ValueItem/index.vue index 9c559337..eb05c733 100644 --- a/src/components/ValueItem/index.vue +++ b/src/components/ValueItem/index.vue @@ -50,7 +50,7 @@ diff --git a/src/views/Northbound/DuerOS/Detail/command/index.vue b/src/views/Northbound/DuerOS/Detail/command/index.vue index e9ac4084..8d22a8f4 100644 --- a/src/views/Northbound/DuerOS/Detail/command/index.vue +++ b/src/views/Northbound/DuerOS/Detail/command/index.vue @@ -14,6 +14,7 @@ placeholder="请选择指令类型" v-model:value="modelRef.messageType" show-search + @change="onTypeChange" > 读取属性 - + @@ -184,6 +186,8 @@ const props = defineProps({ }, }); +const emit = defineEmits(['update:modelValue']) + const editRef = ref(); const modelRef = reactive({ @@ -192,7 +196,7 @@ const modelRef = reactive({ properties: undefined, functionId: undefined, inputs: [], - value: undefined + value: undefined, }, }); @@ -207,12 +211,21 @@ const onPropertyChange = (val: string) => { } }; +const onTypeChange = () => { + modelRef.message = { + properties: undefined, + functionId: undefined, + inputs: [], + value: undefined, + }; +}; + watch( () => props.modelValue, (newVal) => { if (newVal) { Object.assign(modelRef, newVal); - if(newVal?.message?.properties){ + if (newVal?.message?.properties) { onPropertyChange(newVal?.message?.properties); } } @@ -244,10 +257,13 @@ const saveBtn = () => formRef.value .validate() .then(async (_data: any) => { - await editRef.value.onSave().catch(() => { - resolve(false) - }) - resolve(_data) + if (modelRef.message.inputs?.length) { + await editRef.value?.onSave().catch(() => { + resolve(false); + }); + } + emit('update:modelValue', _data) + resolve(_data); }) .catch((err: any) => { resolve(err); diff --git a/src/views/device/Instance/Detail/Diagnose/index.vue b/src/views/device/Instance/Detail/Diagnose/index.vue index 96b791fc..64472d05 100644 --- a/src/views/device/Instance/Detail/Diagnose/index.vue +++ b/src/views/device/Instance/Detail/Diagnose/index.vue @@ -1,20 +1,48 @@ \ No newline at end of file diff --git a/src/views/device/Instance/Detail/EdgeMap/index.vue b/src/views/device/Instance/Detail/EdgeMap/index.vue index 67d5060c..4d680514 100644 --- a/src/views/device/Instance/Detail/EdgeMap/index.vue +++ b/src/views/device/Instance/Detail/EdgeMap/index.vue @@ -84,17 +84,55 @@ @@ -110,7 +148,7 @@ /> - + @@ -171,7 +209,7 @@ const filterOption = (input: string, option: any) => { const instanceStore = useInstanceStore(); const metadata = JSON.parse(instanceStore.current?.metadata || '{}'); const loading = ref(false); -const channelList = ref([]); +const channelList = ref([]); const modelRef = reactive({ dataSource: [], @@ -204,13 +242,16 @@ const handleSearch = async () => { })); console.log(metadata); if (_metadata && _metadata.length) { - const resp: any = await getEdgeMap(instanceStore.current?.parentId || '', { - deviceId: instanceStore.current.id, - query: {}, - }).catch(() => { + const resp: any = await getEdgeMap( + instanceStore.current?.parentId || '', + { + deviceId: instanceStore.current.id, + query: {}, + }, + ).catch(() => { modelRef.dataSource = _metadata; loading.value = false; - }) + }); if (resp.status === 200) { const array = resp.result?.[0].reduce((x: any, y: any) => { const metadataId = _metadata.find( @@ -231,10 +272,13 @@ const handleSearch = async () => { const unbind = async (id: string) => { if (id) { - const resp = await removeEdgeMap(instanceStore.current?.parentId || '', { - deviceId: instanceStore.current.id, - idList: [id], - }); + const resp = await removeEdgeMap( + instanceStore.current?.parentId || '', + { + deviceId: instanceStore.current.id, + idList: [id], + }, + ); if (resp.status === 200) { message.success('操作成功!'); handleSearch(); @@ -264,7 +308,10 @@ const onSave = () => { provider: (arr[0] as any)?.provider, requestList: arr, }; - const resp = await saveEdgeMap(instanceStore.current.parentId || '', submitData); + const resp = await saveEdgeMap( + instanceStore.current.parentId || '', + submitData, + ); if (resp.status === 200) { message.success('操作成功!'); handleSearch(); @@ -275,6 +322,30 @@ const onSave = () => { console.log('error', err); }); }; + +const onAction = async (record: any) => { + const value = await formRef.value.validate(); + const array = value.filter((item: any) => item.channelId); + const findArray = array.find((item: any) => item.id === record?.id); + const arr = { + ...findArray, + state: record?.state.value === 'enabled' ? 'disabled' : 'enabled', + }; + const filterArray = array.filter((item: any) => item.id !== record?.id); + const submitData = { + deviceId: instanceStore.current.id, + provider: array[0]?.provider, + requestList: [...filterArray, arr], + }; + const resp = await saveEdgeMap( + instanceStore.current.parentId || '', + submitData, + ); + if (resp.status === 200) { + message.success('操作成功!'); + handleSearch(); + } +};