Commit 712ebb2ac2abd70e71a72d8e72ac51375f93e315

Authored by wdn127929
1 parent 6b531ae0

已预订列表,桌子或者桌子所属区域比对不上的订单排序放在后面

Showing 1 changed file with 61 additions and 30 deletions
@@ -24,7 +24,7 @@ class NoteBookModel extends ChangeNotifier { @@ -24,7 +24,7 @@ class NoteBookModel extends ChangeNotifier {
24 24
25 bool isSimple = true; 25 bool isSimple = true;
26 26
27 - //获取已预订订单 27 + //获取已预订订单
28 Future<List<Notebook>> getReserveList( 28 Future<List<Notebook>> getReserveList(
29 BuildContext context, Map<String, String> params, 29 BuildContext context, Map<String, String> params,
30 {bool needLoading = false, bool showLoading = true}) async { 30 {bool needLoading = false, bool showLoading = true}) async {
@@ -66,16 +66,16 @@ class NoteBookModel extends ChangeNotifier { @@ -66,16 +66,16 @@ class NoteBookModel extends ChangeNotifier {
66 pageState = PageState.Empty; 66 pageState = PageState.Empty;
67 } else { 67 } else {
68 if (notebooks.length > 0) { 68 if (notebooks.length > 0) {
69 - if (isSimple) {  
70 - for (Notebook item in notebooks) {  
71 - item.issimple = true;  
72 - }  
73 - } else {  
74 - for (Notebook item in notebooks) {  
75 - item.issimple = false; 69 + if (isSimple) {
  70 + for (Notebook item in notebooks) {
  71 + item.issimple = true;
  72 + }
  73 + } else {
  74 + for (Notebook item in notebooks) {
  75 + item.issimple = false;
  76 + }
  77 + }
76 } 78 }
77 - }  
78 - }  
79 pageState = PageState.Success; 79 pageState = PageState.Success;
80 } 80 }
81 } else { 81 } else {
@@ -85,7 +85,6 @@ class NoteBookModel extends ChangeNotifier { @@ -85,7 +85,6 @@ class NoteBookModel extends ChangeNotifier {
85 return notebooks; 85 return notebooks;
86 } 86 }
87 87
88 -  
89 //获取已预订订单 88 //获取已预订订单
90 Future<List<Notebook>> getReserveListSort( 89 Future<List<Notebook>> getReserveListSort(
91 BuildContext context, Map<String, String> params, 90 BuildContext context, Map<String, String> params,
@@ -131,6 +130,7 @@ class NoteBookModel extends ChangeNotifier { @@ -131,6 +130,7 @@ class NoteBookModel extends ChangeNotifier {
131 130
132 await tableManagerModel.getTableList(context); 131 await tableManagerModel.getTableList(context);
133 List<Notebook> temp = []; //其余订单排序 132 List<Notebook> temp = []; //其余订单排序
  133 + List<Notebook> tempNo = []; //区域或者桌子被删除的订单排序
134 List<Notebook> tempLast = []; //3、4、6订单放在最后 134 List<Notebook> tempLast = []; //3、4、6订单放在最后
135 print(notebooks); 135 print(notebooks);
136 notebooks.forEach((notebook) { 136 notebooks.forEach((notebook) {
@@ -138,17 +138,46 @@ class NoteBookModel extends ChangeNotifier { @@ -138,17 +138,46 @@ class NoteBookModel extends ChangeNotifier {
138 if (notebook.status != '3' && 138 if (notebook.status != '3' &&
139 notebook.status != '4' && 139 notebook.status != '4' &&
140 notebook.status != '6') { 140 notebook.status != '6') {
141 - tableManagerModel.tableOuterList.forEach((elementAll) {  
142 - if (notebook.tableinfoList[0].rid == elementAll.rid) { //区域id  
143 - elementAll.list.forEach((element) {  
144 - if (notebook.tableinfoList[0].id == element.id) { 141 + //区域ID存在
  142 + bool tempArea = tableManagerModel.tableOuterList.any(
  143 + (element) => element.rid == notebook.tableinfoList[0].rid);
  144 +
  145 + //桌子id存在
  146 + List tables = tableManagerModel.tableOuterList
  147 + .where(
  148 + (element) => element.rid == notebook.tableinfoList[0].rid)
  149 + .toList();
  150 + bool tempTable = false;
  151 + if (tables != null && tables.length > 0) {
  152 + tempTable = tables[0].list.any(
  153 + (element) => element.id == notebook.tableinfoList[0].id);
  154 + }
  155 +
  156 + if (tempArea && tempTable) {
  157 + tableManagerModel.tableOuterList.forEach((elementAll) {
  158 + //订单第一个桌子的区域存在
  159 + if (notebook.tableinfoList[0].rid == elementAll.rid) {
  160 + //桌子id存在
  161 + bool tempTable = elementAll.list.any((element) =>
  162 + element.id == notebook.tableinfoList[0].id);
  163 + if (tempTable) {
  164 + elementAll.list.forEach((element) {
  165 + if (notebook.tableinfoList[0].id == element.id) {
145 //桌子ID 166 //桌子ID
146 - element.notebook = notebook; 167 + element.notebook = notebook;
147 // 168 //
  169 + }
  170 + });
  171 + } else {
  172 + //订单第一个桌子不存在
  173 + tempNo.add(notebook);
148 } 174 }
149 - });  
150 - }  
151 - }); 175 + }
  176 + });
  177 + } else {
  178 + //订单第一个桌子的区域不存在
  179 + tempNo.add(notebook);
  180 + }
152 } else { 181 } else {
153 tempLast.add(notebook); 182 tempLast.add(notebook);
154 } 183 }
@@ -169,22 +198,24 @@ class NoteBookModel extends ChangeNotifier { @@ -169,22 +198,24 @@ class NoteBookModel extends ChangeNotifier {
169 print(notebooks); 198 print(notebooks);
170 199
171 notebooks = temp.toList(); 200 notebooks = temp.toList();
  201 +
  202 + notebooks.addAll(tempNo);
172 notebooks.addAll(tempLast); 203 notebooks.addAll(tempLast);
173 204
174 // tableManagerModel.tableOuterList //桌子 205 // tableManagerModel.tableOuterList //桌子
175 // tableManagerModel.areaSunModelList //区域 206 // tableManagerModel.areaSunModelList //区域
176 207
177 - if (notebooks.length > 0) {  
178 - if (isSimple) {  
179 - for (Notebook item in notebooks) {  
180 - item.issimple = true;  
181 - }  
182 - } else {  
183 - for (Notebook item in notebooks) {  
184 - item.issimple = false; 208 + if (notebooks.length > 0) {
  209 + if (isSimple) {
  210 + for (Notebook item in notebooks) {
  211 + item.issimple = true;
  212 + }
  213 + } else {
  214 + for (Notebook item in notebooks) {
  215 + item.issimple = false;
  216 + }
  217 + }
185 } 218 }
186 - }  
187 - }  
188 219
189 pageState = PageState.Success; 220 pageState = PageState.Success;
190 } 221 }
@@ -196,7 +227,7 @@ class NoteBookModel extends ChangeNotifier { @@ -196,7 +227,7 @@ class NoteBookModel extends ChangeNotifier {
196 return notebooks; 227 return notebooks;
197 } 228 }
198 229
199 - simpleState() { 230 + simpleState() {
200 if (notebooks.length > 0) { 231 if (notebooks.length > 0) {
201 if (isSimple) { 232 if (isSimple) {
202 for (Notebook item in notebooks) { 233 for (Notebook item in notebooks) {