feat: 新增子设备绑定
This commit is contained in:
parent
a8fd7232eb
commit
02cb643d8c
|
@ -178,6 +178,8 @@ const handleClick = async () => {
|
||||||
_emits('save');
|
_emits('save');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
message.error('暂无对应属性的映射');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<a-spin :spinning="loading" v-if="_metadata">
|
<a-spin :spinning="loading" v-if="_metadata.length">
|
||||||
<a-card :bordered="false">
|
<a-card :bordered="false">
|
||||||
<template #title>
|
<template #title>
|
||||||
<TitleComponent data="点位映射"></TitleComponent>
|
<TitleComponent data="点位映射"></TitleComponent>
|
||||||
|
@ -7,7 +7,7 @@
|
||||||
<template #extra>
|
<template #extra>
|
||||||
<a-space>
|
<a-space>
|
||||||
<a-button @click="showModal">批量映射</a-button>
|
<a-button @click="showModal">批量映射</a-button>
|
||||||
<a-button type="primary" @click="onSave">保存</a-button>
|
<a-button type="primary" @click="onSave">保存并应用</a-button>
|
||||||
</a-space>
|
</a-space>
|
||||||
</template>
|
</template>
|
||||||
<a-form ref="formRef" :model="modelRef">
|
<a-form ref="formRef" :model="modelRef">
|
||||||
|
@ -114,7 +114,7 @@
|
||||||
/>
|
/>
|
||||||
</a-spin>
|
</a-spin>
|
||||||
<a-card v-else>
|
<a-card v-else>
|
||||||
<JEmpty description="暂无数据,请配置物模型" style="margin: 10% 0" />
|
<JEmpty description="暂无数据,请配置物模型" style="margin: 10% 0" />
|
||||||
</a-card>
|
</a-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ const form = ref();
|
||||||
const filterOption = (input: string, option: any) => {
|
const filterOption = (input: string, option: any) => {
|
||||||
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
|
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
|
||||||
};
|
};
|
||||||
const props = defineProps(['productList']);
|
const props = defineProps(['productList']);
|
||||||
const _emit = defineEmits(['close']);
|
const _emit = defineEmits(['close']);
|
||||||
const instanceStore = useInstanceStore();
|
const instanceStore = useInstanceStore();
|
||||||
let _metadata = ref();
|
let _metadata = ref();
|
||||||
|
@ -203,31 +203,33 @@ const getChannel = async () => {
|
||||||
|
|
||||||
const handleSearch = async () => {
|
const handleSearch = async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
modelRef.dataSource = _metadata;
|
|
||||||
getChannel();
|
getChannel();
|
||||||
if (_metadata && _metadata.length) {
|
modelRef.dataSource = _metadata.value;
|
||||||
const resp: any = await getEdgeMap(instanceStore.current?.orgId || '', {
|
console.log(modelRef.dataSource);
|
||||||
deviceId: instanceStore.current.id,
|
// if (_metadata.value && _metadata.value.length) {
|
||||||
query: {},
|
// console.log(1234);
|
||||||
}).catch(() => {
|
// const resp: any = await getEdgeMap(instanceStore.current?.orgId || '', {
|
||||||
modelRef.dataSource = _metadata;
|
// deviceId: instanceStore.current.id,
|
||||||
loading.value = false;
|
// query: {},
|
||||||
});
|
// }).catch(() => {
|
||||||
if (resp.status === 200) {
|
// modelRef.dataSource = _metadata;
|
||||||
const array = resp.result?.[0].reduce((x: any, y: any) => {
|
// loading.value = false;
|
||||||
const metadataId = _metadata.find(
|
// });
|
||||||
(item: any) => item.metadataId === y.metadataId,
|
// if (resp.status === 200) {
|
||||||
);
|
// const array = resp.result?.[0].reduce((x: any, y: any) => {
|
||||||
if (metadataId) {
|
// const metadataId = _metadata.find(
|
||||||
Object.assign(metadataId, y);
|
// (item: any) => item.metadataId === y.metadataId,
|
||||||
} else {
|
// );
|
||||||
x.push(y);
|
// if (metadataId) {
|
||||||
}
|
// Object.assign(metadataId, y);
|
||||||
return x;
|
// } else {
|
||||||
}, _metadata);
|
// x.push(y);
|
||||||
modelRef.dataSource = array;
|
// }
|
||||||
}
|
// return x;
|
||||||
}
|
// }, _metadata);
|
||||||
|
// modelRef.dataSource = array;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -251,17 +253,13 @@ const onPatchBind = () => {
|
||||||
visible.value = false;
|
visible.value = false;
|
||||||
_emit('close');
|
_emit('close');
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
handleSearch();
|
|
||||||
});
|
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
if (instanceStore.current?.metadata) {
|
if (instanceStore.current?.metadata) {
|
||||||
_metadata.value = instanceStore.current?.metadata;
|
_metadata.value = instanceStore.current?.metadata;
|
||||||
} else {
|
} else {
|
||||||
_metadata.value = {};
|
_metadata.value = {};
|
||||||
}
|
}
|
||||||
|
handleSearch();
|
||||||
});
|
});
|
||||||
const onSave = async () => {
|
const onSave = async () => {
|
||||||
form.value = await validate();
|
form.value = await validate();
|
||||||
|
|
|
@ -70,9 +70,61 @@ const getProductList = async () => {
|
||||||
});
|
});
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
productList.value = res.result;
|
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) => {
|
const selectChange = (e: any) => {
|
||||||
if (e) {
|
if (e) {
|
||||||
visible.value = true;
|
visible.value = true;
|
||||||
|
@ -88,64 +140,8 @@ const selectChange = (e: any) => {
|
||||||
);
|
);
|
||||||
current.value.metadata = array;
|
current.value.metadata = array;
|
||||||
};
|
};
|
||||||
watchEffect(() => {
|
onMounted(() => {
|
||||||
if (props.childData?.id) {
|
getProductList();
|
||||||
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;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const validate = async () => {
|
const validate = async () => {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<SaveChild
|
<SaveChild
|
||||||
v-if="childVisible"
|
v-if="childVisible"
|
||||||
@close-child-save="closeChildSave"
|
@close-child-save="closeChildSave"
|
||||||
:childData="current"
|
:childData="_current"
|
||||||
/>
|
/>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<Search
|
<Search
|
||||||
|
@ -43,7 +43,7 @@
|
||||||
"
|
"
|
||||||
hasPermission="device/Instance:update"
|
hasPermission="device/Instance:update"
|
||||||
@click="
|
@click="
|
||||||
current = {};
|
_current = {};
|
||||||
childVisible = true;
|
childVisible = true;
|
||||||
"
|
"
|
||||||
>新增并绑定</PermissionButton
|
>新增并绑定</PermissionButton
|
||||||
|
@ -123,7 +123,7 @@ import { usePermissionStore } from '@/store/permission';
|
||||||
import SaveChild from './SaveChild/index.vue';
|
import SaveChild from './SaveChild/index.vue';
|
||||||
|
|
||||||
const instanceStore = useInstanceStore();
|
const instanceStore = useInstanceStore();
|
||||||
const { detail } = storeToRefs(instanceStore);
|
const { detail } = storeToRefs(instanceStore);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const childVisible = ref(false);
|
const childVisible = ref(false);
|
||||||
const permissionStore = usePermissionStore();
|
const permissionStore = usePermissionStore();
|
||||||
|
@ -139,7 +139,7 @@ const childDeviceRef = ref<Record<string, any>>({});
|
||||||
const params = ref<Record<string, any>>({});
|
const params = ref<Record<string, any>>({});
|
||||||
const _selectedRowKeys = ref<string[]>([]);
|
const _selectedRowKeys = ref<string[]>([]);
|
||||||
const visible = ref<boolean>(false);
|
const visible = ref<boolean>(false);
|
||||||
const current = ref({});
|
const _current = ref({});
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
|
@ -252,7 +252,7 @@ const getActions = (data: Partial<Record<string, any>>): ActionsType[] => {
|
||||||
},
|
},
|
||||||
icon: 'EditOutlined',
|
icon: 'EditOutlined',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
current.value = data;
|
_current.value = data;
|
||||||
childVisible.value = true;
|
childVisible.value = true;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -202,6 +202,7 @@ const handleSearch = async () => {
|
||||||
metadataType: 'property',
|
metadataType: 'property',
|
||||||
name: item.name,
|
name: item.name,
|
||||||
}));
|
}));
|
||||||
|
console.log(metadata);
|
||||||
if (_metadata && _metadata.length) {
|
if (_metadata && _metadata.length) {
|
||||||
const resp: any = await getEdgeMap(instanceStore.current?.parentId || '', {
|
const resp: any = await getEdgeMap(instanceStore.current?.parentId || '', {
|
||||||
deviceId: instanceStore.current.id,
|
deviceId: instanceStore.current.id,
|
||||||
|
|
|
@ -80,10 +80,6 @@
|
||||||
</template>
|
</template>
|
||||||
<template #actions="item">
|
<template #actions="item">
|
||||||
<PermissionButton
|
<PermissionButton
|
||||||
v-if="
|
|
||||||
item.key != 'tigger' ||
|
|
||||||
slotProps.sceneTriggerType == 'manual'
|
|
||||||
"
|
|
||||||
:disabled="item.disabled"
|
:disabled="item.disabled"
|
||||||
:popConfirm="item.popConfirm"
|
:popConfirm="item.popConfirm"
|
||||||
:tooltip="{ ...item.tootip }"
|
:tooltip="{ ...item.tootip }"
|
||||||
|
@ -146,10 +142,6 @@
|
||||||
:key="i.key"
|
:key="i.key"
|
||||||
>
|
>
|
||||||
<PermissionButton
|
<PermissionButton
|
||||||
v-if="
|
|
||||||
i.key != 'tigger' ||
|
|
||||||
slotProps.sceneTriggerType == 'manual'
|
|
||||||
"
|
|
||||||
:disabled="i.disabled"
|
:disabled="i.disabled"
|
||||||
:popConfirm="i.popConfirm"
|
:popConfirm="i.popConfirm"
|
||||||
:tooltip="{
|
:tooltip="{
|
||||||
|
@ -439,7 +431,9 @@ const getActions = (
|
||||||
icon: 'DeleteOutlined',
|
icon: 'DeleteOutlined',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
return actions;
|
return actions.filter((item)=>
|
||||||
|
item.key != 'tigger' || data.sceneTriggerType == 'manual'
|
||||||
|
);
|
||||||
};
|
};
|
||||||
const add = () => {
|
const add = () => {
|
||||||
menuStory.jumpPage('rule-engine/Alarm/Configuration/Save');
|
menuStory.jumpPage('rule-engine/Alarm/Configuration/Save');
|
||||||
|
|
Loading…
Reference in New Issue