fix:修复控制台报错

main
liu.shiyi 1 year ago
parent 316585b45c
commit c89e0adaf3

@ -40,13 +40,16 @@ export default {
// //
getDataByExpression (config) { getDataByExpression (config) {
// //
if (this.config.expressionCodes && this.config.expressionCodes.length) { const len = this.config.expressionCodes ? this.config.expressionCodes.length : 0
// eslint-disable-next-line no-new-func 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) const result = new Function('dataset', 'computedDatas', this.config.expression)
config.customize.title = result(this.dataset, this.computedDatas) config.customize.title = result(this.dataset, this.computedDatas)
// //
this.updateComputedDatas({ code: config.code, name: config.name, data: config.customize.title }) this.updateComputedDatas({ code: config.code, name: config.name, data: config.customize.title })
// this.changeChartConfig(config) // this.changeChartConfig(config)
} }
}, },
dataFormatting (config, data) { dataFormatting (config, data) {

@ -40,7 +40,10 @@ export default {
// //
getDataByExpression (config) { getDataByExpression (config) {
// //
if (this.config.expressionCodes && this.config.expressionCodes.length) { 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 // eslint-disable-next-line no-new-func
const result = new Function('dataset', 'computedDatas', this.config.expression) const result = new Function('dataset', 'computedDatas', this.config.expression)
config.customize.title = result(this.dataset, this.computedDatas) config.customize.title = result(this.dataset, this.computedDatas)
@ -53,7 +56,7 @@ export default {
// //
if (config.dataSource.businessKey) { if (config.dataSource.businessKey) {
config.customize.title = data && data.data && data.data.length ? data.data[0][config.dataSource.metricField] : '暂无数据' 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 return config
} }

Loading…
Cancel
Save