|
@@ -39,6 +39,7 @@ import 'package:scrollable_positioned_list/scrollable_positioned_list.dart'; |
|
@@ -39,6 +39,7 @@ import 'package:scrollable_positioned_list/scrollable_positioned_list.dart'; |
|
39
|
import 'package:one_key/models/table_list.dart' as table;
|
39
|
import 'package:one_key/models/table_list.dart' as table;
|
|
40
|
|
40
|
|
|
41
|
import '../../../provider/table_manager_model.dart';
|
41
|
import '../../../provider/table_manager_model.dart';
|
|
|
|
42
|
+import 'package:flutter_draggable_gridview/flutter_draggable_gridview.dart';
|
|
42
|
|
43
|
|
|
43
|
const scrollDuration = Duration(microseconds: 500);
|
44
|
const scrollDuration = Duration(microseconds: 500);
|
|
44
|
|
45
|
|
|
@@ -97,12 +98,15 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> { |
|
@@ -97,12 +98,15 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> { |
|
97
|
@override
|
98
|
@override
|
|
98
|
void dispose() {
|
99
|
void dispose() {
|
|
99
|
// TODO: implement dispose
|
100
|
// TODO: implement dispose
|
|
|
|
101
|
+ controller.removeListener(scheduleRebuild);
|
|
100
|
EventBus().emit('changeStatusColor');
|
102
|
EventBus().emit('changeStatusColor');
|
|
101
|
super.dispose();
|
103
|
super.dispose();
|
|
102
|
EventBus().off("refresh_table_area");
|
104
|
EventBus().off("refresh_table_area");
|
|
103
|
// EventBus().off("refresh_tablePhoto");
|
105
|
// EventBus().off("refresh_tablePhoto");
|
|
104
|
}
|
106
|
}
|
|
105
|
|
107
|
|
|
|
|
108
|
+ void scheduleRebuild() => setState(() {});
|
|
|
|
109
|
+
|
|
106
|
///刷新图片显示
|
110
|
///刷新图片显示
|
|
107
|
// _refreshTablePhoto() async {
|
111
|
// _refreshTablePhoto() async {
|
|
108
|
// List temp =
|
112
|
// List temp =
|
|
@@ -237,96 +241,227 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> { |
|
@@ -237,96 +241,227 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> { |
|
237
|
|
241
|
|
|
238
|
/// Generate item number [i].
|
242
|
/// Generate item number [i].
|
|
239
|
Widget item(int i) {
|
243
|
Widget item(int i) {
|
|
240
|
- return GridView.builder(
|
|
|
|
241
|
- controller: controller,
|
|
|
|
242
|
- // physics: NeverScrollableScrollPhysics(),
|
244
|
+ final List<DraggableGridItem> _listOfDraggableGridItem = [];
|
|
|
|
245
|
+ for (int j = 0;
|
|
|
|
246
|
+ j < tableManagerModel.tableOuterList[i].list.length + 1;
|
|
|
|
247
|
+ j++) {
|
|
|
|
248
|
+ DraggableGridItem draggableGridItem;
|
|
|
|
249
|
+
|
|
|
|
250
|
+ if (j == tableManagerModel.tableOuterList[i].list.length ||
|
|
|
|
251
|
+ tableManagerModel.tableOuterList[i].list.length == 0) {
|
|
|
|
252
|
+ draggableGridItem = DraggableGridItem(
|
|
|
|
253
|
+ // isDraggable: true,
|
|
|
|
254
|
+ child: Offstage(
|
|
|
|
255
|
+ offstage: tableManagerModel
|
|
|
|
256
|
+ .tableOuterList[tableManagerModel.selectNumber].isSelect,
|
|
|
|
257
|
+ child: InkWell(
|
|
|
|
258
|
+ onTap: () async {
|
|
|
|
259
|
+ List<String> tableTypeS = [];
|
|
|
|
260
|
+ for (int n = 0;
|
|
|
|
261
|
+ n < tableManagerModel.tableTypeList.length;
|
|
|
|
262
|
+ n++) {
|
|
|
|
263
|
+ tableTypeS.add(tableManagerModel.tableTypeList[n].name);
|
|
|
|
264
|
+ }
|
|
243
|
|
265
|
|
|
244
|
- shrinkWrap: true,
|
|
|
|
245
|
- itemCount: tableManagerModel.tableOuterList[i].list.length + 1,
|
|
|
|
246
|
- gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
247
|
- crossAxisCount: 4,
|
|
|
|
248
|
- childAspectRatio: 1,
|
|
|
|
249
|
- mainAxisSpacing: ScreenUtil().setWidth(28),
|
|
|
|
250
|
- crossAxisSpacing: ScreenUtil().setWidth(48),
|
|
|
|
251
|
- ),
|
266
|
+ //添加桌位弹框
|
|
|
|
267
|
+ await DialogUtil.openMyTableManageCreateTableDialog(
|
|
|
|
268
|
+ context, tableTypeS, personNumList,
|
|
|
|
269
|
+ onTap: (Map<String, String> value) async {
|
|
|
|
270
|
+ print(value);
|
|
|
|
271
|
+ // 'areaname':
|
|
|
|
272
|
+ // areas[currentAreaIndex],
|
|
|
|
273
|
+ // 'name': controller.text,
|
|
|
|
274
|
+ // 'pnumMin': pnumMin,
|
|
|
|
275
|
+ // 'pnumMax': pnumMax
|
|
|
|
276
|
+ //添加桌位 接口参数带整合???
|
|
|
|
277
|
+ // 以下是旧的不去,明天添加桌位接口
|
|
|
|
278
|
+ // 'bjtype': baojianList[
|
|
|
|
279
|
+ // currentBaojianIndex],
|
|
|
|
280
|
+ // 'name': controller.text,
|
|
|
|
281
|
+ // 'pnumMin': pnumMin,
|
|
|
|
282
|
+ // 'pnumMax': pnumMax,
|
|
|
|
283
|
+ // 'mulcreate':
|
|
|
|
284
|
+ // mulCreate.toString(),
|
|
|
|
285
|
+ // 'tablenum':
|
|
|
|
286
|
+ // _norNumController.text
|
|
|
|
287
|
+ String rid;
|
|
|
|
288
|
+ for (Area item in tableManagerModel.areas) {
|
|
|
|
289
|
+ if (item.name == tableManagerModel.currentArea) {
|
|
|
|
290
|
+ rid = item.rid;
|
|
|
|
291
|
+ }
|
|
|
|
292
|
+ }
|
|
252
|
|
293
|
|
|
253
|
- itemBuilder: (BuildContext context, int index) {
|
|
|
|
254
|
- if (index == tableManagerModel.tableOuterList[i].list.length ||
|
|
|
|
255
|
- tableManagerModel.tableOuterList[i].list.length == 0) {
|
|
|
|
256
|
- return Offstage(
|
|
|
|
257
|
- offstage: tableManagerModel
|
|
|
|
258
|
- .tableOuterList[tableManagerModel.selectNumber].isSelect,
|
|
|
|
259
|
- child: InkWell(
|
|
|
|
260
|
- onTap: () async {
|
294
|
+ Map<String, String> params = {
|
|
|
|
295
|
+ 'rid': rid,
|
|
|
|
296
|
+ };
|
|
|
|
297
|
+ String tid;
|
|
|
|
298
|
+ for (int i = 0;
|
|
|
|
299
|
+ i < tableManagerModel.tableTypeList.length;
|
|
|
|
300
|
+ i++) {
|
|
|
|
301
|
+ if (value['bjtype'] ==
|
|
|
|
302
|
+ tableManagerModel.tableTypeList[i].name) {
|
|
|
|
303
|
+ tid = tableManagerModel.tableTypeList[i].id;
|
|
|
|
304
|
+ }
|
|
|
|
305
|
+ }
|
|
|
|
306
|
+ if (value['mulcreate'] == 'true') {
|
|
|
|
307
|
+ //批量创建
|
|
|
|
308
|
+ params['tablenum'] = value['tablenum'];
|
|
|
|
309
|
+ params['pnum'] = '10';
|
|
|
|
310
|
+ params['most_pnum'] = '10';
|
|
|
|
311
|
+ // params['name'] = 'lll';
|
|
|
|
312
|
+ } else {
|
|
|
|
313
|
+ //单个创建
|
|
|
|
314
|
+ params['name'] = value['name'];
|
|
|
|
315
|
+ if (value['pnumMin'] != '') {
|
|
|
|
316
|
+ params['pnum'] = value['pnumMin'];
|
|
|
|
317
|
+ }
|
|
|
|
318
|
+ if (value['pnumMax'] != '') {
|
|
|
|
319
|
+ params['most_pnum'] = value['pnumMax'];
|
|
|
|
320
|
+ }
|
|
|
|
321
|
+ }
|
|
|
|
322
|
+
|
|
|
|
323
|
+ bool success = await tableManagerModel
|
|
|
|
324
|
+ .addTable(context, params, tid: tid);
|
|
|
|
325
|
+ print(success);
|
|
|
|
326
|
+ if (success) {
|
|
|
|
327
|
+ Utils.showToast('添加成功!');
|
|
|
|
328
|
+ // TableOuter tableOuter = TableOuter();
|
|
|
|
329
|
+ // tableOuter.name = value;
|
|
|
|
330
|
+ // tableOuter.list = [];
|
|
|
|
331
|
+ // tableManagerModel.tableOuterList.add(tableOuter);
|
|
|
|
332
|
+ // tableManagerModel.initData();
|
|
|
|
333
|
+ // Timer(
|
|
|
|
334
|
+ // Duration(milliseconds: 500),
|
|
|
|
335
|
+ // () => _areaController.jumpTo(
|
|
|
|
336
|
+ // _areaController.position.maxScrollExtent));
|
|
|
|
337
|
+
|
|
|
|
338
|
+ // await tableManagerModel
|
|
|
|
339
|
+ // .getTableList(context);
|
|
|
|
340
|
+ // await tableManagerModel
|
|
|
|
341
|
+ // .initData();
|
|
|
|
342
|
+ // TableManagerModel tableManagerModel1 =
|
|
|
|
343
|
+ // Provider.of<TableManagerModel>(context,
|
|
|
|
344
|
+ // listen: false);
|
|
|
|
345
|
+ // tableManagerModel1.getTableList(
|
|
|
|
346
|
+ // context,
|
|
|
|
347
|
+ // needLoading: false,
|
|
|
|
348
|
+ // );
|
|
|
|
349
|
+ await tableManagerModel.refreshTable(context);
|
|
|
|
350
|
+ }
|
|
|
|
351
|
+ });
|
|
|
|
352
|
+ },
|
|
|
|
353
|
+ child: Container(
|
|
|
|
354
|
+ child: DottedBorder(
|
|
|
|
355
|
+ dashPattern: [8, 8, 8, 8],
|
|
|
|
356
|
+ borderType: BorderType.RRect,
|
|
|
|
357
|
+ radius: Radius.circular(ScreenUtil().setWidth(10)),
|
|
|
|
358
|
+ // padding: EdgeInsets.all(ScreenUtil().setWidth(70)),
|
|
|
|
359
|
+ color: MyColours.color_438E93,
|
|
|
|
360
|
+ strokeWidth: ScreenUtil().setWidth(2),
|
|
|
|
361
|
+ child: ClipRRect(
|
|
|
|
362
|
+ borderRadius: BorderRadius.all(
|
|
|
|
363
|
+ Radius.circular(ScreenUtil().setWidth(10))),
|
|
|
|
364
|
+ child: Container(
|
|
|
|
365
|
+ height: ScreenUtil().screenWidth -
|
|
|
|
366
|
+ ScreenUtil().setWidth(48 * 3 + 32 * 2),
|
|
|
|
367
|
+ width: ScreenUtil().screenWidth -
|
|
|
|
368
|
+ ScreenUtil().setWidth(48 * 3 + 32 * 2),
|
|
|
|
369
|
+ child: Column(
|
|
|
|
370
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
371
|
+ children: [
|
|
|
|
372
|
+ Image.asset(Utils.getImgPath('add_area'),
|
|
|
|
373
|
+ width: ScreenUtil().setWidth(60)),
|
|
|
|
374
|
+ ],
|
|
|
|
375
|
+ ),
|
|
|
|
376
|
+ ),
|
|
|
|
377
|
+ ),
|
|
|
|
378
|
+ )))));
|
|
|
|
379
|
+ } else {
|
|
|
|
380
|
+ draggableGridItem = DraggableGridItem(
|
|
|
|
381
|
+ isDraggable: true,
|
|
|
|
382
|
+ dragCallback: (context, isDragging) {
|
|
|
|
383
|
+ print('isDragging: $isDragging');
|
|
|
|
384
|
+ },
|
|
|
|
385
|
+ child: Selector<MyTableManageHomeModel, t.Table>(
|
|
|
|
386
|
+ shouldRebuild: (pre, next) => true,
|
|
|
|
387
|
+ selector: (context, model) =>
|
|
|
|
388
|
+ tableManagerModel.tableOuterList[i].list[j],
|
|
|
|
389
|
+ builder: (context, table, _) {
|
|
|
|
390
|
+ return ManageTableItem(table,
|
|
|
|
391
|
+ canMulSelected: tableManagerModel
|
|
|
|
392
|
+ .tableOuterList[i].isSelect, onSelected: (table) async {
|
|
|
|
393
|
+ if (tableManagerModel.tableOuterList[i].isSelect) {
|
|
|
|
394
|
+ //多选
|
|
|
|
395
|
+ setState(() {
|
|
|
|
396
|
+ table.selected = !(table.selected ?? false);
|
|
|
|
397
|
+ });
|
|
|
|
398
|
+ if (table.selected) {
|
|
|
|
399
|
+ tableManagerModel.tableOuterList[i].selectTables
|
|
|
|
400
|
+ .add(table);
|
|
|
|
401
|
+ } else {
|
|
|
|
402
|
+ tableManagerModel.tableOuterList[i].selectTables
|
|
|
|
403
|
+ .removeWhere((t) => t.id == table.id);
|
|
|
|
404
|
+ }
|
|
|
|
405
|
+ // tableManagerModel
|
|
|
|
406
|
+ // .tableOuterList[tableManagerModel.selectNumber]
|
|
|
|
407
|
+ // .isAll =
|
|
|
|
408
|
+ // tableManagerModel.tableOuterList[i].list
|
|
|
|
409
|
+ // .every((element) => element.selected);
|
|
|
|
410
|
+ } else {
|
|
|
|
411
|
+ // for (t.Table item
|
|
|
|
412
|
+ // in tableManagerModel.tableOuterList[i].list) {
|
|
|
|
413
|
+ // item.selected = false;
|
|
|
|
414
|
+ // }
|
|
|
|
415
|
+ // tableManagerModel.tableOuterList[i].selectTables = [];
|
|
|
|
416
|
+ // //单选
|
|
|
|
417
|
+ // setState(() {
|
|
|
|
418
|
+ // table.selected = true;
|
|
|
|
419
|
+ // });
|
|
|
|
420
|
+ //修改桌位
|
|
|
|
421
|
+ print(table);
|
|
261
|
List<String> tableTypeS = [];
|
422
|
List<String> tableTypeS = [];
|
|
262
|
for (int i = 0;
|
423
|
for (int i = 0;
|
|
263
|
i < tableManagerModel.tableTypeList.length;
|
424
|
i < tableManagerModel.tableTypeList.length;
|
|
264
|
i++) {
|
425
|
i++) {
|
|
265
|
tableTypeS.add(tableManagerModel.tableTypeList[i].name);
|
426
|
tableTypeS.add(tableManagerModel.tableTypeList[i].name);
|
|
266
|
}
|
427
|
}
|
|
267
|
-
|
|
|
|
268
|
- //添加桌位弹框
|
|
|
|
269
|
- await DialogUtil.openMyTableManageCreateTableDialog(
|
428
|
+ List<t.Table> selectTables = [];
|
|
|
|
429
|
+ if (table.tids != null && table.tids.length > 0) {
|
|
|
|
430
|
+ List<String> tids = table.tids.split(',');
|
|
|
|
431
|
+ tableManagerModel.tableOuterList.forEach((element) {
|
|
|
|
432
|
+ element.list.forEach((table) {
|
|
|
|
433
|
+ tids.forEach((tid) {
|
|
|
|
434
|
+ if (tid == table.id) {
|
|
|
|
435
|
+ selectTables.add(table);
|
|
|
|
436
|
+ }
|
|
|
|
437
|
+ });
|
|
|
|
438
|
+ });
|
|
|
|
439
|
+ });
|
|
|
|
440
|
+ }
|
|
|
|
441
|
+ await DialogUtil.openMyTableManageModifyTableDialog(
|
|
270
|
context, tableTypeS, personNumList,
|
442
|
context, tableTypeS, personNumList,
|
|
271
|
- onTap: (Map<String, String> value) async {
|
|
|
|
272
|
- print(value);
|
|
|
|
273
|
- // 'areaname':
|
|
|
|
274
|
- // areas[currentAreaIndex],
|
|
|
|
275
|
- // 'name': controller.text,
|
|
|
|
276
|
- // 'pnumMin': pnumMin,
|
|
|
|
277
|
- // 'pnumMax': pnumMax
|
|
|
|
278
|
- //添加桌位 接口参数带整合???
|
|
|
|
279
|
- // 以下是旧的不去,明天添加桌位接口
|
|
|
|
280
|
- // 'bjtype': baojianList[
|
|
|
|
281
|
- // currentBaojianIndex],
|
|
|
|
282
|
- // 'name': controller.text,
|
|
|
|
283
|
- // 'pnumMin': pnumMin,
|
|
|
|
284
|
- // 'pnumMax': pnumMax,
|
|
|
|
285
|
- // 'mulcreate':
|
|
|
|
286
|
- // mulCreate.toString(),
|
|
|
|
287
|
- // 'tablenum':
|
|
|
|
288
|
- // _norNumController.text
|
|
|
|
289
|
- String rid;
|
|
|
|
290
|
- for (Area item in tableManagerModel.areas) {
|
|
|
|
291
|
- if (item.name == tableManagerModel.currentArea) {
|
|
|
|
292
|
- rid = item.rid;
|
|
|
|
293
|
- }
|
|
|
|
294
|
- }
|
|
|
|
295
|
-
|
443
|
+ name: table.name,
|
|
|
|
444
|
+ tidStr: table.tidStr,
|
|
|
|
445
|
+ pnumMin: table.table_pnum ?? '',
|
|
|
|
446
|
+ pnumMax: table.most_pnum ?? '',
|
|
|
|
447
|
+ isLock: table.isLock ?? '0',
|
|
|
|
448
|
+ isMerge: table.isMerge ?? '0',
|
|
|
|
449
|
+ tableid: table.id,
|
|
|
|
450
|
+ table: table,
|
|
|
|
451
|
+ selectTables: selectTables,
|
|
|
|
452
|
+ onTapDel: (Map<String, dynamic> value) async {
|
|
296
|
Map<String, String> params = {
|
453
|
Map<String, String> params = {
|
|
297
|
- 'rid': rid,
|
454
|
+ 'sid': Provider.of<UserModel>(context, listen: false)
|
|
|
|
455
|
+ .user
|
|
|
|
456
|
+ .sellerid,
|
|
|
|
457
|
+ 'tid': table.id
|
|
298
|
};
|
458
|
};
|
|
299
|
- String tid;
|
|
|
|
300
|
- for (int i = 0;
|
|
|
|
301
|
- i < tableManagerModel.tableTypeList.length;
|
|
|
|
302
|
- i++) {
|
|
|
|
303
|
- if (value['bjtype'] ==
|
|
|
|
304
|
- tableManagerModel.tableTypeList[i].name) {
|
|
|
|
305
|
- tid = tableManagerModel.tableTypeList[i].id;
|
|
|
|
306
|
- }
|
|
|
|
307
|
- }
|
|
|
|
308
|
- if (value['mulcreate'] == 'true') {
|
|
|
|
309
|
- //批量创建
|
|
|
|
310
|
- params['tablenum'] = value['tablenum'];
|
|
|
|
311
|
- params['pnum'] = '10';
|
|
|
|
312
|
- params['most_pnum'] = '10';
|
|
|
|
313
|
- // params['name'] = 'lll';
|
|
|
|
314
|
- } else {
|
|
|
|
315
|
- //单个创建
|
|
|
|
316
|
- params['name'] = value['name'];
|
|
|
|
317
|
- if (value['pnumMin'] != '') {
|
|
|
|
318
|
- params['pnum'] = value['pnumMin'];
|
|
|
|
319
|
- }
|
|
|
|
320
|
- if (value['pnumMax'] != '') {
|
|
|
|
321
|
- params['most_pnum'] = value['pnumMax'];
|
|
|
|
322
|
- }
|
|
|
|
323
|
- }
|
|
|
|
324
|
|
459
|
|
|
325
|
- bool success = await tableManagerModel
|
|
|
|
326
|
- .addTable(context, params, tid: tid);
|
460
|
+ bool success = await tableManagerModel.delSellerTables(
|
|
|
|
461
|
+ context, params);
|
|
327
|
print(success);
|
462
|
print(success);
|
|
328
|
if (success) {
|
463
|
if (success) {
|
|
329
|
- Utils.showToast('添加成功!');
|
464
|
+ Utils.showToast('删除成功!');
|
|
330
|
// TableOuter tableOuter = TableOuter();
|
465
|
// TableOuter tableOuter = TableOuter();
|
|
331
|
// tableOuter.name = value;
|
466
|
// tableOuter.name = value;
|
|
332
|
// tableOuter.list = [];
|
467
|
// tableOuter.list = [];
|
|
@@ -341,191 +476,113 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> { |
|
@@ -341,191 +476,113 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> { |
|
341
|
// .getTableList(context);
|
476
|
// .getTableList(context);
|
|
342
|
// await tableManagerModel
|
477
|
// await tableManagerModel
|
|
343
|
// .initData();
|
478
|
// .initData();
|
|
344
|
- // TableManagerModel tableManagerModel1 =
|
479
|
+ // TableManagerModel tableManagerModel =
|
|
345
|
// Provider.of<TableManagerModel>(context,
|
480
|
// Provider.of<TableManagerModel>(context,
|
|
346
|
// listen: false);
|
481
|
// listen: false);
|
|
347
|
- // tableManagerModel1.getTableList(
|
482
|
+ // tableManagerModel.getTableList(
|
|
348
|
// context,
|
483
|
// context,
|
|
349
|
// needLoading: false,
|
484
|
// needLoading: false,
|
|
350
|
// );
|
485
|
// );
|
|
351
|
await tableManagerModel.refreshTable(context);
|
486
|
await tableManagerModel.refreshTable(context);
|
|
352
|
}
|
487
|
}
|
|
353
|
- });
|
|
|
|
354
|
- },
|
|
|
|
355
|
- child: Container(
|
|
|
|
356
|
- child: DottedBorder(
|
|
|
|
357
|
- dashPattern: [8, 8, 8, 8],
|
|
|
|
358
|
- borderType: BorderType.RRect,
|
|
|
|
359
|
- radius: Radius.circular(ScreenUtil().setWidth(10)),
|
|
|
|
360
|
- // padding: EdgeInsets.all(ScreenUtil().setWidth(70)),
|
|
|
|
361
|
- color: MyColours.color_438E93,
|
|
|
|
362
|
- strokeWidth: ScreenUtil().setWidth(2),
|
|
|
|
363
|
- child: ClipRRect(
|
|
|
|
364
|
- borderRadius: BorderRadius.all(
|
|
|
|
365
|
- Radius.circular(ScreenUtil().setWidth(10))),
|
|
|
|
366
|
- child: Container(
|
|
|
|
367
|
- height: ScreenUtil().screenWidth -
|
|
|
|
368
|
- ScreenUtil().setWidth(48 * 3 + 32 * 2),
|
|
|
|
369
|
- width: ScreenUtil().screenWidth -
|
|
|
|
370
|
- ScreenUtil().setWidth(48 * 3 + 32 * 2),
|
|
|
|
371
|
- child: Column(
|
|
|
|
372
|
- mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
373
|
- children: [
|
|
|
|
374
|
- Image.asset(Utils.getImgPath('add_area'),
|
|
|
|
375
|
- width: ScreenUtil().setWidth(60)),
|
|
|
|
376
|
- ],
|
|
|
|
377
|
- ),
|
|
|
|
378
|
- ),
|
|
|
|
379
|
- ),
|
|
|
|
380
|
- ))));
|
|
|
|
381
|
- } else {
|
|
|
|
382
|
- return Selector<MyTableManageHomeModel, t.Table>(
|
|
|
|
383
|
- shouldRebuild: (pre, next) => true,
|
|
|
|
384
|
- selector: (context, model) =>
|
|
|
|
385
|
- tableManagerModel.tableOuterList[i].list[index],
|
|
|
|
386
|
- builder: (context, table, _) {
|
|
|
|
387
|
- return ManageTableItem(table,
|
|
|
|
388
|
- canMulSelected: tableManagerModel.tableOuterList[i].isSelect,
|
|
|
|
389
|
- onSelected: (table) async {
|
|
|
|
390
|
- if (tableManagerModel.tableOuterList[i].isSelect) {
|
|
|
|
391
|
- //多选
|
|
|
|
392
|
- setState(() {
|
|
|
|
393
|
- table.selected = !(table.selected ?? false);
|
|
|
|
394
|
- });
|
|
|
|
395
|
- if (table.selected) {
|
|
|
|
396
|
- tableManagerModel.tableOuterList[i].selectTables.add(table);
|
|
|
|
397
|
- } else {
|
|
|
|
398
|
- tableManagerModel.tableOuterList[i].selectTables
|
|
|
|
399
|
- .removeWhere((t) => t.id == table.id);
|
|
|
|
400
|
- }
|
|
|
|
401
|
- // tableManagerModel
|
|
|
|
402
|
- // .tableOuterList[tableManagerModel.selectNumber]
|
|
|
|
403
|
- // .isAll =
|
|
|
|
404
|
- // tableManagerModel.tableOuterList[i].list
|
|
|
|
405
|
- // .every((element) => element.selected);
|
|
|
|
406
|
- } else {
|
|
|
|
407
|
- // for (t.Table item
|
|
|
|
408
|
- // in tableManagerModel.tableOuterList[i].list) {
|
|
|
|
409
|
- // item.selected = false;
|
|
|
|
410
|
- // }
|
|
|
|
411
|
- // tableManagerModel.tableOuterList[i].selectTables = [];
|
|
|
|
412
|
- // //单选
|
|
|
|
413
|
- // setState(() {
|
|
|
|
414
|
- // table.selected = true;
|
|
|
|
415
|
- // });
|
|
|
|
416
|
- //修改桌位
|
|
|
|
417
|
- print(table);
|
|
|
|
418
|
- List<String> tableTypeS = [];
|
|
|
|
419
|
- for (int i = 0;
|
|
|
|
420
|
- i < tableManagerModel.tableTypeList.length;
|
|
|
|
421
|
- i++) {
|
|
|
|
422
|
- tableTypeS.add(tableManagerModel.tableTypeList[i].name);
|
|
|
|
423
|
- }
|
|
|
|
424
|
- List<t.Table> selectTables = [];
|
|
|
|
425
|
- if (table.tids != null && table.tids.length > 0) {
|
|
|
|
426
|
- List<String> tids = table.tids.split(',');
|
|
|
|
427
|
- tableManagerModel.tableOuterList.forEach((element) {
|
|
|
|
428
|
- element.list.forEach((table) {
|
|
|
|
429
|
- tids.forEach((tid) {
|
|
|
|
430
|
- if (tid == table.id) {
|
|
|
|
431
|
- selectTables.add(table);
|
|
|
|
432
|
- }
|
|
|
|
433
|
- });
|
|
|
|
434
|
- });
|
|
|
|
435
|
- });
|
|
|
|
436
|
- }
|
|
|
|
437
|
- await DialogUtil.openMyTableManageModifyTableDialog(
|
|
|
|
438
|
- context, tableTypeS, personNumList,
|
|
|
|
439
|
- name: table.name,
|
|
|
|
440
|
- tidStr: table.tidStr,
|
|
|
|
441
|
- pnumMin: table.table_pnum ?? '',
|
|
|
|
442
|
- pnumMax: table.most_pnum ?? '',
|
|
|
|
443
|
- isLock: table.isLock ?? '0',
|
|
|
|
444
|
- isMerge: table.isMerge ?? '0',
|
|
|
|
445
|
- tableid: table.id,
|
|
|
|
446
|
- table: table,
|
|
|
|
447
|
- selectTables: selectTables,
|
|
|
|
448
|
- onTapDel: (Map<String, dynamic> value) async {
|
|
|
|
449
|
- Map<String, String> params = {
|
|
|
|
450
|
- 'sid': Provider.of<UserModel>(context, listen: false)
|
|
|
|
451
|
- .user
|
|
|
|
452
|
- .sellerid,
|
|
|
|
453
|
- 'tid': table.id
|
|
|
|
454
|
- };
|
|
|
|
455
|
-
|
|
|
|
456
|
- bool success = await tableManagerModel.delSellerTables(
|
|
|
|
457
|
- context, params);
|
|
|
|
458
|
- print(success);
|
|
|
|
459
|
- if (success) {
|
|
|
|
460
|
- Utils.showToast('删除成功!');
|
|
|
|
461
|
- // TableOuter tableOuter = TableOuter();
|
|
|
|
462
|
- // tableOuter.name = value;
|
|
|
|
463
|
- // tableOuter.list = [];
|
|
|
|
464
|
- // tableManagerModel.tableOuterList.add(tableOuter);
|
|
|
|
465
|
- // tableManagerModel.initData();
|
|
|
|
466
|
- // Timer(
|
|
|
|
467
|
- // Duration(milliseconds: 500),
|
|
|
|
468
|
- // () => _areaController.jumpTo(
|
|
|
|
469
|
- // _areaController.position.maxScrollExtent));
|
|
|
|
470
|
-
|
|
|
|
471
|
- // await tableManagerModel
|
|
|
|
472
|
- // .getTableList(context);
|
|
|
|
473
|
- // await tableManagerModel
|
|
|
|
474
|
- // .initData();
|
|
|
|
475
|
- // TableManagerModel tableManagerModel =
|
|
|
|
476
|
- // Provider.of<TableManagerModel>(context,
|
|
|
|
477
|
- // listen: false);
|
|
|
|
478
|
- // tableManagerModel.getTableList(
|
|
|
|
479
|
- // context,
|
|
|
|
480
|
- // needLoading: false,
|
|
|
|
481
|
- // );
|
|
|
|
482
|
- await tableManagerModel.refreshTable(context);
|
|
|
|
483
|
- }
|
|
|
|
484
|
- }, onTap: (Map<String, String> value) async {
|
|
|
|
485
|
- // String rid;
|
|
|
|
486
|
- // for (Area item in tableManagerModel.areas) {
|
|
|
|
487
|
- // if (item.name == tableManagerModel.currentArea) {
|
|
|
|
488
|
- // rid = item.rid;
|
|
|
|
489
|
- // }
|
|
|
|
490
|
- // }
|
|
|
|
491
|
-
|
|
|
|
492
|
- // Map<String, String> params = {
|
|
|
|
493
|
- // 'rid': rid,
|
|
|
|
494
|
- // };
|
|
|
|
495
|
- _setData(value, table);
|
488
|
+ }, onTap: (Map<String, String> value) async {
|
|
|
|
489
|
+ // String rid;
|
|
|
|
490
|
+ // for (Area item in tableManagerModel.areas) {
|
|
|
|
491
|
+ // if (item.name == tableManagerModel.currentArea) {
|
|
|
|
492
|
+ // rid = item.rid;
|
|
|
|
493
|
+ // }
|
|
|
|
494
|
+ // }
|
|
|
|
495
|
+
|
|
|
|
496
|
+ // Map<String, String> params = {
|
|
|
|
497
|
+ // 'rid': rid,
|
|
|
|
498
|
+ // };
|
|
|
|
499
|
+ _setData(value, table);
|
|
496
|
|
500
|
|
|
497
|
// if(isMerge == '1'){
|
501
|
// if(isMerge == '1'){
|
|
498
|
// //
|
502
|
// //
|
|
499
|
// }
|
503
|
// }
|
|
500
|
|
504
|
|
|
501
|
- // if (success) {
|
|
|
|
502
|
- // Utils.showToast('修改成功!');
|
|
|
|
503
|
- // // TableOuter tableOuter = TableOuter();
|
|
|
|
504
|
- // // tableOuter.name = value;
|
|
|
|
505
|
- // // tableOuter.list = [];
|
|
|
|
506
|
- // // tableManagerModel.tableOuterList.add(tableOuter);
|
|
|
|
507
|
- // // tableManagerModel.initData();
|
|
|
|
508
|
- // // Timer(
|
|
|
|
509
|
- // // Duration(milliseconds: 500),
|
|
|
|
510
|
- // // () => _areaController.jumpTo(
|
|
|
|
511
|
- // // _areaController.position.maxScrollExtent));
|
|
|
|
512
|
-
|
|
|
|
513
|
- // // await tableManagerModel
|
|
|
|
514
|
- // // .getTableList(context);
|
|
|
|
515
|
- // // await tableManagerModel
|
|
|
|
516
|
- // // .initData();
|
|
|
|
517
|
- // await tableManagerModel.refreshTable(context);
|
|
|
|
518
|
- // }
|
|
|
|
519
|
- });
|
|
|
|
520
|
- }
|
|
|
|
521
|
- });
|
|
|
|
522
|
- },
|
|
|
|
523
|
- );
|
|
|
|
524
|
- }
|
|
|
|
525
|
- },
|
505
|
+ // if (success) {
|
|
|
|
506
|
+ // Utils.showToast('修改成功!');
|
|
|
|
507
|
+ // // TableOuter tableOuter = TableOuter();
|
|
|
|
508
|
+ // // tableOuter.name = value;
|
|
|
|
509
|
+ // // tableOuter.list = [];
|
|
|
|
510
|
+ // // tableManagerModel.tableOuterList.add(tableOuter);
|
|
|
|
511
|
+ // // tableManagerModel.initData();
|
|
|
|
512
|
+ // // Timer(
|
|
|
|
513
|
+ // // Duration(milliseconds: 500),
|
|
|
|
514
|
+ // // () => _areaController.jumpTo(
|
|
|
|
515
|
+ // // _areaController.position.maxScrollExtent));
|
|
|
|
516
|
+
|
|
|
|
517
|
+ // // await tableManagerModel
|
|
|
|
518
|
+ // // .getTableList(context);
|
|
|
|
519
|
+ // // await tableManagerModel
|
|
|
|
520
|
+ // // .initData();
|
|
|
|
521
|
+ // await tableManagerModel.refreshTable(context);
|
|
|
|
522
|
+ // }
|
|
|
|
523
|
+ });
|
|
|
|
524
|
+ }
|
|
|
|
525
|
+ });
|
|
|
|
526
|
+ },
|
|
|
|
527
|
+ ));
|
|
|
|
528
|
+ }
|
|
|
|
529
|
+
|
|
|
|
530
|
+ // draggableGridItem = DraggableGridItem(
|
|
|
|
531
|
+ // dragCallback: (context, isDragging) {
|
|
|
|
532
|
+ // print('isDragging: $isDragging');
|
|
|
|
533
|
+ // },
|
|
|
|
534
|
+ // child: Container(
|
|
|
|
535
|
+ // color: Colors.red,
|
|
|
|
536
|
+ // width: 100,
|
|
|
|
537
|
+ // height: 100,
|
|
|
|
538
|
+ // ),isDraggable: true);
|
|
|
|
539
|
+ _listOfDraggableGridItem.add(draggableGridItem);
|
|
|
|
540
|
+ }
|
|
|
|
541
|
+
|
|
|
|
542
|
+ return DraggableGridViewBuilder(
|
|
|
|
543
|
+ controller: controller,
|
|
|
|
544
|
+ // physics: NeverScrollableScrollPhysics(),
|
|
|
|
545
|
+
|
|
|
|
546
|
+ shrinkWrap: true,
|
|
|
|
547
|
+ // itemCount: tableManagerModel.tableOuterList[i].list.length + 1,
|
|
|
|
548
|
+ gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
549
|
+ crossAxisCount: 4,
|
|
|
|
550
|
+ childAspectRatio: 1,
|
|
|
|
551
|
+ mainAxisSpacing: ScreenUtil().setWidth(28),
|
|
|
|
552
|
+ crossAxisSpacing: ScreenUtil().setWidth(48),
|
|
|
|
553
|
+ ),
|
|
|
|
554
|
+ children: _listOfDraggableGridItem,
|
|
|
|
555
|
+
|
|
|
|
556
|
+ dragCompletion: onDragAccept,
|
|
|
|
557
|
+ isOnlyLongPress: true,
|
|
|
|
558
|
+ dragFeedback: feedback,
|
|
|
|
559
|
+ dragPlaceHolder: placeHolder,
|
|
|
|
560
|
+ );
|
|
|
|
561
|
+ }
|
|
|
|
562
|
+
|
|
|
|
563
|
+ Widget feedback(List<DraggableGridItem> list, int index) {
|
|
|
|
564
|
+ double size =
|
|
|
|
565
|
+ (ScreenUtil().screenWidth - ScreenUtil().setWidth(28) * 3) / 4;
|
|
|
|
566
|
+ return SizedBox(
|
|
|
|
567
|
+ width: size * 0.8,
|
|
|
|
568
|
+ height: size * 0.8,
|
|
|
|
569
|
+ child: list[index].child,
|
|
526
|
);
|
570
|
);
|
|
527
|
}
|
571
|
}
|
|
528
|
|
572
|
|
|
|
|
573
|
+ PlaceHolderWidget placeHolder(List<DraggableGridItem> list, int index) {
|
|
|
|
574
|
+ return PlaceHolderWidget(
|
|
|
|
575
|
+ child: Container(
|
|
|
|
576
|
+ color: Colors.white,
|
|
|
|
577
|
+ ),
|
|
|
|
578
|
+ );
|
|
|
|
579
|
+ }
|
|
|
|
580
|
+
|
|
|
|
581
|
+ void onDragAccept(
|
|
|
|
582
|
+ List<DraggableGridItem> list, int beforeIndex, int afterIndex) {
|
|
|
|
583
|
+ print('onDragAccept: $beforeIndex -> $afterIndex');
|
|
|
|
584
|
+ }
|
|
|
|
585
|
+
|
|
529
|
@override
|
586
|
@override
|
|
530
|
Widget build(BuildContext context) {
|
587
|
Widget build(BuildContext context) {
|
|
531
|
tableManagerModel =
|
588
|
tableManagerModel =
|