Przeglądaj źródła

评分规则增加是否关联测试包校验

zhangliang2 2 lat temu
rodzic
commit
4a7cf9df58
2 zmienionych plików z 57 dodań i 17 usunięć
  1. 2 0
      src/api/sceneLibrary.js
  2. 55 17
      src/views/sceneLibrary/gradingRule.vue

+ 2 - 0
src/api/sceneLibrary.js

@@ -6,6 +6,7 @@ const queryScoringRules = basePart + '/ScoringRules/queryScoringRules'; // 查
 const saveScoringRules = basePart + '/ScoringRules/saveScoringRules'; // 保存评分规则详情
 const fxScoringRules = basePart + '/ScoringRules/fxScoringRules'; // 分享评分规则
 const deleteScoringRules = basePart + '/ScoringRules/deleteScoringRules'; // 删除评分规则
+const queryCsbById = basePart + '/ScoringRules/queryCsbById'; // 查询该规则是否有关联任务
 
 const queryStandardsRegulationsList = basePart + '/StandardsRegulations/queryStandardsRegulationsList'; // 标准法规仿真场景列表
 const saveStandardsRegulations = basePart + '/StandardsRegulations/saveStandardsRegulations'; // 新增标准法规仿场景
@@ -43,6 +44,7 @@ export default {
     saveScoringRules,
     fxScoringRules,
     deleteScoringRules,
+    queryCsbById,
 
     queryStandardsRegulationsList,
     saveStandardsRegulations,

+ 55 - 17
src/views/sceneLibrary/gradingRule.vue

@@ -115,25 +115,63 @@ export default {
                         this.form.share = "0";
                     }
 
-                    this.$axios({
-                        method: "post",
-                        url: this.$api.sceneLibrary.saveScoringRules,
-                        data: {
-                            ...this.form,
-                        },
-                    }).then((res) => {
-                        if (res.code == 200) {
-                            this.$message.success("保存成功");
-                            this.cancel();
-                        } else {
-                            this.$message.error(res.message || "保存失败");
-                        }
-                    });
-                    // .catch((error) => {
-                    //     this.$message.error(error || "保存失败!");
-                    // });
+                    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.saveFn();
+                }
+            });
+        },
+        saveFn() {
+            this.$axios({
+                method: "post",
+                url: this.$api.sceneLibrary.saveScoringRules,
+                data: {
+                    ...this.form,
+                },
+            }).then((res) => {
+                if (res.code == 200) {
+                    this.$message.success("保存成功");
+                    this.cancel();
+                } else {
+                    this.$message.error(res.message || "保存失败");
                 }
             });
+            // .catch((error) => {
+            //     this.$message.error(error || "保存失败!");
+            // });
         },
         cancel() {
             this.$router.replace({ path: "/gradingRulesList" });