Commit 36976ac9e907e3d5ba48854858c315db6960bbfd

Authored by wdn127929
1 parent be91dd89

区域变更OK

  1 +import 'package:flutter/material.dart';
  2 +import 'package:flutter_screenutil/flutter_screenutil.dart';
  3 +import 'package:one_key/constant/state.dart';
  4 +import 'package:one_key/models/area.dart';
  5 +import 'package:one_key/provider/my_table_manage_home_model.dart';
  6 +import 'package:one_key/provider/user_model.dart';
  7 +import 'package:one_key/res/colors.dart';
  8 +import 'package:one_key/utils/dialog_util.dart';
  9 +import 'package:one_key/utils/event_bus.dart';
  10 +import 'package:one_key/utils/utils.dart';
  11 +import 'package:one_key/widgets/h_empty_view.dart';
  12 +import 'package:one_key/widgets/page_exception.dart';
  13 +import 'package:one_key/widgets/system_app_bar.dart';
  14 +import 'package:provider/provider.dart';
  15 +
  16 +import '../../../provider/table_manager_model.dart';
  17 +import '../../../utils/screen_util.dart';
  18 +import '../../../widgets/round_button.dart';
  19 +
  20 +/*
  21 +**** 区域选择管理
  22 +*/
  23 +class AreasSelectPage extends StatefulWidget {
  24 + final String rid;
  25 + final String name;
  26 + AreasSelectPage({Key key, this.rid, this.name}) : super(key: key);
  27 +
  28 + @override
  29 + _AreasSelectPageState createState() => _AreasSelectPageState();
  30 +}
  31 +
  32 +class _AreasSelectPageState extends State<AreasSelectPage> {
  33 + MyTableManageHomeModel tableManagerModel;
  34 + String rid;
  35 + String name;
  36 + @override
  37 + void initState() {
  38 + // TODO: implement initState
  39 + super.initState();
  40 +
  41 + rid = widget.rid;
  42 +
  43 + WidgetsBinding.instance.addPostFrameCallback((_) {
  44 + tableManagerModel.initTime(context);
  45 +
  46 + // EventBus().on("refresh_tablemanager", (arg) {
  47 + // //订座-完成预订 刷新管理桌位
  48 + // tableManagerModel.getReserveList(context,
  49 + // needLoading: false, needKeep: true);
  50 + // print(tableManagerModel);
  51 + // });
  52 + // EventBus().on("refresh_tablePhoto", (arg) {
  53 + // ///刷新图片显示
  54 + // _refreshTablePhoto();
  55 + // });
  56 + });
  57 + }
  58 +
  59 + @override
  60 + Widget build(BuildContext context) {
  61 + tableManagerModel =
  62 + Provider.of<MyTableManageHomeModel>(context, listen: true);
  63 + return Scaffold(
  64 + resizeToAvoidBottomInset: false, //输入框抵住键盘
  65 + appBar: SystemAppBar(
  66 + "区域选择",
  67 + showLeading: true,
  68 + onTap: () {
  69 + Navigator.pop(context);
  70 + },
  71 + ),
  72 + backgroundColor: MyColours.color_ffffff,
  73 + body: SafeArea(child:
  74 + Consumer<MyTableManageHomeModel>(builder: (context, model, child) {
  75 + return model.pageState != PageState.Success
  76 + ? ExceptionPage(
  77 + pageState: model.pageState,
  78 + callback: () {
  79 + // if (tableManagerModel.tableOuterList.isEmpty) {
  80 + // tableManagerModel.getTableList(context);
  81 + // } else {
  82 + // tableManagerModel.getReserveList(context);
  83 + // }
  84 + },
  85 + emptyMsg: "暂时没有区域数据哦",
  86 + emptyImg: "table_manage_empty",
  87 + showMsg: "加载中,请稍后...",
  88 + )
  89 + : Column(
  90 + children: [
  91 + Expanded(
  92 + child: ListView.builder(
  93 + padding: EdgeInsets.symmetric(
  94 + horizontal: ScreenUtil().setWidth(32),
  95 + vertical: ScreenUtil().setWidth(54)),
  96 + itemCount: tableManagerModel.areas.length,
  97 + shrinkWrap: true,
  98 + // scrollDirection: Axis.horizontal,
  99 + itemBuilder: (BuildContext contxt, int index) {
  100 + Area area = tableManagerModel.areas[index];
  101 + return InkWell(
  102 + onTap: () async {
  103 + if (rid == area.rid) {
  104 + return;
  105 + }
  106 + rid = area.rid;
  107 + name = area.name;
  108 + setState(() {});
  109 + },
  110 + child: Container(
  111 + padding: EdgeInsets.symmetric(
  112 + horizontal: ScreenUtil().setWidth(16),
  113 + vertical: ScreenUtil().setWidth(30)),
  114 + decoration: BoxDecoration(
  115 + border: Border(
  116 + bottom: BorderSide(
  117 + width: ScreenUtil().setWidth(2),
  118 + color:
  119 + MyColours.color_E7E7E7))),
  120 + child: Row(
  121 + mainAxisAlignment:
  122 + MainAxisAlignment.spaceBetween,
  123 + children: [
  124 + Image.asset(
  125 + Utils.getImgPath(rid == area.rid
  126 + ? 'select'
  127 + : 'unselect'),
  128 + width: w(20),
  129 + ),
  130 + HEmptyView(30),
  131 + Expanded(
  132 + child: Text(area.name,
  133 + // textAlign: TextAlign.end,
  134 + style: TextStyle(
  135 + color:
  136 + MyColours.color_000000,
  137 + fontSize: ScreenUtil()
  138 + .setSp(32)))),
  139 + ],
  140 + ),
  141 + ));
  142 + })),
  143 + Container(
  144 + color: MyColours.color_ffffff,
  145 + padding: EdgeInsets.symmetric(horizontal: w(48)),
  146 + margin: EdgeInsets.only(bottom: w(35), top: w(25)),
  147 + child: RoundButton(
  148 + // content: widget.fromPage == 'tablePhoto'
  149 + // ? '确定'
  150 + // : "已选${selectNum}个 确定",
  151 + text: '确定',
  152 + // width: w(128),
  153 + height: w(40),
  154 + radius: r(4),
  155 + isBold: false,
  156 + gradientStart: MyColours.color_438E93,
  157 + gradientEnd: MyColours.color_438E93,
  158 + fontSize: 28,
  159 + textColor: MyColours.color_ffffff,
  160 + onPressed: () {
  161 + // // if (widget.fromPage == "tablePhoto") {
  162 + // // Map temp = {
  163 + // // 'tid': selectTables.length > 0
  164 + // // ? selectTables[0].id
  165 + // // : '',
  166 + // // 'tname': selectTables.length > 0
  167 + // // ? selectTables[0].name
  168 + // // : ''
  169 + // // };
  170 + // // Navigator.of(context).pop(temp);
  171 + // // } else {
  172 + // if (widget.canChoose) {
  173 + // // // if (widget.tableList.length > 0) {
  174 + // // String tid = "";
  175 + // // for (TableList table
  176 + // // in widget.tableList) {
  177 + // // tid += table.id + ",";
  178 + // // }
  179 + // // if (widget.tableList.length > 0) {
  180 + // // tid = tid.substring(
  181 + // // 0, tid.length - 1);
  182 + // // }
  183 +
  184 + Map temp = {
  185 + 'rid': rid,
  186 + 'name':name
  187 + };
  188 + Navigator.of(context).pop(temp);
  189 + // // // }
  190 + // // } else {
  191 +
  192 + // String tid = "";
  193 + // for (t.Table table in selectTables) {
  194 + // tid += table.id + ",";
  195 + // }
  196 + // if (selectTables.length > 0) {
  197 + // tid = tid.substring(0, tid.length - 1);
  198 + // }
  199 +
  200 + // Map temp = {'object': selectTables, 'tid': tid};
  201 + // Navigator.of(context).pop(temp);
  202 + // }
  203 + // }
  204 + },
  205 + ),
  206 + )
  207 + ],
  208 + );
  209 + })));
  210 + }
  211 +}
