Browse Source

设备管理选中优化

gzb
wangzhonglu 8 months ago
parent
commit
d9a4425008

+ 19
- 32
src/views/schoolSection/deviceManage/breakRuleDevice.vue View File

@@ -388,10 +388,7 @@ export default {
388 388
         name: this.searchForm.name
389 389
       }).then((data) => {
390 390
         if (data.code === 0) {
391
-          this.searchForm.list = data.obj.data || [];
392
-          this.searchForm.list.forEach((item) => {
393
-            item._checked = false;
394
-          });
391
+          this.searchForm.list = data.obj.data;
395 392
           this.searchForm.total = data.obj.total;
396 393
         } else {
397 394
           this.$Message.error(data.msg);
@@ -454,7 +451,18 @@ export default {
454 451
       });
455 452
     },
456 453
     selectionChange(selection) {
454
+      console.log("----selection--->", selection);
457 455
       this.tableSelection = selection;
456
+      let userid_sn = this.tableSelection.map((item) => {
457
+        return `${item.userid}_${item.sn}`;
458
+      });
459
+      this.searchForm.list.forEach((item) => {
460
+        if (userid_sn.includes(`${item.userid}_${item.sn}`)) {
461
+          item._checked = true;
462
+        } else {
463
+          item._checked = false;
464
+        }
465
+      });
458 466
     },
459 467
     // 表格行点击
460 468
     deviceTableRowClick(row, index) {
@@ -610,10 +618,7 @@ export default {
610 618
           this.$Message.error("推送失败");
611 619
         }
612 620
       });
613
-      this.tableSelection.forEach((item) => {
614
-        item._checked = false;
615
-      });
616
-      this.tableSelection = [];
621
+      this.$refs.deviceTable.selectAll(false);
617 622
       let form = {
618 623
         pushType: 6,
619 624
         pushObj: 1
@@ -653,10 +658,7 @@ export default {
653 658
             content: this.controlMessageInfo.content
654 659
           };
655 660
           form.userids = useridList;
656
-          this.tableSelection.forEach((item) => {
657
-            item._checked = false;
658
-          });
659
-          this.tableSelection = [];
661
+          this.$refs.deviceTable.selectAll(false);
660 662
           this.addPushLog(form);
661 663
         }
662 664
       });
@@ -676,10 +678,7 @@ export default {
676 678
           this.$Message.error("推送失败");
677 679
         }
678 680
       });
679
-      this.tableSelection.forEach((item) => {
680
-        item._checked = false;
681
-      });
682
-      this.tableSelection = [];
681
+      this.$refs.deviceTable.selectAll(false);
683 682
       let form = {
684 683
         pushType: 2,
685 684
         pushObj: 1
@@ -702,10 +701,7 @@ export default {
702 701
           this.$Message.error("推送失败");
703 702
         }
704 703
       });
705
-      this.tableSelection.forEach((item) => {
706
-        item._checked = false;
707
-      });
708
-      this.tableSelection = [];
704
+      this.$refs.deviceTable.selectAll(false);
709 705
       let form = {
710 706
         pushType: 3,
711 707
         pushObj: 1
@@ -728,10 +724,7 @@ export default {
728 724
           this.$Message.error("推送失败");
729 725
         }
730 726
       });
731
-      this.tableSelection.forEach((item) => {
732
-        item._checked = false;
733
-      });
734
-      this.tableSelection = [];
727
+      this.$refs.deviceTable.selectAll(false);
735 728
       let form = {
736 729
         pushType: 4,
737 730
         pushObj: 1
@@ -754,10 +747,7 @@ export default {
754 747
           this.$Message.error("推送失败");
755 748
         }
756 749
       });
757
-      this.tableSelection.forEach((item) => {
758
-        item._checked = false;
759
-      });
760
-      this.tableSelection = [];
750
+      this.$refs.deviceTable.selectAll(false);
761 751
       let form = {
762 752
         pushType: 5,
763 753
         pushObj: 1
@@ -780,10 +770,7 @@ export default {
780 770
           this.$Message.error("推送失败");
781 771
         }
782 772
       });
