Showing
30 changed files
with
951 additions
and
774 deletions
| 1 | import 'dart:io'; | 1 | import 'dart:io'; |
| 2 | 2 | ||
| 3 | +import 'package:common_utils/common_utils.dart'; | ||
| 3 | import 'package:dio/dio.dart'; | 4 | import 'package:dio/dio.dart'; |
| 4 | import 'package:fluro/fluro.dart'; | 5 | import 'package:fluro/fluro.dart'; |
| 5 | import 'package:flutter/material.dart'; | 6 | import 'package:flutter/material.dart'; |
| @@ -24,7 +25,6 @@ import 'pages/login/login_page.dart'; | @@ -24,7 +25,6 @@ import 'pages/login/login_page.dart'; | ||
| 24 | import 'provider/user_model.dart'; | 25 | import 'provider/user_model.dart'; |
| 25 | import 'route/navigate_service.dart'; | 26 | import 'route/navigate_service.dart'; |
| 26 | import 'route/routes.dart'; | 27 | import 'route/routes.dart'; |
| 27 | -import 'utils/log_util.dart'; | ||
| 28 | import 'package:flutter/services.dart'; | 28 | import 'package:flutter/services.dart'; |
| 29 | 29 | ||
| 30 | Future<void> main() async { | 30 | Future<void> main() async { |
| 1 | import 'dart:convert'; | 1 | import 'dart:convert'; |
| 2 | 2 | ||
| 3 | import 'package:json_annotation/json_annotation.dart'; | 3 | import 'package:json_annotation/json_annotation.dart'; |
| 4 | -import 'package:one_key/utils/log_util.dart'; | ||
| 5 | import 'package:one_key/utils/utils.dart'; | 4 | import 'package:one_key/utils/utils.dart'; |
| 6 | part 'notebook.g.dart'; | 5 | part 'notebook.g.dart'; |
| 7 | 6 |
| 1 | +import 'package:common_utils/common_utils.dart'; | ||
| 2 | +import 'package:flutter/cupertino.dart'; | ||
| 1 | import 'package:json_annotation/json_annotation.dart'; | 3 | import 'package:json_annotation/json_annotation.dart'; |
| 4 | +import 'package:one_key/models/table.dart'; | ||
| 5 | +import 'package:one_key/provider/user_model.dart'; | ||
| 2 | import 'package:one_key/utils/utils.dart'; | 6 | import 'package:one_key/utils/utils.dart'; |
| 7 | +import 'package:provider/provider.dart'; | ||
| 3 | import 'dart:convert'; | 8 | import 'dart:convert'; |
| 4 | import "table.dart"; | 9 | import "table.dart"; |
| 10 | +import 'package:one_key/models/table.dart' as t; | ||
| 5 | part 'notebook_detail.g.dart'; | 11 | part 'notebook_detail.g.dart'; |
| 6 | 12 | ||
| 7 | @JsonSerializable() | 13 | @JsonSerializable() |
| 8 | class NotebookDetail { | 14 | class NotebookDetail { |
| 9 | NotebookDetail(); | 15 | NotebookDetail(); |
| 10 | 16 | ||
| 17 | + NotebookDetail.def(BuildContext context){ | ||
| 18 | + id="-1"; | ||
| 19 | + pnum="6"; | ||
| 20 | + rname=""; | ||
| 21 | + sex="1"; | ||
| 22 | + phone=""; | ||
| 23 | + cusdem=""; | ||
| 24 | + ddate=(DateUtil.getDateMsByTimeStr(DateUtil.formatDate(DateTime.now()).replaceRange(11,19, "00:00:00"))/1000).floor().toString(); | ||
| 25 | + ddate_solt=defDdateSolt(context); | ||
| 26 | + is_set_ddate="0"; | ||
| 27 | + tables=[]; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + NotebookDetail.fromTableManager(DateTime dateTime,String ddate_solt,t.Table table){ | ||
| 31 | + id="-1"; | ||
| 32 | + pnum="6"; | ||
| 33 | + rname=""; | ||
| 34 | + sex="1"; | ||
| 35 | + phone=""; | ||
| 36 | + cusdem=""; | ||
| 37 | + ddate=(DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime).replaceRange(11,19, "00:00:00"))/1000).floor().toString(); | ||
| 38 | + ddate_solt=ddate_solt; | ||
| 39 | + is_set_ddate="0"; | ||
| 40 | + tables=[table]; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + String defDdateSolt(BuildContext context){ | ||
| 44 | + int millsNow=DateTime.now().millisecondsSinceEpoch; | ||
| 45 | + UserModel userModel=Provider.of<UserModel>(context,listen: false); | ||
| 46 | + String morning=userModel.user.morning==""?"00:00-00:00":userModel.user.morning; | ||
| 47 | + String noon=userModel.user.noon==""?"00:00-00:00":userModel.user.noon; | ||
| 48 | + String night=userModel.user.night==""?"00:00-00:00":userModel.user.night; | ||
| 49 | + String endMorning=morning.split("-")[1]; | ||
| 50 | + String endNoon=noon.split("-")[1]; | ||
| 51 | + String endNight=night.split("-")[1]; | ||
| 52 | + int endMorningMills=DateUtil.getDateMsByTimeStr(DateUtil.formatDate(DateTime.now()).replaceRange(11,19, "$endMorning:00")); | ||
| 53 | + int endNoonMills=DateUtil.getDateMsByTimeStr(DateUtil.formatDate(DateTime.now()).replaceRange(11,19, "$endNoon:00")); | ||
| 54 | + int endNightMills=DateUtil.getDateMsByTimeStr(DateUtil.formatDate(DateTime.now()).replaceRange(11,19, "$endNight:00")); | ||
| 55 | + if(millsNow<=endMorningMills){ | ||
| 56 | + return "1"; | ||
| 57 | + }else if(millsNow<=endNoonMills){ | ||
| 58 | + return "2"; | ||
| 59 | + }else if(millsNow<=endNightMills){ | ||
| 60 | + return "3"; | ||
| 61 | + } | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + | ||
| 11 | String id; | 65 | String id; |
| 12 | String abolition; | 66 | String abolition; |
| 13 | String tableinfo; | 67 | String tableinfo; |
| @@ -26,8 +80,8 @@ class NotebookDetail { | @@ -26,8 +80,8 @@ class NotebookDetail { | ||
| 26 | String note_name; | 80 | String note_name; |
| 27 | String channel; | 81 | String channel; |
| 28 | String cdate; | 82 | String cdate; |
| 29 | - List<Table> demands; //需求桌位 | ||
| 30 | - List<Table> tables; //预订桌位 | 83 | + List<t.Table> demands; //需求桌位 |
| 84 | + List<t.Table> tables; //预订桌位 | ||
| 31 | Cancel cancel; | 85 | Cancel cancel; |
| 32 | 86 | ||
| 33 | String get statuImgAssets { | 87 | String get statuImgAssets { |
| @@ -131,6 +185,13 @@ class NotebookDetail { | @@ -131,6 +185,13 @@ class NotebookDetail { | ||
| 131 | factory NotebookDetail.fromJson(Map<String, dynamic> json) => | 185 | factory NotebookDetail.fromJson(Map<String, dynamic> json) => |
| 132 | _$NotebookDetailFromJson(json); | 186 | _$NotebookDetailFromJson(json); |
| 133 | Map<String, dynamic> toJson() => _$NotebookDetailToJson(this); | 187 | Map<String, dynamic> toJson() => _$NotebookDetailToJson(this); |
| 188 | + | ||
| 189 | + @override | ||
| 190 | + String toString() { | ||
| 191 | + return 'NotebookDetail{id: $id, abolition: $abolition, tableinfo: $tableinfo, pnum: $pnum, rname: $rname, sex: $sex, phone: $phone, cusdem: $cusdem, cusman: $cusman, ddate: $ddate, is_set_ddate: $is_set_ddate, ddate_solt: $ddate_solt, status: $status, action: $action, type: $type, note_name: $note_name, channel: $channel, cdate: $cdate, demands: $demands, tables: $tables, cancel: $cancel}'; | ||
| 192 | + } | ||
| 193 | + | ||
| 194 | + | ||
| 134 | } | 195 | } |
| 135 | 196 | ||
| 136 | @JsonSerializable() | 197 | @JsonSerializable() |
| 1 | // GENERATED CODE - DO NOT MODIFY BY HAND | 1 | // GENERATED CODE - DO NOT MODIFY BY HAND |
| 2 | 2 | ||
| 3 | + | ||
| 3 | part of 'notebook_detail.dart'; | 4 | part of 'notebook_detail.dart'; |
| 4 | 5 | ||
| 6 | + | ||
| 5 | // ************************************************************************** | 7 | // ************************************************************************** |
| 6 | // JsonSerializableGenerator | 8 | // JsonSerializableGenerator |
| 7 | // ************************************************************************** | 9 | // ************************************************************************** |
| @@ -28,11 +30,11 @@ NotebookDetail _$NotebookDetailFromJson(Map<String, dynamic> json) { | @@ -28,11 +30,11 @@ NotebookDetail _$NotebookDetailFromJson(Map<String, dynamic> json) { | ||
| 28 | ..cdate = json['cdate'] as String | 30 | ..cdate = json['cdate'] as String |
| 29 | ..demands = (json['demands'] as List) | 31 | ..demands = (json['demands'] as List) |
| 30 | ?.map( | 32 | ?.map( |
| 31 | - (e) => e == null ? null : Table.fromJson(e as Map<String, dynamic>)) | 33 | + (e) => e == null ? null : t.Table.fromJson(e as Map<String, dynamic>)) |
| 32 | ?.toList() | 34 | ?.toList() |
| 33 | ..tables = (json['tables'] as List) | 35 | ..tables = (json['tables'] as List) |
| 34 | ?.map( | 36 | ?.map( |
| 35 | - (e) => e == null ? null : Table.fromJson(e as Map<String, dynamic>)) | 37 | + (e) => e == null ? null : t.Table.fromJson(e as Map<String, dynamic>)) |
| 36 | ?.toList() | 38 | ?.toList() |
| 37 | ..cancel = json['cancel'] == null | 39 | ..cancel = json['cancel'] == null |
| 38 | ? null | 40 | ? null |
| @@ -225,6 +225,13 @@ class Daily extends Object { | @@ -225,6 +225,13 @@ class Daily extends Object { | ||
| 225 | _$DailyFromJson(srcJson); | 225 | _$DailyFromJson(srcJson); |
| 226 | 226 | ||
| 227 | Map<String, dynamic> toJson() => _$DailyToJson(this); | 227 | Map<String, dynamic> toJson() => _$DailyToJson(this); |
| 228 | + | ||
| 229 | + @override | ||
| 230 | + String toString() { | ||
| 231 | + return 'Daily{morning: $morning, noon: $noon, night: $night}'; | ||
| 232 | + } | ||
| 233 | + | ||
| 234 | + | ||
| 228 | } | 235 | } |
| 229 | 236 | ||
| 230 | @JsonSerializable() | 237 | @JsonSerializable() |
| @@ -4,7 +4,6 @@ import 'dart:io'; | @@ -4,7 +4,6 @@ import 'dart:io'; | ||
| 4 | import 'package:dio/dio.dart'; | 4 | import 'package:dio/dio.dart'; |
| 5 | import 'package:flutter/material.dart'; | 5 | import 'package:flutter/material.dart'; |
| 6 | import 'package:one_key/constant/error.dart'; | 6 | import 'package:one_key/constant/error.dart'; |
| 7 | -import 'package:one_key/utils/log_util.dart'; | ||
| 8 | import 'package:one_key/utils/utils.dart'; | 7 | import 'package:one_key/utils/utils.dart'; |
| 9 | import 'package:one_key/widgets/loading.dart'; | 8 | import 'package:one_key/widgets/loading.dart'; |
| 10 | 9 |
| @@ -33,4 +33,6 @@ class HttpUrl { | @@ -33,4 +33,6 @@ class HttpUrl { | ||
| 33 | "?service=Android.Reserve.NewGetTableList"; //根据商家ID 获取桌位信息列表: 1:散座 2:包间 默认:获取所有数据 | 33 | "?service=Android.Reserve.NewGetTableList"; //根据商家ID 获取桌位信息列表: 1:散座 2:包间 默认:获取所有数据 |
| 34 | static const String set_reserve_info = | 34 | static const String set_reserve_info = |
| 35 | "?service=Android.Customer.SetReserveInfo"; //录入顾客订座相关信息,同时更新商家桌位状态 | 35 | "?service=Android.Customer.SetReserveInfo"; //录入顾客订座相关信息,同时更新商家桌位状态 |
| 36 | + static const String set_switch_status = | ||
| 37 | + "?service=App.Reserve.SetSwitchStatus"; //启用/停用桌位 | ||
| 36 | } | 38 | } |
| @@ -27,6 +27,7 @@ class HandleOnlinePage extends StatefulWidget { | @@ -27,6 +27,7 @@ class HandleOnlinePage extends StatefulWidget { | ||
| 27 | final String rid; | 27 | final String rid; |
| 28 | final String mid; | 28 | final String mid; |
| 29 | final bool fromNotify; | 29 | final bool fromNotify; |
| 30 | + | ||
| 30 | HandleOnlinePage(this.rid, this.mid, {this.fromNotify = false}); | 31 | HandleOnlinePage(this.rid, this.mid, {this.fromNotify = false}); |
| 31 | 32 | ||
| 32 | @override | 33 | @override |
| @@ -122,10 +122,10 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> { | @@ -122,10 +122,10 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> { | ||
| 122 | } | 122 | } |
| 123 | } | 123 | } |
| 124 | //选完今天明天刷新页面 | 124 | //选完今天明天刷新页面 |
| 125 | - int ddate = _getDdate(_notebookDetailChangeModel); | 125 | + int ddate = Utils.getDdate(_notebookDetailChangeModel.dateList); |
| 126 | String ddateSolt = | 126 | String ddateSolt = |
| 127 | - _getDdateSolt(_notebookDetailChangeModel); | ||
| 128 | - String pnum = _getPnum(_notebookDetailChangeModel); | 127 | + Utils.getDdateSolt(_notebookDetailChangeModel.sunDateList); |
| 128 | + String pnum = Utils.getPnum(_notebookDetailChangeModel.personNumList); | ||
| 129 | List<t.TableList> list = | 129 | List<t.TableList> list = |
| 130 | await _notebookDetailChangeModel.getNewTableList( | 130 | await _notebookDetailChangeModel.getNewTableList( |
| 131 | context, | 131 | context, |
| @@ -183,9 +183,9 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> { | @@ -183,9 +183,9 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> { | ||
| 183 | _notebookDetailChangeModel.notifyListeners(); | 183 | _notebookDetailChangeModel.notifyListeners(); |
| 184 | } | 184 | } |
| 185 | } | 185 | } |
| 186 | - int ddate = _getDdate(_notebookDetailChangeModel); | ||
| 187 | - String pnum = _getPnum(_notebookDetailChangeModel); | ||
| 188 | - String ddateSolt = _getDdateSolt(_notebookDetailChangeModel); | 186 | + int ddate = Utils.getDdate(_notebookDetailChangeModel.dateList); |
| 187 | + String pnum = Utils.getPnum(_notebookDetailChangeModel.personNumList); | ||
| 188 | + String ddateSolt = Utils.getDdateSolt(_notebookDetailChangeModel.sunDateList); | ||
| 189 | _notebookDetailChangeModel.getNewTableList( | 189 | _notebookDetailChangeModel.getNewTableList( |
| 190 | context, | 190 | context, |
| 191 | '${ddate}', | 191 | '${ddate}', |
| @@ -235,9 +235,9 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> { | @@ -235,9 +235,9 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> { | ||
| 235 | } | 235 | } |
| 236 | _notebookDetailChangeModel.notifyListeners(); | 236 | _notebookDetailChangeModel.notifyListeners(); |
| 237 | //人数选择页面刷新 | 237 | //人数选择页面刷新 |
| 238 | - String pnum = _getPnum(_notebookDetailChangeModel); | ||
| 239 | - int ddate = _getDdate(_notebookDetailChangeModel); | ||
| 240 | - String ddateSolt = _getDdateSolt(_notebookDetailChangeModel); | 238 | + String pnum = Utils.getPnum(_notebookDetailChangeModel.personNumList); |
| 239 | + int ddate = Utils.getDdate(_notebookDetailChangeModel.dateList); | ||
| 240 | + String ddateSolt = Utils.getDdateSolt(_notebookDetailChangeModel.sunDateList); | ||
| 241 | 241 | ||
| 242 | _notebookDetailChangeModel.getNewTableList( | 242 | _notebookDetailChangeModel.getNewTableList( |
| 243 | context, | 243 | context, |
| @@ -285,13 +285,13 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> { | @@ -285,13 +285,13 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> { | ||
| 285 | _notebookDetailChangeModel.dateList[2]['title'] = '其他'; | 285 | _notebookDetailChangeModel.dateList[2]['title'] = '其他'; |
| 286 | } | 286 | } |
| 287 | // 选完日历刷新页面 | 287 | // 选完日历刷新页面 |
| 288 | - String ddateSolt = _getDdateSolt(_notebookDetailChangeModel); | ||
| 289 | - String pnum = _getPnum(_notebookDetailChangeModel); | 288 | + String ddateSolt = Utils.getDdateSolt(_notebookDetailChangeModel.sunDateList); |
| 289 | + String pnum = Utils.getPnum(_notebookDetailChangeModel.personNumList); | ||
| 290 | _notebookDetailChangeModel.getNewTableList( | 290 | _notebookDetailChangeModel.getNewTableList( |
| 291 | context, | 291 | context, |
| 292 | '${dateTimeMill}', | 292 | '${dateTimeMill}', |
| 293 | ddateSolt, | 293 | ddateSolt, |
| 294 | - _getPnum(_notebookDetailChangeModel), | 294 | + pnum, |
| 295 | _notebookDetailChangeModel.tableList); | 295 | _notebookDetailChangeModel.tableList); |
| 296 | } | 296 | } |
| 297 | _notebookDetailChangeModel.notifyListeners(); | 297 | _notebookDetailChangeModel.notifyListeners(); |
| @@ -755,7 +755,7 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> { | @@ -755,7 +755,7 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> { | ||
| 755 | body: Column(children: <Widget>[ | 755 | body: Column(children: <Widget>[ |
| 756 | SizedBox(height: ScreenUtil.statusBarHeight), | 756 | SizedBox(height: ScreenUtil.statusBarHeight), |
| 757 | MyAppBar( | 757 | MyAppBar( |
| 758 | - "变更预订", | 758 | + widget.detailEntity.id=="-1"?"录入订座信息":"变更预订", |
| 759 | showBack: true, | 759 | showBack: true, |
| 760 | ), | 760 | ), |
| 761 | Expanded( | 761 | Expanded( |
| @@ -772,7 +772,7 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> { | @@ -772,7 +772,7 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> { | ||
| 772 | width: double.infinity, | 772 | width: double.infinity, |
| 773 | height: 84, | 773 | height: 84, |
| 774 | fontSize: 34, | 774 | fontSize: 34, |
| 775 | - content: "确定修改", | 775 | + content: widget.detailEntity.id=="-1"?"完成预订":"确定修改", |
| 776 | state: 2, | 776 | state: 2, |
| 777 | onPress: () async { | 777 | onPress: () async { |
| 778 | String name = | 778 | String name = |
| @@ -790,7 +790,7 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> { | @@ -790,7 +790,7 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> { | ||
| 790 | .setReserveInfo(context); | 790 | .setReserveInfo(context); |
| 791 | if (ObjectUtil.isNotEmpty(_model.row) || | 791 | if (ObjectUtil.isNotEmpty(_model.row) || |
| 792 | ObjectUtil.isNotEmpty(_model.row.id)) { | 792 | ObjectUtil.isNotEmpty(_model.row.id)) { |
| 793 | - print('变更成功'); | 793 | + print('成功'); |
| 794 | // _notebookDetailChangeModel.clearData(); | 794 | // _notebookDetailChangeModel.clearData(); |
| 795 | bus.emit("refresh_detail"); | 795 | bus.emit("refresh_detail"); |
| 796 | String ddate_solt = ''; | 796 | String ddate_solt = ''; |
| @@ -820,8 +820,11 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> { | @@ -820,8 +820,11 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> { | ||
| 820 | NavigatorUtil.goInvicationPage(context, _model.row.id, | 820 | NavigatorUtil.goInvicationPage(context, _model.row.id, |
| 821 | _nameStr, _model.row.ddate, ddate_solt, | 821 | _nameStr, _model.row.ddate, ddate_solt, |
| 822 | replace: true); | 822 | replace: true); |
| 823 | + if(widget.detailEntity.id=="-1"){ | ||
| 824 | + EventBus().emit("refresh_tablemanager"); | ||
| 825 | + } | ||
| 823 | } else { | 826 | } else { |
| 824 | - Utils.showToast("变更预订订单失败,请重试!"); | 827 | + Utils.showToast(widget.detailEntity.id=="-1"?"变更预订订单失败,请重试!":"变更预订订单失败,请重试!"); |
| 825 | } | 828 | } |
| 826 | }, | 829 | }, |
| 827 | )) | 830 | )) |
| @@ -830,48 +833,6 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> { | @@ -830,48 +833,6 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> { | ||
| 830 | } | 833 | } |
| 831 | } | 834 | } |
| 832 | 835 | ||
| 833 | -/// 获取日期 今天 明天 后天等等 | ||
| 834 | -int _getDdate(NotebookDetailChangeModel model) { | ||
| 835 | - //当前选中 月 日string | ||
| 836 | - String mdStr = ''; | ||
| 837 | - //今天 明天 其他天 | ||
| 838 | - for (var item in model.dateList) { | ||
| 839 | - if (item['select'] == true) { | ||
| 840 | - mdStr = item['title']; | ||
| 841 | - } | ||
| 842 | - } | ||
| 843 | - String timeNowYear = DateUtil.formatDate(DateTime.now(), format: 'yyyy'); | ||
| 844 | - String ymyStr = timeNowYear + '-' + mdStr; //年月日 | ||
| 845 | - String timeStr = ymyStr + ' ' + "00:00:00"; | ||
| 846 | - int ddate = DateUtil.getDateMsByTimeStr(timeStr); //筛选日期时间戳 | ||
| 847 | - return ddate; | ||
| 848 | -} | ||
| 849 | - | ||
| 850 | -/// 获取早餐、午餐、晚餐字段 1 ,2, 3 | ||
| 851 | -String _getDdateSolt(NotebookDetailChangeModel model) { | ||
| 852 | - String ddateSolt = ''; | ||
| 853 | - for (var item in model.sunDateList) { | ||
| 854 | - if (item['isSelect']) { | ||
| 855 | - ddateSolt = '${item['ddateSolt']}'; | ||
| 856 | - } | ||
| 857 | - } | ||
| 858 | - return ddateSolt; | ||
| 859 | -} | ||
| 860 | - | ||
| 861 | -/// 选中前面的按钮获取人数,输入的自己获取 | ||
| 862 | -String _getPnum(NotebookDetailChangeModel model) { | ||
| 863 | - String pnum = '6'; | ||
| 864 | - for (var item in model.personNumList) { | ||
| 865 | - if (item['isSelect']) { | ||
| 866 | - pnum = item['dateText']; | ||
| 867 | - } | ||
| 868 | - } | ||
| 869 | - if (pnum == '更多') { | ||
| 870 | - pnum = '6'; | ||
| 871 | - } | ||
| 872 | - return pnum; | ||
| 873 | -} | ||
| 874 | - | ||
| 875 | class CustomButton extends StatefulWidget { | 836 | class CustomButton extends StatefulWidget { |
| 876 | final String dateText; | 837 | final String dateText; |
| 877 | final String dayText; | 838 | final String dayText; |
| @@ -991,9 +952,9 @@ class _ButtonState extends State<CustomButton> { | @@ -991,9 +952,9 @@ class _ButtonState extends State<CustomButton> { | ||
| 991 | }, | 952 | }, |
| 992 | onEditingComplete: () { | 953 | onEditingComplete: () { |
| 993 | _cancelNode.unfocus(); | 954 | _cancelNode.unfocus(); |
| 994 | - int ddate = _getDdate(widget.model); | ||
| 995 | - String ddateSolt = _getDdateSolt(widget.model); | ||
| 996 | - String pnum = _getPnum(widget.model); | 955 | + int ddate = Utils.getDdate(widget.model.dateList); |
| 956 | + String ddateSolt = Utils.getDdateSolt(widget.model.sunDateList); | ||
| 957 | + String pnum = Utils.getPnum(widget.model.personNumList); | ||
| 997 | 958 | ||
| 998 | widget.model.getNewTableList(context, '${ddate}', | 959 | widget.model.getNewTableList(context, '${ddate}', |
| 999 | ddateSolt, pnum, widget.model.tableList); | 960 | ddateSolt, pnum, widget.model.tableList); |
| @@ -11,7 +11,6 @@ import 'package:one_key/provider/user_model.dart'; | @@ -11,7 +11,6 @@ import 'package:one_key/provider/user_model.dart'; | ||
| 11 | import 'package:one_key/res/colors.dart'; | 11 | import 'package:one_key/res/colors.dart'; |
| 12 | import 'package:one_key/utils/dialog_util.dart'; | 12 | import 'package:one_key/utils/dialog_util.dart'; |
| 13 | import 'package:one_key/utils/event_bus.dart'; | 13 | import 'package:one_key/utils/event_bus.dart'; |
| 14 | -import 'package:one_key/utils/log_util.dart'; | ||
| 15 | import 'package:one_key/utils/navigator_util.dart'; | 14 | import 'package:one_key/utils/navigator_util.dart'; |
| 16 | import 'package:one_key/utils/utils.dart'; | 15 | import 'package:one_key/utils/utils.dart'; |
| 17 | import 'package:one_key/widgets/MyDivider.dart'; | 16 | import 'package:one_key/widgets/MyDivider.dart'; |
| @@ -7,9 +7,7 @@ import 'package:flutter/services.dart'; | @@ -7,9 +7,7 @@ import 'package:flutter/services.dart'; | ||
| 7 | import 'package:flutter_screenutil/screenutil.dart'; | 7 | import 'package:flutter_screenutil/screenutil.dart'; |
| 8 | import 'package:one_key/models/notebook_detail.dart'; | 8 | import 'package:one_key/models/notebook_detail.dart'; |
| 9 | import 'package:one_key/models/reserve_info_model.dart'; | 9 | import 'package:one_key/models/reserve_info_model.dart'; |
| 10 | -import 'package:one_key/provider/notebook_detail_change_model.dart'; | ||
| 11 | -import 'package:one_key/provider/notebook_detail_model.dart'; | ||
| 12 | -import 'package:one_key/provider/user_model.dart'; | 10 | +import 'package:one_key/provider/enter_model.dart'; |
| 13 | import 'package:one_key/res/colors.dart'; | 11 | import 'package:one_key/res/colors.dart'; |
| 14 | import 'package:one_key/utils/dialog_util.dart'; | 12 | import 'package:one_key/utils/dialog_util.dart'; |
| 15 | import 'package:one_key/utils/event_bus.dart'; | 13 | import 'package:one_key/utils/event_bus.dart'; |
| @@ -20,7 +18,6 @@ import 'package:one_key/widgets/app_bar.dart'; | @@ -20,7 +18,6 @@ import 'package:one_key/widgets/app_bar.dart'; | ||
| 20 | import 'package:one_key/widgets/common_button.dart'; | 18 | import 'package:one_key/widgets/common_button.dart'; |
| 21 | import 'package:one_key/widgets/h_empty_view.dart'; | 19 | import 'package:one_key/widgets/h_empty_view.dart'; |
| 22 | import 'package:one_key/widgets/new_table_item.dart'; | 20 | import 'package:one_key/widgets/new_table_item.dart'; |
| 23 | -import 'package:one_key/widgets/table_item.dart'; | ||
| 24 | import 'package:one_key/widgets/v_empty_view.dart'; | 21 | import 'package:one_key/widgets/v_empty_view.dart'; |
| 25 | import 'package:provider/provider.dart'; | 22 | import 'package:provider/provider.dart'; |
| 26 | import 'package:one_key/models/table_list.dart' as t; | 23 | import 'package:one_key/models/table_list.dart' as t; |
| @@ -34,28 +31,29 @@ class EnterPage extends StatefulWidget { | @@ -34,28 +31,29 @@ class EnterPage extends StatefulWidget { | ||
| 34 | 31 | ||
| 35 | const EnterPage({Key key, this.detailEntity, this.rid}) | 32 | const EnterPage({Key key, this.detailEntity, this.rid}) |
| 36 | : super(key: key); | 33 | : super(key: key); |
| 34 | + | ||
| 37 | @override | 35 | @override |
| 38 | _EnterPageState createState() => _EnterPageState(); | 36 | _EnterPageState createState() => _EnterPageState(); |
| 39 | } | 37 | } |
| 40 | 38 | ||
| 41 | class _EnterPageState extends State<EnterPage> { | 39 | class _EnterPageState extends State<EnterPage> { |
| 42 | DateTime dateTime; //当前日期 | 40 | DateTime dateTime; //当前日期 |
| 43 | - NotebookDetailChangeModel _notebookDetailChangeModel; | 41 | + EnterModel _enterModel; |
| 44 | FocusNode _phoneNode = FocusNode(); | 42 | FocusNode _phoneNode = FocusNode(); |
| 45 | FocusNode _nameNode = FocusNode(); | 43 | FocusNode _nameNode = FocusNode(); |
| 46 | FocusNode _needNode = FocusNode(); | 44 | FocusNode _needNode = FocusNode(); |
| 47 | - NotebookDetailModel detailModel = NotebookDetailModel(); | ||
| 48 | 45 | ||
| 49 | @override | 46 | @override |
| 50 | void initState() { | 47 | void initState() { |
| 51 | super.initState(); | 48 | super.initState(); |
| 49 | + LogUtil.v(widget.detailEntity.toString()); | ||
| 52 | dateTime = DateTime.now(); | 50 | dateTime = DateTime.now(); |
| 53 | - | ||
| 54 | - _notebookDetailChangeModel = | ||
| 55 | - Provider.of<NotebookDetailChangeModel>(context, listen: false); | ||
| 56 | - _notebookDetailChangeModel.initDateHourMinuteList(context); | 51 | + _enterModel = |
| 52 | + Provider.of<EnterModel>(context, listen: true); | ||
| 53 | + _enterModel.initData(widget.detailEntity); | ||
| 54 | + _enterModel.initDateHourMinuteList(context); | ||
| 57 | String ddate = widget.detailEntity.ddate.toString() + '000'; | 55 | String ddate = widget.detailEntity.ddate.toString() + '000'; |
| 58 | - _notebookDetailChangeModel.getNewTableList( | 56 | + _enterModel.getNewTableList( |
| 59 | context, | 57 | context, |
| 60 | ddate, | 58 | ddate, |
| 61 | widget.detailEntity.ddate_solt, | 59 | widget.detailEntity.ddate_solt, |
| @@ -79,7 +77,7 @@ class _EnterPageState extends State<EnterPage> { | @@ -79,7 +77,7 @@ class _EnterPageState extends State<EnterPage> { | ||
| 79 | //第一行 日期选择 | 77 | //第一行 日期选择 |
| 80 | Row( | 78 | Row( |
| 81 | mainAxisAlignment: MainAxisAlignment.spaceBetween, | 79 | mainAxisAlignment: MainAxisAlignment.spaceBetween, |
| 82 | - children: _notebookDetailChangeModel.dateList.map((value) { | 80 | + children: _enterModel.dateList.map((value) { |
| 83 | return CustomButton( | 81 | return CustomButton( |
| 84 | dateText: value['title'], | 82 | dateText: value['title'], |
| 85 | fontSize: value['fontSize'], | 83 | fontSize: value['fontSize'], |
| @@ -94,24 +92,24 @@ class _EnterPageState extends State<EnterPage> { | @@ -94,24 +92,24 @@ class _EnterPageState extends State<EnterPage> { | ||
| 94 | _calendWidget(DateTime.now()); | 92 | _calendWidget(DateTime.now()); |
| 95 | } else { | 93 | } else { |
| 96 | for (int j = 0; | 94 | for (int j = 0; |
| 97 | - j < _notebookDetailChangeModel.dateList.length; | 95 | + j < _enterModel.dateList.length; |
| 98 | j++) { | 96 | j++) { |
| 99 | - _notebookDetailChangeModel.dateList[j]['select'] = | 97 | + _enterModel.dateList[j]['select'] = |
| 100 | false; | 98 | false; |
| 101 | 99 | ||
| 102 | - if (_notebookDetailChangeModel.dateList[j]['title'] == | 100 | + if (_enterModel.dateList[j]['title'] == |
| 103 | value['title']) { | 101 | value['title']) { |
| 104 | - _notebookDetailChangeModel.dateList[j]['select'] = | 102 | + _enterModel.dateList[j]['select'] = |
| 105 | true; | 103 | true; |
| 106 | 104 | ||
| 107 | if (j == 0 || j == 1) { | 105 | if (j == 0 || j == 1) { |
| 108 | - _notebookDetailChangeModel.dateList[2]['title'] = | 106 | + _enterModel.dateList[2]['title'] = |
| 109 | '其他'; | 107 | '其他'; |
| 110 | } | 108 | } |
| 111 | if (j == | 109 | if (j == |
| 112 | - _notebookDetailChangeModel.dateList.length - 1) { | 110 | + _enterModel.dateList.length - 1) { |
| 113 | String selectStr = | 111 | String selectStr = |
| 114 | - _notebookDetailChangeModel.dateList[2]['title']; | 112 | + _enterModel.dateList[2]['title']; |
| 115 | String timeNow = DateUtil.formatDate( | 113 | String timeNow = DateUtil.formatDate( |
| 116 | DateTime.now(), | 114 | DateTime.now(), |
| 117 | ); | 115 | ); |
| @@ -122,22 +120,23 @@ class _EnterPageState extends State<EnterPage> { | @@ -122,22 +120,23 @@ class _EnterPageState extends State<EnterPage> { | ||
| 122 | } | 120 | } |
| 123 | } | 121 | } |
| 124 | //选完今天明天刷新页面 | 122 | //选完今天明天刷新页面 |
| 125 | - int ddate = _getDdate(_notebookDetailChangeModel); | 123 | + int ddate = Utils.getDdate(_enterModel.dateList); |
| 124 | + _enterModel.updateSunDateList(DateTime.fromMillisecondsSinceEpoch(ddate), context); | ||
| 126 | String ddateSolt = | 125 | String ddateSolt = |
| 127 | - _getDdateSolt(_notebookDetailChangeModel); | ||
| 128 | - String pnum = _getPnum(_notebookDetailChangeModel); | 126 | + Utils.getDdateSolt(_enterModel.sunDateList); |
| 127 | + String pnum = Utils.getPnum(_enterModel.personNumList); | ||
| 129 | List<t.TableList> list = | 128 | List<t.TableList> list = |
| 130 | - await _notebookDetailChangeModel.getNewTableList( | 129 | + await _enterModel.getNewTableList( |
| 131 | context, | 130 | context, |
| 132 | '${ddate}', | 131 | '${ddate}', |
| 133 | ddateSolt, | 132 | ddateSolt, |
| 134 | pnum, | 133 | pnum, |
| 135 | - _notebookDetailChangeModel.tableList); | 134 | + _enterModel.tableList); |
| 136 | if (list.length == 0) { | 135 | if (list.length == 0) { |
| 137 | - _notebookDetailChangeModel.isRecommend = true; | 136 | + _enterModel.isRecommend = true; |
| 138 | } | 137 | } |
| 139 | } | 138 | } |
| 140 | - _notebookDetailChangeModel.notifyListeners(); | 139 | + _enterModel.notifyListeners(); |
| 141 | }, | 140 | }, |
| 142 | ); | 141 | ); |
| 143 | }).toList()), | 142 | }).toList()), |
| @@ -146,16 +145,17 @@ class _EnterPageState extends State<EnterPage> { | @@ -146,16 +145,17 @@ class _EnterPageState extends State<EnterPage> { | ||
| 146 | //早市、午市、晚市 | 145 | //早市、午市、晚市 |
| 147 | Row( | 146 | Row( |
| 148 | // mainAxisAlignment: MainAxisAlignment.spaceBetween, | 147 | // mainAxisAlignment: MainAxisAlignment.spaceBetween, |
| 149 | - children: _notebookDetailChangeModel.sunDateList.map((value) { | 148 | + children: _enterModel.sunDateList.map((value) { |
| 150 | return Container( | 149 | return Container( |
| 151 | - margin: _notebookDetailChangeModel.sunDateList.length == 3 && | 150 | + margin: _enterModel.sunDateList.length == 3 && |
| 152 | value['ddateSolt'] == 3 | 151 | value['ddateSolt'] == 3 |
| 153 | ? EdgeInsets.only(right: 0) | 152 | ? EdgeInsets.only(right: 0) |
| 154 | : EdgeInsets.only(right: ScreenUtil().setWidth(20)), | 153 | : EdgeInsets.only(right: ScreenUtil().setWidth(20)), |
| 155 | child: CustomButton( | 154 | child: CustomButton( |
| 156 | onTap: () { | 155 | onTap: () { |
| 157 | FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 | 156 | FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 |
| 158 | - for (var item in _notebookDetailChangeModel.sunDateList) { | 157 | + if(!value['isEnable'])return; |
| 158 | + for (var item in _enterModel.sunDateList) { | ||
| 159 | item['isSelect'] = false; | 159 | item['isSelect'] = false; |
| 160 | if (item['dateText'] == value['dateText']) { | 160 | if (item['dateText'] == value['dateText']) { |
| 161 | item['isSelect'] = true; | 161 | item['isSelect'] = true; |
| @@ -173,28 +173,29 @@ class _EnterPageState extends State<EnterPage> { | @@ -173,28 +173,29 @@ class _EnterPageState extends State<EnterPage> { | ||
| 173 | } | 173 | } |
| 174 | if (key != '') { | 174 | if (key != '') { |
| 175 | for (var sunitem | 175 | for (var sunitem |
| 176 | - in _notebookDetailChangeModel.dailyMap[key]) { | 176 | + in _enterModel.dailyMap[key]) { |
| 177 | if (sunitem['select'] == true) { | 177 | if (sunitem['select'] == true) { |
| 178 | - _notebookDetailChangeModel.ddateStr = | 178 | + _enterModel.ddateStr = |
| 179 | sunitem['title']; | 179 | sunitem['title']; |
| 180 | } | 180 | } |
| 181 | } | 181 | } |
| 182 | } | 182 | } |
| 183 | - _notebookDetailChangeModel.notifyListeners(); | 183 | + _enterModel.notifyListeners(); |
| 184 | } | 184 | } |
| 185 | } | 185 | } |
| 186 | - int ddate = _getDdate(_notebookDetailChangeModel); | ||
| 187 | - String pnum = _getPnum(_notebookDetailChangeModel); | ||
| 188 | - String ddateSolt = _getDdateSolt(_notebookDetailChangeModel); | ||
| 189 | - _notebookDetailChangeModel.getNewTableList( | 186 | + int ddate = Utils.getDdate(_enterModel.dateList); |
| 187 | + String pnum = Utils.getPnum(_enterModel.personNumList); | ||
| 188 | + String ddateSolt = Utils.getDdateSolt(_enterModel.sunDateList); | ||
| 189 | + _enterModel.getNewTableList( | ||
| 190 | context, | 190 | context, |
| 191 | '${ddate}', | 191 | '${ddate}', |
| 192 | '${ddateSolt}', | 192 | '${ddateSolt}', |
| 193 | pnum, | 193 | pnum, |
| 194 | - _notebookDetailChangeModel.tableList); | 194 | + _enterModel.tableList); |
| 195 | }, | 195 | }, |
| 196 | dateText: value['dateText'], | 196 | dateText: value['dateText'], |
| 197 | dayText: '', | 197 | dayText: '', |
| 198 | + isEnable: value['isEnable'], | ||
| 198 | isSelect: value['isSelect'], | 199 | isSelect: value['isSelect'], |
| 199 | ), | 200 | ), |
| 200 | ); | 201 | ); |
| @@ -204,23 +205,23 @@ class _EnterPageState extends State<EnterPage> { | @@ -204,23 +205,23 @@ class _EnterPageState extends State<EnterPage> { | ||
| 204 | ///人数选择 | 205 | ///人数选择 |
| 205 | Row( | 206 | Row( |
| 206 | mainAxisAlignment: MainAxisAlignment.spaceBetween, | 207 | mainAxisAlignment: MainAxisAlignment.spaceBetween, |
| 207 | - children: _notebookDetailChangeModel.personNumList.map((value) { | 208 | + children: _enterModel.personNumList.map((value) { |
| 208 | return CustomButton( | 209 | return CustomButton( |
| 209 | onTap: () { | 210 | onTap: () { |
| 210 | for (int j = 0; | 211 | for (int j = 0; |
| 211 | - j < _notebookDetailChangeModel.personNumList.length; | 212 | + j < _enterModel.personNumList.length; |
| 212 | j++) { | 213 | j++) { |
| 213 | - _notebookDetailChangeModel.personNumList[j]['isSelect'] = | 214 | + _enterModel.personNumList[j]['isSelect'] = |
| 214 | false; | 215 | false; |
| 215 | 216 | ||
| 216 | - if (_notebookDetailChangeModel.personNumList[j] | 217 | + if (_enterModel.personNumList[j] |
| 217 | ['dateText'] == | 218 | ['dateText'] == |
| 218 | value['dateText']) { | 219 | value['dateText']) { |
| 219 | - _notebookDetailChangeModel.personNumList[j]['isSelect'] = | 220 | + _enterModel.personNumList[j]['isSelect'] = |
| 220 | true; | 221 | true; |
| 221 | 222 | ||
| 222 | if (j < 5) { | 223 | if (j < 5) { |
| 223 | - _notebookDetailChangeModel.numController.text = | 224 | + _enterModel.numController.text = |
| 224 | value['dateText']; | 225 | value['dateText']; |
| 225 | FocusScope.of(context) | 226 | FocusScope.of(context) |
| 226 | .requestFocus(FocusNode()); //点击空白处隐藏键盘 | 227 | .requestFocus(FocusNode()); //点击空白处隐藏键盘 |
| @@ -228,23 +229,23 @@ class _EnterPageState extends State<EnterPage> { | @@ -228,23 +229,23 @@ class _EnterPageState extends State<EnterPage> { | ||
| 228 | } | 229 | } |
| 229 | 230 | ||
| 230 | // if (j < 5) { | 231 | // if (j < 5) { |
| 231 | - // _notebookDetailChangeModel.personNumList[5] | 232 | + // _enterModel.personNumList[5] |
| 232 | // ['dateText'] = '更多'; | 233 | // ['dateText'] = '更多'; |
| 233 | // } | 234 | // } |
| 234 | } | 235 | } |
| 235 | } | 236 | } |
| 236 | - _notebookDetailChangeModel.notifyListeners(); | 237 | + _enterModel.notifyListeners(); |
| 237 | //人数选择页面刷新 | 238 | //人数选择页面刷新 |
| 238 | - String pnum = _getPnum(_notebookDetailChangeModel); | ||
| 239 | - int ddate = _getDdate(_notebookDetailChangeModel); | ||
| 240 | - String ddateSolt = _getDdateSolt(_notebookDetailChangeModel); | 239 | + String pnum = Utils.getPnum(_enterModel.personNumList); |
| 240 | + int ddate = Utils.getDdate(_enterModel.dateList); | ||
| 241 | + String ddateSolt = Utils.getDdateSolt(_enterModel.sunDateList); | ||
| 241 | 242 | ||
| 242 | - _notebookDetailChangeModel.getNewTableList( | 243 | + _enterModel.getNewTableList( |
| 243 | context, | 244 | context, |
| 244 | '${ddate}', | 245 | '${ddate}', |
| 245 | ddateSolt, | 246 | ddateSolt, |
| 246 | pnum, | 247 | pnum, |
| 247 | - _notebookDetailChangeModel.tableList); | 248 | + _enterModel.tableList); |
| 248 | }, | 249 | }, |
| 249 | dateText: value['dateText'], | 250 | dateText: value['dateText'], |
| 250 | fontSize: value['fontSize'], | 251 | fontSize: value['fontSize'], |
| @@ -253,7 +254,7 @@ class _EnterPageState extends State<EnterPage> { | @@ -253,7 +254,7 @@ class _EnterPageState extends State<EnterPage> { | ||
| 253 | isImage: value['isImage'], | 254 | isImage: value['isImage'], |
| 254 | isSelect: value['isSelect'], | 255 | isSelect: value['isSelect'], |
| 255 | isTextFiled: value['isTextFiled'], | 256 | isTextFiled: value['isTextFiled'], |
| 256 | - model: _notebookDetailChangeModel, | 257 | + model: _enterModel, |
| 257 | ); | 258 | ); |
| 258 | }).toList(), | 259 | }).toList(), |
| 259 | ) | 260 | ) |
| @@ -270,41 +271,42 @@ class _EnterPageState extends State<EnterPage> { | @@ -270,41 +271,42 @@ class _EnterPageState extends State<EnterPage> { | ||
| 270 | int dateTimeMill = day.millisecondsSinceEpoch; | 271 | int dateTimeMill = day.millisecondsSinceEpoch; |
| 271 | String dateText = DateUtil.formatDateMs(dateTimeMill, format: 'MM-dd'); | 272 | String dateText = DateUtil.formatDateMs(dateTimeMill, format: 'MM-dd'); |
| 272 | bool isThird = true; | 273 | bool isThird = true; |
| 273 | - for (int i = 0; i < _notebookDetailChangeModel.dateList.length; i++) { | ||
| 274 | - _notebookDetailChangeModel.dateList[i]['select'] = false; | 274 | + for (int i = 0; i < _enterModel.dateList.length; i++) { |
| 275 | + _enterModel.dateList[i]['select'] = false; | ||
| 275 | 276 | ||
| 276 | - if (_notebookDetailChangeModel.dateList[i]['title'] == dateText) { | ||
| 277 | - _notebookDetailChangeModel.dateList[i]['select'] = true; | 277 | + if (_enterModel.dateList[i]['title'] == dateText) { |
| 278 | + _enterModel.dateList[i]['select'] = true; | ||
| 278 | isThird = false; | 279 | isThird = false; |
| 279 | } | 280 | } |
| 280 | } | 281 | } |
| 281 | if (isThird) { | 282 | if (isThird) { |
| 282 | - _notebookDetailChangeModel.dateList[2]['select'] = true; | ||
| 283 | - _notebookDetailChangeModel.dateList[2]['title'] = dateText; | 283 | + _enterModel.dateList[2]['select'] = true; |
| 284 | + _enterModel.dateList[2]['title'] = dateText; | ||
| 284 | } else { | 285 | } else { |
| 285 | - _notebookDetailChangeModel.dateList[2]['title'] = '其他'; | 286 | + _enterModel.dateList[2]['title'] = '其他'; |
| 286 | } | 287 | } |
| 288 | + _enterModel.updateSunDateList(dateTime, context); | ||
| 287 | // 选完日历刷新页面 | 289 | // 选完日历刷新页面 |
| 288 | - String ddateSolt = _getDdateSolt(_notebookDetailChangeModel); | ||
| 289 | - String pnum = _getPnum(_notebookDetailChangeModel); | ||
| 290 | - _notebookDetailChangeModel.getNewTableList( | 290 | + String ddateSolt = Utils.getDdateSolt(_enterModel.sunDateList); |
| 291 | + String pnum = Utils.getPnum(_enterModel.personNumList); | ||
| 292 | + _enterModel.getNewTableList( | ||
| 291 | context, | 293 | context, |
| 292 | '${dateTimeMill}', | 294 | '${dateTimeMill}', |
| 293 | ddateSolt, | 295 | ddateSolt, |
| 294 | - _getPnum(_notebookDetailChangeModel), | ||
| 295 | - _notebookDetailChangeModel.tableList); | 296 | + pnum, |
| 297 | + _enterModel.tableList); | ||
| 296 | } | 298 | } |
| 297 | - _notebookDetailChangeModel.notifyListeners(); | 299 | + _enterModel.notifyListeners(); |
| 298 | }); | 300 | }); |
| 299 | } | 301 | } |
| 300 | 302 | ||
| 301 | /// 可订桌位 | 303 | /// 可订桌位 |
| 302 | _middleWidget() { | 304 | _middleWidget() { |
| 303 | List canBookTable = []; | 305 | List canBookTable = []; |
| 304 | - if (_notebookDetailChangeModel.isRecommend) { | ||
| 305 | - canBookTable = _notebookDetailChangeModel.recommendList; | 306 | + if (_enterModel.isRecommend) { |
| 307 | + canBookTable = _enterModel.recommendList; | ||
| 306 | } else { | 308 | } else { |
| 307 | - canBookTable = _notebookDetailChangeModel.tableList; | 309 | + canBookTable = _enterModel.tableList; |
| 308 | } | 310 | } |
| 309 | return Container( | 311 | return Container( |
| 310 | padding: EdgeInsets.all(ScreenUtil().setWidth(40)), | 312 | padding: EdgeInsets.all(ScreenUtil().setWidth(40)), |
| @@ -317,7 +319,7 @@ class _EnterPageState extends State<EnterPage> { | @@ -317,7 +319,7 @@ class _EnterPageState extends State<EnterPage> { | ||
| 317 | //当前选中 月 日string | 319 | //当前选中 月 日string |
| 318 | String mdStr = ''; | 320 | String mdStr = ''; |
| 319 | //今天 明天 其他天 | 321 | //今天 明天 其他天 |
| 320 | - for (var item in _notebookDetailChangeModel.dateList) { | 322 | + for (var item in _enterModel.dateList) { |
| 321 | if (item['select'] == true) { | 323 | if (item['select'] == true) { |
| 322 | mdStr = item['title']; | 324 | mdStr = item['title']; |
| 323 | } | 325 | } |
| @@ -328,7 +330,7 @@ class _EnterPageState extends State<EnterPage> { | @@ -328,7 +330,7 @@ class _EnterPageState extends State<EnterPage> { | ||
| 328 | String timeStr = ymyStr + ' ' + "00:00:00"; | 330 | String timeStr = ymyStr + ' ' + "00:00:00"; |
| 329 | int ddate = DateUtil.getDateMsByTimeStr(timeStr); //筛选日期时间戳 | 331 | int ddate = DateUtil.getDateMsByTimeStr(timeStr); //筛选日期时间戳 |
| 330 | String ddateSolt = ''; | 332 | String ddateSolt = ''; |
| 331 | - for (var item in _notebookDetailChangeModel.sunDateList) { | 333 | + for (var item in _enterModel.sunDateList) { |
| 332 | if (item['isSelect']) { | 334 | if (item['isSelect']) { |
| 333 | ddateSolt = '${item['ddateSolt']}'; | 335 | ddateSolt = '${item['ddateSolt']}'; |
| 334 | } | 336 | } |
| @@ -339,34 +341,34 @@ class _EnterPageState extends State<EnterPage> { | @@ -339,34 +341,34 @@ class _EnterPageState extends State<EnterPage> { | ||
| 339 | Map temp = await NavigatorUtil.goSelectTablePage( | 341 | Map temp = await NavigatorUtil.goSelectTablePage( |
| 340 | context, widget.rid, ddate, ddateSolt, | 342 | context, widget.rid, ddate, ddateSolt, |
| 341 | canChoose: true, | 343 | canChoose: true, |
| 342 | - object: {'object': _notebookDetailChangeModel.tableList}); | 344 | + object: {'object': _enterModel.tableList}); |
| 343 | // if (temp['tid'] != null) { | 345 | // if (temp['tid'] != null) { |
| 344 | // setReserveStatus("5", tid: temp['tid']); | 346 | // setReserveStatus("5", tid: temp['tid']); |
| 345 | // } | 347 | // } |
| 346 | if (temp == null || temp['object'].length == 0) { | 348 | if (temp == null || temp['object'].length == 0) { |
| 347 | - if (_notebookDetailChangeModel.tableList.length == 0) { | ||
| 348 | - _notebookDetailChangeModel.isRecommend = true; | ||
| 349 | - _notebookDetailChangeModel.tableList = []; | 349 | + if (_enterModel.tableList.length == 0) { |
| 350 | + _enterModel.isRecommend = true; | ||
| 351 | + _enterModel.tableList = []; | ||
| 350 | for (t.TableList item | 352 | for (t.TableList item |
| 351 | - in _notebookDetailChangeModel.recommendList) { | 353 | + in _enterModel.recommendList) { |
| 352 | item.selected = false; | 354 | item.selected = false; |
| 353 | } | 355 | } |
| 354 | setState(() {}); | 356 | setState(() {}); |
| 355 | } | 357 | } |
| 356 | } else { | 358 | } else { |
| 357 | - _notebookDetailChangeModel.isRecommend = false; | ||
| 358 | - _notebookDetailChangeModel.tableList = temp['object']; | ||
| 359 | - // if (_notebookDetailChangeModel.tableList.length == 0) { | 359 | + _enterModel.isRecommend = false; |
| 360 | + _enterModel.tableList = temp['object']; | ||
| 361 | + // if (_enterModel.tableList.length == 0) { | ||
| 360 | // isRecommend = true; | 362 | // isRecommend = true; |
| 361 | // } | 363 | // } |
| 362 | for (t.TableList item | 364 | for (t.TableList item |
| 363 | - in _notebookDetailChangeModel.tableList) { | 365 | + in _enterModel.tableList) { |
| 364 | item.selected = true; | 366 | item.selected = true; |
| 365 | } | 367 | } |
| 366 | setState(() {}); | 368 | setState(() {}); |
| 367 | } | 369 | } |
| 368 | 370 | ||
| 369 | - // _notebookDetailChangeModel.notifyListeners(); | 371 | + // _enterModel.notifyListeners(); |
| 370 | }, | 372 | }, |
| 371 | child: Row( | 373 | child: Row( |
| 372 | mainAxisAlignment: MainAxisAlignment.spaceBetween, | 374 | mainAxisAlignment: MainAxisAlignment.spaceBetween, |
| @@ -410,9 +412,9 @@ class _EnterPageState extends State<EnterPage> { | @@ -410,9 +412,9 @@ class _EnterPageState extends State<EnterPage> { | ||
| 410 | canSelected: true, | 412 | canSelected: true, |
| 411 | onSelected: (table) { | 413 | onSelected: (table) { |
| 412 | if ((table as t.TableList).selected) { | 414 | if ((table as t.TableList).selected) { |
| 413 | - _notebookDetailChangeModel.tableList.add(table); | 415 | + _enterModel.tableList.add(table); |
| 414 | } else { | 416 | } else { |
| 415 | - _notebookDetailChangeModel.tableList | 417 | + _enterModel.tableList |
| 416 | .removeWhere((t) => t.id == table.id); | 418 | .removeWhere((t) => t.id == table.id); |
| 417 | } | 419 | } |
| 418 | }, | 420 | }, |
| @@ -448,7 +450,7 @@ class _EnterPageState extends State<EnterPage> { | @@ -448,7 +450,7 @@ class _EnterPageState extends State<EnterPage> { | ||
| 448 | style: TextStyle( | 450 | style: TextStyle( |
| 449 | fontSize: ScreenUtil().setSp(34), | 451 | fontSize: ScreenUtil().setSp(34), |
| 450 | color: MyColours.color_353535), | 452 | color: MyColours.color_353535), |
| 451 | - controller: _notebookDetailChangeModel.phoneController, | 453 | + controller: _enterModel.phoneController, |
| 452 | focusNode: _phoneNode, | 454 | focusNode: _phoneNode, |
| 453 | // textAlignVertical: TextAlignVertical.top, | 455 | // textAlignVertical: TextAlignVertical.top, |
| 454 | decoration: InputDecoration( | 456 | decoration: InputDecoration( |
| @@ -477,7 +479,7 @@ class _EnterPageState extends State<EnterPage> { | @@ -477,7 +479,7 @@ class _EnterPageState extends State<EnterPage> { | ||
| 477 | child: Text( | 479 | child: Text( |
| 478 | int.parse(widget.detailEntity.is_set_ddate) == 0 | 480 | int.parse(widget.detailEntity.is_set_ddate) == 0 |
| 479 | ? '未设置到店时间' | 481 | ? '未设置到店时间' |
| 480 | - : _notebookDetailChangeModel.ddateStr, | 482 | + : _enterModel.ddateStr, |
| 481 | style: TextStyle( | 483 | style: TextStyle( |
| 482 | color: int.parse(widget.detailEntity.is_set_ddate) == 0 | 484 | color: int.parse(widget.detailEntity.is_set_ddate) == 0 |
| 483 | ? MyColours.color_999999 | 485 | ? MyColours.color_999999 |
| @@ -504,7 +506,7 @@ class _EnterPageState extends State<EnterPage> { | @@ -504,7 +506,7 @@ class _EnterPageState extends State<EnterPage> { | ||
| 504 | style: TextStyle( | 506 | style: TextStyle( |
| 505 | fontSize: ScreenUtil().setSp(34), | 507 | fontSize: ScreenUtil().setSp(34), |
| 506 | color: MyColours.color_353535), | 508 | color: MyColours.color_353535), |
| 507 | - controller: _notebookDetailChangeModel.nameController, | 509 | + controller: _enterModel.nameController, |
| 508 | focusNode: _nameNode, | 510 | focusNode: _nameNode, |
| 509 | // textAlignVertical: TextAlignVertical.top, | 511 | // textAlignVertical: TextAlignVertical.top, |
| 510 | decoration: InputDecoration( | 512 | decoration: InputDecoration( |
| @@ -527,16 +529,16 @@ class _EnterPageState extends State<EnterPage> { | @@ -527,16 +529,16 @@ class _EnterPageState extends State<EnterPage> { | ||
| 527 | ), | 529 | ), |
| 528 | HEmptyView(40), | 530 | HEmptyView(40), |
| 529 | Row( | 531 | Row( |
| 530 | - children: _notebookDetailChangeModel.sexList.map((value) { | 532 | + children: _enterModel.sexList.map((value) { |
| 531 | return _callButton( | 533 | return _callButton( |
| 532 | onPress: () { | 534 | onPress: () { |
| 533 | - for (var item in _notebookDetailChangeModel.sexList) { | 535 | + for (var item in _enterModel.sexList) { |
| 534 | item['select'] = false; | 536 | item['select'] = false; |
| 535 | if (item['title'] == value['title']) { | 537 | if (item['title'] == value['title']) { |
| 536 | item['select'] = true; | 538 | item['select'] = true; |
| 537 | } | 539 | } |
| 538 | } | 540 | } |
| 539 | - _notebookDetailChangeModel.notifyListeners(); | 541 | + _enterModel.notifyListeners(); |
| 540 | }, | 542 | }, |
| 541 | content: value['title'], | 543 | content: value['title'], |
| 542 | hasLeftBorder: value['hasLeftBorder'], | 544 | hasLeftBorder: value['hasLeftBorder'], |
| @@ -555,7 +557,7 @@ class _EnterPageState extends State<EnterPage> { | @@ -555,7 +557,7 @@ class _EnterPageState extends State<EnterPage> { | ||
| 555 | style: TextStyle( | 557 | style: TextStyle( |
| 556 | fontSize: ScreenUtil().setSp(34), | 558 | fontSize: ScreenUtil().setSp(34), |
| 557 | color: MyColours.color_353535), | 559 | color: MyColours.color_353535), |
| 558 | - controller: _notebookDetailChangeModel.customController, | 560 | + controller: _enterModel.customController, |
| 559 | focusNode: _needNode, | 561 | focusNode: _needNode, |
| 560 | // textAlignVertical: TextAlignVertical.top, | 562 | // textAlignVertical: TextAlignVertical.top, |
| 561 | decoration: InputDecoration( | 563 | decoration: InputDecoration( |
| @@ -591,11 +593,11 @@ class _EnterPageState extends State<EnterPage> { | @@ -591,11 +593,11 @@ class _EnterPageState extends State<EnterPage> { | ||
| 591 | 593 | ||
| 592 | String title = '早市'; | 594 | String title = '早市'; |
| 593 | String key; | 595 | String key; |
| 594 | - for (var item in _notebookDetailChangeModel.sunDateList) { | 596 | + for (var item in _enterModel.sunDateList) { |
| 595 | if (item['isSelect'] == true) { | 597 | if (item['isSelect'] == true) { |
| 596 | title = item['dateText']; | 598 | title = item['dateText']; |
| 597 | key = item['key']; | 599 | key = item['key']; |
| 598 | - tempMndList = _notebookDetailChangeModel.dailyMap[key]; | 600 | + tempMndList = _enterModel.dailyMap[key]; |
| 599 | } | 601 | } |
| 600 | } | 602 | } |
| 601 | //计算行数 | 603 | //计算行数 |
| @@ -677,14 +679,14 @@ class _EnterPageState extends State<EnterPage> { | @@ -677,14 +679,14 @@ class _EnterPageState extends State<EnterPage> { | ||
| 677 | tempMndList[index]['title']) { | 679 | tempMndList[index]['title']) { |
| 678 | item['select'] = true; | 680 | item['select'] = true; |
| 679 | widget.detailEntity.is_set_ddate = '1'; | 681 | widget.detailEntity.is_set_ddate = '1'; |
| 680 | - _notebookDetailChangeModel.isSetDate = "1"; | ||
| 681 | - _notebookDetailChangeModel.ddateStr = | 682 | + _enterModel.isSetDate = "1"; |
| 683 | + _enterModel.ddateStr = | ||
| 682 | item['title']; | 684 | item['title']; |
| 683 | } | 685 | } |
| 684 | } | 686 | } |
| 685 | // }); | 687 | // }); |
| 686 | 688 | ||
| 687 | - _notebookDetailChangeModel.notifyListeners(); | 689 | + _enterModel.notifyListeners(); |
| 688 | Navigator.pop(context); | 690 | Navigator.pop(context); |
| 689 | }, | 691 | }, |
| 690 | width: 80, | 692 | width: 80, |
| @@ -743,8 +745,6 @@ class _EnterPageState extends State<EnterPage> { | @@ -743,8 +745,6 @@ class _EnterPageState extends State<EnterPage> { | ||
| 743 | 745 | ||
| 744 | @override | 746 | @override |
| 745 | Widget build(BuildContext context) { | 747 | Widget build(BuildContext context) { |
| 746 | - _notebookDetailChangeModel = | ||
| 747 | - Provider.of<NotebookDetailChangeModel>(context, listen: true); | ||
| 748 | return GestureDetector( | 748 | return GestureDetector( |
| 749 | behavior: HitTestBehavior.translucent, | 749 | behavior: HitTestBehavior.translucent, |
| 750 | onTap: () { | 750 | onTap: () { |
| @@ -752,142 +752,103 @@ class _EnterPageState extends State<EnterPage> { | @@ -752,142 +752,103 @@ class _EnterPageState extends State<EnterPage> { | ||
| 752 | }, | 752 | }, |
| 753 | child: Scaffold( | 753 | child: Scaffold( |
| 754 | backgroundColor: Colors.white, | 754 | backgroundColor: Colors.white, |
| 755 | - body: Column(children: <Widget>[ | ||
| 756 | - SizedBox(height: ScreenUtil.statusBarHeight), | ||
| 757 | - MyAppBar( | ||
| 758 | - "变更预订", | ||
| 759 | - showBack: true, | ||
| 760 | - ), | ||
| 761 | - Expanded( | ||
| 762 | - child: SingleChildScrollView( | ||
| 763 | - child: Column( | ||
| 764 | - children: [_topWidget(), _middleWidget(), _bottomWidget()], | ||
| 765 | - ))), | ||
| 766 | - Container( | ||
| 767 | - padding: EdgeInsets.symmetric( | ||
| 768 | - horizontal: ScreenUtil().setWidth(40), | ||
| 769 | - vertical: ScreenUtil().setWidth(60), | ||
| 770 | - ), | ||
| 771 | - child: CommonButton( | ||
| 772 | - width: double.infinity, | ||
| 773 | - height: 84, | ||
| 774 | - fontSize: 34, | ||
| 775 | - content: "确定修改", | ||
| 776 | - state: 2, | ||
| 777 | - onPress: () async { | ||
| 778 | - String name = | ||
| 779 | - _notebookDetailChangeModel.nameController.text.trim(); | ||
| 780 | - if (ObjectUtil.isEmpty(name)) { | ||
| 781 | - Utils.showToast("请填写客户姓名"); | ||
| 782 | - return; | ||
| 783 | - } | ||
| 784 | - if (_notebookDetailChangeModel.tableList.length == 0) { | ||
| 785 | - Utils.showToast("请选择桌位"); | ||
| 786 | - return; | ||
| 787 | - } | ||
| 788 | - SunReserveInfoModel _model = | ||
| 789 | - await _notebookDetailChangeModel | ||
| 790 | - .setReserveInfo(context); | ||
| 791 | - if (ObjectUtil.isNotEmpty(_model.row) || | ||
| 792 | - ObjectUtil.isNotEmpty(_model.row.id)) { | ||
| 793 | - print('变更成功'); | ||
| 794 | - // _notebookDetailChangeModel.clearData(); | ||
| 795 | - bus.emit("refresh_detail"); | ||
| 796 | - String ddate_solt = ''; | ||
| 797 | - if (_model.row.isSetDdate == '1') { | ||
| 798 | - String createtime = _model.row.ddate.toString() + '000'; | ||
| 799 | - DateTime createTime = | ||
| 800 | - DateTime.fromMillisecondsSinceEpoch( | ||
| 801 | - int.parse(createtime)); | ||
| 802 | - ddate_solt = DateUtil.formatDate(createTime, | ||
| 803 | - format: DateFormats.h_m); | ||
| 804 | - } else { | ||
| 805 | - if (_model.row.ddateSolt == '1') { | ||
| 806 | - ddate_solt = '早餐'; | ||
| 807 | - } else if (_model.row.ddateSolt == '2') { | ||
| 808 | - ddate_solt = '午餐'; | ||
| 809 | - } else if (_model.row.ddateSolt == '3') { | ||
| 810 | - ddate_solt = '晚餐'; | ||
| 811 | - } | 755 | + body: SafeArea( |
| 756 | + child: Column(children: <Widget>[ | ||
| 757 | + MyAppBar( | ||
| 758 | + "录入预订", | ||
| 759 | + showBack: false, | ||
| 760 | + ), | ||
| 761 | + Expanded( | ||
| 762 | + child: SingleChildScrollView( | ||
| 763 | + child: Column( | ||
| 764 | + children: [_topWidget(), _middleWidget(), _bottomWidget()], | ||
| 765 | + ))), | ||
| 766 | + Container( | ||
| 767 | + padding: EdgeInsets.symmetric( | ||
| 768 | + horizontal: ScreenUtil().setWidth(40), | ||
| 769 | + vertical: ScreenUtil().setWidth(60), | ||
| 770 | + ), | ||
| 771 | + child: CommonButton( | ||
| 772 | + width: double.infinity, | ||
| 773 | + height: 84, | ||
| 774 | + fontSize: 34, | ||
| 775 | + content: "录入预订", | ||
| 776 | + state: 2, | ||
| 777 | + onPress: () async { | ||
| 778 | + String name = | ||
| 779 | + _enterModel.nameController.text.trim(); | ||
| 780 | + if (ObjectUtil.isEmpty(name)) { | ||
| 781 | + Utils.showToast("请填写客户姓名"); | ||
| 782 | + return; | ||
| 812 | } | 783 | } |
| 813 | - List<dynamic> tableinfo = | ||
| 814 | - convert.jsonDecode(_model.row.tableinfo); | ||
| 815 | - print(tableinfo); | ||
| 816 | - String _nameStr = _model.row.name; | ||
| 817 | - if (tableinfo.length > 1) { | ||
| 818 | - _nameStr = _model.row.name + '等${tableinfo.length}桌'; | 784 | + if (_enterModel.tableList.length == 0) { |
| 785 | + Utils.showToast("请选择桌位"); | ||
| 786 | + return; | ||
| 819 | } | 787 | } |
| 820 | - NavigatorUtil.goInvicationPage(context, _model.row.id, | ||
| 821 | - _nameStr, _model.row.ddate, ddate_solt, | ||
| 822 | - replace: true); | ||
| 823 | - } else { | ||
| 824 | - Utils.showToast("变更预订订单失败,请重试!"); | ||
| 825 | - } | ||
| 826 | - }, | ||
| 827 | - )) | ||
| 828 | - ]), | 788 | + SunReserveInfoModel _model = |
| 789 | + await _enterModel | ||
| 790 | + .setReserveInfo(context); | ||
| 791 | + if (ObjectUtil.isNotEmpty(_model.row) || | ||
| 792 | + ObjectUtil.isNotEmpty(_model.row.id)) { | ||
| 793 | + print('录入成功'); | ||
| 794 | + // _enterModel.clearData(); | ||
| 795 | + bus.emit("refresh_detail"); | ||
| 796 | + String ddate_solt = ''; | ||
| 797 | + if (_model.row.isSetDdate == '1') { | ||
| 798 | + String createtime = _model.row.ddate.toString() + '000'; | ||
| 799 | + DateTime createTime = | ||
| 800 | + DateTime.fromMillisecondsSinceEpoch( | ||
| 801 | + int.parse(createtime)); | ||
| 802 | + ddate_solt = DateUtil.formatDate(createTime, | ||
| 803 | + format: DateFormats.h_m); | ||
| 804 | + } else { | ||
| 805 | + if (_model.row.ddateSolt == '1') { | ||
| 806 | + ddate_solt = '早餐'; | ||
| 807 | + } else if (_model.row.ddateSolt == '2') { | ||
| 808 | + ddate_solt = '午餐'; | ||
| 809 | + } else if (_model.row.ddateSolt == '3') { | ||
| 810 | + ddate_solt = '晚餐'; | ||
| 811 | + } | ||
| 812 | + } | ||
| 813 | + List<dynamic> tableinfo = | ||
| 814 | + convert.jsonDecode(_model.row.tableinfo); | ||
| 815 | + print(tableinfo); | ||
| 816 | + String _nameStr = _model.row.name; | ||
| 817 | + if (tableinfo.length > 1) { | ||
| 818 | + _nameStr = _model.row.name + '等${tableinfo.length}桌'; | ||
| 819 | + } | ||
| 820 | + NavigatorUtil.goInvicationPage(context, _model.row.id, | ||
| 821 | + _nameStr, _model.row.ddate, ddate_solt, | ||
| 822 | + replace: true); | ||
| 823 | + } else { | ||
| 824 | + Utils.showToast("录入预订订单失败,请重试!"); | ||
| 825 | + } | ||
| 826 | + }, | ||
| 827 | + )) | ||
| 828 | + ]), | ||
| 829 | + ), | ||
| 829 | )); | 830 | )); |
| 830 | } | 831 | } |
| 831 | } | 832 | } |
| 832 | 833 | ||
| 833 | -/// 获取日期 今天 明天 后天等等 | ||
| 834 | -int _getDdate(NotebookDetailChangeModel model) { | ||
| 835 | - //当前选中 月 日string | ||
| 836 | - String mdStr = ''; | ||
| 837 | - //今天 明天 其他天 | ||
| 838 | - for (var item in model.dateList) { | ||
| 839 | - if (item['select'] == true) { | ||
| 840 | - mdStr = item['title']; | ||
| 841 | - } | ||
| 842 | - } | ||
| 843 | - String timeNowYear = DateUtil.formatDate(DateTime.now(), format: 'yyyy'); | ||
| 844 | - String ymyStr = timeNowYear + '-' + mdStr; //年月日 | ||
| 845 | - String timeStr = ymyStr + ' ' + "00:00:00"; | ||
| 846 | - int ddate = DateUtil.getDateMsByTimeStr(timeStr); //筛选日期时间戳 | ||
| 847 | - return ddate; | ||
| 848 | -} | ||
| 849 | - | ||
| 850 | -/// 获取早餐、午餐、晚餐字段 1 ,2, 3 | ||
| 851 | -String _getDdateSolt(NotebookDetailChangeModel model) { | ||
| 852 | - String ddateSolt = ''; | ||
| 853 | - for (var item in model.sunDateList) { | ||
| 854 | - if (item['isSelect']) { | ||
| 855 | - ddateSolt = '${item['ddateSolt']}'; | ||
| 856 | - } | ||
| 857 | - } | ||
| 858 | - return ddateSolt; | ||
| 859 | -} | ||
| 860 | - | ||
| 861 | -/// 选中前面的按钮获取人数,输入的自己获取 | ||
| 862 | -String _getPnum(NotebookDetailChangeModel model) { | ||
| 863 | - String pnum = '6'; | ||
| 864 | - for (var item in model.personNumList) { | ||
| 865 | - if (item['isSelect']) { | ||
| 866 | - pnum = item['dateText']; | ||
| 867 | - } | ||
| 868 | - } | ||
| 869 | - if (pnum == '更多') { | ||
| 870 | - pnum = '6'; | ||
| 871 | - } | ||
| 872 | - return pnum; | ||
| 873 | -} | ||
| 874 | - | ||
| 875 | class CustomButton extends StatefulWidget { | 834 | class CustomButton extends StatefulWidget { |
| 876 | final String dateText; | 835 | final String dateText; |
| 877 | final String dayText; | 836 | final String dayText; |
| 837 | + final bool isEnable; | ||
| 878 | final bool isSelect; | 838 | final bool isSelect; |
| 879 | final double fontSize; | 839 | final double fontSize; |
| 880 | final bool isImage; | 840 | final bool isImage; |
| 881 | final double width; | 841 | final double width; |
| 882 | final GestureTapCallback onTap; | 842 | final GestureTapCallback onTap; |
| 883 | final bool isTextFiled; | 843 | final bool isTextFiled; |
| 884 | - final NotebookDetailChangeModel model; | 844 | + final EnterModel model; |
| 885 | final double height; | 845 | final double height; |
| 886 | 846 | ||
| 887 | const CustomButton({ | 847 | const CustomButton({ |
| 888 | Key key, | 848 | Key key, |
| 889 | this.dateText, | 849 | this.dateText, |
| 890 | this.dayText, | 850 | this.dayText, |
| 851 | + this.isEnable=true, | ||
| 891 | this.isSelect, | 852 | this.isSelect, |
| 892 | this.fontSize = 34, | 853 | this.fontSize = 34, |
| 893 | this.isImage = false, | 854 | this.isImage = false, |
| @@ -917,10 +878,10 @@ class _ButtonState extends State<CustomButton> { | @@ -917,10 +878,10 @@ class _ButtonState extends State<CustomButton> { | ||
| 917 | width: ScreenUtil().setWidth(widget.width * 2), | 878 | width: ScreenUtil().setWidth(widget.width * 2), |
| 918 | height: ScreenUtil().setWidth(widget.height * 2), | 879 | height: ScreenUtil().setWidth(widget.height * 2), |
| 919 | decoration: BoxDecoration( | 880 | decoration: BoxDecoration( |
| 920 | - color: widget.isSelect ? MyColours.color_199095 : Colors.white, | 881 | + color: !widget.isEnable?MyColours.color_999999:widget.isSelect ? MyColours.color_199095 : Colors.white, |
| 921 | borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10)), | 882 | borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10)), |
| 922 | border: Border.all( | 883 | border: Border.all( |
| 923 | - color: MyColours.color_199095, | 884 | + color: !widget.isEnable?MyColours.color_999999:MyColours.color_199095, |
| 924 | width: ScreenUtil().setWidth(2))), | 885 | width: ScreenUtil().setWidth(2))), |
| 925 | child: Row( | 886 | child: Row( |
| 926 | mainAxisAlignment: MainAxisAlignment.center, | 887 | mainAxisAlignment: MainAxisAlignment.center, |
| @@ -991,9 +952,9 @@ class _ButtonState extends State<CustomButton> { | @@ -991,9 +952,9 @@ class _ButtonState extends State<CustomButton> { | ||
| 991 | }, | 952 | }, |
| 992 | onEditingComplete: () { | 953 | onEditingComplete: () { |
| 993 | _cancelNode.unfocus(); | 954 | _cancelNode.unfocus(); |
| 994 | - int ddate = _getDdate(widget.model); | ||
| 995 | - String ddateSolt = _getDdateSolt(widget.model); | ||
| 996 | - String pnum = _getPnum(widget.model); | 955 | + int ddate = Utils.getDdate(widget.model.dateList); |
| 956 | + String ddateSolt = Utils.getDdateSolt(widget.model.sunDateList); | ||
| 957 | + String pnum = Utils.getPnum(widget.model.personNumList); | ||
| 997 | 958 | ||
| 998 | widget.model.getNewTableList(context, '${ddate}', | 959 | widget.model.getNewTableList(context, '${ddate}', |
| 999 | ddateSolt, pnum, widget.model.tableList); | 960 | ddateSolt, pnum, widget.model.tableList); |
| @@ -1006,7 +967,7 @@ class _ButtonState extends State<CustomButton> { | @@ -1006,7 +967,7 @@ class _ButtonState extends State<CustomButton> { | ||
| 1006 | fontWeight: widget.isImage && widget.dateText == "其他" | 967 | fontWeight: widget.isImage && widget.dateText == "其他" |
| 1007 | ? FontWeight.normal | 968 | ? FontWeight.normal |
| 1008 | : FontWeight.bold, | 969 | : FontWeight.bold, |
| 1009 | - color: widget.isSelect | 970 | + color: !widget.isEnable?MyColours.color_666666:widget.isSelect |
| 1010 | ? MyColours.color_fefefe | 971 | ? MyColours.color_fefefe |
| 1011 | : MyColours.color_199095, | 972 | : MyColours.color_199095, |
| 1012 | fontSize: ScreenUtil().setSp(widget.fontSize))), | 973 | fontSize: ScreenUtil().setSp(widget.fontSize))), |
| 1 | import 'dart:async'; | 1 | import 'dart:async'; |
| 2 | import 'dart:convert'; | 2 | import 'dart:convert'; |
| 3 | import 'dart:io'; | 3 | import 'dart:io'; |
| 4 | +import 'package:common_utils/common_utils.dart'; | ||
| 4 | import 'package:flutter/cupertino.dart'; | 5 | import 'package:flutter/cupertino.dart'; |
| 5 | import 'package:flutter/material.dart'; | 6 | import 'package:flutter/material.dart'; |
| 6 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 7 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| 7 | import 'package:one_key/app.dart'; | 8 | import 'package:one_key/app.dart'; |
| 9 | +import 'package:one_key/models/notebook_detail.dart'; | ||
| 10 | +import 'package:one_key/pages/detail/notebook_detail_change_page.dart'; | ||
| 11 | +import 'package:one_key/pages/detail/notebook_detail_page.dart'; | ||
| 8 | import 'package:one_key/pages/enter/enter_page.dart'; | 12 | import 'package:one_key/pages/enter/enter_page.dart'; |
| 9 | import 'package:one_key/pages/message/message_page.dart'; | 13 | import 'package:one_key/pages/message/message_page.dart'; |
| 10 | import 'package:one_key/pages/my/my_page.dart'; | 14 | import 'package:one_key/pages/my/my_page.dart'; |
| @@ -15,13 +19,13 @@ import 'package:one_key/provider/enter_model.dart'; | @@ -15,13 +19,13 @@ import 'package:one_key/provider/enter_model.dart'; | ||
| 15 | import 'package:one_key/provider/message_dialog_model.dart'; | 19 | import 'package:one_key/provider/message_dialog_model.dart'; |
| 16 | import 'package:one_key/provider/message_model.dart'; | 20 | import 'package:one_key/provider/message_model.dart'; |
| 17 | import 'package:one_key/provider/my_model.dart'; | 21 | import 'package:one_key/provider/my_model.dart'; |
| 22 | +import 'package:one_key/provider/notebook_detail_change_model.dart'; | ||
| 18 | import 'package:one_key/provider/notebook_model.dart'; | 23 | import 'package:one_key/provider/notebook_model.dart'; |
| 19 | import 'package:one_key/provider/table_manager_model.dart'; | 24 | import 'package:one_key/provider/table_manager_model.dart'; |
| 20 | import 'package:one_key/provider/tools.dart'; | 25 | import 'package:one_key/provider/tools.dart'; |
| 21 | import 'package:one_key/provider/update_model.dart'; | 26 | import 'package:one_key/provider/update_model.dart'; |
| 22 | import 'package:one_key/provider/user_model.dart'; | 27 | import 'package:one_key/provider/user_model.dart'; |
| 23 | import 'package:one_key/res/colors.dart'; | 28 | import 'package:one_key/res/colors.dart'; |
| 24 | -import 'package:one_key/utils/log_util.dart'; | ||
| 25 | import 'package:one_key/utils/misc.dart'; | 29 | import 'package:one_key/utils/misc.dart'; |
| 26 | import 'package:one_key/utils/navigator_util.dart'; | 30 | import 'package:one_key/utils/navigator_util.dart'; |
| 27 | import 'package:one_key/utils/utils.dart'; | 31 | import 'package:one_key/utils/utils.dart'; |
| @@ -33,7 +37,7 @@ import 'package:tpns_flutter_plugin/tpns_flutter_plugin.dart'; | @@ -33,7 +37,7 @@ import 'package:tpns_flutter_plugin/tpns_flutter_plugin.dart'; | ||
| 33 | class HomePage extends StatefulWidget { | 37 | class HomePage extends StatefulWidget { |
| 34 | final int initialIndex; //初始tab | 38 | final int initialIndex; //初始tab |
| 35 | 39 | ||
| 36 | - HomePage({this.initialIndex = 2}); | 40 | + HomePage({this.initialIndex = 1}); |
| 37 | 41 | ||
| 38 | @override | 42 | @override |
| 39 | State<StatefulWidget> createState() { | 43 | State<StatefulWidget> createState() { |
| @@ -44,7 +48,7 @@ class HomePage extends StatefulWidget { | @@ -44,7 +48,7 @@ class HomePage extends StatefulWidget { | ||
| 44 | 48 | ||
| 45 | class HomePageState extends State<HomePage> with WidgetsBindingObserver { | 49 | class HomePageState extends State<HomePage> with WidgetsBindingObserver { |
| 46 | List<Widget> pages = List<Widget>(); | 50 | List<Widget> pages = List<Widget>(); |
| 47 | - int _currIndex = 2; | 51 | + int _currIndex = 1; |
| 48 | Color _activeColor = MyColours.color_199095; | 52 | Color _activeColor = MyColours.color_199095; |
| 49 | Color _defaultColor = MyColours.color_999999; | 53 | Color _defaultColor = MyColours.color_999999; |
| 50 | 54 | ||
| @@ -64,10 +68,10 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | @@ -64,10 +68,10 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | ||
| 64 | create: (_) => MessageModel(), | 68 | create: (_) => MessageModel(), |
| 65 | child: SafeArea(child: MessagePage()), | 69 | child: SafeArea(child: MessagePage()), |
| 66 | )) | 70 | )) |
| 67 | - ..add(ChangeNotifierProvider<EnterModel>( | ||
| 68 | - create: (_) => EnterModel(null), | ||
| 69 | - child: SafeArea(child: EnterPage()), | ||
| 70 | - )) | 71 | +// ..add(ChangeNotifierProvider<EnterModel>( |
| 72 | +// create: (_) => EnterModel(), | ||
| 73 | +// child: SafeArea(child: EnterPage(detailEntity:NotebookDetail.def(context),rid: "-1",)), | ||
| 74 | +// )) | ||
| 71 | ..add(ChangeNotifierProvider<NoteBookModel>( | 75 | ..add(ChangeNotifierProvider<NoteBookModel>( |
| 72 | create: (_) => NoteBookModel(), | 76 | create: (_) => NoteBookModel(), |
| 73 | child: SafeArea(child: NoteBookPage()), | 77 | child: SafeArea(child: NoteBookPage()), |
| @@ -323,24 +327,24 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | @@ -323,24 +327,24 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | ||
| 323 | fontSize: ScreenUtil().setSp(22)), | 327 | fontSize: ScreenUtil().setSp(22)), |
| 324 | ), | 328 | ), |
| 325 | ), | 329 | ), |
| 326 | - BottomNavigationBarItem( | ||
| 327 | - icon: Image( | ||
| 328 | - image: AssetImage("assets/message_default.png"), | ||
| 329 | - width: ScreenUtil().setWidth(48), | ||
| 330 | - height: ScreenUtil().setWidth(48), | ||
| 331 | - ), | ||
| 332 | - activeIcon: Image( | ||
| 333 | - image: AssetImage("assets/message_selected.png"), | ||
| 334 | - width: ScreenUtil().setWidth(48), | ||
| 335 | - height: ScreenUtil().setWidth(48), | ||
| 336 | - ), | ||
| 337 | - title: Text( | ||
| 338 | - "订座", | ||
| 339 | - style: TextStyle( | ||
| 340 | - color: _currIndex == 1 ? _activeColor : _defaultColor, | ||
| 341 | - fontSize: ScreenUtil().setSp(22)), | ||
| 342 | - ), | ||
| 343 | - ), | 330 | +// BottomNavigationBarItem( |
| 331 | +// icon: Image( | ||
| 332 | +// image: AssetImage("assets/message_default.png"), | ||
| 333 | +// width: ScreenUtil().setWidth(48), | ||
| 334 | +// height: ScreenUtil().setWidth(48), | ||
| 335 | +// ), | ||
| 336 | +// activeIcon: Image( | ||
| 337 | +// image: AssetImage("assets/message_selected.png"), | ||
| 338 | +// width: ScreenUtil().setWidth(48), | ||
| 339 | +// height: ScreenUtil().setWidth(48), | ||
| 340 | +// ), | ||
| 341 | +// title: Text( | ||
| 342 | +// "订座", | ||
| 343 | +// style: TextStyle( | ||
| 344 | +// color: _currIndex == 1 ? _activeColor : _defaultColor, | ||
| 345 | +// fontSize: ScreenUtil().setSp(22)), | ||
| 346 | +// ), | ||
| 347 | +// ), | ||
| 344 | BottomNavigationBarItem( | 348 | BottomNavigationBarItem( |
| 345 | icon: Image( | 349 | icon: Image( |
| 346 | image: AssetImage("assets/notebook_default.png"), | 350 | image: AssetImage("assets/notebook_default.png"), |
| @@ -355,7 +359,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | @@ -355,7 +359,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | ||
| 355 | title: Text( | 359 | title: Text( |
| 356 | "已预订", | 360 | "已预订", |
| 357 | style: TextStyle( | 361 | style: TextStyle( |
| 358 | - color: _currIndex == 2 ? _activeColor : _defaultColor, | 362 | + color: _currIndex == 1 ? _activeColor : _defaultColor, |
| 359 | fontSize: ScreenUtil().setSp(22)), | 363 | fontSize: ScreenUtil().setSp(22)), |
| 360 | ), | 364 | ), |
| 361 | ), | 365 | ), |
| @@ -373,7 +377,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | @@ -373,7 +377,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | ||
| 373 | title: Text( | 377 | title: Text( |
| 374 | "桌位", | 378 | "桌位", |
| 375 | style: TextStyle( | 379 | style: TextStyle( |
| 376 | - color: _currIndex == 3? _activeColor : _defaultColor, | 380 | + color: _currIndex == 2? _activeColor : _defaultColor, |
| 377 | fontSize: ScreenUtil().setSp(22)), | 381 | fontSize: ScreenUtil().setSp(22)), |
| 378 | ), | 382 | ), |
| 379 | ), | 383 | ), |
| @@ -391,7 +395,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | @@ -391,7 +395,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | ||
| 391 | title: Text( | 395 | title: Text( |
| 392 | "我的", | 396 | "我的", |
| 393 | style: TextStyle( | 397 | style: TextStyle( |
| 394 | - color: _currIndex == 4 ? _activeColor : _defaultColor, | 398 | + color: _currIndex == 3 ? _activeColor : _defaultColor, |
| 395 | fontSize: ScreenUtil().setSp(22)), | 399 | fontSize: ScreenUtil().setSp(22)), |
| 396 | ), | 400 | ), |
| 397 | ), | 401 | ), |
| @@ -403,7 +407,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | @@ -403,7 +407,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | ||
| 403 | setState(() { | 407 | setState(() { |
| 404 | _currIndex = index; | 408 | _currIndex = index; |
| 405 | }); | 409 | }); |
| 406 | - if (_currIndex == 4) { | 410 | + if (_currIndex == 3) { |
| 407 | Utils.changeStatusColor(color: MyColours.color_199095); | 411 | Utils.changeStatusColor(color: MyColours.color_199095); |
| 408 | } else { | 412 | } else { |
| 409 | Utils.changeStatusColor(color: MyColours.color_ffffff); | 413 | Utils.changeStatusColor(color: MyColours.color_ffffff); |
| @@ -3,7 +3,6 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -3,7 +3,6 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
| 3 | import 'package:one_key/app.dart'; | 3 | import 'package:one_key/app.dart'; |
| 4 | import 'package:one_key/provider/user_model.dart'; | 4 | import 'package:one_key/provider/user_model.dart'; |
| 5 | import 'package:one_key/res/colors.dart'; | 5 | import 'package:one_key/res/colors.dart'; |
| 6 | -import 'package:one_key/utils/log_util.dart'; | ||
| 7 | import 'package:one_key/utils/navigator_util.dart'; | 6 | import 'package:one_key/utils/navigator_util.dart'; |
| 8 | import 'package:one_key/widgets/h_empty_view.dart'; | 7 | import 'package:one_key/widgets/h_empty_view.dart'; |
| 9 | import 'package:one_key/widgets/v_empty_view.dart'; | 8 | import 'package:one_key/widgets/v_empty_view.dart'; |
| 1 | +import 'package:common_utils/common_utils.dart'; | ||
| 1 | import 'package:dio/dio.dart'; | 2 | import 'package:dio/dio.dart'; |
| 2 | import 'package:flutter/material.dart'; | 3 | import 'package:flutter/material.dart'; |
| 3 | import 'package:flutter_easyrefresh/easy_refresh.dart'; | 4 | import 'package:flutter_easyrefresh/easy_refresh.dart'; |
| @@ -10,7 +11,6 @@ import 'package:one_key/provider/user_model.dart'; | @@ -10,7 +11,6 @@ import 'package:one_key/provider/user_model.dart'; | ||
| 10 | import 'package:one_key/res/colors.dart'; | 11 | import 'package:one_key/res/colors.dart'; |
| 11 | import 'package:one_key/utils/dialog_util.dart'; | 12 | import 'package:one_key/utils/dialog_util.dart'; |
| 12 | import 'package:one_key/utils/event_bus.dart'; | 13 | import 'package:one_key/utils/event_bus.dart'; |
| 13 | -import 'package:one_key/utils/log_util.dart'; | ||
| 14 | import 'package:one_key/utils/utils.dart'; | 14 | import 'package:one_key/utils/utils.dart'; |
| 15 | import 'package:one_key/widgets/MyDivider.dart'; | 15 | import 'package:one_key/widgets/MyDivider.dart'; |
| 16 | import 'package:one_key/widgets/app_bar.dart'; | 16 | import 'package:one_key/widgets/app_bar.dart'; |
| @@ -20,6 +20,7 @@ import 'package:one_key/widgets/page_exception.dart'; | @@ -20,6 +20,7 @@ import 'package:one_key/widgets/page_exception.dart'; | ||
| 20 | import 'package:provider/provider.dart'; | 20 | import 'package:provider/provider.dart'; |
| 21 | 21 | ||
| 22 | class NoteBookPage extends StatefulWidget { | 22 | class NoteBookPage extends StatefulWidget { |
| 23 | + | ||
| 23 | @override | 24 | @override |
| 24 | State<StatefulWidget> createState() { | 25 | State<StatefulWidget> createState() { |
| 25 | // TODO: implement createState | 26 | // TODO: implement createState |
| @@ -44,6 +45,7 @@ class NoteBookPageState extends State<NoteBookPage> { | @@ -44,6 +45,7 @@ class NoteBookPageState extends State<NoteBookPage> { | ||
| 44 | void initState() { | 45 | void initState() { |
| 45 | // TODO: implement initState | 46 | // TODO: implement initState |
| 46 | super.initState(); | 47 | super.initState(); |
| 48 | + LogUtil.v("notebook_page initState"); | ||
| 47 | userModel = Provider.of<UserModel>(context, listen: false); | 49 | userModel = Provider.of<UserModel>(context, listen: false); |
| 48 | _controller = EasyRefreshController(); | 50 | _controller = EasyRefreshController(); |
| 49 | _initTime(); | 51 | _initTime(); |
| @@ -419,6 +421,7 @@ class NoteBookPageState extends State<NoteBookPage> { | @@ -419,6 +421,7 @@ class NoteBookPageState extends State<NoteBookPage> { | ||
| 419 | pageState: model.pageState, | 421 | pageState: model.pageState, |
| 420 | callback: () { | 422 | callback: () { |
| 421 | _getReserveList(); | 423 | _getReserveList(); |
| 424 | + _reserveCountDay(); | ||
| 422 | }, | 425 | }, |
| 423 | emptyMsg: "暂时没有预订哦", | 426 | emptyMsg: "暂时没有预订哦", |
| 424 | emptyImg: "empty_search", | 427 | emptyImg: "empty_search", |
| 1 | import 'dart:ffi'; | 1 | import 'dart:ffi'; |
| 2 | 2 | ||
| 3 | +import 'package:common_utils/common_utils.dart'; | ||
| 3 | import 'package:flutter/material.dart'; | 4 | import 'package:flutter/material.dart'; |
| 4 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 5 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| 5 | import 'package:one_key/models/area.dart'; | 6 | import 'package:one_key/models/area.dart'; |
| 6 | import 'package:one_key/models/notebook.dart'; | 7 | import 'package:one_key/models/notebook.dart'; |
| 8 | +import 'package:one_key/models/notebook_detail.dart'; | ||
| 7 | import 'package:one_key/models/tableOuter.dart'; | 9 | import 'package:one_key/models/tableOuter.dart'; |
| 8 | import 'package:one_key/models/table_list.dart'; | 10 | import 'package:one_key/models/table_list.dart'; |
| 9 | import 'package:one_key/provider/choose_table_model.dart'; | 11 | import 'package:one_key/provider/choose_table_model.dart'; |
| @@ -14,7 +16,8 @@ import 'package:one_key/provider/table_manager_model.dart'; | @@ -14,7 +16,8 @@ import 'package:one_key/provider/table_manager_model.dart'; | ||
| 14 | import 'package:one_key/provider/user_model.dart'; | 16 | import 'package:one_key/provider/user_model.dart'; |
| 15 | import 'package:one_key/res/colors.dart'; | 17 | import 'package:one_key/res/colors.dart'; |
| 16 | import 'package:one_key/utils/dialog_util.dart'; | 18 | import 'package:one_key/utils/dialog_util.dart'; |
| 17 | -import 'package:one_key/utils/log_util.dart'; | 19 | +import 'package:one_key/utils/event_bus.dart'; |
| 20 | +import 'package:one_key/utils/navigator_util.dart'; | ||
| 18 | import 'package:one_key/utils/utils.dart'; | 21 | import 'package:one_key/utils/utils.dart'; |
| 19 | import 'package:one_key/widgets/MyDivider.dart'; | 22 | import 'package:one_key/widgets/MyDivider.dart'; |
| 20 | import 'package:one_key/widgets/app_bar.dart'; | 23 | import 'package:one_key/widgets/app_bar.dart'; |
| @@ -37,428 +40,225 @@ class TableManagerPage extends StatefulWidget { | @@ -37,428 +40,225 @@ class TableManagerPage extends StatefulWidget { | ||
| 37 | 40 | ||
| 38 | class TableManagerPageState extends State<TableManagerPage> { | 41 | class TableManagerPageState extends State<TableManagerPage> { |
| 39 | 42 | ||
| 40 | - List<Area> areas = []; //区域列表 | ||
| 41 | - List<t.Table> selectTables = []; //选择的桌位 | ||
| 42 | - | ||
| 43 | - List<TableOuter> tableOuterList = []; //区域-桌位列表 | ||
| 44 | - | ||
| 45 | - Map<String, List<t.Table>> areaTableMap = {}; //区域-桌位Map | ||
| 46 | - | ||
| 47 | TableManagerModel tableManagerModel; | 43 | TableManagerModel tableManagerModel; |
| 48 | 44 | ||
| 49 | - Map<String, Notebook> tableMap = {}; //记录已预订桌位对应的订单 | ||
| 50 | - | ||
| 51 | - String currentArea; //当前选中区域 | ||
| 52 | - | ||
| 53 | - DateTime dateTime=DateTime.now(); | ||
| 54 | - | ||
| 55 | - String dateText = ""; //当前显示日期时间 | ||
| 56 | - int currTimeIndex = 1; //当前选中时间段 | ||
| 57 | - String morning; //早市时间段 | ||
| 58 | - String noon; //午市时间段 | ||
| 59 | - String night; //晚市时间段 | ||
| 60 | - UserModel userModel; | ||
| 61 | - | ||
| 62 | @override | 45 | @override |
| 63 | void initState() { | 46 | void initState() { |
| 64 | // TODO: implement initState | 47 | // TODO: implement initState |
| 65 | super.initState(); | 48 | super.initState(); |
| 66 | LogUtil.v("table_manager_page initState"); | 49 | LogUtil.v("table_manager_page initState"); |
| 67 | WidgetsBinding.instance.addPostFrameCallback((_) { | 50 | WidgetsBinding.instance.addPostFrameCallback((_) { |
| 68 | - userModel = Provider.of<UserModel>(context, listen: false); | ||
| 69 | - tableManagerModel=Provider.of<TableManagerModel>(context,listen: false); | ||
| 70 | - _initTime(); | ||
| 71 | - getTableList(); | 51 | + tableManagerModel=Provider.of<TableManagerModel>(context,listen: true); |
| 52 | + tableManagerModel.initTime(context); | ||
| 53 | + EventBus().on("refresh_tablemanager", (arg) {//订座-完成预订 刷新管理桌位 | ||
| 54 | + tableManagerModel.getReserveList(context); | ||
| 55 | + }); | ||
| 72 | }); | 56 | }); |
| 73 | } | 57 | } |
| 74 | 58 | ||
| 75 | - //初始化时间 | ||
| 76 | - _initTime() { | ||
| 77 | - dateTime = DateTime.now(); | ||
| 78 | - dateText = Utils.addZeroNumber(dateTime.month) + | ||
| 79 | - "月" + | ||
| 80 | - Utils.addZeroNumber(dateTime.day) + | ||
| 81 | - "日" + | ||
| 82 | - " 今天"; | ||
| 83 | - morning = | ||
| 84 | - userModel.user.morning.isEmpty ? "00:00-00:00" : userModel.user.morning; | ||
| 85 | - noon = userModel.user.noon.isEmpty ? "00:00-00:00" : userModel.user.noon; | ||
| 86 | - night = userModel.user.night.isEmpty ? "00:00-00:00" : userModel.user.night; | ||
| 87 | - if (dateTime.isBefore(DateTime.parse(dateTime.year.toString() + | ||
| 88 | - "-" + | ||
| 89 | - Utils.addZeroNumber(dateTime.month) + | ||
| 90 | - "-" + | ||
| 91 | - Utils.addZeroNumber(dateTime.day) + | ||
| 92 | - " " + | ||
| 93 | - morning.split("-")[1] + | ||
| 94 | - ":00"))) { | ||
| 95 | - //未过早市 | ||
| 96 | - currTimeIndex = 1; | ||
| 97 | - } else if (dateTime.isAfter(DateTime.parse(dateTime.year.toString() + | ||
| 98 | - "-" + | ||
| 99 | - Utils.addZeroNumber(dateTime.month) + | ||
| 100 | - "-" + | ||
| 101 | - Utils.addZeroNumber(dateTime.day) + | ||
| 102 | - " " + | ||
| 103 | - morning.split("-")[1] + | ||
| 104 | - ":00")) && | ||
| 105 | - dateTime.isBefore(DateTime.parse(dateTime.year.toString() + | ||
| 106 | - "-" + | ||
| 107 | - Utils.addZeroNumber(dateTime.month) + | ||
| 108 | - "-" + | ||
| 109 | - Utils.addZeroNumber(dateTime.day) + | ||
| 110 | - " " + | ||
| 111 | - noon.split("-")[1] + | ||
| 112 | - ":00"))) { | ||
| 113 | - //过了早市,未过午市 | ||
| 114 | - currTimeIndex = 2; | ||
| 115 | - } else if (dateTime.isAfter(DateTime.parse(dateTime.year.toString() + | ||
| 116 | - "-" + | ||
| 117 | - Utils.addZeroNumber(dateTime.month) + | ||
| 118 | - "-" + | ||
| 119 | - Utils.addZeroNumber(dateTime.day) + | ||
| 120 | - " " + | ||
| 121 | - noon.split("-")[1] + | ||
| 122 | - ":00")) && | ||
| 123 | - dateTime.isBefore(DateTime.parse(dateTime.year.toString() + | ||
| 124 | - "-" + | ||
| 125 | - Utils.addZeroNumber(dateTime.month) + | ||
| 126 | - "-" + | ||
| 127 | - Utils.addZeroNumber(dateTime.day) + | ||
| 128 | - " " + | ||
| 129 | - night.split("-")[1] + | ||
| 130 | - ":00"))) { | ||
| 131 | - //过了午市,未过晚市 | ||
| 132 | - currTimeIndex = 3; | ||
| 133 | - } else { | ||
| 134 | - //过了晚市 | ||
| 135 | - currTimeIndex = 3; | ||
| 136 | - } | ||
| 137 | - } | ||
| 138 | - | ||
| 139 | - //获取桌位列表 | ||
| 140 | - getTableList() async { | ||
| 141 | - Map<String, String> params = {"sellerid": userModel.user.sellerid}; | ||
| 142 | - tableOuterList = await tableManagerModel.getTableList(context, params); | ||
| 143 | - _getReserveList(); | ||
| 144 | - } | ||
| 145 | - | ||
| 146 | - //获取已预订列表 | ||
| 147 | - _getReserveList() async { | ||
| 148 | - NoteBookModel model = new NoteBookModel(); | ||
| 149 | - Map<String, String> params = { | ||
| 150 | - "sid": userModel.user.sellerid, | ||
| 151 | - "rdate": _getRdate(), | ||
| 152 | - "ddate_solt": currTimeIndex.toString(), | ||
| 153 | - "y": "200", | ||
| 154 | - "x": "1", | ||
| 155 | - "keywords": "", | ||
| 156 | - "sort": "1" | ||
| 157 | - }; | ||
| 158 | - List<Notebook> noteBooks = await model.getReserveList(context, params); | ||
| 159 | - for (Notebook notebook in noteBooks) { | ||
| 160 | - if (notebook.tid.isEmpty) continue; | ||
| 161 | - if (notebook.status == "1" || | ||
| 162 | - notebook.status == "2" || | ||
| 163 | - notebook.status == "5") { | ||
| 164 | - //已预订,用餐中,已安排 | ||
| 165 | - List<String> tids = notebook.tid.split(","); | ||
| 166 | - for (String tid in tids) { | ||
| 167 | - tableMap["$tid"] = notebook; | ||
| 168 | - } | ||
| 169 | - } | ||
| 170 | - } | ||
| 171 | - print(tableMap); | ||
| 172 | - initData(); | ||
| 173 | - } | ||
| 174 | - | ||
| 175 | - //初始桌位数据 | ||
| 176 | - initData() { | ||
| 177 | - for (TableOuter outer in tableOuterList) { | ||
| 178 | - int count = 0; | ||
| 179 | - for (t.Table table in outer.list) { | ||
| 180 | - if (table.tablestatus == "0") { | ||
| 181 | - //没有用餐中 | ||
| 182 | - if (tableMap["${table.id}"] != null) { | ||
| 183 | - Notebook notebook = tableMap["${table.id}"]; | ||
| 184 | - table.sign = notebook.status; | ||
| 185 | - table.notebookId = notebook.id; | ||
| 186 | - table.reserver = notebook.rnameStr; | ||
| 187 | - } else { | ||
| 188 | - table.sign = ""; | ||
| 189 | - table.notebookId = ""; | ||
| 190 | - if (table.enable == "1") { | ||
| 191 | - count++; | ||
| 192 | - } | ||
| 193 | - } | ||
| 194 | - } else { | ||
| 195 | - table.sign = "2"; | ||
| 196 | - table.notebookId = ""; | ||
| 197 | - } | ||
| 198 | - } | ||
| 199 | - areaTableMap["${outer.name}"] = outer.list; | ||
| 200 | - Area area = Area(); | ||
| 201 | - area.name = outer.name; | ||
| 202 | - area.count = count; | ||
| 203 | - areas.add(area); | ||
| 204 | - } | ||
| 205 | - currentArea = areaTableMap.keys.first; | ||
| 206 | - setState(() {}); | ||
| 207 | - } | ||
| 208 | - | ||
| 209 | - //获取一天开始-结束时间字符串 | ||
| 210 | - String _getRdate() { | ||
| 211 | - //一天开始时间 | ||
| 212 | - double startDay = (DateTime.parse((dateTime.year.toString() + | ||
| 213 | - "-" + | ||
| 214 | - Utils.addZeroNumber(dateTime.month) + | ||
| 215 | - "-" + | ||
| 216 | - Utils.addZeroNumber(dateTime.day) + | ||
| 217 | - " 00:00:00")) | ||
| 218 | - .millisecondsSinceEpoch) / | ||
| 219 | - 1000; | ||
| 220 | - //一天结束时间 | ||
| 221 | - double endDay = (DateTime.parse((dateTime.year.toString() + | ||
| 222 | - "-" + | ||
| 223 | - Utils.addZeroNumber(dateTime.month) + | ||
| 224 | - "-" + | ||
| 225 | - Utils.addZeroNumber(dateTime.day) + | ||
| 226 | - " 23:59:59")) | ||
| 227 | - .millisecondsSinceEpoch) / | ||
| 228 | - 1000; | ||
| 229 | - return startDay.floor().toString() + "-" + endDay.floor().toString(); | ||
| 230 | - } | ||
| 231 | - | ||
| 232 | - //生成日期文本 | ||
| 233 | - _createDateText(DateTime day) { | ||
| 234 | - if (Utils.isOneDay(day, dateTime)) return; //日期没变 | ||
| 235 | - setState(() { | ||
| 236 | - DateTime dateNow = DateTime.now(); | ||
| 237 | - dateText = Utils.addZeroNumber(day.month) + | ||
| 238 | - "月" + | ||
| 239 | - Utils.addZeroNumber(day.day) + | ||
| 240 | - "日"; | ||
| 241 | - if (Utils.isOneDay(day, dateNow)) { | ||
| 242 | - dateText += " 今天"; | ||
| 243 | - } else if (Utils.isOneDay(day, dateNow.add(Duration(days: 1)))) { | ||
| 244 | - dateText += " 明天"; | ||
| 245 | - } else if (Utils.isOneDay(day, dateNow.add(Duration(days: 2)))) { | ||
| 246 | - dateText += " 后天"; | ||
| 247 | - } else { | ||
| 248 | - dateText += " 周${Utils.formatWeekDayNum(day.weekday)}"; | ||
| 249 | - } | ||
| 250 | - dateTime = day; | ||
| 251 | - }); | ||
| 252 | - _getReserveList(); | ||
| 253 | - } | ||
| 254 | - | ||
| 255 | @override | 59 | @override |
| 256 | Widget build(BuildContext context) { | 60 | Widget build(BuildContext context) { |
| 257 | return SafeArea( | 61 | return SafeArea( |
| 258 | - child: areaTableMap.isEmpty | ||
| 259 | - ? Container( | ||
| 260 | - width: double.infinity, | ||
| 261 | - height: double.infinity, | ||
| 262 | - color: MyColours.color_ffffff, | ||
| 263 | - ) | ||
| 264 | - : Column( | ||
| 265 | - children: <Widget>[ | ||
| 266 | - MyAppBar( | ||
| 267 | - "桌位", | ||
| 268 | - showBack: true, | ||
| 269 | - ), | ||
| 270 | - Container( | ||
| 271 | - color: MyColours.color_ffffff, | ||
| 272 | - width: double.infinity, | ||
| 273 | - padding: EdgeInsets.symmetric(vertical: ScreenUtil().setHeight(16)), | ||
| 274 | - child: Row( | ||
| 275 | - crossAxisAlignment: CrossAxisAlignment.center, | ||
| 276 | - children: <Widget>[ | ||
| 277 | - Expanded( | ||
| 278 | - child: Center( | ||
| 279 | - child: GestureDetector( | ||
| 280 | - onTap: () { | ||
| 281 | - DialogUtil.showCalendarDialog(context, dateTime) | ||
| 282 | - .then((day) { | ||
| 283 | - if (day != null) { | ||
| 284 | - _createDateText(day); | ||
| 285 | - } | ||
| 286 | - }); | ||
| 287 | - }, | ||
| 288 | - child: Container( | ||
| 289 | - child: Text( | ||
| 290 | - dateText, | ||
| 291 | - style: TextStyle( | ||
| 292 | - color: MyColours.color_199095, | ||
| 293 | - fontSize: ScreenUtil().setSp(34)), | 62 | + child: Consumer<TableManagerModel>( |
| 63 | + builder: (context,model,child){ | ||
| 64 | + return Column( | ||
| 65 | + children: <Widget>[ | ||
| 66 | + MyAppBar( | ||
| 67 | + "桌位", | ||
| 68 | + showBack: true, | ||
| 69 | + ), | ||
| 70 | + Container( | ||
| 71 | + color: MyColours.color_ffffff, | ||
| 72 | + width: double.infinity, | ||
| 73 | + padding: EdgeInsets.symmetric(vertical: ScreenUtil().setHeight(16)), | ||
| 74 | + child: Row( | ||
| 75 | + crossAxisAlignment: CrossAxisAlignment.center, | ||
| 76 | + children: <Widget>[ | ||
| 77 | + Expanded( | ||
| 78 | + child: Center( | ||
| 79 | + child: GestureDetector( | ||
| 80 | + onTap: () { | ||
| 81 | + DialogUtil.showCalendarDialog(context, tableManagerModel.dateTime) | ||
| 82 | + .then((day) { | ||
| 83 | + if (day != null) { | ||
| 84 | + tableManagerModel.createDateText(context,day); | ||
| 85 | + } | ||
| 86 | + }); | ||
| 87 | + }, | ||
| 88 | + child: Container( | ||
| 89 | + child: Text( | ||
| 90 | + tableManagerModel.dateText, | ||
| 91 | + style: TextStyle( | ||
| 92 | + color: MyColours.color_199095, | ||
| 93 | + fontSize: ScreenUtil().setSp(34)), | ||
| 94 | + ), | ||
| 95 | + ), | ||
| 294 | ), | 96 | ), |
| 295 | ), | 97 | ), |
| 296 | ), | 98 | ), |
| 297 | - ), | ||
| 298 | - ), | ||
| 299 | - MyDivider( | ||
| 300 | - ScreenUtil().setWidth(2), | ||
| 301 | - ScreenUtil().setHeight(68), | ||
| 302 | - color: MyColours.color_E0E0E0, | 99 | + MyDivider( |
| 100 | + ScreenUtil().setWidth(2), | ||
| 101 | + ScreenUtil().setHeight(68), | ||
| 102 | + color: MyColours.color_E0E0E0, | ||
| 103 | + ), | ||
| 104 | + Expanded( | ||
| 105 | + child: Padding( | ||
| 106 | + padding: EdgeInsets.symmetric( | ||
| 107 | + horizontal: ScreenUtil().setWidth(30)), | ||
| 108 | + child: Row( | ||
| 109 | + mainAxisAlignment: MainAxisAlignment.center, | ||
| 110 | + crossAxisAlignment: CrossAxisAlignment.center, | ||
| 111 | + children: <Widget>[ | ||
| 112 | + Offstage( | ||
| 113 | + offstage: tableManagerModel.morning == "00:00-00:00" ? true : false, | ||
| 114 | + child: Padding( | ||
| 115 | + padding: EdgeInsets.only( | ||
| 116 | + right: ScreenUtil().setWidth(18)), | ||
| 117 | + child: CommonButton( | ||
| 118 | + content: "早市", | ||
| 119 | + state: tableManagerModel.currTimeIndex == 1 ? 1 : 0, | ||
| 120 | + width: 92, | ||
| 121 | + height: 48, | ||
| 122 | + fontSize: 32, | ||
| 123 | + onPress: () { | ||
| 124 | + if (tableManagerModel.currTimeIndex == 1) return; | ||
| 125 | + tableManagerModel.currTimeIndex = 1; | ||
| 126 | + tableManagerModel.getReserveList(context); | ||
| 127 | + }, | ||
| 128 | + ))), | ||
| 129 | + Offstage( | ||
| 130 | + offstage: tableManagerModel.noon == "00:00-00:00" ? true : false, | ||
| 131 | + child: Padding( | ||
| 132 | + padding: EdgeInsets.only( | ||
| 133 | + right: ScreenUtil().setWidth(18)), | ||
| 134 | + child: CommonButton( | ||
| 135 | + content: "午市", | ||
| 136 | + state: tableManagerModel.currTimeIndex == 2 ? 1 : 0, | ||
| 137 | + width: 92, | ||
| 138 | + height: 48, | ||
| 139 | + fontSize: 32, | ||
| 140 | + onPress: () { | ||
| 141 | + if (tableManagerModel.currTimeIndex == 2) return; | ||
| 142 | + tableManagerModel.currTimeIndex = 2; | ||
| 143 | + tableManagerModel.getReserveList(context); | ||
| 144 | + }, | ||
| 145 | + ))), | ||
| 146 | + Offstage( | ||
| 147 | + offstage: tableManagerModel.night == "00:00-00:00" ? true : false, | ||
| 148 | + child: Container( | ||
| 149 | + // padding: EdgeInsets.symmetric( | ||
| 150 | + // horizontal: ScreenUtil().setWidth(10)), | ||
| 151 | + child: CommonButton( | ||
| 152 | + content: "晚市", | ||
| 153 | + state: tableManagerModel.currTimeIndex == 3 ? 1 : 0, | ||
| 154 | + width: 92, | ||
| 155 | + height: 48, | ||
| 156 | + fontSize: 32, | ||
| 157 | + onPress: () { | ||
| 158 | + if (tableManagerModel.currTimeIndex == 3) return; | ||
| 159 | + tableManagerModel.currTimeIndex = 3; | ||
| 160 | + tableManagerModel.getReserveList(context); | ||
| 161 | + }, | ||
| 162 | + )), | ||
| 163 | + ), | ||
| 164 | + ], | ||
| 165 | + ), | ||
| 166 | + ), | ||
| 167 | + ) | ||
| 168 | + ], | ||
| 303 | ), | 169 | ), |
| 304 | - Expanded( | ||
| 305 | - child: Padding( | ||
| 306 | - padding: EdgeInsets.symmetric( | ||
| 307 | - horizontal: ScreenUtil().setWidth(30)), | ||
| 308 | - child: Row( | ||
| 309 | - mainAxisAlignment: MainAxisAlignment.center, | ||
| 310 | - crossAxisAlignment: CrossAxisAlignment.center, | ||
| 311 | - children: <Widget>[ | ||
| 312 | - Offstage( | ||
| 313 | - offstage: morning == "00:00-00:00" ? true : false, | ||
| 314 | - child: Padding( | ||
| 315 | - padding: EdgeInsets.only( | ||
| 316 | - right: ScreenUtil().setWidth(18)), | ||
| 317 | - child: CommonButton( | ||
| 318 | - content: "早市", | ||
| 319 | - state: currTimeIndex == 1 ? 1 : 0, | ||
| 320 | - width: 92, | ||
| 321 | - height: 48, | ||
| 322 | - fontSize: 32, | ||
| 323 | - onPress: () { | ||
| 324 | - if (currTimeIndex == 1) return; | ||
| 325 | - setState(() { | ||
| 326 | - currTimeIndex = 1; | ||
| 327 | - }); | ||
| 328 | - _getReserveList(); | ||
| 329 | - }, | ||
| 330 | - ))), | ||
| 331 | - Offstage( | ||
| 332 | - offstage: noon == "00:00-00:00" ? true : false, | ||
| 333 | - child: Padding( | ||
| 334 | - padding: EdgeInsets.only( | ||
| 335 | - right: ScreenUtil().setWidth(18)), | ||
| 336 | - child: CommonButton( | ||
| 337 | - content: "午市", | ||
| 338 | - state: currTimeIndex == 2 ? 1 : 0, | ||
| 339 | - width: 92, | ||
| 340 | - height: 48, | ||
| 341 | - fontSize: 32, | ||
| 342 | - onPress: () { | ||
| 343 | - if (currTimeIndex == 2) return; | ||
| 344 | - setState(() { | ||
| 345 | - currTimeIndex = 2; | ||
| 346 | - }); | ||
| 347 | - _getReserveList(); | ||
| 348 | - }, | ||
| 349 | - ))), | ||
| 350 | - Offstage( | ||
| 351 | - offstage: night == "00:00-00:00" ? true : false, | ||
| 352 | - child: Container( | ||
| 353 | - // padding: EdgeInsets.symmetric( | ||
| 354 | - // horizontal: ScreenUtil().setWidth(10)), | ||
| 355 | - child: CommonButton( | ||
| 356 | - content: "晚市", | ||
| 357 | - state: currTimeIndex == 3 ? 1 : 0, | ||
| 358 | - width: 92, | ||
| 359 | - height: 48, | ||
| 360 | - fontSize: 32, | ||
| 361 | - onPress: () { | ||
| 362 | - if (currTimeIndex == 3) return; | 170 | + ), |
| 171 | + Expanded( | ||
| 172 | + child: Container( | ||
| 173 | + color: MyColours.color_ffffff, | ||
| 174 | + child: Row( | ||
| 175 | + children: <Widget>[ | ||
| 176 | + Container( | ||
| 177 | + width: ScreenUtil().setWidth(170), | ||
| 178 | + height: double.infinity, | ||
| 179 | + color: MyColours.color_f1f1f1, | ||
| 180 | + child: ListView.builder( | ||
| 181 | + itemBuilder: (context, index) { | ||
| 182 | + return AreaItem(tableManagerModel.areas[index], tableManagerModel.currentArea, | ||
| 183 | + (area) { | ||
| 363 | setState(() { | 184 | setState(() { |
| 364 | - currTimeIndex = 3; | 185 | + tableManagerModel.currentArea = (area as Area).name; |
| 186 | + tableManagerModel.currentTables=tableManagerModel.areaTableMap[tableManagerModel.currentArea]; | ||
| 365 | }); | 187 | }); |
| 366 | - _getReserveList(); | ||
| 367 | - }, | ||
| 368 | - )), | 188 | + }); |
| 189 | + }, | ||
| 190 | + itemExtent: ScreenUtil().setHeight(207), | ||
| 191 | + itemCount: tableManagerModel.areas.length, | ||
| 369 | ), | 192 | ), |
| 370 | - ], | ||
| 371 | - ), | ||
| 372 | - ), | ||
| 373 | - ) | ||
| 374 | - ], | ||
| 375 | - ), | ||
| 376 | - ), | ||
| 377 | - Expanded( | ||
| 378 | - child: Container( | ||
| 379 | - color: MyColours.color_ffffff, | ||
| 380 | - child: Row( | ||
| 381 | - children: <Widget>[ | ||
| 382 | - Container( | ||
| 383 | - width: ScreenUtil().setWidth(170), | ||
| 384 | - height: double.infinity, | ||
| 385 | - color: MyColours.color_f1f1f1, | ||
| 386 | - child: ListView.builder( | ||
| 387 | - itemBuilder: (context, index) { | ||
| 388 | - return AreaItem(areas[index], currentArea, | ||
| 389 | - (area) { | ||
| 390 | - setState(() { | ||
| 391 | - currentArea = (area as Area).name; | ||
| 392 | - }); | ||
| 393 | - }); | ||
| 394 | - }, | ||
| 395 | - itemExtent: ScreenUtil().setHeight(207), | ||
| 396 | - itemCount: areas.length, | ||
| 397 | - ), | 193 | + ), |
| 194 | + Expanded( | ||
| 195 | + child: Padding( | ||
| 196 | + padding: EdgeInsets.symmetric( | ||
| 197 | + vertical: ScreenUtil().setHeight(10), | ||
| 198 | + horizontal: ScreenUtil().setWidth(9)), | ||
| 199 | + child: Column( | ||
| 200 | + children: [ | ||
| 201 | + Expanded( | ||
| 202 | + child: GridView.builder( | ||
| 203 | + gridDelegate: | ||
| 204 | + SliverGridDelegateWithFixedCrossAxisCount( | ||
| 205 | + crossAxisCount: 3, | ||
| 206 | + childAspectRatio: 8 / 9), | ||
| 207 | + itemBuilder: (context, index) { | ||
| 208 | + return TableItem( | ||
| 209 | + tableManagerModel.areaTableMap[tableManagerModel.currentArea][index], | ||
| 210 | + onSelected: (table) { | ||
| 211 | + if ((table as t.Table).selected) { | ||
| 212 | + tableManagerModel.selectTables.add(table); | ||
| 213 | + } else { | ||
| 214 | + tableManagerModel.selectTables.removeWhere( | ||
| 215 | + (t) => t.id == table.id); | ||
| 216 | + } | ||
| 217 | + DialogUtil.showTableManagerDialog(context, table).then((value){ | ||
| 218 | + if(value!=null){ | ||
| 219 | + switch(value){ | ||
| 220 | + case 1://查看详情 | ||
| 221 | + NavigatorUtil.goNotebookDetailPage(context, tableManagerModel.tableMap[table.id].id); | ||
| 222 | + break; | ||
| 223 | + case 2://订座 | ||
| 224 | + NavigatorUtil.goNoteBookChangePage(context, NotebookDetail.fromTableManager(tableManagerModel.dateTime, tableManagerModel.currTimeIndex.toString(),table), ""); | ||
| 225 | + break; | ||
| 226 | + case 3://停用,启用桌位 | ||
| 227 | + Map params={ | ||
| 228 | + "id":table.id, | ||
| 229 | + "status":table.enable=="1"?"0":"1" | ||
| 230 | + }; | ||
| 231 | + tableManagerModel.setSwitchStatus(context, params); | ||
| 232 | + break; | ||
| 233 | + } | ||
| 234 | + } | ||
| 235 | + }); | ||
| 236 | + }, | ||
| 237 | + canSelected: false, | ||
| 238 | + canChoose: false, | ||
| 239 | + tableMap: tableManagerModel.tableMap, | ||
| 240 | + rid: ""); | ||
| 241 | + }, | ||
| 242 | + itemCount: tableManagerModel.areaTableMap[tableManagerModel.currentArea].length, | ||
| 243 | + )), | ||
| 244 | + ], | ||
| 245 | + )), | ||
| 246 | + ) | ||
| 247 | + ], | ||
| 398 | ), | 248 | ), |
| 399 | - Expanded( | ||
| 400 | - child: Padding( | ||
| 401 | - padding: EdgeInsets.symmetric( | ||
| 402 | - vertical: ScreenUtil().setHeight(10), | ||
| 403 | - horizontal: ScreenUtil().setWidth(9)), | ||
| 404 | - child: Column( | ||
| 405 | - children: [ | ||
| 406 | - Expanded( | ||
| 407 | - child: GridView.builder( | ||
| 408 | - gridDelegate: | ||
| 409 | - SliverGridDelegateWithFixedCrossAxisCount( | ||
| 410 | - crossAxisCount: 3, | ||
| 411 | - childAspectRatio: 8 / 9), | ||
| 412 | - itemBuilder: (context, index) { | ||
| 413 | - return TableItem( | ||
| 414 | - areaTableMap[currentArea][index], | ||
| 415 | - onSelected: (table) { | ||
| 416 | - if ((table as t.Table).selected) { | ||
| 417 | - selectTables.add(table); | ||
| 418 | - } else { | ||
| 419 | - selectTables.removeWhere( | ||
| 420 | - (t) => t.id == table.id); | ||
| 421 | - } | ||
| 422 | - }, | ||
| 423 | - canSelected: false, | ||
| 424 | - canChoose: false, | ||
| 425 | - tableMap: tableMap, | ||
| 426 | - rid: ""); | ||
| 427 | - }, | ||
| 428 | - itemCount: areaTableMap[currentArea].length, | ||
| 429 | - )), | ||
| 430 | - ], | ||
| 431 | - )), | ||
| 432 | - ) | ||
| 433 | - ], | 249 | + ), |
| 434 | ), | 250 | ), |
| 435 | - ), | ||
| 436 | - ), | ||
| 437 | - ], | 251 | + ], |
| 252 | + ); | ||
| 253 | + }, | ||
| 438 | ), | 254 | ), |
| 439 | ); | 255 | ); |
| 440 | } | 256 | } |
| 441 | 257 | ||
| 442 | - tableToTableList(t.Table table) { | ||
| 443 | - TableList _tableList = TableList( | ||
| 444 | - '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); | ||
| 445 | - _tableList.id = table.id; | ||
| 446 | - _tableList.rid = table.rid; | ||
| 447 | - _tableList.tid = table.tid; | ||
| 448 | - _tableList.name = table.name; | ||
| 449 | - _tableList.tablePnum = table.table_pnum; | ||
| 450 | - _tableList.sellerid = null; | ||
| 451 | - _tableList.qrcode = null; | ||
| 452 | - _tableList.mostPnum = table.most_pnum; | ||
| 453 | - _tableList.hot = null; | ||
| 454 | - _tableList.orderO = table.order_o; | ||
| 455 | - _tableList.status = table.status; | ||
| 456 | - _tableList.enable = table.enable; | ||
| 457 | - _tableList.spell = table.spell; | ||
| 458 | - _tableList.cdate = null; | ||
| 459 | - _tableList.rname = table.rname; | ||
| 460 | - _tableList.regionName = table.rname; | ||
| 461 | - _tableList.selected = true; | ||
| 462 | - return _tableList; | 258 | + @override |
| 259 | + void dispose() { | ||
| 260 | + // TODO: implement dispose | ||
| 261 | + super.dispose(); | ||
| 262 | + EventBus().off("refresh_tablemanager"); | ||
| 463 | } | 263 | } |
| 464 | } | 264 | } |
| 1 | import 'dart:convert'; | 1 | import 'dart:convert'; |
| 2 | import 'dart:io'; | 2 | import 'dart:io'; |
| 3 | 3 | ||
| 4 | +import 'package:common_utils/common_utils.dart'; | ||
| 4 | import 'package:contacts_service/contacts_service.dart'; | 5 | import 'package:contacts_service/contacts_service.dart'; |
| 5 | import 'package:dio/dio.dart'; | 6 | import 'package:dio/dio.dart'; |
| 6 | import 'package:flutter/cupertino.dart'; | 7 | import 'package:flutter/cupertino.dart'; |
| @@ -9,7 +10,6 @@ import 'package:one_key/net/base_resp.dart'; | @@ -9,7 +10,6 @@ import 'package:one_key/net/base_resp.dart'; | ||
| 9 | import 'package:one_key/net/dio_util.dart'; | 10 | import 'package:one_key/net/dio_util.dart'; |
| 10 | import 'package:one_key/net/http_url.dart'; | 11 | import 'package:one_key/net/http_url.dart'; |
| 11 | import 'package:one_key/provider/user_model.dart'; | 12 | import 'package:one_key/provider/user_model.dart'; |
| 12 | -import 'package:one_key/utils/log_util.dart'; | ||
| 13 | import 'package:one_key/utils/misc.dart'; | 13 | import 'package:one_key/utils/misc.dart'; |
| 14 | import 'package:provider/provider.dart'; | 14 | import 'package:provider/provider.dart'; |
| 15 | 15 |
| @@ -46,9 +46,8 @@ class EnterModel with ChangeNotifier { | @@ -46,9 +46,8 @@ class EnterModel with ChangeNotifier { | ||
| 46 | isSetDate = '0'; | 46 | isSetDate = '0'; |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | - //构造函数,初始化 | ||
| 50 | - EnterModel(this.detailEntity) { | ||
| 51 | - // clearData(); | 49 | + initData(NotebookDetail notebookDetail){ |
| 50 | + this.detailEntity=notebookDetail; | ||
| 52 | print(detailEntity); | 51 | print(detailEntity); |
| 53 | if (detailEntity.phone != '0') { | 52 | if (detailEntity.phone != '0') { |
| 54 | phoneController.text = detailEntity.phone; | 53 | phoneController.text = detailEntity.phone; |
| @@ -111,7 +110,7 @@ class EnterModel with ChangeNotifier { | @@ -111,7 +110,7 @@ class EnterModel with ChangeNotifier { | ||
| 111 | } | 110 | } |
| 112 | 111 | ||
| 113 | /// 初始化 早市、午市、晚市 | 112 | /// 初始化 早市、午市、晚市 |
| 114 | - _initSunDateList(morning, noon, night) { | 113 | + _initSunDateList(BuildContext context,morning, noon, night) { |
| 115 | String ddateSolt = detailEntity.ddate_solt; | 114 | String ddateSolt = detailEntity.ddate_solt; |
| 116 | if (morning != '') { | 115 | if (morning != '') { |
| 117 | sunDateList.add({ | 116 | sunDateList.add({ |
| @@ -119,7 +118,8 @@ class EnterModel with ChangeNotifier { | @@ -119,7 +118,8 @@ class EnterModel with ChangeNotifier { | ||
| 119 | 'dayText': '', | 118 | 'dayText': '', |
| 120 | 'ddateSolt': 1, | 119 | 'ddateSolt': 1, |
| 121 | 'key': 'morning', | 120 | 'key': 'morning', |
| 122 | - 'isSelect': ddateSolt == '1' ? true : false | 121 | + 'isSelect': ddateSolt == '1' ? true : false, |
| 122 | + "isEnable":!isOverMorning(DateTime.fromMillisecondsSinceEpoch(int.parse(detailEntity.ddate)*1000), context) | ||
| 123 | }); | 123 | }); |
| 124 | } | 124 | } |
| 125 | if (noon != '') { | 125 | if (noon != '') { |
| @@ -128,21 +128,75 @@ class EnterModel with ChangeNotifier { | @@ -128,21 +128,75 @@ class EnterModel with ChangeNotifier { | ||
| 128 | 'dayText': '', | 128 | 'dayText': '', |
| 129 | 'ddateSolt': 2, | 129 | 'ddateSolt': 2, |
| 130 | 'key': 'noon', | 130 | 'key': 'noon', |
| 131 | - 'isSelect': ddateSolt == '2' ? true : false | 131 | + 'isSelect': ddateSolt == '2' ? true : false, |
| 132 | + "isEnable":!isOverNoon(DateTime.fromMillisecondsSinceEpoch(int.parse(detailEntity.ddate)*1000), context) | ||
| 132 | }); | 133 | }); |
| 133 | } | 134 | } |
| 134 | - if (noon != '') { | 135 | + if (night != '') { |
| 135 | sunDateList.add({ | 136 | sunDateList.add({ |
| 136 | 'dateText': '晚市', | 137 | 'dateText': '晚市', |
| 137 | 'dayText': '', | 138 | 'dayText': '', |
| 138 | 'ddateSolt': 3, | 139 | 'ddateSolt': 3, |
| 139 | 'key': 'night', | 140 | 'key': 'night', |
| 140 | - 'isSelect': ddateSolt == '3' ? true : false | 141 | + 'isSelect': ddateSolt == '3' ? true : false, |
| 142 | + "isEnable":!isOverNight(DateTime.fromMillisecondsSinceEpoch(int.parse(detailEntity.ddate)*1000), context) | ||
| 141 | }); | 143 | }); |
| 142 | } | 144 | } |
| 143 | notifyListeners(); | 145 | notifyListeners(); |
| 144 | } | 146 | } |
| 145 | 147 | ||
| 148 | + updateSunDateList(DateTime dateTime,BuildContext context){ | ||
| 149 | + UserModel userModel=Provider.of<UserModel>(context,listen: false); | ||
| 150 | + for(Map item in sunDateList){ | ||
| 151 | + item["isEnable"]=true; | ||
| 152 | + if(item['dateText']=="早市"){ | ||
| 153 | + item["isEnable"]=!isOverMorning(dateTime, context); | ||
| 154 | + }else if(item['dateText']=="午市"){ | ||
| 155 | + item["isEnable"]=!isOverNoon(dateTime, context); | ||
| 156 | + }else if(item['dateText']=="晚市"){ | ||
| 157 | + item["isEnable"]=!isOverNight(dateTime, context); | ||
| 158 | + } | ||
| 159 | + } | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + | ||
| 163 | + | ||
| 164 | + //当前时间是否查过所选日期早市 | ||
| 165 | + bool isOverMorning(DateTime dateTime,BuildContext context){ | ||
| 166 | + int millsNow=DateTime.now().millisecondsSinceEpoch; | ||
| 167 | + UserModel userModel=Provider.of<UserModel>(context,listen: false); | ||
| 168 | + String morning=userModel.user.morning==""?"00:00-00:00":userModel.user.morning; | ||
| 169 | + String endMorning=morning.split("-")[1]; | ||
| 170 | + int endMorningMills=DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime).replaceRange(11,19, "$endMorning:00")); | ||
| 171 | + if(millsNow>endMorningMills)return true; | ||
| 172 | + return false; | ||
| 173 | + } | ||
| 174 | + | ||
| 175 | + //当前时间是否查过所选日期午市 | ||
| 176 | + bool isOverNoon(DateTime dateTime,BuildContext context){ | ||
| 177 | + int millsNow=DateTime.now().millisecondsSinceEpoch; | ||
| 178 | + UserModel userModel=Provider.of<UserModel>(context,listen: false); | ||
| 179 | + String noon=userModel.user.noon==""?"00:00-00:00":userModel.user.noon; | ||
| 180 | + String endNoon=noon.split("-")[1]; | ||
| 181 | + int endNoonMills=DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime).replaceRange(11,19, "$endNoon:00")); | ||
| 182 | + if(millsNow>endNoonMills)return true; | ||
| 183 | + return false; | ||
| 184 | + } | ||
| 185 | + | ||
| 186 | + //当前时间是否查过所选日期晚市 | ||
| 187 | + bool isOverNight(DateTime dateTime,BuildContext context){ | ||
| 188 | + int millsNow=DateTime.now().millisecondsSinceEpoch; | ||
| 189 | + UserModel userModel=Provider.of<UserModel>(context,listen: false); | ||
| 190 | + String night=userModel.user.night==""?"00:00-00:00":userModel.user.night; | ||
| 191 | + String endNight=night.split("-")[1]; | ||
| 192 | + int endNightMills=DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime).replaceRange(11,19, "$endNight:00")); | ||
| 193 | + if(millsNow>endNightMills)return true; | ||
| 194 | + return false; | ||
| 195 | + } | ||
| 196 | + | ||
| 197 | + | ||
| 198 | + | ||
| 199 | + | ||
| 146 | //人数 | 200 | //人数 |
| 147 | _initPersonNumList() { | 201 | _initPersonNumList() { |
| 148 | String pnum = detailEntity.pnum; | 202 | String pnum = detailEntity.pnum; |
| @@ -241,7 +295,7 @@ class EnterModel with ChangeNotifier { | @@ -241,7 +295,7 @@ class EnterModel with ChangeNotifier { | ||
| 241 | ? dailyMap.putIfAbsent('night', () => '') | 295 | ? dailyMap.putIfAbsent('night', () => '') |
| 242 | : dailyMap.putIfAbsent( | 296 | : dailyMap.putIfAbsent( |
| 243 | 'night', () => _getHourAndMinute(model.daily.night, 3, model)); | 297 | 'night', () => _getHourAndMinute(model.daily.night, 3, model)); |
| 244 | - _initSunDateList(model.daily.morning, model.daily.noon, model.daily.night); | 298 | + _initSunDateList(context,model.daily.morning, model.daily.noon, model.daily.night); |
| 245 | } | 299 | } |
| 246 | 300 | ||
| 247 | //根据获取时间 11:00-12:30 获取30分钟间隔组装的数组 | 301 | //根据获取时间 11:00-12:30 获取30分钟间隔组装的数组 |
| @@ -380,6 +434,7 @@ class EnterModel with ChangeNotifier { | @@ -380,6 +434,7 @@ class EnterModel with ChangeNotifier { | ||
| 380 | } else { | 434 | } else { |
| 381 | Utils.showToast(baseResp.msg ?? ""); | 435 | Utils.showToast(baseResp.msg ?? ""); |
| 382 | } | 436 | } |
| 437 | + | ||
| 383 | tableList = []; | 438 | tableList = []; |
| 384 | 439 | ||
| 385 | for (int i = 0; i < itemModelList.length; i++) { | 440 | for (int i = 0; i < itemModelList.length; i++) { |
| @@ -543,7 +598,6 @@ class EnterModel with ChangeNotifier { | @@ -543,7 +598,6 @@ class EnterModel with ChangeNotifier { | ||
| 543 | } | 598 | } |
| 544 | Map<String, String> params = { | 599 | Map<String, String> params = { |
| 545 | 'is_set_ddate': isSetDate, | 600 | 'is_set_ddate': isSetDate, |
| 546 | - "rid": detailEntity.id, //变更订单必传预定ID | ||
| 547 | "sid": userModel.user.sellerid, //商家ID | 601 | "sid": userModel.user.sellerid, //商家ID |
| 548 | "tid": tableSelectInfo, //桌子ID: 格式 2,3,4 | 602 | "tid": tableSelectInfo, //桌子ID: 格式 2,3,4 |
| 549 | "pnum": pnum, //预定用餐人数 | 603 | "pnum": pnum, //预定用餐人数 |
| @@ -552,16 +606,16 @@ class EnterModel with ChangeNotifier { | @@ -552,16 +606,16 @@ class EnterModel with ChangeNotifier { | ||
| 552 | "phone": phoneController.text, //预订人电话 | 606 | "phone": phoneController.text, //预订人电话 |
| 553 | "cusdem": customController.text, //预订人需求:25汉字 | 607 | "cusdem": customController.text, //预订人需求:25汉字 |
| 554 | "rdate": rdate, //预定用餐时间范围:时间戳 开始时间戳(time)-结束时间戳(time) | 608 | "rdate": rdate, //预定用餐时间范围:时间戳 开始时间戳(time)-结束时间戳(time) |
| 555 | - "ddate": '${ddate}'.substring(0, 10), //到店时间 | 609 | + "ddate": '$ddate'.substring(0, 10), //到店时间 |
| 556 | "ddate_solt": ddateSolt | 610 | "ddate_solt": ddateSolt |
| 557 | }; | 611 | }; |
| 558 | - print(params); | 612 | + print(params.toString()); |
| 559 | BaseResp<Map<String, dynamic>> baseResp = await DioUtil() | 613 | BaseResp<Map<String, dynamic>> baseResp = await DioUtil() |
| 560 | .request<Map<String, dynamic>>( | 614 | .request<Map<String, dynamic>>( |
| 561 | context, Method.get, HttpUrl.set_reserve_info, | 615 | context, Method.get, HttpUrl.set_reserve_info, |
| 562 | data: params) | 616 | data: params) |
| 563 | .catchError((error) { | 617 | .catchError((error) { |
| 564 | - print(error.toString()); | 618 | + print(error); |
| 565 | }); | 619 | }); |
| 566 | SunReserveInfoModel itemModel; | 620 | SunReserveInfoModel itemModel; |
| 567 | if (baseResp == null) return itemModel; | 621 | if (baseResp == null) return itemModel; |
| 1 | +import 'package:common_utils/common_utils.dart'; | ||
| 1 | import 'package:flutter/material.dart'; | 2 | import 'package:flutter/material.dart'; |
| 2 | import 'package:one_key/constant/constant.dart'; | 3 | import 'package:one_key/constant/constant.dart'; |
| 3 | import 'package:one_key/models/message.dart'; | 4 | import 'package:one_key/models/message.dart'; |
| @@ -7,7 +8,6 @@ import 'package:one_key/net/http_url.dart'; | @@ -7,7 +8,6 @@ import 'package:one_key/net/http_url.dart'; | ||
| 7 | 8 | ||
| 8 | import 'package:one_key/utils/dialog_util.dart'; | 9 | import 'package:one_key/utils/dialog_util.dart'; |
| 9 | import 'package:audioplayers/audio_cache.dart'; | 10 | import 'package:audioplayers/audio_cache.dart'; |
| 10 | -import 'package:one_key/utils/log_util.dart'; | ||
| 11 | import 'package:one_key/utils/utils.dart'; | 11 | import 'package:one_key/utils/utils.dart'; |
| 12 | 12 | ||
| 13 | class MessageDialogModel extends ChangeNotifier{ | 13 | class MessageDialogModel extends ChangeNotifier{ |
| @@ -6,7 +6,6 @@ import 'package:one_key/models/message.dart'; | @@ -6,7 +6,6 @@ import 'package:one_key/models/message.dart'; | ||
| 6 | import 'package:one_key/net/base_resp.dart'; | 6 | import 'package:one_key/net/base_resp.dart'; |
| 7 | import 'package:one_key/net/dio_util.dart'; | 7 | import 'package:one_key/net/dio_util.dart'; |
| 8 | import 'package:one_key/net/http_url.dart'; | 8 | import 'package:one_key/net/http_url.dart'; |
| 9 | -import 'package:one_key/utils/log_util.dart'; | ||
| 10 | import 'package:one_key/utils/utils.dart'; | 9 | import 'package:one_key/utils/utils.dart'; |
| 11 | 10 | ||
| 12 | 11 |
| @@ -131,7 +131,7 @@ class NotebookDetailChangeModel with ChangeNotifier { | @@ -131,7 +131,7 @@ class NotebookDetailChangeModel with ChangeNotifier { | ||
| 131 | 'isSelect': ddateSolt == '2' ? true : false | 131 | 'isSelect': ddateSolt == '2' ? true : false |
| 132 | }); | 132 | }); |
| 133 | } | 133 | } |
| 134 | - if (noon != '') { | 134 | + if (night != '') { |
| 135 | sunDateList.add({ | 135 | sunDateList.add({ |
| 136 | 'dateText': '晚市', | 136 | 'dateText': '晚市', |
| 137 | 'dayText': '', | 137 | 'dayText': '', |
| @@ -244,7 +244,7 @@ class NotebookDetailChangeModel with ChangeNotifier { | @@ -244,7 +244,7 @@ class NotebookDetailChangeModel with ChangeNotifier { | ||
| 244 | _initSunDateList(model.daily.morning, model.daily.noon, model.daily.night); | 244 | _initSunDateList(model.daily.morning, model.daily.noon, model.daily.night); |
| 245 | } | 245 | } |
| 246 | 246 | ||
| 247 | -//根据获取时间 11:00-12:30 获取30分钟间隔组装的数组 | 247 | + //根据获取时间 11:00-12:30 获取30分钟间隔组装的数组 |
| 248 | _getHourAndMinute( | 248 | _getHourAndMinute( |
| 249 | String hourAndMinuteStr, int mnd, SunSellerInfoModel model) { | 249 | String hourAndMinuteStr, int mnd, SunSellerInfoModel model) { |
| 250 | List tempDate = hourAndMinuteStr.split("-"); | 250 | List tempDate = hourAndMinuteStr.split("-"); |
| 1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
| 2 | import 'package:one_key/constant/constant.dart'; | 2 | import 'package:one_key/constant/constant.dart'; |
| 3 | +import 'package:one_key/models/area.dart'; | ||
| 4 | +import 'package:one_key/models/notebook.dart'; | ||
| 3 | import 'package:one_key/models/tableOuter.dart'; | 5 | import 'package:one_key/models/tableOuter.dart'; |
| 4 | import 'package:one_key/net/base_resp.dart'; | 6 | import 'package:one_key/net/base_resp.dart'; |
| 5 | import 'package:one_key/net/dio_util.dart'; | 7 | import 'package:one_key/net/dio_util.dart'; |
| 6 | import 'package:one_key/net/http_url.dart'; | 8 | import 'package:one_key/net/http_url.dart'; |
| 7 | import 'package:one_key/models/table.dart' as t; | 9 | import 'package:one_key/models/table.dart' as t; |
| 10 | +import 'package:one_key/provider/user_model.dart'; | ||
| 8 | import 'package:one_key/utils/navigator_util.dart'; | 11 | import 'package:one_key/utils/navigator_util.dart'; |
| 9 | import 'package:one_key/utils/utils.dart'; | 12 | import 'package:one_key/utils/utils.dart'; |
| 13 | +import 'package:provider/provider.dart'; | ||
| 14 | + | ||
| 15 | +import 'notebook_model.dart'; | ||
| 10 | 16 | ||
| 11 | class TableManagerModel with ChangeNotifier{ | 17 | class TableManagerModel with ChangeNotifier{ |
| 12 | 18 | ||
| 19 | + List<Area> areas = []; //区域列表 | ||
| 20 | + | ||
| 21 | + List<t.Table> selectTables = []; //选择的桌位 | ||
| 22 | + | ||
| 23 | + List<TableOuter> tableOuterList = []; //区域-桌位列表 | ||
| 24 | + | ||
| 25 | + Map<String, List<t.Table>> areaTableMap = {}; //区域-桌位Map | ||
| 26 | + List<t.Table> currentTables=[];//当前显示的区域-桌位 | ||
| 27 | + | ||
| 28 | + TableManagerModel tableManagerModel; | ||
| 29 | + | ||
| 30 | + Map<String, Notebook> tableMap = {}; //记录已预订桌位对应的订单 | ||
| 31 | + | ||
| 32 | + String currentArea; //当前选中区域 | ||
| 33 | + | ||
| 34 | + DateTime dateTime=DateTime.now(); | ||
| 35 | + | ||
| 36 | + String dateText = ""; //当前显示日期时间 | ||
| 37 | + int currTimeIndex = 1; //当前选中时间段 | ||
| 38 | + String morning; //早市时间段 | ||
| 39 | + String noon; //午市时间段 | ||
| 40 | + String night; //晚市时间段 | ||
| 41 | + UserModel userModel; | ||
| 42 | + | ||
| 43 | + //初始化时间 | ||
| 44 | + initTime(BuildContext context) async { | ||
| 45 | + userModel = Provider.of<UserModel>(context, listen: false); | ||
| 46 | + dateTime = DateTime.now(); | ||
| 47 | + dateText = Utils.addZeroNumber(dateTime.month) + | ||
| 48 | + "月" + | ||
| 49 | + Utils.addZeroNumber(dateTime.day) + | ||
| 50 | + "日" + | ||
| 51 | + " 今天"; | ||
| 52 | + morning = | ||
| 53 | + userModel.user.morning.isEmpty ? "00:00-00:00" : userModel.user.morning; | ||
| 54 | + noon = userModel.user.noon.isEmpty ? "00:00-00:00" : userModel.user.noon; | ||
| 55 | + night = userModel.user.night.isEmpty ? "00:00-00:00" : userModel.user.night; | ||
| 56 | + if (dateTime.isBefore(DateTime.parse(dateTime.year.toString() + | ||
| 57 | + "-" + | ||
| 58 | + Utils.addZeroNumber(dateTime.month) + | ||
| 59 | + "-" + | ||
| 60 | + Utils.addZeroNumber(dateTime.day) + | ||
| 61 | + " " + | ||
| 62 | + morning.split("-")[1] + | ||
| 63 | + ":00"))) { | ||
| 64 | + //未过早市 | ||
| 65 | + currTimeIndex = 1; | ||
| 66 | + } else if (dateTime.isAfter(DateTime.parse(dateTime.year.toString() + | ||
| 67 | + "-" + | ||
| 68 | + Utils.addZeroNumber(dateTime.month) + | ||
| 69 | + "-" + | ||
| 70 | + Utils.addZeroNumber(dateTime.day) + | ||
| 71 | + " " + | ||
| 72 | + morning.split("-")[1] + | ||
| 73 | + ":00")) && | ||
| 74 | + dateTime.isBefore(DateTime.parse(dateTime.year.toString() + | ||
| 75 | + "-" + | ||
| 76 | + Utils.addZeroNumber(dateTime.month) + | ||
| 77 | + "-" + | ||
| 78 | + Utils.addZeroNumber(dateTime.day) + | ||
| 79 | + " " + | ||
| 80 | + noon.split("-")[1] + | ||
| 81 | + ":00"))) { | ||
| 82 | + //过了早市,未过午市 | ||
| 83 | + currTimeIndex = 2; | ||
| 84 | + } else if (dateTime.isAfter(DateTime.parse(dateTime.year.toString() + | ||
| 85 | + "-" + | ||
| 86 | + Utils.addZeroNumber(dateTime.month) + | ||
| 87 | + "-" + | ||
| 88 | + Utils.addZeroNumber(dateTime.day) + | ||
| 89 | + " " + | ||
| 90 | + noon.split("-")[1] + | ||
| 91 | + ":00")) && | ||
| 92 | + dateTime.isBefore(DateTime.parse(dateTime.year.toString() + | ||
| 93 | + "-" + | ||
| 94 | + Utils.addZeroNumber(dateTime.month) + | ||
| 95 | + "-" + | ||
| 96 | + Utils.addZeroNumber(dateTime.day) + | ||
| 97 | + " " + | ||
| 98 | + night.split("-")[1] + | ||
| 99 | + ":00"))) { | ||
| 100 | + //过了午市,未过晚市 | ||
| 101 | + currTimeIndex = 3; | ||
| 102 | + } else { | ||
| 103 | + //过了晚市 | ||
| 104 | + currTimeIndex = 3; | ||
| 105 | + } | ||
| 106 | + Map<String, String> params = {"sellerid": userModel.user.sellerid}; | ||
| 107 | + tableOuterList = await tableManagerModel.getTableList(context, params); | ||
| 108 | + getReserveList(context); | ||
| 109 | + } | ||
| 110 | + | ||
| 13 | //获取桌位数据 | 111 | //获取桌位数据 |
| 14 | Future<List<TableOuter>> getTableList(BuildContext context,Map<String,String> params) async { | 112 | Future<List<TableOuter>> getTableList(BuildContext context,Map<String,String> params) async { |
| 15 | BaseResp<List> baseResp = await DioUtil() | 113 | BaseResp<List> baseResp = await DioUtil() |
| @@ -30,4 +128,130 @@ class TableManagerModel with ChangeNotifier{ | @@ -30,4 +128,130 @@ class TableManagerModel with ChangeNotifier{ | ||
| 30 | } | 128 | } |
| 31 | return []; | 129 | return []; |
| 32 | } | 130 | } |
| 131 | + | ||
| 132 | + //获取已预订列表 | ||
| 133 | + getReserveList(BuildContext context) async { | ||
| 134 | + NoteBookModel model = new NoteBookModel(); | ||
| 135 | + Map<String, String> params = { | ||
| 136 | + "sid": userModel.user.sellerid, | ||
| 137 | + "rdate": _getRdate(), | ||
| 138 | + "ddate_solt": currTimeIndex.toString(), | ||
| 139 | + "y": "200", | ||
| 140 | + "x": "1", | ||
| 141 | + "keywords": "", | ||
| 142 | + "sort": "1" | ||
| 143 | + }; | ||
| 144 | + List<Notebook> noteBooks = await model.getReserveList(context, params); | ||
| 145 | + for (Notebook notebook in noteBooks) { | ||
| 146 | + if (notebook.tid.isEmpty) continue; | ||
| 147 | + if (notebook.status == "1" || | ||
| 148 | + notebook.status == "2" || | ||
| 149 | + notebook.status == "5") { | ||
| 150 | + //已预订,用餐中,已安排 | ||
| 151 | + List<String> tids = notebook.tid.split(","); | ||
| 152 | + for (String tid in tids) { | ||
| 153 | + tableMap["$tid"] = notebook; | ||
| 154 | + } | ||
| 155 | + } | ||
| 156 | + } | ||
| 157 | + print(tableMap); | ||
| 158 | + initData(); | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + //获取一天开始-结束时间字符串 | ||
| 162 | + String _getRdate() { | ||
| 163 | + //一天开始时间 | ||
| 164 | + double startDay = (DateTime.parse((dateTime.year.toString() + | ||
| 165 | + "-" + | ||
| 166 | + Utils.addZeroNumber(dateTime.month) + | ||
| 167 | + "-" + | ||
| 168 | + Utils.addZeroNumber(dateTime.day) + | ||
| 169 | + " 00:00:00")) | ||
| 170 | + .millisecondsSinceEpoch) / | ||
| 171 | + 1000; | ||
| 172 | + //一天结束时间 | ||
| 173 | + double endDay = (DateTime.parse((dateTime.year.toString() + | ||
| 174 | + "-" + | ||
| 175 | + Utils.addZeroNumber(dateTime.month) + | ||
| 176 | + "-" + | ||
| 177 | + Utils.addZeroNumber(dateTime.day) + | ||
| 178 | + " 23:59:59")) | ||
| 179 | + .millisecondsSinceEpoch) / | ||
| 180 | + 1000; | ||
| 181 | + return startDay.floor().toString() + "-" + endDay.floor().toString(); | ||
| 182 | + } | ||
| 183 | + | ||
| 184 | + //初始桌位数据 | ||
| 185 | + initData() { | ||
| 186 | + areas.clear(); | ||
| 187 | + areaTableMap.clear(); | ||
| 188 | + for (TableOuter outer in tableOuterList) { | ||
| 189 | + int count = 0; | ||
| 190 | + for (t.Table table in outer.list) { | ||
| 191 | + if (table.tablestatus == "0") { | ||
| 192 | + //没有用餐中 | ||
| 193 | + if (tableMap["${table.id}"] != null) { | ||
| 194 | + Notebook notebook = tableMap["${table.id}"]; | ||
| 195 | + table.sign = notebook.status; | ||
| 196 | + table.notebookId = notebook.id; | ||
| 197 | + table.reserver = notebook.rnameStr; | ||
| 198 | + } else { | ||
| 199 | + table.sign = ""; | ||
| 200 | + table.notebookId = ""; | ||
| 201 | + if (table.enable == "1") { | ||
| 202 | + count++; | ||
| 203 | + } | ||
| 204 | + } | ||
| 205 | + } else { | ||
| 206 | + table.sign = "2"; | ||
| 207 | + table.notebookId = ""; | ||
| 208 | + } | ||
| 209 | + } | ||
| 210 | + areaTableMap["${outer.name}"] = outer.list; | ||
| 211 | + Area area = Area(); | ||
| 212 | + area.name = outer.name; | ||
| 213 | + area.count = count; | ||
| 214 | + areas.add(area); | ||
| 215 | + } | ||
| 216 | + currentArea = areaTableMap.keys.first; | ||
| 217 | + currentTables=areaTableMap[tableManagerModel.currentArea]; | ||
| 218 | + notifyListeners(); | ||
| 219 | + } | ||
| 220 | + | ||
| 221 | + //生成日期文本 | ||
| 222 | + createDateText(BuildContext context,DateTime day) { | ||
| 223 | + if (Utils.isOneDay(day, dateTime)) return; //日期没变 | ||
| 224 | + DateTime dateNow = DateTime.now(); | ||
| 225 | + dateText = Utils.addZeroNumber(day.month) + | ||
| 226 | + "月" + | ||
| 227 | + Utils.addZeroNumber(day.day) + | ||
| 228 | + "日"; | ||
| 229 | + if (Utils.isOneDay(day, dateNow)) { | ||
| 230 | + dateText += " 今天"; | ||
| 231 | + } else if (Utils.isOneDay(day, dateNow.add(Duration(days: 1)))) { | ||
| 232 | + dateText += " 明天"; | ||
| 233 | + } else if (Utils.isOneDay(day, dateNow.add(Duration(days: 2)))) { | ||
| 234 | + dateText += " 后天"; | ||
| 235 | + } else { | ||
| 236 | + dateText += " 周${Utils.formatWeekDayNum(day.weekday)}"; | ||
| 237 | + } | ||
| 238 | + dateTime = day; | ||
| 239 | + getReserveList(context); | ||
| 240 | + } | ||
| 241 | + | ||
| 242 | + //获取桌位数据 | ||
| 243 | + Future<dynamic> setSwitchStatus(BuildContext context,Map<String,String> params) async { | ||
| 244 | + BaseResp<dynamic> baseResp = await DioUtil() | ||
| 245 | + .request<List>(context, Method.get, HttpUrl.set_switch_status, | ||
| 246 | + data: params,showLoading: true) | ||
| 247 | + .catchError((error) { | ||
| 248 | + print(error.toString()); | ||
| 249 | + }); | ||
| 250 | + if(baseResp==null)return null; | ||
| 251 | + if(baseResp.code==Constant.status_success){ | ||
| 252 | + return baseResp.data; | ||
| 253 | + }else{ | ||
| 254 | + Utils.showToast(baseResp.msg); | ||
| 255 | + } | ||
| 256 | + } | ||
| 33 | } | 257 | } |
| @@ -2,6 +2,7 @@ import 'dart:convert'; | @@ -2,6 +2,7 @@ import 'dart:convert'; | ||
| 2 | import 'dart:io'; | 2 | import 'dart:io'; |
| 3 | import 'dart:math'; | 3 | import 'dart:math'; |
| 4 | 4 | ||
| 5 | +import 'package:common_utils/common_utils.dart'; | ||
| 5 | import 'package:dio/dio.dart'; | 6 | import 'package:dio/dio.dart'; |
| 6 | import 'package:flutter/material.dart'; | 7 | import 'package:flutter/material.dart'; |
| 7 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 8 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| @@ -13,7 +14,6 @@ import 'package:one_key/net/dio_util.dart'; | @@ -13,7 +14,6 @@ import 'package:one_key/net/dio_util.dart'; | ||
| 13 | import 'package:one_key/net/http_url.dart'; | 14 | import 'package:one_key/net/http_url.dart'; |
| 14 | import 'package:one_key/provider/user_model.dart'; | 15 | import 'package:one_key/provider/user_model.dart'; |
| 15 | import 'package:one_key/res/colors.dart'; | 16 | import 'package:one_key/res/colors.dart'; |
| 16 | -import 'package:one_key/utils/log_util.dart'; | ||
| 17 | import 'package:one_key/utils/utils.dart'; | 17 | import 'package:one_key/utils/utils.dart'; |
| 18 | import 'package:one_key/widgets/MyDivider.dart'; | 18 | import 'package:one_key/widgets/MyDivider.dart'; |
| 19 | import 'package:one_key/widgets/v_empty_view.dart'; | 19 | import 'package:one_key/widgets/v_empty_view.dart'; |
| @@ -46,4 +46,5 @@ class MyColours { | @@ -46,4 +46,5 @@ class MyColours { | ||
| 46 | static const Color color_E0E0E0 = Color(0xffE0E0E0); | 46 | static const Color color_E0E0E0 = Color(0xffE0E0E0); |
| 47 | static const Color color_E95750 = Color(0xffE95750); | 47 | static const Color color_E95750 = Color(0xffE95750); |
| 48 | static const Color color_A9E3E6 = Color(0xffA9E3E6); | 48 | static const Color color_A9E3E6 = Color(0xffA9E3E6); |
| 49 | + static const Color color_e5e5e5 = Color(0xffe5e5e5); | ||
| 49 | } | 50 | } |
| @@ -18,7 +18,6 @@ import 'package:one_key/pages/webview/webview_page.dart'; | @@ -18,7 +18,6 @@ import 'package:one_key/pages/webview/webview_page.dart'; | ||
| 18 | import 'package:one_key/provider/choose_table_model.dart'; | 18 | import 'package:one_key/provider/choose_table_model.dart'; |
| 19 | import 'package:one_key/provider/notebook_detail_change_model.dart'; | 19 | import 'package:one_key/provider/notebook_detail_change_model.dart'; |
| 20 | import 'package:one_key/utils/fluro_convert_utils.dart'; | 20 | import 'package:one_key/utils/fluro_convert_utils.dart'; |
| 21 | -import 'package:one_key/utils/log_util.dart'; | ||
| 22 | import 'package:provider/provider.dart'; | 21 | import 'package:provider/provider.dart'; |
| 23 | 22 | ||
| 24 | // 登录页 | 23 | // 登录页 |
| 1 | import 'package:fluro/fluro.dart'; | 1 | import 'package:fluro/fluro.dart'; |
| 2 | import 'package:flutter/material.dart'; | 2 | import 'package:flutter/material.dart'; |
| 3 | import 'package:one_key/pages/login/login_page.dart'; | 3 | import 'package:one_key/pages/login/login_page.dart'; |
| 4 | -import 'package:one_key/utils/log_util.dart'; | ||
| 5 | 4 | ||
| 6 | import 'route_handles.dart'; | 5 | import 'route_handles.dart'; |
| 7 | 6 |
| 1 | import 'dart:convert'; | 1 | import 'dart:convert'; |
| 2 | 2 | ||
| 3 | +import 'package:common_utils/common_utils.dart'; | ||
| 3 | import 'package:flutter/material.dart'; | 4 | import 'package:flutter/material.dart'; |
| 4 | import 'package:flutter_picker/flutter_picker.dart'; | 5 | import 'package:flutter_picker/flutter_picker.dart'; |
| 5 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 6 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| @@ -7,13 +8,14 @@ import 'package:one_key/constant/constant.dart'; | @@ -7,13 +8,14 @@ import 'package:one_key/constant/constant.dart'; | ||
| 7 | import 'package:one_key/pages/message/message_dialog_item.dart'; | 8 | import 'package:one_key/pages/message/message_dialog_item.dart'; |
| 8 | import 'package:one_key/provider/message_dialog_model.dart'; | 9 | import 'package:one_key/provider/message_dialog_model.dart'; |
| 9 | import 'package:one_key/res/colors.dart'; | 10 | import 'package:one_key/res/colors.dart'; |
| 10 | -import 'package:one_key/utils/log_util.dart'; | ||
| 11 | import 'package:one_key/utils/navigator_util.dart'; | 11 | import 'package:one_key/utils/navigator_util.dart'; |
| 12 | import 'package:one_key/utils/utils.dart'; | 12 | import 'package:one_key/utils/utils.dart'; |
| 13 | import 'package:one_key/widgets/common_button.dart'; | 13 | import 'package:one_key/widgets/common_button.dart'; |
| 14 | +import 'package:one_key/widgets/table_item.dart'; | ||
| 14 | import 'package:one_key/widgets/v_empty_view.dart'; | 15 | import 'package:one_key/widgets/v_empty_view.dart'; |
| 15 | import 'package:provider/provider.dart'; | 16 | import 'package:provider/provider.dart'; |
| 16 | import 'package:table_calendar/table_calendar.dart'; | 17 | import 'package:table_calendar/table_calendar.dart'; |
| 18 | +import 'package:one_key/models/table.dart' as t; | ||
| 17 | 19 | ||
| 18 | class DialogUtil { | 20 | class DialogUtil { |
| 19 | //显示消息弹框 | 21 | //显示消息弹框 |
| @@ -524,6 +526,102 @@ class DialogUtil { | @@ -524,6 +526,102 @@ class DialogUtil { | ||
| 524 | }); | 526 | }); |
| 525 | } | 527 | } |
| 526 | 528 | ||
| 529 | + //显示桌位管理弹框 | ||
| 530 | + static Future<int> showTableManagerDialog(BuildContext context,t.Table table) { | ||
| 531 | + return showModalBottomSheet( | ||
| 532 | + context: context, | ||
| 533 | + builder: (context) { | ||
| 534 | + Widget widget = Container( | ||
| 535 | + width: double.infinity, | ||
| 536 | + color: MyColours.color_f1f1f1, | ||
| 537 | + child: Column( | ||
| 538 | + mainAxisSize: MainAxisSize.min, | ||
| 539 | + children: <Widget>[ | ||
| 540 | + Container( | ||
| 541 | + width: double.infinity, | ||
| 542 | + alignment: Alignment.center, | ||
| 543 | + padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(20)), | ||
| 544 | + child: Text("${table.name}",style: TextStyle(fontSize: ScreenUtil().setSp(30),color: MyColours.color_999999),), | ||
| 545 | + ), | ||
| 546 | + Offstage( | ||
| 547 | + offstage: table.enable=="0", | ||
| 548 | + child: Column( | ||
| 549 | + mainAxisSize: MainAxisSize.min, | ||
| 550 | + children: [ | ||
| 551 | + Offstage( | ||
| 552 | + offstage: !(table.signStr=="已预订"||table.signStr=="用餐中"), | ||
| 553 | + child: GestureDetector( | ||
| 554 | + behavior: HitTestBehavior.opaque, | ||
| 555 | + onTap: (){ | ||
| 556 | + Navigator.of(context).pop(1); | ||
| 557 | + }, | ||
| 558 | + child: Container( | ||
| 559 | + width: double.infinity, | ||
| 560 | + alignment: Alignment.center, | ||
| 561 | + padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(40)), | ||
| 562 | + child: Text("查看详情",style: TextStyle(fontSize: ScreenUtil().setSp(34),color: MyColours.color_353535),), | ||
| 563 | + ), | ||
| 564 | + ) | ||
| 565 | + ), | ||
| 566 | + Offstage( | ||
| 567 | + offstage: table.signStr!="", | ||
| 568 | + child: GestureDetector( | ||
| 569 | + behavior: HitTestBehavior.opaque, | ||
| 570 | + onTap: (){ | ||
| 571 | + Navigator.of(context).pop(2); | ||
| 572 | + }, | ||
| 573 | + child: Container( | ||
| 574 | + width: double.infinity, | ||
| 575 | + alignment: Alignment.center, | ||
| 576 | + padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(40)), | ||
| 577 | + child: Text("订座",style: TextStyle(fontSize: ScreenUtil().setSp(34),color: MyColours.color_353535),), | ||
| 578 | + ) | ||
| 579 | + ), | ||
| 580 | + ), | ||
| 581 | + Container( | ||
| 582 | + width: double.infinity, | ||
| 583 | + height: ScreenUtil().setWidth(2), | ||
| 584 | + color: MyColours.color_e5e5e5, | ||
| 585 | + ) | ||
| 586 | + ], | ||
| 587 | + ), | ||
| 588 | + ), | ||
| 589 | + GestureDetector( | ||
| 590 | + behavior: HitTestBehavior.opaque, | ||
| 591 | + onTap: (){ | ||
| 592 | + Navigator.of(context).pop(3); | ||
| 593 | + }, | ||
| 594 | + child: Container( | ||
| 595 | + width: double.infinity, | ||
| 596 | + alignment: Alignment.center, | ||
| 597 | + padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(40)), | ||
| 598 | + child: Text("${table.enable=='1'?'停用桌位':'启用桌位'}",style: TextStyle(fontSize: ScreenUtil().setSp(34),color: MyColours.color_353535),), | ||
| 599 | + ) | ||
| 600 | + ), | ||
| 601 | + Container( | ||
| 602 | + width: double.infinity, | ||
| 603 | + height: ScreenUtil().setWidth(10), | ||
| 604 | + color: MyColours.color_e5e5e5, | ||
| 605 | + ), | ||
| 606 | + GestureDetector( | ||
| 607 | + behavior: HitTestBehavior.opaque, | ||
| 608 | + onTap: (){ | ||
| 609 | + Navigator.of(context).pop(); | ||
| 610 | + }, | ||
| 611 | + child: Container( | ||
| 612 | + width: double.infinity, | ||
| 613 | + alignment: Alignment.center, | ||
| 614 | + padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(40)), | ||
| 615 | + child: Text("取消",style: TextStyle(fontSize: ScreenUtil().setSp(34),color: MyColours.color_353535),), | ||
| 616 | + ) | ||
| 617 | + ), | ||
| 618 | + ], | ||
| 619 | + ), | ||
| 620 | + ); | ||
| 621 | + return widget; | ||
| 622 | + }); | ||
| 623 | + } | ||
| 624 | + | ||
| 527 | //显示选择客户经理弹框 | 625 | //显示选择客户经理弹框 |
| 528 | static Future<List<int>> showSelectCusmanDialog( | 626 | static Future<List<int>> showSelectCusmanDialog( |
| 529 | BuildContext context, List<String> data, ValueChanged valueChanged) { | 627 | BuildContext context, List<String> data, ValueChanged valueChanged) { |
lib/utils/log_util.dart
deleted
100644 → 0
| 1 | -class LogUtil { | ||
| 2 | - static const String _TAG_DEF = "###common_utils###"; | ||
| 3 | - | ||
| 4 | - static bool debuggable = false; //是否是debug模式,true: log v 不输出. | ||
| 5 | - static String TAG = _TAG_DEF; | ||
| 6 | - | ||
| 7 | - static void init({bool isDebug = false, String tag = _TAG_DEF}) { | ||
| 8 | - debuggable = isDebug; | ||
| 9 | - TAG = tag; | ||
| 10 | - } | ||
| 11 | - | ||
| 12 | - static void e(Object object, {String tag}) { | ||
| 13 | - _printLog(tag, ':', object); | ||
| 14 | - } | ||
| 15 | - | ||
| 16 | - static void v(Object object, {String tag}) { | ||
| 17 | - if (debuggable) { | ||
| 18 | - _printLog(tag, ':', object); | ||
| 19 | - } | ||
| 20 | - } | ||
| 21 | - | ||
| 22 | - static void _printLog(String tag, String stag, Object object) { | ||
| 23 | - String da = object.toString(); | ||
| 24 | - String _tag = (tag == null || tag.isEmpty) ? TAG : tag; | ||
| 25 | - while (da.isNotEmpty) { | ||
| 26 | - if (da.length > 1024) { | ||
| 27 | - print("$_tag $stag ${da.substring(0, 1024)}"); | ||
| 28 | - da = da.substring(1024, da.length); | ||
| 29 | - } else { | ||
| 30 | - print("$_tag $stag $da"); | ||
| 31 | - da = ""; | ||
| 32 | - } | ||
| 33 | - } | ||
| 34 | - } | ||
| 35 | -} |
| @@ -6,7 +6,6 @@ import 'package:one_key/models/table_list.dart'; | @@ -6,7 +6,6 @@ import 'package:one_key/models/table_list.dart'; | ||
| 6 | import 'package:one_key/res/colors.dart'; | 6 | import 'package:one_key/res/colors.dart'; |
| 7 | import 'package:one_key/route/routes.dart'; | 7 | import 'package:one_key/route/routes.dart'; |
| 8 | import 'package:one_key/utils/fluro_convert_utils.dart'; | 8 | import 'package:one_key/utils/fluro_convert_utils.dart'; |
| 9 | -import 'package:one_key/utils/log_util.dart'; | ||
| 10 | import 'package:one_key/utils/utils.dart'; | 9 | import 'package:one_key/utils/utils.dart'; |
| 11 | 10 | ||
| 12 | import '../app.dart'; | 11 | import '../app.dart'; |
| @@ -32,7 +31,7 @@ class NavigatorUtil { | @@ -32,7 +31,7 @@ class NavigatorUtil { | ||
| 32 | } | 31 | } |
| 33 | 32 | ||
| 34 | /// 首页 | 33 | /// 首页 |
| 35 | - static void goHomePage(BuildContext context, {int initialIndex = 2}) { | 34 | + static void goHomePage(BuildContext context, {int initialIndex = 1}) { |
| 36 | _navigateTo(context, "${Routes.home}?initialIndex=$initialIndex", | 35 | _navigateTo(context, "${Routes.home}?initialIndex=$initialIndex", |
| 37 | clearStack: true); | 36 | clearStack: true); |
| 38 | } | 37 | } |
| 1 | import 'dart:io'; | 1 | import 'dart:io'; |
| 2 | 2 | ||
| 3 | +import 'package:common_utils/common_utils.dart'; | ||
| 3 | import 'package:connectivity/connectivity.dart'; | 4 | import 'package:connectivity/connectivity.dart'; |
| 4 | import 'package:device_info/device_info.dart'; | 5 | import 'package:device_info/device_info.dart'; |
| 5 | import 'package:flutter/cupertino.dart'; | 6 | import 'package:flutter/cupertino.dart'; |
| @@ -8,7 +9,6 @@ import 'package:flutter_statusbarcolor/flutter_statusbarcolor.dart'; | @@ -8,7 +9,6 @@ import 'package:flutter_statusbarcolor/flutter_statusbarcolor.dart'; | ||
| 8 | import 'package:fluttertoast/fluttertoast.dart'; | 9 | import 'package:fluttertoast/fluttertoast.dart'; |
| 9 | import 'package:flutter/services.dart'; | 10 | import 'package:flutter/services.dart'; |
| 10 | import 'package:fluwx/fluwx.dart'; | 11 | import 'package:fluwx/fluwx.dart'; |
| 11 | -import 'package:one_key/utils/log_util.dart'; | ||
| 12 | import 'package:one_key/utils/navigator_util.dart'; | 12 | import 'package:one_key/utils/navigator_util.dart'; |
| 13 | import 'package:package_info/package_info.dart'; | 13 | import 'package:package_info/package_info.dart'; |
| 14 | import 'package:url_launcher/url_launcher.dart'; | 14 | import 'package:url_launcher/url_launcher.dart'; |
| @@ -143,4 +143,46 @@ class Utils { | @@ -143,4 +143,46 @@ class Utils { | ||
| 143 | } | 143 | } |
| 144 | return false; | 144 | return false; |
| 145 | } | 145 | } |
| 146 | + | ||
| 147 | + /// 获取日期 今天 明天 后天等等 | ||
| 148 | + static int getDdate(List dateList) { | ||
| 149 | + //当前选中 月 日string | ||
| 150 | + String mdStr = ''; | ||
| 151 | + //今天 明天 其他天 | ||
| 152 | + for (var item in dateList) { | ||
| 153 | + if (item['select'] == true) { | ||
| 154 | + mdStr = item['title']; | ||
| 155 | + } | ||
| 156 | + } | ||
| 157 | + String timeNowYear = DateUtil.formatDate(DateTime.now(), format: 'yyyy'); | ||
| 158 | + String ymyStr = timeNowYear + '-' + mdStr; //年月日 | ||
| 159 | + String timeStr = ymyStr + ' ' + "00:00:00"; | ||
| 160 | + int ddate = DateUtil.getDateMsByTimeStr(timeStr); //筛选日期时间戳 | ||
| 161 | + return ddate; | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + /// 获取早餐、午餐、晚餐字段 1 ,2, 3 | ||
| 165 | + static String getDdateSolt(List sunDateList) { | ||
| 166 | + String ddateSolt = ''; | ||
| 167 | + for (var item in sunDateList) { | ||
| 168 | + if (item['isSelect']) { | ||
| 169 | + ddateSolt = '${item['ddateSolt']}'; | ||
| 170 | + } | ||
| 171 | + } | ||
| 172 | + return ddateSolt; | ||
| 173 | + } | ||
| 174 | + | ||
| 175 | + /// 选中前面的按钮获取人数,输入的自己获取 | ||
| 176 | + static String getPnum(List personNumList) { | ||
| 177 | + String pnum = '6'; | ||
| 178 | + for (var item in personNumList) { | ||
| 179 | + if (item['isSelect']) { | ||
| 180 | + pnum = item['dateText']; | ||
| 181 | + } | ||
| 182 | + } | ||
| 183 | + if (pnum == '更多') { | ||
| 184 | + pnum = '6'; | ||
| 185 | + } | ||
| 186 | + return pnum; | ||
| 187 | + } | ||
| 146 | } | 188 | } |
-
Please register or login to post a comment