fix: 修改bug
This commit is contained in:
parent
71af134d09
commit
e42c6b34d1
|
@ -3,7 +3,7 @@
|
|||
<div style="padding: 0 10px">
|
||||
<div class="alert">
|
||||
<AIcon type="InfoCircleOutlined" />
|
||||
你可以在该页面选择需要订阅的主题及接收通知的方式。
|
||||
注意:接收人需要有告警配置页面的查询权限,才能收到告警类通知
|
||||
</div>
|
||||
<div class="content-collapse">
|
||||
<template v-if="dataSource.length">
|
||||
|
|
|
@ -2,10 +2,24 @@
|
|||
<div class="metadata-map">
|
||||
<div class="left">
|
||||
<j-space style="margin-bottom: 24px">
|
||||
<j-select @change="onSearchChange" show-search allow-clear placeholder="请选择属性名称" style="width: 250px;">
|
||||
<j-select-option :label="item.name" v-for="item in dataSourceCache" :value="item?.id" :key="item?.id">{{item?.name}}</j-select-option>
|
||||
<j-select
|
||||
@change="onSearchChange"
|
||||
show-search
|
||||
allow-clear
|
||||
placeholder="请选择属性名称"
|
||||
style="width: 250px"
|
||||
>
|
||||
<j-select-option
|
||||
:label="item.name"
|
||||
v-for="item in dataSourceCache"
|
||||
:value="item?.id"
|
||||
:key="item?.id"
|
||||
>{{ item?.name }}</j-select-option
|
||||
>
|
||||
</j-select>
|
||||
<j-button type="primary" @click="onSearch"><AIcon type="SearchOutlined" /></j-button>
|
||||
<j-button type="primary" @click="onSearch"
|
||||
><AIcon type="SearchOutlined"
|
||||
/></j-button>
|
||||
</j-space>
|
||||
<div class="box">
|
||||
<j-scrollbar height="100%">
|
||||
|
@ -151,6 +165,7 @@ const originalData = ref([]);
|
|||
|
||||
const _value = ref<any>(undefined);
|
||||
const searchValue = ref<any>(undefined);
|
||||
const _delTag = ref<boolean>(false);
|
||||
|
||||
const columns = [
|
||||
{
|
||||
|
@ -202,6 +217,7 @@ const getMetadataMapData = () => {
|
|||
return {
|
||||
id: item.metadataId,
|
||||
originalId: item.originalId,
|
||||
customMapping: item.customMapping,
|
||||
};
|
||||
}) || [],
|
||||
);
|
||||
|
@ -218,8 +234,8 @@ const customRow = (record: any) => {
|
|||
};
|
||||
|
||||
const onSearchChange = (_: any, options: any) => {
|
||||
searchValue.value = options?.label
|
||||
}
|
||||
searchValue.value = options?.label;
|
||||
};
|
||||
|
||||
const onSearch = () => {
|
||||
if (searchValue.value) {
|
||||
|
@ -251,16 +267,23 @@ const getDefaultMetadata = async () => {
|
|||
}));
|
||||
|
||||
const concatProperties = [...metadataMap];
|
||||
|
||||
if (!concatProperties.length) {
|
||||
_delTag.value = true;
|
||||
const arr = concatProperties.map((item) => item.id);
|
||||
const _arr = concatProperties.map((item) => item.originalId);
|
||||
|
||||
_properties.map((item) => {
|
||||
// 添加默认映射,但是该选项还没被其他属性映射
|
||||
if (!arr.includes(item.id) && !_arr.includes(item.id)) {
|
||||
concatProperties.push({ id: item.id, originalId: item.id });
|
||||
concatProperties.push({
|
||||
id: item.id,
|
||||
originalId: item.id,
|
||||
customMapping: item?.customMapping,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
dataSource.value =
|
||||
properties?.map((item: any, index: number) => {
|
||||
const _m = concatProperties.find((p) => p.id === item.id);
|
||||
|
@ -269,6 +292,7 @@ const getDefaultMetadata = async () => {
|
|||
id: item.id, // 产品物模型id
|
||||
name: item?.name,
|
||||
type: item.valueType?.type,
|
||||
customMapping: _m?.customMapping,
|
||||
original: _m?.originalId, // 协议包物模型id
|
||||
};
|
||||
}) || [];
|
||||
|
@ -289,16 +313,24 @@ const getMetadata = (): Promise<{ properties: any[] }> => {
|
|||
});
|
||||
};
|
||||
|
||||
const onMapData = async (arr: any[], flag?: boolean) => {
|
||||
const res = await metadataMapById('device', _id, arr);
|
||||
if (res.success && flag) {
|
||||
onlyMessage('操作成功');
|
||||
}
|
||||
};
|
||||
|
||||
const onChange = async (value: any, id: string) => {
|
||||
const res = await metadataMapById('device', _id, [
|
||||
if ((!id && value?.customMapping) || id) {
|
||||
// 映射 / 取消映射
|
||||
const arr = [
|
||||
{
|
||||
metadataType: 'property',
|
||||
metadataId: value.id,
|
||||
originalId: id || null,
|
||||
originalId: id,
|
||||
},
|
||||
]);
|
||||
if (res.success) {
|
||||
onlyMessage('操作成功');
|
||||
];
|
||||
onMapData(arr, true);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -324,6 +356,20 @@ const onClose = () => {
|
|||
onMounted(() => {
|
||||
getDefaultMetadata();
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
if (_delTag.value) {
|
||||
// 保存数据
|
||||
const arr = dataSourceCache.value.filter((i: any) => i?.original).map((item: any) => {
|
||||
return {
|
||||
metadataType: 'property',
|
||||
metadataId: item.id,
|
||||
originalId: item.original,
|
||||
}
|
||||
})
|
||||
onMapData(arr)
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang='less'>
|
||||
|
|
|
@ -151,6 +151,7 @@ const pluginOptions = ref<any[]>([]);
|
|||
const filterValue = ref<boolean | undefined>(undefined);
|
||||
const originalData = ref([]);
|
||||
const searchValue = ref<any>(undefined);
|
||||
const _delTag = ref<boolean>(false);
|
||||
|
||||
// const tableFilter = (value: string, record: any) => {
|
||||
// return true
|
||||
|
@ -203,6 +204,7 @@ const getMetadataMapData = () => {
|
|||
return {
|
||||
id: item.metadataId,
|
||||
pluginId: item.originalId,
|
||||
customMapping: item?.customMapping,
|
||||
};
|
||||
}) || [],
|
||||
);
|
||||
|
@ -250,16 +252,18 @@ const getDefaultMetadata = async () => {
|
|||
|
||||
// const concatProperties = [ ...pluginProperties.map(item => ({ id: item.id, pluginId: item.id})), ...metadataMap]
|
||||
const concatProperties = [...metadataMap];
|
||||
if(!concatProperties.length) {
|
||||
_delTag.value = true
|
||||
const arr = concatProperties.map((item) => item.id);
|
||||
const _arr = concatProperties.map((item) => item.pluginId);
|
||||
|
||||
pluginProperties.map((item) => {
|
||||
// 添加默认映射,但是该选项还没被其他属性映射
|
||||
if (!arr.includes(item.id) && !_arr.includes(item.id)) {
|
||||
concatProperties.push({ id: item.id, pluginId: item.id });
|
||||
concatProperties.push({ id: item.id, pluginId: item.id, customMapping: item?.customMapping, });
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
dataSource.value =
|
||||
properties?.map((item: any, index: number) => {
|
||||
const _m = concatProperties.find((p) => p.id === item.id);
|
||||
|
@ -268,6 +272,7 @@ const getDefaultMetadata = async () => {
|
|||
id: item.id, // 产品物模型id
|
||||
name: item?.name,
|
||||
type: item.valueType?.type,
|
||||
customMapping: _m?.customMapping,
|
||||
plugin: _m?.pluginId, // 插件物模型id
|
||||
};
|
||||
}) || [];
|
||||
|
@ -304,16 +309,24 @@ const getPluginMetadata = (): Promise<{ properties: any[] }> => {
|
|||
});
|
||||
};
|
||||
|
||||
const onMapData = async (arr: any[], flag?: boolean) => {
|
||||
const res = await metadataMapById('product', productDetail.value?.id, arr);
|
||||
if (res.success && flag) {
|
||||
onlyMessage('操作成功');
|
||||
}
|
||||
};
|
||||
|
||||
const pluginChange = async (value: any, id: string) => {
|
||||
const res = await metadataMapById('product', productDetail.value?.id, [
|
||||
if ((!id && value?.customMapping) || id) {
|
||||
// 映射 / 取消映射
|
||||
const arr = [
|
||||
{
|
||||
metadataType: 'property',
|
||||
metadataId: value.id,
|
||||
originalId: id,
|
||||
},
|
||||
]);
|
||||
if (res.success) {
|
||||
onlyMessage('操作成功');
|
||||
];
|
||||
onMapData(arr, true)
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -339,6 +352,20 @@ const onClose = () => {
|
|||
onMounted(() => {
|
||||
getDefaultMetadata();
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
if (_delTag.value) {
|
||||
// 保存数据
|
||||
const arr = dataSourceCache.value.filter((i: any) => i?.plugin).map((item: any) => {
|
||||
return {
|
||||
metadataType: 'property',
|
||||
metadataId: item.id,
|
||||
originalId: item.plugin,
|
||||
}
|
||||
})
|
||||
onMapData(arr)
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang='less'>
|
||||
|
|
|
@ -2006,7 +2006,7 @@ export default [
|
|||
],
|
||||
},
|
||||
],
|
||||
accessSupport: { text: "不支持", value: "unsupported" },
|
||||
accessSupport: { text: "间接支持", value: "indirect" },
|
||||
supportDataAccess: false
|
||||
},
|
||||
],
|
||||
|
@ -2363,10 +2363,10 @@ export default [
|
|||
permission: 'rule-scene',
|
||||
actions: ['query', 'delete'],
|
||||
},
|
||||
{
|
||||
permission: 'alarm-config',
|
||||
actions: ['query'],
|
||||
},
|
||||
// {
|
||||
// permission: 'alarm-config',
|
||||
// actions: ['query'],
|
||||
// },
|
||||
],
|
||||
},
|
||||
{
|
||||
|
|
|
@ -3837,8 +3837,8 @@ jetlinks-ui-components@^1.0.23:
|
|||
|
||||
jetlinks-ui-components@^1.0.24:
|
||||
version "1.0.24"
|
||||
resolved "http://registry.jetlinks.cn/jetlinks-ui-components/-/jetlinks-ui-components-1.0.24.tgz#68660b63aea9b4befeaa4c5e3ff121668bb984bb"
|
||||
integrity sha512-09s73oEPKf+TC3KVL4suXrI4FjylJqyB2qXbFQtBOqyK/mSfMN/TJ7mcEoZdycBqAvmv35zTDKXIQIcvAAaitQ==
|
||||
resolved "http://registry.jetlinks.cn/jetlinks-ui-components/-/jetlinks-ui-components-1.0.24.tgz#b49c1f29c2e0a6dd9550a1f916dfb722a18b81bf"
|
||||
integrity sha512-DtUJeIqb1IJ9uS/85IdOoJfz7V4isN9naxKOoY9azaRAjTbHaZsf20snLmDMT5o2tDlToHmi+KoCO+f1lG2Tyg==
|
||||
dependencies:
|
||||
"@vueuse/core" "^9.12.0"
|
||||
"@vueuse/router" "^9.13.0"
|
||||
|
|
Loading…
Reference in New Issue