Commit 720894863107a09965c6c80dc08d2ac21cddeb3a

Authored by wdn127929
1 parent 2d299df4

差添加菜品接口+样式+菜品数据详情赋值

  1 +class CookbookPracticeModel {
  2 + int ret;
  3 + List<CookbookPracticeSunModel> data;
  4 + String msg;
  5 +
  6 + CookbookPracticeModel({this.ret, this.data, this.msg});
  7 +
  8 + CookbookPracticeModel.fromJson(Map<String, dynamic> json) {
  9 + ret = json['ret'];
  10 + if (json['data'] != null) {
  11 + data = [];
  12 + json['data'][0].forEach((v) {
  13 + data.add(new CookbookPracticeSunModel.fromJson(v));
  14 + });
  15 + }
  16 + msg = json['msg'];
  17 + }
  18 +
  19 + Map<String, dynamic> toJson() {
  20 + final Map<String, dynamic> data = new Map<String, dynamic>();
  21 + data['ret'] = this.ret;
  22 + if (this.data != null) {
  23 + data['data'] = this.data.map((v) => v.toJson()).toList();
  24 + }
  25 + data['msg'] = this.msg;
  26 + return data;
  27 + }
  28 +}
  29 +
  30 +class CookbookPracticeSunModel {
  31 + String id;
  32 + String sellerid;
  33 + String name;
  34 + String cdate;
  35 + bool select = false;
  36 +
  37 + CookbookPracticeSunModel({this.id, this.sellerid, this.name, this.cdate});
  38 +
  39 + CookbookPracticeSunModel.fromJson(Map<String, dynamic> json) {
  40 + id = json['id'];
  41 + sellerid = json['sellerid'];
  42 + name = json['name'];
  43 + cdate = json['cdate'];
  44 + }
  45 +
  46 + Map<String, dynamic> toJson() {
  47 + final Map<String, dynamic> data = new Map<String, dynamic>();
  48 + data['id'] = this.id;
  49 + data['sellerid'] = this.sellerid;
  50 + data['name'] = this.name;
  51 + data['cdate'] = this.cdate;
  52 + return data;
  53 + }
  54 +
  55 + Map<String, dynamic> toJson2() {
  56 + final Map<String, dynamic> data = new Map<String, dynamic>();
  57 + data['id'] = this.id;
  58 + data['name'] = this.name;
  59 + // data['status'] = this.select ? '1':'0';
  60 + return data;
  61 + }
  62 +}
