Commit c684b26a3b6dc835a5058c6e1a925e74d75f23a0

Authored by wdn127929
1 parent 5c747542

调菜未完成

... ... @@ -4,7 +4,7 @@ class MenuModel {
String id;
String sellerid;
String className;
Null classLabel;
dynamic classLabel;
String order;
String status;
String classType;
... ...
... ... @@ -30,7 +30,7 @@ class GetSetmealClassByIdSunModel {
String mid;
String className;
String status;
Null cdate;
dynamic cdate;
List<CookById> cook;
GetSetmealClassByIdSunModel(
... ...
... ... @@ -33,7 +33,7 @@ class GetSetmealClassSunModel {
String mid;
String className;
String status;
Null cdate;
dynamic cdate;
List<Cook> cook;
GetSetmealClassSunModel(
... ...
import 'package:flutter/material.dart';
import 'package:one_key/models/dsolt_xt.dart';
import 'package:one_key/models/table_list.dart' as t;
... ... @@ -21,6 +22,7 @@ class SetXuanTaiModel {
String startDate = '';
String endDate = '';
List<t.TableList> tableList;
int tableSum = 0; //桌位总数
SetXuanTaiModel(
{this.rid,
... ... @@ -102,6 +104,7 @@ class Tids {
String tid;
String numStr;
String name;
TextEditingController tableNumC = TextEditingController(); //桌位个数
Tids({this.tid, this.numStr, this.name});
... ... @@ -125,14 +128,29 @@ class Setmeal {
String pnum;
String min;
String spare;
Setmeal(
{this.setmealId,
this.price,
this.finalPrice,
this.pnum,
this.min,
this.spare});
String name;
bool select = false;
String bargaining;
TextEditingController finalPriceC;
TextEditingController pnumC;
TextEditingController minC;
TextEditingController spareC;
Setmeal({
this.setmealId,
this.price,
this.finalPrice,
this.pnum,
this.min,
this.spare,
this.name,
this.select,
this.bargaining,
// this.finalPriceC,
// this.pnumC,
// this.minC,
// this.spareC,
});
Setmeal.fromJson(Map<String, dynamic> json) {
setmealId = json['setmeal_id'];
... ... @@ -141,6 +159,13 @@ class Setmeal {
pnum = json['pnum'];
min = json['min'];
spare = json['spare'];
name = json['name'];
select = json['select'];
bargaining = json['bargaining'];
// finalPriceC = json['finalPriceC'];
// pnumC = json['pnumC'];
// minC = json['minC'];
// spareC = json['spareC'];
}
Map<String, dynamic> toJson() {
... ... @@ -151,6 +176,14 @@ class Setmeal {
data['pnum'] = this.pnum;
data['min'] = this.min;
data['spare'] = this.spare;
data['name'] = this.name;
data['select'] = this.select;
data['bargaining'] = this.bargaining;
// data['finalPriceC'] = this.finalPriceC;
// data['pnumC'] = this.pnumC;
// data['minC'] = this.minC;
// data['spareC'] = this.spareC;
return data;
}
}
... ...
... ... @@ -31,9 +31,9 @@ class SetMeaByIdSunModel {
String price;
String bargaining;
String status;
Null cdate;
List<Classify> classify;
List<Cook> cook;
dynamic cdate;
List<ClassifyById> classify;
List<CookByIdSetmeal> cook;
SetMeaByIdSunModel(
{this.id,
... ... @@ -55,15 +55,15 @@ class SetMeaByIdSunModel {
status = json['status'];
cdate = json['cdate'];
if (json['class'] != null) {
classify = <Classify>[];
classify = <ClassifyById>[];
json['class'].forEach((v) {
classify.add(new Classify.fromJson(v));
classify.add(new ClassifyById.fromJson(v));
});
}
if (json['cook'] != null) {
cook = <Cook>[];
cook = <CookByIdSetmeal>[];
json['cook'].forEach((v) {
cook.add(new Cook.fromJson(v));
cook.add(new CookByIdSetmeal.fromJson(v));
});
}
}
... ... @@ -87,7 +87,7 @@ class SetMeaByIdSunModel {
}
}
class Classify {
class ClassifyById {
String id;
String sid;
String mid;
... ... @@ -95,10 +95,10 @@ class Classify {
String status;
dynamic cdate;
Classify(
ClassifyById(
{this.id, this.sid, this.mid, this.className, this.status, this.cdate});
Classify.fromJson(Map<String, dynamic> json) {
ClassifyById.fromJson(Map<String, dynamic> json) {
id = json['id'];
sid = json['sid'];
mid = json['mid'];
... ... @@ -119,7 +119,7 @@ class Classify {
}
}
class Cook {
class CookByIdSetmeal {
String id;
String sid;
String cid;
... ... @@ -129,7 +129,7 @@ class Cook {
String isTrim;
String status;
Cook(
CookByIdSetmeal(
{this.id,
this.sid,
this.cid,
... ... @@ -139,7 +139,7 @@ class Cook {
this.isTrim,
this.status});
Cook.fromJson(Map<String, dynamic> json) {
CookByIdSetmeal.fromJson(Map<String, dynamic> json) {
id = json['id'];
sid = json['sid'];
cid = json['cid'];
... ...
... ... @@ -96,7 +96,7 @@ class Classify {
String mid;
String className;
String status;
Null cdate;
dynamic cdate;
Classify(
{this.id, this.sid, this.mid, this.className, this.status, this.cdate});
... ...
... ... @@ -917,6 +917,9 @@ class _FeastCreatePageState extends State<FeastCreatePage> {
return item.title;
}).toList(), (value) {
if (value != null) {
xuantaiData[xuantaiSelIndex].tids = [];
xuantaiData[xuantaiSelIndex].tableList = [];
xuantaiData[xuantaiSelIndex].tableSum = 0;
setState(() {
xuantaiData[xuantaiSelIndex].cdSelIndex =
value.first;
... ... @@ -1005,7 +1008,8 @@ class _FeastCreatePageState extends State<FeastCreatePage> {
recognizer: TapGestureRecognizer()
..onTap = () {}),
TextSpan(
text: '(共0桌)',
text:
'(共${xuantaiData[xuantaiSelIndex].tableSum}桌)',
style: TextStyle(
color: MyColours.color_000000,
fontSize: ScreenUtil().setSp(28)),
... ... @@ -1043,14 +1047,71 @@ class _FeastCreatePageState extends State<FeastCreatePage> {
fontSize: font(16)),
)),
Container(
width: w(22),
child: Text(
'30',
style: TextStyle(
color: MyColours.color_438E93,
fontSize: font(14)),
),
),
width: w(80),
height: h(20),
decoration: BoxDecoration(
border: Border.all(
width: w(1),
color: MyColours
.color_438E93)),
child: TextField(
maxLines: 1,
//输入文本的样式
style: TextStyle(
fontSize: ScreenUtil()
.setSp(28),
color: MyColours
.color_438E93),
controller: xuantaiData[
xuantaiSelIndex]
.tids[index]
.tableNumC,
// focusNode: node,
// textAlignVertical: TextAlignVertical.top,
textAlign: TextAlign.center,
decoration: InputDecoration(
hintText: '请输入',
hintStyle: TextStyle(
color: MyColours
.color_999999,
fontSize: ScreenUtil()
.setSp(28),
),
// contentPadding:
// EdgeInsets.only(bottom: ScreenUtil().setWidth(17)),
// border: InputBorder.none,
contentPadding:
EdgeInsets.zero,
border: OutlineInputBorder(
borderSide:
BorderSide.none),
),
onChanged: (value) {
print('ggg');
xuantaiData[xuantaiSelIndex]
.tableSum = 0;
for (Tids item
in xuantaiData[
xuantaiSelIndex]
.tids) {
xuantaiData[xuantaiSelIndex]
.tableSum +=
int.parse(item
.tableNumC.text);
}
setState(() {});
},
onEditingComplete: () {
// print('fff');
// node.unfocus();
// _homeEnterModel.nameController.text =
// nameStr + _nameSuffix();
// _addNameSuffix(nameStr, sexStr);
},
keyboardType:
TextInputType.number)),
HEmptyView(8),
Text(
'桌',
style: TextStyle(
... ... @@ -1059,10 +1120,38 @@ class _FeastCreatePageState extends State<FeastCreatePage> {
),
HEmptyView(32),
InkWell(
onTap: () {
FocusScope.of(context)
.requestFocus(
FocusNode()); //点击空白处隐藏键盘
//弹框确认是否删除
DialogUtil.cupertinoAlertDialog(
context,
title: "",
content: "是否确定删除?",
isBoldContent: true,
contentColor: MyColours
.color_E6000000,
rTitle: "删除",
rCallback: () {
xuantaiData[xuantaiSelIndex]
.tableSum -=
int.parse(xuantaiData[
xuantaiSelIndex]
.tids[index]
.tableNumC
.text);
xuantaiData[xuantaiSelIndex]
.tids
.removeAt(index);
// _delGuestInfocDay(model.cday[index].id);
});
},
child: Image.asset(
Utils.getImgPath('f_delete_red'),
width: w(20),
))
Utils.getImgPath(
'f_delete_red'),
width: w(20),
))
],
),
);
... ... @@ -1081,6 +1170,11 @@ class _FeastCreatePageState extends State<FeastCreatePage> {
onPressed: () async {
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
if (xuantaiData[xuantaiSelIndex].cdShow ==
'请选择') {
Utils.showToast('请选择餐段');
return;
}
if (xuantaiData[xuantaiSelIndex].cdShow ==
'不带餐') {
... ... @@ -1127,52 +1221,70 @@ class _FeastCreatePageState extends State<FeastCreatePage> {
setState(() {});
}
} else {
if (xuantaiData[xuantaiSelIndex]
.dateTimeShowxt ==
'请选择') {
Utils.showToast('请选择宴会日期');
return;
}
//带餐
int ddate = xuantaiData[xuantaiSelIndex]
.dateTimext
.millisecondsSinceEpoch;
String ddateSolt = dsoltList[
xuantaiData[xuantaiSelIndex]
.cdSelIndex]
.id;
Map temp = {};
if (xuantaiData[xuantaiSelIndex]
.tableList !=
null &&
xuantaiData[xuantaiSelIndex]
.tableList
.length >
0) {
temp = await NavigatorUtil
.goSelectTableFPage(
context, '', ddate, ddateSolt,
canChoose: true,
object: {
'object':
xuantaiData[xuantaiSelIndex]
.tableList
});
} else {
temp = await NavigatorUtil
.goSelectTableFPage(
context,
'',
ddate,
ddateSolt,
canChoose: true,
);
}
if (temp == null) {
} else if (temp['object'].length == 0) {
} else {
xuantaiData[xuantaiSelIndex].tids = [];
xuantaiData[xuantaiSelIndex].tableList =
temp['object'];
for (t.TableList item
in xuantaiData[xuantaiSelIndex]
.tableList) {
item.selected = true;
Tids tids = Tids();
tids.tid = item.tid;
tids.name = item.name;
xuantaiData[xuantaiSelIndex]
.tids
.add(tids);
}
setState(() {});
}
}
// int ddate = xuantaiData[xuantaiSelIndex]
// .dateTimext
// .millisecondsSinceEpoch;
// String ddateSolt = _notebookDetailChangeModel
// .currTimeIndex
// .toString();
// Map temp =
// await NavigatorUtil.goSelectTableFPage(
// context, '', ddate, ddateSolt,
// canChoose: true,
// object: {
// 'object':
// _notebookDetailChangeModel.tableList
// });
// if (temp == null) {
// } else if (temp['object'].length == 0) {
// } else {
// _notebookDetailChangeModel.tableList =
// temp['object'];
// for (t.TableList item
// in _notebookDetailChangeModel
// .tableList) {
// item.selected = true;
// }
// // setState(() {});
// int dateTimeMill =
// _notebookDetailChangeModel
// .dateTime.millisecondsSinceEpoch;
// await _notebookDetailChangeModel
// .getNewTableList(
// context,
// '${dateTimeMill}',
// _notebookDetailChangeModel
// .currTimeIndex
// .toString(),
// widget.detailEntity.pnum,
// _notebookDetailChangeModel
// .tableList);
// _notebookDetailChangeModel
// .notifyListeners();
// }
},
),
VEmptyView(52),
... ... @@ -1183,13 +1295,20 @@ class _FeastCreatePageState extends State<FeastCreatePage> {
fontSize: ScreenUtil().setSp(28)),
),
ListView.builder(
itemCount: 2,
itemCount: xuantaiData[xuantaiSelIndex]
.setmeal
.length,
shrinkWrap: true,
controller: controller,
itemBuilder:
(BuildContext context, int index) {
Setmeal setmeal =
xuantaiData[xuantaiSelIndex]
.setmeal[index];
return Container(
height: h(80),
// height: h(80),
padding:
EdgeInsets.symmetric(vertical: w(10)),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
... ... @@ -1206,7 +1325,7 @@ class _FeastCreatePageState extends State<FeastCreatePage> {
children: [
Expanded(
child: Text(
'1299套餐',
setmeal.name,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color:
... ... @@ -1217,7 +1336,8 @@ class _FeastCreatePageState extends State<FeastCreatePage> {
onTap: () {
NavigatorUtil
.goFeastMenuPage(
context);
context,
setmeal.setmealId);
},
child: Row(
children: [
... ... @@ -1245,15 +1365,44 @@ class _FeastCreatePageState extends State<FeastCreatePage> {
))
],
),
setmeal.finalPrice.isEmpty &&
setmeal.min.isEmpty &&
setmeal.spare.isEmpty &&
setmeal.pnum.isEmpty
? SizedBox()
: VEmptyView(32),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
MainAxisAlignment.start,
children: [
taocanText('1299', ' 元/桌'),
taocanText('10', ' 人/桌'),
taocanTextType(
'保证 ', '1299', ' 桌'),
taocanTextType('备用 ', '2', ' 桌'),
setmeal.finalPrice.isNotEmpty
? Padding(
padding: EdgeInsets.only(
right: w(16)),
child: taocanText(
setmeal.finalPrice,
' 元/桌'))
: SizedBox(),
setmeal.pnum.isNotEmpty
? Padding(
padding: EdgeInsets.only(
right: w(16)),
child: taocanText(
setmeal.pnum, ' 人/桌'))
: SizedBox(),
setmeal.min.isNotEmpty
? Padding(
padding: EdgeInsets.only(
right: w(16)),
child: taocanTextType(
'保证 ',
setmeal.min,
' 桌'))
: SizedBox(),
setmeal.spare.isNotEmpty
? taocanTextType('备用 ',
setmeal.spare, ' 桌')
: SizedBox(),
],
)
],
... ... @@ -1271,8 +1420,36 @@ class _FeastCreatePageState extends State<FeastCreatePage> {
isBold: false,
gradientStart: MyColours.color_438E93,
gradientEnd: MyColours.color_438E93,
onPressed: () {
NavigatorUtil.goFeastSetmealPage(context);
onPressed: () async {
Map temp = {};
if (xuantaiData[xuantaiSelIndex]
.setmeal
.length >
0) {
temp =
await NavigatorUtil.goFeastSetmealPage(
context,
justSelData: {
'object': xuantaiData[xuantaiSelIndex]
.setmeal
});
} else {
temp =
await NavigatorUtil.goFeastSetmealPage(
context,
);
}
if (temp == null) {
} else if (temp['object'].length == 0) {
} else {
xuantaiData[xuantaiSelIndex].setmeal =
temp['object'];
print(xuantaiData[xuantaiSelIndex]
.setmeal
.toString());
}
setState(() {});
},
),
VEmptyView(52),
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/get_setmeal_class_by_id_model.dart';
import 'package:one_key/models/setmeal_by_id_model.dart';
import 'package:one_key/models/setmeal_model.dart';
import 'package:one_key/widgets/MyDivider.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:provider/provider.dart';
import '../../constant/state.dart';
import '../../provider/feast_model.dart';
import '../../res/colors.dart';
import '../../utils/screen_util.dart';
import '../../utils/utils.dart';
import '../../widgets/page_exception.dart';
import '../../widgets/system_app_bar.dart';
import '../../widgets/v_empty_view.dart';
... ... @@ -14,7 +21,8 @@ import '../../widgets/v_empty_view.dart';
* 调菜
*/
class FeastMenuPage extends StatefulWidget {
FeastMenuPage({Key key}) : super(key: key);
final String setmealId;
FeastMenuPage({Key key, this.setmealId}) : super(key: key);
@override
_FeastMenuPageState createState() => _FeastMenuPageState();
... ... @@ -22,12 +30,43 @@ class FeastMenuPage extends StatefulWidget {
class _FeastMenuPageState extends State<FeastMenuPage> {
ScrollController controller = ScrollController();
FeastModel feastModel;
Map<String, List<CookByIdSetmeal>> data = {};
List<String> classNames = [];
@override
void initState() {
// TODO: implement initState
super.initState();
Utils.changeStatusColor(color: MyColours.color_438E93);
WidgetsBinding.instance.addPostFrameCallback((_) {
_getSetmealById();
});
}
/// 根据ID获取宴会套餐
_getSetmealById({bool isShowLoading = true}) async {
Map<String, String> params = {"id": widget.setmealId};
bool success = await feastModel.getSetmealById(context, params,
isShowLoading: isShowLoading);
if (success) {
for (ClassifyById item in feastModel.setmealDetail.classify) {
// Map<String, List<CookByIdSetmeal>> map = {};
String cid = item.id;
String className = item.className;
List<CookByIdSetmeal> temp = [];
for (CookByIdSetmeal itemCook in feastModel.setmealDetail.cook) {
if (cid == itemCook.cid) {
temp.add(itemCook);
}
}
classNames.add(className);
data[className] = temp;
}
feastModel.pageStateMenu = PageState.Success;
setState(() {});
}
}
Widget _callButton(
... ... @@ -122,17 +161,19 @@ class _FeastMenuPageState extends State<FeastMenuPage> {
);
}
Widget _itemBuildWidget(BuildContext context, int index) {
Widget _itemBuildWidget(BuildContext context, int index1) {
List<CookByIdSetmeal> cookList = data[classNames[index1]];
return ListView.builder(
shrinkWrap: true,
controller: controller,
padding: EdgeInsets.only(right: w(12)),
itemCount: _getItemListCount(),
itemCount: cookList.length + 1,
itemBuilder: (BuildContext context, int index) {
if (index < 1) {
return _buildHeaderWidget(context, index);
return _buildHeaderWidget(context, classNames[index1]);
} else {
int itemIndex = index - 1;
CookByIdSetmeal setmeal = cookList[itemIndex];
return Container(
margin: new EdgeInsets.only(bottom: h(12)),
... ... @@ -148,7 +189,7 @@ class _FeastMenuPageState extends State<FeastMenuPage> {
Container(
width: h(90),
child: Text(
'鱼香肉丝',
setmeal.cname,
overflow: TextOverflow.ellipsis,
maxLines: 10,
style: TextStyle(
... ... @@ -159,7 +200,7 @@ class _FeastMenuPageState extends State<FeastMenuPage> {
Container(
width: h(36),
child: Text(
'10份',
'10${setmeal.spec}',
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: TextStyle(
... ... @@ -167,7 +208,7 @@ class _FeastMenuPageState extends State<FeastMenuPage> {
fontSize: ScreenUtil().setSp(32)),
)),
HEmptyView(16),
index == 1
setmeal.isTrim == '0'
? Text(
'不可调菜',
overflow: TextOverflow.ellipsis,
... ... @@ -202,17 +243,17 @@ class _FeastMenuPageState extends State<FeastMenuPage> {
);
}
// 总count数
int _getItemListCount() {
return 3 + 1;
}
// // 总count数
// int _getItemListCount() {
// return data.length + 1;
// }
// header内容
Widget _buildHeaderWidget(BuildContext context, int index) {
Widget _buildHeaderWidget(BuildContext context, String title) {
return Padding(
padding: EdgeInsets.only(bottom: h(12)),
child: Text(
'热菜',
title,
style: TextStyle(
color: MyColours.color_515151,
fontSize: font(16),
... ... @@ -222,6 +263,7 @@ class _FeastMenuPageState extends State<FeastMenuPage> {
@override
Widget build(BuildContext context) {
feastModel = Provider.of(context);
return Scaffold(
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar(
... ... @@ -233,62 +275,76 @@ class _FeastMenuPageState extends State<FeastMenuPage> {
Navigator.pop(context);
},
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: SingleChildScrollView(
controller: controller,
child: Padding(
padding: EdgeInsets.only(left: w(16)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
VEmptyView(64),
Text(
'1299套餐',
style: TextStyle(
color: MyColours.color_E6000000,
fontSize: font(16)),
),
VEmptyView(24),
MyDivider(
double.infinity,
h(1),
color: MyColours.color_E7E7E7,
),
VEmptyView(64),
ListView.builder(
shrinkWrap: true,
controller: controller,
padding: EdgeInsets.only(right: w(12)),
itemCount: 10,
itemBuilder: (BuildContext context, int index) {
return buildItemWidget(context, index);
},
)
],
)),
)),
Row(
body: Consumer<FeastModel>(builder: (context, model, _) {
if (model.pageStateMenu != PageState.Success) {
return ExceptionPage(
pageState: model.pageStateMenu,
callback: () {
// _getSellerUserBySellerid();
},
emptyMsg: "暂时没有菜品哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: _callButton(
onPress: () {
Navigator.pop(context);
},
content: '返回',
hasLeftBorder: true,
isSelect: false)),
Expanded(
child: _callButton(
onPress: () {},
content: '保存并返回',
hasLeftBorder: true,
isSelect: true))
child: SingleChildScrollView(
controller: controller,
child: Padding(
padding: EdgeInsets.only(left: w(16)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
VEmptyView(64),
Text(
feastModel.setmealDetail.mealName,
style: TextStyle(
color: MyColours.color_E6000000,
fontSize: font(16)),
),
VEmptyView(24),
MyDivider(
double.infinity,
h(1),
color: MyColours.color_E7E7E7,
),
VEmptyView(64),
ListView.builder(
shrinkWrap: true,
controller: controller,
padding: EdgeInsets.only(right: w(12)),
itemCount: data.length,
itemBuilder: (BuildContext context, int index) {
return buildItemWidget(context, index);
},
)
],
)),
)),
Row(
children: [
Expanded(
child: _callButton(
onPress: () {
Navigator.pop(context);
},
content: '返回',
hasLeftBorder: true,
isSelect: false)),
Expanded(
child: _callButton(
onPress: () {},
content: '保存并返回',
hasLeftBorder: true,
isSelect: true))
],
)
],
)
],
));
);
}
}));
}
}
... ...
import 'package:contacts_service/contacts_service.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:provider/provider.dart';
import '../../constant/state.dart';
import '../../models/set_xuan_tai_model.dart';
import '../../models/setmeal_model.dart';
import '../../provider/feast_model.dart';
import '../../res/colors.dart';
import '../../utils/screen_util.dart';
import '../../utils/utils.dart';
import '../../widgets/page_exception.dart';
import '../../widgets/round_button.dart';
import '../../widgets/system_app_bar.dart';
import '../../widgets/v_empty_view.dart';
... ... @@ -13,17 +20,64 @@ import '../../widgets/v_empty_view.dart';
* 添加套餐
*/
class FeastSetmealPage extends StatefulWidget {
FeastSetmealPage({Key key}) : super(key: key);
final List<Setmeal> justSelData;
FeastSetmealPage({Key key, this.justSelData}) : super(key: key);
@override
_FeastSetmealPageState createState() => _FeastSetmealPageState();
}
class _FeastSetmealPageState extends State<FeastSetmealPage> {
List<Setmeal> setmealData = [];
FeastModel feastModel;
@override
void initState() {
super.initState();
Utils.changeStatusColor(color: MyColours.color_438E93);
WidgetsBinding.instance.addPostFrameCallback((_) {
_getSetmeal();
// scrollController.jumpTo(scrollController.position.minScrollExtent);
});
}
///获取宴会套餐
Future<bool> _getSetmeal({bool isShowLoading = true}) async {
bool success =
await feastModel.getSetmeal(context, isShowLoading: isShowLoading);
if (success) {
List<String> setmealids = widget.justSelData.map((e) {
return e.setmealId;
}).toList();
for (SetMealSunModel item in feastModel.setmealData) {
Setmeal setmeal = Setmeal();
setmeal.setmealId = item.id;
setmeal.name = item.mealName;
setmeal.bargaining = item.bargaining;
setmeal.finalPriceC = TextEditingController();
setmeal.minC = TextEditingController();
setmeal.pnumC = TextEditingController();
setmeal.spareC = TextEditingController();
if (setmealids.contains(item.id)) {
setmeal.select = true;
int index = widget.justSelData
.indexWhere((element) => element.setmealId == item.id);
Setmeal widgetData = widget.justSelData[index];
setmeal.finalPriceC.text = widgetData.finalPrice;
setmeal.minC.text = widgetData.min;
setmeal.pnumC.text = widgetData.pnum;
setmeal.spareC.text = widgetData.spare;
} else {
setmeal.select = false;
}
setmeal.price = item.price;
setmealData.add(setmeal);
}
setState(() {});
}
}
Widget _callButton(
... ... @@ -114,7 +168,7 @@ class _FeastSetmealPageState extends State<FeastSetmealPage> {
);
}
Widget buildListItem(BuildContext context, int index, bool select) {
Widget buildListItem(Setmeal data) {
return Container(
padding: EdgeInsets.only(
top: h(25), bottom: h(10), left: w(12), right: w(12)),
... ... @@ -129,21 +183,21 @@ class _FeastSetmealPageState extends State<FeastSetmealPage> {
InkWell(
onTap: () {
setState(() {
select = !select;
data.select = !data.select;
});
},
child: Row(
children: [
Image.asset(
Utils.getImgPath(
select ? 'f_select' : 'f_select_not'),
data.select ? 'f_select' : 'f_select_not'),
width: w(24),
),
HEmptyView(24),
Text(
'1299套餐',
data.name,
style: TextStyle(
color: select
color: data.select
? MyColours.color_515151
: MyColours.color_999999,
fontSize: font(16),
... ... @@ -168,14 +222,14 @@ class _FeastSetmealPageState extends State<FeastSetmealPage> {
),
],
),
select
data.select
? Column(
children: [
VEmptyView(42),
Row(
children: [
Text(
'原价:1299元',
'原价:${data.price}元',
style: TextStyle(
color: MyColours.color_515151,
fontSize: font(14),
... ... @@ -189,14 +243,27 @@ class _FeastSetmealPageState extends State<FeastSetmealPage> {
fontSize: font(14),
),
),
_textfield('1299', null, null, width: w(126)),
Text(
' 元',
style: TextStyle(
color: MyColours.color_515151,
fontSize: font(14),
),
),
data.bargaining == '1'
? Row(
children: [
_textfield('', data.finalPriceC, null,
width: w(126)),
Text(
' 元',
style: TextStyle(
color: MyColours.color_515151,
fontSize: font(14),
),
),
],
)
: Text(
'不可议价',
style: TextStyle(
color: MyColours.color_515151,
fontSize: font(14),
),
),
],
),
VEmptyView(42),
... ... @@ -209,7 +276,7 @@ class _FeastSetmealPageState extends State<FeastSetmealPage> {
fontSize: font(14),
),
),
_textfield('3', null, null, width: w(45)),
_textfield('', data.pnumC, null, width: w(45)),
Text(
' 人',
style: TextStyle(
... ... @@ -225,7 +292,7 @@ class _FeastSetmealPageState extends State<FeastSetmealPage> {
fontSize: font(14),
),
),
_textfield('3', null, null, width: w(45)),
_textfield('', data.minC, null, width: w(45)),
Text(
' 桌',
style: TextStyle(
... ... @@ -241,7 +308,7 @@ class _FeastSetmealPageState extends State<FeastSetmealPage> {
fontSize: font(14),
),
),
_textfield('3', null, null, width: w(45)),
_textfield('', data.spareC, null, width: w(45)),
Text(
' 桌',
style: TextStyle(
... ... @@ -260,6 +327,7 @@ class _FeastSetmealPageState extends State<FeastSetmealPage> {
@override
Widget build(BuildContext context) {
feastModel = Provider.of<FeastModel>(context, listen: true);
return Scaffold(
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar(
... ... @@ -271,36 +339,80 @@ class _FeastSetmealPageState extends State<FeastSetmealPage> {
Navigator.pop(context);
},
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: ListView.builder(
shrinkWrap: true,
itemCount: 10,
itemBuilder: (BuildContext context, int index) {
return buildListItem(context, index, true);
body: Consumer<FeastModel>(builder: (context, model, _) {
if (model.pageStateSetmeal != PageState.Success) {
return ExceptionPage(
pageState: model.pageStateSetmeal,
callback: () {
_getSetmeal();
},
)),
Row(
emptyMsg: "暂时没有套餐哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: _callButton(
onPress: () {
Navigator.pop(context);
},
content: '返回',
hasLeftBorder: true,
isSelect: false)),
Expanded(
child: _callButton(
onPress: () {},
content: '保存并返回',
hasLeftBorder: true,
isSelect: true))
child: ListView.builder(
shrinkWrap: true,
itemCount: setmealData.length,
itemBuilder: (BuildContext context, int index) {
Setmeal data = setmealData[index];
return buildListItem(data);
},
)),
Row(
children: [
Expanded(
child: _callButton(
onPress: () {
Navigator.pop(context);
},
content: '返回',
hasLeftBorder: true,
isSelect: false)),
Expanded(
child: _callButton(
onPress: () {
List<Setmeal> selectData = [];
if (setmealData.length > 0) {
String setmealIds = "";
for (Setmeal item in setmealData) {
if (item.select) {
item.finalPrice =
item.finalPriceC.text == '' ||
item.bargaining == '0'
? item.price
: item.finalPriceC.text;
item.pnum = item.pnumC.text;
item.min = item.minC.text;
item.spare = item.spareC.text;
selectData.add(item);
setmealIds += item.setmealId + ",";
}
}
if (setmealIds.length > 0) {
setmealIds = setmealIds.substring(
0, setmealIds.length - 1);
}
Map temp = {
'object': selectData,
'setmealIds': setmealIds
};
Navigator.of(context).pop(temp);
}
},
content: '保存并返回',
hasLeftBorder: true,
isSelect: true))
],
)
],
)
],
));
);
}
}));
}
}
... ...
... ... @@ -45,14 +45,16 @@ class _FeastDishPageState extends State<FeastDishPage> {
}
///添加宴会套餐菜品分类
_setSetmealCook(String name, String per, String trim, {String cookid}) async {
_setSetmealCook(String name, String numStr, String per, String trim,
{String cookid}) async {
Map<String, String> params = {
"sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
'cname': name,
'mid': widget.setmealId,
'cid': widget.classId,
'spec': per,
'is_trim': trim
'is_trim': trim,
'num': numStr
};
if (cookid != null) {
params['id'] = cookid;
... ... @@ -101,8 +103,10 @@ class _FeastDishPageState extends State<FeastDishPage> {
String per = map['per'];
String name = map['name'];
String can = map['can'];
String numStr = map['num'];
print(can);
_setSetmealCook(name, per, can);
_setSetmealCook(name, numStr, per, can);
});
},
text: '添加一项',
... ... @@ -160,9 +164,10 @@ class _FeastDishPageState extends State<FeastDishPage> {
can: cook.isTrim == '1' ? true : false, onTap: (Map map) {
String per = map['per'];
String name = map['name'];
String numStr = map['num'];
String can = map['can'];
print(can);
_setSetmealCook(name, per, can, cookid: cook.id);
_setSetmealCook(name, numStr, per, can, cookid: cook.id);
});
},
child: Text(
... ...
... ... @@ -74,7 +74,7 @@ class _FeastSetmealManageEditPageState
}
}
/// 根据ID获取宴会套餐
/// 获取宴会套餐菜品分类列表
_getSetmealClass({bool isShowLoading = true}) async {
Map<String, String> params = {"mid": widget.setmealId};
await feastModel.getSetmealClass(context, params,
... ...
... ... @@ -50,12 +50,13 @@ class _FeastSetmealManagePageState extends State<FeastSetmealManagePage> {
super.dispose();
}
///获取宴会分类
///获取宴会套餐
Future<bool> _getSetmeal({bool isShowLoading = true}) async {
await feastModel.getSetmeal(context, isShowLoading: isShowLoading);
}
_setSetmeal(String mealName, String price, String bargaining) async {
_setSetmeal(
String mealName, String price, String bargaining) async {
Map<String, String> params = {
"sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
'meal_name': mealName,
... ... @@ -77,13 +78,14 @@ class _FeastSetmealManagePageState extends State<FeastSetmealManagePage> {
Widget buildFeastTypeHeader() {
return RoundButton(
onPressed: () async {
DialogUtil.feastDishEditDialog(context,
DialogUtil.feastSetmealEditDialog(context,
title: '新建套餐',
nametitle: '套餐名称',
pricetitle: '套餐价格',
swichtitle: '是否议价', onTap: (Map map) {
String per = map['per'];
String name = map['name'];
String can = map['can'];
print(can);
_setSetmeal(name, per, can);
... ...
... ... @@ -58,6 +58,8 @@ class FeastModel extends ChangeNotifier {
PageState pageStateFollowUp = PageState.Loading; //待跟进宴会
PageState pageStateDepositData = PageState.Loading; //定金数据
PageState pageStateMenu = PageState.Loading; //调菜
String rid; //宴会id
/***
... ... @@ -92,7 +94,7 @@ class FeastModel extends ChangeNotifier {
}
}
///设置选台信息
///设置选台信息
Future<dynamic> setBanquetInfo(
BuildContext context, Map<String, String> params,
... ... @@ -120,7 +122,6 @@ class FeastModel extends ChangeNotifier {
}
}
/***
*
* 宴会员工
... ... @@ -740,7 +741,19 @@ class FeastModel extends ChangeNotifier {
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {}
if (error is MyError) {
switch (error.type) {
case 1:
pageStateMenu = PageState.ConnectivityError;
break;
case 2:
pageStateMenu = PageState.ConnectivityTimeOut;
break;
default:
pageStateMenu = PageState.ConnectivityError;
break;
}
}
notifyListeners();
return false;
});
... ... @@ -749,11 +762,17 @@ class FeastModel extends ChangeNotifier {
SetMeaByIdModel.fromJson(baseResp.responseData);
if (setMeaByIdModel.ret == Constant.status_success) {
setmealDetail = setMeaByIdModel.data;
if (setmealDetail.classify != null && setmealDetail.classify.length > 0) {
} else {
pageStateMenu = PageState.Empty;
}
notifyListeners();
return true;
} else {
Utils.showToast(baseResp.msg ?? "");
pageStateMenu = PageState.ConnectivityError;
notifyListeners();
return false;
}
... ...
... ... @@ -27,6 +27,7 @@ import 'package:sqflite/sqlite_api.dart';
import '../app.dart';
import '../models/otherset_model.dart';
import '../models/set_xuan_tai_model.dart';
import '../models/wine_model.dart';
class NavigatorUtil {
... ... @@ -865,14 +866,25 @@ class NavigatorUtil {
}
///宴会----调菜
static Future<dynamic> goFeastMenuPage(BuildContext context,
{replace = false, bool onlyShow = false}) {
return _navigateTo(context, "${Routes.feast_menu_page}", replace: replace);
static Future<dynamic> goFeastMenuPage(
BuildContext context,
String setmealId, {
replace = false,
bool onlyShow = false,
}) {
return _navigateTo(
context, "${Routes.feast_menu_page}?setmealId=$setmealId",
replace: replace);
}
///宴会----添加套餐
static Future<dynamic> goFeastSetmealPage(BuildContext context,
{replace = false, bool onlyShow = false}) {
{replace = false, bool onlyShow = false, Map justSelData}) {
if (justSelData != null) {
return _navigateTo(context,
"${Routes.feast_setmeal_page}?object=${FluroConvertUtils.object2string(justSelData)}",
replace: replace);
}
return _navigateTo(context, "${Routes.feast_setmeal_page}",
replace: replace);
}
... ...
... ... @@ -147,6 +147,7 @@ import 'package:one_key/utils/fluro_convert_utils.dart';
import 'package:one_key/utils/utils.dart';
import 'package:provider/provider.dart';
import '../models/set_xuan_tai_model.dart';
import '../pages/feast/feast_board.dart';
import '../pages/feast/feast_create_page.dart';
import '../pages/feast/feast_deposit_data_page.dart';
... ... @@ -1380,18 +1381,28 @@ var feastMenuPageHandle = new Handler(
// String uids = params["uids"].first;
// bool onlyShow = FluroConvertUtils.string2bool(params["onlyShow"].first);
String setmealId = params["setmealId"].first;
return ChangeNotifierProvider<FeastModel>(
create: (_) => FeastModel(), child: FeastMenuPage());
create: (_) => FeastModel(), child: FeastMenuPage(setmealId: setmealId));
});
///宴会----添加套餐
var feastSetmealPageHandle = new Handler(
handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
// String uids = params["uids"].first;
List<Setmeal> justSelData = [];
if (params.keys.contains('object')) {
Map object = FluroConvertUtils.string2map(params["object"].first);
List temp = object['object'];
for (var item in temp) {
justSelData.add(Setmeal.fromJson(item));
}
}
// bool onlyShow = FluroConvertUtils.string2bool(params["onlyShow"].first);
return ChangeNotifierProvider<FeastModel>(
create: (_) => FeastModel(), child: FeastSetmealPage());
create: (_) => FeastModel(),
child: FeastSetmealPage(justSelData: justSelData));
});
///宴会----添加酒水
... ...
... ... @@ -697,6 +697,328 @@ class DialogUtil {
String swichtitle = '是否可调菜',
String content = '',
String per = '',
String numStr = '',
bool can = true,
}) async {
TextEditingController nameC = TextEditingController();
TextEditingController perC = TextEditingController();
TextEditingController numC = TextEditingController();
nameC.text = content;
perC.text = per;
numC.text = numStr;
// bool isRed = content != '' ? false : true;
final action = await showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return StatefulBuilder(builder: (context, state) {
return Scaffold(
backgroundColor: Colors.transparent,
body: Center(
child: Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(50)),
height: ScreenUtil().setWidth(421 * 2),
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(16))),
child: SingleChildScrollView(
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(ScreenUtil().setWidth(10)))), //设置圆角
child: Container(
child: Column(
children: [
VEmptyView(64),
Container(
alignment: Alignment.center,
child: Text(title,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_E5000000)),
),
VEmptyView(32),
Padding(
padding: EdgeInsets.symmetric(horizontal: w(16)),
child: Row(children: [
Text(
nametitle,
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_000000),
),
HEmptyView(24),
Expanded(
child: Container(
height: ScreenUtil().setWidth(48 * 2),
decoration: BoxDecoration(
color: MyColours.color_f3f3f3,
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(8))),
padding:
EdgeInsets.symmetric(horizontal: w(12)),
child: TextField(
controller: nameC,
maxLines: 1,
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_515151),
decoration: InputDecoration(
contentPadding: EdgeInsets.only(
bottom: ScreenUtil()
.setWidth(40)), //设置文字内容与边框距离
border: OutlineInputBorder(
borderSide: BorderSide.none),
hintText: '请输入',
hintStyle: TextStyle(
color: MyColours.color_66000000,
fontSize: ScreenUtil().setSp(32),
),
),
onChanged: (value) {},
onEditingComplete: () {
FocusScope.of(context).requestFocus(
FocusNode()); //点击空白处隐藏键盘
},
keyboardType: TextInputType.text,
),
))
])),
VEmptyView(32),
Padding(
padding: EdgeInsets.symmetric(horizontal: w(16)),
child: Row(children: [
Text(
'菜品数量',
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_000000),
),
HEmptyView(24),
Expanded(
child: Container(
height: ScreenUtil().setWidth(48 * 2),
decoration: BoxDecoration(
color: MyColours.color_f3f3f3,
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(8))),
padding:
EdgeInsets.symmetric(horizontal: w(12)),
child: TextField(
controller: numC,
maxLines: 1,
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_515151),
decoration: InputDecoration(
contentPadding: EdgeInsets.only(
bottom: ScreenUtil()
.setWidth(40)), //设置文字内容与边框距离
border: OutlineInputBorder(
borderSide: BorderSide.none),
hintText: '请输入',
hintStyle: TextStyle(
color: MyColours.color_66000000,
fontSize: ScreenUtil().setSp(32),
),
),
onChanged: (value) {},
onEditingComplete: () {
FocusScope.of(context).requestFocus(
FocusNode()); //点击空白处隐藏键盘
},
keyboardType: TextInputType.text,
),
))
])),
VEmptyView(32),
Padding(
padding: EdgeInsets.symmetric(horizontal: w(16)),
child: Row(children: [
Text(
pricetitle,
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_000000),
),
HEmptyView(24),
Expanded(
child: Container(
height: ScreenUtil().setWidth(48 * 2),
decoration: BoxDecoration(
color: MyColours.color_f3f3f3,
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(8))),
padding:
EdgeInsets.symmetric(horizontal: w(12)),
child: TextField(
controller: perC,
maxLines: 1,
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_515151),
decoration: InputDecoration(
contentPadding: EdgeInsets.only(
bottom: ScreenUtil()
.setWidth(40)), //设置文字内容与边框距离
border: OutlineInputBorder(
borderSide: BorderSide.none),
hintText: '请输入',
hintStyle: TextStyle(
color: MyColours.color_66000000,
fontSize: ScreenUtil().setSp(32),
),
),
onChanged: (value) {},
onEditingComplete: () {
FocusScope.of(context).requestFocus(
FocusNode()); //点击空白处隐藏键盘
},
keyboardType: title == '新建套餐'
? TextInputType.numberWithOptions()
: TextInputType.text,
),
)),
title == '新建套餐'
? Padding(
padding: EdgeInsets.only(left: w(12)),
child: Text('元',
style: TextStyle(
fontSize: font(16),
color: MyColours.color_000000)))
: SizedBox()
])),
VEmptyView(32),
Container(
height: w(48),
padding: EdgeInsets.only(left: w(16)),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
width: h(0.5),
color: MyColours.color_E7E7E7))),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
width: w(81),
height: w(48),
alignment: Alignment.centerLeft,
child: Text(
swichtitle,
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_E6000000),
),
),
Spacer(),
InkWell(
onTap: () {
state(() {
can = !can;
});
},
child: Container(
padding: EdgeInsets.only(
left: w(16), right: w(16)),
child: Image.asset(
Utils.getImgPath(
can ? 'swich_on' : 'swich_off'),
width: w(44),
))),
],
),
),
VEmptyView(64),
MyDivider(double.infinity, ScreenUtil().setWidth(2),
color: MyColours.color_f3f3f3),
Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
RoundButton(
text: '取消',
width: (ScreenUtil().screenWidth -
ScreenUtil().setWidth(62) * 2) /
2,
height: ScreenUtil().setWidth(112),
// radius: ScreenUtil().setWidth(10),
gradientStart: Colors.transparent,
gradientEnd: Colors.transparent,
textColor: MyColours.color_E6000000,
isBold: false,
fontSize: 32,
onPressed: () {
Navigator.pop(context);
}),
MyDivider(ScreenUtil().setWidth(2),
ScreenUtil().setWidth(112),
color: MyColours.color_f3f3f3),
RoundButton(
text: '确定',
width: (ScreenUtil().screenWidth -
ScreenUtil().setWidth(62) * 2) /
2,
height: ScreenUtil().setWidth(112),
// radius: ScreenUtil().setWidth(10),
gradientStart: Colors.transparent,
gradientEnd: Colors.transparent,
textColor: MyColours.color_438E93,
fontSize: 32,
onPressed: () {
if (nameC.text.trim() == '') {
Utils.showToast('请输入${nametitle}!');
return;
}
if (numC.text.trim() == '') {
Utils.showToast('请输入菜品数量!');
return;
}
if (perC.text.trim() == '') {
Utils.showToast('请输入${pricetitle}!');
return;
}
onTap({
'name': nameC.text,
'per': perC.text,
'num':numC.text,
'can': can ? '1' : '0'
});
Navigator.pop(context, {
'name': nameC.text,
'per': perC.text,
'can': can
});
}),
],
)
],
),
),
)),
),
));
});
},
);
}
//宴会---添加菜品
static Future feastSetmealEditDialog(
BuildContext context, {
CustomCallBackMap onTap,
String title = '菜品信息',
String nametitle = '菜品名称',
String pricetitle = '菜品规格',
String swichtitle = '是否可调菜',
String content = '',
String per = '',
bool can = true,
}) async {
TextEditingController nameC = TextEditingController();
... ...
... ... @@ -49,6 +49,11 @@ class FluroConvertUtils {
return json.decode(fluroCnParamsDecode(str));
}
/// string json 转为 map
static List<dynamic> string2list(String str) {
return json.decode(fluroCnParamsDecode(str));
}
/// string json 转为 map
static Map<String, List<TableList>> string2mapTableList(String str) {
return json.decode(fluroCnParamsDecode(str));
... ...