|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
import 'package:cached_network_image/cached_network_image.dart';
|
|
|
|
import 'package:common_utils/common_utils.dart';
|
|
|
|
import 'package:dotted_border/dotted_border.dart';
|
|
|
|
import 'package:flutter/gestures.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
...
|
...
|
@@ -15,6 +16,7 @@ import 'package:provider/provider.dart'; |
|
|
|
import '../../models/dsolt_xt.dart';
|
|
|
|
import '../../models/feast_menu_model.dart';
|
|
|
|
import '../../models/set_xuan_tai_model.dart';
|
|
|
|
import '../../models/setmeal_by_id_model.dart';
|
|
|
|
import '../../models/upload_img_model.dart';
|
|
|
|
import '../../provider/feast_model.dart';
|
|
|
|
import '../../provider/upload_img_provider.dart';
|
|
...
|
...
|
@@ -46,8 +48,7 @@ class _FeastCreatePageState extends State<FeastCreatePage> { |
|
|
|
FocusNode phoneF = FocusNode();
|
|
|
|
TextEditingController customC = TextEditingController(); //意向备注
|
|
|
|
FocusNode customF = FocusNode(); //意向备注
|
|
|
|
TextEditingController customCxt = TextEditingController(); //选台备注
|
|
|
|
FocusNode customFxt = FocusNode(); //选台备注
|
|
|
|
|
|
|
|
TextEditingController customCdb = TextEditingController(); //担保说明
|
|
|
|
FocusNode customFdb = FocusNode(); //担保说明
|
|
|
|
List sexList;
|
|
...
|
...
|
@@ -75,6 +76,7 @@ class _FeastCreatePageState extends State<FeastCreatePage> { |
|
|
|
int xuantaiSelIndex = 0;
|
|
|
|
List<DsoltXt> dsoltList = [];
|
|
|
|
UserModel userModel;
|
|
|
|
Map<String, List<CookByIdSetmeal>> dataMenu = {};
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
...
|
...
|
@@ -84,17 +86,26 @@ class _FeastCreatePageState extends State<FeastCreatePage> { |
|
|
|
Utils.changeStatusColor(color: MyColours.color_438E93);
|
|
|
|
initSexList();
|
|
|
|
|
|
|
|
xuantaiData.add(initSetXuanTaiModel());
|
|
|
|
xuantaiData.add(initSetXuanTaiModel(index: 0));
|
|
|
|
initTime(context);
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
_getSellerUserBySellerid();
|
|
|
|
_getStaff();
|
|
|
|
_getClassify();
|
|
|
|
_getSetmeal();
|
|
|
|
// scrollController.jumpTo(scrollController.position.minScrollExtent);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
initSetXuanTaiModel() {
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
super.dispose();
|
|
|
|
feastModel.rid = null;
|
|
|
|
feastModel.type = null;
|
|
|
|
feastModel.reserve = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
initSetXuanTaiModel({int index}) {
|
|
|
|
SetXuanTaiModel setXuanTaiModel = SetXuanTaiModel();
|
|
|
|
setXuanTaiModel.dateTimeShowxt = '请选择';
|
|
|
|
setXuanTaiModel.cdShow = '请选择';
|
|
...
|
...
|
@@ -104,6 +115,14 @@ class _FeastCreatePageState extends State<FeastCreatePage> { |
|
|
|
setXuanTaiModel.setmeal = [];
|
|
|
|
setXuanTaiModel.tids = [];
|
|
|
|
setXuanTaiModel.wine = [];
|
|
|
|
if (feastModel != null) {
|
|
|
|
setXuanTaiModel.rid = feastModel.rid;
|
|
|
|
}
|
|
|
|
if (index != null) {
|
|
|
|
String numStr = ConvertNumberToChineseMoneyWords.toChinese(index);
|
|
|
|
setXuanTaiModel.reserveOrder = '第${numStr}场';
|
|
|
|
}
|
|
|
|
|
|
|
|
return setXuanTaiModel;
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -153,6 +172,67 @@ class _FeastCreatePageState extends State<FeastCreatePage> { |
|
|
|
await feastModel.getClassify(context, isShowLoading: isShowLoading);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ///获取宴会套餐
|
|
|
|
// Future<bool> _getSetmeal({bool isShowLoading = true}) async {
|
|
|
|
// bool success =
|
|
|
|
// await feastModel.getSetmeal(context, isShowLoading: isShowLoading);
|
|
|
|
// if (success) {
|
|
|
|
|
|
|
|
// for (SetMealSunModel item in feastModel.setmealData) {
|
|
|
|
// Setmeal setmeal = Setmeal();
|
|
|
|
// setmeal.setmealId = item.id;
|
|
|
|
// setmeal.name = item.mealName;
|
|
|
|
// setmeal.bargaining = item.bargaining;
|
|
|
|
// setmeal.finalPriceC = TextEditingController();
|
|
|
|
// setmeal.minC = TextEditingController();
|
|
|
|
// setmeal.pnumC = TextEditingController();
|
|
|
|
// setmeal.spareC = TextEditingController();
|
|
|
|
|
|
|
|
// if (setmealids.contains(item.id)) {
|
|
|
|
// setmeal.select = true;
|
|
|
|
// int index = userModel.justSelData
|
|
|
|
// .indexWhere((element) => element.setmealId == item.id);
|
|
|
|
// Setmeal widgetData = userModel.justSelData[index];
|
|
|
|
// setmeal.finalPriceC.text = widgetData.finalPrice;
|
|
|
|
// setmeal.minC.text = widgetData.min;
|
|
|
|
// setmeal.pnumC.text = widgetData.pnum;
|
|
|
|
// setmeal.spareC.text = widgetData.spare;
|
|
|
|
// setmeal.dataMenu = widgetData.dataMenu;
|
|
|
|
// } else {
|
|
|
|
// setmeal.select = false;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// setmeal.price = item.price;
|
|
|
|
// setmealData.add(setmeal);
|
|
|
|
// }
|
|
|
|
// setState(() {});
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
/// 根据ID获取宴会套餐
|
|
|
|
Future<bool> _getSetmeal({bool isShowLoading = true}) async {
|
|
|
|
await feastModel.getSetmeal(context, isShowLoading: isShowLoading);
|
|
|
|
// if (success) {
|
|
|
|
|
|
|
|
// for ( item in feastModel.setmealData.) {
|
|
|
|
// // Map<String, List<CookByIdSetmeal>> map = {};
|
|
|
|
// String cid = item.id;
|
|
|
|
// String className = item.className;
|
|
|
|
|
|
|
|
// List<CookByIdSetmeal> temp = [];
|
|
|
|
// for (CookByIdSetmeal itemCook in feastModel.setmealDetail.cook) {
|
|
|
|
// if (cid == itemCook.cid) {
|
|
|
|
// temp.add(itemCook);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// // classNames.add(className);
|
|
|
|
// dataMenu[className] = temp;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
///称谓
|
|
|
|
initSexList() {
|
|
|
|
String sexStr = '1';
|
|
...
|
...
|
@@ -552,6 +632,7 @@ class _FeastCreatePageState extends State<FeastCreatePage> { |
|
|
|
return ymd;
|
|
|
|
}
|
|
|
|
|
|
|
|
///意向保存接口
|
|
|
|
Future<bool> yxSave() async {
|
|
|
|
if (dateTimeShow == '请选择') {
|
|
|
|
Utils.showToast('请选择宴会日期');
|
|
...
|
...
|
@@ -601,15 +682,19 @@ class _FeastCreatePageState extends State<FeastCreatePage> { |
|
|
|
'rname': nameC.text,
|
|
|
|
'sex': sexList[sexSelectIndex]['code'],
|
|
|
|
};
|
|
|
|
if (customC.text.trim().length > 0) {
|
|
|
|
pramas['remark'] = customC.text; //备注
|
|
|
|
}
|
|
|
|
if (imageQiniuUrlList.length > 0) {
|
|
|
|
pramas['images'] = json.encode(imageQiniuUrlList); //备注图片
|
|
|
|
// if (customC.text.trim().length > 0) {
|
|
|
|
pramas['remark'] = customC.text; //备注
|
|
|
|
// }
|
|
|
|
// if (imageQiniuUrlList.length > 0) {
|
|
|
|
pramas['images'] = json.encode(imageQiniuUrlList); //备注图片
|
|
|
|
// }
|
|
|
|
if (feastModel.rid != null) {
|
|
|
|
pramas['id'] = feastModel.rid;
|
|
|
|
}
|
|
|
|
bool success = await feastModel.createBanquet(context, pramas);
|
|
|
|
if (success) {
|
|
|
|
Utils.showToast('保存成功');
|
|
|
|
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
...
|
...
|
@@ -750,6 +835,198 @@ class _FeastCreatePageState extends State<FeastCreatePage> { |
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
//获取一天开始-结束时间字符串
|
|
|
|
String _getRdate(DateTime date) {
|
|
|
|
String keys = '';
|
|
|
|
|
|
|
|
String ymd = DateUtil.formatDate(date, format: DateFormats.y_mo_d);
|
|
|
|
String timeStrStart = '';
|
|
|
|
String timeStrEnd = '';
|
|
|
|
//一天开始时间
|
|
|
|
double startDay;
|
|
|
|
//一天结束时间
|
|
|
|
double endDay;
|
|
|
|
if (xuantaiData[xuantaiSelIndex].qsDateShow != '暂未选择') {
|
|
|
|
timeStrStart = ymd + ' ' + xuantaiData[xuantaiSelIndex].startDate + ':00';
|
|
|
|
timeStrEnd = ymd + ' ' + xuantaiData[xuantaiSelIndex].endDate + ':00';
|
|
|
|
} else {
|
|
|
|
timeStrStart = date.year.toString() +
|
|
|
|
"-" +
|
|
|
|
Utils.addZeroNumber(date.month) +
|
|
|
|
"-" +
|
|
|
|
Utils.addZeroNumber(date.day) +
|
|
|
|
" 00:00:00";
|
|
|
|
timeStrEnd = date.year.toString() +
|
|
|
|
"-" +
|
|
|
|
Utils.addZeroNumber(date.month) +
|
|
|
|
"-" +
|
|
|
|
Utils.addZeroNumber(date.day) +
|
|
|
|
" 23:59:59";
|
|
|
|
}
|
|
|
|
startDay = (DateTime.parse(timeStrStart).millisecondsSinceEpoch) / 1000;
|
|
|
|
endDay = (DateTime.parse(timeStrEnd).millisecondsSinceEpoch) / 1000;
|
|
|
|
return startDay.floor().toString() + "-" + endDay.floor().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 选台保存接口
|
|
|
|
Future<bool> xtSave() async {
|
|
|
|
//判断非空选项,并弹窗提醒用户填写信息
|
|
|
|
// xuantaiData 多场次数据
|
|
|
|
bool canRequest = false;
|
|
|
|
xuantaiData.forEach((element) {
|
|
|
|
String reserveOrder = element.reserveOrder;
|
|
|
|
if (element.dateTimeShowxt == '请选择') {
|
|
|
|
Utils.showToast('请选择${reserveOrder}宴会日期');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (element.cdShow == '请选择') {
|
|
|
|
Utils.showToast('请选择${reserveOrder}餐段');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (element.tids.length == 0) {
|
|
|
|
Utils.showToast('请选择${reserveOrder}桌位');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
for (UploadImgModel item in element.feastRemarkXtImageList) {
|
|
|
|
if (item.process < 1) {
|
|
|
|
Utils.showToast('正在上传${reserveOrder}图片,请稍等');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
canRequest = true;
|
|
|
|
});
|
|
|
|
if (!canRequest) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
///组装请求数据
|
|
|
|
List dataRequest = []; //请求数据
|
|
|
|
xuantaiData.forEach((element) {
|
|
|
|
Map map = {};
|
|
|
|
map['rid'] = feastModel.rid;
|
|
|
|
if (element.reserveId != null) {
|
|
|
|
map['id'] = element.reserveId;
|
|
|
|
}
|
|
|
|
map['reserve_order'] = element.reserveOrder;
|
|
|
|
map['ddate_interval'] = element.cdCode;
|
|
|
|
map['rdate'] = _getRdate(element.dateTimext);
|
|
|
|
List tids = [];
|
|
|
|
for (Tids item in element.tids) {
|
|
|
|
Map mapTids = {'tid': item.tid, 'num': item.numStr};
|
|
|
|
tids.add(mapTids);
|
|
|
|
}
|
|
|
|
map['tids'] = tids; //桌位数据
|
|
|
|
|
|
|
|
//套餐数据
|
|
|
|
// if (xuantaiData[xuantaiSelIndex].setmeal.length > 0) {
|
|
|
|
//选择了套餐数据
|
|
|
|
//组装
|
|
|
|
List setmeal = [];
|
|
|
|
element.setmeal.forEach((mealValue) {
|
|
|
|
Map mapMeal = {
|
|
|
|
'setmeal_id': mealValue.setmealId,
|
|
|
|
'price': mealValue.price,
|
|
|
|
'final_price': mealValue.finalPrice,
|
|
|
|
'pnum': mealValue.pnum,
|
|
|
|
'min': mealValue.min,
|
|
|
|
'spare': mealValue.spare,
|
|
|
|
};
|
|
|
|
List cooklist = []; //菜单数据
|
|
|
|
if (mealValue.dataMenu != null && mealValue.dataMenu.length > 0) {
|
|
|
|
//修改过菜单的数据
|
|
|
|
|
|
|
|
mealValue.dataMenu.forEach((key, value) {
|
|
|
|
value.forEach((element) {
|
|
|
|
Map mapMenu = {'cname': element.cname};
|
|
|
|
cooklist.add(mapMenu);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
// 套餐菜单原数据
|
|
|
|
feastModel.setmealData.forEach((element) {
|
|
|
|
if (element.id == mealValue.setmealId) {
|
|
|
|
//找到当前套餐map
|
|
|
|
element.cook.forEach((element) {
|
|
|
|
Map mapMenu = {'cname': element.cname};
|
|
|
|
cooklist.add(mapMenu);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
mapMeal['cooklist'] = cooklist; //菜单
|
|
|
|
setmeal.add(mapMeal);
|
|
|
|
});
|
|
|
|
|
|
|
|
map['setmeal'] = setmeal; //桌位数据
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//酒水
|
|
|
|
// if (xuantaiData[xuantaiSelIndex].wine.length > 0) {
|
|
|
|
List wines = [];
|
|
|
|
element.wine.forEach((element) {
|
|
|
|
Map mapWine = {
|
|
|
|
'wine_id': element.wineId,
|
|
|
|
'price': element.price,
|
|
|
|
'final_price': element.finalPrice,
|
|
|
|
'num': element.numStr
|
|
|
|
};
|
|
|
|
wines.add(mapWine);
|
|
|
|
});
|
|
|
|
map['wine'] = wines; //酒水数据
|
|
|
|
// }
|
|
|
|
//其他配置
|
|
|
|
// if (xuantaiData[xuantaiSelIndex].other.length > 0) {
|
|
|
|
List others = [];
|
|
|
|
element.other.forEach((element) {
|
|
|
|
Map mapOther = {
|
|
|
|
'other_id': element.otherId,
|
|
|
|
'price': element.price,
|
|
|
|
'final_price': element.finalPrice,
|
|
|
|
'num': element.numStr
|
|
|
|
};
|
|
|
|
others.add(mapOther);
|
|
|
|
});
|
|
|
|
map['other'] = others; //其他配置数据
|
|
|
|
// }
|
|
|
|
// 备注
|
|
|
|
// if (element.customCxt.text != null) {
|
|
|
|
map['remark'] = element.remark; //备注数据
|
|
|
|
// }
|
|
|
|
// 图片
|
|
|
|
List imageQiniuUrlList = []; //接口图片数据list
|
|
|
|
for (int i = 0; i < element.feastRemarkXtImageList.length; i++) {
|
|
|
|
imageQiniuUrlList
|
|
|
|
.add({"url": element.feastRemarkXtImageList[i].qiniuUrl});
|
|
|
|
}
|
|
|
|
// if (imageQiniuUrlList.length > 0) {
|
|
|
|
map['images'] = imageQiniuUrlList; //图片数据
|
|
|
|
// }
|
|
|
|
dataRequest.add(map);
|
|
|
|
});
|
|
|
|
|
|
|
|
Map<String, String> pramas = {'data': json.encode(dataRequest)};
|
|
|
|
|
|
|
|
bool success = await feastModel.setBanquetInfo(context, pramas);
|
|
|
|
if (success) {
|
|
|
|
feastModel.sessionsSunModelList.forEach((element) {
|
|
|
|
//把对应场次的ID赋值给本地数据
|
|
|
|
xuantaiData.forEach((item) {
|
|
|
|
if (item.reserveOrder == element.reserveOrder) {
|
|
|
|
//根据“第一场、第二场。。。”找到当前场次的对应数据
|
|
|
|
item.reserveId = element.id;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
print(xuantaiData);
|
|
|
|
Utils.showToast('保存成功');
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///选台
|
|
|
|
Widget xtWidget() {
|
|
|
|
return Column(
|
|
...
|
...
|
@@ -798,7 +1075,8 @@ class _FeastCreatePageState extends State<FeastCreatePage> { |
|
|
|
// }
|
|
|
|
// });
|
|
|
|
xuantaiSelIndex = index;
|
|
|
|
xuantaiData.add(initSetXuanTaiModel());
|
|
|
|
xuantaiData.add(
|
|
|
|
initSetXuanTaiModel(index: index));
|
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
child: DottedBorder(
|
|
...
|
...
|
@@ -837,6 +1115,7 @@ class _FeastCreatePageState extends State<FeastCreatePage> { |
|
|
|
String numStr =
|
|
|
|
ConvertNumberToChineseMoneyWords.toChinese(
|
|
|
|
index);
|
|
|
|
xuantaiData[index].reserveOrder = '第${numStr}场';
|
|
|
|
return InkWell(
|
|
|
|
onTap: () {
|
|
|
|
setState(() {
|
|
...
|
...
|
@@ -889,7 +1168,9 @@ class _FeastCreatePageState extends State<FeastCreatePage> { |
|
|
|
gradientEnd: MyColours.color_E34D59,
|
|
|
|
onPressed: () async {
|
|
|
|
xuantaiData.removeAt(xuantaiSelIndex);
|
|
|
|
xuantaiSelIndex--;
|
|
|
|
|
|
|
|
xuantaiSelIndex--; //删除后,选中前一个
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
}))
|
|
|
|
: SizedBox(),
|
|
...
|
...
|
@@ -927,6 +1208,9 @@ class _FeastCreatePageState extends State<FeastCreatePage> { |
|
|
|
xuantaiData[xuantaiSelIndex].cdShow = dsoltList[
|
|
|
|
xuantaiData[xuantaiSelIndex].cdSelIndex]
|
|
|
|
.title;
|
|
|
|
xuantaiData[xuantaiSelIndex].cdCode = dsoltList[
|
|
|
|
xuantaiData[xuantaiSelIndex].cdSelIndex]
|
|
|
|
.id;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
...
|
...
|
@@ -1213,7 +1497,7 @@ class _FeastCreatePageState extends State<FeastCreatePage> { |
|
|
|
.tableList) {
|
|
|
|
item.selected = true;
|
|
|
|
Tids tids = Tids();
|
|
|
|
tids.tid = item.tid;
|
|
|
|
tids.tid = item.id;
|
|
|
|
tids.name = item.name;
|
|
|
|
xuantaiData[xuantaiSelIndex]
|
|
|
|
.tids
|
|
...
|
...
|
@@ -1277,7 +1561,7 @@ class _FeastCreatePageState extends State<FeastCreatePage> { |
|
|
|
.tableList) {
|
|
|
|
item.selected = true;
|
|
|
|
Tids tids = Tids();
|
|
|
|
tids.tid = item.tid;
|
|
|
|
tids.tid = item.id;
|
|
|
|
tids.name = item.name;
|
|
|
|
xuantaiData[xuantaiSelIndex]
|
|
|
|
.tids
|
|
...
|
...
|
@@ -1744,7 +2028,8 @@ class _FeastCreatePageState extends State<FeastCreatePage> { |
|
|
|
),
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
remark(customCxt, customFxt),
|
|
|
|
remark(xuantaiData[xuantaiSelIndex].customCxt,
|
|
|
|
xuantaiData[xuantaiSelIndex].customFxt),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.fromLTRB(
|
|
|
|
ScreenUtil().setWidth(32),
|
|
...
|
...
|
@@ -1763,6 +2048,8 @@ class _FeastCreatePageState extends State<FeastCreatePage> { |
|
|
|
maxImageNumber: 8,
|
|
|
|
mainAxisSpacing: 72,
|
|
|
|
crossAxisSpacing: 56,
|
|
|
|
feastRemarkXtImageList: xuantaiData[xuantaiSelIndex]
|
|
|
|
.feastRemarkXtImageList,
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
),
|
|
...
|
...
|
@@ -1772,19 +2059,23 @@ class _FeastCreatePageState extends State<FeastCreatePage> { |
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: _callButton(
|
|
|
|
onPress: () {
|
|
|
|
onPress: () async {
|
|
|
|
// setBanquetInfo
|
|
|
|
await xtSave();
|
|
|
|
},
|
|
|
|
content: '仅保存',
|
|
|
|
hasLeftBorder: true,
|
|
|
|
isSelect: false)),
|
|
|
|
Expanded(
|
|
|
|
child: _callButton(
|
|
|
|
onPress: () {
|
|
|
|
selectMenu = '定金';
|
|
|
|
menuSet.add('选台');
|
|
|
|
menuSet.add('定金');
|
|
|
|
setState(() {});
|
|
|
|
onPress: () async {
|
|
|
|
bool success = await xtSave();
|
|
|
|
if (success) {
|
|
|
|
selectMenu = '定金';
|
|
|
|
menuSet.add('选台');
|
|
|
|
menuSet.add('定金');
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
content: '保存并下一步',
|
|
|
|
hasLeftBorder: true,
|
...
|
...
|
|