|
@@ -71,28 +71,13 @@ export default {
|
|
|
pageCode: this.pageCode,
|
|
|
size: size,
|
|
|
type: config.type
|
|
|
- }).then((res) => {
|
|
|
+ }).then(async (res) => {
|
|
|
+ let _res = _.cloneDeep(res)
|
|
|
// 如果是http数据集的前端代理,则需要调封装的axios请求
|
|
|
- // if (data.executionByFrontend) {
|
|
|
- // axiosFormatting(data.data).then(res => {
|
|
|
- // config = this.dataFormatting(config, res)
|
|
|
- // this.changeChartConfig(config)
|
|
|
- // })
|
|
|
- // }
|
|
|
- // if (data.datasetType !== 'http' && data.executionByFrontend) {
|
|
|
- // try {
|
|
|
- // const scriptAfterReplacement = data.data.replace(/\${(.*?)}/g, (match, p) => {
|
|
|
- // // 根据parmas的key获取value
|
|
|
- // return `'${this.config.dataSource?.params[p]}' || '${p}'`
|
|
|
- // })
|
|
|
- // // eslint-disable-next-line no-new-func
|
|
|
- // const scriptMethod = new Function(scriptAfterReplacement)
|
|
|
- // data.data = scriptMethod()
|
|
|
- // } catch (error) {
|
|
|
- // console.error('数据集脚本执行失败', error)
|
|
|
- // }
|
|
|
- // }
|
|
|
if (res.executionByFrontend) {
|
|
|
+ if (res.data.datasetType === 'http') {
|
|
|
+ _res = await axiosFormatting(res.data)
|
|
|
+ }
|
|
|
if (res.data.datasetType === 'js') {
|
|
|
try {
|
|
|
const scriptAfterReplacement = res.data.script.replace(/\${(.*?)}/g, (match, p) => {
|
|
@@ -101,13 +86,13 @@ export default {
|
|
|
})
|
|
|
// eslint-disable-next-line no-new-func
|
|
|
const scriptMethod = new Function(scriptAfterReplacement)
|
|
|
- res.data = scriptMethod()
|
|
|
+ _res.data = scriptMethod()
|
|
|
} catch (error) {
|
|
|
console.error('JS数据集脚本执行失败', error)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- config = this.dataFormatting(config, res)
|
|
|
+ config = this.dataFormatting(config, _res)
|
|
|
this.changeChartConfig(config)
|
|
|
}).catch((err) => {
|
|
|
console.error(err)
|
|
@@ -132,15 +117,13 @@ export default {
|
|
|
filterList: filterList || this.filterList
|
|
|
}
|
|
|
return new Promise((resolve, reject) => {
|
|
|
- getUpdateChartInfo(params).then((res) => {
|
|
|
+ getUpdateChartInfo(params).then(async (res) => {
|
|
|
+ let _res = _.cloneDeep(res)
|
|
|
// 如果是http数据集的前端代理,则需要调封装的axios请求
|
|
|
- // if (data.executionByFrontend) {
|
|
|
- // axiosFormatting(data.data).then(res => {
|
|
|
- // config = this.dataFormatting(config, res)
|
|
|
- // this.changeChartConfig(config)
|
|
|
- // })
|
|
|
- // }
|
|
|
if (res.executionByFrontend) {
|
|
|
+ if (res.data.datasetType === 'http') {
|
|
|
+ _res = await axiosFormatting(res.data)
|
|
|
+ }
|
|
|
if (res.data.datasetType === 'js') {
|
|
|
try {
|
|
|
const scriptAfterReplacement = res.data.script.replace(/\${(.*?)}/g, (match, p) => {
|
|
@@ -149,14 +132,13 @@ export default {
|
|
|
})
|
|
|
// eslint-disable-next-line no-new-func
|
|
|
const scriptMethod = new Function(scriptAfterReplacement)
|
|
|
- res.data = scriptMethod()
|
|
|
+ _res.data = scriptMethod()
|
|
|
} catch (error) {
|
|
|
console.error('JS数据集脚本执行失败', error)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- config = this.dataFormatting(config, res)
|
|
|
- this.changeChartConfig(config)
|
|
|
+ config = this.dataFormatting(config, _res)
|
|
|
if (this.chart) {
|
|
|
// 单指标组件和多指标组件的changeData传参不同
|
|
|
if (['Liquid', 'Gauge', 'RingProgress'].includes(config.chartType)) {
|