Commit 76a48c968e57fb5164104c02d4a6502432c9e168

Authored by wdn127929
1 parent 25ee3657

客情,客户自己点

... ... @@ -42,7 +42,8 @@ class PlanCookByRidSunModel {
List<MenuModel> cooklist;
List<MenuSunModel> packageList;
// Null? oftenList;
// Null? temporaryList;
List<MenuSunModel> temporaryList;
List<MenuSunModel> planList;
String menuPrice;
String memberPrice;
... ... @@ -67,7 +68,7 @@ class PlanCookByRidSunModel {
this.cooklist,
this.packageList,
// this.oftenList,
// this.temporaryList,
this.temporaryList,
this.planList,
this.menuPrice,
this.memberPrice,
... ... @@ -113,7 +114,19 @@ class PlanCookByRidSunModel {
}
}
// oftenList = json['often_list'];
// temporaryList = json['temporary_list'];
if (json1['temporary_list'] != null && json1['temporary_list'] != '') {
temporaryList = <MenuSunModel>[];
if (json1['temporary_list'] is List) {
json1['temporary_list'].forEach((v) {
temporaryList.add(new MenuSunModel.fromJson2(v));
});
} else {
json.decode(json1['temporary_list']).forEach((v) {
temporaryList.add(new MenuSunModel.fromJson2(v));
});
}
}
if (json1['plan_list'] != null && json1['plan_list'] != '') {
planList = <MenuSunModel>[];
... ... @@ -151,7 +164,7 @@ class PlanCookByRidSunModel {
data['cooklist'] = this.cooklist;
data['package_list'] = this.packageList;
// data['often_list'] = this.oftenList;
// data['temporary_list'] = this.temporaryList;
data['temporary_list'] = this.temporaryList;
data['plan_list'] = this.planList;
data['menu_price'] = this.menuPrice;
data['member_price'] = this.memberPrice;
... ...
... ... @@ -23,6 +23,7 @@ import '../../../widgets/round_button.dart';
import '../../models/cookbook_model.dart';
import '../../models/notebook_detail.dart';
import '../../provider/user_model.dart';
import '../../utils/event_bus.dart';
const scrollDuration = Duration(microseconds: 500);
... ... @@ -77,9 +78,40 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
WidgetsBinding.instance.addPostFrameCallback((_) async {
_getPageMenuData();
bus.on("refresh_data", (args) {
print(args);
List<MenuSunModel> temp = args;
_planDishProvider.menuModelForManager.forEach((element) {
if (element.className == '临时加菜') {
element.cookbooklist.forEach((old) {
carSum -= old.amount;
});
element.cookbooklist = [];
temp.forEach((value) {
carSum += value.amount;
element.cookbooklist.add(MenuSunModel.fromJson2(value.toJson()));
});
print(carSum);
List<MenuSunModel> menuSunShort = [];
MenuSunModel menuSunModelShort = MenuSunModel();
menuSunModelShort.name = '临时菜';
menuSunShort.add(menuSunModelShort);
element.cookbooklist.add(menuSunModelShort);
}
});
_calculatePrice();
setState(() {});
});
});
}
@override
void dispose() {
super.dispose();
bus.off('refresh_data');
}
_getPageMenuData() async {
Future.wait<bool>(
[_getCookbookByClass(showLoading: true), _getPlanCookList()])
... ... @@ -214,6 +246,32 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
_planDishProvider.menuModelForManager
.insert(1, menuModelPlanDish); //添加排菜
MenuModel menuModelShort = MenuModel();
menuModelShort.className = '临时加菜';
menuModelShort.classType = '5';
menuModelShort.cookbooklist = [];
// 临时加菜
if (widget.planCookByRidSunModel != null &&
widget.planCookByRidSunModel.temporaryList != null &&
widget.planCookByRidSunModel.temporaryList.length > 0) {
menuModelShort.cookbooklist
.addAll(widget.planCookByRidSunModel.temporaryList);
widget.planCookByRidSunModel.temporaryList.forEach((temporary) {
if (temporary.amount > 0) {
carSum += temporary.amount;
}
});
}
List<MenuSunModel> menuSunShort = [];
MenuSunModel menuSunModelShort = MenuSunModel();
menuSunModelShort.name = '临时菜';
menuSunShort.add(menuSunModelShort);
menuModelShort.cookbooklist.add(menuSunModelShort);
_planDishProvider.menuModelForManager.add(menuModelShort);
if (widget.planCookByRidSunModel != null &&
widget.planCookByRidSunModel.planPrice != null) {
_calculatePrice(planPrice: widget.planCookByRidSunModel.planPrice);
... ... @@ -467,6 +525,10 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
});
});
} else if (element.className == '临时加菜') {
//临时加菜
element.cookbooklist.forEach((value) {
value.amount = 0;
});
} else {
//单菜
element.cookbooklist.forEach((value) {
... ... @@ -489,6 +551,8 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
}
//单品
List<MenuModel> cooklistdata = [];
//临时加菜
List<MenuSunModel> temporarylist = [];
_planDishProvider.menuModelForManager.forEach((element) {
if (element.className == '套餐') {
List<MenuSunModel> packagelist = [];
... ... @@ -514,18 +578,30 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
} else {
params['plan_list'] = null;
}
} else if (element.className == '临时加菜') {
//临时加菜
temporarylist.addAll(element.cookbooklist);
if (temporarylist.length > 0) {
temporarylist.removeWhere((value) => value.amount == 0);
if (temporarylist.length > 0) {
params['temporary_list'] = json.encode(temporarylist);
} else {
params['temporary_list'] = null;
}
}
} else {
//单品
cooklistdata.add(element);
}
if (cooklistdata.length > 0) {
cooklistdata.forEach((cooklist) {
cooklist.cookbooklist.removeWhere((element) => element.amount == 0);
});
if (cooklistdata.length > 0) {
params['cooklist'] = json.encode(cooklistdata);
} else {
params['cooklist'] = null;
cooklistdata.forEach((cooklist) {
cooklist.cookbooklist.removeWhere((element) => element.amount == 0);
});
if (cooklistdata.length > 0) {
params['cooklist'] = json.encode(cooklistdata);
} else {
params['cooklist'] = null;
}
}
}
});
... ... @@ -611,6 +687,18 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
});
});
} else if (element.className == '临时加菜') {
//临时加菜
bool hasmMenu = element.cookbooklist.any(((value) => value.amount > 0));
if (hasmMenu) {
//临时加菜此类有选中菜品
element.cookbooklist.forEach((value) {
if (value.amount > 0) {
priceSum += double.parse(value.price) * value.amount;
memberPriceSum += double.parse(value.member_price) * value.amount;
}
});
}
} else {
//单菜
bool hasmMenu = element.cookbooklist.any(((value) => value.amount > 0));
... ... @@ -803,6 +891,9 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
_planDishProvider
.menuModelForManager[_selectIndex]
.cookbooklist[index];
String className = _planDishProvider
.menuModelForManager[_selectIndex]
.className; //'5'临时加菜
return Container(
padding:
EdgeInsets.symmetric(vertical: w(16)),
... ... @@ -840,31 +931,43 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
// _laduWidget()
],
),
VEmptyView(24),
Row(
children: [
Text(
'${menuSunModel.price}元/${menuSunModel.unit}',
style: TextStyle(
fontSize: font(12),
color: MyColours
.color_999999),
),
HEmptyView(48),
Text(
'${menuSunModel.member_price}元/${menuSunModel.unit}',
style: TextStyle(
fontSize: font(10),
color: MyColours
.color_8EBBBE),
),
],
)
className == '临时加菜' &&
menuSunModel.name == '临时菜'
? SizedBox()
: VEmptyView(24),
className == '临时加菜' &&
menuSunModel.name == '临时菜'
? SizedBox()
: Row(
children: [
Text(
'${menuSunModel.price}元/${menuSunModel.unit}',
style: TextStyle(
fontSize:
font(12),
color: MyColours
.color_999999),
),
HEmptyView(48),
Text(
'${menuSunModel.member_price}元/${menuSunModel.unit}',
style: TextStyle(
fontSize:
font(10),
color: MyColours
.color_8EBBBE),
),
],
)
],
)),
// Spacer(),
menuSunModel.amount != null &&
menuSunModel.amount > 0
(menuSunModel.amount != null &&
menuSunModel.amount > 0 &&
className != '临时加菜') ||
(className == '临时加菜' &&
menuSunModel.name !=
'临时菜')
? InkWell(
onTap: () {
if (menuSunModel.amount >
... ... @@ -920,8 +1023,12 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
)
: SizedBox(),
HEmptyView(8),
menuSunModel.amount != null &&
menuSunModel.amount > 0
(menuSunModel.amount != null &&
menuSunModel.amount > 0 &&
className != '临时加菜') ||
(className == '临时加菜' &&
menuSunModel.name !=
'临时菜')
? Container(
constraints: BoxConstraints(
minWidth: w(32),
... ... @@ -999,38 +1106,50 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
HEmptyView(8),
InkWell(
onTap: () {
setState(() {
menuSunModel.amount++;
// priceSum += double.parse(
// menuSunModel.price);
// memberPriceSum += double.parse(
// menuSunModel.member_price);
// planDishC.text = '${priceSum}';
_calculatePrice();
if (_planDishProvider
.menuModelForManager[
_selectIndex]
.className ==
'套餐' ||
_planDishProvider
.menuModelForManager[
_selectIndex] ==
'我的排菜') {
//套餐菜品总个数
//遍历套餐下的菜品分类
menuSunModel.cookList
.forEach((element) {
//遍历菜品
element.cookbooklist
.forEach((cook) {
carSum += cook.amount;
if (className == '临时加菜' &&
menuSunModel.name == '临时菜') {
//跳转到新建临时菜单页面
NavigatorUtil
.goOrderCreateTemporaryPage(
context,
object: {
'object': _planDishProvider
.menuModelForManager
});
});
} else {
carSum++;
}
});
} else {
setState(() {
menuSunModel.amount++;
// priceSum += double.parse(
// menuSunModel.price);
// memberPriceSum += double.parse(
// menuSunModel.member_price);
// planDishC.text = '${priceSum}';
_calculatePrice();
if (_planDishProvider
.menuModelForManager[
_selectIndex]
.className ==
'套餐' ||
_planDishProvider
.menuModelForManager[
_selectIndex] ==
'我的排菜') {
//套餐菜品总个数
//遍历套餐下的菜品分类
menuSunModel.cookList
.forEach((element) {
//遍历菜品
element.cookbooklist
.forEach((cook) {
carSum += cook.amount;
});
});
} else {
carSum++;
}
});
}
},
child: Container(
height: w(48),
... ... @@ -1326,7 +1445,12 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
element.cookbooklist.forEach((old) {
one.cookbooklist.forEach((newvalue) {
if (old.id == newvalue.id) {
old.amount = newvalue.amount;
if (element.className == '临时加菜' &&
old.name == '临时菜') {
} else {
old.amount = newvalue.amount;
carSumTemp += newvalue.amount;
}
}
});
});
... ... @@ -1364,6 +1488,7 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
if (!success) {
return;
}
bus.emit('refresh_order_advance_home');
}
//调用提交排菜接口
//调用排菜信息提交接口
... ... @@ -1446,8 +1571,10 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
// //套餐中有被选中
// maxIndex++;
// }
} else if (element.className == '临时加菜') {
} else {
}
// else if (element.className == '临时加菜') {
// }
else {
//单菜
bool hasmMenu = element.cookbooklist
.any(((value) => value.amount > 0));
... ... @@ -1563,8 +1690,8 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
NavigatorUtil.goOrderPreviewPage(context,
object: {'object': showList},
name: planDishName,
remark: planDishRemark,
name: planDishName ?? "",
remark: planDishRemark ?? "",
priceSum: priceSum.toString(),
memberPriceSum: memberPriceSum.toString(),
planDishText: planDishC.text,
... ... @@ -1591,6 +1718,7 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
bool success = await setPlanCookByReserve();
if (success) {
Navigator.pop(context);
Navigator.pop(context);
}
// Navigator.pop(context);
// NavigatorUtil.goFinalPlanDishPage(context);
... ...
... ... @@ -228,6 +228,32 @@ class _OrderAdvanceHomePageState extends State<OrderAdvanceHomePage> {
_planDishProvider.menuModelForManager
.insert(1, menuModelPlanDish); //添加排菜
MenuModel menuModelShort = MenuModel();
menuModelShort.className = '临时加菜';
menuModelShort.classType = '5';
menuModelShort.cookbooklist = [];
// 临时加菜
if (_planDishProvider.planCookByRidSunModel != null &&
_planDishProvider.planCookByRidSunModel.temporaryList != null &&
_planDishProvider.planCookByRidSunModel.temporaryList.length > 0) {
menuModelShort.cookbooklist
.addAll(_planDishProvider.planCookByRidSunModel.temporaryList);
_planDishProvider.planCookByRidSunModel.temporaryList.forEach((temporary) {
// if (temporary.amount > 0) {
// carSum += temporary.amount;
// }
});
}
List<MenuSunModel> menuSunShort = [];
MenuSunModel menuSunModelShort = MenuSunModel();
menuSunModelShort.name = '临时菜';
menuSunShort.add(menuSunModelShort);
menuModelShort.cookbooklist.add(menuSunModelShort);
_planDishProvider.menuModelForManager.add(menuModelShort);
// if (_planDishProvider.planCookByRidSunModel != null &&
// _planDishProvider.planCookByRidSunModel.planPrice != null) {
// _calculatePrice(planPrice: _planDishProvider.planCookByRidSunModel.planPrice);
... ... @@ -1002,8 +1028,10 @@ class _OrderAdvanceHomePageState extends State<OrderAdvanceHomePage> {
// //套餐中有被选中
// maxIndex++;
// }
} else if (element.className == '临时加菜') {
} else {
}
// else if (element.className == '临时加菜') {
// }
else {
//单菜
bool hasmMenu = element.cookbooklist
.any(((value) => value.amount > 0));
... ...
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/widgets/MyDivider.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/round_button.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import '../../models/cookbook_model.dart';
import '../../utils/event_bus.dart';
import '../../utils/screen_util.dart';
import '../../utils/utils.dart';
/**
*
* 临时菜新增页
*
*/
class OrderCreateTemporaryPage extends StatefulWidget {
final List<MenuModel> data;
OrderCreateTemporaryPage({Key key, this.data}) : super(key: key);
@override
_OrderCreateTemporaryPageState createState() =>
_OrderCreateTemporaryPageState();
}
class _OrderCreateTemporaryPageState extends State<OrderCreateTemporaryPage> {
TextEditingController name = TextEditingController();
TextEditingController price = TextEditingController();
TextEditingController number = TextEditingController();
TextEditingController unit = TextEditingController();
TextEditingController practice = TextEditingController();
ScrollController controller = ScrollController();
List<MenuSunModel> menuSunShort = [];
int allSum = 0;
@override
void initState() {
super.initState();
if (widget.data != null) {
widget.data.forEach((element) {
if (element.className == '临时加菜') {
menuSunShort = element.cookbooklist;
menuSunShort.removeWhere((value) => value.name == '临时菜');
allSum = 0;
menuSunShort.forEach((short) {
allSum += short.amount;
});
}
});
}
}
_baseInputWidget(
String title, String hintText, TextEditingController controller,
{TextInputType keyboardType = TextInputType.text}) {
return Container(
height: w(40),
child: Row(
children: [
Text(
title,
style: TextStyle(fontSize: font(12), color: MyColours.color_515151),
),
HEmptyView(34),
Container(
width: w(180),
height: w(30),
padding: EdgeInsets.symmetric(horizontal: w(12)),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(r(5)),
border:
Border.all(color: MyColours.color_DBDBDB, width: w(1))),
// constraints: BoxConstraints(minWidth: w(20)),
child: TextField(
maxLines: 1,
controller: controller,
// focusNode: _focusNode,
// autofocus: true,
style: TextStyle(
color: MyColours.color_000000, fontSize: font(12)),
textAlign: TextAlign.left,
// textAlignVertical: TextAlignVertical.center,
decoration: InputDecoration(
hintText: hintText,
hintStyle: TextStyle(
color: MyColours.color_999999,
fontSize: font(12),
),
// isCollapsed:
// true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
border: OutlineInputBorder(borderSide: BorderSide.none),
contentPadding: EdgeInsets.zero,
),
keyboardType: keyboardType,
textInputAction: TextInputAction.done,
onChanged: (value) {
// setState(() {});
// _searchSellerLocation();
// customerProvider.searchData(value);
},
onEditingComplete: () {
FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
// contantShowModel.searchData(
// contantShowModel.controller.text);
// _searchSellerLocation();
// _focusNode.unfocus();
},
)),
],
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: SystemAppBar('临时菜'),
body: Container(
color: MyColours.color_ffffff,
child: Column(
children: [
Expanded(
child: SingleChildScrollView(
controller: controller,
child: Column(
children: [
Padding(
padding: EdgeInsets.only(left: w(20)),
child: Column(
children: [
VEmptyView(16),
_baseInputWidget('菜品名称', '点击输入菜品名称', name),
_baseInputWidget('菜品价格', '点击输入菜品价格', price,
keyboardType: TextInputType.number),
Container(
height: w(40),
child: Row(
children: [
Text(
'菜品数量',
style: TextStyle(
fontSize: font(12),
color: MyColours.color_515151),
),
HEmptyView(34),
InkWell(
onTap: () {
int numStr = int.parse(number.text);
if (numStr == 0) {
return;
}
numStr--;
number.text = numStr.toString();
setState(() {});
},
child: Container(
height: w(48),
padding:
EdgeInsets.symmetric(horizontal: w(8)),
child: Image.asset(
Utils.getImgPath('plan_dish_minus'),
width: w(16),
),
),
),
// 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: number,
// focusNode: _focusNode,
// autofocus: true,
inputFormatters: [
FilteringTextInputFormatter.allow(
RegExp(r'[0-9]')),
],
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) {
if (value != null && value != '') {
//用户输入的数据
// int input = int.parse(value);
setState(() {});
}
},
onEditingComplete: () {
FocusScope.of(context).requestFocus(
FocusNode()); //点击空白处隐藏键盘
// contantShowModel.searchData(
// contantShowModel.controller.text);
// _searchSellerLocation();
// _focusNode.unfocus();
},
)),
// HEmptyView(8),
InkWell(
onTap: () {
if (number.text == '') {
number.text = '0';
}
int numStr = int.parse(number.text);
numStr++;
number.text = numStr.toString();
setState(() {});
},
child: Container(
height: w(48),
padding: EdgeInsets.only(left: w(8)),
child: Image.asset(
Utils.getImgPath('plan_dish_add'),
width: w(16),
),
)),
],
)),
_baseInputWidget('单 位', '点击输入计量单位', unit),
_baseInputWidget('做 法', '点击输入做法', practice),
VEmptyView(62),
Padding(
padding: EdgeInsets.symmetric(horizontal: w(80)),
child: RoundButton(
text: '保存到临时菜单中',
height: w(43),
gradientStart: MyColours.color_ffffff,
gradientEnd: MyColours.color_ffffff,
borderColor: MyColours.color_438E93,
textColor: MyColours.color_438E93,
fontSize: 32,
radius: r(5),
onPressed: () {
if (name.text.trim().length == 0) {
Utils.showToast('请输入菜品名称');
return;
}
if (price.text.trim().length == 0) {
Utils.showToast('请输入菜品价格');
return;
}
if (number.text.trim().length == 0) {
Utils.showToast('请输入菜品数量');
return;
}
if (unit.text.trim().length == 0) {
Utils.showToast('请输入计量单位');
return;
}
if (practice.text.trim().length == 0) {
Utils.showToast('请输入做法');
return;
}
MenuSunModel menuSunModel = MenuSunModel();
menuSunModel.id = DateTime.now()
.millisecondsSinceEpoch
.toString();
menuSunModel.name = name.text;
menuSunModel.price = price.text;
menuSunModel.member_price = price.text;
menuSunModel.amount = number.text == ''
? 0
: int.parse(number.text);
menuSunModel.amountC = TextEditingController();
menuSunModel.amountC.text =
menuSunModel.amount.toString();
allSum += menuSunModel.amount;
menuSunModel.unit = unit.text;
menuSunModel.practice = [practice.text];
menuSunShort.add(menuSunModel);
name.text = '';
price.text = '';
number.text = '';
unit.text = '';
practice.text = '';
setState(() {});
bus.emit('refresh_data', menuSunShort);
},
)),
VEmptyView(26),
],
),
),
MyDivider(
double.infinity,
w(1),
color: MyColours.color_DBDBDB,
),
Container(
height: w(30),
padding: EdgeInsets.only(left: w(10), right: w(20)),
alignment: Alignment.centerLeft,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'已经添加的临时菜品',
style: TextStyle(
fontSize: font(16),
color: MyColours.color_515151,
fontWeight: FontWeight.bold),
),
Text(
'${allSum ?? ''}道',
style: TextStyle(
fontSize: font(14),
color: MyColours.color_515151,
),
)
],
),
),
MyDivider(
double.infinity,
w(1),
color: MyColours.color_DBDBDB,
),
ListView.builder(
controller: controller,
shrinkWrap: true,
itemCount: menuSunShort.length,
itemBuilder: (context, index) {
MenuSunModel menuSunModel = menuSunShort[index];
return Container(
padding: EdgeInsets.only(
left: w(20), top: w(13), bottom: w(13)),
decoration: BoxDecoration(
color: MyColours.color_ffffff,
border: Border(
bottom: BorderSide(
width: w(1),
color: index == menuSunShort.length
? Colors.transparent
: MyColours.color_DBDBDB))),
child: Row(
children: [
Container(
constraints: BoxConstraints(maxWidth: w(80)),
child: Text(
menuSunModel.name,
// 'fdfafaf',
maxLines: 10,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: font(14),
color: MyColours.color_515151),
)),
// HEmptyView(8),
// _laduWidget(),
Spacer(),
Text(
'${menuSunModel.price}元/${menuSunModel.unit}',
// '38元/份',
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: font(12),
color: MyColours.color_999999),
),
HEmptyView(28),
Text(
'${menuSunModel.member_price}元/${menuSunModel.unit}',
// '38元/份',
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: font(10),
color: MyColours.color_8EBBBE),
),
InkWell(
onTap: () {
if (menuSunModel.amount == 0) {
return;
}
menuSunModel.amount--;
menuSunModel.amountC.text =
'${menuSunModel.amount}';
allSum--;
// menuModel.allSum--;
// carSum--;
// // priceSum -= double.parse(
// // menuSunModel.price);
// // planDishC.text =
// // priceSum.toString();
// // memberPriceSum -=
// // double.parse(menuSunModel
// // .member_price);
// _calculatePrice();
// if (menuSunModel.amount == 0) {
// //把当前菜品从列表中去除
// // MenuSunModel menuSunModelFTemp = menuSunModelF
// // dataLocalShowMore[indexMore];
// dataLocalShowOne[indexOne]
// .cookbooklist
// .removeAt(indexReal); //移除当前行
// //判断当前类没有cookbooklist,则删除当前类
// if (dataLocalShowOne[indexOne]
// .cookbooklist
// .length ==
// 0) {
// dataLocalShowOne.removeAt(indexOne);
// }
// }
setState(() {});
bus.emit('refresh_data', menuSunShort);
},
child: Container(
padding: EdgeInsets.only(
left: w(10), right: w(4)),
child: Image.asset(
Utils.getImgPath('plan_dish_minus'),
width: w(16),
))),
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: menuSunModel.amountC,
// focusNode: _focusNode,
// autofocus: true,
inputFormatters: [
FilteringTextInputFormatter.allow(
RegExp(r'[0-9]')),
],
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) {
// if (value != null && value != '') {
// //用户输入的数据
// int input = int.parse(value);
// //减去当前数据
// menuModel.allSum -= menuSunModel.amount;
// carSum -= menuSunModel.amount;
// if (input == 0) {
// //把当前菜品从列表中去除
// dataLocalShowOne[indexOne]
// .cookbooklist
// .removeAt(indexReal); //移除当前行
// //判断当前类没有cookbooklist,则删除当前类
// if (dataLocalShowOne[indexOne]
// .cookbooklist
// .length ==
// 0) {
// dataLocalShowOne.removeAt(indexOne);
// }
// } else {
// menuModel.allSum += input;
// carSum += input;
// }
// menuSunModel.amount = int.parse(value);
// _calculatePrice();
// setState(() {});
// }
},
onEditingComplete: () {
FocusScope.of(context).requestFocus(
FocusNode()); //点击空白处隐藏键盘
// contantShowModel.searchData(
// contantShowModel.controller.text);
// _searchSellerLocation();
// _focusNode.unfocus();
},
)),
InkWell(
onTap: () {
menuSunModel.amount++;
menuSunModel.amountC.text =
'${menuSunModel.amount}';
allSum++;
// menuModel.allSum++;
// carSum++;
// _calculatePrice();
setState(() {});
bus.emit('refresh_data', menuSunShort);
},
child: Container(
padding: EdgeInsets.only(
left: w(4), right: w(18)),
child: Image.asset(
Utils.getImgPath('plan_dish_add'),
width: w(16),
))),
],
),
);
})
],
),
)),
Container(
color: MyColours.color_ffffff,
padding: EdgeInsets.only(
top: w(12), bottom: w(25), left: w(23), right: w(23)),
child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
RoundButton(
text: '返回',
gradientStart: MyColours.color_ffffff,
gradientEnd: MyColours.color_ffffff,
borderColor: MyColours.color_438E93,
textColor: MyColours.color_438E93,
width: w(100),
height: w(43),
radius: r(5),
fontSize: 32,
isBold: false,
onPressed: () {
Navigator.pop(context);
}),
HEmptyView(30),
Expanded(
child: RoundButton(
text: '确定',
gradientStart: MyColours.color_438E93,
gradientEnd: MyColours.color_438E93,
height: w(43),
radius: r(5),
fontSize: 36,
isBold: false,
onPressed: () {
Navigator.pop(context);
}))
])),
],
),
),
);
}
}
... ...
... ... @@ -169,6 +169,36 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> {
// maxIndex++;
// }
} else if (element.className == '临时加菜') {
//临时加菜
bool hasmMenu =
element.cookbooklist.any(((value) => value.amount > 0));
if (hasmMenu) {
//临时加菜此类有选中菜品
MenuModel menuModel = MenuModel();
menuModel.className = element.className;
menuModel.classLabel = element.classLabel;
menuModel.classType = element.classType;
menuModel.id = element.id;
menuModel.order = element.order;
menuModel.sellerid = element.sellerid;
menuModel.status = element.status;
menuModel.cookbooklist = [];
List<MenuSunModel> cookbooklist = [];
int allSum = 0;
element.cookbooklist.forEach((value) {
if (value.amount > 0) {
allSum += value.amount;
// priceSum += double.parse(value.price) * value.amount;
// memberPriceSum +=
// double.parse(value.member_price) * value.amount;
carSum += value.amount;
cookbooklist.add(value);
}
});
menuModel.allSum = allSum;
menuModel.cookbooklist.addAll(cookbooklist);
dataLocalShowOne.add(menuModel);
}
} else {
//单菜
bool hasmMenu =
... ... @@ -409,6 +439,9 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> {
}
//单品
List<MenuModel> cooklistdata = [];
//临时加菜
List<MenuSunModel> temporarylist = [];
temp.forEach((element) {
if (element.className == '套餐') {
List<MenuSunModel> packagelist = [];
... ... @@ -434,18 +467,30 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> {
} else {
params['plan_list'] = null;
}
} else if (element.className == '临时加菜') {
//临时加菜
temporarylist.addAll(element.cookbooklist);
if (temporarylist.length > 0) {
temporarylist.removeWhere((value) => value.amount == 0);
if (temporarylist.length > 0) {
params['temporary_list'] = json.encode(temporarylist);
} else {
params['temporary_list'] = null;
}
}
} else {
//单品
cooklistdata.add(element);
}
if (cooklistdata.length > 0) {
cooklistdata.forEach((cooklist) {
cooklist.cookbooklist.removeWhere((element) => element.amount == 0);
});
if (cooklistdata.length > 0) {
params['cooklist'] = json.encode(cooklistdata);
} else {
params['cooklist'] = null;
cooklistdata.forEach((cooklist) {
cooklist.cookbooklist.removeWhere((element) => element.amount == 0);
});
if (cooklistdata.length > 0) {
params['cooklist'] = json.encode(cooklistdata);
} else {
params['cooklist'] = null;
}
}
}
});
... ... @@ -1892,7 +1937,8 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> {
remark: planDishRemark.text,
priceSum: priceSum.toString(),
memberPriceSum: memberPriceSum.toString(),
planDishText: planDishC.text);
planDishText: planDishC.text,
detailEntity: widget.detailEntity);
},
),
HEmptyView(30),
... ...
import 'dart:ffi';
import 'package:flutter/material.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/plan_cook_by_rid_model.dart';
... ... @@ -114,7 +116,7 @@ class PlanDishProvider extends ChangeNotifier {
// menuModel = [];
if (baseResp != null && baseResp.code == Constant.status_success) {
if (baseResp.data == false) {
if (baseResp.data is Bool) {
// planCookByRidSunModel = PlanCookByRidSunModel();
} else {
... ...
... ... @@ -1273,7 +1273,7 @@ class NavigatorUtil {
// "${Routes.order_advance_home_page}?tids=$tids&tableidNow=$tableidNow&fromPage=$fromPage&canChoose=$canChoose&object=${FluroConvertUtils.object2string(object)}");
// }
return _navigateTo(context,
"${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)}",
"${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)}",
replace: replace);
}
... ... @@ -1349,4 +1349,27 @@ class NavigatorUtil {
"${Routes.plan_dish_edit_page}?isMine=${isMine}&isEdit=${isEdit}&onlyShow=${onlyShow}",
replace: replace);
}
///经理排菜-临时菜新增页
static Future<dynamic> goOrderCreateTemporaryPage(
BuildContext context, {
replace = false,
Map object,
}) {
// if (invoice != null) {
// return _navigateTo(context,
// "${Routes.plan_dish_edit_page}?invoice=${FluroConvertUtils.object2string(invoice)}",
// replace: replace);
// }
// if (sunList != null) {
// return _navigateTo(context,
// "${Routes.order_create_temporary_page}?sunList=${FluroConvertUtils.object2string(sunList)}&isMine=${isMine}&isEdit=${isEdit}&onlyShow=${onlyShow}",
// replace: replace);
// }
return _navigateTo(context,
"${Routes.order_create_temporary_page}?object=${FluroConvertUtils.object2string(object)}",
replace: replace);
}
}
... ...
... ... @@ -185,6 +185,7 @@ import '../pages/my/plan_dish/plan_new_dish_first_page.dart';
import '../pages/my/plan_dish/plan_new_dish_page.dart';
import '../pages/my/table_manage/merge_table_select_page.dart';
import '../pages/order_advance/order_advance_home_page.dart';
import '../pages/order_advance/order_create_temporary_page.dart';
import '../pages/order_advance/order_edit_list_show_page.dart';
import '../pages/order_advance/order_preview_page.dart';
import '../provider/feast_model.dart';
... ... @@ -2198,3 +2199,50 @@ var planDishEidtPageHandle = new Handler(
sunListPlan: sunListPlan,
onlyShow: onlyShow));
});
///经理排菜--临时菜新增页
var orderCreateTemporaryPageHandle = new Handler(
handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
// String fromPage = params["fromPage"].first;
// String tids = params["tids"].first;
// 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'];
// for (var item in temp) {
// res.add(TableList.fromJson(item));
// }
// }
// 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')) {
// sunListPlan = SunListPlan.fromJson(json.decode(
// FluroConvertUtils.fluroCnParamsDecode(params["sunList"].first)));
// }
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));
}
}
return ChangeNotifierProvider<PlanDishProvider>(
create: (_) => PlanDishProvider(), child: OrderCreateTemporaryPage(data:res));
});
... ...
... ... @@ -181,6 +181,8 @@ class Routes {
static String plan_dish_create_select_type_page =
"/plan_dish_create_select_type_page"; //经理排菜---类型选择页
static String plan_dish_edit_page = "/plan_dish_eidt_page"; //经理排菜---编辑页
static String order_create_temporary_page = "/order_create_temporary_page"; //经理排菜---临时菜新建页
static void configureRoutes(FluroRouter router) {
router.notFoundHandler = new Handler(
... ... @@ -356,5 +358,9 @@ class Routes {
handler: planDishCreateSelectTypePageHandle);
router.define(plan_dish_edit_page, handler: planDishEidtPageHandle);
router.define(order_create_temporary_page, handler: orderCreateTemporaryPageHandle);
}
}
... ...