feat: 自定义JS数据集添加动态参数

main
wu.jian2 2 years ago
parent db1e34cb78
commit 8963169f94

@ -140,7 +140,7 @@
<div style="text-align: center; padding: 16px 0;">
<el-button
type="primary"
@click="toExecute"
@click="scriptExecute()"
>
执行
</el-button>
@ -152,9 +152,9 @@
:span="8"
>
<div class="right-setting">
<!-- <div class="paramConfig">
<div class="paramConfig">
<div class="title-style bs-title-style">
方法参数
动态参数
<el-button
type="text"
style="float: right;border: none;margin-top: -4px;"
@ -186,7 +186,7 @@
</el-button>
</div>
</div>
</div> -->
</div>
<div class="structure">
<div class="title-style bs-title-style">
输出字段
@ -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 = ''

Loading…
Cancel
Save