Commit ebbbaf677ff85f290598d8a8b4e2e9bff05292f7

Authored by wdn127929
1 parent 0e1804ed

差定金、是否可退接口

class GetSetmealClassByIdModel {
int ret;
GetSetmealClassByIdSunModel data;
String msg;
GetSetmealClassByIdModel({this.ret, this.data, this.msg});
GetSetmealClassByIdModel.fromJson(Map<String, dynamic> json) {
ret = json['ret'];
data = json['data'] != null
? new GetSetmealClassByIdSunModel.fromJson(json['data'])
: null;
msg = json['msg'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['ret'] = this.ret;
if (this.data != null) {
data['data'] = this.data.toJson();
}
data['msg'] = this.msg;
return data;
}
}
class GetSetmealClassByIdSunModel {
String id;
String sid;
String mid;
String className;
String status;
Null cdate;
List<CookById> cook;
GetSetmealClassByIdSunModel(
{this.id,
this.sid,
this.mid,
this.className,
this.status,
this.cdate,
this.cook});
GetSetmealClassByIdSunModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
sid = json['sid'];
mid = json['mid'];
className = json['class_name'];
status = json['status'];
cdate = json['cdate'];
if (json['cook'] != null) {
cook = <CookById>[];
json['cook'].forEach((v) {
cook.add(new CookById.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['sid'] = this.sid;
data['mid'] = this.mid;
data['class_name'] = this.className;
data['status'] = this.status;
data['cdate'] = this.cdate;
if (this.cook != null) {
data['cook'] = this.cook.map((v) => v.toJson()).toList();
}
return data;
}
}
class CookById {
String id;
String sid;
String cid;
String mid;
String cname;
String spec;
String isTrim;
String status;
CookById(
{this.id,
this.sid,
this.cid,
this.mid,
this.cname,
this.spec,
this.isTrim,
this.status});
CookById.fromJson(Map<String, dynamic> json) {
id = json['id'];
sid = json['sid'];
cid = json['cid'];
mid = json['mid'];
cname = json['cname'];
spec = json['spec'];
isTrim = json['is_trim'];
status = json['status'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['sid'] = this.sid;
data['cid'] = this.cid;
data['mid'] = this.mid;
data['cname'] = this.cname;
data['spec'] = this.spec;
data['is_trim'] = this.isTrim;
data['status'] = this.status;
return data;
}
}
... ...
class GetSetmealClassModel {
int ret;
List<GetSetmealClassSunModel> data;
String msg;
GetSetmealClassModel({this.ret, this.data, this.msg});
GetSetmealClassModel.fromJson(Map<String, dynamic> json) {
ret = json['ret'];
if (json['data'] != null) {
data = <GetSetmealClassSunModel>[];
json['data'].forEach((v) {
data.add(new GetSetmealClassSunModel.fromJson(v));
});
}
msg = json['msg'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['ret'] = this.ret;
if (this.data != null) {
data['data'] = this.data.map((v) => v.toJson()).toList();
}
data['msg'] = this.msg;
return data;
}
}
class GetSetmealClassSunModel {
String id;
String sid;
String mid;
String className;
String status;
Null cdate;
List<Cook> cook;
GetSetmealClassSunModel(
{this.id,
this.sid,
this.mid,
this.className,
this.status,
this.cdate,
this.cook});
GetSetmealClassSunModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
sid = json['sid'];
mid = json['mid'];
className = json['class_name'];
status = json['status'];
cdate = json['cdate'];
if (json['cook'] != null) {
cook = <Cook>[];
json['cook'].forEach((v) {
cook.add(new Cook.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['sid'] = this.sid;
data['mid'] = this.mid;
data['class_name'] = this.className;
data['status'] = this.status;
data['cdate'] = this.cdate;
if (this.cook != null) {
data['cook'] = this.cook.map((v) => v.toJson()).toList();
}
return data;
}
}
class Cook {
String id;
String sid;
String cid;
String mid;
String cname;
String spec;
String isTrim;
String status;
Cook(
{this.id,
this.sid,
this.cid,
this.mid,
this.cname,
this.spec,
this.isTrim,
this.status});
Cook.fromJson(Map<String, dynamic> json) {
id = json['id'];
sid = json['sid'];
cid = json['cid'];
mid = json['mid'];
cname = json['cname'];
spec = json['spec'];
isTrim = json['is_trim'];
status = json['status'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['sid'] = this.sid;
data['cid'] = this.cid;
data['mid'] = this.mid;
data['cname'] = this.cname;
data['spec'] = this.spec;
data['is_trim'] = this.isTrim;
data['status'] = this.status;
return data;
}
}
... ...
class OthersetModel {
int ret;
List<OthersetSunModel> data;
String msg;
OthersetModel({this.ret, this.data, this.msg});
OthersetModel.fromJson(Map<String, dynamic> json) {
ret = json['ret'];
if (json['data'] != null) {
data = <OthersetSunModel>[];
json['data'].forEach((v) {
data.add(new OthersetSunModel.fromJson(v));
});
}
msg = json['msg'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['ret'] = this.ret;
if (this.data != null) {
data['data'] = this.data.map((v) => v.toJson()).toList();
}
data['msg'] = this.msg;
return data;
}
}
class OthersetSunModel {
String id;
String sid;
String otherName;
String price;
String spec;
String bargaining;
OthersetSunModel(
{this.id,
this.sid,
this.otherName,
this.price,
this.spec,
this.bargaining});
OthersetSunModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
sid = json['sid'];
otherName = json['other_name'];
price = json['price'];
spec = json['spec'];
bargaining = json['bargaining'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['sid'] = this.sid;
data['other_name'] = this.otherName;
data['price'] = this.price;
data['spec'] = this.spec;
data['bargaining'] = this.bargaining;
return data;
}
}
... ...
class SetMeaByIdModel {
int ret;
SetMeaByIdSunModel data;
String msg;
SetMeaByIdModel({this.ret, this.data, this.msg});
SetMeaByIdModel.fromJson(Map<String, dynamic> json) {
ret = json['ret'];
data = json['data'] != null
? new SetMeaByIdSunModel.fromJson(json['data'])
: null;
msg = json['msg'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['ret'] = this.ret;
if (this.data != null) {
data['data'] = this.data.toJson();
}
data['msg'] = this.msg;
return data;
}
}
class SetMeaByIdSunModel {
String id;
String sid;
String mealName;
String price;
String bargaining;
String status;
Null cdate;
List<Classify> classify;
List<Cook> cook;
SetMeaByIdSunModel(
{this.id,
this.sid,
this.mealName,
this.price,
this.bargaining,
this.status,
this.cdate,
this.classify,
this.cook});
SetMeaByIdSunModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
sid = json['sid'];
mealName = json['meal_name'];
price = json['price'];
bargaining = json['bargaining'];
status = json['status'];
cdate = json['cdate'];
if (json['class'] != null) {
classify = <Classify>[];
json['class'].forEach((v) {
classify.add(new Classify.fromJson(v));
});
}
if (json['cook'] != null) {
cook = <Cook>[];
json['cook'].forEach((v) {
cook.add(new Cook.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['sid'] = this.sid;
data['meal_name'] = this.mealName;
data['price'] = this.price;
data['bargaining'] = this.bargaining;
data['status'] = this.status;
data['cdate'] = this.cdate;
if (this.classify != null) {
data['class'] = this.classify.map((v) => v.toJson()).toList();
}
if (this.cook != null) {
data['cook'] = this.classify.map((v) => v.toJson()).toList();
}
return data;
}
}
class Classify {
String id;
String sid;
String mid;
String className;
String status;
dynamic cdate;
Classify(
{this.id, this.sid, this.mid, this.className, this.status, this.cdate});
Classify.fromJson(Map<String, dynamic> json) {
id = json['id'];
sid = json['sid'];
mid = json['mid'];
className = json['class_name'];
status = json['status'];
cdate = json['cdate'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['sid'] = this.sid;
data['mid'] = this.mid;
data['class_name'] = this.className;
data['status'] = this.status;
data['cdate'] = this.cdate;
return data;
}
}
class Cook {
String id;
String sid;
String cid;
String mid;
String cname;
String spec;
String isTrim;
String status;
Cook(
{this.id,
this.sid,
this.cid,
this.mid,
this.cname,
this.spec,
this.isTrim,
this.status});
Cook.fromJson(Map<String, dynamic> json) {
id = json['id'];
sid = json['sid'];
cid = json['cid'];
mid = json['mid'];
cname = json['cname'];
spec = json['spec'];
isTrim = json['is_trim'];
status = json['status'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['sid'] = this.sid;
data['cid'] = this.cid;
data['mid'] = this.mid;
data['cname'] = this.cname;
data['spec'] = this.spec;
data['is_trim'] = this.isTrim;
data['status'] = this.status;
return data;
}
}
... ...
class SetMealModel {
int ret;
List<SetMealSunModel> data;
String msg;
SetMealModel({this.ret, this.data, this.msg});
SetMealModel.fromJson(Map<String, dynamic> json) {
ret = json['ret'];
if (json['data'] != null) {
data = <SetMealSunModel>[];
json['data'].forEach((v) {
data.add(new SetMealSunModel.fromJson(v));
});
}
msg = json['msg'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['ret'] = this.ret;
if (this.data != null) {
data['data'] = this.data.map((v) => v.toJson()).toList();
}
data['msg'] = this.msg;
return data;
}
}
class SetMealSunModel {
String id;
String sid;
String mealName;
String price;
String bargaining;
String status;
Null cdate;
List<Classify> classify;
List<Cook> cook;
SetMealSunModel(
{this.id,
this.sid,
this.mealName,
this.price,
this.bargaining,
this.status,
this.cdate,
this.classify,
this.cook});
SetMealSunModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
sid = json['sid'];
mealName = json['meal_name'];
price = json['price'];
bargaining = json['bargaining'];
status = json['status'];
cdate = json['cdate'];
if (json['class'] != null) {
classify = <Classify>[];
json['class'].forEach((v) {
classify.add(new Classify.fromJson(v));
});
}
if (json['cook'] != null) {
cook = <Cook>[];
json['cook'].forEach((v) {
cook.add(new Cook.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['sid'] = this.sid;
data['meal_name'] = this.mealName;
data['price'] = this.price;
data['bargaining'] = this.bargaining;
data['status'] = this.status;
data['cdate'] = this.cdate;
if (this.classify = null) {
data['class'] = this.classify.map((v) => v.toJson()).toList();
}
if (this.cook != null) {
data['cook'] = this.cook.map((v) => v.toJson()).toList();
}
return data;
}
}
class Classify {
String id;
String sid;
String mid;
String className;
String status;
Null cdate;
Classify(
{this.id, this.sid, this.mid, this.className, this.status, this.cdate});
Classify.fromJson(Map<String, dynamic> json) {
id = json['id'];
sid = json['sid'];
mid = json['mid'];
className = json['class_name'];
status = json['status'];
cdate = json['cdate'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['sid'] = this.sid;
data['mid'] = this.mid;
data['class_name'] = this.className;
data['status'] = this.status;
data['cdate'] = this.cdate;
return data;
}
}
class Cook {
String id;
String sid;
String cid;
String mid;
String cname;
String spec;
String isTrim;
String status;
Cook(
{this.id,
this.sid,
this.cid,
this.mid,
this.cname,
this.spec,
this.isTrim,
this.status});
Cook.fromJson(Map<String, dynamic> json) {
id = json['id'];
sid = json['sid'];
cid = json['cid'];
mid = json['mid'];
cname = json['cname'];
spec = json['spec'];
isTrim = json['is_trim'];
status = json['status'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['sid'] = this.sid;
data['cid'] = this.cid;
data['mid'] = this.mid;
data['cname'] = this.cname;
data['spec'] = this.spec;
data['is_trim'] = this.isTrim;
data['status'] = this.status;
return data;
}
}
... ...
... ... @@ -255,4 +255,31 @@ class HttpUrl {
static const String set_wine = "?service=App.Banquet.SetWine"; // 添加酒水
static const String del_wine = "?service=App.Banquet.DelWine"; // 删除酒水
static const String get_other = "?service=App.Banquet.GetOther"; // 获取其他配置
static const String set_other = "?service=App.Banquet.SetOther"; // 添加其他配置
static const String del_other = "?service=App.Banquet.DelOther"; // 删除其他配置
static const String get_setmeal =
"?service=App.Banquet.GetSetmeal"; // 获取宴会套餐
static const String set_setmeal = "?service=App.Banquet.SetSetmeal"; // 添加宴会套餐
static const String del_setmeal = "?service=App.Banquet.DelSetmeal"; // 删除宴会套餐
static const String get_setmeal_by_id =
"?service=App.Banquet.GetSetmealById"; // 根据ID获取宴会套餐
static const String get_setmeal_class =
"?service=App.Banquet.GetSetmealClass"; // 获取宴会套餐菜品分类
static const String set_setmeal_class =
"?service=App.Banquet.SetSetmealClass"; // 添加宴会套餐菜品分类
static const String del_setmeal_class =
"?service=App.Banquet.DelSetmealClass"; // 删除宴会套餐菜品分类
static const String get_setmeal_class_by_id =
"?service=App.Banquet.GetSetmealClassById"; // 根据ID获取宴会套餐菜品分类
static const String set_setmeal_cook =
"?service=App.Banquet.SetSetmealCook"; // 添加/修改宴会套餐菜品
static const String del_setmeal_cook =
"?service=App.Banquet.DelSetmealCook"; // 删除宴会套餐菜品
static const String set_banquet_conf =
"?service=App.Banquet.SetBanquetConf"; // 商家宴会配置
}
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:provider/provider.dart';
import '../../../provider/feast_model.dart';
import '../../../provider/user_model.dart';
import '../../../res/colors.dart';
import '../../../route/navigator_util.dart';
import '../../../utils/screen_util.dart';
... ... @@ -22,6 +25,8 @@ class FeastDepositManagePage extends StatefulWidget {
class _FeastDepositManagePageState extends State<FeastDepositManagePage> {
bool canrReturn = true; //是否可退
FeastModel feastModel;
@override
void initState() {
super.initState();
... ... @@ -65,6 +70,7 @@ class _FeastDepositManagePageState extends State<FeastDepositManagePage> {
@override
Widget build(BuildContext context) {
feastModel = Provider.of<FeastModel>(context);
return Scaffold(
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar(
... ... @@ -98,7 +104,7 @@ class _FeastDepositManagePageState extends State<FeastDepositManagePage> {
height: w(48),
alignment: Alignment.centerLeft,
child: Text(
'是否议价',
'是否可退',
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_E5000000),
... ... @@ -106,10 +112,19 @@ class _FeastDepositManagePageState extends State<FeastDepositManagePage> {
),
Spacer(),
InkWell(
onTap: () {
onTap: () async {
setState(() {
canrReturn = !canrReturn;
});
Map<String, String> pramas = {
'sid':
Provider.of<UserModel>(context, listen: false)
.user
.sellerid,
'is_deposit_back': canrReturn ? '1' : '0'
};
await feastModel.setBanquetConf(context, pramas);
},
child: Container(
padding:
... ...
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_model.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
import '../../../provider/feast_model.dart';
import '../../../provider/user_model.dart';
import '../../../res/colors.dart';
import '../../../utils/dialog_util.dart';
import '../../../utils/event_bus.dart';
import '../../../utils/screen_util.dart';
import '../../../utils/utils.dart';
import '../../../widgets/h_empty_view.dart';
... ... @@ -16,7 +22,9 @@ import '../../../widgets/system_app_bar.dart';
*/
class FeastDishPage extends StatefulWidget {
FeastDishPage({Key key}) : super(key: key);
final String setmealId;
final String classId;
FeastDishPage({Key key, this.setmealId, this.classId}) : super(key: key);
@override
_FeastDishPageState createState() => _FeastDishPageState();
... ... @@ -26,16 +34,76 @@ class _FeastDishPageState extends State<FeastDishPage> {
ScrollController controller = ScrollController();
TextEditingController typeNameC = TextEditingController(); //分类名称
FocusNode typeF = FocusNode();
FeastModel feastModel;
@override
void initState() {
super.initState();
Utils.changeStatusColor(color: MyColours.color_438E93);
WidgetsBinding.instance.addPostFrameCallback((_) {
_getSetmealClassById();
});
}
///添加宴会套餐菜品分类
_setSetmealCook(String name, 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
};
if (cookid != null) {
params['id'] = cookid;
}
bool success = await feastModel.setSetmealCook(context, params);
if (success) {
Utils.showToast(cookid == null ? '添加成功' : '修改成功');
_getSetmealClassById();
}
}
///添加宴会套餐菜品分类
_setSetmealClass() async {
Map<String, String> params = {
"sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
'meal_name': typeNameC.text,
'mid': widget.setmealId
};
params['id'] = widget.classId;
bool success = await feastModel.setSetmealClass(context, params);
if (success) {
Utils.showToast('修改成功');
bus.emit('feast_setmeal_class_list');
}
}
/// 根据ID获取宴会套餐菜品分类
Future<bool> _getSetmealClassById({bool isShowLoading = true}) async {
Map<String, String> params = {"id": widget.classId};
bool success = await feastModel.getSetmealClassById(context, params,
isShowLoading: isShowLoading);
if (success) {
typeNameC.text = feastModel.setmealClassDetail.className;
setState(() {});
}
}
Widget buildFeastTypeHeader() {
return RoundButton(
onPressed: () async {
NavigatorUtil.goFeastSetmealManageEditPage(context);
FocusScope.of(context).requestFocus(FocusNode());
DialogUtil.feastDishEditDialog(context, onTap: (Map map) {
String per = map['per'];
String name = map['name'];
String can = map['can'];
print(can);
_setSetmealCook(name, per, can);
});
},
text: '添加一项',
fontSize: 32,
... ... @@ -51,7 +119,7 @@ class _FeastDishPageState extends State<FeastDishPage> {
);
}
Widget buildFeastTypeItem() {
Widget buildFeastTypeItem(CookById cook, int index) {
return Container(
margin: EdgeInsets.only(bottom: w(12)),
child: Row(
... ... @@ -59,7 +127,7 @@ class _FeastDishPageState extends State<FeastDishPage> {
Container(
width: w(120),
child: Text(
'鱼香肉丝',
cook.cname,
style: TextStyle(
fontSize: font(16), color: MyColours.color_E6000000),
)),
... ... @@ -67,7 +135,7 @@ class _FeastDishPageState extends State<FeastDishPage> {
Container(
width: w(36),
child: Text(
'份',
cook.spec,
style: TextStyle(
fontSize: font(16), color: MyColours.color_515151),
)),
... ... @@ -75,21 +143,26 @@ class _FeastDishPageState extends State<FeastDishPage> {
Container(
width: w(80),
child: Text(
'可调菜/不可调菜',
cook.isTrim == '1' ? '可调菜' : '不可调菜',
style: TextStyle(
fontSize: font(16),
color:
true ? MyColours.color_00A870 : MyColours.color_E34D59),
color: cook.isTrim == '1'
? MyColours.color_00A870
: MyColours.color_E34D59),
)),
Spacer(),
InkWell(
onTap: () {
FocusScope.of(context).requestFocus(FocusNode());
DialogUtil.feastDishEditDialog(context, onTap: (Map map) {
DialogUtil.feastDishEditDialog(context,
content: cook.cname,
per: cook.spec,
can: cook.isTrim == '1' ? true : false, onTap: (Map map) {
String per = map['per'];
String name = map['name'];
String can = map['can'];
print(can);
_setSetmealCook(name, per, can, cookid: cook.id);
});
},
child: Text(
... ... @@ -107,15 +180,21 @@ class _FeastDishPageState extends State<FeastDishPage> {
DialogUtil.cupertinoAlertDialogFeast(context,
rTitle: '删除',
title: "是否确认删除",
content: "鱼香肉丝", lCallback: () {
content: cook.cname, lCallback: () {
print("取消");
}, rCallback: () {
}, rCallback: () async {
print("确定");
// widget.deleteCallback(index);
Map<String, String> pramas = {'id': cook.id};
bool success =
await feastModel.delSetmealCook(context, pramas);
if (success) {
Utils.showToast('删除成功');
_getSetmealClassById(isShowLoading: true);
}
});
},
child: Image.asset(
Utils.getImgPath(true ? 'f_delete_red_un' : 'f_delete_red'),
Utils.getImgPath('f_delete_red'),
width: w(24),
height: w(24),
)),
... ... @@ -187,6 +266,12 @@ class _FeastDishPageState extends State<FeastDishPage> {
),
onChanged: (value) {
typeNameC.text = value;
typeNameC.value = TextEditingValue(
text: typeNameC.text,
selection: TextSelection.fromPosition(TextPosition(
affinity: TextAffinity.downstream,
offset: typeNameC.text.length,
)));
setState(() {});
},
onEditingComplete: () {
... ... @@ -254,6 +339,7 @@ class _FeastDishPageState extends State<FeastDishPage> {
@override
Widget build(BuildContext context) {
feastModel = Provider.of<FeastModel>(context, listen: true);
return Scaffold(
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar(
... ... @@ -275,16 +361,21 @@ class _FeastDishPageState extends State<FeastDishPage> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_textfield('分类名称', '热菜', typeNameC, typeF, ''),
_textfield('分类名称', '请输入', typeNameC, typeF, ''),
buildFeastTypeHeader(),
VEmptyView(54),
ListView.builder(
itemCount: 100,
shrinkWrap: true,
controller: controller,
itemBuilder: (BuildContext context, int index) {
return buildFeastTypeItem();
}),
feastModel.setmealClassDetail != null
? ListView.builder(
itemCount:
feastModel.setmealClassDetail.cook.length,
shrinkWrap: true,
controller: controller,
itemBuilder: (BuildContext context, int index) {
CookById cook =
feastModel.setmealClassDetail.cook[index];
return buildFeastTypeItem(cook, index);
})
: SizedBox(),
],
)),
)),
... ... @@ -300,7 +391,16 @@ class _FeastDishPageState extends State<FeastDishPage> {
isSelect: false)),
Expanded(
child: _callButton(
onPress: () {},
onPress: () {
if (typeNameC.text.trim().length == 0) {
Utils.showToast('请输入分类名称');
return;
}
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
_setSetmealClass();
},
content: '保存',
hasLeftBorder: true,
isSelect: true))
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
import '../../../models/otherset_model.dart';
import '../../../provider/feast_model.dart';
import '../../../provider/user_model.dart';
import '../../../res/colors.dart';
import '../../../route/navigator_util.dart';
import '../../../utils/dialog_util.dart';
import '../../../utils/event_bus.dart';
import '../../../utils/screen_util.dart';
import '../../../utils/utils.dart';
import '../../../widgets/h_empty_view.dart';
... ... @@ -15,10 +20,10 @@ import '../../../widgets/system_app_bar.dart';
* 其他配置添加
*/
class FeastOthersetManageEditPage extends StatefulWidget {
final isCreate;
final OthersetSunModel othersetSunModel;
FeastOthersetManageEditPage({
Key key,
this.isCreate = true,
this.othersetSunModel,
}) : super(key: key);
@override
... ... @@ -26,7 +31,8 @@ class FeastOthersetManageEditPage extends StatefulWidget {
_FeastOthersetManageEditPageState();
}
class _FeastOthersetManageEditPageState extends State<FeastOthersetManageEditPage> {
class _FeastOthersetManageEditPageState
extends State<FeastOthersetManageEditPage> {
TextEditingController othersetNameC = TextEditingController(); //其他配置名称
FocusNode othersetF = FocusNode();
TextEditingController othersetPriceC = TextEditingController(); //其他配置价格
... ... @@ -36,10 +42,38 @@ class _FeastOthersetManageEditPageState extends State<FeastOthersetManageEditPag
bool canBargaining = true; //是否议价
ScrollController controller = ScrollController();
FeastModel feastModel;
@override
void initState() {
super.initState();
Utils.changeStatusColor(color: MyColours.color_438E93);
if (widget.othersetSunModel != null) {
othersetNameC.text = widget.othersetSunModel.otherName;
othersetPriceC.text = widget.othersetSunModel.price;
othersetPerC.text = widget.othersetSunModel.spec;
canBargaining = widget.othersetSunModel.bargaining == '1' ? true : false;
}
}
_setOthersetList() async {
Map<String, String> params = {
"sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
'class_name': othersetNameC.text,
'price': othersetPriceC.text,
'spec': othersetPerC.text,
'bargaining': canBargaining ? '1' : '0'
};
if (widget.othersetSunModel != null) {
params['id'] = widget.othersetSunModel.id;
}
bool success = await feastModel.setOthersetList(context, params);
if (success) {
Utils.showToast('添加成功');
bus.emit('feast_otherset_list');
Navigator.pop(context);
// _getWine(isShowLoading: true);
}
}
///请输入
... ... @@ -104,7 +138,18 @@ class _FeastOthersetManageEditPageState extends State<FeastOthersetManageEditPag
),
contentPadding: EdgeInsets.zero,
),
onChanged: (value) {},
onChanged: (value) {
if (widget.othersetSunModel != null && title == '配置名称') {
othersetNameC.text = value;
othersetNameC.value = TextEditingValue(
text: othersetNameC.text,
selection: TextSelection.fromPosition(TextPosition(
affinity: TextAffinity.downstream,
offset: othersetNameC.text.length,
)));
setState(() {});
}
},
onEditingComplete: () {
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
... ... @@ -168,10 +213,11 @@ class _FeastOthersetManageEditPageState extends State<FeastOthersetManageEditPag
@override
Widget build(BuildContext context) {
feastModel = Provider.of<FeastModel>(context, listen: true);
return Scaffold(
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar(
widget.isCreate ? '添加其他配置' : othersetNameC.text,
widget.othersetSunModel == null ? '添加配置' : othersetNameC.text,
needWhite: true,
bgColor: MyColours.color_438E93,
titleColor: MyColours.color_F6F6F6,
... ... @@ -192,10 +238,11 @@ class _FeastOthersetManageEditPageState extends State<FeastOthersetManageEditPag
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_textfield(
'配置名称', '剑南春52度500ml', othersetNameC, othersetF, ''),
'配置名称', '请输入', othersetNameC, othersetF, ''),
_textfield('配置单价', '请输入', othersetPriceC,
othersetPriceF, '元'),
_textfield(
'配置单价', '1299', othersetPriceC, othersetPriceF, '元'),
_textfield('配置规格', '份', othersetPerC, othersetPerF, ''),
'配置规格', '请输入', othersetPerC, othersetPerF, ''),
Container(
height: w(48),
margin: EdgeInsets.only(top: w(12)),
... ... @@ -252,7 +299,21 @@ class _FeastOthersetManageEditPageState extends State<FeastOthersetManageEditPag
isSelect: false)),
Expanded(
child: _callButton(
onPress: () {},
onPress: () {
if (othersetNameC.text.trim().length == 0) {
Utils.showToast('请输入配置名称');
return;
}
if (othersetPriceC.text.trim().length == 0) {
Utils.showToast('请输入配置单价');
return;
}
if (othersetPerC.text.trim().length == 0) {
Utils.showToast('请输入配置规格');
return;
}
_setOthersetList();
},
content: '保存',
hasLeftBorder: true,
isSelect: true))
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/otherset_model.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
import '../../../constant/state.dart';
import '../../../provider/feast_model.dart';
import '../../../res/colors.dart';
import '../../../utils/dialog_util.dart';
import '../../../utils/event_bus.dart';
import '../../../utils/screen_util.dart';
import '../../../utils/utils.dart';
import '../../../widgets/h_empty_view.dart';
import '../../../widgets/page_exception.dart';
import '../../../widgets/round_button.dart';
import '../../../widgets/system_app_bar.dart';
... ... @@ -24,10 +30,29 @@ class FeastOthersetManagePage extends StatefulWidget {
}
class _FeastOthersetManagePageState extends State<FeastOthersetManagePage> {
FeastModel feastModel;
@override
void initState() {
super.initState();
Utils.changeStatusColor(color: MyColours.color_438E93);
WidgetsBinding.instance.addPostFrameCallback((_) {
_getOthersetList();
// scrollController.jumpTo(scrollController.position.minScrollExtent);
});
bus.on("feast_otherset_list", (arg) {
_getOthersetList();
});
}
@override
void dispose() {
bus.off('feast_otherset_list');
super.dispose();
}
///获取宴会分类
Future<bool> _getOthersetList({bool isShowLoading = true}) async {
await feastModel.getOthersetList(context, isShowLoading: isShowLoading);
}
Widget buildFeastTypeHeader() {
... ... @@ -49,26 +74,27 @@ class _FeastOthersetManagePageState extends State<FeastOthersetManagePage> {
);
}
Widget buildFeastTypeItem(String title, String subTitle) {
Widget buildFeastTypeItem(OthersetSunModel model, int index) {
return Container(
height: h(48),
margin: EdgeInsets.only(top: w(12)),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(width: w(0.5), color: MyColours.color_E7E7E7))),
bottom:
BorderSide(width: w(0.5), color: MyColours.color_E7E7E7))),
child: Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
model.otherName,
style: TextStyle(
fontSize: font(16), color: MyColours.color_E6000000),
),
VEmptyView(12),
Text(
subTitle,
'${model.price}元/${model.spec} ${model.bargaining == '1' ? '可议价' : '不可议价'}',
style: TextStyle(
fontSize: font(12), color: MyColours.color_999999),
)
... ... @@ -77,7 +103,8 @@ class _FeastOthersetManagePageState extends State<FeastOthersetManagePage> {
Spacer(),
InkWell(
onTap: () {
NavigatorUtil.goFeastOthersetManageEditPage(context);
NavigatorUtil.goFeastOthersetManageEditPage(context,
isNew: false, othersetSunModel: model);
},
child: Text(
'修改',
... ... @@ -94,15 +121,21 @@ class _FeastOthersetManagePageState extends State<FeastOthersetManagePage> {
DialogUtil.cupertinoAlertDialogFeast(context,
rTitle: '删除',
title: "是否确认删除",
content: "LED大屏", lCallback: () {
content: model.otherName, lCallback: () {
print("取消");
}, rCallback: () {
}, rCallback: () async {
print("确定");
// widget.deleteCallback(index);
Map<String, String> pramas = {'id': model.id};
bool success =
await feastModel.delOthersetList(context, pramas);
if (success) {
Utils.showToast('删除成功');
_getOthersetList(isShowLoading: true);
}
});
},
child: Image.asset(
Utils.getImgPath(true ? 'f_delete_red_un' : 'f_delete_red'),
Utils.getImgPath('f_delete_red'),
width: w(32),
height: w(32),
)),
... ... @@ -154,6 +187,7 @@ class _FeastOthersetManagePageState extends State<FeastOthersetManagePage> {
@override
Widget build(BuildContext context) {
feastModel = Provider.of<FeastModel>(context, listen: true);
return Scaffold(
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar(
... ... @@ -165,55 +199,45 @@ class _FeastOthersetManagePageState extends State<FeastOthersetManagePage> {
Navigator.pop(context);
},
),
body: Column(
children: [
Expanded(
child: NestedScrollView(
// controller: _scrollViewController,
headerSliverBuilder:
(BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverAppBar(
pinned: true,
floating: false,
leading: null,
backgroundColor: MyColours.color_ffffff,
expandedHeight: ScreenUtil().setWidth(56 * 2),
automaticallyImplyLeading: false,
title: buildFeastTypeHeader(),
// flexibleSpace: FlexibleSpaceBar(
// collapseMode: CollapseMode.pin,
// title: buildFeastTypeHeader())
)
];
},
body: ListView.builder(
itemCount: 100,
padding: EdgeInsets.only(left: w(16)),
itemBuilder: (BuildContext context, int index) {
return buildFeastTypeItem('LED大屏', '1100元/次 不可议价');
}),
)),
Row(
children: [
Expanded(
child: _callButton(
onPress: () {
Navigator.pop(context);
},
content: '返回',
hasLeftBorder: true,
isSelect: false)),
Expanded(
child: _callButton(
onPress: () {},
content: '保存',
hasLeftBorder: true,
isSelect: true))
],
body: NestedScrollView(
// controller: _scrollViewController,
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverAppBar(
pinned: true,
floating: false,
leading: null,
backgroundColor: MyColours.color_ffffff,
expandedHeight: ScreenUtil().setWidth(56 * 2),
automaticallyImplyLeading: false,
title: buildFeastTypeHeader(),
// flexibleSpace: FlexibleSpaceBar(
// collapseMode: CollapseMode.pin,
// title: buildFeastTypeHeader())
)
],
),
];
}, body: Consumer<FeastModel>(builder: (context, model, _) {
if (model.pageStateOther != PageState.Success) {
return ExceptionPage(
pageState: model.pageStateOther,
callback: () {
_getOthersetList();
},
emptyMsg: "暂时没有配置哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return ListView.builder(
itemCount: feastModel.otherData.length,
padding: EdgeInsets.only(left: w(16)),
itemBuilder: (BuildContext context, int index) {
OthersetSunModel sunModel = feastModel.otherData[index];
return buildFeastTypeItem(sunModel, index);
// 'LED大屏', '1100元/次 不可议价'
});
}
})),
);
}
}
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/get_setmeal_class_model.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
import '../../../provider/feast_model.dart';
import '../../../provider/user_model.dart';
import '../../../res/colors.dart';
import '../../../route/navigator_util.dart';
import '../../../utils/dialog_util.dart';
import '../../../utils/event_bus.dart';
import '../../../utils/screen_util.dart';
import '../../../utils/utils.dart';
import '../../../widgets/h_empty_view.dart';
... ... @@ -15,10 +20,10 @@ import '../../../widgets/system_app_bar.dart';
* 套餐添加
*/
class FeastSetmealManageEditPage extends StatefulWidget {
final isCreate;
final String setmealId;
FeastSetmealManageEditPage({
Key key,
this.isCreate = true,
this.setmealId,
}) : super(key: key);
@override
... ... @@ -35,10 +40,82 @@ class _FeastSetmealManageEditPageState
bool canBargaining = true; //是否议价
ScrollController controller = ScrollController();
FeastModel feastModel;
@override
void initState() {
super.initState();
Utils.changeStatusColor(color: MyColours.color_438E93);
WidgetsBinding.instance.addPostFrameCallback((_) {
_getSetmealById();
_getSetmealClass();
});
bus.on("feast_setmeal_class_list", (arg) {
_getSetmealClass();
});
}
@override
void dispose() {
bus.off('feast_setmeal_class_list');
super.dispose();
}
/// 根据ID获取宴会套餐
_getSetmealById({bool isShowLoading = true}) async {
Map<String, String> params = {"id": widget.setmealId};
bool success = await feastModel.getSetmealById(context, params,
isShowLoading: isShowLoading);
if (success) {
mealNameC.text = feastModel.setmealDetail.mealName;
mealPriceC.text = feastModel.setmealDetail.price;
canBargaining = feastModel.setmealDetail.bargaining == '1' ? true : false;
setState(() {});
}
}
/// 根据ID获取宴会套餐
_getSetmealClass({bool isShowLoading = true}) async {
Map<String, String> params = {"mid": widget.setmealId};
await feastModel.getSetmealClass(context, params,
isShowLoading: isShowLoading);
}
///修改套餐基本信息
_setSetmeal() async {
Map<String, String> params = {
"sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
'meal_name': mealNameC.text,
'price': mealPriceC.text,
'bargaining': canBargaining ? '1' : '0'
};
params['id'] = widget.setmealId;
bool success = await feastModel.setSetmeal(context, params);
if (success) {
Utils.showToast('保存成功');
bus.emit('feast_setmeal_list');
// _getWine(isShowLoading: true);
}
}
///添加宴会套餐菜品分类
_setSetmealClass(String name) async {
Map<String, String> params = {
"sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
'meal_name': name,
'mid': widget.setmealId
};
// params['id'] = widget.setmealId;
bool success = await feastModel.setSetmealClass(context, params);
if (success) {
Utils.showToast('添加成功');
bus.emit('feast_setmeal_class_list');
}
}
///请输入
... ... @@ -103,7 +180,18 @@ class _FeastSetmealManageEditPageState
),
contentPadding: EdgeInsets.zero,
),
onChanged: (value) {},
onChanged: (value) {
if (title == '套餐名称') {
mealNameC.text = value;
mealNameC.value = TextEditingValue(
text: mealNameC.text,
selection: TextSelection.fromPosition(TextPosition(
affinity: TextAffinity.downstream,
offset: mealNameC.text.length,
)));
setState(() {});
}
},
onEditingComplete: () {
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
... ... @@ -126,24 +214,26 @@ class _FeastSetmealManageEditPageState
);
}
Widget buildFeastTypeItem(String title) {
Widget buildFeastTypeItem(GetSetmealClassSunModel data, int index) {
return Container(
height: h(48),
margin: EdgeInsets.only(bottom: w(12)),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(width: w(0.5), color: MyColours.color_E7E7E7))),
bottom:
BorderSide(width: w(0.5), color: MyColours.color_E7E7E7))),
child: Row(
children: [
Text(
title,
data.className,
style:
TextStyle(fontSize: font(16), color: MyColours.color_E5000000),
),
Spacer(),
InkWell(
onTap: () {
NavigatorUtil.goFeastDishPage(context);
NavigatorUtil.goFeastDishPage(
context, widget.setmealId, data.id);
},
child: Text(
'修改',
... ... @@ -160,15 +250,21 @@ class _FeastSetmealManageEditPageState
DialogUtil.cupertinoAlertDialogFeast(context,
rTitle: '删除',
title: "是否确认删除",
content: "热菜(18道)", lCallback: () {
content: data.className, lCallback: () {
print("取消");
}, rCallback: () {
}, rCallback: () async {
print("确定");
// widget.deleteCallback(index);
Map<String, String> pramas = {'id': data.id};
bool success =
await feastModel.delSetmealClass(context, pramas);
if (success) {
Utils.showToast('删除成功');
_getSetmealClass(isShowLoading: true);
}
});
},
child: Image.asset(
Utils.getImgPath(true ? 'f_delete_red_un' : 'f_delete_red'),
Utils.getImgPath('f_delete_red'),
width: w(32),
height: w(32),
)),
... ... @@ -220,10 +316,11 @@ class _FeastSetmealManageEditPageState
@override
Widget build(BuildContext context) {
feastModel = Provider.of<FeastModel>(context, listen: true);
return Scaffold(
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar(
widget.isCreate ? '添加套餐' : mealNameC.text,
mealNameC.text,
needWhite: true,
bgColor: MyColours.color_438E93,
titleColor: MyColours.color_F6F6F6,
... ... @@ -243,9 +340,9 @@ class _FeastSetmealManageEditPageState
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_textfield('套餐名称', '1299套餐', mealNameC, mealF, ''),
_textfield('套餐名称', '请输入', mealNameC, mealF, ''),
_textfield(
'套餐价格', '1299', mealPriceC, mealPriceF, '元'),
'套餐价格', '请输入', mealPriceC, mealPriceF, '元'),
Container(
height: w(48),
margin: EdgeInsets.only(top: w(12)),
... ... @@ -305,6 +402,8 @@ class _FeastSetmealManageEditPageState
lenghtLimit: false,
toast: '请输入分类名称', rCallback: (name) {
// _addCookbookClass(name, showLoading: true);
_setSetmealClass(name);
});
},
text: '添加菜品分类',
... ... @@ -320,11 +419,13 @@ class _FeastSetmealManageEditPageState
),
VEmptyView(14),
ListView.builder(
itemCount: 100,
itemCount: feastModel.setmealClassData.length,
shrinkWrap: true,
controller: controller,
itemBuilder: (BuildContext context, int index) {
return buildFeastTypeItem('热菜(18道)');
GetSetmealClassSunModel data =
feastModel.setmealClassData[index];
return buildFeastTypeItem(data, index);
})
],
)))),
... ... @@ -340,7 +441,20 @@ class _FeastSetmealManageEditPageState
isSelect: false)),
Expanded(
child: _callButton(
onPress: () {},
onPress: () {
if (mealNameC.text.trim().length == 0) {
Utils.showToast('请输入套餐名称');
return;
}
if (mealPriceC.text.trim().length == 0) {
Utils.showToast('请输入套餐价格');
return;
}
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
_setSetmeal();
},
content: '保存',
hasLeftBorder: true,
isSelect: true))
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/setmeal_model.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
import '../../../constant/state.dart';
import '../../../provider/feast_model.dart';
import '../../../provider/user_model.dart';
import '../../../res/colors.dart';
import '../../../utils/dialog_util.dart';
import '../../../utils/event_bus.dart';
import '../../../utils/screen_util.dart';
import '../../../utils/utils.dart';
import '../../../widgets/h_empty_view.dart';
import '../../../widgets/page_exception.dart';
import '../../../widgets/round_button.dart';
import '../../../widgets/system_app_bar.dart';
... ... @@ -23,16 +30,64 @@ class FeastSetmealManagePage extends StatefulWidget {
}
class _FeastSetmealManagePageState extends State<FeastSetmealManagePage> {
FeastModel feastModel;
@override
void initState() {
super.initState();
Utils.changeStatusColor(color: MyColours.color_438E93);
WidgetsBinding.instance.addPostFrameCallback((_) {
_getSetmeal();
// scrollController.jumpTo(scrollController.position.minScrollExtent);
});
bus.on("feast_setmeal_list", (arg) {
_getSetmeal();
});
}
@override
void dispose() {
bus.off('feast_setmeal_list');
super.dispose();
}
///获取宴会分类
Future<bool> _getSetmeal({bool isShowLoading = true}) async {
await feastModel.getSetmeal(context, isShowLoading: isShowLoading);
}
_setSetmeal(String mealName, String price, String bargaining) async {
Map<String, String> params = {
"sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
'meal_name': mealName,
'price': price,
'bargaining': bargaining
};
// if (widget.othersetSunModel != null) {
// params['id'] = widget.othersetSunModel.id;
// }
bool success = await feastModel.setSetmeal(context, params);
if (success) {
Utils.showToast('添加成功');
bus.emit('feast_setmeal_list');
// _getWine(isShowLoading: true);
}
}
Widget buildFeastTypeHeader() {
return RoundButton(
onPressed: () async {
NavigatorUtil.goFeastSetmealManageEditPage(context);
DialogUtil.feastDishEditDialog(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);
});
},
text: '添加一项',
fontSize: 32,
... ... @@ -48,26 +103,27 @@ class _FeastSetmealManagePageState extends State<FeastSetmealManagePage> {
);
}
Widget buildFeastTypeItem(String title, String subTitle) {
Widget buildFeastTypeItem(SetMealSunModel data, int index) {
return Container(
height: h(48),
margin: EdgeInsets.only(top: w(12)),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(width:w(0.5), color: MyColours.color_E7E7E7))),
bottom:
BorderSide(width: w(0.5), color: MyColours.color_E7E7E7))),
child: Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
data.mealName,
style: TextStyle(
fontSize: font(16), color: MyColours.color_E6000000),
),
VEmptyView(12),
Text(
subTitle,
'${data.price}元 ${data.bargaining == '1' ? '可议价' : '不可议价'}',
style: TextStyle(
fontSize: font(12), color: MyColours.color_999999),
)
... ... @@ -76,7 +132,7 @@ class _FeastSetmealManagePageState extends State<FeastSetmealManagePage> {
Spacer(),
InkWell(
onTap: () {
NavigatorUtil.goFeastSetmealManageEditPage(context);
NavigatorUtil.goFeastSetmealManageEditPage(context, data.id);
},
child: Text(
'修改',
... ... @@ -93,15 +149,20 @@ class _FeastSetmealManagePageState extends State<FeastSetmealManagePage> {
DialogUtil.cupertinoAlertDialogFeast(context,
rTitle: '删除',
title: "是否确认删除",
content: "1299套餐", lCallback: () {
content: data.mealName, lCallback: () {
print("取消");
}, rCallback: () {
}, rCallback: () async {
print("确定");
// widget.deleteCallback(index);
Map<String, String> pramas = {'id': data.id};
bool success = await feastModel.delSetmeal(context, pramas);
if (success) {
Utils.showToast('删除成功');
_getSetmeal(isShowLoading: true);
}
});
},
child: Image.asset(
Utils.getImgPath(true ? 'f_delete_red_un' : 'f_delete_red'),
Utils.getImgPath('f_delete_red'),
width: w(32),
height: w(32),
)),
... ... @@ -113,6 +174,7 @@ class _FeastSetmealManagePageState extends State<FeastSetmealManagePage> {
@override
Widget build(BuildContext context) {
feastModel = Provider.of<FeastModel>(context, listen: true);
return Scaffold(
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar(
... ... @@ -125,30 +187,44 @@ class _FeastSetmealManagePageState extends State<FeastSetmealManagePage> {
},
),
body: NestedScrollView(
// controller: _scrollViewController,
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverAppBar(
pinned: true,
floating: false,
leading: null,
backgroundColor: MyColours.color_ffffff,
expandedHeight: ScreenUtil().setWidth(56 * 2),
automaticallyImplyLeading: false,
title: buildFeastTypeHeader(),
// flexibleSpace: FlexibleSpaceBar(
// collapseMode: CollapseMode.pin,
// title: buildFeastTypeHeader())
)
];
},
body: ListView.builder(
itemCount: 100,
padding: EdgeInsets.only(left: w(16)),
itemBuilder: (BuildContext context, int index) {
return buildFeastTypeItem('1299套餐', '1499元 不可议价');
}),
),
// controller: _scrollViewController,
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverAppBar(
pinned: true,
floating: false,
leading: null,
backgroundColor: MyColours.color_ffffff,
expandedHeight: ScreenUtil().setWidth(56 * 2),
automaticallyImplyLeading: false,
title: buildFeastTypeHeader(),
// flexibleSpace: FlexibleSpaceBar(
// collapseMode: CollapseMode.pin,
// title: buildFeastTypeHeader())
)
];
}, body: Consumer<FeastModel>(builder: (context, model, _) {
if (model.pageStateSetmeal != PageState.Success) {
return ExceptionPage(
pageState: model.pageStateSetmeal,
callback: () {
_getSetmeal();
},
emptyMsg: "暂时没有套餐哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return ListView.builder(
itemCount: model.setmealData.length,
padding: EdgeInsets.only(left: w(16)),
itemBuilder: (BuildContext context, int index) {
SetMealSunModel data = model.setmealData[index];
return buildFeastTypeItem(data, index);
// '1299套餐', '1499元 不可议价'
});
}
})),
);
}
}
... ...
... ... @@ -136,7 +136,18 @@ class _FeastWineManageEditPageState extends State<FeastWineManageEditPage> {
),
contentPadding: EdgeInsets.zero,
),
onChanged: (value) {},
onChanged: (value) {
if (widget.wineSunModel != null && title == '酒水名称') {
wineNameC.text = value;
wineNameC.value = TextEditingValue(
text: wineNameC.text,
selection: TextSelection.fromPosition(TextPosition(
affinity: TextAffinity.downstream,
offset: wineNameC.text.length,
)));
setState(() {});
}
},
onEditingComplete: () {
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
... ... @@ -204,7 +215,7 @@ class _FeastWineManageEditPageState extends State<FeastWineManageEditPage> {
return Scaffold(
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar(
wineNameC.text,
widget.wineSunModel == null ? '添加酒水' : wineNameC.text,
needWhite: true,
bgColor: MyColours.color_438E93,
titleColor: MyColours.color_F6F6F6,
... ...
... ... @@ -126,9 +126,14 @@ class _FeastWineManagePageState extends State<FeastWineManagePage> {
title: "是否确认删除",
content: data.wineName, lCallback: () {
print("取消");
}, rCallback: () {
}, rCallback: () async {
print("确定");
// widget.deleteCallback(index);
Map<String, String> pramas = {'id': data.id};
bool success = await feastModel.delWine(context, pramas);
if (success) {
Utils.showToast('删除成功');
_getWine(isShowLoading: true);
}
});
},
child: Image.asset(
... ...
import 'package:flutter/material.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/get_setmeal_class_model.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:provider/provider.dart';
... ... @@ -8,8 +9,12 @@ import '../constant/error.dart';
import '../models/classify_model.dart';
import '../models/filter_btn_model.dart';
import '../models/get_seller_user_by_sellerid_model.dart';
import '../models/get_setmeal_class_by_id_model.dart';
import '../models/get_staff_model.dart';
import '../models/otherset_model.dart';
import '../models/personnel_manage_model.dart';
import '../models/setmeal_by_id_model.dart';
import '../models/setmeal_model.dart';
import '../models/wine_model.dart';
import '../net/base_resp.dart';
import '../net/dio_util.dart';
... ... @@ -32,6 +37,18 @@ class FeastModel extends ChangeNotifier {
PageState pageStateWine = PageState.Loading; //酒水
List<WineSunModel> wineData = [];
PageState pageStateOther = PageState.Loading; //其他配置
List<OthersetSunModel> otherData = [];
PageState pageStateSetmeal = PageState.Loading; //宴会套餐
List<SetMealSunModel> setmealData = [];
SetMeaByIdSunModel setmealDetail; //套餐详情
List<GetSetmealClassSunModel> setmealClassData = []; //菜品分类
GetSetmealClassByIdSunModel setmealClassDetail; //菜品分类详情
/***
*
* 宴会员工
... ... @@ -427,4 +444,420 @@ class FeastModel extends ChangeNotifier {
return false;
}
}
/**
* 其他配置
*/
///添加其他配置
Future<dynamic> setOthersetList(
BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.set_other,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {}
return false;
});
if (baseResp.code == Constant.status_success) {
// if (baseResp.data == 1) {
return true;
// } else {
// return false;
// }
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
return false;
}
}
///获取其他配置
Future<bool> getOthersetList(BuildContext context,
{isShowLoading = true}) async {
Map<String, String> params = {
"sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
};
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.get_other,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {
switch (error.type) {
case 1:
pageStateOther = PageState.ConnectivityError;
break;
case 2:
pageStateOther = PageState.ConnectivityTimeOut;
break;
default:
pageStateOther = PageState.ConnectivityError;
break;
}
}
notifyListeners();
return false;
});
OthersetModel otherModel = OthersetModel.fromJson(baseResp.responseData);
if (otherModel.ret == Constant.status_success) {
otherData = otherModel.data;
if (otherData.length == 0) {
pageStateOther = PageState.Empty;
} else {
pageStateOther = PageState.Success;
}
notifyListeners();
return true;
} else {
Utils.showToast(baseResp.msg ?? "");
pageStateOther = PageState.ConnectivityError;
notifyListeners();
return false;
}
}
///删除其他配置
Future<dynamic> delOthersetList(
BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.del_other,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {}
return false;
});
if (baseResp.code == Constant.status_success) {
// if (baseResp.data == 1) {
return true;
// } else {
// return false;
// }
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
return false;
}
}
/**
* 宴会套餐
*/
///添加宴会套餐
Future<dynamic> setSetmeal(BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.set_setmeal,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {}
return false;
});
if (baseResp.code == Constant.status_success) {
// if (baseResp.data == 1) {
return true;
// } else {
// return false;
// }
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
return false;
}
}
///获取宴会套餐
Future<bool> getSetmeal(BuildContext context, {isShowLoading = true}) async {
Map<String, String> params = {
"sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
};
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.get_setmeal,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {
switch (error.type) {
case 1:
pageStateSetmeal = PageState.ConnectivityError;
break;
case 2:
pageStateSetmeal = PageState.ConnectivityTimeOut;
break;
default:
pageStateSetmeal = PageState.ConnectivityError;
break;
}
}
notifyListeners();
return false;
});
SetMealModel setmealModel = SetMealModel.fromJson(baseResp.responseData);
if (setmealModel.ret == Constant.status_success) {
setmealData = setmealModel.data;
if (setmealData.length == 0) {
pageStateSetmeal = PageState.Empty;
} else {
pageStateSetmeal = PageState.Success;
}
notifyListeners();
return true;
} else {
Utils.showToast(baseResp.msg ?? "");
pageStateSetmeal = PageState.ConnectivityError;
notifyListeners();
return false;
}
}
///删除宴会套餐
Future<dynamic> delSetmeal(BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.del_setmeal,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {}
return false;
});
if (baseResp.code == Constant.status_success) {
// if (baseResp.data == 1) {
return true;
// } else {
// return false;
// }
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
return false;
}
}
/// 根据ID获取宴会套餐
Future<bool> getSetmealById(BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.get_setmeal_by_id,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {}
notifyListeners();
return false;
});
SetMeaByIdModel setMeaByIdModel =
SetMeaByIdModel.fromJson(baseResp.responseData);
if (setMeaByIdModel.ret == Constant.status_success) {
setmealDetail = setMeaByIdModel.data;
notifyListeners();
return true;
} else {
Utils.showToast(baseResp.msg ?? "");
notifyListeners();
return false;
}
}
/// 获取宴会套餐菜品分类列表
getSetmealClass(BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.get_setmeal_class,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {}
notifyListeners();
});
GetSetmealClassModel getSetmealClassModel =
GetSetmealClassModel.fromJson(baseResp.responseData);
if (getSetmealClassModel.ret == Constant.status_success) {
setmealClassData = getSetmealClassModel.data;
notifyListeners();
} else {
Utils.showToast(baseResp.msg ?? "");
notifyListeners();
}
}
///添加宴会套餐---菜品分类
Future<dynamic> setSetmealClass(
BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.set_setmeal_class,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {}
return false;
});
if (baseResp.code == Constant.status_success) {
// if (baseResp.data == 1) {
return true;
// } else {
// return false;
// }
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
return false;
}
}
///删除宴会套餐菜品分类
Future<dynamic> delSetmealClass(
BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.del_setmeal_class,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {}
return false;
});
if (baseResp.code == Constant.status_success) {
// if (baseResp.data == 1) {
return true;
// } else {
// return false;
// }
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
return false;
}
}
/// 根据ID获取宴会套餐菜品分类
Future<bool> getSetmealClassById(
BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.get_setmeal_class_by_id,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {}
notifyListeners();
return false;
});
GetSetmealClassByIdModel getSetmealClassByIdModel =
GetSetmealClassByIdModel.fromJson(baseResp.responseData);
if (getSetmealClassByIdModel.ret == Constant.status_success) {
setmealClassDetail = getSetmealClassByIdModel.data;
notifyListeners();
return true;
} else {
Utils.showToast(baseResp.msg ?? "");
notifyListeners();
return false;
}
}
///添加宴会套餐---菜品
Future<dynamic> setSetmealCook(
BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.set_setmeal_cook,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {}
return false;
});
if (baseResp.code == Constant.status_success) {
// if (baseResp.data == 1) {
return true;
// } else {
// return false;
// }
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
return false;
}
}
/// 删除宴会套餐菜品
Future<dynamic> delSetmealCook(
BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.del_setmeal_cook,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {}
return false;
});
if (baseResp.code == Constant.status_success) {
// if (baseResp.data == 1) {
return true;
// } else {
// return false;
// }
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
return false;
}
}
/**
* 定金
*/
///添加宴会套餐
Future<dynamic> setBanquetConf(
BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.set_banquet_conf,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {}
return false;
});
if (baseResp.code == Constant.status_success) {
// if (baseResp.data == 1) {
return true;
// } else {
// return false;
// }
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
return false;
}
}
}
... ...
... ... @@ -26,6 +26,7 @@ import 'package:one_key/utils/utils.dart';
import 'package:sqflite/sqlite_api.dart';
import '../app.dart';
import '../models/otherset_model.dart';
import '../models/wine_model.dart';
class NavigatorUtil {
... ... @@ -923,16 +924,21 @@ class NavigatorUtil {
}
///宴会----宴会管理 --- 套餐添加
static Future<dynamic> goFeastSetmealManageEditPage(BuildContext context,
static Future<dynamic> goFeastSetmealManageEditPage(
BuildContext context, String setmealId,
{replace = false, bool onlyShow = false}) {
return _navigateTo(context, "${Routes.feast_setmeal_manage_edit_page}",
return _navigateTo(context,
"${Routes.feast_setmeal_manage_edit_page}?setmealId=$setmealId",
replace: replace);
}
///宴会----宴会管理 --- 套餐---菜品
static Future<dynamic> goFeastDishPage(BuildContext context,
static Future<dynamic> goFeastDishPage(
BuildContext context, String setmealId, String classId,
{replace = false, bool onlyShow = false}) {
return _navigateTo(context, "${Routes.feast_dish_page}", replace: replace);
return _navigateTo(context,
"${Routes.feast_dish_page}?setmealId=$setmealId&classId=$classId",
replace: replace);
}
///宴会----宴会管理 --- 酒水管理
... ... @@ -959,8 +965,9 @@ class NavigatorUtil {
///宴会----宴会管理 --- 其他配置添加
static Future<dynamic> goFeastOthersetManageEditPage(BuildContext context,
{replace = false, bool onlyShow = false}) {
return _navigateTo(context, "${Routes.feast_otherset_manage_edit_page}",
{replace = false, bool isNew = true, OthersetSunModel othersetSunModel}) {
return _navigateTo(context,
"${Routes.feast_otherset_manage_edit_page}?othersetSunModel=${FluroConvertUtils.object2string(othersetSunModel)}&isNew=$isNew",
replace: replace);
}
... ...
... ... @@ -13,6 +13,7 @@ import 'package:one_key/models/integral_model.dart';
import 'package:one_key/models/marketing_by_id_model.dart';
import 'package:one_key/models/marketing_by_uid_model.dart';
import 'package:one_key/models/notebook_detail.dart';
import 'package:one_key/models/otherset_model.dart';
import 'package:one_key/models/personnel_manage_model.dart';
import 'package:one_key/models/sms_info.dart';
import 'package:one_key/models/statics_model.dart';
... ... @@ -1463,21 +1464,24 @@ var feastSetmealManagePageHandle = new Handler(
///宴会---套餐管理
var feastSetmealManageEditPageHandle = new Handler(
handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
// String uids = params["uids"].first;
String setmealId = params["setmealId"].first;
// bool onlyShow = FluroConvertUtils.string2bool(params["onlyShow"].first);
return ChangeNotifierProvider<FeastModel>(
create: (_) => FeastModel(), child: FeastSetmealManageEditPage());
create: (_) => FeastModel(),
child: FeastSetmealManageEditPage(setmealId: setmealId));
});
///宴会---菜品
var feastDishPageHandle = new Handler(
handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
// String uids = params["uids"].first;
String setmealId = params["setmealId"].first;
String classId = params["classId"].first;
// bool onlyShow = FluroConvertUtils.string2bool(params["onlyShow"].first);
return ChangeNotifierProvider<FeastModel>(
create: (_) => FeastModel(), child: FeastDishPage());
create: (_) => FeastModel(),
child: FeastDishPage(setmealId: setmealId, classId: classId));
});
///宴会---酒水管理
... ... @@ -1527,6 +1531,18 @@ var feastOthersetManageEditPageHandle = new Handler(
// String uids = params["uids"].first;
// bool onlyShow = FluroConvertUtils.string2bool(params["onlyShow"].first);
bool isNew = FluroConvertUtils.string2bool(params["isNew"].first);
if (!isNew) {
OthersetSunModel othersetSunModel = OthersetSunModel.fromJson(json.decode(
FluroConvertUtils.fluroCnParamsDecode(
params["othersetSunModel"].first)));
//
// bool onlyShow = FluroConvertUtils.string2bool(params["onlyShow"].first);
return ChangeNotifierProvider<FeastModel>(
create: (_) => FeastModel(),
child: FeastOthersetManageEditPage(othersetSunModel: othersetSunModel));
}
return ChangeNotifierProvider<FeastModel>(
create: (_) => FeastModel(), child: FeastOthersetManageEditPage());
});
... ...
... ... @@ -692,6 +692,9 @@ class DialogUtil {
BuildContext context, {
CustomCallBackMap onTap,
String title = '菜品信息',
String nametitle = '菜品名称',
String pricetitle = '菜品规格',
String swichtitle = '是否可调菜',
String content = '',
String per = '',
bool can = true,
... ... @@ -738,7 +741,7 @@ class DialogUtil {
padding: EdgeInsets.symmetric(horizontal: w(16)),
child: Row(children: [
Text(
'菜品名称',
nametitle,
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_000000),
... ... @@ -786,7 +789,7 @@ class DialogUtil {
padding: EdgeInsets.symmetric(horizontal: w(16)),
child: Row(children: [
Text(
'菜品规格',
pricetitle,
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_000000),
... ... @@ -825,9 +828,19 @@ class DialogUtil {
FocusScope.of(context).requestFocus(
FocusNode()); //点击空白处隐藏键盘
},
keyboardType: TextInputType.text,
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(
... ... @@ -844,9 +857,9 @@ class DialogUtil {
Container(
width: w(81),
height: w(48),
alignment: Alignment.center,
alignment: Alignment.centerLeft,
child: Text(
'是否可调菜',
swichtitle,
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_E6000000),
... ... @@ -907,12 +920,12 @@ class DialogUtil {
fontSize: 32,
onPressed: () {
if (nameC.text.trim() == '') {
Utils.showToast('请输入菜品名称!');
Utils.showToast('请输入${nametitle}!');
return;
}
if (perC.text.trim() == '') {
Utils.showToast('请输入菜品规格!');
Utils.showToast('请输入${pricetitle}!');
return;
}
onTap({
... ...