|
...
|
...
|
@@ -15,6 +15,12 @@ import 'package:one_key/widgets/page_exception.dart'; |
|
|
|
import 'package:one_key/widgets/system_app_bar.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
/***
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* 分类管理
|
|
|
|
*/
|
|
|
|
|
|
|
|
class MenuCategoryPage extends StatefulWidget {
|
|
|
|
MenuCategoryPage({Key key}) : super(key: key);
|
|
|
|
|
|
...
|
...
|
@@ -47,6 +53,23 @@ class _MenuCategoryPageState extends State<MenuCategoryPage> { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///添加菜品分类
|
|
|
|
_setCookbookClassById(String name, String id,
|
|
|
|
{bool showLoading = true}) async {
|
|
|
|
Map<String, String> params = {
|
|
|
|
"sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid,
|
|
|
|
'id': id,
|
|
|
|
'class_name': name
|
|
|
|
};
|
|
|
|
|
|
|
|
bool sucess = await menuManageProvider.setCookbookClassById(context, params,
|
|
|
|
showLoading: showLoading);
|
|
|
|
if (sucess) {
|
|
|
|
EventBus().emit('menu_manage_page');
|
|
|
|
_getCookbookBySellerId(showLoading: false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///获取分类数据
|
|
|
|
_getCookbookBySellerId({bool showLoading = true}) async {
|
|
|
|
Map<String, String> params = {
|
|
...
|
...
|
@@ -73,69 +96,77 @@ class _MenuCategoryPageState extends State<MenuCategoryPage> { |
|
|
|
}
|
|
|
|
|
|
|
|
///表头
|
|
|
|
Widget _tableItem(CookbookCategorySunModel model, int index,
|
|
|
|
TableItemType type, IntCallback callback) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: () {
|
|
|
|
callback(index);
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.only(left: ScreenUtil().setWidth(30)),
|
|
|
|
height: ScreenUtil().setWidth(130),
|
|
|
|
color: type == TableItemType.TableItemTypeHeader
|
|
|
|
? Color.fromRGBO(235, 234, 239, 1)
|
|
|
|
: MyColours.color_fefefe,
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
width: ScreenUtil().setWidth(85 * 2),
|
|
|
|
height: double.infinity,
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
// HEmptyView(20),
|
|
|
|
Expanded(
|
|
|
|
child: Text(
|
|
|
|
type == TableItemType.TableItemTypeHeader
|
|
|
|
? '序号'
|
|
|
|
: '${index + 1}',
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setSp(28),
|
|
|
|
color: MyColours.color_333333),
|
|
|
|
)),
|
|
|
|
HEmptyView(30),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Container(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
width: ScreenUtil().setWidth(87 * 2),
|
|
|
|
height: double.infinity,
|
|
|
|
Widget _tableItem(
|
|
|
|
CookbookCategorySunModel model,
|
|
|
|
int index,
|
|
|
|
TableItemType type,
|
|
|
|
IntCallback callback,
|
|
|
|
IntCallback callbackDel,
|
|
|
|
) {
|
|
|
|
return Container(
|
|
|
|
padding: EdgeInsets.only(left: ScreenUtil().setWidth(30)),
|
|
|
|
height: ScreenUtil().setWidth(130),
|
|
|
|
color: type == TableItemType.TableItemTypeHeader
|
|
|
|
? Color.fromRGBO(235, 234, 239, 1)
|
|
|
|
: MyColours.color_fefefe,
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
width: ScreenUtil().setWidth(85 * 2),
|
|
|
|
height: double.infinity,
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
// HEmptyView(20),
|
|
|
|
Expanded(
|
|
|
|
child: Text(
|
|
|
|
type == TableItemType.TableItemTypeHeader
|
|
|
|
? '分类名称'
|
|
|
|
: model.className,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setSp(28),
|
|
|
|
color: MyColours.color_333333),
|
|
|
|
))),
|
|
|
|
Container(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
width: ScreenUtil().setWidth(116 * 2),
|
|
|
|
height: double.infinity,
|
|
|
|
child: Text(
|
|
|
|
type == TableItemType.TableItemTypeHeader
|
|
|
|
? '操作'
|
|
|
|
: model.className == '10道必点菜'
|
|
|
|
? ''
|
|
|
|
: '删除',
|
|
|
|
? '序号'
|
|
|
|
: '${index + 1}',
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setSp(28),
|
|
|
|
color: MyColours.color_333333),
|
|
|
|
)),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
HEmptyView(30),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: InkWell(
|
|
|
|
onTap: () {
|
|
|
|
callback(index);
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
width: ScreenUtil().setWidth(87 * 2),
|
|
|
|
height: double.infinity,
|
|
|
|
child: Text(
|
|
|
|
type == TableItemType.TableItemTypeHeader
|
|
|
|
? '分类名称'
|
|
|
|
: model.className,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setSp(28),
|
|
|
|
color: MyColours.color_333333),
|
|
|
|
)))),
|
|
|
|
InkWell(
|
|
|
|
onTap: () {
|
|
|
|
callbackDel(index);
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
width: ScreenUtil().setWidth(116 * 2),
|
|
|
|
height: double.infinity,
|
|
|
|
child: Text(
|
|
|
|
type == TableItemType.TableItemTypeHeader
|
|
|
|
? '操作'
|
|
|
|
: model.className == '10道必点菜'
|
|
|
|
? ''
|
|
|
|
: '删除',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setSp(28),
|
|
|
|
color: MyColours.color_333333),
|
|
|
|
))),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
...
|
...
|
@@ -181,21 +212,33 @@ class _MenuCategoryPageState extends State<MenuCategoryPage> { |
|
|
|
children: [
|
|
|
|
//表头
|
|
|
|
_tableItem(model.categorySunModel[0], 0,
|
|
|
|
TableItemType.TableItemTypeHeader, (index) {}),
|
|
|
|
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(model.categorySunModel[index], index,
|
|
|
|
_tableItem(sunModel, index,
|
|
|
|
TableItemType.TableItemTypeBody, (index) {
|
|
|
|
if (model.categorySunModel[index].className !=
|
|
|
|
'10道必点菜') {
|
|
|
|
if (sunModel.className != '10道必点菜') {
|
|
|
|
DialogUtil.textfeildAlertDialog(context,
|
|
|
|
title: '修改分类',
|
|
|
|
text: sunModel.className,
|
|
|
|
hintText: '输入分类名称',
|
|
|
|
lenghtLimit: true,
|
|
|
|
toast: '请输入分类名称', rCallback: (name) {
|
|
|
|
_setCookbookClassById(name, sunModel.id,
|
|
|
|
showLoading: true);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}, (index) {
|
|
|
|
if (sunModel.className != '10道必点菜') {
|
|
|
|
DialogUtil.cupertinoAlertDialog(context,
|
|
|
|
title: '',
|
|
|
|
content: '删除后,该分类下所有菜品都将删除', rCallback: () {
|
|
|
|
_delCookbookById(
|
|
|
|
model.categorySunModel[index].id);
|
|
|
|
_delCookbookById(sunModel.id);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
...
|
...
|
|