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 { @@ -25,6 +25,8 @@ class Table {
25 String notebookId; //桌位对应的预订id 25 String notebookId; //桌位对应的预订id
26 bool selected; //是否选中 26 bool selected; //是否选中
27 int isPhoto; //桌位是否有照片 27 int isPhoto; //桌位是否有照片
  28 + String pnum; //预计人数
  29 + String noteName; //操作人
28 30
29 //获取桌位类型 31 //获取桌位类型
30 String get tidStr { 32 String get tidStr {
@@ -24,80 +24,78 @@ class AreaItemTableState extends State<AreaItemTable> { @@ -24,80 +24,78 @@ class AreaItemTableState extends State<AreaItemTable> {
24 // TODO: implement build 24 // TODO: implement build
25 Area area = widget.area; 25 Area area = widget.area;
26 bool isSelected = area.name == widget.currentArea; 26 bool isSelected = area.name == widget.currentArea;
27 - return  
28 - // GestureDetector(  
29 -  
30 - // onTap: () {  
31 - // if (widget.selectCallback != null) {  
32 - // widget.selectCallback(widget.area);  
33 - // }  
34 - // },  
35 - // child:  
36 - Stack(  
37 - overflow: Overflow.visible,  
38 - alignment: Alignment.topLeft,  
39 - children: <Widget>[  
40 - Container(  
41 - width: ScreenUtil().setWidth(104 * 2),  
42 - height: ScreenUtil().setWidth(80),  
43 - margin: EdgeInsets.only(  
44 - right: ScreenUtil().setWidth(20),  
45 - top: ScreenUtil().setWidth(20),  
46 - ),  
47 - padding: EdgeInsets.symmetric(  
48 - horizontal: ScreenUtil().setWidth(20),  
49 - vertical: ScreenUtil().setWidth(10)),  
50 - alignment: Alignment.center,  
51 - decoration: BoxDecoration(  
52 - // borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10)),  
53 - color:  
54 - isSelected ? MyColours.color_199095 : MyColours.color_ffffff,  
55 - border: Border.all(  
56 - color: MyColours.color_E0E0E0,  
57 - width: ScreenUtil().setWidth(2))),  
58 - child: Text(  
59 - area.name,  
60 - overflow: TextOverflow.ellipsis,  
61 - style: TextStyle(  
62 - color: isSelected  
63 - ? MyColours.color_ffffff  
64 - : MyColours.color_333333,  
65 - fontSize: ScreenUtil().setSp(28),  
66 - decoration: TextDecoration.none,  
67 - fontWeight: FontWeight.normal),  
68 - ),  
69 - ),  
70 - area.count == -1  
71 - ? Container()  
72 - : Positioned(  
73 - right: ScreenUtil().setWidth(12),  
74 - top: ScreenUtil().setWidth(6),  
75 - child: Container(  
76 - padding: EdgeInsets.symmetric(  
77 - vertical: ScreenUtil().setWidth(6),  
78 - horizontal: ScreenUtil().setWidth(4)),  
79 - // width: ScreenUtil().setWidth(78),  
80 - // height: ScreenUtil().setWidth(30),  
81 - alignment: Alignment.center,  
82 - decoration: BoxDecoration(  
83 - color: area.count <= 0  
84 - ? MyColours.color_999999  
85 - : MyColours.color_199095,  
86 - // borderRadius: BorderRadius.only(  
87 - // topLeft: Radius.circular(ScreenUtil().setWidth(10)),  
88 - // topRight: Radius.circular(ScreenUtil().setWidth(15)),  
89 - // bottomRight:  
90 - // Radius.circular(ScreenUtil().setWidth(15)))  
91 - ),  
92 - child: Text(area.count == 0 ? "满座" : "${area.count}",  
93 - style: TextStyle(  
94 - color: MyColours.color_ffffff,  
95 - fontSize: ScreenUtil().setSp(26),  
96 - decoration: TextDecoration.none,  
97 - fontWeight: FontWeight.normal)),  
98 - ), 27 + return GestureDetector(
  28 + onTap: () {
  29 + if (widget.selectCallback != null) {
  30 + widget.selectCallback(widget.area);
  31 + }
  32 + },
  33 + child: Stack(
  34 + overflow: Overflow.visible,
  35 + alignment: Alignment.topLeft,
  36 + children: <Widget>[
  37 + Container(
  38 + width: ScreenUtil().setWidth(104 * 2),
  39 + height: ScreenUtil().setWidth(80),
  40 + margin: EdgeInsets.only(
  41 + right: ScreenUtil().setWidth(20),
  42 + top: ScreenUtil().setWidth(20),
99 ), 43 ),
100 - ],  
101 - ); 44 + padding: EdgeInsets.symmetric(
  45 + horizontal: ScreenUtil().setWidth(20),
  46 + vertical: ScreenUtil().setWidth(10)),
  47 + alignment: Alignment.center,
  48 + decoration: BoxDecoration(
  49 + // borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10)),
  50 + color: isSelected
  51 + ? MyColours.color_199095
  52 + : MyColours.color_ffffff,
  53 + border: Border.all(
  54 + color: MyColours.color_E0E0E0,
  55 + width: ScreenUtil().setWidth(2))),
  56 + child: Text(
  57 + area.name,
  58 + overflow: TextOverflow.ellipsis,
  59 + style: TextStyle(
  60 + color: isSelected
  61 + ? MyColours.color_ffffff
  62 + : MyColours.color_333333,
  63 + fontSize: ScreenUtil().setSp(28),
  64 + decoration: TextDecoration.none,
  65 + fontWeight: FontWeight.normal),
  66 + ),
  67 + ),
  68 + area.count == -1
  69 + ? Container()
  70 + : Positioned(
  71 + right: ScreenUtil().setWidth(12),
  72 + top: ScreenUtil().setWidth(6),
  73 + child: Container(
  74 + padding: EdgeInsets.symmetric(
  75 + vertical: ScreenUtil().setWidth(6),
  76 + horizontal: ScreenUtil().setWidth(4)),
  77 + // width: ScreenUtil().setWidth(78),
  78 + // height: ScreenUtil().setWidth(30),
  79 + alignment: Alignment.center,
  80 + decoration: BoxDecoration(
  81 + color: area.count <= 0
  82 + ? MyColours.color_999999
  83 + : MyColours.color_199095,
  84 + // borderRadius: BorderRadius.only(
  85 + // topLeft: Radius.circular(ScreenUtil().setWidth(10)),
  86 + // topRight: Radius.circular(ScreenUtil().setWidth(15)),
  87 + // bottomRight:
  88 + // Radius.circular(ScreenUtil().setWidth(15)))
  89 + ),
  90 + child: Text(area.count == 0 ? "满座" : "${area.count}",
  91 + style: TextStyle(
  92 + color: MyColours.color_ffffff,
  93 + fontSize: ScreenUtil().setSp(26),
  94 + decoration: TextDecoration.none,
  95 + fontWeight: FontWeight.normal)),
  96 + ),
  97 + ),
  98 + ],
  99 + ));
102 } 100 }
103 } 101 }
@@ -21,6 +21,7 @@ import 'package:one_key/widgets/app_bar.dart'; @@ -21,6 +21,7 @@ import 'package:one_key/widgets/app_bar.dart';
21 import 'package:one_key/widgets/area_item.dart'; 21 import 'package:one_key/widgets/area_item.dart';
22 import 'package:one_key/widgets/common_button.dart'; 22 import 'package:one_key/widgets/common_button.dart';
23 import 'package:one_key/widgets/common_button_flat.dart'; 23 import 'package:one_key/widgets/common_button_flat.dart';
  24 +import 'package:one_key/widgets/f_table_item.dart';
24 import 'package:one_key/widgets/h_empty_view.dart'; 25 import 'package:one_key/widgets/h_empty_view.dart';
25 import 'package:one_key/widgets/page_exception.dart'; 26 import 'package:one_key/widgets/page_exception.dart';
26 import 'package:one_key/widgets/system_app_bar.dart'; 27 import 'package:one_key/widgets/system_app_bar.dart';
@@ -51,6 +52,9 @@ class TableManagerPageState extends State<TableManagerPage> { @@ -51,6 +52,9 @@ class TableManagerPageState extends State<TableManagerPage> {
51 int _selectIndex = 0; 52 int _selectIndex = 0;
52 ScrollController _areaController = ScrollController(); 53 ScrollController _areaController = ScrollController();
53 List<String> personNumList = []; 54 List<String> personNumList = [];
  55 + bool isSelected = true; //全部按钮
  56 +
  57 + int _selectNumber;
54 58
55 final ItemPositionsListener itemPositionsListener = 59 final ItemPositionsListener itemPositionsListener =
56 ItemPositionsListener.create(); 60 ItemPositionsListener.create();
@@ -59,13 +63,14 @@ class TableManagerPageState extends State<TableManagerPage> { @@ -59,13 +63,14 @@ class TableManagerPageState extends State<TableManagerPage> {
59 void initState() { 63 void initState() {
60 // TODO: implement initState 64 // TODO: implement initState
61 super.initState(); 65 super.initState();
  66 +
62 LogUtil.v("table_manager_page initState"); 67 LogUtil.v("table_manager_page initState");
63 for (int i = 1; i < 31; i++) { 68 for (int i = 1; i < 31; i++) {
64 personNumList.add(i.toString()); 69 personNumList.add(i.toString());
65 } 70 }
66 71
67 // personNumList.add('30以上'); 72 // personNumList.add('30以上');
68 - tableManagerModel = Provider.of<TableManagerModel>(context, listen: false); 73 +
69 WidgetsBinding.instance.addPostFrameCallback((_) { 74 WidgetsBinding.instance.addPostFrameCallback((_) {
70 tableManagerModel.initTime(context); 75 tableManagerModel.initTime(context);
71 EventBus().on("refresh_tablemanager", (arg) { 76 EventBus().on("refresh_tablemanager", (arg) {
@@ -121,225 +126,210 @@ class TableManagerPageState extends State<TableManagerPage> { @@ -121,225 +126,210 @@ class TableManagerPageState extends State<TableManagerPage> {
121 126
122 /// Generate item number [i]. 127 /// Generate item number [i].
123 Widget item(int i) { 128 Widget item(int i) {
124 - return SingleChildScrollView(  
125 - child: Column(  
126 - children: [  
127 - VEmptyView(40),  
128 - Container(  
129 - alignment: Alignment.center,  
130 - height: ScreenUtil().setWidth(21 * 2),  
131 - child: Text(tableManagerModel.areas[i].name,  
132 - style: TextStyle(  
133 - fontSize: ScreenUtil().setWidth(30),  
134 - color: MyColours.color_199095)),  
135 - ),  
136 - VEmptyView(30),  
137 - GridView.builder(  
138 - // controller: _areaController,  
139 - physics: NeverScrollableScrollPhysics(),  
140 - padding: EdgeInsets.only(top: 0),  
141 - shrinkWrap: true,  
142 - itemCount: tableManagerModel  
143 - .areaTableMap[tableManagerModel.areas[i].name].length + 129 + return GridView.builder(
  130 + // controller: _areaController,
  131 + // physics: NeverScrollableScrollPhysics(),
  132 + padding: EdgeInsets.symmetric(
  133 + vertical: ScreenUtil().setWidth(20),
  134 + horizontal: ScreenUtil().setWidth(10)),
  135 + shrinkWrap: true,
  136 + itemCount: tableManagerModel.currentArea == '全部'
  137 + ? tableManagerModel.tablesShow.length
  138 + : tableManagerModel
  139 + .areaTableMapShow[tableManagerModel.areas[i].name].length +
144 1, 140 1,
145 - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(  
146 - crossAxisCount: 4,  
147 - childAspectRatio: 8 / 9,  
148 - ),  
149 - // mainAxisSpacing: ScreenUtil().setWidth(15 * 2),  
150 - // crossAxisSpacing: ScreenUtil().setWidth(38 * 2)),  
151 - itemBuilder: (BuildContext context, int index) {  
152 - if (index ==  
153 - tableManagerModel  
154 - .areaTableMap[tableManagerModel.areas[i].name].length ||  
155 - tableManagerModel  
156 - .areaTableMap[tableManagerModel.areas[i].name].length ==  
157 - 0) {  
158 - return InkWell(  
159 - onTap: () async {  
160 - List<String> areas = [];  
161 - for (int i = 0; i < tableManagerModel.areas.length; i++) {  
162 - areas.add(tableManagerModel.areas[i].name);  
163 - } 141 + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  142 + crossAxisCount: 4,
  143 + childAspectRatio: 1,
  144 + mainAxisSpacing: ScreenUtil().setWidth(30),
  145 + crossAxisSpacing: ScreenUtil().setWidth(12),
  146 + ),
164 147
165 - //添加桌位弹框  
166 - await DialogUtil.openCreateTableDialog(  
167 - context, areas, i, personNumList,  
168 - onTap: (Map<String, String> value) async {  
169 - print(value);  
170 - // 'areaname':  
171 - // areas[currentAreaIndex],  
172 - // 'name': controller.text,  
173 - // 'pnumMin': pnumMin,  
174 - // 'pnumMax': pnumMax  
175 - //添加桌位 接口参数带整合???  
176 - // 以下是旧的不去,明天添加桌位接口  
177 - String rid;  
178 - for (Area item in tableManagerModel.areas) {  
179 - if (item.name == value['areaname']) {  
180 - rid = item.rid;  
181 - }  
182 - }  
183 - Map<String, String> params = {  
184 - 'rid': rid,  
185 - 'name': value['name'],  
186 - };  
187 - if (value['pnumMin'] != '') {  
188 - params['pnum'] = value['pnumMin'];  
189 - }  
190 - if (value['pnumMax'] != '') {  
191 - params['most_pnum'] = value['pnumMax'];  
192 - }  
193 - bool success =  
194 - await tableManagerModel.addTable(context, params);  
195 - print(success);  
196 - if (success) {  
197 - Utils.showToast('添加成功!');  
198 - // TableOuter tableOuter = TableOuter();  
199 - // tableOuter.name = value;  
200 - // tableOuter.list = [];  
201 - // tableManagerModel.tableOuterList.add(tableOuter);  
202 - // tableManagerModel.initData();  
203 - // Timer(  
204 - // Duration(milliseconds: 500),  
205 - // () => _areaController.jumpTo(  
206 - // _areaController.position.maxScrollExtent)); 148 + itemBuilder: (BuildContext context, int index) {
  149 + List<t.Table> data = tableManagerModel.currentArea == '全部'
  150 + ? tableManagerModel.tablesShow
  151 + : tableManagerModel
  152 + .areaTableMapShow[tableManagerModel.areas[i].name];
  153 + if (index == data.length || data.length == 0) {
  154 + return InkWell(
  155 + onTap: () async {
  156 + List<String> areas = [];
  157 + for (int i = 0; i < tableManagerModel.areas.length; i++) {
  158 + areas.add(tableManagerModel.areas[i].name);
  159 + }
207 160
208 - // await tableManagerModel  
209 - // .getTableList(context);  
210 - // await tableManagerModel  
211 - // .initData();  
212 - tableManagerModel.refreshTable(context);  
213 - }  
214 - });  
215 - },  
216 - child: Container(  
217 - margin: EdgeInsets.all(ScreenUtil().setWidth(9)),  
218 - child: DottedBorder(  
219 - dashPattern: [5, 5, 5, 5],  
220 - borderType: BorderType.RRect,  
221 - radius: Radius.circular(ScreenUtil().setWidth(10)),  
222 - // padding: EdgeInsets.all(ScreenUtil().setWidth(70)),  
223 - color: MyColours.color_199095,  
224 - strokeWidth: ScreenUtil().setWidth(2),  
225 - child: ClipRRect(  
226 - borderRadius: BorderRadius.all(  
227 - Radius.circular(ScreenUtil().setWidth(10))),  
228 - child: Container(  
229 - height: ScreenUtil().setWidth(90 * 2),  
230 - width: ScreenUtil().setWidth(80 * 2),  
231 - child: Column(  
232 - mainAxisAlignment: MainAxisAlignment.center,  
233 - children: [  
234 - Image.asset(Utils.getImgPath('add_area'),  
235 - width: ScreenUtil().setWidth(32)),  
236 - ],  
237 - ),  
238 - ),  
239 - ),  
240 - )));  
241 - } else {  
242 - return Selector<TableManagerModel, t.Table>(  
243 - shouldRebuild: (pre, next) => true,  
244 - selector: (context, model) => tableManagerModel  
245 - .areaTableMap[tableManagerModel.areas[i].name][index],  
246 - builder: (context, table, _) {  
247 - return TableItem(table, onSelected: (table) {  
248 - if ((table as t.Table).selected) {  
249 - tableManagerModel.selectTables.add(table);  
250 - } else {  
251 - tableManagerModel.selectTables  
252 - .removeWhere((t) => t.id == table.id); 161 + //添加桌位弹框
  162 + await DialogUtil.openCreateTableDialog(
  163 + context, areas, i, personNumList,
  164 + onTap: (Map<String, String> value) async {
  165 + print(value);
  166 + // 'areaname':
  167 + // areas[currentAreaIndex],
  168 + // 'name': controller.text,
  169 + // 'pnumMin': pnumMin,
  170 + // 'pnumMax': pnumMax
  171 + //添加桌位 接口参数带整合???
  172 + // 以下是旧的不去,明天添加桌位接口
  173 + String rid;
  174 + for (Area item in tableManagerModel.areas) {
  175 + if (item.name == value['areaname']) {
  176 + rid = item.rid;
253 } 177 }
254 - DialogUtil.showTableManagerDialog(context, table)  
255 - .then((value) {  
256 - if (value != null) {  
257 - switch (value) {  
258 - case 1: //查看详情  
259 - NavigatorUtil.goNotebookDetailPage(  
260 - context,  
261 - tableManagerModel.tableMap[table.id].id,  
262 - tableManagerModel.tableMap[table.id].uid);  
263 - break;  
264 - case 2: //订座  
265 - NavigatorUtil.goNoteBookChangePage(  
266 - context,  
267 - NotebookDetail.fromTableManager(  
268 - tableManagerModel.getCurrDdateStr(),  
269 - tableManagerModel.currTimeIndex.toString(),  
270 - table),  
271 - "");  
272 - break; 178 + }
  179 + Map<String, String> params = {
  180 + 'rid': rid,
  181 + 'name': value['name'],
  182 + };
  183 + if (value['pnumMin'] != '') {
  184 + params['pnum'] = value['pnumMin'];
  185 + }
  186 + if (value['pnumMax'] != '') {
  187 + params['most_pnum'] = value['pnumMax'];
  188 + }
  189 + bool success =
  190 + await tableManagerModel.addTable(context, params);
  191 + print(success);
  192 + if (success) {
  193 + Utils.showToast('添加成功!');
  194 + // TableOuter tableOuter = TableOuter();
  195 + // tableOuter.name = value;
  196 + // tableOuter.list = [];
  197 + // tableManagerModel.tableOuterList.add(tableOuter);
  198 + // tableManagerModel.initData();
  199 + // Timer(
  200 + // Duration(milliseconds: 500),
  201 + // () => _areaController.jumpTo(
  202 + // _areaController.position.maxScrollExtent));
273 203
274 - case 3: //停用,启用桌位  
275 - Map<String, String> params = {  
276 - "id": (table as t.Table).id,  
277 - "status":  
278 - (table as t.Table).enable == "1" ? "0" : "1"  
279 - };  
280 - tableManagerModel  
281 - .setSwitchStatus(context, params)  
282 - .then((value) {  
283 - if (value != null) {  
284 - (table as t.Table).enable =  
285 - ((int.parse((table as t.Table).enable) +  
286 - 1) %  
287 - 2)  
288 - .toString();  
289 - if ((table as t.Table).enable == "1") {  
290 - for (Area area in tableManagerModel.areas) {  
291 - if (area.name ==  
292 - tableManagerModel.currentArea) {  
293 - if (table.sign != '5' &&  
294 - table.sign != '1') {  
295 - //已预订  
296 - area.count++;  
297 - }  
298 - break;  
299 - } 204 + // await tableManagerModel
  205 + // .getTableList(context);
  206 + // await tableManagerModel
  207 + // .initData();
  208 + tableManagerModel.refreshTable(context);
  209 + }
  210 + });
  211 + },
  212 + child: Container(
  213 + child: DottedBorder(
  214 + dashPattern: [5, 5, 5, 5],
  215 + borderType: BorderType.RRect,
  216 + radius: Radius.circular(ScreenUtil().setWidth(20)),
  217 + // padding: EdgeInsets.all(ScreenUtil().setWidth(70)),
  218 + color: MyColours.color_E0E0E0,
  219 + strokeWidth: ScreenUtil().setWidth(2),
  220 + child: ClipRRect(
  221 + borderRadius: BorderRadius.all(
  222 + Radius.circular(ScreenUtil().setWidth(20))),
  223 + child: Container(
  224 + height: ScreenUtil.screenWidthDp -
  225 + ScreenUtil().setWidth(12 * 3 - 10 * 2),
  226 + width: ScreenUtil.screenWidthDp -
  227 + ScreenUtil().setWidth(12 * 3 - 10 * 2),
  228 + child: Column(
  229 + mainAxisAlignment: MainAxisAlignment.center,
  230 + children: [
  231 + Image.asset(Utils.getImgPath('add_store'),
  232 + width: ScreenUtil().setWidth(32)),
  233 + ],
  234 + ),
  235 + ),
  236 + ),
  237 + )));
  238 + } else {
  239 + return Selector<TableManagerModel, t.Table>(
  240 + shouldRebuild: (pre, next) => true,
  241 + selector: (context, model) => data[index],
  242 + builder: (context, table, _) {
  243 + return FTableItem(table, onSelected: (table) {
  244 + if ((table as t.Table).selected) {
  245 + tableManagerModel.selectTables.add(table);
  246 + } else {
  247 + tableManagerModel.selectTables
  248 + .removeWhere((t) => t.id == table.id);
  249 + }
  250 + DialogUtil.showTableManagerDialog(context, table).then((value) {
  251 + if (value != null) {
  252 + switch (value) {
  253 + case 1: //查看详情
  254 + NavigatorUtil.goNotebookDetailPage(
  255 + context,
  256 + tableManagerModel.tableMap[table.id].id,
  257 + tableManagerModel.tableMap[table.id].uid);
  258 + break;
  259 + case 2: //订座
  260 + NavigatorUtil.goNoteBookChangePage(
  261 + context,
  262 + NotebookDetail.fromTableManager(
  263 + tableManagerModel.getCurrDdateStr(),
  264 + tableManagerModel.currTimeIndex.toString(),
  265 + table),
  266 + "");
  267 + break;
  268 +
  269 + case 3: //停用,启用桌位
  270 + Map<String, String> params = {
  271 + "id": (table as t.Table).id,
  272 + "status": (table as t.Table).enable == "1" ? "0" : "1"
  273 + };
  274 + tableManagerModel
  275 + .setSwitchStatus(context, params)
  276 + .then((value) {
  277 + if (value != null) {
  278 + (table as t.Table).enable =
  279 + ((int.parse((table as t.Table).enable) + 1) % 2)
  280 + .toString();
  281 + if ((table as t.Table).enable == "1") {
  282 + for (Area area in tableManagerModel.areas) {
  283 + if (area.name ==
  284 + tableManagerModel.currentArea) {
  285 + if (table.sign != '5' && table.sign != '1') {
  286 + //已预订
  287 + area.count++;
300 } 288 }
301 - } else {  
302 - for (Area area in tableManagerModel.areas) {  
303 - if (area.name ==  
304 - tableManagerModel.currentArea) {  
305 - if (table.sign != '5' &&  
306 - table.sign != '1') {  
307 - //已预订  
308 - area.count--;  
309 - }  
310 - break;  
311 - } 289 + break;
  290 + }
  291 + }
  292 + } else {
  293 + for (Area area in tableManagerModel.areas) {
  294 + if (area.name ==
  295 + tableManagerModel.currentArea) {
  296 + if (table.sign != '5' && table.sign != '1') {
  297 + //已预订
  298 + area.count--;
312 } 299 }
  300 + break;
313 } 301 }
314 - tableManagerModel.notifyListeners();  
315 } 302 }
316 - });  
317 - break;  
318 - case 4: //照片管理  
319 - NavigatorUtil.goTablePhotoManagerPage(context,  
320 - tid: (table as t.Table).id,  
321 - tname: (table as t.Table).name);  
322 - break;  
323 - }  
324 - }  
325 - });  
326 - },  
327 - canSelected: false,  
328 - fromPage: 'table_manage',  
329 - tableMap: tableManagerModel.tableMap,  
330 - rid: "");  
331 - },  
332 - );  
333 - }  
334 - },  
335 - ),  
336 - ],  
337 - )); 303 + }
  304 + tableManagerModel.notifyListeners();
  305 + }
  306 + });
  307 + break;
  308 + case 4: //照片管理
  309 + NavigatorUtil.goTablePhotoManagerPage(context,
  310 + tid: (table as t.Table).id,
  311 + tname: (table as t.Table).name);
  312 + break;
  313 + }
  314 + }
  315 + });
  316 + },
  317 + canSelected: false,
  318 + fromPage: 'table_manage',
  319 + tableMap: tableManagerModel.tableMap,
  320 + rid: "");
  321 + },
  322 + );
  323 + }
  324 + },
  325 + );
338 } 326 }
339 327
340 @override 328 @override
341 Widget build(BuildContext context) { 329 Widget build(BuildContext context) {
  330 + tableManagerModel = Provider.of<TableManagerModel>(context, listen: true);
342 return Scaffold( 331 return Scaffold(
  332 + backgroundColor: MyColours.color_ffffff,
343 appBar: SystemAppBar("桌位", showLeading: false), 333 appBar: SystemAppBar("桌位", showLeading: false),
344 body: Consumer<TableManagerModel>( 334 body: Consumer<TableManagerModel>(
345 builder: (context, model, child) { 335 builder: (context, model, child) {
@@ -520,12 +510,11 @@ class TableManagerPageState extends State<TableManagerPage> { @@ -520,12 +510,11 @@ class TableManagerPageState extends State<TableManagerPage> {
520 ], 510 ],
521 ), 511 ),
522 ), 512 ),
523 - VEmptyView(40),  
524 - Consumer<TableManagerModel>(  
525 - builder: (context, model, child) {  
526 - if (model.pageState != PageState.Success) {  
527 - return Expanded(  
528 - child: ExceptionPage( 513 + VEmptyView(30),
  514 +
  515 + model.pageState != PageState.Success
  516 + ? Expanded(
  517 + child: ExceptionPage(
529 pageState: model.pageState, 518 pageState: model.pageState,
530 callback: () { 519 callback: () {
531 if (tableManagerModel.tableOuterList.isEmpty) { 520 if (tableManagerModel.tableOuterList.isEmpty) {
@@ -537,129 +526,293 @@ class TableManagerPageState extends State<TableManagerPage> { @@ -537,129 +526,293 @@ class TableManagerPageState extends State<TableManagerPage> {
537 emptyMsg: "暂时没有桌位哦", 526 emptyMsg: "暂时没有桌位哦",
538 emptyImg: "empty_search", 527 emptyImg: "empty_search",
539 showMsg: "加载中,请稍后...", 528 showMsg: "加载中,请稍后...",
540 - ));  
541 - } else {  
542 - return Column(  
543 - children: [  
544 - Container(  
545 - height: ScreenUtil().setWidth(100),  
546 - child: Row(  
547 - children: [  
548 - Expanded(  
549 - child: ListView.builder(  
550 - itemCount: tableManagerModel.areas.length + 1,  
551 - shrinkWrap: true,  
552 - scrollDirection: Axis.horizontal,  
553 - itemBuilder:  
554 - (BuildContext contxt, int index) {  
555 - if (index ==  
556 - tableManagerModel.areas.length ||  
557 - tableManagerModel.areas.length == 0) {  
558 - return Column(  
559 - children: [  
560 - VEmptyView(20),  
561 - DottedBorder(  
562 - dashPattern: [5, 5, 5, 5],  
563 - borderType: BorderType.RRect,  
564 - radius: Radius.circular(  
565 - ScreenUtil().setWidth(10)),  
566 - // padding: EdgeInsets.all(ScreenUtil().setWidth(70)),  
567 - color: MyColours.color_199095,  
568 - strokeWidth:  
569 - ScreenUtil().setWidth(2),  
570 - child: ClipRRect(  
571 - borderRadius: BorderRadius.all(  
572 - Radius.circular(ScreenUtil()  
573 - .setWidth(10))),  
574 - child: Container(  
575 - height: ScreenUtil()  
576 - .setWidth(25 * 2),  
577 - width: ScreenUtil()  
578 - .setWidth(104 * 2),  
579 - child: Column(  
580 - mainAxisAlignment:  
581 - MainAxisAlignment.center,  
582 - children: [  
583 - Image.asset(  
584 - Utils.getImgPath(  
585 - 'add_area'),  
586 - width: ScreenUtil()  
587 - .setWidth(24)),  
588 - ], 529 + ))
  530 + : Expanded(
  531 + child: Column(
  532 + // crossAxisAlignment: CrossAxisAlignment.center,
  533 + children: [
  534 + Container(
  535 + color: MyColours.color_ffffff,
  536 + height: ScreenUtil().setWidth(90),
  537 + margin: EdgeInsets.only(
  538 + bottom: ScreenUtil().setWidth(30)),
  539 + child: Row(
  540 + children: [
  541 + HEmptyView(20),
  542 + Expanded(
  543 + child: ListView.builder(
  544 + itemCount: tableManagerModel.areas.length ==
  545 + 0
  546 + ? 1
  547 + : tableManagerModel.areas.length + 2,
  548 + shrinkWrap: true,
  549 + scrollDirection: Axis.horizontal,
  550 + itemBuilder:
  551 + (BuildContext contxt, int index) {
  552 + if (index ==
  553 + tableManagerModel.areas.length +
  554 + 1 ||
  555 + tableManagerModel.areas.length == 0) {
  556 + return InkWell(
  557 + onTap: () async {
  558 + //添加区域弹框
  559 + await DialogUtil
  560 + .openCreateAreaDialog(context,
  561 + onTap: (value) async {
  562 + print(value);
  563 + //添加区域
  564 + bool success =
  565 + await tableManagerModel
  566 + .addTableAreas(
  567 + context, value);
  568 + print(success);
  569 + if (success) {
  570 + Utils.showToast('添加成功!');
  571 +
  572 + await tableManagerModel
  573 + .getTableList(context,
  574 + needLoading: false);
  575 + tableManagerModel.initData();
  576 +
  577 + // setState(() {
  578 + // updateMenu();
  579 + // });
  580 + // _scrollToIndex(widget
  581 + // .tableManagerModel
  582 + // .areas
  583 + // .length);
  584 +
  585 + }
  586 + });
  587 + },
  588 + child: Column(
  589 + children: [
  590 + VEmptyView(20),
  591 + DottedBorder(
  592 + dashPattern: [5, 5, 5, 5],
  593 + borderType: BorderType.RRect,
  594 + radius: Radius.circular(
  595 + ScreenUtil().setWidth(10)),
  596 + // padding: EdgeInsets.all(ScreenUtil().setWidth(70)),
  597 + color: MyColours.color_199095,
  598 + strokeWidth:
  599 + ScreenUtil().setWidth(2),
  600 + child: ClipRRect(
  601 + borderRadius: BorderRadius
  602 + .all(Radius.circular(
  603 + ScreenUtil()
  604 + .setWidth(10))),
  605 + child: Container(
  606 + height: ScreenUtil()
  607 + .setWidth(25 * 2),
  608 + width: ScreenUtil()
  609 + .setWidth(104 * 2),
  610 + child: Column(
  611 + mainAxisAlignment:
  612 + MainAxisAlignment
  613 + .center,
  614 + children: [
  615 + Image.asset(
  616 + Utils.getImgPath(
  617 + 'add_area'),
  618 + width: ScreenUtil()
  619 + .setWidth(24)),
  620 + ],
  621 + ),
  622 + ),
589 ), 623 ),
  624 + )
  625 + ],
  626 + ),
  627 + );
  628 + } else {
  629 + if (index == 0) {
  630 + return InkWell(
  631 + onTap: () {
  632 + setState(() {
  633 + isSelected = true;
  634 + tableManagerModel.currentArea =
  635 + '全部';
  636 + tableManagerModel
  637 + .currentTables =
  638 + tableManagerModel
  639 + .areaTableMapShow[
  640 + tableManagerModel
  641 + .currentArea];
  642 + });
  643 + },
  644 + child: Container(
  645 + // width: ScreenUtil().setWidth(104 * 2),
  646 + height: ScreenUtil().setWidth(80),
  647 + margin: EdgeInsets.only(
  648 + right:
  649 + ScreenUtil().setWidth(20),
  650 + top: ScreenUtil().setWidth(20),
  651 + ),
  652 + padding: EdgeInsets.symmetric(
  653 + horizontal:
  654 + ScreenUtil().setWidth(20),
  655 + vertical: ScreenUtil()
  656 + .setWidth(10)),
  657 + alignment: Alignment.center,
  658 + decoration: BoxDecoration(
  659 + // borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10)),
  660 + color: isSelected
  661 + ? MyColours.color_199095
  662 + : MyColours.color_ffffff,
  663 + border: Border.all(
  664 + color: MyColours
  665 + .color_E0E0E0,
  666 + width: ScreenUtil()
  667 + .setWidth(2))),
  668 + child: Text(
  669 + '全部',
  670 + overflow: TextOverflow.ellipsis,
  671 + style: TextStyle(
  672 + color: isSelected
  673 + ? MyColours.color_ffffff
  674 + : MyColours
  675 + .color_333333,
  676 + fontSize:
  677 + ScreenUtil().setSp(28),
  678 + decoration:
  679 + TextDecoration.none,
  680 + fontWeight:
  681 + FontWeight.normal),
590 ), 682 ),
591 ), 683 ),
592 - )  
593 - ],  
594 - );  
595 - } else {  
596 - return AreaItemTable(  
597 - model.areas[index],  
598 - tableManagerModel.currentArea,  
599 - (area) {});  
600 - }  
601 - },  
602 - )),  
603 - HEmptyView(40),  
604 - MyDivider(ScreenUtil().setWidth(2),  
605 - ScreenUtil().setWidth(40),  
606 - color: MyColours.color_F1F0F4),  
607 - ], 684 + );
  685 + } else {
  686 + return AreaItemTable(
  687 + model.areas[index - 1],
  688 + tableManagerModel.currentArea,
  689 + (area) {
  690 + setState(() {
  691 + isSelected = false;
  692 + _selectNumber = index - 1;
  693 + tableManagerModel.currentArea =
  694 + tableManagerModel
  695 + .areas[index - 1].name;
  696 + tableManagerModel.currentTables =
  697 + tableManagerModel
  698 + .areaTableMapShow[
  699 + tableManagerModel
  700 + .currentArea];
  701 + // _anmationMenu();
  702 + });
  703 + });
  704 + }
  705 + }
  706 + },
  707 + )),
  708 + InkWell(
  709 + onTap: () {
  710 + setState(() {
  711 + model.swichState = !model.swichState;
  712 + if (model.swichState) {
  713 + model.areaTableMapShow =
  714 + tableManagerModel
  715 + .areaTableMapCanNote;
  716 + model.tablesShow =
  717 + tableManagerModel.tablesCanNote;
  718 + } else {
  719 + model.areaTableMapShow =
  720 + model.areaTableMap;
  721 + model.tablesShow = model.tablesAll;
  722 + }
  723 + });
  724 + },
  725 + child: Container(
  726 + margin: EdgeInsets.only(
  727 + top: ScreenUtil().setWidth(20),
  728 + ),
  729 + child: Row(
  730 + children: [
  731 + MyDivider(ScreenUtil().setWidth(15),
  732 + ScreenUtil().setWidth(80),
  733 + color: MyColours.color_F1F0F4),
  734 + MyDivider(ScreenUtil().setWidth(2),
  735 + ScreenUtil().setWidth(80),
  736 + color: MyColours.color_9C9C9C),
  737 + HEmptyView(30),
  738 + Image.asset(
  739 + model.swichState
  740 + ? Utils.getImgPath(
  741 + 'f_swich_on')
  742 + : Utils.getImgPath(
  743 + 'f_swich_off'),
  744 + width: ScreenUtil().setWidth(90),
  745 + // height: ScreenUtil().setWidth(82),
  746 + ),
  747 + HEmptyView(20),
  748 + Text(
  749 + '仅看\n空座',
  750 + style: TextStyle(
  751 + fontSize:
  752 + ScreenUtil().setSp(30),
  753 + color: MyColours.color_333333,
  754 + ),
  755 + ),
  756 + HEmptyView(40)
  757 + ],
  758 + )),
  759 + )
  760 + ],
  761 + ),
608 ), 762 ),
609 - )  
610 - ],  
611 - );  
612 - // return CCMenuPage.builder(  
613 - // tableManagerModel: tableManagerModel,  
614 - // itemCount: tableManagerModel.areas.length,  
615 - // onTap: (index) async {},  
616 - // tabBuilder: (BuildContext context, int index) {  
617 - // if (index == tableManagerModel.areas.length ||  
618 - // tableManagerModel.areas.length == 0) {  
619 - // return Column(  
620 - // children: [  
621 - // VEmptyView(20),  
622 - // DottedBorder(  
623 - // dashPattern: [5, 5, 5, 5],  
624 - // borderType: BorderType.RRect,  
625 - // radius:  
626 - // Radius.circular(ScreenUtil().setWidth(10)),  
627 - // // padding: EdgeInsets.all(ScreenUtil().setWidth(70)),  
628 - // color: MyColours.color_199095,  
629 - // strokeWidth: ScreenUtil().setWidth(2),  
630 - // child: ClipRRect(  
631 - // borderRadius: BorderRadius.all(  
632 - // Radius.circular(  
633 - // ScreenUtil().setWidth(10))),  
634 - // child: Container(  
635 - // height: ScreenUtil().setWidth(25 * 2),  
636 - // width: ScreenUtil().setWidth(104 * 2),  
637 - // child: Column(  
638 - // mainAxisAlignment:  
639 - // MainAxisAlignment.center,  
640 - // children: [  
641 - // Image.asset(  
642 - // Utils.getImgPath('add_area'),  
643 - // width: ScreenUtil().setWidth(24)),  
644 - // ],  
645 - // ),  
646 - // ),  
647 - // ),  
648 - // )  
649 - // ],  
650 - // );  
651 - // } else {  
652 - // return AreaItemTable(model.areas[index],  
653 - // tableManagerModel.currentArea, (area) {});  
654 - // }  
655 - // },  
656 - // itemBuilder: (BuildContext context, int index) {  
657 - // return item(index);  
658 - // },  
659 - // );  
660 - }  
661 - },  
662 - ), 763 + Expanded(
  764 + child: Container(
  765 + color: Color.fromRGBO(249, 249, 249, 1),
  766 + child: item(_selectNumber))),
  767 + ]))
  768 + // return CCMenuPage.builder(
  769 + // tableManagerModel: tableManagerModel,
  770 + // itemCount: tableManagerModel.areas.length,
  771 + // onTap: (index) async {},
  772 + // tabBuilder: (BuildContext context, int index) {
  773 + // if (index == tableManagerModel.areas.length ||
  774 + // tableManagerModel.areas.length == 0) {
  775 + // return Column(
  776 + // children: [
  777 + // VEmptyView(20),
  778 + // DottedBorder(
  779 + // dashPattern: [5, 5, 5, 5],
  780 + // borderType: BorderType.RRect,
  781 + // radius:
  782 + // Radius.circular(ScreenUtil().setWidth(10)),
  783 + // // padding: EdgeInsets.all(ScreenUtil().setWidth(70)),
  784 + // color: MyColours.color_199095,
  785 + // strokeWidth: ScreenUtil().setWidth(2),
  786 + // child: ClipRRect(
  787 + // borderRadius: BorderRadius.all(
  788 + // Radius.circular(
  789 + // ScreenUtil().setWidth(10))),
  790 + // child: Container(
  791 + // height: ScreenUtil().setWidth(25 * 2),
  792 + // width: ScreenUtil().setWidth(104 * 2),
  793 + // child: Column(
  794 + // mainAxisAlignment:
  795 + // MainAxisAlignment.center,
  796 + // children: [
  797 + // Image.asset(
  798 + // Utils.getImgPath('add_area'),
  799 + // width: ScreenUtil().setWidth(24)),
  800 + // ],
  801 + // ),
  802 + // ),
  803 + // ),
  804 + // )
  805 + // ],
  806 + // );
  807 + // } else {
  808 + // return AreaItemTable(model.areas[index],
  809 + // tableManagerModel.currentArea, (area) {});
  810 + // }
  811 + // },
  812 + // itemBuilder: (BuildContext context, int index) {
  813 + // return item(index);
  814 + // },
  815 + // );
663 ], 816 ],
664 ); 817 );
665 }, 818 },
@@ -576,15 +576,15 @@ class NotebookDetailChangeModel with ChangeNotifier { @@ -576,15 +576,15 @@ class NotebookDetailChangeModel with ChangeNotifier {
576 ///录入更改内部预订 576 ///录入更改内部预订
577 Future<SunReserveInfoModel> setReserveInfo(BuildContext context) async { 577 Future<SunReserveInfoModel> setReserveInfo(BuildContext context) async {
578 UserModel userModel = Provider.of<UserModel>(context, listen: false); 578 UserModel userModel = Provider.of<UserModel>(context, listen: false);
579 - String pnum = '6'; 579 + String pnum = '';
580 for (var item in personNumList) { 580 for (var item in personNumList) {
581 if (item['isSelect']) { 581 if (item['isSelect']) {
582 pnum = item['dateText']; 582 pnum = item['dateText'];
583 } 583 }
584 } 584 }
585 - if (pnum == '') {  
586 - pnum = '6';  
587 - } 585 + // if (pnum == '') {
  586 + // pnum = '6';
  587 + // }
588 String sex = '1'; 588 String sex = '1';
589 for (var item in sexList) { 589 for (var item in sexList) {
590 if (item['select']) { 590 if (item['select']) {
@@ -26,7 +26,11 @@ class TableManagerModel with ChangeNotifier { @@ -26,7 +26,11 @@ class TableManagerModel with ChangeNotifier {
26 26
27 List<TableOuter> tableOuterList = []; //区域-桌位列表 27 List<TableOuter> tableOuterList = []; //区域-桌位列表
28 28
29 - Map<String, List<t.Table>> areaTableMap = {}; //区域-桌位Map 29 + Map<String, List<t.Table>> areaTableMap = {}; //区域-桌位Map 已预订和空桌子
  30 + Map<String, List<t.Table>> areaTableMapCanNote =
  31 + {}; //区域-桌位Map 筛选出已经预订的桌子,剩余空桌子
  32 +
  33 + Map<String, List<t.Table>> areaTableMapShow; ////区域-桌位Map 页面展示用(全部或者只看空桌子)
30 List<t.Table> currentTables = []; //当前显示的区域-桌位 34 List<t.Table> currentTables = []; //当前显示的区域-桌位
31 35
32 Map<String, Notebook> tableMap = {}; //记录已预订桌位对应的订单 36 Map<String, Notebook> tableMap = {}; //记录已预订桌位对应的订单
@@ -34,6 +38,10 @@ class TableManagerModel with ChangeNotifier { @@ -34,6 +38,10 @@ class TableManagerModel with ChangeNotifier {
34 String currentArea; //当前选中区域 38 String currentArea; //当前选中区域
35 int selectIndex = 0; 39 int selectIndex = 0;
36 40
  41 + List<t.Table> tablesAll = []; //全部桌子(已预订和空桌子)
  42 + List<t.Table> tablesCanNote = []; //全部桌子(空桌子)
  43 + List<t.Table> tablesShow = []; //页面展示
  44 +
37 DateTime dateTime = DateTime.now(); 45 DateTime dateTime = DateTime.now();
38 46
39 String dateText = ""; //当前显示日期时间 47 String dateText = ""; //当前显示日期时间
@@ -46,6 +54,7 @@ class TableManagerModel with ChangeNotifier { @@ -46,6 +54,7 @@ class TableManagerModel with ChangeNotifier {
46 PageState pageState = PageState.Loading; 54 PageState pageState = PageState.Loading;
47 55
48 Map dailyMap = {}; // 早市对应半点钟,午市对应半点钟、晚市对应半点钟 56 Map dailyMap = {}; // 早市对应半点钟,午市对应半点钟、晚市对应半点钟
  57 + bool swichState = false; //仅看空座
49 58
50 //初始化时间 59 //初始化时间
51 initTime(BuildContext context) async { 60 initTime(BuildContext context) async {
@@ -267,12 +276,14 @@ class TableManagerModel with ChangeNotifier { @@ -267,12 +276,14 @@ class TableManagerModel with ChangeNotifier {
267 notifyListeners(); 276 notifyListeners();
268 return []; 277 return [];
269 } 278 }
  279 + tablesAll = [];
270 tableOuterList = (baseResp.data[0] as List).map((value) { 280 tableOuterList = (baseResp.data[0] as List).map((value) {
271 TableOuter tableOuter = TableOuter(); 281 TableOuter tableOuter = TableOuter();
272 tableOuter.name = value["name"]; 282 tableOuter.name = value["name"];
273 tableOuter.list = (value["list"] as List).map((table) { 283 tableOuter.list = (value["list"] as List).map((table) {
274 return t.Table.fromJson(table as Map<String, dynamic>); 284 return t.Table.fromJson(table as Map<String, dynamic>);
275 }).toList(); 285 }).toList();
  286 + tablesAll.addAll(tableOuter.list);
276 return tableOuter; 287 return tableOuter;
277 }).toList(); 288 }).toList();
278 } 289 }
@@ -405,8 +416,14 @@ class TableManagerModel with ChangeNotifier { @@ -405,8 +416,14 @@ class TableManagerModel with ChangeNotifier {
405 initData({bool needKeep = false}) { 416 initData({bool needKeep = false}) {
406 areas.clear(); 417 areas.clear();
407 areaTableMap.clear(); 418 areaTableMap.clear();
  419 + List<t.Table> tempTableAll = [];
  420 + tempTableAll.addAll(tablesAll);
408 for (TableOuter outer in tableOuterList) { 421 for (TableOuter outer in tableOuterList) {
409 int count = 0; 422 int count = 0;
  423 +
  424 + List<t.Table> tempList = [];
  425 + tempList.addAll(outer.list);
  426 +
410 for (t.Table table in outer.list) { 427 for (t.Table table in outer.list) {
411 table.sign = ""; 428 table.sign = "";
412 table.notebookId = ""; 429 table.notebookId = "";
@@ -418,6 +435,13 @@ class TableManagerModel with ChangeNotifier { @@ -418,6 +435,13 @@ class TableManagerModel with ChangeNotifier {
418 table.sign = notebook.status; 435 table.sign = notebook.status;
419 table.notebookId = notebook.id; 436 table.notebookId = notebook.id;
420 table.reserver = notebook.rnameStr; 437 table.reserver = notebook.rnameStr;
  438 + table.pnum = notebook.pnum;
  439 + table.noteName = notebook.note_name;
  440 +
  441 + //剔除已经预订的桌子,剩下空桌子(仅看空座)
  442 + tempList.remove(table);
  443 + //全部
  444 + tempTableAll.remove(table);
421 } else { 445 } else {
422 table.sign = ""; 446 table.sign = "";
423 table.notebookId = ""; 447 table.notebookId = "";
@@ -432,16 +456,28 @@ class TableManagerModel with ChangeNotifier { @@ -432,16 +456,28 @@ class TableManagerModel with ChangeNotifier {
432 } 456 }
433 } 457 }
434 areaTableMap["${outer.name}"] = outer.list; 458 areaTableMap["${outer.name}"] = outer.list;
  459 + areaTableMapCanNote["${outer.name}"] = tempList;
435 Area area = Area(); 460 Area area = Area();
436 area.name = outer.name; 461 area.name = outer.name;
437 area.count = outer.list.length == 0 ? -1 : count; 462 area.count = outer.list.length == 0 ? -1 : count;
438 area.rid = outer.list.length == 0 ? outer.rid : outer.list[0].rid; 463 area.rid = outer.list.length == 0 ? outer.rid : outer.list[0].rid;
439 areas.add(area); 464 areas.add(area);
440 } 465 }
  466 + tablesCanNote = tempTableAll;
  467 + if (swichState) {
  468 + areaTableMapShow = areaTableMapCanNote;
  469 + tablesShow = tablesCanNote;
  470 + } else {
  471 + areaTableMapShow = areaTableMap;
  472 + tablesShow = tablesAll;
  473 + }
  474 +
441 if (areaTableMap.isNotEmpty) { 475 if (areaTableMap.isNotEmpty) {
442 if (!needKeep) { 476 if (!needKeep) {
443 - currentArea = areaTableMap.keys.first;  
444 - currentTables = areaTableMap[currentArea]; 477 + // currentArea = areaTableMap.keys.first;
  478 + // currentTables = areaTableMap[currentArea];
  479 + currentArea = '全部';
  480 + currentTables = tablesAll;
445 pageState = PageState.Success; 481 pageState = PageState.Success;
446 } 482 }
447 } else { 483 } else {
@@ -478,9 +514,7 @@ class TableManagerModel with ChangeNotifier { @@ -478,9 +514,7 @@ class TableManagerModel with ChangeNotifier {
478 date += ymd; 514 date += ymd;
479 date += " 星期${Utils.formatWeekDayNum(day.weekday)}"; 515 date += " 星期${Utils.formatWeekDayNum(day.weekday)}";
480 516
481 - LunarCalendar lunarCalendar = LunarCalendar(day);  
482 - String time =  
483 - '${lunarCalendar.getChinaMonthString()}月${LunarCalendar.getChinaDayString(lunarCalendar.day)}'; 517 + String time = Utils.lunarCalendarHolidays(day);
484 date += ' ${time}'; 518 date += ' ${time}';
485 return date; 519 return date;
486 } 520 }
@@ -34,6 +34,15 @@ typedef CustomCallBackMap = void Function(Map<String, String> object); @@ -34,6 +34,15 @@ typedef CustomCallBackMap = void Function(Map<String, String> object);
34 34
35 typedef ClickCallback = void Function(String value); 35 typedef ClickCallback = void Function(String value);
36 36
  37 +// Example holidays
  38 +// final Map<DateTime, List> _holidays = {
  39 +// DateTime(2021, 1, 1): ['元旦节'],
  40 +// DateTime(2021, 1, 6): ['Epiphany'],
  41 +// DateTime(2021, 2, 14): ['Valentine\'s Day'],
  42 +// DateTime(2021, 4, 21): ['Easter Sunday'],
  43 +// DateTime(2021, 4, 22): ['Easter Monday'],
  44 +// };
  45 +
37 class DialogUtil { 46 class DialogUtil {
38 ///添加图片UI弹出 47 ///添加图片UI弹出
39 static openImageModalBottomSheet(context, 48 static openImageModalBottomSheet(context,
@@ -1118,6 +1127,7 @@ class DialogUtil { @@ -1118,6 +1127,7 @@ class DialogUtil {
1118 onDaySelected: (day, events, holidays) { 1127 onDaySelected: (day, events, holidays) {
1119 Navigator.of(dialogContext).pop(day); 1128 Navigator.of(dialogContext).pop(day);
1120 }, 1129 },
  1130 + // holidays: _holidays,
1121 availableGestures: AvailableGestures.none, 1131 availableGestures: AvailableGestures.none,
1122 events: _events, 1132 events: _events,
1123 locale: "zh_CN", 1133 locale: "zh_CN",
@@ -15,6 +15,7 @@ import 'package:fluwx/fluwx.dart'; @@ -15,6 +15,7 @@ import 'package:fluwx/fluwx.dart';
15 import 'package:one_key/pages/login/web_page.dart'; 15 import 'package:one_key/pages/login/web_page.dart';
16 import 'package:one_key/provider/user_model.dart'; 16 import 'package:one_key/provider/user_model.dart';
17 import 'package:one_key/utils/dialog_util.dart'; 17 import 'package:one_key/utils/dialog_util.dart';
  18 +import 'package:one_key/utils/lunar_calendar.dart';
18 import 'package:one_key/utils/misc.dart'; 19 import 'package:one_key/utils/misc.dart';
19 import 'package:one_key/route/navigator_util.dart'; 20 import 'package:one_key/route/navigator_util.dart';
20 import 'package:one_key/widgets/loading.dart'; 21 import 'package:one_key/widgets/loading.dart';
@@ -29,6 +30,78 @@ import '../app.dart'; @@ -29,6 +30,78 @@ import '../app.dart';
29 typedef BookTimeSetCallback = void Function(bool needChange); 30 typedef BookTimeSetCallback = void Function(bool needChange);
30 31
31 class Utils { 32 class Utils {
  33 + static String lunarCalendarUtils(DateTime day) {
  34 + LunarCalendar lunarCalendar = LunarCalendar(day);
  35 + String time =
  36 + '${lunarCalendar.getChinaMonthString()}月${LunarCalendar.getChinaDayString(lunarCalendar.day)}';
  37 + return time;
  38 + }
  39 +
  40 + //农历节日 *表示放假日
  41 + static String lunarCalendarHolidays(DateTime day) {
  42 + LunarCalendar lunarCalendar = LunarCalendar(day);
  43 + //阴历月-日
  44 + String keyLunar =
  45 + addZeroNumber(lunarCalendar.month) + addZeroNumber(lunarCalendar.day);
  46 + //阳历月-日
  47 + String keySolar =
  48 + Utils.addZeroNumber(day.month) + Utils.addZeroNumber(day.day);
  49 + Map<String, String> holiday1 = {
  50 + "0101": "春节",
  51 + "0102": "大年初二",
  52 + "0103": "大年初三",
  53 + "0104": "大年初四",
  54 + "0105": "大年初五",
  55 + "0106": "大年初六",
  56 + "0107": "大年初七",
  57 + "0115": "元宵节",
  58 + "0505": "端午节",
  59 + "0707": "七夕情人节",
  60 + "0815": "中秋节",
  61 + "0909": "重阳节",
  62 + "1208": "腊八节",
  63 + "1223": "过小年",
  64 + "0100": "除夕"
  65 + };
  66 + Map<String, String> holiday2 = {
  67 + "0101": '元旦',
  68 + "0214": "情人节",
  69 + "0308": "妇女节",
  70 + "0501": "劳动节",
  71 + "0504": "青年节",
  72 + "0601": "国际儿童节",
  73 + "0801": "八一建军节",
  74 + "0910": "教师节",
  75 + "1001": "国庆节",
  76 + "1224": "平安夜",
  77 + "1225": "圣诞节",
  78 + };
  79 + if (holiday1.containsKey(keyLunar)) {
  80 + return holiday1[keyLunar];
  81 + }
  82 + if (holiday2.containsKey(keySolar)) {
  83 + return holiday2[keySolar];
  84 + }
  85 + return lunarCalendarUtils(day);
  86 + }
  87 +
  88 + //国历节日 *表示放假日
  89 + static String solarCalendarHolidays(DateTime day) {
  90 + Map<String, String> holiday1 = {
  91 + "0101": '元旦',
  92 + "0214": "情人节",
  93 + "0308": "妇女节",
  94 + "0501": "劳动节",
  95 + "0504": "青年节",
  96 + "0601": "国际儿童节",
  97 + "0801": "八一建军节",
  98 + "0910": "教师节",
  99 + "1001": "国庆节",
  100 + "1224": "平安夜",
  101 + "1225": "圣诞节",
  102 + };
  103 + }
  104 +
32 static String starPhone(phone) { 105 static String starPhone(phone) {
33 return phone.replaceFirst(new RegExp(r'\d{4}'), '****', 3); 106 return phone.replaceFirst(new RegExp(r'\d{4}'), '****', 3);
34 } 107 }
  1 +import 'package:flutter/material.dart';
  2 +import 'package:flutter_screenutil/flutter_screenutil.dart';
  3 +import 'package:one_key/models/notebook.dart';
  4 +import 'package:one_key/res/colors.dart';
  5 +
  6 +import 'package:one_key/models/table.dart' as t;
  7 +import 'package:one_key/widgets/v_empty_view.dart';
  8 +
  9 +class FTableItem extends StatefulWidget {
  10 + final t.Table table;
  11 + final bool canSelected; //是否能选中
  12 + final ValueChanged<t.Table> onSelected;
  13 + final String fromPage; // 变更、新建、桌位管理三个页面
  14 + final String rid;
  15 + final Map<String, Notebook> tableMap; //记录已预订桌位对应的订单
  16 +
  17 + final int height; //高度
  18 + final bool need;
  19 +
  20 + FTableItem(this.table,
  21 + {this.onSelected,
  22 + this.canSelected = false,
  23 + this.height = 185,
  24 + this.fromPage = 'new',
  25 + this.rid,
  26 + this.tableMap,
  27 + this.need = true});
  28 +
  29 + @override
  30 + State<StatefulWidget> createState() {
  31 + // TODO: implement createState
  32 + return new FTableItemState();
  33 + }
  34 +}
  35 +
  36 +class FTableItemState extends State<FTableItem> {
  37 + @override
  38 + Widget build(BuildContext context) {
  39 + t.Table table = widget.table;
  40 +
  41 + String signStr = table.signStr;
  42 + if (table.sign == '5' && widget.tableMap[table.id].orderInfo != null) {
  43 + if (widget.tableMap[table.id].orderInfo.status == '3') {
  44 + signStr = '已买单';
  45 + }
  46 + }
  47 +
  48 + return GestureDetector(
  49 + onTap: () {
  50 + if (widget.canSelected && widget.fromPage == 'change') {
  51 + //从变更页面进来 canChoose = true
  52 + if (widget.canSelected && signStr.isEmpty) {
  53 + setState(() {
  54 + table.selected = !(table.selected ?? false);
  55 + });
  56 + widget.onSelected(table);
  57 + } else {
  58 + if (table.sign == '5' || table.sign == '1') {
  59 + // 1一般是商户端
  60 + // 5是用户端
  61 + //已预订状态 不是自己的不可以选择,是自己的可以选择
  62 + //当前桌子的预订id
  63 + String idNow = '';
  64 + if (widget.tableMap.containsKey('${table.id}')) {
  65 + //包含,证明该桌子已经被预订了
  66 + idNow = widget.tableMap['${table.id}'].id;
  67 + if (idNow == widget.rid) {
  68 + setState(() {
  69 + table.selected = !(table.selected ?? false);
  70 + });
  71 + widget.onSelected(table);
  72 + }
  73 + }
  74 + }
  75 + }
  76 + } else if (widget.fromPage == 'new' &&
  77 + widget.canSelected &&
  78 + signStr.isEmpty) {
  79 + //从安排桌位进来
  80 + setState(() {
  81 + table.selected = !(table.selected ?? false);
  82 + });
  83 + widget.onSelected(table);
  84 + } else if (widget.fromPage == 'table_manage' ||
  85 + widget.fromPage == 'room_manage') {
  86 + table.selected = !(table.selected ?? false);
  87 + widget.onSelected(table);
  88 + } else if (widget.fromPage == 'tablePhoto') {
  89 + // setState(() {
  90 + // table.selected = true;
  91 + // });
  92 +
  93 + widget.onSelected(table);
  94 + }
  95 + },
  96 + child: Stack(
  97 + children: <Widget>[
  98 + Container(
  99 + // width: ScreenUtil().setWidth(160),
  100 + // height: ScreenUtil().setWidth(widget.height),
  101 + // margin: EdgeInsets.all(ScreenUtil().setWidth(9)),
  102 + decoration: BoxDecoration(
  103 + color: widget.need && signStr == '已预订'
  104 + ? Color.fromRGBO(154, 23, 45, 1)
  105 + : MyColours.color_ffffff,
  106 + border: Border.all(
  107 + width: ScreenUtil().setWidth(2),
  108 + color: MyColours.color_E0E0E0),
  109 + borderRadius: BorderRadius.all(
  110 + Radius.circular(ScreenUtil().setWidth(20)))),
  111 + child: Stack(
  112 + // alignment: Alignment.center,
  113 + children: <Widget>[
  114 + Container(
  115 + alignment: Alignment.center,
  116 + // padding: EdgeInsets.symmetric(
  117 + // horizontal: ScreenUtil().setWidth(20)),
  118 + // margin: EdgeInsets.only(left: ScreenUtil().setWidth(20)),
  119 + child: Column(
  120 + mainAxisSize: MainAxisSize.min,
  121 + crossAxisAlignment: CrossAxisAlignment.center,
  122 + mainAxisAlignment: MainAxisAlignment.center,
  123 + children: <Widget>[
  124 + widget.need && signStr == '已预订'
  125 + ? SizedBox()
  126 + : VEmptyView(10),
  127 + Container(
  128 + alignment: Alignment.center,
  129 + child: Text(
  130 + table.name,
  131 + maxLines: 1,
  132 + style: TextStyle(
  133 + color: widget.need && signStr == '已预订'
  134 + ? MyColours.color_ffffff
  135 + : MyColours.color_333333,
  136 + fontSize: ScreenUtil().setSp(36),
  137 + decoration: TextDecoration.none,
  138 + fontWeight: FontWeight.bold),
  139 + overflow: TextOverflow.ellipsis,
  140 + )
  141 + // Text(
  142 + // table.name,
  143 + // // textAlign: TextAlign.center,
  144 + // maxLines: 2,
  145 + // style: TextStyle(
  146 + // color: table.signStr == '已停用'
  147 + // ? MyColours.color_999999
  148 + // : MyColours.color_353535,
  149 + // fontSize: ScreenUtil().setSp(28),
  150 + // decoration: TextDecoration.none,
  151 + // fontWeight: FontWeight.normal),
  152 + // overflow: TextOverflow.ellipsis,
  153 + // ),
  154 + ),
  155 + ((table.reserver == null || table.reserver.isEmpty)
  156 + ? table.tableNum
  157 + : table.reserver) !=
  158 + ''
  159 + ? VEmptyView(8)
  160 + : SizedBox(),
  161 + Text(
  162 + (table.reserver == null || table.reserver.isEmpty)
  163 + ? table.tableNum
  164 + : '${table.reserver}' +
  165 + (table.pnum != '' && table.pnum != '0'
  166 + ? '(${table.pnum}人)'
  167 + : ''),
  168 + style: TextStyle(
  169 + color: signStr == '已预订'
  170 + ? MyColours.color_ffffff
  171 + : MyColours.color_353535,
  172 + fontSize: ScreenUtil().setSp(22),
  173 + decoration: TextDecoration.none,
  174 + fontWeight: FontWeight.normal),
  175 + overflow: TextOverflow.ellipsis,
  176 + ),
  177 +
  178 + widget.need && signStr == '已预订'
  179 + ? Padding(
  180 + padding: EdgeInsets.only(
  181 + top: ScreenUtil().setWidth(6),
  182 + bottom: ScreenUtil().setWidth(10),
  183 + ),
  184 + child: Text(
  185 + '${table.noteName}订',
  186 + style: TextStyle(
  187 + color: MyColours.color_ffffff,
  188 + fontSize: ScreenUtil().setSp(22),
  189 + decoration: TextDecoration.none,
  190 + fontWeight: FontWeight.normal),
  191 + overflow: TextOverflow.ellipsis,
  192 + ),
  193 + )
  194 + : SizedBox(),
  195 +
  196 + signStr == '已预订'
  197 + ? Container(
  198 + // width: ScreenUtil().setWidth(160),
  199 + height: ScreenUtil().setWidth(34),
  200 + alignment: Alignment.centerLeft,
  201 + padding: EdgeInsets.symmetric(
  202 + horizontal: ScreenUtil().setWidth(10)),
  203 + decoration: BoxDecoration(
  204 + color: Color.fromRGBO(232, 141, 164, 1),
  205 + ),
  206 + child: Text(
  207 + '新客',
  208 + style: TextStyle(
  209 + color: MyColours.color_ffffff,
  210 + fontSize: ScreenUtil().setSp(24),
  211 + decoration: TextDecoration.none,
  212 + fontWeight: FontWeight.normal),
  213 + ),
  214 + )
  215 + : SizedBox()
  216 + // VEmptyView(6),
  217 + // Text(
  218 + // table.lowStr,
  219 + // style: TextStyle(
  220 + // color: MyColours.color_777777,
  221 + // fontSize: ScreenUtil().setSp(26),
  222 + // decoration: TextDecoration.none,
  223 + // fontWeight: FontWeight.normal),
  224 + // overflow: TextOverflow.ellipsis,
  225 + // )
  226 + ],
  227 + ),
  228 + ),
  229 + signStr == '已预订'
  230 + ? SizedBox()
  231 + : Positioned(
  232 + left: 0,
  233 + top: 0,
  234 + child: table.tidStr == null
  235 + ? Container()
  236 + : Container(
  237 + // width: ScreenUtil().setWidth(60),
  238 + // height: ScreenUtil().setWidth(42),
  239 + padding:
  240 + EdgeInsets.all(ScreenUtil().setWidth(4)),
  241 + alignment: Alignment.center,
  242 + decoration: BoxDecoration(
  243 + color: Color.fromRGBO(239, 239, 239, 1),
  244 + borderRadius: BorderRadius.only(
  245 + topLeft: Radius.circular(
  246 + ScreenUtil().setWidth(20)),
  247 + // topRight:
  248 + // Radius.circular(ScreenUtil().setWidth(8)),
  249 + // bottomRight: Radius.circular(
  250 + // ScreenUtil().setWidth(8))
  251 + )),
  252 + child: Text(table.tidStr,
  253 + style: TextStyle(
  254 + color: MyColours.color_333333,
  255 + fontSize: ScreenUtil().setSp(20),
  256 + decoration: TextDecoration.none,
  257 + fontWeight: FontWeight.normal)),
  258 + ),
  259 + ),
  260 + // widget.need && signStr == '已预订'
  261 + // ? Positioned(
  262 + // bottom: 0,
  263 + // left: 0,
  264 + // right: 0,
  265 + // child: signStr.isEmpty
  266 + // ? Container()
  267 + // : Container(
  268 + // width: ScreenUtil().setWidth(160),
  269 + // height: ScreenUtil().setWidth(40),
  270 + // alignment: Alignment.center,
  271 + // decoration: BoxDecoration(
  272 + // color: signStr == '已停用'
  273 + // ? MyColours.color_777777
  274 + // : signStr == '已买单'
  275 + // ? MyColours.color_F59A23
  276 + // : MyColours.color_E95750,
  277 + // borderRadius: BorderRadius.only(
  278 + // bottomLeft: Radius.circular(
  279 + // ScreenUtil().setWidth(8)),
  280 + // bottomRight: Radius.circular(
  281 + // ScreenUtil().setWidth(8)))),
  282 + // child: Text(
  283 + // signStr,
  284 + // style: TextStyle(
  285 + // color: MyColours.color_ffffff,
  286 + // fontSize: ScreenUtil().setSp(24),
  287 + // decoration: TextDecoration.none,
  288 + // fontWeight: FontWeight.normal),
  289 + // ),
  290 + // ),
  291 + // )
  292 + // : SizedBox(),
  293 + ],
  294 + ),
  295 + ),
  296 + Positioned(
  297 + top: 3,
  298 + right: 5,
  299 + child: widget.canSelected && (table.selected ?? false)
  300 + ? Image.asset(
  301 + "assets/icon_selected.png",
  302 + width: ScreenUtil().setWidth(40),
  303 + height: ScreenUtil().setWidth(40),
  304 + )
  305 + : Container()),
  306 + widget.need && signStr == '已预订'
  307 + ? SizedBox()
  308 + : Positioned(
  309 + left: ScreenUtil().setWidth(18),
  310 + bottom: ScreenUtil().setWidth(12),
  311 + child: table.isPhoto != 1
  312 + ? Image.asset(
  313 + "assets/f_camera.png",
  314 + width: ScreenUtil().setWidth(22),
  315 + height: ScreenUtil().setWidth(22),
  316 + )
  317 + : Container())
  318 + ],
  319 + ),
  320 + );
  321 + }
  322 +}