Эх сурвалжийг харах

解决缺陷:app端教育培训登记,选择知识库文件后,点删除,重新选点选取知识库文件,还是会勾选已删除的

zhulu 8 сар өмнө
parent
commit
896784625c

+ 4 - 3
src/views/menu/training/components/addTraining.vue

@@ -162,6 +162,7 @@
         ref="SelectData"
         :organizationId="trainingData.orgId"
         :listLength="studyList.length"
+        :defaultSelectList="studyList"
         @dataList="dataList"
       ></SelectData>
     </van-form>
@@ -312,7 +313,7 @@ export default {
     //从资料里选取
     selectData() {
       this.$refs.SelectData.show = true
-      this.studyList = this.studyList.filter(item => item.type != undefined)
+      // this.studyList = this.studyList.filter(item => item.type != undefined)
     },
     clikHadner() {
       this.$refs.PDFAndImgLook.show = true
@@ -517,8 +518,8 @@ export default {
         }
       })
     },
-    dataList(list) {
-      this.studyList.push(...list)
+    dataList(list) {      
+      this.studyList=list;
       this.studyList = uniqBy(this.studyList, 'name')
     },
     tagHandler(i) {

+ 32 - 3
src/views/menu/training/components/selectData.vue

@@ -43,6 +43,7 @@ import { deptTreeList } from '@/api/toConsult.js'
 import { materialsFileList } from '@/api/training.js'
 import OrgTree from '@/components/orgTree'
 import { Toast } from 'vant'
+import { uniqBy } from 'lodash'
 export default {
   name: 'SocAppIndex',
   components: {
@@ -56,6 +57,12 @@ export default {
     //培训资料数量
     listLength: {
       type: Number
+    },
+    defaultSelectList:{
+      type: Array,
+      default: () => {
+        return []
+      }
     }
   },
   data() {
@@ -120,6 +127,24 @@ export default {
 
           this.peopleList = rows
           this.peopleListCpoy = JSON.parse(JSON.stringify(rows))
+          console.info("defaultSelectList1",this.defaultSelectList,this.peopleList);
+          this.result=[];
+          this.activeNames=[];
+          if(this.defaultSelectList && this.defaultSelectList.length>0)
+          {
+            console.info("defaultSelectList2",this.defaultSelectList);
+            this.defaultSelectList.forEach(x=>{
+              let index= this.peopleList.findIndex(y=>
+                y.fileList!=null && y.fileList.length>0 && y.fileList.findIndex(z=>z.url == x.url)>-1
+              );
+              if(index>-1)
+              {
+                let id =this.peopleList[index].id;
+                this.result.push(id);
+                this.activeNames.push(id);
+              }
+            })
+          }
         }
       })
     },
@@ -145,15 +170,19 @@ export default {
           }
         })
       })
-
+      // 文件路径相同的去重
+      list = uniqBy(list, 'url')
       // this.peoples = list.map(item => item.name).join(',')
-      if (list.length + this.listLength > 5) {
+      // console.info("submiter",this.result,this.activeNames,list)
+      if (list.length > 5) {
         return Toast('资料附件数量不能超过5个,请修改!')
       }
       this.$set(this.$data, 'peoples', list.map(item => item.name).join(','))
       // 抛出已选择资料信息
       this.$emit('dataList', list)
-      this.show = false
+      this.show = false;  
+      this.result=[];
+      this.activeNames=[];
     },
     //复选框单选
     // changeCheckBox(list) {