|
|
|
import 'dart:ffi';
|
|
|
|
|
|
|
|
import 'package:common_utils/common_utils.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/notebook_detail.dart';
|
|
|
|
import 'package:one_key/models/tableOuter.dart';
|
|
|
|
import 'package:one_key/models/table_list.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/table_manager_model.dart';
|
|
|
|
import 'package:one_key/provider/user_model.dart';
|
|
|
|
import 'package:one_key/res/colors.dart';
|
|
|
|
import 'package:one_key/utils/dialog_util.dart';
|
|
|
|
import 'package:one_key/utils/event_bus.dart';
|
|
|
|
import 'package:one_key/utils/navigator_util.dart';
|
|
|
|
import 'package:one_key/utils/utils.dart';
|
|
|
|
import 'package:one_key/widgets/MyDivider.dart';
|
|
|
|
import 'package:one_key/widgets/app_bar.dart';
|
|
|
|
import 'package:one_key/widgets/area_item.dart';
|
|
|
|
import 'package:one_key/widgets/common_button.dart';
|
|
|
|
import 'package:one_key/widgets/page_exception.dart';
|
|
|
|
import 'package:one_key/widgets/table_item.dart';
|
|
|
|
import 'package:one_key/models/table.dart' as t;
|
|
|
|
import 'package:provider/provider.dart';
|
|
...
|
...
|
@@ -64,7 +56,7 @@ class TableManagerPageState extends State<TableManagerPage> { |
|
|
|
children: <Widget>[
|
|
|
|
MyAppBar(
|
|
|
|
"桌位",
|
|
|
|
showBack: true,
|
|
|
|
showBack: false
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
color: MyColours.color_ffffff,
|
|
...
|
...
|
@@ -167,18 +159,43 @@ class TableManagerPageState extends State<TableManagerPage> { |
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(20),
|
|
|
|
width: double.infinity,
|
|
|
|
color: MyColours.color_f5f5f5,
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: 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 AreaItem(tableManagerModel.areas[index], tableManagerModel.currentArea,
|
|
|
|
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;
|
|
...
|
...
|
@@ -186,26 +203,31 @@ class TableManagerPageState extends State<TableManagerPage> { |
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
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: [
|
|
|
|
Expanded(
|
|
|
|
child: GridView.builder(
|
|
|
|
gridDelegate:
|
|
|
|
SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
crossAxisCount: 3,
|
|
|
|
childAspectRatio: 8 / 9),
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
);
|
|
|
|
},
|
|
|
|
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: [
|
|
|
|
Expanded(
|
|
|
|
child: GridView.builder(
|
|
|
|
gridDelegate:
|
|
|
|
SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
crossAxisCount: 3,
|
|
|
|
childAspectRatio: 8 / 9),
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
return Selector<TableManagerModel,t.Table>(
|
|
|
|
selector: (context,model)=>model.currentTables[index],
|
|
|
|
builder: (context,table,_){
|
|
|
|
return TableItem(
|
|
|
|
tableManagerModel.areaTableMap[tableManagerModel.currentArea][index],
|
|
|
|
table,
|
|
|
|
onSelected: (table) {
|
|
|
|
if ((table as t.Table).selected) {
|
|
|
|
tableManagerModel.selectTables.add(table);
|
|
...
|
...
|
@@ -223,11 +245,35 @@ class TableManagerPageState extends State<TableManagerPage> { |
|
|
|
NavigatorUtil.goNoteBookChangePage(context, NotebookDetail.fromTableManager(tableManagerModel.dateTime, tableManagerModel.currTimeIndex.toString(),table), "");
|
|
|
|
break;
|
|
|
|
case 3://停用,启用桌位
|
|
|
|
Map params={
|
|
|
|
"id":table.id,
|
|
|
|
"status":table.enable=="1"?"0":"1"
|
|
|
|
Map<String,String> params={
|
|
|
|
"id":(table as t.Table).id,
|
|
|
|
"status":(table as t.Table).enable=="1"?"0":"1"
|
|
|
|
};
|
|
|
|
tableManagerModel.setSwitchStatus(context, params);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -238,14 +284,19 @@ class TableManagerPageState extends State<TableManagerPage> { |
|
|
|
tableMap: tableManagerModel.tableMap,
|
|
|
|
rid: "");
|
|
|
|
},
|
|
|
|
itemCount: tableManagerModel.areaTableMap[tableManagerModel.currentArea].length,
|
|
|
|
)),
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
itemCount: tableManagerModel.currentTables.length,
|
|
|
|
)),
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
...
|
...
|
|