Showing
7 changed files
with
2172 additions
and
14 deletions
lib/pages/enter/enter_page.dart
0 → 100644
| 1 | +import 'dart:convert'; | ||
| 2 | +import 'dart:ui'; | ||
| 3 | + | ||
| 4 | +import 'package:common_utils/common_utils.dart'; | ||
| 5 | +import 'package:flutter/material.dart'; | ||
| 6 | +import 'package:flutter/services.dart'; | ||
| 7 | +import 'package:flutter_screenutil/screenutil.dart'; | ||
| 8 | +import 'package:one_key/models/notebook_detail.dart'; | ||
| 9 | +import 'package:one_key/models/reserve_info_model.dart'; | ||
| 10 | +import 'package:one_key/provider/notebook_detail_change_model.dart'; | ||
| 11 | +import 'package:one_key/provider/notebook_detail_model.dart'; | ||
| 12 | +import 'package:one_key/provider/user_model.dart'; | ||
| 13 | +import 'package:one_key/res/colors.dart'; | ||
| 14 | +import 'package:one_key/utils/dialog_util.dart'; | ||
| 15 | +import 'package:one_key/utils/event_bus.dart'; | ||
| 16 | +import 'package:one_key/utils/navigator_util.dart'; | ||
| 17 | +import 'package:one_key/utils/utils.dart'; | ||
| 18 | +import 'package:one_key/widgets/MyDivider.dart'; | ||
| 19 | +import 'package:one_key/widgets/app_bar.dart'; | ||
| 20 | +import 'package:one_key/widgets/common_button.dart'; | ||
| 21 | +import 'package:one_key/widgets/h_empty_view.dart'; | ||
| 22 | +import 'package:one_key/widgets/new_table_item.dart'; | ||
| 23 | +import 'package:one_key/widgets/table_item.dart'; | ||
| 24 | +import 'package:one_key/widgets/v_empty_view.dart'; | ||
| 25 | +import 'package:provider/provider.dart'; | ||
| 26 | +import 'package:one_key/models/table_list.dart' as t; | ||
| 27 | +import 'dart:convert' as convert; | ||
| 28 | + | ||
| 29 | +typedef clickCallback = void Function(String value); | ||
| 30 | + | ||
| 31 | +class EnterPage extends StatefulWidget { | ||
| 32 | + final NotebookDetail detailEntity; | ||
| 33 | + final String rid; | ||
| 34 | + | ||
| 35 | + const EnterPage({Key key, this.detailEntity, this.rid}) | ||
| 36 | + : super(key: key); | ||
| 37 | + @override | ||
| 38 | + _EnterPageState createState() => _EnterPageState(); | ||
| 39 | +} | ||
| 40 | + | ||
| 41 | +class _EnterPageState extends State<EnterPage> { | ||
| 42 | + DateTime dateTime; //当前日期 | ||
| 43 | + NotebookDetailChangeModel _notebookDetailChangeModel; | ||
| 44 | + FocusNode _phoneNode = FocusNode(); | ||
| 45 | + FocusNode _nameNode = FocusNode(); | ||
| 46 | + FocusNode _needNode = FocusNode(); | ||
| 47 | + NotebookDetailModel detailModel = NotebookDetailModel(); | ||
| 48 | + | ||
| 49 | + @override | ||
| 50 | + void initState() { | ||
| 51 | + super.initState(); | ||
| 52 | + dateTime = DateTime.now(); | ||
| 53 | + | ||
| 54 | + _notebookDetailChangeModel = | ||
| 55 | + Provider.of<NotebookDetailChangeModel>(context, listen: false); | ||
| 56 | + _notebookDetailChangeModel.initDateHourMinuteList(context); | ||
| 57 | + String ddate = widget.detailEntity.ddate.toString() + '000'; | ||
| 58 | + _notebookDetailChangeModel.getNewTableList( | ||
| 59 | + context, | ||
| 60 | + ddate, | ||
| 61 | + widget.detailEntity.ddate_solt, | ||
| 62 | + widget.detailEntity.pnum, | ||
| 63 | + widget.detailEntity.tables); | ||
| 64 | + _initData(); | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + _initData() { | ||
| 68 | + print(widget.detailEntity); | ||
| 69 | + for (var item in widget.detailEntity.tables) { | ||
| 70 | + item.selected = true; | ||
| 71 | + } | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + _topWidget() { | ||
| 75 | + return Container( | ||
| 76 | + padding: EdgeInsets.all(ScreenUtil().setWidth(40)), | ||
| 77 | + child: Column( | ||
| 78 | + children: [ | ||
| 79 | + //第一行 日期选择 | ||
| 80 | + Row( | ||
| 81 | + mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
| 82 | + children: _notebookDetailChangeModel.dateList.map((value) { | ||
| 83 | + return CustomButton( | ||
| 84 | + dateText: value['title'], | ||
| 85 | + fontSize: value['fontSize'], | ||
| 86 | + dayText: value['dayText'], | ||
| 87 | + isImage: value['isImage'], | ||
| 88 | + isSelect: value['select'], | ||
| 89 | + onTap: () async { | ||
| 90 | + print(value['title']); | ||
| 91 | + FocusScope.of(context) | ||
| 92 | + .requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 93 | + if (value['title'] == '其他') { | ||
| 94 | + _calendWidget(DateTime.now()); | ||
| 95 | + } else { | ||
| 96 | + for (int j = 0; | ||
| 97 | + j < _notebookDetailChangeModel.dateList.length; | ||
| 98 | + j++) { | ||
| 99 | + _notebookDetailChangeModel.dateList[j]['select'] = | ||
| 100 | + false; | ||
| 101 | + | ||
| 102 | + if (_notebookDetailChangeModel.dateList[j]['title'] == | ||
| 103 | + value['title']) { | ||
| 104 | + _notebookDetailChangeModel.dateList[j]['select'] = | ||
| 105 | + true; | ||
| 106 | + | ||
| 107 | + if (j == 0 || j == 1) { | ||
| 108 | + _notebookDetailChangeModel.dateList[2]['title'] = | ||
| 109 | + '其他'; | ||
| 110 | + } | ||
| 111 | + if (j == | ||
| 112 | + _notebookDetailChangeModel.dateList.length - 1) { | ||
| 113 | + String selectStr = | ||
| 114 | + _notebookDetailChangeModel.dateList[2]['title']; | ||
| 115 | + String timeNow = DateUtil.formatDate( | ||
| 116 | + DateTime.now(), | ||
| 117 | + ); | ||
| 118 | + String selectDate = | ||
| 119 | + timeNow.replaceRange(5, 10, selectStr); | ||
| 120 | + _calendWidget(DateUtil.getDateTime(selectDate)); | ||
| 121 | + } | ||
| 122 | + } | ||
| 123 | + } | ||
| 124 | + //选完今天明天刷新页面 | ||
| 125 | + int ddate = _getDdate(_notebookDetailChangeModel); | ||
| 126 | + String ddateSolt = | ||
| 127 | + _getDdateSolt(_notebookDetailChangeModel); | ||
| 128 | + String pnum = _getPnum(_notebookDetailChangeModel); | ||
| 129 | + List<t.TableList> list = | ||
| 130 | + await _notebookDetailChangeModel.getNewTableList( | ||
| 131 | + context, | ||
| 132 | + '${ddate}', | ||
| 133 | + ddateSolt, | ||
| 134 | + pnum, | ||
| 135 | + _notebookDetailChangeModel.tableList); | ||
| 136 | + if (list.length == 0) { | ||
| 137 | + _notebookDetailChangeModel.isRecommend = true; | ||
| 138 | + } | ||
| 139 | + } | ||
| 140 | + _notebookDetailChangeModel.notifyListeners(); | ||
| 141 | + }, | ||
| 142 | + ); | ||
| 143 | + }).toList()), | ||
| 144 | + | ||
| 145 | + VEmptyView(60), | ||
| 146 | + //早市、午市、晚市 | ||
| 147 | + Row( | ||
| 148 | + // mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
| 149 | + children: _notebookDetailChangeModel.sunDateList.map((value) { | ||
| 150 | + return Container( | ||
| 151 | + margin: _notebookDetailChangeModel.sunDateList.length == 3 && | ||
| 152 | + value['ddateSolt'] == 3 | ||
| 153 | + ? EdgeInsets.only(right: 0) | ||
| 154 | + : EdgeInsets.only(right: ScreenUtil().setWidth(20)), | ||
| 155 | + child: CustomButton( | ||
| 156 | + onTap: () { | ||
| 157 | + FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 158 | + for (var item in _notebookDetailChangeModel.sunDateList) { | ||
| 159 | + item['isSelect'] = false; | ||
| 160 | + if (item['dateText'] == value['dateText']) { | ||
| 161 | + item['isSelect'] = true; | ||
| 162 | + String key = ''; | ||
| 163 | + | ||
| 164 | + if (item['ddateSolt'] == 1) { | ||
| 165 | + //早市 | ||
| 166 | + key = 'morning'; | ||
| 167 | + } else if (item['ddateSolt'] == 2) { | ||
| 168 | + //午市 | ||
| 169 | + key = 'noon'; | ||
| 170 | + } else if (item['ddateSolt'] == 3) { | ||
| 171 | + //晚市 | ||
| 172 | + key = 'night'; | ||
| 173 | + } | ||
| 174 | + if (key != '') { | ||
| 175 | + for (var sunitem | ||
| 176 | + in _notebookDetailChangeModel.dailyMap[key]) { | ||
| 177 | + if (sunitem['select'] == true) { | ||
| 178 | + _notebookDetailChangeModel.ddateStr = | ||
| 179 | + sunitem['title']; | ||
| 180 | + } | ||
| 181 | + } | ||
| 182 | + } | ||
| 183 | + _notebookDetailChangeModel.notifyListeners(); | ||
| 184 | + } | ||
| 185 | + } | ||
| 186 | + int ddate = _getDdate(_notebookDetailChangeModel); | ||
| 187 | + String pnum = _getPnum(_notebookDetailChangeModel); | ||
| 188 | + String ddateSolt = _getDdateSolt(_notebookDetailChangeModel); | ||
| 189 | + _notebookDetailChangeModel.getNewTableList( | ||
| 190 | + context, | ||
| 191 | + '${ddate}', | ||
| 192 | + '${ddateSolt}', | ||
| 193 | + pnum, | ||
| 194 | + _notebookDetailChangeModel.tableList); | ||
| 195 | + }, | ||
| 196 | + dateText: value['dateText'], | ||
| 197 | + dayText: '', | ||
| 198 | + isSelect: value['isSelect'], | ||
| 199 | + ), | ||
| 200 | + ); | ||
| 201 | + }).toList()), | ||
| 202 | + VEmptyView(60), | ||
| 203 | + | ||
| 204 | + ///人数选择 | ||
| 205 | + Row( | ||
| 206 | + mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
| 207 | + children: _notebookDetailChangeModel.personNumList.map((value) { | ||
| 208 | + return CustomButton( | ||
| 209 | + onTap: () { | ||
| 210 | + for (int j = 0; | ||
| 211 | + j < _notebookDetailChangeModel.personNumList.length; | ||
| 212 | + j++) { | ||
| 213 | + _notebookDetailChangeModel.personNumList[j]['isSelect'] = | ||
| 214 | + false; | ||
| 215 | + | ||
| 216 | + if (_notebookDetailChangeModel.personNumList[j] | ||
| 217 | + ['dateText'] == | ||
| 218 | + value['dateText']) { | ||
| 219 | + _notebookDetailChangeModel.personNumList[j]['isSelect'] = | ||
| 220 | + true; | ||
| 221 | + | ||
| 222 | + if (j < 5) { | ||
| 223 | + _notebookDetailChangeModel.numController.text = | ||
| 224 | + value['dateText']; | ||
| 225 | + FocusScope.of(context) | ||
| 226 | + .requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 227 | + | ||
| 228 | + } | ||
| 229 | + | ||
| 230 | + // if (j < 5) { | ||
| 231 | + // _notebookDetailChangeModel.personNumList[5] | ||
| 232 | + // ['dateText'] = '更多'; | ||
| 233 | + // } | ||
| 234 | + } | ||
| 235 | + } | ||
| 236 | + _notebookDetailChangeModel.notifyListeners(); | ||
| 237 | + //人数选择页面刷新 | ||
| 238 | + String pnum = _getPnum(_notebookDetailChangeModel); | ||
| 239 | + int ddate = _getDdate(_notebookDetailChangeModel); | ||
| 240 | + String ddateSolt = _getDdateSolt(_notebookDetailChangeModel); | ||
| 241 | + | ||
| 242 | + _notebookDetailChangeModel.getNewTableList( | ||
| 243 | + context, | ||
| 244 | + '${ddate}', | ||
| 245 | + ddateSolt, | ||
| 246 | + pnum, | ||
| 247 | + _notebookDetailChangeModel.tableList); | ||
| 248 | + }, | ||
| 249 | + dateText: value['dateText'], | ||
| 250 | + fontSize: value['fontSize'], | ||
| 251 | + dayText: '', | ||
| 252 | + width: value['width'], | ||
| 253 | + isImage: value['isImage'], | ||
| 254 | + isSelect: value['isSelect'], | ||
| 255 | + isTextFiled: value['isTextFiled'], | ||
| 256 | + model: _notebookDetailChangeModel, | ||
| 257 | + ); | ||
| 258 | + }).toList(), | ||
| 259 | + ) | ||
| 260 | + ], | ||
| 261 | + ), | ||
| 262 | + ); | ||
| 263 | + } | ||
| 264 | + | ||
| 265 | + _calendWidget(DateTime dateTime) { | ||
| 266 | + DialogUtil.showCalendarDialog(context, dateTime).then((day) { | ||
| 267 | + if (day != null) { | ||
| 268 | + // _createDateText(day); | ||
| 269 | + dateTime = day; | ||
| 270 | + int dateTimeMill = day.millisecondsSinceEpoch; | ||
| 271 | + String dateText = DateUtil.formatDateMs(dateTimeMill, format: 'MM-dd'); | ||
| 272 | + bool isThird = true; | ||
| 273 | + for (int i = 0; i < _notebookDetailChangeModel.dateList.length; i++) { | ||
| 274 | + _notebookDetailChangeModel.dateList[i]['select'] = false; | ||
| 275 | + | ||
| 276 | + if (_notebookDetailChangeModel.dateList[i]['title'] == dateText) { | ||
| 277 | + _notebookDetailChangeModel.dateList[i]['select'] = true; | ||
| 278 | + isThird = false; | ||
| 279 | + } | ||
| 280 | + } | ||
| 281 | + if (isThird) { | ||
| 282 | + _notebookDetailChangeModel.dateList[2]['select'] = true; | ||
| 283 | + _notebookDetailChangeModel.dateList[2]['title'] = dateText; | ||
| 284 | + } else { | ||
| 285 | + _notebookDetailChangeModel.dateList[2]['title'] = '其他'; | ||
| 286 | + } | ||
| 287 | + // 选完日历刷新页面 | ||
| 288 | + String ddateSolt = _getDdateSolt(_notebookDetailChangeModel); | ||
| 289 | + String pnum = _getPnum(_notebookDetailChangeModel); | ||
| 290 | + _notebookDetailChangeModel.getNewTableList( | ||
| 291 | + context, | ||
| 292 | + '${dateTimeMill}', | ||
| 293 | + ddateSolt, | ||
| 294 | + _getPnum(_notebookDetailChangeModel), | ||
| 295 | + _notebookDetailChangeModel.tableList); | ||
| 296 | + } | ||
| 297 | + _notebookDetailChangeModel.notifyListeners(); | ||
| 298 | + }); | ||
| 299 | + } | ||
| 300 | + | ||
| 301 | + /// 可订桌位 | ||
| 302 | + _middleWidget() { | ||
| 303 | + List canBookTable = []; | ||
| 304 | + if (_notebookDetailChangeModel.isRecommend) { | ||
| 305 | + canBookTable = _notebookDetailChangeModel.recommendList; | ||
| 306 | + } else { | ||
| 307 | + canBookTable = _notebookDetailChangeModel.tableList; | ||
| 308 | + } | ||
| 309 | + return Container( | ||
| 310 | + padding: EdgeInsets.all(ScreenUtil().setWidth(40)), | ||
| 311 | + color: MyColours.color_f5f5f5, | ||
| 312 | + child: Column( | ||
| 313 | + children: [ | ||
| 314 | + InkWell( | ||
| 315 | + onTap: () async { | ||
| 316 | + FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 317 | + //当前选中 月 日string | ||
| 318 | + String mdStr = ''; | ||
| 319 | + //今天 明天 其他天 | ||
| 320 | + for (var item in _notebookDetailChangeModel.dateList) { | ||
| 321 | + if (item['select'] == true) { | ||
| 322 | + mdStr = item['title']; | ||
| 323 | + } | ||
| 324 | + } | ||
| 325 | + String timeNowYear = | ||
| 326 | + DateUtil.formatDate(DateTime.now(), format: 'yyyy'); | ||
| 327 | + String ymyStr = timeNowYear + '-' + mdStr; //年月日 | ||
| 328 | + String timeStr = ymyStr + ' ' + "00:00:00"; | ||
| 329 | + int ddate = DateUtil.getDateMsByTimeStr(timeStr); //筛选日期时间戳 | ||
| 330 | + String ddateSolt = ''; | ||
| 331 | + for (var item in _notebookDetailChangeModel.sunDateList) { | ||
| 332 | + if (item['isSelect']) { | ||
| 333 | + ddateSolt = '${item['ddateSolt']}'; | ||
| 334 | + } | ||
| 335 | + } | ||
| 336 | + | ||
| 337 | + // String tempDdate = ymyStr + ' ' + ddateStr + ':00'; | ||
| 338 | + // int ddate = DateUtil.getDateMsByTimeStr(timeStr); | ||
| 339 | + Map temp = await NavigatorUtil.goSelectTablePage( | ||
| 340 | + context, widget.rid, ddate, ddateSolt, | ||
| 341 | + canChoose: true, | ||
| 342 | + object: {'object': _notebookDetailChangeModel.tableList}); | ||
| 343 | + // if (temp['tid'] != null) { | ||
| 344 | + // setReserveStatus("5", tid: temp['tid']); | ||
| 345 | + // } | ||
| 346 | + if (temp == null || temp['object'].length == 0) { | ||
| 347 | + if (_notebookDetailChangeModel.tableList.length == 0) { | ||
| 348 | + _notebookDetailChangeModel.isRecommend = true; | ||
| 349 | + _notebookDetailChangeModel.tableList = []; | ||
| 350 | + for (t.TableList item | ||
| 351 | + in _notebookDetailChangeModel.recommendList) { | ||
| 352 | + item.selected = false; | ||
| 353 | + } | ||
| 354 | + setState(() {}); | ||
| 355 | + } | ||
| 356 | + } else { | ||
| 357 | + _notebookDetailChangeModel.isRecommend = false; | ||
| 358 | + _notebookDetailChangeModel.tableList = temp['object']; | ||
| 359 | + // if (_notebookDetailChangeModel.tableList.length == 0) { | ||
| 360 | + // isRecommend = true; | ||
| 361 | + // } | ||
| 362 | + for (t.TableList item | ||
| 363 | + in _notebookDetailChangeModel.tableList) { | ||
| 364 | + item.selected = true; | ||
| 365 | + } | ||
| 366 | + setState(() {}); | ||
| 367 | + } | ||
| 368 | + | ||
| 369 | + // _notebookDetailChangeModel.notifyListeners(); | ||
| 370 | + }, | ||
| 371 | + child: Row( | ||
| 372 | + mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
| 373 | + crossAxisAlignment: CrossAxisAlignment.end, | ||
| 374 | + children: [ | ||
| 375 | + Text( | ||
| 376 | + '可订桌位', | ||
| 377 | + style: TextStyle( | ||
| 378 | + color: MyColours.color_353535, | ||
| 379 | + fontSize: ScreenUtil().setSp(30)), | ||
| 380 | + ), | ||
| 381 | + Row( | ||
| 382 | + children: [ | ||
| 383 | + Text('更多', | ||
| 384 | + style: TextStyle( | ||
| 385 | + color: MyColours.color_353535, | ||
| 386 | + fontSize: ScreenUtil().setSp(26))), | ||
| 387 | + HEmptyView(20), | ||
| 388 | + Image.asset( | ||
| 389 | + 'assets/arr_right_gray.png', | ||
| 390 | + width: ScreenUtil().setWidth(12), | ||
| 391 | + height: ScreenUtil().setWidth(22), | ||
| 392 | + ) | ||
| 393 | + ], | ||
| 394 | + ), | ||
| 395 | + ], | ||
| 396 | + )), | ||
| 397 | + VEmptyView(32), | ||
| 398 | + Align( | ||
| 399 | + alignment: Alignment.centerRight, | ||
| 400 | + child: Container( | ||
| 401 | + // color: Colors.red, | ||
| 402 | + // height: ScreenUtil().setHeight(178), | ||
| 403 | + height: ScreenUtil().setWidth(185), | ||
| 404 | + child: ListView.builder( | ||
| 405 | + physics: const NeverScrollableScrollPhysics(), | ||
| 406 | + itemBuilder: (BuildContext contxt, int index) { | ||
| 407 | + return NewTableItem( | ||
| 408 | + canBookTable[index], | ||
| 409 | + isRegionName: true, | ||
| 410 | + canSelected: true, | ||
| 411 | + onSelected: (table) { | ||
| 412 | + if ((table as t.TableList).selected) { | ||
| 413 | + _notebookDetailChangeModel.tableList.add(table); | ||
| 414 | + } else { | ||
| 415 | + _notebookDetailChangeModel.tableList | ||
| 416 | + .removeWhere((t) => t.id == table.id); | ||
| 417 | + } | ||
| 418 | + }, | ||
| 419 | + ); | ||
| 420 | + }, | ||
| 421 | + itemCount: canBookTable.length > 3 ? 3 : canBookTable.length, | ||
| 422 | + shrinkWrap: true, | ||
| 423 | + scrollDirection: Axis.horizontal, | ||
| 424 | + ), | ||
| 425 | + ), | ||
| 426 | + ), | ||
| 427 | + ], | ||
| 428 | + ), | ||
| 429 | + ); | ||
| 430 | + } | ||
| 431 | + | ||
| 432 | + _bottomWidget() { | ||
| 433 | + return Container( | ||
| 434 | + padding: EdgeInsets.symmetric( | ||
| 435 | + horizontal: ScreenUtil().setWidth(40), | ||
| 436 | + ), | ||
| 437 | + margin: EdgeInsets.only(top: ScreenUtil().setWidth(72)), | ||
| 438 | + child: Column( | ||
| 439 | + children: [ | ||
| 440 | + Row( | ||
| 441 | + mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
| 442 | + crossAxisAlignment: CrossAxisAlignment.center, | ||
| 443 | + children: [ | ||
| 444 | + Expanded( | ||
| 445 | + child: TextField( | ||
| 446 | + maxLines: 1, | ||
| 447 | + //输入文本的样式 | ||
| 448 | + style: TextStyle( | ||
| 449 | + fontSize: ScreenUtil().setSp(34), | ||
| 450 | + color: MyColours.color_353535), | ||
| 451 | + controller: _notebookDetailChangeModel.phoneController, | ||
| 452 | + focusNode: _phoneNode, | ||
| 453 | + // textAlignVertical: TextAlignVertical.top, | ||
| 454 | + decoration: InputDecoration( | ||
| 455 | + hintText: "客户电话", | ||
| 456 | + hintStyle: TextStyle( | ||
| 457 | + color: MyColours.color_999999, | ||
| 458 | + fontSize: ScreenUtil().setSp(34), | ||
| 459 | + ), | ||
| 460 | + // contentPadding: | ||
| 461 | + // EdgeInsets.only(bottom: ScreenUtil().setWidth(17)), | ||
| 462 | + border: InputBorder.none, | ||
| 463 | + ), | ||
| 464 | + onChanged: (value) {}, | ||
| 465 | + onEditingComplete: () { | ||
| 466 | + print('fff'); | ||
| 467 | + _phoneNode.unfocus(); | ||
| 468 | + }, | ||
| 469 | + keyboardType: TextInputType.number, | ||
| 470 | + ), | ||
| 471 | + ), | ||
| 472 | + HEmptyView(40), | ||
| 473 | + InkWell( | ||
| 474 | + onTap: () { | ||
| 475 | + _showDateChooseWidget(context); | ||
| 476 | + }, | ||
| 477 | + child: Text( | ||
| 478 | + int.parse(widget.detailEntity.is_set_ddate) == 0 | ||
| 479 | + ? '未设置到店时间' | ||
| 480 | + : _notebookDetailChangeModel.ddateStr, | ||
| 481 | + style: TextStyle( | ||
| 482 | + color: int.parse(widget.detailEntity.is_set_ddate) == 0 | ||
| 483 | + ? MyColours.color_999999 | ||
| 484 | + : MyColours.color_199095, | ||
| 485 | + fontSize: ScreenUtil().setSp(34), | ||
| 486 | + ), | ||
| 487 | + ), | ||
| 488 | + ), | ||
| 489 | + ], | ||
| 490 | + ), | ||
| 491 | + VEmptyView(40), | ||
| 492 | + MyDivider(ScreenUtil().setWidth(335 * 2), ScreenUtil().setWidth(2), | ||
| 493 | + color: MyColours.color_F1F0F4), | ||
| 494 | + VEmptyView(72), | ||
| 495 | + Row( | ||
| 496 | + mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
| 497 | + crossAxisAlignment: CrossAxisAlignment.center, | ||
| 498 | + children: [ | ||
| 499 | + Expanded( | ||
| 500 | + child: TextField( | ||
| 501 | + maxLines: 1, | ||
| 502 | + | ||
| 503 | + //输入文本的样式 | ||
| 504 | + style: TextStyle( | ||
| 505 | + fontSize: ScreenUtil().setSp(34), | ||
| 506 | + color: MyColours.color_353535), | ||
| 507 | + controller: _notebookDetailChangeModel.nameController, | ||
| 508 | + focusNode: _nameNode, | ||
| 509 | + // textAlignVertical: TextAlignVertical.top, | ||
| 510 | + decoration: InputDecoration( | ||
| 511 | + hintText: "客户姓名(必填)", | ||
| 512 | + hintStyle: TextStyle( | ||
| 513 | + color: MyColours.color_999999, | ||
| 514 | + fontSize: ScreenUtil().setSp(34), | ||
| 515 | + ), | ||
| 516 | + // contentPadding: | ||
| 517 | + // EdgeInsets.only(bottom: ScreenUtil().setWidth(17)), | ||
| 518 | + border: InputBorder.none, | ||
| 519 | + ), | ||
| 520 | + onChanged: (value) {}, | ||
| 521 | + onEditingComplete: () { | ||
| 522 | + print('fff'); | ||
| 523 | + _nameNode.unfocus(); | ||
| 524 | + }, | ||
| 525 | + // keyboardType: TextInputType.number, | ||
| 526 | + ), | ||
| 527 | + ), | ||
| 528 | + HEmptyView(40), | ||
| 529 | + Row( | ||
| 530 | + children: _notebookDetailChangeModel.sexList.map((value) { | ||
| 531 | + return _callButton( | ||
| 532 | + onPress: () { | ||
| 533 | + for (var item in _notebookDetailChangeModel.sexList) { | ||
| 534 | + item['select'] = false; | ||
| 535 | + if (item['title'] == value['title']) { | ||
| 536 | + item['select'] = true; | ||
| 537 | + } | ||
| 538 | + } | ||
| 539 | + _notebookDetailChangeModel.notifyListeners(); | ||
| 540 | + }, | ||
| 541 | + content: value['title'], | ||
| 542 | + hasLeftBorder: value['hasLeftBorder'], | ||
| 543 | + isSelect: value['select']); | ||
| 544 | + }).toList()), | ||
| 545 | + ], | ||
| 546 | + ), | ||
| 547 | + VEmptyView(40), | ||
| 548 | + MyDivider(ScreenUtil().setWidth(335 * 2), ScreenUtil().setWidth(2), | ||
| 549 | + color: MyColours.color_F1F0F4), | ||
| 550 | + VEmptyView(72), | ||
| 551 | + TextField( | ||
| 552 | + maxLines: 1, | ||
| 553 | + inputFormatters: [LengthLimitingTextInputFormatter(25)], | ||
| 554 | + //输入文本的样式 | ||
| 555 | + style: TextStyle( | ||
| 556 | + fontSize: ScreenUtil().setSp(34), | ||
| 557 | + color: MyColours.color_353535), | ||
| 558 | + controller: _notebookDetailChangeModel.customController, | ||
| 559 | + focusNode: _needNode, | ||
| 560 | + // textAlignVertical: TextAlignVertical.top, | ||
| 561 | + decoration: InputDecoration( | ||
| 562 | + hintText: "客户要求(25字以内,选填)", | ||
| 563 | + hintStyle: TextStyle( | ||
| 564 | + color: MyColours.color_999999, | ||
| 565 | + fontSize: ScreenUtil().setSp(34), | ||
| 566 | + ), | ||
| 567 | + // contentPadding: | ||
| 568 | + // EdgeInsets.only(bottom: ScreenUtil().setWidth(17)), | ||
| 569 | + border: InputBorder.none, | ||
| 570 | + ), | ||
| 571 | + onChanged: (value) {}, | ||
| 572 | + onEditingComplete: () { | ||
| 573 | + print('fff'); | ||
| 574 | + _needNode.unfocus(); | ||
| 575 | + }, | ||
| 576 | + // keyboardType: TextInputType.number, | ||
| 577 | + ), | ||
| 578 | + VEmptyView(40), | ||
| 579 | + MyDivider(ScreenUtil().setWidth(335 * 2), ScreenUtil().setWidth(2), | ||
| 580 | + color: MyColours.color_F1F0F4), | ||
| 581 | + // VEmptyView(72), | ||
| 582 | + // VEmptyView(62), | ||
| 583 | + ], | ||
| 584 | + ), | ||
| 585 | + ); | ||
| 586 | + } | ||
| 587 | + | ||
| 588 | + ///底部弹框,设置时间30分钟间隔布局 | ||
| 589 | + _showDateChooseWidget(BuildContext context) async { | ||
| 590 | + List tempMndList = []; | ||
| 591 | + | ||
| 592 | + String title = '早市'; | ||
| 593 | + String key; | ||
| 594 | + for (var item in _notebookDetailChangeModel.sunDateList) { | ||
| 595 | + if (item['isSelect'] == true) { | ||
| 596 | + title = item['dateText']; | ||
| 597 | + key = item['key']; | ||
| 598 | + tempMndList = _notebookDetailChangeModel.dailyMap[key]; | ||
| 599 | + } | ||
| 600 | + } | ||
| 601 | + //计算行数 | ||
| 602 | + | ||
| 603 | + int line = 0; | ||
| 604 | + int count = tempMndList.length; | ||
| 605 | + if (count % 3 == 0) { | ||
| 606 | + line = int.parse('${count / 3}'); | ||
| 607 | + } else { | ||
| 608 | + line = (count / 3).ceil(); | ||
| 609 | + } | ||
| 610 | + int height = 85 + 40 + 36 * line + (line - 1) * 15; | ||
| 611 | + final option = await showModalBottomSheet( | ||
| 612 | + context: context, | ||
| 613 | + backgroundColor: Colors.white, | ||
| 614 | + builder: (context) { | ||
| 615 | + return StatefulBuilder(builder: (context, state) { | ||
| 616 | + return SafeArea( | ||
| 617 | + child: Container( | ||
| 618 | + decoration: BoxDecoration( | ||
| 619 | + borderRadius: | ||
| 620 | + BorderRadius.circular(ScreenUtil().setWidth(10))), | ||
| 621 | + height: ScreenUtil().setWidth(height * 2), | ||
| 622 | + child: Column( | ||
| 623 | + children: [ | ||
| 624 | + InkWell( | ||
| 625 | + onTap: () { | ||
| 626 | + Navigator.pop(context); | ||
| 627 | + }, | ||
| 628 | + child: Align( | ||
| 629 | + alignment: Alignment.centerRight, | ||
| 630 | + child: Container( | ||
| 631 | + padding: EdgeInsets.fromLTRB( | ||
| 632 | + ScreenUtil().setWidth(40), | ||
| 633 | + ScreenUtil().setWidth(40), | ||
| 634 | + ScreenUtil().setWidth(40), | ||
| 635 | + ScreenUtil().setWidth(10)), | ||
| 636 | + child: Image.asset( | ||
| 637 | + 'assets/close.png', | ||
| 638 | + width: ScreenUtil().setWidth(32), | ||
| 639 | + height: ScreenUtil().setWidth(32), | ||
| 640 | + ), | ||
| 641 | + ), | ||
| 642 | + ), | ||
| 643 | + ), | ||
| 644 | + Center( | ||
| 645 | + child: Text(title, | ||
| 646 | + style: TextStyle( | ||
| 647 | + fontSize: ScreenUtil().setSp(34), | ||
| 648 | + fontWeight: FontWeight.bold, | ||
| 649 | + color: MyColours.color_353535)), | ||
| 650 | + ), | ||
| 651 | + VEmptyView(40), | ||
| 652 | + Padding( | ||
| 653 | + padding: EdgeInsets.symmetric( | ||
| 654 | + horizontal: ScreenUtil().setWidth(60)), | ||
| 655 | + child: GridView.builder( | ||
| 656 | + padding: | ||
| 657 | + EdgeInsets.only(top: ScreenUtil().setWidth(20)), | ||
| 658 | + shrinkWrap: true, | ||
| 659 | + cacheExtent: ScreenUtil().setWidth(0), | ||
| 660 | + itemCount: tempMndList.length, | ||
| 661 | + gridDelegate: | ||
| 662 | + SliverGridDelegateWithFixedCrossAxisCount( | ||
| 663 | + crossAxisCount: 3, | ||
| 664 | + childAspectRatio: 80 / 36, | ||
| 665 | + mainAxisSpacing: | ||
| 666 | + ScreenUtil().setWidth(15 * 2), | ||
| 667 | + crossAxisSpacing: | ||
| 668 | + ScreenUtil().setWidth(38 * 2)), | ||
| 669 | + itemBuilder: (BuildContext context, int index) { | ||
| 670 | + // locationState = state; | ||
| 671 | + return CustomButton( | ||
| 672 | + onTap: () { | ||
| 673 | + // state(() { | ||
| 674 | + for (var item in tempMndList) { | ||
| 675 | + item['select'] = false; | ||
| 676 | + if (item['title'] == | ||
| 677 | + tempMndList[index]['title']) { | ||
| 678 | + item['select'] = true; | ||
| 679 | + widget.detailEntity.is_set_ddate = '1'; | ||
| 680 | + _notebookDetailChangeModel.isSetDate = "1"; | ||
| 681 | + _notebookDetailChangeModel.ddateStr = | ||
| 682 | + item['title']; | ||
| 683 | + } | ||
| 684 | + } | ||
| 685 | + // }); | ||
| 686 | + | ||
| 687 | + _notebookDetailChangeModel.notifyListeners(); | ||
| 688 | + Navigator.pop(context); | ||
| 689 | + }, | ||
| 690 | + width: 80, | ||
| 691 | + height: 36, | ||
| 692 | + dateText: tempMndList[index]['title'].toString(), | ||
| 693 | + dayText: '', | ||
| 694 | + isSelect: tempMndList[index]['select'], | ||
| 695 | + ); | ||
| 696 | + })) | ||
| 697 | + ], | ||
| 698 | + ), | ||
| 699 | + )); | ||
| 700 | + }); | ||
| 701 | + }); | ||
| 702 | + } | ||
| 703 | + | ||
| 704 | + Widget _callButton( | ||
| 705 | + {GestureTapCallback onPress, | ||
| 706 | + content, | ||
| 707 | + hasLeftBorder = true, | ||
| 708 | + isSelect = false}) { | ||
| 709 | + return InkWell( | ||
| 710 | + onTap: onPress, | ||
| 711 | + child: Container( | ||
| 712 | + width: ScreenUtil().setWidth(84), | ||
| 713 | + height: ScreenUtil().setHeight(48), | ||
| 714 | + decoration: BoxDecoration( | ||
| 715 | + color: isSelect ? MyColours.color_199095 : MyColours.color_fefefe, | ||
| 716 | + border: Border( | ||
| 717 | + bottom: BorderSide( | ||
| 718 | + color: MyColours.color_6AB6B9, | ||
| 719 | + width: ScreenUtil().setWidth(2)), | ||
| 720 | + top: BorderSide( | ||
| 721 | + color: MyColours.color_6AB6B9, | ||
| 722 | + width: ScreenUtil().setWidth(2)), | ||
| 723 | + left: hasLeftBorder | ||
| 724 | + ? BorderSide( | ||
| 725 | + color: MyColours.color_6AB6B9, | ||
| 726 | + width: ScreenUtil().setWidth(2)) | ||
| 727 | + : BorderSide.none, | ||
| 728 | + right: BorderSide( | ||
| 729 | + color: MyColours.color_6AB6B9, | ||
| 730 | + width: ScreenUtil().setWidth(2)))), | ||
| 731 | + child: Align( | ||
| 732 | + alignment: Alignment.center, | ||
| 733 | + child: Text( | ||
| 734 | + content, | ||
| 735 | + style: TextStyle( | ||
| 736 | + color: isSelect ? Colors.white : MyColours.color_353535, | ||
| 737 | + fontSize: ScreenUtil().setSp(28)), | ||
| 738 | + ), | ||
| 739 | + ), | ||
| 740 | + ), | ||
| 741 | + ); | ||
| 742 | + } | ||
| 743 | + | ||
| 744 | + @override | ||
| 745 | + Widget build(BuildContext context) { | ||
| 746 | + _notebookDetailChangeModel = | ||
| 747 | + Provider.of<NotebookDetailChangeModel>(context, listen: true); | ||
| 748 | + return GestureDetector( | ||
| 749 | + behavior: HitTestBehavior.translucent, | ||
| 750 | + onTap: () { | ||
| 751 | + FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 752 | + }, | ||
| 753 | + child: Scaffold( | ||
| 754 | + backgroundColor: Colors.white, | ||
| 755 | + body: Column(children: <Widget>[ | ||
| 756 | + SizedBox(height: ScreenUtil.statusBarHeight), | ||
| 757 | + MyAppBar( | ||
| 758 | + "变更预订", | ||
| 759 | + showBack: true, | ||
| 760 | + ), | ||
| 761 | + Expanded( | ||
| 762 | + child: SingleChildScrollView( | ||
| 763 | + child: Column( | ||
| 764 | + children: [_topWidget(), _middleWidget(), _bottomWidget()], | ||
| 765 | + ))), | ||
| 766 | + Container( | ||
| 767 | + padding: EdgeInsets.symmetric( | ||
| 768 | + horizontal: ScreenUtil().setWidth(40), | ||
| 769 | + vertical: ScreenUtil().setWidth(60), | ||
| 770 | + ), | ||
| 771 | + child: CommonButton( | ||
| 772 | + width: double.infinity, | ||
| 773 | + height: 84, | ||
| 774 | + fontSize: 34, | ||
| 775 | + content: "确定修改", | ||
| 776 | + state: 2, | ||
| 777 | + onPress: () async { | ||
| 778 | + String name = | ||
| 779 | + _notebookDetailChangeModel.nameController.text.trim(); | ||
| 780 | + if (ObjectUtil.isEmpty(name)) { | ||
| 781 | + Utils.showToast("请填写客户姓名"); | ||
| 782 | + return; | ||
| 783 | + } | ||
| 784 | + if (_notebookDetailChangeModel.tableList.length == 0) { | ||
| 785 | + Utils.showToast("请选择桌位"); | ||
| 786 | + return; | ||
| 787 | + } | ||
| 788 | + SunReserveInfoModel _model = | ||
| 789 | + await _notebookDetailChangeModel | ||
| 790 | + .setReserveInfo(context); | ||
| 791 | + if (ObjectUtil.isNotEmpty(_model.row) || | ||
| 792 | + ObjectUtil.isNotEmpty(_model.row.id)) { | ||
| 793 | + print('变更成功'); | ||
| 794 | + // _notebookDetailChangeModel.clearData(); | ||
| 795 | + bus.emit("refresh_detail"); | ||
| 796 | + String ddate_solt = ''; | ||
| 797 | + if (_model.row.isSetDdate == '1') { | ||
| 798 | + String createtime = _model.row.ddate.toString() + '000'; | ||
| 799 | + DateTime createTime = | ||
| 800 | + DateTime.fromMillisecondsSinceEpoch( | ||
| 801 | + int.parse(createtime)); | ||
| 802 | + ddate_solt = DateUtil.formatDate(createTime, | ||
| 803 | + format: DateFormats.h_m); | ||
| 804 | + } else { | ||
| 805 | + if (_model.row.ddateSolt == '1') { | ||
| 806 | + ddate_solt = '早餐'; | ||
| 807 | + } else if (_model.row.ddateSolt == '2') { | ||
| 808 | + ddate_solt = '午餐'; | ||
| 809 | + } else if (_model.row.ddateSolt == '3') { | ||
| 810 | + ddate_solt = '晚餐'; | ||
| 811 | + } | ||
| 812 | + } | ||
| 813 | + List<dynamic> tableinfo = | ||
| 814 | + convert.jsonDecode(_model.row.tableinfo); | ||
| 815 | + print(tableinfo); | ||
| 816 | + String _nameStr = _model.row.name; | ||
| 817 | + if (tableinfo.length > 1) { | ||
| 818 | + _nameStr = _model.row.name + '等${tableinfo.length}桌'; | ||
| 819 | + } | ||
| 820 | + NavigatorUtil.goInvicationPage(context, _model.row.id, | ||
| 821 | + _nameStr, _model.row.ddate, ddate_solt, | ||
| 822 | + replace: true); | ||
| 823 | + } else { | ||
| 824 | + Utils.showToast("变更预订订单失败,请重试!"); | ||
| 825 | + } | ||
| 826 | + }, | ||
| 827 | + )) | ||
| 828 | + ]), | ||
| 829 | + )); | ||
| 830 | + } | ||
| 831 | +} | ||
| 832 | + | ||
| 833 | +/// 获取日期 今天 明天 后天等等 | ||
| 834 | +int _getDdate(NotebookDetailChangeModel model) { | ||
| 835 | + //当前选中 月 日string | ||
| 836 | + String mdStr = ''; | ||
| 837 | + //今天 明天 其他天 | ||
| 838 | + for (var item in model.dateList) { | ||
| 839 | + if (item['select'] == true) { | ||
| 840 | + mdStr = item['title']; | ||
| 841 | + } | ||
| 842 | + } | ||
| 843 | + String timeNowYear = DateUtil.formatDate(DateTime.now(), format: 'yyyy'); | ||
| 844 | + String ymyStr = timeNowYear + '-' + mdStr; //年月日 | ||
| 845 | + String timeStr = ymyStr + ' ' + "00:00:00"; | ||
| 846 | + int ddate = DateUtil.getDateMsByTimeStr(timeStr); //筛选日期时间戳 | ||
| 847 | + return ddate; | ||
| 848 | +} | ||
| 849 | + | ||
| 850 | +/// 获取早餐、午餐、晚餐字段 1 ,2, 3 | ||
| 851 | +String _getDdateSolt(NotebookDetailChangeModel model) { | ||
| 852 | + String ddateSolt = ''; | ||
| 853 | + for (var item in model.sunDateList) { | ||
| 854 | + if (item['isSelect']) { | ||
| 855 | + ddateSolt = '${item['ddateSolt']}'; | ||
| 856 | + } | ||
| 857 | + } | ||
| 858 | + return ddateSolt; | ||
| 859 | +} | ||
| 860 | + | ||
| 861 | +/// 选中前面的按钮获取人数,输入的自己获取 | ||
| 862 | +String _getPnum(NotebookDetailChangeModel model) { | ||
| 863 | + String pnum = '6'; | ||
| 864 | + for (var item in model.personNumList) { | ||
| 865 | + if (item['isSelect']) { | ||
| 866 | + pnum = item['dateText']; | ||
| 867 | + } | ||
| 868 | + } | ||
| 869 | + if (pnum == '更多') { | ||
| 870 | + pnum = '6'; | ||
| 871 | + } | ||
| 872 | + return pnum; | ||
| 873 | +} | ||
| 874 | + | ||
| 875 | +class CustomButton extends StatefulWidget { | ||
| 876 | + final String dateText; | ||
| 877 | + final String dayText; | ||
| 878 | + final bool isSelect; | ||
| 879 | + final double fontSize; | ||
| 880 | + final bool isImage; | ||
| 881 | + final double width; | ||
| 882 | + final GestureTapCallback onTap; | ||
| 883 | + final bool isTextFiled; | ||
| 884 | + final NotebookDetailChangeModel model; | ||
| 885 | + final double height; | ||
| 886 | + | ||
| 887 | + const CustomButton({ | ||
| 888 | + Key key, | ||
| 889 | + this.dateText, | ||
| 890 | + this.dayText, | ||
| 891 | + this.isSelect, | ||
| 892 | + this.fontSize = 34, | ||
| 893 | + this.isImage = false, | ||
| 894 | + this.width = 105, | ||
| 895 | + this.onTap, | ||
| 896 | + this.isTextFiled = false, | ||
| 897 | + this.model, | ||
| 898 | + this.height = 25, | ||
| 899 | + }) : super(key: key); | ||
| 900 | + @override | ||
| 901 | + _ButtonState createState() => _ButtonState(); | ||
| 902 | +} | ||
| 903 | + | ||
| 904 | +class _ButtonState extends State<CustomButton> { | ||
| 905 | + FocusNode _cancelNode = FocusNode(); | ||
| 906 | + @override | ||
| 907 | + Widget build(BuildContext context) { | ||
| 908 | + String imgStrSelect = widget.isImage && !widget.isTextFiled | ||
| 909 | + ? 'assets/calender_select.png' | ||
| 910 | + : 'assets/more_select.png'; | ||
| 911 | + String imgStrNormal = widget.isImage && !widget.isTextFiled | ||
| 912 | + ? 'assets/calender_narmol.png' | ||
| 913 | + : 'assets/more_narmol.png'; | ||
| 914 | + return InkWell( | ||
| 915 | + onTap: widget.onTap, | ||
| 916 | + child: Container( | ||
| 917 | + width: ScreenUtil().setWidth(widget.width * 2), | ||
| 918 | + height: ScreenUtil().setWidth(widget.height * 2), | ||
| 919 | + decoration: BoxDecoration( | ||
| 920 | + color: widget.isSelect ? MyColours.color_199095 : Colors.white, | ||
| 921 | + borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10)), | ||
| 922 | + border: Border.all( | ||
| 923 | + color: MyColours.color_199095, | ||
| 924 | + width: ScreenUtil().setWidth(2))), | ||
| 925 | + child: Row( | ||
| 926 | + mainAxisAlignment: MainAxisAlignment.center, | ||
| 927 | + children: [ | ||
| 928 | + widget.isTextFiled | ||
| 929 | + ? Container( | ||
| 930 | + alignment: Alignment.center, | ||
| 931 | + // color: Colors.red, | ||
| 932 | + width: ScreenUtil().setWidth(114), | ||
| 933 | + height: ScreenUtil().setWidth(50), | ||
| 934 | + // padding: EdgeInsets.zero, | ||
| 935 | + child: TextField( | ||
| 936 | + controller: widget.model.numController, | ||
| 937 | + maxLines: 1, | ||
| 938 | + | ||
| 939 | + inputFormatters: [ | ||
| 940 | + LengthLimitingTextInputFormatter(3), | ||
| 941 | + WhitelistingTextInputFormatter.digitsOnly | ||
| 942 | + ], | ||
| 943 | + //光标颜色 | ||
| 944 | + cursorColor: widget.isSelect | ||
| 945 | + ? Colors.white | ||
| 946 | + : MyColours.color_199095, | ||
| 947 | + //输入文本的样式 | ||
| 948 | + style: TextStyle( | ||
| 949 | + fontSize: ScreenUtil().setSp(30), | ||
| 950 | + color: widget.isSelect | ||
| 951 | + ? Colors.white | ||
| 952 | + : MyColours.color_199095), | ||
| 953 | + // controller: _cancelController, | ||
| 954 | + focusNode: _cancelNode, | ||
| 955 | + textAlignVertical: TextAlignVertical.bottom, | ||
| 956 | + decoration: InputDecoration( | ||
| 957 | + // fillColor: Colors.lightGreenAccent, | ||
| 958 | + // filled: true, | ||
| 959 | + border: OutlineInputBorder(borderSide: BorderSide.none), | ||
| 960 | + hintText: "更多", | ||
| 961 | + hintStyle: TextStyle( | ||
| 962 | + color: widget.isSelect | ||
| 963 | + ? Colors.white | ||
| 964 | + : MyColours.color_199095, | ||
| 965 | + fontSize: ScreenUtil().setSp(30), | ||
| 966 | + ), | ||
| 967 | + // contentPadding: EdgeInsets.only( | ||
| 968 | + // bottom: ScreenUtil().setWidth(30)), //ios 17 | ||
| 969 | + // border: InputBorder.none, | ||
| 970 | + ), | ||
| 971 | + onChanged: (value) { | ||
| 972 | + bool isThird = true; | ||
| 973 | + for (int i = 0; | ||
| 974 | + i < widget.model.personNumList.length; | ||
| 975 | + i++) { | ||
| 976 | + widget.model.personNumList[i]['isSelect'] = false; | ||
| 977 | + | ||
| 978 | + if (widget.model.personNumList[i]['dateText'] == | ||
| 979 | + value) { | ||
| 980 | + widget.model.personNumList[i]['isSelect'] = true; | ||
| 981 | + isThird = false; | ||
| 982 | + } | ||
| 983 | + } | ||
| 984 | + if (isThird) { | ||
| 985 | + widget.model.personNumList[5]['isSelect'] = true; | ||
| 986 | + widget.model.personNumList[5]['dateText'] = value; | ||
| 987 | + } else { | ||
| 988 | + widget.model.personNumList[5]['dateText'] = '更多'; | ||
| 989 | + } | ||
| 990 | + widget.model.notifyListeners(); | ||
| 991 | + }, | ||
| 992 | + onEditingComplete: () { | ||
| 993 | + _cancelNode.unfocus(); | ||
| 994 | + int ddate = _getDdate(widget.model); | ||
| 995 | + String ddateSolt = _getDdateSolt(widget.model); | ||
| 996 | + String pnum = _getPnum(widget.model); | ||
| 997 | + | ||
| 998 | + widget.model.getNewTableList(context, '${ddate}', | ||
| 999 | + ddateSolt, pnum, widget.model.tableList); | ||
| 1000 | + }, | ||
| 1001 | + keyboardType: TextInputType.number, | ||
| 1002 | + ), | ||
| 1003 | + ) | ||
| 1004 | + : Text(widget.dateText, | ||
| 1005 | + style: TextStyle( | ||
| 1006 | + fontWeight: widget.isImage && widget.dateText == "其他" | ||
| 1007 | + ? FontWeight.normal | ||
| 1008 | + : FontWeight.bold, | ||
| 1009 | + color: widget.isSelect | ||
| 1010 | + ? MyColours.color_fefefe | ||
| 1011 | + : MyColours.color_199095, | ||
| 1012 | + fontSize: ScreenUtil().setSp(widget.fontSize))), | ||
| 1013 | + widget.isImage && !widget.isTextFiled | ||
| 1014 | + ? HEmptyView(20) | ||
| 1015 | + : Container(), | ||
| 1016 | + widget.isImage | ||
| 1017 | + ? Image.asset(widget.isSelect ? imgStrSelect : imgStrNormal, | ||
| 1018 | + width: ScreenUtil().setWidth(36)) | ||
| 1019 | + : Text(widget.dayText, | ||
| 1020 | + style: TextStyle( | ||
| 1021 | + fontWeight: FontWeight.bold, | ||
| 1022 | + color: widget.isSelect | ||
| 1023 | + ? MyColours.color_fefefe | ||
| 1024 | + : MyColours.color_199095, | ||
| 1025 | + fontSize: ScreenUtil().setSp(30))) | ||
| 1026 | + ], | ||
| 1027 | + ), | ||
| 1028 | + ), | ||
| 1029 | + ); | ||
| 1030 | + } | ||
| 1031 | +} |
| @@ -5,14 +5,18 @@ import 'package:flutter/cupertino.dart'; | @@ -5,14 +5,18 @@ import 'package:flutter/cupertino.dart'; | ||
| 5 | import 'package:flutter/material.dart'; | 5 | import 'package:flutter/material.dart'; |
| 6 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 6 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| 7 | import 'package:one_key/app.dart'; | 7 | import 'package:one_key/app.dart'; |
| 8 | +import 'package:one_key/pages/enter/enter_page.dart'; | ||
| 8 | import 'package:one_key/pages/message/message_page.dart'; | 9 | import 'package:one_key/pages/message/message_page.dart'; |
| 9 | import 'package:one_key/pages/my/my_page.dart'; | 10 | import 'package:one_key/pages/my/my_page.dart'; |
| 10 | import 'package:one_key/pages/notebook/notebook_page.dart'; | 11 | import 'package:one_key/pages/notebook/notebook_page.dart'; |
| 12 | +import 'package:one_key/pages/table/table_manager_page.dart'; | ||
| 11 | import 'package:one_key/provider/contact_model.dart'; | 13 | import 'package:one_key/provider/contact_model.dart'; |
| 14 | +import 'package:one_key/provider/enter_model.dart'; | ||
| 12 | import 'package:one_key/provider/message_dialog_model.dart'; | 15 | import 'package:one_key/provider/message_dialog_model.dart'; |
| 13 | import 'package:one_key/provider/message_model.dart'; | 16 | import 'package:one_key/provider/message_model.dart'; |
| 14 | import 'package:one_key/provider/my_model.dart'; | 17 | import 'package:one_key/provider/my_model.dart'; |
| 15 | import 'package:one_key/provider/notebook_model.dart'; | 18 | import 'package:one_key/provider/notebook_model.dart'; |
| 19 | +import 'package:one_key/provider/table_manager_model.dart'; | ||
| 16 | import 'package:one_key/provider/tools.dart'; | 20 | import 'package:one_key/provider/tools.dart'; |
| 17 | import 'package:one_key/provider/update_model.dart'; | 21 | import 'package:one_key/provider/update_model.dart'; |
| 18 | import 'package:one_key/provider/user_model.dart'; | 22 | import 'package:one_key/provider/user_model.dart'; |
| @@ -29,7 +33,7 @@ import 'package:tpns_flutter_plugin/tpns_flutter_plugin.dart'; | @@ -29,7 +33,7 @@ import 'package:tpns_flutter_plugin/tpns_flutter_plugin.dart'; | ||
| 29 | class HomePage extends StatefulWidget { | 33 | class HomePage extends StatefulWidget { |
| 30 | final int initialIndex; //初始tab | 34 | final int initialIndex; //初始tab |
| 31 | 35 | ||
| 32 | - HomePage({this.initialIndex = 1}); | 36 | + HomePage({this.initialIndex = 2}); |
| 33 | 37 | ||
| 34 | @override | 38 | @override |
| 35 | State<StatefulWidget> createState() { | 39 | State<StatefulWidget> createState() { |
| @@ -40,7 +44,7 @@ class HomePage extends StatefulWidget { | @@ -40,7 +44,7 @@ class HomePage extends StatefulWidget { | ||
| 40 | 44 | ||
| 41 | class HomePageState extends State<HomePage> with WidgetsBindingObserver { | 45 | class HomePageState extends State<HomePage> with WidgetsBindingObserver { |
| 42 | List<Widget> pages = List<Widget>(); | 46 | List<Widget> pages = List<Widget>(); |
| 43 | - int _currIndex = 1; | 47 | + int _currIndex = 2; |
| 44 | Color _activeColor = MyColours.color_199095; | 48 | Color _activeColor = MyColours.color_199095; |
| 45 | Color _defaultColor = MyColours.color_999999; | 49 | Color _defaultColor = MyColours.color_999999; |
| 46 | 50 | ||
| @@ -60,10 +64,18 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | @@ -60,10 +64,18 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | ||
| 60 | create: (_) => MessageModel(), | 64 | create: (_) => MessageModel(), |
| 61 | child: SafeArea(child: MessagePage()), | 65 | child: SafeArea(child: MessagePage()), |
| 62 | )) | 66 | )) |
| 67 | + ..add(ChangeNotifierProvider<EnterModel>( | ||
| 68 | + create: (_) => EnterModel(null), | ||
| 69 | + child: SafeArea(child: EnterPage()), | ||
| 70 | + )) | ||
| 63 | ..add(ChangeNotifierProvider<NoteBookModel>( | 71 | ..add(ChangeNotifierProvider<NoteBookModel>( |
| 64 | create: (_) => NoteBookModel(), | 72 | create: (_) => NoteBookModel(), |
| 65 | child: SafeArea(child: NoteBookPage()), | 73 | child: SafeArea(child: NoteBookPage()), |
| 66 | )) | 74 | )) |
| 75 | + ..add(ChangeNotifierProvider<TableManagerModel>( | ||
| 76 | + create: (_) => TableManagerModel(), | ||
| 77 | + child: SafeArea(child: TableManagerPage()), | ||
| 78 | + )) | ||
| 67 | ..add(ChangeNotifierProvider<MyModel>( | 79 | ..add(ChangeNotifierProvider<MyModel>( |
| 68 | create: (_) => MyModel(), | 80 | create: (_) => MyModel(), |
| 69 | child: MyPage(), | 81 | child: MyPage(), |
| @@ -313,6 +325,24 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | @@ -313,6 +325,24 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | ||
| 313 | ), | 325 | ), |
| 314 | BottomNavigationBarItem( | 326 | BottomNavigationBarItem( |
| 315 | icon: Image( | 327 | icon: Image( |
| 328 | + image: AssetImage("assets/message_default.png"), | ||
| 329 | + width: ScreenUtil().setWidth(48), | ||
| 330 | + height: ScreenUtil().setWidth(48), | ||
| 331 | + ), | ||
| 332 | + activeIcon: Image( | ||
| 333 | + image: AssetImage("assets/message_selected.png"), | ||
| 334 | + width: ScreenUtil().setWidth(48), | ||
| 335 | + height: ScreenUtil().setWidth(48), | ||
| 336 | + ), | ||
| 337 | + title: Text( | ||
| 338 | + "订座", | ||
| 339 | + style: TextStyle( | ||
| 340 | + color: _currIndex == 1 ? _activeColor : _defaultColor, | ||
| 341 | + fontSize: ScreenUtil().setSp(22)), | ||
| 342 | + ), | ||
| 343 | + ), | ||
| 344 | + BottomNavigationBarItem( | ||
| 345 | + icon: Image( | ||
| 316 | image: AssetImage("assets/notebook_default.png"), | 346 | image: AssetImage("assets/notebook_default.png"), |
| 317 | width: ScreenUtil().setWidth(48), | 347 | width: ScreenUtil().setWidth(48), |
| 318 | height: ScreenUtil().setWidth(48), | 348 | height: ScreenUtil().setWidth(48), |
| @@ -325,7 +355,25 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | @@ -325,7 +355,25 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | ||
| 325 | title: Text( | 355 | title: Text( |
| 326 | "已预订", | 356 | "已预订", |
| 327 | style: TextStyle( | 357 | style: TextStyle( |
| 328 | - color: _currIndex == 1 ? _activeColor : _defaultColor, | 358 | + color: _currIndex == 2 ? _activeColor : _defaultColor, |
| 359 | + fontSize: ScreenUtil().setSp(22)), | ||
| 360 | + ), | ||
| 361 | + ), | ||
| 362 | + BottomNavigationBarItem( | ||
| 363 | + icon: Image( | ||
| 364 | + image: AssetImage("assets/notebook_default.png"), | ||
| 365 | + width: ScreenUtil().setWidth(48), | ||
| 366 | + height: ScreenUtil().setWidth(48), | ||
| 367 | + ), | ||
| 368 | + activeIcon: Image( | ||
| 369 | + image: AssetImage("assets/notebook_selected.png"), | ||
| 370 | + width: ScreenUtil().setWidth(48), | ||
| 371 | + height: ScreenUtil().setWidth(48), | ||
| 372 | + ), | ||
| 373 | + title: Text( | ||
| 374 | + "桌位", | ||
| 375 | + style: TextStyle( | ||
| 376 | + color: _currIndex == 3? _activeColor : _defaultColor, | ||
| 329 | fontSize: ScreenUtil().setSp(22)), | 377 | fontSize: ScreenUtil().setSp(22)), |
| 330 | ), | 378 | ), |
| 331 | ), | 379 | ), |
| @@ -343,7 +391,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | @@ -343,7 +391,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | ||
| 343 | title: Text( | 391 | title: Text( |
| 344 | "我的", | 392 | "我的", |
| 345 | style: TextStyle( | 393 | style: TextStyle( |
| 346 | - color: _currIndex == 2 ? _activeColor : _defaultColor, | 394 | + color: _currIndex == 4 ? _activeColor : _defaultColor, |
| 347 | fontSize: ScreenUtil().setSp(22)), | 395 | fontSize: ScreenUtil().setSp(22)), |
| 348 | ), | 396 | ), |
| 349 | ), | 397 | ), |
| @@ -355,7 +403,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | @@ -355,7 +403,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | ||
| 355 | setState(() { | 403 | setState(() { |
| 356 | _currIndex = index; | 404 | _currIndex = index; |
| 357 | }); | 405 | }); |
| 358 | - if (_currIndex == 2) { | 406 | + if (_currIndex == 4) { |
| 359 | Utils.changeStatusColor(color: MyColours.color_199095); | 407 | Utils.changeStatusColor(color: MyColours.color_199095); |
| 360 | } else { | 408 | } else { |
| 361 | Utils.changeStatusColor(color: MyColours.color_ffffff); | 409 | Utils.changeStatusColor(color: MyColours.color_ffffff); |
lib/pages/table/table_manager_page.dart
0 → 100644
| 1 | +import 'dart:ffi'; | ||
| 2 | + | ||
| 3 | +import 'package:flutter/material.dart'; | ||
| 4 | +import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
| 5 | +import 'package:one_key/models/area.dart'; | ||
| 6 | +import 'package:one_key/models/notebook.dart'; | ||
| 7 | +import 'package:one_key/models/tableOuter.dart'; | ||
| 8 | +import 'package:one_key/models/table_list.dart'; | ||
| 9 | +import 'package:one_key/provider/choose_table_model.dart'; | ||
| 10 | +import 'package:one_key/provider/notebook_detail_change_model.dart'; | ||
| 11 | +import 'package:one_key/provider/notebook_model.dart'; | ||
| 12 | +import 'package:one_key/provider/select_table_model.dart'; | ||
| 13 | +import 'package:one_key/provider/table_manager_model.dart'; | ||
| 14 | +import 'package:one_key/provider/user_model.dart'; | ||
| 15 | +import 'package:one_key/res/colors.dart'; | ||
| 16 | +import 'package:one_key/utils/dialog_util.dart'; | ||
| 17 | +import 'package:one_key/utils/log_util.dart'; | ||
| 18 | +import 'package:one_key/utils/utils.dart'; | ||
| 19 | +import 'package:one_key/widgets/MyDivider.dart'; | ||
| 20 | +import 'package:one_key/widgets/app_bar.dart'; | ||
| 21 | +import 'package:one_key/widgets/area_item.dart'; | ||
| 22 | +import 'package:one_key/widgets/common_button.dart'; | ||
| 23 | +import 'package:one_key/widgets/table_item.dart'; | ||
| 24 | +import 'package:one_key/models/table.dart' as t; | ||
| 25 | +import 'package:provider/provider.dart'; | ||
| 26 | +import 'dart:convert' as convert; | ||
| 27 | + | ||
| 28 | +class TableManagerPage extends StatefulWidget { | ||
| 29 | + | ||
| 30 | + | ||
| 31 | + @override | ||
| 32 | + State<StatefulWidget> createState() { | ||
| 33 | + // TODO: implement createState | ||
| 34 | + return new TableManagerPageState(); | ||
| 35 | + } | ||
| 36 | +} | ||
| 37 | + | ||
| 38 | +class TableManagerPageState extends State<TableManagerPage> { | ||
| 39 | + | ||
| 40 | + List<Area> areas = []; //区域列表 | ||
| 41 | + List<t.Table> selectTables = []; //选择的桌位 | ||
| 42 | + | ||
| 43 | + List<TableOuter> tableOuterList = []; //区域-桌位列表 | ||
| 44 | + | ||
| 45 | + Map<String, List<t.Table>> areaTableMap = {}; //区域-桌位Map | ||
| 46 | + | ||
| 47 | + TableManagerModel tableManagerModel; | ||
| 48 | + | ||
| 49 | + Map<String, Notebook> tableMap = {}; //记录已预订桌位对应的订单 | ||
| 50 | + | ||
| 51 | + String currentArea; //当前选中区域 | ||
| 52 | + | ||
| 53 | + DateTime dateTime=DateTime.now(); | ||
| 54 | + | ||
| 55 | + String dateText = ""; //当前显示日期时间 | ||
| 56 | + int currTimeIndex = 1; //当前选中时间段 | ||
| 57 | + String morning; //早市时间段 | ||
| 58 | + String noon; //午市时间段 | ||
| 59 | + String night; //晚市时间段 | ||
| 60 | + UserModel userModel; | ||
| 61 | + | ||
| 62 | + @override | ||
| 63 | + void initState() { | ||
| 64 | + // TODO: implement initState | ||
| 65 | + super.initState(); | ||
| 66 | + LogUtil.v("table_manager_page initState"); | ||
| 67 | + WidgetsBinding.instance.addPostFrameCallback((_) { | ||
| 68 | + userModel = Provider.of<UserModel>(context, listen: false); | ||
| 69 | + tableManagerModel=Provider.of<TableManagerModel>(context,listen: false); | ||
| 70 | + _initTime(); | ||
| 71 | + getTableList(); | ||
| 72 | + }); | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + //初始化时间 | ||
| 76 | + _initTime() { | ||
| 77 | + dateTime = DateTime.now(); | ||
| 78 | + dateText = Utils.addZeroNumber(dateTime.month) + | ||
| 79 | + "月" + | ||
| 80 | + Utils.addZeroNumber(dateTime.day) + | ||
| 81 | + "日" + | ||
| 82 | + " 今天"; | ||
| 83 | + morning = | ||
| 84 | + userModel.user.morning.isEmpty ? "00:00-00:00" : userModel.user.morning; | ||
| 85 | + noon = userModel.user.noon.isEmpty ? "00:00-00:00" : userModel.user.noon; | ||
| 86 | + night = userModel.user.night.isEmpty ? "00:00-00:00" : userModel.user.night; | ||
| 87 | + if (dateTime.isBefore(DateTime.parse(dateTime.year.toString() + | ||
| 88 | + "-" + | ||
| 89 | + Utils.addZeroNumber(dateTime.month) + | ||
| 90 | + "-" + | ||
| 91 | + Utils.addZeroNumber(dateTime.day) + | ||
| 92 | + " " + | ||
| 93 | + morning.split("-")[1] + | ||
| 94 | + ":00"))) { | ||
| 95 | + //未过早市 | ||
| 96 | + currTimeIndex = 1; | ||
| 97 | + } else if (dateTime.isAfter(DateTime.parse(dateTime.year.toString() + | ||
| 98 | + "-" + | ||
| 99 | + Utils.addZeroNumber(dateTime.month) + | ||
| 100 | + "-" + | ||
| 101 | + Utils.addZeroNumber(dateTime.day) + | ||
| 102 | + " " + | ||
| 103 | + morning.split("-")[1] + | ||
| 104 | + ":00")) && | ||
| 105 | + dateTime.isBefore(DateTime.parse(dateTime.year.toString() + | ||
| 106 | + "-" + | ||
| 107 | + Utils.addZeroNumber(dateTime.month) + | ||
| 108 | + "-" + | ||
| 109 | + Utils.addZeroNumber(dateTime.day) + | ||
| 110 | + " " + | ||
| 111 | + noon.split("-")[1] + | ||
| 112 | + ":00"))) { | ||
| 113 | + //过了早市,未过午市 | ||
| 114 | + currTimeIndex = 2; | ||
| 115 | + } else if (dateTime.isAfter(DateTime.parse(dateTime.year.toString() + | ||
| 116 | + "-" + | ||
| 117 | + Utils.addZeroNumber(dateTime.month) + | ||
| 118 | + "-" + | ||
| 119 | + Utils.addZeroNumber(dateTime.day) + | ||
| 120 | + " " + | ||
| 121 | + noon.split("-")[1] + | ||
| 122 | + ":00")) && | ||
| 123 | + dateTime.isBefore(DateTime.parse(dateTime.year.toString() + | ||
| 124 | + "-" + | ||
| 125 | + Utils.addZeroNumber(dateTime.month) + | ||
| 126 | + "-" + | ||
| 127 | + Utils.addZeroNumber(dateTime.day) + | ||
| 128 | + " " + | ||
| 129 | + night.split("-")[1] + | ||
| 130 | + ":00"))) { | ||
| 131 | + //过了午市,未过晚市 | ||
| 132 | + currTimeIndex = 3; | ||
| 133 | + } else { | ||
| 134 | + //过了晚市 | ||
| 135 | + currTimeIndex = 3; | ||
| 136 | + } | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + //获取桌位列表 | ||
| 140 | + getTableList() async { | ||
| 141 | + Map<String, String> params = {"sellerid": userModel.user.sellerid}; | ||
| 142 | + tableOuterList = await tableManagerModel.getTableList(context, params); | ||
| 143 | + _getReserveList(); | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + //获取已预订列表 | ||
| 147 | + _getReserveList() async { | ||
| 148 | + NoteBookModel model = new NoteBookModel(); | ||
| 149 | + Map<String, String> params = { | ||
| 150 | + "sid": userModel.user.sellerid, | ||
| 151 | + "rdate": _getRdate(), | ||
| 152 | + "ddate_solt": currTimeIndex.toString(), | ||
| 153 | + "y": "200", | ||
| 154 | + "x": "1", | ||
| 155 | + "keywords": "", | ||
| 156 | + "sort": "1" | ||
| 157 | + }; | ||
| 158 | + List<Notebook> noteBooks = await model.getReserveList(context, params); | ||
| 159 | + for (Notebook notebook in noteBooks) { | ||
| 160 | + if (notebook.tid.isEmpty) continue; | ||
| 161 | + if (notebook.status == "1" || | ||
| 162 | + notebook.status == "2" || | ||
| 163 | + notebook.status == "5") { | ||
| 164 | + //已预订,用餐中,已安排 | ||
| 165 | + List<String> tids = notebook.tid.split(","); | ||
| 166 | + for (String tid in tids) { | ||
| 167 | + tableMap["$tid"] = notebook; | ||
| 168 | + } | ||
| 169 | + } | ||
| 170 | + } | ||
| 171 | + print(tableMap); | ||
| 172 | + initData(); | ||
| 173 | + } | ||
| 174 | + | ||
| 175 | + //初始桌位数据 | ||
| 176 | + initData() { | ||
| 177 | + for (TableOuter outer in tableOuterList) { | ||
| 178 | + int count = 0; | ||
| 179 | + for (t.Table table in outer.list) { | ||
| 180 | + if (table.tablestatus == "0") { | ||
| 181 | + //没有用餐中 | ||
| 182 | + if (tableMap["${table.id}"] != null) { | ||
| 183 | + Notebook notebook = tableMap["${table.id}"]; | ||
| 184 | + table.sign = notebook.status; | ||
| 185 | + table.notebookId = notebook.id; | ||
| 186 | + table.reserver = notebook.rnameStr; | ||
| 187 | + } else { | ||
| 188 | + table.sign = ""; | ||
| 189 | + table.notebookId = ""; | ||
| 190 | + if (table.enable == "1") { | ||
| 191 | + count++; | ||
| 192 | + } | ||
| 193 | + } | ||
| 194 | + } else { | ||
| 195 | + table.sign = "2"; | ||
| 196 | + table.notebookId = ""; | ||
| 197 | + } | ||
| 198 | + } | ||
| 199 | + areaTableMap["${outer.name}"] = outer.list; | ||
| 200 | + Area area = Area(); | ||
| 201 | + area.name = outer.name; | ||
| 202 | + area.count = count; | ||
| 203 | + areas.add(area); | ||
| 204 | + } | ||
| 205 | + currentArea = areaTableMap.keys.first; | ||
| 206 | + setState(() {}); | ||
| 207 | + } | ||
| 208 | + | ||
| 209 | + //获取一天开始-结束时间字符串 | ||
| 210 | + String _getRdate() { | ||
| 211 | + //一天开始时间 | ||
| 212 | + double startDay = (DateTime.parse((dateTime.year.toString() + | ||
| 213 | + "-" + | ||
| 214 | + Utils.addZeroNumber(dateTime.month) + | ||
| 215 | + "-" + | ||
| 216 | + Utils.addZeroNumber(dateTime.day) + | ||
| 217 | + " 00:00:00")) | ||
| 218 | + .millisecondsSinceEpoch) / | ||
| 219 | + 1000; | ||
| 220 | + //一天结束时间 | ||
| 221 | + double endDay = (DateTime.parse((dateTime.year.toString() + | ||
| 222 | + "-" + | ||
| 223 | + Utils.addZeroNumber(dateTime.month) + | ||
| 224 | + "-" + | ||
| 225 | + Utils.addZeroNumber(dateTime.day) + | ||
| 226 | + " 23:59:59")) | ||
| 227 | + .millisecondsSinceEpoch) / | ||
| 228 | + 1000; | ||
| 229 | + return startDay.floor().toString() + "-" + endDay.floor().toString(); | ||
| 230 | + } | ||
| 231 | + | ||
| 232 | + //生成日期文本 | ||
| 233 | + _createDateText(DateTime day) { | ||
| 234 | + if (Utils.isOneDay(day, dateTime)) return; //日期没变 | ||
| 235 | + setState(() { | ||
| 236 | + DateTime dateNow = DateTime.now(); | ||
| 237 | + dateText = Utils.addZeroNumber(day.month) + | ||
| 238 | + "月" + | ||
| 239 | + Utils.addZeroNumber(day.day) + | ||
| 240 | + "日"; | ||
| 241 | + if (Utils.isOneDay(day, dateNow)) { | ||
| 242 | + dateText += " 今天"; | ||
| 243 | + } else if (Utils.isOneDay(day, dateNow.add(Duration(days: 1)))) { | ||
| 244 | + dateText += " 明天"; | ||
| 245 | + } else if (Utils.isOneDay(day, dateNow.add(Duration(days: 2)))) { | ||
| 246 | + dateText += " 后天"; | ||
| 247 | + } else { | ||
| 248 | + dateText += " 周${Utils.formatWeekDayNum(day.weekday)}"; | ||
| 249 | + } | ||
| 250 | + dateTime = day; | ||
| 251 | + }); | ||
| 252 | + _getReserveList(); | ||
| 253 | + } | ||
| 254 | + | ||
| 255 | + @override | ||
| 256 | + Widget build(BuildContext context) { | ||
| 257 | + return SafeArea( | ||
| 258 | + child: areaTableMap.isEmpty | ||
| 259 | + ? Container( | ||
| 260 | + width: double.infinity, | ||
| 261 | + height: double.infinity, | ||
| 262 | + color: MyColours.color_ffffff, | ||
| 263 | + ) | ||
| 264 | + : Column( | ||
| 265 | + children: <Widget>[ | ||
| 266 | + MyAppBar( | ||
| 267 | + "桌位", | ||
| 268 | + showBack: true, | ||
| 269 | + ), | ||
| 270 | + Container( | ||
| 271 | + color: MyColours.color_ffffff, | ||
| 272 | + width: double.infinity, | ||
| 273 | + padding: EdgeInsets.symmetric(vertical: ScreenUtil().setHeight(16)), | ||
| 274 | + child: Row( | ||
| 275 | + crossAxisAlignment: CrossAxisAlignment.center, | ||
| 276 | + children: <Widget>[ | ||
| 277 | + Expanded( | ||
| 278 | + child: Center( | ||
| 279 | + child: GestureDetector( | ||
| 280 | + onTap: () { | ||
| 281 | + DialogUtil.showCalendarDialog(context, dateTime) | ||
| 282 | + .then((day) { | ||
| 283 | + if (day != null) { | ||
| 284 | + _createDateText(day); | ||
| 285 | + } | ||
| 286 | + }); | ||
| 287 | + }, | ||
| 288 | + child: Container( | ||
| 289 | + child: Text( | ||
| 290 | + dateText, | ||
| 291 | + style: TextStyle( | ||
| 292 | + color: MyColours.color_199095, | ||
| 293 | + fontSize: ScreenUtil().setSp(34)), | ||
| 294 | + ), | ||
| 295 | + ), | ||
| 296 | + ), | ||
| 297 | + ), | ||
| 298 | + ), | ||
| 299 | + MyDivider( | ||
| 300 | + ScreenUtil().setWidth(2), | ||
| 301 | + ScreenUtil().setHeight(68), | ||
| 302 | + color: MyColours.color_E0E0E0, | ||
| 303 | + ), | ||
| 304 | + Expanded( | ||
| 305 | + child: Padding( | ||
| 306 | + padding: EdgeInsets.symmetric( | ||
| 307 | + horizontal: ScreenUtil().setWidth(30)), | ||
| 308 | + child: Row( | ||
| 309 | + mainAxisAlignment: MainAxisAlignment.center, | ||
| 310 | + crossAxisAlignment: CrossAxisAlignment.center, | ||
| 311 | + children: <Widget>[ | ||
| 312 | + Offstage( | ||
| 313 | + offstage: morning == "00:00-00:00" ? true : false, | ||
| 314 | + child: Padding( | ||
| 315 | + padding: EdgeInsets.only( | ||
| 316 | + right: ScreenUtil().setWidth(18)), | ||
| 317 | + child: CommonButton( | ||
| 318 | + content: "早市", | ||
| 319 | + state: currTimeIndex == 1 ? 1 : 0, | ||
| 320 | + width: 92, | ||
| 321 | + height: 48, | ||
| 322 | + fontSize: 32, | ||
| 323 | + onPress: () { | ||
| 324 | + if (currTimeIndex == 1) return; | ||
| 325 | + setState(() { | ||
| 326 | + currTimeIndex = 1; | ||
| 327 | + }); | ||
| 328 | + _getReserveList(); | ||
| 329 | + }, | ||
| 330 | + ))), | ||
| 331 | + Offstage( | ||
| 332 | + offstage: noon == "00:00-00:00" ? true : false, | ||
| 333 | + child: Padding( | ||
| 334 | + padding: EdgeInsets.only( | ||
| 335 | + right: ScreenUtil().setWidth(18)), | ||
| 336 | + child: CommonButton( | ||
| 337 | + content: "午市", | ||
| 338 | + state: currTimeIndex == 2 ? 1 : 0, | ||
| 339 | + width: 92, | ||
| 340 | + height: 48, | ||
| 341 | + fontSize: 32, | ||
| 342 | + onPress: () { | ||
| 343 | + if (currTimeIndex == 2) return; | ||
| 344 | + setState(() { | ||
| 345 | + currTimeIndex = 2; | ||
| 346 | + }); | ||
| 347 | + _getReserveList(); | ||
| 348 | + }, | ||
| 349 | + ))), | ||
| 350 | + Offstage( | ||
| 351 | + offstage: night == "00:00-00:00" ? true : false, | ||
| 352 | + child: Container( | ||
| 353 | + // padding: EdgeInsets.symmetric( | ||
| 354 | + // horizontal: ScreenUtil().setWidth(10)), | ||
| 355 | + child: CommonButton( | ||
| 356 | + content: "晚市", | ||
| 357 | + state: currTimeIndex == 3 ? 1 : 0, | ||
| 358 | + width: 92, | ||
| 359 | + height: 48, | ||
| 360 | + fontSize: 32, | ||
| 361 | + onPress: () { | ||
| 362 | + if (currTimeIndex == 3) return; | ||
| 363 | + setState(() { | ||
| 364 | + currTimeIndex = 3; | ||
| 365 | + }); | ||
| 366 | + _getReserveList(); | ||
| 367 | + }, | ||
| 368 | + )), | ||
| 369 | + ), | ||
| 370 | + ], | ||
| 371 | + ), | ||
| 372 | + ), | ||
| 373 | + ) | ||
| 374 | + ], | ||
| 375 | + ), | ||
| 376 | + ), | ||
| 377 | + Expanded( | ||
| 378 | + child: Container( | ||
| 379 | + color: MyColours.color_ffffff, | ||
| 380 | + child: Row( | ||
| 381 | + children: <Widget>[ | ||
| 382 | + Container( | ||
| 383 | + width: ScreenUtil().setWidth(170), | ||
| 384 | + height: double.infinity, | ||
| 385 | + color: MyColours.color_f1f1f1, | ||
| 386 | + child: ListView.builder( | ||
| 387 | + itemBuilder: (context, index) { | ||
| 388 | + return AreaItem(areas[index], currentArea, | ||
| 389 | + (area) { | ||
| 390 | + setState(() { | ||
| 391 | + currentArea = (area as Area).name; | ||
| 392 | + }); | ||
| 393 | + }); | ||
| 394 | + }, | ||
| 395 | + itemExtent: ScreenUtil().setHeight(207), | ||
| 396 | + itemCount: areas.length, | ||
| 397 | + ), | ||
| 398 | + ), | ||
| 399 | + Expanded( | ||
| 400 | + child: Padding( | ||
| 401 | + padding: EdgeInsets.symmetric( | ||
| 402 | + vertical: ScreenUtil().setHeight(10), | ||
| 403 | + horizontal: ScreenUtil().setWidth(9)), | ||
| 404 | + child: Column( | ||
| 405 | + children: [ | ||
| 406 | + Expanded( | ||
| 407 | + child: GridView.builder( | ||
| 408 | + gridDelegate: | ||
| 409 | + SliverGridDelegateWithFixedCrossAxisCount( | ||
| 410 | + crossAxisCount: 3, | ||
| 411 | + childAspectRatio: 8 / 9), | ||
| 412 | + itemBuilder: (context, index) { | ||
| 413 | + return TableItem( | ||
| 414 | + areaTableMap[currentArea][index], | ||
| 415 | + onSelected: (table) { | ||
| 416 | + if ((table as t.Table).selected) { | ||
| 417 | + selectTables.add(table); | ||
| 418 | + } else { | ||
| 419 | + selectTables.removeWhere( | ||
| 420 | + (t) => t.id == table.id); | ||
| 421 | + } | ||
| 422 | + }, | ||
| 423 | + canSelected: false, | ||
| 424 | + canChoose: false, | ||
| 425 | + tableMap: tableMap, | ||
| 426 | + rid: ""); | ||
| 427 | + }, | ||
| 428 | + itemCount: areaTableMap[currentArea].length, | ||
| 429 | + )), | ||
| 430 | + ], | ||
| 431 | + )), | ||
| 432 | + ) | ||
| 433 | + ], | ||
| 434 | + ), | ||
| 435 | + ), | ||
| 436 | + ), | ||
| 437 | + ], | ||
| 438 | + ), | ||
| 439 | + ); | ||
| 440 | + } | ||
| 441 | + | ||
| 442 | + tableToTableList(t.Table table) { | ||
| 443 | + TableList _tableList = TableList( | ||
| 444 | + '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); | ||
| 445 | + _tableList.id = table.id; | ||
| 446 | + _tableList.rid = table.rid; | ||
| 447 | + _tableList.tid = table.tid; | ||
| 448 | + _tableList.name = table.name; | ||
| 449 | + _tableList.tablePnum = table.table_pnum; | ||
| 450 | + _tableList.sellerid = null; | ||
| 451 | + _tableList.qrcode = null; | ||
| 452 | + _tableList.mostPnum = table.most_pnum; | ||
| 453 | + _tableList.hot = null; | ||
| 454 | + _tableList.orderO = table.order_o; | ||
| 455 | + _tableList.status = table.status; | ||
| 456 | + _tableList.enable = table.enable; | ||
| 457 | + _tableList.spell = table.spell; | ||
| 458 | + _tableList.cdate = null; | ||
| 459 | + _tableList.rname = table.rname; | ||
| 460 | + _tableList.regionName = table.rname; | ||
| 461 | + _tableList.selected = true; | ||
| 462 | + return _tableList; | ||
| 463 | + } | ||
| 464 | +} |
lib/provider/enter_model.dart
0 → 100644
| 1 | +import 'package:common_utils/common_utils.dart'; | ||
| 2 | +import 'package:flutter/material.dart'; | ||
| 3 | +import 'package:one_key/constant/constant.dart'; | ||
| 4 | +import 'package:one_key/models/notebook_detail.dart'; | ||
| 5 | +import 'package:one_key/models/reserve_info_model.dart'; | ||
| 6 | +import 'package:one_key/models/seller_info.dart'; | ||
| 7 | +import 'package:one_key/models/table_list.dart'; | ||
| 8 | +import 'package:one_key/net/base_resp.dart'; | ||
| 9 | +import 'package:one_key/net/dio_util.dart'; | ||
| 10 | +import 'package:one_key/net/http_url.dart'; | ||
| 11 | +import 'package:one_key/provider/notebook_detail_model.dart'; | ||
| 12 | +import 'package:one_key/provider/user_model.dart'; | ||
| 13 | +import 'package:one_key/utils/utils.dart'; | ||
| 14 | +import 'package:provider/provider.dart'; | ||
| 15 | + | ||
| 16 | +class EnterModel with ChangeNotifier { | ||
| 17 | + List dateList = []; //日期选择 月-日 某天 | ||
| 18 | + List sunDateList = []; // 早市、午市、晚市 | ||
| 19 | + List personNumList = []; // 人数 | ||
| 20 | + TextEditingController numController = TextEditingController(); //人数 | ||
| 21 | + TextEditingController phoneController = TextEditingController(); //电话 | ||
| 22 | + TextEditingController nameController = TextEditingController(); //客户姓名 | ||
| 23 | + TextEditingController customController = TextEditingController(); //客户要求 | ||
| 24 | + List sexList = []; // 先生、女士、公司 | ||
| 25 | + Map dailyMap = {}; // 早市对应半点钟,午市对应半点钟、晚市对应半点钟 | ||
| 26 | + String ddateStr = ''; //16:30 | ||
| 27 | + NotebookDetail detailEntity; | ||
| 28 | + List<TableList> tableList = []; | ||
| 29 | + String isSetDate = '0'; | ||
| 30 | + List<TableList> recommendList = []; //推荐列表 | ||
| 31 | + bool isRecommend = false; //是否展示推荐 | ||
| 32 | + List oldTableList = []; | ||
| 33 | + | ||
| 34 | + clearData() { | ||
| 35 | + dateList = []; //日期选择 月-日 某天 | ||
| 36 | + sunDateList = []; // 早市、午市、晚市 | ||
| 37 | + personNumList = []; // 人数 | ||
| 38 | + numController = TextEditingController(); //人数 | ||
| 39 | + phoneController = TextEditingController(); //电话 | ||
| 40 | + nameController = TextEditingController(); //客户姓名 | ||
| 41 | + customController = TextEditingController(); //客户要求 | ||
| 42 | + sexList = []; // 先生、女士、公司 | ||
| 43 | + dailyMap = {}; // 早市对应半点钟,午市对应半点钟、晚市对应半点钟 | ||
| 44 | + ddateStr = ''; //16:30 | ||
| 45 | + tableList = []; | ||
| 46 | + isSetDate = '0'; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + //构造函数,初始化 | ||
| 50 | + EnterModel(this.detailEntity) { | ||
| 51 | + // clearData(); | ||
| 52 | + print(detailEntity); | ||
| 53 | + if (detailEntity.phone != '0') { | ||
| 54 | + phoneController.text = detailEntity.phone; | ||
| 55 | + } | ||
| 56 | + if (detailEntity.rnameStr != '') { | ||
| 57 | + nameController.text = detailEntity.rname; | ||
| 58 | + } | ||
| 59 | + if (detailEntity.cusdem != '') { | ||
| 60 | + customController.text = detailEntity.cusdem; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + _initDateList(); | ||
| 64 | + _initPersonNumList(); | ||
| 65 | + _initSexList(); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + ///初始化 日期选择 月-日 某天 | ||
| 69 | + _initDateList() { | ||
| 70 | + String createtime = detailEntity.ddate.toString() + '000'; | ||
| 71 | + DateTime createTime = | ||
| 72 | + DateTime.fromMillisecondsSinceEpoch(int.parse(createtime)); | ||
| 73 | + ddateStr = DateUtil.formatDate(createTime, format: DateFormats.h_m); | ||
| 74 | + String dateTimeSelect = DateUtil.formatDateMs( | ||
| 75 | + createTime.millisecondsSinceEpoch, | ||
| 76 | + format: 'MM-dd'); | ||
| 77 | + //今天 | ||
| 78 | + DateTime dateTime = DateTime.now(); | ||
| 79 | + int dateTimeMill = dateTime.millisecondsSinceEpoch; | ||
| 80 | + String dateText = DateUtil.formatDateMs(dateTimeMill, format: 'MM-dd'); | ||
| 81 | + dateList.add({ | ||
| 82 | + 'title': dateText, | ||
| 83 | + 'select': dateTimeSelect == dateText ? true : false, | ||
| 84 | + 'fontSize': 34.0, | ||
| 85 | + 'dayText': ' 今天', | ||
| 86 | + 'isImage': false | ||
| 87 | + }); | ||
| 88 | + //明天 | ||
| 89 | + int tomorrowMill = dateTimeMill + 24 * 60 * 60 * 1000; | ||
| 90 | + String dateTextTomorrow = | ||
| 91 | + DateUtil.formatDateMs(tomorrowMill, format: 'MM-dd'); | ||
| 92 | + dateList.add({ | ||
| 93 | + 'title': dateTextTomorrow, | ||
| 94 | + 'select': dateTimeSelect == dateTextTomorrow ? true : false, | ||
| 95 | + 'fontSize': 34.0, | ||
| 96 | + 'dayText': ' 明天', | ||
| 97 | + 'isImage': false | ||
| 98 | + }); | ||
| 99 | + //第三个 | ||
| 100 | + dateList.add({ | ||
| 101 | + 'title': dateTimeSelect != dateText && dateTimeSelect != dateTextTomorrow | ||
| 102 | + ? dateTimeSelect | ||
| 103 | + : '其他', | ||
| 104 | + 'select': dateTimeSelect != dateText && dateTimeSelect != dateTextTomorrow | ||
| 105 | + ? true | ||
| 106 | + : false, | ||
| 107 | + 'fontSize': 30.0, | ||
| 108 | + 'dayText': '', | ||
| 109 | + 'isImage': true | ||
| 110 | + }); | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + /// 初始化 早市、午市、晚市 | ||
| 114 | + _initSunDateList(morning, noon, night) { | ||
| 115 | + String ddateSolt = detailEntity.ddate_solt; | ||
| 116 | + if (morning != '') { | ||
| 117 | + sunDateList.add({ | ||
| 118 | + 'dateText': '早市', | ||
| 119 | + 'dayText': '', | ||
| 120 | + 'ddateSolt': 1, | ||
| 121 | + 'key': 'morning', | ||
| 122 | + 'isSelect': ddateSolt == '1' ? true : false | ||
| 123 | + }); | ||
| 124 | + } | ||
| 125 | + if (noon != '') { | ||
| 126 | + sunDateList.add({ | ||
| 127 | + 'dateText': '午市', | ||
| 128 | + 'dayText': '', | ||
| 129 | + 'ddateSolt': 2, | ||
| 130 | + 'key': 'noon', | ||
| 131 | + 'isSelect': ddateSolt == '2' ? true : false | ||
| 132 | + }); | ||
| 133 | + } | ||
| 134 | + if (noon != '') { | ||
| 135 | + sunDateList.add({ | ||
| 136 | + 'dateText': '晚市', | ||
| 137 | + 'dayText': '', | ||
| 138 | + 'ddateSolt': 3, | ||
| 139 | + 'key': 'night', | ||
| 140 | + 'isSelect': ddateSolt == '3' ? true : false | ||
| 141 | + }); | ||
| 142 | + } | ||
| 143 | + notifyListeners(); | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | +//人数 | ||
| 147 | + _initPersonNumList() { | ||
| 148 | + String pnum = detailEntity.pnum; | ||
| 149 | + if (int.parse(pnum) < 6 || int.parse(pnum) > 10) { | ||
| 150 | + numController.text = pnum; | ||
| 151 | + } | ||
| 152 | + personNumList = [ | ||
| 153 | + { | ||
| 154 | + 'dateText': '6', | ||
| 155 | + 'width': 30.0, | ||
| 156 | + 'fontSize': 34.0, | ||
| 157 | + 'isImage': false, | ||
| 158 | + 'isSelect': pnum == '6' ? true : false, | ||
| 159 | + 'isTextFiled': false | ||
| 160 | + }, | ||
| 161 | + { | ||
| 162 | + 'dateText': '7', | ||
| 163 | + 'width': 30.0, | ||
| 164 | + 'fontSize': 34.0, | ||
| 165 | + 'isImage': false, | ||
| 166 | + 'isSelect': pnum == '7' ? true : false, | ||
| 167 | + 'isTextFiled': false | ||
| 168 | + }, | ||
| 169 | + { | ||
| 170 | + 'dateText': '8', | ||
| 171 | + 'width': 30.0, | ||
| 172 | + 'fontSize': 34.0, | ||
| 173 | + 'isImage': false, | ||
| 174 | + 'isSelect': pnum == '8' ? true : false, | ||
| 175 | + 'isTextFiled': false | ||
| 176 | + }, | ||
| 177 | + { | ||
| 178 | + 'dateText': '9', | ||
| 179 | + 'width': 30.0, | ||
| 180 | + 'fontSize': 34.0, | ||
| 181 | + 'isImage': false, | ||
| 182 | + 'isSelect': pnum == '9' ? true : false, | ||
| 183 | + 'isTextFiled': false | ||
| 184 | + }, | ||
| 185 | + { | ||
| 186 | + 'dateText': '10', | ||
| 187 | + 'width': 30.0, | ||
| 188 | + 'fontSize': 34.0, | ||
| 189 | + 'isImage': false, | ||
| 190 | + 'isSelect': pnum == '10' ? true : false, | ||
| 191 | + 'isTextFiled': false | ||
| 192 | + }, | ||
| 193 | + { | ||
| 194 | + 'dateText': numController.text.length > 0 ? numController.text : '更多', | ||
| 195 | + 'width': 105.0, | ||
| 196 | + 'fontSize': 30.0, | ||
| 197 | + 'isImage': true, | ||
| 198 | + 'isSelect': int.parse(pnum) < 6 || int.parse(pnum) > 10 ? true : false, | ||
| 199 | + 'isTextFiled': true | ||
| 200 | + } | ||
| 201 | + ]; | ||
| 202 | + } | ||
| 203 | + | ||
| 204 | + ///称谓 | ||
| 205 | + _initSexList() { | ||
| 206 | + String sexStr = detailEntity.sex; | ||
| 207 | + sexList = [ | ||
| 208 | + { | ||
| 209 | + 'title': '先生', | ||
| 210 | + 'select': sexStr == '1' ? true : false, | ||
| 211 | + 'code': '1', | ||
| 212 | + 'hasLeftBorder': true | ||
| 213 | + }, | ||
| 214 | + { | ||
| 215 | + 'title': '女士', | ||
| 216 | + 'select': sexStr == '2' ? true : false, | ||
| 217 | + 'code': '2', | ||
| 218 | + 'hasLeftBorder': false | ||
| 219 | + }, | ||
| 220 | + { | ||
| 221 | + 'title': '公司', | ||
| 222 | + 'select': sexStr == '3' ? true : false, | ||
| 223 | + 'code': '3', | ||
| 224 | + 'hasLeftBorder': false | ||
| 225 | + } | ||
| 226 | + ]; | ||
| 227 | + } | ||
| 228 | + | ||
| 229 | + /// 早市、午市、晚市对应的半个小时间隔时间段 | ||
| 230 | + initDateHourMinuteList(BuildContext context) async { | ||
| 231 | + SunSellerInfoModel model = await getManagersInfo(context); | ||
| 232 | + model.daily.morning == '' | ||
| 233 | + ? dailyMap.putIfAbsent('morning', () => '') | ||
| 234 | + : dailyMap.putIfAbsent( | ||
| 235 | + 'morning', () => _getHourAndMinute(model.daily.morning, 1, model)); | ||
| 236 | + model.daily.noon == '' | ||
| 237 | + ? dailyMap.putIfAbsent('noon', () => '') | ||
| 238 | + : dailyMap.putIfAbsent( | ||
| 239 | + 'noon', () => _getHourAndMinute(model.daily.noon, 2, model)); | ||
| 240 | + model.daily.night == '' | ||
| 241 | + ? dailyMap.putIfAbsent('night', () => '') | ||
| 242 | + : dailyMap.putIfAbsent( | ||
| 243 | + 'night', () => _getHourAndMinute(model.daily.night, 3, model)); | ||
| 244 | + _initSunDateList(model.daily.morning, model.daily.noon, model.daily.night); | ||
| 245 | + } | ||
| 246 | + | ||
| 247 | +//根据获取时间 11:00-12:30 获取30分钟间隔组装的数组 | ||
| 248 | + _getHourAndMinute( | ||
| 249 | + String hourAndMinuteStr, int mnd, SunSellerInfoModel model) { | ||
| 250 | + List tempDate = hourAndMinuteStr.split("-"); | ||
| 251 | + String beginDate = tempDate[0]; | ||
| 252 | + String endDate = tempDate[1]; | ||
| 253 | + List tempHour = beginDate.split(':'); | ||
| 254 | + String isSetDate = detailEntity.is_set_ddate; | ||
| 255 | + String ddateSolt = detailEntity.ddate_solt; | ||
| 256 | + /*获取开始小时*/ | ||
| 257 | + int beginHour = int.parse(tempHour[0]); | ||
| 258 | + /*获取开始分钟*/ | ||
| 259 | + int beginMinute = int.parse(tempHour[1]); | ||
| 260 | + List res = []; | ||
| 261 | + bool tempLimit = true; | ||
| 262 | + while (tempLimit) { | ||
| 263 | + String temp = _dealTime(beginHour, beginMinute); | ||
| 264 | + bool tempSelect = false; | ||
| 265 | + if (int.parse(isSetDate) == 1) //设置预订时间 | ||
| 266 | + { | ||
| 267 | + if (temp == ddateStr) { | ||
| 268 | + tempSelect = true; | ||
| 269 | + } | ||
| 270 | + } else { | ||
| 271 | + if (mnd == 1) { | ||
| 272 | + if (temp == '08:00') { | ||
| 273 | + tempSelect = true; | ||
| 274 | + } | ||
| 275 | + } else if (mnd == 2) { | ||
| 276 | + if (temp == '12:00') { | ||
| 277 | + tempSelect = true; | ||
| 278 | + } | ||
| 279 | + } else if (mnd == 3) { | ||
| 280 | + if (temp == '18:30') { | ||
| 281 | + tempSelect = true; | ||
| 282 | + } | ||
| 283 | + } | ||
| 284 | + } | ||
| 285 | + | ||
| 286 | + Map tempMap = {'title': temp, 'select': tempSelect}; | ||
| 287 | + res.add(tempMap); | ||
| 288 | + if (temp == endDate) { | ||
| 289 | + tempLimit = false; | ||
| 290 | + break; | ||
| 291 | + } | ||
| 292 | + if (beginMinute == 30) { | ||
| 293 | + beginHour++; | ||
| 294 | + if (beginHour >= 24) { | ||
| 295 | + beginHour = 0; | ||
| 296 | + } | ||
| 297 | + } | ||
| 298 | + beginMinute = (beginMinute + 30) % 60; | ||
| 299 | + } | ||
| 300 | + return res; | ||
| 301 | + } | ||
| 302 | + | ||
| 303 | + /// 根据时间和分钟组装 格式:11:00 | ||
| 304 | + _dealTime(int begin, int mm) { | ||
| 305 | + String sb = ''; | ||
| 306 | + if (begin < 10) { | ||
| 307 | + sb = '0$begin'; | ||
| 308 | + } else { | ||
| 309 | + sb = '$begin'; | ||
| 310 | + } | ||
| 311 | + sb = '$sb:'; | ||
| 312 | + if (mm < 10) { | ||
| 313 | + sb = '${sb}0${mm}'; | ||
| 314 | + } else { | ||
| 315 | + sb = '${sb}${mm}'; | ||
| 316 | + } | ||
| 317 | + return sb; | ||
| 318 | + } | ||
| 319 | + | ||
| 320 | + ///获取某个商家下所有服务员信息 **** 取得某个商家的早市、午市、晚市营业时间 | ||
| 321 | + Future<SunSellerInfoModel> getManagersInfo(BuildContext context) async { | ||
| 322 | + UserModel userModel = Provider.of<UserModel>(context, listen: false); | ||
| 323 | + Map<String, String> params = { | ||
| 324 | + "seller_id": userModel.user.sellerid, | ||
| 325 | + "seller_openid": userModel.user.openid | ||
| 326 | + }; | ||
| 327 | + BaseResp<Map<String, dynamic>> baseResp = await DioUtil() | ||
| 328 | + .request<Map<String, dynamic>>(context, Method.get, HttpUrl.sellerinfo, | ||
| 329 | + data: params) | ||
| 330 | + .catchError((error) { | ||
| 331 | + print(error.toString()); | ||
| 332 | + }); | ||
| 333 | + SunSellerInfoModel itemModel; | ||
| 334 | + if (baseResp == null) return itemModel; | ||
| 335 | + if (baseResp.code == Constant.status_success) { | ||
| 336 | + if (int.parse(baseResp.status) != Constant.status_success) { | ||
| 337 | + Utils.showToast(baseResp.msg ?? ""); | ||
| 338 | + return itemModel; | ||
| 339 | + } | ||
| 340 | + if (baseResp.responseData['data'] != null) { | ||
| 341 | + itemModel = SellerInfoModel.fromJson(baseResp.responseData).data; | ||
| 342 | + } else { | ||
| 343 | + Utils.showToast(baseResp.msg ?? ""); | ||
| 344 | + } | ||
| 345 | + return itemModel; | ||
| 346 | + } | ||
| 347 | + } | ||
| 348 | + | ||
| 349 | + ///根据商家ID 获取桌位信息列表: 1:散座 2:包间 默认:获取所有数据 | ||
| 350 | + Future<List<TableList>> getNewTableList(BuildContext context, String ddate, | ||
| 351 | + String ddate_solt, String pnum, List oldTableList) async { | ||
| 352 | + if (pnum == '') { | ||
| 353 | + pnum = '6'; | ||
| 354 | + } | ||
| 355 | + DateTime createTime = DateTime.fromMillisecondsSinceEpoch(int.parse(ddate)); | ||
| 356 | + String rdate = DateUtil.formatDate(createTime, format: "yyyyMMdd"); | ||
| 357 | + UserModel userModel = Provider.of<UserModel>(context, listen: false); | ||
| 358 | + Map<String, String> params = { | ||
| 359 | + "sid": userModel.user.sellerid, | ||
| 360 | + "rid": detailEntity.id, | ||
| 361 | + "rdate": rdate, | ||
| 362 | + 'ddate_solt': ddate_solt, | ||
| 363 | + 'pnum': pnum | ||
| 364 | + }; | ||
| 365 | + BaseResp<dynamic> baseResp = await DioUtil() | ||
| 366 | + .request<dynamic>(context, Method.get, HttpUrl.get_table_list, | ||
| 367 | + data: params) | ||
| 368 | + .catchError((error) { | ||
| 369 | + print(error.toString()); | ||
| 370 | + }); | ||
| 371 | + List<TableListSunModel> itemModelList; | ||
| 372 | + if (baseResp == null) return tableList; | ||
| 373 | + if (baseResp.code == Constant.status_success) { | ||
| 374 | + if (int.parse(baseResp.status) != Constant.status_success) { | ||
| 375 | + Utils.showToast(baseResp.msg ?? ""); | ||
| 376 | + return tableList; | ||
| 377 | + } | ||
| 378 | + if (baseResp.responseData['data'] != null) { | ||
| 379 | + itemModelList = TableListModel.fromJson(baseResp.responseData).data; | ||
| 380 | + } else { | ||
| 381 | + Utils.showToast(baseResp.msg ?? ""); | ||
| 382 | + } | ||
| 383 | + tableList = []; | ||
| 384 | + | ||
| 385 | + for (int i = 0; i < itemModelList.length; i++) { | ||
| 386 | + if (itemModelList[i].name == "推荐") { | ||
| 387 | + recommendList = itemModelList[i].list; | ||
| 388 | + itemModelList.removeAt(i); | ||
| 389 | + } | ||
| 390 | + } | ||
| 391 | + for (TableListSunModel item in itemModelList) { | ||
| 392 | + if (item.name == "推荐") { | ||
| 393 | + itemModelList.remove(item); | ||
| 394 | + } | ||
| 395 | + for (var item in item.list) { | ||
| 396 | + for (var table in oldTableList) { | ||
| 397 | + if (item.id == table.id) { | ||
| 398 | + item.selected = true; | ||
| 399 | + if (!tableList.contains(item)) { | ||
| 400 | + tableList.add(item); | ||
| 401 | + } | ||
| 402 | + } | ||
| 403 | + } | ||
| 404 | + } | ||
| 405 | + } | ||
| 406 | + // List usedTableList = []; //被占用的包间 | ||
| 407 | + // for (var itemOld in oldTableList) { | ||
| 408 | + // if (tableList.length == 0) { | ||
| 409 | + // usedTableList = oldTableList; | ||
| 410 | + // } else { | ||
| 411 | + // for (var item in tableList) { | ||
| 412 | + // if (item.id != itemOld.id) { | ||
| 413 | + // usedTableList.add(item); | ||
| 414 | + // } | ||
| 415 | + // } | ||
| 416 | + // } | ||
| 417 | + // } | ||
| 418 | + List idold = []; | ||
| 419 | + for (var itemOld in oldTableList) { | ||
| 420 | + idold.add(itemOld.id); | ||
| 421 | + } | ||
| 422 | + List idnew = []; | ||
| 423 | + for (var item in tableList) { | ||
| 424 | + idnew.add(item.id); | ||
| 425 | + } | ||
| 426 | + for (var item in idnew) { | ||
| 427 | + idold.remove(item); | ||
| 428 | + } | ||
| 429 | + print(idold); //被占用的桌子的id | ||
| 430 | + if (idold.length > 0) { | ||
| 431 | + String msg = ''; | ||
| 432 | + for (var item in oldTableList) { | ||
| 433 | + if (idold.contains(item.id)) { | ||
| 434 | + msg += '${item.name},'; | ||
| 435 | + } | ||
| 436 | + } | ||
| 437 | + if (msg.endsWith(',')) { | ||
| 438 | + msg = msg.substring(0, msg.length - 1); | ||
| 439 | + } | ||
| 440 | + Utils.showToast('${msg}已被占用啦'); | ||
| 441 | + } | ||
| 442 | + | ||
| 443 | + // if (usedTableList.length > 0) { | ||
| 444 | + // print(usedTableList); | ||
| 445 | + // String msg = ''; | ||
| 446 | + // for (var item in usedTableList) { | ||
| 447 | + // msg += '${item.name},'; | ||
| 448 | + // } | ||
| 449 | + // if (msg.endsWith(',')) { | ||
| 450 | + // msg = msg.substring(0, msg.length - 1); | ||
| 451 | + // } | ||
| 452 | + // Utils.showToast('${msg}已被占用啦'); | ||
| 453 | + // } | ||
| 454 | + | ||
| 455 | + // if(usedTableList.length > 0){ | ||
| 456 | + // for (TableList item in usedTableList) { | ||
| 457 | + // item | ||
| 458 | + // } | ||
| 459 | + // } | ||
| 460 | + | ||
| 461 | + if (tableList.length == 0) { | ||
| 462 | + // Utils.showToast('包间已经被预订'); | ||
| 463 | + isRecommend = true; | ||
| 464 | + } else { | ||
| 465 | + isRecommend = false; | ||
| 466 | + } | ||
| 467 | + print(tableList); | ||
| 468 | + notifyListeners(); | ||
| 469 | + return tableList; | ||
| 470 | + } | ||
| 471 | + } | ||
| 472 | + | ||
| 473 | + ///录入顾客订座相关信息,同时更新商家桌位状态 | ||
| 474 | + Future<SunReserveInfoModel> setReserveInfo(BuildContext context) async { | ||
| 475 | + UserModel userModel = Provider.of<UserModel>(context, listen: false); | ||
| 476 | + String pnum = '6'; | ||
| 477 | + for (var item in personNumList) { | ||
| 478 | + if (item['isSelect']) { | ||
| 479 | + pnum = item['dateText']; | ||
| 480 | + } | ||
| 481 | + } | ||
| 482 | + if (pnum == '') { | ||
| 483 | + pnum = '6'; | ||
| 484 | + } | ||
| 485 | + String sex = '1'; | ||
| 486 | + for (var item in sexList) { | ||
| 487 | + if (item['select']) { | ||
| 488 | + sex = item['code']; | ||
| 489 | + } | ||
| 490 | + } | ||
| 491 | + //当前选中 月 日string | ||
| 492 | + String mdStr = ''; | ||
| 493 | + //今天 明天 其他天 | ||
| 494 | + for (var item in dateList) { | ||
| 495 | + if (item['select'] == true) { | ||
| 496 | + mdStr = item['title']; | ||
| 497 | + } | ||
| 498 | + } | ||
| 499 | + String timeNowYear = DateUtil.formatDate(DateTime.now(), format: 'yyyy'); | ||
| 500 | + String ymyStr = timeNowYear + '-' + mdStr; //年月日 | ||
| 501 | + String timeStr = ymyStr + ' ' + ddateStr + ':00'; | ||
| 502 | + // int start = DateUtil.getDateMsByTimeStr(timeStr); | ||
| 503 | + | ||
| 504 | + // String tempDdate = ymyStr + ' ' + ddateStr + ':00'; | ||
| 505 | + int ddate = DateUtil.getDateMsByTimeStr(timeStr); | ||
| 506 | + String tableSelectInfo = ''; | ||
| 507 | + for (TableList item in tableList) { | ||
| 508 | + // if (item.selected) { | ||
| 509 | + tableSelectInfo += ',${item.id}'; | ||
| 510 | + // } | ||
| 511 | + } | ||
| 512 | + print(tableSelectInfo); | ||
| 513 | + if (tableSelectInfo.startsWith(',')) { | ||
| 514 | + tableSelectInfo = tableSelectInfo.substring(1); | ||
| 515 | + } | ||
| 516 | + print(tableSelectInfo); | ||
| 517 | + String rdate = ''; | ||
| 518 | + String ddateSolt = ''; | ||
| 519 | + print(sunDateList); | ||
| 520 | + for (var item in sunDateList) { | ||
| 521 | + if (item['isSelect'] == true) { | ||
| 522 | + String keys = ''; | ||
| 523 | + ddateSolt = '${item['ddateSolt']}'; | ||
| 524 | + if (item['ddateSolt'] == 1) { | ||
| 525 | + //早市 | ||
| 526 | + keys = 'morning'; | ||
| 527 | + } else if (item['ddateSolt'] == 2) { | ||
| 528 | + //午市 | ||
| 529 | + keys = 'noon'; | ||
| 530 | + } else if (item['ddateSolt'] == 3) { | ||
| 531 | + //晚市 | ||
| 532 | + keys = 'night'; | ||
| 533 | + } | ||
| 534 | + if (keys != '') { | ||
| 535 | + String start = '${ddate}'.substring(0, 10); | ||
| 536 | + List temp = dailyMap[keys]; | ||
| 537 | + String timeStrEnd = ymyStr + ' ' + temp.last['title'] + ':00'; | ||
| 538 | + int endM = DateUtil.getDateMsByTimeStr(timeStrEnd); | ||
| 539 | + String end = '${endM}'.substring(0, 10); | ||
| 540 | + rdate = start + '-' + end; | ||
| 541 | + } | ||
| 542 | + } | ||
| 543 | + } | ||
| 544 | + Map<String, String> params = { | ||
| 545 | + 'is_set_ddate': isSetDate, | ||
| 546 | + "rid": detailEntity.id, //变更订单必传预定ID | ||
| 547 | + "sid": userModel.user.sellerid, //商家ID | ||
| 548 | + "tid": tableSelectInfo, //桌子ID: 格式 2,3,4 | ||
| 549 | + "pnum": pnum, //预定用餐人数 | ||
| 550 | + "rname": nameController.text, //预订人姓名 | ||
| 551 | + "sex": sex, //预订人姓名:1:男 2:女 | ||
| 552 | + "phone": phoneController.text, //预订人电话 | ||
| 553 | + "cusdem": customController.text, //预订人需求:25汉字 | ||
| 554 | + "rdate": rdate, //预定用餐时间范围:时间戳 开始时间戳(time)-结束时间戳(time) | ||
| 555 | + "ddate": '${ddate}'.substring(0, 10), //到店时间 | ||
| 556 | + "ddate_solt": ddateSolt | ||
| 557 | + }; | ||
| 558 | + print(params); | ||
| 559 | + BaseResp<Map<String, dynamic>> baseResp = await DioUtil() | ||
| 560 | + .request<Map<String, dynamic>>( | ||
| 561 | + context, Method.get, HttpUrl.set_reserve_info, | ||
| 562 | + data: params) | ||
| 563 | + .catchError((error) { | ||
| 564 | + print(error.toString()); | ||
| 565 | + }); | ||
| 566 | + SunReserveInfoModel itemModel; | ||
| 567 | + if (baseResp == null) return itemModel; | ||
| 568 | + if (baseResp.code == Constant.status_success) { | ||
| 569 | + if (int.parse(baseResp.status) != Constant.status_success) { | ||
| 570 | + Utils.showToast(baseResp.msg ?? ""); | ||
| 571 | + return itemModel; | ||
| 572 | + } | ||
| 573 | + if (baseResp.responseData['data'] != null && | ||
| 574 | + baseResp.responseData['data']['row'] != null) { | ||
| 575 | + itemModel = ReserveInfoModel.fromJson(baseResp.responseData).data; | ||
| 576 | + } else { | ||
| 577 | + Utils.showToast(baseResp.msg ?? "变更预订失败,请重试"); | ||
| 578 | + } | ||
| 579 | + return itemModel; | ||
| 580 | + } | ||
| 581 | + } | ||
| 582 | +} |
lib/provider/table_manager_model.dart
0 → 100644
| 1 | +import 'package:flutter/material.dart'; | ||
| 2 | +import 'package:one_key/constant/constant.dart'; | ||
| 3 | +import 'package:one_key/models/tableOuter.dart'; | ||
| 4 | +import 'package:one_key/net/base_resp.dart'; | ||
| 5 | +import 'package:one_key/net/dio_util.dart'; | ||
| 6 | +import 'package:one_key/net/http_url.dart'; | ||
| 7 | +import 'package:one_key/models/table.dart' as t; | ||
| 8 | +import 'package:one_key/utils/navigator_util.dart'; | ||
| 9 | +import 'package:one_key/utils/utils.dart'; | ||
| 10 | + | ||
| 11 | +class TableManagerModel with ChangeNotifier{ | ||
| 12 | + | ||
| 13 | + //获取桌位数据 | ||
| 14 | + Future<List<TableOuter>> getTableList(BuildContext context,Map<String,String> params) async { | ||
| 15 | + BaseResp<List> baseResp = await DioUtil() | ||
| 16 | + .request<List>(context, Method.get, HttpUrl.table_list, | ||
| 17 | + data: params,showLoading: true) | ||
| 18 | + .catchError((error) { | ||
| 19 | + print(error.toString()); | ||
| 20 | + }); | ||
| 21 | + if(baseResp.code==Constant.status_success){ | ||
| 22 | + return (baseResp.data[0] as List).map((value){ | ||
| 23 | + TableOuter tableOuter=TableOuter(); | ||
| 24 | + tableOuter.name=value["name"]; | ||
| 25 | + tableOuter.list=(value["list"] as List).map((table){ | ||
| 26 | + return t.Table.fromJson(table as Map<String,dynamic>); | ||
| 27 | + }).toList(); | ||
| 28 | + return tableOuter; | ||
| 29 | + }).toList(); | ||
| 30 | + } | ||
| 31 | + return []; | ||
| 32 | + } | ||
| 33 | +} |
| @@ -32,7 +32,7 @@ class NavigatorUtil { | @@ -32,7 +32,7 @@ class NavigatorUtil { | ||
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | /// 首页 | 34 | /// 首页 |
| 35 | - static void goHomePage(BuildContext context, {int initialIndex = 1}) { | 35 | + static void goHomePage(BuildContext context, {int initialIndex = 2}) { |
| 36 | _navigateTo(context, "${Routes.home}?initialIndex=$initialIndex", | 36 | _navigateTo(context, "${Routes.home}?initialIndex=$initialIndex", |
| 37 | clearStack: true); | 37 | clearStack: true); |
| 38 | } | 38 | } |
| @@ -64,14 +64,14 @@ class TableItemState extends State<TableItem> { | @@ -64,14 +64,14 @@ class TableItemState extends State<TableItem> { | ||
| 64 | } | 64 | } |
| 65 | } | 65 | } |
| 66 | } | 66 | } |
| 67 | - } else { | ||
| 68 | - //从安排桌位进来 | ||
| 69 | - if (widget.canSelected && table.signStr.isEmpty) { | ||
| 70 | - setState(() { | ||
| 71 | - table.selected = !(table.selected ?? false); | ||
| 72 | - }); | ||
| 73 | - widget.onSelected(table); | ||
| 74 | - } | 67 | + } else if (widget.canSelected && table.signStr.isEmpty){//从安排桌位进来 |
| 68 | + setState(() { | ||
| 69 | + table.selected = !(table.selected ?? false); | ||
| 70 | + }); | ||
| 71 | + widget.onSelected(table); | ||
| 72 | + }else{ | ||
| 73 | + table.selected = !(table.selected ?? false); | ||
| 74 | + widget.onSelected(table); | ||
| 75 | } | 75 | } |
| 76 | }, | 76 | }, |
| 77 | child: Stack( | 77 | child: Stack( |
-
Please register or login to post a comment