zengyicheng 1 år sedan
förälder
incheckning
8000d10261
2 ändrade filer med 178 tillägg och 7 borttagningar
  1. 174 7
      src/components/pages/addCourse.vue
  2. 4 0
      src/components/pages/evaBox/index.vue

+ 174 - 7
src/components/pages/addCourse.vue

@@ -3924,6 +3924,37 @@
         <div style="min-width: 100px">模板名称:</div>
         <el-input v-model="templateName" style="width: 200px"></el-input>
       </div>
+      <div class="addTypeBox">
+        <div class="addTypeChoose">
+          <div style="min-width: 100px">选择一级分类:</div>
+          <el-select
+            v-model="setTypeJson.one"
+            placeholder="请选择"
+            @change="getTwoType(setTypeJson.one)"
+            style="width: 200px;"
+          >
+            <el-option
+              v-for="(item, index) in oneJson"
+              :key="index"
+              :label="item.name"
+              :value="item.id"
+            >
+            </el-option>
+          </el-select>
+        </div>
+        <div class="addTypeChoose" v-if="setTypeJson.one != ''">
+          <div style="min-width: 100px">选择二级分类:</div>
+          <el-select v-model="setTypeJson.two" placeholder="请选择" style="width: 200px;">
+            <el-option
+              v-for="(item1, index1) in twoJson"
+              :key="index1"
+              :label="item1.name"
+              :value="item1.id"
+            >
+            </el-option>
+          </el-select>
+        </div>
+      </div>
       <span slot="footer" class="dialog-footer">
         <el-button type="primary" @click="addCETemplate()">确 认</el-button>
         <el-button @click="close()">关 闭</el-button>
