diff --git a/src/views/device/Instance/Detail/ChildDevice/EdgeMap/PatchMapping.vue b/src/views/device/Instance/Detail/ChildDevice/EdgeMap/PatchMapping.vue
index e28e2733..6d2c80ab 100644
--- a/src/views/device/Instance/Detail/ChildDevice/EdgeMap/PatchMapping.vue
+++ b/src/views/device/Instance/Detail/ChildDevice/EdgeMap/PatchMapping.vue
@@ -178,6 +178,8 @@ const handleClick = async () => {
_emits('save');
}
}
+ } else {
+ message.error('暂无对应属性的映射');
}
}
}
diff --git a/src/views/device/Instance/Detail/ChildDevice/EdgeMap/index.vue b/src/views/device/Instance/Detail/ChildDevice/EdgeMap/index.vue
index a6c8b265..10d5fc07 100644
--- a/src/views/device/Instance/Detail/ChildDevice/EdgeMap/index.vue
+++ b/src/views/device/Instance/Detail/ChildDevice/EdgeMap/index.vue
@@ -1,5 +1,5 @@
-
+
@@ -7,7 +7,7 @@
批量映射
- 保存
+ 保存并应用
@@ -114,7 +114,7 @@
/>
-
+
@@ -174,7 +174,7 @@ const form = ref();
const filterOption = (input: string, option: any) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
};
-const props = defineProps(['productList']);
+const props = defineProps(['productList']);
const _emit = defineEmits(['close']);
const instanceStore = useInstanceStore();
let _metadata = ref();
@@ -203,31 +203,33 @@ const getChannel = async () => {
const handleSearch = async () => {
loading.value = true;
- modelRef.dataSource = _metadata;
getChannel();
- if (_metadata && _metadata.length) {
- const resp: any = await getEdgeMap(instanceStore.current?.orgId || '', {
- 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(
- (item: any) => item.metadataId === y.metadataId,
- );
- if (metadataId) {
- Object.assign(metadataId, y);
- } else {
- x.push(y);
- }
- return x;
- }, _metadata);
- modelRef.dataSource = array;
- }
- }
+ modelRef.dataSource = _metadata.value;
+ console.log(modelRef.dataSource);
+ // if (_metadata.value && _metadata.value.length) {
+ // console.log(1234);
+ // const resp: any = await getEdgeMap(instanceStore.current?.orgId || '', {
+ // 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(
+ // (item: any) => item.metadataId === y.metadataId,
+ // );
+ // if (metadataId) {
+ // Object.assign(metadataId, y);
+ // } else {
+ // x.push(y);
+ // }
+ // return x;
+ // }, _metadata);
+ // modelRef.dataSource = array;
+ // }
+ // }
loading.value = false;
};
@@ -251,17 +253,13 @@ const onPatchBind = () => {
visible.value = false;
_emit('close');
};
-
-onMounted(() => {
- handleSearch();
-});
-
watchEffect(() => {
if (instanceStore.current?.metadata) {
_metadata.value = instanceStore.current?.metadata;
} else {
_metadata.value = {};
}
+ handleSearch();
});
const onSave = async () => {
form.value = await validate();
diff --git a/src/views/device/Instance/Detail/ChildDevice/SaveChild/index.vue b/src/views/device/Instance/Detail/ChildDevice/SaveChild/index.vue
index 9579050e..8bebc5f3 100644
--- a/src/views/device/Instance/Detail/ChildDevice/SaveChild/index.vue
+++ b/src/views/device/Instance/Detail/ChildDevice/SaveChild/index.vue
@@ -70,9 +70,61 @@ const getProductList = async () => {
});
if (res.status === 200) {
productList.value = res.result;
+ if (props.childData?.id) {
+ current.value.parentId = props.childData.id;
+ form.name = props.childData?.name;
+ form.productId = props.childData?.productId;
+ selectChange(form.productId);
+ if (current.value.metadata) {
+ const metadata = current.value.metadata;
+ if (metadata && metadata.length !== 0) {
+ getEdgeMap(current.value.id, {
+ deviceId: props.childData.id,
+ query: {},
+ }).then((res) => {
+ if (res.status === 200) {
+ // console.log(res.result)
+ //合并物模型
+ const array = res.result[0]?.reduce(
+ (x: any, y: any) => {
+ const metadataId = metadata.find(
+ (item: any) =>
+ item.metadataId === y.metadataId,
+ );
+ if (metadataId) {
+ Object.assign(metadataId, y);
+ } else {
+ x.push(y);
+ }
+ return x;
+ },
+ metadata,
+ );
+ //删除物模型
+ const items = array.filter(
+ (item: any) => item.metadataName,
+ );
+ current.value.metadata = items;
+ const delList = array
+ .filter((a: any) => !a.metadataName)
+ .map((b: any) => b.id);
+ //删除后解绑
+ if (delList && delList.length !== 0) {
+ removeEdgeMap(current.value.id, {
+ deviceId: props.childData.id,
+ idList: [...delList],
+ });
+ }
+ }
+ });
+ }
+ }
+ visible.value = true;
+ } else {
+ current.value.parentId = '';
+ }
}
};
-getProductList();
const selectChange = (e: any) => {
if (e) {
visible.value = true;
@@ -88,64 +140,8 @@ const selectChange = (e: any) => {
);
current.value.metadata = array;
};
-watchEffect(() => {
- if (props.childData?.id) {
- current.value.parentId = props.childData.id;
- form.name = props.childData?.name;
- form.productId = props.childData?.productId;
- if (props.childData.deriveMetadata) {
- const metadata = JSON.parse(
- props.childData?.deriveMetadata || {},
- )?.properties?.map((item: any) => ({
- metadataId: item.id,
- metadataName: `${item.name}(${item.id})`,
- metadataType: 'property',
- name: item.name,
- }));
- if (metadata && metadata.length !== 0) {
- getEdgeMap(current.value.id, {
- deviceId: props.childData.id,
- query: {},
- }).then((res) => {
- if (res.status === 200) {
- // console.log(res.result)
- //合并物模型
- const array = res.result[0]?.reduce(
- (x: any, y: any) => {
- const metadataId = metadata.find(
- (item: any) =>
- item.metadataId === y.metadataId,
- );
- if (metadataId) {
- Object.assign(metadataId, y);
- } else {
- x.push(y);
- }
- return x;
- },
- metadata,
- );
- //删除物模型
- const items = array.filter(
- (item: any) => item.metadataName,
- );
- current.value.metadata = items;
- const delList = array
- .filter((a: any) => !a.metadataName)
- .map((b: any) => b.id);
- //删除后解绑
- if (delList && delList.length !== 0) {
- removeEdgeMap(current.value.id, {
- deviceId: props.childData.id,
- idList: [...delList],
- });
- }
- }
- });
- }
- }
- visible.value = true;
- }
+onMounted(() => {
+ getProductList();
});
const validate = async () => {
diff --git a/src/views/device/Instance/Detail/ChildDevice/index.vue b/src/views/device/Instance/Detail/ChildDevice/index.vue
index a1759bf3..e3e298f2 100644
--- a/src/views/device/Instance/Detail/ChildDevice/index.vue
+++ b/src/views/device/Instance/Detail/ChildDevice/index.vue
@@ -3,7 +3,7 @@
新增并绑定>({});
const params = ref>({});
const _selectedRowKeys = ref([]);
const visible = ref(false);
-const current = ref({});
+const _current = ref({});
const columns = [
{
@@ -252,7 +252,7 @@ const getActions = (data: Partial>): ActionsType[] => {
},
icon: 'EditOutlined',
onClick: () => {
- current.value = data;
+ _current.value = data;
childVisible.value = true;
},
},
diff --git a/src/views/device/Instance/Detail/EdgeMap/index.vue b/src/views/device/Instance/Detail/EdgeMap/index.vue
index cb193cb8..0b59e97c 100644
--- a/src/views/device/Instance/Detail/EdgeMap/index.vue
+++ b/src/views/device/Instance/Detail/EdgeMap/index.vue
@@ -202,6 +202,7 @@ const handleSearch = async () => {
metadataType: 'property',
name: item.name,
}));
+ console.log(metadata);
if (_metadata && _metadata.length) {
const resp: any = await getEdgeMap(instanceStore.current?.parentId || '', {
deviceId: instanceStore.current.id,
diff --git a/src/views/rule-engine/Alarm/Configuration/index.vue b/src/views/rule-engine/Alarm/Configuration/index.vue
index 37b034fc..7caf7701 100644
--- a/src/views/rule-engine/Alarm/Configuration/index.vue
+++ b/src/views/rule-engine/Alarm/Configuration/index.vue
@@ -80,10 +80,6 @@