Commit 3f14062887c9b177c51f84d5a4c54ef9f66b8889

Authored by wdn127929
1 parent f764b6ce

菜品向上向下移动

... ... @@ -203,7 +203,28 @@ class MenuSunModel {
}
//图片移动数组
List<RadioModel> get moveList {
List<RadioModel> moveList(int length) {
if (length == 1) {
return [];
}
if (indexNew == 0) {
//没有向上移动选项
RadioModel radioModel2 = RadioModel();
radioModel2.title = '菜品向下移动一个';
radioModel2.code = '2';
radioModel2.select = false;
return [radioModel2];
} else if (indexNew == length - 1) {
//最后一个没有向下移动选项
RadioModel radioModel1 = RadioModel();
radioModel1.title = '菜品向上移动一个';
radioModel1.code = '1';
radioModel1.select = false;
return [radioModel1];
}
RadioModel radioModel1 = RadioModel();
radioModel1.title = '菜品向上移动一个';
radioModel1.code = '1';
... ... @@ -608,7 +629,7 @@ class MenuSunModel {
amounttemp += v.amount;
amountHasOrderList.add(v);
}
amount = amounttemp * (json['out_all_num']??1);
amount = amounttemp * (json['out_all_num'] ?? 1);
});
// }
... ...
... ... @@ -441,4 +441,9 @@ class HttpUrl {
static const String get_pay_message_by_id =
"?service=App.Activity.GetPayMessageByID"; // 充值成功通知消息获取详情
static const String set_cook_book_order =
"?service=App.Cookbook.SetCookbookOrder"; // App设置菜品移动
}
... ...
... ... @@ -173,6 +173,23 @@ class _MenuManagePageState extends State<MenuManagePage> {
}
}
/// App设置菜品移动
_setCookbookOrder(String id, String upid) async {
Map<String, String> params = {
// "sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid,
"id": id,
'upid': upid
};
print(params);
bool sucess = await menuManageProvider.setCookbookOrder(context, params,
showLoading: true);
if (sucess) {
Utils.showToast('修改成功!');
//刷新列表数据
_getCookbookByClass(showLoading: true);
}
}
///处理数据
_handleData({isMove = false}) {
if (menuManageProvider.menuModel != null) {
... ... @@ -699,8 +716,13 @@ class _MenuManagePageState extends State<MenuManagePage> {
}
_onLongPress(MenuSunModel model, int indexOut) async {
List<MenuSunModel> cookbooklist =
menuManageProvider.menuModel[indexOut].cookbooklist;
Map object = await DialogUtil.menuMagageAlertDialog(
context, model.nameTypeList, model.imageTypeList, model.moveList);
context,
model.nameTypeList,
model.imageTypeList,
model.moveList(cookbooklist.length));
if (object != null) {
print(object);
if (object['name_type'] != null) {
... ... @@ -720,25 +742,37 @@ class _MenuManagePageState extends State<MenuManagePage> {
if (object['move'] == '1' && model.indexNew != 0) {
//向上移动
var child = menuManageProvider.menuModel[indexOut].cookbooklist
.removeAt(model.indexNew);
// 当前菜品id
// model.id
//上一个id
// cookbooklist[model.indexNew-1].id
_setCookbookOrder(model.id, cookbooklist[model.indexNew - 1].id);
menuManageProvider.menuModel[indexOut].cookbooklist
.insert(model.indexNew - 1, child);
// var child = menuManageProvider.menuModel[indexOut].cookbooklist
// .removeAt(model.indexNew);
_handleData(isMove: true);
// menuManageProvider.menuModel[indexOut].cookbooklist
// .insert(model.indexNew - 1, child);
// _handleData(isMove: true);
} else if (object['move'] == '2' &&
model.indexNew !=
menuManageProvider.menuModel[indexOut].cookbooklist.length -
1) {
//向下移动
var child = menuManageProvider.menuModel[indexOut].cookbooklist
.removeAt(model.indexNew);
// 当前菜品id
// model.id
//下一个id
// cookbooklist[model.indexNew+1].id
_setCookbookOrder(model.id, cookbooklist[model.indexNew + 1].id);
// var child = menuManageProvider.menuModel[indexOut].cookbooklist
// .removeAt(model.indexNew);
menuManageProvider.menuModel[indexOut].cookbooklist
.insert(model.indexNew + 1, child);
// menuManageProvider.menuModel[indexOut].cookbooklist
// .insert(model.indexNew + 1, child);
_handleData(isMove: true);
// _handleData(isMove: true);
}
} else {
_handleData();
... ...
... ... @@ -361,6 +361,28 @@ class MenuManageProvider extends ChangeNotifier {
return false;
}
/// App设置菜品移动
Future<bool> setCookbookOrder(
BuildContext context, Map<String, String> params,
{showLoading = false}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.set_cook_book_order,
data: params, showLoading: showLoading)
.catchError((error) {
print(error.toString());
Utils.showToast('移动失败,请重试!');
});
if (baseResp != null && baseResp.code == Constant.status_success) {
if (baseResp.data == true) {
return true;
}
} else {
Utils.showToast(baseResp.msg ?? "");
}
return false;
}
///修改菜品
Future<bool> setCookbookById(BuildContext context, Map<String, String> params,
{showLoading = false}) async {
... ...
... ... @@ -374,9 +374,10 @@ class DialogUtil {
// fontSize: ScreenUtil().setSp(fontSize),
// color: MyColours.color_515151)),
// ),
MyDivider(
ScreenUtil().setWidth(280 * 2), ScreenUtil().setWidth(2),
color: MyColours.color_efefef),
if (moveList.length > 0)
MyDivider(ScreenUtil().setWidth(280 * 2),
ScreenUtil().setWidth(2),
color: MyColours.color_efefef),
ListView.builder(
itemCount: moveList.length,
shrinkWrap: true,
... ...