|
1
|
-
|
|
|
|
2
|
import 'package:flutter/material.dart';
|
1
|
import 'package:flutter/material.dart';
|
|
3
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
2
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
4
|
import 'package:one_key/constant/state.dart';
|
3
|
import 'package:one_key/constant/state.dart';
|
|
@@ -55,14 +54,21 @@ class _MenuCategoryPageState extends State<MenuCategoryPage> { |
|
@@ -55,14 +54,21 @@ class _MenuCategoryPageState extends State<MenuCategoryPage> { |
|
55
|
}
|
54
|
}
|
|
56
|
|
55
|
|
|
57
|
///添加菜品分类
|
56
|
///添加菜品分类
|
|
58
|
- _setCookbookClassById(String? name, String? id,
|
57
|
+ _setCookbookClassById(String? name, String? id, String? order,
|
|
59
|
{bool showLoading = true}) async {
|
58
|
{bool showLoading = true}) async {
|
|
60
|
Map<String, String?> params = {
|
59
|
Map<String, String?> params = {
|
|
61
|
"sellerid": Provider.of<UserModel>(context, listen: false).user!.sellerid,
|
60
|
"sellerid": Provider.of<UserModel>(context, listen: false).user!.sellerid,
|
|
62
|
'id': id,
|
61
|
'id': id,
|
|
63
|
- 'class_name': name
|
62
|
+ // 'class_name': name
|
|
64
|
};
|
63
|
};
|
|
65
|
|
64
|
|
|
|
|
65
|
+ if (name != null) {
|
|
|
|
66
|
+ params['class_name'] = name;
|
|
|
|
67
|
+ }
|
|
|
|
68
|
+ if (order != null) {
|
|
|
|
69
|
+ params['order'] = order;
|
|
|
|
70
|
+ }
|
|
|
|
71
|
+
|
|
66
|
bool sucess = await menuManageProvider.setCookbookClassById(context, params,
|
72
|
bool sucess = await menuManageProvider.setCookbookClassById(context, params,
|
|
67
|
showLoading: showLoading);
|
73
|
showLoading: showLoading);
|
|
68
|
if (sucess) {
|
74
|
if (sucess) {
|
|
@@ -122,7 +128,7 @@ class _MenuCategoryPageState extends State<MenuCategoryPage> { |
|
@@ -122,7 +128,7 @@ class _MenuCategoryPageState extends State<MenuCategoryPage> { |
|
122
|
child: Text(
|
128
|
child: Text(
|
|
123
|
type == TableItemType.TableItemTypeHeader
|
129
|
type == TableItemType.TableItemTypeHeader
|
|
124
|
? '序号'
|
130
|
? '序号'
|
|
125
|
- : '${index + 1}',
|
131
|
+ : '${menuManageProvider.categorySunModel!.indexOf(model) + 1}',
|
|
126
|
textAlign: TextAlign.center,
|
132
|
textAlign: TextAlign.center,
|
|
127
|
style: TextStyle(
|
133
|
style: TextStyle(
|
|
128
|
fontSize: ScreenUtil().setSp(28),
|
134
|
fontSize: ScreenUtil().setSp(28),
|
|
@@ -217,42 +223,76 @@ class _MenuCategoryPageState extends State<MenuCategoryPage> { |
|
@@ -217,42 +223,76 @@ class _MenuCategoryPageState extends State<MenuCategoryPage> { |
|
217
|
_tableItem(model.categorySunModel![0], 0,
|
223
|
_tableItem(model.categorySunModel![0], 0,
|
|
218
|
TableItemType.TableItemTypeHeader, (index) {}, (index) {}),
|
224
|
TableItemType.TableItemTypeHeader, (index) {}, (index) {}),
|
|
219
|
Expanded(
|
225
|
Expanded(
|
|
220
|
- child: ListView.builder(
|
|
|
|
221
|
- itemCount: model.categorySunModel!.length,
|
|
|
|
222
|
- itemBuilder: (BuildContext context, int index) {
|
|
|
|
223
|
- CookbookCategorySunModel sunModel =
|
|
|
|
224
|
- model.categorySunModel![index];
|
|
|
|
225
|
- return Column(children: [
|
|
|
|
226
|
- _tableItem(sunModel, index,
|
|
|
|
227
|
- TableItemType.TableItemTypeBody, (index) {
|
|
|
|
228
|
- if (sunModel.className != '10道必点菜') {
|
|
|
|
229
|
- DialogUtil.textfeildAlertDialog(context,
|
|
|
|
230
|
- title: '修改分类',
|
|
|
|
231
|
- text: sunModel.className!,
|
|
|
|
232
|
- hintText: '输入分类名称',
|
|
|
|
233
|
- lenghtLimit: true,
|
|
|
|
234
|
- toast: '请输入分类名称', rCallback: (name) {
|
|
|
|
235
|
- _setCookbookClassById(name as String?, sunModel.id,
|
|
|
|
236
|
- showLoading: true);
|
|
|
|
237
|
- });
|
|
|
|
238
|
- }
|
|
|
|
239
|
- }, (index) {
|
|
|
|
240
|
- if (sunModel.className != '10道必点菜') {
|
|
|
|
241
|
- DialogUtil.cupertinoAlertDialog(context,
|
|
|
|
242
|
- title: '',
|
|
|
|
243
|
- content: '删除后,该分类下所有菜品都将删除', rCallback: () {
|
|
|
|
244
|
- _delCookbookById(sunModel.id);
|
|
|
|
245
|
- });
|
|
|
|
246
|
- }
|
|
|
|
247
|
- }),
|
|
|
|
248
|
- Padding(
|
|
|
|
249
|
- padding: EdgeInsets.symmetric(
|
|
|
|
250
|
- horizontal: ScreenUtil().setWidth(40)),
|
|
|
|
251
|
- child: MyDivider(
|
|
|
|
252
|
- double.infinity, ScreenUtil().setWidth(2),
|
|
|
|
253
|
- color: MyColours.color_f5f5f5))
|
|
|
|
254
|
- ]);
|
|
|
|
255
|
- })),
|
226
|
+ child: ReorderableListView(
|
|
|
|
227
|
+ onReorder: (int oldIndex, int newIndex) async {
|
|
|
|
228
|
+ if (oldIndex < newIndex) {
|
|
|
|
229
|
+ newIndex -= 1;
|
|
|
|
230
|
+ }
|
|
|
|
231
|
+
|
|
|
|
232
|
+ CookbookCategorySunModel childold =
|
|
|
|
233
|
+ model.categorySunModel![oldIndex];
|
|
|
|
234
|
+ // Map<String, String?> params = {
|
|
|
|
235
|
+ // 'sid': Provider.of<UserModel>(context, listen: false)
|
|
|
|
236
|
+ // .user!
|
|
|
|
237
|
+ // .sellerid,
|
|
|
|
238
|
+ // 'regionid': childold.id,
|
|
|
|
239
|
+ // 'order_o': tableManagerModel.areas[newIndex].orderId,
|
|
|
|
240
|
+ // 'sort': oldIndex < newIndex ? '2' : '1'
|
|
|
|
241
|
+ // };
|
|
|
|
242
|
+ // var child = tableManagerModel.areas.removeAt(oldIndex);
|
|
|
|
243
|
+ // tableManagerModel.areas.insert(newIndex, child);
|
|
|
|
244
|
+ // setState(() {});
|
|
|
|
245
|
+
|
|
|
|
246
|
+ _setCookbookClassById(null, childold.id,
|
|
|
|
247
|
+ model.categorySunModel![newIndex].order);
|
|
|
|
248
|
+ },
|
|
|
|
249
|
+ children: <Widget>[
|
|
|
|
250
|
+ for (CookbookCategorySunModel sunModel
|
|
|
|
251
|
+ in model.categorySunModel!)
|
|
|
|
252
|
+ // Container(
|
|
|
|
253
|
+ // ListView.builder(
|
|
|
|
254
|
+ // itemCount: model.categorySunModel!.length,
|
|
|
|
255
|
+ // itemBuilder: (BuildContext context, int index) {
|
|
|
|
256
|
+ // CookbookCategorySunModel sunModel =
|
|
|
|
257
|
+ // model.categorySunModel![index];
|
|
|
|
258
|
+ // return
|
|
|
|
259
|
+ Container(
|
|
|
|
260
|
+ key: ValueKey(sunModel),
|
|
|
|
261
|
+ child: Column(children: [
|
|
|
|
262
|
+ _tableItem(
|
|
|
|
263
|
+ sunModel,
|
|
|
|
264
|
+ int.parse(sunModel.order ?? ''),
|
|
|
|
265
|
+ TableItemType.TableItemTypeBody, (index) {
|
|
|
|
266
|
+ if (sunModel.className != '10道必点菜') {
|
|
|
|
267
|
+ DialogUtil.textfeildAlertDialog(context,
|
|
|
|
268
|
+ title: '修改分类',
|
|
|
|
269
|
+ text: sunModel.className!,
|
|
|
|
270
|
+ hintText: '输入分类名称',
|
|
|
|
271
|
+ lenghtLimit: true,
|
|
|
|
272
|
+ toast: '请输入分类名称', rCallback: (name) {
|
|
|
|
273
|
+ _setCookbookClassById(
|
|
|
|
274
|
+ name as String?, sunModel.id, null,
|
|
|
|
275
|
+ showLoading: true);
|
|
|
|
276
|
+ });
|
|
|
|
277
|
+ }
|
|
|
|
278
|
+ }, (index) {
|
|
|
|
279
|
+ if (sunModel.className != '10道必点菜') {
|
|
|
|
280
|
+ DialogUtil.cupertinoAlertDialog(context,
|
|
|
|
281
|
+ title: '', content: '删除后,该分类下所有菜品都将删除',
|
|
|
|
282
|
+ rCallback: () {
|
|
|
|
283
|
+ _delCookbookById(sunModel.id);
|
|
|
|
284
|
+ });
|
|
|
|
285
|
+ }
|
|
|
|
286
|
+ }),
|
|
|
|
287
|
+ Padding(
|
|
|
|
288
|
+ padding: EdgeInsets.symmetric(
|
|
|
|
289
|
+ horizontal: ScreenUtil().setWidth(40)),
|
|
|
|
290
|
+ child: MyDivider(
|
|
|
|
291
|
+ double.infinity, ScreenUtil().setWidth(2),
|
|
|
|
292
|
+ color: MyColours.color_f5f5f5))
|
|
|
|
293
|
+ ]))
|
|
|
|
294
|
+ // })
|
|
|
|
295
|
+ ]))
|
|
256
|
],
|
296
|
],
|
|
257
|
);
|
297
|
);
|
|
258
|
}
|
298
|
}
|