Commit 8495b7e62f35356e1a5a4b674cf2af2114a7e5e4

Authored by wdn127929
1 parent 7397c3ea

桌位UI 和日历

32.6 KB | W: | H:

30.9 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin

47.8 KB | W: | H:

45.1 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin

37.2 KB | W: | H:

34.9 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
... ... @@ -25,6 +25,8 @@ class Table {
String notebookId; //桌位对应的预订id
bool selected; //是否选中
int isPhoto; //桌位是否有照片
String pnum; //预计人数
String noteName; //操作人
//获取桌位类型
String get tidStr {
... ...
... ... @@ -24,80 +24,78 @@ class AreaItemTableState extends State<AreaItemTable> {
// TODO: implement build
Area area = widget.area;
bool isSelected = area.name == widget.currentArea;
return
// GestureDetector(
// onTap: () {
// if (widget.selectCallback != null) {
// widget.selectCallback(widget.area);
// }
// },
// child:
Stack(
overflow: Overflow.visible,
alignment: Alignment.topLeft,
children: <Widget>[
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(
area.name,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: isSelected
? MyColours.color_ffffff
: MyColours.color_333333,
fontSize: ScreenUtil().setSp(28),
decoration: TextDecoration.none,
fontWeight: FontWeight.normal),
),
),
area.count == -1
? Container()
: Positioned(
right: ScreenUtil().setWidth(12),
top: ScreenUtil().setWidth(6),
child: Container(
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setWidth(6),
horizontal: ScreenUtil().setWidth(4)),
// width: ScreenUtil().setWidth(78),
// height: ScreenUtil().setWidth(30),
alignment: Alignment.center,
decoration: BoxDecoration(
color: area.count <= 0
? MyColours.color_999999
: MyColours.color_199095,
// borderRadius: BorderRadius.only(
// topLeft: Radius.circular(ScreenUtil().setWidth(10)),
// topRight: Radius.circular(ScreenUtil().setWidth(15)),
// bottomRight:
// Radius.circular(ScreenUtil().setWidth(15)))
),
child: Text(area.count == 0 ? "满座" : "${area.count}",
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(26),
decoration: TextDecoration.none,
fontWeight: FontWeight.normal)),
),
return GestureDetector(
onTap: () {
if (widget.selectCallback != null) {
widget.selectCallback(widget.area);
}
},
child: Stack(
overflow: Overflow.visible,
alignment: Alignment.topLeft,
children: <Widget>[
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(
area.name,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: isSelected
? MyColours.color_ffffff
: MyColours.color_333333,
fontSize: ScreenUtil().setSp(28),
decoration: TextDecoration.none,
fontWeight: FontWeight.normal),
),
),
area.count == -1
? Container()
: Positioned(
right: ScreenUtil().setWidth(12),
top: ScreenUtil().setWidth(6),
child: Container(
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setWidth(6),
horizontal: ScreenUtil().setWidth(4)),
// width: ScreenUtil().setWidth(78),
// height: ScreenUtil().setWidth(30),
alignment: Alignment.center,
decoration: BoxDecoration(
color: area.count <= 0
? MyColours.color_999999
: MyColours.color_199095,
// borderRadius: BorderRadius.only(
// topLeft: Radius.circular(ScreenUtil().setWidth(10)),
// topRight: Radius.circular(ScreenUtil().setWidth(15)),
// bottomRight:
// Radius.circular(ScreenUtil().setWidth(15)))
),
child: Text(area.count == 0 ? "满座" : "${area.count}",
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(26),
decoration: TextDecoration.none,
fontWeight: FontWeight.normal)),
),
),
],
));
}
}
... ...
... ... @@ -21,6 +21,7 @@ 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/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/system_app_bar.dart';
... ... @@ -51,6 +52,9 @@ class TableManagerPageState extends State<TableManagerPage> {
int _selectIndex = 0;
ScrollController _areaController = ScrollController();
List<String> personNumList = [];
bool isSelected = true; //全部按钮
int _selectNumber;
final ItemPositionsListener itemPositionsListener =
ItemPositionsListener.create();
... ... @@ -59,13 +63,14 @@ class TableManagerPageState extends State<TableManagerPage> {
void initState() {
// TODO: implement initState
super.initState();
LogUtil.v("table_manager_page initState");
for (int i = 1; i < 31; i++) {
personNumList.add(i.toString());
}
// personNumList.add('30以上');
tableManagerModel = Provider.of<TableManagerModel>(context, listen: false);
WidgetsBinding.instance.addPostFrameCallback((_) {
tableManagerModel.initTime(context);
EventBus().on("refresh_tablemanager", (arg) {
... ... @@ -121,225 +126,210 @@ class TableManagerPageState extends State<TableManagerPage> {
/// Generate item number [i].
Widget item(int i) {
return SingleChildScrollView(
child: Column(
children: [
VEmptyView(40),
Container(
alignment: Alignment.center,
height: ScreenUtil().setWidth(21 * 2),
child: Text(tableManagerModel.areas[i].name,
style: TextStyle(
fontSize: ScreenUtil().setWidth(30),
color: MyColours.color_199095)),
),
VEmptyView(30),
GridView.builder(
// controller: _areaController,
physics: NeverScrollableScrollPhysics(),
padding: EdgeInsets.only(top: 0),
shrinkWrap: true,
itemCount: tableManagerModel
.areaTableMap[tableManagerModel.areas[i].name].length +
return GridView.builder(
// controller: _areaController,
// physics: NeverScrollableScrollPhysics(),
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setWidth(20),
horizontal: ScreenUtil().setWidth(10)),
shrinkWrap: true,
itemCount: tableManagerModel.currentArea == '全部'
? tableManagerModel.tablesShow.length
: tableManagerModel
.areaTableMapShow[tableManagerModel.areas[i].name].length +
1,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 4,
childAspectRatio: 8 / 9,
),
// mainAxisSpacing: ScreenUtil().setWidth(15 * 2),
// crossAxisSpacing: ScreenUtil().setWidth(38 * 2)),
itemBuilder: (BuildContext context, int index) {
if (index ==
tableManagerModel
.areaTableMap[tableManagerModel.areas[i].name].length ||
tableManagerModel
.areaTableMap[tableManagerModel.areas[i].name].length ==
0) {
return InkWell(
onTap: () async {
List<String> areas = [];
for (int i = 0; i < tableManagerModel.areas.length; i++) {
areas.add(tableManagerModel.areas[i].name);
}
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 4,
childAspectRatio: 1,
mainAxisSpacing: ScreenUtil().setWidth(30),
crossAxisSpacing: ScreenUtil().setWidth(12),
),
//添加桌位弹框
await DialogUtil.openCreateTableDialog(
context, areas, 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 tableManagerModel.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 tableManagerModel.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));
itemBuilder: (BuildContext context, int index) {
List<t.Table> data = tableManagerModel.currentArea == '全部'
? tableManagerModel.tablesShow
: tableManagerModel
.areaTableMapShow[tableManagerModel.areas[i].name];
if (index == data.length || data.length == 0) {
return InkWell(
onTap: () async {
List<String> areas = [];
for (int i = 0; i < tableManagerModel.areas.length; i++) {
areas.add(tableManagerModel.areas[i].name);
}
// await tableManagerModel
// .getTableList(context);
// await tableManagerModel
// .initData();
tableManagerModel.refreshTable(context);
}
});
},
child: Container(
margin: EdgeInsets.all(ScreenUtil().setWidth(9)),
child: 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(90 * 2),
width: ScreenUtil().setWidth(80 * 2),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(Utils.getImgPath('add_area'),
width: ScreenUtil().setWidth(32)),
],
),
),
),
)));
} else {
return Selector<TableManagerModel, t.Table>(
shouldRebuild: (pre, next) => true,
selector: (context, model) => tableManagerModel
.areaTableMap[tableManagerModel.areas[i].name][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);
//添加桌位弹框
await DialogUtil.openCreateTableDialog(
context, areas, 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 tableManagerModel.areas) {
if (item.name == value['areaname']) {
rid = item.rid;
}
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;
}
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 tableManagerModel.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));
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;
}
// await tableManagerModel
// .getTableList(context);
// await tableManagerModel
// .initData();
tableManagerModel.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.screenWidthDp -
ScreenUtil().setWidth(12 * 3 - 10 * 2),
width: ScreenUtil.screenWidthDp -
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<TableManagerModel, t.Table>(
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);
} 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++;
}
} else {
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--;
}
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: "");
},
);
}
},
),
],
));
}
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: "");
},
);
}
},
);
}
@override
Widget build(BuildContext context) {
tableManagerModel = Provider.of<TableManagerModel>(context, listen: true);
return Scaffold(
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar("桌位", showLeading: false),
body: Consumer<TableManagerModel>(
builder: (context, model, child) {
... ... @@ -520,12 +510,11 @@ class TableManagerPageState extends State<TableManagerPage> {
],
),
),
VEmptyView(40),
Consumer<TableManagerModel>(
builder: (context, model, child) {
if (model.pageState != PageState.Success) {
return Expanded(
child: ExceptionPage(
VEmptyView(30),
model.pageState != PageState.Success
? Expanded(
child: ExceptionPage(
pageState: model.pageState,
callback: () {
if (tableManagerModel.tableOuterList.isEmpty) {
... ... @@ -537,129 +526,293 @@ class TableManagerPageState extends State<TableManagerPage> {
emptyMsg: "暂时没有桌位哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
));
} else {
return Column(
children: [
Container(
height: ScreenUtil().setWidth(100),
child: Row(
children: [
Expanded(
child: ListView.builder(
itemCount: tableManagerModel.areas.length + 1,
shrinkWrap: true,
scrollDirection: Axis.horizontal,
itemBuilder:
(BuildContext contxt, int index) {
if (index ==
tableManagerModel.areas.length ||
tableManagerModel.areas.length == 0) {
return 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)),
],
))
: Expanded(
child: Column(
// crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
color: MyColours.color_ffffff,
height: ScreenUtil().setWidth(90),
margin: EdgeInsets.only(
bottom: ScreenUtil().setWidth(30)),
child: Row(
children: [
HEmptyView(20),
Expanded(
child: ListView.builder(
itemCount: tableManagerModel.areas.length ==
0
? 1
: tableManagerModel.areas.length + 2,
shrinkWrap: true,
scrollDirection: Axis.horizontal,
itemBuilder:
(BuildContext contxt, int index) {
if (index ==
tableManagerModel.areas.length +
1 ||
tableManagerModel.areas.length == 0) {
return InkWell(
onTap: () async {
//添加区域弹框
await DialogUtil
.openCreateAreaDialog(context,
onTap: (value) async {
print(value);
//添加区域
bool success =
await tableManagerModel
.addTableAreas(
context, value);
print(success);
if (success) {
Utils.showToast('添加成功!');
await tableManagerModel
.getTableList(context,
needLoading: false);
tableManagerModel.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;
tableManagerModel.currentArea =
'全部';
tableManagerModel
.currentTables =
tableManagerModel
.areaTableMapShow[
tableManagerModel
.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(
model.areas[index],
tableManagerModel.currentArea,
(area) {});
}
},
)),
HEmptyView(40),
MyDivider(ScreenUtil().setWidth(2),
ScreenUtil().setWidth(40),
color: MyColours.color_F1F0F4),
],
);
} else {
return AreaItemTable(
model.areas[index - 1],
tableManagerModel.currentArea,
(area) {
setState(() {
isSelected = false;
_selectNumber = index - 1;
tableManagerModel.currentArea =
tableManagerModel
.areas[index - 1].name;
tableManagerModel.currentTables =
tableManagerModel
.areaTableMapShow[
tableManagerModel
.currentArea];
// _anmationMenu();
});
});
}
}
},
)),
InkWell(
onTap: () {
setState(() {
model.swichState = !model.swichState;
if (model.swichState) {
model.areaTableMapShow =
tableManagerModel
.areaTableMapCanNote;
model.tablesShow =
tableManagerModel.tablesCanNote;
} else {
model.areaTableMapShow =
model.areaTableMap;
model.tablesShow = model.tablesAll;
}
});
},
child: Container(
margin: EdgeInsets.only(
top: ScreenUtil().setWidth(20),
),
child: Row(
children: [
MyDivider(ScreenUtil().setWidth(15),
ScreenUtil().setWidth(80),
color: MyColours.color_F1F0F4),
MyDivider(ScreenUtil().setWidth(2),
ScreenUtil().setWidth(80),
color: MyColours.color_9C9C9C),
HEmptyView(30),
Image.asset(
model.swichState
? Utils.getImgPath(
'f_swich_on')
: Utils.getImgPath(
'f_swich_off'),
width: ScreenUtil().setWidth(90),
// height: ScreenUtil().setWidth(82),
),
HEmptyView(20),
Text(
'仅看\n空座',
style: TextStyle(
fontSize:
ScreenUtil().setSp(30),
color: MyColours.color_333333,
),
),
HEmptyView(40)
],
)),
)
],
),
),
)
],
);
// return CCMenuPage.builder(
// tableManagerModel: tableManagerModel,
// itemCount: tableManagerModel.areas.length,
// onTap: (index) async {},
// tabBuilder: (BuildContext context, int index) {
// if (index == tableManagerModel.areas.length ||
// tableManagerModel.areas.length == 0) {
// return Column(
// children: [
// VEmptyView(20),
// DottedBorder(
// dashPattern: [5, 5, 5, 5],
// borderType: BorderType.RRect,
// radius:
// Radius.circular(ScreenUtil().setWidth(10)),
// // padding: EdgeInsets.all(ScreenUtil().setWidth(70)),
// color: MyColours.color_199095,
// strokeWidth: ScreenUtil().setWidth(2),
// child: ClipRRect(
// borderRadius: BorderRadius.all(
// Radius.circular(
// ScreenUtil().setWidth(10))),
// child: Container(
// height: ScreenUtil().setWidth(25 * 2),
// width: ScreenUtil().setWidth(104 * 2),
// child: Column(
// mainAxisAlignment:
// MainAxisAlignment.center,
// children: [
// Image.asset(
// Utils.getImgPath('add_area'),
// width: ScreenUtil().setWidth(24)),
// ],
// ),
// ),
// ),
// )
// ],
// );
// } else {
// return AreaItemTable(model.areas[index],
// tableManagerModel.currentArea, (area) {});
// }
// },
// itemBuilder: (BuildContext context, int index) {
// return item(index);
// },
// );
}
},
),
Expanded(
child: Container(
color: Color.fromRGBO(249, 249, 249, 1),
child: item(_selectNumber))),
]))
// return CCMenuPage.builder(
// tableManagerModel: tableManagerModel,
// itemCount: tableManagerModel.areas.length,
// onTap: (index) async {},
// tabBuilder: (BuildContext context, int index) {
// if (index == tableManagerModel.areas.length ||
// tableManagerModel.areas.length == 0) {
// return Column(
// children: [
// VEmptyView(20),
// DottedBorder(
// dashPattern: [5, 5, 5, 5],
// borderType: BorderType.RRect,
// radius:
// Radius.circular(ScreenUtil().setWidth(10)),
// // padding: EdgeInsets.all(ScreenUtil().setWidth(70)),
// color: MyColours.color_199095,
// strokeWidth: ScreenUtil().setWidth(2),
// child: ClipRRect(
// borderRadius: BorderRadius.all(
// Radius.circular(
// ScreenUtil().setWidth(10))),
// child: Container(
// height: ScreenUtil().setWidth(25 * 2),
// width: ScreenUtil().setWidth(104 * 2),
// child: Column(
// mainAxisAlignment:
// MainAxisAlignment.center,
// children: [
// Image.asset(
// Utils.getImgPath('add_area'),
// width: ScreenUtil().setWidth(24)),
// ],
// ),
// ),
// ),
// )
// ],
// );
// } else {
// return AreaItemTable(model.areas[index],
// tableManagerModel.currentArea, (area) {});
// }
// },
// itemBuilder: (BuildContext context, int index) {
// return item(index);
// },
// );
],
);
},
... ...
... ... @@ -576,15 +576,15 @@ class NotebookDetailChangeModel with ChangeNotifier {
///录入更改内部预订
Future<SunReserveInfoModel> setReserveInfo(BuildContext context) async {
UserModel userModel = Provider.of<UserModel>(context, listen: false);
String pnum = '6';
String pnum = '';
for (var item in personNumList) {
if (item['isSelect']) {
pnum = item['dateText'];
}
}
if (pnum == '') {
pnum = '6';
}
// if (pnum == '') {
// pnum = '6';
// }
String sex = '1';
for (var item in sexList) {
if (item['select']) {
... ...
... ... @@ -26,7 +26,11 @@ class TableManagerModel with ChangeNotifier {
List<TableOuter> tableOuterList = []; //区域-桌位列表
Map<String, List<t.Table>> areaTableMap = {}; //区域-桌位Map
Map<String, List<t.Table>> areaTableMap = {}; //区域-桌位Map 已预订和空桌子
Map<String, List<t.Table>> areaTableMapCanNote =
{}; //区域-桌位Map 筛选出已经预订的桌子,剩余空桌子
Map<String, List<t.Table>> areaTableMapShow; ////区域-桌位Map 页面展示用(全部或者只看空桌子)
List<t.Table> currentTables = []; //当前显示的区域-桌位
Map<String, Notebook> tableMap = {}; //记录已预订桌位对应的订单
... ... @@ -34,6 +38,10 @@ class TableManagerModel with ChangeNotifier {
String currentArea; //当前选中区域
int selectIndex = 0;
List<t.Table> tablesAll = []; //全部桌子(已预订和空桌子)
List<t.Table> tablesCanNote = []; //全部桌子(空桌子)
List<t.Table> tablesShow = []; //页面展示
DateTime dateTime = DateTime.now();
String dateText = ""; //当前显示日期时间
... ... @@ -46,6 +54,7 @@ class TableManagerModel with ChangeNotifier {
PageState pageState = PageState.Loading;
Map dailyMap = {}; // 早市对应半点钟,午市对应半点钟、晚市对应半点钟
bool swichState = false; //仅看空座
//初始化时间
initTime(BuildContext context) async {
... ... @@ -267,12 +276,14 @@ class TableManagerModel with ChangeNotifier {
notifyListeners();
return [];
}
tablesAll = [];
tableOuterList = (baseResp.data[0] as List).map((value) {
TableOuter tableOuter = TableOuter();
tableOuter.name = value["name"];
tableOuter.list = (value["list"] as List).map((table) {
return t.Table.fromJson(table as Map<String, dynamic>);
}).toList();
tablesAll.addAll(tableOuter.list);
return tableOuter;
}).toList();
}
... ... @@ -405,8 +416,14 @@ class TableManagerModel with ChangeNotifier {
initData({bool needKeep = false}) {
areas.clear();
areaTableMap.clear();
List<t.Table> tempTableAll = [];
tempTableAll.addAll(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.sign = "";
table.notebookId = "";
... ... @@ -418,6 +435,13 @@ class TableManagerModel with ChangeNotifier {
table.sign = notebook.status;
table.notebookId = notebook.id;
table.reserver = notebook.rnameStr;
table.pnum = notebook.pnum;
table.noteName = notebook.note_name;
//剔除已经预订的桌子,剩下空桌子(仅看空座)
tempList.remove(table);
//全部
tempTableAll.remove(table);
} else {
table.sign = "";
table.notebookId = "";
... ... @@ -432,16 +456,28 @@ class TableManagerModel with ChangeNotifier {
}
}
areaTableMap["${outer.name}"] = outer.list;
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);
}
tablesCanNote = tempTableAll;
if (swichState) {
areaTableMapShow = areaTableMapCanNote;
tablesShow = tablesCanNote;
} else {
areaTableMapShow = areaTableMap;
tablesShow = tablesAll;
}
if (areaTableMap.isNotEmpty) {
if (!needKeep) {
currentArea = areaTableMap.keys.first;
currentTables = areaTableMap[currentArea];
// currentArea = areaTableMap.keys.first;
// currentTables = areaTableMap[currentArea];
currentArea = '全部';
currentTables = tablesAll;
pageState = PageState.Success;
}
} else {
... ... @@ -478,9 +514,7 @@ class TableManagerModel with ChangeNotifier {
date += ymd;
date += " 星期${Utils.formatWeekDayNum(day.weekday)}";
LunarCalendar lunarCalendar = LunarCalendar(day);
String time =
'${lunarCalendar.getChinaMonthString()}月${LunarCalendar.getChinaDayString(lunarCalendar.day)}';
String time = Utils.lunarCalendarHolidays(day);
date += ' ${time}';
return date;
}
... ...
... ... @@ -34,6 +34,15 @@ typedef CustomCallBackMap = void Function(Map<String, String> object);
typedef ClickCallback = void Function(String value);
// Example holidays
// final Map<DateTime, List> _holidays = {
// DateTime(2021, 1, 1): ['元旦节'],
// DateTime(2021, 1, 6): ['Epiphany'],
// DateTime(2021, 2, 14): ['Valentine\'s Day'],
// DateTime(2021, 4, 21): ['Easter Sunday'],
// DateTime(2021, 4, 22): ['Easter Monday'],
// };
class DialogUtil {
///添加图片UI弹出
static openImageModalBottomSheet(context,
... ... @@ -1118,6 +1127,7 @@ class DialogUtil {
onDaySelected: (day, events, holidays) {
Navigator.of(dialogContext).pop(day);
},
// holidays: _holidays,
availableGestures: AvailableGestures.none,
events: _events,
locale: "zh_CN",
... ...
... ... @@ -15,6 +15,7 @@ import 'package:fluwx/fluwx.dart';
import 'package:one_key/pages/login/web_page.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/utils/dialog_util.dart';
import 'package:one_key/utils/lunar_calendar.dart';
import 'package:one_key/utils/misc.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/widgets/loading.dart';
... ... @@ -29,6 +30,78 @@ import '../app.dart';
typedef BookTimeSetCallback = void Function(bool needChange);
class Utils {
static String lunarCalendarUtils(DateTime day) {
LunarCalendar lunarCalendar = LunarCalendar(day);
String time =
'${lunarCalendar.getChinaMonthString()}月${LunarCalendar.getChinaDayString(lunarCalendar.day)}';
return time;
}
//农历节日 *表示放假日
static String lunarCalendarHolidays(DateTime day) {
LunarCalendar lunarCalendar = LunarCalendar(day);
//阴历月-日
String keyLunar =
addZeroNumber(lunarCalendar.month) + addZeroNumber(lunarCalendar.day);
//阳历月-日
String keySolar =
Utils.addZeroNumber(day.month) + Utils.addZeroNumber(day.day);
Map<String, String> holiday1 = {
"0101": "春节",
"0102": "大年初二",
"0103": "大年初三",
"0104": "大年初四",
"0105": "大年初五",
"0106": "大年初六",
"0107": "大年初七",
"0115": "元宵节",
"0505": "端午节",
"0707": "七夕情人节",
"0815": "中秋节",
"0909": "重阳节",
"1208": "腊八节",
"1223": "过小年",
"0100": "除夕"
};
Map<String, String> holiday2 = {
"0101": '元旦',
"0214": "情人节",
"0308": "妇女节",
"0501": "劳动节",
"0504": "青年节",
"0601": "国际儿童节",
"0801": "八一建军节",
"0910": "教师节",
"1001": "国庆节",
"1224": "平安夜",
"1225": "圣诞节",
};
if (holiday1.containsKey(keyLunar)) {
return holiday1[keyLunar];
}
if (holiday2.containsKey(keySolar)) {
return holiday2[keySolar];
}
return lunarCalendarUtils(day);
}
//国历节日 *表示放假日
static String solarCalendarHolidays(DateTime day) {
Map<String, String> holiday1 = {
"0101": '元旦',
"0214": "情人节",
"0308": "妇女节",
"0501": "劳动节",
"0504": "青年节",
"0601": "国际儿童节",
"0801": "八一建军节",
"0910": "教师节",
"1001": "国庆节",
"1224": "平安夜",
"1225": "圣诞节",
};
}
static String starPhone(phone) {
return phone.replaceFirst(new RegExp(r'\d{4}'), '****', 3);
}
... ...
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 FTableItem 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;
FTableItem(this.table,
{this.onSelected,
this.canSelected = false,
this.height = 185,
this.fromPage = 'new',
this.rid,
this.tableMap,
this.need = true});
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return new FTableItemState();
}
}
class FTableItemState extends State<FTableItem> {
@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 = '已买单';
}
}
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(() {
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') {
table.selected = !(table.selected ?? false);
widget.onSelected(table);
} else if (widget.fromPage == 'tablePhoto') {
// setState(() {
// table.selected = true;
// });
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 == '已预订'
? Color.fromRGBO(154, 23, 45, 1)
: MyColours.color_ffffff,
border: Border.all(
width: ScreenUtil().setWidth(2),
color: MyColours.color_E0E0E0),
borderRadius: BorderRadius.all(
Radius.circular(ScreenUtil().setWidth(20)))),
child: Stack(
// alignment: Alignment.center,
children: <Widget>[
Container(
alignment: Alignment.center,
// 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 == '已预订'
? SizedBox()
: VEmptyView(10),
Container(
alignment: Alignment.center,
child: Text(
table.name,
maxLines: 1,
style: TextStyle(
color: widget.need && signStr == '已预订'
? MyColours.color_ffffff
: MyColours.color_333333,
fontSize: ScreenUtil().setSp(36),
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.isEmpty)
? table.tableNum
: table.reserver) !=
''
? VEmptyView(8)
: SizedBox(),
Text(
(table.reserver == null || table.reserver.isEmpty)
? table.tableNum
: '${table.reserver}' +
(table.pnum != '' && table.pnum != '0'
? '(${table.pnum}人)'
: ''),
style: TextStyle(
color: signStr == '已预订'
? MyColours.color_ffffff
: MyColours.color_353535,
fontSize: ScreenUtil().setSp(22),
decoration: TextDecoration.none,
fontWeight: FontWeight.normal),
overflow: TextOverflow.ellipsis,
),
widget.need && signStr == '已预订'
? Padding(
padding: EdgeInsets.only(
top: ScreenUtil().setWidth(6),
bottom: ScreenUtil().setWidth(10),
),
child: Text(
'${table.noteName}订',
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(22),
decoration: TextDecoration.none,
fontWeight: FontWeight.normal),
overflow: TextOverflow.ellipsis,
),
)
: SizedBox(),
signStr == '已预订'
? Container(
// width: ScreenUtil().setWidth(160),
height: ScreenUtil().setWidth(34),
alignment: Alignment.centerLeft,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(10)),
decoration: BoxDecoration(
color: Color.fromRGBO(232, 141, 164, 1),
),
child: Text(
'新客',
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(24),
decoration: TextDecoration.none,
fontWeight: FontWeight.normal),
),
)
: 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 == '已预订'
? 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: Color.fromRGBO(239, 239, 239, 1),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(
ScreenUtil().setWidth(20)),
// topRight:
// Radius.circular(ScreenUtil().setWidth(8)),
// bottomRight: Radius.circular(
// ScreenUtil().setWidth(8))
)),
child: Text(table.tidStr,
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(20),
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 == '已预订'
? SizedBox()
: Positioned(
left: ScreenUtil().setWidth(18),
bottom: ScreenUtil().setWidth(12),
child: table.isPhoto != 1
? Image.asset(
"assets/f_camera.png",
width: ScreenUtil().setWidth(22),
height: ScreenUtil().setWidth(22),
)
: Container())
],
),
);
}
}
... ...