Commit ae4fe892be0676df322e92332e4b07e5f983fccd

Authored by wdn127929
1 parent c7ed10bc

合并桌位接口+桌位选中页面

@@ -29,6 +29,9 @@ class Table { @@ -29,6 +29,9 @@ class Table {
29 String pnum; //预计人数 29 String pnum; //预计人数
30 String nickName; //操作人 30 String nickName; //操作人
31 String noteName; //操作人 31 String noteName; //操作人
  32 + String isLock; //是否被合并上锁
  33 + String isMerge; //是否打开桌位合并开关
  34 + String tids; //被合并桌位tids
32 35
33 //获取桌位类型 36 //获取桌位类型
34 String get tidStr { 37 String get tidStr {
@@ -104,6 +107,6 @@ class Table { @@ -104,6 +107,6 @@ class Table {
104 107
105 @override 108 @override
106 String toString() { 109 String toString() {
107 - return 'Table{id: $id,isPhoto:$isPhoto rid: $rid, tid: $tid, name: $name, table_pnum: $table_pnum, most_pnum: $most_pnum, order_o: $order_o, status: $status, tablestatus: $tablestatus, enable: $enable, spell: $spell, rname: $rname, isExitsClass:$isExitsClass,max: $max, low: $low}'; 110 + return 'Table{id: $id,isPhoto:$isPhoto rid: $rid, tid: $tid, name: $name, table_pnum: $table_pnum, most_pnum: $most_pnum, order_o: $order_o, status: $status, tablestatus: $tablestatus, enable: $enable, spell: $spell, rname: $rname, isExitsClass:$isExitsClass,max: $max, low: $low, is_lock: $isLock, is_merge: $isMerge,tids:$tids}';
108 } 111 }
109 } 112 }
@@ -27,7 +27,10 @@ Table _$TableFromJson(Map<String, dynamic> json) { @@ -27,7 +27,10 @@ Table _$TableFromJson(Map<String, dynamic> json) {
27 ..sign = json['sign'] as String 27 ..sign = json['sign'] as String
28 ..reserver = json['reserver'] as String 28 ..reserver = json['reserver'] as String
29 ..notebookId = json['notebookId'] as String 29 ..notebookId = json['notebookId'] as String
30 - ..selected = json['selected'] as bool; 30 + ..selected = json['selected'] as bool
  31 + ..isLock = json['is_lock'] as String
  32 + ..isMerge = json['is_merge'] as String
  33 + ..tids = json['tids'] as String;
31 } 34 }
32 35
33 Map<String, dynamic> _$TableToJson(Table instance) => <String, dynamic>{ 36 Map<String, dynamic> _$TableToJson(Table instance) => <String, dynamic>{
@@ -50,5 +53,8 @@ Map<String, dynamic> _$TableToJson(Table instance) => <String, dynamic>{ @@ -50,5 +53,8 @@ Map<String, dynamic> _$TableToJson(Table instance) => <String, dynamic>{
50 'sign': instance.sign, 53 'sign': instance.sign,
51 'reserver': instance.reserver, 54 'reserver': instance.reserver,
52 'notebookId': instance.notebookId, 55 'notebookId': instance.notebookId,
53 - 'selected': instance.selected 56 + 'selected': instance.selected,
  57 + 'is_lock': instance.isLock,
  58 + 'is_merge': instance.isMerge,
  59 + 'tids': instance.tids
54 }; 60 };
@@ -9,6 +9,10 @@ class TableOuter { @@ -9,6 +9,10 @@ class TableOuter {
9 bool isAll = false; //全选 9 bool isAll = false; //全选
10 List<t.Table> selectTables = []; //选择的桌位 10 List<t.Table> selectTables = []; //选择的桌位
11 11
  12 + // bool get isAll {
  13 + // return list.every((element) => element.selected);
  14 + // }
  15 +
12 TableOuter(); 16 TableOuter();
13 17
14 factory TableOuter.fromJson(Map<String, dynamic> json) => TableOuter() 18 factory TableOuter.fromJson(Map<String, dynamic> json) => TableOuter()
@@ -334,4 +334,8 @@ class HttpUrl { @@ -334,4 +334,8 @@ class HttpUrl {
334 static const String set_cookbook_by_id = 334 static const String set_cookbook_by_id =
335 "?service=App.Cookbook.SetCookbookById"; //修改菜品 335 "?service=App.Cookbook.SetCookbookById"; //修改菜品
336 336
  337 + static const String merge_tables =
  338 + "?service=App.Tables.MergeTables"; // 合并桌位
  339 +
  340 +
337 } 341 }
  1 +import 'dart:ffi';
  2 +
  3 +import 'package:common_utils/common_utils.dart';
  4 +import 'package:dotted_border/dotted_border.dart';
  5 +import 'package:flutter/material.dart';
  6 +import 'package:flutter_screenutil/flutter_screenutil.dart';
  7 +import 'package:one_key/constant/state.dart';
  8 +import 'package:one_key/models/area.dart';
  9 +import 'package:one_key/models/notebook.dart';
  10 +import 'package:one_key/models/tableOuter.dart';
  11 +import 'package:one_key/models/table_list.dart';
  12 +import 'package:one_key/pages/table/area_item_table.dart';
  13 +import 'package:one_key/provider/choose_table_model.dart';
  14 +import 'package:one_key/provider/notebook_detail_change_model.dart';
  15 +import 'package:one_key/provider/notebook_model.dart';
  16 +import 'package:one_key/provider/user_model.dart';
  17 +import 'package:one_key/res/colors.dart';
  18 +import 'package:one_key/route/navigator_util.dart';
  19 +import 'package:one_key/utils/dialog_util.dart';
  20 +import 'package:one_key/utils/event_bus.dart';
  21 +import 'package:one_key/utils/utils.dart';
  22 +import 'package:one_key/widgets/MyDivider.dart';
  23 +import 'package:one_key/widgets/app_bar.dart';
  24 +import 'package:one_key/widgets/area_item.dart';
  25 +import 'package:one_key/widgets/common_button.dart';
  26 +import 'package:one_key/widgets/f_table_item.dart';
  27 +import 'package:one_key/widgets/h_empty_view.dart';
  28 +import 'package:one_key/widgets/merge_table_item.dart';
  29 +import 'package:one_key/widgets/page_exception.dart';
  30 +import 'package:one_key/widgets/round_button.dart';
  31 +import 'package:one_key/widgets/system_app_bar.dart';
  32 +import 'package:one_key/widgets/table_item.dart';
  33 +import 'package:one_key/models/table.dart' as t;
  34 +import 'package:one_key/widgets/v_empty_view.dart';
  35 +import 'package:provider/provider.dart';
  36 +import 'dart:convert' as convert;
  37 +
  38 +import '../../../utils/screen_util.dart';
  39 +
  40 +class MergeTableSelectPage extends StatefulWidget {
  41 + // final String rid; //预订id
  42 + // final DateTime dateTime; //日期
  43 + // final String ddate_slot; //时段
  44 + final bool canChoose; //变更预订可以取消原来已预订的选中状态
  45 + final List<TableList> tableList;
  46 + final String fromPage;
  47 + final String tid;
  48 + final String tableid;
  49 +
  50 + MergeTableSelectPage(
  51 + {this.canChoose = false,
  52 + this.tableList,
  53 + this.fromPage,
  54 + this.tid,
  55 + this.tableid});
  56 +
  57 + @override
  58 + State<StatefulWidget> createState() {
  59 + // TODO: implement createState
  60 + return new MergeTableSelectPageState();
  61 + }
  62 +}
  63 +
  64 +class MergeTableSelectPageState extends State<MergeTableSelectPage> {
  65 + List<Area> areas = []; //区域列表
  66 + List<t.Table> selectTables = []; //选择的桌位
  67 +
  68 + List<TableOuter> tableOuterList = []; //区域-桌位列表
  69 +
  70 + Map<String, List<t.Table>> areaTableMap = {}; //区域-桌位Map
  71 +
  72 + ChooseTableModel _chooseTableModel;
  73 +
  74 + Map<String, Notebook> tableMap = {}; //记录已预订桌位对应的订单
  75 +
  76 + String currentArea; //当前选中区域
  77 + List<String> personNumList = [];
  78 +
  79 + // int selectNum = 0;
  80 + bool isSelected = true; //全部按钮
  81 + int _selectNumber;
  82 + Map dailyMap = {}; // 早市对应半点钟,午市对应半点钟、晚市对应半点钟
  83 +
  84 + String selectTableId;
  85 +
  86 + @override
  87 + void initState() {
  88 + // TODO: implement initState
  89 + super.initState();
  90 + // for (int i = 1; i < 31; i++) {
  91 + // personNumList.add(i.toString());
  92 + // }
  93 + // initDateHourMinuteList(context);
  94 +
  95 + WidgetsBinding.instance.addPostFrameCallback((_) {
  96 + getTableList();
  97 + });
  98 + bus.on("refresh_photo_manager", (args) {
  99 + getTableList();
  100 + });
  101 + }
  102 +
  103 + @override
  104 + void dispose() {
  105 + super.dispose();
  106 + bus.off("refresh_photo_manager");
  107 + }
  108 +
  109 + /// 早市、午市、晚市对应的半个小时间隔时间段
  110 + // initDateHourMinuteList(BuildContext context) async {
  111 + // UserModel userModel = Provider.of<UserModel>(context, listen: false);
  112 + // String morning =
  113 + // userModel.user.morning.isEmpty ? "00:00-00:00" : userModel.user.morning;
  114 + // String noon =
  115 + // userModel.user.noon.isEmpty ? "00:00-00:00" : userModel.user.noon;
  116 + // String night =
  117 + // userModel.user.night.isEmpty ? "00:00-00:00" : userModel.user.night;
  118 + // userModel.user.morning == ''
  119 + // ? dailyMap.putIfAbsent('morning', () => '')
  120 + // : dailyMap.putIfAbsent(
  121 + // 'morning', () => _getHourAndMinute(userModel.user.morning, 1));
  122 + // userModel.user.noon == ''
  123 + // ? dailyMap.putIfAbsent('noon', () => '')
  124 + // : dailyMap.putIfAbsent(
  125 + // 'noon', () => _getHourAndMinute(userModel.user.noon, 2));
  126 + // userModel.user.night == ''
  127 + // ? dailyMap.putIfAbsent('night', () => '')
  128 + // : dailyMap.putIfAbsent(
  129 + // 'night', () => _getHourAndMinute(userModel.user.night, 3));
  130 + // // _initSunDateList(
  131 + // // userModel.user.morning, userModel.user.noon, userModel.user.night);
  132 + // }
  133 +
  134 + //根据获取时间 11:00-12:30 获取30分钟间隔组装的数组
  135 + // _getHourAndMinute(String hourAndMinuteStr, int mnd) {
  136 + // List tempDate = hourAndMinuteStr.split("-");
  137 + // String beginDate = tempDate[0];
  138 + // String endDate = tempDate[1];
  139 + // List tempHour = beginDate.split(':');
  140 +
  141 + // /*获取开始小时*/
  142 + // int beginHour = int.parse(tempHour[0]);
  143 + // /*获取开始分钟*/
  144 + // int beginMinute = int.parse(tempHour[1]);
  145 + // List res = [];
  146 + // bool tempLimit = true;
  147 + // while (tempLimit) {
  148 + // String temp = _dealTime(beginHour, beginMinute);
  149 +
  150 + // // bool tempSelect = false;
  151 +
  152 + // // Map tempMap = {'title': temp, 'select': tempSelect};
  153 + // res.add(temp);
  154 + // if (temp == endDate) {
  155 + // tempLimit = false;
  156 + // break;
  157 + // }
  158 + // if (beginMinute == 30) {
  159 + // beginHour++;
  160 + // if (beginHour >= 24) {
  161 + // beginHour = 0;
  162 + // }
  163 + // }
  164 + // beginMinute = (beginMinute + 30) % 60;
  165 + // }
  166 + // return res;
  167 + // }
  168 +
  169 + // /// 根据时间和分钟组装 格式:11:00
  170 + // _dealTime(int begin, int mm) {
  171 + // String sb = '';
  172 + // if (begin < 10) {
  173 + // sb = '0$begin';
  174 + // } else {
  175 + // sb = '$begin';
  176 + // }
  177 + // sb = '$sb:';
  178 + // if (mm < 10) {
  179 + // sb = '${sb}0${mm}';
  180 + // } else {
  181 + // sb = '${sb}${mm}';
  182 + // }
  183 + // return sb;
  184 + // }
  185 +
  186 + //获取桌位列表
  187 + getTableList({needLoading = true}) async {
  188 + UserModel userModel = Provider.of<UserModel>(context, listen: false);
  189 + Map<String, String> params = {"sellerid": userModel.user.sellerid};
  190 + tableOuterList = await _chooseTableModel.getTableList(context, params,
  191 + needLoading: needLoading);
  192 + _chooseTableModel.tablesAll = [];
  193 + tableOuterList.forEach((element) {
  194 + element.list.removeWhere((value) => value.id == widget.tableid);
  195 + });
  196 + print(tableOuterList);
  197 +
  198 + for (TableOuter item in tableOuterList) {
  199 + // if (item.name == "推荐") {
  200 + // itemModelList.remove(item);
  201 + // }
  202 + for (var item1 in item.list) {
  203 + item1.selected = false;
  204 + for (var table in widget.tableList) {
  205 + if (item1.id == table.id) {
  206 + item1.selected = true;
  207 + // selectNum++;
  208 + selectTables.add(tableListToTable(table));
  209 +
  210 + // if (!tableList.contains(item)) {
  211 + // tableList.add(item);
  212 + // }
  213 + }
  214 + }
  215 + }
  216 + //如果当前的桌子全部选中,则全选按钮---选中状态
  217 + item.isAll = item.list.every((element) => element.selected);
  218 + // selectAreaAll[]
  219 +
  220 + print(selectTables);
  221 + _chooseTableModel.tablesAll.addAll(item.list);
  222 + }
  223 +
  224 + if (tableOuterList.isEmpty) {
  225 + _chooseTableModel.pageState = PageState.Success;
  226 + _chooseTableModel.notifyListeners();
  227 + } else {
  228 + initData();
  229 + // _getReserveList(userModel.user.sellerid, needLoading: needLoading);
  230 + }
  231 + // if (_chooseTableModel.pageState == PageState.Success) {
  232 +
  233 + // }
  234 + }
  235 +
  236 + refreshTable(context) async {
  237 + await getTableList(needLoading: false);
  238 + // if (temp.length > 0) {
  239 + // _getReserveList(context, needLoading: false);
  240 + // } else {
  241 + // // pageState = PageState.Empty;
  242 + // _chooseTableModel.pageState = PageState.Success;
  243 + // _chooseTableModel.notifyListeners();
  244 + // }
  245 + }
  246 +
  247 + //获取已预订列表
  248 + // _getReserveList(String sid, {needLoading = true}) async {
  249 + // NoteBookModel model = new NoteBookModel();
  250 + // Map<String, String> params = {
  251 + // "sid": sid,
  252 + // "rdate": _getRdate(),
  253 + // "ddate_solt": widget.ddate_slot,
  254 + // "y": "200",
  255 + // "x": "1",
  256 + // "keywords": "",
  257 + // "sort": "1"
  258 + // };
  259 + // List<Notebook> noteBooks =
  260 + // await model.getReserveList(context, params, needLoading: needLoading);
  261 + // for (Notebook notebook in noteBooks) {
  262 + // if (notebook.tid.isEmpty) continue;
  263 + // if (notebook.status == "1" ||
  264 + // notebook.status == "2" ||
  265 + // notebook.status == "5") {
  266 + // //已预订,用餐中,已安排
  267 + // List<String> tids = notebook.tid.split(",");
  268 + // for (String tid in tids) {
  269 + // tableMap["$tid"] = notebook;
  270 + // }
  271 + // }
  272 + // }
  273 + // print(tableMap);
  274 + // if (needLoading) {
  275 + // initData();
  276 + // } else {
  277 + // initData(needRetain: true);
  278 + // }
  279 + // }
  280 +
  281 + // //初始桌位数据
  282 + initData({bool needRetain = false}) {
  283 + areas.clear();
  284 + areaTableMap.clear();
  285 + List<t.Table> tempTableAll = [];
  286 + tempTableAll.addAll(_chooseTableModel.tablesAll);
  287 + for (TableOuter outer in tableOuterList) {
  288 + int count = 0;
  289 + List<t.Table> tempList = [];
  290 + tempList.addAll(outer.list);
  291 + for (t.Table table in outer.list) {
  292 + // table.selected = false;
  293 + if (widget.tid != '' && table.id == widget.tid) {
  294 + table.selected = true;
  295 + currentArea = outer.name;
  296 + }
  297 + if (table.id == selectTableId) {
  298 + table.selected = true;
  299 + currentArea = outer.name;
  300 + }
  301 + // if (table.tablestatus == "0") {
  302 + // //没有用餐中
  303 + // if (tableMap["${table.id}"] != null) {
  304 + // Notebook notebook = tableMap["${table.id}"];
  305 + // table.sign = notebook.status;
  306 + // table.notebookId = notebook.id;
  307 + // table.reserver = notebook.rnameStr;
  308 + // table.pnum = notebook.actual_pnum;
  309 + // table.nickName = notebook.nick_name;
  310 + // table.noteName = notebook.note_name;
  311 + // //(不能移除自己定的桌子)
  312 + // String idNow = '';
  313 + // if (tableMap.containsKey('${table.id}')) {
  314 + // //包含,证明该桌子已经被预订了
  315 + // idNow = tableMap['${table.id}'].id;
  316 + // if (idNow != widget.rid) {
  317 + // //不是自己的当前订单
  318 + // //剔除已经预订的桌子,剩下空桌子(仅看空座)
  319 + // tempList.remove(table);
  320 + // //全部
  321 + // tempTableAll.remove(table);
  322 + // }
  323 + // }
  324 + // } else {
  325 + // table.sign = "";
  326 + // table.notebookId = "";
  327 + // if (table.enable == "1") {
  328 + // count++;
  329 + // }
  330 + // }
  331 + // } else {
  332 + // table.sign = "2";
  333 + // table.notebookId = "";
  334 + // }
  335 + }
  336 +
  337 + areaTableMap["${outer.name}"] = outer.list;
  338 +
  339 + _chooseTableModel.areaTableMapCanNote["${outer.name}"] = tempList;
  340 + Area area = Area();
  341 + area.name = outer.name;
  342 + area.count = outer.list.length == 0 ? -1 : count;
  343 + area.rid = outer.list.length == 0 ? outer.rid : outer.list[0].rid;
  344 + areas.add(area);
  345 + }
  346 + _chooseTableModel.tablesCanNote = tempTableAll;
  347 + // if (_chooseTableModel.swichState) {
  348 + // _chooseTableModel.areaTableMapShow =
  349 + // _chooseTableModel.areaTableMapCanNote;
  350 + // _chooseTableModel.tablesShow = _chooseTableModel.tablesCanNote;
  351 + // } else {
  352 + _chooseTableModel.areaTableMapShow = areaTableMap;
  353 + _chooseTableModel.tablesShow = _chooseTableModel.tablesAll;
  354 + // }
  355 +
  356 + if (areaTableMap.isNotEmpty) {
  357 + // if (!needRetain) {
  358 + // currentArea = '全部';
  359 + // _chooseTableModel.currentTables = _chooseTableModel.tablesAll;
  360 + // } else {
  361 + if (currentArea != null && currentArea != '') {
  362 + // tablesShow = areaTableMapShow[currentArea];
  363 + List keys = areaTableMap.keys.toList();
  364 + _selectNumber = keys.indexOf(currentArea);
  365 + } else {
  366 + currentArea = areas[0].name;
  367 + List keys = areaTableMap.keys.toList();
  368 + _selectNumber = keys.indexOf(currentArea);
  369 + }
  370 + // }
  371 + } else {
  372 + // if (currentArea != null && currentArea != '') {
  373 + // tablesShow = areaTableMap[currentArea];
  374 + // _selectNumber = areaTableMap.length;
  375 + // }
  376 + // pageState = PageState.Empty;
  377 + // pageState = PageState.Success;
  378 + }
  379 + // if (widget.tid == '') {
  380 + // if (!needRetain) {
  381 + // // currentArea = areaTableMap.keys.first;
  382 + // currentArea = '全部';
  383 + // _chooseTableModel.currentTables = _chooseTableModel.tablesAll;
  384 + // } else {
  385 + // if (currentArea != null && currentArea != '') {
  386 + // // tablesShow = areaTableMapShow[currentArea];
  387 + // List keys = areaTableMap.keys.toList();
  388 + // _selectNumber = keys.indexOf(currentArea);
  389 + // }
  390 + // }
  391 + // if (areas.length == 1) {
  392 + // currentArea = areaTableMap.keys.first;
  393 + // }
  394 + // } else {
  395 + // // if (currentArea != null && currentArea != '') {
  396 + // // tablesShow = areaTableMapShow[currentArea];
  397 + // // selectNumber = areaTableMapShow.length;
  398 + // // }
  399 + // // // pageState = PageState.Empty;
  400 + // // pageState = PageState.Success;
  401 + // }
  402 +
  403 + _chooseTableModel.pageState = PageState.Success;
  404 + _chooseTableModel.notifyListeners();
  405 + }
  406 +
  407 + //获取一天开始-结束时间字符串
  408 + // String _getRdate() {
  409 + // String keys = '';
  410 +
  411 + // if (widget.ddate_slot == '1') {
  412 + // //早市
  413 + // keys = 'morning';
  414 + // } else if (widget.ddate_slot == '2') {
  415 + // //午市
  416 + // keys = 'noon';
  417 + // } else if (widget.ddate_slot == '3') {
  418 + // //晚市
  419 + // keys = 'night';
  420 + // }
  421 + // String ymd =
  422 + // DateUtil.formatDate(widget.dateTime, format: DateFormats.y_mo_d);
  423 + // String timeStrStart = '';
  424 + // String timeStrEnd = '';
  425 + // //一天开始时间
  426 + // double startDay;
  427 + // //一天结束时间
  428 + // double endDay;
  429 + // if (keys != '') {
  430 + // List temp = dailyMap[keys];
  431 + // timeStrStart = ymd + ' ' + temp.first + ':00';
  432 + // timeStrEnd = ymd + ' ' + temp.last + ':00';
  433 + // } else {
  434 + // timeStrStart = widget.dateTime.year.toString() +
  435 + // "-" +
  436 + // Utils.addZeroNumber(widget.dateTime.month) +
  437 + // "-" +
  438 + // Utils.addZeroNumber(widget.dateTime.day) +
  439 + // " 00:00:00";
  440 + // timeStrEnd = widget.dateTime.year.toString() +
  441 + // "-" +
  442 + // Utils.addZeroNumber(widget.dateTime.month) +
  443 + // "-" +
  444 + // Utils.addZeroNumber(widget.dateTime.day) +
  445 + // " 23:59:59";
  446 + // }
  447 + // startDay = (DateTime.parse(timeStrStart).millisecondsSinceEpoch) / 1000;
  448 + // endDay = (DateTime.parse(timeStrEnd).millisecondsSinceEpoch) / 1000;
  449 + // return startDay.floor().toString() + "-" + endDay.floor().toString();
  450 + // }
  451 +
  452 + Widget item(int i) {
  453 + return Column(
  454 + children: [
  455 + _chooseTableModel.areaTableMapShow[areas[i].name].length > 0
  456 + ? InkWell(
  457 + onTap: () {
  458 + tableOuterList[i].isAll = !tableOuterList[i].isAll;
  459 + tableOuterList[i].list.forEach((element) {
  460 + element.selected = tableOuterList[i].isAll;
  461 + });
  462 +
  463 + if (tableOuterList[i].isAll) {
  464 + //移除当前区域原来的选中的桌子
  465 + tableOuterList[i].list.forEach((value) {
  466 + selectTables
  467 + .removeWhere((element) => value.id == element.id);
  468 + });
  469 +
  470 + //加入当前区域全部桌子
  471 + tableOuterList[i].list.forEach((value) {
  472 + selectTables.add(value);
  473 + });
  474 +
  475 + //全选
  476 + // object.addAll(elements)
  477 +
  478 + } else {
  479 + //取消全选
  480 + tableOuterList[i].list.forEach((value) {
  481 + selectTables
  482 + .removeWhere((element) => element.id == value.id);
  483 + });
  484 + // selectNum = selectNum-
  485 + }
  486 + // selectNum++;
  487 + // selectTables.add(table);
  488 + print(selectTables);
  489 + setState(() {});
  490 + },
  491 + child: Padding(
  492 + padding: EdgeInsets.symmetric(
  493 + horizontal: w(24), vertical: w(16)),
  494 + child: Row(
  495 + children: [
  496 + Image.asset(
  497 + Utils.getImgPath(
  498 + tableOuterList[i].isAll ? 'select' : 'unselect'),
  499 + width: w(20),
  500 + ),
  501 + HEmptyView(4),
  502 + Text(
  503 + '全选',
  504 + style: TextStyle(
  505 + fontSize: font(16),
  506 + color: MyColours.color_515151),
  507 + )
  508 + ],
  509 + )))
  510 + : SizedBox(),
  511 + GridView.builder(
  512 + // controller: _areaController,
  513 + // physics: NeverScrollableScrollPhysics(),
  514 + padding: EdgeInsets.symmetric(
  515 + vertical: ScreenUtil().setWidth(20),
  516 + horizontal: ScreenUtil().setWidth(64)),
  517 + shrinkWrap: true,
  518 + itemCount: _chooseTableModel.tablesShow.length == 0 ||
  519 + (i != null &&
  520 + _chooseTableModel
  521 + .areaTableMapShow[areas[i].name].length ==
  522 + 0)
  523 + ? 0
  524 + : _chooseTableModel.areaTableMapShow[areas[i].name].length,
  525 + // itemCount: _chooseTableModel.tablesShow.length == 0 ||
  526 + // (i != null &&
  527 + // _chooseTableModel.areaTableMapShow[areas[i].name].length == 0)
  528 + // ? 0
  529 + // : currentArea == '全部'
  530 + // ? _chooseTableModel.tablesShow.length
  531 + // : _chooseTableModel.areaTableMapShow[areas[i].name].length,
  532 + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  533 + crossAxisCount: 4,
  534 + childAspectRatio: 1,
  535 + mainAxisSpacing: ScreenUtil().setWidth(28),
  536 + crossAxisSpacing: ScreenUtil().setWidth(48),
  537 + ),
  538 +
  539 + itemBuilder: (BuildContext context, int index) {
  540 + List<t.Table> data = _chooseTableModel.tablesShow.length == 0 ||
  541 + (i != null &&
  542 + _chooseTableModel
  543 + .areaTableMapShow[areas[i].name].length ==
  544 + 0)
  545 + ? 0
  546 + : _chooseTableModel.areaTableMapShow[areas[i].name];
  547 + // if (index == data.length || data.length == 0) {
  548 + // return InkWell(
  549 + // onTap: () async {
  550 + // List<String> areasTemp = [];
  551 + // for (int i = 0; i < areas.length; i++) {
  552 + // areasTemp.add(areas[i].name);
  553 + // }
  554 +
  555 + // //添加桌位弹框
  556 + // await DialogUtil.openCreateTableDialog(
  557 + // context, areasTemp, i, personNumList,
  558 + // onTap: (Map<String, String> value) async {
  559 + // print(value);
  560 + // // 'areaname':
  561 + // // areas[currentAreaIndex],
  562 + // // 'name': controller.text,
  563 + // // 'pnumMin': pnumMin,
  564 + // // 'pnumMax': pnumMax
  565 + // //添加桌位 接口参数带整合???
  566 + // // 以下是旧的不去,明天添加桌位接口
  567 + // String rid;
  568 + // for (Area item in areas) {
  569 + // if (item.name == value['areaname']) {
  570 + // rid = item.rid;
  571 + // }
  572 + // }
  573 + // Map<String, String> params = {
  574 + // 'rid': rid,
  575 + // 'name': value['name'],
  576 + // };
  577 + // if (value['pnumMin'] != '') {
  578 + // params['pnum'] = value['pnumMin'];
  579 + // }
  580 + // if (value['pnumMax'] != '') {
  581 + // params['most_pnum'] = value['pnumMax'];
  582 + // }
  583 + // bool success =
  584 + // await _chooseTableModel.addTable(context, params);
  585 + // print(success);
  586 + // if (success) {
  587 + // Utils.showToast('添加成功!');
  588 + // // TableOuter tableOuter = TableOuter();
  589 + // // tableOuter.name = value;
  590 + // // tableOuter.list = [];
  591 + // // tableManagerModel.tableOuterList.add(tableOuter);
  592 + // // tableManagerModel.initData();
  593 + // // Timer(
  594 + // // Duration(milliseconds: 500),
  595 + // // () => _areaController.jumpTo(
  596 + // // _areaController.position.maxScrollExtent));
  597 +
  598 + // // await tableManagerModel
  599 + // // .getTableList(context);
  600 + // // await tableManagerModel
  601 + // // .initData();
  602 + // refreshTable(context);
  603 + // }
  604 + // });
  605 + // },
  606 + // child: Container(
  607 + // child: DottedBorder(
  608 + // dashPattern: [5, 5, 5, 5],
  609 + // borderType: BorderType.RRect,
  610 + // radius: Radius.circular(ScreenUtil().setWidth(20)),
  611 + // // padding: EdgeInsets.all(ScreenUtil().setWidth(70)),
  612 + // color: MyColours.color_E0E0E0,
  613 + // strokeWidth: ScreenUtil().setWidth(2),
  614 + // child: ClipRRect(
  615 + // borderRadius: BorderRadius.all(
  616 + // Radius.circular(ScreenUtil().setWidth(20))),
  617 + // child: Container(
  618 + // height: ScreenUtil().screenWidth -
  619 + // ScreenUtil().setWidth(12 * 3 - 10 * 2),
  620 + // width: ScreenUtil().screenWidth -
  621 + // ScreenUtil().setWidth(12 * 3 - 10 * 2),
  622 + // child: Column(
  623 + // mainAxisAlignment: MainAxisAlignment.center,
  624 + // children: [
  625 + // Image.asset(Utils.getImgPath('add_store'),
  626 + // width: ScreenUtil().setWidth(32)),
  627 + // ],
  628 + // ),
  629 + // ),
  630 + // ),
  631 + // )));
  632 + // } else {
  633 + return Selector<ChooseTableModel, t.Table>(
  634 + shouldRebuild: (pre, next) => true,
  635 + selector: (context, model) => data[index],
  636 + builder: (context, table, _) {
  637 + return MergeTableItem(data[index], canSelected: true,
  638 + onSelected: (t.Table table) {
  639 + print(areaTableMap.keys);
  640 + // for (String item in areaTableMap.keys) {
  641 + // for (t.Table tableItem in areaTableMap[item]) {
  642 + // tableItem.selected = false;
  643 + // selectNum = 0;
  644 + // if (table.id == tableItem.id) {
  645 + // selectTableId = table.id;
  646 +
  647 + // selectTables = [];
  648 + // selectNum++;
  649 + if (table.selected) {
  650 + //选中
  651 + selectTables.add(table);
  652 + Map temp = {
  653 + 'tid': selectTables.length > 0 ? selectTables[0].id : '',
  654 + 'tname':
  655 + selectTables.length > 0 ? selectTables[0].name : ''
  656 + };
  657 + // print(selectNum);
  658 + print(selectTables);
  659 + //检测当前选中区域全选按钮状态更新
  660 +
  661 + } else {
  662 + //取消选中
  663 + selectTables
  664 + .removeWhere((element) => table.id == element.id);
  665 + }
  666 + tableOuterList[i].isAll = tableOuterList[i]
  667 + .list
  668 + .every((element) => element.selected);
  669 +
  670 + setState(() {});
  671 +
  672 + // NavigatorUtil.goTableMergeTableSelectPage(context,
  673 + // tid: table.id, tname: table.name);
  674 + // setState(() {
  675 + // tableItem.selected = true;
  676 + // });
  677 + // }
  678 + // }
  679 + // }
  680 + }, fromPage: widget.fromPage, tableMap: tableMap, rid: null);
  681 + },
  682 + );
  683 + // }
  684 + },
  685 + )
  686 + ],
  687 + );
  688 + }
  689 +
  690 + @override
  691 + Widget build(BuildContext context) {
  692 + _chooseTableModel = Provider.of<ChooseTableModel>(context);
  693 + return Scaffold(
  694 + backgroundColor: MyColours.color_ffffff,
  695 + body: SafeArea(
  696 + child: Column(
  697 + children: <Widget>[
  698 + SystemAppBar(
  699 + "选择要合并的桌位",
  700 + onTap: () {
  701 + EventBus().emit('changeStatusColor');
  702 + Navigator.of(context).pop();
  703 + },
  704 + ),
  705 + WillPopScope(
  706 + onWillPop: () {
  707 + EventBus().emit('changeStatusColor');
  708 + Navigator.of(context).pop();
  709 + },
  710 + child: Expanded(
  711 + child:
  712 + Consumer<ChooseTableModel>(builder: (context, model, _) {
  713 + if (model.pageState != PageState.Success) {
  714 + return ExceptionPage(
  715 + pageState: model.pageState,
  716 + callback: () {
  717 + getTableList();
  718 + },
  719 + emptyMsg: "暂时没有桌位哦",
  720 + emptyImg: "empty_search",
  721 + showMsg: "加载中,请稍后...",
  722 + );
  723 + } else {
  724 + return Column(
  725 + // crossAxisAlignment: CrossAxisAlignment.center,
  726 + children: [
  727 + Container(
  728 + color: MyColours.color_ffffff,
  729 + height: ScreenUtil().setWidth(92),
  730 + margin: EdgeInsets.only(
  731 + bottom: ScreenUtil().setWidth(30)),
  732 + child: Row(
  733 + children: [
  734 + HEmptyView(48),
  735 + Expanded(
  736 + child: ListView.builder(
  737 + itemCount: areas.length,
  738 + shrinkWrap: true,
  739 + scrollDirection: Axis.horizontal,
  740 + itemBuilder:
  741 + (BuildContext contxt, int index) {
  742 + // if (index == areas.length + 1 ||
  743 + // areas.length == 0) {
  744 + // return InkWell(
  745 + // onTap: () async {
  746 + // //添加区域弹框
  747 + // await DialogUtil.openCreateAreaDialog(
  748 + // context, onTap: (value) async {
  749 + // print(value);
  750 + // //添加区域
  751 + // bool success = await _chooseTableModel
  752 + // .addTableAreas(context, value);
  753 + // print(success);
  754 + // if (success) {
  755 + // Utils.showToast('添加成功!');
  756 + // UserModel userModel =
  757 + // Provider.of<UserModel>(context,
  758 + // listen: false);
  759 + // Map<String, String> params = {
  760 + // "sellerid": userModel.user.sellerid
  761 + // };
  762 + // await _chooseTableModel.getTableList(
  763 + // context, params,
  764 + // needLoading: false);
  765 + // initData();
  766 +
  767 + // // setState(() {
  768 + // // updateMenu();
  769 + // // });
  770 + // // _scrollToIndex(widget
  771 + // // .tableManagerModel
  772 + // // .areas
  773 + // // .length);
  774 +
  775 + // }
  776 + // });
  777 + // },
  778 + // child: Column(
  779 + // children: [
  780 + // VEmptyView(20),
  781 + // DottedBorder(
  782 + // dashPattern: [5, 5, 5, 5],
  783 + // borderType: BorderType.RRect,
  784 + // radius: Radius.circular(
  785 + // ScreenUtil().setWidth(10)),
  786 + // // padding: EdgeInsets.all(ScreenUtil().setWidth(70)),
  787 + // color: MyColours.color_199095,
  788 + // strokeWidth: ScreenUtil().setWidth(2),
  789 + // child: ClipRRect(
  790 + // borderRadius: BorderRadius.all(
  791 + // Radius.circular(
  792 + // ScreenUtil().setWidth(10))),
  793 + // child: Container(
  794 + // height:
  795 + // ScreenUtil().setWidth(25 * 2),
  796 + // width: ScreenUtil()
  797 + // .setWidth(104 * 2),
  798 + // child: Column(
  799 + // mainAxisAlignment:
  800 + // MainAxisAlignment.center,
  801 + // children: [
  802 + // Image.asset(
  803 + // Utils.getImgPath(
  804 + // 'add_area'),
  805 + // width: ScreenUtil()
  806 + // .setWidth(24)),
  807 + // ],
  808 + // ),
  809 + // ),
  810 + // ),
  811 + // )
  812 + // ],
  813 + // ),
  814 + // );
  815 + // } else {
  816 + // if (index == 0) {
  817 + // return InkWell(
  818 + // onTap: () {
  819 + // setState(() {
  820 + // isSelected = true;
  821 + // currentArea = '全部';
  822 + // _chooseTableModel
  823 + // .currentTables =
  824 + // _chooseTableModel
  825 + // .areaTableMapShow[
  826 + // currentArea];
  827 + // });
  828 + // },
  829 + // child: Container(
  830 + // // width: ScreenUtil().setWidth(104 * 2),
  831 + // height: ScreenUtil().setWidth(80),
  832 + // margin: EdgeInsets.only(
  833 + // right:
  834 + // ScreenUtil().setWidth(20),
  835 + // top: ScreenUtil().setWidth(20),
  836 + // ),
  837 + // padding: EdgeInsets.symmetric(
  838 + // horizontal:
  839 + // ScreenUtil().setWidth(20),
  840 + // vertical: ScreenUtil()
  841 + // .setWidth(10)),
  842 + // alignment: Alignment.center,
  843 + // decoration: BoxDecoration(
  844 + // // borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10)),
  845 + // color: isSelected
  846 + // ? MyColours.color_199095
  847 + // : MyColours.color_ffffff,
  848 + // border: Border.all(
  849 + // color: MyColours
  850 + // .color_E0E0E0,
  851 + // width: ScreenUtil()
  852 + // .setWidth(2))),
  853 + // child: Text(
  854 + // '全部',
  855 + // overflow: TextOverflow.ellipsis,
  856 + // style: TextStyle(
  857 + // color: isSelected
  858 + // ? MyColours.color_ffffff
  859 + // : MyColours
  860 + // .color_333333,
  861 + // fontSize:
  862 + // ScreenUtil().setSp(28),
  863 + // decoration:
  864 + // TextDecoration.none,
  865 + // fontWeight:
  866 + // FontWeight.normal),
  867 + // ),
  868 + // ),
  869 + // );
  870 + // } else {
  871 + return AreaItemTable(
  872 + areas[index],
  873 + currentArea,
  874 + (area) {
  875 + setState(() {
  876 + isSelected = false;
  877 + _selectNumber = index;
  878 + currentArea = areas[index].name;
  879 + _chooseTableModel.currentTables =
  880 + _chooseTableModel
  881 + .areaTableMapShow[
  882 + currentArea];
  883 + // _anmationMenu();
  884 + });
  885 + },
  886 + showBadge: false,
  887 + );
  888 + // }
  889 + // }
  890 + },
  891 + )),
  892 + ],
  893 + ),
  894 + ),
  895 + Expanded(
  896 + // flex: 2,
  897 + child: Container(
  898 + constraints: BoxConstraints(
  899 + minHeight: ScreenUtil().setWidth(100)),
  900 + color: MyColours.color_ffffff,
  901 + child: item(_selectNumber))),
  902 + Container(
  903 + padding:
  904 + EdgeInsets.symmetric(horizontal: w(48)),
  905 + margin: EdgeInsets.only(bottom: w(40)),
  906 + child: Row(
  907 + mainAxisAlignment:
  908 + MainAxisAlignment.spaceBetween,
  909 + children: [
  910 + RoundButton(
  911 + // content: widget.fromPage == 'tablePhoto'
  912 + // ? '确定'
  913 + // : "已选${selectNum}个 确定",
  914 +
  915 + text: '返回',
  916 + radius: r(4),
  917 + width: w(128),
  918 + height: w(36),
  919 + fontSize: 28,
  920 + isBold: false,
  921 + textColor: MyColours.color_515151,
  922 + gradientStart: MyColours.color_DBDBDB,
  923 + gradientEnd: MyColours.color_DBDBDB,
  924 + onPressed: () {
  925 + Navigator.pop(context);
  926 + },
  927 + ),
  928 + RoundButton(
  929 + // content: widget.fromPage == 'tablePhoto'
  930 + // ? '确定'
  931 + // : "已选${selectNum}个 确定",
  932 + text: '保存',
  933 + width: w(128),
  934 + height: w(36),
  935 + radius: r(4),
  936 + isBold: false,
  937 + gradientStart: MyColours.color_438E93,
  938 + gradientEnd: MyColours.color_438E93,
  939 + fontSize: 28,
  940 + textColor: MyColours.color_ffffff,
  941 + onPressed: () {
  942 + // if (widget.fromPage == "tablePhoto") {
  943 + // Map temp = {
  944 + // 'tid': selectTables.length > 0
  945 + // ? selectTables[0].id
  946 + // : '',
  947 + // 'tname': selectTables.length > 0
  948 + // ? selectTables[0].name
  949 + // : ''
  950 + // };
  951 + // Navigator.of(context).pop(temp);
  952 + // } else {
  953 + if (widget.canChoose) {
  954 + // // if (widget.tableList.length > 0) {
  955 + // String tid = "";
  956 + // for (TableList table
  957 + // in widget.tableList) {
  958 + // tid += table.id + ",";
  959 + // }
  960 + // if (widget.tableList.length > 0) {
  961 + // tid = tid.substring(
  962 + // 0, tid.length - 1);
  963 + // }
  964 +
  965 + // Map temp = {
  966 + // 'object': widget.tableList,
  967 + // 'tid': tid
  968 + // };
  969 + // Navigator.of(context).pop(temp);
  970 + // // }
  971 + // } else {
  972 + if (selectTables.length > 0) {
  973 + String tid = "";
  974 + for (t.Table table
  975 + in selectTables) {
  976 + tid += table.id + ",";
  977 + }
  978 + if (selectTables.length > 0) {
  979 + tid = tid.substring(
  980 + 0, tid.length - 1);
  981 + }
  982 +
  983 + Map temp = {
  984 + 'object': selectTables,
  985 + 'tid': tid
  986 + };
  987 + Navigator.of(context).pop(temp);
  988 + } else {
  989 + Navigator.of(context).pop();
  990 + }
  991 + }
  992 + // }
  993 + },
  994 + ),
  995 + ],
  996 + ))
  997 + ]);
  998 + }
  999 + }),
  1000 + ),
  1001 + )
  1002 + ],
  1003 + ),
  1004 + ));
  1005 + }
  1006 +
  1007 + tableToTableList(t.Table table) {
  1008 + TableList _tableList = TableList(
  1009 + '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '');
  1010 + _tableList.id = table.id;
  1011 + _tableList.rid = table.rid;
  1012 + _tableList.tid = table.tid;
  1013 + _tableList.name = table.name;
  1014 + _tableList.tablePnum = table.table_pnum;
  1015 + _tableList.sellerid = null;
  1016 + _tableList.qrcode = null;
  1017 + _tableList.mostPnum = table.most_pnum;
  1018 + _tableList.hot = null;
  1019 + _tableList.orderO = table.order_o;
  1020 + _tableList.status = table.status;
  1021 + _tableList.enable = table.enable;
  1022 + _tableList.spell = table.spell;
  1023 + _tableList.cdate = null;
  1024 + _tableList.rname = table.rname;
  1025 + _tableList.regionName = table.rname;
  1026 + _tableList.selected = true;
  1027 + return _tableList;
  1028 + }
  1029 +
  1030 + tableListToTable(TableList table) {
  1031 + t.Table _table = t.Table();
  1032 + _table.id = table.id;
  1033 + _table.rid = table.rid;
  1034 + _table.tid = table.tid;
  1035 + _table.name = table.name;
  1036 + _table.table_pnum = table.table_pnum;
  1037 + // _table.sellerid = null;
  1038 + // _table.qrcode = null;
  1039 + _table.most_pnum = table.mostPnum;
  1040 + // _table.hot = null;
  1041 + _table.order_o = table.orderO;
  1042 + _table.status = table.status;
  1043 + _table.enable = table.enable;
  1044 + _table.spell = table.spell;
  1045 + // _table.cdate = null;
  1046 + _table.rname = table.rname;
  1047 + _table.rname = table.regionName;
  1048 + _table.selected = true;
  1049 + return _table;
  1050 + }
  1051 +}
@@ -109,6 +109,78 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> { @@ -109,6 +109,78 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> {
109 // } 109 // }
110 // } 110 // }
111 111
  112 + ///获取经理数据
  113 + Future<bool> _setTableById(value, table) async {
  114 + String tid;
  115 + for (int i = 0; i < tableManagerModel.tableTypeList.length; i++) {
  116 + if (value['bjtype'] == tableManagerModel.tableTypeList[i].name) {
  117 + tid = tableManagerModel.tableTypeList[i].id;
  118 + }
  119 + }
  120 + Map<String, String> params = {
  121 + 'id': table.id,
  122 + 'name': value['name'],
  123 + 'tid': tid
  124 + };
  125 +
  126 + if (value['pnumMin'] != '') {
  127 + params['table_pnum'] = value['pnumMin'];
  128 + }
  129 + if (value['pnumMax'] != '') {
  130 + params['most_pnum'] = value['pnumMax'];
  131 + }
  132 +
  133 + bool success = await tableManagerModel.setTableById(context, params);
  134 + if (success) {
  135 + return true;
  136 + } else {
  137 + return false;
  138 + }
  139 + }
  140 +
  141 + ///
  142 + Future<bool> _mergeTables(value, table) async {
  143 + String isMerge = value['isMerge'];
  144 + String tids = value['tids'];
  145 + Map<String, String> params = {
  146 + 'tid': table.id,
  147 + 'is_merge': isMerge,
  148 + 'tids': tids
  149 + };
  150 +
  151 + bool success = await tableManagerModel.mergeTables(context, params);
  152 + if (success) {
  153 + return true;
  154 + } else {
  155 + return false;
  156 + }
  157 + }
  158 +
  159 + _setData(value, table) async {
  160 + await Future.wait<bool>(
  161 + [_setTableById(value, table), _mergeTables(value, table)])
  162 + .then((results) async {
  163 + print(results[0]);
  164 + if (results[0] && results[1]) {
  165 + await tableManagerModel.refreshTable(context);
  166 + } else {
  167 + if (results[0]) {
  168 + //修改桌位信息成功
  169 + await tableManagerModel.refreshTable(context);
  170 + } else {
  171 + //修改桌位信息失败
  172 + }
  173 + if (results[1]) {
  174 + //合并桌位成功
  175 + } else {
  176 + //合并桌位失败
  177 + }
  178 + }
  179 + }).catchError((e) {
  180 + print(e);
  181 + });
  182 + }
  183 +
112 Widget list(List data) => ScrollablePositionedList.builder( 184 Widget list(List data) => ScrollablePositionedList.builder(
113 itemCount: data.length, 185 itemCount: data.length,
114 itemBuilder: (context, index) => item(index), 186 itemBuilder: (context, index) => item(index),
@@ -293,11 +365,11 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> { @@ -293,11 +365,11 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> {
293 tableManagerModel.tableOuterList[i].selectTables 365 tableManagerModel.tableOuterList[i].selectTables
294 .removeWhere((t) => t.id == table.id); 366 .removeWhere((t) => t.id == table.id);
295 } 367 }
296 - tableManagerModel  
297 - .tableOuterList[tableManagerModel.selectNumber]  
298 - .isAll =  
299 - tableManagerModel.tableOuterList[i].list  
300 - .every((element) => element.selected); 368 + // tableManagerModel
  369 + // .tableOuterList[tableManagerModel.selectNumber]
  370 + // .isAll =
  371 + // tableManagerModel.tableOuterList[i].list
  372 + // .every((element) => element.selected);
301 } else { 373 } else {
302 // for (t.Table item 374 // for (t.Table item
303 // in tableManagerModel.tableOuterList[i].list) { 375 // in tableManagerModel.tableOuterList[i].list) {
@@ -316,13 +388,30 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> { @@ -316,13 +388,30 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> {
316 i++) { 388 i++) {
317 tableTypeS.add(tableManagerModel.tableTypeList[i].name); 389 tableTypeS.add(tableManagerModel.tableTypeList[i].name);
318 } 390 }
  391 + List<t.Table> selectTables = [];
  392 + if (table.tids != null && table.tids.length > 0) {
  393 + List<String> tids = table.tids.split(',');
  394 + tableManagerModel.tableOuterList.forEach((element) {
  395 + element.list.forEach((table) {
  396 + tids.forEach((tid) {
  397 + if (tid == table.id) {
  398 + selectTables.add(table);
  399 + }
  400 + });
  401 + });
  402 + });
  403 + }
319 await DialogUtil.openMyTableManageModifyTableDialog( 404 await DialogUtil.openMyTableManageModifyTableDialog(
320 context, tableTypeS, personNumList, 405 context, tableTypeS, personNumList,
321 name: table.name, 406 name: table.name,
322 tidStr: table.tidStr, 407 tidStr: table.tidStr,
323 pnumMin: table.table_pnum ?? '', 408 pnumMin: table.table_pnum ?? '',
324 pnumMax: table.most_pnum ?? '', 409 pnumMax: table.most_pnum ?? '',
325 - onTapDel: (Map<String, String> value) async { 410 + isLock: table.isLock ?? '0',
  411 + isMerge: table.isMerge ?? '0',
  412 + tableid: table.id,
  413 + selectTables: selectTables,
  414 + onTapDel: (Map<String, dynamic> value) async {
326 Map<String, String> params = { 415 Map<String, String> params = {
327 'sid': Provider.of<UserModel>(context, listen: false) 416 'sid': Provider.of<UserModel>(context, listen: false)
328 .user 417 .user
@@ -362,49 +451,30 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> { @@ -362,49 +451,30 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> {
362 // Map<String, String> params = { 451 // Map<String, String> params = {
363 // 'rid': rid, 452 // 'rid': rid,
364 // }; 453 // };
365 - String tid;  
366 - for (int i = 0;  
367 - i < tableManagerModel.tableTypeList.length;  
368 - i++) {  
369 - if (value['bjtype'] ==  
370 - tableManagerModel.tableTypeList[i].name) {  
371 - tid = tableManagerModel.tableTypeList[i].id;  
372 - }  
373 - }  
374 - Map<String, String> params = {  
375 - 'id': table.id,  
376 - 'name': value['name'],  
377 - 'tid': tid  
378 - }; 454 + _setData(value, table);
379 455
380 - if (value['pnumMin'] != '') {  
381 - params['table_pnum'] = value['pnumMin'];  
382 - }  
383 - if (value['pnumMax'] != '') {  
384 - params['most_pnum'] = value['pnumMax'];  
385 - } 456 +// if(isMerge == '1'){
  457 +// //
  458 +// }
386 459
387 - bool success =  
388 - await tableManagerModel.setTableById(context, params);  
389 - print(success);  
390 - if (success) {  
391 - Utils.showToast('修改成功!');  
392 - // TableOuter tableOuter = TableOuter();  
393 - // tableOuter.name = value;  
394 - // tableOuter.list = [];  
395 - // tableManagerModel.tableOuterList.add(tableOuter);  
396 - // tableManagerModel.initData();  
397 - // Timer(  
398 - // Duration(milliseconds: 500),  
399 - // () => _areaController.jumpTo(  
400 - // _areaController.position.maxScrollExtent)); 460 + // if (success) {
  461 + // Utils.showToast('修改成功!');
  462 + // // TableOuter tableOuter = TableOuter();
  463 + // // tableOuter.name = value;
  464 + // // tableOuter.list = [];
  465 + // // tableManagerModel.tableOuterList.add(tableOuter);
  466 + // // tableManagerModel.initData();
  467 + // // Timer(
  468 + // // Duration(milliseconds: 500),
  469 + // // () => _areaController.jumpTo(
  470 + // // _areaController.position.maxScrollExtent));
401 471
402 - // await tableManagerModel  
403 - // .getTableList(context);  
404 - // await tableManagerModel  
405 - // .initData();  
406 - await tableManagerModel.refreshTable(context);  
407 - } 472 + // // await tableManagerModel
  473 + // // .getTableList(context);
  474 + // // await tableManagerModel
  475 + // // .initData();
  476 + // await tableManagerModel.refreshTable(context);
  477 + // }
408 }); 478 });
409 } 479 }
410 }); 480 });
@@ -50,7 +50,7 @@ class AreaItemTableState extends State<AreaItemTable> { @@ -50,7 +50,7 @@ class AreaItemTableState extends State<AreaItemTable> {
50 ), 50 ),
51 alignment: Alignment.center, 51 alignment: Alignment.center,
52 decoration: BoxDecoration( 52 decoration: BoxDecoration(
53 - // borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10)), 53 + borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10)),
54 color: isSelected 54 color: isSelected
55 ? MyColours.color_199095 55 ? MyColours.color_199095
56 : widget.showBadge && area.count != -1 && area.count <= 0 56 : widget.showBadge && area.count != -1 && area.count <= 0
@@ -459,6 +459,45 @@ class MyTableManageHomeModel with ChangeNotifier { @@ -459,6 +459,45 @@ class MyTableManageHomeModel with ChangeNotifier {
459 return false; 459 return false;
460 } 460 }
461 461
  462 + // 合并桌位
  463 +
  464 + Future<bool> mergeTables(
  465 + BuildContext context, Map<String, String> params) async {
  466 + BaseResp<dynamic> baseResp = await DioUtil()
  467 + .request<dynamic>(context, Method.get, HttpUrl.merge_tables,
  468 + data: params, showLoading: true)
  469 + .catchError((error) {
  470 + print(error.toString());
  471 + // if (error is MyError) {
  472 + // switch (error.type) {
  473 + // case 1:
  474 + // pageState = PageState.ConnectivityError;
  475 + // break;
  476 + // case 2:
  477 + // pageState = PageState.ConnectivityTimeOut;
  478 + // break;
  479 + // default:
  480 + // pageState = PageState.ConnectivityError;
  481 + // break;
  482 + // }
  483 + // }
  484 + // notifyListeners();
  485 + return false;
  486 + });
  487 +
  488 + if (baseResp.code == Constant.status_success) {
  489 + if (baseResp.responseData['data'] != null &&
  490 + baseResp.responseData['data'] == 1) {
  491 + return true;
  492 + } else {
  493 + Utils.showToast(baseResp.msg ?? '合并桌位失败!');
  494 + }
  495 + } else {
  496 + Utils.showToast(baseResp.msg ?? '合并桌位失败!');
  497 + }
  498 + return false;
  499 + }
  500 +
462 //批量修改桌位信息 501 //批量修改桌位信息
463 Future<bool> batchSetTable( 502 Future<bool> batchSetTable(
464 BuildContext context, Map<String, String> params) async { 503 BuildContext context, Map<String, String> params) async {
@@ -1102,4 +1102,26 @@ class NavigatorUtil { @@ -1102,4 +1102,26 @@ class NavigatorUtil {
1102 return _navigateTo(context, "${Routes.feast_invoice_detail_page}", 1102 return _navigateTo(context, "${Routes.feast_invoice_detail_page}",
1103 replace: replace); 1103 replace: replace);
1104 } 1104 }
  1105 +
  1106 + ///桌位管理----合并桌位----桌位选择
  1107 + static Future<dynamic> goMergeTableSelectPage(BuildContext context,
  1108 + {replace = false,
  1109 + bool canChoose = true,
  1110 + Map object,
  1111 + String fromPage = 'table_manage',
  1112 + String tableidNow,
  1113 + String tid = ''}) {
  1114 + // if (invoice != null) {
  1115 + // return _navigateTo(context,
  1116 + // "${Routes.merge_table_select_page}?invoice=${FluroConvertUtils.object2string(invoice)}",
  1117 + // replace: replace);
  1118 + // }
  1119 + if (object != null) {
  1120 + return _navigateTo(context,
  1121 + "${Routes.merge_table_select_page}?tableidNow=$tableidNow&fromPage=$fromPage&canChoose=$canChoose&object=${FluroConvertUtils.object2string(object)}");
  1122 + }
  1123 + return _navigateTo(context,
  1124 + "${Routes.merge_table_select_page}?tableidNow=$tableidNow&fromPage=$fromPage&canChoose=$canChoose",
  1125 + replace: replace);
  1126 + }
1105 } 1127 }
@@ -174,6 +174,7 @@ import '../pages/my/feast_manage/feast_setmeal_manage_edit_page.dart'; @@ -174,6 +174,7 @@ import '../pages/my/feast_manage/feast_setmeal_manage_edit_page.dart';
174 import '../pages/my/feast_manage/feast_type_page.dart'; 174 import '../pages/my/feast_manage/feast_type_page.dart';
175 import '../pages/my/feast_manage/feast_wine_manage_edit_page.dart'; 175 import '../pages/my/feast_manage/feast_wine_manage_edit_page.dart';
176 import '../pages/my/feast_manage/feast_wine_manage_page.dart'; 176 import '../pages/my/feast_manage/feast_wine_manage_page.dart';
  177 +import '../pages/my/table_manage/merge_table_select_page.dart';
177 import '../provider/feast_model.dart'; 178 import '../provider/feast_model.dart';
178 179
179 // 登录页 180 // 登录页
@@ -988,11 +989,16 @@ var customerListPageHandle = new Handler( @@ -988,11 +989,16 @@ var customerListPageHandle = new Handler(
988 String index = params["index"].first; 989 String index = params["index"].first;
989 990
990 String uid = params["uid"].first; 991 String uid = params["uid"].first;
991 - bool distribution = FluroConvertUtils.string2bool(params["distribution"].first); 992 + bool distribution =
  993 + FluroConvertUtils.string2bool(params["distribution"].first);
992 994
993 return ChangeNotifierProvider<CustomerProvider>( 995 return ChangeNotifierProvider<CustomerProvider>(
994 create: (_) => CustomerProvider(), 996 create: (_) => CustomerProvider(),
995 - child: CustomerListPage(fromPage: fromPage, index: index, uidStr: uid,distribution: distribution)); 997 + child: CustomerListPage(
  998 + fromPage: fromPage,
  999 + index: index,
  1000 + uidStr: uid,
  1001 + distribution: distribution));
996 }); 1002 });
997 1003
998 ///仅供展示的客情列表 ---商家 1004 ///仅供展示的客情列表 ---商家
@@ -1777,3 +1783,28 @@ var feastInvoiceDetailPageHandle = new Handler( @@ -1777,3 +1783,28 @@ var feastInvoiceDetailPageHandle = new Handler(
1777 create: (_) => FeastModel(), 1783 create: (_) => FeastModel(),
1778 child: FeastInvoiceDetailPage(invoice: invoice)); 1784 child: FeastInvoiceDetailPage(invoice: invoice));
1779 }); 1785 });
  1786 +
  1787 +///桌位管理----合并桌位----选择桌位
  1788 +var mergeTableSelectPageHandle = new Handler(
  1789 + handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
  1790 + String fromPage = params["fromPage"].first;
  1791 +
  1792 + String tableidNow = params["tableidNow"].first;
  1793 + bool canChoose = params["canChoose"].first == "true" ? true : false;
  1794 + List<TableList> res = [];
  1795 + if (params.keys.contains('object')) {
  1796 + Map object = FluroConvertUtils.string2map(params["object"].first);
  1797 + List temp = object['object'];
  1798 +
  1799 + for (var item in temp) {
  1800 + res.add(TableList.fromJson(item));
  1801 + }
  1802 + }
  1803 + return ChangeNotifierProvider<ChooseTableModel>(
  1804 + create: (_) => ChooseTableModel(),
  1805 + child: MergeTableSelectPage(
  1806 + tableid: tableidNow,
  1807 + tableList: res,
  1808 + canChoose: canChoose,
  1809 + fromPage: fromPage));
  1810 +});
@@ -156,6 +156,9 @@ class Routes { @@ -156,6 +156,9 @@ class Routes {
156 static String feast_detail_page = "/feast_detail_page"; //宴会-----详情 156 static String feast_detail_page = "/feast_detail_page"; //宴会-----详情
157 157
158 static String feast_invoice_detail_page = "/feast_invoice_detail_page"; //宴会-----发票详情 158 static String feast_invoice_detail_page = "/feast_invoice_detail_page"; //宴会-----发票详情
  159 +
  160 + static String merge_table_select_page = "/merge_table_select_page"; //桌位管理---合并桌位选择桌位页面
  161 +
159 162
160 163
161 static void configureRoutes(FluroRouter router) { 164 static void configureRoutes(FluroRouter router) {
@@ -314,6 +317,9 @@ class Routes { @@ -314,6 +317,9 @@ class Routes {
314 317
315 router.define(feast_detail_page, handler: feastDetailPageHandle); 318 router.define(feast_detail_page, handler: feastDetailPageHandle);
316 router.define(feast_invoice_detail_page, handler: feastInvoiceDetailPageHandle); 319 router.define(feast_invoice_detail_page, handler: feastInvoiceDetailPageHandle);
  320 +router.define(merge_table_select_page, handler: mergeTableSelectPageHandle);
  321 +
  322 +
317 323
318 324
319 325
@@ -2061,6 +2061,10 @@ class DialogUtil { @@ -2061,6 +2061,10 @@ class DialogUtil {
2061 String tidStr, 2061 String tidStr,
2062 String pnumMin = '', 2062 String pnumMin = '',
2063 String pnumMax = '', 2063 String pnumMax = '',
  2064 + String isLock = '0',
  2065 + String isMerge = '0',
  2066 + String tableid,
  2067 + List<t.Table> selectTables,
2064 CustomCallBackMap onTap, 2068 CustomCallBackMap onTap,
2065 CustomCallBackMap onTapDel}) async { 2069 CustomCallBackMap onTapDel}) async {
2066 TextEditingController controller = TextEditingController(); 2070 TextEditingController controller = TextEditingController();
@@ -2092,6 +2096,19 @@ class DialogUtil { @@ -2092,6 +2096,19 @@ class DialogUtil {
2092 // } 2096 // }
2093 // }); 2097 // });
2094 2098
  2099 + String tids = '';
  2100 + String tableNames = '';
  2101 + selectTables.forEach((element) {
  2102 + tableNames += '${element.name}、';
  2103 + tids += '${element.id},';
  2104 + });
  2105 + if (tableNames.endsWith('、')) {
  2106 + tableNames = tableNames.substring(0, tableNames.length - 1);
  2107 + }
  2108 + if (tids.endsWith(',')) {
  2109 + tids = tids.substring(0, tids.length - 1);
  2110 + }
  2111 +
2095 final action = await showDialog( 2112 final action = await showDialog(
2096 context: context, 2113 context: context,
2097 barrierDismissible: false, 2114 barrierDismissible: false,
@@ -2211,7 +2228,7 @@ class DialogUtil { @@ -2211,7 +2228,7 @@ class DialogUtil {
2211 child: Container( 2228 child: Container(
2212 padding: EdgeInsets.symmetric( 2229 padding: EdgeInsets.symmetric(
2213 horizontal: ScreenUtil().setWidth(44)), 2230 horizontal: ScreenUtil().setWidth(44)),
2214 - height: ScreenUtil().setWidth(30 * 2), 2231 + height: ScreenUtil().setWidth(48 * 2),
2215 child: Row( 2232 child: Row(
2216 crossAxisAlignment: 2233 crossAxisAlignment:
2217 CrossAxisAlignment.center, 2234 CrossAxisAlignment.center,
@@ -2242,13 +2259,19 @@ class DialogUtil { @@ -2242,13 +2259,19 @@ class DialogUtil {
2242 ], 2259 ],
2243 ), 2260 ),
2244 )), 2261 )),
  2262 + Padding(
  2263 + padding: EdgeInsets.only(
  2264 + left: ScreenUtil().setWidth(74),
  2265 + right: ScreenUtil().setWidth(74)),
  2266 + child: MyDivider(double.infinity, w(1),
  2267 + color: MyColours.color_E7E7E7)),
2245 Container( 2268 Container(
2246 margin: EdgeInsets.only( 2269 margin: EdgeInsets.only(
2247 top: ScreenUtil().setWidth(30)), 2270 top: ScreenUtil().setWidth(30)),
2248 padding: EdgeInsets.only( 2271 padding: EdgeInsets.only(
2249 left: ScreenUtil().setWidth(44), 2272 left: ScreenUtil().setWidth(44),
2250 right: ScreenUtil().setWidth(44)), 2273 right: ScreenUtil().setWidth(44)),
2251 - height: ScreenUtil().setWidth(30 * 2), 2274 + height: ScreenUtil().setWidth(48 * 2),
2252 child: Row( 2275 child: Row(
2253 crossAxisAlignment: CrossAxisAlignment.center, 2276 crossAxisAlignment: CrossAxisAlignment.center,
2254 children: [ 2277 children: [
@@ -2291,7 +2314,198 @@ class DialogUtil { @@ -2291,7 +2314,198 @@ class DialogUtil {
2291 ], 2314 ],
2292 ), 2315 ),
2293 ), 2316 ),
2294 - VEmptyView(40), 2317 + VEmptyView(32),
  2318 + isLock == '1'
  2319 + ?
  2320 + // 已被合并到
  2321 + Column(
  2322 + children: [
  2323 + InkWell(
  2324 + onTap: () {
  2325 + //跳转到被合并桌位展示页面
  2326 + },
  2327 + child: Container(
  2328 + padding: EdgeInsets.only(
  2329 + left:
  2330 + ScreenUtil().setWidth(44),
  2331 + right: ScreenUtil()
  2332 + .setWidth(44)),
  2333 + height:
  2334 + ScreenUtil().setWidth(48 * 2),
  2335 + child: Row(
  2336 + mainAxisAlignment:
  2337 + MainAxisAlignment.center,
  2338 + children: [
  2339 + HEmptyView(32),
  2340 + Text(
  2341 + '已被合并到',
  2342 + style: TextStyle(
  2343 + fontSize: ScreenUtil()
  2344 + .setSp(32),
  2345 + color: MyColours
  2346 + .color_BFC4D4),
  2347 + ),
  2348 + // Spacer(),
  2349 + Expanded(
  2350 + child: Text(
  2351 + '桌位23333',
  2352 + maxLines: 1,
  2353 + textAlign: TextAlign.right,
  2354 + overflow:
  2355 + TextOverflow.ellipsis,
  2356 + style: TextStyle(
  2357 + fontSize: ScreenUtil()
  2358 + .setSp(32),
  2359 + color: MyColours
  2360 + .color_BFC4D4),
  2361 + )),
  2362 + HEmptyView(22),
  2363 + ],
  2364 + ))),
  2365 + Padding(
  2366 + padding: EdgeInsets.only(
  2367 + left: ScreenUtil().setWidth(74),
  2368 + right: ScreenUtil().setWidth(74)),
  2369 + child: MyDivider(
  2370 + double.infinity, w(1),
  2371 + color: MyColours.color_E7E7E7)),
  2372 + ],
  2373 + )
  2374 + :
  2375 + // 合并桌位开关等
  2376 + Column(
  2377 + children: [
  2378 + InkWell(
  2379 + onTap: () {
  2380 + if (isMerge == '1') {
  2381 + isMerge = '0';
  2382 + } else {
  2383 + isMerge = '1';
  2384 + }
  2385 + state(() {});
  2386 + },
  2387 + child: Container(
  2388 + padding: EdgeInsets.only(
  2389 + left:
  2390 + ScreenUtil().setWidth(44),
  2391 + right: ScreenUtil()
  2392 + .setWidth(44)),
  2393 + height:
  2394 + ScreenUtil().setWidth(48 * 2),
  2395 + child: Row(
  2396 + mainAxisAlignment:
  2397 + MainAxisAlignment.center,
  2398 + children: [
  2399 + HEmptyView(32),
  2400 + Text(
  2401 + '合并桌位',
  2402 + style: TextStyle(
  2403 + fontSize: ScreenUtil()
  2404 + .setSp(32),
  2405 + color: MyColours
  2406 + .color_000000),
  2407 + ),
  2408 + Spacer(),
  2409 + Image.asset(
  2410 + Utils.getImgPath(
  2411 + isMerge == '1'
  2412 + ? 'swich_on'
  2413 + : 'swich_off'),
  2414 + width: w(44)),
  2415 + HEmptyView(32),
  2416 + ],
  2417 + ))),
  2418 + VEmptyView(32),
  2419 + InkWell(
  2420 + onTap: () async {
  2421 + //跳转到被合并桌位展示页面
  2422 + Map object;
  2423 + if (selectTables.length > 0) {
  2424 + object = await NavigatorUtil
  2425 + .goMergeTableSelectPage(
  2426 + context,
  2427 + tableidNow: tableid,
  2428 + object: {
  2429 + 'object': selectTables
  2430 + });
  2431 + } else {
  2432 + object = await NavigatorUtil
  2433 + .goMergeTableSelectPage(
  2434 + context,
  2435 + tableidNow: tableid,
  2436 + );
  2437 + }
  2438 +
  2439 + if (object != null) {
  2440 + selectTables = object['object'];
  2441 + tids = object['tid'];
  2442 + } else {
  2443 + selectTables = []; //没有选择桌子
  2444 + tids = '';
  2445 + }
  2446 + tableNames = '';
  2447 + selectTables.forEach((element) {
  2448 + tableNames += '${element.name}、';
  2449 + });
  2450 + if (tableNames.endsWith('、')) {
  2451 + tableNames = tableNames.substring(
  2452 + 0, tableNames.length - 1);
  2453 + }
  2454 + print(object);
  2455 + state(() {});
  2456 + },
  2457 + child: Container(
  2458 + padding: EdgeInsets.only(
  2459 + left:
  2460 + ScreenUtil().setWidth(44),
  2461 + right: ScreenUtil()
  2462 + .setWidth(44)),
  2463 + height:
  2464 + ScreenUtil().setWidth(48 * 2),
  2465 + child: Row(
  2466 + mainAxisAlignment:
  2467 + MainAxisAlignment.center,
  2468 + children: [
  2469 + HEmptyView(32),
  2470 + Text(
  2471 + '被合并桌位',
  2472 + style: TextStyle(
  2473 + fontSize: ScreenUtil()
  2474 + .setSp(32),
  2475 + color: MyColours
  2476 + .color_000000),
  2477 + ),
  2478 + HEmptyView(40),
  2479 + Expanded(
  2480 + child: Text(
  2481 + tableNames ?? "",
  2482 + maxLines: 1,
  2483 + textAlign: TextAlign.right,
  2484 + overflow:
  2485 + TextOverflow.ellipsis,
  2486 + style: TextStyle(
  2487 + fontSize: ScreenUtil()
  2488 + .setSp(32),
  2489 + color: MyColours
  2490 + .color_66000000),
  2491 + )),
  2492 + Image.asset(
  2493 + Utils.getImgPath(
  2494 + 'base_arrow_r'),
  2495 + width: w(24)),
  2496 + HEmptyView(22),
  2497 + ],
  2498 + ))),
  2499 + Padding(
  2500 + padding: EdgeInsets.only(
  2501 + left: ScreenUtil().setWidth(74),
  2502 + right: ScreenUtil().setWidth(74)),
  2503 + child: MyDivider(
  2504 + double.infinity, w(1),
  2505 + color: MyColours.color_E7E7E7)),
  2506 + ],
  2507 + ),
  2508 + VEmptyView(50),
2295 RoundButton( 2509 RoundButton(
2296 text: '删除桌位', 2510 text: '删除桌位',
2297 width: ScreenUtil().setWidth(88 * 2), 2511 width: ScreenUtil().setWidth(88 * 2),
@@ -2368,6 +2582,13 @@ class DialogUtil { @@ -2368,6 +2582,13 @@ class DialogUtil {
2368 Utils.showToast('请输入桌位名称!'); 2582 Utils.showToast('请输入桌位名称!');
2369 return; 2583 return;
2370 } 2584 }
  2585 + if (isLock != '1' && isMerge == '1') {
  2586 + //合并桌位的时候,开关打开的情况下,必须选择至少一个桌位
  2587 + if (selectTables.length == 0) {
  2588 + Utils.showToast('请选择被合并桌位');
  2589 + return;
  2590 + }
  2591 + }
2371 // 当前选中区域 2592 // 当前选中区域
2372 // areas[currentAreaIndex] 2593 // areas[currentAreaIndex]
2373 //最低人数 2594 //最低人数
@@ -2381,6 +2602,8 @@ class DialogUtil { @@ -2381,6 +2602,8 @@ class DialogUtil {
2381 'name': controller.text, 2602 'name': controller.text,
2382 'pnumMin': pnumMin, 2603 'pnumMin': pnumMin,
2383 'pnumMax': pnumMax, 2604 'pnumMax': pnumMax,
  2605 + 'isMerge': isMerge,
  2606 + 'tids': tids
2384 }); 2607 });
2385 Navigator.pop(context); 2608 Navigator.pop(context);
2386 }), 2609 }),
  1 +import 'package:flutter/material.dart';
  2 +import 'package:flutter_screenutil/flutter_screenutil.dart';
  3 +import 'package:one_key/models/notebook.dart';
  4 +import 'package:one_key/res/colors.dart';
  5 +
  6 +import 'package:one_key/models/table.dart' as t;
  7 +import 'package:one_key/widgets/v_empty_view.dart';
  8 +
  9 +class MergeTableItem extends StatefulWidget {
  10 + final t.Table table;
  11 + final bool canSelected; //是否能选中
  12 + final ValueChanged<t.Table> onSelected;
  13 + final String fromPage; // 变更、新建、桌位管理三个页面
  14 + final String rid;
  15 + final Map<String, Notebook> tableMap; //记录已预订桌位对应的订单
  16 +
  17 + final int height; //高度
  18 + final bool need;
  19 +
  20 + MergeTableItem(this.table,
  21 + {this.onSelected,
  22 + this.canSelected = false,
  23 + this.height = 60,
  24 + this.fromPage = 'new',
  25 + this.rid,
  26 + this.tableMap,
  27 + this.need = true});
  28 +
  29 + @override
  30 + State<StatefulWidget> createState() {
  31 + // TODO: implement createState
  32 + return new MergeTableItemState();
  33 + }
  34 +}
  35 +
  36 +class MergeTableItemState extends State<MergeTableItem> {
  37 + @override
  38 + Widget build(BuildContext context) {
  39 + t.Table table = widget.table;
  40 +
  41 + String signStr = table.signStr;
  42 + if (table.sign == '5' && widget.tableMap[table.id]?.orderInfo != null) {
  43 + if (widget.tableMap[table.id].orderInfo?.status == '3') {
  44 + signStr = '已买单';
  45 + }
  46 + }
  47 +
  48 + bool isSelf = false;
  49 + //当前桌子的预订id
  50 + String idNow = '';
  51 + if (widget.tableMap.containsKey('${table.id}')) {
  52 + //包含,证明该桌子已经被预订了
  53 + idNow = widget.tableMap['${table.id}'].id;
  54 + if (idNow == widget.rid) {
  55 + isSelf = true;
  56 + }
  57 + }
  58 +
  59 + return GestureDetector(
  60 + onTap: () {
  61 + if (widget.canSelected && widget.fromPage == 'change') {
  62 + //从变更页面进来 canChoose = true
  63 + if (widget.canSelected && signStr.isEmpty) {
  64 + setState(() {
  65 + table.selected = !(table.selected ?? false);
  66 + });
  67 + widget.onSelected(table);
  68 + } else {
  69 + if (table.sign == '5' || table.sign == '1') {
  70 + // 1一般是商户端
  71 + // 5是用户端
  72 + //已预订状态 不是自己的不可以选择,是自己的可以选择
  73 + //当前桌子的预订id
  74 + String idNow = '';
  75 + if (widget.tableMap.containsKey('${table.id}')) {
  76 + //包含,证明该桌子已经被预订了
  77 + idNow = widget.tableMap['${table.id}'].id;
  78 + if (idNow == widget.rid) {
  79 + setState(() {
  80 + isSelf = true;
  81 + table.selected = !(table.selected ?? false);
  82 + });
  83 + widget.onSelected(table);
  84 + }
  85 + }
  86 + }
  87 + }
  88 + } else if (widget.fromPage == 'new' &&
  89 + widget.canSelected &&
  90 + signStr.isEmpty) {
  91 + //从安排桌位进来
  92 + setState(() {
  93 + table.selected = !(table.selected ?? false);
  94 + });
  95 + widget.onSelected(table);
  96 + } else if (widget.fromPage == 'table_manage' ||
  97 + widget.fromPage == 'room_manage') {
  98 + setState(() {
  99 + table.selected = !(table.selected ?? false);
  100 + });
  101 +
  102 + widget.onSelected(table);
  103 + } else if (widget.fromPage == 'tablePhoto') {
  104 + // setState(() {
  105 + // table.selected = true;
  106 + // });
  107 +
  108 + widget.onSelected(table);
  109 + } else {
  110 + setState(() {
  111 + table.selected = !(table.selected ?? false);
  112 + });
  113 + widget.onSelected(table);
  114 + }
  115 + },
  116 + child: Stack(
  117 + children: <Widget>[
  118 + Container(
  119 + // width: ScreenUtil().setWidth(160),
  120 + // height: ScreenUtil().setWidth(widget.height),
  121 + // margin: EdgeInsets.all(ScreenUtil().setWidth(9)),
  122 + decoration: BoxDecoration(
  123 + color: widget.need && signStr == '已预订' && !isSelf
  124 + ? MyColours.color_afbcc4
  125 + : widget.canSelected && table.selected
  126 + ? MyColours.color_199095
  127 + : MyColours.color_ffffff,
  128 + border: Border.all(
  129 + width: ScreenUtil().setWidth(2),
  130 + color: MyColours.color_E0E0E0),
  131 + borderRadius: BorderRadius.all(
  132 + Radius.circular(ScreenUtil().setWidth(10)))),
  133 + child: Stack(
  134 + // alignment: Alignment.center,
  135 + children: <Widget>[
  136 + Container(
  137 + // alignment: Alignment.center,
  138 + // color: Colors.blueAccent,
  139 + // height: ScreenUtil().setWidth(widget.height),
  140 + // padding: EdgeInsets.symmetric(
  141 + // horizontal: ScreenUtil().setWidth(20)),
  142 + // margin: EdgeInsets.only(left: ScreenUtil().setWidth(20)),
  143 + child: Column(
  144 + // mainAxisSize: MainAxisSize.min,
  145 + crossAxisAlignment: CrossAxisAlignment.center,
  146 + mainAxisAlignment: MainAxisAlignment.center,
  147 + children: <Widget>[
  148 + widget.need && signStr == '已预订' && !isSelf
  149 + ? SizedBox()
  150 + : VEmptyView(10),
  151 + Container(
  152 + // color: Colors.red,
  153 + alignment: Alignment.center,
  154 + child: Text(
  155 + table.name,
  156 + maxLines: 1,
  157 + style: TextStyle(
  158 + color:
  159 + (widget.need && signStr == '已预订' && !isSelf)
  160 + ? MyColours.color_333333
  161 + : (widget.canSelected && table.selected)
  162 + ? MyColours.color_ffffff
  163 + : MyColours.color_333333,
  164 + fontSize: ScreenUtil().setSp(30),
  165 + decoration: TextDecoration.none,
  166 + fontWeight: FontWeight.bold),
  167 + overflow: TextOverflow.ellipsis,
  168 + )
  169 + // Text(
  170 + // table.name,
  171 + // // textAlign: TextAlign.center,
  172 + // maxLines: 2,
  173 + // style: TextStyle(
  174 + // color: table.signStr == '已停用'
  175 + // ? MyColours.color_999999
  176 + // : MyColours.color_353535,
  177 + // fontSize: ScreenUtil().setSp(28),
  178 + // decoration: TextDecoration.none,
  179 + // fontWeight: FontWeight.normal),
  180 + // overflow: TextOverflow.ellipsis,
  181 + // ),
  182 + ),
  183 + // ((table.reserver != null && table.reserver != '') ||
  184 + // (table.pnum != '' &&
  185 + // table.pnum != null &&
  186 + // table.pnum != '0'))
  187 + // ? VEmptyView(20)
  188 + // : SizedBox(),
  189 + VEmptyView(12),
  190 + signStr == '已预订' && !isSelf
  191 + ? SizedBox()
  192 + : Text(
  193 + table.tableNum,
  194 + style: TextStyle(
  195 + color: signStr == '已预订' && !isSelf
  196 + ? MyColours.color_353535
  197 + : (widget.canSelected && table.selected)
  198 + ? MyColours.color_ffffff
  199 + : MyColours.color_353535,
  200 + fontSize: ScreenUtil().setSp(14),
  201 + decoration: TextDecoration.none,
  202 + fontWeight: FontWeight.normal),
  203 + overflow: TextOverflow.ellipsis,
  204 + ),
  205 + // signStr == '已预订' &&
  206 + // !isSelf &&
  207 + // ((table.reserver != null &&
  208 + // !table.reserver.isEmpty) ||
  209 + // (table.pnum != '' &&
  210 + // table.pnum != null &&
  211 + // table.pnum != '0'))
  212 + // ? Text(
  213 + // (table.reserver == null || table.reserver.isEmpty)
  214 + // ? (table.pnum != '' &&
  215 + // table.pnum != null &&
  216 + // table.pnum != '0')
  217 + // ? '(${table.pnum}人)'
  218 + // : ''
  219 + // : '${table.reserver}' +
  220 + // (table.pnum != '' &&
  221 + // table.pnum != null &&
  222 + // table.pnum != '0'
  223 + // ? '(${table.pnum}人)'
  224 + // : ''),
  225 + // style: TextStyle(
  226 + // color: signStr == '已预订' && !isSelf
  227 + // ? MyColours.color_353535
  228 + // : (widget.canSelected && table.selected)
  229 + // ? MyColours.color_ffffff
  230 + // : MyColours.color_353535,
  231 + // fontSize: ScreenUtil().setSp(14),
  232 + // decoration: TextDecoration.none,
  233 + // fontWeight: FontWeight.normal),
  234 + // overflow: TextOverflow.ellipsis,
  235 + // )
  236 + // : SizedBox(),
  237 +
  238 + // widget.need &&
  239 + // signStr == '已预订' &&
  240 + // !isSelf &&
  241 + // table.nickName != null &&
  242 + // table.nickName != ''
  243 + // ? Padding(
  244 + // padding: EdgeInsets.only(
  245 + // top: ScreenUtil().setWidth(6),
  246 + // bottom: ScreenUtil().setWidth(8),
  247 + // ),
  248 + // child: Text(
  249 + // table.nickName != null && table.nickName != ''
  250 + // ? '${table.nickName}订'
  251 + // : '',
  252 + // style: TextStyle(
  253 + // color: MyColours.color_353535,
  254 + // fontSize: ScreenUtil().setSp(22),
  255 + // decoration: TextDecoration.none,
  256 + // fontWeight: FontWeight.normal),
  257 + // overflow: TextOverflow.ellipsis,
  258 + // ),
  259 + // )
  260 + // : SizedBox(),
  261 + // VEmptyView(6),
  262 + // Text(
  263 + // table.lowStr,
  264 + // style: TextStyle(
  265 + // color: MyColours.color_777777,
  266 + // fontSize: ScreenUtil().setSp(26),
  267 + // decoration: TextDecoration.none,
  268 + // fontWeight: FontWeight.normal),
  269 + // overflow: TextOverflow.ellipsis,
  270 + // )
  271 + signStr == '已预订' && !isSelf
  272 + ? Container(
  273 + // width: ScreenUtil().setWidth(160),
  274 + height: ScreenUtil().setWidth(34),
  275 + )
  276 + : SizedBox()
  277 + ],
  278 + ),
  279 + ),
  280 +
  281 + signStr == '已预订' && !isSelf
  282 + ? SizedBox()
  283 + : Positioned(
  284 + left: 0,
  285 + top: 0,
  286 + child: table.tidStr == null
  287 + ? Container()
  288 + : Container(
  289 + // width: ScreenUtil().setWidth(60),
  290 + // height: ScreenUtil().setWidth(42),
  291 + padding:
  292 + EdgeInsets.all(ScreenUtil().setWidth(4)),
  293 + alignment: Alignment.center,
  294 + decoration: BoxDecoration(
  295 + color: widget.canSelected && table.selected
  296 + ? MyColours.color_199095
  297 + : MyColours.color_999999,
  298 + borderRadius: BorderRadius.only(
  299 + topLeft: Radius.circular(
  300 + ScreenUtil().setWidth(10)),
  301 + // topRight:
  302 + // Radius.circular(ScreenUtil().setWidth(8)),
  303 + // bottomRight: Radius.circular(
  304 + // ScreenUtil().setWidth(8))
  305 + )),
  306 + child: Text(table.tidStr,
  307 + style: TextStyle(
  308 + color:
  309 + MyColours.color_ffffff
  310 + ,
  311 + fontSize: ScreenUtil().setSp(14),
  312 + decoration: TextDecoration.none,
  313 + fontWeight: FontWeight.normal)),
  314 + ),
  315 + ),
  316 + // widget.need && signStr == '已预订'
  317 + // ? Positioned(
  318 + // bottom: 0,
  319 + // left: 0,
  320 + // right: 0,
  321 + // child: signStr.isEmpty
  322 + // ? Container()
  323 + // : Container(
  324 + // width: ScreenUtil().setWidth(160),
  325 + // height: ScreenUtil().setWidth(40),
  326 + // alignment: Alignment.center,
  327 + // decoration: BoxDecoration(
  328 + // color: signStr == '已停用'
  329 + // ? MyColours.color_777777
  330 + // : signStr == '已买单'
  331 + // ? MyColours.color_F59A23
  332 + // : MyColours.color_E95750,
  333 + // borderRadius: BorderRadius.only(
  334 + // bottomLeft: Radius.circular(
  335 + // ScreenUtil().setWidth(8)),
  336 + // bottomRight: Radius.circular(
  337 + // ScreenUtil().setWidth(8)))),
  338 + // child: Text(
  339 + // signStr,
  340 + // style: TextStyle(
  341 + // color: MyColours.color_ffffff,
  342 + // fontSize: ScreenUtil().setSp(24),
  343 + // decoration: TextDecoration.none,
  344 + // fontWeight: FontWeight.normal),
  345 + // ),
  346 + // ),
  347 + // )
  348 + // : SizedBox(),
  349 + ],
  350 + ),
  351 + ),
  352 + // Positioned(
  353 + // top: 3,
  354 + // right: 5,
  355 + // child: widget.canSelected && (table.selected ?? false)
  356 + // ? Image.asset(
  357 + // "assets/icon_selected.png",
  358 + // width: ScreenUtil().setWidth(40),
  359 + // height: ScreenUtil().setWidth(40),
  360 + // )
  361 + // : Container()),
  362 + // widget.need && signStr == '已预订' && !isSelf
  363 + // ? SizedBox()
  364 + // : Positioned(
  365 + // left: ScreenUtil().setWidth(18),
  366 + // bottom: ScreenUtil().setWidth(12),
  367 + // child: table.isPhoto != 1
  368 + // ? Image.asset(
  369 + // widget.canSelected && table.selected
  370 + // ? 'assets/f_camera_white.png'
  371 + // : "assets/f_camera.png",
  372 + // width: ScreenUtil().setWidth(22),
  373 + // height: ScreenUtil().setWidth(22),
  374 + // )
  375 + // : Container()),
  376 + // Positioned(
  377 + // bottom: 0,
  378 + // right: 0,
  379 + // left: 0,
  380 + // child: signStr == '已预订' && !isSelf
  381 + // ? Container(
  382 + // // width: ScreenUtil().setWidth(160),
  383 + // height: ScreenUtil().setWidth(34),
  384 + // alignment: Alignment.centerLeft,
  385 + // padding: EdgeInsets.symmetric(
  386 + // horizontal: ScreenUtil().setWidth(10)),
  387 + // decoration: BoxDecoration(
  388 + // color: MyColours.color_d7d7d7,
  389 + // borderRadius: BorderRadius.only(
  390 + // bottomLeft:
  391 + // Radius.circular(ScreenUtil().setWidth(20)),
  392 + // bottomRight:
  393 + // Radius.circular(ScreenUtil().setWidth(20)))),
  394 + // child: Text(
  395 + // '新客',
  396 + // style: TextStyle(
  397 + // color: MyColours.color_353535,
  398 + // fontSize: ScreenUtil().setSp(24),
  399 + // decoration: TextDecoration.none,
  400 + // fontWeight: FontWeight.normal),
  401 + // ),
  402 + // )
  403 + // : SizedBox())
  404 + ],
  405 + ),
  406 + );
  407 + }
  408 +}