输出字段
@@ -606,8 +606,11 @@ export default {
const javascript = this.dataForm.config.script
let scriptMethod = null
try {
+ const scriptAfterReplacement = javascript.replace(/\${(.*?)}/g, (match, p) => {
+ return `'${this.dataForm.config.paramsList.find(param => param.name === p).value}'`
+ })
// eslint-disable-next-line no-new-func
- scriptMethod = new Function(javascript)
+ scriptMethod = new Function(scriptAfterReplacement)
} catch (error) {
this.passTest = false
this.$message.error('脚本执行错误,请检查脚本')
@@ -671,15 +674,15 @@ export default {
}
},
// 执行事件
- toExecute () {
- // if (this.dataForm.config.paramsList.length) {
- // this.isSet = false
- // this.paramsVisible = true
- // } else {
- // 无参数,直接执行脚本
- this.scriptExecute()
- // }
- },
+ // toExecute () {
+ // if (this.dataForm.config.paramsList.length) {
+ // this.isSet = false
+ // this.paramsVisible = true
+ // } else {
+ // 无参数,直接执行脚本
+ // this.scriptExecute()
+ // }
+ // },
// 清空分类
clearType () {
this.typeName = ''