Commit 76a48c968e57fb5164104c02d4a6502432c9e168

Authored by wdn127929
1 parent 25ee3657

客情,客户自己点

@@ -42,7 +42,8 @@ class PlanCookByRidSunModel { @@ -42,7 +42,8 @@ class PlanCookByRidSunModel {
42 List<MenuModel> cooklist; 42 List<MenuModel> cooklist;
43 List<MenuSunModel> packageList; 43 List<MenuSunModel> packageList;
44 // Null? oftenList; 44 // Null? oftenList;
45 - // Null? temporaryList; 45 +
  46 + List<MenuSunModel> temporaryList;
46 List<MenuSunModel> planList; 47 List<MenuSunModel> planList;
47 String menuPrice; 48 String menuPrice;
48 String memberPrice; 49 String memberPrice;
@@ -67,7 +68,7 @@ class PlanCookByRidSunModel { @@ -67,7 +68,7 @@ class PlanCookByRidSunModel {
67 this.cooklist, 68 this.cooklist,
68 this.packageList, 69 this.packageList,
69 // this.oftenList, 70 // this.oftenList,
70 - // this.temporaryList, 71 + this.temporaryList,
71 this.planList, 72 this.planList,
72 this.menuPrice, 73 this.menuPrice,
73 this.memberPrice, 74 this.memberPrice,
@@ -113,7 +114,19 @@ class PlanCookByRidSunModel { @@ -113,7 +114,19 @@ class PlanCookByRidSunModel {
113 } 114 }
114 } 115 }
115 // oftenList = json['often_list']; 116 // oftenList = json['often_list'];
116 - // temporaryList = json['temporary_list']; 117 +
  118 + if (json1['temporary_list'] != null && json1['temporary_list'] != '') {
  119 + temporaryList = <MenuSunModel>[];
  120 + if (json1['temporary_list'] is List) {
  121 + json1['temporary_list'].forEach((v) {
  122 + temporaryList.add(new MenuSunModel.fromJson2(v));
  123 + });
  124 + } else {
  125 + json.decode(json1['temporary_list']).forEach((v) {
  126 + temporaryList.add(new MenuSunModel.fromJson2(v));
  127 + });
  128 + }
  129 + }
117 130
118 if (json1['plan_list'] != null && json1['plan_list'] != '') { 131 if (json1['plan_list'] != null && json1['plan_list'] != '') {
119 planList = <MenuSunModel>[]; 132 planList = <MenuSunModel>[];
@@ -151,7 +164,7 @@ class PlanCookByRidSunModel { @@ -151,7 +164,7 @@ class PlanCookByRidSunModel {
151 data['cooklist'] = this.cooklist; 164 data['cooklist'] = this.cooklist;
152 data['package_list'] = this.packageList; 165 data['package_list'] = this.packageList;
153 // data['often_list'] = this.oftenList; 166 // data['often_list'] = this.oftenList;
154 - // data['temporary_list'] = this.temporaryList; 167 + data['temporary_list'] = this.temporaryList;
155 data['plan_list'] = this.planList; 168 data['plan_list'] = this.planList;
156 data['menu_price'] = this.menuPrice; 169 data['menu_price'] = this.menuPrice;
157 data['member_price'] = this.memberPrice; 170 data['member_price'] = this.memberPrice;
@@ -23,6 +23,7 @@ import '../../../widgets/round_button.dart'; @@ -23,6 +23,7 @@ import '../../../widgets/round_button.dart';
23 import '../../models/cookbook_model.dart'; 23 import '../../models/cookbook_model.dart';
24 import '../../models/notebook_detail.dart'; 24 import '../../models/notebook_detail.dart';
25 import '../../provider/user_model.dart'; 25 import '../../provider/user_model.dart';
  26 +import '../../utils/event_bus.dart';
26 27
27 const scrollDuration = Duration(microseconds: 500); 28 const scrollDuration = Duration(microseconds: 500);
28 29
@@ -77,9 +78,40 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> { @@ -77,9 +78,40 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
77 78
78 WidgetsBinding.instance.addPostFrameCallback((_) async { 79 WidgetsBinding.instance.addPostFrameCallback((_) async {
79 _getPageMenuData(); 80 _getPageMenuData();
  81 + bus.on("refresh_data", (args) {
  82 + print(args);
  83 + List<MenuSunModel> temp = args;
  84 +
  85 + _planDishProvider.menuModelForManager.forEach((element) {
  86 + if (element.className == '临时加菜') {
  87 + element.cookbooklist.forEach((old) {
  88 + carSum -= old.amount;
  89 + });
  90 + element.cookbooklist = [];
  91 + temp.forEach((value) {
  92 + carSum += value.amount;
  93 + element.cookbooklist.add(MenuSunModel.fromJson2(value.toJson()));
  94 + });
  95 + print(carSum);
  96 + List<MenuSunModel> menuSunShort = [];
  97 + MenuSunModel menuSunModelShort = MenuSunModel();
  98 + menuSunModelShort.name = '临时菜';
  99 + menuSunShort.add(menuSunModelShort);
  100 + element.cookbooklist.add(menuSunModelShort);
  101 + }
  102 + });
  103 + _calculatePrice();
  104 + setState(() {});
  105 + });
80 }); 106 });
81 } 107 }
82 108
  109 + @override
  110 + void dispose() {
  111 + super.dispose();
  112 + bus.off('refresh_data');
  113 + }
  114 +
83 _getPageMenuData() async { 115 _getPageMenuData() async {
84 Future.wait<bool>( 116 Future.wait<bool>(
85 [_getCookbookByClass(showLoading: true), _getPlanCookList()]) 117 [_getCookbookByClass(showLoading: true), _getPlanCookList()])
@@ -214,6 +246,32 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> { @@ -214,6 +246,32 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
214 246
215 _planDishProvider.menuModelForManager 247 _planDishProvider.menuModelForManager
216 .insert(1, menuModelPlanDish); //添加排菜 248 .insert(1, menuModelPlanDish); //添加排菜
  249 +
  250 + MenuModel menuModelShort = MenuModel();
  251 + menuModelShort.className = '临时加菜';
  252 + menuModelShort.classType = '5';
  253 + menuModelShort.cookbooklist = [];
  254 +
  255 + // 临时加菜
  256 + if (widget.planCookByRidSunModel != null &&
  257 + widget.planCookByRidSunModel.temporaryList != null &&
  258 + widget.planCookByRidSunModel.temporaryList.length > 0) {
  259 + menuModelShort.cookbooklist
  260 + .addAll(widget.planCookByRidSunModel.temporaryList);
  261 + widget.planCookByRidSunModel.temporaryList.forEach((temporary) {
  262 + if (temporary.amount > 0) {
  263 + carSum += temporary.amount;
  264 + }
  265 + });
  266 + }
  267 +
  268 + List<MenuSunModel> menuSunShort = [];
  269 + MenuSunModel menuSunModelShort = MenuSunModel();
  270 + menuSunModelShort.name = '临时菜';
  271 + menuSunShort.add(menuSunModelShort);
  272 + menuModelShort.cookbooklist.add(menuSunModelShort);
  273 + _planDishProvider.menuModelForManager.add(menuModelShort);
  274 +
217 if (widget.planCookByRidSunModel != null && 275 if (widget.planCookByRidSunModel != null &&
218 widget.planCookByRidSunModel.planPrice != null) { 276 widget.planCookByRidSunModel.planPrice != null) {
219 _calculatePrice(planPrice: widget.planCookByRidSunModel.planPrice); 277 _calculatePrice(planPrice: widget.planCookByRidSunModel.planPrice);
@@ -467,6 +525,10 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> { @@ -467,6 +525,10 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
467 }); 525 });
468 }); 526 });
469 } else if (element.className == '临时加菜') { 527 } else if (element.className == '临时加菜') {
  528 + //临时加菜
  529 + element.cookbooklist.forEach((value) {
  530 + value.amount = 0;
  531 + });
470 } else { 532 } else {
471 //单菜 533 //单菜
472 element.cookbooklist.forEach((value) { 534 element.cookbooklist.forEach((value) {
@@ -489,6 +551,8 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> { @@ -489,6 +551,8 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
489 } 551 }
490 //单品 552 //单品
491 List<MenuModel> cooklistdata = []; 553 List<MenuModel> cooklistdata = [];
  554 + //临时加菜
  555 + List<MenuSunModel> temporarylist = [];
492 _planDishProvider.menuModelForManager.forEach((element) { 556 _planDishProvider.menuModelForManager.forEach((element) {
493 if (element.className == '套餐') { 557 if (element.className == '套餐') {
494 List<MenuSunModel> packagelist = []; 558 List<MenuSunModel> packagelist = [];
@@ -514,18 +578,30 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> { @@ -514,18 +578,30 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
514 } else { 578 } else {
515 params['plan_list'] = null; 579 params['plan_list'] = null;
516 } 580 }
  581 + } else if (element.className == '临时加菜') {
  582 + //临时加菜
  583 +
  584 + temporarylist.addAll(element.cookbooklist);
  585 + if (temporarylist.length > 0) {
  586 + temporarylist.removeWhere((value) => value.amount == 0);
  587 + if (temporarylist.length > 0) {
  588 + params['temporary_list'] = json.encode(temporarylist);
  589 + } else {
  590 + params['temporary_list'] = null;
  591 + }
  592 + }
517 } else { 593 } else {
518 //单品 594 //单品
519 cooklistdata.add(element); 595 cooklistdata.add(element);
520 - }  
521 - if (cooklistdata.length > 0) {  
522 - cooklistdata.forEach((cooklist) {  
523 - cooklist.cookbooklist.removeWhere((element) => element.amount == 0);  
524 - });  
525 if (cooklistdata.length > 0) { 596 if (cooklistdata.length > 0) {
526 - params['cooklist'] = json.encode(cooklistdata);  
527 - } else {  
528 - params['cooklist'] = null; 597 + cooklistdata.forEach((cooklist) {
  598 + cooklist.cookbooklist.removeWhere((element) => element.amount == 0);
  599 + });
  600 + if (cooklistdata.length > 0) {
  601 + params['cooklist'] = json.encode(cooklistdata);
  602 + } else {
  603 + params['cooklist'] = null;
  604 + }
529 } 605 }
530 } 606 }
531 }); 607 });
@@ -611,6 +687,18 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> { @@ -611,6 +687,18 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
611 }); 687 });
612 }); 688 });
613 } else if (element.className == '临时加菜') { 689 } else if (element.className == '临时加菜') {
  690 + //临时加菜
  691 + bool hasmMenu = element.cookbooklist.any(((value) => value.amount > 0));
  692 + if (hasmMenu) {
  693 + //临时加菜此类有选中菜品
  694 +
  695 + element.cookbooklist.forEach((value) {
  696 + if (value.amount > 0) {
  697 + priceSum += double.parse(value.price) * value.amount;
  698 + memberPriceSum += double.parse(value.member_price) * value.amount;
  699 + }
  700 + });
  701 + }
614 } else { 702 } else {
615 //单菜 703 //单菜
616 bool hasmMenu = element.cookbooklist.any(((value) => value.amount > 0)); 704 bool hasmMenu = element.cookbooklist.any(((value) => value.amount > 0));
@@ -803,6 +891,9 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> { @@ -803,6 +891,9 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
803 _planDishProvider 891 _planDishProvider
804 .menuModelForManager[_selectIndex] 892 .menuModelForManager[_selectIndex]
805 .cookbooklist[index]; 893 .cookbooklist[index];
  894 + String className = _planDishProvider
  895 + .menuModelForManager[_selectIndex]
  896 + .className; //'5'临时加菜
806 return Container( 897 return Container(
807 padding: 898 padding:
808 EdgeInsets.symmetric(vertical: w(16)), 899 EdgeInsets.symmetric(vertical: w(16)),
@@ -840,31 +931,43 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> { @@ -840,31 +931,43 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
840 // _laduWidget() 931 // _laduWidget()
841 ], 932 ],
842 ), 933 ),
843 - VEmptyView(24),  
844 - Row(  
845 - children: [  
846 - Text(  
847 - '${menuSunModel.price}元/${menuSunModel.unit}',  
848 - style: TextStyle(  
849 - fontSize: font(12),  
850 - color: MyColours  
851 - .color_999999),  
852 - ),  
853 - HEmptyView(48),  
854 - Text(  
855 - '${menuSunModel.member_price}元/${menuSunModel.unit}',  
856 - style: TextStyle(  
857 - fontSize: font(10),  
858 - color: MyColours  
859 - .color_8EBBBE),  
860 - ),  
861 - ],  
862 - ) 934 + className == '临时加菜' &&
  935 + menuSunModel.name == '临时菜'
  936 + ? SizedBox()
  937 + : VEmptyView(24),
  938 + className == '临时加菜' &&
  939 + menuSunModel.name == '临时菜'
  940 + ? SizedBox()
  941 + : Row(
  942 + children: [
  943 + Text(
  944 + '${menuSunModel.price}元/${menuSunModel.unit}',
  945 + style: TextStyle(
  946 + fontSize:
  947 + font(12),
  948 + color: MyColours
  949 + .color_999999),
  950 + ),
  951 + HEmptyView(48),
  952 + Text(
  953 + '${menuSunModel.member_price}元/${menuSunModel.unit}',
  954 + style: TextStyle(
  955 + fontSize:
  956 + font(10),
  957 + color: MyColours
  958 + .color_8EBBBE),
  959 + ),
  960 + ],
  961 + )
863 ], 962 ],
864 )), 963 )),
865 // Spacer(), 964 // Spacer(),
866 - menuSunModel.amount != null &&  
867 - menuSunModel.amount > 0 965 + (menuSunModel.amount != null &&
  966 + menuSunModel.amount > 0 &&
  967 + className != '临时加菜') ||
  968 + (className == '临时加菜' &&
  969 + menuSunModel.name !=
  970 + '临时菜')
