|
...
|
...
|
@@ -5,8 +5,12 @@ import 'package:provider/provider.dart'; |
|
|
|
|
|
|
|
import '../constant/constant.dart';
|
|
|
|
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_staff_model.dart';
|
|
|
|
import '../models/personnel_manage_model.dart';
|
|
|
|
import '../models/wine_model.dart';
|
|
|
|
import '../net/base_resp.dart';
|
|
|
|
import '../net/dio_util.dart';
|
|
|
|
import '../net/http_url.dart';
|
|
...
|
...
|
@@ -17,39 +21,410 @@ class FeastModel extends ChangeNotifier { |
|
|
|
|
|
|
|
List<FilterBtnModel> sellerManageList = []; //经理数据 ---- 商家编辑页面
|
|
|
|
|
|
|
|
///商家详情编辑页面 ------ 获取经理数据
|
|
|
|
Future<List<FilterBtnModel>> getSellerUserBySellerid(BuildContext context,
|
|
|
|
PageState pageStatePersonnalHome = PageState.Loading; //员工管理
|
|
|
|
List<String> selectPersonnalData = [];
|
|
|
|
bool checkValue = false;
|
|
|
|
List<String> getPersonnalList = []; //宴会员工
|
|
|
|
|
|
|
|
PageState pageStateType = PageState.Loading; //宴会类型
|
|
|
|
List<ClassifySunModel> classifyData = [];
|
|
|
|
|
|
|
|
PageState pageStateWine = PageState.Loading; //酒水
|
|
|
|
List<WineSunModel> wineData = [];
|
|
|
|
|
|
|
|
/***
|
|
|
|
*
|
|
|
|
* 宴会员工
|
|
|
|
*/
|
|
|
|
|
|
|
|
//全选按钮执行“全选”
|
|
|
|
addAllMy() async {
|
|
|
|
//把数据状态全部改成true,即选中状态
|
|
|
|
selectPersonnalData = [];
|
|
|
|
for (var i = 0; i < sellerManageList.length; i++) {
|
|
|
|
sellerManageList[i].select = true;
|
|
|
|
selectPersonnalData.add(sellerManageList[i].id);
|
|
|
|
}
|
|
|
|
checkValue = true;
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
|
|
|
|
//全选按钮执行“全不选”
|
|
|
|
cancelAllMy() async {
|
|
|
|
selectPersonnalData = [];
|
|
|
|
//把数据状态全部改成false,即不选中状态
|
|
|
|
for (var i = 0; i < sellerManageList.length; i++) {
|
|
|
|
sellerManageList[i].select = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
checkValue = false;
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
|
|
|
|
//选中
|
|
|
|
addDataMy(int index) {
|
|
|
|
// userHistorys[index].select = true;
|
|
|
|
selectPersonnalData.add(sellerManageList[index].id);
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
|
|
|
|
//未选中
|
|
|
|
cancelDataMy(int index) {
|
|
|
|
// userHistorys[index].select = false;
|
|
|
|
selectPersonnalData
|
|
|
|
.removeWhere((element) => element == sellerManageList[index].id);
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
|
|
|
|
//获取全选按钮的状态 true or false
|
|
|
|
getCheckValueMy() {
|
|
|
|
bool temp = sellerManageList.any((value) {
|
|
|
|
return value.select == false;
|
|
|
|
});
|
|
|
|
if (temp == true) {
|
|
|
|
checkValue = false;
|
|
|
|
} else {
|
|
|
|
checkValue = true;
|
|
|
|
}
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
|
|
|
|
FilterBtnModel returnModel(PersonnelManageSunModel item) {
|
|
|
|
FilterBtnModel model = FilterBtnModel();
|
|
|
|
model.id = item.id;
|
|
|
|
model.title = item.nickName ?? item.account;
|
|
|
|
model.account = item.account;
|
|
|
|
model.phone = item.phone;
|
|
|
|
return model;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 获取店员列表
|
|
|
|
Future<bool> getAuthUserLists(BuildContext context,
|
|
|
|
{showLoading = false}) async {
|
|
|
|
Map<String, String> params = {
|
|
|
|
"sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid,
|
|
|
|
};
|
|
|
|
BaseResp<dynamic> baseResp = await DioUtil()
|
|
|
|
.request<dynamic>(context, Method.get, HttpUrl.get_auth_user_lists,
|
|
|
|
data: params, showLoading: showLoading)
|
|
|
|
.catchError((error) {
|
|
|
|
print(error.toString());
|
|
|
|
if (error is MyError) {
|
|
|
|
switch (error.type) {
|
|
|
|
case 1:
|
|
|
|
pageStatePersonnalHome = PageState.ConnectivityError;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
pageStatePersonnalHome = PageState.ConnectivityTimeOut;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
pageStatePersonnalHome = PageState.ConnectivityError;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
notifyListeners();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
if (baseResp != null && baseResp.code == Constant.status_success) {
|
|
|
|
Map data = baseResp.data;
|
|
|
|
Map<String, dynamic> tempData = {};
|
|
|
|
data.forEach((key, value) {
|
|
|
|
String keyTemp = key.split('_')[0];
|
|
|
|
String role_id = key.split('_')[1];
|
|
|
|
tempData[keyTemp] = {'listdata': value, 'role_id': role_id};
|
|
|
|
});
|
|
|
|
baseResp.responseData['data'] = tempData;
|
|
|
|
PersonnelManageModelData dataMap =
|
|
|
|
PersonnelManageModel.fromJson(baseResp.responseData).data;
|
|
|
|
sellerManageList = [];
|
|
|
|
for (PersonnelManageSunModel item in dataMap.admin.listdata) {
|
|
|
|
FilterBtnModel model = returnModel(item);
|
|
|
|
model.roleName = '管理员';
|
|
|
|
sellerManageList.add(model);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (PersonnelManageSunModel item in dataMap.cashier.listdata) {
|
|
|
|
FilterBtnModel model = returnModel(item);
|
|
|
|
model.roleName = '收银员';
|
|
|
|
sellerManageList.add(model);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (PersonnelManageSunModel item in dataMap.manager.listdata) {
|
|
|
|
FilterBtnModel model = returnModel(item);
|
|
|
|
model.roleName = '客户经理';
|
|
|
|
sellerManageList.add(model);
|
|
|
|
}
|
|
|
|
for (PersonnelManageSunModel item in dataMap.shopowner.listdata) {
|
|
|
|
FilterBtnModel model = returnModel(item);
|
|
|
|
model.roleName = '店长';
|
|
|
|
sellerManageList.add(model);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (PersonnelManageSunModel item in dataMap.waiter.listdata) {
|
|
|
|
FilterBtnModel model = returnModel(item);
|
|
|
|
model.roleName = '服务员';
|
|
|
|
sellerManageList.add(model);
|
|
|
|
}
|
|
|
|
pageStatePersonnalHome = PageState.Success;
|
|
|
|
notifyListeners();
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
Utils.showToast(baseResp.msg ?? "");
|
|
|
|
pageStatePersonnalHome = PageState.ConnectivityError;
|
|
|
|
notifyListeners();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///添加宴会员工
|
|
|
|
Future<dynamic> addStaff(BuildContext context, Map<String, String> params,
|
|
|
|
{isShowLoading = true}) async {
|
|
|
|
BaseResp<dynamic> baseResp = await DioUtil()
|
|
|
|
.request<dynamic>(context, Method.get, HttpUrl.add_staff,
|
|
|
|
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> getStaff(BuildContext context, {isShowLoading = true}) async {
|
|
|
|
Map<String, String> params = {
|
|
|
|
'sellerid': Provider.of<UserModel>(context, listen: false).user.sellerid
|
|
|
|
"sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
|
|
|
|
};
|
|
|
|
BaseResp<dynamic> baseResp = await DioUtil()
|
|
|
|
.request<dynamic>(
|
|
|
|
context, Method.get, HttpUrl.get_seller_user_by_sellerid,
|
|
|
|
data: params, showLoading: false)
|
|
|
|
.request<dynamic>(context, Method.get, HttpUrl.get_staff,
|
|
|
|
data: params, showLoading: isShowLoading)
|
|
|
|
.catchError((error) {
|
|
|
|
print(error.toString());
|
|
|
|
if (error is MyError) {}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
getPersonnalList = [];
|
|
|
|
GetStaffModel getStaffModel = GetStaffModel.fromJson(baseResp.responseData);
|
|
|
|
if (getStaffModel.ret == Constant.status_success) {
|
|
|
|
List<GetStaffSunModel> data = getStaffModel.data;
|
|
|
|
data.forEach((element) {
|
|
|
|
getPersonnalList.add(element.userId);
|
|
|
|
});
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
Utils.showToast(baseResp.msg ?? "");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 宴会类型
|
|
|
|
*/
|
|
|
|
|
|
|
|
///添加宴会类型
|
|
|
|
Future<dynamic> setClassify(BuildContext context, Map<String, String> params,
|
|
|
|
{isShowLoading = true}) async {
|
|
|
|
BaseResp<dynamic> baseResp = await DioUtil()
|
|
|
|
.request<dynamic>(context, Method.get, HttpUrl.set_classify,
|
|
|
|
data: params, showLoading: isShowLoading)
|
|
|
|
.catchError((error) {
|
|
|
|
print(error.toString());
|
|
|
|
if (error is MyError) {}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
if (baseResp.code == Constant.status_success) {
|
|
|
|
List<GetSellerUserBySelleridSunModel> sunmodel =
|
|
|
|
GetSellerUserBySelleridModel.fromJson(baseResp.responseData).data;
|
|
|
|
sellerManageList = [];
|
|
|
|
if (sunmodel != null && sunmodel.length > 0) {
|
|
|
|
for (GetSellerUserBySelleridSunModel item in sunmodel) {
|
|
|
|
if (item.nickName != null) {
|
|
|
|
FilterBtnModel model = FilterBtnModel();
|
|
|
|
model.id = item.id;
|
|
|
|
model.title = item.nickName;
|
|
|
|
sellerManageList.add(model);
|
|
|
|
}
|
|
|
|
// if (baseResp.data == 1) {
|
|
|
|
return true;
|
|
|
|
// } else {
|
|
|
|
// return false;
|
|
|
|
// }
|
|
|
|
} else {
|
|
|
|
if (baseResp != null) {
|
|
|
|
Utils.showToast(baseResp.msg ?? "");
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///获取宴会类型
|
|
|
|
Future<bool> getClassify(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_classify,
|
|
|
|
data: params, showLoading: isShowLoading)
|
|
|
|
.catchError((error) {
|
|
|
|
print(error.toString());
|
|
|
|
if (error is MyError) {
|
|
|
|
switch (error.type) {
|
|
|
|
case 1:
|
|
|
|
pageStateType = PageState.ConnectivityError;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
pageStateType = PageState.ConnectivityTimeOut;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
pageStateType = PageState.ConnectivityError;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
notifyListeners();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
ClassifyModel classifyModel = ClassifyModel.fromJson(baseResp.responseData);
|
|
|
|
if (classifyModel.ret == Constant.status_success) {
|
|
|
|
classifyData = classifyModel.data;
|
|
|
|
if (classifyData.length == 0) {
|
|
|
|
pageStateType = PageState.Empty;
|
|
|
|
} else {
|
|
|
|
pageStateType = PageState.Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
Utils.showToast(baseResp.msg ?? "");
|
|
|
|
pageStateType = PageState.ConnectivityError;
|
|
|
|
notifyListeners();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///删除宴会类型
|
|
|
|
Future<dynamic> delClassify(BuildContext context, Map<String, String> params,
|
|
|
|
{isShowLoading = true}) async {
|
|
|
|
BaseResp<dynamic> baseResp = await DioUtil()
|
|
|
|
.request<dynamic>(context, Method.get, HttpUrl.del_classify,
|
|
|
|
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> setWine(BuildContext context, Map<String, String> params,
|
|
|
|
{isShowLoading = true}) async {
|
|
|
|
BaseResp<dynamic> baseResp = await DioUtil()
|
|
|
|
.request<dynamic>(context, Method.get, HttpUrl.set_wine,
|
|
|
|
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> getWine(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_wine,
|
|
|
|
data: params, showLoading: isShowLoading)
|
|
|
|
.catchError((error) {
|
|
|
|
print(error.toString());
|
|
|
|
if (error is MyError) {
|
|
|
|
switch (error.type) {
|
|
|
|
case 1:
|
|
|
|
pageStateWine = PageState.ConnectivityError;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
pageStateWine = PageState.ConnectivityTimeOut;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
pageStateWine = PageState.ConnectivityError;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
notifyListeners();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
WineModel wineModel = WineModel.fromJson(baseResp.responseData);
|
|
|
|
if (wineModel.ret == Constant.status_success) {
|
|
|
|
wineData = wineModel.data;
|
|
|
|
if (wineData.length == 0) {
|
|
|
|
pageStateWine = PageState.Empty;
|
|
|
|
} else {
|
|
|
|
pageStateWine = PageState.Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
Utils.showToast(baseResp.msg ?? "");
|
|
|
|
pageStateWine = PageState.ConnectivityError;
|
|
|
|
notifyListeners();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///删除酒水
|
|
|
|
Future<dynamic> delWine(BuildContext context, Map<String, String> params,
|
|
|
|
{isShowLoading = true}) async {
|
|
|
|
BaseResp<dynamic> baseResp = await DioUtil()
|
|
|
|
.request<dynamic>(context, Method.get, HttpUrl.del_wine,
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
return sellerManageList;
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|