From b196affbe04c7f5abfc0e3ce459c73ef302d1cc9 Mon Sep 17 00:00:00 2001 From: "liu.shiyi" Date: Tue, 17 Oct 2023 10:12:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E6=95=B0=E6=8D=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BasicComponents/Numbers/index.vue | 24 +++++++++---------- .../packages/BasicComponents/Texts/index.vue | 20 +++++++++------- .../BigScreenDesign/DataViewDialog/index.vue | 4 +++- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/data-room-ui/packages/BasicComponents/Numbers/index.vue b/data-room-ui/packages/BasicComponents/Numbers/index.vue index a1cf5bd7..f28e5bdb 100644 --- a/data-room-ui/packages/BasicComponents/Numbers/index.vue +++ b/data-room-ui/packages/BasicComponents/Numbers/index.vue @@ -40,23 +40,23 @@ export default { // 通过表达式计算得来的值 getDataByExpression (config) { // 如果表达式是由其他组件的值构成的 - const len = this.config.expressionCodes ? this.config.expressionCodes.length : 0 - const len1 = this.currentComputedDatas ? Object.keys(this.currentComputedDatas).length : 0 - const len2 = this.currentDataset ? Object.keys(this.currentDataset).length : 0 - if (len && len === len1 + len2) { - // eslint-disable-next-line no-new-func - const result = new Function('dataset', 'computedDatas', this.config.expression) - config.customize.title = result(this.dataset, this.computedDatas) - // 同时将计算得来的值保存到公共的数据存储的地方 - this.updateComputedDatas({ code: config.code, name: config.name, data: config.customize.title }) - // this.changeChartConfig(config) - } + // const len = this.config.expressionCodes ? this.config.expressionCodes.length : 0 + // const len1 = this.currentComputedDatas ? Object.keys(this.currentComputedDatas).length : 0 + // const len2 = this.currentDataset ? Object.keys(this.currentDataset).length : 0 + // if (len && len === len1 + len2) { + // eslint-disable-next-line no-new-func + const result = new Function('dataset', 'computedDatas', this.config.expression) + config.customize.title = result(this.dataset, this.computedDatas) + // 同时将计算得来的值保存到公共的数据存储的地方 + this.updateComputedDatas({ code: config.code, name: config.name, data: config.customize.title }) + // this.changeChartConfig(config) + // } }, dataFormatting (config, data) { // 文本数据配置原则:选择数据集则以后端返回的数据为主,否则以设置面板中标题设置为准 if (config.dataSource.businessKey) { config.customize.title = data && data.data && data.data.length ? data.data[0][config.dataSource.metricField] : '暂无数据' - config.option.data = data && data.data && data.data.length ? data.data :[] + config.option.data = data && data.data && data.data.length ? data.data : [] } return config } diff --git a/data-room-ui/packages/BasicComponents/Texts/index.vue b/data-room-ui/packages/BasicComponents/Texts/index.vue index 4f24012d..1cc6c5ec 100644 --- a/data-room-ui/packages/BasicComponents/Texts/index.vue +++ b/data-room-ui/packages/BasicComponents/Texts/index.vue @@ -40,17 +40,19 @@ export default { // 通过表达式计算得来的值 getDataByExpression (config) { // 如果表达式是由其他组件的值构成的 - const len = this.config.expressionCodes ? this.config.expressionCodes.length : 0 - const len1 = this.currentComputedDatas ? Object.keys(this.currentComputedDatas).length : 0 - const len2 = this.currentDataset ? Object.keys(this.currentDataset).length : 0 - if (len && len === len1 + len2) { + // const len = this.config.expressionCodes ? this.config.expressionCodes.length : 0 + // const len1 = this.currentComputedDatas ? Object.keys(this.currentComputedDatas).length : 0 + // const len2 = this.currentDataset ? Object.keys(this.currentDataset).length : 0 + // console.log('len', len, len1, len2) + // if (len && len === len1 + len2) { // eslint-disable-next-line no-new-func - const result = new Function('dataset', 'computedDatas', this.config.expression) - config.customize.title = result(this.dataset, this.computedDatas) - // 同时将计算得来的值保存到公共的数据存储的地方 - this.updateComputedDatas({ code: config.code, name: config.name, data: config.customize.title }) + const result = new Function('dataset', 'computedDatas', this.config.expression) + config.customize.title = result(this.dataset, this.computedDatas) + console.log(result(this.dataset, this.computedDatas)) + // 同时将计算得来的值保存到公共的数据存储的地方 + this.updateComputedDatas({ code: config.code, name: config.name, data: config.customize.title }) // this.changeChartConfig(config) - } + // } }, dataFormatting (config, data) { // 文本数据配置原则:选择数据集则以后端返回的数据为主,否则以设置面板中标题设置为准 diff --git a/data-room-ui/packages/BigScreenDesign/DataViewDialog/index.vue b/data-room-ui/packages/BigScreenDesign/DataViewDialog/index.vue index bae9014d..edb15202 100644 --- a/data-room-ui/packages/BigScreenDesign/DataViewDialog/index.vue +++ b/data-room-ui/packages/BigScreenDesign/DataViewDialog/index.vue @@ -107,7 +107,7 @@ export default { getDataList (config) { this.loading = true // 如果是G2组件并且未配置数据集的情况下,则需要从option里面取数据 - if (['customComponent', 'remoteComponent', 'echartsComponent'].includes(config.type) && (!config.dataSource.businessKey)) { + if ((['customComponent', 'remoteComponent', 'echartsComponent'].includes(config.type) && (!config.dataSource.businessKey)) || (config.expressionCodes && config.expressionCodes.length)) { this.getDataByOption(config) this.fieldsFormat() this.loading = false @@ -146,6 +146,8 @@ export default { list = config.option.data.children } else if (config.type === 'tables') { list = config.option.tableData + } else if (config.expressionCodes && config.expressionCodes.length) { + list = [{ title: config.customize.title }] } else { list = config.option.data }