lsc 2 years ago
parent
commit
f78df8a7e4
1 changed files with 16 additions and 3 deletions
  1. 16 3
      src/components/pages/addCourse.vue

+ 16 - 3
src/components/pages/addCourse.vue

@@ -4414,15 +4414,28 @@ export default {
         .get(this.$store.state.api + "select_course_detail", params)
         .then((res) => {
           let unitJson = JSON.parse(res.data[0][0].chapters);
-          this.unitJson2 = JSON.parse(res.data[0][0].chapters);
-          let _unitJson = JSON.parse(JSON.stringify(this.unitJson));
+          // this.unitJson2 = JSON.parse(res.data[0][0].chapters);
+          let _unitJson2 = JSON.parse(JSON.stringify(this.unitJson));
+          let _unitJson = [];
+
           let _unitIndex = this.unitIndex;
+          if(_unitJson2.length > unitJson.length){
+            for(let j = 0;j<unitJson.length;j++){
+              // let count = 0
+              for(let k = 0;k<_unitJson2.length;k++){
+                if(unitJson[j].chapterInfo[0].chapterid == _unitJson2[k].chapterInfo[0].chapterid){
+                  _unitJson.push(unitJson[j]);
+                  break;
+                }
+              }
+            }
+          }
           for (let i = 0; i < unitJson.length; i++) {
             if (i == _unitIndex) {
               continue;
             } else if (i > this.unitJson.length - 1) {
               _unitJson.push(unitJson[i]);
-            } else {
+            } else if(_unitJson[i].chapterInfo[0].chapterid == unitJson[i].chapterInfo[0].chapterid){
               _unitJson[i] = unitJson[i];
             }
           }