Commit e252688fd71bc07a8293fd56a594450bb2d481fa

Authored by “gaiyaguang”
1 parent 79bc9afc

hebing

... ... @@ -50,35 +50,36 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> {
void initState() {
super.initState();
dateTime = DateTime.now();
_notebookDetailChangeModel =
Provider.of<NotebookDetailChangeModel>(context, listen: false);
_notebookDetailChangeModel.initDateHourMinuteList(context);
String ddate = widget.detailEntity.ddate.toString() + '000';
_notebookDetailChangeModel.getNewTableList(
context,
ddate,
widget.detailEntity.ddate_solt,
widget.detailEntity.pnum,
widget.detailEntity.tables);
_initData();
// //输入框焦点
// _nameNode.addListener(() {
// if (!_nameNode.hasFocus) {
// print('失去焦点');
// } else {
// print('得到焦点');
// _phoneNode.unfocus();
// }
// });
// //输入框焦点
// _phoneNode.addListener(() {
// if (!_phoneNode.hasFocus) {
// print('失去焦点');
// } else {
// print('得到焦点');
// }
// });
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
// _notebookDetailChangeModel =
// Provider.of<NotebookDetailChangeModel>(context, listen: false);
_notebookDetailChangeModel.initDateHourMinuteList(context);
String ddate = widget.detailEntity.ddate.toString() + '000';
_notebookDetailChangeModel.getNewTableList(
context,
ddate,
widget.detailEntity.ddate_solt,
widget.detailEntity.pnum,
widget.detailEntity.tables);
_initData();
// //输入框焦点
// _nameNode.addListener(() {
// if (!_nameNode.hasFocus) {
// print('失去焦点');
// } else {
// print('得到焦点');
// _phoneNode.unfocus();
// }
// });
// //输入框焦点
// _phoneNode.addListener(() {
// if (!_phoneNode.hasFocus) {
// print('失去焦点');
// } else {
// print('得到焦点');
// }
// });
});
}
@override
... ... @@ -202,17 +203,19 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> {
_notebookDetailChangeModel.initHourAndMinuteSelect();
if (key != '') {
for (var sunitem
in _notebookDetailChangeModel.dailyMap[key]) {
in _notebookDetailChangeModel.dailyMap[key]) {
if (sunitem['select'] == true) {
_notebookDetailChangeModel.ddateStr =
sunitem['title'];
_notebookDetailChangeModel.ddateStr = sunitem['title'];
}
}
}
_notebookDetailChangeModel.notifyListeners();
int ddate = Utils.getDdate(_notebookDetailChangeModel.dateList);
String pnum = Utils.getPnum(_notebookDetailChangeModel.personNumList);
String ddateSolt = Utils.getDdateSolt(_notebookDetailChangeModel.sunDateList);
int ddate =
Utils.getDdate(_notebookDetailChangeModel.dateList);
String pnum =
Utils.getPnum(_notebookDetailChangeModel.personNumList);
String ddateSolt = Utils.getDdateSolt(
_notebookDetailChangeModel.sunDateList);
_notebookDetailChangeModel.getNewTableList(
context,
'${ddate}',
... ... @@ -827,7 +830,7 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> {
print('成功');
// _notebookDetailChangeModel.clearData();
bus.emit("refresh_detail");
bus.emit("refresh_book_list");//刷新已预订列表
bus.emit("refresh_book_list"); //刷新已预订列表
String ddate_solt = '';
if (_model.row.isSetDdate == '1') {
String createtime = _model.row.ddate.toString() + '000';
... ... @@ -854,8 +857,13 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> {
'等${tableinfo.length}桌';
}
LogUtil.v(_nameStr);
NavigatorUtil.goInvicationPage(context, _model.row.id,
_nameStr, _model.row.ddate, ddate_solt,_model.row.phone,
NavigatorUtil.goInvicationPage(
context,
_model.row.id,
_nameStr,
_model.row.ddate,
ddate_solt,
_model.row.phone,
replace: true);
EventBus().emit("refresh_tablemanager"); //刷新桌位
} else {
... ...
... ... @@ -24,9 +24,9 @@ class NotebookDetailChangeModel with ChangeNotifier {
TextEditingController customController = TextEditingController(); //客户要求
List sexList = []; // 先生、女士、公司
Map dailyMap = {}; // 早市对应半点钟,午市对应半点钟、晚市对应半点钟
List<String> mornings=[];//早市时间段
List<String> noons=[];//午市时间段
List<String> nights=[];//晚市时间段
List<String> mornings = []; //早市时间段
List<String> noons = []; //午市时间段
List<String> nights = []; //晚市时间段
String ddateStr = ''; //16:30
NotebookDetail detailEntity;
List<TableList> tableList = [];
... ... @@ -233,7 +233,7 @@ class NotebookDetailChangeModel with ChangeNotifier {
/// 早市、午市、晚市对应的半个小时间隔时间段
initDateHourMinuteList(BuildContext context) async {
UserModel userModel=Provider.of<UserModel>(context);
UserModel userModel = Provider.of<UserModel>(context, listen: false);
userModel.user.morning == ''
? dailyMap.putIfAbsent('morning', () => '')
: dailyMap.putIfAbsent(
... ... @@ -247,12 +247,12 @@ class NotebookDetailChangeModel with ChangeNotifier {
: dailyMap.putIfAbsent(
'night', () => _getHourAndMinute(userModel.user.night, 3));
_initSunDateList(userModel.user.morning, userModel.user.noon, userModel.user.night);
_initSunDateList(
userModel.user.morning, userModel.user.noon, userModel.user.night);
}
//根据获取时间 11:00-12:30 获取30分钟间隔组装的数组
_getHourAndMinute(
String hourAndMinuteStr, int mnd) {
_getHourAndMinute(String hourAndMinuteStr, int mnd) {
List tempDate = hourAndMinuteStr.split("-");
String beginDate = tempDate[0];
String endDate = tempDate[1];
... ... @@ -267,11 +267,14 @@ class NotebookDetailChangeModel with ChangeNotifier {
bool tempLimit = true;
while (tempLimit) {
String temp = _dealTime(beginHour, beginMinute);
if(mnd==1){//早市
if (mnd == 1) {
//早市
mornings.add(temp);
}else if(mnd==2){//午市
} else if (mnd == 2) {
//午市
noons.add(temp);
}else if(mnd==3){//晚市
} else if (mnd == 3) {
//晚市
nights.add(temp);
}
bool tempSelect = false;
... ... @@ -313,8 +316,8 @@ class NotebookDetailChangeModel with ChangeNotifier {
}
//初始化早市午市晚市选中时间
initHourAndMinuteSelect(){
int timeMillsNow=DateTime.now().millisecondsSinceEpoch;
initHourAndMinuteSelect() {
int timeMillsNow = DateTime.now().millisecondsSinceEpoch;
//当前选中 月 日string
String mdStr = '';
//今天 明天 其他天
... ... @@ -325,55 +328,70 @@ class NotebookDetailChangeModel with ChangeNotifier {
}
String timeNowYear = DateUtil.formatDate(DateTime.now(), format: 'yyyy');
String ymyStr = timeNowYear + '-' + mdStr; //年月日
String timeStr = ymyStr+' 00:00:00';
String timeStr = ymyStr + ' 00:00:00';
LogUtil.v(timeStr);
DateTime dateTime=DateUtil.getDateTime(timeStr);//当前年月日
for(var sunDate in sunDateList){
if(sunDate['isSelect']==false)continue;
switch(sunDate['key']){
case "morning"://选中早市
bool select=false;
for(var temp in dailyMap['morning']){//早市选中距离当前时间最近
temp['select']=false;
if(select)continue;//只选中第一个
if(timeMillsNow<=DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime).replaceRange(11,19, "${temp['title']}:00"))){
temp['select']=true;
select=true;
DateTime dateTime = DateUtil.getDateTime(timeStr); //当前年月日
for (var sunDate in sunDateList) {
if (sunDate['isSelect'] == false) continue;
switch (sunDate['key']) {
case "morning": //选中早市
bool select = false;
for (var temp in dailyMap['morning']) {
//早市选中距离当前时间最近
temp['select'] = false;
if (select) continue; //只选中第一个
if (timeMillsNow <=
DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime)
.replaceRange(11, 19, "${temp['title']}:00"))) {
temp['select'] = true;
select = true;
}
}
break;
case "noon"://选中午市
bool select=false;
for(var temp in dailyMap['noon']){//午市选中12:30
temp['select']=false;
if(select)continue;
if(noons.contains("12:30")&&timeMillsNow<=DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime).replaceRange(11,19, "12:30:00"))){
if(temp['title']=="12:30"){
temp['select']=true;
select=true;
case "noon": //选中午市
bool select = false;
for (var temp in dailyMap['noon']) {
//午市选中12:30
temp['select'] = false;
if (select) continue;
if (noons.contains("12:30") &&
timeMillsNow <=
DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime)
.replaceRange(11, 19, "12:30:00"))) {
if (temp['title'] == "12:30") {
temp['select'] = true;
select = true;
}
}else{
if(timeMillsNow<=DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime).replaceRange(11,19, "${temp['title']}:00"))){
temp['select']=true;
select=true;
} else {
if (timeMillsNow <=
DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime)
.replaceRange(11, 19, "${temp['title']}:00"))) {
temp['select'] = true;
select = true;
}
}
}
break;
case "night"://选中晚市
bool select=false;
for(var temp in dailyMap['night']){//晚市选中18:30
temp['select']=false;
if(select)continue;
if(nights.contains("18:30")&&timeMillsNow<=DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime).replaceRange(11,19, "18:30:00"))){
if(temp['title']=="18:30"){
temp['select']=true;
select=true;
case "night": //选中晚市
bool select = false;
for (var temp in dailyMap['night']) {
//晚市选中18:30
temp['select'] = false;
if (select) continue;
if (nights.contains("18:30") &&
timeMillsNow <=
DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime)
.replaceRange(11, 19, "18:30:00"))) {
if (temp['title'] == "18:30") {
temp['select'] = true;
select = true;
}
}else{
if(timeMillsNow<=DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime).replaceRange(11,19, "${temp['title']}:00"))){
temp['select']=true;
select=true;
} else {
if (timeMillsNow <=
DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime)
.replaceRange(11, 19, "${temp['title']}:00"))) {
temp['select'] = true;
select = true;
}
}
}
... ... @@ -444,8 +462,8 @@ class NotebookDetailChangeModel with ChangeNotifier {
'ddate_solt': ddate_solt,
'pnum': pnum
};
if(detailEntity.id.isNotEmpty&&detailEntity.id!="-1"){
params['rid']=detailEntity.id;
if (detailEntity.id.isNotEmpty && detailEntity.id != "-1") {
params['rid'] = detailEntity.id;
}
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.get_table_list,
... ... @@ -623,7 +641,7 @@ class NotebookDetailChangeModel with ChangeNotifier {
String timeStrEnd = ymyStr + ' ' + temp.last['title'] + ':00';
int startM = DateUtil.getDateMsByTimeStr(timeStrStart);
int endM = DateUtil.getDateMsByTimeStr(timeStrEnd);
String start='${startM}'.substring(0, 10);
String start = '${startM}'.substring(0, 10);
String end = '${endM}'.substring(0, 10);
rdate = start + '-' + end;
}
... ... @@ -637,14 +655,14 @@ class NotebookDetailChangeModel with ChangeNotifier {
"sex": sex, //预订人姓名:1:男 2:女
"phone": phoneController.text, //预订人电话
"cusdem": customController.text, //预订人需求:25汉字
'note_name':userModel.user.account,
'type':"0",//内部预订
'note_name': userModel.user.account,
'type': "0", //内部预订
"rdate": rdate, //预定用餐时间范围:时间戳 开始时间戳(time)-结束时间戳(time)
"ddate": '${ddate}'.substring(0, 10), //到店时间
'is_set_ddate':"1"
'is_set_ddate': "1"
};
if(detailEntity.id.isNotEmpty&&detailEntity.id!="-1"){
params['rid']=detailEntity.id;
if (detailEntity.id.isNotEmpty && detailEntity.id != "-1") {
params['rid'] = detailEntity.id;
}
print(params);
BaseResp<Map<String, dynamic>> baseResp = await DioUtil()
... ... @@ -665,14 +683,17 @@ class NotebookDetailChangeModel with ChangeNotifier {
baseResp.responseData['data']['row'] != null) {
itemModel = ReserveInfoModel.fromJson(baseResp.responseData).data;
} else {
Utils.showToast(baseResp.msg ?? detailEntity.id=="-1"?"录入预订订单失败,请重试!":"变更预订订单失败,请重试!");
Utils.showToast(baseResp.msg ?? detailEntity.id == "-1"
? "录入预订订单失败,请重试!"
: "变更预订订单失败,请重试!");
}
return itemModel;
}
}
//更改在线预订
Future<SunReserveInfoModel> updateOnlineReserveInfo(BuildContext context) async {
Future<SunReserveInfoModel> updateOnlineReserveInfo(
BuildContext context) async {
UserModel userModel = Provider.of<UserModel>(context, listen: false);
String pnum = '6';
for (var item in personNumList) {
... ... @@ -738,14 +759,14 @@ class NotebookDetailChangeModel with ChangeNotifier {
String timeStrEnd = ymyStr + ' ' + temp.last['title'] + ':00';
int startM = DateUtil.getDateMsByTimeStr(timeStrStart);
int endM = DateUtil.getDateMsByTimeStr(timeStrEnd);
String start='${startM}'.substring(0, 10);
String start = '${startM}'.substring(0, 10);
String end = '${endM}'.substring(0, 10);
rdate = start + '-' + end;
}
}
}
Map<String, String> params = {
"rid":detailEntity.id,
"rid": detailEntity.id,
'is_set_ddate': isSetDate,
"sid": userModel.user.sellerid, //商家ID
"tid": tableSelectInfo, //桌子ID: 格式 2,3,4
... ... @@ -754,7 +775,7 @@ class NotebookDetailChangeModel with ChangeNotifier {
"sex": sex, //预订人姓名:1:男 2:女
"phone": phoneController.text, //预订人电话
"cusdem": customController.text, //预订人需求:25汉字
"type":"0",
"type": "0",
"rdate": rdate, //预定用餐时间范围:时间戳 开始时间戳(time)-结束时间戳(time)
"ddate": '${ddate}'.substring(0, 10), //到店时间
"ddate_solt": ddateSolt
... ... @@ -762,8 +783,8 @@ class NotebookDetailChangeModel with ChangeNotifier {
print(params);
BaseResp<Map<String, dynamic>> baseResp = await DioUtil()
.request<Map<String, dynamic>>(
context, Method.get, HttpUrl.set_customer_info,
data: params)
context, Method.get, HttpUrl.set_customer_info,
data: params)
.catchError((error) {
print(error.toString());
});
... ...