Commit 92aacb1d90e2a8f9c7d6faca442416284a3b55c4

Authored by wdn127929
1 parent 4fd0bd2c

预订,提醒

... ... @@ -46,6 +46,7 @@ class Notebook {
String cdate;
String name;
OrderInfo orderInfo;
String nick_name;
String get tableinfoStr {
return name +
... ... @@ -141,7 +142,7 @@ class OrderInfo extends Object {
@JsonKey(name: 'sid')
String sid;
@JsonKey(name: 'uid')
@JsonKey(name: 'uid')
String uid;
@JsonKey(name: 'rid')
... ...
... ... @@ -41,6 +41,7 @@ Notebook _$NotebookFromJson(Map<String, dynamic> json) {
..code = json['code'] as String
..note_openid = json['note_openid'] as String
..note_name = json['note_name'] as String
..nick_name = json['nick_name'] as String
..operator_openid = json['operator_openid'] as String
..channel = json['channel'] as String
..cdate = json['cdate'] as String
... ... @@ -88,7 +89,8 @@ Map<String, dynamic> _$NotebookToJson(Notebook instance) => <String, dynamic>{
'channel': instance.channel,
'cdate': instance.cdate,
'name': instance.name,
'order_info': instance.orderInfo
'order_info': instance.orderInfo,
'nick_name': instance.nick_name,
};
OrderInfo _$OrderInfoFromJson(Map<String, dynamic> json) {
... ...
... ... @@ -91,6 +91,7 @@ class NotebookDetail {
String action;
String type; //0 内部订单 1 在线预订
String note_name;
String nick_name;
String channel;
String cdate;
List<t.Table> demands; //需求桌位
... ... @@ -216,7 +217,7 @@ class NotebookDetail {
@override
String toString() {
return 'NotebookDetail{id: $id, con_amount:$con_amount,abolition: $abolition, tableinfo: $tableinfo,actual_pum:$actual_pum, pnum: $pnum, rname: $rname, sex: $sex, phone: $phone, cusdem: $cusdem, cusman: $cusman, ddate: $ddate, is_set_ddate: $is_set_ddate, ddate_solt: $ddate_solt, status: $status, action: $action, type: $type, note_name: $note_name, channel: $channel, cdate: $cdate, demands: $demands, tables: $tables, cancel: $cancel}';
return 'NotebookDetail{id: $id, con_amount:$con_amount,abolition: $abolition, tableinfo: $tableinfo,actual_pum:$actual_pum, pnum: $pnum, rname: $rname, sex: $sex, phone: $phone, cusdem: $cusdem, cusman: $cusman, ddate: $ddate, is_set_ddate: $is_set_ddate, ddate_solt: $ddate_solt, status: $status, action: $action, type: $type, note_name: $note_name, , nick_name: $nick_name,channel: $channel, cdate: $cdate, demands: $demands, tables: $tables, cancel: $cancel}';
}
}
... ...
... ... @@ -27,6 +27,7 @@ NotebookDetail _$NotebookDetailFromJson(Map<String, dynamic> json) {
..action = json['action'] as String
..type = json['type'] as String
..note_name = json['note_name'] as String
..nick_name = json['nick_name'] as String
..channel = json['channel'] as String
..cdate = json['cdate'] as String
..demands = (json['demands'] as List)
... ... @@ -54,8 +55,8 @@ Map<String, dynamic> _$NotebookDetailToJson(NotebookDetail instance) =>
'tableinfo': instance.tableinfo,
'abolition': instance.abolition,
'pnum': instance.pnum,
'con_amount':instance.con_amount,
'actual_pum':instance.actual_pum,
'con_amount': instance.con_amount,
'actual_pum': instance.actual_pum,
'rname': instance.rname,
'sex': instance.sex,
'phone': instance.phone,
... ... @@ -68,6 +69,7 @@ Map<String, dynamic> _$NotebookDetailToJson(NotebookDetail instance) =>
'action': instance.action,
'type': instance.type,
'note_name': instance.note_name,
'nick_name': instance.nick_name,
'channel': instance.channel,
'cdate': instance.cdate,
'demands': instance.demands,
... ...
... ... @@ -26,7 +26,7 @@ class Table {
bool selected; //是否选中
int isPhoto; //桌位是否有照片
String pnum; //预计人数
String noteName; //操作人
String nickName; //操作人
//获取桌位类型
String get tidStr {
... ...
... ... @@ -789,12 +789,12 @@ class NotebookDetailPageState extends State<NotebookDetailPage> {
),
Offstage(
offstage:
detailEntity.note_name ==
detailEntity.nick_name ==
'' ||
detailEntity.note_name ==
detailEntity.nick_name ==
null,
child: RowMultiText("记录人",
detailEntity.note_name ?? ""),
detailEntity.nick_name ?? ""),
),
RowMultiText(
"下单时间",
... ...
... ... @@ -8,6 +8,7 @@ import 'package:one_key/constant/state.dart';
import 'package:one_key/models/area.dart';
import 'package:one_key/models/notebook_detail.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/cc_menu_wdn.dart';
import 'package:one_key/provider/table_manager_model.dart';
... ... @@ -24,6 +25,7 @@ import 'package:one_key/widgets/common_button_flat.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/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;
... ... @@ -55,7 +57,7 @@ class TableManagerPageState extends State<TableManagerPage> {
bool isSelected = true; //全部按钮
int _selectNumber;
ScrollController _scrollCrl = ScrollController();
final ItemPositionsListener itemPositionsListener =
ItemPositionsListener.create();
... ... @@ -85,6 +87,14 @@ class TableManagerPageState extends State<TableManagerPage> {
});
}
@override
void dispose() {
// TODO: implement dispose
super.dispose();
EventBus().off("refresh_tablemanager");
EventBus().off("refresh_tablePhoto");
}
///刷新图片显示
_refreshTablePhoto() async {
List temp =
... ... @@ -240,81 +250,94 @@ class TableManagerPageState extends State<TableManagerPage> {
shouldRebuild: (pre, next) => true,
selector: (context, model) => data[index],
builder: (context, table, _) {
return FTableItem(table, onSelected: (table) {
if ((table as t.Table).selected) {
tableManagerModel.selectTables.add(table);
return FTableItem(table, canSelected: true, onSelected: (table) {
if (table.signStr == '已预订') {
//进入订座详情页面
NavigatorUtil.goNotebookDetailPage(
context,
tableManagerModel.tableMap[table.id].id,
tableManagerModel.tableMap[table.id].uid);
} else {
tableManagerModel.selectTables
.removeWhere((t) => t.id == table.id);
}
DialogUtil.showTableManagerDialog(context, table).then((value) {
if (value != null) {
switch (value) {
case 1: //查看详情
NavigatorUtil.goNotebookDetailPage(
context,
tableManagerModel.tableMap[table.id].id,
tableManagerModel.tableMap[table.id].uid);
break;
case 2: //订座
NavigatorUtil.goNoteBookChangePage(
context,
NotebookDetail.fromTableManager(
tableManagerModel.getCurrDdateStr(),
tableManagerModel.currTimeIndex.toString(),
table),
"");
break;
case 3: //停用,启用桌位
Map<String, String> params = {
"id": (table as t.Table).id,
"status": (table as t.Table).enable == "1" ? "0" : "1"
};
tableManagerModel
.setSwitchStatus(context, params)
.then((value) {
if (value != null) {
(table as t.Table).enable =
((int.parse((table as t.Table).enable) + 1) % 2)
.toString();
if ((table as t.Table).enable == "1") {
for (Area area in tableManagerModel.areas) {
if (area.name ==
tableManagerModel.currentArea) {
if (table.sign != '5' && table.sign != '1') {
//已预订
area.count++;
}
break;
}
}
} else {
for (Area area in tableManagerModel.areas) {
if (area.name ==
tableManagerModel.currentArea) {
if (table.sign != '5' && table.sign != '1') {
//已预订
area.count--;
}
break;
}
}
}
tableManagerModel.notifyListeners();
}
});
break;
case 4: //照片管理
NavigatorUtil.goTablePhotoManagerPage(context,
tid: (table as t.Table).id,
tname: (table as t.Table).name);
break;
setState(() {
if ((table as t.Table).selected) {
tableManagerModel.selectTables.add(table);
} else {
tableManagerModel.selectTables
.removeWhere((t) => t.id == table.id);
}
}
});
if (tableManagerModel.selectTables.length > 1) {
_scrollCrl.position
.didUpdateScrollPositionBy(0); //这里触发更新滚动条
}
});
}
// DialogUtil.showTableManagerDialog(context, table).then((value) {
// if (value != null) {
// switch (value) {
// case 1: //查看详情
// NavigatorUtil.goNotebookDetailPage(
// context,
// tableManagerModel.tableMap[table.id].id,
// tableManagerModel.tableMap[table.id].uid);
// break;
// case 2: //订座
// NavigatorUtil.goNoteBookChangePage(
// context,
// NotebookDetail.fromTableManager(
// tableManagerModel.getCurrDdateStr(),
// tableManagerModel.currTimeIndex.toString(),
// table),
// "");
// break;
// case 3: //停用,启用桌位
// Map<String, String> params = {
// "id": (table as t.Table).id,
// "status": (table as t.Table).enable == "1" ? "0" : "1"
// };
// tableManagerModel
// .setSwitchStatus(context, params)
// .then((value) {
// if (value != null) {
// (table as t.Table).enable =
// ((int.parse((table as t.Table).enable) + 1) % 2)
// .toString();
// if ((table as t.Table).enable == "1") {
// for (Area area in tableManagerModel.areas) {
// if (area.name ==
// tableManagerModel.currentArea) {
// if (table.sign != '5' && table.sign != '1') {
// //已预订
// area.count++;
// }
// break;
// }
// }
// } else {
// for (Area area in tableManagerModel.areas) {
// if (area.name ==
// tableManagerModel.currentArea) {
// if (table.sign != '5' && table.sign != '1') {
// //已预订
// area.count--;
// }
// break;
// }
// }
// }
// tableManagerModel.notifyListeners();
// }
// });
// break;
// case 4: //照片管理
// NavigatorUtil.goTablePhotoManagerPage(context,
// tid: (table as t.Table).id,
// tname: (table as t.Table).name);
// break;
// }
// }
// });
},
canSelected: false,
fromPage: 'table_manage',
tableMap: tableManagerModel.tableMap,
rid: "");
... ... @@ -325,6 +348,190 @@ class TableManagerPageState extends State<TableManagerPage> {
);
}
///选中的桌子widget
Widget _selectTableWidget() {
return Expanded(
flex: 1,
child: Container(
// constraints: BoxConstraints(maxHeight: ScreenUtil().setWidth(300)),
// height: ScreenUtil().setWidth(400),
width: double.infinity,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(30)),
decoration: BoxDecoration(
color: MyColours.color_ffffff,
boxShadow: [
BoxShadow(
color: MyColours.color_333333,
blurRadius: ScreenUtil().setWidth(14))
],
borderRadius: BorderRadius.only(
topLeft: Radius.circular(ScreenUtil().setWidth(30)),
topRight: Radius.circular(ScreenUtil().setWidth(30)),
)),
child: Row(
// mainAxisSize: MainAxisSize.min,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
tableManagerModel.selectDateStr,
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(28)),
),
VEmptyView(20),
Text(
'已选桌位:',
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(26)),
),
VEmptyView(20),
Expanded(
child: Container(
width: ScreenUtil.screenWidthDp -
ScreenUtil().setWidth(100 + 180),
// height: ScreenUtil().setWidth(200),
// color: Colors.blueAccent,
child:
// ListView.builder(
// shrinkWrap: true,
// itemBuilder: (BuildContext context, int index) {
// return
Scrollbar(
isAlwaysShown: true, //设置滚动条常亮
controller: _scrollCrl, //必须设置一个controller
///添加进度条
child: SingleChildScrollView(
controller: _scrollCrl,
child: Container(
width: ScreenUtil.screenWidthDp -
ScreenUtil().setWidth(100 + 180),
child: Wrap(
spacing: ScreenUtil().setWidth(20),
runSpacing:
ScreenUtil().setWidth(20),
children: _buildAlwayItems())),
))
// },
// itemCount: 1,
// ),
))
],
),
HEmptyView(20),
Container(
// width: ScreenUtil().setWidth(100),
// color: Colors.red,
child: Column(
children: [
RoundButton(
onPressed: () async {
await tableManagerModel.setReserveInfo(context);
},
text: '预订',
fontSize: 48,
isBold: true,
width: ScreenUtil().setWidth(180),
height: ScreenUtil().setWidth(140),
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(20),
vertical: ScreenUtil().setWidth(4)),
textColor: MyColours.color_ffffff,
gradientStart: MyColours.color_199095,
gradientEnd: MyColours.color_199095,
radius: ScreenUtil().setWidth(10),
borderColor: MyColours.color_199095,
),
InkWell(
onTap: () {
tableManagerModel.selectTables = [];
for (t.Table item in tableManagerModel.tablesShow) {
item.selected = false;
}
tableManagerModel.areaTableMapShow
.forEach((key, value) {
value.forEach((element) {
element.selected = false;
});
});
tableManagerModel.notifyListeners();
},
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(30)),
child: Text(
'取消重置',
style: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setSp(26)),
),
),
),
],
),
)
],
),
));
}
//构建常用备注
List<Widget> _buildAlwayItems() {
List<Widget> tables = [];
for (t.Table table in tableManagerModel.selectTables) {
tables.add(Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(20),
vertical: ScreenUtil().setWidth(4)),
decoration: BoxDecoration(
border: Border.all(
color: MyColours.color_E0E0E0,
width: ScreenUtil().setWidth(2)),
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(10))),
child: Text(
table.name,
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
color: MyColours.color_333333,
fontWeight: FontWeight.bold),
))
// RoundButton(
// onPressed: () async {},
// text: table.name,
// fontSize: 26,
// isBold: false,
// padding: EdgeInsets.symmetric(
// horizontal: ScreenUtil().setWidth(20),
// vertical: ScreenUtil().setWidth(4)),
// height: ScreenUtil().setWidth(48),
// textColor: MyColours.color_333333,
// gradientStart: MyColours.color_ffffff,
// gradientEnd: MyColours.color_ffffff,
// radius: ScreenUtil().setWidth(10),
// borderColor: MyColours.color_E0E0E0,
// )
);
}
return tables;
}
///早餐、午餐、晚餐点击方法
_clickMorAndNoonAndNig() {
tableManagerModel.selectDateStr = tableManagerModel.returnDayDateWeekStr(
tableManagerModel.dateTimeSelect, tableManagerModel.currTimeIndex);
tableManagerModel.getReserveList(context, needLoading: false);
}
@override
Widget build(BuildContext context) {
tableManagerModel = Provider.of<TableManagerModel>(context, listen: true);
... ... @@ -435,7 +642,7 @@ class TableManagerPageState extends State<TableManagerPage> {
if (tableManagerModel.currTimeIndex == 1)
return;
tableManagerModel.currTimeIndex = 1;
tableManagerModel.getReserveList(context);
_clickMorAndNoonAndNig();
},
)),
btnNum == 3 && tableManagerModel.currTimeIndex == 3
... ... @@ -469,7 +676,7 @@ class TableManagerPageState extends State<TableManagerPage> {
if (tableManagerModel.currTimeIndex == 2)
return;
tableManagerModel.currTimeIndex = 2;
tableManagerModel.getReserveList(context);
_clickMorAndNoonAndNig();
},
)),
btnNum == 3 && tableManagerModel.currTimeIndex == 1
... ... @@ -500,7 +707,7 @@ class TableManagerPageState extends State<TableManagerPage> {
if (tableManagerModel.currTimeIndex == 3)
return;
tableManagerModel.currTimeIndex = 3;
tableManagerModel.getReserveList(context);
_clickMorAndNoonAndNig();
},
)),
),
... ... @@ -761,9 +968,15 @@ class TableManagerPageState extends State<TableManagerPage> {
),
),
Expanded(
flex: 2,
child: Container(
constraints: BoxConstraints(
minHeight: ScreenUtil().setWidth(100)),
color: Color.fromRGBO(249, 249, 249, 1),
child: item(_selectNumber))),
tableManagerModel.selectTables.length > 0
? _selectTableWidget()
: SizedBox()
]))
// return CCMenuPage.builder(
// tableManagerModel: tableManagerModel,
... ... @@ -818,12 +1031,4 @@ class TableManagerPageState extends State<TableManagerPage> {
},
));
}
@override
void dispose() {
// TODO: implement dispose
super.dispose();
EventBus().off("refresh_tablemanager");
EventBus().off("refresh_tablePhoto");
}
}
... ...
... ... @@ -6,7 +6,9 @@ import 'package:one_key/constant/state.dart';
import 'package:one_key/models/area.dart';
import 'package:one_key/models/area_model.dart';
import 'package:one_key/models/notebook.dart';
import 'package:one_key/models/reserve_info_model.dart';
import 'package:one_key/models/tableOuter.dart';
import 'package:one_key/models/table_list.dart';
import 'package:one_key/net/base_resp.dart';
import 'package:one_key/net/dio_util.dart';
import 'package:one_key/net/http_url.dart';
... ... @@ -55,12 +57,16 @@ class TableManagerModel with ChangeNotifier {
Map dailyMap = {}; // 早市对应半点钟,午市对应半点钟、晚市对应半点钟
bool swichState = false; //仅看空座
String selectDateStr = '';
DateTime dateTimeSelect;
//初始化时间
initTime(BuildContext context) async {
userModel = Provider.of<UserModel>(context, listen: false);
dateTime = DateTime.now();
dateText = _returnDate(dateTime);
dateTimeSelect = dateTime;
morning =
userModel.user.morning.isEmpty ? "00:00-00:00" : userModel.user.morning;
noon = userModel.user.noon.isEmpty ? "00:00-00:00" : userModel.user.noon;
... ... @@ -124,6 +130,7 @@ class TableManagerModel with ChangeNotifier {
//过了晚市
currTimeIndex = 3;
}
selectDateStr = returnDayDateWeekStr(dateTime, currTimeIndex);
List temp = await getTableList(context);
if (temp.length > 0) {
getReserveList(context);
... ... @@ -236,6 +243,105 @@ class TableManagerModel with ChangeNotifier {
return sb;
}
///录入更改内部预订
Future<SunReserveInfoModel> setReserveInfo(BuildContext context) async {
if (selectTables.length == 0) {
Utils.showToast('请选择桌位');
return null;
}
bool sucess =
await getReserveList(context, showMsg: true, needLoading: false);
if (sucess) {
UserModel userModel = Provider.of<UserModel>(context, listen: false);
//
String tempTime;
if (currTimeIndex == 1) {
tempTime = '08:00';
} else if (currTimeIndex == 2) {
tempTime = '12:00';
} else if (currTimeIndex == 3) {
tempTime = '18:00';
}
String ymd = DateUtil.formatDate(dateTime, format: DateFormats.y_mo_d);
String timeStr = ymd + ' ' + tempTime + ':00';
// int start = DateUtil.getDateMsByTimeStr(timeStr);
LogUtil.v(timeStr);
// String tempDdate = ymyStr + ' ' + ddateStr + ':00';
int ddate = DateUtil.getDateMsByTimeStr(timeStr);
String tableSelectInfo = '';
for (t.Table item in selectTables) {
// if (item.selected) {
tableSelectInfo += ',${item.id}';
// }
}
print(tableSelectInfo);
if (tableSelectInfo.startsWith(',')) {
tableSelectInfo = tableSelectInfo.substring(1);
}
print(tableSelectInfo);
String rdate = '';
String keys = '';
if (currTimeIndex == 1) {
//早市
keys = 'morning';
} else if (currTimeIndex == 2) {
//午市
keys = 'noon';
} else if (currTimeIndex == 3) {
//晚市
keys = 'night';
}
if (keys != '') {
List temp = dailyMap[keys];
String timeStrStart = ymd + ' ' + temp.first + ':00';
String timeStrEnd = ymd + ' ' + temp.last + ':00';
int startM = DateUtil.getDateMsByTimeStr(timeStrStart);
int endM = DateUtil.getDateMsByTimeStr(timeStrEnd);
String start = '${startM}'.substring(0, 10);
String end = '${endM}'.substring(0, 10);
rdate = start + '-' + end;
}
Map<String, String> params = {
"sid": userModel.user.sellerid, //商家ID
"tid": tableSelectInfo, //桌子ID: 格式 2,3,4
'note_name': userModel.user.account,
'type': "0", //内部预订
"rdate": rdate, //预定用餐时间范围:时间戳 开始时间戳(time)-结束时间戳(time)
"ddate": '${ddate}'.substring(0, 10), //到店时间
'is_set_ddate': '1',
"channel": '5',
"uid": userModel.user.openid
};
print(params);
BaseResp<Map<String, dynamic>> baseResp = await DioUtil()
.request<Map<String, dynamic>>(
context, Method.get, HttpUrl.set_reserve_info,
data: params)
.catchError((error) {
print(error.toString());
});
SunReserveInfoModel itemModel;
if (baseResp == null) return itemModel;
if (baseResp.code == Constant.status_success) {
if (int.parse(baseResp.status) != Constant.status_success) {
Utils.showToast(baseResp.msg ?? "");
return itemModel;
}
if (baseResp.responseData['data'] != null &&
baseResp.responseData['data']['row'] != null) {
itemModel = ReserveInfoModel.fromJson(baseResp.responseData).data;
} else {
Utils.showToast("录入预订订单失败,请重试!");
}
return itemModel;
}
}
}
//获取桌位数据
Future<List<TableOuter>> getTableList(BuildContext context,
{bool needLoading = true}) async {
... ... @@ -321,7 +427,9 @@ class TableManagerModel with ChangeNotifier {
//获取已预订列表
getReserveList(BuildContext context,
{bool needLoading = true, bool needKeep = false}) async {
{bool needLoading = true,
bool needKeep = false,
bool showMsg = false}) async {
tableMap.clear();
NoteBookModel model = new NoteBookModel();
Map<String, String> params = {
... ... @@ -339,20 +447,48 @@ class TableManagerModel with ChangeNotifier {
}
List<Notebook> noteBooks = await newGetReserveList(context, params);
List<t.Table> tempSelectTables = [];
tempSelectTables.addAll(selectTables);
String msg = '';
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) {
//已预订,用餐中,已安排
List<String> tids = notebook.tid.split(",");
for (String tid in tids) {
if (notebook.status == "1" ||
notebook.status == "2" ||
notebook.status == "5") {
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;
}
//获取已预订订单
... ... @@ -428,6 +564,9 @@ class TableManagerModel with ChangeNotifier {
table.sign = "";
table.notebookId = "";
table.reserver = "";
table.selected = false;
if (table.tablestatus == "0") {
//没有用餐中
if (tableMap["${table.id}"] != null) {
... ... @@ -436,7 +575,7 @@ class TableManagerModel with ChangeNotifier {
table.notebookId = notebook.id;
table.reserver = notebook.rnameStr;
table.pnum = notebook.pnum;
table.noteName = notebook.note_name;
table.nickName = notebook.nick_name;
//剔除已经预订的桌子,剩下空桌子(仅看空座)
tempList.remove(table);
... ... @@ -472,6 +611,24 @@ class TableManagerModel with ChangeNotifier {
tablesShow = tablesAll;
}
if (selectTables.length > 0) {
//刷新页面时,让原来选中的按钮继续选中
for (t.Table itemSelect in selectTables) {
areaTableMapShow.forEach((key, value) {
for (t.Table item in value) {
if (itemSelect.id == item.id) {
item.selected = true;
}
}
});
for (t.Table item in tablesShow) {
if (itemSelect.id == item.id) {
item.selected = true;
}
}
}
}
if (areaTableMap.isNotEmpty) {
if (!needKeep) {
// currentArea = areaTableMap.keys.first;
... ... @@ -491,12 +648,34 @@ class TableManagerModel with ChangeNotifier {
//生成日期文本
createDateText(BuildContext context, DateTime day) {
if (Utils.isOneDay(day, dateTime)) return; //日期没变
dateTimeSelect = day;
dateText = _returnDate(day);
selectDateStr = returnDayDateWeekStr(day, currTimeIndex);
dateTime = day;
getReserveList(context);
getReserveList(context, needLoading: false);
}
_returnDate(DateTime day) {
String time = Utils.lunarCalendarHolidays(day);
String date = _returnDayDateWeek(day);
date += ' ${time}';
return date;
}
String returnDayDateWeekStr(DateTime day, int index) {
String date = _returnDayDateWeek(day);
if (index == 1) {
date += ' 早餐';
} else if (index == 2) {
date += ' 午餐';
} else if (index == 3) {
date += ' 晚餐';
}
return date;
}
String _returnDayDateWeek(DateTime day) {
String date = '';
DateTime dateNow = DateTime.now();
String ymd = "${day.year}-" +
... ... @@ -513,9 +692,6 @@ class TableManagerModel with ChangeNotifier {
}
date += ymd;
date += " 星期${Utils.formatWeekDayNum(day.weekday)}";
String time = Utils.lunarCalendarHolidays(day);
date += ' ${time}';
return date;
}
... ...
... ... @@ -83,7 +83,10 @@ class FTableItemState extends State<FTableItem> {
widget.onSelected(table);
} else if (widget.fromPage == 'table_manage' ||
widget.fromPage == 'room_manage') {
table.selected = !(table.selected ?? false);
setState(() {
table.selected = !(table.selected ?? false);
});
widget.onSelected(table);
} else if (widget.fromPage == 'tablePhoto') {
// setState(() {
... ... @@ -91,6 +94,11 @@ class FTableItemState extends State<FTableItem> {
// });
widget.onSelected(table);
} else {
setState(() {
table.selected = !(table.selected ?? false);
});
widget.onSelected(table);
}
},
child: Stack(
... ... @@ -102,7 +110,9 @@ class FTableItemState extends State<FTableItem> {
decoration: BoxDecoration(
color: widget.need && signStr == '已预订'
? Color.fromRGBO(154, 23, 45, 1)
: MyColours.color_ffffff,
: widget.canSelected && table.selected
? MyColours.color_199095
: MyColours.color_ffffff,
border: Border.all(
width: ScreenUtil().setWidth(2),
color: MyColours.color_E0E0E0),
... ... @@ -130,7 +140,8 @@ class FTableItemState extends State<FTableItem> {
table.name,
maxLines: 1,
style: TextStyle(
color: widget.need && signStr == '已预订'
color: (widget.need && signStr == '已预订') ||
(widget.canSelected && table.selected)
? MyColours.color_ffffff
: MyColours.color_333333,
fontSize: ScreenUtil().setSp(36),
... ... @@ -166,7 +177,8 @@ class FTableItemState extends State<FTableItem> {
? '(${table.pnum}人)'
: ''),
style: TextStyle(
color: signStr == '已预订'
color: signStr == '已预订' ||
(widget.canSelected && table.selected)
? MyColours.color_ffffff
: MyColours.color_353535,
fontSize: ScreenUtil().setSp(22),
... ... @@ -182,7 +194,7 @@ class FTableItemState extends State<FTableItem> {
bottom: ScreenUtil().setWidth(10),
),
child: Text(
'${table.noteName}订',
'${table.nickName}订',
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(22),
... ... @@ -240,7 +252,9 @@ class FTableItemState extends State<FTableItem> {
EdgeInsets.all(ScreenUtil().setWidth(4)),
alignment: Alignment.center,
decoration: BoxDecoration(
color: Color.fromRGBO(239, 239, 239, 1),
color: widget.canSelected && table.selected
? MyColours.color_199095
: Color.fromRGBO(239, 239, 239, 1),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(
ScreenUtil().setWidth(20)),
... ... @@ -251,7 +265,10 @@ class FTableItemState extends State<FTableItem> {
)),
child: Text(table.tidStr,
style: TextStyle(
color: MyColours.color_333333,
color:
widget.canSelected && table.selected
? MyColours.color_ffffff
: MyColours.color_333333,
fontSize: ScreenUtil().setSp(20),
decoration: TextDecoration.none,
fontWeight: FontWeight.normal)),
... ... @@ -293,16 +310,16 @@ class FTableItemState extends State<FTableItem> {
],
),
),
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()),
// 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 == '已预订'
? SizedBox()
: Positioned(
... ... @@ -310,7 +327,9 @@ class FTableItemState extends State<FTableItem> {
bottom: ScreenUtil().setWidth(12),
child: table.isPhoto != 1
? Image.asset(
"assets/f_camera.png",
widget.canSelected && table.selected
? 'assets/f_camera_white.png'
: "assets/f_camera.png",
width: ScreenUtil().setWidth(22),
height: ScreenUtil().setWidth(22),
)
... ...
... ... @@ -25,6 +25,7 @@ class RoundButton extends StatelessWidget {
this.textColor = Colors.white,
this.borderColor = Colors.transparent,
this.isBold = true,
this.padding = EdgeInsets.zero,
this.space = 6})
: super(key: key);
... ... @@ -51,6 +52,7 @@ class RoundButton extends StatelessWidget {
final String text;
final TextStyle style;
final EdgeInsetsGeometry padding;
final VoidCallback onPressed;
... ... @@ -59,6 +61,7 @@ class RoundButton extends StatelessWidget {
Color _bgColor = bgColor ?? Theme.of(context).primaryColor;
BorderRadius _borderRadius = BorderRadius.circular(radius ?? (height / 2));
return new Container(
padding: padding,
width: width,
height: height,
margin: margin,
... ...