Browse Source

fix:修改代理全选问题

wuguojie 1 năm trước cách đây
mục cha
commit
ada9e824ca

+ 33 - 25
src/views/PeopleManage/Agent/QuoteCountManagement.vue

@@ -141,7 +141,7 @@
         :reserve-selection="true"
         :reserve-selection="true"
         style="width: 100%"
         style="width: 100%"
         @select-all="handleSelectAll"
         @select-all="handleSelectAll"
-        @selection-change="handleSelectChange"
+        @select="handleSelectChange"
       >
       >
         <el-table-column type="selection"></el-table-column>
         <el-table-column type="selection"></el-table-column>
         <el-table-column prop="deptId" label="部门编码"></el-table-column>
         <el-table-column prop="deptId" label="部门编码"></el-table-column>
@@ -273,7 +273,7 @@ export default {
               that.selectedLength = res.data.totalSize
               that.selectedLength = res.data.totalSize
               if(that.agentDataList.length>0) {
               if(that.agentDataList.length>0) {
                 that.agentDataList.forEach(item => {
                 that.agentDataList.forEach(item => {
-                  that.$refs.multipleTable.toggleRowSelection(item)
+                  that.$refs.multipleTable.toggleRowSelection(item, true)
                 })
                 })
               }
               }
             } else {
             } else {
@@ -282,7 +282,7 @@ export default {
                 list.forEach(item => {
                 list.forEach(item => {
                   let arrayItem = that.agentDataList.find(sub => sub.id === item.id)
                   let arrayItem = that.agentDataList.find(sub => sub.id === item.id)
                   if(arrayItem) {
                   if(arrayItem) {
-                    that.$refs.multipleTable.toggleRowSelection(arrayItem)
+                    that.$refs.multipleTable.toggleRowSelection(arrayItem, true)
                   }
                   }
                 })
                 })
               }
               }
@@ -314,7 +314,9 @@ export default {
     },
     },
     // 选择代理人取消
     // 选择代理人取消
     handleCancel() {
     handleCancel() {
-      this.selectList = [...this.myList]
+      // this.selectList = [...this.myList]
+      this.selectedList = [...this.selectList]
+      this.selectedLength = this.selectedList.length
       this.agentTableShow = false
       this.agentTableShow = false
     },
     },
     // 代理选择
     // 代理选择
@@ -323,36 +325,39 @@ export default {
         this.selectedLength = this.total
         this.selectedLength = this.total
         return;
         return;
       }
       }
-      if(rows.length>0) {
-        let list = [...this.selectedList]
-        if(this.selectedList.length>0){
-          list.forEach((item, index) => {
-            this.agentDataList.forEach(sub => {
-              if(sub.id === item.id) {
-                list.splice(index,1)
-              }
-            })
-          })
-          this.selectedList = this.uniqueItems([...list, ...rows])
-          this.selectedLength = this.selectedList.length
+      let list = [...this.selectedList]
+      if(list.length>0){
+        if(rows.length>0) {
+          let arr = list.filter(item1 => !this.agentDataList.some(item2 => item1.id === item2.id))
+          this.selectedList = this.uniqueItems([...arr, ...rows])
         } else {
         } else {
+          this.selectedList = this.uniqueItems([...list])
+        }
+        this.selectedLength = this.selectedList.length
+      } else {
+        if(rows.length>0) {
           this.selectedList = [...rows]
           this.selectedList = [...rows]
-          this.selectedLength = this.selectedList.length
+        } else {
+          this.selectedList = []
         }
         }
+        this.selectedLength = this.selectedList.length
       }
       }
     },
     },
     // 手动点击全选
     // 手动点击全选
     handleSelectAll(rows) {
     handleSelectAll(rows) {
-      console.log(123, rows)
-      console.log(456, this.selectedList)
+      let list = [...this.selectedList]
       if(rows.length===0) {
       if(rows.length===0) {
-        let list = [...this.selectedList]
         if(list.length>0){
         if(list.length>0){
           let arr = list.filter(item1 => !this.agentDataList.some(item2 => item1.id === item2.id))
           let arr = list.filter(item1 => !this.agentDataList.some(item2 => item1.id === item2.id))
           this.selectedList = this.uniqueItems([...arr])
           this.selectedList = this.uniqueItems([...arr])
           this.selectedLength = this.selectedList.length
           this.selectedLength = this.selectedList.length
-          console.log(789, this.selectedList)
+        } else {
+          this.selectedList = [...rows]
         }
         }
+      } else {
+        let arr = [...rows], brr = [...list], crr = brr.concat(arr)
+        this.selectedList = this.uniqueItems([...crr])
+        this.selectedLength = this.selectedList.length
       }
       }
     },
     },
     // 数组去重
     // 数组去重