@@ -125,7 +125,8 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> { @@ -125,7 +125,8 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> {
125 Map<String, String> params = { 125 Map<String, String> params = {
126 'id': table.id, 126 'id': table.id,
127 'name': value['name'], 127 'name': value['name'],
128 - 'tid': tid 128 + 'tid': tid,
  129 + 'rid':value['rid']
129 }; 130 };
130 131
131 if (value['pnumMin'] != '') { 132 if (value['pnumMin'] != '') {
@@ -109,7 +109,11 @@ class MyTableManageHomeModel with ChangeNotifier { @@ -109,7 +109,11 @@ class MyTableManageHomeModel with ChangeNotifier {
109 tableOuterList = (baseResp.data[0] as List).map((value) { 109 tableOuterList = (baseResp.data[0] as List).map((value) {
110 TableOuter tableOuter = TableOuter(); 110 TableOuter tableOuter = TableOuter();
111 tableOuter.name = value["name"]; 111 tableOuter.name = value["name"];
  112 +
112 List tableOuterList = value["list"] as List; 113 List tableOuterList = value["list"] as List;
  114 + if (tableOuterList.length > 0) {
  115 + tableOuter.rid = tableOuterList[0]['rid'];
  116 + }
113 List enableList = []; //删除已停用的桌子,剩余可用的桌子 117 List enableList = []; //删除已停用的桌子,剩余可用的桌子
114 tableOuterList.forEach((element) { 118 tableOuterList.forEach((element) {
115 if (element['enable'] != '0') { 119 if (element['enable'] != '0') {
@@ -1871,4 +1871,15 @@ class NavigatorUtil { @@ -1871,4 +1871,15 @@ class NavigatorUtil {
1871 return _navigateTo(context, "${Routes.verify_food_page}?rid=$rid", 1871 return _navigateTo(context, "${Routes.verify_food_page}?rid=$rid",
1872 replace: replace); 1872 replace: replace);
1873 } 1873 }
  1874 +
  1875 + ///区域选择页面
  1876 + static Future<dynamic> goAreasSelectPage(
  1877 + BuildContext context,
  1878 + String rid, String name,{
  1879 + replace = false,
  1880 + }) {
  1881 + return _navigateTo(
  1882 + context, "${Routes.areas_select_page}?rid=$rid&name=$name",
  1883 + replace: replace);
  1884 + }
1874 } 1885 }
@@ -112,6 +112,7 @@ import 'package:one_key/pages/my/store_base_info_page.dart'; @@ -112,6 +112,7 @@ import 'package:one_key/pages/my/store_base_info_page.dart';
112 import 'package:one_key/pages/my/store_base_info_page_old.dart'; 112 import 'package:one_key/pages/my/store_base_info_page_old.dart';
113 import 'package:one_key/pages/my/store_type_fill_manage_page.dart'; 113 import 'package:one_key/pages/my/store_type_fill_manage_page.dart';
114 import 'package:one_key/pages/my/store_wine_manage/create_store_wine_page.dart'; 114 import 'package:one_key/pages/my/store_wine_manage/create_store_wine_page.dart';
  115 +import 'package:one_key/pages/my/table_manage/areas_select_page.dart';
115 import 'package:one_key/pages/my/table_manage/my_areas_manage_page.dart'; 116 import 'package:one_key/pages/my/table_manage/my_areas_manage_page.dart';
116 import 'package:one_key/pages/my/table_manage/my_table_manage_home_page.dart'; 117 import 'package:one_key/pages/my/table_manage/my_table_manage_home_page.dart';
117 import 'package:one_key/pages/notebook/statistics_page.dart'; 118 import 'package:one_key/pages/notebook/statistics_page.dart';
@@ -3167,7 +3168,16 @@ var bookDepositPageHandle = new Handler( @@ -3167,7 +3168,16 @@ var bookDepositPageHandle = new Handler(
3167 //核餐确认 3168 //核餐确认
3168 var verifyFoodPageHandle = new Handler( 3169 var verifyFoodPageHandle = new Handler(
3169 handlerFunc: (BuildContext context, Map<String, List<Object>> params) { 3170 handlerFunc: (BuildContext context, Map<String, List<Object>> params) {
3170 - String rid = params["rid"].first; 3171 + String rid = params["rid"].first;
3171 return ChangeNotifierProvider<NotebookDetailModel>( 3172 return ChangeNotifierProvider<NotebookDetailModel>(
3172 - create: (_) => NotebookDetailModel(), child: VerifyFoodPage(rid:rid)); 3173 + create: (_) => NotebookDetailModel(), child: VerifyFoodPage(rid: rid));
  3174 +});
  3175 +
  3176 +//区域选择页面
  3177 +var areasSelectPageHandle = new Handler(
  3178 + handlerFunc: (BuildContext context, Map<String, List<Object>> params) {
  3179 + String rid = params["rid"].first;
  3180 + String name = params["name"].first;
  3181 + return ChangeNotifierProvider<MyTableManageHomeModel>(
  3182 + create: (_) => MyTableManageHomeModel(), child: AreasSelectPage(rid:rid,name:name));
3173 }); 3183 });
@@ -299,12 +299,11 @@ class Routes { @@ -299,12 +299,11 @@ class Routes {
299 static String invitation_theme_home_preview_page = 299 static String invitation_theme_home_preview_page =
300 "/invitation_theme_home_preview_page"; //邀请函主题选择预览页 300 "/invitation_theme_home_preview_page"; //邀请函主题选择预览页
301 301
302 -static String book_deposit_page =  
303 - "/book_deposit_page"; //预订订金  
304 -  
305 -static String verify_food_page =  
306 - "/verify_food_page"; //核餐确认  
307 - 302 + static String book_deposit_page = "/book_deposit_page"; //预订订金
  303 +
  304 + static String verify_food_page = "/verify_food_page"; //核餐确认
  305 +
  306 + static String areas_select_page = "/areas_select_page"; //区域选择页面
308 307
309 static void configureRoutes(FluroRouter router) { 308 static void configureRoutes(FluroRouter router) {
310 router.notFoundHandler = new Handler( 309 router.notFoundHandler = new Handler(
@@ -563,16 +562,11 @@ static String verify_food_page = @@ -563,16 +562,11 @@ static String verify_food_page =
563 router.define(invitation_theme_home_page, 562 router.define(invitation_theme_home_page,
564 handler: invitationThemeHomePageHandle); 563 handler: invitationThemeHomePageHandle);
565 564
566 - router.define(invitation_theme_home_preview_page, 565 + router.define(invitation_theme_home_preview_page,
567 handler: invitationThemeHomePreviewPageHandle); 566 handler: invitationThemeHomePreviewPageHandle);
568 - router.define(book_deposit_page,  
569 - handler: bookDepositPageHandle);  
570 - router.define(verify_food_page,  
571 - handler: verifyFoodPageHandle);  
572 -  
573 - 567 + router.define(book_deposit_page, handler: bookDepositPageHandle);
  568 + router.define(verify_food_page, handler: verifyFoodPageHandle);
574 569
575 -  
576 - 570 + router.define(areas_select_page, handler: areasSelectPageHandle);
577 } 571 }
578 } 572 }
@@ -3590,6 +3590,10 @@ class DialogUtil { @@ -3590,6 +3590,10 @@ class DialogUtil {
3590 ? 0 3590 ? 0
3591 : baojianList.indexWhere((element) => element == tidStr) ?? 0; 3591 : baojianList.indexWhere((element) => element == tidStr) ?? 0;
3592 String baojian = baojianList[currentBaojianIndex]; 3592 String baojian = baojianList[currentBaojianIndex];
  3593 +
  3594 + String rid = table.rid;
  3595 +
  3596 + String areaName = table.rname;
3593 // StateSetter globalState; 3597 // StateSetter globalState;
3594 // //输入框焦点 3598 // //输入框焦点
3595 // focusNode.addListener(() { 3599 // focusNode.addListener(() {
@@ -3832,13 +3836,19 @@ class DialogUtil { @@ -3832,13 +3836,19 @@ class DialogUtil {
3832 // return; 3836 // return;
3833 // } 3837 // }
3834 // //跳转到被合并桌位展示页面 3838 // //跳转到被合并桌位展示页面
3835 - // Map object;  
3836 - // if (selectTables.length > 0) {  
3837 - // object = await NavigatorUtil  
3838 - // .goMergeTableSelectPage(context,  
3839 - // tableidNow: tableid,  
3840 - // tids: table.tids,  
3841 - // object: {'object': selectTables}); 3839 + Map object =
  3840 + await NavigatorUtil.goAreasSelectPage(
  3841 + context,
  3842 + table.rid,
  3843 + table.name
  3844 + );
  3845 + if (object != null) {
  3846 + state(() {
  3847 + rid = object['rid'];
  3848 + areaName = object['name'];
  3849 + });
  3850 + }
  3851 +
3842 // } else { 3852 // } else {
3843 // object = await NavigatorUtil 3853 // object = await NavigatorUtil
3844 // .goMergeTableSelectPage( 3854 // .goMergeTableSelectPage(
@@ -3886,7 +3896,7 @@ class DialogUtil { @@ -3886,7 +3896,7 @@ class DialogUtil {
3886 HEmptyView(40), 3896 HEmptyView(40),
3887 Expanded( 3897 Expanded(
3888 child: Text( 3898 child: Text(
3889 - table.rname??'ff', 3899 + areaName,
3890 maxLines: 1, 3900 maxLines: 1,
3891 textAlign: TextAlign.right, 3901 textAlign: TextAlign.right,
3892 overflow: TextOverflow.ellipsis, 3902 overflow: TextOverflow.ellipsis,
@@ -4203,7 +4213,8 @@ class DialogUtil { @@ -4203,7 +4213,8 @@ class DialogUtil {
4203 'pnumMin': pnumMin, 4213 'pnumMin': pnumMin,
4204 'pnumMax': pnumMax, 4214 'pnumMax': pnumMax,
4205 'isMerge': isMerge, 4215 'isMerge': isMerge,
4206 - 'tids': tids 4216 + 'tids': tids,
  4217 + 'rid': rid
4207 }); 4218 });
4208 Navigator.pop(context); 4219 Navigator.pop(context);
4209 }), 4220 }),