|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:one_key/constant/state.dart';
|
|
|
|
import 'package:one_key/models/get_setmeal_class_model.dart';
|
|
|
|
import 'package:one_key/provider/user_model.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
...
|
...
|
@@ -8,8 +9,12 @@ import '../constant/error.dart'; |
|
|
|
import '../models/classify_model.dart';
|
|
|
|
import '../models/filter_btn_model.dart';
|
|
|
|
import '../models/get_seller_user_by_sellerid_model.dart';
|
|
|
|
import '../models/get_setmeal_class_by_id_model.dart';
|
|
|
|
import '../models/get_staff_model.dart';
|
|
|
|
import '../models/otherset_model.dart';
|
|
|
|
import '../models/personnel_manage_model.dart';
|
|
|
|
import '../models/setmeal_by_id_model.dart';
|
|
|
|
import '../models/setmeal_model.dart';
|
|
|
|
import '../models/wine_model.dart';
|
|
|
|
import '../net/base_resp.dart';
|
|
|
|
import '../net/dio_util.dart';
|
|
...
|
...
|
@@ -32,6 +37,18 @@ class FeastModel extends ChangeNotifier { |
|
|
|
PageState pageStateWine = PageState.Loading; //酒水
|
|
|
|
List<WineSunModel> wineData = [];
|
|
|
|
|
|
|
|
PageState pageStateOther = PageState.Loading; //其他配置
|
|
|
|
List<OthersetSunModel> otherData = [];
|
|
|
|
|
|
|
|
PageState pageStateSetmeal = PageState.Loading; //宴会套餐
|
|
|
|
List<SetMealSunModel> setmealData = [];
|
|
|
|
|
|
|
|
SetMeaByIdSunModel setmealDetail; //套餐详情
|
|
|
|
|
|
|
|
List<GetSetmealClassSunModel> setmealClassData = []; //菜品分类
|
|
|
|
|
|
|
|
GetSetmealClassByIdSunModel setmealClassDetail; //菜品分类详情
|
|
|
|
|
|
|
|
/***
|
|
|
|
*
|
|
|
|
* 宴会员工
|
|
...
|
...
|
@@ -427,4 +444,420 @@ class FeastModel extends ChangeNotifier { |
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 其他配置
|
|
|
|
*/
|
|
|
|
|
|
|
|
///添加其他配置
|
|
|
|
Future<dynamic> setOthersetList(
|
|
|
|
BuildContext context, Map<String, String> params,
|
|
|
|
{isShowLoading = true}) async {
|
|
|
|
BaseResp<dynamic> baseResp = await DioUtil()
|
|
|
|
.request<dynamic>(context, Method.get, HttpUrl.set_other,
|
|
|
|
data: params, showLoading: isShowLoading)
|
|
|
|
.catchError((error) {
|
|
|
|
print(error.toString());
|
|
|
|
if (error is MyError) {}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
if (baseResp.code == Constant.status_success) {
|
|
|
|
// if (baseResp.data == 1) {
|
|
|
|
return true;
|
|
|
|
// } else {
|
|
|
|
// return false;
|
|
|
|
// }
|
|
|
|
} else {
|
|
|
|
if (baseResp != null) {
|
|
|
|
Utils.showToast(baseResp.msg ?? "");
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///获取其他配置
|
|
|
|
Future<bool> getOthersetList(BuildContext context,
|
|
|
|
{isShowLoading = true}) async {
|
|
|
|
Map<String, String> params = {
|
|
|
|
"sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
|
|
|
|
};
|
|
|
|
BaseResp<dynamic> baseResp = await DioUtil()
|
|
|
|
.request<dynamic>(context, Method.get, HttpUrl.get_other,
|
|
|
|
data: params, showLoading: isShowLoading)
|
|
|
|
.catchError((error) {
|
|
|
|
print(error.toString());
|
|
|
|
if (error is MyError) {
|
|
|
|
switch (error.type) {
|
|
|
|
case 1:
|
|
|
|
pageStateOther = PageState.ConnectivityError;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
pageStateOther = PageState.ConnectivityTimeOut;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
pageStateOther = PageState.ConnectivityError;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
notifyListeners();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
OthersetModel otherModel = OthersetModel.fromJson(baseResp.responseData);
|
|
|
|
if (otherModel.ret == Constant.status_success) {
|
|
|
|
otherData = otherModel.data;
|
|
|
|
if (otherData.length == 0) {
|
|
|
|
pageStateOther = PageState.Empty;
|
|
|
|
} else {
|
|
|
|
pageStateOther = PageState.Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
Utils.showToast(baseResp.msg ?? "");
|
|
|
|
pageStateOther = PageState.ConnectivityError;
|
|
|
|
notifyListeners();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///删除其他配置
|
|
|
|
Future<dynamic> delOthersetList(
|
|
|
|
BuildContext context, Map<String, String> params,
|
|
|
|
{isShowLoading = true}) async {
|
|
|
|
BaseResp<dynamic> baseResp = await DioUtil()
|
|
|
|
.request<dynamic>(context, Method.get, HttpUrl.del_other,
|
|
|
|
data: params, showLoading: isShowLoading)
|
|
|
|
.catchError((error) {
|
|
|
|
print(error.toString());
|
|
|
|
if (error is MyError) {}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
if (baseResp.code == Constant.status_success) {
|
|
|
|
// if (baseResp.data == 1) {
|
|
|
|
return true;
|
|
|
|
// } else {
|
|
|
|
// return false;
|
|
|
|
// }
|
|
|
|
} else {
|
|
|
|
if (baseResp != null) {
|
|
|
|
Utils.showToast(baseResp.msg ?? "");
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 宴会套餐
|
|
|
|
*/
|
|
|
|
|
|
|
|
///添加宴会套餐
|
|
|
|
Future<dynamic> setSetmeal(BuildContext context, Map<String, String> params,
|
|
|
|
{isShowLoading = true}) async {
|
|
|
|
BaseResp<dynamic> baseResp = await DioUtil()
|
|
|
|
.request<dynamic>(context, Method.get, HttpUrl.set_setmeal,
|
|
|
|
data: params, showLoading: isShowLoading)
|
|
|
|
.catchError((error) {
|
|
|
|
print(error.toString());
|
|
|
|
if (error is MyError) {}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
if (baseResp.code == Constant.status_success) {
|
|
|
|
// if (baseResp.data == 1) {
|
|
|
|
return true;
|
|
|
|
// } else {
|
|
|
|
// return false;
|
|
|
|
// }
|
|
|
|
} else {
|
|
|
|
if (baseResp != null) {
|
|
|
|
Utils.showToast(baseResp.msg ?? "");
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///获取宴会套餐
|
|
|
|
Future<bool> getSetmeal(BuildContext context, {isShowLoading = true}) async {
|
|
|
|
Map<String, String> params = {
|
|
|
|
"sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
|
|
|
|
};
|
|
|
|
BaseResp<dynamic> baseResp = await DioUtil()
|
|
|
|
.request<dynamic>(context, Method.get, HttpUrl.get_setmeal,
|
|
|
|
data: params, showLoading: isShowLoading)
|
|
|
|
.catchError((error) {
|
|
|
|
print(error.toString());
|
|
|
|
if (error is MyError) {
|
|
|
|
switch (error.type) {
|
|
|
|
case 1:
|
|
|
|
pageStateSetmeal = PageState.ConnectivityError;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
pageStateSetmeal = PageState.ConnectivityTimeOut;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
pageStateSetmeal = PageState.ConnectivityError;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
notifyListeners();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
SetMealModel setmealModel = SetMealModel.fromJson(baseResp.responseData);
|
|
|
|
if (setmealModel.ret == Constant.status_success) {
|
|
|
|
setmealData = setmealModel.data;
|
|
|
|
if (setmealData.length == 0) {
|
|
|
|
pageStateSetmeal = PageState.Empty;
|
|
|
|
} else {
|
|
|
|
pageStateSetmeal = PageState.Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
Utils.showToast(baseResp.msg ?? "");
|
|
|
|
pageStateSetmeal = PageState.ConnectivityError;
|
|
|
|
notifyListeners();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///删除宴会套餐
|
|
|
|
Future<dynamic> delSetmeal(BuildContext context, Map<String, String> params,
|
|
|
|
{isShowLoading = true}) async {
|
|
|
|
BaseResp<dynamic> baseResp = await DioUtil()
|
|
|
|
.request<dynamic>(context, Method.get, HttpUrl.del_setmeal,
|
|
|
|
data: params, showLoading: isShowLoading)
|
|
|
|
.catchError((error) {
|
|
|
|
print(error.toString());
|
|
|
|
if (error is MyError) {}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
if (baseResp.code == Constant.status_success) {
|
|
|
|
// if (baseResp.data == 1) {
|
|
|
|
return true;
|
|
|
|
// } else {
|
|
|
|
// return false;
|
|
|
|
// }
|
|
|
|
} else {
|
|
|
|
if (baseResp != null) {
|
|
|
|
Utils.showToast(baseResp.msg ?? "");
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 根据ID获取宴会套餐
|
|
|
|
Future<bool> getSetmealById(BuildContext context, Map<String, String> params,
|
|
|
|
{isShowLoading = true}) async {
|
|
|
|
BaseResp<dynamic> baseResp = await DioUtil()
|
|
|
|
.request<dynamic>(context, Method.get, HttpUrl.get_setmeal_by_id,
|
|
|
|
data: params, showLoading: isShowLoading)
|
|
|
|
.catchError((error) {
|
|
|
|
print(error.toString());
|
|
|
|
if (error is MyError) {}
|
|
|
|
notifyListeners();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
SetMeaByIdModel setMeaByIdModel =
|
|
|
|
SetMeaByIdModel.fromJson(baseResp.responseData);
|
|
|
|
if (setMeaByIdModel.ret == Constant.status_success) {
|
|
|
|
setmealDetail = setMeaByIdModel.data;
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
Utils.showToast(baseResp.msg ?? "");
|
|
|
|
notifyListeners();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 获取宴会套餐菜品分类列表
|
|
|
|
getSetmealClass(BuildContext context, Map<String, String> params,
|
|
|
|
{isShowLoading = true}) async {
|
|
|
|
BaseResp<dynamic> baseResp = await DioUtil()
|
|
|
|
.request<dynamic>(context, Method.get, HttpUrl.get_setmeal_class,
|
|
|
|
data: params, showLoading: isShowLoading)
|
|
|
|
.catchError((error) {
|
|
|
|
print(error.toString());
|
|
|
|
if (error is MyError) {}
|
|
|
|
notifyListeners();
|
|
|
|
});
|
|
|
|
|
|
|
|
GetSetmealClassModel getSetmealClassModel =
|
|
|
|
GetSetmealClassModel.fromJson(baseResp.responseData);
|
|
|
|
if (getSetmealClassModel.ret == Constant.status_success) {
|
|
|
|
setmealClassData = getSetmealClassModel.data;
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
} else {
|
|
|
|
Utils.showToast(baseResp.msg ?? "");
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///添加宴会套餐---菜品分类
|
|
|
|
Future<dynamic> setSetmealClass(
|
|
|
|
BuildContext context, Map<String, String> params,
|
|
|
|
{isShowLoading = true}) async {
|
|
|
|
BaseResp<dynamic> baseResp = await DioUtil()
|
|
|
|
.request<dynamic>(context, Method.get, HttpUrl.set_setmeal_class,
|
|
|
|
data: params, showLoading: isShowLoading)
|
|
|
|
.catchError((error) {
|
|
|
|
print(error.toString());
|
|
|
|
if (error is MyError) {}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
if (baseResp.code == Constant.status_success) {
|
|
|
|
// if (baseResp.data == 1) {
|
|
|
|
return true;
|
|
|
|
// } else {
|
|
|
|
// return false;
|
|
|
|
// }
|
|
|
|
} else {
|
|
|
|
if (baseResp != null) {
|
|
|
|
Utils.showToast(baseResp.msg ?? "");
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///删除宴会套餐菜品分类
|
|
|
|
Future<dynamic> delSetmealClass(
|
|
|
|
BuildContext context, Map<String, String> params,
|
|
|
|
{isShowLoading = true}) async {
|
|
|
|
BaseResp<dynamic> baseResp = await DioUtil()
|
|
|
|
.request<dynamic>(context, Method.get, HttpUrl.del_setmeal_class,
|
|
|
|
data: params, showLoading: isShowLoading)
|
|
|
|
.catchError((error) {
|
|
|
|
print(error.toString());
|
|
|
|
if (error is MyError) {}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
if (baseResp.code == Constant.status_success) {
|
|
|
|
// if (baseResp.data == 1) {
|
|
|
|
return true;
|
|
|
|
// } else {
|
|
|
|
// return false;
|
|
|
|
// }
|
|
|
|
} else {
|
|
|
|
if (baseResp != null) {
|
|
|
|
Utils.showToast(baseResp.msg ?? "");
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 根据ID获取宴会套餐菜品分类
|
|
|
|
Future<bool> getSetmealClassById(
|
|
|
|
BuildContext context, Map<String, String> params,
|
|
|
|
{isShowLoading = true}) async {
|
|
|
|
BaseResp<dynamic> baseResp = await DioUtil()
|
|
|
|
.request<dynamic>(context, Method.get, HttpUrl.get_setmeal_class_by_id,
|
|
|
|
data: params, showLoading: isShowLoading)
|
|
|
|
.catchError((error) {
|
|
|
|
print(error.toString());
|
|
|
|
if (error is MyError) {}
|
|
|
|
notifyListeners();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
GetSetmealClassByIdModel getSetmealClassByIdModel =
|
|
|
|
GetSetmealClassByIdModel.fromJson(baseResp.responseData);
|
|
|
|
if (getSetmealClassByIdModel.ret == Constant.status_success) {
|
|
|
|
setmealClassDetail = getSetmealClassByIdModel.data;
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
Utils.showToast(baseResp.msg ?? "");
|
|
|
|
notifyListeners();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///添加宴会套餐---菜品
|
|
|
|
Future<dynamic> setSetmealCook(
|
|
|
|
BuildContext context, Map<String, String> params,
|
|
|
|
{isShowLoading = true}) async {
|
|
|
|
BaseResp<dynamic> baseResp = await DioUtil()
|
|
|
|
.request<dynamic>(context, Method.get, HttpUrl.set_setmeal_cook,
|
|
|
|
data: params, showLoading: isShowLoading)
|
|
|
|
.catchError((error) {
|
|
|
|
print(error.toString());
|
|
|
|
if (error is MyError) {}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
if (baseResp.code == Constant.status_success) {
|
|
|
|
// if (baseResp.data == 1) {
|
|
|
|
return true;
|
|
|
|
// } else {
|
|
|
|
// return false;
|
|
|
|
// }
|
|
|
|
} else {
|
|
|
|
if (baseResp != null) {
|
|
|
|
Utils.showToast(baseResp.msg ?? "");
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 删除宴会套餐菜品
|
|
|
|
Future<dynamic> delSetmealCook(
|
|
|
|
BuildContext context, Map<String, String> params,
|
|
|
|
{isShowLoading = true}) async {
|
|
|
|
BaseResp<dynamic> baseResp = await DioUtil()
|
|
|
|
.request<dynamic>(context, Method.get, HttpUrl.del_setmeal_cook,
|
|
|
|
data: params, showLoading: isShowLoading)
|
|
|
|
.catchError((error) {
|
|
|
|
print(error.toString());
|
|
|
|
if (error is MyError) {}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
if (baseResp.code == Constant.status_success) {
|
|
|
|
// if (baseResp.data == 1) {
|
|
|
|
return true;
|
|
|
|
// } else {
|
|
|
|
// return false;
|
|
|
|
// }
|
|
|
|
} else {
|
|
|
|
if (baseResp != null) {
|
|
|
|
Utils.showToast(baseResp.msg ?? "");
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 定金
|
|
|
|
*/
|
|
|
|
|
|
|
|
///添加宴会套餐
|
|
|
|
Future<dynamic> setBanquetConf(
|
|
|
|
BuildContext context, Map<String, String> params,
|
|
|
|
{isShowLoading = true}) async {
|
|
|
|
BaseResp<dynamic> baseResp = await DioUtil()
|
|
|
|
.request<dynamic>(context, Method.get, HttpUrl.set_banquet_conf,
|
|
|
|
data: params, showLoading: isShowLoading)
|
|
|
|
.catchError((error) {
|
|
|
|
print(error.toString());
|
|
|
|
if (error is MyError) {}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
if (baseResp.code == Constant.status_success) {
|
|
|
|
// if (baseResp.data == 1) {
|
|
|
|
return true;
|
|
|
|
// } else {
|
|
|
|
// return false;
|
|
|
|
// }
|
|
|
|
} else {
|
|
|
|
if (baseResp != null) {
|
|
|
|
Utils.showToast(baseResp.msg ?? "");
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|