@@ -39,6 +39,8 @@ class CookbookSpecSunModel extends Object { @@ -39,6 +39,8 @@ class CookbookSpecSunModel extends Object {
39 @JsonKey(name: 'cdate') 39 @JsonKey(name: 'cdate')
40 String cdate; 40 String cdate;
41 41
  42 + bool select = false;
  43 +
42 CookbookSpecSunModel( 44 CookbookSpecSunModel(
43 this.id, 45 this.id,
44 this.sellerid, 46 this.sellerid,
  1 +import 'package:flutter/material.dart';
  2 +
  3 +class MenuUnitModel {
  4 + String specs; //销售单位
  5 + String specid; //销售单位id
  6 + String price; //售价
  7 + String memberPrice; //会员价
  8 + String status; //是否启用
  9 + bool select; //是否启用
  10 +
  11 + TextEditingController priceC = TextEditingController();
  12 + TextEditingController memberPriceC = TextEditingController();
  13 +
  14 + MenuUnitModel();
  15 +
  16 + factory MenuUnitModel.fromJson(Map<String, dynamic> json) => MenuUnitModel()
  17 + ..specs = json["specs"]
  18 + ..specid = json["specid"]
  19 + ..price = json["price"]
  20 + ..memberPrice = json["member_price"]
  21 + ..status = json["status"]
  22 + ..select = json["status"] == '1' ? true : false
  23 + ..memberPriceC.text = json["member_price"]
  24 + ..priceC.text = json["price"];
  25 +
  26 + Map<String, dynamic> toJson() => <String, dynamic>{
  27 + "specs": specs,
  28 + "specid": specid,
  29 + 'price': price,
  30 + 'member_price': memberPrice,
  31 + 'status': select ? '1' : '0'
  32 + };
  33 +}
@@ -418,4 +418,24 @@ class HttpUrl { @@ -418,4 +418,24 @@ class HttpUrl {
418 static const String set_new_recharge_write_off = 418 static const String set_new_recharge_write_off =
419 "?service=App.Activity.SetNewRechargeWriteOff"; // 核销未使用优惠券 419 "?service=App.Activity.SetNewRechargeWriteOff"; // 核销未使用优惠券
420 420
  421 + static const String get_seller_practice_by_id =
  422 + "?service=App.Seller.GetSellerPracticeById"; // 获取商家默认做法数据
  423 +
  424 + static const String add_practice =
  425 + "?service=Android.Seller.AddPractice"; // 商家添加做法
  426 +
  427 +
  428 + static const String add_unit_value =
  429 + "?service=App.Seller.AddUnitValue"; // 添加商家计价单位
  430 +
  431 +
  432 + static const String del_unit_value =
  433 + "?service=App.Seller.DelUnitValue"; // 删除商家计价单位
  434 +
  435 +
  436 +
  437 +
  438 +
  439 +
  440 +
421 } 441 }
  1 +import 'dart:convert';
1 import 'dart:io'; 2 import 'dart:io';
2 3
3 import 'package:amap_map_fluttify/amap_map_fluttify.dart'; 4 import 'package:amap_map_fluttify/amap_map_fluttify.dart';
4 import 'package:cached_network_image/cached_network_image.dart'; 5 import 'package:cached_network_image/cached_network_image.dart';
5 import 'package:flutter/material.dart'; 6 import 'package:flutter/material.dart';
  7 +import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
6 import 'package:flutter_native_image/flutter_native_image.dart'; 8 import 'package:flutter_native_image/flutter_native_image.dart';
7 import 'package:flutter_screenutil/flutter_screenutil.dart'; 9 import 'package:flutter_screenutil/flutter_screenutil.dart';
8 import 'package:image_picker/image_picker.dart'; 10 import 'package:image_picker/image_picker.dart';
@@ -25,6 +27,8 @@ import 'package:one_key/widgets/v_empty_view.dart'; @@ -25,6 +27,8 @@ import 'package:one_key/widgets/v_empty_view.dart';
25 import 'package:permission_handler/permission_handler.dart'; 27 import 'package:permission_handler/permission_handler.dart';
26 import 'package:provider/provider.dart'; 28 import 'package:provider/provider.dart';
27 29
  30 +import '../../../models/cookbook_practice_model.dart';
  31 +import '../../../models/menu_unit_model.dart';
28 import '../../../utils/screen_util.dart'; 32 import '../../../utils/screen_util.dart';
29 33
30 /** 34 /**
@@ -55,6 +59,14 @@ class _MenuAddDishesPageState extends State<MenuAddDishesPage> { @@ -55,6 +59,14 @@ class _MenuAddDishesPageState extends State<MenuAddDishesPage> {
55 List<String> specStrList = []; 59 List<String> specStrList = [];
56 String specStr = '请选择'; 60 String specStr = '请选择';
57 String mid = ''; 61 String mid = '';
  62 + List<MenuUnitModel> data; //价格
  63 + String showPrice;
  64 + String selectPracticeShow;
  65 + String selectPracticeIds;
  66 + List<CookbookPracticeSunModel> selectPractice;
  67 + TextEditingController introduceC = TextEditingController(); //简介
  68 + TextEditingController tasteC = TextEditingController(); //味型
  69 + TextEditingController cooksC = TextEditingController(); //烹调
58 @override 70 @override
59 void initState() { 71 void initState() {
60 super.initState(); 72 super.initState();
@@ -120,18 +132,19 @@ class _MenuAddDishesPageState extends State<MenuAddDishesPage> { @@ -120,18 +132,19 @@ class _MenuAddDishesPageState extends State<MenuAddDishesPage> {
120 Utils.showToast('请输入菜品名称'); 132 Utils.showToast('请输入菜品名称');
121 return; 133 return;
122 } 134 }
123 - if (_priceController.text.trim().length == 0) {  
124 - Utils.showToast('请输入菜品价格');  
125 - return;  
126 - } 135 +
127 if (categoryStr == "请选择") { 136 if (categoryStr == "请选择") {
128 Utils.showToast('请选择菜品分类'); 137 Utils.showToast('请选择菜品分类');
129 return; 138 return;
130 } 139 }
131 - if (specStr == "请选择") {  
132 - Utils.showToast('请选择计价方式'); 140 + if (showPrice == null || showPrice == '') {
  141 + Utils.showToast('请选择菜品价格');
133 return; 142 return;
134 } 143 }
  144 + // if (specStr == "请选择") {
  145 + // Utils.showToast('请选择计价方式');
  146 + // return;
  147 + // }
135 String cid = ''; 148 String cid = '';
136 // String unit = ''; 149 // String unit = '';
137 menuManageProvider.categorySunModel.forEach((element) { 150 menuManageProvider.categorySunModel.forEach((element) {
@@ -147,11 +160,13 @@ class _MenuAddDishesPageState extends State<MenuAddDishesPage> { @@ -147,11 +160,13 @@ class _MenuAddDishesPageState extends State<MenuAddDishesPage> {
147 Map<String, String> params = { 160 Map<String, String> params = {
148 "sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid, 161 "sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid,
149 'cid': cid, 162 'cid': cid,
150 - 'unit': specStr, 163 + // 'unit': specStr,
151 'name': _nameController.text, 164 'name': _nameController.text,
152 'status': swichState ? '1' : '0', 165 'status': swichState ? '1' : '0',
153 - 'price': _priceController.text 166 + // 'price': _priceController.text
  167 + 'dishSkuList': json.encode(data)
154 }; 168 };
  169 +
155 if (mid != '') { 170 if (mid != '') {
156 params['id'] = mid; 171 params['id'] = mid;
157 } 172 }
@@ -159,7 +174,27 @@ class _MenuAddDishesPageState extends State<MenuAddDishesPage> { @@ -159,7 +174,27 @@ class _MenuAddDishesPageState extends State<MenuAddDishesPage> {
159 uploadImageProvider.dish.qiniuUrl != '') { 174 uploadImageProvider.dish.qiniuUrl != '') {
160 params['image'] = uploadImageProvider.dish.qiniuUrl; 175 params['image'] = uploadImageProvider.dish.qiniuUrl;
161 } 176 }
  177 + if (selectPracticeShow != null && selectPracticeShow != '') {
  178 + List temp = [];
  179 + selectPractice.forEach((element) {
  180 + temp.add(element.toJson2());
  181 + });
  182 + params['practiceList'] = json.encode(temp);
  183 + }
  184 +
  185 + if (introduceC.text.trim().length > 0) {
  186 + params['desc'] = introduceC.text;
  187 + }
  188 +
  189 + if (tasteC.text.trim().length > 0) {
  190 + params['taste'] = tasteC.text;
  191 + }
  192 + if (cooksC.text.trim().length > 0) {
  193 + params['cooks'] = cooksC.text;
  194 + }
  195 +
162 bool sucess = false; 196 bool sucess = false;
  197 + print(params);
163 if (mid != '') { 198 if (mid != '') {
164 sucess = await menuManageProvider.setCookbookById(context, params, 199 sucess = await menuManageProvider.setCookbookById(context, params,
165 showLoading: showLoading); 200 showLoading: showLoading);
@@ -323,18 +358,21 @@ class _MenuAddDishesPageState extends State<MenuAddDishesPage> { @@ -323,18 +358,21 @@ class _MenuAddDishesPageState extends State<MenuAddDishesPage> {
323 ), 358 ),
324 ) 359 )
325 : SizedBox(), 360 : SizedBox(),
326 - Spacer(),  
327 - Text(hintText,  
328 - style: TextStyle(  
329 - color: hintText == '请选择' ||  
330 - hintText == '点击配置菜品价格' ||  
331 - hintText == '点击配置菜品做法' ||  
332 - hintText == '点击配置烹调方法'  
333 - ? MyColours.color_999999  
334 - : MyColours.color_515151,  
335 - fontWeight: FontWeight.normal,  
336 - fontSize: ScreenUtil().setSp(32),  
337 - )), 361 + // Spacer(),
  362 + HEmptyView(100),
  363 + Expanded(
  364 + child: Text(hintText,
  365 + textAlign: TextAlign.right,
  366 + style: TextStyle(
  367 + color: hintText == '请选择' ||
  368 + hintText == '点击配置菜品价格' ||
  369 + hintText == '点击配置菜品做法' ||
  370 + hintText == '点击配置烹调方法'
  371 + ? MyColours.color_999999
  372 + : MyColours.color_515151,
  373 + fontWeight: FontWeight.normal,
  374 + fontSize: ScreenUtil().setSp(32),
  375 + ))),
338 HEmptyView(20), 376 HEmptyView(20),
339 Image.asset( 377 Image.asset(
340 Utils.getImgPath('arr_right_gray'), 378 Utils.getImgPath('arr_right_gray'),
@@ -445,277 +483,342 @@ class _MenuAddDishesPageState extends State<MenuAddDishesPage> { @@ -445,277 +483,342 @@ class _MenuAddDishesPageState extends State<MenuAddDishesPage> {
445 uploadImageProvider = 483 uploadImageProvider =
446 Provider.of<UploadImageProvider>(context, listen: true); 484 Provider.of<UploadImageProvider>(context, listen: true);
447 menuManageProvider = Provider.of<MenuManageProvider>(context, listen: true); 485 menuManageProvider = Provider.of<MenuManageProvider>(context, listen: true);
448 - return Material(  
449 - child: InkWell(  
450 - onTap: () {  
451 - FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘  
452 - },  
453 - child: Scaffold(  
454 - appBar: SystemAppBar('添加菜品', onTap: () {  
455 - Navigator.pop(context);  
456 - }),  
457 - body: Column(children: [  
458 - Expanded(  
459 - child: SingleChildScrollView(  
460 - child: Column(  
461 - children: [  
462 - InkWell(  
463 - onTap: () {  
464 - DialogUtil.openImageModalBottomSheet(context,  
465 - lCallback: () {  
466 - Utils.getPickPermission(context, () {  
467 - _getFromPictureOrCamera(ImageSource.camera);  
468 - Navigator.pop(context);  
469 - }, Permission.camera);  
470 - }, rCallback: () {  
471 - Utils.getPickPermission(context, () {  
472 - _getFromPictureOrCamera(ImageSource.gallery);  
473 - // _getFromPictureOrCamera(ImageSource.gallery);  
474 - Navigator.pop(context); 486 + return KeyboardDismissOnTap(
  487 + child: Material(
  488 + child: InkWell(
  489 + onTap: () {
  490 + FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
  491 + },
  492 + child: Scaffold(
  493 + appBar: SystemAppBar('添加菜品', onTap: () {
  494 + Navigator.pop(context);
  495 + }),
  496 + body: Column(children: [
  497 + Expanded(
  498 + child: SingleChildScrollView(
  499 + child: Column(
  500 + children: [
  501 + InkWell(
  502 + onTap: () {
  503 + DialogUtil.openImageModalBottomSheet(context,
  504 + lCallback: () {
  505 + Utils.getPickPermission(context, () {
  506 + _getFromPictureOrCamera(
  507 + ImageSource.camera);
  508 + Navigator.pop(context);
  509 + }, Permission.camera);
  510 + }, rCallback: () {
  511 + Utils.getPickPermission(context, () {
  512 + _getFromPictureOrCamera(
  513 + ImageSource.gallery);
  514 + // _getFromPictureOrCamera(ImageSource.gallery);
  515 + Navigator.pop(context);
  516 + },
  517 + Platform.isAndroid
  518 + ? Permission.storage
  519 + : Permission.photos);
  520 + });
475 }, 521 },
476 - Platform.isAndroid  
477 - ? Permission.storage  
478 - : Permission.photos);  
479 - });  
480 - },  
481 - child: Stack(children: [  
482 - uploadImageProvider.dish.file == null  
483 - ? uploadImageProvider.dish.qiniuUrl != null &&  
484 - uploadImageProvider.dish.qiniuUrl !=  
485 - ''  
486 - ? CachedNetworkImage(  
487 - imageUrl:  
488 - uploadImageProvider.dish.qiniuUrl, 522 + child: Stack(children: [
  523 + uploadImageProvider.dish.file == null
  524 + ? uploadImageProvider.dish.qiniuUrl !=
  525 + null &&
  526 + uploadImageProvider
  527 + .dish.qiniuUrl !=
  528 + ''
  529 + ? CachedNetworkImage(
  530 + imageUrl: uploadImageProvider
  531 + .dish.qiniuUrl,
  532 + fit: BoxFit.cover,
  533 + width: double.infinity,
  534 + height:
  535 + ScreenUtil().setWidth(400),
  536 + )
  537 + : Container(
  538 + width: double.infinity,
  539 + height:
  540 + ScreenUtil().setWidth(400),
  541 + color: Color.fromRGBO(
  542 + 235, 234, 239, 1),
  543 + child: Column(
  544 + mainAxisAlignment:
  545 + MainAxisAlignment.center,
  546 + children: [
  547 + Container(
  548 + padding: EdgeInsets.all(
  549 + ScreenUtil()
  550 + .setWidth(34)),
  551 + decoration: BoxDecoration(
  552 + shape: BoxShape.circle,
  553 + border: Border.all(
  554 + width: ScreenUtil()
  555 + .setWidth(2),
  556 + color: MyColours
  557 + .color_c1c1c1,
  558 + )),
  559 + child: Image.asset(
  560 + Utils.getImgPath(
  561 + 'take-picture'),
  562 + width: ScreenUtil()
  563 + .setWidth(80)),
  564 + ),
  565 + VEmptyView(20),
  566 + Text(
  567 + '+菜谱效果图',
  568 + style: TextStyle(
  569 + fontSize: ScreenUtil()
  570 + .setSp(30),
  571 + color: MyColours
  572 + .color_999999),
  573 + )
  574 + ],
  575 + ),
  576 + )
  577 + : Image.file(
  578 + uploadImageProvider.dish.file,
489 fit: BoxFit.cover, 579 fit: BoxFit.cover,
490 width: double.infinity, 580 width: double.infinity,
491 height: ScreenUtil().setWidth(400), 581 height: ScreenUtil().setWidth(400),
492 - )  
493 - : Container( 582 + ),
  583 + (uploadImageProvider.dish.file != null) &&
  584 + uploadImageProvider.dish.process !=
  585 + 1 &&
  586 + uploadImageProvider.dish.process !=
  587 + 0.01
  588 + ? Container(
494 width: double.infinity, 589 width: double.infinity,
495 height: ScreenUtil().setWidth(400), 590 height: ScreenUtil().setWidth(400),
496 - color:  
497 - Color.fromRGBO(235, 234, 239, 1),  
498 - child: Column(  
499 - mainAxisAlignment:  
500 - MainAxisAlignment.center,  
501 - children: [  
502 - Container(  
503 - padding: EdgeInsets.all(  
504 - ScreenUtil().setWidth(34)),  
505 - decoration: BoxDecoration(  
506 - shape: BoxShape.circle,  
507 - border: Border.all(  
508 - width: ScreenUtil()  
509 - .setWidth(2),  
510 - color: MyColours  
511 - .color_c1c1c1,  
512 - )),  
513 - child: Image.asset(  
514 - Utils.getImgPath(  
515 - 'take-picture'),  
516 - width: ScreenUtil()  
517 - .setWidth(80)),  
518 - ),  
519 - VEmptyView(20),  
520 - Text(  
521 - '+菜谱效果图', 591 + child: Center(
  592 + child: Text('上传中...',
522 style: TextStyle( 593 style: TextStyle(
523 - fontSize:  
524 - ScreenUtil().setSp(30),  
525 - color:  
526 - MyColours.color_999999),  
527 - )  
528 - ], 594 + color: MyColours
  595 + .color_999999)),
529 ), 596 ),
530 ) 597 )
531 - : Image.file(  
532 - uploadImageProvider.dish.file,  
533 - fit: BoxFit.cover,  
534 - width: double.infinity,  
535 - height: ScreenUtil().setWidth(400),  
536 - ),  
537 - (uploadImageProvider.dish.file != null) &&  
538 - uploadImageProvider.dish.process != 1 &&  
539 - uploadImageProvider.dish.process != 0.01  
540 - ? Container(  
541 - width: double.infinity,  
542 - height: ScreenUtil().setWidth(400),  
543 - child: Center(  
544 - child: Text('上传中...',  
545 - style: TextStyle(  
546 - color: MyColours.color_999999)),  
547 - ),  
548 - )  
549 - : Container(),  
550 - ])),  
551 - InkWell(  
552 - onTap: () {  
553 - setState(() {  
554 - swichState = !swichState;  
555 - });  
556 - },  
557 - child: Container(  
558 - height: w(48),  
559 - padding: EdgeInsets.symmetric(  
560 - horizontal: ScreenUtil().setWidth(32),  
561 - ),  
562 - child: Row(  
563 - mainAxisAlignment:  
564 - MainAxisAlignment.spaceBetween,  
565 - children: [  
566 - Container(  
567 - child: Text(  
568 - swichState ? '上架菜品,在所有点餐设备上显示' : '商品已下架',  
569 - style: TextStyle(  
570 - color: MyColours.color_666666,  
571 - fontSize: ScreenUtil().setSp(24)),  
572 - ), 598 + : Container(),
  599 + ])),
  600 + InkWell(
  601 + onTap: () {
  602 + setState(() {
  603 + swichState = !swichState;
  604 + });
  605 + },
  606 + child: Container(
  607 + height: w(48),
  608 + padding: EdgeInsets.symmetric(
  609 + horizontal: ScreenUtil().setWidth(32),
573 ), 610 ),
574 - Image.asset(  
575 - swichState  
576 - ? Utils.getImgPath('swich_on')  
577 - : Utils.getImgPath('swich_off'),  
578 - width: w(44),  
579 - height: w(24),  
580 - )  
581 - ],  
582 - )),  
583 - ),  
584 - Padding(  
585 - padding: EdgeInsets.only(left: w(16)),  
586 - child: MyDivider(  
587 - double.infinity,  
588 - w(0.5),  
589 - color: MyColours.color_E7E7E7,  
590 - )),  
591 - Container(  
592 - height: w(48),  
593 - padding: EdgeInsets.symmetric(  
594 - horizontal: ScreenUtil().setWidth(32),  
595 - ),  
596 - child: _textfield('名称', '点击输入菜品名称', _nameController,  
597 - _nameFocusNode, '',  
598 - inputType: TextInputType.text)),  
599 - Padding(  
600 - padding: EdgeInsets.only(left: w(16)),  
601 - child: MyDivider(  
602 - double.infinity,  
603 - w(0.5),  
604 - color: MyColours.color_E7E7E7,  
605 - )),  
606 - Container(  
607 - height: w(48),  
608 - padding: EdgeInsets.symmetric(  
609 - horizontal: ScreenUtil().setWidth(32), 611 + child: Row(
  612 + mainAxisAlignment:
  613 + MainAxisAlignment.spaceBetween,
  614 + children: [
  615 + Container(
  616 + child: Text(
  617 + swichState
  618 + ? '上架菜品,在所有点餐设备上显示'
  619 + : '商品已下架',
  620 + style: TextStyle(
  621 + color: MyColours.color_666666,
  622 + fontSize: ScreenUtil().setSp(24)),
  623 + ),
  624 + ),
  625 + Image.asset(
  626 + swichState
  627 + ? Utils.getImgPath('swich_on')
  628 + : Utils.getImgPath('swich_off'),
  629 + width: w(44),
  630 + height: w(24),
  631 + )
  632 + ],
  633 + )),
610 ), 634 ),
611 - child: _select('分类', categoryStr, () { 635 + Padding(
  636 + padding: EdgeInsets.only(left: w(16)),
  637 + child: MyDivider(
  638 + double.infinity,
  639 + w(0.5),
  640 + color: MyColours.color_E7E7E7,
  641 + )),
  642 + Container(
  643 + height: w(48),
  644 + padding: EdgeInsets.symmetric(
  645 + horizontal: ScreenUtil().setWidth(32),
  646 + ),
  647 + child: _textfield('名称', '点击输入菜品名称',
  648 + _nameController, _nameFocusNode, '',
  649 + inputType: TextInputType.text)),
  650 + Padding(
  651 + padding: EdgeInsets.only(left: w(16)),
  652 + child: MyDivider(
  653 + double.infinity,
  654 + w(0.5),
  655 + color: MyColours.color_E7E7E7,
  656 + )),
  657 + Container(
  658 + height: w(48),
  659 + padding: EdgeInsets.symmetric(
  660 + horizontal: ScreenUtil().setWidth(32),
  661 + ),
  662 + child: _select('分类', categoryStr, () {
  663 + FocusScope.of(context)
  664 + .requestFocus(FocusNode()); //点击空白处隐藏键盘
  665 + DialogUtil.showSelectCusmanDialog(
  666 + context, categoryStrList, (value) {
  667 + if (value != null) {
  668 + setState(() {
  669 + categoryStr =
  670 + categoryStrList[value.first];
  671 + });
  672 + }
  673 + }, selecteds: [
  674 + categoryStrList.indexOf(categoryStr)
  675 + ]).then((value) {});
  676 + })),
  677 + Padding(
  678 + padding: EdgeInsets.only(left: w(16)),
  679 + child: MyDivider(
  680 + double.infinity,
  681 + w(0.5),
  682 + color: MyColours.color_E7E7E7,
  683 + )),
  684 + Container(
  685 + height: w(48),
  686 + padding: EdgeInsets.symmetric(
  687 + horizontal: ScreenUtil().setWidth(32),
  688 + ),
  689 + child: _select(
  690 + '价格',
  691 + showPrice == null || showPrice == ''
  692 + ? '点击配置菜品价格'
  693 + : showPrice, () async {
  694 + Map object =
  695 + await NavigatorUtil.goMenuSetPricePage(
  696 + context, {'object': data});
  697 + if (object != null) {
  698 + //选择了
  699 + data = object['data'];
  700 + print(data);
  701 +
  702 + outerloop:
  703 + for (int i = 0; i < data.length; i++) {
  704 + MenuUnitModel menumodel = data[i];
  705 + if (menumodel.select) {
  706 + showPrice = menumodel.priceC.text;
  707 + break outerloop;
  708 + }
  709 + }
  710 + setState(() {});
  711 + }
  712 + })),
  713 + Padding(
  714 + padding: EdgeInsets.only(left: w(16)),
  715 + child: MyDivider(
  716 + double.infinity,
  717 + w(0.5),
  718 + color: MyColours.color_E7E7E7,
  719 + )),
  720 + Container(
  721 + height: w(48),
  722 + padding: EdgeInsets.symmetric(
  723 + horizontal: ScreenUtil().setWidth(32),
  724 + ),
  725 + child: _select(
  726 + '做法',
  727 + selectPracticeShow == null ||
  728 + selectPracticeShow == ''
  729 + ? '点击配置菜品做法'
  730 + : selectPracticeShow, () async {
  731 + Map object =
  732 + await NavigatorUtil.goMenuDishMethodPage(
  733 + context, selectPracticeIds);
  734 + if (object != null) {
  735 + selectPractice = object['select_practice'];
  736 + selectPracticeShow = '';
  737 + selectPracticeIds = '';
  738 + selectPractice.forEach((element) {
  739 + if (element.select) {
  740 + selectPracticeShow +=
  741 + '${element.name}、';
  742 + selectPracticeIds += '${element.id},';
  743 + }
  744 + });
  745 + if (selectPracticeShow.endsWith('、')) {
  746 + selectPracticeShow =
  747 + selectPracticeShow.substring(
  748 + 0, selectPracticeShow.length - 1);
  749 + }
  750 + if (selectPracticeIds.endsWith(',')) {
  751 + selectPracticeIds =
  752 + selectPracticeIds.substring(
  753 + 0, selectPracticeIds.length - 1);
  754 + }
  755 + setState(() {});
  756 + }
  757 + }, needStar: false)),
  758 + Padding(
  759 + padding: EdgeInsets.only(left: w(16)),
  760 + child: MyDivider(
  761 + double.infinity,
  762 + w(0.5),
  763 + color: MyColours.color_E7E7E7,
  764 + )),
  765 + Container(
  766 + height: w(48),
  767 + padding: EdgeInsets.symmetric(
  768 + horizontal: ScreenUtil().setWidth(32),
  769 + ),
  770 + child: _textfield(
  771 + '味型', '如咸鲜、香辣等,向客户介绍菜品味型', tasteC, null, '',
  772 + fontsize: 12,
  773 + needStar: false,
  774 + inputType: TextInputType.text)),
  775 + Padding(
  776 + padding: EdgeInsets.only(left: w(16)),
  777 + child: MyDivider(
  778 + double.infinity,
  779 + w(0.5),
  780 + color: MyColours.color_E7E7E7,
  781 + )),
  782 + Container(
  783 + height: w(48),
  784 + padding: EdgeInsets.symmetric(
  785 + horizontal: ScreenUtil().setWidth(32),
  786 + ),
  787 + child: _textfield('烹调',
  788 + '如炙烤、熬煮、爆炒等,向客户介绍菜品烹调方法', cooksC, null, '',
  789 + fontsize: 12,
  790 + needStar: false,
  791 + inputType: TextInputType.text)),
  792 + Padding(
  793 + padding: EdgeInsets.only(left: w(16)),
  794 + child: MyDivider(
  795 + double.infinity,
  796 + w(0.5),
  797 + color: MyColours.color_E7E7E7,
  798 + )),
  799 + _explain('菜品简介', '请输入菜品简介', introduceC, null)
  800 + ],
  801 + ),
  802 + )),
  803 + Padding(
  804 + padding: EdgeInsets.fromLTRB(
  805 + ScreenUtil().setWidth(40),
  806 + 0,
  807 + ScreenUtil().setWidth(40),
  808 + ScreenUtil().setWidth(40)),
  809 + child: RoundButton(
  810 + onPressed: () async {
612 FocusScope.of(context) 811 FocusScope.of(context)
613 .requestFocus(FocusNode()); //点击空白处隐藏键盘 812 .requestFocus(FocusNode()); //点击空白处隐藏键盘
614 - DialogUtil.showSelectCusmanDialog(  
615 - context, categoryStrList, (value) {  
616 - if (value != null) {  
617 - setState(() {  
618 - categoryStr = categoryStrList[value.first];  
619 - });  
620 - }  
621 - }, selecteds: [  
622 - categoryStrList.indexOf(categoryStr)  
623 - ]).then((value) {});  
624 - })),  
625 - Padding(  
626 - padding: EdgeInsets.only(left: w(16)),  
627 - child: MyDivider(  
628 - double.infinity,  
629 - w(0.5),  
630 - color: MyColours.color_E7E7E7,  
631 - )),  
632 - Container(  
633 - height: w(48),  
634 - padding: EdgeInsets.symmetric(  
635 - horizontal: ScreenUtil().setWidth(32),  
636 - ),  
637 - child: _select('价格', '点击配置菜品价格', () async {  
638 - Map object =  
639 - await NavigatorUtil.goMenuSetPricePage(  
640 - context);  
641 - if (object != null) {  
642 - //选择了  
643 - }  
644 - })),  
645 - Padding(  
646 - padding: EdgeInsets.only(left: w(16)),  
647 - child: MyDivider(  
648 - double.infinity,  
649 - w(0.5),  
650 - color: MyColours.color_E7E7E7,  
651 - )),  
652 - Container(  
653 - height: w(48),  
654 - padding: EdgeInsets.symmetric(  
655 - horizontal: ScreenUtil().setWidth(32),  
656 - ),  
657 - child: _select('做法', '点击配置菜品做法', () async {  
658 - await NavigatorUtil.goMenuDishMethodPage(context);  
659 - }, needStar: false)),  
660 - Padding(  
661 - padding: EdgeInsets.only(left: w(16)),  
662 - child: MyDivider(  
663 - double.infinity,  
664 - w(0.5),  
665 - color: MyColours.color_E7E7E7,  
666 - )),  
667 - Container(  
668 - height: w(48),  
669 - padding: EdgeInsets.symmetric(  
670 - horizontal: ScreenUtil().setWidth(32),  
671 - ),  
672 - child: _textfield(  
673 - '味型', '如咸鲜、香辣等,向客户介绍菜品味型', null, null, '',  
674 - fontsize: 12,  
675 - needStar: false,  
676 - inputType: TextInputType.text)),  
677 - Padding(  
678 - padding: EdgeInsets.only(left: w(16)),  
679 - child: MyDivider(  
680 - double.infinity,  
681 - w(0.5),  
682 - color: MyColours.color_E7E7E7,  
683 - )),  
684 - Container(  
685 - height: w(48),  
686 - padding: EdgeInsets.symmetric(  
687 - horizontal: ScreenUtil().setWidth(32),  
688 - ),  
689 - child: _textfield(  
690 - '烹调', '如炙烤、熬煮、爆炒等,向客户介绍菜品烹调方法', null, null, '',  
691 - fontsize: 12, needStar: false)),  
692 - Padding(  
693 - padding: EdgeInsets.only(left: w(16)),  
694 - child: MyDivider(  
695 - double.infinity,  
696 - w(0.5),  
697 - color: MyColours.color_E7E7E7,  
698 - )),  
699 - _explain('菜品简介', '请输入菜品简介', null, null)  
700 - ],  
701 - ),  
702 - )),  
703 - Padding(  
704 - padding: EdgeInsets.fromLTRB(ScreenUtil().setWidth(40), 0,  
705 - ScreenUtil().setWidth(40), ScreenUtil().setWidth(40)),  
706 - child: RoundButton(  
707 - onPressed: () async {  
708 - FocusScope.of(context)  
709 - .requestFocus(FocusNode()); //点击空白处隐藏键盘  
710 - _addCookbook();  
711 - },  
712 - text: '保存',  
713 - fontSize: 34,  
714 - isBold: false,  
715 - height: ScreenUtil().setWidth(80),  
716 - width: double.infinity,  
717 - radius: ScreenUtil().setWidth(10),  
718 - ))  
719 - ])))); 813 + _addCookbook();
  814 + },
  815 + text: '保存',
  816 + fontSize: 34,
  817 + isBold: false,
  818 + height: ScreenUtil().setWidth(80),
  819 + width: double.infinity,
  820 + radius: ScreenUtil().setWidth(10),
  821 + ))
  822 + ])))));
720 } 823 }
721 } 824 }
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
  2 +import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
2 import 'package:flutter_screenutil/flutter_screenutil.dart'; 3 import 'package:flutter_screenutil/flutter_screenutil.dart';
  4 +import 'package:one_key/models/cookbook_practice_model.dart';
3 import 'package:one_key/res/colors.dart'; 5 import 'package:one_key/res/colors.dart';
4 import 'package:one_key/utils/dialog_util.dart'; 6 import 'package:one_key/utils/dialog_util.dart';
5 import 'package:one_key/widgets/system_app_bar.dart'; 7 import 'package:one_key/widgets/system_app_bar.dart';
  8 +import 'package:provider/provider.dart';
6 9
  10 +import '../../../constant/state.dart';
  11 +import '../../../provider/menu_provider.dart';
  12 +import '../../../provider/user_model.dart';
7 import '../../../utils/screen_util.dart'; 13 import '../../../utils/screen_util.dart';
8 import '../../../utils/utils.dart'; 14 import '../../../utils/utils.dart';
  15 +import '../../../widgets/page_exception.dart';
9 import '../../../widgets/round_button.dart'; 16 import '../../../widgets/round_button.dart';
10 17
11 /** 18 /**
12 * 菜品做法选择 19 * 菜品做法选择
13 */ 20 */
14 class MenuDishMethodPage extends StatefulWidget { 21 class MenuDishMethodPage extends StatefulWidget {
15 - MenuDishMethodPage({Key key}) : super(key: key); 22 + final String selectPracticeIds;
  23 + MenuDishMethodPage({Key key, this.selectPracticeIds}) : super(key: key);
16 24
17 @override 25 @override
18 _MenuDishMethodPageState createState() => _MenuDishMethodPageState(); 26 _MenuDishMethodPageState createState() => _MenuDishMethodPageState();
19 } 27 }
20 28
21 class _MenuDishMethodPageState extends State<MenuDishMethodPage> { 29 class _MenuDishMethodPageState extends State<MenuDishMethodPage> {
22 - List data = ['清蒸', '爆炒', '红烧', '椒盐']; 30 + MenuManageProvider menuManageProvider;
  31 +
  32 + @override
  33 + void initState() {
  34 + super.initState();
  35 +
  36 + WidgetsBinding.instance.addPostFrameCallback((_) {
  37 + getSellerPracticeById();
  38 + });
  39 + }
  40 +
  41 + getSellerPracticeById() async {
  42 + Map<String, String> params = {
  43 + 'sellerid': Provider.of<UserModel>(context, listen: false).user.sellerid
  44 + };
  45 + await menuManageProvider.getSellerPracticeById(context, params);
  46 +
  47 + if (menuManageProvider.dataPractice.length > 0) {
  48 + // //如果第一次进来
  49 + if (widget.selectPracticeIds != null) {
  50 + List<String> ids = widget.selectPracticeIds.split(',');
  51 + menuManageProvider.dataPractice.forEach((element) {
  52 + if (ids.contains(element.id)) {
  53 + element.select = true;
  54 + }
  55 + });
  56 + }
  57 + // else {
  58 + // String specid = App.sp.getString('specid');
  59 + // if (specid != null) {
  60 + // menuManageProvider.specSunModel.forEach((element) {
  61 + // if (element.id == specid) {
  62 + // element.select = true;
  63 + // }
  64 + // });
  65 + // }
  66 + // }
  67 + }
  68 + setState(() {});
  69 + }
  70 +
23 @override 71 @override
24 Widget build(BuildContext context) { 72 Widget build(BuildContext context) {
25 - return Scaffold( 73 + menuManageProvider = Provider.of<MenuManageProvider>(context, listen: true);
  74 + return KeyboardDismissOnTap(
  75 + child: Scaffold(
26 backgroundColor: MyColours.color_DBDBDB, 76 backgroundColor: MyColours.color_DBDBDB,
27 appBar: SystemAppBar('菜品做法选择'), 77 appBar: SystemAppBar('菜品做法选择'),
28 body: Column( 78 body: Column(
29 children: [ 79 children: [
30 - Container(  
31 - width: double.infinity,  
32 - height: w(48),  
33 - padding: EdgeInsets.symmetric(horizontal: w(16)),  
34 - alignment: Alignment.centerLeft,  
35 - color: MyColours.color_ffffff,  
36 - child: Text(  
37 - '选择当前菜品支持选择的做法:',  
38 - style: TextStyle(  
39 - fontSize: font(16), color: MyColours.color_515151),  
40 - )),  
41 - Expanded(  
42 - child: ListView.builder(  
43 - itemCount: data.length + 1,  
44 - shrinkWrap: true,  
45 - itemBuilder: (context, index) {  
46 - if ((index == 0 && data.length == 0) ||  
47 - data.length == index) {  
48 - return InkWell(  
49 - onTap: () {  
50 - DialogUtil.textfeildAlertDialog(context,  
51 - title: '添加做法',  
52 - hintText: '输入菜品做法名称', rCallback: (name) {  
53 - //确定添加  
54 - setState(() {  
55 - data.add(name);  
56 - });  
57 - });  
58 - },  
59 - child: Container(  
60 - height: w(64), 80 + if (menuManageProvider.pageStatePractice == PageState.Success ||
  81 + menuManageProvider.pageStatePractice == PageState.Empty)
  82 + Container(
  83 + width: double.infinity,
  84 + height: w(48),
  85 + padding: EdgeInsets.symmetric(horizontal: w(16)),
  86 + alignment: Alignment.centerLeft,
  87 + color: MyColours.color_ffffff,
  88 + child: Text(
  89 + '选择当前菜品支持选择的做法:',
  90 + style: TextStyle(
  91 + fontSize: font(16), color: MyColours.color_515151),
  92 + )),
  93 + Consumer<MenuManageProvider>(builder: (context, model, _) {
  94 + if (model.pageStatePractice != PageState.Success) {
  95 + return Expanded(
  96 + child: ExceptionPage(
  97 + pageState: model.pageStatePractice,
  98 + callback: () {
  99 + // offset = 0;
  100 + getSellerPracticeById();
  101 + },
  102 + emptyMsg: "做法数据为哦",
  103 + emptyImg: "empty_search",
  104 + showMsg: "加载中,请稍后...",
  105 + ));
  106 + } else {
  107 + return Expanded(
  108 + child: ListView.builder(
  109 + itemCount: model.dataPractice.length + 1,
  110 + shrinkWrap: true,
  111 + itemBuilder: (context, index) {
  112 + if ((index == 0 && model.dataPractice.length == 0) ||
  113 + model.dataPractice.length == index) {
  114 + return InkWell(
  115 + onTap: () {
  116 + DialogUtil.textfeildAlertDialog(context,
  117 + title: '添加做法', hintText: '输入菜品做法名称',
  118 + rCallback: (name) async {
  119 + Map<String, String> pramas = {
  120 + 'sellerid': Provider.of<UserModel>(context,
  121 + listen: false)
  122 + .user
  123 + .sellerid,
  124 + 'name': name
  125 + };
  126 + bool success = await menuManageProvider
  127 + .addPractice(context, pramas);
  128 + if (success) {
  129 + //添加成功
  130 + Utils.showToast('添加成功');
  131 + getSellerPracticeById();
  132 + }
  133 + });
  134 + },
  135 + child: Container(
  136 + height: w(64),
  137 + color: MyColours.color_ffffff,
  138 + margin: EdgeInsets.only(top: w(10)),
  139 + alignment: Alignment.center,
  140 + child: Text(
  141 + '添加做法',
  142 + style: TextStyle(
  143 + fontSize: font(24),
  144 + color: MyColours.color_000000),
  145 + ),
  146 + ));
  147 + }
  148 + return Container(
  149 + height: w(48),
61 color: MyColours.color_ffffff, 150 color: MyColours.color_ffffff,
62 margin: EdgeInsets.only(top: w(10)), 151 margin: EdgeInsets.only(top: w(10)),
63 - alignment: Alignment.center,  
64 - child: Text(  
65 - '添加做法',  
66 - style: TextStyle(  
67 - fontSize: font(24),  
68 - color: MyColours.color_000000),  
69 - ),  
70 - )); 152 + padding: EdgeInsets.symmetric(horizontal: w(16)),
  153 + child: Row(
  154 + mainAxisAlignment: MainAxisAlignment.spaceBetween,
  155 + children: [
  156 + Text(
  157 + model.dataPractice[index].name,
  158 + style: TextStyle(
  159 + fontSize: font(16),
  160 + color: MyColours.color_515151),
  161 + ),
  162 + InkWell(
  163 + onTap: () {
  164 + model.dataPractice[index].select =
  165 + !model.dataPractice[index].select;
  166 +
  167 + setState(() {});
  168 + },
  169 + child: Image.asset(
  170 + model.dataPractice[index].select
  171 + ? Utils.getImgPath('swich_on')
  172 + : Utils.getImgPath('swich_off'),
  173 + width: w(44),
  174 + height: w(24),
  175 + ))
  176 + ],
  177 + ));
  178 + }));
  179 + }
  180 + }),
  181 + if (menuManageProvider.pageStatePractice == PageState.Success ||
  182 + menuManageProvider.pageStatePractice == PageState.Empty)
  183 + Container(
  184 + color: MyColours.color_ffffff,
  185 + padding: EdgeInsets.fromLTRB(w(45), w(13), w(45), w(26)),
  186 + child: RoundButton(
  187 + onPressed: () async {
  188 + // FocusScope.of(context)
  189 + // .requestFocus(FocusNode()); //点击空白处隐藏键盘
  190 + // // _addCookbook();
  191 + List<CookbookPracticeSunModel> selectPractice = [];
  192 + menuManageProvider.dataPractice.forEach((element) {
  193 + if (element.select) {
  194 + selectPractice.add(element);
  195 + }
  196 + });
  197 + if (selectPractice.length == 0) {
  198 + Utils.showToast('请选择做法!');
  199 + return;
71 } 200 }
72 - return Container(  
73 - height: w(48),  
74 - color: MyColours.color_ffffff,  
75 - margin: EdgeInsets.only(top: w(10)),  
76 - padding: EdgeInsets.symmetric(horizontal: w(16)),  
77 - child: Row(  
78 - mainAxisAlignment: MainAxisAlignment.spaceBetween,  
79 - children: [  
80 - Text(  
81 - data[index],  
82 - style: TextStyle(  
83 - fontSize: font(16),  
84 - color: MyColours.color_515151),  
85 - ),  
86 - InkWell(  
87 - onTap: () {  
88 - setState(() {});  
89 - },  
90 - child: Image.asset(  
91 - true  
92 - ? Utils.getImgPath('swich_on')  
93 - : Utils.getImgPath('swich_off'),  
94 - width: w(44),  
95 - height: w(24),  
96 - ))  
97 - ],  
98 - ));  
99 - })),  
100 - Container(  
101 - color: MyColours.color_ffffff,  
102 - padding: EdgeInsets.fromLTRB(w(45), w(13), w(45), w(26)),  
103 - child: RoundButton(  
104 - onPressed: () async {  
105 - FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘  
106 - // _addCookbook();  
107 - },  
108 - text: '保存',  
109 - fontSize: 34,  
110 - isBold: false,  
111 - height: ScreenUtil().setWidth(80),  
112 - width: double.infinity,  
113 - radius: ScreenUtil().setWidth(10),  
114 - )) 201 +
  202 + Navigator.pop(context, {'select_practice': selectPractice});
  203 + },
  204 + text: '保存',
  205 + fontSize: 34,
  206 + isBold: false,
  207 + height: ScreenUtil().setWidth(80),
  208 + width: double.infinity,
  209 + radius: ScreenUtil().setWidth(10),
  210 + ))
115 ], 211 ],
116 ), 212 ),
117 - ); 213 + ));
118 } 214 }
119 } 215 }
@@ -5,6 +5,8 @@ import 'package:one_key/widgets/round_button.dart'; @@ -5,6 +5,8 @@ import 'package:one_key/widgets/round_button.dart';
5 import 'package:one_key/widgets/system_app_bar.dart'; 5 import 'package:one_key/widgets/system_app_bar.dart';
6 import 'package:one_key/widgets/v_empty_view.dart'; 6 import 'package:one_key/widgets/v_empty_view.dart';
7 7
  8 +import '../../../app.dart';
  9 +import '../../../models/menu_unit_model.dart';
8 import '../../../res/colors.dart'; 10 import '../../../res/colors.dart';
9 import '../../../utils/screen_util.dart'; 11 import '../../../utils/screen_util.dart';
10 import '../../../utils/utils.dart'; 12 import '../../../utils/utils.dart';
@@ -16,16 +18,29 @@ import '../../../widgets/h_empty_view.dart'; @@ -16,16 +18,29 @@ import '../../../widgets/h_empty_view.dart';
16 * 配置规格和价格 18 * 配置规格和价格
17 */ 19 */
18 class MenuSetPricePage extends StatefulWidget { 20 class MenuSetPricePage extends StatefulWidget {
19 - MenuSetPricePage({Key key}) : super(key: key); 21 + final List<MenuUnitModel> data;
  22 + MenuSetPricePage({Key key, this.data}) : super(key: key);
20 23
21 @override 24 @override
22 _MenuSetPricePageState createState() => _MenuSetPricePageState(); 25 _MenuSetPricePageState createState() => _MenuSetPricePageState();
23 } 26 }
24 27
25 class _MenuSetPricePageState extends State<MenuSetPricePage> { 28 class _MenuSetPricePageState extends State<MenuSetPricePage> {
26 - bool swichState = false; 29 + List<MenuUnitModel> data = [];
27 30
28 - List data = ['', '']; 31 + @override
  32 + void initState() {
  33 + // TODO: implement initState
  34 + super.initState();
  35 + if (widget.data == null || widget.data.length == 0) {
  36 + MenuUnitModel menuUnitModel = MenuUnitModel();
  37 + // menuUnitModel.status = '1';
  38 + menuUnitModel.select = true;
  39 + data.add(menuUnitModel);
  40 + } else {
  41 + data = widget.data;
  42 + }
  43 + }
29 44
30 ///输入框 45 ///输入框
31 Widget _textfield( 46 Widget _textfield(
@@ -192,7 +207,15 @@ class _MenuSetPricePageState extends State<MenuSetPricePage> { @@ -192,7 +207,15 @@ class _MenuSetPricePageState extends State<MenuSetPricePage> {
192 index == data.length) { 207 index == data.length) {
193 return InkWell( 208 return InkWell(
194 onTap: () { 209 onTap: () {
195 - data.add(''); 210 + MenuUnitModel menuUnitModel = MenuUnitModel();
  211 + menuUnitModel.select = false;
  212 + String specid = App.sp.getString('specid');
  213 + String specs = App.sp.getString('specs');
  214 + if (specid != null) {
  215 + menuUnitModel.specs = specs;
  216 + menuUnitModel.specid = specid;
  217 + }
  218 + data.add(menuUnitModel);
196 setState(() {}); 219 setState(() {});
197 }, 220 },
198 child: Container( 221 child: Container(
@@ -224,7 +247,7 @@ class _MenuSetPricePageState extends State<MenuSetPricePage> { @@ -224,7 +247,7 @@ class _MenuSetPricePageState extends State<MenuSetPricePage> {
224 InkWell( 247 InkWell(
225 onTap: () { 248 onTap: () {
226 setState(() { 249 setState(() {
227 - swichState = !swichState; 250 + data[index].select = !data[index].select;
228 }); 251 });
229 }, 252 },
230 child: Container( 253 child: Container(
@@ -245,7 +268,7 @@ class _MenuSetPricePageState extends State<MenuSetPricePage> { @@ -245,7 +268,7 @@ class _MenuSetPricePageState extends State<MenuSetPricePage> {
245 ), 268 ),
246 ), 269 ),
247 Image.asset( 270 Image.asset(
248 - swichState 271 + data[index].select
249 ? Utils.getImgPath('swich_on') 272 ? Utils.getImgPath('swich_on')
250 : Utils.getImgPath('swich_off'), 273 : Utils.getImgPath('swich_off'),
251 width: w(44), 274 width: w(44),
@@ -265,8 +288,30 @@ class _MenuSetPricePageState extends State<MenuSetPricePage> { @@ -265,8 +288,30 @@ class _MenuSetPricePageState extends State<MenuSetPricePage> {
265 height: w(48), 288 height: w(48),
266 padding: 289 padding:
267 EdgeInsets.symmetric(horizontal: w(16)), 290 EdgeInsets.symmetric(horizontal: w(16)),
268 - child: _select('销售单位', '请选择销售单位', () async {  
269 - await NavigatorUtil.goMenuUnitPage(context); 291 + child: _select(
  292 + '销售单位',
  293 + data[index].specs == null &&
  294 + data[index].specid == null
  295 + ? '请选择销售单位'
  296 + : data[index].specs, () async {
  297 + Map object =
  298 + await NavigatorUtil.goMenuUnitPage(
  299 + context, data[index].specid);
  300 + if (object != null) {
  301 + // 'specs': menuManageProvider
  302 + // .specSunModel[index].name,
  303 + // 'specid':
  304 + // menuManageProvider.specSunModel[index].id
  305 + if (object.containsKey('specs')) {
  306 + data[index].specs = object['specs'];
  307 + data[index].specid = object['specid'];
  308 + App.sp.setString(
  309 + 'specid', object['specid']);
  310 + App.sp
  311 + .setString('specs', object['specs']);
  312 + setState(() {});
  313 + }
  314 + }
270 }, needStar: false)), 315 }, needStar: false)),
271 Padding( 316 Padding(
272 padding: EdgeInsets.only(left: w(16)), 317 padding: EdgeInsets.only(left: w(16)),
@@ -279,8 +324,9 @@ class _MenuSetPricePageState extends State<MenuSetPricePage> { @@ -279,8 +324,9 @@ class _MenuSetPricePageState extends State<MenuSetPricePage> {
279 height: w(48), 324 height: w(48),
280 padding: 325 padding:
281 EdgeInsets.symmetric(horizontal: w(16)), 326 EdgeInsets.symmetric(horizontal: w(16)),
282 - child:  
283 - _textfield('售价', '点击输入售价', null, null, '')), 327 + child: _textfield('售价', '点击输入售价',
  328 + data[index].priceC, null, '',
  329 + needStar: false)),
284 Padding( 330 Padding(
285 padding: EdgeInsets.only(left: w(16)), 331 padding: EdgeInsets.only(left: w(16)),
286 child: MyDivider( 332 child: MyDivider(
@@ -292,8 +338,9 @@ class _MenuSetPricePageState extends State<MenuSetPricePage> { @@ -292,8 +338,9 @@ class _MenuSetPricePageState extends State<MenuSetPricePage> {
292 height: w(48), 338 height: w(48),
293 padding: 339 padding:
294 EdgeInsets.symmetric(horizontal: w(16)), 340 EdgeInsets.symmetric(horizontal: w(16)),
295 - child: _textfield(  
296 - '会员价格', '点击输入会员价格', null, null, '')), 341 + child: _textfield('会员价格', '点击输入会员价格',
  342 + data[index].memberPriceC, null, '',
  343 + needStar: false)),
297 ], 344 ],
298 ), 345 ),
299 ); 346 );
@@ -309,7 +356,39 @@ class _MenuSetPricePageState extends State<MenuSetPricePage> { @@ -309,7 +356,39 @@ class _MenuSetPricePageState extends State<MenuSetPricePage> {
309 radius: r(5), 356 radius: r(5),
310 fontSize: 32, 357 fontSize: 32,
311 isBold: true, 358 isBold: true,
312 - onPressed: () {}, 359 + onPressed: () {
  360 + data.forEach((element) {
  361 + element.price = element.priceC.text;
  362 + element.memberPrice = element.memberPriceC.text;
  363 + });
  364 + bool isContains = data.any((element) => element.select);
  365 + if (!isContains) {
  366 + Utils.showToast('请至少启用一个规格!');
  367 + return;
  368 + } else {
  369 + bool can = true;
  370 + outerloop:
  371 + for (int i = 0; i < data.length; i++) {
  372 + MenuUnitModel element = data[i];
  373 +
  374 + if (element.select) {
  375 + if (element.specid == null) {
  376 + Utils.showToast('请完善规格销售单位!');
  377 + can = false;
  378 + break outerloop;
  379 + }
  380 + if (element.price == null || element.price == '') {
  381 + Utils.showToast('请完善规格售价!');
  382 + can = false;
  383 + break outerloop;
  384 + }
  385 + }
  386 + }
  387 + if (can) {
  388 + Navigator.pop(context, {'data': data});
  389 + }
  390 + }
  391 + },
313 ), 392 ),
314 ) 393 )
315 ], 394 ],
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
  2 +import 'package:one_key/provider/menu_provider.dart';
  3 +import 'package:one_key/provider/user_model.dart';
2 import 'package:one_key/res/colors.dart'; 4 import 'package:one_key/res/colors.dart';
3 import 'package:one_key/utils/dialog_util.dart'; 5 import 'package:one_key/utils/dialog_util.dart';
4 import 'package:one_key/utils/utils.dart'; 6 import 'package:one_key/utils/utils.dart';
5 import 'package:one_key/widgets/h_empty_view.dart'; 7 import 'package:one_key/widgets/h_empty_view.dart';
6 import 'package:one_key/widgets/system_app_bar.dart'; 8 import 'package:one_key/widgets/system_app_bar.dart';
  9 +import 'package:provider/provider.dart';
7 10
  11 +import '../../../app.dart';
  12 +import '../../../constant/state.dart';
8 import '../../../utils/screen_util.dart'; 13 import '../../../utils/screen_util.dart';
  14 +import '../../../widgets/page_exception.dart';
9 15
10 /** 16 /**
11 * 销售单位 份、位、晚 17 * 销售单位 份、位、晚
12 */ 18 */
13 19
14 class MenuUnitPage extends StatefulWidget { 20 class MenuUnitPage extends StatefulWidget {
15 - MenuUnitPage({Key key}) : super(key: key); 21 + final String specid;
  22 +
  23 + MenuUnitPage({Key key, this.specid}) : super(key: key);
16 24
17 @override 25 @override
18 _MenuUnitPageState createState() => _MenuUnitPageState(); 26 _MenuUnitPageState createState() => _MenuUnitPageState();
19 } 27 }
20 28
21 class _MenuUnitPageState extends State<MenuUnitPage> { 29 class _MenuUnitPageState extends State<MenuUnitPage> {
22 - List data = ['位', '份'];  
23 - bool select = true; 30 + // List data = ['位', '份'];
  31 + // bool select = true;
  32 +
  33 + MenuManageProvider menuManageProvider;
  34 +
  35 + @override
  36 + void initState() {
  37 + super.initState();
  38 + WidgetsBinding.instance.addPostFrameCallback((_) {
  39 + getSpecBySellerid();
  40 + });
  41 + }
  42 +
  43 + getSpecBySellerid() async {
  44 + Map<String, String> params = {
  45 + 'sellerid': Provider.of<UserModel>(context, listen: false).user.sellerid
  46 + };
  47 + await menuManageProvider.getSpecBySellerid(context, params);
  48 +
  49 + if (menuManageProvider.specSunModel.length > 0) {
  50 + //如果第一次进来
  51 + if (widget.specid != null) {
  52 + menuManageProvider.specSunModel.forEach((element) {
  53 + if (element.id == widget.specid) {
  54 + element.select = true;
  55 + }
  56 + });
  57 + } else {
  58 + String specid = App.sp.getString('specid');
  59 + if (specid != null) {
  60 + menuManageProvider.specSunModel.forEach((element) {
  61 + if (element.id == specid) {
  62 + element.select = true;
  63 + }
  64 + });
  65 + }
  66 + }
  67 + }
  68 + setState(() {});
  69 + }
  70 +
24 @override 71 @override
25 Widget build(BuildContext context) { 72 Widget build(BuildContext context) {
  73 + menuManageProvider =
  74 + Provider.of<MenuManageProvider>(context, listen: false);
26 return Scaffold( 75 return Scaffold(
27 - backgroundColor: MyColours.color_DBDBDB,  
28 - appBar: SystemAppBar('销售单位'),  
29 - body: ListView.builder(  
30 - itemCount: data.length + 1,  
31 - itemBuilder: (context, index) {  
32 - if ((index == 0 && data.length == 0) || index == data.length) {  
33 - return Container(  
34 - height: w(48),  
35 - margin: EdgeInsets.only(top: w(10), left: w(10), right: w(10)),  
36 - decoration: BoxDecoration(  
37 - color: MyColours.color_ffffff,  
38 - border:  
39 - Border.all(width: w(1), color: MyColours.color_515151),  
40 - borderRadius: BorderRadius.circular(r(5))),  
41 - child: Row(  
42 - mainAxisAlignment: MainAxisAlignment.center,  
43 - children: [  
44 - Image.asset(  
45 - Utils.getImgPath('f_add_image'),  
46 - width: w(15),  
47 - ),  
48 - HEmptyView(22),  
49 - Text(  
50 - '添加新规格',  
51 - textAlign: TextAlign.center,  
52 - style: TextStyle(  
53 - color: MyColours.color_515151, fontSize: font(16)), 76 + backgroundColor: MyColours.color_DBDBDB,
  77 + appBar: SystemAppBar('销售单位'),
  78 + body: Column(
  79 + children: [
  80 + Consumer<MenuManageProvider>(builder: (context, model, _) {
  81 + if (model.pageStateUnit != PageState.Success) {
  82 + return Expanded(
  83 + child: ExceptionPage(
  84 + pageState: model.pageStateUnit,
  85 + callback: () {
  86 + // offset = 0;
  87 + getSpecBySellerid();
  88 + },
  89 + emptyMsg: "销售单位数据为哦",
  90 + emptyImg: "empty_search",
  91 + showMsg: "加载中,请稍后...",
  92 + ));
  93 + } else {
  94 + return Expanded(
  95 + child: ListView.builder(
  96 + shrinkWrap: true,
  97 + itemCount: menuManageProvider.specSunModel.length,
  98 + itemBuilder: (context, index) {
  99 + // if ((index == 0 &&
  100 + // menuManageProvider.specSunModel.length == 0) ||
  101 + // index == menuManageProvider.specSunModel.length) {
  102 + // return Container(
  103 + // height: w(48),
  104 + // margin: EdgeInsets.only(
  105 + // top: w(10), left: w(10), right: w(10)),
  106 + // decoration: BoxDecoration(
  107 + // color: MyColours.color_ffffff,
  108 + // border: Border.all(
  109 + // width: w(1), color: MyColours.color_515151),
  110 + // borderRadius: BorderRadius.circular(r(5))),
  111 + // child: Row(
  112 + // mainAxisAlignment: MainAxisAlignment.center,
  113 + // children: [
  114 + // Image.asset(
  115 + // Utils.getImgPath('f_add_image'),
  116 + // width: w(15),
  117 + // ),
  118 + // HEmptyView(22),
  119 + // Text(
  120 + // '添加新规格',
  121 + // textAlign: TextAlign.center,
  122 + // style: TextStyle(
  123 + // color: MyColours.color_515151,
  124 + // fontSize: font(16)),
  125 + // ),
  126 + // ],
  127 + // ),
  128 + // );
  129 + // }
  130 + return InkWell(
  131 + onTap: () {
  132 + // menuManageProvider.specSunModel
  133 + // .forEach((element) {
  134 + // element.select = false;
  135 + // });
  136 + // menuManageProvider.specSunModel[index].select =
  137 + // true;
  138 + // setState(() {});
  139 + Navigator.pop(context, {
  140 + 'specs': menuManageProvider
  141 + .specSunModel[index].name,
  142 + 'specid':
  143 + menuManageProvider.specSunModel[index].id
  144 + });
  145 + },
  146 + child: Container(
  147 + height: w(48),
  148 + margin: EdgeInsets.only(
  149 + top: w(10), left: w(10), right: w(10)),
  150 + decoration: BoxDecoration(
  151 + color: menuManageProvider
  152 + .specSunModel[index].select
  153 + ? MyColours.color_438E93
  154 + : MyColours.color_ffffff,
  155 + border: Border.all(
  156 + width: w(1),
  157 + color: menuManageProvider
  158 + .specSunModel[index].select
  159 + ? MyColours.color_438E93
  160 + : MyColours.color_515151),
  161 + borderRadius: BorderRadius.circular(r(5))),
  162 + child: Row(
  163 + children: [
  164 + Expanded(
  165 + child: Text(
  166 + menuManageProvider
  167 + .specSunModel[index].name,
  168 + textAlign: TextAlign.center,
  169 + style: TextStyle(
  170 + color: menuManageProvider
  171 + .specSunModel[index].select
  172 + ? MyColours.color_F8F9FD
  173 + : MyColours.color_515151,
  174 + fontSize: font(16)),
  175 + )),
  176 + InkWell(
  177 + onTap: () {
  178 + DialogUtil.cupertinoAlertDialog(
  179 + context,
  180 + content:
  181 + '确定要删除销售规格“条”吗?删除后,您可以通过添加新规格增加。\n如果有菜品使用该销售单位定价,则无法删除。',
  182 + textAlign: TextAlign.left,
  183 + rCallback: () async {
  184 + //确定删除
  185 + Map<String, String> pramas = {
  186 + 'sellerid':
  187 + Provider.of<UserModel>(
  188 + context,
  189 + listen: false)
  190 + .user
  191 + .sellerid,
  192 + 'name': menuManageProvider
  193 + .specSunModel[index].name
  194 + };
  195 + bool success =
  196 + await menuManageProvider
  197 + .delUnitValue(
  198 + context, pramas);
  199 + if (success) {
  200 + Utils.showToast('删除成功!');
  201 + getSpecBySellerid();
  202 + }
  203 + });
  204 + },
  205 + child: Image.asset(
  206 + Utils.getImgPath('close'),
  207 + width: w(15),
  208 + )),
  209 + HEmptyView(20)
  210 + ],
  211 + ),
  212 + ));
  213 + }));
  214 + }
  215 + }),
  216 + if (menuManageProvider.pageStateUnit == PageState.Success ||
  217 + menuManageProvider.pageStateUnit == PageState.Empty)
  218 + InkWell(
  219 + onTap: () {
  220 + DialogUtil.textfeildAlertDialog(context,
  221 + title: '添加销售单位',
  222 + hintText: '输入销售单位名称', rCallback: (name) async {
  223 + Map<String, String> pramas = {
  224 + 'sellerid':
  225 + Provider.of<UserModel>(context, listen: false)
  226 + .user
  227 + .sellerid,
  228 + 'name': name
  229 + };
  230 + bool success = await menuManageProvider.addUnitValue(
  231 + context, pramas);
  232 + if (success) {
  233 + //添加成功
  234 + Utils.showToast('添加成功');
  235 + getSpecBySellerid();
  236 + }
  237 + });
  238 + },
  239 + child: Container(
  240 + height: w(48),
  241 + margin:
  242 + EdgeInsets.only(top: w(10), left: w(10), right: w(10)),
  243 + decoration: BoxDecoration(
  244 + color: MyColours.color_ffffff,
  245 + border: Border.all(
  246 + width: w(1), color: MyColours.color_515151),
  247 + borderRadius: BorderRadius.circular(r(5))),
  248 + child: Row(
  249 + mainAxisAlignment: MainAxisAlignment.center,
  250 + children: [
  251 + Image.asset(
  252 + Utils.getImgPath('f_add_image'),
  253 + width: w(15),
  254 + ),
  255 + HEmptyView(22),
  256 + Text(
  257 + '添加新规格',
  258 + textAlign: TextAlign.center,
  259 + style: TextStyle(
  260 + color: MyColours.color_515151,
  261 + fontSize: font(16)),
  262 + ),
  263 + ],
54 ), 264 ),
55 - ],  
56 - ),  
57 - );  
58 - }  
59 - return Container(  
60 - height: w(48),  
61 - margin: EdgeInsets.only(top: w(10), left: w(10), right: w(10)),  
62 - decoration: BoxDecoration(  
63 - color:  
64 - select ? MyColours.color_438E93 : MyColours.color_ffffff,  
65 - border: Border.all(  
66 - width: w(1),  
67 - color: select  
68 - ? MyColours.color_438E93  
69 - : MyColours.color_515151),  
70 - borderRadius: BorderRadius.circular(r(5))),  
71 - child: Row(  
72 - children: [  
73 - Expanded(  
74 - child: Text(  
75 - '份',  
76 - textAlign: TextAlign.center,  
77 - style: TextStyle(  
78 - color: select  
79 - ? MyColours.color_F8F9FD  
80 - : MyColours.color_515151,  
81 - fontSize: font(16)),  
82 - )),  
83 - InkWell(  
84 - onTap: () {  
85 - DialogUtil.cupertinoAlertDialog(context,  
86 - content:  
87 - '确定要删除销售规格“条”吗?删除后,您可以通过添加新规格增加。\n如果有菜品使用该销售单位定价,则无法删除。',  
88 - textAlign: TextAlign.left,rCallback: (){  
89 - //确定删除  
90 - });  
91 - },  
92 - child: Image.asset(  
93 - Utils.getImgPath('close'),  
94 - width: w(15),  
95 - )),  
96 - HEmptyView(20)  
97 - ],  
98 - ),  
99 - );  
100 - }),  
101 - ); 265 + ))
  266 + ],
  267 + ));
102 } 268 }
103 } 269 }
@@ -11,6 +11,8 @@ import 'package:one_key/net/dio_util.dart'; @@ -11,6 +11,8 @@ import 'package:one_key/net/dio_util.dart';
11 import 'package:one_key/net/http_url.dart'; 11 import 'package:one_key/net/http_url.dart';
12 import 'package:one_key/utils/utils.dart'; 12 import 'package:one_key/utils/utils.dart';
13 13
  14 +import '../models/cookbook_practice_model.dart';
  15 +
14 class MenuManageProvider extends ChangeNotifier { 16 class MenuManageProvider extends ChangeNotifier {
15 PageState pageState = PageState.Loading; 17 PageState pageState = PageState.Loading;
16 PageState pageStateCategory = PageState.Loading; 18 PageState pageStateCategory = PageState.Loading;
@@ -20,6 +22,10 @@ class MenuManageProvider extends ChangeNotifier { @@ -20,6 +22,10 @@ class MenuManageProvider extends ChangeNotifier {
20 22
21 CookbookOneSunModel cookbookOneSunModel; 23 CookbookOneSunModel cookbookOneSunModel;
22 24
  25 + PageState pageStateUnit = PageState.Loading;
  26 + PageState pageStatePractice = PageState.Loading;
  27 + List<CookbookPracticeSunModel> dataPractice; //做法数据
  28 +
23 /// 获取单个菜品信息 29 /// 获取单个菜品信息
24 getCookbookById(BuildContext context, Map<String, String> params, 30 getCookbookById(BuildContext context, Map<String, String> params,
25 {showLoading = false}) async { 31 {showLoading = false}) async {
@@ -37,6 +43,98 @@ class MenuManageProvider extends ChangeNotifier { @@ -37,6 +43,98 @@ class MenuManageProvider extends ChangeNotifier {
37 } 43 }
38 } 44 }
39 45
  46 + ///商家添加做法
  47 + Future<bool> addPractice(BuildContext context, Map<String, String> params,
  48 + {showLoading = false}) async {
  49 + BaseResp<dynamic> baseResp = await DioUtil()
  50 + .request<dynamic>(context, Method.get, HttpUrl.add_practice,
  51 + data: params, showLoading: showLoading)
  52 + .catchError((error) {
  53 + print(error.toString());
  54 + });
  55 +
  56 + if (baseResp != null && baseResp.code == Constant.status_success) {
  57 + if (baseResp.data != null) {
  58 + return true;
  59 + }
  60 + } else {
  61 + Utils.showToast(baseResp.msg ?? "");
  62 + }
  63 + return false;
  64 + }
  65 +
  66 + // 添加商家计价单位
  67 +
  68 + Future<bool> addUnitValue(BuildContext context, Map<String, String> params,
  69 + {showLoading = false}) async {
  70 + BaseResp<dynamic> baseResp = await DioUtil()
  71 + .request<dynamic>(context, Method.get, HttpUrl.add_unit_value,
  72 + data: params, showLoading: showLoading)
  73 + .catchError((error) {
  74 + print(error.toString());
  75 + });
  76 +
  77 + if (baseResp != null && baseResp.code == Constant.status_success) {
  78 + if (baseResp.data != '' && baseResp.data != null) {
  79 + return true;
  80 + }
  81 + } else {
  82 + Utils.showToast(baseResp.msg ?? "");
  83 + }
  84 + return false;
  85 + }
  86 +
  87 + ///删除商家计价单位
  88 + Future<bool> delUnitValue(BuildContext context, Map<String, String> params,
  89 + {showLoading = false}) async {
  90 + BaseResp<dynamic> baseResp = await DioUtil()
  91 + .request<dynamic>(context, Method.get, HttpUrl.del_unit_value,
  92 + data: params, showLoading: showLoading)
  93 + .catchError((error) {
  94 + print(error.toString());
  95 + });
  96 +
  97 + if (baseResp != null && baseResp.code == Constant.status_success) {
  98 + if (baseResp.data != '' && baseResp.data != null) {
  99 + return true;
  100 + }
  101 + } else {
  102 + Utils.showToast(baseResp.msg ?? "");
  103 + }
  104 + return false;
  105 + }
  106 +
  107 + /// 获取商家默认做法数据
  108 + getSellerPracticeById(BuildContext context, Map<String, String> params,
  109 + {showLoading = false}) async {
  110 + BaseResp<dynamic> baseResp = await DioUtil()
  111 + .request<dynamic>(
  112 + context, Method.get, HttpUrl.get_seller_practice_by_id,
  113 + data: params, showLoading: showLoading)
  114 + .catchError((error) {
  115 + print(error.toString());
  116 + pageStatePractice = PageState.ConnectivityError;
  117 + });
  118 + specSunModel = [];
  119 + if (baseResp != null && baseResp.code == Constant.status_success) {
  120 + if (baseResp.data is List) {
  121 + if (baseResp.data.length > 0) {
  122 + dataPractice =
  123 + CookbookPracticeModel.fromJson(baseResp.responseData).data;
  124 + pageStatePractice = PageState.Success;
  125 + } else {
  126 + pageStatePractice = PageState.Empty;
  127 + }
  128 + } else {
  129 + pageStatePractice = PageState.Empty;
  130 + }
  131 + } else {
  132 + Utils.showToast(baseResp.msg ?? "");
  133 + pageStatePractice = PageState.ConnectivityError;
  134 + }
  135 + notifyListeners();
  136 + }
  137 +
40 /// 获取商家计价单位 138 /// 获取商家计价单位
41 getSpecBySellerid(BuildContext context, Map<String, String> params, 139 getSpecBySellerid(BuildContext context, Map<String, String> params,
42 {showLoading = false}) async { 140 {showLoading = false}) async {
@@ -45,16 +143,23 @@ class MenuManageProvider extends ChangeNotifier { @@ -45,16 +143,23 @@ class MenuManageProvider extends ChangeNotifier {
45 data: params, showLoading: showLoading) 143 data: params, showLoading: showLoading)
46 .catchError((error) { 144 .catchError((error) {
47 print(error.toString()); 145 print(error.toString());
  146 + pageStateUnit = PageState.ConnectivityError;
48 }); 147 });
49 specSunModel = []; 148 specSunModel = [];
50 if (baseResp != null && baseResp.code == Constant.status_success) { 149 if (baseResp != null && baseResp.code == Constant.status_success) {
51 if (baseResp.data is List) { 150 if (baseResp.data is List) {
52 if (baseResp.data.length > 0) { 151 if (baseResp.data.length > 0) {
53 specSunModel = CookbookSpecModel.fromJson(baseResp.responseData).data; 152 specSunModel = CookbookSpecModel.fromJson(baseResp.responseData).data;
  153 + pageStateUnit = PageState.Success;
  154 + } else {
  155 + pageStateUnit = PageState.Empty;
54 } 156 }
55 - } else {} 157 + } else {
  158 + pageStateUnit = PageState.Empty;
  159 + }
56 } else { 160 } else {
57 Utils.showToast(baseResp.msg ?? ""); 161 Utils.showToast(baseResp.msg ?? "");
  162 + pageStateUnit = PageState.ConnectivityError;
58 } 163 }
59 notifyListeners(); 164 notifyListeners();
60 } 165 }
@@ -65,7 +170,8 @@ class MenuManageProvider extends ChangeNotifier { @@ -65,7 +170,8 @@ class MenuManageProvider extends ChangeNotifier {
65 {showLoading = false}) async { 170 {showLoading = false}) async {
66 BaseResp<dynamic> baseResp = await DioUtil() 171 BaseResp<dynamic> baseResp = await DioUtil()
67 .request<dynamic>(context, Method.get, HttpUrl.get_cookbook_by_class, 172 .request<dynamic>(context, Method.get, HttpUrl.get_cookbook_by_class,
68 - data: params, showLoading:pageState == PageState.Loading? false: showLoading) 173 + data: params,
  174 + showLoading: pageState == PageState.Loading ? false : showLoading)
69 .catchError((error) { 175 .catchError((error) {
70 print(error.toString()); 176 print(error.toString());
71 if (error is MyError) { 177 if (error is MyError) {
@@ -109,7 +215,9 @@ class MenuManageProvider extends ChangeNotifier { @@ -109,7 +215,9 @@ class MenuManageProvider extends ChangeNotifier {
109 BaseResp<dynamic> baseResp = await DioUtil() 215 BaseResp<dynamic> baseResp = await DioUtil()
110 .request<dynamic>( 216 .request<dynamic>(
111 context, Method.get, HttpUrl.get_cookbook_by_seller_id, 217 context, Method.get, HttpUrl.get_cookbook_by_seller_id,
112 - data: params, showLoading:pageStateCategory == PageState.Loading?false: showLoading) 218 + data: params,
  219 + showLoading:
  220 + pageStateCategory == PageState.Loading ? false : showLoading)
113 .catchError((error) { 221 .catchError((error) {
114 print(error.toString()); 222 print(error.toString());
115 if (error is MyError) { 223 if (error is MyError) {
@@ -340,6 +340,11 @@ class UserModel with ChangeNotifier { @@ -340,6 +340,11 @@ class UserModel with ChangeNotifier {
340 //退出清空桌位数据 340 //退出清空桌位数据
341 App.sp.remove('table_list'); 341 App.sp.remove('table_list');
342 } 342 }
  343 + if (App.sp.containsKey('specid')) {
  344 + //退出清空销售计价
  345 + App.sp.remove('specid');
  346 + App.sp.remove('specs');
  347 + }
343 348
344 App.sp.setBool("isLogin", false); 349 App.sp.setBool("isLogin", false);
345 // XgFlutterPlugin().stopXg(); 350 // XgFlutterPlugin().stopXg();
@@ -28,6 +28,7 @@ import 'package:sqflite/sqlite_api.dart'; @@ -28,6 +28,7 @@ import 'package:sqflite/sqlite_api.dart';
28 import '../app.dart'; 28 import '../app.dart';
29 import '../models/get_banquet_by_id_new_model.dart'; 29 import '../models/get_banquet_by_id_new_model.dart';
30 import '../models/get_banquet_deposit_model.dart'; 30 import '../models/get_banquet_deposit_model.dart';
  31 +import '../models/menu_unit_model.dart';
31 import '../models/otherset_model.dart'; 32 import '../models/otherset_model.dart';
32 import '../models/out_wine_record_model.dart'; 33 import '../models/out_wine_record_model.dart';
33 import '../models/plan_cook_by_rid_model.dart'; 34 import '../models/plan_cook_by_rid_model.dart';
@@ -1646,27 +1647,31 @@ class NavigatorUtil { @@ -1646,27 +1647,31 @@ class NavigatorUtil {
1646 1647
1647 ///菜单管理------规格和价格设置 1648 ///菜单管理------规格和价格设置
1648 static Future<dynamic> goMenuSetPricePage( 1649 static Future<dynamic> goMenuSetPricePage(
1649 - BuildContext context, { 1650 + BuildContext context, Map object, {
1650 replace = false, 1651 replace = false,
1651 }) { 1652 }) {
1652 - return _navigateTo(context, "${Routes.menu_set_price_page}", 1653 + return _navigateTo(context, "${Routes.menu_set_price_page}?object=${FluroConvertUtils.object2string(object)}",
1653 replace: replace); 1654 replace: replace);
1654 } 1655 }
1655 1656
1656 ///菜单管理-----配置销售单位 1657 ///菜单管理-----配置销售单位
1657 static Future<dynamic> goMenuUnitPage( 1658 static Future<dynamic> goMenuUnitPage(
1658 - BuildContext context, { 1659 + BuildContext context,
  1660 + String specid, {
1659 replace = false, 1661 replace = false,
1660 }) { 1662 }) {
1661 - return _navigateTo(context, "${Routes.menu_unit_page}", replace: replace); 1663 + return _navigateTo(context, "${Routes.menu_unit_page}?specid=$specid",
  1664 + replace: replace);
1662 } 1665 }
1663 1666
1664 ///菜单管理-----做法 1667 ///菜单管理-----做法
1665 static Future<dynamic> goMenuDishMethodPage( 1668 static Future<dynamic> goMenuDishMethodPage(
1666 - BuildContext context, { 1669 + BuildContext context,
  1670 + String selectPracticeIds, {
1667 replace = false, 1671 replace = false,
1668 }) { 1672 }) {
1669 - return _navigateTo(context, "${Routes.menu_dish_method_page}", 1673 + return _navigateTo(context,
  1674 + "${Routes.menu_dish_method_page}?selectPracticeIds=$selectPracticeIds",
1670 replace: replace); 1675 replace: replace);
1671 } 1676 }
1672 1677
@@ -154,6 +154,7 @@ import 'package:one_key/utils/utils.dart'; @@ -154,6 +154,7 @@ import 'package:one_key/utils/utils.dart';
154 import 'package:provider/provider.dart'; 154 import 'package:provider/provider.dart';
155 155
156 import '../models/get_banquet_by_id_new_model.dart'; 156 import '../models/get_banquet_by_id_new_model.dart';
  157 +import '../models/menu_unit_model.dart';
157 import '../models/out_wine_record_model.dart'; 158 import '../models/out_wine_record_model.dart';
158 import '../models/plan_cook_by_rid_model.dart'; 159 import '../models/plan_cook_by_rid_model.dart';
159 import '../models/plan_cook_list_model.dart'; 160 import '../models/plan_cook_list_model.dart';
@@ -2678,34 +2679,52 @@ var menuSetPricePageHandle = new Handler( @@ -2678,34 +2679,52 @@ var menuSetPricePageHandle = new Handler(
2678 // String idstr = params["idstr"].first; 2679 // String idstr = params["idstr"].first;
2679 // NotebookDetail detailEntity = NotebookDetail.fromJson(json 2680 // NotebookDetail detailEntity = NotebookDetail.fromJson(json
2680 // .decode(FluroConvertUtils.fluroCnParamsDecode(params["detail"].first))); 2681 // .decode(FluroConvertUtils.fluroCnParamsDecode(params["detail"].first)));
  2682 + List<MenuUnitModel> res = [];
  2683 + // String planDishPrice = '';
  2684 + if (params.keys.contains('object')) {
  2685 + Map object = FluroConvertUtils.string2map(params["object"].first);
  2686 + List temp = object['object'];
  2687 +
  2688 + // planDishPrice = params["planDishPrice"].first;
  2689 + if (temp != null) {
  2690 + for (var item in temp) {
  2691 + // MenuModel menuModel = MenuModel.fromJson2(item);
  2692 + // res.add(menuModel);
  2693 + // print(res);
  2694 + res.add(MenuUnitModel.fromJson(item));
  2695 + }
  2696 + }
  2697 + }
2681 return ChangeNotifierProvider<MenuManageProvider>( 2698 return ChangeNotifierProvider<MenuManageProvider>(
2682 - create: (_) => MenuManageProvider(), child: MenuSetPricePage()); 2699 + create: (_) => MenuManageProvider(), child: MenuSetPricePage(data: res));
2683 }); 2700 });
2684 2701
2685 ///菜单管理--配置销售单位 2702 ///菜单管理--配置销售单位
2686 var menuUnitPageHandle = new Handler( 2703 var menuUnitPageHandle = new Handler(
2687 handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) { 2704 handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
2688 - // String idstr = params["idstr"].first; 2705 + String specid = params["specid"].first;
2689 // NotebookDetail detailEntity = NotebookDetail.fromJson(json 2706 // NotebookDetail detailEntity = NotebookDetail.fromJson(json
2690 // .decode(FluroConvertUtils.fluroCnParamsDecode(params["detail"].first))); 2707 // .decode(FluroConvertUtils.fluroCnParamsDecode(params["detail"].first)));
  2708 +
2691 return ChangeNotifierProvider<MenuManageProvider>( 2709 return ChangeNotifierProvider<MenuManageProvider>(
2692 - create: (_) => MenuManageProvider(), child: MenuUnitPage()); 2710 + create: (_) => MenuManageProvider(), child: MenuUnitPage(specid: specid));
2693 }); 2711 });
2694 2712
2695 ///菜单管理--做法 2713 ///菜单管理--做法
2696 var menuDishMethodPageHandle = new Handler( 2714 var menuDishMethodPageHandle = new Handler(
2697 handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) { 2715 handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
2698 - // String idstr = params["idstr"].first; 2716 + String selectPracticeIds = params["selectPracticeIds"].first;
2699 // NotebookDetail detailEntity = NotebookDetail.fromJson(json 2717 // NotebookDetail detailEntity = NotebookDetail.fromJson(json
2700 // .decode(FluroConvertUtils.fluroCnParamsDecode(params["detail"].first))); 2718 // .decode(FluroConvertUtils.fluroCnParamsDecode(params["detail"].first)));
2701 return ChangeNotifierProvider<MenuManageProvider>( 2719 return ChangeNotifierProvider<MenuManageProvider>(
2702 - create: (_) => MenuManageProvider(), child: MenuDishMethodPage()); 2720 + create: (_) => MenuManageProvider(),
  2721 + child: MenuDishMethodPage(selectPracticeIds: selectPracticeIds));
2703 }); 2722 });
2704 2723
2705 ///菜单管理--菜单管理配置 2724 ///菜单管理--菜单管理配置
2706 var menuThemeColorSetPageHandle = new Handler( 2725 var menuThemeColorSetPageHandle = new Handler(
2707 handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) { 2726 handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
2708 - List<MenuModel> res = []; 2727 + List<MenuModel> res = [];
2709 if (params.keys.contains('object')) { 2728 if (params.keys.contains('object')) {
2710 Map object = FluroConvertUtils.string2map(params["object"].first); 2729 Map object = FluroConvertUtils.string2map(params["object"].first);
2711 List temp = object['object']; 2730 List temp = object['object'];
@@ -2715,5 +2734,6 @@ var menuThemeColorSetPageHandle = new Handler( @@ -2715,5 +2734,6 @@ var menuThemeColorSetPageHandle = new Handler(
2715 } 2734 }
2716 } 2735 }
2717 return ChangeNotifierProvider<MenuManageProvider>( 2736 return ChangeNotifierProvider<MenuManageProvider>(
2718 - create: (_) => MenuManageProvider(), child: MenuThemeColorSetPage(menuModel:res)); 2737 + create: (_) => MenuManageProvider(),
  2738 + child: MenuThemeColorSetPage(menuModel: res));
2719 }); 2739 });