Showing
11 changed files
with
574 additions
and
157 deletions
| @@ -38,6 +38,22 @@ class MenuModel { | @@ -38,6 +38,22 @@ class MenuModel { | ||
| 38 | } | 38 | } |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | + MenuModel.fromJson2(Map<String, dynamic> json) { | ||
| 42 | + id = json['id']; | ||
| 43 | + sellerid = json['sellerid']; | ||
| 44 | + className = json['class_name']; | ||
| 45 | + classLabel = json['class_label']; | ||
| 46 | + order = json['order']; | ||
| 47 | + status = json['status']; | ||
| 48 | + classType = json['class_type']; | ||
| 49 | + if (json['cookbooklist'] != null) { | ||
| 50 | + cookbooklist = []; | ||
| 51 | + json['cookbooklist'].forEach((v) { | ||
| 52 | + cookbooklist.add(new MenuSunModel.fromJson2(v)); | ||
| 53 | + }); | ||
| 54 | + } | ||
| 55 | + } | ||
| 56 | + | ||
| 41 | Map<String, dynamic> toJson() { | 57 | Map<String, dynamic> toJson() { |
| 42 | final Map<String, dynamic> data = new Map<String, dynamic>(); | 58 | final Map<String, dynamic> data = new Map<String, dynamic>(); |
| 43 | data['id'] = this.id; | 59 | data['id'] = this.id; |
| @@ -84,7 +100,7 @@ class MenuSunModel { | @@ -84,7 +100,7 @@ class MenuSunModel { | ||
| 84 | int isSpec; | 100 | int isSpec; |
| 85 | List practice; | 101 | List practice; |
| 86 | 102 | ||
| 87 | - int amount = 0; //菜品数量 | 103 | + int amount; //菜品数量 |
| 88 | 104 | ||
| 89 | MenuSunModel({ | 105 | MenuSunModel({ |
| 90 | this.id, | 106 | this.id, |
| @@ -114,6 +130,7 @@ class MenuSunModel { | @@ -114,6 +130,7 @@ class MenuSunModel { | ||
| 114 | this.spec, | 130 | this.spec, |
| 115 | this.isSpec, | 131 | this.isSpec, |
| 116 | this.practice, | 132 | this.practice, |
| 133 | + this.amount = 0, | ||
| 117 | }); | 134 | }); |
| 118 | 135 | ||
| 119 | MenuSunModel.fromJson(Map<String, dynamic> json) { | 136 | MenuSunModel.fromJson(Map<String, dynamic> json) { |
| @@ -145,6 +162,36 @@ class MenuSunModel { | @@ -145,6 +162,36 @@ class MenuSunModel { | ||
| 145 | practice = json['practice']; | 162 | practice = json['practice']; |
| 146 | } | 163 | } |
| 147 | 164 | ||
| 165 | + MenuSunModel.fromJson2(Map<String, dynamic> json) { | ||
| 166 | + id = json['id']; | ||
| 167 | + sellerid = json['sellerid']; | ||
| 168 | + mid = json['mid']; | ||
| 169 | + lid = json['lid']; | ||
| 170 | + unit = json['unit']; | ||
| 171 | + name = json['name']; | ||
| 172 | + price = json['price']; | ||
| 173 | + member_price = json['member_price']; | ||
| 174 | + first_name = json['first_name']; | ||
| 175 | + search_code = json['search_code']; | ||
| 176 | + channel = json['channel']; | ||
| 177 | + dishesvideo = json['dishesvideo']; | ||
| 178 | + dishesgif = json['dishesgif']; | ||
| 179 | + status = json['status']; | ||
| 180 | + setup = json['setup']; | ||
| 181 | + give = json['give']; | ||
| 182 | + clear_num = json['clear_num']; | ||
| 183 | + record_num = json['record_num']; | ||
| 184 | + image = json['image']; | ||
| 185 | + is_weigh = json['is_weigh']; | ||
| 186 | + desc = json['desc']; | ||
| 187 | + order_o = json['order_o']; | ||
| 188 | + cdate = json['cdate']; | ||
| 189 | + spec = json['spec']; | ||
| 190 | + isSpec = json['isSpec']; | ||
| 191 | + practice = json['practice']; | ||
| 192 | + amount = json['amount']??0; | ||
| 193 | + } | ||
| 194 | + | ||
| 148 | Map<String, dynamic> toJson() { | 195 | Map<String, dynamic> toJson() { |
| 149 | final Map<String, dynamic> data = new Map<String, dynamic>(); | 196 | final Map<String, dynamic> data = new Map<String, dynamic>(); |
| 150 | data['id'] = this.id; | 197 | data['id'] = this.id; |
| @@ -174,6 +221,7 @@ class MenuSunModel { | @@ -174,6 +221,7 @@ class MenuSunModel { | ||
| 174 | data['spec'] = this.spec; | 221 | data['spec'] = this.spec; |
| 175 | data['isSpec'] = this.isSpec; | 222 | data['isSpec'] = this.isSpec; |
| 176 | data['practice'] = this.practice; | 223 | data['practice'] = this.practice; |
| 224 | + data['amount'] = this.amount; | ||
| 177 | return data; | 225 | return data; |
| 178 | } | 226 | } |
| 179 | } | 227 | } |
lib/models/plan_cook_list_model.dart
0 → 100644
| 1 | +import 'dart:convert'; | ||
| 2 | + | ||
| 3 | +import 'package:one_key/models/cookbook_model.dart'; | ||
| 4 | + | ||
| 5 | +class PlanCookListModel { | ||
| 6 | + int ret; | ||
| 7 | + PlanCookListSunModel data; | ||
| 8 | + String msg; | ||
| 9 | + | ||
| 10 | + PlanCookListModel({this.ret, this.data, this.msg}); | ||
| 11 | + | ||
| 12 | + PlanCookListModel.fromJson(Map<String, dynamic> json) { | ||
| 13 | + ret = json['ret']; | ||
| 14 | + data = json['data'] != null | ||
| 15 | + ? new PlanCookListSunModel.fromJson(json['data']) | ||
| 16 | + : null; | ||
| 17 | + msg = json['msg']; | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + Map<String, dynamic> toJson() { | ||
| 21 | + final Map<String, dynamic> data = new Map<String, dynamic>(); | ||
| 22 | + data['ret'] = this.ret; | ||
| 23 | + if (this.data != null) { | ||
| 24 | + data['data'] = this.data.toJson(); | ||
| 25 | + } | ||
| 26 | + data['msg'] = this.msg; | ||
| 27 | + return data; | ||
| 28 | + } | ||
| 29 | +} | ||
| 30 | + | ||
| 31 | +class PlanCookListSunModel { | ||
| 32 | + List<SunList> packageList; | ||
| 33 | + List<SunList> plancookList; | ||
| 34 | + | ||
| 35 | + PlanCookListSunModel({this.packageList, this.plancookList}); | ||
| 36 | + | ||
| 37 | + PlanCookListSunModel.fromJson(Map<String, dynamic> json) { | ||
| 38 | + if (json['package_list'] != null) { | ||
| 39 | + packageList = <SunList>[]; | ||
| 40 | + json['package_list'].forEach((v) { | ||
| 41 | + packageList.add(new SunList.fromJson(v)); | ||
| 42 | + }); | ||
| 43 | + } | ||
| 44 | + if (json['plancook_list'] != null) { | ||
| 45 | + plancookList = <SunList>[]; | ||
| 46 | + json['plancook_list'].forEach((v) { | ||
| 47 | + plancookList.add(new SunList.fromJson(v)); | ||
| 48 | + }); | ||
| 49 | + } | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + Map<String, dynamic> toJson() { | ||
| 53 | + final Map<String, dynamic> data = new Map<String, dynamic>(); | ||
| 54 | + if (this.packageList != null) { | ||
| 55 | + data['package_list'] = this.packageList.map((v) => v.toJson()).toList(); | ||
| 56 | + } | ||
| 57 | + if (this.plancookList != null) { | ||
| 58 | + data['plancook_list'] = this.plancookList.map((v) => v.toJson()).toList(); | ||
| 59 | + } | ||
| 60 | + return data; | ||
| 61 | + } | ||
| 62 | +} | ||
| 63 | + | ||
| 64 | +class SunList { | ||
| 65 | + String id; | ||
| 66 | + String sellerid; | ||
| 67 | + String uid; | ||
| 68 | + String pname; | ||
| 69 | + String type; | ||
| 70 | + String status; | ||
| 71 | + String pnum; | ||
| 72 | + String menuPrice; | ||
| 73 | + String memberPrice; | ||
| 74 | + String planPrice; | ||
| 75 | + List<MenuModel> cookList; | ||
| 76 | + String isDel; | ||
| 77 | + String cdate; | ||
| 78 | + | ||
| 79 | + SunList( | ||
| 80 | + {this.id, | ||
| 81 | + this.sellerid, | ||
| 82 | + this.uid, | ||
| 83 | + this.pname, | ||
| 84 | + this.type, | ||
| 85 | + this.status, | ||
| 86 | + this.pnum, | ||
| 87 | + this.menuPrice, | ||
| 88 | + this.memberPrice, | ||
| 89 | + this.planPrice, | ||
| 90 | + this.cookList, | ||
| 91 | + this.isDel, | ||
| 92 | + this.cdate}); | ||
| 93 | + | ||
| 94 | + SunList.fromJson(Map<String, dynamic> json1) { | ||
| 95 | + id = json1['id']; | ||
| 96 | + sellerid = json1['sellerid']; | ||
| 97 | + uid = json1['uid']; | ||
| 98 | + pname = json1['pname']; | ||
| 99 | + type = json1['type']; | ||
| 100 | + status = json1['status']; | ||
| 101 | + pnum = json1['pnum']; | ||
| 102 | + menuPrice = json1['menu_price']; | ||
| 103 | + memberPrice = json1['member_price']; | ||
| 104 | + planPrice = json1['plan_price']; | ||
| 105 | + // cookList = json1['cook_list']; | ||
| 106 | + | ||
| 107 | + if (json1['cook_list'] != null) { | ||
| 108 | + cookList = <MenuModel>[]; | ||
| 109 | + json.decode(json1['cook_list']).forEach((v) { | ||
| 110 | + cookList.add(new MenuModel.fromJson2(v)); | ||
| 111 | + }); | ||
| 112 | + } | ||
| 113 | + isDel = json1['is_del']; | ||
| 114 | + cdate = json1['cdate']; | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + Map<String, dynamic> toJson() { | ||
| 118 | + final Map<String, dynamic> data = new Map<String, dynamic>(); | ||
| 119 | + data['id'] = this.id; | ||
| 120 | + data['sellerid'] = this.sellerid; | ||
| 121 | + data['uid'] = this.uid; | ||
| 122 | + data['pname'] = this.pname; | ||
| 123 | + data['type'] = this.type; | ||
| 124 | + data['status'] = this.status; | ||
| 125 | + data['pnum'] = this.pnum; | ||
| 126 | + data['menu_price'] = this.menuPrice; | ||
| 127 | + data['member_price'] = this.memberPrice; | ||
| 128 | + data['plan_price'] = this.planPrice; | ||
| 129 | + data['cook_list'] = this.cookList; | ||
| 130 | + data['is_del'] = this.isDel; | ||
| 131 | + data['cdate'] = this.cdate; | ||
| 132 | + return data; | ||
| 133 | + } | ||
| 134 | +} |
| @@ -338,5 +338,10 @@ class HttpUrl { | @@ -338,5 +338,10 @@ class HttpUrl { | ||
| 338 | 338 | ||
| 339 | static const String set_cookbook_class_by_id = | 339 | static const String set_cookbook_class_by_id = |
| 340 | "?service=App.Cookbook.SetCookbookClassById"; // 修改菜品分类 | 340 | "?service=App.Cookbook.SetCookbookClassById"; // 修改菜品分类 |
| 341 | + static const String set_plan_cook = | ||
| 342 | + "?service=App.PlanCook.SetPlanCook"; // 添加排菜/套餐 | ||
| 343 | + | ||
| 344 | + static const String get_plan_cook_list = | ||
| 345 | + "?service=App.PlanCook.GetPlanCookList"; // 排菜/套餐列表 | ||
| 341 | 346 | ||
| 342 | } | 347 | } |
| @@ -184,7 +184,7 @@ class _PlanDishCreateSelectTypePageState | @@ -184,7 +184,7 @@ class _PlanDishCreateSelectTypePageState | ||
| 184 | onPressed: () async { | 184 | onPressed: () async { |
| 185 | bool needRefresh = await NavigatorUtil.goPlanDishEditPage( | 185 | bool needRefresh = await NavigatorUtil.goPlanDishEditPage( |
| 186 | context, | 186 | context, |
| 187 | - isMine: selectF); | 187 | + isMine: selectF,isEdit:true); |
| 188 | print(needRefresh); | 188 | print(needRefresh); |
| 189 | if (needRefresh != null && needRefresh) { | 189 | if (needRefresh != null && needRefresh) { |
| 190 | Navigator.pop(context); | 190 | Navigator.pop(context); |
| 1 | +import 'dart:convert'; | ||
| 2 | + | ||
| 1 | import 'package:flutter/material.dart'; | 3 | import 'package:flutter/material.dart'; |
| 4 | +import 'package:flutter/services.dart'; | ||
| 2 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 5 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| 3 | import 'package:one_key/provider/plan_dish_provider.dart'; | 6 | import 'package:one_key/provider/plan_dish_provider.dart'; |
| 4 | 7 | ||
| @@ -36,7 +39,9 @@ import 'package:provider/provider.dart'; | @@ -36,7 +39,9 @@ import 'package:provider/provider.dart'; | ||
| 36 | 39 | ||
| 37 | class PlanDishEidtPage extends StatefulWidget { | 40 | class PlanDishEidtPage extends StatefulWidget { |
| 38 | final bool isMine; | 41 | final bool isMine; |
| 39 | - PlanDishEidtPage({Key key, this.isMine = true}) : super(key: key); | 42 | + final bool isEdit; |
| 43 | + PlanDishEidtPage({Key key, this.isMine = false, this.isEdit = true}) | ||
| 44 | + : super(key: key); | ||
| 40 | 45 | ||
| 41 | @override | 46 | @override |
| 42 | _PlanDishEidtPageState createState() => _PlanDishEidtPageState(); | 47 | _PlanDishEidtPageState createState() => _PlanDishEidtPageState(); |
| @@ -60,10 +65,26 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> { | @@ -60,10 +65,26 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> { | ||
| 60 | List labelList = ['店内通用套餐', '自定义排菜单']; | 65 | List labelList = ['店内通用套餐', '自定义排菜单']; |
| 61 | int labelSelIndex = 0; | 66 | int labelSelIndex = 0; |
| 62 | String labelShow; | 67 | String labelShow; |
| 68 | + TextEditingController pNumC = TextEditingController(); //就餐人数 | ||
| 69 | + String priceSum = '0'; //菜品总价 | ||
| 70 | + String memberPriceSum = '0'; //会员价 | ||
| 71 | + TextEditingController dishPriceC = TextEditingController(); //排菜价格 | ||
| 72 | + int pNum = 0; //人数 | ||
| 73 | + List<MenuModel> menuModel; //菜品数据 | ||
| 74 | + | ||
| 63 | @override | 75 | @override |
| 64 | void initState() { | 76 | void initState() { |
| 65 | super.initState(); | 77 | super.initState(); |
| 66 | - labelShow = labelList[labelSelIndex]; | 78 | + if (widget.isEdit) { |
| 79 | + if (widget.isMine == true) { | ||
| 80 | + labelShow = '自定义排菜单'; | ||
| 81 | + } else { | ||
| 82 | + labelShow = '店内通用套餐'; | ||
| 83 | + } | ||
| 84 | + } else { | ||
| 85 | + labelShow = labelList[labelSelIndex]; | ||
| 86 | + } | ||
| 87 | + | ||
| 67 | _nameFocusNode.addListener(() { | 88 | _nameFocusNode.addListener(() { |
| 68 | if (_nameFocusNode.hasFocus) { | 89 | if (_nameFocusNode.hasFocus) { |
| 69 | //有焦点 | 90 | //有焦点 |
| @@ -92,36 +113,33 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> { | @@ -92,36 +113,33 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> { | ||
| 92 | 113 | ||
| 93 | //创建新券 客户经理创建活动 | 114 | //创建新券 客户经理创建活动 |
| 94 | _createNewdish() async { | 115 | _createNewdish() async { |
| 95 | - // FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 96 | - // Map<String, String> params = { | ||
| 97 | - // "uid": Provider.of<UserModel>(context, listen: false).user.openid, | ||
| 98 | - // "aname": _dishNameEditControl.text.trim(), | ||
| 99 | - // "desc": _dishRequireEditControl.text.trim(), | ||
| 100 | - // "stime": fromDate == '点击选择' | ||
| 101 | - // ? "" | ||
| 102 | - // : '${DateUtil.getDateMsByTimeStr(fromDate) / 1000}', | ||
| 103 | - // "etime": endDate == '点击选择' | ||
| 104 | - // ? '' | ||
| 105 | - // : '${DateUtil.getDateMsByTimeStr(endDate) / 1000}', | ||
| 106 | - // "explain": _dishExplainEditControl.text, | ||
| 107 | - // "is_open": swichState ? "1" : "0", | ||
| 108 | - // "status": swichState ? "1" : "0", | ||
| 109 | - // 'is_type': widget.isMine ? "2" : "1" | ||
| 110 | - // }; | 116 | + FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 |
| 117 | + Map<String, String> params = { | ||
| 118 | + 'sellerid': Provider.of<UserModel>(context, listen: false).user.sellerid, | ||
| 119 | + "uid": Provider.of<UserModel>(context, listen: false).user.openid, | ||
| 120 | + "pname": _dishNameEditControl.text.trim(), | ||
| 121 | + 'type': widget.isMine ? "2" : "1", | ||
| 122 | + "status": swichState ? "1" : "0", | ||
| 123 | + 'pnum': pNumC.text, | ||
| 124 | + "menu_price": priceSum, | ||
| 125 | + "member_price": memberPriceSum, | ||
| 126 | + "plan_price": dishPriceC.text, | ||
| 127 | + "cook_list": json.encode(menuModel), | ||
| 128 | + }; | ||
| 111 | // if (!widget.isMine) { | 129 | // if (!widget.isMine) { |
| 112 | // params['is_examine'] = swichHexiao ? "1" : "0"; | 130 | // params['is_examine'] = swichHexiao ? "1" : "0"; |
| 113 | // params['uid_list'] = uids; | 131 | // params['uid_list'] = uids; |
| 114 | // } | 132 | // } |
| 115 | - // bool isSuccess = await dishProvider.createCustomerActivity(context, params); | ||
| 116 | - // if (isSuccess) { | ||
| 117 | - // //成功之后跳回前一个页面 | ||
| 118 | - // // bus.emit('refresh_dish_list'); | ||
| 119 | - // EventBus().emit('refresh_dish_invitation'); | ||
| 120 | - // bus.emit('refresh_dish_list_f'); | 133 | + bool isSuccess = await dishProvider.setPlanCook(context, params); |
| 134 | + if (isSuccess) { | ||
| 135 | + //成功之后跳回前一个页面 | ||
| 136 | + // bus.emit('refresh_dish_list'); | ||
| 137 | + // EventBus().emit('refresh_dish_invitation'); | ||
| 138 | + // bus.emit('refresh_dish_list_f'); | ||
| 121 | 139 | ||
| 122 | - // bus.emit('refresh_table_m_dish'); | ||
| 123 | - // Navigator.pop(context, true); | ||
| 124 | - // } | 140 | + // bus.emit('refresh_table_m_dish'); |
| 141 | + Navigator.pop(context, true); | ||
| 142 | + } | ||
| 125 | } | 143 | } |
| 126 | 144 | ||
| 127 | ///输入框 | 145 | ///输入框 |
| @@ -157,6 +175,9 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> { | @@ -157,6 +175,9 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> { | ||
| 157 | color: MyColours.color_515151, | 175 | color: MyColours.color_515151, |
| 158 | fontSize: ScreenUtil().setSp(32), | 176 | fontSize: ScreenUtil().setSp(32), |
| 159 | ), | 177 | ), |
| 178 | + inputFormatters: title.contains('排菜名称') | ||
| 179 | + ? [LengthLimitingTextInputFormatter(15)] | ||
| 180 | + : [], | ||
| 160 | focusNode: | 181 | focusNode: |
| 161 | title.contains('排菜名称') ? _nameFocusNode : _requireFocusNode, | 182 | title.contains('排菜名称') ? _nameFocusNode : _requireFocusNode, |
| 162 | decoration: InputDecoration( | 183 | decoration: InputDecoration( |
| @@ -414,24 +435,27 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> { | @@ -414,24 +435,27 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> { | ||
| 414 | color: MyColours.color_DBDBDB), | 435 | color: MyColours.color_DBDBDB), |
| 415 | InkWell( | 436 | InkWell( |
| 416 | onTap: () { | 437 | onTap: () { |
| 417 | - FocusScope.of(context) | ||
| 418 | - .requestFocus(FocusNode()); //隐藏键盘 | ||
| 419 | - DialogUtil.showSelectCusmanDialog( | ||
| 420 | - context, | ||
| 421 | - labelList.map((item) { | ||
| 422 | - return item; | ||
| 423 | - }).toList(), (value) { | ||
| 424 | - if (value != null) { | ||
| 425 | - setState(() { | ||
| 426 | - labelSelIndex = value.first; | ||
| 427 | - labelShow = labelList[labelSelIndex]; | ||
| 428 | - }); | ||
| 429 | - } | ||
| 430 | - }, | ||
| 431 | - selecteds: labelSelIndex == null | ||
| 432 | - ? [] | ||
| 433 | - : [labelSelIndex]) | ||
| 434 | - .then((value) {}); | 438 | + if (!widget.isEdit) { |
| 439 | + FocusScope.of(context) | ||
| 440 | + .requestFocus(FocusNode()); //隐藏键盘 | ||
| 441 | + DialogUtil.showSelectCusmanDialog( | ||
| 442 | + context, | ||
| 443 | + labelList.map((item) { | ||
| 444 | + return item; | ||
| 445 | + }).toList(), (value) { | ||
| 446 | + if (value != null) { | ||
| 447 | + setState(() { | ||
| 448 | + labelSelIndex = value.first; | ||
| 449 | + labelShow = | ||
| 450 | + labelList[labelSelIndex]; | ||
| 451 | + }); | ||
| 452 | + } | ||
| 453 | + }, | ||
| 454 | + selecteds: labelSelIndex == null | ||
| 455 | + ? [] | ||
| 456 | + : [labelSelIndex]) | ||
| 457 | + .then((value) {}); | ||
| 458 | + } | ||
| 435 | }, | 459 | }, |
| 436 | child: Container( | 460 | child: Container( |
| 437 | height: ScreenUtil().setWidth(48 * 2), | 461 | height: ScreenUtil().setWidth(48 * 2), |
| @@ -466,12 +490,18 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> { | @@ -466,12 +490,18 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> { | ||
| 466 | fontSize: ScreenUtil().setSp(32), | 490 | fontSize: ScreenUtil().setSp(32), |
| 467 | ), | 491 | ), |
| 468 | )), | 492 | )), |
| 469 | - HEmptyView(10), | ||
| 470 | - Image.asset( | ||
| 471 | - Utils.getImgPath('c_arrow_down'), | ||
| 472 | - width: ScreenUtil().setWidth(24), | ||
| 473 | - // height: ScreenUtil().setWidth(10), | ||
| 474 | - ) | 493 | + !widget.isEdit |
| 494 | + ? HEmptyView(10) | ||
| 495 | + : SizedBox(), | ||
| 496 | + !widget.isEdit | ||
| 497 | + ? Image.asset( | ||
| 498 | + Utils.getImgPath( | ||
| 499 | + 'c_arrow_down'), | ||
| 500 | + width: | ||
| 501 | + ScreenUtil().setWidth(24), | ||
| 502 | + // height: ScreenUtil().setWidth(10), | ||
| 503 | + ) | ||
| 504 | + : SizedBox() | ||
| 475 | ], | 505 | ], |
| 476 | ), | 506 | ), |
| 477 | )), | 507 | )), |
| @@ -500,11 +530,24 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> { | @@ -500,11 +530,24 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> { | ||
| 500 | ), | 530 | ), |
| 501 | ), | 531 | ), |
| 502 | Spacer(), | 532 | Spacer(), |
| 503 | - Image.asset( | ||
| 504 | - Utils.getImgPath('plan_dish_minus'), | ||
| 505 | - width: w(16), | 533 | + InkWell( |
| 534 | + onTap: () { | ||
| 535 | + if (pNum == 0) { | ||
| 536 | + return; | ||
| 537 | + } | ||
| 538 | + pNum--; | ||
| 539 | + pNumC.text = '${pNum}'; | ||
| 540 | + }, | ||
| 541 | + child: Container( | ||
| 542 | + height: w(48), | ||
| 543 | + padding: EdgeInsets.symmetric( | ||
| 544 | + horizontal: w(23)), | ||
| 545 | + child: Image.asset( | ||
| 546 | + Utils.getImgPath('plan_dish_minus'), | ||
| 547 | + width: w(16), | ||
| 548 | + ), | ||
| 549 | + ), | ||
| 506 | ), | 550 | ), |
| 507 | - HEmptyView(46), | ||
| 508 | Container( | 551 | Container( |
| 509 | // constraints: BoxConstraints( | 552 | // constraints: BoxConstraints( |
| 510 | // minWidth: w(34), | 553 | // minWidth: w(34), |
| @@ -521,9 +564,13 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> { | @@ -521,9 +564,13 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> { | ||
| 521 | // constraints: BoxConstraints(minWidth: w(20)), | 564 | // constraints: BoxConstraints(minWidth: w(20)), |
| 522 | child: TextField( | 565 | child: TextField( |
| 523 | maxLines: 1, | 566 | maxLines: 1, |
| 524 | - // controller: | 567 | + controller: pNumC, |
| 525 | // focusNode: _focusNode, | 568 | // focusNode: _focusNode, |
| 526 | // autofocus: true, | 569 | // autofocus: true, |
| 570 | + inputFormatters: [ | ||
| 571 | + FilteringTextInputFormatter.allow( | ||
| 572 | + RegExp(r'[0-9]')), | ||
| 573 | + ], | ||
| 527 | 574 | ||
| 528 | style: TextStyle( | 575 | style: TextStyle( |
| 529 | color: MyColours.color_438E93, | 576 | color: MyColours.color_438E93, |
| @@ -547,6 +594,19 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> { | @@ -547,6 +594,19 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> { | ||
| 547 | TextInputAction.done, | 594 | TextInputAction.done, |
| 548 | 595 | ||
| 549 | onChanged: (value) { | 596 | onChanged: (value) { |
| 597 | + // bool isNumber = Utils.isNumeric( | ||
| 598 | + // value); //判断输入的内容是否是数字 | ||
| 599 | + // if (!isNumber) { | ||
| 600 | + // Utils.showToast('请输入数字'); | ||
| 601 | + // pNumC.text = ''; | ||
| 602 | + // return; | ||
| 603 | + // } else { | ||
| 604 | + if (value != null && | ||
| 605 | + value != '') { | ||
| 606 | + pNum = int.parse(value); | ||
| 607 | + } | ||
| 608 | + | ||
| 609 | + // } | ||
| 550 | // setState(() {}); | 610 | // setState(() {}); |
| 551 | // _searchSellerLocation(); | 611 | // _searchSellerLocation(); |
| 552 | // customerProvider.searchData(value); | 612 | // customerProvider.searchData(value); |
| @@ -561,10 +621,19 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> { | @@ -561,10 +621,19 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> { | ||
| 561 | // _focusNode.unfocus(); | 621 | // _focusNode.unfocus(); |
| 562 | }, | 622 | }, |
| 563 | )), | 623 | )), |
| 564 | - HEmptyView(46), | ||
| 565 | - Image.asset( | ||
| 566 | - Utils.getImgPath('plan_dish_add'), | ||
| 567 | - width: w(16), | 624 | + InkWell( |
| 625 | + onTap: () { | ||
| 626 | + pNum++; | ||
| 627 | + pNumC.text = '${pNum}'; | ||
| 628 | + }, | ||
| 629 | + child: Container( | ||
| 630 | + height: w(48), | ||
| 631 | + padding: EdgeInsets.only(left: w(23)), | ||
| 632 | + child: Image.asset( | ||
| 633 | + Utils.getImgPath('plan_dish_add'), | ||
| 634 | + width: w(16), | ||
| 635 | + ), | ||
| 636 | + ), | ||
| 568 | ), | 637 | ), |
| 569 | ], | 638 | ], |
| 570 | )), | 639 | )), |
| @@ -586,7 +655,7 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> { | @@ -586,7 +655,7 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> { | ||
| 586 | ), | 655 | ), |
| 587 | Spacer(), | 656 | Spacer(), |
| 588 | Text( | 657 | Text( |
| 589 | - '0元/0元', | 658 | + '${priceSum}元/${memberPriceSum}元', |
| 590 | style: TextStyle( | 659 | style: TextStyle( |
| 591 | color: MyColours.color_99515151, | 660 | color: MyColours.color_99515151, |
| 592 | fontSize: ScreenUtil().setSp(32)), | 661 | fontSize: ScreenUtil().setSp(32)), |
| @@ -609,7 +678,7 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> { | @@ -609,7 +678,7 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> { | ||
| 609 | Expanded( | 678 | Expanded( |
| 610 | child: TextField( | 679 | child: TextField( |
| 611 | maxLines: 1, | 680 | maxLines: 1, |
| 612 | - // controller: controller, | 681 | + controller: dishPriceC, |
| 613 | // focusNode: _focusNode, | 682 | // focusNode: _focusNode, |
| 614 | // autofocus: true, | 683 | // autofocus: true, |
| 615 | 684 | ||
| @@ -661,27 +730,48 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> { | @@ -661,27 +730,48 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> { | ||
| 661 | color: MyColours.color_DBDBDB), | 730 | color: MyColours.color_DBDBDB), |
| 662 | VEmptyView(24), | 731 | VEmptyView(24), |
| 663 | _select('菜品', '编辑', () async { | 732 | _select('菜品', '编辑', () async { |
| 664 | - Map temp = | ||
| 665 | - await NavigatorUtil.goPlanNewDishPage( | ||
| 666 | - context); | 733 | + FocusScope.of(context) |
| 734 | + .requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 735 | + Map temp; | ||
| 736 | + if (menuModel == null) { | ||
| 737 | + temp = await NavigatorUtil.goPlanNewDishPage( | ||
| 738 | + context, | ||
| 739 | + ); | ||
| 740 | + } else { | ||
| 741 | + temp = await NavigatorUtil.goPlanNewDishPage( | ||
| 742 | + context, | ||
| 743 | + object: {'object': menuModel}, | ||
| 744 | + planDishPrice: dishPriceC.text); | ||
| 745 | + } | ||
| 746 | + | ||
| 667 | if (temp != null) { | 747 | if (temp != null) { |
| 668 | - int priceSum = temp['priceSum']; | ||
| 669 | - int memberPriceSum = temp['memberPriceSum']; | 748 | + double priceSumTemp = temp['priceSum']; |
| 749 | + double memberPriceSumTemp = | ||
| 750 | + temp['memberPriceSum']; | ||
| 670 | String planDishSum = temp['planDishSum']; | 751 | String planDishSum = temp['planDishSum']; |
| 671 | - List<MenuModel> menuModel = | ||
| 672 | - temp['menu']; //菜品数据 | 752 | + menuModel = temp['menu']; //菜品数据 |
| 673 | print(priceSum); | 753 | print(priceSum); |
| 674 | print(memberPriceSum); | 754 | print(memberPriceSum); |
| 675 | print(planDishSum); | 755 | print(planDishSum); |
| 676 | print(menuModel); | 756 | print(menuModel); |
| 677 | 757 | ||
| 678 | // 刷新页面*************** | 758 | // 刷新页面*************** |
| 679 | - | ||
| 680 | - | ||
| 681 | - | ||
| 682 | - | ||
| 683 | - | ||
| 684 | - | 759 | + priceSum = priceSumTemp.toString(); |
| 760 | + memberPriceSum = | ||
| 761 | + memberPriceSumTemp.toString(); | ||
| 762 | + dishPriceC.text = planDishSum; | ||
| 763 | + String dish = ''; | ||
| 764 | + menuModel.forEach((element) { | ||
| 765 | + element.cookbooklist.forEach((cookbook) { | ||
| 766 | + if (cookbook.amount > 0) { | ||
| 767 | + dish += cookbook.name + '、'; | ||
| 768 | + } | ||
| 769 | + }); | ||
| 770 | + }); | ||
| 771 | + if (dish.endsWith('、')) { | ||
| 772 | + dish = dish.substring(0, dish.length - 1); | ||
| 773 | + } | ||
| 774 | + _dishExplainEditControl.text = dish; | ||
| 685 | } | 775 | } |
| 686 | }), | 776 | }), |
| 687 | _explain('券说明', '点击上面右侧的“编辑”,开始选菜吧!'), | 777 | _explain('券说明', '点击上面右侧的“编辑”,开始选菜吧!'), |
| @@ -11,6 +11,7 @@ import 'package:one_key/widgets/round_button.dart'; | @@ -11,6 +11,7 @@ import 'package:one_key/widgets/round_button.dart'; | ||
| 11 | import 'package:one_key/widgets/v_empty_view.dart'; | 11 | import 'package:one_key/widgets/v_empty_view.dart'; |
| 12 | import 'package:provider/provider.dart'; | 12 | import 'package:provider/provider.dart'; |
| 13 | 13 | ||
| 14 | +import '../../../models/plan_cook_list_model.dart'; | ||
| 14 | import '../../../provider/user_model.dart'; | 15 | import '../../../provider/user_model.dart'; |
| 15 | import '../../../utils/screen_util.dart'; | 16 | import '../../../utils/screen_util.dart'; |
| 16 | 17 | ||
| @@ -18,7 +19,7 @@ class PlanDishItem extends StatefulWidget { | @@ -18,7 +19,7 @@ class PlanDishItem extends StatefulWidget { | ||
| 18 | // final String from; | 19 | // final String from; |
| 19 | final VoidCallback onPressedDel; | 20 | final VoidCallback onPressedDel; |
| 20 | final VoidCallback onPressedReUse; | 21 | final VoidCallback onPressedReUse; |
| 21 | - // final CouponSunModel couponSonModel; | 22 | + final SunList sunList; |
| 22 | // final bool showBtn; | 23 | // final bool showBtn; |
| 23 | // final bool showCheck; | 24 | // final bool showCheck; |
| 24 | PlanDishItem({ | 25 | PlanDishItem({ |
| @@ -26,7 +27,7 @@ class PlanDishItem extends StatefulWidget { | @@ -26,7 +27,7 @@ class PlanDishItem extends StatefulWidget { | ||
| 26 | // this.from, | 27 | // this.from, |
| 27 | this.onPressedDel, | 28 | this.onPressedDel, |
| 28 | this.onPressedReUse, | 29 | this.onPressedReUse, |
| 29 | - // this.couponSonModel, | 30 | + this.sunList, |
| 30 | // this.showBtn = false, | 31 | // this.showBtn = false, |
| 31 | // this.showCheck = false | 32 | // this.showCheck = false |
| 32 | }) : super(key: key); | 33 | }) : super(key: key); |
| @@ -60,6 +61,17 @@ class _PlanDishItemState extends State<PlanDishItem> { | @@ -60,6 +61,17 @@ class _PlanDishItemState extends State<PlanDishItem> { | ||
| 60 | // context); | 61 | // context); |
| 61 | // } | 62 | // } |
| 62 | UserModel userModel = Provider.of<UserModel>(context, listen: false); | 63 | UserModel userModel = Provider.of<UserModel>(context, listen: false); |
| 64 | + String dish = ''; | ||
| 65 | + widget.sunList.cookList.forEach((element) { | ||
| 66 | + element.cookbooklist.forEach((value) { | ||
| 67 | + if (value.amount > 0) { | ||
| 68 | + dish += value.name + '、'; | ||
| 69 | + } | ||
| 70 | + }); | ||
| 71 | + }); | ||
| 72 | + if (dish.endsWith('、')) { | ||
| 73 | + dish = dish.substring(0, dish.length - 1); | ||
| 74 | + } | ||
| 63 | return InkWell( | 75 | return InkWell( |
| 64 | // onTap: widget.onPressed, | 76 | // onTap: widget.onPressed, |
| 65 | child: Container( | 77 | child: Container( |
| @@ -91,8 +103,8 @@ class _PlanDishItemState extends State<PlanDishItem> { | @@ -91,8 +103,8 @@ class _PlanDishItemState extends State<PlanDishItem> { | ||
| 91 | padding: EdgeInsets.symmetric( | 103 | padding: EdgeInsets.symmetric( |
| 92 | horizontal: ScreenUtil().setWidth(24)), | 104 | horizontal: ScreenUtil().setWidth(24)), |
| 93 | decoration: BoxDecoration( | 105 | decoration: BoxDecoration( |
| 94 | - color: true //开启可用 | ||
| 95 | - ? true //店铺 | 106 | + color: widget.sunList.status == '1' //开启可用 |
| 107 | + ? widget.sunList.type == '1' //店铺 | ||
| 96 | ? MyColours.color_438E93 | 108 | ? MyColours.color_438E93 |
| 97 | : MyColours.color_ED7B2F | 109 | : MyColours.color_ED7B2F |
| 98 | : MyColours.color_999999, | 110 | : MyColours.color_999999, |
| @@ -124,7 +136,7 @@ class _PlanDishItemState extends State<PlanDishItem> { | @@ -124,7 +136,7 @@ class _PlanDishItemState extends State<PlanDishItem> { | ||
| 124 | // ? '店铺优惠券(核销)' | 136 | // ? '店铺优惠券(核销)' |
| 125 | // : '店铺优惠券' | 137 | // : '店铺优惠券' |
| 126 | // : | 138 | // : |
| 127 | - true ? '店' : '私', | 139 | + widget.sunList.type == '1' ? '店' : '私', |
| 128 | textAlign: TextAlign.center, | 140 | textAlign: TextAlign.center, |
| 129 | style: TextStyle( | 141 | style: TextStyle( |
| 130 | color: MyColours.color_F8F9FD, | 142 | color: MyColours.color_F8F9FD, |
| @@ -138,7 +150,7 @@ class _PlanDishItemState extends State<PlanDishItem> { | @@ -138,7 +150,7 @@ class _PlanDishItemState extends State<PlanDishItem> { | ||
| 138 | // ? '店铺优惠券(核销)' | 150 | // ? '店铺优惠券(核销)' |
| 139 | // : '店铺优惠券' | 151 | // : '店铺优惠券' |
| 140 | // : | 152 | // : |
| 141 | - '朋友小聚8人畅享', | 153 | + '${widget.sunList.pname}', |
| 142 | style: TextStyle( | 154 | style: TextStyle( |
| 143 | fontWeight: FontWeight.bold, | 155 | fontWeight: FontWeight.bold, |
| 144 | color: MyColours.color_ffffff, | 156 | color: MyColours.color_ffffff, |
| @@ -153,7 +165,7 @@ class _PlanDishItemState extends State<PlanDishItem> { | @@ -153,7 +165,7 @@ class _PlanDishItemState extends State<PlanDishItem> { | ||
| 153 | // ? '被领取:${sunModel.receiveNum}张 已核销:${sunModel.useNum}张' | 165 | // ? '被领取:${sunModel.receiveNum}张 已核销:${sunModel.useNum}张' |
| 154 | // : '创建人:${sunModel.nickname ?? sunModel.uid} 被领取:${sunModel.receiveNum}张' | 166 | // : '创建人:${sunModel.nickname ?? sunModel.uid} 被领取:${sunModel.receiveNum}张' |
| 155 | // : '被领取:${sunModel.receiveNum}张', | 167 | // : '被领取:${sunModel.receiveNum}张', |
| 156 | - '1100元/8人', | 168 | + '${widget.sunList.planPrice}元/${widget.sunList.pnum}人', |
| 157 | maxLines: 1, | 169 | maxLines: 1, |
| 158 | overflow: TextOverflow.ellipsis, | 170 | overflow: TextOverflow.ellipsis, |
| 159 | style: TextStyle( | 171 | style: TextStyle( |
| @@ -175,7 +187,7 @@ class _PlanDishItemState extends State<PlanDishItem> { | @@ -175,7 +187,7 @@ class _PlanDishItemState extends State<PlanDishItem> { | ||
| 175 | // ? '店铺优惠券(核销)' | 187 | // ? '店铺优惠券(核销)' |
| 176 | // : '店铺优惠券' | 188 | // : '店铺优惠券' |
| 177 | // : | 189 | // : |
| 178 | - '铁锅炖大鹅,白山叫花鸡,主席红烧肉,清蒸鲈鱼,荷塘小炒,松仁玉米,咸蛋黄焗南瓜,黑椒牛柳,夫妻肺片,蒜泥茄子,卤水…', | 190 | + '${widget.sunList.cookList}', |
| 179 | 191 | ||
| 180 | maxLines: 2, | 192 | maxLines: 2, |
| 181 | style: TextStyle( | 193 | style: TextStyle( |
| @@ -203,7 +215,8 @@ class _PlanDishItemState extends State<PlanDishItem> { | @@ -203,7 +215,8 @@ class _PlanDishItemState extends State<PlanDishItem> { | ||
| 203 | fontSize: ScreenUtil().setSp(20))), | 215 | fontSize: ScreenUtil().setSp(20))), |
| 204 | Spacer(), | 216 | Spacer(), |
| 205 | //私,则是自己的,可删除 | 217 | //私,则是自己的,可删除 |
| 206 | - true || userModel.user.role_name == '管理员' || | 218 | + true || |
| 219 | + userModel.user.role_name == '管理员' || | ||
| 207 | userModel.user.role_name == '店长' | 220 | userModel.user.role_name == '店长' |
| 208 | ? RoundButton( | 221 | ? RoundButton( |
| 209 | width: ScreenUtil().setWidth(50 * 2), | 222 | width: ScreenUtil().setWidth(50 * 2), |
| @@ -3,6 +3,7 @@ import 'package:flutter_easyrefresh/easy_refresh.dart'; | @@ -3,6 +3,7 @@ import 'package:flutter_easyrefresh/easy_refresh.dart'; | ||
| 3 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 3 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| 4 | import 'package:one_key/constant/state.dart'; | 4 | import 'package:one_key/constant/state.dart'; |
| 5 | import 'package:one_key/models/personnel_manage_model.dart'; | 5 | import 'package:one_key/models/personnel_manage_model.dart'; |
| 6 | +import 'package:one_key/models/plan_cook_list_model.dart'; | ||
| 6 | import 'package:one_key/pages/coupon/coupon_item_f.dart'; | 7 | import 'package:one_key/pages/coupon/coupon_item_f.dart'; |
| 7 | import 'package:one_key/pages/my/plan_dish/plan_dish_item.dart'; | 8 | import 'package:one_key/pages/my/plan_dish/plan_dish_item.dart'; |
| 8 | import 'package:one_key/provider/coupon_provider.dart'; | 9 | import 'package:one_key/provider/coupon_provider.dart'; |
| @@ -37,15 +38,15 @@ class _PlanDishSunPageState extends State<PlanDishSunPage> { | @@ -37,15 +38,15 @@ class _PlanDishSunPageState extends State<PlanDishSunPage> { | ||
| 37 | super.initState(); | 38 | super.initState(); |
| 38 | 39 | ||
| 39 | WidgetsBinding.instance.addPostFrameCallback((_) { | 40 | WidgetsBinding.instance.addPostFrameCallback((_) { |
| 40 | - // if (widget.index == 0) { | ||
| 41 | - // planDishProvider.pageState = PageState.Loading; | ||
| 42 | - // } else if (widget.index == 1) { | ||
| 43 | - // planDishProvider.pageStateStore = PageState.Loading; | ||
| 44 | - // } else if (widget.index == 2) { | ||
| 45 | - // planDishProvider.pageStateMine = PageState.Loading; | ||
| 46 | - // } | ||
| 47 | - // couponProvider.notifyListeners(); | ||
| 48 | - // _couponNetworkData(widget.index, isShowLoading: false); | 41 | + if (widget.index == 0) { |
| 42 | + planDishProvider.pageStateHome = PageState.Loading; | ||
| 43 | + } else if (widget.index == 1) { | ||
| 44 | + planDishProvider.pageStateStore = PageState.Loading; | ||
| 45 | + } else if (widget.index == 2) { | ||
| 46 | + planDishProvider.pageStateMine = PageState.Loading; | ||
| 47 | + } | ||
| 48 | + planDishProvider.notifyListeners(); | ||
| 49 | + _getPlanCookList(widget.index, isShowLoading: false); | ||
| 49 | 50 | ||
| 50 | // bus.on("refresh_coupon_list_f", (arg) { | 51 | // bus.on("refresh_coupon_list_f", (arg) { |
| 51 | // _couponNetworkData(widget.index); | 52 | // _couponNetworkData(widget.index); |
| @@ -58,16 +59,17 @@ class _PlanDishSunPageState extends State<PlanDishSunPage> { | @@ -58,16 +59,17 @@ class _PlanDishSunPageState extends State<PlanDishSunPage> { | ||
| 58 | super.dispose(); | 59 | super.dispose(); |
| 59 | } | 60 | } |
| 60 | 61 | ||
| 61 | - ///获取优惠券列表数据 | ||
| 62 | - // _couponNetworkData(int index, {bool isShowLoading = true}) async { | ||
| 63 | - // Map<String, String> params = { | ||
| 64 | - // "uid": Provider.of<UserModel>(context, listen: false).user.openid, | ||
| 65 | - // // 'is_time': '0' | ||
| 66 | - // "is_type": index.toString() | ||
| 67 | - // }; | ||
| 68 | - // await couponProvider.getCustomerActivity(context, params, index, | ||
| 69 | - // isShowLoading: isShowLoading); | ||
| 70 | - // } | 62 | + ///排菜/套餐列表 |
| 63 | + | ||
| 64 | + _getPlanCookList(int index, {bool isShowLoading = true}) async { | ||
| 65 | + Map<String, String> params = { | ||
| 66 | + "uid": Provider.of<UserModel>(context, listen: false).user.openid, | ||
| 67 | + // 'is_time': '0' | ||
| 68 | + "sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid, | ||
| 69 | + }; | ||
| 70 | + await planDishProvider.getPlanCookList(context, params, | ||
| 71 | + showLoading: isShowLoading); | ||
| 72 | + } | ||
| 71 | 73 | ||
| 72 | ///修改活动信息 | 74 | ///修改活动信息 |
| 73 | // _setCustomerActivity(int index) async { | 75 | // _setCustomerActivity(int index) async { |
| @@ -92,12 +94,16 @@ class _PlanDishSunPageState extends State<PlanDishSunPage> { | @@ -92,12 +94,16 @@ class _PlanDishSunPageState extends State<PlanDishSunPage> { | ||
| 92 | Widget build(BuildContext context) { | 94 | Widget build(BuildContext context) { |
| 93 | planDishProvider = Provider.of<PlanDishProvider>(context, listen: true); | 95 | planDishProvider = Provider.of<PlanDishProvider>(context, listen: true); |
| 94 | PageState pageState; | 96 | PageState pageState; |
| 97 | + List<SunList> data = []; | ||
| 95 | if (widget.index == 0) { | 98 | if (widget.index == 0) { |
| 96 | - pageState = planDishProvider.pageState; | 99 | + pageState = planDishProvider.pageStateHome; |
| 100 | + data = planDishProvider.allList; | ||
| 97 | } else if (widget.index == 1) { | 101 | } else if (widget.index == 1) { |
| 98 | pageState = planDishProvider.pageStateStore; | 102 | pageState = planDishProvider.pageStateStore; |
| 103 | + data = planDishProvider.storeList; | ||
| 99 | } else if (widget.index == 2) { | 104 | } else if (widget.index == 2) { |
| 100 | pageState = planDishProvider.pageStateMine; | 105 | pageState = planDishProvider.pageStateMine; |
| 106 | + data = planDishProvider.mineList; | ||
| 101 | } | 107 | } |
| 102 | return Container( | 108 | return Container( |
| 103 | child: Consumer<CouponProvider>(builder: (context, model, _) { | 109 | child: Consumer<CouponProvider>(builder: (context, model, _) { |
| @@ -124,7 +130,7 @@ class _PlanDishSunPageState extends State<PlanDishSunPage> { | @@ -124,7 +130,7 @@ class _PlanDishSunPageState extends State<PlanDishSunPage> { | ||
| 124 | (BuildContext context, int index) { | 130 | (BuildContext context, int index) { |
| 125 | return PlanDishItem( | 131 | return PlanDishItem( |
| 126 | // from: 'quan', | 132 | // from: 'quan', |
| 127 | - // couponSonModel: couponProvider.couponList[index], | 133 | + sunList:data[index], |
| 128 | // showBtn: true, | 134 | // showBtn: true, |
| 129 | onPressedDel: () { | 135 | onPressedDel: () { |
| 130 | //弹框确认是否删除 | 136 | //弹框确认是否删除 |
| @@ -136,11 +142,14 @@ class _PlanDishSunPageState extends State<PlanDishSunPage> { | @@ -136,11 +142,14 @@ class _PlanDishSunPageState extends State<PlanDishSunPage> { | ||
| 136 | // _delGuestInfocDay(model.cday[index].id); | 142 | // _delGuestInfocDay(model.cday[index].id); |
| 137 | }); | 143 | }); |
| 138 | }, | 144 | }, |
| 139 | - onPressedReUse: () { | ||
| 140 | - NavigatorUtil.goFinalPlanDishPage(context); | 145 | + onPressedReUse: () async { |
| 146 | + bool needRefresh = await NavigatorUtil.goPlanDishEditPage( | ||
| 147 | + context, | ||
| 148 | + isMine: false, | ||
| 149 | + isEdit: false); | ||
| 141 | }, | 150 | }, |
| 142 | ); | 151 | ); |
| 143 | - }, childCount: 10), | 152 | + }, childCount: data.length), |
| 144 | ), | 153 | ), |
| 145 | // SliverList( | 154 | // SliverList( |
| 146 | // delegate: SliverChildBuilderDelegate( | 155 | // delegate: SliverChildBuilderDelegate( |
| @@ -21,8 +21,12 @@ import '../../../widgets/round_button.dart'; | @@ -21,8 +21,12 @@ import '../../../widgets/round_button.dart'; | ||
| 21 | const scrollDuration = Duration(microseconds: 500); | 21 | const scrollDuration = Duration(microseconds: 500); |
| 22 | 22 | ||
| 23 | class PlanNewDishPage extends StatefulWidget { | 23 | class PlanNewDishPage extends StatefulWidget { |
| 24 | + final List<MenuModel> data; | ||
| 25 | + final String planDishPrice; //排菜价用户输入 | ||
| 24 | PlanNewDishPage({ | 26 | PlanNewDishPage({ |
| 25 | Key key, | 27 | Key key, |
| 28 | + this.data, | ||
| 29 | + this.planDishPrice, | ||
| 26 | }) : super(key: key); | 30 | }) : super(key: key); |
| 27 | 31 | ||
| 28 | @override | 32 | @override |
| @@ -50,6 +54,7 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> { | @@ -50,6 +54,7 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> { | ||
| 50 | @override | 54 | @override |
| 51 | void initState() { | 55 | void initState() { |
| 52 | super.initState(); | 56 | super.initState(); |
| 57 | + | ||
| 53 | WidgetsBinding.instance.addPostFrameCallback((_) async { | 58 | WidgetsBinding.instance.addPostFrameCallback((_) async { |
| 54 | _getCookbookByClass(showLoading: false); | 59 | _getCookbookByClass(showLoading: false); |
| 55 | }); | 60 | }); |
| @@ -62,6 +67,36 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> { | @@ -62,6 +67,36 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> { | ||
| 62 | 67 | ||
| 63 | await _planDishProvider.getCookbookByClass(context, params, | 68 | await _planDishProvider.getCookbookByClass(context, params, |
| 64 | showLoading: showLoading); | 69 | showLoading: showLoading); |
| 70 | + print(widget.data); | ||
| 71 | + | ||
| 72 | + if (widget.data.length > 0) { | ||
| 73 | + widget.data.forEach((old) { | ||
| 74 | + _planDishProvider.menuModel.forEach((element) { | ||
| 75 | + if (old.id == element.id) { | ||
| 76 | + element.cookbooklist.forEach((value) { | ||
| 77 | + old.cookbooklist.forEach((oldCook) { | ||
| 78 | + if (oldCook.id == value.id) { | ||
| 79 | + value.amount = oldCook.amount; | ||
| 80 | + if (oldCook.amount > 0) { | ||
| 81 | + carSum += oldCook.amount; | ||
| 82 | + priceSum += double.parse(oldCook.price) * oldCook.amount; | ||
| 83 | + memberPriceSum += | ||
| 84 | + double.parse(oldCook.member_price) * oldCook.amount; | ||
| 85 | + } | ||
| 86 | + } | ||
| 87 | + }); | ||
| 88 | + }); | ||
| 89 | + } | ||
| 90 | + }); | ||
| 91 | + }); | ||
| 92 | + if (widget.planDishPrice != '' && widget.planDishPrice != null) { | ||
| 93 | + planDishC.text = widget.planDishPrice; | ||
| 94 | + } else { | ||
| 95 | + planDishC.text = '${priceSum}'; | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + setState(() {}); | ||
| 99 | + } | ||
| 65 | } | 100 | } |
| 66 | 101 | ||
| 67 | Widget list(List data) => ScrollablePositionedList.builder( | 102 | Widget list(List data) => ScrollablePositionedList.builder( |
| @@ -403,11 +438,18 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> { | @@ -403,11 +438,18 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> { | ||
| 403 | }); | 438 | }); |
| 404 | } | 439 | } |
| 405 | }, | 440 | }, |
| 406 | - child: Image.asset( | ||
| 407 | - Utils.getImgPath( | ||
| 408 | - 'plan_dish_minus'), | ||
| 409 | - width: w(16), | ||
| 410 | - )) | 441 | + child: Container( |
| 442 | + height: w(48), | ||
| 443 | + padding: | ||
| 444 | + EdgeInsets.symmetric( | ||
| 445 | + horizontal: w(8)), | ||
| 446 | + child: Image.asset( | ||
| 447 | + Utils.getImgPath( | ||
| 448 | + 'plan_dish_minus'), | ||
| 449 | + width: w(16), | ||
| 450 | + ), | ||
| 451 | + ), | ||
| 452 | + ) | ||
| 411 | : SizedBox(), | 453 | : SizedBox(), |
| 412 | HEmptyView(8), | 454 | HEmptyView(8), |
| 413 | menuSunModel.amount != null && | 455 | menuSunModel.amount != null && |
| @@ -488,24 +530,28 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> { | @@ -488,24 +530,28 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> { | ||
| 488 | : SizedBox(), | 530 | : SizedBox(), |
| 489 | HEmptyView(8), | 531 | HEmptyView(8), |
| 490 | InkWell( | 532 | InkWell( |
| 491 | - onTap: () { | ||
| 492 | - setState(() { | ||
| 493 | - menuSunModel.amount++; | ||
| 494 | - carSum++; | ||
| 495 | - priceSum += double.parse( | ||
| 496 | - menuSunModel.price); | ||
| 497 | - memberPriceSum += | ||
| 498 | - double.parse(menuSunModel | ||
| 499 | - .member_price); | ||
| 500 | - planDishC.text = | ||
| 501 | - '${priceSum}'; | ||
| 502 | - }); | ||
| 503 | - }, | 533 | + onTap: () { |
| 534 | + setState(() { | ||
| 535 | + menuSunModel.amount++; | ||
| 536 | + carSum++; | ||
| 537 | + priceSum += double.parse( | ||
| 538 | + menuSunModel.price); | ||
| 539 | + memberPriceSum += double.parse( | ||
| 540 | + menuSunModel.member_price); | ||
| 541 | + planDishC.text = '${priceSum}'; | ||
| 542 | + }); | ||
| 543 | + }, | ||
| 544 | + child: Container( | ||
| 545 | + height: w(48), | ||
| 546 | + padding: | ||
| 547 | + EdgeInsets.only(left: w(8)), | ||
| 504 | child: Image.asset( | 548 | child: Image.asset( |
| 505 | Utils.getImgPath( | 549 | Utils.getImgPath( |
| 506 | 'plan_dish_add'), | 550 | 'plan_dish_add'), |
| 507 | width: w(16), | 551 | width: w(16), |
| 508 | - )), | 552 | + ), |
| 553 | + ), | ||
| 554 | + ), | ||
| 509 | ], | 555 | ], |
| 510 | ), | 556 | ), |
| 511 | ); | 557 | ); |
| @@ -686,13 +732,17 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> { | @@ -686,13 +732,17 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> { | ||
| 686 | // }); | 732 | // }); |
| 687 | 733 | ||
| 688 | // }); | 734 | // }); |
| 689 | - Map data = { | ||
| 690 | - 'priceSum': priceSum, | ||
| 691 | - 'memberPriceSum': memberPriceSum, | ||
| 692 | - 'planDishSum': planDishC.text, | ||
| 693 | - 'menu': _planDishProvider.menuModel | ||
| 694 | - }; | ||
| 695 | - Navigator.of(context).pop(data); | 735 | + if (carSum == 0) { |
| 736 | + Navigator.of(context).pop(); | ||
| 737 | + } else { | ||
| 738 | + Map data = { | ||
| 739 | + 'priceSum': priceSum, | ||
| 740 | + 'memberPriceSum': memberPriceSum, | ||
| 741 | + 'planDishSum': planDishC.text, | ||
| 742 | + 'menu': _planDishProvider.menuModel | ||
| 743 | + }; | ||
| 744 | + Navigator.of(context).pop(data); | ||
| 745 | + } | ||
| 696 | }, | 746 | }, |
| 697 | ), | 747 | ), |
| 698 | ) | 748 | ) |
| 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/models/plan_cook_list_model.dart'; | ||
| 3 | import 'package:one_key/net/base_resp.dart'; | 4 | import 'package:one_key/net/base_resp.dart'; |
| 4 | import 'package:one_key/net/dio_util.dart'; | 5 | import 'package:one_key/net/dio_util.dart'; |
| 5 | import 'package:one_key/utils/utils.dart'; | 6 | import 'package:one_key/utils/utils.dart'; |
| @@ -13,12 +14,17 @@ import '../net/http_url.dart'; | @@ -13,12 +14,17 @@ import '../net/http_url.dart'; | ||
| 13 | * 预排菜 | 14 | * 预排菜 |
| 14 | */ | 15 | */ |
| 15 | class PlanDishProvider extends ChangeNotifier { | 16 | class PlanDishProvider extends ChangeNotifier { |
| 17 | + PageState pageStateHome = PageState.Loading; | ||
| 16 | PageState pageState = PageState.Loading; | 18 | PageState pageState = PageState.Loading; |
| 17 | PageState pageStateStore = PageState.Success; | 19 | PageState pageStateStore = PageState.Success; |
| 18 | PageState pageStateMine = PageState.Success; | 20 | PageState pageStateMine = PageState.Success; |
| 19 | PageState pageStateMy = PageState.Loading; | 21 | PageState pageStateMy = PageState.Loading; |
| 20 | 22 | ||
| 21 | List<MenuModel> menuModel; //菜品数据 | 23 | List<MenuModel> menuModel; //菜品数据 |
| 24 | + | ||
| 25 | + List<SunList> allList = []; //排菜套餐列表--全部 | ||
| 26 | + List<SunList> storeList = []; //排菜套餐列表--店铺 | ||
| 27 | + List<SunList> mineList = []; //排菜套餐列表--我的 | ||
| 22 | // List<CookbookCategorySunModel> categorySunModel; //菜品分类数据 | 28 | // List<CookbookCategorySunModel> categorySunModel; //菜品分类数据 |
| 23 | // List<CookbookSpecSunModel> specSunModel; //计价单位 | 29 | // List<CookbookSpecSunModel> specSunModel; //计价单位 |
| 24 | 30 | ||
| @@ -67,4 +73,56 @@ class PlanDishProvider extends ChangeNotifier { | @@ -67,4 +73,56 @@ class PlanDishProvider extends ChangeNotifier { | ||
| 67 | } | 73 | } |
| 68 | notifyListeners(); | 74 | notifyListeners(); |
| 69 | } | 75 | } |
| 76 | + | ||
| 77 | + ///添加排菜/套餐 | ||
| 78 | + | ||
| 79 | + Future<bool> setPlanCook(BuildContext context, Map<String, String> params, | ||
| 80 | + {showLoading = false}) async { | ||
| 81 | + BaseResp<dynamic> baseResp = await DioUtil() | ||
| 82 | + .request<dynamic>(context, Method.get, HttpUrl.set_plan_cook, | ||
| 83 | + data: params, showLoading: showLoading) | ||
| 84 | + .catchError((error) { | ||
| 85 | + print(error.toString()); | ||
| 86 | + if (error is MyError) {} | ||
| 87 | + return false; | ||
| 88 | + }); | ||
| 89 | + | ||
| 90 | + if (baseResp != null && baseResp.code == Constant.status_success) { | ||
| 91 | + return true; | ||
| 92 | + } else { | ||
| 93 | + Utils.showToast(baseResp.msg ?? ""); | ||
| 94 | + return false; | ||
| 95 | + } | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + ///排菜/套餐列表 | ||
| 99 | + | ||
| 100 | + Future<bool> getPlanCookList(BuildContext context, Map<String, String> params, | ||
| 101 | + {showLoading = false}) async { | ||
| 102 | + BaseResp<dynamic> baseResp = await DioUtil() | ||
| 103 | + .request<dynamic>(context, Method.get, HttpUrl.get_plan_cook_list, | ||
| 104 | + data: params, showLoading: showLoading) | ||
| 105 | + .catchError((error) { | ||
| 106 | + print(error.toString()); | ||
| 107 | + if (error is MyError) {} | ||
| 108 | + return false; | ||
| 109 | + }); | ||
| 110 | + | ||
| 111 | + if (baseResp != null && baseResp.code == Constant.status_success) { | ||
| 112 | + PlanCookListSunModel planCookListSunModel = | ||
| 113 | + PlanCookListModel.fromJson(baseResp.responseData).data; | ||
| 114 | + storeList.addAll(planCookListSunModel.packageList); | ||
| 115 | + mineList.addAll(planCookListSunModel.plancookList); | ||
| 116 | + allList.addAll(storeList); | ||
| 117 | + allList.addAll(mineList); | ||
| 118 | + pageStateHome = PageState.Success; | ||
| 119 | + pageStateStore = PageState.Success; | ||
| 120 | + pageStateMine = PageState.Success; | ||
| 121 | + notifyListeners(); | ||
| 122 | + return true; | ||
| 123 | + } else { | ||
| 124 | + Utils.showToast(baseResp.msg ?? ""); | ||
| 125 | + return false; | ||
| 126 | + } | ||
| 127 | + } | ||
| 70 | } | 128 | } |
| @@ -1169,19 +1169,18 @@ class NavigatorUtil { | @@ -1169,19 +1169,18 @@ class NavigatorUtil { | ||
| 1169 | ///排菜-菜单点菜 | 1169 | ///排菜-菜单点菜 |
| 1170 | /// | 1170 | /// |
| 1171 | 1171 | ||
| 1172 | - static Future<dynamic> goPlanNewDishPage( | ||
| 1173 | - BuildContext context, { | ||
| 1174 | - replace = false, | ||
| 1175 | - }) { | 1172 | + static Future<dynamic> goPlanNewDishPage(BuildContext context, |
| 1173 | + {replace = false, Map object, String planDishPrice}) { | ||
| 1176 | // if (invoice != null) { | 1174 | // if (invoice != null) { |
| 1177 | // return _navigateTo(context, | 1175 | // return _navigateTo(context, |
| 1178 | // "${Routes.plan_new_dish_first_page}?invoice=${FluroConvertUtils.object2string(invoice)}", | 1176 | // "${Routes.plan_new_dish_first_page}?invoice=${FluroConvertUtils.object2string(invoice)}", |
| 1179 | // replace: replace); | 1177 | // replace: replace); |
| 1180 | // } | 1178 | // } |
| 1181 | - // if (object != null) { | ||
| 1182 | - // return _navigateTo(context, | ||
| 1183 | - // "${Routes.plan_new_dish_first_page}?tids=$tids&tableidNow=$tableidNow&fromPage=$fromPage&canChoose=$canChoose&object=${FluroConvertUtils.object2string(object)}"); | ||
| 1184 | - // } | 1179 | + if (object != null) { |
| 1180 | + return _navigateTo(context, | ||
| 1181 | + "${Routes.plan_new_dish_page}?object=${FluroConvertUtils.object2string(object)}&planDishPrice=$planDishPrice", | ||
| 1182 | + replace: replace); | ||
| 1183 | + } | ||
| 1185 | return _navigateTo(context, "${Routes.plan_new_dish_page}", | 1184 | return _navigateTo(context, "${Routes.plan_new_dish_page}", |
| 1186 | replace: replace); | 1185 | replace: replace); |
| 1187 | } | 1186 | } |
| @@ -1304,7 +1303,7 @@ class NavigatorUtil { | @@ -1304,7 +1303,7 @@ class NavigatorUtil { | ||
| 1304 | ///经理排菜- 编辑页 | 1303 | ///经理排菜- 编辑页 |
| 1305 | 1304 | ||
| 1306 | static Future<dynamic> goPlanDishEditPage(BuildContext context, | 1305 | static Future<dynamic> goPlanDishEditPage(BuildContext context, |
| 1307 | - {replace = false, bool isMine}) { | 1306 | + {replace = false, bool isMine, bool isEdit}) { |
| 1308 | // if (invoice != null) { | 1307 | // if (invoice != null) { |
| 1309 | // return _navigateTo(context, | 1308 | // return _navigateTo(context, |
| 1310 | // "${Routes.plan_dish_edit_page}?invoice=${FluroConvertUtils.object2string(invoice)}", | 1309 | // "${Routes.plan_dish_edit_page}?invoice=${FluroConvertUtils.object2string(invoice)}", |
| @@ -1314,8 +1313,8 @@ class NavigatorUtil { | @@ -1314,8 +1313,8 @@ class NavigatorUtil { | ||
| 1314 | // return _navigateTo(context, | 1313 | // return _navigateTo(context, |
| 1315 | // "${Routes.plan_dish_edit_page}?tids=$tids&tableidNow=$tableidNow&fromPage=$fromPage&canChoose=$canChoose&object=${FluroConvertUtils.object2string(object)}"); | 1314 | // "${Routes.plan_dish_edit_page}?tids=$tids&tableidNow=$tableidNow&fromPage=$fromPage&canChoose=$canChoose&object=${FluroConvertUtils.object2string(object)}"); |
| 1316 | // } | 1315 | // } |
| 1317 | - return _navigateTo( | ||
| 1318 | - context, "${Routes.plan_dish_edit_page}?isMine=${isMine}", | 1316 | + return _navigateTo(context, |
| 1317 | + "${Routes.plan_dish_edit_page}?isMine=${isMine}&isEdit=${isEdit}", | ||
| 1319 | replace: replace); | 1318 | replace: replace); |
| 1320 | } | 1319 | } |
| 1321 | } | 1320 | } |
| @@ -1884,17 +1884,25 @@ var planNewDishPageHandle = new Handler( | @@ -1884,17 +1884,25 @@ var planNewDishPageHandle = new Handler( | ||
| 1884 | 1884 | ||
| 1885 | // String tableidNow = params["tableidNow"].first; | 1885 | // String tableidNow = params["tableidNow"].first; |
| 1886 | // bool canChoose = params["canChoose"].first == "true" ? true : false; | 1886 | // bool canChoose = params["canChoose"].first == "true" ? true : false; |
| 1887 | - // List<TableList> res = []; | ||
| 1888 | - // if (params.keys.contains('object')) { | ||
| 1889 | - // Map object = FluroConvertUtils.string2map(params["object"].first); | ||
| 1890 | - // List temp = object['object']; | 1887 | + List<MenuModel> res = []; |
| 1888 | + String planDishPrice = ''; | ||
| 1889 | + if (params.keys.contains('object')) { | ||
| 1890 | + Map object = FluroConvertUtils.string2map(params["object"].first); | ||
| 1891 | + List temp = object['object']; | ||
| 1892 | + | ||
| 1893 | + planDishPrice = params["planDishPrice"].first; | ||
| 1894 | + | ||
| 1895 | + for (var item in temp) { | ||
| 1896 | + // MenuModel menuModel = MenuModel.fromJson2(item); | ||
| 1897 | + // res.add(menuModel); | ||
| 1898 | + // print(res); | ||
| 1899 | + res.add(MenuModel.fromJson2(item)); | ||
| 1900 | + } | ||
| 1901 | + } | ||
| 1891 | 1902 | ||
| 1892 | - // for (var item in temp) { | ||
| 1893 | - // res.add(TableList.fromJson(item)); | ||
| 1894 | - // } | ||
| 1895 | - // } | ||
| 1896 | return ChangeNotifierProvider<PlanDishProvider>( | 1903 | return ChangeNotifierProvider<PlanDishProvider>( |
| 1897 | - create: (_) => PlanDishProvider(), child: PlanNewDishPage()); | 1904 | + create: (_) => PlanDishProvider(), |
| 1905 | + child: PlanNewDishPage(data: res, planDishPrice: planDishPrice)); | ||
| 1898 | }); | 1906 | }); |
| 1899 | 1907 | ||
| 1900 | ///排菜---排菜单 | 1908 | ///排菜---排菜单 |
| @@ -2041,6 +2049,9 @@ var planDishEidtPageHandle = new Handler( | @@ -2041,6 +2049,9 @@ var planDishEidtPageHandle = new Handler( | ||
| 2041 | // } | 2049 | // } |
| 2042 | // } | 2050 | // } |
| 2043 | bool isMine = FluroConvertUtils.string2bool(params["isMine"].first); | 2051 | bool isMine = FluroConvertUtils.string2bool(params["isMine"].first); |
| 2052 | + bool isEdit = FluroConvertUtils.string2bool(params["isEdit"].first); | ||
| 2053 | + | ||
| 2044 | return ChangeNotifierProvider<PlanDishProvider>( | 2054 | return ChangeNotifierProvider<PlanDishProvider>( |
| 2045 | - create: (_) => PlanDishProvider(), child: PlanDishEidtPage(isMine: isMine,)); | 2055 | + create: (_) => PlanDishProvider(), |
| 2056 | + child: PlanDishEidtPage(isMine: isMine, isEdit: isEdit)); | ||
| 2046 | }); | 2057 | }); |
-
Please register or login to post a comment