From 8ac8329a222f66b8a50cc06dc59a12164efe8be8 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Mon, 26 Sep 2022 13:32:28 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E4=BB=AA=E8=A1=A8=E6=9D=BF):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=AF=8C=E6=96=87=E6=9C=AC=E8=A7=86=E5=9B=BE=E6=8C=87?= =?UTF-8?q?=E6=A0=87=E6=A0=BC=E5=BC=8F=E5=8C=96=E6=9C=AA=E7=94=9F=E6=95=88?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../canvas/custom-component/UserView.vue | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/frontend/src/components/canvas/custom-component/UserView.vue b/frontend/src/components/canvas/custom-component/UserView.vue index 68a044312f..dc755f8d9e 100644 --- a/frontend/src/components/canvas/custom-component/UserView.vue +++ b/frontend/src/components/canvas/custom-component/UserView.vue @@ -141,6 +141,7 @@ import { viewEditSave, viewPropsSave } from '@/api/chart/chart' import { checkAddHttp } from '@/utils/urlUtils' import DeRichTextView from '@/components/canvas/custom-component/DeRichTextView' import Vue from 'vue' +import { formatterItem, valueFormatter } from '@/views/chart/chart/formatter' export default { name: 'UserView', @@ -653,7 +654,20 @@ export default { pre[next['dataeaseName']] = next['name'] return pre }, {}) + let yAxis = [] + try { + yAxis = JSON.parse(chartDetails.yaxis) + } catch (err) { + yAxis = JSON.parse(JSON.stringify(chartDetails.yaxis)) + } + let yDataeaseNames = [] + let yDataeaseNamesCfg = [] + yAxis.forEach(yItem => { + yDataeaseNames.push(yItem.dataeaseName) + yDataeaseNamesCfg[yItem.dataeaseName]=yItem.formatterCfg + }) const rowData = chartDetails.data.tableRow[0] + this.rowDataFormat(rowData,yDataeaseNames,yDataeaseNamesCfg) for (const key in rowData) { this.dataRowSelect[nameIdMap[key]] = rowData[key] this.dataRowNameSelect[sourceFieldNameIdMap[key]] = rowData[key] @@ -666,6 +680,25 @@ export default { }) } }, + rowDataFormat(rowData,yDataeaseNames,yDataeaseNamesCfg) { + for (const key in rowData) { + if(yDataeaseNames.includes(key)){ + let formatterCfg = yDataeaseNamesCfg[key] + let value = rowData[key] + if (value === null || value === undefined) { + rowData[key] = '-' + } + if (formatterCfg) { + const v = valueFormatter(value, formatterCfg) + rowData[key] = v.includes('NaN') ? value : v + } else { + const v = valueFormatter(value, formatterItem) + rowData[key] = v.includes('NaN') ? value : v + } + } + } + + }, viewIdMatch(viewIds, viewId) { return !viewIds || viewIds.length === 0 || viewIds.includes(viewId) },