@@ -4148,9 +4179,12 @@ export default {
       AttTextIndex: 0,
       cTemplate: "",
       CourseType: [],
+      CourseType1: [],
       CourseType2: [],
       CourseTypeJson: {},
+      CourseTypeJson1: {},
       courseTypeId: [],
+      courseTypeId1: [],
       courseTypeSon: [],
       clearArray: [],
       pTypeCheck: [],
@@ -4241,6 +4275,12 @@ export default {
         cettIndex: '',
         cetBoxDialog: false,
         templateName: '',
+        setTypeJson: {
+          one: "",
+          two: "",
+        },
+        twoJson: [],
+        oneJson: [],
     };
   },
   directives: {
@@ -9423,7 +9463,7 @@ export default {
     addCET(index,tIndex){
       this.cetIndex = index;
       this.cettIndex = tIndex;
-      this.cetBoxDialog = true;
+      this.selectAllType1();
     },
     addCETemplate(){
       var array = this.unitJson[this.cetIndex].chapterInfo[0].taskJson[this.cettIndex].eList;
@@ -9439,11 +9479,52 @@ export default {
       this.ajax
         .post(this.$store.state.api + "addCETShare", params)
         .then((res) => {
-          this.$message({
-            message: "添加成功",
-            type: "success",
-          });
-          this.close();
+          this.addTypeByCET(res.data[0][0].id);
+        })
+        .catch((err) => {
+          this.$message.error("网络不佳");
+          console.error(err);
+        });
+    },
+    addTypeByCET(id) {
+      if (this.setTypeJson.two == "") {
+        this.$message.warning("请选择二级分类,如没有二级分类请前往添加!");
+        return;
+      }
+      let params = {
+        cid: id,
+      };
+      this.ajax
+        .get(this.$store.state.api + "deleteCETLabel", params)
+        .then((res) => {
+          for (var i = 0; i < 2; i++) {
+            let tid = "";
+            if (i == 0) {
+              tid = this.setTypeJson.one;
+            } else {
+              tid = this.setTypeJson.two;
+            }
+            let params = [
+              {
+                cid: id,
+                tid: tid,
+                uid: this.userid,
+              },
+            ];
+            this.ajax
+              .post(this.$store.state.api + "addCETLabel", params)
+              .then((res) => {
+                this.$message({
+                  message: "添加成功",
+                  type: "success",
+                });
+                this.close();
+              })
+              .catch((err) => {
+                this.$message.error("网络不佳");
+                console.error(err);
+              });
+          }
         })
         .catch((err) => {
           this.$message.error("网络不佳");
@@ -10427,7 +10508,78 @@ export default {
           });
       });
       
-    }
+    },
+    getTwoType(id) {
+      this.twoJson = [];
+      var array = this.CourseTypeJson1[
+        "3f8eed32-aba9-11ee-b534-005056b86db5"
+      ].filter((e) => {
+        return e.ppid == id;
+      });
+      this.twoJson = array;
+      this.$forceUpdate();
+    },
+    ctype(){
+      this.oneJson =  this.CourseTypeJson1["3c73702a-aba9-11ee-b534-005056b86db5"];
+    },
+    selectAllType1() {
+      this.CourseType1 = [];
+      this.CourseTypeJson1 = {};
+      this.courseTypeId1 = {};
+      this.$forceUpdate();
+      let params = {
+        org: this.org && this.org != "" ? this.org : "",
+        oid: this.oid && this.oid != "" ? this.oid : "",
+      };
+      this.ajax
+        .get(this.$store.state.api + "selectAllEvaType", params)
+        .then((res) => {
+          this.CourseType1 = res.data;
+          for (var i = 0; i < res.data[0].length; i++) {
+            if (res.data[0][i].id == "3c73702a-aba9-11ee-b534-005056b86db5") {
+              res.data[0][i].name = "一级分类";
+            } else if (
+              res.data[0][i].id == "3f8eed32-aba9-11ee-b534-005056b86db5"
+            ) {
+              res.data[0][i].name = "二级分类";
+            }
+            if (!this.cid) {
+              this.courseTypeId1[res.data[0][i].id] = [];
+            }
+            if (!this.CourseTypeJson1[res.data[0][i].id]) {
+              this.CourseTypeJson1[res.data[0][i].id] = [];
+            }
+
+            // if (res.data[2].length == 0 && res.data[3].length == 0) {
+            for (var j = 0; j < res.data[1].length; j++) {
+              if (res.data[0][i].id == res.data[1][j].pid) {
+                this.CourseTypeJson1[res.data[0][i].id].push(res.data[1][j]); // 去除公共分类
+              }
+            }
+            // } else {
+            if (res.data[2].length > 0) {
+              for (var j = 0; j < res.data[2].length; j++) {
+                if (res.data[0][i].id == res.data[2][j].pid) {
+                  this.CourseTypeJson1[res.data[0][i].id].push(res.data[2][j]); // 去除公共分类
+                }
+              }
+            }
+            if (res.data[3].length > 0) {
+              for (var j = 0; j < res.data[3].length; j++) {
+                if (res.data[0][i].id == res.data[3][j].pid) {
+                  this.CourseTypeJson1[res.data[0][i].id].push(res.data[3][j]); // 去除公共分类
+                }
+              }
+            }
+            // }
+          }
+          this.ctype();
+          this.cetBoxDialog = true;
+        })
+        .catch((err) => {
+          console.error(err);
+        });
+    },
   },
   beforeDestroy() {
     clearTimeout(this.timer);
@@ -14546,6 +14698,21 @@ ol {
   align-items: center;
 }
 
+.addTypeChoose {
+  display: flex;
+  flex-direction: row;
+  flex-wrap: nowrap;
+  align-items: center;
+  margin: 15px 0;
+}
+
+.addTypeBox {
+  display: flex;
+  flex-direction: column;
+  flex-wrap: nowrap;
+  align-items: center;
+}
+
 .addTypeChoose {
   display: flex;
   flex-direction: row;

+ 4 - 0
src/components/pages/evaBox/index.vue

@@ -415,6 +415,7 @@ export default {
       this.getSource();
     },
     getTwoType(id) {
+      this.twoJson = [];
       var array = this.CourseTypeJson[
         "3f8eed32-aba9-11ee-b534-005056b86db5"
       ].filter((e) => {
@@ -462,6 +463,9 @@ export default {
       this.shareDialogVisible = false;
     },
     setType(t) {
+      this.typea = "";
+      this.typeb = "";
+      this.typeE = [];
       this.type = t;
       this.getSource();
     },