fix:修复组件查看数据的问题

main
liu.shiyi 1 year ago
parent cb00c0805a
commit b196affbe0

@ -40,17 +40,17 @@ export default {
// //
getDataByExpression (config) { getDataByExpression (config) {
// //
const len = this.config.expressionCodes ? this.config.expressionCodes.length : 0 // const len = this.config.expressionCodes ? this.config.expressionCodes.length : 0
const len1 = this.currentComputedDatas ? Object.keys(this.currentComputedDatas).length : 0 // const len1 = this.currentComputedDatas ? Object.keys(this.currentComputedDatas).length : 0
const len2 = this.currentDataset ? Object.keys(this.currentDataset).length : 0 // const len2 = this.currentDataset ? Object.keys(this.currentDataset).length : 0
if (len && len === len1 + len2) { // 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)
// //
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,17 +40,19 @@ export default {
// //
getDataByExpression (config) { getDataByExpression (config) {
// //
const len = this.config.expressionCodes ? this.config.expressionCodes.length : 0 // const len = this.config.expressionCodes ? this.config.expressionCodes.length : 0
const len1 = this.currentComputedDatas ? Object.keys(this.currentComputedDatas).length : 0 // const len1 = this.currentComputedDatas ? Object.keys(this.currentComputedDatas).length : 0
const len2 = this.currentDataset ? Object.keys(this.currentDataset).length : 0 // const len2 = this.currentDataset ? Object.keys(this.currentDataset).length : 0
if (len && len === len1 + len2) { // console.log('len', len, len1, len2)
// 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)
console.log(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) {
// //

@ -107,7 +107,7 @@ export default {
getDataList (config) { getDataList (config) {
this.loading = true this.loading = true
// G2option // G2option
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.getDataByOption(config)
this.fieldsFormat() this.fieldsFormat()
this.loading = false this.loading = false
@ -146,6 +146,8 @@ export default {
list = config.option.data.children list = config.option.data.children
} else if (config.type === 'tables') { } else if (config.type === 'tables') {
list = config.option.tableData list = config.option.tableData
} else if (config.expressionCodes && config.expressionCodes.length) {
list = [{ title: config.customize.title }]
} else { } else {
list = config.option.data list = config.option.data
} }

Loading…
Cancel
Save