Commit 7391be56de340534e262ec12c87c6ed146066781

Authored by wdn127929
1 parent 8fbb8d70

UI+菜品接口

  1 +import 'package:flutter/material.dart';
  2 +import 'package:one_key/models/cookbook_model.dart';
  3 +import 'package:one_key/provider/plan_dish_provider.dart';
  4 +import 'package:one_key/utils/screen_util.dart';
  5 +import 'package:one_key/widgets/h_empty_view.dart';
  6 +import 'package:one_key/widgets/system_app_bar.dart';
  7 +import 'package:flutter_screenutil/flutter_screenutil.dart';
  8 +import 'package:one_key/widgets/v_empty_view.dart';
  9 +import 'package:provider/provider.dart';
  10 +import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
  11 +
  12 +import '../../../constant/state.dart';
  13 +import '../../../res/colors.dart';
  14 +import '../../../route/navigator_util.dart';
  15 +import '../../../utils/utils.dart';
  16 +import '../../../widgets/MyDivider.dart';
  17 +import '../../../widgets/page_exception.dart';
  18 +import '../../../widgets/round_button.dart';
  19 +import '../../provider/user_model.dart';
  20 +
  21 +const scrollDuration = Duration(microseconds: 500);
  22 +
  23 +class OrderAdvanceEidtPage extends StatefulWidget {
  24 + OrderAdvanceEidtPage({
  25 + Key key,
  26 + }) : super(key: key);
  27 +
  28 + @override
  29 + _OrderAdvanceEidtPageState createState() => _OrderAdvanceEidtPageState();
  30 +}
  31 +
  32 +class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
  33 + int _selectIndex = 0;
  34 + int min;
  35 + int max;
  36 + bool isTap = false;
  37 +
  38 + final ItemScrollController itemScrollController = ItemScrollController();
  39 +
  40 + final ItemPositionsListener itemPositionsListener =
  41 + ItemPositionsListener.create();
  42 +
  43 + PlanDishProvider _planDishProvider;
  44 +
  45 + @override
  46 + void initState() {
  47 + super.initState();
  48 + WidgetsBinding.instance.addPostFrameCallback((_) async {
  49 + _getCookbookByClass(showLoading: false);
  50 + });
  51 + }
  52 +
  53 + _getCookbookByClass({bool showLoading = true}) async {
  54 + Map<String, String> params = {
  55 + "sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid,
  56 + };
  57 +
  58 + await _planDishProvider.getCookbookByClass(context, params,
  59 + showLoading: showLoading);
  60 + }
  61 +
  62 + ///接口
  63 + _getMenuData() {
  64 + // Map<String, dynamic> params = {"sellerid": int.parse(widget.sellerID)};
  65 + // _storeMenuProvider.getStoreMenu(context, params);
  66 + }
  67 +
  68 + Widget list(List data) => ScrollablePositionedList.builder(
  69 + // itemCount: data.length,
  70 + itemCount: 10,
  71 + itemBuilder: (context, index) => item(index),
  72 + itemScrollController: itemScrollController,
  73 + itemPositionsListener: itemPositionsListener,
  74 + reverse: false,
  75 + scrollDirection: Axis.vertical,
  76 + );
  77 +
  78 + void scrollTo(int index) => itemScrollController.scrollTo(
  79 + index: index,
  80 + duration: scrollDuration,
  81 + curve: Curves.easeInOutCubic,
  82 + alignment: 0);
  83 +
  84 + void jumpTo(int index) =>
  85 + itemScrollController.jumpTo(index: index, alignment: 0);
  86 +
  87 + /// Generate item number [i].
  88 + Widget item(int i) {
  89 + return ListView.builder(
  90 + shrinkWrap: true,
  91 + physics: NeverScrollableScrollPhysics(),
  92 + itemCount: 100,
  93 + itemBuilder: (BuildContext context, int index) {
  94 + return Container(
  95 + width: 200,
  96 + height: 200,
  97 + color: Colors.red,
  98 + );
  99 + });
  100 + // return Container(
  101 + // // height: ScreenUtil().setWidth(110 * 2) *
  102 + // // _storeMenuProvider.menulist[i].cookbooklist.length +
  103 + // // ScreenUtil().setWidth(60 * 2),
  104 + // height: ScreenUtil().setWidth(110 * 2) * 100 +
  105 + // ScreenUtil().setWidth(60 * 2),
  106 + // child: Column(
  107 + // children: [
  108 + // Container(
  109 + // alignment: Alignment.centerLeft,
  110 + // height: ScreenUtil().setWidth(60 * 2),
  111 + // child: Text('热菜',
  112 + // style: TextStyle(
  113 + // fontSize: ScreenUtil().setWidth(30),
  114 + // color: MyColours.color_666666)),
  115 + // ),
  116 + // Container(
  117 + // height: ScreenUtil().setWidth(110 * 2) * 100,
  118 + // child: ListView.builder(
  119 + // shrinkWrap: true,
  120 + // physics: NeverScrollableScrollPhysics(),
  121 + // itemCount: 100,
  122 + // itemBuilder: (BuildContext context, int index) {
  123 + // return Container();
  124 + // })),
  125 + // ],
  126 + // ));
  127 + }
  128 +
  129 + Widget _laduWidget() {
  130 + // if (labelIcon[widget
  131 + // .cookBookList.labelList[index].icon] is int) {
  132 + // int ladu = labelIcon[
  133 + // widget.cookBookList.labelList[index].icon];
  134 + int ladu = 3;
  135 + List<Widget> widgetList = [];
  136 + for (var i = 0; i < ladu; i++) {
  137 + widgetList.add(Image.asset(
  138 + Utils.getImgPath('ladu'),
  139 + width: w(10),
  140 + ));
  141 + }
  142 + // widgetList.add(HEmptyView(10));
  143 + return Row(
  144 + children: widgetList,
  145 + );
  146 + // }else{
  147 + // return SizedBox();
  148 + // }
  149 + }
  150 +
  151 + @override
  152 + Widget build(BuildContext context) {
  153 + _planDishProvider = Provider.of<PlanDishProvider>(context, listen: true);
  154 + return Scaffold(
  155 + backgroundColor: MyColours.color_ffffff,
  156 + appBar: SystemAppBar('经理排菜'),
  157 + body: Consumer<PlanDishProvider>(builder: (context, model, child) {
  158 + if (model.pageState == PageState.Success) {
  159 + return Column(
  160 + children: [
  161 + MyDivider(
  162 + double.infinity,
  163 + ScreenUtil().setWidth(1),
  164 + color: MyColours.color_DBDBDB,
  165 + ),
  166 + Expanded(
  167 + child: Row(
  168 + crossAxisAlignment: CrossAxisAlignment.start,
  169 + children: [
  170 + ValueListenableBuilder<Iterable<ItemPosition>>(
  171 + valueListenable: itemPositionsListener.itemPositions,
  172 + builder: (context, positions, child) {
  173 + // if (positions.isNotEmpty) {
  174 + // // max = positions
  175 + // // .where((ItemPosition position) =>
  176 + // // position.itemLeadingEdge < 1)
  177 + // // .reduce((ItemPosition max,
  178 + // // ItemPosition position) =>
  179 + // // position.itemLeadingEdge >
  180 + // // max.itemLeadingEdge
  181 + // // ? position
  182 + // // : max)
  183 + // // .index;
  184 + // min = positions
  185 + // .where((ItemPosition position) =>
  186 + // position.itemTrailingEdge > 0)
  187 + // .reduce((ItemPosition min,
  188 + // ItemPosition position) =>
  189 + // position.itemTrailingEdge <
  190 + // min.itemTrailingEdge
  191 + // ? position
  192 + // : min)
  193 + // .index;
  194 +
  195 + // if (isTap) {
  196 + // if (min >= _selectIndex) {
  197 + // _selectIndex = min;
  198 + // } else {
  199 + // _selectIndex = _selectIndex;
  200 + // }
  201 + // isTap = false;
  202 + // } else {
  203 + // _selectIndex = min;
  204 + // }
  205 + // }
  206 + return Container(
  207 + height: double.infinity,
  208 + color: MyColours.color_F9F9F9,
  209 + width: ScreenUtil().setWidth(85 * 2),
  210 + child: ListView.builder(
  211 + // itemCount:
  212 + // _storeMenuProvider.menulist.length,
  213 + itemCount:
  214 + _planDishProvider.menuModel.length,
  215 + itemBuilder:
  216 + (BuildContext context, int index) {
  217 + return InkWell(
  218 + onTap: () {
  219 + isTap = true;
  220 + // scrollTo(index);
  221 + setState(() {
  222 + _selectIndex = index;
  223 + });
  224 + },
  225 + child: Stack(
  226 + children: [
  227 + Container(
  228 + height:
  229 + ScreenUtil().setWidth(60 * 2),
  230 + decoration: BoxDecoration(
  231 + color: _selectIndex == index
  232 + ? MyColours.color_DBDBDB
  233 + : MyColours.color_ffffff,
  234 + border: Border(
  235 + right: BorderSide(
  236 + width: w(1),
  237 + color: MyColours
  238 + .color_DBDBDB),
  239 + bottom: BorderSide(
  240 + width: w(1),
  241 + color: MyColours
  242 + .color_DBDBDB))),
  243 + alignment: Alignment.center,
  244 + padding: EdgeInsets.symmetric(
  245 + horizontal:
  246 + ScreenUtil().setWidth(30),
  247 + vertical: ScreenUtil()
  248 + .setWidth(20)),
  249 + child: Text(
  250 + // _storeMenuProvider
  251 + // .menulist[index].className,
  252 + _planDishProvider
  253 + .menuModel[index].className,
  254 + maxLines: 2,
  255 + overflow: TextOverflow.ellipsis,
  256 + style: TextStyle(
  257 + fontSize:
  258 + ScreenUtil().setSp(28),
  259 + color: _selectIndex == index
  260 + ? MyColours.color_333333
  261 + : MyColours
  262 + .color_999999),
  263 + ),
  264 + ),
  265 + Positioned(
  266 + top: w(2),
  267 + right: w(2),
  268 + child: Container(
  269 + // width: w(16),
  270 + constraints: BoxConstraints(
  271 + minWidth: w(16)),
  272 + height: w(16),
  273 + alignment: Alignment.center,
  274 + decoration: BoxDecoration(
  275 + borderRadius:
  276 + BorderRadius.circular(
  277 + r(8)),
  278 + color: MyColours
  279 + .color_E34D59),
  280 + child: Text(
  281 + '23',
  282 + style: TextStyle(
  283 + fontSize: font(10),
  284 + color: MyColours
  285 + .color_F6F6F6),
  286 + ),
  287 + ))
  288 + ],
  289 + ),
  290 + );
  291 + }));
  292 + }),
  293 + Expanded(
  294 + child: Container(
  295 + padding: EdgeInsets.symmetric(horizontal: w(10)),
  296 + // width: ScreenUtil().setWidth(290 * 2),
  297 +
  298 + child: ListView.builder(
  299 + shrinkWrap: true,
  300 + // physics: NeverScrollableScrollPhysics(),
  301 + itemCount: _planDishProvider
  302 + .menuModel[_selectIndex]
  303 + .cookbooklist
  304 + .length,
  305 + itemBuilder:
  306 + (BuildContext context, int index) {
  307 + MenuSunModel menuSunModel =
  308 + _planDishProvider
  309 + .menuModel[_selectIndex]
  310 + .cookbooklist[index];
  311 + return Container(
  312 + padding:
  313 + EdgeInsets.symmetric(vertical: w(16)),
  314 + decoration: BoxDecoration(
  315 + border: Border(
  316 + bottom: BorderSide(
  317 + color: MyColours.color_DBDBDB,
  318 + width: w(1)))),
  319 + child: Row(
  320 + children: [
  321 + Expanded(
  322 + child: Column(
  323 + crossAxisAlignment:
  324 + CrossAxisAlignment.start,
  325 + children: [
  326 + Row(
  327 + children: [
  328 + Container(
  329 + constraints:
  330 + BoxConstraints(
  331 + maxWidth: w(100)),
  332 + child: Text(
  333 + menuSunModel.name,
  334 + maxLines: 10,
  335 + overflow: TextOverflow
  336 + .ellipsis,
  337 + style: TextStyle(
  338 + fontSize: font(16),
  339 + fontWeight:
  340 + FontWeight.bold,
  341 + color: MyColours
  342 + .color_515151),
  343 + )),
  344 + HEmptyView(8),
  345 + _laduWidget()
  346 + ],
  347 + ),
  348 + VEmptyView(24),
  349 + Row(
  350 + children: [
  351 + Text(
  352 + '${menuSunModel.price}元/${menuSunModel.unit}',
  353 + style: TextStyle(
  354 + fontSize: font(12),
  355 + color: MyColours
  356 + .color_999999),
  357 + ),
  358 + Text(
  359 + '${menuSunModel.member_price}元/${menuSunModel.unit}',
  360 + style: TextStyle(
  361 + fontSize: font(10),
  362 + color: MyColours
  363 + .color_8EBBBE),
  364 + ),
  365 + ],
  366 + )
  367 + ],
  368 + )),
  369 + // Spacer(),
  370 + Image.asset(
  371 + Utils.getImgPath('plan_dish_minus'),
  372 + width: w(16),
  373 + ),
  374 + HEmptyView(8),
  375 + Container(
  376 + width: w(32),
  377 + height: w(16),
  378 + decoration: BoxDecoration(
  379 + borderRadius:
  380 + BorderRadius.circular(
  381 + r(5)),
  382 + border: Border.all(
  383 + width: w(1),
  384 + color: MyColours
  385 + .color_999999)),
  386 + // constraints: BoxConstraints(minWidth: w(20)),
  387 + child: TextField(
  388 + maxLines: 1,
  389 + // controller:
  390 + // focusNode: _focusNode,
  391 + // autofocus: true,
  392 +
  393 + style: TextStyle(
  394 + color:
  395 + MyColours.color_438E93,
  396 + fontSize: font(12)),
  397 + textAlign: TextAlign.center,
  398 + // textAlignVertical: TextAlignVertical.center,
  399 + decoration: InputDecoration(
  400 + hintText: "人数",
  401 + hintStyle: TextStyle(
  402 + color:
  403 + MyColours.color_999999,
  404 + fontSize: font(12),
  405 + ),
  406 + // isCollapsed:
  407 + // true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
  408 + border: OutlineInputBorder(
  409 + borderSide:
  410 + BorderSide.none),
  411 + contentPadding:
  412 + EdgeInsets.zero,
  413 + ),
  414 + keyboardType:
  415 + TextInputType.number,
  416 + textInputAction:
  417 + TextInputAction.done,
  418 +
  419 + onChanged: (value) {
  420 + // setState(() {});
  421 + // _searchSellerLocation();
  422 + // customerProvider.searchData(value);
  423 + },
  424 + onEditingComplete: () {
  425 + FocusScope.of(context)
  426 + .requestFocus(
  427 + FocusNode()); //点击空白处隐藏键盘
  428 + // contantShowModel.searchData(
  429 + // contantShowModel.controller.text);
  430 + // _searchSellerLocation();
  431 + // _focusNode.unfocus();
  432 + },
  433 + )),
  434 + HEmptyView(8),
  435 + Image.asset(
  436 + Utils.getImgPath('plan_dish_add'),
  437 + width: w(16),
  438 + ),
  439 + ],
  440 + ),
  441 + );
  442 + })))
  443 + ],
  444 + ),
  445 + ),
  446 + Container(
  447 + decoration: BoxDecoration(
  448 + border: Border(
  449 + top: BorderSide(
  450 + width: w(1), color: MyColours.color_DBDBDB))),
  451 + padding:
  452 + EdgeInsets.symmetric(horizontal: w(20), vertical: w(15)),
  453 + child: Row(
  454 + children: [
  455 + Stack(
  456 + clipBehavior: Clip.none,
  457 + children: [
  458 + Image.asset(
  459 + Utils.getImgPath('plan_dish_car'),
  460 + width: w(35),
  461 + ),
  462 + Positioned(
  463 + top: w(-3),
  464 + right: w(-4),
  465 + child: Container(
  466 + // width: w(16),
  467 + constraints: BoxConstraints(minWidth: w(16)),
  468 + height: w(16),
  469 + alignment: Alignment.center,
  470 + decoration: BoxDecoration(
  471 + borderRadius: BorderRadius.circular(r(8)),
  472 + color: MyColours.color_E34D59),
  473 + child: Text(
  474 + '23',
  475 + style: TextStyle(
  476 + fontSize: font(10),
  477 + color: MyColours.color_F6F6F6),
  478 + ),
  479 + ))
  480 + ],
  481 + ),
  482 + HEmptyView(66),
  483 + Expanded(
  484 + child: Column(
  485 + children: [
  486 + Row(
  487 + children: [
  488 + Text(
  489 + '总计:',
  490 + style: TextStyle(
  491 + fontSize: font(12),
  492 + color: MyColours.color_515151),
  493 + ),
  494 + Text(
  495 + '0.00',
  496 + style: TextStyle(
  497 + fontSize: font(12),
  498 + color: MyColours.color_000000),
  499 + ),
  500 + Text(
  501 + '元',
  502 + style: TextStyle(
  503 + fontSize: font(12),
  504 + color: MyColours.color_515151),
  505 + ),
  506 + ],
  507 + ),
  508 + VEmptyView(20),
  509 + Row(
  510 + children: [
  511 + Text(
  512 + '会员价:',
  513 + style: TextStyle(
  514 + fontSize: font(12),
  515 + color: MyColours.color_515151),
  516 + ),
  517 + Text(
  518 + '0.00',
  519 + style: TextStyle(
  520 + fontSize: font(12),
  521 + color: MyColours.color_000000),
  522 + ),
  523 + Text(
  524 + '元',
  525 + style: TextStyle(
  526 + fontSize: font(12),
  527 + color: MyColours.color_515151),
  528 + ),
  529 + ],
  530 + )
  531 + ],
  532 + )),
  533 + HEmptyView(10),
  534 + Text(
  535 + '排菜价:',
  536 + style: TextStyle(
  537 + fontSize: font(12), color: MyColours.color_515151),
  538 + ),
  539 + Container(
  540 + width: w(65),
  541 + height: w(30),
  542 + decoration: BoxDecoration(
  543 + borderRadius: BorderRadius.circular(r(5)),
  544 + border: Border.all(
  545 + color: MyColours.color_515151, width: w(1))),
  546 + // constraints: BoxConstraints(minWidth: w(20)),
  547 + child: TextField(
  548 + maxLines: 1,
  549 + // controller:
  550 + // focusNode: _focusNode,
  551 + // autofocus: true,
  552 +
  553 + style: TextStyle(
  554 + color: MyColours.color_000000,
  555 + fontSize: font(12)),
  556 + textAlign: TextAlign.center,
  557 + // textAlignVertical: TextAlignVertical.center,
  558 + decoration: InputDecoration(
  559 + hintText: "0.00",
  560 + hintStyle: TextStyle(
  561 + color: MyColours.color_999999,
  562 + fontSize: font(12),
  563 + ),
  564 + // isCollapsed:
  565 + // true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
  566 + border: OutlineInputBorder(
  567 + borderSide: BorderSide.none),
  568 + contentPadding: EdgeInsets.zero,
  569 + ),
  570 + keyboardType: TextInputType.number,
  571 + textInputAction: TextInputAction.done,
  572 +
  573 + onChanged: (value) {
  574 + // setState(() {});
  575 + // _searchSellerLocation();
  576 + // customerProvider.searchData(value);
  577 + },
  578 + onEditingComplete: () {
  579 + FocusScope.of(context)
  580 + .requestFocus(FocusNode()); //点击空白处隐藏键盘
  581 + // contantShowModel.searchData(
  582 + // contantShowModel.controller.text);
  583 + // _searchSellerLocation();
  584 + // _focusNode.unfocus();
  585 + },
  586 + )),
  587 + Text(
  588 + '元',
  589 + style: TextStyle(
  590 + fontSize: font(12), color: MyColours.color_515151),
  591 + ),
  592 + ],
  593 + ),
  594 + ),
  595 + Container(
  596 + color: MyColours.color_FAFAFA,
  597 + padding: EdgeInsets.only(
  598 + top: w(12), bottom: w(25), left: w(20), right: w(20)),
  599 + child: Row(
  600 + mainAxisAlignment: MainAxisAlignment.spaceBetween,
  601 + children: [
  602 + RoundButton(
  603 + text: '排菜编辑',
  604 + gradientStart: MyColours.color_ffffff,
  605 + gradientEnd: MyColours.color_ffffff,
  606 + width: w(100),
  607 + height: w(43),
  608 + radius: r(5),
  609 + fontSize: 32,
  610 + isBold: false,
  611 + borderColor: MyColours.color_438E93,
  612 + textColor: MyColours.color_438E93,
  613 + onPressed: () {
  614 + // NavigatorUtil.goFinalPlanDishPage(context);
  615 + },
  616 + ),
  617 + RoundButton(
  618 + text: '生成预览',
  619 + gradientStart: MyColours.color_ffffff,
  620 + gradientEnd: MyColours.color_ffffff,
  621 + width: w(100),
  622 + height: w(43),
  623 + radius: r(5),
  624 + fontSize: 32,
  625 + borderColor: MyColours.color_438E93,
  626 + textColor: MyColours.color_438E93,
  627 + isBold: false,
  628 + onPressed: () {
  629 + // NavigatorUtil.goFinalPlanDishPage(context);
  630 + },
  631 + ),
  632 + RoundButton(
  633 + text: '提交',
  634 + gradientStart: MyColours.color_438E93,
  635 + gradientEnd: MyColours.color_438E93,
  636 + width: w(100),
  637 + height: w(43),
  638 + radius: r(5),
  639 + fontSize: 36,
  640 + isBold: false,
  641 + onPressed: () {
  642 + // NavigatorUtil.goFinalPlanDishPage(context);
  643 + },
  644 + )
  645 + ],
  646 + ))
  647 + ],
  648 + );
  649 + } else {
  650 + return ExceptionPage(
  651 + pageState: model.pageState,
  652 + emptyMsg: '暂时没有菜单哦',
  653 + callback: () {
  654 + _getCookbookByClass();
  655 + },
  656 + );
  657 + }
  658 + }));
  659 + }
  660 +}
