|
|
|
1
|
+import 'dart:async';
|
|
|
|
2
|
+
|
|
1
|
import 'package:common_utils/common_utils.dart';
|
3
|
import 'package:common_utils/common_utils.dart';
|
|
|
|
4
|
+import 'package:dotted_border/dotted_border.dart';
|
|
2
|
import 'package:flutter/material.dart';
|
5
|
import 'package:flutter/material.dart';
|
|
3
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
6
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
4
|
import 'package:one_key/constant/state.dart';
|
7
|
import 'package:one_key/constant/state.dart';
|
|
5
|
import 'package:one_key/models/area.dart';
|
8
|
import 'package:one_key/models/area.dart';
|
|
6
|
import 'package:one_key/models/notebook_detail.dart';
|
9
|
import 'package:one_key/models/notebook_detail.dart';
|
|
|
|
10
|
+import 'package:one_key/models/tableOuter.dart';
|
|
|
|
11
|
+import 'package:one_key/pages/table/area_item_table.dart';
|
|
7
|
import 'package:one_key/provider/table_manager_model.dart';
|
12
|
import 'package:one_key/provider/table_manager_model.dart';
|
|
8
|
import 'package:one_key/res/colors.dart';
|
13
|
import 'package:one_key/res/colors.dart';
|
|
9
|
import 'package:one_key/utils/dialog_util.dart';
|
14
|
import 'package:one_key/utils/dialog_util.dart';
|
|
10
|
import 'package:one_key/utils/event_bus.dart';
|
15
|
import 'package:one_key/utils/event_bus.dart';
|
|
11
|
import 'package:one_key/route/navigator_util.dart';
|
16
|
import 'package:one_key/route/navigator_util.dart';
|
|
|
|
17
|
+import 'package:one_key/utils/utils.dart';
|
|
12
|
import 'package:one_key/widgets/MyDivider.dart';
|
18
|
import 'package:one_key/widgets/MyDivider.dart';
|
|
13
|
import 'package:one_key/widgets/app_bar.dart';
|
19
|
import 'package:one_key/widgets/app_bar.dart';
|
|
14
|
import 'package:one_key/widgets/area_item.dart';
|
20
|
import 'package:one_key/widgets/area_item.dart';
|
|
@@ -17,8 +23,12 @@ import 'package:one_key/widgets/page_exception.dart'; |
|
@@ -17,8 +23,12 @@ import 'package:one_key/widgets/page_exception.dart'; |
|
17
|
import 'package:one_key/widgets/system_app_bar.dart';
|
23
|
import 'package:one_key/widgets/system_app_bar.dart';
|
|
18
|
import 'package:one_key/widgets/table_item.dart';
|
24
|
import 'package:one_key/widgets/table_item.dart';
|
|
19
|
import 'package:one_key/models/table.dart' as t;
|
25
|
import 'package:one_key/models/table.dart' as t;
|
|
|
|
26
|
+import 'package:one_key/widgets/v_empty_view.dart';
|
|
20
|
import 'package:provider/provider.dart';
|
27
|
import 'package:provider/provider.dart';
|
|
21
|
import 'dart:convert' as convert;
|
28
|
import 'dart:convert' as convert;
|
|
|
|
29
|
+import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
|
|
|
|
30
|
+
|
|
|
|
31
|
+const scrollDuration = Duration(microseconds: 500);
|
|
22
|
|
32
|
|
|
23
|
class TableManagerPage extends StatefulWidget {
|
33
|
class TableManagerPage extends StatefulWidget {
|
|
24
|
@override
|
34
|
@override
|
|
@@ -30,6 +40,15 @@ class TableManagerPage extends StatefulWidget { |
|
@@ -30,6 +40,15 @@ class TableManagerPage extends StatefulWidget { |
|
30
|
|
40
|
|
|
31
|
class TableManagerPageState extends State<TableManagerPage> {
|
41
|
class TableManagerPageState extends State<TableManagerPage> {
|
|
32
|
TableManagerModel tableManagerModel;
|
42
|
TableManagerModel tableManagerModel;
|
|
|
|
43
|
+ final ItemScrollController itemScrollController = ItemScrollController();
|
|
|
|
44
|
+ bool isTap = false;
|
|
|
|
45
|
+ int min;
|
|
|
|
46
|
+ int max;
|
|
|
|
47
|
+ int _selectIndex;
|
|
|
|
48
|
+ ScrollController _areaController = ScrollController();
|
|
|
|
49
|
+
|
|
|
|
50
|
+ final ItemPositionsListener itemPositionsListener =
|
|
|
|
51
|
+ ItemPositionsListener.create();
|
|
33
|
|
52
|
|
|
34
|
@override
|
53
|
@override
|
|
35
|
void initState() {
|
54
|
void initState() {
|
|
@@ -42,10 +61,159 @@ class TableManagerPageState extends State<TableManagerPage> { |
|
@@ -42,10 +61,159 @@ class TableManagerPageState extends State<TableManagerPage> { |
|
42
|
EventBus().on("refresh_tablemanager", (arg) {
|
61
|
EventBus().on("refresh_tablemanager", (arg) {
|
|
43
|
//订座-完成预订 刷新管理桌位
|
62
|
//订座-完成预订 刷新管理桌位
|
|
44
|
tableManagerModel.getReserveList(context);
|
63
|
tableManagerModel.getReserveList(context);
|
|
|
|
64
|
+ print(tableManagerModel);
|
|
45
|
});
|
65
|
});
|
|
46
|
});
|
66
|
});
|
|
47
|
}
|
67
|
}
|
|
48
|
|
68
|
|
|
|
|
69
|
+ Widget list(List data) => ScrollablePositionedList.builder(
|
|
|
|
70
|
+ itemCount: data.length,
|
|
|
|
71
|
+ itemBuilder: (context, index) => item(index),
|
|
|
|
72
|
+ itemScrollController: itemScrollController,
|
|
|
|
73
|
+ itemPositionsListener: itemPositionsListener,
|
|
|
|
74
|
+ reverse: false,
|
|
|
|
75
|
+ scrollDirection: Axis.vertical,
|
|
|
|
76
|
+ );
|
|
|
|
77
|
+
|
|
|
|
78
|
+ void scrollTo(int index) => itemScrollController.scrollTo(
|
|
|
|
79
|
+ index: index,
|
|
|
|
80
|
+ duration: scrollDuration,
|
|
|
|
81
|
+ curve: Curves.easeInOutCubic,
|
|
|
|
82
|
+ alignment: 0);
|
|
|
|
83
|
+
|
|
|
|
84
|
+ void jumpTo(int index) =>
|
|
|
|
85
|
+ itemScrollController.jumpTo(index: index, alignment: 0);
|
|
|
|
86
|
+
|
|
|
|
87
|
+ /// Generate item number [i].
|
|
|
|
88
|
+ Widget item(int i) {
|
|
|
|
89
|
+ int heightSum;
|
|
|
|
90
|
+ int length =
|
|
|
|
91
|
+ tableManagerModel.areaTableMap[tableManagerModel.areas[i].name].length;
|
|
|
|
92
|
+ if (length % 4 == 0) {
|
|
|
|
93
|
+ heightSum = (length / 4).floor();
|
|
|
|
94
|
+ } else {
|
|
|
|
95
|
+ heightSum = (length / 4).floor() + 1;
|
|
|
|
96
|
+ }
|
|
|
|
97
|
+ return Container(
|
|
|
|
98
|
+ height: ScreenUtil().setWidth(185) * heightSum +
|
|
|
|
99
|
+ heightSum * 10 +
|
|
|
|
100
|
+ ScreenUtil().setWidth(60 * 2),
|
|
|
|
101
|
+ child: Column(
|
|
|
|
102
|
+ children: [
|
|
|
|
103
|
+ Container(
|
|
|
|
104
|
+ alignment: Alignment.center,
|
|
|
|
105
|
+ height: ScreenUtil().setWidth(30 * 2),
|
|
|
|
106
|
+ child: Text(tableManagerModel.areas[i].name,
|
|
|
|
107
|
+ style: TextStyle(
|
|
|
|
108
|
+ fontSize: ScreenUtil().setWidth(30),
|
|
|
|
109
|
+ color: MyColours.color_666666)),
|
|
|
|
110
|
+ ),
|
|
|
|
111
|
+ Container(
|
|
|
|
112
|
+ constraints: BoxConstraints(
|
|
|
|
113
|
+ minHeight: ScreenUtil().setWidth(185) * heightSum),
|
|
|
|
114
|
+ height: ScreenUtil().setWidth(200) * heightSum + heightSum * 10,
|
|
|
|
115
|
+ child: GridView.builder(
|
|
|
|
116
|
+ physics: NeverScrollableScrollPhysics(),
|
|
|
|
117
|
+ gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
118
|
+ crossAxisCount: 4,
|
|
|
|
119
|
+ childAspectRatio: 8 / 9,
|
|
|
|
120
|
+ ),
|
|
|
|
121
|
+ itemBuilder: (context, index) {
|
|
|
|
122
|
+ return Selector<TableManagerModel, t.Table>(
|
|
|
|
123
|
+ shouldRebuild: (pre, next) => true,
|
|
|
|
124
|
+ selector: (context, model) => model.currentTables[index],
|
|
|
|
125
|
+ builder: (context, table, _) {
|
|
|
|
126
|
+ return TableItem(table, onSelected: (table) {
|
|
|
|
127
|
+ if ((table as t.Table).selected) {
|
|
|
|
128
|
+ tableManagerModel.selectTables.add(table);
|
|
|
|
129
|
+ } else {
|
|
|
|
130
|
+ tableManagerModel.selectTables
|
|
|
|
131
|
+ .removeWhere((t) => t.id == table.id);
|
|
|
|
132
|
+ }
|
|
|
|
133
|
+ DialogUtil.showTableManagerDialog(context, table)
|
|
|
|
134
|
+ .then((value) {
|
|
|
|
135
|
+ if (value != null) {
|
|
|
|
136
|
+ switch (value) {
|
|
|
|
137
|
+ case 1: //查看详情
|
|
|
|
138
|
+ NavigatorUtil.goNotebookDetailPage(context,
|
|
|
|
139
|
+ tableManagerModel.tableMap[table.id].id);
|
|
|
|
140
|
+ break;
|
|
|
|
141
|
+ case 2: //订座
|
|
|
|
142
|
+ NavigatorUtil.goNoteBookChangePage(
|
|
|
|
143
|
+ context,
|
|
|
|
144
|
+ NotebookDetail.fromTableManager(
|
|
|
|
145
|
+ tableManagerModel.getCurrDdateStr(),
|
|
|
|
146
|
+ tableManagerModel.currTimeIndex
|
|
|
|
147
|
+ .toString(),
|
|
|
|
148
|
+ table),
|
|
|
|
149
|
+ "");
|
|
|
|
150
|
+ break;
|
|
|
|
151
|
+ case 3: //停用,启用桌位
|
|
|
|
152
|
+ Map<String, String> params = {
|
|
|
|
153
|
+ "id": (table as t.Table).id,
|
|
|
|
154
|
+ "status": (table as t.Table).enable == "1"
|
|
|
|
155
|
+ ? "0"
|
|
|
|
156
|
+ : "1"
|
|
|
|
157
|
+ };
|
|
|
|
158
|
+ tableManagerModel
|
|
|
|
159
|
+ .setSwitchStatus(context, params)
|
|
|
|
160
|
+ .then((value) {
|
|
|
|
161
|
+ if (value != null) {
|
|
|
|
162
|
+ (table as t.Table).enable = ((int.parse(
|
|
|
|
163
|
+ (table as t.Table)
|
|
|
|
164
|
+ .enable) +
|
|
|
|
165
|
+ 1) %
|
|
|
|
166
|
+ 2)
|
|
|
|
167
|
+ .toString();
|
|
|
|
168
|
+ if ((table as t.Table).enable == "1") {
|
|
|
|
169
|
+ for (Area area
|
|
|
|
170
|
+ in tableManagerModel.areas) {
|
|
|
|
171
|
+ if (area.name ==
|
|
|
|
172
|
+ tableManagerModel.currentArea) {
|
|
|
|
173
|
+ if (table.sign != '5' &&
|
|
|
|
174
|
+ table.sign != '1') {
|
|
|
|
175
|
+ //已预订
|
|
|
|
176
|
+ area.count++;
|
|
|
|
177
|
+ }
|
|
|
|
178
|
+ break;
|
|
|
|
179
|
+ }
|
|
|
|
180
|
+ }
|
|
|
|
181
|
+ } else {
|
|
|
|
182
|
+ for (Area area
|
|
|
|
183
|
+ in tableManagerModel.areas) {
|
|
|
|
184
|
+ if (area.name ==
|
|
|
|
185
|
+ tableManagerModel.currentArea) {
|
|
|
|
186
|
+ if (table.sign != '5' &&
|
|
|
|
187
|
+ table.sign != '1') {
|
|
|
|
188
|
+ //已预订
|
|
|
|
189
|
+ area.count--;
|
|
|
|
190
|
+ }
|
|
|
|
191
|
+ break;
|
|
|
|
192
|
+ }
|
|
|
|
193
|
+ }
|
|
|
|
194
|
+ }
|
|
|
|
195
|
+ tableManagerModel.notifyListeners();
|
|
|
|
196
|
+ }
|
|
|
|
197
|
+ });
|
|
|
|
198
|
+ break;
|
|
|
|
199
|
+ }
|
|
|
|
200
|
+ }
|
|
|
|
201
|
+ });
|
|
|
|
202
|
+ },
|
|
|
|
203
|
+ canSelected: false,
|
|
|
|
204
|
+ fromPage: 'table_manage',
|
|
|
|
205
|
+ tableMap: tableManagerModel.tableMap,
|
|
|
|
206
|
+ rid: "");
|
|
|
|
207
|
+ },
|
|
|
|
208
|
+ );
|
|
|
|
209
|
+ },
|
|
|
|
210
|
+ itemCount: tableManagerModel
|
|
|
|
211
|
+ .areaTableMap[tableManagerModel.areas[i].name].length,
|
|
|
|
212
|
+ )),
|
|
|
|
213
|
+ ],
|
|
|
|
214
|
+ ));
|
|
|
|
215
|
+ }
|
|
|
|
216
|
+
|
|
49
|
@override
|
217
|
@override
|
|
50
|
Widget build(BuildContext context) {
|
218
|
Widget build(BuildContext context) {
|
|
51
|
return Consumer<TableManagerModel>(
|
219
|
return Consumer<TableManagerModel>(
|
|
@@ -171,11 +339,6 @@ class TableManagerPageState extends State<TableManagerPage> { |
|
@@ -171,11 +339,6 @@ class TableManagerPageState extends State<TableManagerPage> { |
|
171
|
],
|
339
|
],
|
|
172
|
),
|
340
|
),
|
|
173
|
),
|
341
|
),
|
|
174
|
- Container(
|
|
|
|
175
|
- height: ScreenUtil().setWidth(20),
|
|
|
|
176
|
- width: double.infinity,
|
|
|
|
177
|
- color: MyColours.color_f5f5f5,
|
|
|
|
178
|
- ),
|
|
|
|
179
|
Expanded(
|
342
|
Expanded(
|
|
180
|
child: Consumer<TableManagerModel>(
|
343
|
child: Consumer<TableManagerModel>(
|
|
181
|
builder: (context, model, child) {
|
344
|
builder: (context, model, child) {
|
|
@@ -196,178 +359,317 @@ class TableManagerPageState extends State<TableManagerPage> { |
|
@@ -196,178 +359,317 @@ class TableManagerPageState extends State<TableManagerPage> { |
|
196
|
} else {
|
359
|
} else {
|
|
197
|
return Container(
|
360
|
return Container(
|
|
198
|
color: MyColours.color_ffffff,
|
361
|
color: MyColours.color_ffffff,
|
|
199
|
- child: Row(
|
|
|
|
200
|
- children: <Widget>[
|
|
|
|
201
|
- Container(
|
|
|
|
202
|
- width: ScreenUtil().setWidth(170),
|
|
|
|
203
|
- height: double.infinity,
|
|
|
|
204
|
- color: MyColours.color_f1f1f1,
|
|
|
|
205
|
- child: ListView.builder(
|
|
|
|
206
|
- itemBuilder: (context, index) {
|
|
|
|
207
|
- return Selector<TableManagerModel, Area>(
|
|
|
|
208
|
- selector: (context, model) =>
|
|
|
|
209
|
- model.areas[index],
|
|
|
|
210
|
- builder: (context, area, _) {
|
|
|
|
211
|
- return AreaItem(
|
|
|
|
212
|
- area, tableManagerModel.currentArea,
|
|
|
|
213
|
- (area) {
|
|
|
|
214
|
- setState(() {
|
|
|
|
215
|
- tableManagerModel.currentArea =
|
|
|
|
216
|
- (area as Area).name;
|
|
|
|
217
|
- tableManagerModel.currentTables =
|
|
|
|
218
|
- tableManagerModel.areaTableMap[
|
|
|
|
219
|
- tableManagerModel.currentArea];
|
|
|
|
220
|
- });
|
|
|
|
221
|
- });
|
|
|
|
222
|
- },
|
|
|
|
223
|
- );
|
|
|
|
224
|
- },
|
|
|
|
225
|
- itemExtent: ScreenUtil().setHeight(207),
|
|
|
|
226
|
- itemCount: tableManagerModel.areas.length,
|
|
|
|
227
|
- ),
|
|
|
|
228
|
- ),
|
|
|
|
229
|
- Expanded(
|
|
|
|
230
|
- child: Padding(
|
|
|
|
231
|
- padding: EdgeInsets.symmetric(
|
|
|
|
232
|
- vertical: ScreenUtil().setHeight(10),
|
|
|
|
233
|
- horizontal: ScreenUtil().setWidth(9)),
|
|
|
|
234
|
- child: Column(
|
|
|
|
235
|
- children: [
|
|
|
|
236
|
- Expanded(
|
|
|
|
237
|
- child: GridView.builder(
|
|
|
|
238
|
- gridDelegate:
|
|
|
|
239
|
- SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
240
|
- crossAxisCount: 3,
|
|
|
|
241
|
- childAspectRatio: 8 / 9),
|
|
|
|
242
|
- itemBuilder: (context, index) {
|
|
|
|
243
|
- return Selector<TableManagerModel,
|
|
|
|
244
|
- t.Table>(
|
|
|
|
245
|
- shouldRebuild: (pre, next) => true,
|
|
|
|
246
|
- selector: (context, model) =>
|
|
|
|
247
|
- model.currentTables[index],
|
|
|
|
248
|
- builder: (context, table, _) {
|
|
|
|
249
|
- return TableItem(table,
|
|
|
|
250
|
- onSelected: (table) {
|
|
|
|
251
|
- if ((table as t.Table).selected) {
|
|
|
|
252
|
- tableManagerModel.selectTables
|
|
|
|
253
|
- .add(table);
|
|
|
|
254
|
- } else {
|
|
|
|
255
|
- tableManagerModel.selectTables
|
|
|
|
256
|
- .removeWhere((t) =>
|
|
|
|
257
|
- t.id == table.id);
|
362
|
+ child: Column(children: <Widget>[
|
|
|
|
363
|
+ VEmptyView(20),
|
|
|
|
364
|
+ ValueListenableBuilder<Iterable<ItemPosition>>(
|
|
|
|
365
|
+ valueListenable:
|
|
|
|
366
|
+ itemPositionsListener.itemPositions,
|
|
|
|
367
|
+ builder: (context, positions, child) {
|
|
|
|
368
|
+ if (positions.isNotEmpty) {
|
|
|
|
369
|
+ // max = positions
|
|
|
|
370
|
+ // .where((ItemPosition position) =>
|
|
|
|
371
|
+ // position.itemLeadingEdge < 1)
|
|
|
|
372
|
+ // .reduce((ItemPosition max,
|
|
|
|
373
|
+ // ItemPosition position) =>
|
|
|
|
374
|
+ // position.itemLeadingEdge >
|
|
|
|
375
|
+ // max.itemLeadingEdge
|
|
|
|
376
|
+ // ? position
|
|
|
|
377
|
+ // : max)
|
|
|
|
378
|
+ // .index;
|
|
|
|
379
|
+ min = positions
|
|
|
|
380
|
+ .where((ItemPosition position) =>
|
|
|
|
381
|
+ position.itemTrailingEdge > 0)
|
|
|
|
382
|
+ .reduce((ItemPosition min,
|
|
|
|
383
|
+ ItemPosition position) =>
|
|
|
|
384
|
+ position.itemTrailingEdge <
|
|
|
|
385
|
+ min.itemTrailingEdge
|
|
|
|
386
|
+ ? position
|
|
|
|
387
|
+ : min)
|
|
|
|
388
|
+ .index;
|
|
|
|
389
|
+
|
|
|
|
390
|
+ if (isTap) {
|
|
|
|
391
|
+ if (min >= _selectIndex) {
|
|
|
|
392
|
+ _selectIndex = min;
|
|
|
|
393
|
+ } else {
|
|
|
|
394
|
+ _selectIndex = _selectIndex;
|
|
|
|
395
|
+ }
|
|
|
|
396
|
+ isTap = false;
|
|
|
|
397
|
+ } else {
|
|
|
|
398
|
+ _selectIndex = min;
|
|
|
|
399
|
+ }
|
|
|
|
400
|
+ tableManagerModel.currentArea =
|
|
|
|
401
|
+ tableManagerModel.areas[_selectIndex].name;
|
|
|
|
402
|
+ }
|
|
|
|
403
|
+ return Container(
|
|
|
|
404
|
+ height: ScreenUtil().setWidth(50),
|
|
|
|
405
|
+ color: MyColours.color_ffffff,
|
|
|
|
406
|
+ margin: EdgeInsets.only(
|
|
|
|
407
|
+ bottom: ScreenUtil().setWidth(20)),
|
|
|
|
408
|
+ child: ListView.builder(
|
|
|
|
409
|
+ controller: _areaController,
|
|
|
|
410
|
+ scrollDirection: Axis.horizontal,
|
|
|
|
411
|
+ itemBuilder: (context, index) {
|
|
|
|
412
|
+ if (index ==
|
|
|
|
413
|
+ tableManagerModel.areas.length ||
|
|
|
|
414
|
+ tableManagerModel.areas.length == 0) {
|
|
|
|
415
|
+ return InkWell(
|
|
|
|
416
|
+ onTap: () async {
|
|
|
|
417
|
+ //添加区域弹框
|
|
|
|
418
|
+ await DialogUtil
|
|
|
|
419
|
+ .openCreateAreaDialog(context,
|
|
|
|
420
|
+ onTap: (value) async {
|
|
|
|
421
|
+ print(value);
|
|
|
|
422
|
+ //添加区域
|
|
|
|
423
|
+ bool success =
|
|
|
|
424
|
+ await tableManagerModel
|
|
|
|
425
|
+ .addTableAreas(
|
|
|
|
426
|
+ context, value);
|
|
|
|
427
|
+ print(success);
|
|
|
|
428
|
+ if (success) {
|
|
|
|
429
|
+ Utils.showToast('添加成功!');
|
|
|
|
430
|
+ TableOuter tableOuter =
|
|
|
|
431
|
+ TableOuter();
|
|
|
|
432
|
+ tableOuter.name = value;
|
|
|
|
433
|
+ tableOuter.list = [];
|
|
|
|
434
|
+ tableManagerModel.tableOuterList
|
|
|
|
435
|
+ .add(tableOuter);
|
|
|
|
436
|
+ tableManagerModel.initData();
|
|
|
|
437
|
+ Timer(
|
|
|
|
438
|
+ Duration(milliseconds: 500),
|
|
|
|
439
|
+ () => _areaController
|
|
|
|
440
|
+ .jumpTo(_areaController
|
|
|
|
441
|
+ .position
|
|
|
|
442
|
+ .maxScrollExtent));
|
|
|
|
443
|
+
|
|
|
|
444
|
+ // await tableManagerModel
|
|
|
|
445
|
+ // .getTableList(context);
|
|
|
|
446
|
+ // await tableManagerModel
|
|
|
|
447
|
+ // .initData();
|
|
258
|
}
|
448
|
}
|
|
259
|
- DialogUtil.showTableManagerDialog(
|
|
|
|
260
|
- context, table)
|
|
|
|
261
|
- .then((value) {
|
|
|
|
262
|
- if (value != null) {
|
|
|
|
263
|
- switch (value) {
|
|
|
|
264
|
- case 1: //查看详情
|
|
|
|
265
|
- NavigatorUtil
|
|
|
|
266
|
- .goNotebookDetailPage(
|
|
|
|
267
|
- context,
|
|
|
|
268
|
- tableManagerModel
|
|
|
|
269
|
- .tableMap[
|
|
|
|
270
|
- table.id]
|
|
|
|
271
|
- .id);
|
|
|
|
272
|
- break;
|
|
|
|
273
|
- case 2: //订座
|
|
|
|
274
|
- NavigatorUtil.goNoteBookChangePage(
|
|
|
|
275
|
- context,
|
|
|
|
276
|
- NotebookDetail.fromTableManager(
|
|
|
|
277
|
- tableManagerModel
|
|
|
|
278
|
- .getCurrDdateStr(),
|
|
|
|
279
|
- tableManagerModel
|
|
|
|
280
|
- .currTimeIndex
|
|
|
|
281
|
- .toString(),
|
|
|
|
282
|
- table),
|
|
|
|
283
|
- "");
|
|
|
|
284
|
- break;
|
|
|
|
285
|
- case 3: //停用,启用桌位
|
|
|
|
286
|
- Map<String, String>
|
|
|
|
287
|
- params = {
|
|
|
|
288
|
- "id": (table as t.Table)
|
|
|
|
289
|
- .id,
|
|
|
|
290
|
- "status": (table as t
|
|
|
|
291
|
- .Table)
|
|
|
|
292
|
- .enable ==
|
|
|
|
293
|
- "1"
|
|
|
|
294
|
- ? "0"
|
|
|
|
295
|
- : "1"
|
|
|
|
296
|
- };
|
|
|
|
297
|
- tableManagerModel
|
|
|
|
298
|
- .setSwitchStatus(
|
|
|
|
299
|
- context, params)
|
|
|
|
300
|
- .then((value) {
|
|
|
|
301
|
- if (value != null) {
|
|
|
|
302
|
- (table as t.Table)
|
|
|
|
303
|
- .enable =
|
|
|
|
304
|
- ((int.parse((table as t.Table)
|
|
|
|
305
|
- .enable) +
|
|
|
|
306
|
- 1) %
|
|
|
|
307
|
- 2)
|
|
|
|
308
|
- .toString();
|
|
|
|
309
|
- if ((table as t.Table)
|
|
|
|
310
|
- .enable ==
|
|
|
|
311
|
- "1") {
|
|
|
|
312
|
- for (Area area
|
|
|
|
313
|
- in tableManagerModel
|
|
|
|
314
|
- .areas) {
|
|
|
|
315
|
- if (area.name ==
|
|
|
|
316
|
- tableManagerModel
|
|
|
|
317
|
- .currentArea) {
|
|
|
|
318
|
- if (table.sign !=
|
|
|
|
319
|
- '5' &&
|
|
|
|
320
|
- table.sign !=
|
|
|
|
321
|
- '1') {
|
|
|
|
322
|
- //已预订
|
|
|
|
323
|
- area.count++;
|
|
|
|
324
|
- }
|
|
|
|
325
|
- break;
|
|
|
|
326
|
- }
|
|
|
|
327
|
- }
|
|
|
|
328
|
- } else {
|
|
|
|
329
|
- for (Area area
|
|
|
|
330
|
- in tableManagerModel
|
|
|
|
331
|
- .areas) {
|
|
|
|
332
|
- if (area.name ==
|
|
|
|
333
|
- tableManagerModel
|
|
|
|
334
|
- .currentArea) {
|
|
|
|
335
|
- if (table.sign !=
|
|
|
|
336
|
- '5' &&
|
|
|
|
337
|
- table.sign !=
|
|
|
|
338
|
- '1') {
|
|
|
|
339
|
- //已预订
|
|
|
|
340
|
- area.count--;
|
|
|
|
341
|
- }
|
|
|
|
342
|
- break;
|
|
|
|
343
|
- }
|
|
|
|
344
|
- }
|
|
|
|
345
|
- }
|
|
|
|
346
|
- tableManagerModel
|
|
|
|
347
|
- .notifyListeners();
|
|
|
|
348
|
- }
|
|
|
|
349
|
- });
|
|
|
|
350
|
- break;
|
|
|
|
351
|
- }
|
|
|
|
352
|
- }
|
|
|
|
353
|
- });
|
|
|
|
354
|
- },
|
|
|
|
355
|
- canSelected: false,
|
|
|
|
356
|
- fromPage: 'table_manage',
|
|
|
|
357
|
- tableMap:
|
|
|
|
358
|
- tableManagerModel.tableMap,
|
|
|
|
359
|
- rid: "");
|
449
|
+ });
|
|
360
|
},
|
450
|
},
|
|
361
|
- );
|
|
|
|
362
|
- },
|
|
|
|
363
|
- itemCount: tableManagerModel
|
|
|
|
364
|
- .currentTables.length,
|
|
|
|
365
|
- )),
|
|
|
|
366
|
- ],
|
|
|
|
367
|
- )),
|
|
|
|
368
|
- )
|
|
|
|
369
|
- ],
|
|
|
|
370
|
- ),
|
451
|
+ child: DottedBorder(
|
|
|
|
452
|
+ dashPattern: [5, 5, 5, 5],
|
|
|
|
453
|
+ borderType: BorderType.RRect,
|
|
|
|
454
|
+ radius: Radius.circular(
|
|
|
|
455
|
+ ScreenUtil().setWidth(30)),
|
|
|
|
456
|
+ // padding: EdgeInsets.all(ScreenUtil().setWidth(70)),
|
|
|
|
457
|
+ color: MyColours.color_199095,
|
|
|
|
458
|
+ strokeWidth:
|
|
|
|
459
|
+ ScreenUtil().setWidth(2),
|
|
|
|
460
|
+ child: ClipRRect(
|
|
|
|
461
|
+ borderRadius: BorderRadius.all(
|
|
|
|
462
|
+ Radius.circular(ScreenUtil()
|
|
|
|
463
|
+ .setWidth(30))),
|
|
|
|
464
|
+ child: Container(
|
|
|
|
465
|
+ height: ScreenUtil()
|
|
|
|
466
|
+ .setWidth(50 * 2),
|
|
|
|
467
|
+ width: ScreenUtil()
|
|
|
|
468
|
+ .setWidth(60 * 2),
|
|
|
|
469
|
+ child: Column(
|
|
|
|
470
|
+ mainAxisAlignment:
|
|
|
|
471
|
+ MainAxisAlignment.center,
|
|
|
|
472
|
+ children: [
|
|
|
|
473
|
+ Image.asset(
|
|
|
|
474
|
+ Utils.getImgPath(
|
|
|
|
475
|
+ 'add_store'),
|
|
|
|
476
|
+ width: ScreenUtil()
|
|
|
|
477
|
+ .setWidth(22)),
|
|
|
|
478
|
+ ],
|
|
|
|
479
|
+ ),
|
|
|
|
480
|
+ ),
|
|
|
|
481
|
+ ),
|
|
|
|
482
|
+ ));
|
|
|
|
483
|
+ } else {
|
|
|
|
484
|
+ return Selector<TableManagerModel, Area>(
|
|
|
|
485
|
+ selector: (context, model) =>
|
|
|
|
486
|
+ model.areas[index],
|
|
|
|
487
|
+ builder: (context, area, _) {
|
|
|
|
488
|
+ return AreaItemTable(area,
|
|
|
|
489
|
+ tableManagerModel.currentArea,
|
|
|
|
490
|
+ (area) {
|
|
|
|
491
|
+ isTap = true;
|
|
|
|
492
|
+ scrollTo(index);
|
|
|
|
493
|
+ // setState(() {
|
|
|
|
494
|
+ tableManagerModel.currentArea =
|
|
|
|
495
|
+ tableManagerModel
|
|
|
|
496
|
+ .areas[index].name;
|
|
|
|
497
|
+ tableManagerModel.currentTables =
|
|
|
|
498
|
+ tableManagerModel.areaTableMap[
|
|
|
|
499
|
+ tableManagerModel
|
|
|
|
500
|
+ .currentArea];
|
|
|
|
501
|
+ _selectIndex = index;
|
|
|
|
502
|
+ // });
|
|
|
|
503
|
+ // setState(() {
|
|
|
|
504
|
+ // tableManagerModel.currentArea =
|
|
|
|
505
|
+ // (area as Area).name;
|
|
|
|
506
|
+ // tableManagerModel.currentTables =
|
|
|
|
507
|
+ // tableManagerModel.areaTableMap[
|
|
|
|
508
|
+ // tableManagerModel
|
|
|
|
509
|
+ // .currentArea];
|
|
|
|
510
|
+ // });
|
|
|
|
511
|
+ });
|
|
|
|
512
|
+ },
|
|
|
|
513
|
+ );
|
|
|
|
514
|
+ }
|
|
|
|
515
|
+ },
|
|
|
|
516
|
+
|
|
|
|
517
|
+ // itemExtent: ScreenUtil().setHeight(207),
|
|
|
|
518
|
+ itemCount: tableManagerModel.areas.length + 1,
|
|
|
|
519
|
+ ),
|
|
|
|
520
|
+ );
|
|
|
|
521
|
+ }),
|
|
|
|
522
|
+ Expanded(
|
|
|
|
523
|
+ child: Container(
|
|
|
|
524
|
+ color: MyColours.color_ffffff,
|
|
|
|
525
|
+ padding: EdgeInsets.symmetric(
|
|
|
|
526
|
+ horizontal: ScreenUtil().setWidth(40)),
|
|
|
|
527
|
+ width: double.infinity,
|
|
|
|
528
|
+ child: list(tableManagerModel.areas)),
|
|
|
|
529
|
+ ),
|
|
|
|
530
|
+ // Expanded(
|
|
|
|
531
|
+ // child: Container(
|
|
|
|
532
|
+ // color: MyColours.color_e5e5e5,
|
|
|
|
533
|
+ // padding: EdgeInsets.symmetric(
|
|
|
|
534
|
+ // vertical: ScreenUtil().setHeight(10),
|
|
|
|
535
|
+ // horizontal: ScreenUtil().setWidth(9)),
|
|
|
|
536
|
+ // child: Column(
|
|
|
|
537
|
+ // children: [
|
|
|
|
538
|
+ // Expanded(
|
|
|
|
539
|
+ // child: GridView.builder(
|
|
|
|
540
|
+ // gridDelegate:
|
|
|
|
541
|
+ // SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
542
|
+ // crossAxisCount: 3,
|
|
|
|
543
|
+ // childAspectRatio: 8 / 9),
|
|
|
|
544
|
+ // itemBuilder: (context, index) {
|
|
|
|
545
|
+ // return Selector<TableManagerModel,
|
|
|
|
546
|
+ // t.Table>(
|
|
|
|
547
|
+ // shouldRebuild: (pre, next) => true,
|
|
|
|
548
|
+ // selector: (context, model) =>
|
|
|
|
549
|
+ // model.currentTables[index],
|
|
|
|
550
|
+ // builder: (context, table, _) {
|
|
|
|
551
|
+ // return TableItem(table,
|
|
|
|
552
|
+ // onSelected: (table) {
|
|
|
|
553
|
+ // if ((table as t.Table).selected) {
|
|
|
|
554
|
+ // tableManagerModel.selectTables
|
|
|
|
555
|
+ // .add(table);
|
|
|
|
556
|
+ // } else {
|
|
|
|
557
|
+ // tableManagerModel.selectTables
|
|
|
|
558
|
+ // .removeWhere((t) =>
|
|
|
|
559
|
+ // t.id == table.id);
|
|
|
|
560
|
+ // }
|
|
|
|
561
|
+ // DialogUtil.showTableManagerDialog(
|
|
|
|
562
|
+ // context, table)
|
|
|
|
563
|
+ // .then((value) {
|
|
|
|
564
|
+ // if (value != null) {
|
|
|
|
565
|
+ // switch (value) {
|
|
|
|
566
|
+ // case 1: //查看详情
|
|
|
|
567
|
+ // NavigatorUtil
|
|
|
|
568
|
+ // .goNotebookDetailPage(
|
|
|
|
569
|
+ // context,
|
|
|
|
570
|
+ // tableManagerModel
|
|
|
|
571
|
+ // .tableMap[
|
|
|
|
572
|
+ // table.id]
|
|
|
|
573
|
+ // .id);
|
|
|
|
574
|
+ // break;
|
|
|
|
575
|
+ // case 2: //订座
|
|
|
|
576
|
+ // NavigatorUtil.goNoteBookChangePage(
|
|
|
|
577
|
+ // context,
|
|
|
|
578
|
+ // NotebookDetail.fromTableManager(
|
|
|
|
579
|
+ // tableManagerModel
|
|
|
|
580
|
+ // .getCurrDdateStr(),
|
|
|
|
581
|
+ // tableManagerModel
|
|
|
|
582
|
+ // .currTimeIndex
|
|
|
|
583
|
+ // .toString(),
|
|
|
|
584
|
+ // table),
|
|
|
|
585
|
+ // "");
|
|
|
|
586
|
+ // break;
|
|
|
|
587
|
+ // case 3: //停用,启用桌位
|
|
|
|
588
|
+ // Map<String, String>
|
|
|
|
589
|
+ // params = {
|
|
|
|
590
|
+ // "id": (table as t.Table)
|
|
|
|
591
|
+ // .id,
|
|
|
|
592
|
+ // "status": (table as t
|
|
|
|
593
|
+ // .Table)
|
|
|
|
594
|
+ // .enable ==
|
|
|
|
595
|
+ // "1"
|
|
|
|
596
|
+ // ? "0"
|
|
|
|
597
|
+ // : "1"
|
|
|
|
598
|
+ // };
|
|
|
|
599
|
+ // tableManagerModel
|
|
|
|
600
|
+ // .setSwitchStatus(
|
|
|
|
601
|
+ // context, params)
|
|
|
|
602
|
+ // .then((value) {
|
|
|
|
603
|
+ // if (value != null) {
|
|
|
|
604
|
+ // (table as t.Table)
|
|
|
|
605
|
+ // .enable =
|
|
|
|
606
|
+ // ((int.parse((table as t.Table)
|
|
|
|
607
|
+ // .enable) +
|
|
|
|
608
|
+ // 1) %
|
|
|
|
609
|
+ // 2)
|
|
|
|
610
|
+ // .toString();
|
|
|
|
611
|
+ // if ((table as t.Table)
|
|
|
|
612
|
+ // .enable ==
|
|
|
|
613
|
+ // "1") {
|
|
|
|
614
|
+ // for (Area area
|
|
|
|
615
|
+ // in tableManagerModel
|
|
|
|
616
|
+ // .areas) {
|
|
|
|
617
|
+ // if (area.name ==
|
|
|
|
618
|
+ // tableManagerModel
|
|
|
|
619
|
+ // .currentArea) {
|
|
|
|
620
|
+ // if (table.sign !=
|
|
|
|
621
|
+ // '5' &&
|
|
|
|
622
|
+ // table.sign !=
|
|
|
|
623
|
+ // '1') {
|
|
|
|
624
|
+ // //已预订
|
|
|
|
625
|
+ // area.count++;
|
|
|
|
626
|
+ // }
|
|
|
|
627
|
+ // break;
|
|
|
|
628
|
+ // }
|
|
|
|
629
|
+ // }
|
|
|
|
630
|
+ // } else {
|
|
|
|
631
|
+ // for (Area area
|
|
|
|
632
|
+ // in tableManagerModel
|
|
|
|
633
|
+ // .areas) {
|
|
|
|
634
|
+ // if (area.name ==
|
|
|
|
635
|
+ // tableManagerModel
|
|
|
|
636
|
+ // .currentArea) {
|
|
|
|
637
|
+ // if (table.sign !=
|
|
|
|
638
|
+ // '5' &&
|
|
|
|
639
|
+ // table.sign !=
|
|
|
|
640
|
+ // '1') {
|
|
|
|
641
|
+ // //已预订
|
|
|
|
642
|
+ // area.count--;
|
|
|
|
643
|
+ // }
|
|
|
|
644
|
+ // break;
|
|
|
|
645
|
+ // }
|
|
|
|
646
|
+ // }
|
|
|
|
647
|
+ // }
|
|
|
|
648
|
+ // tableManagerModel
|
|
|
|
649
|
+ // .notifyListeners();
|
|
|
|
650
|
+ // }
|
|
|
|
651
|
+ // });
|
|
|
|
652
|
+ // break;
|
|
|
|
653
|
+ // }
|
|
|
|
654
|
+ // }
|
|
|
|
655
|
+ // });
|
|
|
|
656
|
+ // },
|
|
|
|
657
|
+ // canSelected: false,
|
|
|
|
658
|
+ // fromPage: 'table_manage',
|
|
|
|
659
|
+ // tableMap:
|
|
|
|
660
|
+ // tableManagerModel.tableMap,
|
|
|
|
661
|
+ // rid: "");
|
|
|
|
662
|
+ // },
|
|
|
|
663
|
+ // );
|
|
|
|
664
|
+ // },
|
|
|
|
665
|
+ // itemCount: tableManagerModel
|
|
|
|
666
|
+ // .currentTables.length,
|
|
|
|
667
|
+ // )),
|
|
|
|
668
|
+ // ],
|
|
|
|
669
|
+ // )),
|
|
|
|
670
|
+ // )
|
|
|
|
671
|
+ // ],
|
|
|
|
672
|
+ ]),
|
|
371
|
);
|
673
|
);
|
|
372
|
}
|
674
|
}
|
|
373
|
},
|
675
|
},
|