|
@@ -652,7 +652,38 @@ export default {
|
|
|
scriptMethod = new Function(scriptAfterReplacement)
|
|
|
} catch (error) {
|
|
|
this.passTest = false
|
|
|
- this.$message.error(`脚本执行错误,请检查脚本,具体错误:${error}`)
|
|
|
+ const javascriptParams = javascript.match(/\${(.*?)}/g)
|
|
|
+ // 取出${}中的参数名
|
|
|
+ if (javascriptParams) {
|
|
|
+ const paramList = []
|
|
|
+ javascriptParams.forEach(item => {
|
|
|
+ const name = item.replace(/\${(.*?)}/g, '$1')
|
|
|
+ const param = this.dataForm.config.paramsList.find(param => param.name === name)
|
|
|
+ if (!param) {
|
|
|
+ // 添加确认框,是否填充参数
|
|
|
+ paramList.push(name)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.$confirm(`脚本中的参数${paramList.join(',')}不存在,是否添加?`, '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ customClass: 'bs-el-message-box',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ paramList.forEach(name => {
|
|
|
+ this.dataForm.config.paramsList.push({
|
|
|
+ name,
|
|
|
+ type: '',
|
|
|
+ value: '',
|
|
|
+ status: 1,
|
|
|
+ require: 0,
|
|
|
+ remark: ''
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }).catch(() => {})
|
|
|
+ } else {
|
|
|
+ this.$message.error(`脚本执行错误,请检查脚本,具体错误:${error}`)
|
|
|
+ }
|
|
|
return
|
|
|
}
|
|
|
// 调用方法生成随机数据
|