|
1
|
import 'dart:ffi';
|
1
|
import 'dart:ffi';
|
|
2
|
|
2
|
|
|
|
|
3
|
+import 'package:dotted_border/dotted_border.dart';
|
|
3
|
import 'package:flutter/material.dart';
|
4
|
import 'package:flutter/material.dart';
|
|
4
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
5
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
5
|
import 'package:one_key/constant/state.dart';
|
6
|
import 'package:one_key/constant/state.dart';
|
|
@@ -12,6 +13,7 @@ import 'package:one_key/provider/notebook_detail_change_model.dart'; |
|
@@ -12,6 +13,7 @@ import 'package:one_key/provider/notebook_detail_change_model.dart'; |
|
12
|
import 'package:one_key/provider/notebook_model.dart';
|
13
|
import 'package:one_key/provider/notebook_model.dart';
|
|
13
|
import 'package:one_key/provider/user_model.dart';
|
14
|
import 'package:one_key/provider/user_model.dart';
|
|
14
|
import 'package:one_key/res/colors.dart';
|
15
|
import 'package:one_key/res/colors.dart';
|
|
|
|
16
|
+import 'package:one_key/utils/dialog_util.dart';
|
|
15
|
import 'package:one_key/utils/utils.dart';
|
17
|
import 'package:one_key/utils/utils.dart';
|
|
16
|
import 'package:one_key/widgets/app_bar.dart';
|
18
|
import 'package:one_key/widgets/app_bar.dart';
|
|
17
|
import 'package:one_key/widgets/area_item.dart';
|
19
|
import 'package:one_key/widgets/area_item.dart';
|
|
@@ -19,6 +21,7 @@ import 'package:one_key/widgets/common_button.dart'; |
|
@@ -19,6 +21,7 @@ import 'package:one_key/widgets/common_button.dart'; |
|
19
|
import 'package:one_key/widgets/page_exception.dart';
|
21
|
import 'package:one_key/widgets/page_exception.dart';
|
|
20
|
import 'package:one_key/widgets/table_item.dart';
|
22
|
import 'package:one_key/widgets/table_item.dart';
|
|
21
|
import 'package:one_key/models/table.dart' as t;
|
23
|
import 'package:one_key/models/table.dart' as t;
|
|
|
|
24
|
+import 'package:one_key/widgets/v_empty_view.dart';
|
|
22
|
import 'package:provider/provider.dart';
|
25
|
import 'package:provider/provider.dart';
|
|
23
|
import 'dart:convert' as convert;
|
26
|
import 'dart:convert' as convert;
|
|
24
|
|
27
|
|
|
@@ -52,24 +55,26 @@ class SelectTablePageState extends State<SelectTablePage> { |
|
@@ -52,24 +55,26 @@ class SelectTablePageState extends State<SelectTablePage> { |
|
52
|
Map<String, Notebook> tableMap = {}; //记录已预订桌位对应的订单
|
55
|
Map<String, Notebook> tableMap = {}; //记录已预订桌位对应的订单
|
|
53
|
|
56
|
|
|
54
|
String currentArea; //当前选中区域
|
57
|
String currentArea; //当前选中区域
|
|
|
|
58
|
+ List<String> personNumList = [];
|
|
55
|
|
59
|
|
|
56
|
@override
|
60
|
@override
|
|
57
|
void initState() {
|
61
|
void initState() {
|
|
58
|
// TODO: implement initState
|
62
|
// TODO: implement initState
|
|
59
|
super.initState();
|
63
|
super.initState();
|
|
|
|
64
|
+ for (int i = 1; i < 31; i++) {
|
|
|
|
65
|
+ personNumList.add(i.toString());
|
|
|
|
66
|
+ }
|
|
60
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
67
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
61
|
getTableList();
|
68
|
getTableList();
|
|
62
|
});
|
69
|
});
|
|
63
|
}
|
70
|
}
|
|
64
|
|
71
|
|
|
65
|
//获取桌位列表
|
72
|
//获取桌位列表
|
|
66
|
- getTableList() async {
|
73
|
+ getTableList({needLoading = true}) async {
|
|
67
|
UserModel userModel = Provider.of<UserModel>(context, listen: false);
|
74
|
UserModel userModel = Provider.of<UserModel>(context, listen: false);
|
|
68
|
Map<String, String> params = {"sellerid": userModel.user.sellerid};
|
75
|
Map<String, String> params = {"sellerid": userModel.user.sellerid};
|
|
69
|
- tableOuterList = await _chooseTableModel.getTableList(
|
|
|
|
70
|
- context,
|
|
|
|
71
|
- params,
|
|
|
|
72
|
- );
|
76
|
+ tableOuterList = await _chooseTableModel.getTableList(context, params,
|
|
|
|
77
|
+ needLoading: needLoading);
|
|
73
|
for (TableOuter item in tableOuterList) {
|
78
|
for (TableOuter item in tableOuterList) {
|
|
74
|
// if (item.name == "推荐") {
|
79
|
// if (item.name == "推荐") {
|
|
75
|
// itemModelList.remove(item);
|
80
|
// itemModelList.remove(item);
|
|
@@ -85,17 +90,30 @@ class SelectTablePageState extends State<SelectTablePage> { |
|
@@ -85,17 +90,30 @@ class SelectTablePageState extends State<SelectTablePage> { |
|
85
|
}
|
90
|
}
|
|
86
|
}
|
91
|
}
|
|
87
|
}
|
92
|
}
|
|
88
|
- if (tableOuterList.length == 0) {
|
|
|
|
89
|
- _chooseTableModel.pageState = PageState.Empty;
|
93
|
+ if (tableOuterList.isEmpty) {
|
|
|
|
94
|
+ _chooseTableModel.pageState = PageState.Success;
|
|
90
|
_chooseTableModel.notifyListeners();
|
95
|
_chooseTableModel.notifyListeners();
|
|
|
|
96
|
+ } else {
|
|
|
|
97
|
+ _getReserveList(userModel.user.sellerid, needLoading: needLoading);
|
|
91
|
}
|
98
|
}
|
|
92
|
- if (_chooseTableModel.pageState == PageState.Success) {
|
|
|
|
93
|
- _getReserveList(userModel.user.sellerid);
|
|
|
|
94
|
- }
|
99
|
+ // if (_chooseTableModel.pageState == PageState.Success) {
|
|
|
|
100
|
+
|
|
|
|
101
|
+ // }
|
|
|
|
102
|
+ }
|
|
|
|
103
|
+
|
|
|
|
104
|
+ refreshTable(context) async {
|
|
|
|
105
|
+ await getTableList(needLoading: false);
|
|
|
|
106
|
+ // if (temp.length > 0) {
|
|
|
|
107
|
+ // _getReserveList(context, needLoading: false);
|
|
|
|
108
|
+ // } else {
|
|
|
|
109
|
+ // // pageState = PageState.Empty;
|
|
|
|
110
|
+ // _chooseTableModel.pageState = PageState.Success;
|
|
|
|
111
|
+ // _chooseTableModel.notifyListeners();
|
|
|
|
112
|
+ // }
|
|
95
|
}
|
113
|
}
|
|
96
|
|
114
|
|
|
97
|
//获取已预订列表
|
115
|
//获取已预订列表
|
|
98
|
- _getReserveList(String sid) async {
|
116
|
+ _getReserveList(String sid, {needLoading = true}) async {
|
|
99
|
NoteBookModel model = new NoteBookModel();
|
117
|
NoteBookModel model = new NoteBookModel();
|
|
100
|
Map<String, String> params = {
|
118
|
Map<String, String> params = {
|
|
101
|
"sid": sid,
|
119
|
"sid": sid,
|
|
@@ -106,7 +124,8 @@ class SelectTablePageState extends State<SelectTablePage> { |
|
@@ -106,7 +124,8 @@ class SelectTablePageState extends State<SelectTablePage> { |
|
106
|
"keywords": "",
|
124
|
"keywords": "",
|
|
107
|
"sort": "1"
|
125
|
"sort": "1"
|
|
108
|
};
|
126
|
};
|
|
109
|
- List<Notebook> noteBooks = await model.getReserveList(context, params);
|
127
|
+ List<Notebook> noteBooks =
|
|
|
|
128
|
+ await model.getReserveList(context, params, needLoading: needLoading);
|
|
110
|
for (Notebook notebook in noteBooks) {
|
129
|
for (Notebook notebook in noteBooks) {
|
|
111
|
if (notebook.tid.isEmpty) continue;
|
130
|
if (notebook.tid.isEmpty) continue;
|
|
112
|
if (notebook.status == "1" ||
|
131
|
if (notebook.status == "1" ||
|
|
@@ -120,11 +139,17 @@ class SelectTablePageState extends State<SelectTablePage> { |
|
@@ -120,11 +139,17 @@ class SelectTablePageState extends State<SelectTablePage> { |
|
120
|
}
|
139
|
}
|
|
121
|
}
|
140
|
}
|
|
122
|
print(tableMap);
|
141
|
print(tableMap);
|
|
123
|
- initData();
|
142
|
+ if (needLoading) {
|
|
|
|
143
|
+ initData();
|
|
|
|
144
|
+ } else {
|
|
|
|
145
|
+ initData(needRetain: true);
|
|
|
|
146
|
+ }
|
|
124
|
}
|
147
|
}
|
|
125
|
|
148
|
|
|
126
|
//初始桌位数据
|
149
|
//初始桌位数据
|
|
127
|
- initData() {
|
150
|
+ initData({bool needRetain = false}) {
|
|
|
|
151
|
+ areas.clear();
|
|
|
|
152
|
+ areaTableMap.clear();
|
|
128
|
for (TableOuter outer in tableOuterList) {
|
153
|
for (TableOuter outer in tableOuterList) {
|
|
129
|
int count = 0;
|
154
|
int count = 0;
|
|
130
|
for (t.Table table in outer.list) {
|
155
|
for (t.Table table in outer.list) {
|
|
@@ -151,10 +176,18 @@ class SelectTablePageState extends State<SelectTablePage> { |
|
@@ -151,10 +176,18 @@ class SelectTablePageState extends State<SelectTablePage> { |
|
151
|
Area area = Area();
|
176
|
Area area = Area();
|
|
152
|
area.name = outer.name;
|
177
|
area.name = outer.name;
|
|
153
|
area.count = count;
|
178
|
area.count = count;
|
|
|
|
179
|
+ area.rid = outer.list.length == 0 ? outer.rid : outer.list[0].rid;
|
|
154
|
areas.add(area);
|
180
|
areas.add(area);
|
|
155
|
}
|
181
|
}
|
|
156
|
- currentArea = areaTableMap.keys.first;
|
|
|
|
157
|
- setState(() {});
|
182
|
+ if (!needRetain) {
|
|
|
|
183
|
+ currentArea = areaTableMap.keys.first;
|
|
|
|
184
|
+ }
|
|
|
|
185
|
+ if (areas.length == 1) {
|
|
|
|
186
|
+ currentArea = areaTableMap.keys.first;
|
|
|
|
187
|
+ }
|
|
|
|
188
|
+
|
|
|
|
189
|
+ _chooseTableModel.pageState = PageState.Success;
|
|
|
|
190
|
+ _chooseTableModel.notifyListeners();
|
|
158
|
}
|
191
|
}
|
|
159
|
|
192
|
|
|
160
|
//获取一天开始-结束时间字符串
|
193
|
//获取一天开始-结束时间字符串
|
|
@@ -214,14 +247,41 @@ class SelectTablePageState extends State<SelectTablePage> { |
|
@@ -214,14 +247,41 @@ class SelectTablePageState extends State<SelectTablePage> { |
|
214
|
color: MyColours.color_f1f1f1,
|
247
|
color: MyColours.color_f1f1f1,
|
|
215
|
child: ListView.builder(
|
248
|
child: ListView.builder(
|
|
216
|
itemBuilder: (context, index) {
|
249
|
itemBuilder: (context, index) {
|
|
217
|
- return AreaItem(areas[index], currentArea, (area) {
|
|
|
|
218
|
- setState(() {
|
|
|
|
219
|
- currentArea = (area as Area).name;
|
250
|
+ if (areas.isEmpty || index == areas.length) {
|
|
|
|
251
|
+ return InkWell(
|
|
|
|
252
|
+ onTap: () async {
|
|
|
|
253
|
+ //添加区域弹框
|
|
|
|
254
|
+ await DialogUtil.openCreateAreaDialog(context,
|
|
|
|
255
|
+ onTap: (value) async {
|
|
|
|
256
|
+ print(value);
|
|
|
|
257
|
+ //添加区域
|
|
|
|
258
|
+ bool success = await _chooseTableModel
|
|
|
|
259
|
+ .addTableAreas(context, value);
|
|
|
|
260
|
+ print(success);
|
|
|
|
261
|
+ if (success) {
|
|
|
|
262
|
+ Utils.showToast('添加成功!');
|
|
|
|
263
|
+
|
|
|
|
264
|
+ await getTableList(needLoading: false);
|
|
|
|
265
|
+ }
|
|
|
|
266
|
+ });
|
|
|
|
267
|
+ },
|
|
|
|
268
|
+ child: Center(
|
|
|
|
269
|
+ child: Image.asset(
|
|
|
|
270
|
+ Utils.getImgPath('add_area'),
|
|
|
|
271
|
+ width: ScreenUtil().setWidth(32)),
|
|
|
|
272
|
+ ),
|
|
|
|
273
|
+ );
|
|
|
|
274
|
+ } else {
|
|
|
|
275
|
+ return AreaItem(areas[index], currentArea,
|
|
|
|
276
|
+ (area) {
|
|
|
|
277
|
+ setState(() {
|
|
|
|
278
|
+ currentArea = (area as Area).name;
|
|
|
|
279
|
+ });
|
|
220
|
});
|
280
|
});
|
|
221
|
- });
|
281
|
+ }
|
|
222
|
},
|
282
|
},
|
|
223
|
itemExtent: ScreenUtil().setHeight(207),
|
283
|
itemExtent: ScreenUtil().setHeight(207),
|
|
224
|
- itemCount: areas.length,
|
284
|
+ itemCount: areas.length + 1,
|
|
225
|
),
|
285
|
),
|
|
226
|
),
|
286
|
),
|
|
227
|
Expanded(
|
287
|
Expanded(
|
|
@@ -238,26 +298,127 @@ class SelectTablePageState extends State<SelectTablePage> { |
|
@@ -238,26 +298,127 @@ class SelectTablePageState extends State<SelectTablePage> { |
|
238
|
crossAxisCount: 3,
|
298
|
crossAxisCount: 3,
|
|
239
|
childAspectRatio: 8 / 9),
|
299
|
childAspectRatio: 8 / 9),
|
|
240
|
itemBuilder: (context, index) {
|
300
|
itemBuilder: (context, index) {
|
|
241
|
- return TableItem(
|
|
|
|
242
|
- areaTableMap[currentArea][index],
|
|
|
|
243
|
- onSelected: (table) {
|
|
|
|
244
|
- if ((table as t.Table).selected) {
|
|
|
|
245
|
- selectTables.add(table);
|
|
|
|
246
|
- widget.tableList
|
|
|
|
247
|
- .add(tableToTableList(table));
|
|
|
|
248
|
- } else {
|
|
|
|
249
|
- widget.tableList.removeWhere(
|
|
|
|
250
|
- (t) => t.id == table.id);
|
|
|
|
251
|
- selectTables.removeWhere(
|
|
|
|
252
|
- (t) => t.id == table.id);
|
|
|
|
253
|
- }
|
|
|
|
254
|
- },
|
|
|
|
255
|
- canSelected: true,
|
|
|
|
256
|
- fromPage: 'change',
|
|
|
|
257
|
- tableMap: tableMap,
|
|
|
|
258
|
- rid: widget.rid);
|
301
|
+ if (index ==
|
|
|
|
302
|
+ areaTableMap[currentArea].length ||
|
|
|
|
303
|
+ areaTableMap[currentArea].length == 0) {
|
|
|
|
304
|
+ return InkWell(
|
|
|
|
305
|
+ onTap: () async {
|
|
|
|
306
|
+ List<String> areasTemp = [];
|
|
|
|
307
|
+ for (int i = 0;
|
|
|
|
308
|
+ i < areas.length;
|
|
|
|
309
|
+ i++) {
|
|
|
|
310
|
+ areasTemp.add(areas[i].name);
|
|
|
|
311
|
+ }
|
|
|
|
312
|
+
|
|
|
|
313
|
+ //添加桌位弹框
|
|
|
|
314
|
+ await DialogUtil
|
|
|
|
315
|
+ .openCreateTableDialog(
|
|
|
|
316
|
+ context,
|
|
|
|
317
|
+ areasTemp,
|
|
|
|
318
|
+ areasTemp
|
|
|
|
319
|
+ .indexOf(currentArea),
|
|
|
|
320
|
+ personNumList, onTap:
|
|
|
|
321
|
+ (Map<String, String>
|
|
|
|
322
|
+ value) async {
|
|
|
|
323
|
+ print(value);
|
|
|
|
324
|
+ // 'areaname':
|
|
|
|
325
|
+ // areas[currentAreaIndex],
|
|
|
|
326
|
+ // 'name': controller.text,
|
|
|
|
327
|
+ // 'pnumMin': pnumMin,
|
|
|
|
328
|
+ // 'pnumMax': pnumMax
|
|
|
|
329
|
+ //添加桌位 接口参数带整合???
|
|
|
|
330
|
+ // 以下是旧的不去,明天添加桌位接口
|
|
|
|
331
|
+ String rid;
|
|
|
|
332
|
+ for (Area item in areas) {
|
|
|
|
333
|
+ if (item.name ==
|
|
|
|
334
|
+ value['areaname']) {
|
|
|
|
335
|
+ rid = item.rid;
|
|
|
|
336
|
+ }
|
|
|
|
337
|
+ }
|
|
|
|
338
|
+ Map<String, String> params = {
|
|
|
|
339
|
+ 'rid': rid,
|
|
|
|
340
|
+ 'name': value['name'],
|
|
|
|
341
|
+ };
|
|
|
|
342
|
+ if (value['pnumMin'] != '') {
|
|
|
|
343
|
+ params['pnum'] =
|
|
|
|
344
|
+ value['pnumMin'];
|
|
|
|
345
|
+ }
|
|
|
|
346
|
+ if (value['pnumMax'] != '') {
|
|
|
|
347
|
+ params['most_pnum'] =
|
|
|
|
348
|
+ value['pnumMax'];
|
|
|
|
349
|
+ }
|
|
|
|
350
|
+ bool success =
|
|
|
|
351
|
+ await _chooseTableModel
|
|
|
|
352
|
+ .addTable(
|
|
|
|
353
|
+ context, params);
|
|
|
|
354
|
+ print(success);
|
|
|
|
355
|
+ if (success) {
|
|
|
|
356
|
+ Utils.showToast('添加成功!');
|
|
|
|
357
|
+ refreshTable(context);
|
|
|
|
358
|
+ }
|
|
|
|
359
|
+ });
|
|
|
|
360
|
+ },
|
|
|
|
361
|
+ child: Container(
|
|
|
|
362
|
+ margin: EdgeInsets.all(
|
|
|
|
363
|
+ ScreenUtil().setWidth(15)),
|
|
|
|
364
|
+ child: DottedBorder(
|
|
|
|
365
|
+ dashPattern: [5, 5, 5, 5],
|
|
|
|
366
|
+ borderType: BorderType.RRect,
|
|
|
|
367
|
+ radius: Radius.circular(
|
|
|
|
368
|
+ ScreenUtil().setWidth(10)),
|
|
|
|
369
|
+ // padding: EdgeInsets.all(ScreenUtil().setWidth(70)),
|
|
|
|
370
|
+ color: MyColours.color_199095,
|
|
|
|
371
|
+ strokeWidth:
|
|
|
|
372
|
+ ScreenUtil().setWidth(2),
|
|
|
|
373
|
+ child: ClipRRect(
|
|
|
|
374
|
+ borderRadius: BorderRadius
|
|
|
|
375
|
+ .all(Radius.circular(
|
|
|
|
376
|
+ ScreenUtil()
|
|
|
|
377
|
+ .setWidth(10))),
|
|
|
|
378
|
+ child: Container(
|
|
|
|
379
|
+ height: ScreenUtil()
|
|
|
|
380
|
+ .setWidth(90 * 2),
|
|
|
|
381
|
+ width: ScreenUtil()
|
|
|
|
382
|
+ .setWidth(80 * 2),
|
|
|
|
383
|
+ child: Column(
|
|
|
|
384
|
+ mainAxisAlignment:
|
|
|
|
385
|
+ MainAxisAlignment
|
|
|
|
386
|
+ .center,
|
|
|
|
387
|
+ children: [
|
|
|
|
388
|
+ Image.asset(
|
|
|
|
389
|
+ Utils.getImgPath(
|
|
|
|
390
|
+ 'add_area'),
|
|
|
|
391
|
+ width: ScreenUtil()
|
|
|
|
392
|
+ .setWidth(32)),
|
|
|
|
393
|
+ ],
|
|
|
|
394
|
+ ),
|
|
|
|
395
|
+ ),
|
|
|
|
396
|
+ ),
|
|
|
|
397
|
+ )));
|
|
|
|
398
|
+ } else {
|
|
|
|
399
|
+ return TableItem(
|
|
|
|
400
|
+ areaTableMap[currentArea][index],
|
|
|
|
401
|
+ onSelected: (table) {
|
|
|
|
402
|
+ if ((table as t.Table).selected) {
|
|
|
|
403
|
+ selectTables.add(table);
|
|
|
|
404
|
+ widget.tableList
|
|
|
|
405
|
+ .add(tableToTableList(table));
|
|
|
|
406
|
+ } else {
|
|
|
|
407
|
+ widget.tableList.removeWhere(
|
|
|
|
408
|
+ (t) => t.id == table.id);
|
|
|
|
409
|
+ selectTables.removeWhere(
|
|
|
|
410
|
+ (t) => t.id == table.id);
|
|
|
|
411
|
+ }
|
|
|
|
412
|
+ },
|
|
|
|
413
|
+ canSelected: true,
|
|
|
|
414
|
+ fromPage: 'change',
|
|
|
|
415
|
+ tableMap: tableMap,
|
|
|
|
416
|
+ rid: widget.rid);
|
|
|
|
417
|
+ }
|
|
259
|
},
|
418
|
},
|
|
260
|
- itemCount: areaTableMap[currentArea].length,
|
419
|
+ itemCount: currentArea == null
|
|
|
|
420
|
+ ? 0
|
|
|
|
421
|
+ : areaTableMap[currentArea].length + 1,
|
|
261
|
)),
|
422
|
)),
|
|
262
|
Container(
|
423
|
Container(
|
|
263
|
width: double.infinity,
|
424
|
width: double.infinity,
|