|
@@ -121,7 +121,7 @@ export default {
|
|
|
ruleDetails: '',
|
|
|
ruleType: '',
|
|
|
// scriptName: '',
|
|
|
- localPath:'',
|
|
|
+ localPath: '',
|
|
|
},
|
|
|
ruleTypeDisabled: false,
|
|
|
fileList: [], // 文件上传列表
|
|
@@ -149,83 +149,74 @@ export default {
|
|
|
this.scriptUpdate = true
|
|
|
},
|
|
|
save(isAdd) {
|
|
|
- let ruleDetails = null
|
|
|
+ if (this.isScore) {
|
|
|
+ this.saveFn()
|
|
|
+ } else {
|
|
|
+ let ruleDetails = null
|
|
|
|
|
|
- if (!this.isScore) {
|
|
|
- ruleDetails = this.$refs.editor.editor.getText().trim()
|
|
|
- this.form.ruleDetails = ruleDetails
|
|
|
- }
|
|
|
- // 调用save时,应写成save(),给不给参数均可,不写小括号的话,isAdd会是事件源,则为true
|
|
|
- this.$refs.form.validate((valid) => {
|
|
|
- if (valid) {
|
|
|
- if (!this.isScore && ruleDetails && ruleDetails.length > 1000000) {
|
|
|
- this.$message.error('规则详情长度不得超过100万!')
|
|
|
- return
|
|
|
- }
|
|
|
+ if (!this.isScore) {
|
|
|
+ ruleDetails = this.$refs.editor.editor.getText().trim()
|
|
|
+ this.form.ruleDetails = ruleDetails
|
|
|
+ }
|
|
|
+ // 调用save时,应写成save(),给不给参数均可,不写小括号的话,isAdd会是事件源,则为true
|
|
|
+ this.$refs.form.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ if (!this.isScore && ruleDetails && ruleDetails.length > 1000000) {
|
|
|
+ this.$message.error('规则详情长度不得超过100万!')
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
- if (isAdd || !this.$route.query.rulesId) {
|
|
|
- // 另存为或新增页面
|
|
|
- this.form.rulesId = ''
|
|
|
- this.form.share = '0'
|
|
|
- }
|
|
|
+ if (isAdd || !this.$route.query.rulesId) {
|
|
|
+ // 另存为或新增页面
|
|
|
+ this.form.rulesId = ''
|
|
|
+ this.form.share = '0'
|
|
|
+ }
|
|
|
|
|
|
- if (this.form.rulesId) {
|
|
|
- this.$axios({
|
|
|
- method: 'post',
|
|
|
- url: this.$api.sceneLibrary.queryCsbById,
|
|
|
- data: {
|
|
|
- rulesId: this.form.rulesId,
|
|
|
- },
|
|
|
- }).then((res) => {
|
|
|
- if (res.code === 200) {
|
|
|
- if (res.info === 0) {
|
|
|
- this.saveFn()
|
|
|
- return
|
|
|
+ if (this.form.rulesId) {
|
|
|
+ this.$axios({
|
|
|
+ method: 'post',
|
|
|
+ url: this.$api.sceneLibrary.queryCsbById,
|
|
|
+ data: {
|
|
|
+ rulesId: this.form.rulesId,
|
|
|
+ },
|
|
|
+ }).then((res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ if (res.info === 0) {
|
|
|
+ this.saveFn()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$confirm(
|
|
|
+ '该评分规则已经被场景测试包引用,保存后同步更新场景测试包中的评分规则,是否确认保存?',
|
|
|
+ '提示',
|
|
|
+ {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ }
|
|
|
+ ).then(() => {
|
|
|
+ this.saveFn()
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.$message.error(
|
|
|
+ res.message || '获取该评分规则是否被场景测试包引用失败'
|
|
|
+ )
|
|
|
}
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
- this.$confirm(
|
|
|
- '该评分规则已经被场景测试包引用,保存后同步更新场景测试包中的评分规则,是否确认保存?',
|
|
|
- '提示',
|
|
|
- {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning',
|
|
|
- }
|
|
|
- ).then(() => {
|
|
|
- this.saveFn()
|
|
|
- })
|
|
|
- } else {
|
|
|
- this.$message.error(
|
|
|
- res.message || '获取该评分规则是否被场景测试包引用失败'
|
|
|
- )
|
|
|
- }
|
|
|
- })
|
|
|
- return
|
|
|
+ this.saveFn()
|
|
|
}
|
|
|
-
|
|
|
- this.saveFn()
|
|
|
- }
|
|
|
- })
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
saveFn() {
|
|
|
if (this.isScore) {
|
|
|
- // let formData = new FormData()
|
|
|
- // let source = { ...this.form }
|
|
|
- // source['ruleId'] = source.rulesId
|
|
|
- // delete source.rulesId
|
|
|
- // const json = JSON.stringify({
|
|
|
- // ...source,
|
|
|
- // uploadNewFile: this.scriptUpdate,
|
|
|
- // })
|
|
|
- // const blob = new Blob([json], {
|
|
|
- // type: 'application/json',
|
|
|
- // })
|
|
|
- // formData.append('content', blob)
|
|
|
- // this.scriptUpdate && formData.append('file', this.fileList[0])
|
|
|
this.$axios({
|
|
|
method: 'post',
|
|
|
url: this.$api.sceneLibrary.queryScoringRulesInfo,
|
|
|
- data: {...this.form,scriptUpdate:true},
|
|
|
+ data: { ...this.form,ruleId:this.form.rulesId, uploadNewFile: true },
|
|
|
withCredentials: true,
|
|
|
headers: {
|
|
|
'Content-type': 'application/json',
|