Commit a22e89ae0037b736d77a952bba08e5d0b6aca782

Authored by wdn127929
1 parent 2286d476

排菜编辑数据

... ... @@ -102,37 +102,39 @@ class MenuSunModel {
List<MenuModel> cookList;
int amount; //菜品数量
TextEditingController amountC = TextEditingController();
MenuSunModel({
this.id,
this.sellerid,
this.mid,
this.cid,
this.lid,
this.unit,
this.name,
this.price,
this.member_price,
this.first_name,
this.search_code,
this.channel,
this.dishesvideo,
this.dishesgif,
this.status,
this.setup,
this.give,
this.clear_num,
this.record_num,
this.image,
this.is_weigh,
this.desc,
this.order_o,
this.cdate,
this.spec,
this.isSpec,
this.practice,
this.amount = 0,
});
MenuSunModel(
{this.id,
this.sellerid,
this.mid,
this.cid,
this.lid,
this.unit,
this.name,
this.price,
this.member_price,
this.first_name,
this.search_code,
this.channel,
this.dishesvideo,
this.dishesgif,
this.status,
this.setup,
this.give,
this.clear_num,
this.record_num,
this.image,
this.is_weigh,
this.desc,
this.order_o,
this.cdate,
this.spec,
this.isSpec,
this.practice,
this.amount = 0,
this.cookList,
this.amountC});
MenuSunModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
... ... @@ -162,6 +164,13 @@ class MenuSunModel {
isSpec = json['isSpec'];
practice = json['practice'];
amount = 0;
amountC.text = '0';
if (json['cookList'] != null) {
cookList = [];
json['cookList'].forEach((v) {
cookList.add(new MenuModel.fromJson2(v));
});
}
}
MenuSunModel.fromJson2(Map<String, dynamic> json) {
... ... @@ -192,6 +201,13 @@ class MenuSunModel {
isSpec = json['isSpec'];
practice = json['practice'];
amount = json['amount'] ?? 0;
amountC.text = amount.toString();
if (json['cookList'] != null) {
cookList = [];
json['cookList'].forEach((v) {
cookList.add(new MenuModel.fromJson2(v));
});
}
}
Map<String, dynamic> toJson() {
... ... @@ -224,6 +240,7 @@ class MenuSunModel {
data['isSpec'] = this.isSpec;
data['practice'] = this.practice;
data['amount'] = this.amount;
data['cookList'] = this.cookList;
return data;
}
}
... ...
... ... @@ -812,11 +812,16 @@ 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);
// _planDishProvider.menuModel.forEach((element) {
// _planDishProvider.menuModelForManager
// .forEach((value) {});
// });
NavigatorUtil.goOrderEditListShowPage(context,
object: {
'object':
_planDishProvider.menuModelForManager
});
},
),
RoundButton(
... ...
... ... @@ -8,10 +8,13 @@ import '../../../widgets/MyDivider.dart';
import '../../../widgets/h_empty_view.dart';
import '../../../widgets/round_button.dart';
import '../../../widgets/v_empty_view.dart';
import '../../models/cookbook_model.dart';
import '../../provider/plan_dish_provider.dart';
import '../../route/navigator_util.dart';
class OrderEditListShowPage extends StatefulWidget {
OrderEditListShowPage({Key key}) : super(key: key);
final List<MenuModel> data;
OrderEditListShowPage({Key key, this.data}) : super(key: key);
@override
_OrderEditListShowPageState createState() => _OrderEditListShowPageState();
... ... @@ -19,6 +22,9 @@ class OrderEditListShowPage extends StatefulWidget {
class _OrderEditListShowPageState extends State<OrderEditListShowPage> {
ScrollController controller = ScrollController();
List<MenuSunModel> dataLocalShowMore = []; //二级菜单
List<MenuModel> dataLocalShowOne = []; //一级菜单
Widget _laduWidget() {
// if (labelIcon[widget
// .cookBookList.labelList[index].icon] is int) {
... ... @@ -42,6 +48,62 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> {
}
@override
void initState() {
super.initState();
dataLocalShowMore = []; //二级菜单
dataLocalShowOne = []; //一级菜单
if (widget.data != null) {
widget.data.forEach((element) {
if (element.className == '套餐' || element.className == '我的排菜') {
//如果是套餐,则看cooklist有没有选中的
element.cookbooklist.forEach((value) {
if (value.amount > 0) {
dataLocalShowMore.add(value);
}
});
} else if (element.className == '店内常点') {
// //如果是我的排菜,则看cooklist有没有选中的
// bool hasmMine =
// element.cookbooklist.any(((value) => value.amount > 0));
// if (hasmMine) {
// //套餐中有被选中
// maxIndex++;
// }
} else if (element.className == '临时加菜') {
} else {
//单菜
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 = [];
element.cookbooklist.forEach((value) {
if (value.amount > 0) {
cookbooklist.add(value);
}
});
menuModel.cookbooklist.addAll(cookbooklist);
dataLocalShowOne.add(menuModel);
}
}
});
}
print(dataLocalShowMore);
print(dataLocalShowOne);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: SystemAppBar('排菜单'),
... ... @@ -121,12 +183,282 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> {
],
)),
ListView.builder(
itemCount: 20,
controller: controller,
itemCount: dataLocalShowMore.length,
shrinkWrap: true,
itemBuilder: (context, index) {
MenuSunModel menuSunModel =
dataLocalShowMore[index];
return ListView.builder(
itemCount: 2,
controller: controller,
shrinkWrap: true,
itemBuilder: (context, index) {
if (index == 0) {
return Column(
children: [
//头
Container(
width: double.infinity,
// width: w(32),
height: w(48),
padding: EdgeInsets.symmetric(
horizontal: w(10)),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
width: w(1),
color: MyColours
.color_DBDBDB))),
// constraints: BoxConstraints(minWidth: w(20)),
child: Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Text(
menuSunModel.name,
style: TextStyle(
fontSize: font(16),
color: MyColours
.color_515151,
fontWeight:
FontWeight.bold),
),
Text(
'6道',
style: TextStyle(
fontSize: font(14),
color:
MyColours.color_515151,
),
),
],
))
],
);
}
return ListView.builder(
itemCount: menuSunModel.cookList.length,
shrinkWrap: true,
controller: controller,
itemBuilder: (context, index) {
MenuModel menuModel =
menuSunModel.cookList[index];
return ListView.builder(
itemCount:
menuModel.cookbooklist.length +
1,
shrinkWrap: true,
controller: controller,
itemBuilder: (context, index) {
if (index == 0) {
return Column(
children: [
//头
Container(
width: double.infinity,
// width: w(32),
height: w(48),
padding: EdgeInsets
.symmetric(
horizontal:
w(10)),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
width: w(1),
color: MyColours
.color_DBDBDB))),
// constraints: BoxConstraints(minWidth: w(20)),
child: Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Text(
menuModel
.className,
style: TextStyle(
fontSize:
font(16),
color: MyColours
.color_515151,
fontWeight:
FontWeight
.bold),
),
Text(
'6道',
style: TextStyle(
fontSize:
font(14),
color: MyColours
.color_515151,
),
),
],
))
],
);
}
int indexReal = index - 1;
MenuSunModel menuSunModel =
menuModel
.cookbooklist[indexReal];
return Container(
padding: EdgeInsets.symmetric(
horizontal: w(20),
vertical: w(13)),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
width: w(1),
color: MyColours
.color_DBDBDB))),
child: Row(
children: [
Container(
constraints:
BoxConstraints(
maxWidth:
w(80)),
child: Text(
menuSunModel.name,
maxLines: 10,
overflow: TextOverflow
.ellipsis,
style: TextStyle(
fontSize:
font(14),
color: MyColours
.color_515151),
)),
// HEmptyView(8),
// _laduWidget(),
Spacer(),
Text(
'${menuSunModel.price}元/${menuSunModel.unit}',
maxLines: 2,
overflow:
TextOverflow.ellipsis,
style: TextStyle(
fontSize: font(12),
color: MyColours
.color_999999),
),
HEmptyView(28),
Text(
'${menuSunModel.member_price}元/${menuSunModel.unit}',
maxLines: 2,
overflow:
TextOverflow.ellipsis,
style: TextStyle(
fontSize: font(10),
color: MyColours
.color_8EBBBE),
),
HEmptyView(20),
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:
menuSunModel
.amountC,
// 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();
},
)),
HEmptyView(8),
Image.asset(
Utils.getImgPath(
'plan_dish_add'),
width: w(16),
),
],
),
);
});
});
});
}),
ListView.builder(
itemCount: dataLocalShowOne.length,
shrinkWrap: true,
controller: controller,
itemBuilder: (context, index) {
MenuModel menuModel = dataLocalShowOne[index];
return ListView.builder(
itemCount: 2 + 1,
itemCount: menuModel.cookbooklist.length + 1,
shrinkWrap: true,
controller: controller,
itemBuilder: (context, index) {
... ... @@ -153,7 +485,7 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> {
.spaceBetween,
children: [
Text(
'热菜',
menuModel.className,
style: TextStyle(
fontSize: font(16),
color: MyColours
... ... @@ -175,6 +507,8 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> {
);
}
int indexReal = index - 1;
MenuSunModel menuSunModel =
menuModel.cookbooklist[indexReal];
return Container(
padding: EdgeInsets.symmetric(
horizontal: w(20), vertical: w(13)),
... ... @@ -190,7 +524,7 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> {
constraints:
BoxConstraints(maxWidth: w(80)),
child: Text(
'山城辣子鸡',
menuSunModel.name,
maxLines: 10,
overflow: TextOverflow.ellipsis,
style: TextStyle(
... ... @@ -198,11 +532,11 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> {
color:
MyColours.color_515151),
)),
HEmptyView(8),
_laduWidget(),
// HEmptyView(8),
// _laduWidget(),
Spacer(),
Text(
'38元/份',
'${menuSunModel.price}元/${menuSunModel.unit}',
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
... ... @@ -211,7 +545,7 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> {
),
HEmptyView(28),
Text(
'38元/份',
'${menuSunModel.member_price}元/${menuSunModel.unit}',
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
... ... @@ -237,7 +571,7 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> {
// constraints: BoxConstraints(minWidth: w(20)),
child: TextField(
maxLines: 1,
// controller:
controller: menuSunModel.amountC,
// focusNode: _focusNode,
// autofocus: true,
... ...
... ... @@ -1265,19 +1265,17 @@ class NavigatorUtil {
///经理排菜-编辑列表展示
static Future<dynamic> goOrderEditListShowPage(
BuildContext context, {
replace = false,
}) {
static Future<dynamic> goOrderEditListShowPage(BuildContext context,
{replace = false, Map object}) {
// if (invoice != null) {
// return _navigateTo(context,
// "${Routes.order_advance_home_page}?invoice=${FluroConvertUtils.object2string(invoice)}",
// replace: replace);
// }
// if (object != null) {
// return _navigateTo(context,
// "${Routes.order_advance_home_page}?tids=$tids&tableidNow=$tableidNow&fromPage=$fromPage&canChoose=$canChoose&object=${FluroConvertUtils.object2string(object)}");
// }
if (object != null) {
return _navigateTo(context,
"${Routes.order_edit_list_show_page}?object=${FluroConvertUtils.object2string(object)}");
}
return _navigateTo(context, "${Routes.order_edit_list_show_page}",
replace: replace);
}
... ...
... ... @@ -2007,8 +2007,24 @@ var orderEditListShowPageHandle = new Handler(
// res.add(TableList.fromJson(item));
// }
// }
return ChangeNotifierProvider<PlanDishProvider>(
create: (_) => PlanDishProvider(), child: OrderEditListShowPage());
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 OrderEditListShowPage(data: res);
});
///经理排菜--类型选择
... ...