Commit 2286d47605cd145c1132273c7d0398695510cec6

Authored by wdn127929
1 parent bf559000

预点菜部分

... ... @@ -12,14 +12,14 @@ if (flutterRoot == null) {
}
def flutterVersionCode = "423"
def flutterVersionCode = "430"
if (flutterVersionCode == null) {
flutterVersionCode = '423'
flutterVersionCode = '430'
}
def flutterVersionName = "4.2.3"
def flutterVersionName = "4.3.0"
if (flutterVersionName == null) {
flutterVersionName = '4.2.3'
flutterVersionName = '4.3.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
... ...
... ... @@ -99,6 +99,7 @@ class MenuSunModel {
List spec;
int isSpec;
List practice;
List<MenuModel> cookList;
int amount; //菜品数量
... ... @@ -160,6 +161,7 @@ class MenuSunModel {
spec = json['spec'];
isSpec = json['isSpec'];
practice = json['practice'];
amount = 0;
}
MenuSunModel.fromJson2(Map<String, dynamic> json) {
... ... @@ -189,7 +191,7 @@ class MenuSunModel {
spec = json['spec'];
isSpec = json['isSpec'];
practice = json['practice'];
amount = json['amount']??0;
amount = json['amount'] ?? 0;
}
Map<String, dynamic> toJson() {
... ...
import 'dart:convert';
import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:one_key/models/cookbook_model.dart';
class PlanCookListModel {
... ... @@ -76,6 +78,12 @@ class SunListPlan {
String isDel;
String cdate;
String get cdateStr {
DateTime dateTime =
DateTime.fromMillisecondsSinceEpoch(int.parse(cdate) * 1000);
return DateUtil.formatDate(dateTime, format: DateFormats.y_mo_d);
}
SunListPlan(
{this.id,
this.sellerid,
... ... @@ -103,9 +111,8 @@ class SunListPlan {
memberPrice = json1['member_price'];
planPrice = json1['plan_price'];
// cookList = json1['cook_list'];
if (json1['cook_list'] != null) {
cookList = <MenuModel>[];
cookList = <MenuModel>[];
if (json1['cook_list'] != null && json1['cook_list'] != 'null') {
if (json1['cook_list'] is List) {
json1['cook_list'].forEach((v) {
cookList.add(new MenuModel.fromJson2(v));
... ...
... ... @@ -343,5 +343,9 @@ class HttpUrl {
static const String get_plan_cook_list =
"?service=App.PlanCook.GetPlanCookList"; // 排菜/套餐列表
static const String del_plan_cook =
"?service=App.PlanCook.DelPlanCook"; // 删除排菜/套餐列表
}
... ...
... ... @@ -15,6 +15,7 @@ import 'package:one_key/widgets/system_app_bar.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
import '../../../models/plan_cook_list_model.dart';
import '../../../provider/plan_dish_provider.dart';
/**
... ... @@ -33,7 +34,7 @@ class MyPlanDishHomePage extends StatefulWidget {
class _MyPlanDishHomePageState extends State<MyPlanDishHomePage>
with TickerProviderStateMixin {
EasyRefreshController _controller = EasyRefreshController();
CouponProvider couponProvider;
PlanDishProvider planDishProvider;
TabController tabController;
// ///获取优惠券列表数据
... ... @@ -81,25 +82,52 @@ class _MyPlanDishHomePageState extends State<MyPlanDishHomePage>
// _couponNetworkData(tabController.index);
// selectIndex = tabController.index;
// setState(() {});
// if (tabController.index == 0) {
// planDishProvider.pageStateHome = PageState.Loading;
// } else if (tabController.index == 1) {
// planDishProvider.pageStateStore = PageState.Loading;
// } else if (tabController.index == 2) {
// planDishProvider.pageStateMine = PageState.Loading;
// }
// planDishProvider.notifyListeners();
// _getPlanCookList(isShowLoading: false);
}
});
WidgetsBinding.instance.addPostFrameCallback((_) {
// _couponNetworkData(0);
_getPlanCookList(isShowLoading: false);
});
// bus.on("refresh_coupon_list_f", (arg) {
// _couponNetworkData(tabController.index);
// });
bus.on('refresh_dish_plan_home_list', (arg) {
_getPlanCookList(isShowLoading: false);
});
}
@override
void dispose() {
bus.off("refresh_coupon_list_f");
super.dispose();
bus.off('refresh_dish_plan_home_list');
}
///排菜/套餐列表
_getPlanCookList({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);
}
@override
Widget build(BuildContext context) {
couponProvider = Provider.of<CouponProvider>(context, listen: true);
planDishProvider = Provider.of<PlanDishProvider>(context, listen: true);
return Scaffold(
backgroundColor: MyColours.color_f3f3f3,
appBar: SystemAppBar('排菜与套餐', onTap: () {
... ... @@ -161,13 +189,25 @@ class _MyPlanDishHomePageState extends State<MyPlanDishHomePage>
children: [
ChangeNotifierProvider<PlanDishProvider>(
create: (_) => PlanDishProvider(),
child: PlanDishSunPage(index: 0)),
child: PlanDishSunPage(
index: 0,
data: planDishProvider.allList,
pageState: planDishProvider.pageStateHome,
)),
ChangeNotifierProvider<PlanDishProvider>(
create: (_) => PlanDishProvider(),
child: PlanDishSunPage(index: 1)),
child: PlanDishSunPage(
index: 1,
data: planDishProvider.storeList,
pageState: planDishProvider.pageStateStore,
)),
ChangeNotifierProvider<PlanDishProvider>(
create: (_) => PlanDishProvider(),
child: PlanDishSunPage(index: 2)),
child: PlanDishSunPage(
index: 2,
data: planDishProvider.mineList,
pageState: planDishProvider.pageStateMine,
)),
],
),
),
... ... @@ -206,8 +246,9 @@ class _MyPlanDishHomePageState extends State<MyPlanDishHomePage>
userModel.user.role_name == '店长') {
NavigatorUtil.goPlanDishCreateSelectTypePage(context);
} else {
bool needRefresh =
await NavigatorUtil.goPlanDishEditPage(context);
bool needRefresh = await NavigatorUtil.goPlanDishEditPage(
context,
isMine: true,isEdit: true);
print(needRefresh);
if (needRefresh != null && needRefresh) {
// bus.emit('refresh_coupon_list_f');
... ...
... ... @@ -39,11 +39,16 @@ import 'package:provider/provider.dart';
*/
class PlanDishEidtPage extends StatefulWidget {
final bool onlyShow;
final bool isMine;
final bool isEdit;
final SunListPlan sunListPlan;
PlanDishEidtPage(
{Key key, this.isMine = false, this.isEdit = true, this.sunListPlan})
{Key key,
this.isMine = false,
this.isEdit = true,
this.sunListPlan,
this.onlyShow = false})
: super(key: key);
@override
... ... @@ -88,12 +93,16 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> {
labelShow = labelList[labelSelIndex];
}
if (widget.sunListPlan != null) {
_dishNameEditControl.text = widget.sunListPlan.pname;
if (widget.isEdit) {
_dishNameEditControl.text = widget.sunListPlan.pname;
} else {}
if (widget.sunListPlan.type == '1') {
labelShow = '店内通用套餐';
} else {
labelShow = '自定义排菜单';
}
labelSelIndex = labelList.indexOf(labelShow);
swichState = widget.sunListPlan.status == '1' ? true : false;
pNumC.text = widget.sunListPlan.pnum;
pNum = int.parse(widget.sunListPlan.pnum);
... ... @@ -144,11 +153,17 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> {
//创建新券 客户经理创建活动
_createNewdish() async {
FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
String type;
if (widget.isEdit) {
type = widget.isMine ? "2" : "1";
} else {
type = labelSelIndex == 0 ? '1' : '2';
}
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",
'type': type,
"status": swichState ? "1" : "0",
'pnum': pNumC.text,
"menu_price": priceSum,
... ... @@ -156,7 +171,7 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> {
"plan_price": dishPriceC.text,
"cook_list": json.encode(menuModel),
};
if (widget.sunListPlan != null) {
if (widget.sunListPlan != null && widget.isEdit) {
params['id'] = widget.sunListPlan.id;
}
// if (!widget.isMine) {
... ... @@ -200,6 +215,7 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> {
textAlign: TextAlign.right,
textAlignVertical: TextAlignVertical.bottom,
maxLines: 1,
enabled: widget.onlyShow ? false : true,
// //光标颜色
// cursorColor:
// widget.isSelect ? Colors.white : MyColours.color_199095,
... ... @@ -261,18 +277,22 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> {
),
HEmptyView(20),
Spacer(),
Text(hintText,
style: TextStyle(
color: hintText == '点击选择'
? MyColours.color_999999
: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32),
)),
widget.onlyShow
? SizedBox()
: Text(hintText,
style: TextStyle(
color: widget.onlyShow || hintText == '点击选择'
? MyColours.color_999999
: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32),
)),
HEmptyView(20),
Image.asset(
Utils.getImgPath('arrow_right_new'),
width: ScreenUtil().setWidth(20),
),
widget.onlyShow
? SizedBox()
: Image.asset(
Utils.getImgPath('arrow_right_new'),
width: ScreenUtil().setWidth(20),
),
// HEmptyView(32),
],
),
... ... @@ -463,7 +483,8 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> {
child: Column(
children: [
VEmptyView(40),
_textfield('排菜名称 *', '点击输入排菜套餐名称'),
_textfield(widget.onlyShow ? '排菜名称' : '排菜名称 *',
'点击输入排菜套餐名称'),
MyDivider(double.infinity, w(1),
color: MyColours.color_DBDBDB),
InkWell(
... ... @@ -541,9 +562,11 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> {
MyDivider(double.infinity, w(1),
color: MyColours.color_DBDBDB),
_canUse('是否启用', swichState, () {
setState(() {
swichState = !swichState;
});
if (!widget.onlyShow) {
setState(() {
swichState = !swichState;
});
}
}),
MyDivider(double.infinity, w(1),
color: MyColours.color_DBDBDB),
... ... @@ -563,24 +586,27 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> {
),
),
Spacer(),
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),
),
),
),
widget.onlyShow
? SizedBox()
: 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),
),
),
),
Container(
// constraints: BoxConstraints(
// minWidth: w(34),
... ... @@ -600,13 +626,17 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> {
controller: pNumC,
// focusNode: _focusNode,
// autofocus: true,
enabled:
widget.onlyShow ? false : true,
inputFormatters: [
FilteringTextInputFormatter.allow(
RegExp(r'[0-9]')),
],
style: TextStyle(
color: MyColours.color_438E93,
color: widget.onlyShow
? MyColours.color_515151
: MyColours.color_438E93,
fontSize: font(16)),
textAlign: TextAlign.center,
// textAlignVertical: TextAlignVertical.center,
... ... @@ -654,20 +684,24 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> {
// _focusNode.unfocus();
},
)),
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),
),
),
),
widget.onlyShow
? SizedBox()
: 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),
),
),
),
],
)),
MyDivider(double.infinity, w(1),
... ... @@ -690,7 +724,9 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> {
Text(
'${priceSum}元/${memberPriceSum}元',
style: TextStyle(
color: MyColours.color_99515151,
color: widget.onlyShow
? MyColours.color_515151
: MyColours.color_99515151,
fontSize: ScreenUtil().setSp(32)),
),
])),
... ... @@ -714,7 +750,7 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> {
controller: dishPriceC,
// focusNode: _focusNode,
// autofocus: true,
enabled: widget.onlyShow ? false : true,
style: TextStyle(
color: MyColours.color_515151,
fontSize: font(16)),
... ... @@ -763,96 +799,143 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> {
color: MyColours.color_DBDBDB),
VEmptyView(24),
_select('菜品', '编辑', () async {
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
Map temp;
if (menuModel == null) {
temp = await NavigatorUtil.goPlanNewDishPage(
context,
);
} else {
temp = await NavigatorUtil.goPlanNewDishPage(
if (widget.onlyShow) {
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
Map temp;
if (menuModel == null) {
temp =
await NavigatorUtil.goPlanNewDishPage(
context,
object: {'object': menuModel},
planDishPrice: dishPriceC.text);
}
);
} else {
temp =
await NavigatorUtil.goPlanNewDishPage(
context,
object: {'object': menuModel},
planDishPrice: dishPriceC.text);
}
if (temp != null) {
double priceSumTemp = temp['priceSum'];
double memberPriceSumTemp =
temp['memberPriceSum'];
String planDishSum = temp['planDishSum'];
menuModel = temp['menu']; //菜品数据
print(priceSum);
print(memberPriceSum);
print(planDishSum);
print(menuModel);
if (temp != null) {
double priceSumTemp = temp['priceSum'];
double memberPriceSumTemp =
temp['memberPriceSum'];
String planDishSum = temp['planDishSum'];
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 + '、';
}
// 刷新页面***************
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);
if (dish.endsWith('、')) {
dish = dish.substring(0, dish.length - 1);
}
_dishExplainEditControl.text = dish;
}
_dishExplainEditControl.text = dish;
}
}),
_explain('券说明', '点击上面右侧的“编辑”,开始选菜吧!'),
widget.onlyShow
? Container(
width: double.infinity,
// height: ScreenUtil().setWidth(380),
// padding: EdgeInsets.symmetric(
// // horizontal: w(16),
// vertical: ScreenUtil().setWidth(20)),
// decoration: BoxDecoration(
// borderRadius:
// BorderRadius.circular(r(5)),
// border: Border.all(
// width: w(1),
// color: MyColours.color_DBDBDB)),
child: Text(
_dishExplainEditControl.text,
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_999999),
))
: _explain('券说明', '点击上面右侧的“编辑”,开始选菜吧!'),
VEmptyView(20),
],
))),
),
VEmptyView(20),
RoundButton(
onPressed: () {
// if (_dishNameEditControl.text.trim().length == 0) {
// Utils.showToast('请填写券名称');
// return;
// }
// if (_dishRequireEditControl.text.trim().length == 0) {
// Utils.showToast('请填写券要求');
// return;
// }
// if (fromDate == '点击选择') {
// Utils.showToast('请选择有效期起始时间');
// return;
// }
// if (endDate == '点击选择') {
// Utils.showToast('请选择有效期结束时间');
// return;
// }
// if (DateUtil.getDateTime(endDate)
// .compareTo(DateUtil.getDateTime(fromDate)) <
// 0) {
// Utils.showToast('有效期结束时间不能早于起始时间');
// return;
// }
// // ***参数***
// // _dishNameEditControl.text
// // _dishRequireEditControl.text
// // fromDate
// // endDate
// // _dishExplainEditControl.text
// // swichState
_createNewdish();
},
text: '保存',
fontSize: 24,
isBold: false,
height: ScreenUtil().setWidth(37 * 2),
width: ScreenUtil().setWidth(130 * 2),
radius: ScreenUtil().setWidth(22),
),
widget.onlyShow
? Container(
padding: EdgeInsets.only(
top: w(12),
bottom: w(25),
left: w(45),
right: w(45)),
child: RoundButton(
onPressed: () {
Navigator.pop(context);
},
text: '返回',
fontSize: 32,
isBold: false,
height: ScreenUtil().setWidth(43 * 2),
// width: ScreenUtil().setWidth(130 * 2),
radius: ScreenUtil().setWidth(10),
))
: Container(
padding: EdgeInsets.only(
top: w(12),
bottom: w(25),
left: w(45),
right: w(45)),
child: RoundButton(
onPressed: () {
if (_dishNameEditControl.text.trim().length == 0) {
Utils.showToast('请输入排菜套餐名称');
return;
}
// if (_dishRequireEditControl.text.trim().length == 0) {
// Utils.showToast('请填写券要求');
// return;
// }
// if (fromDate == '点击选择') {
// Utils.showToast('请选择有效期起始时间');
// return;
// }
// if (endDate == '点击选择') {
// Utils.showToast('请选择有效期结束时间');
// return;
// }
// if (DateUtil.getDateTime(endDate)
// .compareTo(DateUtil.getDateTime(fromDate)) <
// 0) {
// Utils.showToast('有效期结束时间不能早于起始时间');
// return;
// }
// // ***参数***
// // _dishNameEditControl.text
// // _dishRequireEditControl.text
// // fromDate
// // endDate
// // _dishExplainEditControl.text
// // swichState
_createNewdish();
},
text: '保存',
fontSize: 32,
isBold: false,
height: ScreenUtil().setWidth(43 * 2),
// width: ScreenUtil().setWidth(130 * 2),
radius: ScreenUtil().setWidth(10),
)),
VEmptyView(32)
]))),
);
... ...
... ... @@ -207,7 +207,7 @@ class _PlanDishItemState extends State<PlanDishItem> {
// ? '被领取:${sunModel.receiveNum}张 已核销:${sunModel.useNum}张'
// : '创建人:${sunModel.nickname ?? sunModel.uid} 被领取:${sunModel.receiveNum}张'
// : '被领取:${sunModel.receiveNum}张',
'更新时间:2022-11-08',
'更新时间:${widget.sunList.cdateStr}',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
... ... @@ -215,7 +215,7 @@ class _PlanDishItemState extends State<PlanDishItem> {
fontSize: ScreenUtil().setSp(20))),
Spacer(),
//私,则是自己的,可删除
true ||
widget.sunList.type == '2' ||
userModel.user.role_name == '管理员' ||
userModel.user.role_name == '店长'
? RoundButton(
... ... @@ -232,18 +232,22 @@ class _PlanDishItemState extends State<PlanDishItem> {
)
: SizedBox(),
HEmptyView(34),
RoundButton(
width: ScreenUtil().setWidth(50 * 2),
height: ScreenUtil().setWidth(20 * 2),
radius: ScreenUtil().setWidth(10),
text: '复用',
fontSize: 24,
textColor: MyColours.color_438E93,
borderColor: MyColours.color_438E93,
gradientStart: MyColours.color_ffffff,
gradientEnd: MyColours.color_ffffff,
onPressed: widget.onPressedReUse,
)
widget.sunList.type == '2' ||
userModel.user.role_name == '管理员' ||
userModel.user.role_name == '店长'
? RoundButton(
width: ScreenUtil().setWidth(50 * 2),
height: ScreenUtil().setWidth(20 * 2),
radius: ScreenUtil().setWidth(10),
text: '复用',
fontSize: 24,
textColor: MyColours.color_438E93,
borderColor: MyColours.color_438E93,
gradientStart: MyColours.color_ffffff,
gradientEnd: MyColours.color_ffffff,
onPressed: widget.onPressedReUse,
)
: SizedBox()
],
))
])));
... ...
... ... @@ -21,7 +21,10 @@ import '../../../utils/dialog_util.dart';
class PlanDishSunPage extends StatefulWidget {
final int index;
PlanDishSunPage({Key key, this.index}) : super(key: key);
final List<SunListPlan> data;
final PageState pageState;
PlanDishSunPage({Key key, this.index, this.data, this.pageState})
: super(key: key);
@override
_PlanDishSunPageState createState() => _PlanDishSunPageState();
... ... @@ -29,8 +32,9 @@ class PlanDishSunPage extends StatefulWidget {
class _PlanDishSunPageState extends State<PlanDishSunPage> {
EasyRefreshController _controller = EasyRefreshController();
PlanDishProvider planDishProvider;
List<PersonnelManageSunModel> authUserLists = [];
PlanDishProvider planDishProvider;
@override
void initState() {
... ... @@ -38,41 +42,30 @@ class _PlanDishSunPageState extends State<PlanDishSunPage> {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
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);
// 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);
// });
});
bus.on('refresh_dish_plan_home_list', (arg) {
_getPlanCookList(widget.index, isShowLoading: false);
});
}
@override
void dispose() {
super.dispose();
bus.off('refresh_dish_plan_home_list');
}
///排菜/套餐列表
_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);
delPlanCook(String id) async {
Map<String, String> params = {"id": id};
bool success =
await planDishProvider.delPlanCook(context, params, showLoading: true);
if (success) {
// _getPlanCookList(widget.index, isShowLoading: true);
bus.emit('refresh_dish_plan_home_list');
}
}
///修改活动信息
... ... @@ -96,24 +89,12 @@ class _PlanDishSunPageState extends State<PlanDishSunPage> {
@override
Widget build(BuildContext context) {
planDishProvider = Provider.of<PlanDishProvider>(context, listen: true);
PageState pageState;
List<SunListPlan> data = [];
if (widget.index == 0) {
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;
}
planDishProvider = Provider.of<PlanDishProvider>(context, listen: true);
return Container(
child: Consumer<CouponProvider>(builder: (context, model, _) {
if (pageState != PageState.Success) {
if (widget.pageState != PageState.Success) {
return ExceptionPage(
pageState: pageState,
pageState: widget.pageState,
callback: () {
// offset = 0;
// getMessage(showLoading: true);
... ... @@ -122,7 +103,7 @@ class _PlanDishSunPageState extends State<PlanDishSunPage> {
emptyMsg: "暂时没有列表信息哦,",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
needEmpty: true,
// needEmpty: true,
);
} else {
return EasyRefresh.custom(
... ... @@ -134,13 +115,21 @@ class _PlanDishSunPageState extends State<PlanDishSunPage> {
(BuildContext context, int index) {
return InkWell(
onTap: () async {
UserModel userModel =
Provider.of<UserModel>(context, listen: false);
bool canedit = widget.data[index].type == '0' ||
userModel.user.role_name == '管理员' ||
userModel.user.role_name == '店长';
bool needRefresh =
await NavigatorUtil.goPlanDishEditPage(context,
isEdit: true, sunList: data[index]);
isEdit: true,
sunList: widget.data[index],
onlyShow: !canedit);
},
child: PlanDishItem(
// from: 'quan',
sunList: data[index],
sunList: widget.data[index],
// showBtn: true,
onPressedDel: () {
//弹框确认是否删除
... ... @@ -149,16 +138,16 @@ class _PlanDishSunPageState extends State<PlanDishSunPage> {
content: "确定要将该排菜删除吗?删除后将无法再次使用该排菜。",
rTitle: "确定", rCallback: () {
// Navigator.pop(context);
// _delGuestInfocDay(model.cday[index].id);
delPlanCook(widget.data[index].id);
});
},
onPressedReUse: () async {
bool needRefresh =
await NavigatorUtil.goPlanDishEditPage(context,
isMine: false, isEdit: false);
isEdit: false, sunList: widget.data[index]);
},
));
}, childCount: data.length),
}, childCount: widget.data.length),
),
// SliverList(
// delegate: SliverChildBuilderDelegate(
... ...
import 'package:flutter/material.dart';
import 'package:one_key/models/cookbook_model.dart';
import 'package:one_key/models/plan_cook_list_model.dart';
import 'package:one_key/provider/plan_dish_provider.dart';
import 'package:one_key/utils/screen_util.dart';
import 'package:one_key/widgets/h_empty_view.dart';
... ... @@ -16,6 +17,7 @@ import '../../../utils/utils.dart';
import '../../../widgets/MyDivider.dart';
import '../../../widgets/page_exception.dart';
import '../../../widgets/round_button.dart';
import '../../models/cookbook_model.dart';
import '../../provider/user_model.dart';
const scrollDuration = Duration(microseconds: 500);
... ... @@ -42,27 +44,145 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
PlanDishProvider _planDishProvider;
int carSum = 0; //购物车显示菜品总个数
double priceSum = 0; //总计
double memberPriceSum = 0; //会员价
TextEditingController planDishC = TextEditingController(); //排菜价
List<MenuSunModel> selectMenu = [];
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) async {
_getCookbookByClass(showLoading: false);
_getPageMenuData();
});
}
_getCookbookByClass({bool showLoading = true}) async {
_getPageMenuData() async {
Future.wait<bool>(
[_getCookbookByClass(showLoading: true), _getPlanCookList()])
.then((results) {
print(results[0]);
if (results[0] && results[1]) {
_planDishProvider.menuModelForManager
.addAll(_planDishProvider.menuModel);
//成功
MenuModel menuModelSetMeal = MenuModel();
menuModelSetMeal.className = '套餐';
List<MenuSunModel> cookList = [];
List<SunListPlan> storeList = _planDishProvider.storeList;
storeList.forEach((element) {
MenuSunModel menuSunModel = MenuSunModel();
menuSunModel.id = element.id;
menuSunModel.name = element.pname;
menuSunModel.price = element.menuPrice;
menuSunModel.member_price = element.memberPrice;
menuSunModel.unit = '份';
// menuSunModel.amount = element.amount;
menuSunModel.cookList = element.cookList;
cookList.add(menuSunModel);
});
menuModelSetMeal.cookbooklist = cookList;
_planDishProvider.menuModelForManager
.insert(0, menuModelSetMeal); //添加套餐
MenuModel menuModelPlanDish = MenuModel();
menuModelPlanDish.className = '我的排菜';
List<MenuSunModel> cookListPlanDish = [];
List<SunListPlan> mineList = _planDishProvider.mineList;
mineList.forEach((element) {
MenuSunModel menuSunModel = MenuSunModel();
menuSunModel.id = element.id;
menuSunModel.name = element.pname;
menuSunModel.price = element.menuPrice;
menuSunModel.member_price = element.memberPrice;
menuSunModel.unit = '份';
// menuSunModel.amount = element.amount;
menuSunModel.cookList = element.cookList;
cookListPlanDish.add(menuSunModel);
});
menuModelPlanDish.cookbooklist = cookListPlanDish;
_planDishProvider.menuModelForManager
.insert(1, menuModelPlanDish); //添加排菜
setState(() {});
} else {
if (!results[0]) {
// Utils.showToast('');
} else {
// Utils.showToast('');
}
}
}).catchError((e) {
print(e);
});
}
///菜品数据
Future<bool> _getCookbookByClass({bool showLoading = true}) async {
Map<String, String> params = {
"sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid,
};
await _planDishProvider.getCookbookByClass(context, params,
bool success = await _planDishProvider.getCookbookByClass(context, params,
showLoading: showLoading);
if (success) {
return true;
} else {
return false;
}
// 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(() {});
// }
}
///接口
_getMenuData() {
// Map<String, dynamic> params = {"sellerid": int.parse(widget.sellerID)};
// _storeMenuProvider.getStoreMenu(context, params);
///排菜/套餐列表
Future<bool> _getPlanCookList({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,
};
bool success = await _planDishProvider.getPlanCookList(context, params,
showLoading: isShowLoading);
if (success) {
return true;
} else {
return false;
}
}
Widget list(List data) => ScrollablePositionedList.builder(
... ... @@ -206,14 +326,20 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
return Container(
height: double.infinity,
color: MyColours.color_F9F9F9,
width: ScreenUtil().setWidth(85 * 2),
width: ScreenUtil().setWidth(90 * 2),
child: ListView.builder(
// itemCount:
// _storeMenuProvider.menulist.length,
itemCount:
_planDishProvider.menuModel.length,
itemCount: _planDishProvider
.menuModelForManager.length,
itemBuilder:
(BuildContext context, int index) {
MenuModel menuModel = _planDishProvider
.menuModelForManager[index];
int sum = 0;
menuModel.cookbooklist.forEach((element) {
sum += element.amount;
});
return InkWell(
onTap: () {
isTap = true;
... ... @@ -249,8 +375,7 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
child: Text(
// _storeMenuProvider
// .menulist[index].className,
_planDishProvider
.menuModel[index].className,
menuModel.className,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
... ... @@ -262,29 +387,34 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
.color_999999),
),
),
Positioned(
top: w(2),
right: w(2),
child: Container(
// width: w(16),
constraints: BoxConstraints(
minWidth: w(16)),
height: w(16),
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(
r(8)),
color: MyColours
.color_E34D59),
child: Text(
'23',
style: TextStyle(
fontSize: font(10),
color: MyColours
.color_F6F6F6),
),
))
sum > 0
? Positioned(
top: w(2),
right: w(2),
child: Container(
// width: w(16),
constraints:
BoxConstraints(
minWidth: w(16)),
height: w(16),
alignment:
Alignment.center,
decoration: BoxDecoration(
borderRadius:
BorderRadius
.circular(
r(8)),
color: MyColours
.color_E34D59),
child: Text(
'${sum}',
style: TextStyle(
fontSize: font(10),
color: MyColours
.color_F6F6F6),
),
))
: SizedBox()
],
),
);
... ... @@ -299,14 +429,14 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
shrinkWrap: true,
// physics: NeverScrollableScrollPhysics(),
itemCount: _planDishProvider
.menuModel[_selectIndex]
.menuModelForManager[_selectIndex]
.cookbooklist
.length,
itemBuilder:
(BuildContext context, int index) {
MenuSunModel menuSunModel =
_planDishProvider
.menuModel[_selectIndex]
.menuModelForManager[_selectIndex]
.cookbooklist[index];
return Container(
padding:
... ... @@ -341,8 +471,8 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
color: MyColours
.color_515151),
)),
HEmptyView(8),
_laduWidget()
// HEmptyView(8),
// _laduWidget()
],
),
VEmptyView(24),
... ... @@ -368,74 +498,140 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
],
)),
// Spacer(),
Image.asset(
Utils.getImgPath('plan_dish_minus'),
width: w(16),
),
menuSunModel.amount != null &&
menuSunModel.amount > 0
? InkWell(
onTap: () {
if (menuSunModel.amount >
0) {
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.symmetric(
horizontal: w(8)),
child: Image.asset(
Utils.getImgPath(
'plan_dish_minus'),
width: w(16),
),
),
)
: SizedBox(),
HEmptyView(8),
Container(
width: w(32),
height: w(16),
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(
r(5)),
border: Border.all(
width: w(1),
color: MyColours
.color_999999)),
// constraints: BoxConstraints(minWidth: w(20)),
child: TextField(
maxLines: 1,
// controller:
// focusNode: _focusNode,
// autofocus: true,
style: TextStyle(
color:
MyColours.color_438E93,
fontSize: font(12)),
textAlign: TextAlign.center,
// textAlignVertical: TextAlignVertical.center,
decoration: InputDecoration(
hintText: "人数",
hintStyle: TextStyle(
color:
MyColours.color_999999,
fontSize: font(12),
menuSunModel.amount != null &&
menuSunModel.amount > 0
? Container(
constraints: BoxConstraints(
minWidth: w(32),
),
// isCollapsed:
// true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
border: OutlineInputBorder(
borderSide:
BorderSide.none),
contentPadding:
EdgeInsets.zero,
),
keyboardType:
TextInputType.number,
textInputAction:
TextInputAction.done,
onChanged: (value) {
// setState(() {});
// _searchSellerLocation();
// customerProvider.searchData(value);
},
onEditingComplete: () {
FocusScope.of(context)
.requestFocus(
FocusNode()); //点击空白处隐藏键盘
// contantShowModel.searchData(
// contantShowModel.controller.text);
// _searchSellerLocation();
// _focusNode.unfocus();
},
)),
// width: w(32),
height: w(16),
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(
r(5)),
border: Border.all(
width: w(1),
color: MyColours
.color_999999)),
alignment: Alignment.center,
// constraints: BoxConstraints(minWidth: w(20)),
child: Text(
'${menuSunModel.amount}',
style: TextStyle(
color: MyColours
.color_438E93,
fontSize: font(12)),
),
// child: TextField(
// maxLines: 1,
// // controller:
// // focusNode: _focusNode,
// // autofocus: true,
// style: TextStyle(
// color: MyColours
// .color_438E93,
// fontSize: font(12)),
// textAlign: TextAlign.center,
// // textAlignVertical: TextAlignVertical.center,
// decoration: InputDecoration(
// hintText: "人数",
// hintStyle: TextStyle(
// color: MyColours
// .color_999999,
// fontSize: font(12),
// ),
// // isCollapsed:
// // true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
// border:
// OutlineInputBorder(
// borderSide:
// BorderSide
// .none),
// contentPadding:
// EdgeInsets.zero,
// ),
// keyboardType:
// TextInputType.number,
// textInputAction:
// TextInputAction.done,
// onChanged: (value) {
// // setState(() {});
// // _searchSellerLocation();
// // customerProvider.searchData(value);
// },
// onEditingComplete: () {
// FocusScope.of(context)
// .requestFocus(
// FocusNode()); //点击空白处隐藏键盘
// // contantShowModel.searchData(
// // contantShowModel.controller.text);
// // _searchSellerLocation();
// // _focusNode.unfocus();
// },
// )
)
: SizedBox(),
HEmptyView(8),
Image.asset(
Utils.getImgPath('plan_dish_add'),
width: w(16),
InkWell(
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),
),
),
),
],
),
... ... @@ -460,24 +656,28 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
Utils.getImgPath('plan_dish_car'),
width: w(35),
),
Positioned(
top: w(-3),
right: w(-4),
child: Container(
// width: w(16),
constraints: BoxConstraints(minWidth: w(16)),
height: w(16),
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(r(8)),
color: MyColours.color_E34D59),
child: Text(
'23',
style: TextStyle(
fontSize: font(10),
color: MyColours.color_F6F6F6),
),
))
carSum > 0
? Positioned(
top: w(-3),
right: w(-4),
child: Container(
// width: w(16),
constraints:
BoxConstraints(minWidth: w(16)),
height: w(16),
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(r(8)),
color: MyColours.color_E34D59),
child: Text(
'${carSum}',
style: TextStyle(
fontSize: font(10),
color: MyColours.color_F6F6F6),
),
))
: SizedBox()
],
),
HEmptyView(66),
... ... @@ -493,7 +693,7 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
color: MyColours.color_515151),
),
Text(
'0.00',
'${priceSum}',
style: TextStyle(
fontSize: font(12),
color: MyColours.color_000000),
... ... @@ -516,7 +716,7 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
color: MyColours.color_515151),
),
Text(
'0.00',
'${memberPriceSum}',
style: TextStyle(
fontSize: font(12),
color: MyColours.color_000000),
... ... @@ -547,7 +747,7 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
// constraints: BoxConstraints(minWidth: w(20)),
child: TextField(
maxLines: 1,
// controller:
controller: planDishC,
// focusNode: _focusNode,
// autofocus: true,
... ... @@ -612,6 +812,10 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
borderColor: MyColours.color_438E93,
textColor: MyColours.color_438E93,
onPressed: () {
_planDishProvider.menuModel.forEach((element) {
_planDishProvider.menuModelForManager
.forEach((value) {});
});
NavigatorUtil.goOrderEditListShowPage(context);
},
),
... ...
... ... @@ -21,6 +21,7 @@ class PlanDishProvider extends ChangeNotifier {
PageState pageStateMy = PageState.Loading;
List<MenuModel> menuModel; //菜品数据
List<MenuModel> menuModelForManager = []; //经理点菜菜品数据
List<SunListPlan> allList = []; //排菜套餐列表--全部
List<SunListPlan> storeList = []; //排菜套餐列表--店铺
... ... @@ -53,6 +54,7 @@ class PlanDishProvider extends ChangeNotifier {
}
}
notifyListeners();
return false;
});
menuModel = [];
... ... @@ -67,11 +69,14 @@ class PlanDishProvider extends ChangeNotifier {
print(menuModel);
pageState = PageState.Success;
}
notifyListeners();
return true;
} else {
Utils.showToast(baseResp.msg ?? "");
pageState = PageState.ConnectivityError;
notifyListeners();
return false;
}
notifyListeners();
}
///添加排菜/套餐
... ... @@ -95,6 +100,27 @@ class PlanDishProvider extends ChangeNotifier {
}
}
///删除排菜/套餐列表
Future<bool> delPlanCook(BuildContext context, Map<String, String> params,
{showLoading = false}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.del_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,
... ... @@ -111,13 +137,29 @@ class PlanDishProvider extends ChangeNotifier {
if (baseResp != null && baseResp.code == Constant.status_success) {
PlanCookListSunModel planCookListSunModel =
PlanCookListModel.fromJson(baseResp.responseData).data;
storeList = [];
mineList = [];
allList = [];
storeList.addAll(planCookListSunModel.packageList);
mineList.addAll(planCookListSunModel.plancookList);
allList.addAll(storeList);
allList.addAll(mineList);
pageStateHome = PageState.Success;
pageStateStore = PageState.Success;
pageStateMine = PageState.Success;
if (storeList.length == 0) {
pageStateStore = PageState.Empty;
} else {
pageStateStore = PageState.Success;
}
if (mineList.length == 0) {
pageStateMine = PageState.Empty;
} else {
pageStateMine = PageState.Success;
}
if (allList.length == 0) {
pageStateHome = PageState.Empty;
} else {
pageStateHome = PageState.Success;
}
notifyListeners();
return true;
} else {
... ...
... ... @@ -1304,7 +1304,11 @@ class NavigatorUtil {
///经理排菜- 编辑页
static Future<dynamic> goPlanDishEditPage(BuildContext context,
{replace = false, bool isMine, bool isEdit, SunListPlan sunList}) {
{replace = false,
bool isMine,
bool isEdit,
SunListPlan sunList,
bool onlyShow}) {
// if (invoice != null) {
// return _navigateTo(context,
// "${Routes.plan_dish_edit_page}?invoice=${FluroConvertUtils.object2string(invoice)}",
... ... @@ -1312,11 +1316,11 @@ class NavigatorUtil {
// }
if (sunList != null) {
return _navigateTo(context,
"${Routes.plan_dish_edit_page}?sunList=${FluroConvertUtils.object2string(sunList)}&isMine=${isMine}&isEdit=${isEdit}",
"${Routes.plan_dish_edit_page}?sunList=${FluroConvertUtils.object2string(sunList)}&isMine=${isMine}&isEdit=${isEdit}&onlyShow=${onlyShow}",
replace: replace);
}
return _navigateTo(context,
"${Routes.plan_dish_edit_page}?isMine=${isMine}&isEdit=${isEdit}",
"${Routes.plan_dish_edit_page}?isMine=${isMine}&isEdit=${isEdit}&onlyShow=${onlyShow}",
replace: replace);
}
}
... ...
... ... @@ -2051,6 +2051,8 @@ var planDishEidtPageHandle = new Handler(
// }
bool isMine = FluroConvertUtils.string2bool(params["isMine"].first);
bool isEdit = FluroConvertUtils.string2bool(params["isEdit"].first);
bool onlyShow = FluroConvertUtils.string2bool(params["onlyShow"].first);
SunListPlan sunListPlan;
if (params.keys.contains('sunList')) {
... ... @@ -2061,5 +2063,8 @@ var planDishEidtPageHandle = new Handler(
return ChangeNotifierProvider<PlanDishProvider>(
create: (_) => PlanDishProvider(),
child: PlanDishEidtPage(
isMine: isMine, isEdit: isEdit, sunListPlan: sunListPlan));
isMine: isMine,
isEdit: isEdit,
sunListPlan: sunListPlan,
onlyShow: onlyShow));
});
... ...