Showing
9 changed files
with
1249 additions
and
0 deletions
| @@ -366,6 +366,19 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver { | @@ -366,6 +366,19 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver { | ||
| 366 | color: MyColours.color_f3f3f3, | 366 | color: MyColours.color_f3f3f3, |
| 367 | ), | 367 | ), |
| 368 | MyItem( | 368 | MyItem( |
| 369 | + title: "桌位管理", | ||
| 370 | + content: "", | ||
| 371 | + callback: () { | ||
| 372 | + NavigatorUtil.goMyTableManagerHomePage(context); | ||
| 373 | + }, | ||
| 374 | + ), | ||
| 375 | + | ||
| 376 | + MyDivider( | ||
| 377 | + double.infinity, | ||
| 378 | + ScreenUtil().setHeight(1), | ||
| 379 | + color: MyColours.color_f3f3f3, | ||
| 380 | + ), | ||
| 381 | + MyItem( | ||
| 369 | title: "短信管理", | 382 | title: "短信管理", |
| 370 | content: | 383 | content: |
| 371 | myModel.smsInfo.isNotEmpty ? '剩余${myModel.smsInfo}条' : '', | 384 | myModel.smsInfo.isNotEmpty ? '剩余${myModel.smsInfo}条' : '', |
| 1 | +import 'dart:async'; | ||
| 2 | + | ||
| 3 | +import 'package:common_utils/common_utils.dart'; | ||
| 4 | +import 'package:dotted_border/dotted_border.dart'; | ||
| 5 | +import 'package:flutter/material.dart'; | ||
| 6 | +import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
| 7 | +import 'package:one_key/constant/state.dart'; | ||
| 8 | +import 'package:one_key/models/area.dart'; | ||
| 9 | +import 'package:one_key/models/guest_info_model.dart'; | ||
| 10 | + | ||
| 11 | +import 'package:one_key/models/reserve_info_model.dart'; | ||
| 12 | +import 'package:one_key/pages/my/table_manage/table_manage_area_item.dart'; | ||
| 13 | + | ||
| 14 | +import 'package:one_key/pages/table/area_item_table.dart'; | ||
| 15 | +import 'package:one_key/provider/my_table_manage_home_model.dart'; | ||
| 16 | + | ||
| 17 | +import 'package:one_key/provider/user_model.dart'; | ||
| 18 | +import 'package:one_key/res/colors.dart'; | ||
| 19 | +import 'package:one_key/utils/dialog_util.dart'; | ||
| 20 | +import 'package:one_key/utils/event_bus.dart'; | ||
| 21 | +import 'package:one_key/route/navigator_util.dart'; | ||
| 22 | +import 'package:one_key/utils/utils.dart'; | ||
| 23 | +import 'package:one_key/widgets/MyDivider.dart'; | ||
| 24 | + | ||
| 25 | +import 'package:one_key/widgets/common_button_flat.dart'; | ||
| 26 | +import 'package:one_key/widgets/f_table_item.dart'; | ||
| 27 | +import 'package:one_key/widgets/h_empty_view.dart'; | ||
| 28 | +import 'package:one_key/widgets/page_exception.dart'; | ||
| 29 | +import 'package:one_key/widgets/round_button.dart'; | ||
| 30 | +import 'package:one_key/widgets/system_app_bar.dart'; | ||
| 31 | + | ||
| 32 | +import 'package:one_key/models/table.dart' as t; | ||
| 33 | +import 'package:one_key/widgets/table_manage_item.dart'; | ||
| 34 | +import 'package:one_key/widgets/v_empty_view.dart'; | ||
| 35 | +import 'package:provider/provider.dart'; | ||
| 36 | +import 'dart:convert' as convert; | ||
| 37 | +import 'package:scrollable_positioned_list/scrollable_positioned_list.dart'; | ||
| 38 | +import 'package:one_key/models/table_list.dart' as table; | ||
| 39 | + | ||
| 40 | +const scrollDuration = Duration(microseconds: 500); | ||
| 41 | + | ||
| 42 | +class MyTableManagerHomePage extends StatefulWidget { | ||
| 43 | + @override | ||
| 44 | + State<StatefulWidget> createState() { | ||
| 45 | + // TODO: implement createState | ||
| 46 | + return new MyTableManagerHomePageState(); | ||
| 47 | + } | ||
| 48 | +} | ||
| 49 | + | ||
| 50 | +class MyTableManagerHomePageState extends State<MyTableManagerHomePage> { | ||
| 51 | + MyTableManageHomeModel tableManagerModel; | ||
| 52 | + final ItemScrollController itemScrollController = ItemScrollController(); | ||
| 53 | + bool isTap = false; | ||
| 54 | + // 进度监听对象 | ||
| 55 | + int min; | ||
| 56 | + int max; | ||
| 57 | + int _selectIndex = 0; | ||
| 58 | + ScrollController _areaController = ScrollController(); | ||
| 59 | + List<String> personNumList = []; | ||
| 60 | + | ||
| 61 | + // ScrollController _scrollCrl = ScrollController(); | ||
| 62 | + final ItemPositionsListener itemPositionsListener = | ||
| 63 | + ItemPositionsListener.create(); | ||
| 64 | + | ||
| 65 | + @override | ||
| 66 | + void initState() { | ||
| 67 | + // TODO: implement initState | ||
| 68 | + super.initState(); | ||
| 69 | + | ||
| 70 | + LogUtil.v("table_manager_page initState"); | ||
| 71 | + for (int i = 1; i < 31; i++) { | ||
| 72 | + personNumList.add(i.toString()); | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + // personNumList.add('30以上'); | ||
| 76 | + | ||
| 77 | + WidgetsBinding.instance.addPostFrameCallback((_) { | ||
| 78 | + tableManagerModel.initTime(context); | ||
| 79 | + // EventBus().on("refresh_tablemanager", (arg) { | ||
| 80 | + // //订座-完成预订 刷新管理桌位 | ||
| 81 | + // tableManagerModel.getReserveList(context, | ||
| 82 | + // needLoading: false, needKeep: true); | ||
| 83 | + // print(tableManagerModel); | ||
| 84 | + // }); | ||
| 85 | + // EventBus().on("refresh_tablePhoto", (arg) { | ||
| 86 | + // ///刷新图片显示 | ||
| 87 | + // _refreshTablePhoto(); | ||
| 88 | + // }); | ||
| 89 | + }); | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + @override | ||
| 93 | + void dispose() { | ||
| 94 | + // TODO: implement dispose | ||
| 95 | + super.dispose(); | ||
| 96 | + // EventBus().off("refresh_tablemanager"); | ||
| 97 | + // EventBus().off("refresh_tablePhoto"); | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + ///刷新图片显示 | ||
| 101 | + // _refreshTablePhoto() async { | ||
| 102 | + // List temp = | ||
| 103 | + // await tableManagerModel.getTableList(context, needLoading: false); | ||
| 104 | + // if (temp.length > 0) { | ||
| 105 | + // tableManagerModel.getReserveList(context, | ||
| 106 | + // needLoading: false, needKeep: true); | ||
| 107 | + // tableManagerModel.notifyListeners(); | ||
| 108 | + // } | ||
| 109 | + // } | ||
| 110 | + | ||
| 111 | + Widget list(List data) => ScrollablePositionedList.builder( | ||
| 112 | + itemCount: data.length, | ||
| 113 | + itemBuilder: (context, index) => item(index), | ||
| 114 | + itemScrollController: itemScrollController, | ||
| 115 | + itemPositionsListener: itemPositionsListener, | ||
| 116 | + reverse: false, | ||
| 117 | + scrollDirection: Axis.vertical, | ||
| 118 | + ); | ||
| 119 | + | ||
| 120 | + void scrollTo(int index) => itemScrollController | ||
| 121 | + .scrollTo( | ||
| 122 | + index: index, | ||
| 123 | + duration: scrollDuration, | ||
| 124 | + curve: Curves.easeInOutCubic, | ||
| 125 | + alignment: 0) | ||
| 126 | + .then((value) { | ||
| 127 | + print(_selectIndex); | ||
| 128 | + // _selectIndex = _selectIndex; | ||
| 129 | + // // } | ||
| 130 | + // isTap = false; | ||
| 131 | + this.setState(() {}); | ||
| 132 | + }).whenComplete(() { | ||
| 133 | + // print(''); | ||
| 134 | + }); | ||
| 135 | + | ||
| 136 | + void jumpTo(int index) => | ||
| 137 | + itemScrollController.jumpTo(index: index, alignment: 0); | ||
| 138 | + | ||
| 139 | + /// Generate item number [i]. | ||
| 140 | + Widget item(int i) { | ||
| 141 | + return GridView.builder( | ||
| 142 | + // controller: _areaController, | ||
| 143 | + // physics: NeverScrollableScrollPhysics(), | ||
| 144 | + | ||
| 145 | + shrinkWrap: true, | ||
| 146 | + itemCount: tableManagerModel.tableOuterList[i].list.length + 1, | ||
| 147 | + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( | ||
| 148 | + crossAxisCount: 4, | ||
| 149 | + childAspectRatio: 1, | ||
| 150 | + mainAxisSpacing: ScreenUtil().setWidth(28), | ||
| 151 | + crossAxisSpacing: ScreenUtil().setWidth(48), | ||
| 152 | + ), | ||
| 153 | + | ||
| 154 | + itemBuilder: (BuildContext context, int index) { | ||
| 155 | + if (index == tableManagerModel.tableOuterList[i].list.length || | ||
| 156 | + tableManagerModel.tableOuterList[i].list.length == 0) { | ||
| 157 | + return InkWell( | ||
| 158 | + onTap: () async { | ||
| 159 | + List<String> areas = []; | ||
| 160 | + for (int i = 0; i < tableManagerModel.areas.length; i++) { | ||
| 161 | + areas.add(tableManagerModel.areas[i].name); | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + //添加桌位弹框 | ||
| 165 | + await DialogUtil.openCreateTableDialog( | ||
| 166 | + context, areas, i, personNumList, | ||
| 167 | + onTap: (Map<String, String> value) async { | ||
| 168 | + print(value); | ||
| 169 | + // 'areaname': | ||
| 170 | + // areas[currentAreaIndex], | ||
| 171 | + // 'name': controller.text, | ||
| 172 | + // 'pnumMin': pnumMin, | ||
| 173 | + // 'pnumMax': pnumMax | ||
| 174 | + //添加桌位 接口参数带整合??? | ||
| 175 | + // 以下是旧的不去,明天添加桌位接口 | ||
| 176 | + String rid; | ||
| 177 | + for (Area item in tableManagerModel.areas) { | ||
| 178 | + if (item.name == value['areaname']) { | ||
| 179 | + rid = item.rid; | ||
| 180 | + } | ||
| 181 | + } | ||
| 182 | + Map<String, String> params = { | ||
| 183 | + 'rid': rid, | ||
| 184 | + 'name': value['name'], | ||
| 185 | + }; | ||
| 186 | + if (value['pnumMin'] != '') { | ||
| 187 | + params['pnum'] = value['pnumMin']; | ||
| 188 | + } | ||
| 189 | + if (value['pnumMax'] != '') { | ||
| 190 | + params['most_pnum'] = value['pnumMax']; | ||
| 191 | + } | ||
| 192 | + bool success = | ||
| 193 | + await tableManagerModel.addTable(context, params); | ||
| 194 | + print(success); | ||
| 195 | + if (success) { | ||
| 196 | + Utils.showToast('添加成功!'); | ||
| 197 | + // TableOuter tableOuter = TableOuter(); | ||
| 198 | + // tableOuter.name = value; | ||
| 199 | + // tableOuter.list = []; | ||
| 200 | + // tableManagerModel.tableOuterList.add(tableOuter); | ||
| 201 | + // tableManagerModel.initData(); | ||
| 202 | + // Timer( | ||
| 203 | + // Duration(milliseconds: 500), | ||
| 204 | + // () => _areaController.jumpTo( | ||
| 205 | + // _areaController.position.maxScrollExtent)); | ||
| 206 | + | ||
| 207 | + // await tableManagerModel | ||
| 208 | + // .getTableList(context); | ||
| 209 | + // await tableManagerModel | ||
| 210 | + // .initData(); | ||
| 211 | + await tableManagerModel.refreshTable(context); | ||
| 212 | + } | ||
| 213 | + }); | ||
| 214 | + }, | ||
| 215 | + child: Container( | ||
| 216 | + child: DottedBorder( | ||
| 217 | + dashPattern: [8, 8, 8, 8], | ||
| 218 | + borderType: BorderType.RRect, | ||
| 219 | + radius: Radius.circular(ScreenUtil().setWidth(10)), | ||
| 220 | + // padding: EdgeInsets.all(ScreenUtil().setWidth(70)), | ||
| 221 | + color: MyColours.color_438E93, | ||
| 222 | + strokeWidth: ScreenUtil().setWidth(2), | ||
| 223 | + child: ClipRRect( | ||
| 224 | + borderRadius: BorderRadius.all( | ||
| 225 | + Radius.circular(ScreenUtil().setWidth(10))), | ||
| 226 | + child: Container( | ||
| 227 | + height: ScreenUtil.screenWidthDp - | ||
| 228 | + ScreenUtil().setWidth(48 * 3 + 32 * 2), | ||
| 229 | + width: ScreenUtil.screenWidthDp - | ||
| 230 | + ScreenUtil().setWidth(48 * 3 + 32 * 2), | ||
| 231 | + child: Column( | ||
| 232 | + mainAxisAlignment: MainAxisAlignment.center, | ||
| 233 | + children: [ | ||
| 234 | + Image.asset(Utils.getImgPath('add_area'), | ||
| 235 | + width: ScreenUtil().setWidth(60)), | ||
| 236 | + ], | ||
| 237 | + ), | ||
| 238 | + ), | ||
| 239 | + ), | ||
| 240 | + ))); | ||
| 241 | + } else { | ||
| 242 | + return Selector<MyTableManageHomeModel, t.Table>( | ||
| 243 | + shouldRebuild: (pre, next) => true, | ||
| 244 | + selector: (context, model) => | ||
| 245 | + tableManagerModel.tableOuterList[i].list[index], | ||
| 246 | + builder: (context, table, _) { | ||
| 247 | + return ManageTableItem(table, | ||
| 248 | + canMulSelected: tableManagerModel.tableOuterList[i].isSelect, | ||
| 249 | + onSelected: (table) { | ||
| 250 | + if (tableManagerModel.tableOuterList[i].isSelect) { | ||
| 251 | + //多选 | ||
| 252 | + setState(() { | ||
| 253 | + table.selected = !(table.selected ?? false); | ||
| 254 | + }); | ||
| 255 | + } else { | ||
| 256 | + for (t.Table item | ||
| 257 | + in tableManagerModel.tableOuterList[i].list) { | ||
| 258 | + item.selected = false; | ||
| 259 | + } | ||
| 260 | + //单选 | ||
| 261 | + setState(() { | ||
| 262 | + table.selected = true; | ||
| 263 | + }); | ||
| 264 | + } | ||
| 265 | + }); | ||
| 266 | + }, | ||
| 267 | + ); | ||
| 268 | + } | ||
| 269 | + }, | ||
| 270 | + ); | ||
| 271 | + } | ||
| 272 | + | ||
| 273 | + @override | ||
| 274 | + Widget build(BuildContext context) { | ||
| 275 | + tableManagerModel = | ||
| 276 | + Provider.of<MyTableManageHomeModel>(context, listen: true); | ||
| 277 | + return WillPopScope( | ||
| 278 | + onWillPop: () async { | ||
| 279 | + EventBus().emit('changeStatusColor'); | ||
| 280 | + return true; | ||
| 281 | + }, | ||
| 282 | + child: Scaffold( | ||
| 283 | + appBar: SystemAppBar( | ||
| 284 | + "桌位管理", | ||
| 285 | + showLeading: true, | ||
| 286 | + onTap: () { | ||
| 287 | + EventBus().emit('changeStatusColor'); | ||
| 288 | + Navigator.pop(context); | ||
| 289 | + }, | ||
| 290 | + ), | ||
| 291 | + backgroundColor: MyColours.color_ffffff, | ||
| 292 | + body: SafeArea(child: Consumer<MyTableManageHomeModel>( | ||
| 293 | + builder: (context, model, child) { | ||
| 294 | + return Column( | ||
| 295 | + children: <Widget>[ | ||
| 296 | + model.pageState != PageState.Success | ||
| 297 | + ? Expanded( | ||
| 298 | + child: ExceptionPage( | ||
| 299 | + pageState: model.pageState, | ||
| 300 | + callback: () { | ||
| 301 | + // if (tableManagerModel.tableOuterList.isEmpty) { | ||
| 302 | + // tableManagerModel.getTableList(context); | ||
| 303 | + // } else { | ||
| 304 | + // tableManagerModel.getReserveList(context); | ||
| 305 | + // } | ||
| 306 | + }, | ||
| 307 | + emptyMsg: "暂时没有桌位哦", | ||
| 308 | + emptyImg: "empty_search", | ||
| 309 | + showMsg: "加载中,请稍后...", | ||
| 310 | + )) | ||
| 311 | + : Expanded( | ||
| 312 | + child: Column( | ||
| 313 | + // crossAxisAlignment: CrossAxisAlignment.center, | ||
| 314 | + children: [ | ||
| 315 | + VEmptyView(48), | ||
| 316 | + Container( | ||
| 317 | + color: MyColours.color_ffffff, | ||
| 318 | + height: ScreenUtil().setWidth(92), | ||
| 319 | + margin: EdgeInsets.only( | ||
| 320 | + bottom: ScreenUtil().setWidth(24)), | ||
| 321 | + child: Row( | ||
| 322 | + children: [ | ||
| 323 | + HEmptyView(48), | ||
| 324 | + Expanded( | ||
| 325 | + child: ListView.builder( | ||
| 326 | + itemCount: | ||
| 327 | + tableManagerModel.areas.length == 0 | ||
| 328 | + ? 1 | ||
| 329 | + : tableManagerModel | ||
| 330 | + .areas.length + | ||
| 331 | + 1, | ||
| 332 | + shrinkWrap: true, | ||
| 333 | + scrollDirection: Axis.horizontal, | ||
| 334 | + itemBuilder: | ||
| 335 | + (BuildContext contxt, int index) { | ||
| 336 | + if (index == | ||
| 337 | + tableManagerModel | ||
| 338 | + .areas.length || | ||
| 339 | + tableManagerModel.areas.length == | ||
| 340 | + 0) { | ||
| 341 | + return InkWell( | ||
| 342 | + onTap: () async { | ||
| 343 | + //添加区域弹框 | ||
| 344 | + await DialogUtil | ||
| 345 | + .openCreateAreaDialog( | ||
| 346 | + context, | ||
| 347 | + onTap: (value) async { | ||
| 348 | + print(value); | ||
| 349 | + //添加区域 | ||
| 350 | + bool success = | ||
| 351 | + await tableManagerModel | ||
| 352 | + .addTableAreas( | ||
| 353 | + context, value); | ||
| 354 | + print(success); | ||
| 355 | + if (success) { | ||
| 356 | + Utils.showToast('添加成功!'); | ||
| 357 | + tableManagerModel | ||
| 358 | + .currentArea = value; | ||
| 359 | + | ||
| 360 | + await tableManagerModel | ||
| 361 | + .refreshTable(context); | ||
| 362 | + // await tableManagerModel | ||
| 363 | + // .getTableList(context, | ||
| 364 | + // needLoading: false); | ||
| 365 | + // tableManagerModel.initData(); | ||
| 366 | + | ||
| 367 | + // setState(() { | ||
| 368 | + // updateMenu(); | ||
| 369 | + // }); | ||
| 370 | + // _scrollToIndex(widget | ||
| 371 | + // .tableManagerModel | ||
| 372 | + // .areas | ||
| 373 | + // .length); | ||
| 374 | + | ||
| 375 | + } | ||
| 376 | + }); | ||
| 377 | + }, | ||
| 378 | + child: Column( | ||
| 379 | + children: [ | ||
| 380 | + VEmptyView(20), | ||
| 381 | + DottedBorder( | ||
| 382 | + dashPattern: [2, 2, 2, 2], | ||
| 383 | + borderType: | ||
| 384 | + BorderType.RRect, | ||
| 385 | + radius: Radius.circular( | ||
| 386 | + ScreenUtil() | ||
| 387 | + .setWidth(10)), | ||
| 388 | + // padding: EdgeInsets.all(ScreenUtil().setWidth(70)), | ||
| 389 | + color: | ||
| 390 | + MyColours.color_999999, | ||
| 391 | + strokeWidth: ScreenUtil() | ||
| 392 | + .setWidth(2), | ||
| 393 | + child: ClipRRect( | ||
| 394 | + borderRadius: | ||
| 395 | + BorderRadius.all( | ||
| 396 | + Radius.circular( | ||
| 397 | + ScreenUtil() | ||
| 398 | + .setWidth( | ||
| 399 | + 10))), | ||
| 400 | + child: Container( | ||
| 401 | + height: ScreenUtil() | ||
| 402 | + .setWidth(28 * 2), | ||
| 403 | + width: ScreenUtil() | ||
| 404 | + .setWidth(48 * 2), | ||
| 405 | + child: Column( | ||
| 406 | + mainAxisAlignment: | ||
| 407 | + MainAxisAlignment | ||
| 408 | + .center, | ||
| 409 | + children: [ | ||
| 410 | + Image.asset( | ||
| 411 | + Utils.getImgPath( | ||
| 412 | + 'add_store'), | ||
| 413 | + width: ScreenUtil() | ||
| 414 | + .setWidth( | ||
| 415 | + 24)), | ||
| 416 | + ], | ||
| 417 | + ), | ||
| 418 | + ), | ||
| 419 | + ), | ||
| 420 | + ) | ||
| 421 | + ], | ||
| 422 | + ), | ||
| 423 | + ); | ||
| 424 | + } else { | ||
| 425 | + return TableManageAreaItem( | ||
| 426 | + model.areas[index], | ||
| 427 | + tableManagerModel.currentArea, | ||
| 428 | + (area) { | ||
| 429 | + setState(() { | ||
| 430 | + tableManagerModel.selectNumber = | ||
| 431 | + index; | ||
| 432 | + tableManagerModel.currentArea = | ||
| 433 | + tableManagerModel | ||
| 434 | + .areas[index].name; | ||
| 435 | + // tableManagerModel.currentTables = | ||
| 436 | + // tableManagerModel | ||
| 437 | + // .areaTableMapShow[ | ||
| 438 | + // tableManagerModel | ||
| 439 | + // .currentArea]; | ||
| 440 | + // _anmationMenu(); | ||
| 441 | + }); | ||
| 442 | + }); | ||
| 443 | + } | ||
| 444 | + }, | ||
| 445 | + )), | ||
| 446 | + InkWell( | ||
| 447 | + onTap: () { | ||
| 448 | + if (tableManagerModel | ||
| 449 | + .tableOuterList.length > | ||
| 450 | + 0) { | ||
| 451 | + //区域管理页面跳转 | ||
| 452 | + } | ||
| 453 | + }, | ||
| 454 | + child: Container( | ||
| 455 | + margin: EdgeInsets.only( | ||
| 456 | + top: ScreenUtil().setWidth(20), | ||
| 457 | + ), | ||
| 458 | + child: Row( | ||
| 459 | + children: [ | ||
| 460 | + HEmptyView(20), | ||
| 461 | + MyDivider( | ||
| 462 | + ScreenUtil().setWidth(2), | ||
| 463 | + ScreenUtil().setWidth(36), | ||
| 464 | + color: | ||
| 465 | + MyColours.color_BFC4D4), | ||
| 466 | + HEmptyView(20), | ||
| 467 | + Text( | ||
| 468 | + '区域管理', | ||
| 469 | + style: TextStyle( | ||
| 470 | + fontSize: ScreenUtil() | ||
| 471 | + .setSp(28), | ||
| 472 | + color: tableManagerModel | ||
| 473 | + .tableOuterList | ||
| 474 | + .length == | ||
| 475 | + 0 | ||
| 476 | + ? MyColours | ||
| 477 | + .color_BFC4D4 | ||
| 478 | + : MyColours | ||
| 479 | + .color_000000, | ||
| 480 | + decoration: TextDecoration | ||
| 481 | + .underline), | ||
| 482 | + ), | ||
| 483 | + HEmptyView(40) | ||
| 484 | + ], | ||
| 485 | + )), | ||
| 486 | + ) | ||
| 487 | + ], | ||
| 488 | + ), | ||
| 489 | + ), | ||
| 490 | + tableManagerModel.tableOuterList.length == 0 | ||
| 491 | + ? Padding( | ||
| 492 | + padding: EdgeInsets.only( | ||
| 493 | + left: ScreenUtil().setWidth(100)), | ||
| 494 | + child: Column( | ||
| 495 | + crossAxisAlignment: | ||
| 496 | + CrossAxisAlignment.start, | ||
| 497 | + children: [ | ||
| 498 | + VEmptyView(180), | ||
| 499 | + Row( | ||
| 500 | + children: [ | ||
| 501 | + Text( | ||
| 502 | + '1、', | ||
| 503 | + style: TextStyle( | ||
| 504 | + fontSize: ScreenUtil() | ||
| 505 | + .setSp(32), | ||
| 506 | + color: MyColours | ||
| 507 | + .color_BFC4D4), | ||
| 508 | + ), | ||
| 509 | + InkWell( | ||
| 510 | + onTap: () async { | ||
| 511 | + //添加区域弹框 | ||
| 512 | + await DialogUtil | ||
| 513 | + .openCreateAreaDialog( | ||
| 514 | + context, onTap: | ||
| 515 | + (value) async { | ||
| 516 | + print(value); | ||
| 517 | + //添加区域 | ||
| 518 | + bool success = | ||
| 519 | + await tableManagerModel | ||
| 520 | + .addTableAreas( | ||
| 521 | + context, | ||
| 522 | + value); | ||
| 523 | + print(success); | ||
| 524 | + if (success) { | ||
| 525 | + Utils.showToast( | ||
| 526 | + '添加成功!'); | ||
| 527 | + tableManagerModel | ||
| 528 | + .currentArea = | ||
| 529 | + value; | ||
| 530 | + | ||
| 531 | + await tableManagerModel | ||
| 532 | + .refreshTable( | ||
| 533 | + context); | ||
| 534 | + // await tableManagerModel | ||
| 535 | + // .getTableList(context, | ||
| 536 | + // needLoading: false); | ||
| 537 | + // tableManagerModel.initData(); | ||
| 538 | + | ||
| 539 | + // setState(() { | ||
| 540 | + // updateMenu(); | ||
| 541 | + // }); | ||
| 542 | + // _scrollToIndex(widget | ||
| 543 | + // .tableManagerModel | ||
| 544 | + // .areas | ||
| 545 | + // .length); | ||
| 546 | + | ||
| 547 | + } | ||
| 548 | + }); | ||
| 549 | + }, | ||
| 550 | + child: Text('添加区域', | ||
| 551 | + style: TextStyle( | ||
| 552 | + fontSize: ScreenUtil() | ||
| 553 | + .setSp(32), | ||
| 554 | + color: MyColours | ||
| 555 | + .color_438E93, | ||
| 556 | + decoration: | ||
| 557 | + TextDecoration | ||
| 558 | + .underline)), | ||
| 559 | + ), | ||
| 560 | + Text('(如:一楼、二楼、东厅等)', | ||
| 561 | + style: TextStyle( | ||
| 562 | + fontSize: ScreenUtil() | ||
| 563 | + .setSp(32), | ||
| 564 | + color: MyColours | ||
| 565 | + .color_BFC4D4)) | ||
| 566 | + ], | ||
| 567 | + ), | ||
| 568 | + VEmptyView(40), | ||
| 569 | + Text('2、选择要添加桌位的区域', | ||
| 570 | + style: TextStyle( | ||
| 571 | + fontSize: | ||
| 572 | + ScreenUtil().setSp(32), | ||
| 573 | + color: MyColours | ||
| 574 | + .color_BFC4D4)), | ||
| 575 | + VEmptyView(40), | ||
| 576 | + Text('3、点击“+”号添加桌位', | ||
| 577 | + style: TextStyle( | ||
| 578 | + fontSize: | ||
| 579 | + ScreenUtil().setSp(32), | ||
| 580 | + color: MyColours | ||
| 581 | + .color_BFC4D4)), | ||
| 582 | + VEmptyView(120), | ||
| 583 | + Image.asset( | ||
| 584 | + "assets/empty_search.png", | ||
| 585 | + width: ScreenUtil().setWidth(520), | ||
| 586 | + height: | ||
| 587 | + ScreenUtil().setWidth(384), | ||
| 588 | + ), | ||
| 589 | + VEmptyView(40), | ||
| 590 | + ], | ||
| 591 | + )) | ||
| 592 | + : SizedBox(), | ||
| 593 | + Expanded( | ||
| 594 | + // flex: 2, | ||
| 595 | + child: Container( | ||
| 596 | + constraints: BoxConstraints( | ||
| 597 | + minHeight: | ||
| 598 | + ScreenUtil().setWidth(100)), | ||
| 599 | + color: MyColours.color_ffffff, | ||
| 600 | + padding: EdgeInsets.symmetric( | ||
| 601 | + vertical: ScreenUtil().setWidth(20), | ||
| 602 | + horizontal: | ||
| 603 | + ScreenUtil().setWidth(48)), | ||
| 604 | + child: Column( | ||
| 605 | + children: [ | ||
| 606 | + VEmptyView(26), | ||
| 607 | + tableManagerModel | ||
| 608 | + .tableOuterList[ | ||
| 609 | + tableManagerModel | ||
| 610 | + .selectNumber] | ||
| 611 | + .list | ||
| 612 | + .length == | ||
| 613 | + 0 | ||
| 614 | + ? SizedBox() | ||
| 615 | + : InkWell( | ||
| 616 | + onTap: () { | ||
| 617 | + for (t.Table item | ||
| 618 | + in tableManagerModel | ||
| 619 | + .tableOuterList[ | ||
| 620 | + tableManagerModel | ||
| 621 | + .selectNumber] | ||
| 622 | + .list) { | ||
| 623 | + item.selected = false; | ||
| 624 | + } | ||
| 625 | + setState(() { | ||
| 626 | + tableManagerModel | ||
| 627 | + .tableOuterList[ | ||
| 628 | + tableManagerModel | ||
| 629 | + .selectNumber] | ||
| 630 | + .isSelect = | ||
| 631 | + !tableManagerModel | ||
| 632 | + .tableOuterList[ | ||
| 633 | + tableManagerModel | ||
| 634 | + .selectNumber] | ||
| 635 | + .isSelect; | ||
| 636 | + }); | ||
| 637 | + }, | ||
| 638 | + child: Row( | ||
| 639 | + children: [ | ||
| 640 | + Image.asset( | ||
| 641 | + Utils.getImgPath(tableManagerModel | ||
| 642 | + .tableOuterList[ | ||
| 643 | + tableManagerModel | ||
| 644 | + .selectNumber] | ||
| 645 | + .isSelect | ||
| 646 | + ? 'base_radio_sel' | ||
| 647 | + : 'base_radio_un'), | ||
| 648 | + width: ScreenUtil() | ||
| 649 | + .setWidth(40), | ||
| 650 | + ), | ||
| 651 | + HEmptyView(10), | ||
| 652 | + Text( | ||
| 653 | + '批量选择桌位', | ||
| 654 | + style: TextStyle( | ||
| 655 | + fontSize: | ||
| 656 | + ScreenUtil() | ||
| 657 | + .setSp( | ||
| 658 | + 32), | ||
| 659 | + color: MyColours | ||
| 660 | + .color_000000), | ||
| 661 | + ) | ||
| 662 | + ], | ||
| 663 | + )), | ||
| 664 | + tableManagerModel | ||
| 665 | + .tableOuterList[ | ||
| 666 | + tableManagerModel | ||
| 667 | + .selectNumber] | ||
| 668 | + .list | ||
| 669 | + .length == | ||
| 670 | + 0 | ||
| 671 | + ? VEmptyView(20) | ||
| 672 | + : VEmptyView(60), | ||
| 673 | + item(tableManagerModel.selectNumber) | ||
| 674 | + ], | ||
| 675 | + ))), | ||
| 676 | + ])) | ||
| 677 | + ], | ||
| 678 | + ); | ||
| 679 | + }, | ||
| 680 | + )))); | ||
| 681 | + } | ||
| 682 | +} |
| 1 | +import 'package:flutter/material.dart'; | ||
| 2 | +import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
| 3 | +import 'package:one_key/models/area.dart'; | ||
| 4 | +import 'package:one_key/res/colors.dart'; | ||
| 5 | +import 'package:one_key/widgets/h_empty_view.dart'; | ||
| 6 | + | ||
| 7 | +class TableManageAreaItem extends StatefulWidget { | ||
| 8 | + final String currentArea; //当前选中区域名称 | ||
| 9 | + final Area area; | ||
| 10 | + final ValueChanged selectCallback; | ||
| 11 | + | ||
| 12 | + TableManageAreaItem( | ||
| 13 | + this.area, | ||
| 14 | + this.currentArea, | ||
| 15 | + this.selectCallback, | ||
| 16 | + ); | ||
| 17 | + | ||
| 18 | + @override | ||
| 19 | + State<StatefulWidget> createState() { | ||
| 20 | + // TODO: implement createState | ||
| 21 | + return new TableManageAreaItemState(); | ||
| 22 | + } | ||
| 23 | +} | ||
| 24 | + | ||
| 25 | +class TableManageAreaItemState extends State<TableManageAreaItem> { | ||
| 26 | + @override | ||
| 27 | + Widget build(BuildContext context) { | ||
| 28 | + // TODO: implement build | ||
| 29 | + Area area = widget.area; | ||
| 30 | + bool isSelected = area.name == widget.currentArea; | ||
| 31 | + return GestureDetector( | ||
| 32 | + onTap: () { | ||
| 33 | + if (widget.selectCallback != null) { | ||
| 34 | + widget.selectCallback(widget.area); | ||
| 35 | + } | ||
| 36 | + }, | ||
| 37 | + child: | ||
| 38 | + // Stack( | ||
| 39 | + // overflow: Overflow.visible, | ||
| 40 | + // alignment: Alignment.topLeft, | ||
| 41 | + // children: <Widget>[ | ||
| 42 | + Container( | ||
| 43 | + // width: ScreenUtil().setWidth(104 * 2), | ||
| 44 | + height: ScreenUtil().setWidth(60), | ||
| 45 | + margin: EdgeInsets.only( | ||
| 46 | + right: ScreenUtil().setWidth(24), | ||
| 47 | + top: ScreenUtil().setWidth(20), | ||
| 48 | + ), | ||
| 49 | + padding: EdgeInsets.symmetric( | ||
| 50 | + horizontal: ScreenUtil().setWidth(16), | ||
| 51 | + // vertical: ScreenUtil().setWidth(4) | ||
| 52 | + ), | ||
| 53 | + alignment: Alignment.center, | ||
| 54 | + decoration: BoxDecoration( | ||
| 55 | + borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10)), | ||
| 56 | + color: isSelected ? MyColours.color_438E93 : MyColours.color_ffffff, | ||
| 57 | + border: Border.all( | ||
| 58 | + color: isSelected | ||
| 59 | + ? MyColours.color_438E93 | ||
| 60 | + : MyColours.color_999999, | ||
| 61 | + width: ScreenUtil().setWidth(2))), | ||
| 62 | + child: Text( | ||
| 63 | + area.name, | ||
| 64 | + overflow: TextOverflow.ellipsis, | ||
| 65 | + style: TextStyle( | ||
| 66 | + color: | ||
| 67 | + isSelected ? MyColours.color_ffffff : MyColours.color_999999, | ||
| 68 | + fontSize: ScreenUtil().setSp(32), | ||
| 69 | + decoration: TextDecoration.none, | ||
| 70 | + fontWeight: FontWeight.normal), | ||
| 71 | + ), | ||
| 72 | + ), | ||
| 73 | + ); | ||
| 74 | + } | ||
| 75 | +} |
lib/provider/my_table_manage_home_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/constant/error.dart'; | ||
| 5 | +import 'package:one_key/constant/state.dart'; | ||
| 6 | +import 'package:one_key/models/area.dart'; | ||
| 7 | +import 'package:one_key/models/area_model.dart'; | ||
| 8 | +import 'package:one_key/models/guest_info_model.dart'; | ||
| 9 | +import 'package:one_key/models/notebook.dart'; | ||
| 10 | +import 'package:one_key/models/reserve_info_model.dart'; | ||
| 11 | +import 'package:one_key/models/tableOuter.dart'; | ||
| 12 | +import 'package:one_key/models/table_list.dart'; | ||
| 13 | +import 'package:one_key/net/base_resp.dart'; | ||
| 14 | +import 'package:one_key/net/dio_util.dart'; | ||
| 15 | +import 'package:one_key/net/http_url.dart'; | ||
| 16 | +import 'package:one_key/models/table.dart' as t; | ||
| 17 | +import 'package:one_key/provider/user_model.dart'; | ||
| 18 | +import 'package:one_key/route/navigator_util.dart'; | ||
| 19 | +import 'package:one_key/utils/lunar_calendar.dart'; | ||
| 20 | +import 'package:one_key/utils/utils.dart'; | ||
| 21 | +import 'package:provider/provider.dart'; | ||
| 22 | + | ||
| 23 | +import 'notebook_model.dart'; | ||
| 24 | + | ||
| 25 | +class MyTableManageHomeModel with ChangeNotifier { | ||
| 26 | + List<Area> areas = []; //区域列表 | ||
| 27 | + | ||
| 28 | + List<t.Table> selectTables = []; //选择的桌位 | ||
| 29 | + | ||
| 30 | + List<TableOuter> tableOuterList = []; //区域-桌位列表 | ||
| 31 | + | ||
| 32 | + List<t.Table> currentTables = []; //当前显示的区域-桌位 | ||
| 33 | + | ||
| 34 | + String currentArea; //当前选中区域 | ||
| 35 | + int selectIndex = 0; | ||
| 36 | + | ||
| 37 | + UserModel userModel; | ||
| 38 | + | ||
| 39 | + PageState pageState = PageState.Loading; | ||
| 40 | + | ||
| 41 | + int selectNumber; | ||
| 42 | + | ||
| 43 | + //初始化时间 | ||
| 44 | + initTime(BuildContext context) async { | ||
| 45 | + userModel = Provider.of<UserModel>(context, listen: false); | ||
| 46 | + | ||
| 47 | + List temp = await getTableList(context); | ||
| 48 | + // if (temp.length > 0) { | ||
| 49 | + // getReserveList(context); | ||
| 50 | + // } else { | ||
| 51 | + // // pageState = PageState.Empty; | ||
| 52 | + | ||
| 53 | + //没有区域、没有桌子 | ||
| 54 | + pageState = PageState.Success; | ||
| 55 | + initData(); | ||
| 56 | + | ||
| 57 | + // pageState = PageState.Success; | ||
| 58 | + // notifyListeners(); | ||
| 59 | + // } | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + //获取桌位数据 | ||
| 63 | + Future<List<TableOuter>> getTableList(BuildContext context, | ||
| 64 | + {bool needLoading = true}) async { | ||
| 65 | + if (needLoading) { | ||
| 66 | + pageState = PageState.Loading; | ||
| 67 | + notifyListeners(); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + Map<String, String> params = {"sellerid": userModel.user.sellerid}; | ||
| 71 | + BaseResp<List> baseResp = await DioUtil() | ||
| 72 | + .request<List>(context, Method.get, HttpUrl.table_list, | ||
| 73 | + data: params, showLoading: false) | ||
| 74 | + .catchError((error) { | ||
| 75 | + print(error.toString()); | ||
| 76 | + if (error is MyError) { | ||
| 77 | + switch (error.type) { | ||
| 78 | + case 1: | ||
| 79 | + pageState = PageState.ConnectivityError; | ||
| 80 | + break; | ||
| 81 | + case 2: | ||
| 82 | + pageState = PageState.ConnectivityTimeOut; | ||
| 83 | + break; | ||
| 84 | + default: | ||
| 85 | + pageState = PageState.ConnectivityError; | ||
| 86 | + break; | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | + notifyListeners(); | ||
| 90 | + }); | ||
| 91 | + tableOuterList = []; | ||
| 92 | + if (baseResp.code == Constant.status_success) { | ||
| 93 | + if (baseResp.data.length == 0) { | ||
| 94 | + pageState = PageState.ConnectivityError; | ||
| 95 | + notifyListeners(); | ||
| 96 | + } | ||
| 97 | + if ((baseResp.data[0] as List).isEmpty) { | ||
| 98 | + pageState = PageState.Success; | ||
| 99 | + notifyListeners(); | ||
| 100 | + return []; | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + tableOuterList = (baseResp.data[0] as List).map((value) { | ||
| 104 | + TableOuter tableOuter = TableOuter(); | ||
| 105 | + tableOuter.name = value["name"]; | ||
| 106 | + List tableOuterList = value["list"] as List; | ||
| 107 | + List enableList = []; //删除已停用的桌子,剩余可用的桌子 | ||
| 108 | + tableOuterList.forEach((element) { | ||
| 109 | + if (element['enable'] != '0') { | ||
| 110 | + enableList.add(element); | ||
| 111 | + } | ||
| 112 | + }); | ||
| 113 | + tableOuter.list = enableList.map((table) { | ||
| 114 | + return t.Table.fromJson(table as Map<String, dynamic>); | ||
| 115 | + }).toList(); | ||
| 116 | + return tableOuter; | ||
| 117 | + }).toList(); | ||
| 118 | + } | ||
| 119 | + List<AreaSunModel> areaSunModelList = await getRegionBySellerid(context); | ||
| 120 | + if (areaSunModelList != null && areaSunModelList.length > 0) { | ||
| 121 | + List<String> tempTableName = []; //有桌子区域 | ||
| 122 | + List<String> tempAreaName = []; //全部区域 | ||
| 123 | + for (TableOuter itemTable in tableOuterList) { | ||
| 124 | + tempTableName.add(itemTable.name); | ||
| 125 | + } | ||
| 126 | + for (AreaSunModel itemArea in areaSunModelList) { | ||
| 127 | + tempAreaName.add(itemArea.name); | ||
| 128 | + } | ||
| 129 | + if (tempAreaName.length > tempTableName.length) { | ||
| 130 | + for (var itemT in tempTableName) { | ||
| 131 | + tempAreaName.removeWhere( | ||
| 132 | + (element) => element == itemT); //全部区域移除有桌子的区域,剩下没有桌子的区域 | ||
| 133 | + } | ||
| 134 | + for (var item in tempAreaName) { | ||
| 135 | + for (AreaSunModel itemarea in areaSunModelList) { | ||
| 136 | + if (item == itemarea.name) { | ||
| 137 | + TableOuter tableOuter = TableOuter(); | ||
| 138 | + tableOuter.name = item; | ||
| 139 | + tableOuter.list = []; | ||
| 140 | + tableOuter.rid = itemarea.id; | ||
| 141 | + tableOuterList.add(tableOuter); //区域信息包含有桌子和没有桌子两部分类型 | ||
| 142 | + } | ||
| 143 | + } | ||
| 144 | + } | ||
| 145 | + } | ||
| 146 | + } | ||
| 147 | + if (tableOuterList.length == 0) { | ||
| 148 | + pageState = PageState.Success; | ||
| 149 | + } | ||
| 150 | + | ||
| 151 | + return tableOuterList; | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + //初始桌位数据 | ||
| 155 | + initData({bool needKeep = false}) { | ||
| 156 | + areas.clear(); | ||
| 157 | + List<String> tempList = []; | ||
| 158 | + for (TableOuter outer in tableOuterList) { | ||
| 159 | + int count = 0; | ||
| 160 | + | ||
| 161 | + tempList.add(outer.name); | ||
| 162 | + | ||
| 163 | + for (t.Table table in outer.list) { | ||
| 164 | + table.sign = ""; | ||
| 165 | + table.notebookId = ""; | ||
| 166 | + table.reserver = ""; | ||
| 167 | + | ||
| 168 | + table.selected = false; | ||
| 169 | + } | ||
| 170 | + | ||
| 171 | + Area area = Area(); | ||
| 172 | + area.name = outer.name; | ||
| 173 | + area.count = outer.list.length == 0 ? -1 : count; | ||
| 174 | + area.rid = outer.list.length == 0 ? outer.rid : outer.list[0].rid; | ||
| 175 | + areas.add(area); | ||
| 176 | + } | ||
| 177 | + | ||
| 178 | + if (currentArea != null && currentArea != '') { | ||
| 179 | + // tablesShow = areaTableMapShow[currentArea]; | ||
| 180 | + selectNumber = tempList.indexOf(currentArea); | ||
| 181 | + } else { | ||
| 182 | + if (areas.length > 0) { | ||
| 183 | + currentArea = areas[0].name; | ||
| 184 | + selectNumber = 0; | ||
| 185 | + } | ||
| 186 | + } | ||
| 187 | + | ||
| 188 | + notifyListeners(); | ||
| 189 | + } | ||
| 190 | + | ||
| 191 | + //获取桌位数据 | ||
| 192 | + Future<dynamic> setSwitchStatus( | ||
| 193 | + BuildContext context, Map<String, String> params) async { | ||
| 194 | + BaseResp<dynamic> baseResp = await DioUtil() | ||
| 195 | + .request<dynamic>(context, Method.get, HttpUrl.set_switch_status, | ||
| 196 | + data: params, showLoading: true) | ||
| 197 | + .catchError((error) { | ||
| 198 | + print(error.toString()); | ||
| 199 | + }); | ||
| 200 | + if (baseResp == null) return null; | ||
| 201 | + if (baseResp.code == Constant.status_success) { | ||
| 202 | + return baseResp.data; | ||
| 203 | + } else { | ||
| 204 | + Utils.showToast(baseResp.msg); | ||
| 205 | + } | ||
| 206 | + } | ||
| 207 | + | ||
| 208 | + //添加商家桌位区域 | ||
| 209 | + Future<bool> addTableAreas(BuildContext context, String name) async { | ||
| 210 | + Map<String, String> params = { | ||
| 211 | + "sellerid": userModel.user.sellerid, | ||
| 212 | + "name": name | ||
| 213 | + }; | ||
| 214 | + BaseResp<dynamic> baseResp = await DioUtil() | ||
| 215 | + .request<dynamic>(context, Method.get, HttpUrl.add_table_area, | ||
| 216 | + data: params, showLoading: true) | ||
| 217 | + .catchError((error) { | ||
| 218 | + print(error.toString()); | ||
| 219 | + // if (error is MyError) { | ||
| 220 | + // switch (error.type) { | ||
| 221 | + // case 1: | ||
| 222 | + // pageState = PageState.ConnectivityError; | ||
| 223 | + // break; | ||
| 224 | + // case 2: | ||
| 225 | + // pageState = PageState.ConnectivityTimeOut; | ||
| 226 | + // break; | ||
| 227 | + // default: | ||
| 228 | + // pageState = PageState.ConnectivityError; | ||
| 229 | + // break; | ||
| 230 | + // } | ||
| 231 | + // } | ||
| 232 | + // notifyListeners(); | ||
| 233 | + return false; | ||
| 234 | + }); | ||
| 235 | + | ||
| 236 | + if (baseResp.code == Constant.status_success) { | ||
| 237 | + if (baseResp.responseData['data'] != null && | ||
| 238 | + baseResp.responseData['data'].length > 0) { | ||
| 239 | + return true; | ||
| 240 | + } else { | ||
| 241 | + Utils.showToast(baseResp.msg ?? '新增区域失败!'); | ||
| 242 | + } | ||
| 243 | + } else { | ||
| 244 | + Utils.showToast(baseResp.msg ?? '新增区域失败!'); | ||
| 245 | + } | ||
| 246 | + return false; | ||
| 247 | + } | ||
| 248 | + | ||
| 249 | + //获取区域数据 | ||
| 250 | + Future<List<AreaSunModel>> getRegionBySellerid(BuildContext context) async { | ||
| 251 | + Map<String, String> params = {"sellerid": userModel.user.sellerid}; | ||
| 252 | + BaseResp<List> baseResp = await DioUtil() | ||
| 253 | + .request<List>(context, Method.get, HttpUrl.get_area_by_sellerid, | ||
| 254 | + data: params, showLoading: false) | ||
| 255 | + .catchError((error) { | ||
| 256 | + print(error.toString()); | ||
| 257 | + }); | ||
| 258 | + List<AreaSunModel> areaSunModelList; | ||
| 259 | + if (baseResp.code == Constant.status_success) { | ||
| 260 | + if (baseResp.data.length == 1 && baseResp.data[0] is String) { | ||
| 261 | + return areaSunModelList; | ||
| 262 | + } else if (baseResp.data.length > 0) { | ||
| 263 | + areaSunModelList = AreaModel.fromJson(baseResp.responseData).data; | ||
| 264 | + } | ||
| 265 | + } | ||
| 266 | + return areaSunModelList; | ||
| 267 | + } | ||
| 268 | + | ||
| 269 | + //添加商家桌位 | ||
| 270 | + Future<bool> addTable( | ||
| 271 | + BuildContext context, Map<String, String> params) async { | ||
| 272 | + params["sellerid"] = userModel.user.sellerid; | ||
| 273 | + params["tid"] = '2'; | ||
| 274 | + BaseResp<dynamic> baseResp = await DioUtil() | ||
| 275 | + .request<dynamic>(context, Method.get, HttpUrl.add_table, | ||
| 276 | + data: params, showLoading: true) | ||
| 277 | + .catchError((error) { | ||
| 278 | + print(error.toString()); | ||
| 279 | + // if (error is MyError) { | ||
| 280 | + // switch (error.type) { | ||
| 281 | + // case 1: | ||
| 282 | + // pageState = PageState.ConnectivityError; | ||
| 283 | + // break; | ||
| 284 | + // case 2: | ||
| 285 | + // pageState = PageState.ConnectivityTimeOut; | ||
| 286 | + // break; | ||
| 287 | + // default: | ||
| 288 | + // pageState = PageState.ConnectivityError; | ||
| 289 | + // break; | ||
| 290 | + // } | ||
| 291 | + // } | ||
| 292 | + // notifyListeners(); | ||
| 293 | + return false; | ||
| 294 | + }); | ||
| 295 | + | ||
| 296 | + if (baseResp.code == Constant.status_success) { | ||
| 297 | + if (baseResp.responseData['data'] != null && | ||
| 298 | + baseResp.responseData['data'].length > 0) { | ||
| 299 | + return true; | ||
| 300 | + } else { | ||
| 301 | + Utils.showToast(baseResp.msg ?? '新增桌位失败!'); | ||
| 302 | + } | ||
| 303 | + } else { | ||
| 304 | + Utils.showToast(baseResp.msg ?? '新增桌位失败!'); | ||
| 305 | + } | ||
| 306 | + return false; | ||
| 307 | + } | ||
| 308 | + | ||
| 309 | + refreshTable(context) async { | ||
| 310 | + List temp = await getTableList(context, needLoading: false); | ||
| 311 | + // if (temp.length > 0) { | ||
| 312 | + // getReserveList(context, needLoading: false, needKeep: true); | ||
| 313 | + // } else { | ||
| 314 | + // // pageState = PageState.Empty; | ||
| 315 | + // pageState = PageState.Success; | ||
| 316 | + // notifyListeners(); | ||
| 317 | + // } | ||
| 318 | + } | ||
| 319 | +} |
| @@ -787,4 +787,13 @@ class NavigatorUtil { | @@ -787,4 +787,13 @@ class NavigatorUtil { | ||
| 787 | "${Routes.table_manager_page}?guest=${FluroConvertUtils.object2string(guest)}", | 787 | "${Routes.table_manager_page}?guest=${FluroConvertUtils.object2string(guest)}", |
| 788 | replace: replace); | 788 | replace: replace); |
| 789 | } | 789 | } |
| 790 | + | ||
| 791 | + ///我的----桌位管理 | ||
| 792 | + static Future<dynamic> goMyTableManagerHomePage( | ||
| 793 | + BuildContext context, { | ||
| 794 | + replace = false, | ||
| 795 | + }) { | ||
| 796 | + return _navigateTo(context, "${Routes.my_table_manager_home_page}", | ||
| 797 | + replace: replace); | ||
| 798 | + } | ||
| 790 | } | 799 | } |
| @@ -95,6 +95,7 @@ import 'package:one_key/pages/my/sms_manager.dart'; | @@ -95,6 +95,7 @@ import 'package:one_key/pages/my/sms_manager.dart'; | ||
| 95 | import 'package:one_key/pages/my/sms_recharge_page.dart'; | 95 | import 'package:one_key/pages/my/sms_recharge_page.dart'; |
| 96 | import 'package:one_key/pages/my/store_base_info_page.dart'; | 96 | import 'package:one_key/pages/my/store_base_info_page.dart'; |
| 97 | import 'package:one_key/pages/my/store_type_fill_manage_page.dart'; | 97 | import 'package:one_key/pages/my/store_type_fill_manage_page.dart'; |
| 98 | +import 'package:one_key/pages/my/table_manage/my_table_manage_home_page.dart'; | ||
| 98 | import 'package:one_key/pages/notebook/statistics_page.dart'; | 99 | import 'package:one_key/pages/notebook/statistics_page.dart'; |
| 99 | import 'package:one_key/pages/notebook/statistics_sms_page.dart'; | 100 | import 'package:one_key/pages/notebook/statistics_sms_page.dart'; |
| 100 | import 'package:one_key/pages/online_check/invoice_detail_page.dart'; | 101 | import 'package:one_key/pages/online_check/invoice_detail_page.dart'; |
| @@ -114,6 +115,7 @@ import 'package:one_key/provider/create_store_model.dart'; | @@ -114,6 +115,7 @@ import 'package:one_key/provider/create_store_model.dart'; | ||
| 114 | import 'package:one_key/provider/customer_provider.dart'; | 115 | import 'package:one_key/provider/customer_provider.dart'; |
| 115 | import 'package:one_key/provider/menu_provider.dart'; | 116 | import 'package:one_key/provider/menu_provider.dart'; |
| 116 | import 'package:one_key/provider/my_model.dart'; | 117 | import 'package:one_key/provider/my_model.dart'; |
| 118 | +import 'package:one_key/provider/my_table_manage_home_model.dart'; | ||
| 117 | import 'package:one_key/provider/notebook_detail_change_model.dart'; | 119 | import 'package:one_key/provider/notebook_detail_change_model.dart'; |
| 118 | import 'package:one_key/provider/notebook_detail_model.dart'; | 120 | import 'package:one_key/provider/notebook_detail_model.dart'; |
| 119 | import 'package:one_key/provider/online_check_edit_provider.dart'; | 121 | import 'package:one_key/provider/online_check_edit_provider.dart'; |
| @@ -1215,3 +1217,17 @@ var accountLoginPageHandle = new Handler( | @@ -1215,3 +1217,17 @@ var accountLoginPageHandle = new Handler( | ||
| 1215 | return ChangeNotifierProvider<OtherLoginProvider>( | 1217 | return ChangeNotifierProvider<OtherLoginProvider>( |
| 1216 | create: (_) => OtherLoginProvider(), child: AccountLoginPage()); | 1218 | create: (_) => OtherLoginProvider(), child: AccountLoginPage()); |
| 1217 | }); | 1219 | }); |
| 1220 | + | ||
| 1221 | +///我的---桌位管理 | ||
| 1222 | +var myTableManagerHomePageHandle = new Handler( | ||
| 1223 | + handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) { | ||
| 1224 | + // Guest guest = Guest.fromJson(json | ||
| 1225 | + // .decode(FluroConvertUtils.fluroCnParamsDecode(params["guest"].first))); | ||
| 1226 | + // UserHistoryEntity userHistoryEntity = UserHistoryEntity.fromJson(json.decode( | ||
| 1227 | + // FluroConvertUtils.fluroCnParamsDecode( | ||
| 1228 | + // params["userHistoryEntity"].first))); | ||
| 1229 | + return ChangeNotifierProvider<MyTableManageHomeModel>( | ||
| 1230 | + create: (_) => MyTableManageHomeModel(), | ||
| 1231 | + child: MyTableManagerHomePage(), | ||
| 1232 | + ); | ||
| 1233 | +}); |
| @@ -106,6 +106,8 @@ class Routes { | @@ -106,6 +106,8 @@ class Routes { | ||
| 106 | "/my_show_customer_list_page"; //仅展示的客户列表----我的 | 106 | "/my_show_customer_list_page"; //仅展示的客户列表----我的 |
| 107 | static String table_manager_page = "/table_manager_page"; //客情再次预订跳转的桌位预订页面 | 107 | static String table_manager_page = "/table_manager_page"; //客情再次预订跳转的桌位预订页面 |
| 108 | static String account_login_page = "/account_login_page"; //账号登录页面 | 108 | static String account_login_page = "/account_login_page"; //账号登录页面 |
| 109 | + static String my_table_manager_home_page = "/my_table_manager_home_page"; //我的---桌位管理 | ||
| 110 | + | ||
| 109 | 111 | ||
| 110 | 112 | ||
| 111 | static void configureRoutes(FluroRouter router) { | 113 | static void configureRoutes(FluroRouter router) { |
| @@ -216,6 +218,8 @@ class Routes { | @@ -216,6 +218,8 @@ class Routes { | ||
| 216 | handler: myShowCustomerListPageHandle); | 218 | handler: myShowCustomerListPageHandle); |
| 217 | router.define(table_manager_page, handler: tableManagerPageHandle); | 219 | router.define(table_manager_page, handler: tableManagerPageHandle); |
| 218 | router.define(account_login_page, handler: accountLoginPageHandle); | 220 | router.define(account_login_page, handler: accountLoginPageHandle); |
| 221 | + router.define(my_table_manager_home_page, handler: myTableManagerHomePageHandle); | ||
| 222 | + | ||
| 219 | 223 | ||
| 220 | } | 224 | } |
| 221 | } | 225 | } |
lib/widgets/table_manage_item.dart
0 → 100644
| 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 ManageTableItem extends StatefulWidget { | ||
| 10 | + final t.Table table; | ||
| 11 | + final bool canMulSelected; //是否多选 | ||
| 12 | + final ValueChanged<t.Table> onSelected; | ||
| 13 | + | ||
| 14 | + final int height; //高度 | ||
| 15 | + | ||
| 16 | + ManageTableItem( | ||
| 17 | + this.table, { | ||
| 18 | + this.onSelected, | ||
| 19 | + this.canMulSelected = false, | ||
| 20 | + this.height = 185, | ||
| 21 | + }); | ||
| 22 | + | ||
| 23 | + @override | ||
| 24 | + State<StatefulWidget> createState() { | ||
| 25 | + // TODO: implement createState | ||
| 26 | + return new ManageTableItemState(); | ||
| 27 | + } | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +class ManageTableItemState extends State<ManageTableItem> { | ||
| 31 | + @override | ||
| 32 | + Widget build(BuildContext context) { | ||
| 33 | + t.Table table = widget.table; | ||
| 34 | + return GestureDetector( | ||
| 35 | + onTap: () { | ||
| 36 | + widget.onSelected(table); | ||
| 37 | + }, | ||
| 38 | + child: Stack( | ||
| 39 | + children: <Widget>[ | ||
| 40 | + Container( | ||
| 41 | + decoration: BoxDecoration( | ||
| 42 | + color: table.selected | ||
| 43 | + ? MyColours.color_199095 | ||
| 44 | + : MyColours.color_ffffff, | ||
| 45 | + border: Border.all( | ||
| 46 | + width: ScreenUtil().setWidth(2), | ||
| 47 | + color: MyColours.color_438E93), | ||
| 48 | + borderRadius: BorderRadius.all( | ||
| 49 | + Radius.circular(ScreenUtil().setWidth(10)))), | ||
| 50 | + child: Stack( | ||
| 51 | + // alignment: Alignment.center, | ||
| 52 | + children: <Widget>[ | ||
| 53 | + Container( | ||
| 54 | + child: Column( | ||
| 55 | + // mainAxisSize: MainAxisSize.min, | ||
| 56 | + crossAxisAlignment: CrossAxisAlignment.center, | ||
| 57 | + mainAxisAlignment: MainAxisAlignment.center, | ||
| 58 | + children: <Widget>[ | ||
| 59 | + VEmptyView(10), | ||
| 60 | + Container( | ||
| 61 | + // color: Colors.red, | ||
| 62 | + height: ScreenUtil().setWidth(48), | ||
| 63 | + alignment: Alignment.center, | ||
| 64 | + child: Text( | ||
| 65 | + table.name, | ||
| 66 | + maxLines: 1, | ||
| 67 | + style: TextStyle( | ||
| 68 | + color: table.selected | ||
| 69 | + ? MyColours.color_ffffff | ||
| 70 | + : MyColours.color_438E93, | ||
| 71 | + fontSize: ScreenUtil().setSp(32), | ||
| 72 | + decoration: TextDecoration.none, | ||
| 73 | + fontWeight: FontWeight.bold), | ||
| 74 | + overflow: TextOverflow.ellipsis, | ||
| 75 | + )), | ||
| 76 | + table.tableNum != '' && table.tableNum != null | ||
| 77 | + ? Container( | ||
| 78 | + // color: Colors.red, | ||
| 79 | + alignment: Alignment.center, | ||
| 80 | + height: ScreenUtil().setWidth(48), | ||
| 81 | + | ||
| 82 | + child: Text( | ||
| 83 | + table.tableNum, | ||
| 84 | + style: TextStyle( | ||
| 85 | + color: table.selected | ||
| 86 | + ? MyColours.color_ffffff | ||
| 87 | + : MyColours.color_000000, | ||
| 88 | + fontSize: ScreenUtil().setSp(14), | ||
| 89 | + decoration: TextDecoration.none, | ||
| 90 | + fontWeight: FontWeight.normal), | ||
| 91 | + overflow: TextOverflow.ellipsis, | ||
| 92 | + ), | ||
| 93 | + ) | ||
| 94 | + : SizedBox() | ||
| 95 | + ], | ||
| 96 | + ), | ||
| 97 | + ), | ||
| 98 | + Positioned( | ||
| 99 | + left: 0, | ||
| 100 | + top: 0, | ||
| 101 | + child: table.tidStr == null | ||
| 102 | + ? Container() | ||
| 103 | + : Container( | ||
| 104 | + width: ScreenUtil().setWidth(44), | ||
| 105 | + height: ScreenUtil().setWidth(22), | ||
| 106 | + alignment: Alignment.center, | ||
| 107 | + decoration: BoxDecoration( | ||
| 108 | + color: table.selected | ||
| 109 | + ? MyColours.color_199095 | ||
| 110 | + : MyColours.color_999999, | ||
| 111 | + borderRadius: BorderRadius.only( | ||
| 112 | + topLeft: | ||
| 113 | + Radius.circular(ScreenUtil().setWidth(8)), | ||
| 114 | + )), | ||
| 115 | + child: Text(table.tidStr, | ||
| 116 | + style: TextStyle( | ||
| 117 | + color: MyColours.color_ffffff, | ||
| 118 | + fontSize: ScreenUtil().setSp(14), | ||
| 119 | + decoration: TextDecoration.none, | ||
| 120 | + fontWeight: FontWeight.normal)), | ||
| 121 | + ), | ||
| 122 | + ), | ||
| 123 | + ], | ||
| 124 | + ), | ||
| 125 | + ), | ||
| 126 | + ], | ||
| 127 | + ), | ||
| 128 | + ); | ||
| 129 | + } | ||
| 130 | +} |
-
Please register or login to post a comment