Browse Source

#3538 C960 学校资源--知识点库,导入知识点需进行重复检查

XW 10 months ago
parent
commit
afb2b4b4d9
1 changed files with 29 additions and 2 deletions
  1. 29 2
      TEAMModelOS/ClientApp/src/view/knowledge-point/index/page.vue

+ 29 - 2
TEAMModelOS/ClientApp/src/view/knowledge-point/index/page.vue

@@ -233,7 +233,7 @@ export default {
             subjectList: [],
             originSubjectList: [],
             searchSubject: '',
-            activeSubjectIndex: 2,
+            activeSubjectIndex: 0,
             countArr: [],
             knowledgeTrees: undefined,
             subTreeRoot: [],
@@ -762,7 +762,13 @@ export default {
                         if(notContinue) break
                     }
                     if(!notContinue) {
-                        this.subTree = this.subTree.concat(pointTree)
+                        this.pointHandle(pointTree, this.subTree, 1)
+                        // el-tree未更新视图,需给subTree重新赋值,触发el-tree重新渲染
+                        let tree = [...this.subTree]
+                        this.subTree = []
+                        this.subTree = tree
+                        this.$forceUpdate()
+                        // this.subTree = this.subTree.concat(pointTree)
                         this.$Message.success(this.$t("knowledge.import.sucTip"))
                         this.batchUploadModal = false
                         this.updated = true
@@ -811,6 +817,27 @@ export default {
                 }
             })
         },
+        /* 
+         * arrAdd:新增数组
+         * arrOld:原数组
+         * index:代表第几层
+         * pid:父代id
+         */
+        pointHandle(arrAdd, arrOld, index, pid) {
+            arrAdd.forEach(item => {
+                let sameIndex = arrOld.findIndex(old => old.name === item.name)
+                if(sameIndex === -1) {
+                    let idLast4 = arrOld.length ? arrOld[arrOld.length - 1].id : '-0'
+                    let id4 = idLast4.split(`-`)
+                    item.id = `${pid}-${Number(id4[id4.length - 1]) + 1}`
+                    item.level = index
+                    item.pid = pid
+                    arrOld.push(item)
+                } else {
+                    this.pointHandle(item.children, arrOld[sameIndex].children, index + 1, arrOld[sameIndex].id)
+                }
+            })
+        },
     },
     beforeRouteLeave(to, from, next) {
         if (this.updated) {