plan_dish_sun_page.dart
7.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/personnel_manage_model.dart';
import 'package:one_key/models/plan_cook_list_model.dart';
import 'package:one_key/pages/coupon/coupon_item_f.dart';
import 'package:one_key/pages/my/plan_dish/plan_dish_item.dart';
import 'package:one_key/provider/coupon_provider.dart';
import 'package:one_key/provider/personnel_provider.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/utils/event_bus.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/page_exception.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
import '../../../provider/plan_dish_provider.dart';
import '../../../utils/dialog_util.dart';
class PlanDishSunPage extends StatefulWidget {
final int index;
final List<SunListPlan> data;
final PageState pageState;
PlanDishSunPage({Key key, this.index, this.data, this.pageState})
: super(key: key);
@override
_PlanDishSunPageState createState() => _PlanDishSunPageState();
}
class _PlanDishSunPageState extends State<PlanDishSunPage> {
EasyRefreshController _controller = EasyRefreshController();
List<PersonnelManageSunModel> authUserLists = [];
PlanDishProvider planDishProvider;
@override
void initState() {
// TODO: implement initState
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
// if (widget.index == 0) {
// planDishProvider.pageStateHome = PageState.Loading;
// } else if (widget.index == 1) {
// planDishProvider.pageStateStore = PageState.Loading;
// } else if (widget.index == 2) {
// planDishProvider.pageStateMine = PageState.Loading;
// }
// planDishProvider.notifyListeners();
// _getPlanCookList(widget.index, isShowLoading: false);
// bus.on("refresh_coupon_list_f", (arg) {
// _couponNetworkData(widget.index);
// });
});
}
delPlanCook(String id) async {
Map<String, String> params = {"id": id};
bool success =
await planDishProvider.delPlanCook(context, params, showLoading: true);
if (success) {
// _getPlanCookList(widget.index, isShowLoading: true);
bus.emit('refresh_dish_plan_home_list');
}
}
///修改活动信息
// _setCustomerActivity(int index) async {
// Map<String, String> params = {
// "id": couponProvider.couponList[index].id,
// "status": couponProvider.couponList[index].isOpenBool ? '1' : '0',
// };
// bool isSuccess = await couponProvider.setCustomerActivity(context, params,
// isShowLoading: false);
// print(isSuccess);
// _couponNetworkData(widget.index, isShowLoading: false);
// // if (isSuccess) {
// // couponProvider.notifyListeners();
// // } else {
// // couponProvider.couponList[index].isOpenBool =
// // !couponProvider.couponList[index].isOpenBool;
// // couponProvider.notifyListeners();
// // }
// }
@override
Widget build(BuildContext context) {
planDishProvider = Provider.of<PlanDishProvider>(context, listen: true);
return Container(
child: Consumer<CouponProvider>(builder: (context, model, _) {
if (widget.pageState != PageState.Success) {
return ExceptionPage(
pageState: widget.pageState,
callback: () {
// offset = 0;
// getMessage(showLoading: true);
// _couponNetworkData(widget.index);
},
emptyMsg: "暂时没有列表信息哦,",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
// needEmpty: true,
);
} else {
return EasyRefresh.custom(
controller: _controller,
shrinkWrap: true,
slivers: [
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return InkWell(
onTap: () async {
// UserModel userModel =
// Provider.of<UserModel>(context, listen: false);
bool canedit = widget.data[index].type == '2' ||
Utils.getAuthority(context, '编辑排菜');
bool needRefresh =
await NavigatorUtil.goPlanDishEditPage(context,
isEdit: true,
isMine: widget.data[index].type == '2'
? true
: false,
sunList: widget.data[index],
onlyShow: !canedit);
},
child: PlanDishItem(
// from: 'quan',
sunList: widget.data[index],
// showBtn: true,
onPressedDel: () {
//弹框确认是否删除
DialogUtil.cupertinoAlertDialog(context,
title: "",
content: "确定要将该排菜删除吗?删除后将无法再次使用该排菜。",
rTitle: "确定", rCallback: () {
// Navigator.pop(context);
delPlanCook(widget.data[index].id);
});
},
onPressedReUse: () async {
bool needRefresh =
await NavigatorUtil.goPlanDishEditPage(context,
isEdit: false, sunList: widget.data[index]);
},
));
}, childCount: widget.data.length),
),
// SliverList(
// delegate: SliverChildBuilderDelegate(
// (BuildContext context, int index) {
// return Column(
// children: [
// InkWell(
// onTap: () {
// NavigatorUtil.goCouponHistoryPage(context);
// },
// child: RichText(
// text: TextSpan(
// style: TextStyle(
// fontSize: ScreenUtil().setSp(28),
// ),
// children: [
// TextSpan(
// text: '没有更多了,',
// style: TextStyle(
// color: MyColours.color_000000)),
// TextSpan(
// text: '查看过期优惠券',
// style: TextStyle(
// color: MyColours.color_438E93)),
// ]))),
// VEmptyView(80)
// ],
// );
// }, childCount: 1),
// )
],
// onRefresh: () async {
// // offset = 0;
// // getMessage(showLoading: false);
// },
// onLoad: () async {
// // offset++;
// // getMessage(showLoading: false);
// },
);
}
}),
);
}
}