Commit 0e1804ed6d192252005960876d8561302f3c2594

Authored by wdn127929
1 parent 01a2f7af

酒水差删除

class ClassifyModel {
int ret;
List<ClassifySunModel> data;
String msg;
ClassifyModel({this.ret, this.data, this.msg});
ClassifyModel.fromJson(Map<String, dynamic> json) {
ret = json['ret'];
if (json['data'] != null) {
data = <ClassifySunModel>[];
json['data'].forEach((v) {
data.add(new ClassifySunModel.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 ClassifySunModel {
String id;
String sid;
String className;
String status;
dynamic cdate;
ClassifySunModel(
{this.id, this.sid, this.className, this.status, this.cdate});
ClassifySunModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
sid = json['sid'];
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['class_name'] = this.className;
data['status'] = this.status;
data['cdate'] = this.cdate;
return data;
}
}
... ...
... ... @@ -3,14 +3,26 @@ class FilterBtnModel {
String id;
String title;
bool select = false;
String roleName;
String phone;
String account;
FilterBtnModel();
factory FilterBtnModel.fromJson(Map<String, dynamic> json) => FilterBtnModel()
..id = json["id"]
..title = json["title"]
..select = json["select"];
..select = json["select"]
..roleName = json["role_name"]
..phone = json["phone"]
..account = json["account"];
Map<String, dynamic> toJson() =>
<String, dynamic>{"id": id, "title": title, "select": select};
Map<String, dynamic> toJson() => <String, dynamic>{
"id": id,
"title": title,
"select": select,
'roleName': roleName,
'phone': phone,
'account': account
};
}
... ...
class GetStaffModel {
int ret;
List<GetStaffSunModel> data;
String msg;
GetStaffModel({this.ret, this.data, this.msg});
GetStaffModel.fromJson(Map<String, dynamic> json) {
ret = json['ret'];
if (json['data'] != null) {
data = <GetStaffSunModel>[];
json['data'].forEach((v) {
data.add(new GetStaffSunModel.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 GetStaffSunModel {
String id;
String sid;
String userId;
Null status;
Null cdate;
GetStaffSunModel({this.id, this.sid, this.userId, this.status, this.cdate});
GetStaffSunModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
sid = json['sid'];
userId = json['user_id'];
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['user_id'] = this.userId;
data['status'] = this.status;
data['cdate'] = this.cdate;
return data;
}
}
... ...
class WineModel {
int ret;
List<WineSunModel> data;
String msg;
WineModel({this.ret, this.data, this.msg});
WineModel.fromJson(Map<String, dynamic> json) {
ret = json['ret'];
if (json['data'] != null) {
data = <WineSunModel>[];
json['data'].forEach((v) {
data.add(new WineSunModel.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 WineSunModel {
String id;
String sid;
String wineName;
String price;
String spec;
String bargaining;
WineSunModel(
{this.id,
this.sid,
this.wineName,
this.price,
this.spec,
this.bargaining});
WineSunModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
sid = json['sid'];
wineName = json['wine_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['wine_name'] = this.wineName;
data['price'] = this.price;
data['spec'] = this.spec;
data['bargaining'] = this.bargaining;
return data;
}
}
... ...
... ... @@ -133,8 +133,7 @@ class HttpUrl {
static const String get_table_fill_update =
"?service=App.Customer.GetTableFillUpDate"; // 根据指定日期,返回当前商家包间类型置满情况的日期
static const String app_pay_sub =
"?service=App.Pay.AppPaySub"; // 微信支付
static const String app_pay_sub = "?service=App.Pay.AppPaySub"; // 微信支付
static const String get_table_class_by_id =
"?service=App.Seller.GetTableClassById"; // 获取包间分类
... ... @@ -243,5 +242,17 @@ class HttpUrl {
"?service=Android.Reserve.NewGetMessageList"; //根据不同得消息类型获取对应得消息列表
static const String get_seller_reserve_total =
"?service=Android.Reserve.GetSellerReserveTotal"; // 获取商家时间区间内订单数量
static const String add_staff = "?service=App.Banquet.AddStaff"; // 添加宴会员工
static const String get_staff = "?service=App.Banquet.GetStaff"; // 获取宴会员工
static const String get_classify =
"?service=App.Banquet.GetClassify"; // 获取宴会分类
static const String set_classify =
"?service=App.Banquet.SetClassify"; // 添加宴会分类
static const String del_classify =
"?service=App.Banquet.DelClassify"; // 删除宴会分类
static const String get_wine = "?service=App.Banquet.GetWine"; // 获取酒水
static const String set_wine = "?service=App.Banquet.SetWine"; // 添加酒水
static const String del_wine = "?service=App.Banquet.DelWine"; // 删除酒水
}
... ...
... ... @@ -85,7 +85,7 @@ class _FeastCreatePageState extends State<FeastCreatePage> {
///商家编辑页面 ----- 获取经理数据
_getSellerUserBySellerid() async {
await feastModel.getSellerUserBySellerid(context);
await feastModel.getAuthUserLists(context);
// for (int i = 0; i < feastModel.sellerManageList.length; i++) {
// if (manageShow == feastModel.sellerManageList[i].title) {
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/filter_btn_model.dart';
import 'package:one_key/widgets/MyDivider.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/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';
... ... @@ -22,73 +28,145 @@ class FeastPersonalPage extends StatefulWidget {
}
class _FeastPersonalPageState extends State<FeastPersonalPage> {
FeastModel feastModel;
@override
void initState() {
super.initState();
Utils.changeStatusColor(color: MyColours.color_438E93);
WidgetsBinding.instance.addPostFrameCallback((_) {
_getData();
// scrollController.jumpTo(scrollController.position.minScrollExtent);
});
}
Widget buildFeastTypeHeader(bool select) {
_getData() async {
await Future.wait<bool>([_getSellerUserBySellerid(), _getStaff()])
.then((results) {
print(results[0]);
if (results[0] && results[1]) {
//成功
feastModel.sellerManageList.forEach((element) {
if (feastModel.getPersonnalList.contains(element.id)) {
element.select = true;
feastModel.selectPersonnalData.add(element.id);
} else {
element.select = false;
}
});
feastModel.getCheckValueMy();
} else {
if (!results[0]) {
// Utils.showToast('');
} else {
// Utils.showToast('');
}
}
}).catchError((e) {
print(e);
});
}
///获取经理数据
Future<bool> _getSellerUserBySellerid() async {
bool success = await feastModel.getAuthUserLists(context);
if (success) {
return true;
} else {
return false;
}
}
///
Future<bool> _getStaff() async {
bool success = await feastModel.getStaff(context);
if (success) {
return true;
} else {
return false;
}
}
Widget buildFeastTypeHeader() {
return RoundButton(
onPressed: () async {},
onPressed: () {
if (feastModel.checkValue) {
feastModel.cancelAllMy();
} else {
feastModel.addAllMy();
}
},
text: '全选',
fontSize: 32,
isBold: false,
height: h(32),
width: w(48),
margin: EdgeInsets.only(top: w(18), bottom: w(4)),
textColor: select ? MyColours.color_ffffff : MyColours.color_438E93,
gradientStart: select ? MyColours.color_438E93 : MyColours.color_ffffff,
gradientEnd: select ? MyColours.color_438E93 : MyColours.color_ffffff,
borderColor: select ? MyColours.color_438E93 : MyColours.color_ffffff,
textColor: feastModel.checkValue
? MyColours.color_ffffff
: MyColours.color_438E93,
gradientStart: feastModel.checkValue
? MyColours.color_438E93
: MyColours.color_ffffff,
gradientEnd: feastModel.checkValue
? MyColours.color_438E93
: MyColours.color_ffffff,
borderColor: MyColours.color_438E93,
radius: r(6),
);
}
Widget buildFeastTypeItem() {
return Column(
children: [
Container(
height: h(48),
margin: EdgeInsets.only(top: w(12)),
// decoration: BoxDecoration(
// border: Border(
// bottom:
// BorderSide(width: w(1), color: MyColours.color_E7E7E7))),
child: Row(
children: [
InkWell(
onTap: () {},
child: Image.asset(
Utils.getImgPath(true ? 'select' : 'unselect'),
Widget buildFeastTypeItem(FilterBtnModel model, int index) {
return InkWell(
onTap: () {
model.select = !model.select;
if (model.select) {
feastModel.addDataMy(index);
} else {
feastModel.cancelDataMy(index);
}
feastModel.getCheckValueMy();
},
child: Column(
children: [
Container(
height: h(48),
margin: EdgeInsets.only(top: w(12)),
// decoration: BoxDecoration(
// border: Border(
// bottom:
// BorderSide(width: w(1), color: MyColours.color_E7E7E7))),
child: Row(
children: [
Image.asset(
Utils.getImgPath(model.select ? 'select' : 'unselect'),
width: w(24),
height: w(24),
)),
HEmptyView(16),
Text(
'刘经理 15833517582',
style: TextStyle(
fontSize: font(16), color: MyColours.color_E6000000),
),
Spacer(),
Text(
'管理员 0001',
style: TextStyle(
fontSize: font(14), color: MyColours.color_999999),
),
HEmptyView(16),
Text(
'${model.title} ${model.phone ?? ''}',
style: TextStyle(
fontSize: font(16), color: MyColours.color_E6000000),
),
Spacer(),
Text(
'${model.roleName} ${model.account}',
style: TextStyle(
fontSize: font(14), color: MyColours.color_999999),
),
HEmptyView(32),
],
),
HEmptyView(32),
],
),
),
Padding(
padding: EdgeInsets.only(left: w(32)),
child: MyDivider(
double.infinity,
w(0.5),
color: MyColours.color_E7E7E7,
))
],
);
),
Padding(
padding: EdgeInsets.only(left: w(32)),
child: MyDivider(
double.infinity,
w(0.5),
color: MyColours.color_E7E7E7,
))
],
));
}
Widget _callButton(
... ... @@ -133,6 +211,7 @@ class _FeastPersonalPageState extends State<FeastPersonalPage> {
@override
Widget build(BuildContext context) {
feastModel = Provider.of<FeastModel>(context, listen: true);
return Scaffold(
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar(
... ... @@ -144,55 +223,89 @@ class _FeastPersonalPageState extends State<FeastPersonalPage> {
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(true),
// flexibleSpace: FlexibleSpaceBar(
// collapseMode: CollapseMode.pin,
// title: buildFeastTypeHeader())
)
];
body: Consumer<FeastModel>(builder: (context, model, _) {
if (model.pageStatePersonnalHome != PageState.Success) {
return ExceptionPage(
pageState: model.pageStatePersonnalHome,
callback: () {
_getSellerUserBySellerid();
},
body: ListView.builder(
itemCount: 100,
padding: EdgeInsets.only(left: w(16)),
itemBuilder: (BuildContext context, int index) {
return buildFeastTypeItem();
}),
)),
Row(
emptyMsg: "暂时没有员工哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return Column(
children: [
Expanded(
child: _callButton(
onPress: () {
Navigator.pop(context);
},
content: '返回',
hasLeftBorder: true,
isSelect: false)),
Expanded(
child: _callButton(
onPress: () {},
content: '保存',
hasLeftBorder: true,
isSelect: true))
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: feastModel.sellerManageList.length,
padding: EdgeInsets.only(left: w(16)),
itemBuilder: (BuildContext context, int index) {
FilterBtnModel model = feastModel.sellerManageList[index];
return buildFeastTypeItem(model, index);
}),
)),
Row(
children: [
Expanded(
child: _callButton(
onPress: () {
Navigator.pop(context);
},
content: '返回',
hasLeftBorder: true,
isSelect: false)),
Expanded(
child: _callButton(
onPress: () async {
if (feastModel.selectPersonnalData.length == 0) {
Utils.showToast('请至少选择一个员工!');
return;
}
Map<String, String> params = {
"sid":
Provider.of<UserModel>(context, listen: false)
.user
.sellerid,
'user_id': Utils.listToStringEnglish(
feastModel.selectPersonnalData)
};
bool success =
await feastModel.addStaff(context, params);
if (success) {
Utils.showToast('保存成功');
Navigator.pop(context);
}
},
content: '保存',
hasLeftBorder: true,
isSelect: true))
],
)
],
)
],
),
);
}
}),
);
}
}
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/classify_model.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/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';
... ... @@ -21,10 +27,35 @@ class FeastTypePage extends StatefulWidget {
}
class _FeastTypePageState extends State<FeastTypePage> {
FeastModel feastModel;
@override
void initState() {
super.initState();
Utils.changeStatusColor(color: MyColours.color_438E93);
WidgetsBinding.instance.addPostFrameCallback((_) {
_getClassify();
// scrollController.jumpTo(scrollController.position.minScrollExtent);
});
}
///获取宴会分类
Future<bool> _getClassify({bool isShowLoading = true}) async {
await feastModel.getClassify(context, isShowLoading: isShowLoading);
}
_setClassify(String name, {String idstr}) async {
Map<String, String> params = {
"sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
'class_name': name
};
if (idstr != null) {
params['id'] = idstr;
}
bool success = await feastModel.setClassify(context, params);
if (success) {
Utils.showToast('添加成功');
_getClassify(isShowLoading: true);
}
}
Widget buildFeastTypeHeader() {
... ... @@ -36,6 +67,7 @@ class _FeastTypePageState extends State<FeastTypePage> {
text: '',
lenghtLimit: false,
toast: '请输入类型名称', rCallback: (name) {
_setClassify(name);
// _addCookbookClass(name, showLoading: true);
});
},
... ... @@ -53,17 +85,18 @@ class _FeastTypePageState extends State<FeastTypePage> {
);
}
Widget buildFeastTypeItem(String title) {
Widget buildFeastTypeItem(ClassifySunModel 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: [
Text(
title,
data.className,
style:
TextStyle(fontSize: font(16), color: MyColours.color_E6000000),
),
... ... @@ -73,10 +106,10 @@ class _FeastTypePageState extends State<FeastTypePage> {
DialogUtil.textfeildAlertDialog(context,
title: '输入类型名称',
hintText: '请输入',
text: '原来的内容',
text: data.className,
lenghtLimit: true,
toast: '请输入类型名称', rCallback: (name) {
// _addCookbookClass(name, showLoading: true);
_setClassify(name, idstr: data.id);
});
},
child: Text(
... ... @@ -89,20 +122,28 @@ class _FeastTypePageState extends State<FeastTypePage> {
HEmptyView(32),
InkWell(
onTap: () {
//已经传到服务器,弹提醒窗口,是否删除
//修改之前有内容,则弹框
if (index == 0) {
return;
}
DialogUtil.cupertinoAlertDialogFeast(context,
rTitle: '删除',
title: "是否确认删除",
content: "满月宴", lCallback: () {
content: data.className, lCallback: () {
print("取消");
}, rCallback: () {
}, rCallback: () async {
print("确定");
// widget.deleteCallback(index);
Map<String, String> pramas = {'id': data.id};
bool success = await feastModel.delClassify(context, pramas);
if (success) {
Utils.showToast('删除成功');
_getClassify(isShowLoading: true);
}
});
},
child: Image.asset(
Utils.getImgPath(true ? 'f_delete_red_un' : 'f_delete_red'),
Utils.getImgPath(
index == 0 ? 'f_delete_red_un' : 'f_delete_red'),
width: w(32),
height: w(32),
)),
... ... @@ -114,6 +155,7 @@ class _FeastTypePageState extends State<FeastTypePage> {
@override
Widget build(BuildContext context) {
feastModel = Provider.of<FeastModel>(context, listen: true);
return Scaffold(
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar(
... ... @@ -126,30 +168,43 @@ class _FeastTypePageState extends State<FeastTypePage> {
},
),
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('公司年会');
}),
),
// 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.pageStateType != PageState.Success) {
return ExceptionPage(
pageState: model.pageStateType,
callback: () {
// _getSellerUserBySellerid();
},
emptyMsg: "暂时没有宴会类型哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return ListView.builder(
itemCount: feastModel.classifyData.length,
padding: EdgeInsets.only(left: w(16)),
itemBuilder: (BuildContext context, int index) {
ClassifySunModel data = feastModel.classifyData[index];
return buildFeastTypeItem(data, index);
});
}
})),
);
}
}
... ...
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/wine_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 FeastWineManageEditPage extends StatefulWidget {
final isCreate;
final WineSunModel wineSunModel;
FeastWineManageEditPage({
Key key,
this.isCreate = true,
this.wineSunModel,
}) : super(key: key);
@override
... ... @@ -35,11 +40,38 @@ class _FeastWineManageEditPageState extends State<FeastWineManageEditPage> {
FocusNode winePerF = FocusNode();
bool canBargaining = true; //是否议价
ScrollController controller = ScrollController();
FeastModel feastModel;
@override
void initState() {
super.initState();
Utils.changeStatusColor(color: MyColours.color_438E93);
if (widget.wineSunModel != null) {
wineNameC.text = widget.wineSunModel.wineName;
winePriceC.text = widget.wineSunModel.price;
winePerC.text = widget.wineSunModel.spec;
canBargaining = widget.wineSunModel.bargaining == '1' ? true : false;
}
}
_setWine() async {
Map<String, String> params = {
"sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
'wine_name': wineNameC.text,
'price': winePriceC.text,
'spec': winePerC.text,
'bargaining': canBargaining ? '1' : '0'
};
if (widget.wineSunModel != null) {
params['id'] = widget.wineSunModel.id;
}
bool success = await feastModel.setWine(context, params);
if (success) {
Utils.showToast('添加成功');
bus.emit('feast_wine_list');
Navigator.pop(context);
// _getWine(isShowLoading: true);
}
}
///请输入
... ... @@ -50,7 +82,7 @@ class _FeastWineManageEditPageState extends State<FeastWineManageEditPage> {
TextEditingController editingController,
FocusNode focusNode,
String subTitle,
{TextInputType inputType = TextInputType.number}) {
{TextInputType inputType = TextInputType.text}) {
return Container(
height: w(48),
margin: EdgeInsets.only(top: w(12)),
... ... @@ -168,10 +200,11 @@ class _FeastWineManageEditPageState extends State<FeastWineManageEditPage> {
@override
Widget build(BuildContext context) {
feastModel = Provider.of<FeastModel>(context, listen: true);
return Scaffold(
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar(
widget.isCreate ? '添加酒水' : wineNameC.text,
wineNameC.text,
needWhite: true,
bgColor: MyColours.color_438E93,
titleColor: MyColours.color_F6F6F6,
... ... @@ -191,11 +224,11 @@ class _FeastWineManageEditPageState extends State<FeastWineManageEditPage> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_textfield('酒水名称', '请输入', wineNameC, wineF, ''),
_textfield(
'酒水名称', '剑南春52度500ml', wineNameC, wineF, ''),
_textfield(
'酒水单价', '1299', winePriceC, winePriceF, '元'),
_textfield('酒水规格', '份', winePerC, winePerF, ''),
'酒水单价', '请输入', winePriceC, winePriceF, '元',
inputType: TextInputType.numberWithOptions()),
_textfield('酒水规格', '请输入', winePerC, winePerF, ''),
Container(
height: w(48),
margin: EdgeInsets.only(top: w(12)),
... ... @@ -252,7 +285,21 @@ class _FeastWineManageEditPageState extends State<FeastWineManageEditPage> {
isSelect: false)),
Expanded(
child: _callButton(
onPress: () {},
onPress: () {
if (wineNameC.text.trim().length == 0) {
Utils.showToast('请输入酒水名称');
return;
}
if (winePriceC.text.trim().length == 0) {
Utils.showToast('请输入酒水单价');
return;
}
if (winePerC.text.trim().length == 0) {
Utils.showToast('请输入酒水规格');
return;
}
_setWine();
},
content: '保存',
hasLeftBorder: true,
isSelect: true))
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/wine_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,37 @@ class FeastWineManagePage extends StatefulWidget {
}
class _FeastWineManagePageState extends State<FeastWineManagePage> {
FeastModel feastModel;
@override
void initState() {
super.initState();
Utils.changeStatusColor(color: MyColours.color_438E93);
WidgetsBinding.instance.addPostFrameCallback((_) {
_getWine();
// scrollController.jumpTo(scrollController.position.minScrollExtent);
});
bus.on("feast_wine_list", (arg) {
_getWine();
});
}
@override
void dispose() {
bus.off('feast_wine_list');
super.dispose();
}
///获取宴会分类
Future<bool> _getWine({bool isShowLoading = true}) async {
await feastModel.getWine(context, isShowLoading: isShowLoading);
}
Widget buildFeastTypeHeader() {
return RoundButton(
onPressed: () async {
NavigatorUtil.goFeastWineManageEditPage(context);
NavigatorUtil.goFeastWineManageEditPage(
context,
);
},
text: '添加一项',
fontSize: 32,
... ... @@ -48,26 +76,28 @@ class _FeastWineManagePageState extends State<FeastWineManagePage> {
);
}
Widget buildFeastTypeItem(String title, String subTitle) {
Widget buildFeastTypeItem(WineSunModel 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.wineName,
style: TextStyle(
fontSize: font(16), color: MyColours.color_E6000000),
),
VEmptyView(12),
Text(
subTitle,
// '剑南春52度500ml', '1150元/份 不可议价'
'${data.price}元/${data.spec} ${data.bargaining == '1' ? '可议价' : '不可议价'}',
style: TextStyle(
fontSize: font(12), color: MyColours.color_999999),
)
... ... @@ -76,7 +106,8 @@ class _FeastWineManagePageState extends State<FeastWineManagePage> {
Spacer(),
InkWell(
onTap: () {
NavigatorUtil.goFeastWineManageEditPage(context);
NavigatorUtil.goFeastWineManageEditPage(context,
isNew: false, wineSunModel: data);
},
child: Text(
'修改',
... ... @@ -93,7 +124,7 @@ class _FeastWineManagePageState extends State<FeastWineManagePage> {
DialogUtil.cupertinoAlertDialogFeast(context,
rTitle: '删除',
title: "是否确认删除",
content: "剑南春52度500ml", lCallback: () {
content: data.wineName, lCallback: () {
print("取消");
}, rCallback: () {
print("确定");
... ... @@ -101,7 +132,7 @@ class _FeastWineManagePageState extends State<FeastWineManagePage> {
});
},
child: Image.asset(
Utils.getImgPath(true ? 'f_delete_red_un' : 'f_delete_red'),
Utils.getImgPath('f_delete_red'),
width: w(32),
height: w(32),
)),
... ... @@ -153,24 +184,25 @@ class _FeastWineManagePageState extends State<FeastWineManagePage> {
@override
Widget build(BuildContext context) {
feastModel = Provider.of<FeastModel>(context, listen: true);
return Scaffold(
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar(
'酒水管理',
needWhite: true,
bgColor: MyColours.color_438E93,
titleColor: MyColours.color_F6F6F6,
onTap: () {
Navigator.pop(context);
},
),
body: Column(
children: [
Expanded(
child: NestedScrollView(
// controller: _scrollViewController,
headerSliverBuilder:
(BuildContext context, bool innerBoxIsScrolled) {
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar(
'酒水管理',
needWhite: true,
bgColor: MyColours.color_438E93,
titleColor: MyColours.color_F6F6F6,
onTap: () {
Navigator.pop(context);
},
),
body: Column(
children: [
Expanded(
child: NestedScrollView(
// controller: _scrollViewController,
headerSliverBuilder:
(BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverAppBar(
pinned: true,
... ... @@ -185,34 +217,47 @@ class _FeastWineManagePageState extends State<FeastWineManagePage> {
// title: buildFeastTypeHeader())
)
];
},
body: ListView.builder(
itemCount: 100,
padding: EdgeInsets.only(left: w(16)),
itemBuilder: (BuildContext context, int index) {
return buildFeastTypeItem('剑南春52度500ml', '1150元/份 不可议价');
}),
)),
Row(
children: [
Expanded(
child: _callButton(
onPress: () {
Navigator.pop(context);
},
content: '返回',
hasLeftBorder: true,
isSelect: false)),
Expanded(
child: _callButton(
onPress: () {},
content: '保存',
hasLeftBorder: true,
isSelect: true))
],
)
],
),
);
}, body: Consumer<FeastModel>(builder: (context, model, _) {
if (model.pageStateWine != PageState.Success) {
return ExceptionPage(
pageState: model.pageStateWine,
callback: () {
_getWine();
},
emptyMsg: "暂时没有酒水哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return ListView.builder(
itemCount: feastModel.wineData.length,
padding: EdgeInsets.only(left: w(16)),
itemBuilder: (BuildContext context, int index) {
WineSunModel data = feastModel.wineData[index];
return buildFeastTypeItem(data, index);
// '剑南春52度500ml', '1150元/份 不可议价'
});
}
}))),
// Row(
// children: [
// Expanded(
// child: _callButton(
// onPress: () {
// Navigator.pop(context);
// },
// content: '返回',
// hasLeftBorder: true,
// isSelect: false)),
// Expanded(
// child: _callButton(
// onPress: () {},
// content: '保存',
// hasLeftBorder: true,
// isSelect: true))
// ],
// )
],
));
}
}
... ...
... ... @@ -5,8 +5,12 @@ import 'package:provider/provider.dart';
import '../constant/constant.dart';
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_staff_model.dart';
import '../models/personnel_manage_model.dart';
import '../models/wine_model.dart';
import '../net/base_resp.dart';
import '../net/dio_util.dart';
import '../net/http_url.dart';
... ... @@ -17,39 +21,410 @@ class FeastModel extends ChangeNotifier {
List<FilterBtnModel> sellerManageList = []; //经理数据 ---- 商家编辑页面
///商家详情编辑页面 ------ 获取经理数据
Future<List<FilterBtnModel>> getSellerUserBySellerid(BuildContext context,
PageState pageStatePersonnalHome = PageState.Loading; //员工管理
List<String> selectPersonnalData = [];
bool checkValue = false;
List<String> getPersonnalList = []; //宴会员工
PageState pageStateType = PageState.Loading; //宴会类型
List<ClassifySunModel> classifyData = [];
PageState pageStateWine = PageState.Loading; //酒水
List<WineSunModel> wineData = [];
/***
*
* 宴会员工
*/
//全选按钮执行“全选”
addAllMy() async {
//把数据状态全部改成true,即选中状态
selectPersonnalData = [];
for (var i = 0; i < sellerManageList.length; i++) {
sellerManageList[i].select = true;
selectPersonnalData.add(sellerManageList[i].id);
}
checkValue = true;
notifyListeners();
}
//全选按钮执行“全不选”
cancelAllMy() async {
selectPersonnalData = [];
//把数据状态全部改成false,即不选中状态
for (var i = 0; i < sellerManageList.length; i++) {
sellerManageList[i].select = false;
}
checkValue = false;
notifyListeners();
}
//选中
addDataMy(int index) {
// userHistorys[index].select = true;
selectPersonnalData.add(sellerManageList[index].id);
notifyListeners();
}
//未选中
cancelDataMy(int index) {
// userHistorys[index].select = false;
selectPersonnalData
.removeWhere((element) => element == sellerManageList[index].id);
notifyListeners();
}
//获取全选按钮的状态 true or false
getCheckValueMy() {
bool temp = sellerManageList.any((value) {
return value.select == false;
});
if (temp == true) {
checkValue = false;
} else {
checkValue = true;
}
notifyListeners();
}
FilterBtnModel returnModel(PersonnelManageSunModel item) {
FilterBtnModel model = FilterBtnModel();
model.id = item.id;
model.title = item.nickName ?? item.account;
model.account = item.account;
model.phone = item.phone;
return model;
}
/// 获取店员列表
Future<bool> getAuthUserLists(BuildContext context,
{showLoading = false}) async {
Map<String, String> params = {
"sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid,
};
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.get_auth_user_lists,
data: params, showLoading: showLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {
switch (error.type) {
case 1:
pageStatePersonnalHome = PageState.ConnectivityError;
break;
case 2:
pageStatePersonnalHome = PageState.ConnectivityTimeOut;
break;
default:
pageStatePersonnalHome = PageState.ConnectivityError;
break;
}
}
notifyListeners();
return false;
});
if (baseResp != null && baseResp.code == Constant.status_success) {
Map data = baseResp.data;
Map<String, dynamic> tempData = {};
data.forEach((key, value) {
String keyTemp = key.split('_')[0];
String role_id = key.split('_')[1];
tempData[keyTemp] = {'listdata': value, 'role_id': role_id};
});
baseResp.responseData['data'] = tempData;
PersonnelManageModelData dataMap =
PersonnelManageModel.fromJson(baseResp.responseData).data;
sellerManageList = [];
for (PersonnelManageSunModel item in dataMap.admin.listdata) {
FilterBtnModel model = returnModel(item);
model.roleName = '管理员';
sellerManageList.add(model);
}
for (PersonnelManageSunModel item in dataMap.cashier.listdata) {
FilterBtnModel model = returnModel(item);
model.roleName = '收银员';
sellerManageList.add(model);
}
for (PersonnelManageSunModel item in dataMap.manager.listdata) {
FilterBtnModel model = returnModel(item);
model.roleName = '客户经理';
sellerManageList.add(model);
}
for (PersonnelManageSunModel item in dataMap.shopowner.listdata) {
FilterBtnModel model = returnModel(item);
model.roleName = '店长';
sellerManageList.add(model);
}
for (PersonnelManageSunModel item in dataMap.waiter.listdata) {
FilterBtnModel model = returnModel(item);
model.roleName = '服务员';
sellerManageList.add(model);
}
pageStatePersonnalHome = PageState.Success;
notifyListeners();
return true;
} else {
Utils.showToast(baseResp.msg ?? "");
pageStatePersonnalHome = PageState.ConnectivityError;
notifyListeners();
return false;
}
}
///添加宴会员工
Future<dynamic> addStaff(BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.add_staff,
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> getStaff(BuildContext context, {isShowLoading = true}) async {
Map<String, String> params = {
'sellerid': Provider.of<UserModel>(context, listen: false).user.sellerid
"sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
};
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(
context, Method.get, HttpUrl.get_seller_user_by_sellerid,
data: params, showLoading: false)
.request<dynamic>(context, Method.get, HttpUrl.get_staff,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {}
return false;
});
getPersonnalList = [];
GetStaffModel getStaffModel = GetStaffModel.fromJson(baseResp.responseData);
if (getStaffModel.ret == Constant.status_success) {
List<GetStaffSunModel> data = getStaffModel.data;
data.forEach((element) {
getPersonnalList.add(element.userId);
});
return true;
} else {
Utils.showToast(baseResp.msg ?? "");
return false;
}
}
/**
* 宴会类型
*/
///添加宴会类型
Future<dynamic> setClassify(BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.set_classify,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {}
return false;
});
if (baseResp.code == Constant.status_success) {
List<GetSellerUserBySelleridSunModel> sunmodel =
GetSellerUserBySelleridModel.fromJson(baseResp.responseData).data;
sellerManageList = [];
if (sunmodel != null && sunmodel.length > 0) {
for (GetSellerUserBySelleridSunModel item in sunmodel) {
if (item.nickName != null) {
FilterBtnModel model = FilterBtnModel();
model.id = item.id;
model.title = item.nickName;
sellerManageList.add(model);
}
// if (baseResp.data == 1) {
return true;
// } else {
// return false;
// }
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
return false;
}
}
///获取宴会类型
Future<bool> getClassify(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_classify,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {
switch (error.type) {
case 1:
pageStateType = PageState.ConnectivityError;
break;
case 2:
pageStateType = PageState.ConnectivityTimeOut;
break;
default:
pageStateType = PageState.ConnectivityError;
break;
}
}
notifyListeners();
return false;
});
ClassifyModel classifyModel = ClassifyModel.fromJson(baseResp.responseData);
if (classifyModel.ret == Constant.status_success) {
classifyData = classifyModel.data;
if (classifyData.length == 0) {
pageStateType = PageState.Empty;
} else {
pageStateType = PageState.Success;
}
notifyListeners();
return true;
} else {
Utils.showToast(baseResp.msg ?? "");
pageStateType = PageState.ConnectivityError;
notifyListeners();
return false;
}
}
///删除宴会类型
Future<dynamic> delClassify(BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.del_classify,
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> setWine(BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.set_wine,
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> getWine(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_wine,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {
switch (error.type) {
case 1:
pageStateWine = PageState.ConnectivityError;
break;
case 2:
pageStateWine = PageState.ConnectivityTimeOut;
break;
default:
pageStateWine = PageState.ConnectivityError;
break;
}
}
notifyListeners();
return false;
});
WineModel wineModel = WineModel.fromJson(baseResp.responseData);
if (wineModel.ret == Constant.status_success) {
wineData = wineModel.data;
if (wineData.length == 0) {
pageStateWine = PageState.Empty;
} else {
pageStateWine = PageState.Success;
}
notifyListeners();
return true;
} else {
Utils.showToast(baseResp.msg ?? "");
pageStateWine = PageState.ConnectivityError;
notifyListeners();
return false;
}
}
///删除酒水
Future<dynamic> delWine(BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.del_wine,
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;
}
return sellerManageList;
}
}
... ...
... ... @@ -26,6 +26,7 @@ import 'package:one_key/utils/utils.dart';
import 'package:sqflite/sqlite_api.dart';
import '../app.dart';
import '../models/wine_model.dart';
class NavigatorUtil {
static Future _navigateTo(BuildContext context, String path,
... ... @@ -943,8 +944,9 @@ class NavigatorUtil {
///宴会----宴会管理 --- 酒水添加
static Future<dynamic> goFeastWineManageEditPage(BuildContext context,
{replace = false, bool onlyShow = false}) {
return _navigateTo(context, "${Routes.feast_wine_manage_edit_page}",
{replace = false, bool isNew = true, WineSunModel wineSunModel}) {
return _navigateTo(context,
"${Routes.feast_wine_manage_edit_page}?wineSunModel=${FluroConvertUtils.object2string(wineSunModel)}&isNew=$isNew",
replace: replace);
}
... ...
... ... @@ -18,6 +18,7 @@ import 'package:one_key/models/sms_info.dart';
import 'package:one_key/models/statics_model.dart';
import 'package:one_key/models/table_list.dart';
import 'package:one_key/models/user_history_entity.dart';
import 'package:one_key/models/wine_model.dart';
import 'package:one_key/pages/coupon/coupon_create_select_type_page.dart';
import 'package:one_key/pages/coupon/coupon_detail_page.dart';
import 'package:one_key/pages/coupon/coupon_edit_page.dart';
... ... @@ -1493,7 +1494,18 @@ var feastWineManagePageHandle = new Handler(
var feastWineManageEditPageHandle = new Handler(
handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
// String uids = params["uids"].first;
bool isNew = FluroConvertUtils.string2bool(params["isNew"].first);
if (!isNew) {
WineSunModel wineSunModel = WineSunModel.fromJson(json.decode(
FluroConvertUtils.fluroCnParamsDecode(params["wineSunModel"].first)));
//
// bool onlyShow = FluroConvertUtils.string2bool(params["onlyShow"].first);
return ChangeNotifierProvider<FeastModel>(
create: (_) => FeastModel(),
child: FeastWineManageEditPage(wineSunModel: wineSunModel));
}
//
// bool onlyShow = FluroConvertUtils.string2bool(params["onlyShow"].first);
return ChangeNotifierProvider<FeastModel>(
create: (_) => FeastModel(), child: FeastWineManageEditPage());
... ... @@ -1519,7 +1531,6 @@ var feastOthersetManageEditPageHandle = new Handler(
create: (_) => FeastModel(), child: FeastOthersetManageEditPage());
});
///宴会---定金管理
var feastDepositManagePageHandle = new Handler(
handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
... ... @@ -1539,10 +1550,3 @@ var feastDepositTypePageHandle = new Handler(
return ChangeNotifierProvider<FeastModel>(
create: (_) => FeastModel(), child: FeastDepositTypePage());
});
... ...
... ... @@ -659,14 +659,14 @@ packages:
name: json_annotation
url: "https://pub.flutter-io.cn"
source: hosted
version: "4.5.0"
version: "4.6.0"
json_serializable:
dependency: "direct dev"
description:
name: json_serializable
url: "https://pub.flutter-io.cn"
source: hosted
version: "6.2.0"
version: "6.3.1"
logging:
dependency: transitive
description:
... ...
... ... @@ -28,7 +28,7 @@ dependencies:
# cupertino_icons: ^0.1.2
cupertino_icons: ^1.0.4
json_annotation: ^4.5.0
json_annotation: ^4.6.0
# 状态管理
provider: ^6.0.3
# provider: ^4.0.4
... ...