@@ -398,7 +403,8 @@ export default {
             list.push('3')
             list.push('3')
           }
           }
           this.$set(this.quoteForm, 'quoteLimit', list)
           this.$set(this.quoteForm, 'quoteLimit', list)
-          this.selectedList = res.data.proxyList
+          this.selectedList = [...res.data.proxyList]
+          this.selectedLength = res.data.proxyList.length
           this.selectList = [...res.data.proxyList]
           this.selectList = [...res.data.proxyList]
           this.myList = [...res.data.proxyList]
           this.myList = [...res.data.proxyList]
         } else {
         } else {
@@ -467,6 +473,7 @@ export default {
       this.agentTableShow = true
       this.agentTableShow = true
       this.countDetailForm = {}
       this.countDetailForm = {}
       this.pageNum = 1
       this.pageNum = 1
+      this.checkType = ''
       this.initAgentUser()
       this.initAgentUser()
       this.initOrganization()
       this.initOrganization()
     },
     },
@@ -479,11 +486,11 @@ export default {
       }
       }
       if(this.checkType === 'all') {
       if(this.checkType === 'all') {
         this.selectedLength = this.total
         this.selectedLength = this.total
+        this.selectedList = []
       }
       }
       if(this.checkType === 'cur') {
       if(this.checkType === 'cur') {
-        this.selectedLength = 0
-        let list = [...this.selectedList, ...this.agentDataList]
-        this.selectedList = this.uniqueItems(list)
+        let list = [...this.selectedList], arr = [...this.agentDataList]
+        this.selectedList = this.uniqueItems(list.concat(arr))
         this.selectedLength = this.selectedList.length
         this.selectedLength = this.selectedList.length
       }
       }
     },
     },
@@ -502,6 +509,7 @@ export default {
       })
       })
       this.selectList = [...list]
       this.selectList = [...list]
       this.selectedList = [...list]
       this.selectedList = [...list]
+      this.selectedLength = this.selectedList.length
       this.myList = [...list]
       this.myList = [...list]
     }
     }
   },
   },

+ 6 - 3
src/views/PeopleManage/Agent/QuoteManagement.vue

@@ -116,7 +116,7 @@ export default {
       quoteForm: {
       quoteForm: {
         people: '',
         people: '',
         agentId: '',
         agentId: '',
-        companyId: ''
+        companyId: '',
       }, // 查询条件form
       }, // 查询条件form
       quoteData: [], // 列表数据
       quoteData: [], // 列表数据
       pageNum: 1,
       pageNum: 1,
@@ -147,8 +147,11 @@ export default {
     },
     },
     // 列表
     // 列表
     initData() {
     initData() {
-      this.$api.quote.quoteUserDetails({...this.quoteForm}).then(res => {
-        console.log(123, res.data)
+      this.$api.quote.quoteUserDetails({
+        pageNum: this.pageNum,
+        pageSize: this.pageSize,
+        ...this.quoteForm
+      }).then(res => {
         if(res.code === 200) {
         if(res.code === 200) {
           this.quoteData = res.data.records
           this.quoteData = res.data.records
           this.total = res.data.total
           this.total = res.data.total