my_areas_manage_page.dart
10 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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/provider/my_table_manage_home_model.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/dialog_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/system_app_bar.dart';
import 'package:provider/provider.dart';
import '../../../provider/table_manager_model.dart';
/*
**** 区域管理
*/
class MyAreaManagePage extends StatefulWidget {
MyAreaManagePage({Key key}) : super(key: key);
@override
_MyAreaManagePageState createState() => _MyAreaManagePageState();
}
class _MyAreaManagePageState extends State<MyAreaManagePage> {
MyTableManageHomeModel tableManagerModel;
@override
void initState() {
// TODO: implement initState
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
tableManagerModel.initTime(context);
// EventBus().on("refresh_tablemanager", (arg) {
// //订座-完成预订 刷新管理桌位
// tableManagerModel.getReserveList(context,
// needLoading: false, needKeep: true);
// print(tableManagerModel);
// });
// EventBus().on("refresh_tablePhoto", (arg) {
// ///刷新图片显示
// _refreshTablePhoto();
// });
});
}
@override
Widget build(BuildContext context) {
tableManagerModel =
Provider.of<MyTableManageHomeModel>(context, listen: true);
return Scaffold(
resizeToAvoidBottomInset: false, //输入框抵住键盘
appBar: SystemAppBar(
"区域管理",
showLeading: true,
onTap: () {
Navigator.pop(context);
},
),
backgroundColor: MyColours.color_ffffff,
body: SafeArea(child:
Consumer<MyTableManageHomeModel>(builder: (context, model, child) {
return model.pageState != PageState.Success
? ExceptionPage(
pageState: model.pageState,
callback: () {
// if (tableManagerModel.tableOuterList.isEmpty) {
// tableManagerModel.getTableList(context);
// } else {
// tableManagerModel.getReserveList(context);
// }
},
emptyMsg: "暂时没有区域数据哦",
emptyImg: "table_manage_empty",
showMsg: "加载中,请稍后...",
)
: ListView.builder(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(32),
vertical: ScreenUtil().setWidth(54)),
itemCount: tableManagerModel.areas.length,
shrinkWrap: true,
// scrollDirection: Axis.horizontal,
itemBuilder: (BuildContext contxt, int index) {
return Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(16),
vertical: ScreenUtil().setWidth(30)),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
width: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7))),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: InkWell(
onTap: () async {
//修改区域弹框
await DialogUtil
.openTableManageCreateAreaDialog(
context,
title: '修改区域',
content: tableManagerModel
.areas[index]
.name, onTap: (value) async {
print(value);
//添加区域
bool success = await tableManagerModel
.setTableRegionById(
context,
value,
tableManagerModel
.areas[index].rid);
print(success);
if (success) {
Utils.showToast('修改成功!');
tableManagerModel.currentArea = value;
TableManagerModel tableManagerModel1 =
Provider.of<TableManagerModel>(
context,
listen: false);
tableManagerModel1.getTableList(
context,
needLoading: false,
);
await tableManagerModel
.refreshTable(context);
EventBus().emit("refresh_table_area");
// await tableManagerModel
// .getTableList(context,
// needLoading: false);
// tableManagerModel.initData();
// setState(() {
// updateMenu();
// });
// _scrollToIndex(widget
// .tableManagerModel
// .areas
// .length);
}
});
},
child: Text(
tableManagerModel.areas[index].name,
style: TextStyle(
color: MyColours.color_000000,
fontSize: ScreenUtil().setSp(32))))),
InkWell(
onTap: () {
DialogUtil.cupertinoAlertDialog(context,
title: "",
content: "是否确定删除该区域",
lTitle: "取消",
rTitle: "确认删除",
isBold: true,
isBoldContent: true,
rColor: MyColours.color_E34D59,
lCallback: () {
print("取消");
}, rCallback: () async {
bool success =
await tableManagerModel.delTableRegion(
context,
tableManagerModel.areas[index].rid);
print(success);
if (success) {
Utils.showToast('删除成功!');
// TableOuter tableOuter = TableOuter();
// tableOuter.name = value;
// tableOuter.list = [];
// tableManagerModel.tableOuterList.add(tableOuter);
// tableManagerModel.initData();
// Timer(
// Duration(milliseconds: 500),
// () => _areaController.jumpTo(
// _areaController.position.maxScrollExtent));
// await tableManagerModel
// .getTableList(context);
// await tableManagerModel
// .initData();
TableManagerModel tableManagerModel =
Provider.of<TableManagerModel>(context,
listen: false);
tableManagerModel.getTableList(
context,
needLoading: false,
);
await tableManagerModel
.refreshTable(context);
EventBus().emit("refresh_table_area");
}
});
},
child: Text('删除',
style: TextStyle(
color: MyColours.color_438E93,
decoration: TextDecoration.underline,
fontSize: ScreenUtil().setSp(32))))
],
),
);
});
})));
}
}