|
...
|
...
|
@@ -20,8 +20,6 @@ import 'package:provider/provider.dart'; |
|
|
|
import 'dart:convert' as convert;
|
|
|
|
|
|
|
|
class TableManagerPage extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() {
|
|
|
|
// TODO: implement createState
|
|
...
|
...
|
@@ -30,7 +28,6 @@ class TableManagerPage extends StatefulWidget { |
|
|
|
}
|
|
|
|
|
|
|
|
class TableManagerPageState extends State<TableManagerPage> {
|
|
|
|
|
|
|
|
TableManagerModel tableManagerModel;
|
|
|
|
|
|
|
|
@override
|
|
...
|
...
|
@@ -38,10 +35,11 @@ class TableManagerPageState extends State<TableManagerPage> { |
|
|
|
// TODO: implement initState
|
|
|
|
super.initState();
|
|
|
|
LogUtil.v("table_manager_page initState");
|
|
|
|
tableManagerModel=Provider.of<TableManagerModel>(context,listen: false);
|
|
|
|
tableManagerModel = Provider.of<TableManagerModel>(context, listen: false);
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
tableManagerModel.initTime(context);
|
|
|
|
EventBus().on("refresh_tablemanager", (arg) {//订座-完成预订 刷新管理桌位
|
|
|
|
EventBus().on("refresh_tablemanager", (arg) {
|
|
|
|
//订座-完成预订 刷新管理桌位
|
|
|
|
tableManagerModel.getReserveList(context);
|
|
|
|
});
|
|
|
|
});
|
|
...
|
...
|
@@ -51,17 +49,15 @@ class TableManagerPageState extends State<TableManagerPage> { |
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return SafeArea(
|
|
|
|
child: Consumer<TableManagerModel>(
|
|
|
|
builder: (context,model,child){
|
|
|
|
builder: (context, model, child) {
|
|
|
|
return Column(
|
|
|
|
children: <Widget>[
|
|
|
|
MyAppBar(
|
|
|
|
"桌位",
|
|
|
|
showBack: false
|
|
|
|
),
|
|
|
|
MyAppBar("桌位", showBack: false),
|
|
|
|
Container(
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
width: double.infinity,
|
|
|
|
padding: EdgeInsets.symmetric(vertical: ScreenUtil().setHeight(16)),
|
|
|
|
padding:
|
|
|
|
EdgeInsets.symmetric(vertical: ScreenUtil().setHeight(16)),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: <Widget>[
|
|
...
|
...
|
@@ -69,10 +65,11 @@ class TableManagerPageState extends State<TableManagerPage> { |
|
|
|
child: Center(
|
|
|
|
child: GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
DialogUtil.showCalendarDialog(context, tableManagerModel.dateTime)
|
|
|
|
DialogUtil.showCalendarDialog(
|
|
|
|
context, tableManagerModel.dateTime)
|
|
|
|
.then((day) {
|
|
|
|
if (day != null) {
|
|
|
|
tableManagerModel.createDateText(context,day);
|
|
|
|
tableManagerModel.createDateText(context, day);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
...
|
...
|
@@ -101,56 +98,77 @@ class TableManagerPageState extends State<TableManagerPage> { |
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: <Widget>[
|
|
|
|
Offstage(
|
|
|
|
offstage: tableManagerModel.morning == "00:00-00:00" ? true : false,
|
|
|
|
offstage:
|
|
|
|
tableManagerModel.morning == "00:00-00:00"
|
|
|
|
? true
|
|
|
|
: false,
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
right: ScreenUtil().setWidth(18)),
|
|
|
|
child: CommonButton(
|
|
|
|
content: "早市",
|
|
|
|
state: tableManagerModel.currTimeIndex == 1 ? 1 : 0,
|
|
|
|
state:
|
|
|
|
tableManagerModel.currTimeIndex == 1
|
|
|
|
? 1
|
|
|
|
: 0,
|
|
|
|
width: 92,
|
|
|
|
height: 48,
|
|
|
|
fontSize: 32,
|
|
|
|
onPress: () {
|
|
|
|
if (tableManagerModel.currTimeIndex == 1) return;
|
|
|
|
if (tableManagerModel.currTimeIndex ==
|
|
|
|
1) return;
|
|
|
|
tableManagerModel.currTimeIndex = 1;
|
|
|
|
tableManagerModel.getReserveList(context);
|
|
|
|
tableManagerModel
|
|
|
|
.getReserveList(context);
|
|
|
|
},
|
|
|
|
))),
|
|
|
|
Offstage(
|
|
|
|
offstage: tableManagerModel.noon == "00:00-00:00" ? true : false,
|
|
|
|
offstage:
|
|
|
|
tableManagerModel.noon == "00:00-00:00"
|
|
|
|
? true
|
|
|
|
: false,
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
right: ScreenUtil().setWidth(18)),
|
|
|
|
child: CommonButton(
|
|
|
|
content: "午市",
|
|
|
|
state: tableManagerModel.currTimeIndex == 2 ? 1 : 0,
|
|
|
|
state:
|
|
|
|
tableManagerModel.currTimeIndex == 2
|
|
|
|
? 1
|
|
|
|
: 0,
|
|
|
|
width: 92,
|
|
|
|
height: 48,
|
|
|
|
fontSize: 32,
|
|
|
|
onPress: () {
|
|
|
|
if (tableManagerModel.currTimeIndex == 2) return;
|
|
|
|
if (tableManagerModel.currTimeIndex ==
|
|
|
|
2) return;
|
|
|
|
tableManagerModel.currTimeIndex = 2;
|
|
|
|
tableManagerModel.getReserveList(context);
|
|
|
|
tableManagerModel
|
|
|
|
.getReserveList(context);
|
|
|
|
},
|
|
|
|
))),
|
|
|
|
Offstage(
|
|
|
|
offstage: tableManagerModel.night == "00:00-00:00" ? true : false,
|
|
|
|
offstage: tableManagerModel.night == "00:00-00:00"
|
|
|
|
? true
|
|
|
|
: false,
|
|
|
|
child: Container(
|
|
|
|
// padding: EdgeInsets.symmetric(
|
|
|
|
// horizontal: ScreenUtil().setWidth(10)),
|
|
|
|
// padding: EdgeInsets.symmetric(
|
|
|
|
// horizontal: ScreenUtil().setWidth(10)),
|
|
|
|
child: CommonButton(
|
|
|
|
content: "晚市",
|
|
|
|
state: tableManagerModel.currTimeIndex == 3 ? 1 : 0,
|
|
|
|
width: 92,
|
|
|
|
height: 48,
|
|
|
|
fontSize: 32,
|
|
|
|
onPress: () {
|
|
|
|
if (tableManagerModel.currTimeIndex == 3) return;
|
|
|
|
tableManagerModel.currTimeIndex = 3;
|
|
|
|
tableManagerModel.getReserveList(context);
|
|
|
|
},
|
|
|
|
)),
|
|
|
|
content: "晚市",
|
|
|
|
state: tableManagerModel.currTimeIndex == 3
|
|
|
|
? 1
|
|
|
|
: 0,
|
|
|
|
width: 92,
|
|
|
|
height: 48,
|
|
|
|
fontSize: 32,
|
|
|
|
onPress: () {
|
|
|
|
if (tableManagerModel.currTimeIndex == 3)
|
|
|
|
return;
|
|
|
|
tableManagerModel.currTimeIndex = 3;
|
|
|
|
tableManagerModel.getReserveList(context);
|
|
|
|
},
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
...
|
...
|
@@ -166,138 +184,205 @@ class TableManagerPageState extends State<TableManagerPage> { |
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Consumer<TableManagerModel>(
|
|
|
|
builder: (context,model,child){
|
|
|
|
if (model.pageState != PageState.Success) {
|
|
|
|
return ExceptionPage(
|
|
|
|
pageState: model.pageState,
|
|
|
|
callback: () {
|
|
|
|
if(tableManagerModel.tableOuterList.isEmpty){
|
|
|
|
tableManagerModel.getTableList(context);
|
|
|
|
}else{
|
|
|
|
tableManagerModel.getReserveList(context);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
emptyMsg: "暂时没有桌位哦",
|
|
|
|
emptyImg: "empty_search",
|
|
|
|
showMsg: "加载中,请稍后...",
|
|
|
|
);
|
|
|
|
}else{
|
|
|
|
return Container(
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Container(
|
|
|
|
width: ScreenUtil().setWidth(170),
|
|
|
|
height: double.infinity,
|
|
|
|
color: MyColours.color_f1f1f1,
|
|
|
|
child: ListView.builder(
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
return Selector<TableManagerModel,Area>(
|
|
|
|
selector: (context,model)=>model.areas[index],
|
|
|
|
builder: (context,area,_){
|
|
|
|
return AreaItem(area, tableManagerModel.currentArea,
|
|
|
|
(area) {
|
|
|
|
setState(() {
|
|
|
|
tableManagerModel.currentArea = (area as Area).name;
|
|
|
|
tableManagerModel.currentTables=tableManagerModel.areaTableMap[tableManagerModel.currentArea];
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
itemExtent: ScreenUtil().setHeight(207),
|
|
|
|
itemCount: tableManagerModel.areas.length,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
vertical: ScreenUtil().setHeight(10),
|
|
|
|
horizontal: ScreenUtil().setWidth(9)),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
builder: (context, model, child) {
|
|
|
|
if (model.pageState != PageState.Success) {
|
|
|
|
return ExceptionPage(
|
|
|
|
pageState: model.pageState,
|
|
|
|
callback: () {
|
|
|
|
if (tableManagerModel.tableOuterList.isEmpty) {
|
|
|
|
tableManagerModel.getTableList(context);
|
|
|
|
} else {
|
|
|
|
tableManagerModel.getReserveList(context);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
emptyMsg: "暂时没有桌位哦",
|
|
|
|
emptyImg: "empty_search",
|
|
|
|
showMsg: "加载中,请稍后...",
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return Container(
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Container(
|
|
|
|
width: ScreenUtil().setWidth(170),
|
|
|
|
height: double.infinity,
|
|
|
|
color: MyColours.color_f1f1f1,
|
|
|
|
child: ListView.builder(
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
return Selector<TableManagerModel, Area>(
|
|
|
|
selector: (context, model) =>
|
|
|
|
model.areas[index],
|
|
|
|
builder: (context, area, _) {
|
|
|
|
return AreaItem(
|
|
|
|
area, tableManagerModel.currentArea,
|
|
|
|
(area) {
|
|
|
|
setState(() {
|
|
|
|
tableManagerModel.currentArea =
|
|
|
|
(area as Area).name;
|
|
|
|
tableManagerModel.currentTables =
|
|
|
|
tableManagerModel.areaTableMap[
|
|
|
|
tableManagerModel
|
|
|
|
.currentArea];
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
itemExtent: ScreenUtil().setHeight(207),
|
|
|
|
itemCount: tableManagerModel.areas.length,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: GridView.builder(
|
|
|
|
gridDelegate:
|
|
|
|
SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
crossAxisCount: 3,
|
|
|
|
childAspectRatio: 8 / 9),
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
return Selector<TableManagerModel,t.Table>(
|
|
|
|
shouldRebuild: (pre,next)=>true,
|
|
|
|
selector: (context,model)=>model.currentTables[index],
|
|
|
|
builder: (context,table,_){
|
|
|
|
return TableItem(
|
|
|
|
table,
|
|
|
|
onSelected: (table) {
|
|
|
|
if ((table as t.Table).selected) {
|
|
|
|
tableManagerModel.selectTables.add(table);
|
|
|
|
} 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);
|
|
|
|
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++;
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
vertical: ScreenUtil().setHeight(10),
|
|
|
|
horizontal: ScreenUtil().setWidth(9)),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: GridView.builder(
|
|
|
|
gridDelegate:
|
|
|
|
SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
crossAxisCount: 3,
|
|
|
|
childAspectRatio: 8 / 9),
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
return Selector<TableManagerModel,
|
|
|
|
t.Table>(
|
|
|
|
shouldRebuild: (pre, next) => true,
|
|
|
|
selector: (context, model) =>
|
|
|
|
model.currentTables[index],
|
|
|
|
builder: (context, table, _) {
|
|
|
|
return TableItem(table,
|
|
|
|
onSelected: (table) {
|
|
|
|
if ((table as t.Table)
|
|
|
|
.selected) {
|
|
|
|
tableManagerModel.selectTables
|
|
|
|
.add(table);
|
|
|
|
} 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);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
for(Area area in tableManagerModel.areas){
|
|
|
|
if(area.name==tableManagerModel.currentArea){
|
|
|
|
if(table.sign != '5'&&table.sign != '1'){//已预订
|
|
|
|
area.count--;
|
|
|
|
} else {
|
|
|
|
for (Area area
|
|
|
|
in tableManagerModel
|
|
|
|
.areas) {
|
|
|
|
if (area.name ==
|
|
|
|
tableManagerModel
|
|
|
|
.currentArea) {
|
|
|
|
if (table.sign !=
|
|
|
|
'5' &&
|
|
|
|
table.sign !=
|
|
|
|
'1') {
|
|
|
|
//已预订
|
|
|
|
area.count--;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tableManagerModel
|
|
|
|
.notifyListeners();
|
|
|
|
}
|
|
|
|
tableManagerModel.notifyListeners();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
canSelected: false,
|
|
|
|
fromPage: 'table_manage',
|
|
|
|
tableMap: tableManagerModel
|
|
|
|
.tableMap,
|
|
|
|
rid: "");
|
|
|
|
},
|
|
|
|
canSelected: false,
|
|
|
|
canChoose: false,
|
|
|
|
tableMap: tableManagerModel.tableMap,
|
|
|
|
rid: "");
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
itemCount: tableManagerModel.currentTables.length,
|
|
|
|
)),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
itemCount: tableManagerModel
|
|
|
|
.currentTables.length,
|
|
|
|
)),
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
...
|
...
|
|