783
-      this.tableSelection.forEach((item) => {
784
-        item._checked = false;
785
-      });
786
-      this.tableSelection = [];
773
+      this.$refs.deviceTable.selectAll(false);
787 774
       let form = {
788 775
         pushType: 7,
789 776
         pushObj: 1

+ 19
- 36
src/views/schoolSection/deviceManage/deviceManage.vue View File

@@ -1062,10 +1062,7 @@ export default {
1062 1062
         name: this.searchForm.name
1063 1063
       }).then((data) => {
1064 1064
         if (data.code === 0) {
1065
-          this.searchForm.list = data.obj.data || [];
1066
-          this.searchForm.list.forEach((item) => {
1067
-            item._checked = false;
1068
-          });
1065
+          this.searchForm.list = data.obj.data;
1069 1066
           this.searchForm.total = data.obj.total;
1070 1067
         } else {
1071 1068
           this.$Message.error(data.msg);
@@ -1268,6 +1265,16 @@ export default {
1268 1265
     },
1269 1266
     selectionChange(selection) {
1270 1267
       this.tableSelection = selection;
1268
+      let userid_sn = this.tableSelection.map((item) => {
1269
+        return `${item.userid}_${item.sn}`;
1270
+      });
1271
+      this.searchForm.list.forEach((item) => {
1272
+        if (userid_sn.includes(`${item.userid}_${item.sn}`)) {
1273
+          item._checked = true;
1274
+        } else {
1275
+          item._checked = false;
1276
+        }
1277
+      });
1271 1278
     },
1272 1279
     // 表格行点击
1273 1280
     deviceTableRowClick(row, index) {
@@ -1453,10 +1460,7 @@ export default {
1453 1460
           this.$Message.error("推送失败");
1454 1461
         }
1455 1462
       });
1456
-      this.tableSelection.forEach((item) => {
1457
-        item._checked = false;
1458
-      });
1459
-      this.tableSelection = [];
1463
+      this.$refs.deviceTable.selectAll(false);
1460 1464
       let form = {
1461 1465
         pushType: 6,
1462 1466
         pushObj: 1
@@ -1500,10 +1504,7 @@ export default {
1500 1504
           } else {
1501 1505
             form.userids = useridList;
1502 1506
           }
1503
-          this.tableSelection.forEach((item) => {
1504
-            item._checked = false;
1505
-          });
1506
-          this.tableSelection = [];
1507
+          this.$refs.deviceTable.selectAll(false);
1507 1508
           this.addPushLog(form);
1508 1509
         }
1509 1510
       });
@@ -1523,10 +1524,7 @@ export default {
1523 1524
           this.$Message.error("推送失败");
1524 1525
         }
1525 1526
       });
1526
-      this.tableSelection.forEach((item) => {
1527
-        item._checked = false;
1528
-      });
1529
-      this.tableSelection = [];
1527
+      this.$refs.deviceTable.selectAll(false);
1530 1528
       let form = {
1531 1529
         pushType: 2,
1532 1530
         pushObj: 1
@@ -1549,10 +1547,7 @@ export default {
1549 1547
           this.$Message.error("推送失败");
1550 1548
         }
1551 1549
       });
1552
-      this.tableSelection.forEach((item) => {
1553
-        item._checked = false;
1554
-      });
1555
-      this.tableSelection = [];
1550
+      this.$refs.deviceTable.selectAll(false);
1556 1551
       let form = {
1557 1552
         pushType: 3,
1558 1553
         pushObj: 1
@@ -1575,10 +1570,7 @@ export default {
1575 1570
           this.$Message.error("推送失败");
1576 1571
         }
1577 1572
       });
1578
-      this.tableSelection.forEach((item) => {
1579
-        item._checked = false;
1580
-      });
1581
-      this.tableSelection = [];
1573
+      this.$refs.deviceTable.selectAll(false);
1582 1574
       let form = {
1583 1575
         pushType: 4,
1584 1576
         pushObj: 1
@@ -1601,10 +1593,7 @@ export default {
1601 1593
           this.$Message.error("推送失败");
1602 1594
         }
1603 1595
       });
1604
-      this.tableSelection.forEach((item) => {
1605
-        item._checked = false;
1606
-      });
1607
-      this.tableSelection = [];
1596
+      this.$refs.deviceTable.selectAll(false);
1608 1597
       let form = {
1609 1598
         pushType: 5,
1610 1599
         pushObj: 1
@@ -1627,10 +1616,7 @@ export default {
1627 1616
           this.$Message.error("推送失败");
1628 1617
         }
1629 1618
       });
1630
-      this.tableSelection.forEach((item) => {
1631
-        item._checked = false;
1632
-      });
1633
-      this.tableSelection = [];
1619
+      this.$refs.deviceTable.selectAll(false);
1634 1620
       let form = {
1635 1621
         pushType: 7,
1636 1622
         pushObj: 1
@@ -1653,10 +1639,7 @@ export default {
1653 1639
           this.$Message.error("推送失败");
1654 1640
         }
1655 1641
       });
1656
-      this.tableSelection.forEach((item) => {
1657
-        item._checked = false;
1658
-      });
1659
-      this.tableSelection = [];
1642
+      this.$refs.deviceTable.selectAll(false);
1660 1643
       let form = {
1661 1644
         pushType: 8,
1662 1645
         pushObj: 1

Loading…
Cancel
Save