|
|
|
// import 'dart:ffi';
|
|
|
|
|
|
|
|
// import 'package:common_utils/common_utils.dart';
|
|
|
|
// import 'package:dotted_border/dotted_border.dart';
|
|
|
|
// import 'package:flutter/material.dart';
|
|
|
|
// import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
// import 'package:one_key/constant/state.dart';
|
|
|
|
// import 'package:one_key/models/area.dart';
|
|
|
|
// import 'package:one_key/models/notebook.dart';
|
|
|
|
// import 'package:one_key/models/tableOuter.dart';
|
|
|
|
// import 'package:one_key/models/table_list.dart';
|
|
|
|
// import 'package:one_key/pages/table/area_item_table.dart';
|
|
|
|
// import 'package:one_key/pages/table/area_item_table_or_reserve.dart';
|
|
|
|
// import 'package:one_key/provider/choose_table_model.dart';
|
|
|
|
// import 'package:one_key/provider/notebook_detail_change_model.dart';
|
|
|
|
// import 'package:one_key/provider/notebook_model.dart';
|
|
|
|
// import 'package:one_key/provider/user_model.dart';
|
|
|
|
// import 'package:one_key/res/colors.dart';
|
|
|
|
// import 'package:one_key/utils/dialog_util.dart';
|
|
|
|
// import 'package:one_key/utils/utils.dart';
|
|
|
|
// import 'package:one_key/widgets/MyDivider.dart';
|
|
|
|
// import 'package:one_key/widgets/app_bar.dart';
|
|
|
|
// import 'package:one_key/widgets/area_item.dart';
|
|
|
|
// import 'package:one_key/widgets/common_button.dart';
|
|
|
|
// import 'package:one_key/widgets/f_table_item.dart';
|
|
|
|
// import 'package:one_key/widgets/h_empty_view.dart';
|
|
|
|
// import 'package:one_key/widgets/page_exception.dart';
|
|
|
|
// import 'package:one_key/widgets/table_item.dart';
|
|
|
|
// import 'package:one_key/models/table.dart' as t;
|
|
|
|
// import 'package:one_key/widgets/v_empty_view.dart';
|
|
|
|
// import 'package:provider/provider.dart';
|
|
|
|
// import 'dart:convert' as convert;
|
|
|
|
|
|
|
|
// import '../../models/get_board_model.dart';
|
|
|
|
// import '../../models/table_or_reserve_model.dart';
|
|
|
|
// import '../../models/table_or_reserve_model.dart';
|
|
|
|
// import '../../models/table_or_reserve_model.dart';
|
|
|
|
// import '../../models/table_or_reserve_model.dart';
|
|
|
|
// import '../../provider/table_manage_model_or_reserve.dart';
|
|
|
|
// import '../table/table_item_or_reserve.dart';
|
|
|
|
|
|
|
|
// class SelectTableFPageOrReserve extends StatefulWidget {
|
|
|
|
// final String rid; //预订id
|
|
|
|
// final DateTime dateTime; //日期
|
|
|
|
// final String ddate_slot; //时段
|
|
|
|
// final bool canChoose; //变更预订可以取消原来已预订的选中状态
|
|
|
|
// final List<TableList> tableList;
|
|
|
|
// final String fromPage;
|
|
|
|
// final String tid;
|
|
|
|
// final String hmS;
|
|
|
|
// final String hmE;
|
|
|
|
// final String source;
|
|
|
|
// final String ridFeast; //宴会id
|
|
|
|
// SelectTableFPageOrReserve(this.rid, this.dateTime, this.ddate_slot,
|
|
|
|
// {this.canChoose = false,
|
|
|
|
// this.tableList,
|
|
|
|
// this.fromPage,
|
|
|
|
// this.tid,
|
|
|
|
// this.hmS,
|
|
|
|
// this.hmE,
|
|
|
|
// this.source = '0',
|
|
|
|
// this.ridFeast});
|
|
|
|
|
|
|
|
// @override
|
|
|
|
// State<StatefulWidget> createState() {
|
|
|
|
// // TODO: implement createState
|
|
|
|
// return new SelectTableFPageOrReserveState();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// class SelectTableFPageOrReserveState extends State<SelectTableFPageOrReserve> {
|
|
|
|
// // List<Area> areas = []; //区域列表
|
|
|
|
// // List<t.Table> selectTables = []; //选择的桌位
|
|
|
|
|
|
|
|
// // List<TableOuter> tableOuterList = []; //区域-桌位列表
|
|
|
|
|
|
|
|
// // Map<String, List<t.Table>> areaTableMap = {}; //区域-桌位Map
|
|
|
|
|
|
|
|
// ChooseTableModel _chooseTableModel;
|
|
|
|
|
|
|
|
// // Map<String, Notebook> tableMap = {}; //记录已预订桌位对应的订单
|
|
|
|
|
|
|
|
// // String currentArea; //当前选中区域
|
|
|
|
// List<String> personNumList = [];
|
|
|
|
|
|
|
|
// int selectNum = 0;
|
|
|
|
// // bool isSelected = true; //全部按钮
|
|
|
|
// int _selectNumber;
|
|
|
|
// // Map dailyMap = {}; // 早市对应半点钟,午市对应半点钟、晚市对应半点钟
|
|
|
|
// List<Notebook> noteBooks;
|
|
|
|
|
|
|
|
// TableManagerModelOrReserve tableManagerModel;
|
|
|
|
|
|
|
|
// @override
|
|
|
|
// void initState() {
|
|
|
|
// // TODO: implement initState
|
|
|
|
// super.initState();
|
|
|
|
// for (int i = 1; i < 31; i++) {
|
|
|
|
// personNumList.add(i.toString());
|
|
|
|
// }
|
|
|
|
// // initDateHourMinuteList(context);
|
|
|
|
|
|
|
|
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
// // getTableList();
|
|
|
|
// _getTableListOrReserve();
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
|
|
|
|
// ///
|
|
|
|
// _getTableListOrReserve() async {
|
|
|
|
// await tableManagerModel.getTableListOrReserve(
|
|
|
|
// context,
|
|
|
|
// );
|
|
|
|
// tableManagerModel.tablesOrReserveDataShow.forEach((element) {
|
|
|
|
// element.tableList.forEach((element) {
|
|
|
|
// element.selected = false;
|
|
|
|
// for (var table in widget.tableList) {
|
|
|
|
// if (element.id == table.id) {
|
|
|
|
// element.selected = true;
|
|
|
|
// selectNum++;
|
|
|
|
// tableManagerModel.selectTablesOrReserve.add(element);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// });
|
|
|
|
// tableManagerModel.notifyListeners();
|
|
|
|
// }
|
|
|
|
|
|
|
|
// /// 早市、午市、晚市对应的半个小时间隔时间段
|
|
|
|
// // initDateHourMinuteList(BuildContext context) async {
|
|
|
|
// // UserModel userModel = Provider.of<UserModel>(context, listen: false);
|
|
|
|
// // String morning =
|
|
|
|
// // userModel.user.morning.isEmpty ? "00:00-00:00" : userModel.user.morning;
|
|
|
|
// // String noon =
|
|
|
|
// // userModel.user.noon.isEmpty ? "00:00-00:00" : userModel.user.noon;
|
|
|
|
// // String night =
|
|
|
|
// // userModel.user.night.isEmpty ? "00:00-00:00" : userModel.user.night;
|
|
|
|
// // userModel.user.morning == ''
|
|
|
|
// // ? dailyMap.putIfAbsent('morning', () => '')
|
|
|
|
// // : dailyMap.putIfAbsent(
|
|
|
|
// // 'morning', () => _getHourAndMinute(userModel.user.morning, 1));
|
|
|
|
// // userModel.user.noon == ''
|
|
|
|
// // ? dailyMap.putIfAbsent('noon', () => '')
|
|
|
|
// // : dailyMap.putIfAbsent(
|
|
|
|
// // 'noon', () => _getHourAndMinute(userModel.user.noon, 2));
|
|
|
|
// // userModel.user.night == ''
|
|
|
|
// // ? dailyMap.putIfAbsent('night', () => '')
|
|
|
|
// // : dailyMap.putIfAbsent(
|
|
|
|
// // 'night', () => _getHourAndMinute(userModel.user.night, 3));
|
|
|
|
// // // _initSunDateList(
|
|
|
|
// // // userModel.user.morning, userModel.user.noon, userModel.user.night);
|
|
|
|
// // }
|
|
|
|
|
|
|
|
// //根据获取时间 11:00-12:30 获取30分钟间隔组装的数组
|
|
|
|
// // _getHourAndMinute(String hourAndMinuteStr, int mnd) {
|
|
|
|
// // List tempDate = hourAndMinuteStr.split("-");
|
|
|
|
// // String beginDate = tempDate[0];
|
|
|
|
// // String endDate = tempDate[1];
|
|
|
|
// // List tempHour = beginDate.split(':');
|
|
|
|
|
|
|
|
// // /*获取开始小时*/
|
|
|
|
// // int beginHour = int.parse(tempHour[0]);
|
|
|
|
// // /*获取开始分钟*/
|
|
|
|
// // int beginMinute = int.parse(tempHour[1]);
|
|
|
|
// // if (beginMinute == 15) {
|
|
|
|
// // beginMinute = 30;
|
|
|
|
// // } else if (beginMinute == 45) {
|
|
|
|
// // beginHour++;
|
|
|
|
// // beginMinute = 0;
|
|
|
|
// // }
|
|
|
|
// // List endTemp = endDate.split(':');
|
|
|
|
// // /*获取结束小时*/
|
|
|
|
// // int endHour = int.parse(endTemp[0]);
|
|
|
|
// // /*获取结束分钟*/
|
|
|
|
// // int endMinute = int.parse(endTemp[1]);
|
|
|
|
// // if (endMinute == 15) {
|
|
|
|
// // endDate = '${endTemp[0]}:00';
|
|
|
|
// // } else if (endMinute == 45) {
|
|
|
|
// // endDate = '${endTemp[0]}:30';
|
|
|
|
// // }
|
|
|
|
// // List res = [];
|
|
|
|
// // bool tempLimit = true;
|
|
|
|
// // while (tempLimit) {
|
|
|
|
// // String temp = _dealTime(beginHour, beginMinute);
|
|
|
|
|
|
|
|
// // // bool tempSelect = false;
|
|
|
|
|
|
|
|
// // // Map tempMap = {'title': temp, 'select': tempSelect};
|
|
|
|
// // res.add(temp);
|
|
|
|
// // if (temp == endDate) {
|
|
|
|
// // tempLimit = false;
|
|
|
|
// // break;
|
|
|
|
// // }
|
|
|
|
// // if (beginMinute == 30) {
|
|
|
|
// // beginHour++;
|
|
|
|
// // if (beginHour >= 24) {
|
|
|
|
// // beginHour = 0;
|
|
|
|
// // }
|
|
|
|
// // }
|
|
|
|
// // beginMinute = (beginMinute + 30) % 60;
|
|
|
|
// // }
|
|
|
|
// // return res;
|
|
|
|
// // }
|
|
|
|
|
|
|
|
// /// 根据时间和分钟组装 格式:11:00
|
|
|
|
// // _dealTime(int begin, int mm) {
|
|
|
|
// // String sb = '';
|
|
|
|
// // if (begin < 10) {
|
|
|
|
// // sb = '0$begin';
|
|
|
|
// // } else {
|
|
|
|
// // sb = '$begin';
|
|
|
|
// // }
|
|
|
|
// // sb = '$sb:';
|
|
|
|
// // if (mm < 10) {
|
|
|
|
// // sb = '${sb}0${mm}';
|
|
|
|
// // } else {
|
|
|
|
// // sb = '${sb}${mm}';
|
|
|
|
// // }
|
|
|
|
// // return sb;
|
|
|
|
// // }
|
|
|
|
|
|
|
|
// //获取桌位列表
|
|
|
|
// // getTableList({needLoading = true}) async {
|
|
|
|
// // UserModel userModel = Provider.of<UserModel>(context, listen: false);
|
|
|
|
// // Map<String, String> params = {"sellerid": userModel.user.sellerid};
|
|
|
|
// // tableOuterList = await _chooseTableModel.getTableList(context, params,
|
|
|
|
// // needLoading: needLoading);
|
|
|
|
// // _chooseTableModel.tablesAll = [];
|
|
|
|
// // selectTables = [];
|
|
|
|
// // for (TableOuter item in tableOuterList) {
|
|
|
|
// // // if (item.name == "推荐") {
|
|
|
|
// // // itemModelList.remove(item);
|
|
|
|
// // // }
|
|
|
|
// // for (var item1 in item.list) {
|
|
|
|
// // item1.selected = false;
|
|
|
|
// // for (var table in widget.tableList) {
|
|
|
|
// // if (item1.id == table.id) {
|
|
|
|
// // item1.selected = true;
|
|
|
|
// // selectNum++;
|
|
|
|
// // selectTables.add(item1);
|
|
|
|
// // // if (!tableList.contains(item)) {
|
|
|
|
// // // tableList.add(item);
|
|
|
|
// // // }
|
|
|
|
// // }
|
|
|
|
// // }
|
|
|
|
// // }
|
|
|
|
// // _chooseTableModel.tablesAll.addAll(item.list);
|
|
|
|
// // }
|
|
|
|
|
|
|
|
// // if (tableOuterList.isEmpty) {
|
|
|
|
// // _chooseTableModel.pageState = PageState.Success;
|
|
|
|
// // _chooseTableModel.notifyListeners();
|
|
|
|
// // } else {
|
|
|
|
// // _getReserveList(userModel.user.sellerid, needLoading: needLoading);
|
|
|
|
// // }
|
|
|
|
// // // if (_chooseTableModel.pageState == PageState.Success) {
|
|
|
|
|
|
|
|
// // // }
|
|
|
|
// // }
|
|
|
|
|
|
|
|
// // refreshTable(context) async {
|
|
|
|
// // await getTableList(needLoading: false);
|
|
|
|
// // // if (temp.length > 0) {
|
|
|
|
// // // _getReserveList(context, needLoading: false);
|
|
|
|
// // // } else {
|
|
|
|
// // // // pageState = PageState.Empty;
|
|
|
|
// // // _chooseTableModel.pageState = PageState.Success;
|
|
|
|
// // // _chooseTableModel.notifyListeners();
|
|
|
|
// // // }
|
|
|
|
// // }
|
|
|
|
|
|
|
|
// // //获取预订(原来普通预订和宴会预订)
|
|
|
|
// // _getReserveListAndFeastData(context, params, showloading) async {
|
|
|
|
// // UserModel userModel = Provider.of<UserModel>(context, listen: false);
|
|
|
|
// // String timeStrStart = '';
|
|
|
|
// // String timeStrEnd = '';
|
|
|
|
|
|
|
|
// // String hmsS = " ${widget.hmS}:00"; //起始
|
|
|
|
// // String hmsE = " ${widget.hmE}:59"; //结束
|
|
|
|
|
|
|
|
// // if (widget.hmS == 'null' || widget.hmE == 'null') {
|
|
|
|
// // //用餐段对应的时间段作为起始时间
|
|
|
|
// // String keys = '';
|
|
|
|
|
|
|
|
// // if (widget.ddate_slot == '1') {
|
|
|
|
// // //早市
|
|
|
|
// // keys = 'morning';
|
|
|
|
// // } else if (widget.ddate_slot == '2') {
|
|
|
|
// // //午市
|
|
|
|
// // keys = 'noon';
|
|
|
|
// // } else if (widget.ddate_slot == '3') {
|
|
|
|
// // //晚市
|
|
|
|
// // keys = 'night';
|
|
|
|
// // }
|
|
|
|
// // String ymd =
|
|
|
|
// // DateUtil.formatDate(widget.dateTime, format: DateFormats.y_mo_d);
|
|
|
|
// // if (keys != '') {
|
|
|
|
// // List temp = dailyMap[keys];
|
|
|
|
// // timeStrStart = ymd + ' ' + temp.first + ':00';
|
|
|
|
// // timeStrEnd = ymd + ' ' + temp.last + ':00';
|
|
|
|
// // } else {
|
|
|
|
// // hmsS = " 00:00:00";
|
|
|
|
// // hmsE = " 23:59:59";
|
|
|
|
// // timeStrStart = widget.dateTime.year.toString() +
|
|
|
|
// // "-" +
|
|
|
|
// // Utils.addZeroNumber(widget.dateTime.month) +
|
|
|
|
// // "-" +
|
|
|
|
// // Utils.addZeroNumber(widget.dateTime.day) +
|
|
|
|
// // hmsS;
|
|
|
|
// // timeStrEnd = widget.dateTime.year.toString() +
|
|
|
|
// // "-" +
|
|
|
|
// // Utils.addZeroNumber(widget.dateTime.month) +
|
|
|
|
// // "-" +
|
|
|
|
// // Utils.addZeroNumber(widget.dateTime.day) +
|
|
|
|
// // hmsE;
|
|
|
|
// // }
|
|
|
|
// // } else {
|
|
|
|
// // hmsS = " ${widget.hmS}:00"; //起始
|
|
|
|
// // hmsE = " ${widget.hmE}:59"; //结束
|
|
|
|
// // timeStrStart = widget.dateTime.year.toString() +
|
|
|
|
// // "-" +
|
|
|
|
// // Utils.addZeroNumber(widget.dateTime.month) +
|
|
|
|
// // "-" +
|
|
|
|
// // Utils.addZeroNumber(widget.dateTime.day) +
|
|
|
|
// // hmsS;
|
|
|
|
// // timeStrEnd = widget.dateTime.year.toString() +
|
|
|
|
// // "-" +
|
|
|
|
// // Utils.addZeroNumber(widget.dateTime.month) +
|
|
|
|
// // "-" +
|
|
|
|
// // Utils.addZeroNumber(widget.dateTime.day) +
|
|
|
|
// // hmsE;
|
|
|
|
// // }
|
|
|
|
|
|
|
|
// // String start =
|
|
|
|
// // (DateUtil.getDateMsByTimeStr(timeStrStart) / 1000).floor().toString();
|
|
|
|
// // String end =
|
|
|
|
// // (DateUtil.getDateMsByTimeStr(timeStrEnd) / 1000).floor().toString();
|
|
|
|
|
|
|
|
// // Map<String, String> banquetmap = {
|
|
|
|
// // 'sid': userModel.user.sellerid,
|
|
|
|
// // 'rdate': '${start}',
|
|
|
|
// // 'edate': '${end}',
|
|
|
|
// // // 'ddate_interval': widget.ddate_slot
|
|
|
|
// // };
|
|
|
|
// // return await Future.wait<bool>([
|
|
|
|
// // _getOldReserve(context, params, showloading),
|
|
|
|
// // _chooseTableModel.getBanquetByDate(context, banquetmap,
|
|
|
|
// // showLoading: showloading)
|
|
|
|
// // ]).then((results) {
|
|
|
|
// // if (results[0] && results[1]) {
|
|
|
|
// // //成功
|
|
|
|
// // return true;
|
|
|
|
// // } else {
|
|
|
|
// // if (!results[0]) {
|
|
|
|
// // // Utils.showToast('');
|
|
|
|
// // } else {
|
|
|
|
// // // Utils.showToast('');
|
|
|
|
// // }
|
|
|
|
// // return false;
|
|
|
|
// // }
|
|
|
|
// // }).catchError((e) {
|
|
|
|
// // print(e);
|
|
|
|
// // return false;
|
|
|
|
// // });
|
|
|
|
// // }
|
|
|
|
|
|
|
|
// // Future<bool> _getOldReserve(context, params, showloading) async {
|
|
|
|
// // NoteBookModel model = new NoteBookModel();
|
|
|
|
// // noteBooks =
|
|
|
|
// // await model.getReserveList(context, params, needLoading: showloading);
|
|
|
|
// // return true;
|
|
|
|
// // }
|
|
|
|
|
|
|
|
// // //获取已预订列表
|
|
|
|
// // _getReserveList(String sid, {needLoading = true}) async {
|
|
|
|
// // NoteBookModel model = new NoteBookModel();
|
|
|
|
// // Map<String, String> params = {
|
|
|
|
// // "sid": sid,
|
|
|
|
// // "rdate": _getRdate(),
|
|
|
|
// // // "ddate_solt": widget.ddate_slot,
|
|
|
|
// // "y": "200",
|
|
|
|
// // "x": "1",
|
|
|
|
// // "keywords": "",
|
|
|
|
// // "sort": "1"
|
|
|
|
// // };
|
|
|
|
// // if (widget.source == '1') {
|
|
|
|
// // params['source'] = '1';
|
|
|
|
// // }
|
|
|
|
// // // List<Notebook> noteBooks =
|
|
|
|
// // // await model.getReserveList(context, params, needLoading: needLoading);
|
|
|
|
// // bool success =
|
|
|
|
// // await _getReserveListAndFeastData(context, params, needLoading);
|
|
|
|
// // if (success) {
|
|
|
|
// // List<FeastBoardModel> banquetByDateDataTemp = []; //转换为桌子id为key,data为value
|
|
|
|
// // _chooseTableModel.banquetByDateData.forEach((element) {
|
|
|
|
// // _chooseTableModel.tablesAll.forEach((table) {
|
|
|
|
// // if (table.name == element.title) {
|
|
|
|
// // FeastBoardModel feastBoardModel = FeastBoardModel();
|
|
|
|
// // feastBoardModel.title = table.id;
|
|
|
|
// // feastBoardModel.data = element.data;
|
|
|
|
// // banquetByDateDataTemp.add(feastBoardModel);
|
|
|
|
// // }
|
|
|
|
// // });
|
|
|
|
// // });
|
|
|
|
// // // banquetByDateData.map((e) => null)
|
|
|
|
// // // String banquetKey = '';
|
|
|
|
// // // if (widget.ddate_slot == '1') {
|
|
|
|
// // // banquetKey = '早餐';
|
|
|
|
// // // } else if (widget.ddate_slot == '2') {
|
|
|
|
// // // banquetKey = '午餐';
|
|
|
|
// // // } else if (widget.ddate_slot == '3') {
|
|
|
|
// // // banquetKey = '晚餐';
|
|
|
|
// // // }
|
|
|
|
|
|
|
|
// // Map<String, List<FeastBoardSunModel>> banquetData = {};
|
|
|
|
// // banquetByDateDataTemp.forEach((element) {
|
|
|
|
// // List<FeastBoardSunModel> data = [];
|
|
|
|
|
|
|
|
// // if (element.data['其他'].length > 0) {
|
|
|
|
// // // FeastBoardSunModel feastBoardSunModel = element.data['其他'][0];
|
|
|
|
// // element.data['其他'].forEach((feastBoardSunModel) {
|
|
|
|
// // if (feastBoardSunModel.lost == null ||
|
|
|
|
// // feastBoardSunModel.lost == '') {
|
|
|
|
// // data.add(feastBoardSunModel); //未丢单宴会合集
|
|
|
|
// // }
|
|
|
|
// // });
|
|
|
|
// // }
|
|
|
|
// // if (element.data['早餐'].length > 0) {
|
|
|
|
// // // FeastBoardSunModel feastBoardSunModel = element.data['早餐'][0];
|
|
|
|
// // element.data['早餐'].forEach((feastBoardSunModel) {
|
|
|
|
// // if (feastBoardSunModel.lost == null ||
|
|
|
|
// // feastBoardSunModel.lost == '') {
|
|
|
|
// // data.add(feastBoardSunModel); //未丢单宴会合集
|
|
|
|
// // }
|
|
|
|
// // });
|
|
|
|
// // }
|
|
|
|
// // if (element.data['午餐'].length > 0) {
|
|
|
|
// // // FeastBoardSunModel feastBoardSunModel = element.data['午餐'][0];
|
|
|
|
// // element.data['午餐'].forEach((feastBoardSunModel) {
|
|
|
|
// // if (feastBoardSunModel.lost == null ||
|
|
|
|
// // feastBoardSunModel.lost == '') {
|
|
|
|
// // data.add(feastBoardSunModel); //未丢单宴会合集
|
|
|
|
// // }
|
|
|
|
// // });
|
|
|
|
// // }
|
|
|
|
// // if (element.data['晚餐'].length > 0) {
|
|
|
|
// // // FeastBoardSunModel feastBoardSunModel = element.data['晚餐'][0];
|
|
|
|
// // element.data['晚餐'].forEach((feastBoardSunModel) {
|
|
|
|
// // if (feastBoardSunModel.lost == null ||
|
|
|
|
// // feastBoardSunModel.lost == '') {
|
|
|
|
// // data.add(feastBoardSunModel); //未丢单宴会合集
|
|
|
|
// // }
|
|
|
|
// // });
|
|
|
|
// // }
|
|
|
|
// // // 不是丢单宴会&&不是当前宴会
|
|
|
|
// // // 移除当前宴会订单
|
|
|
|
// // if (widget.ridFeast != null) {
|
|
|
|
// // print(data);
|
|
|
|
// // data.removeWhere((element) => element.rid == widget.ridFeast);
|
|
|
|
// // print(data);
|
|
|
|
// // }
|
|
|
|
|
|
|
|
// // if (!banquetData.containsKey(element.title) && data.length > 0) {
|
|
|
|
// // banquetData[element.title] = data;
|
|
|
|
// // }
|
|
|
|
// // });
|
|
|
|
|
|
|
|
// // List<String> tidsWidget =
|
|
|
|
// // widget.tableList.map((element) => element.id).toList();
|
|
|
|
// // print(tidsWidget);
|
|
|
|
// // banquetData.forEach((key, value) {
|
|
|
|
// // value.forEach((element) {
|
|
|
|
// // //未丢单的宴会
|
|
|
|
|
|
|
|
// // if (!tidsWidget.contains(key)) {
|
|
|
|
// // //带过来的桌子,不能标记已预订,或者已经有宴会
|
|
|
|
// // Notebook notebook = Notebook();
|
|
|
|
// // notebook.tid = key;
|
|
|
|
// // notebook.status = '10'; //宴会类型
|
|
|
|
// // notebook.className = element.className;
|
|
|
|
// // notebook.id = element.rid;
|
|
|
|
// // notebook.rname = element.rname;
|
|
|
|
// // notebook.nick_name = element.nickName ?? element.account;
|
|
|
|
// // noteBooks.add(notebook);
|
|
|
|
// // }
|
|
|
|
|
|
|
|
// // print(noteBooks);
|
|
|
|
|
|
|
|
// // // banquetByDateDataTemp.forEach((element) {
|
|
|
|
// // // FeastBoardSunModel feastBoardSunModel = element.data[banquetKey][0];
|
|
|
|
// // // if (feastBoardSunModel.lost == null || feastBoardSunModel.lost == '') {
|
|
|
|
// // //未丢单的宴会
|
|
|
|
// // // Notebook notebook = Notebook();
|
|
|
|
// // // notebook.tid = element.title;
|
|
|
|
// // // notebook.status = '10'; //宴会类型
|
|
|
|
// // // notebook.className = feastBoardSunModel.className;
|
|
|
|
// // // notebook.id = feastBoardSunModel.rid;
|
|
|
|
// // // notebook.rname = feastBoardSunModel.rname;
|
|
|
|
// // // notebook.nick_name =
|
|
|
|
// // // feastBoardSunModel.nickName ?? feastBoardSunModel.account;
|
|
|
|
// // // noteBooks.add(notebook);
|
|
|
|
// // // }
|
|
|
|
// // });
|
|
|
|
// // });
|
|
|
|
// // for (Notebook notebook in noteBooks) {
|
|
|
|
// // if (notebook.tid.isEmpty) continue;
|
|
|
|
// // if (notebook.status == "1" ||
|
|
|
|
// // notebook.status == "2" ||
|
|
|
|
// // notebook.status == "5" ||
|
|
|
|
// // notebook.status == "10") {
|
|
|
|
// // //已预订,用餐中,已安排
|
|
|
|
// // List<String> tids = notebook.tid.split(",");
|
|
|
|
// // for (String tid in tids) {
|
|
|
|
// // tableMap["$tid"] = notebook;
|
|
|
|
// // }
|
|
|
|
// // }
|
|
|
|
// // }
|
|
|
|
|
|
|
|
// // // List<Notebook> noteBooks =
|
|
|
|
// // // await newGetReserveList(context, params, showLoading: showloading);
|
|
|
|
// // // List<t.Table> tempSelectTables = [];
|
|
|
|
// // // tempSelectTables.addAll(selectTables);
|
|
|
|
// // // String msg = '';
|
|
|
|
// // // for (Notebook notebook in noteBooks) {
|
|
|
|
// // // if (notebook.tid.isEmpty) continue;
|
|
|
|
|
|
|
|
// // // //已预订,用餐中,已安排
|
|
|
|
// // // List<String> tids = notebook.tid.split(",");
|
|
|
|
// // // for (String tid in tids) {
|
|
|
|
// // // if (notebook.status == "1" ||
|
|
|
|
// // // notebook.status == "2" ||
|
|
|
|
// // // notebook.status == "5" ||
|
|
|
|
// // // notebook.status == "10") {
|
|
|
|
// // // tableMap["$tid"] = notebook;
|
|
|
|
|
|
|
|
// // // ///预订按钮点击的时候提醒已经被预订的桌子
|
|
|
|
// // // ///
|
|
|
|
// // // if (showMsg && selectTables.length > 0) {
|
|
|
|
// // // for (t.Table item in selectTables) {
|
|
|
|
// // // if (item.id == tid) {
|
|
|
|
// // // msg += '${item.name},';
|
|
|
|
// // // tempSelectTables.remove(item);
|
|
|
|
// // // }
|
|
|
|
// // // }
|
|
|
|
// // // }
|
|
|
|
// // // }
|
|
|
|
// // // }
|
|
|
|
// // // }
|
|
|
|
// // // if (showMsg && msg != '' && selectTables.length > 0) {
|
|
|
|
// // // if (msg.endsWith(',')) {
|
|
|
|
// // // msg = msg.substring(0, msg.length - 1);
|
|
|
|
// // // }
|
|
|
|
// // // selectTables = tempSelectTables;
|
|
|
|
// // // Utils.showToast('${msg}已被预订,请选择其他桌位!');
|
|
|
|
// // // print(tableMap);
|
|
|
|
// // // initData(needKeep: needKeep);
|
|
|
|
// // // // notifyListeners();
|
|
|
|
// // // return false;
|
|
|
|
// // // }
|
|
|
|
|
|
|
|
// // // print(tableMap);
|
|
|
|
// // // initData(needKeep: needKeep);
|
|
|
|
// // // return true;
|
|
|
|
// // }
|
|
|
|
|
|
|
|
// // print(tableMap);
|
|
|
|
// // if (needLoading) {
|
|
|
|
// // initData();
|
|
|
|
// // } else {
|
|
|
|
// // initData(needRetain: true);
|
|
|
|
// // }
|
|
|
|
// // }
|
|
|
|
|
|
|
|
// //初始桌位数据
|
|
|
|
// // initData({bool needRetain = false}) {
|
|
|
|
// // areas.clear();
|
|
|
|
// // areaTableMap.clear();
|
|
|
|
// // List<t.Table> tempTableAll = [];
|
|
|
|
// // tempTableAll.addAll(_chooseTableModel.tablesAll);
|
|
|
|
// // for (TableOuter outer in tableOuterList) {
|
|
|
|
// // int count = 0;
|
|
|
|
// // List<t.Table> tempList = [];
|
|
|
|
// // tempList.addAll(outer.list);
|
|
|
|
// // for (t.Table table in outer.list) {
|
|
|
|
// // // table.selected = false;
|
|
|
|
// // if (widget.tid != '' && table.id == widget.tid) {
|
|
|
|
// // table.selected = true;
|
|
|
|
// // currentArea = outer.name;
|
|
|
|
// // }
|
|
|
|
// // if (table.tablestatus == "0") {
|
|
|
|
// // //没有用餐中
|
|
|
|
// // if (tableMap["${table.id}"] != null) {
|
|
|
|
// // Notebook notebook = tableMap["${table.id}"];
|
|
|
|
// // table.sign = notebook.status;
|
|
|
|
// // table.notebookId = notebook.id;
|
|
|
|
// // table.reserver = notebook.rnameStr;
|
|
|
|
// // table.pnum = notebook.actual_pnum;
|
|
|
|
// // table.nickName = notebook.nick_name;
|
|
|
|
// // table.noteName = notebook.note_name;
|
|
|
|
// // table.label = notebook.className;
|
|
|
|
// // //(不能移除自己定的桌子)
|
|
|
|
// // String idNow = '';
|
|
|
|
// // if (tableMap.containsKey('${table.id}')) {
|
|
|
|
// // //包含,证明该桌子已经被预订了
|
|
|
|
// // idNow = tableMap['${table.id}'].id;
|
|
|
|
// // if (idNow != widget.rid) {
|
|
|
|
// // //不是自己的当前订单
|
|
|
|
// // //剔除已经预订的桌子,剩下空桌子(仅看空座)
|
|
|
|
// // tempList.remove(table);
|
|
|
|
// // //全部
|
|
|
|
// // tempTableAll.remove(table);
|
|
|
|
// // }
|
|
|
|
// // }
|
|
|
|
// // } else {
|
|
|
|
// // table.sign = "";
|
|
|
|
// // table.notebookId = "";
|
|
|
|
// // if (table.enable == "1") {
|
|
|
|
// // count++;
|
|
|
|
// // }
|
|
|
|
// // }
|
|
|
|
// // } else {
|
|
|
|
// // table.sign = "2";
|
|
|
|
// // table.notebookId = "";
|
|
|
|
// // }
|
|
|
|
// // }
|
|
|
|
|
|
|
|
// // areaTableMap["${outer.name}"] = outer.list;
|
|
|
|
// // _chooseTableModel.areaTableMapCanNote["${outer.name}"] = tempList;
|
|
|
|
// // Area area = Area();
|
|
|
|
// // area.name = outer.name;
|
|
|
|
// // area.count = outer.list.length == 0 ? -1 : count;
|
|
|
|
// // area.rid = outer.list.length == 0 ? outer.rid : outer.list[0].rid;
|
|
|
|
// // area.orderId = outer.orderId;
|
|
|
|
// // areas.add(area);
|
|
|
|
// // }
|
|
|
|
// // _chooseTableModel.tablesCanNote = tempTableAll;
|
|
|
|
// // if (_chooseTableModel.swichState) {
|
|
|
|
// // _chooseTableModel.areaTableMapShow =
|
|
|
|
// // _chooseTableModel.areaTableMapCanNote;
|
|
|
|
// // _chooseTableModel.tablesShow = _chooseTableModel.tablesCanNote;
|
|
|
|
// // } else {
|
|
|
|
// // _chooseTableModel.areaTableMapShow = areaTableMap;
|
|
|
|
// // _chooseTableModel.tablesShow = _chooseTableModel.tablesAll;
|
|
|
|
// // }
|
|
|
|
// // print(currentArea);
|
|
|
|
// // if (widget.tid == '') {
|
|
|
|
// // if (!needRetain) {
|
|
|
|
// // // currentArea = areaTableMap.keys.first;
|
|
|
|
// // currentArea = '全部';
|
|
|
|
// // _chooseTableModel.currentTables = _chooseTableModel.tablesAll;
|
|
|
|
// // }
|
|
|
|
// // // if (areas.length == 1) {
|
|
|
|
// // // currentArea = areaTableMap.keys.first;
|
|
|
|
// // // }
|
|
|
|
// // }
|
|
|
|
|
|
|
|
// // _chooseTableModel.pageState = PageState.Success;
|
|
|
|
// // _chooseTableModel.notifyListeners();
|
|
|
|
// // }
|
|
|
|
|
|
|
|
// //获取一天开始-结束时间字符串
|
|
|
|
// // String _getRdate() {
|
|
|
|
// // String timeStrStart = '';
|
|
|
|
// // String timeStrEnd = '';
|
|
|
|
// // //一天开始时间
|
|
|
|
// // double startDay;
|
|
|
|
// // //一天结束时间
|
|
|
|
// // double endDay;
|
|
|
|
|
|
|
|
// // String hmsS = " ${widget.hmS}:00"; //起始
|
|
|
|
// // String hmsE = " ${widget.hmE}:59"; //结束
|
|
|
|
|
|
|
|
// // if (widget.hmS == 'null' || widget.hmE == 'null') {
|
|
|
|
// // //用餐段对应的时间段作为起始时间
|
|
|
|
// // String keys = '';
|
|
|
|
|
|
|
|
// // if (widget.ddate_slot == '1') {
|
|
|
|
// // //早市
|
|
|
|
// // keys = 'morning';
|
|
|
|
// // } else if (widget.ddate_slot == '2') {
|
|
|
|
// // //午市
|
|
|
|
// // keys = 'noon';
|
|
|
|
// // } else if (widget.ddate_slot == '3') {
|
|
|
|
// // //晚市
|
|
|
|
// // keys = 'night';
|
|
|
|
// // }
|
|
|
|
// // String ymd =
|
|
|
|
// // DateUtil.formatDate(widget.dateTime, format: DateFormats.y_mo_d);
|
|
|
|
// // if (keys != '') {
|
|
|
|
// // List temp = dailyMap[keys];
|
|
|
|
// // timeStrStart = ymd + ' ' + temp.first + ':00';
|
|
|
|
// // timeStrEnd = ymd + ' ' + temp.last + ':00';
|
|
|
|
// // } else {
|
|
|
|
// // hmsS = " 00:00:00";
|
|
|
|
// // hmsE = " 23:59:59";
|
|
|
|
// // timeStrStart = widget.dateTime.year.toString() +
|
|
|
|
// // "-" +
|
|
|
|
// // Utils.addZeroNumber(widget.dateTime.month) +
|
|
|
|
// // "-" +
|
|
|
|
// // Utils.addZeroNumber(widget.dateTime.day) +
|
|
|
|
// // hmsS;
|
|
|
|
// // timeStrEnd = widget.dateTime.year.toString() +
|
|
|
|
// // "-" +
|
|
|
|
// // Utils.addZeroNumber(widget.dateTime.month) +
|
|
|
|
// // "-" +
|
|
|
|
// // Utils.addZeroNumber(widget.dateTime.day) +
|
|
|
|
// // hmsE;
|
|
|
|
// // }
|
|
|
|
// // } else {
|
|
|
|
// // hmsS = " ${widget.hmS}:00"; //起始
|
|
|
|
// // hmsE = " ${widget.hmE}:59"; //结束
|
|
|
|
// // timeStrStart = widget.dateTime.year.toString() +
|
|
|
|
// // "-" +
|
|
|
|
// // Utils.addZeroNumber(widget.dateTime.month) +
|
|
|
|
// // "-" +
|
|
|
|
// // Utils.addZeroNumber(widget.dateTime.day) +
|
|
|
|
// // hmsS;
|
|
|
|
// // timeStrEnd = widget.dateTime.year.toString() +
|
|
|
|
// // "-" +
|
|
|
|
// // Utils.addZeroNumber(widget.dateTime.month) +
|
|
|
|
// // "-" +
|
|
|
|
// // Utils.addZeroNumber(widget.dateTime.day) +
|
|
|
|
// // hmsE;
|
|
|
|
// // }
|
|
|
|
|
|
|
|
// // // }
|
|
|
|
// // startDay = (DateTime.parse(timeStrStart).millisecondsSinceEpoch) / 1000;
|
|
|
|
// // endDay = (DateTime.parse(timeStrEnd).millisecondsSinceEpoch) / 1000;
|
|
|
|
// // return startDay.floor().toString() + "-" + endDay.floor().toString();
|
|
|
|
// // }
|
|
|
|
|
|
|
|
// Widget item(int i) {
|
|
|
|
// return GridView.builder(
|
|
|
|
// // controller: _areaController,
|
|
|
|
// // physics: NeverScrollableScrollPhysics(),
|
|
|
|
// padding: EdgeInsets.symmetric(
|
|
|
|
// vertical: ScreenUtil().setWidth(20),
|
|
|
|
// horizontal: ScreenUtil().setWidth(10)),
|
|
|
|
// shrinkWrap: true,
|
|
|
|
|
|
|
|
// itemCount:
|
|
|
|
// tableManagerModel.tablesOrReserveDataShow[i].tableList.length == 0
|
|
|
|
// ? 1
|
|
|
|
// : tableManagerModel.tablesOrReserveDataShow[i].tableList.length +
|
|
|
|
// 1,
|
|
|
|
// gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
// crossAxisCount: 4,
|
|
|
|
// childAspectRatio: 1,
|
|
|
|
// mainAxisSpacing: ScreenUtil().setWidth(30),
|
|
|
|
// crossAxisSpacing: ScreenUtil().setWidth(12),
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// itemBuilder: (BuildContext context, int index) {
|
|
|
|
// if (index ==
|
|
|
|
// tableManagerModel.tablesOrReserveDataShow[i].tableList.length ||
|
|
|
|
// tableManagerModel.tablesOrReserveDataShow[i].tableList.length ==
|
|
|
|
// 0) {
|
|
|
|
// return InkWell(
|
|
|
|
// onTap: () async {
|
|
|
|
// List<String> areasTemp = [];
|
|
|
|
|
|
|
|
// for (int i = 0;
|
|
|
|
// i < tableManagerModel.tablesOrReserveDataShow.length;
|
|
|
|
// i++) {
|
|
|
|
// areasTemp
|
|
|
|
// .add(tableManagerModel.tablesOrReserveDataShow[i].name);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //添加桌位弹框
|
|
|
|
// await DialogUtil.openCreateTableDialog(
|
|
|
|
// context, areasTemp, i, personNumList,
|
|
|
|
// onTap: (Map<String, String> value) async {
|
|
|
|
// print(value);
|
|
|
|
// // 'areaname':
|
|
|
|
// // areas[currentAreaIndex],
|
|
|
|
// // 'name': controller.text,
|
|
|
|
// // 'pnumMin': pnumMin,
|
|
|
|
// // 'pnumMax': pnumMax
|
|
|
|
// //添加桌位 接口参数带整合???
|
|
|
|
// // 以下是旧的不去,明天添加桌位接口
|
|
|
|
// String rid;
|
|
|
|
// for (TableListReseveSunModel item
|
|
|
|
// in tableManagerModel.tablesOrReserveDataShow) {
|
|
|
|
// if (item.name == value['areaname']) {
|
|
|
|
// rid = item.id;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// Map<String, String> params = {
|
|
|
|
// 'rid': rid,
|
|
|
|
// 'name': value['name'],
|
|
|
|
// };
|
|
|
|
// if (value['pnumMin'] != '') {
|
|
|
|
// params['pnum'] = value['pnumMin'];
|
|
|
|
// }
|
|
|
|
// if (value['pnumMax'] != '') {
|
|
|
|
// params['most_pnum'] = value['pnumMax'];
|
|
|
|
// }
|
|
|
|
// bool success =
|
|
|
|
// await _chooseTableModel.addTable(context, params);
|
|
|
|
// print(success);
|
|
|
|
// if (success) {
|
|
|
|
// Utils.showToast('添加成功!');
|
|
|
|
|
|
|
|
// _getTableListOrReserve();
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// },
|
|
|
|
// child: Container(
|
|
|
|
// child: DottedBorder(
|
|
|
|
// dashPattern: [5, 5, 5, 5],
|
|
|
|
// borderType: BorderType.RRect,
|
|
|
|
// radius: Radius.circular(ScreenUtil().setWidth(20)),
|
|
|
|
// // padding: EdgeInsets.all(ScreenUtil().setWidth(70)),
|
|
|
|
// color: MyColours.color_E0E0E0,
|
|
|
|
// strokeWidth: ScreenUtil().setWidth(2),
|
|
|
|
// child: ClipRRect(
|
|
|
|
// borderRadius: BorderRadius.all(
|
|
|
|
// Radius.circular(ScreenUtil().setWidth(20))),
|
|
|
|
// child: Container(
|
|
|
|
// height: ScreenUtil().screenWidth -
|
|
|
|
// ScreenUtil().setWidth(12 * 3 - 10 * 2),
|
|
|
|
// width: ScreenUtil().screenWidth -
|
|
|
|
// ScreenUtil().setWidth(12 * 3 - 10 * 2),
|
|
|
|
// child: Column(
|
|
|
|
// mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
// children: [
|
|
|
|
// Image.asset(Utils.getImgPath('add_store'),
|
|
|
|
// width: ScreenUtil().setWidth(32)),
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// )));
|
|
|
|
// } else {
|
|
|
|
// TableListReserve data =
|
|
|
|
// tableManagerModel.tablesOrReserveDataShow[i].tableList[index];
|
|
|
|
// return Selector<TableManagerModelOrReserve, TableListReserve>(
|
|
|
|
// shouldRebuild: (pre, next) => true,
|
|
|
|
// selector: (context, model) => data,
|
|
|
|
// builder: (context, table, _) {
|
|
|
|
// return TableItemOrReserve(table,
|
|
|
|
// canSelected: true,
|
|
|
|
// selectTables: tableManagerModel.selectTablesOrReserve,
|
|
|
|
// onSelected: (tableListReserve) {
|
|
|
|
// if (widget.fromPage == 'tablePhoto') {
|
|
|
|
// for (TableListReseveSunModel item
|
|
|
|
// in tableManagerModel.tablesOrReserveDataShow) {
|
|
|
|
// for (TableListReserve element in item.tableList) {
|
|
|
|
// element.selected = false;
|
|
|
|
// selectNum = 0;
|
|
|
|
// if (table.id == item.id) {
|
|
|
|
// element.selected = true;
|
|
|
|
// tableManagerModel.selectTablesOrReserve = [];
|
|
|
|
// selectNum++;
|
|
|
|
// tableManagerModel.selectTablesOrReserve.add(table);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// setState(() {});
|
|
|
|
// } else {
|
|
|
|
// if ((table as t.Table).selected) {
|
|
|
|
// tableManagerModel.selectTablesOrReserve.add(table);
|
|
|
|
// selectNum++;
|
|
|
|
// widget.tableList.add(tableToTableList(table));
|
|
|
|
// } else {
|
|
|
|
// widget.tableList.removeWhere((t) => t.id == table.id);
|
|
|
|
// selectNum--;
|
|
|
|
// tableManagerModel.selectTablesOrReserve
|
|
|
|
// .removeWhere((t) => t.id == table.id);
|
|
|
|
// }
|
|
|
|
// setState(() {});
|
|
|
|
// }
|
|
|
|
// }, fromPage: widget.fromPage, rid: widget.rid);
|
|
|
|
// },
|
|
|
|
// );
|
|
|
|
// }
|
|
|
|
// },
|
|
|
|
// );
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @override
|
|
|
|
// Widget build(BuildContext context) {
|
|
|
|
// _chooseTableModel = Provider.of<ChooseTableModel>(context);
|
|
|
|
// tableManagerModel =
|
|
|
|
// Provider.of<TableManagerModelOrReserve>(context, listen: true);
|
|
|
|
// return Scaffold(
|
|
|
|
// body: SafeArea(
|
|
|
|
// child: Column(
|
|
|
|
// children: <Widget>[
|
|
|
|
// MyAppBar(
|
|
|
|
// "选择桌位",
|
|
|
|
// showBack: true,
|
|
|
|
// ),
|
|
|
|
// Expanded(
|
|
|
|
// child: Consumer<TableManagerModelOrReserve>(
|
|
|
|
// builder: (context, model, child) {
|
|
|
|
// if (model.pageStateOrReserve != PageState.Success) {
|
|
|
|
// Expanded(
|
|
|
|
// child: ExceptionPage(
|
|
|
|
// pageState: model.pageStateOrReserve,
|
|
|
|
// callback: () {
|
|
|
|
// tableManagerModel.getTableListOrReserve(context,
|
|
|
|
// showLoading: true);
|
|
|
|
// },
|
|
|
|
// emptyMsg: "暂时没有桌位哦",
|
|
|
|
// emptyImg: "empty_search",
|
|
|
|
// showMsg: "加载中,请稍后...",
|
|
|
|
// ));
|
|
|
|
// } else {
|
|
|
|
// return Column(
|
|
|
|
// // crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
// children: [
|
|
|
|
// Container(
|
|
|
|
// color: MyColours.color_ffffff,
|
|
|
|
// height: ScreenUtil().setWidth(92),
|
|
|
|
// margin:
|
|
|
|
// EdgeInsets.only(bottom: ScreenUtil().setWidth(30)),
|
|
|
|
// child: Row(
|
|
|
|
// children: [
|
|
|
|
// HEmptyView(20),
|
|
|
|
// Expanded(
|
|
|
|
// child: ListView.builder(
|
|
|
|
// itemCount: tableManagerModel
|
|
|
|
// .tablesOrReserveDataShow
|
|
|
|
// .length ==
|
|
|
|
// 0
|
|
|
|
// ? 1
|
|
|
|
// : tableManagerModel
|
|
|
|
// .tablesOrReserveDataShow
|
|
|
|
// .length +
|
|
|
|
// 1,
|
|
|
|
// shrinkWrap: true,
|
|
|
|
// scrollDirection: Axis.horizontal,
|
|
|
|
// itemBuilder:
|
|
|
|
// (BuildContext contxt, int index) {
|
|
|
|
// if (index ==
|
|
|
|
// tableManagerModel
|
|
|
|
// .tablesOrReserveDataShow
|
|
|
|
// .length ||
|
|
|
|
// tableManagerModel
|
|
|
|
// .tablesOrReserveDataShow
|
|
|
|
// .length ==
|
|
|
|
// 0) {
|
|
|
|
// return InkWell(
|
|
|
|
// onTap: () async {
|
|
|
|
// //添加区域弹框
|
|
|
|
// await DialogUtil
|
|
|
|
// .openCreateAreaDialog(context,
|
|
|
|
// onTap: (value) async {
|
|
|
|
// print(value);
|
|
|
|
// //添加区域
|
|
|
|
// bool success =
|
|
|
|
// await _chooseTableModel
|
|
|
|
// .addTableAreas(
|
|
|
|
// context, value);
|
|
|
|
// print(success);
|
|
|
|
// if (success) {
|
|
|
|
// Utils.showToast('添加成功!');
|
|
|
|
// tableManagerModel
|
|
|
|
// .getTableListOrReserve(
|
|
|
|
// context,
|
|
|
|
// showLoading: true);
|
|
|
|
// // UserModel userModel =
|
|
|
|
// // Provider.of<UserModel>(context,
|
|
|
|
// // listen: false);
|
|
|
|
// // Map<String, String> params = {
|
|
|
|
// // "sellerid": userModel.user.sellerid
|
|
|
|
// // };
|
|
|
|
// // await _chooseTableModel.getTableList(
|
|
|
|
// // context, params,
|
|
|
|
// // needLoading: false);
|
|
|
|
// // initData();
|
|
|
|
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// },
|
|
|
|
// child: Column(
|
|
|
|
// children: [
|
|
|
|
// VEmptyView(20),
|
|
|
|
// DottedBorder(
|
|
|
|
// dashPattern: [5, 5, 5, 5],
|
|
|
|
// borderType: BorderType.RRect,
|
|
|
|
// radius: Radius.circular(
|
|
|
|
// ScreenUtil().setWidth(10)),
|
|
|
|
// // padding: EdgeInsets.all(ScreenUtil().setWidth(70)),
|
|
|
|
// color: MyColours.color_199095,
|
|
|
|
// strokeWidth:
|
|
|
|
// ScreenUtil().setWidth(2),
|
|
|
|
// child: ClipRRect(
|
|
|
|
// borderRadius: BorderRadius
|
|
|
|
// .all(Radius.circular(
|
|
|
|
// ScreenUtil()
|
|
|
|
// .setWidth(10))),
|
|
|
|
// child: Container(
|
|
|
|
// height: ScreenUtil()
|
|
|
|
// .setWidth(25 * 2),
|
|
|
|
// width: ScreenUtil()
|
|
|
|
// .setWidth(104 * 2),
|
|
|
|
// child: Column(
|
|
|
|
// mainAxisAlignment:
|
|
|
|
// MainAxisAlignment
|
|
|
|
// .center,
|
|
|
|
// children: [
|
|
|
|
// Image.asset(
|
|
|
|
// Utils.getImgPath(
|
|
|
|
// 'add_area'),
|
|
|
|
// width: ScreenUtil()
|
|
|
|
// .setWidth(24)),
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// )
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
// );
|
|
|
|
// } else {
|
|
|
|
// return AreaItemTableOrReserve(
|
|
|
|
// tableManagerModel
|
|
|
|
// .tablesOrReserveDataShow[index],
|
|
|
|
// (area) {
|
|
|
|
// tableManagerModel
|
|
|
|
// .tablesOrReserveDataShow
|
|
|
|
// .forEach((element) {
|
|
|
|
// element.select = false;
|
|
|
|
// });
|
|
|
|
// setState(() {
|
|
|
|
// // isSelected = false;
|
|
|
|
// area.select = true;
|
|
|
|
// tableManagerModel.selectNumber =
|
|
|
|
// index;
|
|
|
|
// });
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
// })),
|
|
|
|
// InkWell(
|
|
|
|
// onTap: () {
|
|
|
|
// setState(() {
|
|
|
|
// model.swichState = !model.swichState;
|
|
|
|
// });
|
|
|
|
// if (model.swichState) {
|
|
|
|
// //把没有预订和宴会的桌子筛选出来显示
|
|
|
|
|
|
|
|
// model.tablesOrReserveData.forEach((element) {
|
|
|
|
// if (element.tableList != null &&
|
|
|
|
// element.tableList.length > 0) {
|
|
|
|
// List<TableListReserve> tableList = [];
|
|
|
|
// element.tableList.forEach((element1) {
|
|
|
|
// if (element1.reserveList == null &&
|
|
|
|
// element1.banquetList == null) {
|
|
|
|
// //空桌子
|
|
|
|
// tableList.add(element1);
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
|
|
|
|
// model
|
|
|
|
// .tablesOrReserveDataShow[model
|
|
|
|
// .tablesOrReserveDataShow
|
|
|
|
// .indexWhere((elementShow) =>
|
|
|
|
// elementShow.id == element.id)]
|
|
|
|
// .tableList = tableList;
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// } else {
|
|
|
|
// model.tablesOrReserveDataShow =
|
|
|
|
// model.tablesOrReserveData.toList();
|
|
|
|
// }
|
|
|
|
|
|
|
|
// setState(() {});
|
|
|
|
// },
|
|
|
|
// child: Container(
|
|
|
|
// margin: EdgeInsets.only(
|
|
|
|
// top: ScreenUtil().setWidth(20),
|
|
|
|
// ),
|
|
|
|
// child: Row(
|
|
|
|
// children: [
|
|
|
|
// MyDivider(ScreenUtil().setWidth(15),
|
|
|
|
// ScreenUtil().setWidth(80),
|
|
|
|
// color: MyColours.color_F1F0F4),
|
|
|
|
// MyDivider(ScreenUtil().setWidth(2),
|
|
|
|
// ScreenUtil().setWidth(80),
|
|
|
|
// color: MyColours.color_9C9C9C),
|
|
|
|
// HEmptyView(30),
|
|
|
|
// Image.asset(
|
|
|
|
// model.swichState
|
|
|
|
// ? Utils.getImgPath('f_swich_on')
|
|
|
|
// : Utils.getImgPath('f_swich_off'),
|
|
|
|
// width: ScreenUtil().setWidth(90),
|
|
|
|
// // height: ScreenUtil().setWidth(82),
|
|
|
|
// ),
|
|
|
|
// HEmptyView(20),
|
|
|
|
// Text(
|
|
|
|
// '仅看\n空座',
|
|
|
|
// style: TextStyle(
|
|
|
|
// fontSize: ScreenUtil().setSp(28),
|
|
|
|
// color: MyColours.color_333333,
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// HEmptyView(40)
|
|
|
|
// ],
|
|
|
|
// )),
|
|
|
|
// )
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// Expanded(
|
|
|
|
// flex: 2,
|
|
|
|
// child: Container(
|
|
|
|
// constraints: BoxConstraints(
|
|
|
|
// minHeight: ScreenUtil().setWidth(100)),
|
|
|
|
// color: Color.fromRGBO(249, 249, 249, 1),
|
|
|
|
// child: item(_selectNumber))),
|
|
|
|
// Container(
|
|
|
|
// width: double.infinity,
|
|
|
|
// height: ScreenUtil().setHeight(84),
|
|
|
|
// margin: EdgeInsets.only(
|
|
|
|
// bottom: ScreenUtil().setWidth(50)),
|
|
|
|
// padding: EdgeInsets.symmetric(
|
|
|
|
// horizontal: ScreenUtil().setWidth(31)),
|
|
|
|
// alignment: Alignment.center,
|
|
|
|
// color: MyColours.color_ffffff,
|
|
|
|
// child: CommonButton(
|
|
|
|
// // content: widget.fromPage == 'tablePhoto'
|
|
|
|
// // ? '确定'
|
|
|
|
// // : "已选${selectNum}个 确定",
|
|
|
|
// content: '确定',
|
|
|
|
// width: 300,
|
|
|
|
// height: 84,
|
|
|
|
// fontSize: 34,
|
|
|
|
// state: 1,
|
|
|
|
// onPress: () {
|
|
|
|
// if (widget.fromPage == "tablePhoto") {
|
|
|
|
// Map temp = {
|
|
|
|
// 'tid': tableManagerModel
|
|
|
|
// .selectTablesOrReserve.length >
|
|
|
|
// 0
|
|
|
|
// ? tableManagerModel
|
|
|
|
// .selectTablesOrReserve[0].id
|
|
|
|
// : '',
|
|
|
|
// 'tname': tableManagerModel
|
|
|
|
// .selectTablesOrReserve.length >
|
|
|
|
// 0
|
|
|
|
// ? tableManagerModel
|
|
|
|
// .selectTablesOrReserve[0].name
|
|
|
|
// : ''
|
|
|
|
// };
|
|
|
|
// Navigator.of(context).pop(temp);
|
|
|
|
// } else {
|
|
|
|
// if (widget.canChoose) {
|
|
|
|
// // if (widget.tableList.length > 0) {
|
|
|
|
// String tid = "";
|
|
|
|
// for (TableList table in widget.tableList) {
|
|
|
|
// tid += table.id + ",";
|
|
|
|
// }
|
|
|
|
// if (widget.tableList.length > 0) {
|
|
|
|
// tid = tid.substring(0, tid.length - 1);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// Map temp = {
|
|
|
|
// 'object': widget.tableList,
|
|
|
|
// 'tid': tid
|
|
|
|
// };
|
|
|
|
// Navigator.of(context).pop(temp);
|
|
|
|
// // }
|
|
|
|
// } else {
|
|
|
|
// if (tableManagerModel
|
|
|
|
// .selectTablesOrReserve.length >
|
|
|
|
// 0) {
|
|
|
|
// String tid = "";
|
|
|
|
// for (TableListReserve table
|
|
|
|
// in tableManagerModel
|
|
|
|
// .selectTablesOrReserve) {
|
|
|
|
// tid += table.id + ",";
|
|
|
|
// }
|
|
|
|
// if (tableManagerModel
|
|
|
|
// .selectTablesOrReserve.length >
|
|
|
|
// 0) {
|
|
|
|
// tid = tid.substring(0, tid.length - 1);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// Map temp = {
|
|
|
|
// 'object': widget.tableList,
|
|
|
|
// 'tid': tid
|
|
|
|
// };
|
|
|
|
// Navigator.of(context).pop(temp);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// },
|
|
|
|
// )),
|
|
|
|
// ]);
|
|
|
|
// }
|
|
|
|
// }),
|
|
|
|
// ),
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
// ));
|
|
|
|
// }
|
|
|
|
|
|
|
|
// tableToTableList(TableListReserve table) {
|
|
|
|
// TableList _tableList = TableList(
|
|
|
|
// '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '');
|
|
|
|
// _tableList.id = table.id;
|
|
|
|
// _tableList.rid = table.rid;
|
|
|
|
// _tableList.tid = table.tid;
|
|
|
|
// _tableList.name = table.name;
|
|
|
|
// _tableList.tablePnum = table.tablePnum;
|
|
|
|
// _tableList.sellerid = null;
|
|
|
|
// _tableList.qrcode = null;
|
|
|
|
// _tableList.mostPnum = table.mostPnum;
|
|
|
|
// _tableList.hot = null;
|
|
|
|
// _tableList.orderO = table.orderO;
|
|
|
|
// _tableList.status = table.status;
|
|
|
|
// _tableList.enable = table.enable;
|
|
|
|
// _tableList.spell = table.spell;
|
|
|
|
// _tableList.cdate = null;
|
|
|
|
// _tableList.rname = table.reserver;
|
|
|
|
// _tableList.regionName = table.reserver;
|
|
|
|
// _tableList.selected = true;
|
|
|
|
// return _tableList;
|
|
|
|
// }
|
|
|
|
// } |
|
|
|
import 'dart:ffi';
|
|
|
|
|
|
|
|
import 'package:common_utils/common_utils.dart';
|
|
|
|
import 'package:dotted_border/dotted_border.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:one_key/constant/state.dart';
|
|
|
|
import 'package:one_key/models/area.dart';
|
|
|
|
import 'package:one_key/models/notebook.dart';
|
|
|
|
import 'package:one_key/models/tableOuter.dart';
|
|
|
|
import 'package:one_key/models/table_list.dart';
|
|
|
|
import 'package:one_key/pages/table/area_item_table.dart';
|
|
|
|
import 'package:one_key/pages/table/area_item_table_or_reserve.dart';
|
|
|
|
import 'package:one_key/provider/choose_table_model.dart';
|
|
|
|
import 'package:one_key/provider/notebook_detail_change_model.dart';
|
|
|
|
import 'package:one_key/provider/notebook_model.dart';
|
|
|
|
import 'package:one_key/provider/user_model.dart';
|
|
|
|
import 'package:one_key/res/colors.dart';
|
|
|
|
import 'package:one_key/utils/dialog_util.dart';
|
|
|
|
import 'package:one_key/utils/utils.dart';
|
|
|
|
import 'package:one_key/widgets/MyDivider.dart';
|
|
|
|
import 'package:one_key/widgets/app_bar.dart';
|
|
|
|
import 'package:one_key/widgets/area_item.dart';
|
|
|
|
import 'package:one_key/widgets/common_button.dart';
|
|
|
|
import 'package:one_key/widgets/f_table_item.dart';
|
|
|
|
import 'package:one_key/widgets/h_empty_view.dart';
|
|
|
|
import 'package:one_key/widgets/page_exception.dart';
|
|
|
|
import 'package:one_key/widgets/table_item.dart';
|
|
|
|
|
|
|
|
import 'package:one_key/widgets/v_empty_view.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'dart:convert' as convert;
|
|
|
|
|
|
|
|
import '../../models/get_board_model.dart';
|
|
|
|
import '../../models/table_or_reserve_model.dart';
|
|
|
|
import '../../models/table_or_reserve_model.dart';
|
|
|
|
import '../../models/table_or_reserve_model.dart';
|
|
|
|
import '../../models/table_or_reserve_model.dart';
|
|
|
|
import '../../provider/table_manage_model_or_reserve.dart';
|
|
|
|
import '../table/table_item_or_reserve.dart';
|
|
|
|
|
|
|
|
class SelectTableFPageOrReserve extends StatefulWidget {
|
|
|
|
final String rid; //预订id
|
|
|
|
final DateTime dateTime; //日期
|
|
|
|
final String ddate_slot; //时段
|
|
|
|
final bool canChoose; //变更预订可以取消原来已预订的选中状态
|
|
|
|
final List<TableListReserve> tableList;
|
|
|
|
final String fromPage;
|
|
|
|
final String tid;
|
|
|
|
final String hmS;
|
|
|
|
final String hmE;
|
|
|
|
final String source;
|
|
|
|
final String ridFeast; //宴会id
|
|
|
|
SelectTableFPageOrReserve(this.rid, this.dateTime, this.ddate_slot,
|
|
|
|
{this.canChoose = false,
|
|
|
|
this.tableList,
|
|
|
|
this.fromPage,
|
|
|
|
this.tid,
|
|
|
|
this.hmS,
|
|
|
|
this.hmE,
|
|
|
|
this.source = '0',
|
|
|
|
this.ridFeast});
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() {
|
|
|
|
// TODO: implement createState
|
|
|
|
return new SelectTableFPageOrReserveState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class SelectTableFPageOrReserveState extends State<SelectTableFPageOrReserve> {
|
|
|
|
// List<Area> areas = []; //区域列表
|
|
|
|
// List<t.Table> selectTables = []; //选择的桌位
|
|
|
|
|
|
|
|
// List<TableOuter> tableOuterList = []; //区域-桌位列表
|
|
|
|
|
|
|
|
// Map<String, List<t.Table>> areaTableMap = {}; //区域-桌位Map
|
|
|
|
|
|
|
|
ChooseTableModel _chooseTableModel;
|
|
|
|
|
|
|
|
// Map<String, Notebook> tableMap = {}; //记录已预订桌位对应的订单
|
|
|
|
|
|
|
|
// String currentArea; //当前选中区域
|
|
|
|
List<String> personNumList = [];
|
|
|
|
|
|
|
|
int selectNum = 0;
|
|
|
|
// bool isSelected = true; //全部按钮
|
|
|
|
int _selectNumber = 0;
|
|
|
|
// Map dailyMap = {}; // 早市对应半点钟,午市对应半点钟、晚市对应半点钟
|
|
|
|
List<Notebook> noteBooks;
|
|
|
|
|
|
|
|
TableManagerModelOrReserve tableManagerModel;
|
|
|
|
bool swichState = false; //仅看空座
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
// TODO: implement initState
|
|
|
|
super.initState();
|
|
|
|
for (int i = 1; i < 31; i++) {
|
|
|
|
personNumList.add(i.toString());
|
|
|
|
}
|
|
|
|
// initDateHourMinuteList(context);
|
|
|
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
// getTableList();
|
|
|
|
_getTableListOrReserve();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
///
|
|
|
|
_getTableListOrReserve() async {
|
|
|
|
await tableManagerModel.getTableListOrReserve(
|
|
|
|
context, int.parse(widget.ddate_slot), widget.dateTime, _selectNumber);
|
|
|
|
tableManagerModel.tablesOrReserveDataShow.forEach((element) {
|
|
|
|
element.tableList.forEach((element) {
|
|
|
|
element.selected = false;
|
|
|
|
for (var table in widget.tableList) {
|
|
|
|
if (element.id == table.id) {
|
|
|
|
element.selected = true;
|
|
|
|
selectNum++;
|
|
|
|
tableManagerModel.selectTablesOrReserve.add(element);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
tableManagerModel.notifyListeners();
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget item(int i) {
|
|
|
|
return GridView.builder(
|
|
|
|
// controller: _areaController,
|
|
|
|
// physics: NeverScrollableScrollPhysics(),
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
vertical: ScreenUtil().setWidth(20),
|
|
|
|
horizontal: ScreenUtil().setWidth(10)),
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
|
|
|
itemCount:
|
|
|
|
tableManagerModel.tablesOrReserveDataShow[i].tableList.length == 0
|
|
|
|
? 1
|
|
|
|
: tableManagerModel.tablesOrReserveDataShow[i].tableList.length +
|
|
|
|
1,
|
|
|
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
crossAxisCount: 4,
|
|
|
|
childAspectRatio: 1,
|
|
|
|
mainAxisSpacing: ScreenUtil().setWidth(30),
|
|
|
|
crossAxisSpacing: ScreenUtil().setWidth(12),
|
|
|
|
),
|
|
|
|
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
if (index ==
|
|
|
|
tableManagerModel.tablesOrReserveDataShow[i].tableList.length ||
|
|
|
|
tableManagerModel.tablesOrReserveDataShow[i].tableList.length ==
|
|
|
|
0) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: () async {
|
|
|
|
List<String> areasTemp = [];
|
|
|
|
|
|
|
|
for (int i = 0;
|
|
|
|
i < tableManagerModel.tablesOrReserveDataShow.length;
|
|
|
|
i++) {
|
|
|
|
areasTemp
|
|
|
|
.add(tableManagerModel.tablesOrReserveDataShow[i].name);
|
|
|
|
}
|
|
|
|
|
|
|
|
//添加桌位弹框
|
|
|
|
await DialogUtil.openCreateTableDialog(
|
|
|
|
context, areasTemp, i, personNumList,
|
|
|
|
onTap: (Map<String, String> value) async {
|
|
|
|
print(value);
|
|
|
|
// 'areaname':
|
|
|
|
// areas[currentAreaIndex],
|
|
|
|
// 'name': controller.text,
|
|
|
|
// 'pnumMin': pnumMin,
|
|
|
|
// 'pnumMax': pnumMax
|
|
|
|
//添加桌位 接口参数带整合???
|
|
|
|
// 以下是旧的不去,明天添加桌位接口
|
|
|
|
String rid;
|
|
|
|
for (TableListReseveSunModel item
|
|
|
|
in tableManagerModel.tablesOrReserveDataShow) {
|
|
|
|
if (item.name == value['areaname']) {
|
|
|
|
rid = item.id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Map<String, String> params = {
|
|
|
|
'rid': rid,
|
|
|
|
'name': value['name'],
|
|
|
|
};
|
|
|
|
if (value['pnumMin'] != '') {
|
|
|
|
params['pnum'] = value['pnumMin'];
|
|
|
|
}
|
|
|
|
if (value['pnumMax'] != '') {
|
|
|
|
params['most_pnum'] = value['pnumMax'];
|
|
|
|
}
|
|
|
|
bool success =
|
|
|
|
await _chooseTableModel.addTable(context, params);
|
|
|
|
print(success);
|
|
|
|
if (success) {
|
|
|
|
Utils.showToast('添加成功!');
|
|
|
|
|
|
|
|
_getTableListOrReserve();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
child: DottedBorder(
|
|
|
|
dashPattern: [5, 5, 5, 5],
|
|
|
|
borderType: BorderType.RRect,
|
|
|
|
radius: Radius.circular(ScreenUtil().setWidth(20)),
|
|
|
|
// padding: EdgeInsets.all(ScreenUtil().setWidth(70)),
|
|
|
|
color: MyColours.color_E0E0E0,
|
|
|
|
strokeWidth: ScreenUtil().setWidth(2),
|
|
|
|
child: ClipRRect(
|
|
|
|
borderRadius: BorderRadius.all(
|
|
|
|
Radius.circular(ScreenUtil().setWidth(20))),
|
|
|
|
child: Container(
|
|
|
|
height: ScreenUtil().screenWidth -
|
|
|
|
ScreenUtil().setWidth(12 * 3 - 10 * 2),
|
|
|
|
width: ScreenUtil().screenWidth -
|
|
|
|
ScreenUtil().setWidth(12 * 3 - 10 * 2),
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Image.asset(Utils.getImgPath('add_store'),
|
|
|
|
width: ScreenUtil().setWidth(32)),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)));
|
|
|
|
} else {
|
|
|
|
TableListReserve data =
|
|
|
|
tableManagerModel.tablesOrReserveDataShow[i].tableList[index];
|
|
|
|
return Selector<TableManagerModelOrReserve, TableListReserve>(
|
|
|
|
shouldRebuild: (pre, next) => true,
|
|
|
|
selector: (context, model) => data,
|
|
|
|
builder: (context, table, _) {
|
|
|
|
return TableItemOrReserve(table,
|
|
|
|
canSelected: true,
|
|
|
|
selectTables: tableManagerModel.selectTablesOrReserve,
|
|
|
|
onSelected: (tableListReserve) {
|
|
|
|
if (widget.fromPage == 'tablePhoto') {
|
|
|
|
for (TableListReseveSunModel item
|
|
|
|
in tableManagerModel.tablesOrReserveDataShow) {
|
|
|
|
for (TableListReserve element in item.tableList) {
|
|
|
|
element.selected = false;
|
|
|
|
selectNum = 0;
|
|
|
|
if (table.id == item.id) {
|
|
|
|
element.selected = true;
|
|
|
|
tableManagerModel.selectTablesOrReserve = [];
|
|
|
|
selectNum++;
|
|
|
|
tableManagerModel.selectTablesOrReserve.add(table);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
} else {
|
|
|
|
if ((table as TableListReserve).selected) {
|
|
|
|
tableManagerModel.selectTablesOrReserve.add(table);
|
|
|
|
selectNum++;
|
|
|
|
widget.tableList.add(table);
|
|
|
|
} else {
|
|
|
|
widget.tableList.removeWhere((t) => t.id == table.id);
|
|
|
|
selectNum--;
|
|
|
|
tableManagerModel.selectTablesOrReserve
|
|
|
|
.removeWhere((t) => t.id == table.id);
|
|
|
|
}
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
}, fromPage: widget.fromPage, rid: widget.rid);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
_chooseTableModel = Provider.of<ChooseTableModel>(context);
|
|
|
|
tableManagerModel =
|
|
|
|
Provider.of<TableManagerModelOrReserve>(context, listen: true);
|
|
|
|
return Scaffold(
|
|
|
|
body: SafeArea(
|
|
|
|
child: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
MyAppBar(
|
|
|
|
"选择桌位",
|
|
|
|
showBack: true,
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Consumer<TableManagerModelOrReserve>(
|
|
|
|
builder: (context, model, child) {
|
|
|
|
if (model.pageStateOrReserve != PageState.Success) {
|
|
|
|
Expanded(
|
|
|
|
child: ExceptionPage(
|
|
|
|
pageState: model.pageStateOrReserve,
|
|
|
|
callback: () {
|
|
|
|
tableManagerModel.getTableListOrReserve(context,
|
|
|
|
int.parse(widget.ddate_slot), widget.dateTime, _selectNumber,
|
|
|
|
showLoading: true);
|
|
|
|
},
|
|
|
|
emptyMsg: "暂时没有桌位哦",
|
|
|
|
emptyImg: "empty_search",
|
|
|
|
showMsg: "加载中,请稍后...",
|
|
|
|
));
|
|
|
|
} else {
|
|
|
|
return Column(
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
height: ScreenUtil().setWidth(92),
|
|
|
|
margin:
|
|
|
|
EdgeInsets.only(bottom: ScreenUtil().setWidth(30)),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
HEmptyView(20),
|
|
|
|
Expanded(
|
|
|
|
child: ListView.builder(
|
|
|
|
itemCount: tableManagerModel
|
|
|
|
.tablesOrReserveDataShow
|
|
|
|
.length ==
|
|
|
|
0
|
|
|
|
? 1
|
|
|
|
: tableManagerModel
|
|
|
|
.tablesOrReserveDataShow
|
|
|
|
.length +
|
|
|
|
1,
|
|
|
|
shrinkWrap: true,
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
itemBuilder:
|
|
|
|
(BuildContext contxt, int index) {
|
|
|
|
if (index ==
|
|
|
|
tableManagerModel
|
|
|
|
.tablesOrReserveDataShow
|
|
|
|
.length ||
|
|
|
|
tableManagerModel
|
|
|
|
.tablesOrReserveDataShow
|
|
|
|
.length ==
|
|
|
|
0) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: () async {
|
|
|
|
//添加区域弹框
|
|
|
|
await DialogUtil
|
|
|
|
.openCreateAreaDialog(context,
|
|
|
|
onTap: (value) async {
|
|
|
|
print(value);
|
|
|
|
//添加区域
|
|
|
|
bool success =
|
|
|
|
await _chooseTableModel
|
|
|
|
.addTableAreas(
|
|
|
|
context, value);
|
|
|
|
print(success);
|
|
|
|
if (success) {
|
|
|
|
Utils.showToast('添加成功!');
|
|
|
|
tableManagerModel
|
|
|
|
.getTableListOrReserve(
|
|
|
|
context,
|
|
|
|
int.parse(
|
|
|
|
widget.ddate_slot),
|
|
|
|
widget.dateTime,
|
|
|
|
_selectNumber,
|
|
|
|
showLoading: true);
|
|
|
|
// UserModel userModel =
|
|
|
|
// Provider.of<UserModel>(context,
|
|
|
|
// listen: false);
|
|
|
|
// Map<String, String> params = {
|
|
|
|
// "sellerid": userModel.user.sellerid
|
|
|
|
// };
|
|
|
|
// await _chooseTableModel.getTableList(
|
|
|
|
// context, params,
|
|
|
|
// needLoading: false);
|
|
|
|
// initData();
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
VEmptyView(20),
|
|
|
|
DottedBorder(
|
|
|
|
dashPattern: [5, 5, 5, 5],
|
|
|
|
borderType: BorderType.RRect,
|
|
|
|
radius: Radius.circular(
|
|
|
|
ScreenUtil().setWidth(10)),
|
|
|
|
// padding: EdgeInsets.all(ScreenUtil().setWidth(70)),
|
|
|
|
color: MyColours.color_199095,
|
|
|
|
strokeWidth:
|
|
|
|
ScreenUtil().setWidth(2),
|
|
|
|
child: ClipRRect(
|
|
|
|
borderRadius: BorderRadius
|
|
|
|
.all(Radius.circular(
|
|
|
|
ScreenUtil()
|
|
|
|
.setWidth(10))),
|
|
|
|
child: Container(
|
|
|
|
height: ScreenUtil()
|
|
|
|
.setWidth(25 * 2),
|
|
|
|
width: ScreenUtil()
|
|
|
|
.setWidth(104 * 2),
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment:
|
|
|
|
MainAxisAlignment
|
|
|
|
.center,
|
|
|
|
children: [
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath(
|
|
|
|
'add_area'),
|
|
|
|
width: ScreenUtil()
|
|
|
|
.setWidth(24)),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return AreaItemTableOrReserve(
|
|
|
|
tableManagerModel
|
|
|
|
.tablesOrReserveDataShow[index],
|
|
|
|
(area) {
|
|
|
|
tableManagerModel
|
|
|
|
.tablesOrReserveDataShow
|
|
|
|
.forEach((element) {
|
|
|
|
element.select = false;
|
|
|
|
});
|
|
|
|
setState(() {
|
|
|
|
// isSelected = false;
|
|
|
|
area.select = true;
|
|
|
|
_selectNumber = index;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
})),
|
|
|
|
InkWell(
|
|
|
|
onTap: () {
|
|
|
|
setState(() {
|
|
|
|
swichState = !swichState;
|
|
|
|
});
|
|
|
|
if (swichState) {
|
|
|
|
//把没有预订和宴会的桌子筛选出来显示
|
|
|
|
|
|
|
|
model.tablesOrReserveData.forEach((element) {
|
|
|
|
if (element.tableList != null &&
|
|
|
|
element.tableList.length > 0) {
|
|
|
|
List<TableListReserve> tableList = [];
|
|
|
|
element.tableList.forEach((element1) {
|
|
|
|
if (element1.reserveList ==
|
|
|
|
null &&
|
|
|
|
(element1.banquetList ==
|
|
|
|
null ||
|
|
|
|
element1.banquetList
|
|
|
|
.length ==
|
|
|
|
0)) {
|
|
|
|
//空桌子
|
|
|
|
tableList.add(element1);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
model
|
|
|
|
.tablesOrReserveDataShow[model
|
|
|
|
.tablesOrReserveDataShow
|
|
|
|
.indexWhere((elementShow) =>
|
|
|
|
elementShow.id == element.id)]
|
|
|
|
.tableList = tableList;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
// model.tablesOrReserveDataShow =
|
|
|
|
// model.tablesOrReserveData.toList();
|
|
|
|
tableManagerModel.getTableListOrReserve(
|
|
|
|
context,
|
|
|
|
int.parse(widget.ddate_slot),
|
|
|
|
widget.dateTime,
|
|
|
|
_selectNumber,
|
|
|
|
showLoading: true);
|
|
|
|
}
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
margin: EdgeInsets.only(
|
|
|
|
top: ScreenUtil().setWidth(20),
|
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
MyDivider(ScreenUtil().setWidth(15),
|
|
|
|
ScreenUtil().setWidth(80),
|
|
|
|
color: MyColours.color_F1F0F4),
|
|
|
|
MyDivider(ScreenUtil().setWidth(2),
|
|
|
|
ScreenUtil().setWidth(80),
|
|
|
|
color: MyColours.color_9C9C9C),
|
|
|
|
HEmptyView(30),
|
|
|
|
Image.asset(
|
|
|
|
swichState
|
|
|
|
? Utils.getImgPath('f_swich_on')
|
|
|
|
: Utils.getImgPath('f_swich_off'),
|
|
|
|
width: ScreenUtil().setWidth(90),
|
|
|
|
// height: ScreenUtil().setWidth(82),
|
|
|
|
),
|
|
|
|
HEmptyView(20),
|
|
|
|
Text(
|
|
|
|
'仅看\n空座',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setSp(28),
|
|
|
|
color: MyColours.color_333333,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
HEmptyView(40)
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
flex: 2,
|
|
|
|
child: Container(
|
|
|
|
constraints: BoxConstraints(
|
|
|
|
minHeight: ScreenUtil().setWidth(100)),
|
|
|
|
color: Color.fromRGBO(249, 249, 249, 1),
|
|
|
|
child: item(_selectNumber))),
|
|
|
|
Container(
|
|
|
|
width: double.infinity,
|
|
|
|
height: ScreenUtil().setHeight(84),
|
|
|
|
margin: EdgeInsets.only(
|
|
|
|
bottom: ScreenUtil().setWidth(50)),
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: ScreenUtil().setWidth(31)),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
child: CommonButton(
|
|
|
|
// content: widget.fromPage == 'tablePhoto'
|
|
|
|
// ? '确定'
|
|
|
|
// : "已选${selectNum}个 确定",
|
|
|
|
content: '确定',
|
|
|
|
width: 300,
|
|
|
|
height: 84,
|
|
|
|
fontSize: 34,
|
|
|
|
state: 1,
|
|
|
|
onPress: () {
|
|
|
|
if (widget.fromPage == "tablePhoto") {
|
|
|
|
Map temp = {
|
|
|
|
'tid': tableManagerModel
|
|
|
|
.selectTablesOrReserve.length >
|
|
|
|
0
|
|
|
|
? tableManagerModel
|
|
|
|
.selectTablesOrReserve[0].id
|
|
|
|
: '',
|
|
|
|
'tname': tableManagerModel
|
|
|
|
.selectTablesOrReserve.length >
|
|
|
|
0
|
|
|
|
? tableManagerModel
|
|
|
|
.selectTablesOrReserve[0].name
|
|
|
|
: ''
|
|
|
|
};
|
|
|
|
Navigator.of(context).pop(temp);
|
|
|
|
} else {
|
|
|
|
if (widget.canChoose) {
|
|
|
|
// if (widget.tableList.length > 0) {
|
|
|
|
String tid = "";
|
|
|
|
for (TableListReserve table
|
|
|
|
in widget.tableList) {
|
|
|
|
tid += table.id + ",";
|
|
|
|
}
|
|
|
|
if (widget.tableList.length > 0) {
|
|
|
|
tid = tid.substring(0, tid.length - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
Map temp = {
|
|
|
|
'object': widget.tableList,
|
|
|
|
'tid': tid
|
|
|
|
};
|
|
|
|
Navigator.of(context).pop(temp);
|
|
|
|
// }
|
|
|
|
} else {
|
|
|
|
if (tableManagerModel
|
|
|
|
.selectTablesOrReserve.length >
|
|
|
|
0) {
|
|
|
|
String tid = "";
|
|
|
|
for (TableListReserve table
|
|
|
|
in tableManagerModel
|
|
|
|
.selectTablesOrReserve) {
|
|
|
|
tid += table.id + ",";
|
|
|
|
}
|
|
|
|
if (tableManagerModel
|
|
|
|
.selectTablesOrReserve.length >
|
|
|
|
0) {
|
|
|
|
tid = tid.substring(0, tid.length - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
Map temp = {
|
|
|
|
'object': widget.tableList,
|
|
|
|
'tid': tid
|
|
|
|
};
|
|
|
|
Navigator.of(context).pop(temp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
)),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
// tableToTableList(TableListReserve table) {
|
|
|
|
// TableList _tableList = TableList(
|
|
|
|
// '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '');
|
|
|
|
// _tableList.id = table.id;
|
|
|
|
// _tableList.rid = table.rid;
|
|
|
|
// _tableList.tid = table.tid;
|
|
|
|
// _tableList.name = table.name;
|
|
|
|
// _tableList.tablePnum = table.tablePnum;
|
|
|
|
// _tableList.sellerid = null;
|
|
|
|
// _tableList.qrcode = null;
|
|
|
|
// _tableList.mostPnum = table.mostPnum;
|
|
|
|
// _tableList.hot = null;
|
|
|
|
// _tableList.orderO = table.orderO;
|
|
|
|
// _tableList.status = table.status;
|
|
|
|
// _tableList.enable = table.enable;
|
|
|
|
// _tableList.spell = table.spell;
|
|
|
|
// _tableList.cdate = null;
|
|
|
|
// _tableList.rname = table.reserver;
|
|
|
|
// _tableList.regionName = table.reserver;
|
|
|
|
// _tableList.selected = true;
|
|
|
|
// return _tableList;
|
|
|
|
// }
|
|
|
|
} |
...
|
...
|
|