diff --git a/data-room-ui/packages/DataSetManagement/src/JsEditForm.vue b/data-room-ui/packages/DataSetManagement/src/JsEditForm.vue index 6f7f5d26..808bea88 100644 --- a/data-room-ui/packages/DataSetManagement/src/JsEditForm.vue +++ b/data-room-ui/packages/DataSetManagement/src/JsEditForm.vue @@ -641,7 +641,12 @@ export default { let scriptMethod = null try { const scriptAfterReplacement = javascript.replace(/\${(.*?)}/g, (match, p) => { - return `'${this.dataForm.config.paramsList.find(param => param.name === p).value}'` + const value = this.dataForm.config.paramsList.find(param => param.name === p).value + if (!isNaN(value)) { + return value + } else { + return `'${value}'` + } }) // eslint-disable-next-line no-new-func scriptMethod = new Function(scriptAfterReplacement) diff --git a/data-room-ui/packages/js/mixins/commonMixins.js b/data-room-ui/packages/js/mixins/commonMixins.js index 26ddc205..e4112247 100644 --- a/data-room-ui/packages/js/mixins/commonMixins.js +++ b/data-room-ui/packages/js/mixins/commonMixins.js @@ -82,8 +82,13 @@ export default { if (res.data.datasetType === 'js') { try { const scriptAfterReplacement = res.data.script.replace(/\${(.*?)}/g, (match, p) => { - // 根据parmas的key获取value - return `'${this.config.dataSource?.params[p]}' || '${p}'` + const value = this.config.dataSource?.params[p] + + if (!isNaN(value)) { + return value || p + } else { + return `'${value}' || '${p}'` + } }) // eslint-disable-next-line no-new-func const scriptMethod = new Function(scriptAfterReplacement) @@ -129,8 +134,12 @@ export default { if (res.data.datasetType === 'js') { try { const scriptAfterReplacement = res.data.script.replace(/\${(.*?)}/g, (match, p) => { - // 根据parmas的key获取value - return `'${this.config.dataSource?.params[p]}' || '${p}'` + const value = this.config.dataSource?.params[p] + if (!isNaN(value)) { + return value || p + } else { + return `'${value}' || '${p}'` + } }) // eslint-disable-next-line no-new-func const scriptMethod = new Function(scriptAfterReplacement)