@@ -339,9 +339,11 @@ class _OrderAdvanceHomePageState extends State<OrderAdvanceHomePage> { @@ -339,9 +339,11 @@ class _OrderAdvanceHomePageState extends State<OrderAdvanceHomePage> {
339 VEmptyView(32), 339 VEmptyView(32),
340 _textMulLine('喜好', '点这里输入客户喜好的东西,请用逗号隔开。', likeController), 340 _textMulLine('喜好', '点这里输入客户喜好的东西,请用逗号隔开。', likeController),
341 VEmptyView(20), 341 VEmptyView(20),
342 - _textMulLine('忌口', '点这里输入客户忌口的东西,请用逗号隔开。', noFoodController), 342 + _textMulLine(
  343 + '忌口', '点这里输入客户忌口的东西,请用逗号隔开。', noFoodController),
343 VEmptyView(20), 344 VEmptyView(20),
344 - _textMulLine('服务', '点这里输入客户需要的服务,如安静的包间、远离厕所等,请用逗号隔开。', serviceController), 345 + _textMulLine('服务', '点这里输入客户需要的服务,如安静的包间、远离厕所等,请用逗号隔开。',
  346 + serviceController),
345 ], 347 ],
346 ), 348 ),
347 ), 349 ),
@@ -392,11 +394,9 @@ class _OrderAdvanceHomePageState extends State<OrderAdvanceHomePage> { @@ -392,11 +394,9 @@ class _OrderAdvanceHomePageState extends State<OrderAdvanceHomePage> {
392 flex: 2, 394 flex: 2,
393 child: InkWell( 395 child: InkWell(
394 onTap: () { 396 onTap: () {
395 - // NavigatorUtil  
396 - // .goInvicationPage(  
397 - // context,  
398 - // detailEntity.id,  
399 - // ); 397 + NavigatorUtil.goOrderAdvanceEditPage(
  398 + context,
  399 + );
400 }, 400 },
401 child: Container( 401 child: Container(
402 decoration: BoxDecoration( 402 decoration: BoxDecoration(
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
2 import 'package:one_key/constant/state.dart'; 2 import 'package:one_key/constant/state.dart';
  3 +import 'package:one_key/net/base_resp.dart';
  4 +import 'package:one_key/net/dio_util.dart';
  5 +import 'package:one_key/utils/utils.dart';
  6 +
  7 +import '../constant/constant.dart';
  8 +import '../constant/error.dart';
  9 +import '../models/cookbook_model.dart';
  10 +import '../net/http_url.dart';
3 11
4 /** 12 /**
5 * 预排菜 13 * 预排菜
6 */ 14 */
7 class PlanDishProvider extends ChangeNotifier { 15 class PlanDishProvider extends ChangeNotifier {
8 - PageState pageState = PageState.Success; 16 + PageState pageState = PageState.Loading;
  17 + List<MenuModel> menuModel; //菜品数据
  18 + // List<CookbookCategorySunModel> categorySunModel; //菜品分类数据
  19 + // List<CookbookSpecSunModel> specSunModel; //计价单位
  20 +
  21 + // CookbookOneSunModel cookbookOneSunModel;
  22 +
  23 + ///分类下所有菜品列表(1.传orderid顾客端获取带订单信息的 否则不传
  24 +
  25 + getCookbookByClass(BuildContext context, Map<String, String> params,
  26 + {showLoading = false}) async {
  27 + BaseResp<dynamic> baseResp = await DioUtil()
  28 + .request<dynamic>(context, Method.get, HttpUrl.get_cookbook_by_class,
  29 + data: params, showLoading: showLoading)
  30 + .catchError((error) {
  31 + print(error.toString());
  32 + if (error is MyError) {
  33 + switch (error.type) {
  34 + case 1:
  35 + pageState = PageState.ConnectivityError;
  36 + break;
  37 + case 2:
  38 + pageState = PageState.ConnectivityTimeOut;
  39 + break;
  40 + default:
  41 + pageState = PageState.ConnectivityError;
  42 + break;
  43 + }
  44 + }
  45 + notifyListeners();
  46 + });
  47 + menuModel = [];
  48 +
  49 + if (baseResp != null && baseResp.code == Constant.status_success) {
  50 + if (baseResp.data[0]['list'] == '') {
  51 + pageState = PageState.Empty;
  52 + } else {
  53 + List menu = baseResp.data[0]['list'];
  54 + for (int i = 0; i < menu.length; i++) {
  55 + menuModel.add(MenuModel.fromJson(menu[i]));
  56 + }
  57 + print(menuModel);
  58 + pageState = PageState.Success;
  59 + }
  60 + } else {
  61 + Utils.showToast(baseResp.msg ?? "");
  62 + pageState = PageState.ConnectivityError;
  63 + }
  64 + notifyListeners();
  65 + }
9 } 66 }
@@ -1224,4 +1224,23 @@ class NavigatorUtil { @@ -1224,4 +1224,23 @@ class NavigatorUtil {
1224 return _navigateTo(context, "${Routes.order_advance_home_page}", 1224 return _navigateTo(context, "${Routes.order_advance_home_page}",
1225 replace: replace); 1225 replace: replace);
1226 } 1226 }
  1227 +
  1228 + ///经理排菜-编辑
  1229 +
  1230 + static Future<dynamic> goOrderAdvanceEditPage(
  1231 + BuildContext context, {
  1232 + replace = false,
  1233 + }) {
  1234 + // if (invoice != null) {
  1235 + // return _navigateTo(context,
  1236 + // "${Routes.order_advance_home_page}?invoice=${FluroConvertUtils.object2string(invoice)}",
  1237 + // replace: replace);
  1238 + // }
  1239 + // if (object != null) {
  1240 + // return _navigateTo(context,
  1241 + // "${Routes.order_advance_home_page}?tids=$tids&tableidNow=$tableidNow&fromPage=$fromPage&canChoose=$canChoose&object=${FluroConvertUtils.object2string(object)}");
  1242 + // }
  1243 + return _navigateTo(context, "${Routes.order_advance_edit_page}",
  1244 + replace: replace);
  1245 + }
1227 } 1246 }
@@ -115,6 +115,7 @@ import 'package:one_key/pages/notebook/statistics_sms_page.dart'; @@ -115,6 +115,7 @@ import 'package:one_key/pages/notebook/statistics_sms_page.dart';
115 import 'package:one_key/pages/online_check/invoice_detail_page.dart'; 115 import 'package:one_key/pages/online_check/invoice_detail_page.dart';
116 import 'package:one_key/pages/online_check/online_check_detail_page.dart'; 116 import 'package:one_key/pages/online_check/online_check_detail_page.dart';
117 import 'package:one_key/pages/online_check/online_check_edit_page.dart'; 117 import 'package:one_key/pages/online_check/online_check_edit_page.dart';
  118 +import 'package:one_key/pages/order_advance/order_advance_eidt_page.dart';
118 import 'package:one_key/pages/sms/sms_page.dart'; 119 import 'package:one_key/pages/sms/sms_page.dart';
119 import 'package:one_key/pages/table/select_table_page.dart'; 120 import 'package:one_key/pages/table/select_table_page.dart';
120 import 'package:one_key/pages/my/photo_type/table_photo_manager_page.dart'; 121 import 'package:one_key/pages/my/photo_type/table_photo_manager_page.dart';
@@ -1933,3 +1934,24 @@ var orderAdvanceHomePageHandle = new Handler( @@ -1933,3 +1934,24 @@ var orderAdvanceHomePageHandle = new Handler(
1933 return ChangeNotifierProvider<PlanDishProvider>( 1934 return ChangeNotifierProvider<PlanDishProvider>(
1934 create: (_) => PlanDishProvider(), child: OrderAdvanceHomePage()); 1935 create: (_) => PlanDishProvider(), child: OrderAdvanceHomePage());
1935 }); 1936 });
  1937 +
  1938 +///经理排菜---编辑
  1939 +var orderAdvanceEidtPageHandle = new Handler(
  1940 + handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
  1941 + // String fromPage = params["fromPage"].first;
  1942 + // String tids = params["tids"].first;
  1943 +
  1944 + // String tableidNow = params["tableidNow"].first;
  1945 + // bool canChoose = params["canChoose"].first == "true" ? true : false;
  1946 + // List<TableList> res = [];
  1947 + // if (params.keys.contains('object')) {
  1948 + // Map object = FluroConvertUtils.string2map(params["object"].first);
  1949 + // List temp = object['object'];
  1950 +
  1951 + // for (var item in temp) {
  1952 + // res.add(TableList.fromJson(item));
  1953 + // }
  1954 + // }
  1955 + return ChangeNotifierProvider<PlanDishProvider>(
  1956 + create: (_) => PlanDishProvider(), child: OrderAdvanceEidtPage());
  1957 +});
@@ -174,6 +174,8 @@ class Routes { @@ -174,6 +174,8 @@ class Routes {
174 * 经理排菜 174 * 经理排菜
175 */ 175 */
176 static String order_advance_home_page = "/order_advance_home_page"; //经理预点菜首页 176 static String order_advance_home_page = "/order_advance_home_page"; //经理预点菜首页
  177 + static String order_advance_edit_page = "/order_advance_edit_page"; //经理预点菜编辑
  178 +
177 179
178 static void configureRoutes(FluroRouter router) { 180 static void configureRoutes(FluroRouter router) {
179 router.notFoundHandler = new Handler( 181 router.notFoundHandler = new Handler(
@@ -340,6 +342,9 @@ class Routes { @@ -340,6 +342,9 @@ class Routes {
340 router.define(plan_new_dish_page, handler: planNewDishPageHandle); 342 router.define(plan_new_dish_page, handler: planNewDishPageHandle);
341 router.define(final_plan_dish_page, handler: finalPlanDishPageHandle); 343 router.define(final_plan_dish_page, handler: finalPlanDishPageHandle);
342 router.define(order_advance_home_page, handler: orderAdvanceHomePageHandle); 344 router.define(order_advance_home_page, handler: orderAdvanceHomePageHandle);
  345 +
  346 + router.define(order_advance_edit_page, handler: orderAdvanceEidtPageHandle);
  347 +
343 348
344 } 349 }
345 } 350 }