fix: 修改bug

This commit is contained in:
100011797 2023-07-10 19:46:43 +08:00
parent 71af134d09
commit e42c6b34d1
5 changed files with 123 additions and 50 deletions

View File

@ -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">

View File

@ -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,18 +234,18 @@ const customRow = (record: any) => {
};
const onSearchChange = (_: any, options: any) => {
searchValue.value = options?.label
}
searchValue.value = options?.label;
};
const onSearch = () => {
if (searchValue.value) {
const _item: any = dataSourceCache.value.find((item: any) => {
return searchValue.value === item?.name;
});
if(_item) {
if (_item) {
_value.value = _item?.name;
document.getElementById(_item?.id)?.scrollIntoView(); //
}
}
} else {
_value.value = undefined;
}
@ -251,16 +267,23 @@ const getDefaultMetadata = async () => {
}));
const concatProperties = [...metadataMap];
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 });
}
});
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,
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,19 +313,27 @@ const getMetadata = (): Promise<{ properties: any[] }> => {
});
};
const onChange = async (value: any, id: string) => {
const res = await metadataMapById('device', _id, [
{
metadataType: 'property',
metadataId: value.id,
originalId: id || null,
},
]);
if (res.success) {
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) => {
if ((!id && value?.customMapping) || id) {
// /
const arr = [
{
metadataType: 'property',
metadataId: value.id,
originalId: id,
},
];
onMapData(arr, true);
}
};
const onFilter = ({ key }: any) => {
originalData.value = dataSource.value;
const _dataSource = cloneDeep(dataSource.value).sort((a: any, b: any) => {
@ -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'>

View File

@ -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];
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 });
}
});
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, 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,19 +309,27 @@ const getPluginMetadata = (): Promise<{ properties: any[] }> => {
});
};
const pluginChange = async (value: any, id: string) => {
const res = await metadataMapById('product', productDetail.value?.id, [
{
metadataType: 'property',
metadataId: value.id,
originalId: id,
},
]);
if (res.success) {
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) => {
if ((!id && value?.customMapping) || id) {
// /
const arr = [
{
metadataType: 'property',
metadataId: value.id,
originalId: id,
},
];
onMapData(arr, true)
}
};
const onFilter = ({ key }: any) => {
originalData.value = dataSource.value;
const _dataSource = cloneDeep(dataSource.value).sort((a: any, b: any) => {
@ -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'>

View File

@ -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'],
// },
],
},
{

View File

@ -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"