Commit a3281935c34f69e890b9ab17d436c3053083da70

Authored by wdn127929
1 parent 6d107492

排菜套餐列表

... ... @@ -38,6 +38,22 @@ class MenuModel {
}
}
MenuModel.fromJson2(Map<String, dynamic> json) {
id = json['id'];
sellerid = json['sellerid'];
className = json['class_name'];
classLabel = json['class_label'];
order = json['order'];
status = json['status'];
classType = json['class_type'];
if (json['cookbooklist'] != null) {
cookbooklist = [];
json['cookbooklist'].forEach((v) {
cookbooklist.add(new MenuSunModel.fromJson2(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
... ... @@ -84,7 +100,7 @@ class MenuSunModel {
int isSpec;
List practice;
int amount = 0; //菜品数量
int amount; //菜品数量
MenuSunModel({
this.id,
... ... @@ -114,6 +130,7 @@ class MenuSunModel {
this.spec,
this.isSpec,
this.practice,
this.amount = 0,
});
MenuSunModel.fromJson(Map<String, dynamic> json) {
... ... @@ -145,6 +162,36 @@ class MenuSunModel {
practice = json['practice'];
}
MenuSunModel.fromJson2(Map<String, dynamic> json) {
id = json['id'];
sellerid = json['sellerid'];
mid = json['mid'];
lid = json['lid'];
unit = json['unit'];
name = json['name'];
price = json['price'];
member_price = json['member_price'];
first_name = json['first_name'];
search_code = json['search_code'];
channel = json['channel'];
dishesvideo = json['dishesvideo'];
dishesgif = json['dishesgif'];
status = json['status'];
setup = json['setup'];
give = json['give'];
clear_num = json['clear_num'];
record_num = json['record_num'];
image = json['image'];
is_weigh = json['is_weigh'];
desc = json['desc'];
order_o = json['order_o'];
cdate = json['cdate'];
spec = json['spec'];
isSpec = json['isSpec'];
practice = json['practice'];
amount = json['amount']??0;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
... ... @@ -174,6 +221,7 @@ class MenuSunModel {
data['spec'] = this.spec;
data['isSpec'] = this.isSpec;
data['practice'] = this.practice;
data['amount'] = this.amount;
return data;
}
}
... ...
import 'dart:convert';
import 'package:one_key/models/cookbook_model.dart';
class PlanCookListModel {
int ret;
PlanCookListSunModel data;
String msg;
PlanCookListModel({this.ret, this.data, this.msg});
PlanCookListModel.fromJson(Map<String, dynamic> json) {
ret = json['ret'];
data = json['data'] != null
? new PlanCookListSunModel.fromJson(json['data'])
: null;
msg = json['msg'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['ret'] = this.ret;
if (this.data != null) {
data['data'] = this.data.toJson();
}
data['msg'] = this.msg;
return data;
}
}
class PlanCookListSunModel {
List<SunList> packageList;
List<SunList> plancookList;
PlanCookListSunModel({this.packageList, this.plancookList});
PlanCookListSunModel.fromJson(Map<String, dynamic> json) {
if (json['package_list'] != null) {
packageList = <SunList>[];
json['package_list'].forEach((v) {
packageList.add(new SunList.fromJson(v));
});
}
if (json['plancook_list'] != null) {
plancookList = <SunList>[];
json['plancook_list'].forEach((v) {
plancookList.add(new SunList.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.packageList != null) {
data['package_list'] = this.packageList.map((v) => v.toJson()).toList();
}
if (this.plancookList != null) {
data['plancook_list'] = this.plancookList.map((v) => v.toJson()).toList();
}
return data;
}
}
class SunList {
String id;
String sellerid;
String uid;
String pname;
String type;
String status;
String pnum;
String menuPrice;
String memberPrice;
String planPrice;
List<MenuModel> cookList;
String isDel;
String cdate;
SunList(
{this.id,
this.sellerid,
this.uid,
this.pname,
this.type,
this.status,
this.pnum,
this.menuPrice,
this.memberPrice,
this.planPrice,
this.cookList,
this.isDel,
this.cdate});
SunList.fromJson(Map<String, dynamic> json1) {
id = json1['id'];
sellerid = json1['sellerid'];
uid = json1['uid'];
pname = json1['pname'];
type = json1['type'];
status = json1['status'];
pnum = json1['pnum'];
menuPrice = json1['menu_price'];
memberPrice = json1['member_price'];
planPrice = json1['plan_price'];
// cookList = json1['cook_list'];
if (json1['cook_list'] != null) {
cookList = <MenuModel>[];
json.decode(json1['cook_list']).forEach((v) {
cookList.add(new MenuModel.fromJson2(v));
});
}
isDel = json1['is_del'];
cdate = json1['cdate'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['sellerid'] = this.sellerid;
data['uid'] = this.uid;
data['pname'] = this.pname;
data['type'] = this.type;
data['status'] = this.status;
data['pnum'] = this.pnum;
data['menu_price'] = this.menuPrice;
data['member_price'] = this.memberPrice;
data['plan_price'] = this.planPrice;
data['cook_list'] = this.cookList;
data['is_del'] = this.isDel;
data['cdate'] = this.cdate;
return data;
}
}
... ...
... ... @@ -338,5 +338,10 @@ class HttpUrl {
static const String set_cookbook_class_by_id =
"?service=App.Cookbook.SetCookbookClassById"; // 修改菜品分类
static const String set_plan_cook =
"?service=App.PlanCook.SetPlanCook"; // 添加排菜/套餐
static const String get_plan_cook_list =
"?service=App.PlanCook.GetPlanCookList"; // 排菜/套餐列表
}
... ...
... ... @@ -184,7 +184,7 @@ class _PlanDishCreateSelectTypePageState
onPressed: () async {
bool needRefresh = await NavigatorUtil.goPlanDishEditPage(
context,
isMine: selectF);
isMine: selectF,isEdit:true);
print(needRefresh);
if (needRefresh != null && needRefresh) {
Navigator.pop(context);
... ...
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/provider/plan_dish_provider.dart';
... ... @@ -36,7 +39,9 @@ import 'package:provider/provider.dart';
class PlanDishEidtPage extends StatefulWidget {
final bool isMine;
PlanDishEidtPage({Key key, this.isMine = true}) : super(key: key);
final bool isEdit;
PlanDishEidtPage({Key key, this.isMine = false, this.isEdit = true})
: super(key: key);
@override
_PlanDishEidtPageState createState() => _PlanDishEidtPageState();
... ... @@ -60,10 +65,26 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> {
List labelList = ['店内通用套餐', '自定义排菜单'];
int labelSelIndex = 0;
String labelShow;
TextEditingController pNumC = TextEditingController(); //就餐人数
String priceSum = '0'; //菜品总价
String memberPriceSum = '0'; //会员价
TextEditingController dishPriceC = TextEditingController(); //排菜价格
int pNum = 0; //人数
List<MenuModel> menuModel; //菜品数据
@override
void initState() {
super.initState();
labelShow = labelList[labelSelIndex];
if (widget.isEdit) {
if (widget.isMine == true) {
labelShow = '自定义排菜单';
} else {
labelShow = '店内通用套餐';
}
} else {
labelShow = labelList[labelSelIndex];
}
_nameFocusNode.addListener(() {
if (_nameFocusNode.hasFocus) {
//有焦点
... ... @@ -92,36 +113,33 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> {
//创建新券 客户经理创建活动
_createNewdish() async {
// FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
// Map<String, String> params = {
// "uid": Provider.of<UserModel>(context, listen: false).user.openid,
// "aname": _dishNameEditControl.text.trim(),
// "desc": _dishRequireEditControl.text.trim(),
// "stime": fromDate == '点击选择'
// ? ""
// : '${DateUtil.getDateMsByTimeStr(fromDate) / 1000}',
// "etime": endDate == '点击选择'
// ? ''
// : '${DateUtil.getDateMsByTimeStr(endDate) / 1000}',
// "explain": _dishExplainEditControl.text,
// "is_open": swichState ? "1" : "0",
// "status": swichState ? "1" : "0",
// 'is_type': widget.isMine ? "2" : "1"
// };
FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
Map<String, String> params = {
'sellerid': Provider.of<UserModel>(context, listen: false).user.sellerid,
"uid": Provider.of<UserModel>(context, listen: false).user.openid,
"pname": _dishNameEditControl.text.trim(),
'type': widget.isMine ? "2" : "1",
"status": swichState ? "1" : "0",
'pnum': pNumC.text,
"menu_price": priceSum,
"member_price": memberPriceSum,
"plan_price": dishPriceC.text,
"cook_list": json.encode(menuModel),
};
// if (!widget.isMine) {
// params['is_examine'] = swichHexiao ? "1" : "0";
// params['uid_list'] = uids;
// }
// bool isSuccess = await dishProvider.createCustomerActivity(context, params);
// if (isSuccess) {
// //成功之后跳回前一个页面
// // bus.emit('refresh_dish_list');
// EventBus().emit('refresh_dish_invitation');
// bus.emit('refresh_dish_list_f');
bool isSuccess = await dishProvider.setPlanCook(context, params);
if (isSuccess) {
//成功之后跳回前一个页面
// bus.emit('refresh_dish_list');
// EventBus().emit('refresh_dish_invitation');
// bus.emit('refresh_dish_list_f');
// bus.emit('refresh_table_m_dish');
// Navigator.pop(context, true);
// }
// bus.emit('refresh_table_m_dish');
Navigator.pop(context, true);
}
}
///输入框
... ... @@ -157,6 +175,9 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> {
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32),
),
inputFormatters: title.contains('排菜名称')
? [LengthLimitingTextInputFormatter(15)]
: [],
focusNode:
title.contains('排菜名称') ? _nameFocusNode : _requireFocusNode,
decoration: InputDecoration(
... ... @@ -414,24 +435,27 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> {
color: MyColours.color_DBDBDB),
InkWell(
onTap: () {
FocusScope.of(context)
.requestFocus(FocusNode()); //隐藏键盘
DialogUtil.showSelectCusmanDialog(
context,
labelList.map((item) {
return item;
}).toList(), (value) {
if (value != null) {
setState(() {
labelSelIndex = value.first;
labelShow = labelList[labelSelIndex];
});
}
},
selecteds: labelSelIndex == null
? []
: [labelSelIndex])
.then((value) {});
if (!widget.isEdit) {
FocusScope.of(context)
.requestFocus(FocusNode()); //隐藏键盘
DialogUtil.showSelectCusmanDialog(
context,
labelList.map((item) {
return item;
}).toList(), (value) {
if (value != null) {
setState(() {
labelSelIndex = value.first;
labelShow =
labelList[labelSelIndex];
});
}
},
selecteds: labelSelIndex == null
? []
: [labelSelIndex])
.then((value) {});
}
},
child: Container(
height: ScreenUtil().setWidth(48 * 2),
... ... @@ -466,12 +490,18 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> {
fontSize: ScreenUtil().setSp(32),
),
)),
HEmptyView(10),
Image.asset(
Utils.getImgPath('c_arrow_down'),
width: ScreenUtil().setWidth(24),
// height: ScreenUtil().setWidth(10),
)
!widget.isEdit
? HEmptyView(10)
: SizedBox(),
!widget.isEdit
? Image.asset(
Utils.getImgPath(
'c_arrow_down'),
width:
ScreenUtil().setWidth(24),
// height: ScreenUtil().setWidth(10),
)
: SizedBox()
],
),
)),
... ... @@ -500,11 +530,24 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> {
),
),
Spacer(),
Image.asset(
Utils.getImgPath('plan_dish_minus'),
width: w(16),
InkWell(
onTap: () {
if (pNum == 0) {
return;
}
pNum--;
pNumC.text = '${pNum}';
},
child: Container(
height: w(48),
padding: EdgeInsets.symmetric(
horizontal: w(23)),
child: Image.asset(
Utils.getImgPath('plan_dish_minus'),
width: w(16),
),
),
),
HEmptyView(46),
Container(
// constraints: BoxConstraints(
// minWidth: w(34),
... ... @@ -521,9 +564,13 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> {
// constraints: BoxConstraints(minWidth: w(20)),
child: TextField(
maxLines: 1,
// controller:
controller: pNumC,
// focusNode: _focusNode,
// autofocus: true,
inputFormatters: [
FilteringTextInputFormatter.allow(
RegExp(r'[0-9]')),
],
style: TextStyle(
color: MyColours.color_438E93,
... ... @@ -547,6 +594,19 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> {
TextInputAction.done,
onChanged: (value) {
// bool isNumber = Utils.isNumeric(
// value); //判断输入的内容是否是数字
// if (!isNumber) {
// Utils.showToast('请输入数字');
// pNumC.text = '';
// return;
// } else {
if (value != null &&
value != '') {
pNum = int.parse(value);
}
// }
// setState(() {});
// _searchSellerLocation();
// customerProvider.searchData(value);
... ... @@ -561,10 +621,19 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> {
// _focusNode.unfocus();
},
)),
HEmptyView(46),
Image.asset(
Utils.getImgPath('plan_dish_add'),
width: w(16),
InkWell(
onTap: () {
pNum++;
pNumC.text = '${pNum}';
},
child: Container(
height: w(48),
padding: EdgeInsets.only(left: w(23)),
child: Image.asset(
Utils.getImgPath('plan_dish_add'),
width: w(16),
),
),
),
],
)),
... ... @@ -586,7 +655,7 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> {
),
Spacer(),
Text(
'0元/0元',
'${priceSum}元/${memberPriceSum}元',
style: TextStyle(
color: MyColours.color_99515151,
fontSize: ScreenUtil().setSp(32)),
... ... @@ -609,7 +678,7 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> {
Expanded(
child: TextField(
maxLines: 1,
// controller: controller,
controller: dishPriceC,
// focusNode: _focusNode,
// autofocus: true,
... ... @@ -661,27 +730,48 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> {
color: MyColours.color_DBDBDB),
VEmptyView(24),
_select('菜品', '编辑', () async {
Map temp =
await NavigatorUtil.goPlanNewDishPage(
context);
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
Map temp;
if (menuModel == null) {
temp = await NavigatorUtil.goPlanNewDishPage(
context,
);
} else {
temp = await NavigatorUtil.goPlanNewDishPage(
context,
object: {'object': menuModel},
planDishPrice: dishPriceC.text);
}
if (temp != null) {
int priceSum = temp['priceSum'];
int memberPriceSum = temp['memberPriceSum'];
double priceSumTemp = temp['priceSum'];
double memberPriceSumTemp =
temp['memberPriceSum'];
String planDishSum = temp['planDishSum'];
List<MenuModel> menuModel =
temp['menu']; //菜品数据
menuModel = temp['menu']; //菜品数据
print(priceSum);
print(memberPriceSum);
print(planDishSum);
print(menuModel);
// 刷新页面***************
priceSum = priceSumTemp.toString();
memberPriceSum =
memberPriceSumTemp.toString();
dishPriceC.text = planDishSum;
String dish = '';
menuModel.forEach((element) {
element.cookbooklist.forEach((cookbook) {
if (cookbook.amount > 0) {
dish += cookbook.name + '、';
}
});
});
if (dish.endsWith('、')) {
dish = dish.substring(0, dish.length - 1);
}
_dishExplainEditControl.text = dish;
}
}),
_explain('券说明', '点击上面右侧的“编辑”,开始选菜吧!'),
... ...
... ... @@ -11,6 +11,7 @@ import 'package:one_key/widgets/round_button.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
import '../../../models/plan_cook_list_model.dart';
import '../../../provider/user_model.dart';
import '../../../utils/screen_util.dart';
... ... @@ -18,7 +19,7 @@ class PlanDishItem extends StatefulWidget {
// final String from;
final VoidCallback onPressedDel;
final VoidCallback onPressedReUse;
// final CouponSunModel couponSonModel;
final SunList sunList;
// final bool showBtn;
// final bool showCheck;
PlanDishItem({
... ... @@ -26,7 +27,7 @@ class PlanDishItem extends StatefulWidget {
// this.from,
this.onPressedDel,
this.onPressedReUse,
// this.couponSonModel,
this.sunList,
// this.showBtn = false,
// this.showCheck = false
}) : super(key: key);
... ... @@ -60,6 +61,17 @@ class _PlanDishItemState extends State<PlanDishItem> {
// context);
// }
UserModel userModel = Provider.of<UserModel>(context, listen: false);
String dish = '';
widget.sunList.cookList.forEach((element) {
element.cookbooklist.forEach((value) {
if (value.amount > 0) {
dish += value.name + '、';
}
});
});
if (dish.endsWith('、')) {
dish = dish.substring(0, dish.length - 1);
}
return InkWell(
// onTap: widget.onPressed,
child: Container(
... ... @@ -91,8 +103,8 @@ class _PlanDishItemState extends State<PlanDishItem> {
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(24)),
decoration: BoxDecoration(
color: true //开启可用
? true //店铺
color: widget.sunList.status == '1' //开启可用
? widget.sunList.type == '1' //店铺
? MyColours.color_438E93
: MyColours.color_ED7B2F
: MyColours.color_999999,
... ... @@ -124,7 +136,7 @@ class _PlanDishItemState extends State<PlanDishItem> {
// ? '店铺优惠券(核销)'
// : '店铺优惠券'
// :
true ? '店' : '私',
widget.sunList.type == '1' ? '店' : '私',
textAlign: TextAlign.center,
style: TextStyle(
color: MyColours.color_F8F9FD,
... ... @@ -138,7 +150,7 @@ class _PlanDishItemState extends State<PlanDishItem> {
// ? '店铺优惠券(核销)'
// : '店铺优惠券'
// :
'朋友小聚8人畅享',
'${widget.sunList.pname}',
style: TextStyle(
fontWeight: FontWeight.bold,
color: MyColours.color_ffffff,
... ... @@ -153,7 +165,7 @@ class _PlanDishItemState extends State<PlanDishItem> {
// ? '被领取:${sunModel.receiveNum}张 已核销:${sunModel.useNum}张'
// : '创建人:${sunModel.nickname ?? sunModel.uid} 被领取:${sunModel.receiveNum}张'
// : '被领取:${sunModel.receiveNum}张',
'1100元/8人',
'${widget.sunList.planPrice}元/${widget.sunList.pnum}人',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
... ... @@ -175,7 +187,7 @@ class _PlanDishItemState extends State<PlanDishItem> {
// ? '店铺优惠券(核销)'
// : '店铺优惠券'
// :
'铁锅炖大鹅,白山叫花鸡,主席红烧肉,清蒸鲈鱼,荷塘小炒,松仁玉米,咸蛋黄焗南瓜,黑椒牛柳,夫妻肺片,蒜泥茄子,卤水…',
'${widget.sunList.cookList}',
maxLines: 2,
style: TextStyle(
... ... @@ -203,7 +215,8 @@ class _PlanDishItemState extends State<PlanDishItem> {
fontSize: ScreenUtil().setSp(20))),
Spacer(),
//私,则是自己的,可删除
true || userModel.user.role_name == '管理员' ||
true ||
userModel.user.role_name == '管理员' ||
userModel.user.role_name == '店长'
? RoundButton(
width: ScreenUtil().setWidth(50 * 2),
... ...
... ... @@ -3,6 +3,7 @@ import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/personnel_manage_model.dart';
import 'package:one_key/models/plan_cook_list_model.dart';
import 'package:one_key/pages/coupon/coupon_item_f.dart';
import 'package:one_key/pages/my/plan_dish/plan_dish_item.dart';
import 'package:one_key/provider/coupon_provider.dart';
... ... @@ -37,15 +38,15 @@ class _PlanDishSunPageState extends State<PlanDishSunPage> {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
// if (widget.index == 0) {
// planDishProvider.pageState = PageState.Loading;
// } else if (widget.index == 1) {
// planDishProvider.pageStateStore = PageState.Loading;
// } else if (widget.index == 2) {
// planDishProvider.pageStateMine = PageState.Loading;
// }
// couponProvider.notifyListeners();
// _couponNetworkData(widget.index, isShowLoading: false);
if (widget.index == 0) {
planDishProvider.pageStateHome = PageState.Loading;
} else if (widget.index == 1) {
planDishProvider.pageStateStore = PageState.Loading;
} else if (widget.index == 2) {
planDishProvider.pageStateMine = PageState.Loading;
}
planDishProvider.notifyListeners();
_getPlanCookList(widget.index, isShowLoading: false);
// bus.on("refresh_coupon_list_f", (arg) {
// _couponNetworkData(widget.index);
... ... @@ -58,16 +59,17 @@ class _PlanDishSunPageState extends State<PlanDishSunPage> {
super.dispose();
}
///获取优惠券列表数据
// _couponNetworkData(int index, {bool isShowLoading = true}) async {
// Map<String, String> params = {
// "uid": Provider.of<UserModel>(context, listen: false).user.openid,
// // 'is_time': '0'
// "is_type": index.toString()
// };
// await couponProvider.getCustomerActivity(context, params, index,
// isShowLoading: isShowLoading);
// }
///排菜/套餐列表
_getPlanCookList(int index, {bool isShowLoading = true}) async {
Map<String, String> params = {
"uid": Provider.of<UserModel>(context, listen: false).user.openid,
// 'is_time': '0'
"sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid,
};
await planDishProvider.getPlanCookList(context, params,
showLoading: isShowLoading);
}
///修改活动信息
// _setCustomerActivity(int index) async {
... ... @@ -92,12 +94,16 @@ class _PlanDishSunPageState extends State<PlanDishSunPage> {
Widget build(BuildContext context) {
planDishProvider = Provider.of<PlanDishProvider>(context, listen: true);
PageState pageState;
List<SunList> data = [];
if (widget.index == 0) {
pageState = planDishProvider.pageState;
pageState = planDishProvider.pageStateHome;
data = planDishProvider.allList;
} else if (widget.index == 1) {
pageState = planDishProvider.pageStateStore;
data = planDishProvider.storeList;
} else if (widget.index == 2) {
pageState = planDishProvider.pageStateMine;
data = planDishProvider.mineList;
}
return Container(
child: Consumer<CouponProvider>(builder: (context, model, _) {
... ... @@ -124,7 +130,7 @@ class _PlanDishSunPageState extends State<PlanDishSunPage> {
(BuildContext context, int index) {
return PlanDishItem(
// from: 'quan',
// couponSonModel: couponProvider.couponList[index],
sunList:data[index],
// showBtn: true,
onPressedDel: () {
//弹框确认是否删除
... ... @@ -136,11 +142,14 @@ class _PlanDishSunPageState extends State<PlanDishSunPage> {
// _delGuestInfocDay(model.cday[index].id);
});
},
onPressedReUse: () {
NavigatorUtil.goFinalPlanDishPage(context);
onPressedReUse: () async {
bool needRefresh = await NavigatorUtil.goPlanDishEditPage(
context,
isMine: false,
isEdit: false);
},
);
}, childCount: 10),
}, childCount: data.length),
),
// SliverList(
// delegate: SliverChildBuilderDelegate(
... ...
... ... @@ -21,8 +21,12 @@ import '../../../widgets/round_button.dart';
const scrollDuration = Duration(microseconds: 500);
class PlanNewDishPage extends StatefulWidget {
final List<MenuModel> data;
final String planDishPrice; //排菜价用户输入
PlanNewDishPage({
Key key,
this.data,
this.planDishPrice,
}) : super(key: key);
@override
... ... @@ -50,6 +54,7 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> {
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) async {
_getCookbookByClass(showLoading: false);
});
... ... @@ -62,6 +67,36 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> {
await _planDishProvider.getCookbookByClass(context, params,
showLoading: showLoading);
print(widget.data);
if (widget.data.length > 0) {
widget.data.forEach((old) {
_planDishProvider.menuModel.forEach((element) {
if (old.id == element.id) {
element.cookbooklist.forEach((value) {
old.cookbooklist.forEach((oldCook) {
if (oldCook.id == value.id) {
value.amount = oldCook.amount;
if (oldCook.amount > 0) {
carSum += oldCook.amount;
priceSum += double.parse(oldCook.price) * oldCook.amount;
memberPriceSum +=
double.parse(oldCook.member_price) * oldCook.amount;
}
}
});
});
}
});
});
if (widget.planDishPrice != '' && widget.planDishPrice != null) {
planDishC.text = widget.planDishPrice;
} else {
planDishC.text = '${priceSum}';
}
setState(() {});
}
}
Widget list(List data) => ScrollablePositionedList.builder(
... ... @@ -403,11 +438,18 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> {
});
}
},
child: Image.asset(
Utils.getImgPath(
'plan_dish_minus'),
width: w(16),
))
child: Container(
height: w(48),
padding:
EdgeInsets.symmetric(
horizontal: w(8)),
child: Image.asset(
Utils.getImgPath(
'plan_dish_minus'),
width: w(16),
),
),
)
: SizedBox(),
HEmptyView(8),
menuSunModel.amount != null &&
... ... @@ -488,24 +530,28 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> {
: SizedBox(),
HEmptyView(8),
InkWell(
onTap: () {
setState(() {
menuSunModel.amount++;
carSum++;
priceSum += double.parse(
menuSunModel.price);
memberPriceSum +=
double.parse(menuSunModel
.member_price);
planDishC.text =
'${priceSum}';
});
},
onTap: () {
setState(() {
menuSunModel.amount++;
carSum++;
priceSum += double.parse(
menuSunModel.price);
memberPriceSum += double.parse(
menuSunModel.member_price);
planDishC.text = '${priceSum}';
});
},
child: Container(
height: w(48),
padding:
EdgeInsets.only(left: w(8)),
child: Image.asset(
Utils.getImgPath(
'plan_dish_add'),
width: w(16),
)),
),
),
),
],
),
);
... ... @@ -686,13 +732,17 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> {
// });
// });
Map data = {
'priceSum': priceSum,
'memberPriceSum': memberPriceSum,
'planDishSum': planDishC.text,
'menu': _planDishProvider.menuModel
};
Navigator.of(context).pop(data);
if (carSum == 0) {
Navigator.of(context).pop();
} else {
Map data = {
'priceSum': priceSum,
'memberPriceSum': memberPriceSum,
'planDishSum': planDishC.text,
'menu': _planDishProvider.menuModel
};
Navigator.of(context).pop(data);
}
},
),
)
... ...
import 'package:flutter/material.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/plan_cook_list_model.dart';
import 'package:one_key/net/base_resp.dart';
import 'package:one_key/net/dio_util.dart';
import 'package:one_key/utils/utils.dart';
... ... @@ -13,12 +14,17 @@ import '../net/http_url.dart';
* 预排菜
*/
class PlanDishProvider extends ChangeNotifier {
PageState pageStateHome = PageState.Loading;
PageState pageState = PageState.Loading;
PageState pageStateStore = PageState.Success;
PageState pageStateMine = PageState.Success;
PageState pageStateMy = PageState.Loading;
List<MenuModel> menuModel; //菜品数据
List<SunList> allList = []; //排菜套餐列表--全部
List<SunList> storeList = []; //排菜套餐列表--店铺
List<SunList> mineList = []; //排菜套餐列表--我的
// List<CookbookCategorySunModel> categorySunModel; //菜品分类数据
// List<CookbookSpecSunModel> specSunModel; //计价单位
... ... @@ -67,4 +73,56 @@ class PlanDishProvider extends ChangeNotifier {
}
notifyListeners();
}
///添加排菜/套餐
Future<bool> setPlanCook(BuildContext context, Map<String, String> params,
{showLoading = false}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.set_plan_cook,
data: params, showLoading: showLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {}
return false;
});
if (baseResp != null && baseResp.code == Constant.status_success) {
return true;
} else {
Utils.showToast(baseResp.msg ?? "");
return false;
}
}
///排菜/套餐列表
Future<bool> getPlanCookList(BuildContext context, Map<String, String> params,
{showLoading = false}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.get_plan_cook_list,
data: params, showLoading: showLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {}
return false;
});
if (baseResp != null && baseResp.code == Constant.status_success) {
PlanCookListSunModel planCookListSunModel =
PlanCookListModel.fromJson(baseResp.responseData).data;
storeList.addAll(planCookListSunModel.packageList);
mineList.addAll(planCookListSunModel.plancookList);
allList.addAll(storeList);
allList.addAll(mineList);
pageStateHome = PageState.Success;
pageStateStore = PageState.Success;
pageStateMine = PageState.Success;
notifyListeners();
return true;
} else {
Utils.showToast(baseResp.msg ?? "");
return false;
}
}
}
... ...
... ... @@ -1169,19 +1169,18 @@ class NavigatorUtil {
///排菜-菜单点菜
///
static Future<dynamic> goPlanNewDishPage(
BuildContext context, {
replace = false,
}) {
static Future<dynamic> goPlanNewDishPage(BuildContext context,
{replace = false, Map object, String planDishPrice}) {
// if (invoice != null) {
// return _navigateTo(context,
// "${Routes.plan_new_dish_first_page}?invoice=${FluroConvertUtils.object2string(invoice)}",
// replace: replace);
// }
// if (object != null) {
// return _navigateTo(context,
// "${Routes.plan_new_dish_first_page}?tids=$tids&tableidNow=$tableidNow&fromPage=$fromPage&canChoose=$canChoose&object=${FluroConvertUtils.object2string(object)}");
// }
if (object != null) {
return _navigateTo(context,
"${Routes.plan_new_dish_page}?object=${FluroConvertUtils.object2string(object)}&planDishPrice=$planDishPrice",
replace: replace);
}
return _navigateTo(context, "${Routes.plan_new_dish_page}",
replace: replace);
}
... ... @@ -1304,7 +1303,7 @@ class NavigatorUtil {
///经理排菜- 编辑页
static Future<dynamic> goPlanDishEditPage(BuildContext context,
{replace = false, bool isMine}) {
{replace = false, bool isMine, bool isEdit}) {
// if (invoice != null) {
// return _navigateTo(context,
// "${Routes.plan_dish_edit_page}?invoice=${FluroConvertUtils.object2string(invoice)}",
... ... @@ -1314,8 +1313,8 @@ class NavigatorUtil {
// return _navigateTo(context,
// "${Routes.plan_dish_edit_page}?tids=$tids&tableidNow=$tableidNow&fromPage=$fromPage&canChoose=$canChoose&object=${FluroConvertUtils.object2string(object)}");
// }
return _navigateTo(
context, "${Routes.plan_dish_edit_page}?isMine=${isMine}",
return _navigateTo(context,
"${Routes.plan_dish_edit_page}?isMine=${isMine}&isEdit=${isEdit}",
replace: replace);
}
}
... ...
... ... @@ -1884,17 +1884,25 @@ var planNewDishPageHandle = new Handler(
// String tableidNow = params["tableidNow"].first;
// bool canChoose = params["canChoose"].first == "true" ? true : false;
// List<TableList> res = [];
// if (params.keys.contains('object')) {
// Map object = FluroConvertUtils.string2map(params["object"].first);
// List temp = object['object'];
List<MenuModel> res = [];
String planDishPrice = '';
if (params.keys.contains('object')) {
Map object = FluroConvertUtils.string2map(params["object"].first);
List temp = object['object'];
planDishPrice = params["planDishPrice"].first;
for (var item in temp) {
// MenuModel menuModel = MenuModel.fromJson2(item);
// res.add(menuModel);
// print(res);
res.add(MenuModel.fromJson2(item));
}
}
// for (var item in temp) {
// res.add(TableList.fromJson(item));
// }
// }
return ChangeNotifierProvider<PlanDishProvider>(
create: (_) => PlanDishProvider(), child: PlanNewDishPage());
create: (_) => PlanDishProvider(),
child: PlanNewDishPage(data: res, planDishPrice: planDishPrice));
});
///排菜---排菜单
... ... @@ -2041,6 +2049,9 @@ var planDishEidtPageHandle = new Handler(
// }
// }
bool isMine = FluroConvertUtils.string2bool(params["isMine"].first);
bool isEdit = FluroConvertUtils.string2bool(params["isEdit"].first);
return ChangeNotifierProvider<PlanDishProvider>(
create: (_) => PlanDishProvider(), child: PlanDishEidtPage(isMine: isMine,));
create: (_) => PlanDishProvider(),
child: PlanDishEidtPage(isMine: isMine, isEdit: isEdit));
});
... ...