|
|
|
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('券说明', '点击上面右侧的“编辑”,开始选菜吧!'),
|
...
|
...
|
|