|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:one_key/constant/state.dart';
|
|
...
|
...
|
@@ -55,14 +54,21 @@ class _MenuCategoryPageState extends State<MenuCategoryPage> { |
|
|
|
}
|
|
|
|
|
|
|
|
///添加菜品分类
|
|
|
|
_setCookbookClassById(String? name, String? id,
|
|
|
|
_setCookbookClassById(String? name, String? id, String? order,
|
|
|
|
{bool showLoading = true}) async {
|
|
|
|
Map<String, String?> params = {
|
|
|
|
"sellerid": Provider.of<UserModel>(context, listen: false).user!.sellerid,
|
|
|
|
'id': id,
|
|
|
|
'class_name': name
|
|
|
|
// 'class_name': name
|
|
|
|
};
|
|
|
|
|
|
|
|
if (name != null) {
|
|
|
|
params['class_name'] = name;
|
|
|
|
}
|
|
|
|
if (order != null) {
|
|
|
|
params['order'] = order;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool sucess = await menuManageProvider.setCookbookClassById(context, params,
|
|
|
|
showLoading: showLoading);
|
|
|
|
if (sucess) {
|
|
...
|
...
|
@@ -122,7 +128,7 @@ class _MenuCategoryPageState extends State<MenuCategoryPage> { |
|
|
|
child: Text(
|
|
|
|
type == TableItemType.TableItemTypeHeader
|
|
|
|
? '序号'
|
|
|
|
: '${index + 1}',
|
|
|
|
: '${menuManageProvider.categorySunModel!.indexOf(model) + 1}',
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setSp(28),
|
|
...
|
...
|
@@ -217,42 +223,76 @@ class _MenuCategoryPageState extends State<MenuCategoryPage> { |
|
|
|
_tableItem(model.categorySunModel![0], 0,
|
|
|
|
TableItemType.TableItemTypeHeader, (index) {}, (index) {}),
|
|
|
|
Expanded(
|
|
|
|
child: ListView.builder(
|
|
|
|
itemCount: model.categorySunModel!.length,
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
CookbookCategorySunModel sunModel =
|
|
|
|
model.categorySunModel![index];
|
|
|
|
return Column(children: [
|
|
|
|
_tableItem(sunModel, index,
|
|
|
|
TableItemType.TableItemTypeBody, (index) {
|
|
|
|
if (sunModel.className != '10道必点菜') {
|
|
|
|
DialogUtil.textfeildAlertDialog(context,
|
|
|
|
title: '修改分类',
|
|
|
|
text: sunModel.className!,
|
|
|
|
hintText: '输入分类名称',
|
|
|
|
lenghtLimit: true,
|
|
|
|
toast: '请输入分类名称', rCallback: (name) {
|
|
|
|
_setCookbookClassById(name as String?, sunModel.id,
|
|
|
|
showLoading: true);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}, (index) {
|
|
|
|
if (sunModel.className != '10道必点菜') {
|
|
|
|
DialogUtil.cupertinoAlertDialog(context,
|
|
|
|
title: '',
|
|
|
|
content: '删除后,该分类下所有菜品都将删除', rCallback: () {
|
|
|
|
_delCookbookById(sunModel.id);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: ScreenUtil().setWidth(40)),
|
|
|
|
child: MyDivider(
|
|
|
|
double.infinity, ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_f5f5f5))
|
|
|
|
]);
|
|
|
|
})),
|
|
|
|
child: ReorderableListView(
|
|
|
|
onReorder: (int oldIndex, int newIndex) async {
|
|
|
|
if (oldIndex < newIndex) {
|
|
|
|
newIndex -= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
CookbookCategorySunModel childold =
|
|
|
|
model.categorySunModel![oldIndex];
|
|
|
|
// Map<String, String?> params = {
|
|
|
|
// 'sid': Provider.of<UserModel>(context, listen: false)
|
|
|
|
// .user!
|
|
|
|
// .sellerid,
|
|
|
|
// 'regionid': childold.id,
|
|
|
|
// 'order_o': tableManagerModel.areas[newIndex].orderId,
|
|
|
|
// 'sort': oldIndex < newIndex ? '2' : '1'
|
|
|
|
// };
|
|
|
|
// var child = tableManagerModel.areas.removeAt(oldIndex);
|
|
|
|
// tableManagerModel.areas.insert(newIndex, child);
|
|
|
|
// setState(() {});
|
|
|
|
|
|
|
|
_setCookbookClassById(null, childold.id,
|
|
|
|
model.categorySunModel![newIndex].order);
|
|
|
|
},
|
|
|
|
children: <Widget>[
|
|
|
|
for (CookbookCategorySunModel sunModel
|
|
|
|
in model.categorySunModel!)
|
|
|
|
// Container(
|
|
|
|
// ListView.builder(
|
|
|
|
// itemCount: model.categorySunModel!.length,
|
|
|
|
// itemBuilder: (BuildContext context, int index) {
|
|
|
|
// CookbookCategorySunModel sunModel =
|
|
|
|
// model.categorySunModel![index];
|
|
|
|
// return
|
|
|
|
Container(
|
|
|
|
key: ValueKey(sunModel),
|
|
|
|
child: Column(children: [
|
|
|
|
_tableItem(
|
|
|
|
sunModel,
|
|
|
|
int.parse(sunModel.order ?? ''),
|
|
|
|
TableItemType.TableItemTypeBody, (index) {
|
|
|
|
if (sunModel.className != '10道必点菜') {
|
|
|
|
DialogUtil.textfeildAlertDialog(context,
|
|
|
|
title: '修改分类',
|
|
|
|
text: sunModel.className!,
|
|
|
|
hintText: '输入分类名称',
|
|
|
|
lenghtLimit: true,
|
|
|
|
toast: '请输入分类名称', rCallback: (name) {
|
|
|
|
_setCookbookClassById(
|
|
|
|
name as String?, sunModel.id, null,
|
|
|
|
showLoading: true);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}, (index) {
|
|
|
|
if (sunModel.className != '10道必点菜') {
|
|
|
|
DialogUtil.cupertinoAlertDialog(context,
|
|
|
|
title: '', content: '删除后,该分类下所有菜品都将删除',
|
|
|
|
rCallback: () {
|
|
|
|
_delCookbookById(sunModel.id);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: ScreenUtil().setWidth(40)),
|
|
|
|
child: MyDivider(
|
|
|
|
double.infinity, ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_f5f5f5))
|
|
|
|
]))
|
|
|
|
// })
|
|
|
|
]))
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
...
|
...
|
|