feat: 优化产品物模型映射搜索和排序
This commit is contained in:
parent
5772c050f8
commit
a1982f1538
|
@ -4,6 +4,7 @@
|
||||||
<j-input-search
|
<j-input-search
|
||||||
style='width: 350px;margin-bottom:24px;'
|
style='width: 350px;margin-bottom:24px;'
|
||||||
placeholder='搜索平台属性名称'
|
placeholder='搜索平台属性名称'
|
||||||
|
allowClear
|
||||||
@search='search'
|
@search='search'
|
||||||
/>
|
/>
|
||||||
<j-table
|
<j-table
|
||||||
|
@ -17,7 +18,7 @@
|
||||||
}'
|
}'
|
||||||
rowKey='id'
|
rowKey='id'
|
||||||
>
|
>
|
||||||
<template #bodyCell="{ column, text, record }">
|
<template #bodyCell="{ column, text, record, index }">
|
||||||
<template v-if='column.dataIndex === "name"'>
|
<template v-if='column.dataIndex === "name"'>
|
||||||
<span class='metadata-title'>{{ text }} ({{ record.id }})</span>
|
<span class='metadata-title'>{{ text }} ({{ record.id }})</span>
|
||||||
</template>
|
</template>
|
||||||
|
@ -73,6 +74,7 @@ import { getMetadateMapById, metadateMapById } from '@/api/device/instance'
|
||||||
|
|
||||||
const productStore = useProductStore();
|
const productStore = useProductStore();
|
||||||
const { current: productDetail } = storeToRefs(productStore)
|
const { current: productDetail } = storeToRefs(productStore)
|
||||||
|
const dataSourceCache = ref([])
|
||||||
const dataSource = ref([])
|
const dataSource = ref([])
|
||||||
const pluginOptions = ref<any[]>([])
|
const pluginOptions = ref<any[]>([])
|
||||||
|
|
||||||
|
@ -94,11 +96,7 @@ const columns = [
|
||||||
{
|
{
|
||||||
title: '目标属性',
|
title: '目标属性',
|
||||||
dataIndex: 'plugin',
|
dataIndex: 'plugin',
|
||||||
filters: [
|
sorter: tableFilter
|
||||||
{ text: '置顶已映射数据', value: 'already' },
|
|
||||||
{ text: '置顶未映射数据', value: 'not' },
|
|
||||||
],
|
|
||||||
onFilter: tableFilter
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -125,6 +123,16 @@ const getMetadataMapData = () => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const search = (value: string) => {
|
||||||
|
console.log(value)
|
||||||
|
if (value) {
|
||||||
|
dataSource.value = dataSourceCache.value.filter((item: any) => {
|
||||||
|
return !!item.name?.includes(value)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
dataSource.value = dataSourceCache.value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const getDefaultMetadata = async () => {
|
const getDefaultMetadata = async () => {
|
||||||
const metadata = JSON.parse(productDetail.value?.metadata || '{}')
|
const metadata = JSON.parse(productDetail.value?.metadata || '{}')
|
||||||
|
@ -136,7 +144,6 @@ const getDefaultMetadata = async () => {
|
||||||
|
|
||||||
const concatProperties = [ ...pluginProperties.map(item => ({ id: item.id, pluginId: item.id})), ...metadataMap]
|
const concatProperties = [ ...pluginProperties.map(item => ({ id: item.id, pluginId: item.id})), ...metadataMap]
|
||||||
dataSource.value = properties?.map((item: any, index: number) => {
|
dataSource.value = properties?.map((item: any, index: number) => {
|
||||||
|
|
||||||
const _m = concatProperties.find(p => p.id === item.id)
|
const _m = concatProperties.find(p => p.id === item.id)
|
||||||
return {
|
return {
|
||||||
index: index + 1,
|
index: index + 1,
|
||||||
|
@ -146,6 +153,7 @@ const getDefaultMetadata = async () => {
|
||||||
plugin: _m?.pluginId, // 插件物模型id
|
plugin: _m?.pluginId, // 插件物模型id
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
dataSourceCache.value = dataSource.value
|
||||||
}
|
}
|
||||||
|
|
||||||
const getPluginMetadata = (): Promise<{ properties: any[]}> => {
|
const getPluginMetadata = (): Promise<{ properties: any[]}> => {
|
||||||
|
|
Loading…
Reference in New Issue