Commit cfc9d9f273a35b29faa9788fb80c7a5d6d257ebf
Merge branch 'fix/issure' into 'main_dev'
fix: 修改Teambition上的问题 See merge request yunteng/thingskit-front!1304
Showing
4 changed files
with
71 additions
and
10 deletions
@@ -20,6 +20,7 @@ export enum ConfigurationPermission { | @@ -20,6 +20,7 @@ export enum ConfigurationPermission { | ||
20 | // DESIGN = 'api:yt:dataview:center:get_configuration_info:design', | 20 | // DESIGN = 'api:yt:dataview:center:get_configuration_info:design', |
21 | DESIGN = 'api:yt:dataview:center:get_dataview_info:design', | 21 | DESIGN = 'api:yt:dataview:center:get_dataview_info:design', |
22 | PREVIEW = 'api:yt:dataview:center:get_configuration_info:preview', | 22 | PREVIEW = 'api:yt:dataview:center:get_configuration_info:preview', |
23 | + DATAVIEW_PREVIEW = 'api:yt:dataview:center:get_dataview_info:preview', //大屏预览 | ||
23 | PUBLISH = 'api:yt:dataview:center:publish', | 24 | PUBLISH = 'api:yt:dataview:center:publish', |
24 | // CANCEL_PUBLISH = 'api:yt:dataview:center:cancel_publish', | 25 | // CANCEL_PUBLISH = 'api:yt:dataview:center:cancel_publish', |
25 | PUBLISH_INTERFACE = 'api:yt:dataview:center:public_interface', | 26 | PUBLISH_INTERFACE = 'api:yt:dataview:center:public_interface', |
@@ -191,6 +191,7 @@ | @@ -191,6 +191,7 @@ | ||
191 | <template class="ant-card-actions" #actions> | 191 | <template class="ant-card-actions" #actions> |
192 | <Tooltip title="预览"> | 192 | <Tooltip title="预览"> |
193 | <AuthIcon | 193 | <AuthIcon |
194 | + :auth="ConfigurationPermission.DATAVIEW_PREVIEW" | ||
194 | class="!text-lg" | 195 | class="!text-lg" |
195 | icon="ant-design:eye-outlined" | 196 | icon="ant-design:eye-outlined" |
196 | @click="handlePreview(item)" | 197 | @click="handlePreview(item)" |
@@ -20,10 +20,12 @@ | @@ -20,10 +20,12 @@ | ||
20 | import { BasicTable, useTable } from '/@/components/Table'; | 20 | import { BasicTable, useTable } from '/@/components/Table'; |
21 | import { viewDeviceColumn } from '../config'; | 21 | import { viewDeviceColumn } from '../config'; |
22 | import { reportEditDetailPage } from '/@/api/report/reportManager'; | 22 | import { reportEditDetailPage } from '/@/api/report/reportManager'; |
23 | + import { getDeviceDetail } from '/@/api/device/deviceManager'; | ||
24 | + import { getAttribute } from '/@/api/ruleengine/ruleengineApi'; | ||
23 | 25 | ||
24 | const tableData = ref([]); | 26 | const tableData = ref([]); |
25 | 27 | ||
26 | - const [registerTable] = useTable({ | 28 | + const [registerTable, { setLoading }] = useTable({ |
27 | columns: viewDeviceColumn, | 29 | columns: viewDeviceColumn, |
28 | showIndexColumn: false, | 30 | showIndexColumn: false, |
29 | clickToRowSelect: false, | 31 | clickToRowSelect: false, |
@@ -32,18 +34,68 @@ | @@ -32,18 +34,68 @@ | ||
32 | }); | 34 | }); |
33 | 35 | ||
34 | const [register] = useModalInner((data) => { | 36 | const [register] = useModalInner((data) => { |
37 | + setLoading(true); | ||
38 | + tableData.value = []; | ||
35 | const getTableData = async () => { | 39 | const getTableData = async () => { |
36 | const res = (await reportEditDetailPage(data.record?.id)) as any; | 40 | const res = (await reportEditDetailPage(data.record?.id)) as any; |
37 | - const resMap = res?.data?.executeAttributes?.map((item) => ({ | ||
38 | - device: item.name, | ||
39 | - attribute: item.attributes.join(','), | ||
40 | - })); | ||
41 | - tableData.value = resMap; | 41 | + const deviceInfo = res?.data?.executeAttributes || []; |
42 | + let attributesList: Recordable[] = []; | ||
43 | + // 处理为物模型里的标识符名 | ||
44 | + const reflectDeviceList = deviceInfo.map(async (item) => { | ||
45 | + const { device, attributes } = item as Recordable; | ||
46 | + if (!device) return; | ||
47 | + const thingsModel = (await handleDeviceProfileAttributes(item.device)) as Recordable; | ||
48 | + const { tbDeviceId, attribute } = thingsModel as Recordable; | ||
49 | + if (!tbDeviceId) return; | ||
50 | + if (device === tbDeviceId) { | ||
51 | + attributesList = attributes.reduce((acc, curr) => { | ||
52 | + attribute.forEach((item: Recordable) => { | ||
53 | + if (item.identifier === curr) { | ||
54 | + acc.push({ | ||
55 | + label: item.name, | ||
56 | + value: item.identifier, | ||
57 | + }); | ||
58 | + } | ||
59 | + }); | ||
60 | + return [...acc]; | ||
61 | + }, []); | ||
62 | + } | ||
63 | + return { | ||
64 | + device: item.name, | ||
65 | + attribute: attributesList.map((item: Recordable) => item.label).join(','), | ||
66 | + }; | ||
67 | + }); | ||
68 | + tableData.value = (await Promise.all(reflectDeviceList)) as any; | ||
69 | + if (tableData.value) { | ||
70 | + setLoading(false); | ||
71 | + } | ||
42 | }; | 72 | }; |
43 | nextTick(() => { | 73 | nextTick(() => { |
44 | getTableData(); | 74 | getTableData(); |
45 | }); | 75 | }); |
46 | }); | 76 | }); |
77 | + | ||
78 | + const handleDeviceProfileAttributes = async (entityId: string) => { | ||
79 | + const deviceDetailRes = await getDeviceDetail(entityId); | ||
80 | + const { deviceProfileId } = deviceDetailRes; | ||
81 | + if (!deviceProfileId) return; | ||
82 | + const attributeRes = await getAttribute(deviceProfileId); | ||
83 | + return handleDataFormat(deviceDetailRes, attributeRes); | ||
84 | + }; | ||
85 | + | ||
86 | + const handleDataFormat = (deviceDetail: any, attributes: any) => { | ||
87 | + const { name, tbDeviceId } = deviceDetail; | ||
88 | + const attribute = attributes.map((item: any) => ({ | ||
89 | + identifier: item.identifier, | ||
90 | + name: item.name, | ||
91 | + detail: item.detail, | ||
92 | + })); | ||
93 | + return { | ||
94 | + name, | ||
95 | + tbDeviceId, | ||
96 | + attribute, | ||
97 | + }; | ||
98 | + }; | ||
47 | </script> | 99 | </script> |
48 | <style lang="less" scoped> | 100 | <style lang="less" scoped> |
49 | :deep(.ant-table-body) { | 101 | :deep(.ant-table-body) { |
@@ -117,10 +117,12 @@ | @@ -117,10 +117,12 @@ | ||
117 | ); | 117 | ); |
118 | }; | 118 | }; |
119 | 119 | ||
120 | - const getChartsOption = (result: ResponsData) => { | 120 | + const getChartsOption = (result: ResponsData, thingsModel: Recordable) => { |
121 | + const { attribute } = thingsModel; | ||
121 | const generateInfo = Object.entries(result).map((item) => { | 122 | const generateInfo = Object.entries(result).map((item) => { |
122 | const [attr, val] = item; | 123 | const [attr, val] = item; |
123 | - return { attr, val } as { attr: string; val: { ts: number; value: string }[] }; | 124 | + const findAttrName = attribute.find((attrItem) => attrItem.identifier === attr)?.name; |
125 | + return { attr: findAttrName, val } as { attr: string; val: { ts: number; value: string }[] }; | ||
124 | }); | 126 | }); |
125 | const chartDataConfig = | 127 | const chartDataConfig = |
126 | generateInfo.map((item) => { | 128 | generateInfo.map((item) => { |
@@ -216,9 +218,13 @@ | @@ -216,9 +218,13 @@ | ||
216 | }, | 218 | }, |
217 | }; | 219 | }; |
218 | 220 | ||
221 | + const thingsModel = (await handleDeviceProfileAttributes(device)) as Recordable; | ||
219 | const result = await exportViewChartApi(device, sendParams); | 222 | const result = await exportViewChartApi(device, sendParams); |
220 | item.notFoundData = validateHasData(result); | 223 | item.notFoundData = validateHasData(result); |
221 | - const { xAxisData, series } = getChartsOption(result as unknown as ResponsData); | 224 | + const { xAxisData, series } = getChartsOption( |
225 | + result as unknown as ResponsData, | ||
226 | + thingsModel as unknown as Recordable | ||
227 | + ); | ||
222 | 228 | ||
223 | await nextTick(); | 229 | await nextTick(); |
224 | chartsInstance[device] = echarts.init( | 230 | chartsInstance[device] = echarts.init( |
@@ -320,7 +326,8 @@ | @@ -320,7 +326,8 @@ | ||
320 | const result = await exportViewChartApi(device, sendParams); | 326 | const result = await exportViewChartApi(device, sendParams); |
321 | 327 | ||
322 | item.notFoundData = validateHasData(result); | 328 | item.notFoundData = validateHasData(result); |
323 | - const { xAxisData, series } = getChartsOption(result as unknown as ResponsData); | 329 | + const thingsModel = (await handleDeviceProfileAttributes(device)) as Recordable; |
330 | + const { xAxisData, series } = getChartsOption(result as unknown as ResponsData, thingsModel); | ||
324 | 331 | ||
325 | chartsInstance[device].setOption({ | 332 | chartsInstance[device].setOption({ |
326 | series, | 333 | series, |