Commit 6b6ec22bd73bd6e3602dc6155f492dcb4d5cf4b4

Authored by wdn127929
1 parent d9edaefb

selecttables

1 import 'package:one_key/models/table.dart'; 1 import 'package:one_key/models/table.dart';
  2 +import 'package:one_key/models/table.dart' as t;
2 3
3 class TableOuter { 4 class TableOuter {
4 String name; 5 String name;
@@ -6,6 +7,7 @@ class TableOuter { @@ -6,6 +7,7 @@ class TableOuter {
6 String rid; 7 String rid;
7 bool isSelect = false; //批量选择桌位 8 bool isSelect = false; //批量选择桌位
8 bool isAll = false; //全选 9 bool isAll = false; //全选
  10 + List<t.Table> selectTables = []; //选择的桌位
9 11
10 TableOuter(); 12 TableOuter();
11 13
@@ -261,11 +261,18 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> { @@ -261,11 +261,18 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> {
261 in tableManagerModel.tableOuterList[i].list) { 261 in tableManagerModel.tableOuterList[i].list) {
262 item.selected = false; 262 item.selected = false;
263 } 263 }
  264 + tableManagerModel.tableOuterList[i].selectTables = [];
264 //单选 265 //单选
265 setState(() { 266 setState(() {
266 table.selected = true; 267 table.selected = true;
267 }); 268 });
268 } 269 }
  270 + if (table.selected) {
  271 + tableManagerModel.tableOuterList[i].selectTables.add(table);
  272 + } else {
  273 + tableManagerModel.tableOuterList[i].selectTables
  274 + .removeWhere((t) => t.id == table.id);
  275 + }
269 }); 276 });
270 }, 277 },
271 ); 278 );
@@ -650,27 +657,45 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> { @@ -650,27 +657,45 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> {
650 : Row(children: [ 657 : Row(children: [
651 InkWell( 658 InkWell(
652 onTap: () { 659 onTap: () {
653 - for (t.Table item  
654 - in tableManagerModel 660 + tableManagerModel
655 .tableOuterList[ 661 .tableOuterList[
656 tableManagerModel 662 tableManagerModel
657 .selectNumber] 663 .selectNumber]
658 - .list) {  
659 - item.selected =  
660 - false;  
661 - }  
662 - setState(() {  
663 - tableManagerModel  
664 - .tableOuterList[  
665 - tableManagerModel  
666 - .selectNumber]  
667 - .isSelect =  
668 - !tableManagerModel 664 + .isSelect =
  665 + !tableManagerModel
  666 + .tableOuterList[
  667 + tableManagerModel
  668 + .selectNumber]
  669 + .isSelect;
  670 +
  671 + if (!tableManagerModel
  672 + .tableOuterList[
  673 + tableManagerModel
  674 + .selectNumber]
  675 + .isSelect &&
  676 + tableManagerModel
  677 + .tableOuterList[
  678 + tableManagerModel
  679 + .selectNumber]
  680 + .selectTables
  681 + .length >
  682 + 1) {
  683 + for (t.Table item
  684 + in tableManagerModel
669 .tableOuterList[ 685 .tableOuterList[
670 tableManagerModel 686 tableManagerModel
671 .selectNumber] 687 .selectNumber]
672 - .isSelect;  
673 - }); 688 + .list) {
  689 + item.selected =
  690 + false;
  691 + }
  692 + tableManagerModel
  693 + .tableOuterList[
  694 + tableManagerModel
  695 + .selectNumber]
  696 + .selectTables = [];
  697 + }
  698 + setState(() {});
674 }, 699 },
675 child: Row( 700 child: Row(
676 children: [ 701 children: [
@@ -709,6 +734,11 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> { @@ -709,6 +734,11 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> {
709 ? InkWell( 734 ? InkWell(
710 onTap: () { 735 onTap: () {
711 tableManagerModel 736 tableManagerModel
  737 + .tableOuterList[
  738 + tableManagerModel
  739 + .selectNumber]
  740 + .selectTables = [];
  741 + tableManagerModel
712 .tableOuterList[ 742 .tableOuterList[
713 tableManagerModel 743 tableManagerModel
714 .selectNumber] 744 .selectNumber]
@@ -730,6 +760,13 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> { @@ -730,6 +760,13 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> {
730 .list) { 760 .list) {
731 item.selected = 761 item.selected =
732 true; 762 true;
  763 + tableManagerModel
  764 + .tableOuterList[
  765 + tableManagerModel
  766 + .selectNumber]
  767 + .selectTables
  768 + .add(
  769 + item);
733 } 770 }
734 } else { 771 } else {
735 for (t.Table item 772 for (t.Table item
@@ -25,7 +25,7 @@ import 'notebook_model.dart'; @@ -25,7 +25,7 @@ import 'notebook_model.dart';
25 class MyTableManageHomeModel with ChangeNotifier { 25 class MyTableManageHomeModel with ChangeNotifier {
26 List<Area> areas = []; //区域列表 26 List<Area> areas = []; //区域列表
27 27
28 - List<t.Table> selectTables = []; //选择的桌位 28 + // List<t.Table> selectTables = []; //选择的桌位
29 29
30 List<TableOuter> tableOuterList = []; //区域-桌位列表 30 List<TableOuter> tableOuterList = []; //区域-桌位列表
31 31