868 ? InkWell( 971 ? InkWell(
869 onTap: () { 972 onTap: () {
870 if (menuSunModel.amount > 973 if (menuSunModel.amount >
@@ -920,8 +1023,12 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> { @@ -920,8 +1023,12 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
920 ) 1023 )
921 : SizedBox(), 1024 : SizedBox(),
922 HEmptyView(8), 1025 HEmptyView(8),
923 - menuSunModel.amount != null &&  
924 - menuSunModel.amount > 0 1026 + (menuSunModel.amount != null &&
  1027 + menuSunModel.amount > 0 &&
  1028 + className != '临时加菜') ||
  1029 + (className == '临时加菜' &&
  1030 + menuSunModel.name !=
  1031 + '临时菜')
925 ? Container( 1032 ? Container(
926 constraints: BoxConstraints( 1033 constraints: BoxConstraints(
927 minWidth: w(32), 1034 minWidth: w(32),
@@ -999,38 +1106,50 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> { @@ -999,38 +1106,50 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
999 HEmptyView(8), 1106 HEmptyView(8),
1000 InkWell( 1107 InkWell(
1001 onTap: () { 1108 onTap: () {
1002 - setState(() {  
1003 - menuSunModel.amount++;  
1004 -  
1005 - // priceSum += double.parse(  
1006 - // menuSunModel.price);  
1007 - // memberPriceSum += double.parse(  
1008 - // menuSunModel.member_price);  
1009 - // planDishC.text = '${priceSum}';  
1010 - _calculatePrice();  
1011 - if (_planDishProvider  
1012 - .menuModelForManager[  
1013 - _selectIndex]  
1014 - .className ==  
1015 - '套餐' ||  
1016 - _planDishProvider  
1017 - .menuModelForManager[  
1018 - _selectIndex] ==  
1019 - '我的排菜') {  
1020 - //套餐菜品总个数  
1021 - //遍历套餐下的菜品分类  
1022 - menuSunModel.cookList  
1023 - .forEach((element) {  
1024 - //遍历菜品  
1025 - element.cookbooklist  
1026 - .forEach((cook) {  
1027 - carSum += cook.amount; 1109 + if (className == '临时加菜' &&
  1110 + menuSunModel.name == '临时菜') {
  1111 + //跳转到新建临时菜单页面
  1112 + NavigatorUtil
  1113 + .goOrderCreateTemporaryPage(
  1114 + context,
  1115 + object: {
  1116 + 'object': _planDishProvider
  1117 + .menuModelForManager
1028 }); 1118 });
1029 - });  
1030 - } else {  
1031 - carSum++;  
1032 - }  
1033 - }); 1119 + } else {
  1120 + setState(() {
  1121 + menuSunModel.amount++;
  1122 +
  1123 + // priceSum += double.parse(
  1124 + // menuSunModel.price);
  1125 + // memberPriceSum += double.parse(
  1126 + // menuSunModel.member_price);
  1127 + // planDishC.text = '${priceSum}';
  1128 + _calculatePrice();
  1129 + if (_planDishProvider
  1130 + .menuModelForManager[
  1131 + _selectIndex]
  1132 + .className ==
  1133 + '套餐' ||
  1134 + _planDishProvider
  1135 + .menuModelForManager[
  1136 + _selectIndex] ==
  1137 + '我的排菜') {
  1138 + //套餐菜品总个数
  1139 + //遍历套餐下的菜品分类
  1140 + menuSunModel.cookList
  1141 + .forEach((element) {
  1142 + //遍历菜品
  1143 + element.cookbooklist
  1144 + .forEach((cook) {
  1145 + carSum += cook.amount;
  1146 + });
  1147 + });
  1148 + } else {
  1149 + carSum++;
  1150 + }
  1151 + });
  1152 + }
1034 }, 1153 },
1035 child: Container( 1154 child: Container(
1036 height: w(48), 1155 height: w(48),
@@ -1326,7 +1445,12 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> { @@ -1326,7 +1445,12 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
1326 element.cookbooklist.forEach((old) { 1445 element.cookbooklist.forEach((old) {
1327 one.cookbooklist.forEach((newvalue) { 1446 one.cookbooklist.forEach((newvalue) {
1328 if (old.id == newvalue.id) { 1447 if (old.id == newvalue.id) {
1329 - old.amount = newvalue.amount; 1448 + if (element.className == '临时加菜' &&
  1449 + old.name == '临时菜') {
  1450 + } else {
  1451 + old.amount = newvalue.amount;
  1452 + carSumTemp += newvalue.amount;
  1453 + }
1330 } 1454 }
1331 }); 1455 });
1332 }); 1456 });
@@ -1364,6 +1488,7 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> { @@ -1364,6 +1488,7 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
1364 if (!success) { 1488 if (!success) {
1365 return; 1489 return;
1366 } 1490 }
  1491 + bus.emit('refresh_order_advance_home');
1367 } 1492 }
1368 //调用提交排菜接口 1493 //调用提交排菜接口
1369 //调用排菜信息提交接口 1494 //调用排菜信息提交接口
@@ -1446,8 +1571,10 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> { @@ -1446,8 +1571,10 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
1446 // //套餐中有被选中 1571 // //套餐中有被选中
1447 // maxIndex++; 1572 // maxIndex++;
1448 // } 1573 // }
1449 - } else if (element.className == '临时加菜') {  
1450 - } else { 1574 + }
  1575 + // else if (element.className == '临时加菜') {
  1576 + // }
  1577 + else {
1451 //单菜 1578 //单菜
1452 bool hasmMenu = element.cookbooklist 1579 bool hasmMenu = element.cookbooklist
1453 .any(((value) => value.amount > 0)); 1580 .any(((value) => value.amount > 0));
@@ -1563,8 +1690,8 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> { @@ -1563,8 +1690,8 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
1563 1690
1564 NavigatorUtil.goOrderPreviewPage(context, 1691 NavigatorUtil.goOrderPreviewPage(context,
1565 object: {'object': showList}, 1692 object: {'object': showList},
1566 - name: planDishName,  
1567 - remark: planDishRemark, 1693 + name: planDishName ?? "",
  1694 + remark: planDishRemark ?? "",
1568 priceSum: priceSum.toString(), 1695 priceSum: priceSum.toString(),
1569 memberPriceSum: memberPriceSum.toString(), 1696 memberPriceSum: memberPriceSum.toString(),
1570 planDishText: planDishC.text, 1697 planDishText: planDishC.text,
@@ -1591,6 +1718,7 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> { @@ -1591,6 +1718,7 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
1591 bool success = await setPlanCookByReserve(); 1718 bool success = await setPlanCookByReserve();
1592 if (success) { 1719 if (success) {
1593 Navigator.pop(context); 1720 Navigator.pop(context);
  1721 + Navigator.pop(context);
1594 } 1722 }
1595 // Navigator.pop(context); 1723 // Navigator.pop(context);
1596 // NavigatorUtil.goFinalPlanDishPage(context); 1724 // NavigatorUtil.goFinalPlanDishPage(context);
@@ -228,6 +228,32 @@ class _OrderAdvanceHomePageState extends State<OrderAdvanceHomePage> { @@ -228,6 +228,32 @@ class _OrderAdvanceHomePageState extends State<OrderAdvanceHomePage> {
228 228
229 _planDishProvider.menuModelForManager 229 _planDishProvider.menuModelForManager
230 .insert(1, menuModelPlanDish); //添加排菜 230 .insert(1, menuModelPlanDish); //添加排菜
  231 +
  232 + MenuModel menuModelShort = MenuModel();
  233 + menuModelShort.className = '临时加菜';
  234 + menuModelShort.classType = '5';
  235 + menuModelShort.cookbooklist = [];
  236 +
  237 + // 临时加菜
  238 + if (_planDishProvider.planCookByRidSunModel != null &&
  239 + _planDishProvider.planCookByRidSunModel.temporaryList != null &&
  240 + _planDishProvider.planCookByRidSunModel.temporaryList.length > 0) {
  241 + menuModelShort.cookbooklist
  242 + .addAll(_planDishProvider.planCookByRidSunModel.temporaryList);
  243 + _planDishProvider.planCookByRidSunModel.temporaryList.forEach((temporary) {
  244 + // if (temporary.amount > 0) {
  245 + // carSum += temporary.amount;
  246 + // }
  247 + });
  248 + }
  249 +
  250 + List<MenuSunModel> menuSunShort = [];
  251 + MenuSunModel menuSunModelShort = MenuSunModel();
  252 + menuSunModelShort.name = '临时菜';
  253 + menuSunShort.add(menuSunModelShort);
  254 + menuModelShort.cookbooklist.add(menuSunModelShort);
  255 + _planDishProvider.menuModelForManager.add(menuModelShort);
  256 +
231 // if (_planDishProvider.planCookByRidSunModel != null && 257 // if (_planDishProvider.planCookByRidSunModel != null &&
232 // _planDishProvider.planCookByRidSunModel.planPrice != null) { 258 // _planDishProvider.planCookByRidSunModel.planPrice != null) {
233 // _calculatePrice(planPrice: _planDishProvider.planCookByRidSunModel.planPrice); 259 // _calculatePrice(planPrice: _planDishProvider.planCookByRidSunModel.planPrice);
@@ -1002,8 +1028,10 @@ class _OrderAdvanceHomePageState extends State<OrderAdvanceHomePage> { @@ -1002,8 +1028,10 @@ class _OrderAdvanceHomePageState extends State<OrderAdvanceHomePage> {
1002 // //套餐中有被选中 1028 // //套餐中有被选中
1003 // maxIndex++; 1029 // maxIndex++;
1004 // } 1030 // }
1005 - } else if (element.className == '临时加菜') {  
1006 - } else { 1031 + }
  1032 + // else if (element.className == '临时加菜') {
  1033 + // }
  1034 + else {
1007 //单菜 1035 //单菜
1008 bool hasmMenu = element.cookbooklist 1036 bool hasmMenu = element.cookbooklist
1009 .any(((value) => value.amount > 0)); 1037 .any(((value) => value.amount > 0));
  1 +import 'package:flutter/material.dart';
  2 +import 'package:flutter/services.dart';
  3 +import 'package:one_key/res/colors.dart';
  4 +import 'package:one_key/widgets/MyDivider.dart';
  5 +import 'package:one_key/widgets/h_empty_view.dart';
  6 +import 'package:one_key/widgets/round_button.dart';
  7 +import 'package:one_key/widgets/system_app_bar.dart';
  8 +import 'package:one_key/widgets/v_empty_view.dart';
  9 +
  10 +import '../../models/cookbook_model.dart';
  11 +import '../../utils/event_bus.dart';
  12 +import '../../utils/screen_util.dart';
  13 +import '../../utils/utils.dart';
  14 +
  15 +/**
  16 + *
  17 + * 临时菜新增页
  18 + *
  19 + */
  20 +
  21 +class OrderCreateTemporaryPage extends StatefulWidget {
  22 + final List<MenuModel> data;
  23 + OrderCreateTemporaryPage({Key key, this.data}) : super(key: key);
  24 +
  25 + @override
  26 + _OrderCreateTemporaryPageState createState() =>
  27 + _OrderCreateTemporaryPageState();
  28 +}
  29 +
  30 +class _OrderCreateTemporaryPageState extends State<OrderCreateTemporaryPage> {
  31 + TextEditingController name = TextEditingController();
  32 + TextEditingController price = TextEditingController();
  33 + TextEditingController number = TextEditingController();
  34 + TextEditingController unit = TextEditingController();
  35 + TextEditingController practice = TextEditingController();
  36 + ScrollController controller = ScrollController();
  37 + List<MenuSunModel> menuSunShort = [];
  38 + int allSum = 0;
  39 +
  40 + @override
  41 + void initState() {
  42 + super.initState();
  43 + if (widget.data != null) {
  44 + widget.data.forEach((element) {
  45 + if (element.className == '临时加菜') {
  46 + menuSunShort = element.cookbooklist;
  47 + menuSunShort.removeWhere((value) => value.name == '临时菜');
  48 + allSum = 0;
  49 + menuSunShort.forEach((short) {
  50 + allSum += short.amount;
  51 + });
  52 + }
  53 + });
  54 + }
  55 + }
  56 +
  57 + _baseInputWidget(
  58 + String title, String hintText, TextEditingController controller,
  59 + {TextInputType keyboardType = TextInputType.text}) {
  60 + return Container(
  61 + height: w(40),
  62 + child: Row(
  63 + children: [
  64 + Text(
  65 + title,
  66 + style: TextStyle(fontSize: font(12), color: MyColours.color_515151),
  67 + ),
  68 + HEmptyView(34),
  69 + Container(
  70 + width: w(180),
  71 + height: w(30),
  72 + padding: EdgeInsets.symmetric(horizontal: w(12)),
  73 + decoration: BoxDecoration(
  74 + borderRadius: BorderRadius.circular(r(5)),
  75 + border:
  76 + Border.all(color: MyColours.color_DBDBDB, width: w(1))),
  77 + // constraints: BoxConstraints(minWidth: w(20)),
  78 + child: TextField(
  79 + maxLines: 1,
  80 + controller: controller,
  81 + // focusNode: _focusNode,
  82 + // autofocus: true,
  83 +
  84 + style: TextStyle(
  85 + color: MyColours.color_000000, fontSize: font(12)),
  86 + textAlign: TextAlign.left,
  87 + // textAlignVertical: TextAlignVertical.center,
  88 + decoration: InputDecoration(
  89 + hintText: hintText,
  90 + hintStyle: TextStyle(
  91 + color: MyColours.color_999999,
  92 + fontSize: font(12),
  93 + ),
  94 + // isCollapsed:
  95 + // true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
  96 + border: OutlineInputBorder(borderSide: BorderSide.none),
  97 + contentPadding: EdgeInsets.zero,
  98 + ),
  99 + keyboardType: keyboardType,
  100 + textInputAction: TextInputAction.done,
  101 +
  102 + onChanged: (value) {
  103 + // setState(() {});
  104 + // _searchSellerLocation();
  105 + // customerProvider.searchData(value);
  106 + },
  107 + onEditingComplete: () {
  108 + FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
  109 + // contantShowModel.searchData(
  110 + // contantShowModel.controller.text);
  111 + // _searchSellerLocation();
  112 + // _focusNode.unfocus();
  113 + },
  114 + )),
  115 + ],
  116 + ),
  117 + );
  118 + }
  119 +
  120 + @override
  121 + Widget build(BuildContext context) {
  122 + return Scaffold(
  123 + appBar: SystemAppBar('临时菜'),
  124 + body: Container(
  125 + color: MyColours.color_ffffff,
  126 + child: Column(
  127 + children: [
  128 + Expanded(
  129 + child: SingleChildScrollView(
  130 + controller: controller,
  131 + child: Column(
  132 + children: [
  133 + Padding(
  134 + padding: EdgeInsets.only(left: w(20)),
  135 + child: Column(
  136 + children: [
  137 + VEmptyView(16),
  138 + _baseInputWidget('菜品名称', '点击输入菜品名称', name),
  139 + _baseInputWidget('菜品价格', '点击输入菜品价格', price,
  140 + keyboardType: TextInputType.number),
  141 + Container(
  142 + height: w(40),
  143 + child: Row(
  144 + children: [
  145 + Text(
  146 + '菜品数量',
  147 + style: TextStyle(
  148 + fontSize: font(12),
  149 + color: MyColours.color_515151),
  150 + ),
  151 + HEmptyView(34),
  152 + InkWell(
  153 + onTap: () {
  154 + int numStr = int.parse(number.text);
  155 + if (numStr == 0) {
  156 + return;
  157 + }
  158 + numStr--;
  159 + number.text = numStr.toString();
  160 + setState(() {});
  161 + },
  162 + child: Container(
  163 + height: w(48),
  164 + padding:
  165 + EdgeInsets.symmetric(horizontal: w(8)),
  166 + child: Image.asset(
  167 + Utils.getImgPath('plan_dish_minus'),
  168 + width: w(16),
  169 + ),
  170 + ),
  171 + ),
  172 + // HEmptyView(8),
  173 + Container(
  174 + width: w(32),
  175 + height: w(16),
  176 + decoration: BoxDecoration(
  177 + borderRadius:
  178 + BorderRadius.circular(r(5)),
  179 + border: Border.all(
  180 + width: w(1),
  181 + color: MyColours.color_999999)),
  182 + // constraints: BoxConstraints(minWidth: w(20)),
  183 + child: TextField(
  184 + maxLines: 1,
  185 + controller: number,
  186 + // focusNode: _focusNode,
  187 + // autofocus: true,
  188 + inputFormatters: [
  189 + FilteringTextInputFormatter.allow(
  190 + RegExp(r'[0-9]')),
  191 + ],
  192 +
  193 + style: TextStyle(
  194 + color: MyColours.color_438E93,
  195 + fontSize: font(12)),
  196 + textAlign: TextAlign.center,
  197 + // textAlignVertical: TextAlignVertical.center,
  198 + decoration: InputDecoration(
  199 + hintText: "数量",
  200 + hintStyle: TextStyle(
  201 + color: MyColours.color_999999,
  202 + fontSize: font(12),
  203 + ),
  204 + // isCollapsed:
  205 + // true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
  206 + border: OutlineInputBorder(
  207 + borderSide: BorderSide.none),
  208 + contentPadding: EdgeInsets.zero,
  209 + ),
  210 + keyboardType: TextInputType.number,
  211 + textInputAction: TextInputAction.done,
  212 +
  213 + onChanged: (value) {
  214 + if (value != null && value != '') {
  215 + //用户输入的数据
  216 + // int input = int.parse(value);
  217 +
  218 + setState(() {});
  219 + }
  220 + },
  221 + onEditingComplete: () {
  222 + FocusScope.of(context).requestFocus(
  223 + FocusNode()); //点击空白处隐藏键盘
  224 + // contantShowModel.searchData(
  225 + // contantShowModel.controller.text);
  226 + // _searchSellerLocation();
  227 + // _focusNode.unfocus();
  228 + },
  229 + )),
  230 + // HEmptyView(8),
  231 + InkWell(
  232 + onTap: () {
  233 + if (number.text == '') {
  234 + number.text = '0';
  235 + }
  236 + int numStr = int.parse(number.text);
  237 + numStr++;
  238 + number.text = numStr.toString();
  239 + setState(() {});
  240 + },
  241 + child: Container(
  242 + height: w(48),
  243 + padding: EdgeInsets.only(left: w(8)),
  244 + child: Image.asset(
  245 + Utils.getImgPath('plan_dish_add'),
  246 + width: w(16),
  247 + ),
  248 + )),
  249 + ],
  250 + )),
  251 + _baseInputWidget('单 位', '点击输入计量单位', unit),
  252 + _baseInputWidget('做 法', '点击输入做法', practice),
  253 + VEmptyView(62),
  254 + Padding(
  255 + padding: EdgeInsets.symmetric(horizontal: w(80)),
  256 + child: RoundButton(
  257 + text: '保存到临时菜单中',
  258 + height: w(43),
  259 + gradientStart: MyColours.color_ffffff,
  260 + gradientEnd: MyColours.color_ffffff,
  261 + borderColor: MyColours.color_438E93,
  262 + textColor: MyColours.color_438E93,
  263 + fontSize: 32,
  264 + radius: r(5),
  265 + onPressed: () {
  266 + if (name.text.trim().length == 0) {
  267 + Utils.showToast('请输入菜品名称');
  268 + return;
  269 + }
  270 + if (price.text.trim().length == 0) {
  271 + Utils.showToast('请输入菜品价格');
  272 + return;
  273 + }
  274 + if (number.text.trim().length == 0) {
  275 + Utils.showToast('请输入菜品数量');
  276 + return;
  277 + }
  278 + if (unit.text.trim().length == 0) {
  279 + Utils.showToast('请输入计量单位');
  280 + return;
  281 + }
  282 + if (practice.text.trim().length == 0) {
  283 + Utils.showToast('请输入做法');
  284 + return;
  285 + }
  286 +
  287 + MenuSunModel menuSunModel = MenuSunModel();
  288 + menuSunModel.id = DateTime.now()
  289 + .millisecondsSinceEpoch
  290 + .toString();
  291 + menuSunModel.name = name.text;
  292 + menuSunModel.price = price.text;
  293 + menuSunModel.member_price = price.text;
  294 + menuSunModel.amount = number.text == ''
  295 + ? 0
  296 + : int.parse(number.text);
  297 + menuSunModel.amountC = TextEditingController();
  298 + menuSunModel.amountC.text =
  299 + menuSunModel.amount.toString();
  300 + allSum += menuSunModel.amount;
  301 + menuSunModel.unit = unit.text;
  302 + menuSunModel.practice = [practice.text];
  303 +
  304 + menuSunShort.add(menuSunModel);
  305 +
  306 + name.text = '';
  307 + price.text = '';
  308 + number.text = '';
  309 + unit.text = '';
  310 + practice.text = '';
  311 +
  312 + setState(() {});
  313 + bus.emit('refresh_data', menuSunShort);
  314 + },
  315 + )),
  316 + VEmptyView(26),
  317 + ],
  318 + ),
  319 + ),
  320 + MyDivider(
  321 + double.infinity,
  322 + w(1),
  323 + color: MyColours.color_DBDBDB,
  324 + ),
  325 + Container(
  326 + height: w(30),
  327 + padding: EdgeInsets.only(left: w(10), right: w(20)),
  328 + alignment: Alignment.centerLeft,
  329 + child: Row(
  330 + mainAxisAlignment: MainAxisAlignment.spaceBetween,
  331 + children: [
  332 + Text(
  333 + '已经添加的临时菜品',
  334 + style: TextStyle(
  335 + fontSize: font(16),
  336 + color: MyColours.color_515151,
  337 + fontWeight: FontWeight.bold),
  338 + ),
  339 + Text(
  340 + '${allSum ?? ''}道',
  341 + style: TextStyle(
  342 + fontSize: font(14),
  343 + color: MyColours.color_515151,
  344 + ),
  345 + )
  346 + ],
  347 + ),
  348 + ),
  349 + MyDivider(
  350 + double.infinity,
  351 + w(1),
  352 + color: MyColours.color_DBDBDB,
  353 + ),
  354 + ListView.builder(
  355 + controller: controller,
  356 + shrinkWrap: true,
  357 + itemCount: menuSunShort.length,
  358 + itemBuilder: (context, index) {
  359 + MenuSunModel menuSunModel = menuSunShort[index];
  360 + return Container(
  361 + padding: EdgeInsets.only(
  362 + left: w(20), top: w(13), bottom: w(13)),
  363 + decoration: BoxDecoration(
  364 + color: MyColours.color_ffffff,
  365 + border: Border(
  366 + bottom: BorderSide(
  367 + width: w(1),
  368 + color: index == menuSunShort.length
  369 + ? Colors.transparent
  370 + : MyColours.color_DBDBDB))),
  371 + child: Row(
  372 + children: [
  373 + Container(
  374 + constraints: BoxConstraints(maxWidth: w(80)),
  375 + child: Text(
  376 + menuSunModel.name,
  377 + // 'fdfafaf',
  378 + maxLines: 10,
  379 + overflow: TextOverflow.ellipsis,
  380 + style: TextStyle(
  381 + fontSize: font(14),
  382 + color: MyColours.color_515151),
  383 + )),
  384 + // HEmptyView(8),
  385 + // _laduWidget(),
  386 + Spacer(),
  387 + Text(
  388 + '${menuSunModel.price}元/${menuSunModel.unit}',
  389 + // '38元/份',
  390 + maxLines: 2,
  391 + overflow: TextOverflow.ellipsis,
  392 + style: TextStyle(
  393 + fontSize: font(12),
  394 + color: MyColours.color_999999),
  395 + ),
  396 + HEmptyView(28),
  397 + Text(
  398 + '${menuSunModel.member_price}元/${menuSunModel.unit}',
  399 + // '38元/份',
  400 + maxLines: 2,
  401 + overflow: TextOverflow.ellipsis,
  402 + style: TextStyle(
  403 + fontSize: font(10),
  404 + color: MyColours.color_8EBBBE),
  405 + ),
  406 +
  407 + InkWell(
  408 + onTap: () {
  409 + if (menuSunModel.amount == 0) {
  410 + return;
  411 + }
  412 + menuSunModel.amount--;
  413 + menuSunModel.amountC.text =
  414 + '${menuSunModel.amount}';
  415 + allSum--;
  416 + // menuModel.allSum--;
  417 + // carSum--;
  418 +
  419 + // // priceSum -= double.parse(
  420 + // // menuSunModel.price);
  421 + // // planDishC.text =
  422 + // // priceSum.toString();
  423 + // // memberPriceSum -=
  424 + // // double.parse(menuSunModel
  425 + // // .member_price);
  426 + // _calculatePrice();
  427 + // if (menuSunModel.amount == 0) {
  428 + // //把当前菜品从列表中去除
  429 + // // MenuSunModel menuSunModelFTemp = menuSunModelF
  430 + // // dataLocalShowMore[indexMore];
  431 + // dataLocalShowOne[indexOne]
  432 + // .cookbooklist
  433 + // .removeAt(indexReal); //移除当前行
  434 + // //判断当前类没有cookbooklist,则删除当前类
  435 + // if (dataLocalShowOne[indexOne]
  436 + // .cookbooklist
  437 + // .length ==
  438 + // 0) {
  439 + // dataLocalShowOne.removeAt(indexOne);
  440 + // }
  441 + // }
  442 + setState(() {});
  443 + bus.emit('refresh_data', menuSunShort);
  444 + },
  445 + child: Container(
  446 + padding: EdgeInsets.only(
  447 + left: w(10), right: w(4)),
  448 + child: Image.asset(
  449 + Utils.getImgPath('plan_dish_minus'),
  450 + width: w(16),
  451 + ))),
  452 +
  453 + Container(
  454 + width: w(32),
  455 + height: w(16),
  456 + decoration: BoxDecoration(
  457 + borderRadius: BorderRadius.circular(r(5)),
  458 + border: Border.all(
  459 + width: w(1),
  460 + color: MyColours.color_999999)),
  461 + // constraints: BoxConstraints(minWidth: w(20)),
  462 + child: TextField(
  463 + maxLines: 1,
  464 + controller: menuSunModel.amountC,
  465 + // focusNode: _focusNode,
  466 + // autofocus: true,
  467 + inputFormatters: [
  468 + FilteringTextInputFormatter.allow(
  469 + RegExp(r'[0-9]')),
  470 + ],
  471 +
  472 + style: TextStyle(
  473 + color: MyColours.color_438E93,
  474 + fontSize: font(12)),
  475 + textAlign: TextAlign.center,
  476 + // textAlignVertical: TextAlignVertical.center,
  477 + decoration: InputDecoration(
  478 + hintText: "数量",
  479 + hintStyle: TextStyle(
  480 + color: MyColours.color_999999,
  481 + fontSize: font(12),
  482 + ),
  483 + // isCollapsed:
  484 + // true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
  485 + border: OutlineInputBorder(
  486 + borderSide: BorderSide.none),
  487 + contentPadding: EdgeInsets.zero,
  488 + ),
  489 + keyboardType: TextInputType.number,
  490 + textInputAction: TextInputAction.done,
  491 +
  492 + onChanged: (value) {
  493 + // if (value != null && value != '') {
  494 + // //用户输入的数据
  495 + // int input = int.parse(value);
  496 + // //减去当前数据
  497 +
  498 + // menuModel.allSum -= menuSunModel.amount;
  499 +
  500 + // carSum -= menuSunModel.amount;
  501 +
  502 + // if (input == 0) {
  503 + // //把当前菜品从列表中去除
  504 +
  505 + // dataLocalShowOne[indexOne]
  506 + // .cookbooklist
  507 + // .removeAt(indexReal); //移除当前行
  508 + // //判断当前类没有cookbooklist,则删除当前类
  509 + // if (dataLocalShowOne[indexOne]
  510 + // .cookbooklist
  511 + // .length ==
  512 + // 0) {
  513 + // dataLocalShowOne.removeAt(indexOne);
  514 + // }
  515 + // } else {
  516 + // menuModel.allSum += input;
  517 +
  518 + // carSum += input;
  519 + // }
  520 +
  521 + // menuSunModel.amount = int.parse(value);
  522 + // _calculatePrice();
  523 + // setState(() {});
  524 + // }
  525 + },
  526 + onEditingComplete: () {
  527 + FocusScope.of(context).requestFocus(
  528 + FocusNode()); //点击空白处隐藏键盘
  529 + // contantShowModel.searchData(
  530 + // contantShowModel.controller.text);
  531 + // _searchSellerLocation();
  532 + // _focusNode.unfocus();
  533 + },
  534 + )),
  535 +
  536 + InkWell(
  537 + onTap: () {
  538 + menuSunModel.amount++;
  539 + menuSunModel.amountC.text =
  540 + '${menuSunModel.amount}';
  541 + allSum++;
  542 + // menuModel.allSum++;
  543 + // carSum++;
  544 +
  545 + // _calculatePrice();
  546 +
  547 + setState(() {});
  548 + bus.emit('refresh_data', menuSunShort);
  549 + },
  550 + child: Container(
  551 + padding: EdgeInsets.only(
  552 + left: w(4), right: w(18)),
  553 + child: Image.asset(
  554 + Utils.getImgPath('plan_dish_add'),
  555 + width: w(16),
  556 + ))),
  557 + ],
  558 + ),
  559 + );
  560 + })
  561 + ],
  562 + ),
  563 + )),
  564 + Container(
  565 + color: MyColours.color_ffffff,
  566 + padding: EdgeInsets.only(
  567 + top: w(12), bottom: w(25), left: w(23), right: w(23)),
  568 + child: Row(
  569 + // mainAxisAlignment: MainAxisAlignment.spaceBetween,
  570 + children: [
  571 + RoundButton(
  572 + text: '返回',
  573 + gradientStart: MyColours.color_ffffff,
  574 + gradientEnd: MyColours.color_ffffff,
  575 + borderColor: MyColours.color_438E93,
  576 + textColor: MyColours.color_438E93,
  577 + width: w(100),
  578 + height: w(43),
  579 + radius: r(5),
  580 + fontSize: 32,
  581 + isBold: false,
  582 + onPressed: () {
  583 + Navigator.pop(context);
  584 + }),
  585 + HEmptyView(30),
  586 + Expanded(
  587 + child: RoundButton(
  588 + text: '确定',
  589 + gradientStart: MyColours.color_438E93,
  590 + gradientEnd: MyColours.color_438E93,
  591 + height: w(43),
  592 + radius: r(5),
  593 + fontSize: 36,
  594 + isBold: false,
  595 + onPressed: () {
  596 + Navigator.pop(context);
  597 + }))
  598 + ])),
  599 + ],
  600 + ),
  601 + ),
  602 + );
  603 + }
  604 +}
@@ -169,6 +169,36 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> { @@ -169,6 +169,36 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> {
169 // maxIndex++; 169 // maxIndex++;
170 // } 170 // }
171 } else if (element.className == '临时加菜') { 171 } else if (element.className == '临时加菜') {
  172 + //临时加菜
  173 + bool hasmMenu =
  174 + element.cookbooklist.any(((value) => value.amount > 0));
  175 + if (hasmMenu) {
  176 + //临时加菜此类有选中菜品
  177 + MenuModel menuModel = MenuModel();
  178 + menuModel.className = element.className;
  179 + menuModel.classLabel = element.classLabel;
  180 + menuModel.classType = element.classType;
  181 + menuModel.id = element.id;
  182 + menuModel.order = element.order;
  183 + menuModel.sellerid = element.sellerid;
  184 + menuModel.status = element.status;
  185 + menuModel.cookbooklist = [];
  186 + List<MenuSunModel> cookbooklist = [];
  187 + int allSum = 0;
  188 + element.cookbooklist.forEach((value) {
  189 + if (value.amount > 0) {
  190 + allSum += value.amount;
  191 + // priceSum += double.parse(value.price) * value.amount;
  192 + // memberPriceSum +=
  193 + // double.parse(value.member_price) * value.amount;
  194 + carSum += value.amount;
  195 + cookbooklist.add(value);
  196 + }
  197 + });
  198 + menuModel.allSum = allSum;
  199 + menuModel.cookbooklist.addAll(cookbooklist);
  200 + dataLocalShowOne.add(menuModel);
  201 + }
172 } else { 202 } else {
173 //单菜 203 //单菜
174 bool hasmMenu = 204 bool hasmMenu =
@@ -409,6 +439,9 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> { @@ -409,6 +439,9 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> {
409 } 439 }
410 //单品 440 //单品
411 List<MenuModel> cooklistdata = []; 441 List<MenuModel> cooklistdata = [];
  442 + //临时加菜
  443 + List<MenuSunModel> temporarylist = [];
  444 +
412 temp.forEach((element) { 445 temp.forEach((element) {
413 if (element.className == '套餐') { 446 if (element.className == '套餐') {
414 List<MenuSunModel> packagelist = []; 447 List<MenuSunModel> packagelist = [];
@@ -434,18 +467,30 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> { @@ -434,18 +467,30 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> {
434 } else { 467 } else {
435 params['plan_list'] = null; 468 params['plan_list'] = null;
436 } 469 }
  470 + } else if (element.className == '临时加菜') {
  471 + //临时加菜
  472 +
  473 + temporarylist.addAll(element.cookbooklist);
  474 + if (temporarylist.length > 0) {
  475 + temporarylist.removeWhere((value) => value.amount == 0);
  476 + if (temporarylist.length > 0) {
  477 + params['temporary_list'] = json.encode(temporarylist);
  478 + } else {
  479 + params['temporary_list'] = null;
  480 + }
  481 + }
437 } else { 482 } else {
438 //单品 483 //单品
439 cooklistdata.add(element); 484 cooklistdata.add(element);
440 - }  
441 - if (cooklistdata.length > 0) {  
442 - cooklistdata.forEach((cooklist) {  
443 - cooklist.cookbooklist.removeWhere((element) => element.amount == 0);  
444 - });  
445 if (cooklistdata.length > 0) { 485 if (cooklistdata.length > 0) {
446 - params['cooklist'] = json.encode(cooklistdata);  
447 - } else {  
448 - params['cooklist'] = null; 486 + cooklistdata.forEach((cooklist) {
  487 + cooklist.cookbooklist.removeWhere((element) => element.amount == 0);
  488 + });
  489 + if (cooklistdata.length > 0) {
  490 + params['cooklist'] = json.encode(cooklistdata);
  491 + } else {
  492 + params['cooklist'] = null;
  493 + }
449 } 494 }
450 } 495 }
451 }); 496 });
@@ -1892,7 +1937,8 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> { @@ -1892,7 +1937,8 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> {
1892 remark: planDishRemark.text, 1937 remark: planDishRemark.text,
1893 priceSum: priceSum.toString(), 1938 priceSum: priceSum.toString(),
1894 memberPriceSum: memberPriceSum.toString(), 1939 memberPriceSum: memberPriceSum.toString(),
1895 - planDishText: planDishC.text); 1940 + planDishText: planDishC.text,
  1941 + detailEntity: widget.detailEntity);
1896 }, 1942 },
1897 ), 1943 ),
1898 HEmptyView(30), 1944 HEmptyView(30),
  1 +import 'dart:ffi';
  2 +
1 import 'package:flutter/material.dart'; 3 import 'package:flutter/material.dart';
2 import 'package:one_key/constant/state.dart'; 4 import 'package:one_key/constant/state.dart';
3 import 'package:one_key/models/plan_cook_by_rid_model.dart'; 5 import 'package:one_key/models/plan_cook_by_rid_model.dart';
@@ -114,7 +116,7 @@ class PlanDishProvider extends ChangeNotifier { @@ -114,7 +116,7 @@ class PlanDishProvider extends ChangeNotifier {
114 // menuModel = []; 116 // menuModel = [];
115 117
116 if (baseResp != null && baseResp.code == Constant.status_success) { 118 if (baseResp != null && baseResp.code == Constant.status_success) {
117 - if (baseResp.data == false) { 119 + if (baseResp.data is Bool) {
118 // planCookByRidSunModel = PlanCookByRidSunModel(); 120 // planCookByRidSunModel = PlanCookByRidSunModel();
119 121
120 } else { 122 } else {
@@ -1273,7 +1273,7 @@ class NavigatorUtil { @@ -1273,7 +1273,7 @@ class NavigatorUtil {
1273 // "${Routes.order_advance_home_page}?tids=$tids&tableidNow=$tableidNow&fromPage=$fromPage&canChoose=$canChoose&object=${FluroConvertUtils.object2string(object)}"); 1273 // "${Routes.order_advance_home_page}?tids=$tids&tableidNow=$tableidNow&fromPage=$fromPage&canChoose=$canChoose&object=${FluroConvertUtils.object2string(object)}");
1274 // } 1274 // }
1275 return _navigateTo(context, 1275 return _navigateTo(context,
1276 - "${Routes.order_preview_page}?object=${FluroConvertUtils.object2string(object)}&priceSum=$priceSum&memberPriceSum=$memberPriceSum&planDishText=$planDishText&name=${Uri.encodeComponent(name)}&remark=${Uri.encodeComponent(remark)}&detail=${FluroConvertUtils.object2string(detailEntity)}", 1276 + "${Routes.order_preview_page}?object=${FluroConvertUtils.object2string(object)}&priceSum=$priceSum&memberPriceSum=$memberPriceSum&planDishText=${Uri.encodeComponent(planDishText)}&name=${Uri.encodeComponent(name)}&remark=${Uri.encodeComponent(remark)}&detail=${FluroConvertUtils.object2string(detailEntity)}",
1277 replace: replace); 1277 replace: replace);
1278 } 1278 }
1279 1279
@@ -1349,4 +1349,27 @@ class NavigatorUtil { @@ -1349,4 +1349,27 @@ class NavigatorUtil {
1349 "${Routes.plan_dish_edit_page}?isMine=${isMine}&isEdit=${isEdit}&onlyShow=${onlyShow}", 1349 "${Routes.plan_dish_edit_page}?isMine=${isMine}&isEdit=${isEdit}&onlyShow=${onlyShow}",
1350 replace: replace); 1350 replace: replace);
1351 } 1351 }
  1352 +
  1353 + ///经理排菜-临时菜新增页
  1354 +
  1355 + static Future<dynamic> goOrderCreateTemporaryPage(
  1356 + BuildContext context, {
  1357 + replace = false,
  1358 + Map object,
  1359 + }) {
  1360 + // if (invoice != null) {
  1361 + // return _navigateTo(context,
  1362 + // "${Routes.plan_dish_edit_page}?invoice=${FluroConvertUtils.object2string(invoice)}",
  1363 + // replace: replace);
  1364 + // }
  1365 + // if (sunList != null) {
  1366 + // return _navigateTo(context,
  1367 + // "${Routes.order_create_temporary_page}?sunList=${FluroConvertUtils.object2string(sunList)}&isMine=${isMine}&isEdit=${isEdit}&onlyShow=${onlyShow}",
  1368 + // replace: replace);
  1369 +
  1370 + // }
  1371 + return _navigateTo(context,
  1372 + "${Routes.order_create_temporary_page}?object=${FluroConvertUtils.object2string(object)}",
  1373 + replace: replace);
  1374 + }
1352 } 1375 }
@@ -185,6 +185,7 @@ import '../pages/my/plan_dish/plan_new_dish_first_page.dart'; @@ -185,6 +185,7 @@ import '../pages/my/plan_dish/plan_new_dish_first_page.dart';
185 import '../pages/my/plan_dish/plan_new_dish_page.dart'; 185 import '../pages/my/plan_dish/plan_new_dish_page.dart';
186 import '../pages/my/table_manage/merge_table_select_page.dart'; 186 import '../pages/my/table_manage/merge_table_select_page.dart';
187 import '../pages/order_advance/order_advance_home_page.dart'; 187 import '../pages/order_advance/order_advance_home_page.dart';
  188 +import '../pages/order_advance/order_create_temporary_page.dart';
188 import '../pages/order_advance/order_edit_list_show_page.dart'; 189 import '../pages/order_advance/order_edit_list_show_page.dart';
189 import '../pages/order_advance/order_preview_page.dart'; 190 import '../pages/order_advance/order_preview_page.dart';
190 import '../provider/feast_model.dart'; 191 import '../provider/feast_model.dart';
@@ -2198,3 +2199,50 @@ var planDishEidtPageHandle = new Handler( @@ -2198,3 +2199,50 @@ var planDishEidtPageHandle = new Handler(
2198 sunListPlan: sunListPlan, 2199 sunListPlan: sunListPlan,
2199 onlyShow: onlyShow)); 2200 onlyShow: onlyShow));
2200 }); 2201 });
  2202 +
  2203 +///经理排菜--临时菜新增页
  2204 +var orderCreateTemporaryPageHandle = new Handler(
  2205 + handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
  2206 + // String fromPage = params["fromPage"].first;
  2207 + // String tids = params["tids"].first;
  2208 +
  2209 + // String tableidNow = params["tableidNow"].first;
  2210 + // bool canChoose = params["canChoose"].first == "true" ? true : false;
  2211 + // List<TableList> res = [];
  2212 + // if (params.keys.contains('object')) {
  2213 + // Map object = FluroConvertUtils.string2map(params["object"].first);
  2214 + // List temp = object['object'];
  2215 +
  2216 + // for (var item in temp) {
  2217 + // res.add(TableList.fromJson(item));
  2218 + // }
  2219 + // }
  2220 + // bool isMine = FluroConvertUtils.string2bool(params["isMine"].first);
  2221 + // bool isEdit = FluroConvertUtils.string2bool(params["isEdit"].first);
  2222 + // bool onlyShow = FluroConvertUtils.string2bool(params["onlyShow"].first);
  2223 +
  2224 + // SunListPlan sunListPlan;
  2225 +
  2226 + // if (params.keys.contains('sunList')) {
  2227 + // sunListPlan = SunListPlan.fromJson(json.decode(
  2228 + // FluroConvertUtils.fluroCnParamsDecode(params["sunList"].first)));
  2229 + // }
  2230 + List<MenuModel> res = [];
  2231 + // String planDishPrice = '';
  2232 + if (params.keys.contains('object')) {
  2233 + Map object = FluroConvertUtils.string2map(params["object"].first);
  2234 + List temp = object['object'];
  2235 +
  2236 + // planDishPrice = params["planDishPrice"].first;
  2237 +
  2238 + for (var item in temp) {
  2239 + // MenuModel menuModel = MenuModel.fromJson2(item);
  2240 + // res.add(menuModel);
  2241 + // print(res);
  2242 + res.add(MenuModel.fromJson2(item));
  2243 + }
  2244 + }
  2245 +
  2246 + return ChangeNotifierProvider<PlanDishProvider>(
  2247 + create: (_) => PlanDishProvider(), child: OrderCreateTemporaryPage(data:res));
  2248 +});
@@ -181,6 +181,8 @@ class Routes { @@ -181,6 +181,8 @@ class Routes {
181 static String plan_dish_create_select_type_page = 181 static String plan_dish_create_select_type_page =
182 "/plan_dish_create_select_type_page"; //经理排菜---类型选择页 182 "/plan_dish_create_select_type_page"; //经理排菜---类型选择页
183 static String plan_dish_edit_page = "/plan_dish_eidt_page"; //经理排菜---编辑页 183 static String plan_dish_edit_page = "/plan_dish_eidt_page"; //经理排菜---编辑页
  184 + static String order_create_temporary_page = "/order_create_temporary_page"; //经理排菜---临时菜新建页
  185 +
184 186
185 static void configureRoutes(FluroRouter router) { 187 static void configureRoutes(FluroRouter router) {
186 router.notFoundHandler = new Handler( 188 router.notFoundHandler = new Handler(
@@ -356,5 +358,9 @@ class Routes { @@ -356,5 +358,9 @@ class Routes {
356 handler: planDishCreateSelectTypePageHandle); 358 handler: planDishCreateSelectTypePageHandle);
357 359
358 router.define(plan_dish_edit_page, handler: planDishEidtPageHandle); 360 router.define(plan_dish_edit_page, handler: planDishEidtPageHandle);
  361 +
  362 + router.define(order_create_temporary_page, handler: orderCreateTemporaryPageHandle);
  363 +
  364 +
359 } 365 }
360 } 366 }