Commit ae4fe892be0676df322e92332e4b07e5f983fccd

Authored by wdn127929
1 parent c7ed10bc

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

... ... @@ -29,6 +29,9 @@ class Table {
String pnum; //预计人数
String nickName; //操作人
String noteName; //操作人
String isLock; //是否被合并上锁
String isMerge; //是否打开桌位合并开关
String tids; //被合并桌位tids
//获取桌位类型
String get tidStr {
... ... @@ -104,6 +107,6 @@ class Table {
@override
String toString() {
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}';
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}';
}
}
... ...
... ... @@ -27,7 +27,10 @@ Table _$TableFromJson(Map<String, dynamic> json) {
..sign = json['sign'] as String
..reserver = json['reserver'] as String
..notebookId = json['notebookId'] as String
..selected = json['selected'] as bool;
..selected = json['selected'] as bool
..isLock = json['is_lock'] as String
..isMerge = json['is_merge'] as String
..tids = json['tids'] as String;
}
Map<String, dynamic> _$TableToJson(Table instance) => <String, dynamic>{
... ... @@ -50,5 +53,8 @@ Map<String, dynamic> _$TableToJson(Table instance) => <String, dynamic>{
'sign': instance.sign,
'reserver': instance.reserver,
'notebookId': instance.notebookId,
'selected': instance.selected
'selected': instance.selected,
'is_lock': instance.isLock,
'is_merge': instance.isMerge,
'tids': instance.tids
};
... ...
... ... @@ -9,6 +9,10 @@ class TableOuter {
bool isAll = false; //全选
List<t.Table> selectTables = []; //选择的桌位
// bool get isAll {
// return list.every((element) => element.selected);
// }
TableOuter();
factory TableOuter.fromJson(Map<String, dynamic> json) => TableOuter()
... ...
... ... @@ -334,4 +334,8 @@ class HttpUrl {
static const String set_cookbook_by_id =
"?service=App.Cookbook.SetCookbookById"; //修改菜品
static const String merge_tables =
"?service=App.Tables.MergeTables"; // 合并桌位
}
... ...
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/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/route/navigator_util.dart';
import 'package:one_key/utils/dialog_util.dart';
import 'package:one_key/utils/event_bus.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/merge_table_item.dart';
import 'package:one_key/widgets/page_exception.dart';
import 'package:one_key/widgets/round_button.dart';
import 'package:one_key/widgets/system_app_bar.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 '../../../utils/screen_util.dart';
class MergeTableSelectPage 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 tableid;
MergeTableSelectPage(
{this.canChoose = false,
this.tableList,
this.fromPage,
this.tid,
this.tableid});
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return new MergeTableSelectPageState();
}
}
class MergeTableSelectPageState extends State<MergeTableSelectPage> {
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 = {}; // 早市对应半点钟,午市对应半点钟、晚市对应半点钟
String selectTableId;
@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();
});
bus.on("refresh_photo_manager", (args) {
getTableList();
});
}
@override
void dispose() {
super.dispose();
bus.off("refresh_photo_manager");
}
/// 早市、午市、晚市对应的半个小时间隔时间段
// 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]);
// 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 = [];
tableOuterList.forEach((element) {
element.list.removeWhere((value) => value.id == widget.tableid);
});
print(tableOuterList);
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(tableListToTable(table));
// if (!tableList.contains(item)) {
// tableList.add(item);
// }
}
}
}
//如果当前的桌子全部选中,则全选按钮---选中状态
item.isAll = item.list.every((element) => element.selected);
// selectAreaAll[]
print(selectTables);
_chooseTableModel.tablesAll.addAll(item.list);
}
if (tableOuterList.isEmpty) {
_chooseTableModel.pageState = PageState.Success;
_chooseTableModel.notifyListeners();
} else {
initData();
// _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();
// }
}
//获取已预订列表
// _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"
// };
// List<Notebook> noteBooks =
// await model.getReserveList(context, params, needLoading: needLoading);
// for (Notebook notebook in noteBooks) {
// if (notebook.tid.isEmpty) continue;
// if (notebook.status == "1" ||
// notebook.status == "2" ||
// notebook.status == "5") {
// //已预订,用餐中,已安排
// List<String> tids = notebook.tid.split(",");
// for (String tid in tids) {
// tableMap["$tid"] = notebook;
// }
// }
// }
// 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.id == selectTableId) {
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;
// //(不能移除自己定的桌子)
// 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;
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;
// }
if (areaTableMap.isNotEmpty) {
// if (!needRetain) {
// currentArea = '全部';
// _chooseTableModel.currentTables = _chooseTableModel.tablesAll;
// } else {
if (currentArea != null && currentArea != '') {
// tablesShow = areaTableMapShow[currentArea];
List keys = areaTableMap.keys.toList();
_selectNumber = keys.indexOf(currentArea);
} else {
currentArea = areas[0].name;
List keys = areaTableMap.keys.toList();
_selectNumber = keys.indexOf(currentArea);
}
// }
} else {
// if (currentArea != null && currentArea != '') {
// tablesShow = areaTableMap[currentArea];
// _selectNumber = areaTableMap.length;
// }
// pageState = PageState.Empty;
// pageState = PageState.Success;
}
// if (widget.tid == '') {
// if (!needRetain) {
// // currentArea = areaTableMap.keys.first;
// currentArea = '全部';
// _chooseTableModel.currentTables = _chooseTableModel.tablesAll;
// } else {
// if (currentArea != null && currentArea != '') {
// // tablesShow = areaTableMapShow[currentArea];
// List keys = areaTableMap.keys.toList();
// _selectNumber = keys.indexOf(currentArea);
// }
// }
// if (areas.length == 1) {
// currentArea = areaTableMap.keys.first;
// }
// } else {
// // if (currentArea != null && currentArea != '') {
// // tablesShow = areaTableMapShow[currentArea];
// // selectNumber = areaTableMapShow.length;
// // }
// // // pageState = PageState.Empty;
// // pageState = PageState.Success;
// }
_chooseTableModel.pageState = PageState.Success;
_chooseTableModel.notifyListeners();
}
//获取一天开始-结束时间字符串
// String _getRdate() {
// 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);
// String timeStrStart = '';
// String timeStrEnd = '';
// //一天开始时间
// double startDay;
// //一天结束时间
// double endDay;
// if (keys != '') {
// List temp = dailyMap[keys];
// timeStrStart = ymd + ' ' + temp.first + ':00';
// timeStrEnd = ymd + ' ' + temp.last + ':00';
// } else {
// timeStrStart = widget.dateTime.year.toString() +
// "-" +
// Utils.addZeroNumber(widget.dateTime.month) +
// "-" +
// Utils.addZeroNumber(widget.dateTime.day) +
// " 00:00:00";
// timeStrEnd = widget.dateTime.year.toString() +
// "-" +
// Utils.addZeroNumber(widget.dateTime.month) +
// "-" +
// Utils.addZeroNumber(widget.dateTime.day) +
// " 23:59:59";
// }
// startDay = (DateTime.parse(timeStrStart).millisecondsSinceEpoch) / 1000;
// endDay = (DateTime.parse(timeStrEnd).millisecondsSinceEpoch) / 1000;
// return startDay.floor().toString() + "-" + endDay.floor().toString();
// }
Widget item(int i) {
return Column(
children: [
_chooseTableModel.areaTableMapShow[areas[i].name].length > 0
? InkWell(
onTap: () {
tableOuterList[i].isAll = !tableOuterList[i].isAll;
tableOuterList[i].list.forEach((element) {
element.selected = tableOuterList[i].isAll;
});
if (tableOuterList[i].isAll) {
//移除当前区域原来的选中的桌子
tableOuterList[i].list.forEach((value) {
selectTables
.removeWhere((element) => value.id == element.id);
});
//加入当前区域全部桌子
tableOuterList[i].list.forEach((value) {
selectTables.add(value);
});
//全选
// object.addAll(elements)
} else {
//取消全选
tableOuterList[i].list.forEach((value) {
selectTables
.removeWhere((element) => element.id == value.id);
});
// selectNum = selectNum-
}
// selectNum++;
// selectTables.add(table);
print(selectTables);
setState(() {});
},
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: w(24), vertical: w(16)),
child: Row(
children: [
Image.asset(
Utils.getImgPath(
tableOuterList[i].isAll ? 'select' : 'unselect'),
width: w(20),
),
HEmptyView(4),
Text(
'全选',
style: TextStyle(
fontSize: font(16),
color: MyColours.color_515151),
)
],
)))
: SizedBox(),
GridView.builder(
// controller: _areaController,
// physics: NeverScrollableScrollPhysics(),
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setWidth(20),
horizontal: ScreenUtil().setWidth(64)),
shrinkWrap: true,
itemCount: _chooseTableModel.tablesShow.length == 0 ||
(i != null &&
_chooseTableModel
.areaTableMapShow[areas[i].name].length ==
0)
? 0
: _chooseTableModel.areaTableMapShow[areas[i].name].length,
// itemCount: _chooseTableModel.tablesShow.length == 0 ||
// (i != null &&
// _chooseTableModel.areaTableMapShow[areas[i].name].length == 0)
// ? 0
// : currentArea == '全部'
// ? _chooseTableModel.tablesShow.length
// : _chooseTableModel.areaTableMapShow[areas[i].name].length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 4,
childAspectRatio: 1,
mainAxisSpacing: ScreenUtil().setWidth(28),
crossAxisSpacing: ScreenUtil().setWidth(48),
),
itemBuilder: (BuildContext context, int index) {
List<t.Table> data = _chooseTableModel.tablesShow.length == 0 ||
(i != null &&
_chooseTableModel
.areaTableMapShow[areas[i].name].length ==
0)
? 0
: _chooseTableModel.areaTableMapShow[areas[i].name];
// if (index == data.length || data.length == 0) {
// return InkWell(
// onTap: () async {
// List<String> areasTemp = [];
// for (int i = 0; i < areas.length; i++) {
// areasTemp.add(areas[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 (Area item in areas) {
// if (item.name == value['areaname']) {
// rid = item.rid;
// }
// }
// 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('添加成功!');
// // TableOuter tableOuter = TableOuter();
// // tableOuter.name = value;
// // tableOuter.list = [];
// // tableManagerModel.tableOuterList.add(tableOuter);
// // tableManagerModel.initData();
// // Timer(
// // Duration(milliseconds: 500),
// // () => _areaController.jumpTo(
// // _areaController.position.maxScrollExtent));
// // await tableManagerModel
// // .getTableList(context);
// // await tableManagerModel
// // .initData();
// refreshTable(context);
// }
// });
// },
// 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 {
return Selector<ChooseTableModel, t.Table>(
shouldRebuild: (pre, next) => true,
selector: (context, model) => data[index],
builder: (context, table, _) {
return MergeTableItem(data[index], canSelected: true,
onSelected: (t.Table table) {
print(areaTableMap.keys);
// for (String item in areaTableMap.keys) {
// for (t.Table tableItem in areaTableMap[item]) {
// tableItem.selected = false;
// selectNum = 0;
// if (table.id == tableItem.id) {
// selectTableId = table.id;
// selectTables = [];
// selectNum++;
if (table.selected) {
//选中
selectTables.add(table);
Map temp = {
'tid': selectTables.length > 0 ? selectTables[0].id : '',
'tname':
selectTables.length > 0 ? selectTables[0].name : ''
};
// print(selectNum);
print(selectTables);
//检测当前选中区域全选按钮状态更新
} else {
//取消选中
selectTables
.removeWhere((element) => table.id == element.id);
}
tableOuterList[i].isAll = tableOuterList[i]
.list
.every((element) => element.selected);
setState(() {});
// NavigatorUtil.goTableMergeTableSelectPage(context,
// tid: table.id, tname: table.name);
// setState(() {
// tableItem.selected = true;
// });
// }
// }
// }
}, fromPage: widget.fromPage, tableMap: tableMap, rid: null);
},
);
// }
},
)
],
);
}
@override
Widget build(BuildContext context) {
_chooseTableModel = Provider.of<ChooseTableModel>(context);
return Scaffold(
backgroundColor: MyColours.color_ffffff,
body: SafeArea(
child: Column(
children: <Widget>[
SystemAppBar(
"选择要合并的桌位",
onTap: () {
EventBus().emit('changeStatusColor');
Navigator.of(context).pop();
},
),
WillPopScope(
onWillPop: () {
EventBus().emit('changeStatusColor');
Navigator.of(context).pop();
},
child: Expanded(
child:
Consumer<ChooseTableModel>(builder: (context, model, _) {
if (model.pageState != PageState.Success) {
return ExceptionPage(
pageState: model.pageState,
callback: () {
getTableList();
},
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(48),
Expanded(
child: ListView.builder(
itemCount: areas.length,
shrinkWrap: true,
scrollDirection: Axis.horizontal,
itemBuilder:
(BuildContext contxt, int index) {
// if (index == areas.length + 1 ||
// areas.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('添加成功!');
// UserModel userModel =
// Provider.of<UserModel>(context,
// listen: false);
// Map<String, String> params = {
// "sellerid": userModel.user.sellerid
// };
// await _chooseTableModel.getTableList(
// context, params,
// needLoading: false);
// initData();
// // setState(() {
// // updateMenu();
// // });
// // _scrollToIndex(widget
// // .tableManagerModel
// // .areas
// // .length);
// }
// });
// },
// 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 {
// if (index == 0) {
// return InkWell(
// onTap: () {
// setState(() {
// isSelected = true;
// currentArea = '全部';
// _chooseTableModel
// .currentTables =
// _chooseTableModel
// .areaTableMapShow[
// currentArea];
// });
// },
// child: Container(
// // width: ScreenUtil().setWidth(104 * 2),
// height: ScreenUtil().setWidth(80),
// margin: EdgeInsets.only(
// right:
// ScreenUtil().setWidth(20),
// top: ScreenUtil().setWidth(20),
// ),
// padding: EdgeInsets.symmetric(
// horizontal:
// ScreenUtil().setWidth(20),
// vertical: ScreenUtil()
// .setWidth(10)),
// alignment: Alignment.center,
// decoration: BoxDecoration(
// // borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10)),
// color: isSelected
// ? MyColours.color_199095
// : MyColours.color_ffffff,
// border: Border.all(
// color: MyColours
// .color_E0E0E0,
// width: ScreenUtil()
// .setWidth(2))),
// child: Text(
// '全部',
// overflow: TextOverflow.ellipsis,
// style: TextStyle(
// color: isSelected
// ? MyColours.color_ffffff
// : MyColours
// .color_333333,
// fontSize:
// ScreenUtil().setSp(28),
// decoration:
// TextDecoration.none,
// fontWeight:
// FontWeight.normal),
// ),
// ),
// );
// } else {
return AreaItemTable(
areas[index],
currentArea,
(area) {
setState(() {
isSelected = false;
_selectNumber = index;
currentArea = areas[index].name;
_chooseTableModel.currentTables =
_chooseTableModel
.areaTableMapShow[
currentArea];
// _anmationMenu();
});
},
showBadge: false,
);
// }
// }
},
)),
],
),
),
Expanded(
// flex: 2,
child: Container(
constraints: BoxConstraints(
minHeight: ScreenUtil().setWidth(100)),
color: MyColours.color_ffffff,
child: item(_selectNumber))),
Container(
padding:
EdgeInsets.symmetric(horizontal: w(48)),
margin: EdgeInsets.only(bottom: w(40)),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
RoundButton(
// content: widget.fromPage == 'tablePhoto'
// ? '确定'
// : "已选${selectNum}个 确定",
text: '返回',
radius: r(4),
width: w(128),
height: w(36),
fontSize: 28,
isBold: false,
textColor: MyColours.color_515151,
gradientStart: MyColours.color_DBDBDB,
gradientEnd: MyColours.color_DBDBDB,
onPressed: () {
Navigator.pop(context);
},
),
RoundButton(
// content: widget.fromPage == 'tablePhoto'
// ? '确定'
// : "已选${selectNum}个 确定",
text: '保存',
width: w(128),
height: w(36),
radius: r(4),
isBold: false,
gradientStart: MyColours.color_438E93,
gradientEnd: MyColours.color_438E93,
fontSize: 28,
textColor: MyColours.color_ffffff,
onPressed: () {
// if (widget.fromPage == "tablePhoto") {
// Map temp = {
// 'tid': selectTables.length > 0
// ? selectTables[0].id
// : '',
// 'tname': selectTables.length > 0
// ? selectTables[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 (selectTables.length > 0) {
String tid = "";
for (t.Table table
in selectTables) {
tid += table.id + ",";
}
if (selectTables.length > 0) {
tid = tid.substring(
0, tid.length - 1);
}
Map temp = {
'object': selectTables,
'tid': tid
};
Navigator.of(context).pop(temp);
} else {
Navigator.of(context).pop();
}
}
// }
},
),
],
))
]);
}
}),
),
)
],
),
));
}
tableToTableList(t.Table table) {
TableList _tableList = TableList(
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '');
_tableList.id = table.id;
_tableList.rid = table.rid;
_tableList.tid = table.tid;
_tableList.name = table.name;
_tableList.tablePnum = table.table_pnum;
_tableList.sellerid = null;
_tableList.qrcode = null;
_tableList.mostPnum = table.most_pnum;
_tableList.hot = null;
_tableList.orderO = table.order_o;
_tableList.status = table.status;
_tableList.enable = table.enable;
_tableList.spell = table.spell;
_tableList.cdate = null;
_tableList.rname = table.rname;
_tableList.regionName = table.rname;
_tableList.selected = true;
return _tableList;
}
tableListToTable(TableList table) {
t.Table _table = t.Table();
_table.id = table.id;
_table.rid = table.rid;
_table.tid = table.tid;
_table.name = table.name;
_table.table_pnum = table.table_pnum;
// _table.sellerid = null;
// _table.qrcode = null;
_table.most_pnum = table.mostPnum;
// _table.hot = null;
_table.order_o = table.orderO;
_table.status = table.status;
_table.enable = table.enable;
_table.spell = table.spell;
// _table.cdate = null;
_table.rname = table.rname;
_table.rname = table.regionName;
_table.selected = true;
return _table;
}
}
... ...
... ... @@ -109,6 +109,78 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> {
// }
// }
///获取经理数据
Future<bool> _setTableById(value, table) async {
String tid;
for (int i = 0; i < tableManagerModel.tableTypeList.length; i++) {
if (value['bjtype'] == tableManagerModel.tableTypeList[i].name) {
tid = tableManagerModel.tableTypeList[i].id;
}
}
Map<String, String> params = {
'id': table.id,
'name': value['name'],
'tid': tid
};
if (value['pnumMin'] != '') {
params['table_pnum'] = value['pnumMin'];
}
if (value['pnumMax'] != '') {
params['most_pnum'] = value['pnumMax'];
}
bool success = await tableManagerModel.setTableById(context, params);
if (success) {
return true;
} else {
return false;
}
}
///
Future<bool> _mergeTables(value, table) async {
String isMerge = value['isMerge'];
String tids = value['tids'];
Map<String, String> params = {
'tid': table.id,
'is_merge': isMerge,
'tids': tids
};
bool success = await tableManagerModel.mergeTables(context, params);
if (success) {
return true;
} else {
return false;
}
}
_setData(value, table) async {
await Future.wait<bool>(
[_setTableById(value, table), _mergeTables(value, table)])
.then((results) async {
print(results[0]);
if (results[0] && results[1]) {
await tableManagerModel.refreshTable(context);
} else {
if (results[0]) {
//修改桌位信息成功
await tableManagerModel.refreshTable(context);
} else {
//修改桌位信息失败
}
if (results[1]) {
//合并桌位成功
} else {
//合并桌位失败
}
}
}).catchError((e) {
print(e);
});
}
Widget list(List data) => ScrollablePositionedList.builder(
itemCount: data.length,
itemBuilder: (context, index) => item(index),
... ... @@ -293,11 +365,11 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> {
tableManagerModel.tableOuterList[i].selectTables
.removeWhere((t) => t.id == table.id);
}
tableManagerModel
.tableOuterList[tableManagerModel.selectNumber]
.isAll =
tableManagerModel.tableOuterList[i].list
.every((element) => element.selected);
// tableManagerModel
// .tableOuterList[tableManagerModel.selectNumber]
// .isAll =
// tableManagerModel.tableOuterList[i].list
// .every((element) => element.selected);
} else {
// for (t.Table item
// in tableManagerModel.tableOuterList[i].list) {
... ... @@ -316,13 +388,30 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> {
i++) {
tableTypeS.add(tableManagerModel.tableTypeList[i].name);
}
List<t.Table> selectTables = [];
if (table.tids != null && table.tids.length > 0) {
List<String> tids = table.tids.split(',');
tableManagerModel.tableOuterList.forEach((element) {
element.list.forEach((table) {
tids.forEach((tid) {
if (tid == table.id) {
selectTables.add(table);
}
});
});
});
}
await DialogUtil.openMyTableManageModifyTableDialog(
context, tableTypeS, personNumList,
name: table.name,
tidStr: table.tidStr,
pnumMin: table.table_pnum ?? '',
pnumMax: table.most_pnum ?? '',
onTapDel: (Map<String, String> value) async {
isLock: table.isLock ?? '0',
isMerge: table.isMerge ?? '0',
tableid: table.id,
selectTables: selectTables,
onTapDel: (Map<String, dynamic> value) async {
Map<String, String> params = {
'sid': Provider.of<UserModel>(context, listen: false)
.user
... ... @@ -362,49 +451,30 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> {
// Map<String, String> params = {
// 'rid': rid,
// };
String tid;
for (int i = 0;
i < tableManagerModel.tableTypeList.length;
i++) {
if (value['bjtype'] ==
tableManagerModel.tableTypeList[i].name) {
tid = tableManagerModel.tableTypeList[i].id;
}
}
Map<String, String> params = {
'id': table.id,
'name': value['name'],
'tid': tid
};
_setData(value, table);
if (value['pnumMin'] != '') {
params['table_pnum'] = value['pnumMin'];
}
if (value['pnumMax'] != '') {
params['most_pnum'] = value['pnumMax'];
}
// if(isMerge == '1'){
// //
// }
bool success =
await tableManagerModel.setTableById(context, params);
print(success);
if (success) {
Utils.showToast('修改成功!');
// TableOuter tableOuter = TableOuter();
// tableOuter.name = value;
// tableOuter.list = [];
// tableManagerModel.tableOuterList.add(tableOuter);
// tableManagerModel.initData();
// Timer(
// Duration(milliseconds: 500),
// () => _areaController.jumpTo(
// _areaController.position.maxScrollExtent));
// if (success) {
// Utils.showToast('修改成功!');
// // TableOuter tableOuter = TableOuter();
// // tableOuter.name = value;
// // tableOuter.list = [];
// // tableManagerModel.tableOuterList.add(tableOuter);
// // tableManagerModel.initData();
// // Timer(
// // Duration(milliseconds: 500),
// // () => _areaController.jumpTo(
// // _areaController.position.maxScrollExtent));
// await tableManagerModel
// .getTableList(context);
// await tableManagerModel
// .initData();
await tableManagerModel.refreshTable(context);
}
// // await tableManagerModel
// // .getTableList(context);
// // await tableManagerModel
// // .initData();
// await tableManagerModel.refreshTable(context);
// }
});
}
});
... ...
... ... @@ -50,7 +50,7 @@ class AreaItemTableState extends State<AreaItemTable> {
),
alignment: Alignment.center,
decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10)),
borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10)),
color: isSelected
? MyColours.color_199095
: widget.showBadge && area.count != -1 && area.count <= 0
... ...
... ... @@ -459,6 +459,45 @@ class MyTableManageHomeModel with ChangeNotifier {
return false;
}
// 合并桌位
Future<bool> mergeTables(
BuildContext context, Map<String, String> params) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.merge_tables,
data: params, showLoading: true)
.catchError((error) {
print(error.toString());
// if (error is MyError) {
// switch (error.type) {
// case 1:
// pageState = PageState.ConnectivityError;
// break;
// case 2:
// pageState = PageState.ConnectivityTimeOut;
// break;
// default:
// pageState = PageState.ConnectivityError;
// break;
// }
// }
// notifyListeners();
return false;
});
if (baseResp.code == Constant.status_success) {
if (baseResp.responseData['data'] != null &&
baseResp.responseData['data'] == 1) {
return true;
} else {
Utils.showToast(baseResp.msg ?? '合并桌位失败!');
}
} else {
Utils.showToast(baseResp.msg ?? '合并桌位失败!');
}
return false;
}
//批量修改桌位信息
Future<bool> batchSetTable(
BuildContext context, Map<String, String> params) async {
... ...
... ... @@ -1102,4 +1102,26 @@ class NavigatorUtil {
return _navigateTo(context, "${Routes.feast_invoice_detail_page}",
replace: replace);
}
///桌位管理----合并桌位----桌位选择
static Future<dynamic> goMergeTableSelectPage(BuildContext context,
{replace = false,
bool canChoose = true,
Map object,
String fromPage = 'table_manage',
String tableidNow,
String tid = ''}) {
// if (invoice != null) {
// return _navigateTo(context,
// "${Routes.merge_table_select_page}?invoice=${FluroConvertUtils.object2string(invoice)}",
// replace: replace);
// }
if (object != null) {
return _navigateTo(context,
"${Routes.merge_table_select_page}?tableidNow=$tableidNow&fromPage=$fromPage&canChoose=$canChoose&object=${FluroConvertUtils.object2string(object)}");
}
return _navigateTo(context,
"${Routes.merge_table_select_page}?tableidNow=$tableidNow&fromPage=$fromPage&canChoose=$canChoose",
replace: replace);
}
}
... ...
... ... @@ -174,6 +174,7 @@ import '../pages/my/feast_manage/feast_setmeal_manage_edit_page.dart';
import '../pages/my/feast_manage/feast_type_page.dart';
import '../pages/my/feast_manage/feast_wine_manage_edit_page.dart';
import '../pages/my/feast_manage/feast_wine_manage_page.dart';
import '../pages/my/table_manage/merge_table_select_page.dart';
import '../provider/feast_model.dart';
// 登录页
... ... @@ -988,11 +989,16 @@ var customerListPageHandle = new Handler(
String index = params["index"].first;
String uid = params["uid"].first;
bool distribution = FluroConvertUtils.string2bool(params["distribution"].first);
bool distribution =
FluroConvertUtils.string2bool(params["distribution"].first);
return ChangeNotifierProvider<CustomerProvider>(
create: (_) => CustomerProvider(),
child: CustomerListPage(fromPage: fromPage, index: index, uidStr: uid,distribution: distribution));
child: CustomerListPage(
fromPage: fromPage,
index: index,
uidStr: uid,
distribution: distribution));
});
///仅供展示的客情列表 ---商家
... ... @@ -1777,3 +1783,28 @@ var feastInvoiceDetailPageHandle = new Handler(
create: (_) => FeastModel(),
child: FeastInvoiceDetailPage(invoice: invoice));
});
///桌位管理----合并桌位----选择桌位
var mergeTableSelectPageHandle = new Handler(
handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
String fromPage = params["fromPage"].first;
String tableidNow = params["tableidNow"].first;
bool canChoose = params["canChoose"].first == "true" ? true : false;
List<TableList> res = [];
if (params.keys.contains('object')) {
Map object = FluroConvertUtils.string2map(params["object"].first);
List temp = object['object'];
for (var item in temp) {
res.add(TableList.fromJson(item));
}
}
return ChangeNotifierProvider<ChooseTableModel>(
create: (_) => ChooseTableModel(),
child: MergeTableSelectPage(
tableid: tableidNow,
tableList: res,
canChoose: canChoose,
fromPage: fromPage));
});
... ...
... ... @@ -156,6 +156,9 @@ class Routes {
static String feast_detail_page = "/feast_detail_page"; //宴会-----详情
static String feast_invoice_detail_page = "/feast_invoice_detail_page"; //宴会-----发票详情
static String merge_table_select_page = "/merge_table_select_page"; //桌位管理---合并桌位选择桌位页面
static void configureRoutes(FluroRouter router) {
... ... @@ -314,6 +317,9 @@ class Routes {
router.define(feast_detail_page, handler: feastDetailPageHandle);
router.define(feast_invoice_detail_page, handler: feastInvoiceDetailPageHandle);
router.define(merge_table_select_page, handler: mergeTableSelectPageHandle);
... ...
... ... @@ -2061,6 +2061,10 @@ class DialogUtil {
String tidStr,
String pnumMin = '',
String pnumMax = '',
String isLock = '0',
String isMerge = '0',
String tableid,
List<t.Table> selectTables,
CustomCallBackMap onTap,
CustomCallBackMap onTapDel}) async {
TextEditingController controller = TextEditingController();
... ... @@ -2092,6 +2096,19 @@ class DialogUtil {
// }
// });
String tids = '';
String tableNames = '';
selectTables.forEach((element) {
tableNames += '${element.name}、';
tids += '${element.id},';
});
if (tableNames.endsWith('、')) {
tableNames = tableNames.substring(0, tableNames.length - 1);
}
if (tids.endsWith(',')) {
tids = tids.substring(0, tids.length - 1);
}
final action = await showDialog(
context: context,
barrierDismissible: false,
... ... @@ -2211,7 +2228,7 @@ class DialogUtil {
child: Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(44)),
height: ScreenUtil().setWidth(30 * 2),
height: ScreenUtil().setWidth(48 * 2),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.center,
... ... @@ -2242,13 +2259,19 @@ class DialogUtil {
],
),
)),
Padding(
padding: EdgeInsets.only(
left: ScreenUtil().setWidth(74),
right: ScreenUtil().setWidth(74)),
child: MyDivider(double.infinity, w(1),
color: MyColours.color_E7E7E7)),
Container(
margin: EdgeInsets.only(
top: ScreenUtil().setWidth(30)),
padding: EdgeInsets.only(
left: ScreenUtil().setWidth(44),
right: ScreenUtil().setWidth(44)),
height: ScreenUtil().setWidth(30 * 2),
height: ScreenUtil().setWidth(48 * 2),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
... ... @@ -2291,7 +2314,198 @@ class DialogUtil {
],
),
),
VEmptyView(40),
VEmptyView(32),
isLock == '1'
?
// 已被合并到
Column(
children: [
InkWell(
onTap: () {
//跳转到被合并桌位展示页面
},
child: Container(
padding: EdgeInsets.only(
left:
ScreenUtil().setWidth(44),
right: ScreenUtil()
.setWidth(44)),
height:
ScreenUtil().setWidth(48 * 2),
child: Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
HEmptyView(32),
Text(
'已被合并到',
style: TextStyle(
fontSize: ScreenUtil()
.setSp(32),
color: MyColours
.color_BFC4D4),
),
// Spacer(),
Expanded(
child: Text(
'桌位23333',
maxLines: 1,
textAlign: TextAlign.right,
overflow:
TextOverflow.ellipsis,
style: TextStyle(
fontSize: ScreenUtil()
.setSp(32),
color: MyColours
.color_BFC4D4),
)),
HEmptyView(22),
],
))),
Padding(
padding: EdgeInsets.only(
left: ScreenUtil().setWidth(74),
right: ScreenUtil().setWidth(74)),
child: MyDivider(
double.infinity, w(1),
color: MyColours.color_E7E7E7)),
],
)
:
// 合并桌位开关等
Column(
children: [
InkWell(
onTap: () {
if (isMerge == '1') {
isMerge = '0';
} else {
isMerge = '1';
}
state(() {});
},
child: Container(
padding: EdgeInsets.only(
left:
ScreenUtil().setWidth(44),
right: ScreenUtil()
.setWidth(44)),
height:
ScreenUtil().setWidth(48 * 2),
child: Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
HEmptyView(32),
Text(
'合并桌位',
style: TextStyle(
fontSize: ScreenUtil()
.setSp(32),
color: MyColours
.color_000000),
),
Spacer(),
Image.asset(
Utils.getImgPath(
isMerge == '1'
? 'swich_on'
: 'swich_off'),
width: w(44)),
HEmptyView(32),
],
))),
VEmptyView(32),
InkWell(
onTap: () async {
//跳转到被合并桌位展示页面
Map object;
if (selectTables.length > 0) {
object = await NavigatorUtil
.goMergeTableSelectPage(
context,
tableidNow: tableid,
object: {
'object': selectTables
});
} else {
object = await NavigatorUtil
.goMergeTableSelectPage(
context,
tableidNow: tableid,
);
}
if (object != null) {
selectTables = object['object'];
tids = object['tid'];
} else {
selectTables = []; //没有选择桌子
tids = '';
}
tableNames = '';
selectTables.forEach((element) {
tableNames += '${element.name}、';
});
if (tableNames.endsWith('、')) {
tableNames = tableNames.substring(
0, tableNames.length - 1);
}
print(object);
state(() {});
},
child: Container(
padding: EdgeInsets.only(
left:
ScreenUtil().setWidth(44),
right: ScreenUtil()
.setWidth(44)),
height:
ScreenUtil().setWidth(48 * 2),
child: Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
HEmptyView(32),
Text(
'被合并桌位',
style: TextStyle(
fontSize: ScreenUtil()
.setSp(32),
color: MyColours
.color_000000),
),
HEmptyView(40),
Expanded(
child: Text(
tableNames ?? "",
maxLines: 1,
textAlign: TextAlign.right,
overflow:
TextOverflow.ellipsis,
style: TextStyle(
fontSize: ScreenUtil()
.setSp(32),
color: MyColours
.color_66000000),
)),
Image.asset(
Utils.getImgPath(
'base_arrow_r'),
width: w(24)),
HEmptyView(22),
],
))),
Padding(
padding: EdgeInsets.only(
left: ScreenUtil().setWidth(74),
right: ScreenUtil().setWidth(74)),
child: MyDivider(
double.infinity, w(1),
color: MyColours.color_E7E7E7)),
],
),
VEmptyView(50),
RoundButton(
text: '删除桌位',
width: ScreenUtil().setWidth(88 * 2),
... ... @@ -2368,6 +2582,13 @@ class DialogUtil {
Utils.showToast('请输入桌位名称!');
return;
}
if (isLock != '1' && isMerge == '1') {
//合并桌位的时候,开关打开的情况下,必须选择至少一个桌位
if (selectTables.length == 0) {
Utils.showToast('请选择被合并桌位');
return;
}
}
// 当前选中区域
// areas[currentAreaIndex]
//最低人数
... ... @@ -2381,6 +2602,8 @@ class DialogUtil {
'name': controller.text,
'pnumMin': pnumMin,
'pnumMax': pnumMax,
'isMerge': isMerge,
'tids': tids
});
Navigator.pop(context);
}),
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/notebook.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/models/table.dart' as t;
import 'package:one_key/widgets/v_empty_view.dart';
class MergeTableItem extends StatefulWidget {
final t.Table table;
final bool canSelected; //是否能选中
final ValueChanged<t.Table> onSelected;
final String fromPage; // 变更、新建、桌位管理三个页面
final String rid;
final Map<String, Notebook> tableMap; //记录已预订桌位对应的订单
final int height; //高度
final bool need;
MergeTableItem(this.table,
{this.onSelected,
this.canSelected = false,
this.height = 60,
this.fromPage = 'new',
this.rid,
this.tableMap,
this.need = true});
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return new MergeTableItemState();
}
}
class MergeTableItemState extends State<MergeTableItem> {
@override
Widget build(BuildContext context) {
t.Table table = widget.table;
String signStr = table.signStr;
if (table.sign == '5' && widget.tableMap[table.id]?.orderInfo != null) {
if (widget.tableMap[table.id].orderInfo?.status == '3') {
signStr = '已买单';
}
}
bool isSelf = false;
//当前桌子的预订id
String idNow = '';
if (widget.tableMap.containsKey('${table.id}')) {
//包含,证明该桌子已经被预订了
idNow = widget.tableMap['${table.id}'].id;
if (idNow == widget.rid) {
isSelf = true;
}
}
return GestureDetector(
onTap: () {
if (widget.canSelected && widget.fromPage == 'change') {
//从变更页面进来 canChoose = true
if (widget.canSelected && signStr.isEmpty) {
setState(() {
table.selected = !(table.selected ?? false);
});
widget.onSelected(table);
} else {
if (table.sign == '5' || table.sign == '1') {
// 1一般是商户端
// 5是用户端
//已预订状态 不是自己的不可以选择,是自己的可以选择
//当前桌子的预订id
String idNow = '';
if (widget.tableMap.containsKey('${table.id}')) {
//包含,证明该桌子已经被预订了
idNow = widget.tableMap['${table.id}'].id;
if (idNow == widget.rid) {
setState(() {
isSelf = true;
table.selected = !(table.selected ?? false);
});
widget.onSelected(table);
}
}
}
}
} else if (widget.fromPage == 'new' &&
widget.canSelected &&
signStr.isEmpty) {
//从安排桌位进来
setState(() {
table.selected = !(table.selected ?? false);
});
widget.onSelected(table);
} else if (widget.fromPage == 'table_manage' ||
widget.fromPage == 'room_manage') {
setState(() {
table.selected = !(table.selected ?? false);
});
widget.onSelected(table);
} else if (widget.fromPage == 'tablePhoto') {
// setState(() {
// table.selected = true;
// });
widget.onSelected(table);
} else {
setState(() {
table.selected = !(table.selected ?? false);
});
widget.onSelected(table);
}
},
child: Stack(
children: <Widget>[
Container(
// width: ScreenUtil().setWidth(160),
// height: ScreenUtil().setWidth(widget.height),
// margin: EdgeInsets.all(ScreenUtil().setWidth(9)),
decoration: BoxDecoration(
color: widget.need && signStr == '已预订' && !isSelf
? MyColours.color_afbcc4
: widget.canSelected && table.selected
? MyColours.color_199095
: MyColours.color_ffffff,
border: Border.all(
width: ScreenUtil().setWidth(2),
color: MyColours.color_E0E0E0),
borderRadius: BorderRadius.all(
Radius.circular(ScreenUtil().setWidth(10)))),
child: Stack(
// alignment: Alignment.center,
children: <Widget>[
Container(
// alignment: Alignment.center,
// color: Colors.blueAccent,
// height: ScreenUtil().setWidth(widget.height),
// padding: EdgeInsets.symmetric(
// horizontal: ScreenUtil().setWidth(20)),
// margin: EdgeInsets.only(left: ScreenUtil().setWidth(20)),
child: Column(
// mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
widget.need && signStr == '已预订' && !isSelf
? SizedBox()
: VEmptyView(10),
Container(
// color: Colors.red,
alignment: Alignment.center,
child: Text(
table.name,
maxLines: 1,
style: TextStyle(
color:
(widget.need && signStr == '已预订' && !isSelf)
? MyColours.color_333333
: (widget.canSelected && table.selected)
? MyColours.color_ffffff
: MyColours.color_333333,
fontSize: ScreenUtil().setSp(30),
decoration: TextDecoration.none,
fontWeight: FontWeight.bold),
overflow: TextOverflow.ellipsis,
)
// Text(
// table.name,
// // textAlign: TextAlign.center,
// maxLines: 2,
// style: TextStyle(
// color: table.signStr == '已停用'
// ? MyColours.color_999999
// : MyColours.color_353535,
// fontSize: ScreenUtil().setSp(28),
// decoration: TextDecoration.none,
// fontWeight: FontWeight.normal),
// overflow: TextOverflow.ellipsis,
// ),
),
// ((table.reserver != null && table.reserver != '') ||
// (table.pnum != '' &&
// table.pnum != null &&
// table.pnum != '0'))
// ? VEmptyView(20)
// : SizedBox(),
VEmptyView(12),
signStr == '已预订' && !isSelf
? SizedBox()
: Text(
table.tableNum,
style: TextStyle(
color: signStr == '已预订' && !isSelf
? MyColours.color_353535
: (widget.canSelected && table.selected)
? MyColours.color_ffffff
: MyColours.color_353535,
fontSize: ScreenUtil().setSp(14),
decoration: TextDecoration.none,
fontWeight: FontWeight.normal),
overflow: TextOverflow.ellipsis,
),
// signStr == '已预订' &&
// !isSelf &&
// ((table.reserver != null &&
// !table.reserver.isEmpty) ||
// (table.pnum != '' &&
// table.pnum != null &&
// table.pnum != '0'))
// ? Text(
// (table.reserver == null || table.reserver.isEmpty)
// ? (table.pnum != '' &&
// table.pnum != null &&
// table.pnum != '0')
// ? '(${table.pnum}人)'
// : ''
// : '${table.reserver}' +
// (table.pnum != '' &&
// table.pnum != null &&
// table.pnum != '0'
// ? '(${table.pnum}人)'
// : ''),
// style: TextStyle(
// color: signStr == '已预订' && !isSelf
// ? MyColours.color_353535
// : (widget.canSelected && table.selected)
// ? MyColours.color_ffffff
// : MyColours.color_353535,
// fontSize: ScreenUtil().setSp(14),
// decoration: TextDecoration.none,
// fontWeight: FontWeight.normal),
// overflow: TextOverflow.ellipsis,
// )
// : SizedBox(),
// widget.need &&
// signStr == '已预订' &&
// !isSelf &&
// table.nickName != null &&
// table.nickName != ''
// ? Padding(
// padding: EdgeInsets.only(
// top: ScreenUtil().setWidth(6),
// bottom: ScreenUtil().setWidth(8),
// ),
// child: Text(
// table.nickName != null && table.nickName != ''
// ? '${table.nickName}订'
// : '',
// style: TextStyle(
// color: MyColours.color_353535,
// fontSize: ScreenUtil().setSp(22),
// decoration: TextDecoration.none,
// fontWeight: FontWeight.normal),
// overflow: TextOverflow.ellipsis,
// ),
// )
// : SizedBox(),
// VEmptyView(6),
// Text(
// table.lowStr,
// style: TextStyle(
// color: MyColours.color_777777,
// fontSize: ScreenUtil().setSp(26),
// decoration: TextDecoration.none,
// fontWeight: FontWeight.normal),
// overflow: TextOverflow.ellipsis,
// )
signStr == '已预订' && !isSelf
? Container(
// width: ScreenUtil().setWidth(160),
height: ScreenUtil().setWidth(34),
)
: SizedBox()
],
),
),
signStr == '已预订' && !isSelf
? SizedBox()
: Positioned(
left: 0,
top: 0,
child: table.tidStr == null
? Container()
: Container(
// width: ScreenUtil().setWidth(60),
// height: ScreenUtil().setWidth(42),
padding:
EdgeInsets.all(ScreenUtil().setWidth(4)),
alignment: Alignment.center,
decoration: BoxDecoration(
color: widget.canSelected && table.selected
? MyColours.color_199095
: MyColours.color_999999,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(
ScreenUtil().setWidth(10)),
// topRight:
// Radius.circular(ScreenUtil().setWidth(8)),
// bottomRight: Radius.circular(
// ScreenUtil().setWidth(8))
)),
child: Text(table.tidStr,
style: TextStyle(
color:
MyColours.color_ffffff
,
fontSize: ScreenUtil().setSp(14),
decoration: TextDecoration.none,
fontWeight: FontWeight.normal)),
),
),
// widget.need && signStr == '已预订'
// ? Positioned(
// bottom: 0,
// left: 0,
// right: 0,
// child: signStr.isEmpty
// ? Container()
// : Container(
// width: ScreenUtil().setWidth(160),
// height: ScreenUtil().setWidth(40),
// alignment: Alignment.center,
// decoration: BoxDecoration(
// color: signStr == '已停用'
// ? MyColours.color_777777
// : signStr == '已买单'
// ? MyColours.color_F59A23
// : MyColours.color_E95750,
// borderRadius: BorderRadius.only(
// bottomLeft: Radius.circular(
// ScreenUtil().setWidth(8)),
// bottomRight: Radius.circular(
// ScreenUtil().setWidth(8)))),
// child: Text(
// signStr,
// style: TextStyle(
// color: MyColours.color_ffffff,
// fontSize: ScreenUtil().setSp(24),
// decoration: TextDecoration.none,
// fontWeight: FontWeight.normal),
// ),
// ),
// )
// : SizedBox(),
],
),
),
// Positioned(
// top: 3,
// right: 5,
// child: widget.canSelected && (table.selected ?? false)
// ? Image.asset(
// "assets/icon_selected.png",
// width: ScreenUtil().setWidth(40),
// height: ScreenUtil().setWidth(40),
// )
// : Container()),
// widget.need && signStr == '已预订' && !isSelf
// ? SizedBox()
// : Positioned(
// left: ScreenUtil().setWidth(18),
// bottom: ScreenUtil().setWidth(12),
// child: table.isPhoto != 1
// ? Image.asset(
// widget.canSelected && table.selected
// ? 'assets/f_camera_white.png'
// : "assets/f_camera.png",
// width: ScreenUtil().setWidth(22),
// height: ScreenUtil().setWidth(22),
// )
// : Container()),
// Positioned(
// bottom: 0,
// right: 0,
// left: 0,
// child: signStr == '已预订' && !isSelf
// ? Container(
// // width: ScreenUtil().setWidth(160),
// height: ScreenUtil().setWidth(34),
// alignment: Alignment.centerLeft,
// padding: EdgeInsets.symmetric(
// horizontal: ScreenUtil().setWidth(10)),
// decoration: BoxDecoration(
// color: MyColours.color_d7d7d7,
// borderRadius: BorderRadius.only(
// bottomLeft:
// Radius.circular(ScreenUtil().setWidth(20)),
// bottomRight:
// Radius.circular(ScreenUtil().setWidth(20)))),
// child: Text(
// '新客',
// style: TextStyle(
// color: MyColours.color_353535,
// fontSize: ScreenUtil().setSp(24),
// decoration: TextDecoration.none,
// fontWeight: FontWeight.normal),
// ),
// )
// : SizedBox())
],
),
);
}
}
... ...