Commit d561a492e1ab38482cf43126b3060b6ba62dd508

Authored by wdn127929
1 parent c1199eb2

桌位选中widget

@@ -104,6 +104,8 @@ class _CouponEidtPageState extends State<CouponEidtPage> { @@ -104,6 +104,8 @@ class _CouponEidtPageState extends State<CouponEidtPage> {
104 // bus.emit('refresh_coupon_list'); 104 // bus.emit('refresh_coupon_list');
105 EventBus().emit('refresh_coupon_invitation'); 105 EventBus().emit('refresh_coupon_invitation');
106 bus.emit('refresh_coupon_list_f'); 106 bus.emit('refresh_coupon_list_f');
  107 +
  108 + bus.emit('refresh_table_m_coupon');
107 Navigator.pop(context, true); 109 Navigator.pop(context, true);
108 } 110 }
109 } 111 }
@@ -87,6 +87,7 @@ class TableManagerPageState extends State<TableManagerPage> { @@ -87,6 +87,7 @@ class TableManagerPageState extends State<TableManagerPage> {
87 SmsInfoData smsInfoData; 87 SmsInfoData smsInfoData;
88 MyModel myModel; 88 MyModel myModel;
89 89
  90 + String smsErro = '';
90 String showErro = ''; 91 String showErro = '';
91 92
92 // ScrollController _scrollCrl = ScrollController(); 93 // ScrollController _scrollCrl = ScrollController();
@@ -121,6 +122,10 @@ class TableManagerPageState extends State<TableManagerPage> { @@ -121,6 +122,10 @@ class TableManagerPageState extends State<TableManagerPage> {
121 ///刷新图片显示 122 ///刷新图片显示
122 _refreshTablePhoto(); 123 _refreshTablePhoto();
123 }); 124 });
  125 + EventBus().on("refresh_table_m_coupon", (arg) {
  126 + ///刷新优惠券
  127 + _couponNetworkData();
  128 + });
124 }); 129 });
125 } 130 }
126 131
@@ -130,17 +135,22 @@ class TableManagerPageState extends State<TableManagerPage> { @@ -130,17 +135,22 @@ class TableManagerPageState extends State<TableManagerPage> {
130 super.dispose(); 135 super.dispose();
131 EventBus().off("refresh_tablemanager"); 136 EventBus().off("refresh_tablemanager");
132 EventBus().off("refresh_tablePhoto"); 137 EventBus().off("refresh_tablePhoto");
  138 + EventBus().off("refresh_table_m_coupon");
133 } 139 }
134 140
135 ///获取短信余量 141 ///获取短信余量
136 _getSmsInfo(context) async { 142 _getSmsInfo(context) async {
137 smsInfoData = await myModel.getSmsInfo(context); 143 smsInfoData = await myModel.getSmsInfo(context);
138 - if (myModel.smsInfo.isEmpty) { 144 + if (myModel.smsInfo == '0') {
139 setState(() { 145 setState(() {
140 - showErro = '短信余额不足,请充值短信条数'; 146 + smsErro = '短信余额不足,请充值短信条数';
  147 + showErro = smsErro;
141 }); 148 });
142 } else { 149 } else {
143 - showErro = ''; 150 + setState(() {
  151 + smsErro = '';
  152 + showErro = '';
  153 + });
144 } 154 }
145 155
146 // setState(() { 156 // setState(() {
@@ -827,6 +837,9 @@ class TableManagerPageState extends State<TableManagerPage> { @@ -827,6 +837,9 @@ class TableManagerPageState extends State<TableManagerPage> {
827 if (value != null) { 837 if (value != null) {
828 sexSelectIndex = value.first; 838 sexSelectIndex = value.first;
829 sexStr = list[sexSelectIndex]; 839 sexStr = list[sexSelectIndex];
  840 + if (nameStr != null && nameStr != '') {
  841 + _addNameSuffix(nameStr, sexStr);
  842 + }
830 setState(() {}); 843 setState(() {});
831 } 844 }
832 }, selecteds: [sexSelectIndex]) 845 }, selecteds: [sexSelectIndex])
@@ -917,6 +930,7 @@ class TableManagerPageState extends State<TableManagerPage> { @@ -917,6 +930,7 @@ class TableManagerPageState extends State<TableManagerPage> {
917 setState(() {}); 930 setState(() {});
918 } 931 }
919 }, 932 },
  933 + title: '人数',
920 selecteds: 934 selecteds:
921 actualPnumIndex == 935 actualPnumIndex ==
922 null 936 null
@@ -983,6 +997,7 @@ class TableManagerPageState extends State<TableManagerPage> { @@ -983,6 +997,7 @@ class TableManagerPageState extends State<TableManagerPage> {
983 setState(() {}); 997 setState(() {});
984 } 998 }
985 }, 999 },
  1000 + title: '到店时间',
986 selecteds: 1001 selecteds:
987 ddateIndex == null 1002 ddateIndex == null
988 ? [] 1003 ? []
@@ -1236,19 +1251,53 @@ class TableManagerPageState extends State<TableManagerPage> { @@ -1236,19 +1251,53 @@ class TableManagerPageState extends State<TableManagerPage> {
1236 color: Colors.transparent), 1251 color: Colors.transparent),
1237 child: _buttonChoose(youhui, (value) { 1252 child: _buttonChoose(youhui, (value) {
1238 if (couponsCan == null || couponsCan.length == 0) { 1253 if (couponsCan == null || couponsCan.length == 0) {
1239 - Utils.showToast('暂无优惠券!'); 1254 + Utils.showToast('暂无优惠券,请创建新优惠');
1240 return; 1255 return;
1241 } 1256 }
1242 FocusScope.of(context).requestFocus(FocusNode()); //隐藏键盘 1257 FocusScope.of(context).requestFocus(FocusNode()); //隐藏键盘
1243 - DialogUtil.showSelectCusmanDialog(context, couponsCan, 1258 + DialogUtil.showSelectCusmanDialog(
  1259 + context,
  1260 + couponsCan,
1244 (value) { 1261 (value) {
1245 - if (value != null) {  
1246 - setState(() {  
1247 - couponSelectIndex = value.first;  
1248 - youhui = couponsCan[couponSelectIndex];  
1249 - });  
1250 - }  
1251 - }, 1262 + if (value != null) {
  1263 + setState(() {
  1264 + couponSelectIndex = value.first;
  1265 + youhui = couponsCan[couponSelectIndex];
  1266 + });
  1267 + }
  1268 + },
  1269 + title: '选择优惠',
  1270 + cancelText: '新增优惠',
  1271 + cancelTextColor: MyColours.color_438E93,
  1272 + onCancel: () async {
  1273 + UserModel userModel = Provider.of<UserModel>(
  1274 + context,
  1275 + listen: false);
  1276 + if (userModel.user.role_name == '管理员' ||
  1277 + userModel.user.role_name == '店长') {
  1278 + NavigatorUtil.goCouponCreateSelectTypePage(
  1279 + context);
  1280 + } else {
  1281 + bool needRefresh =
  1282 + await NavigatorUtil.goCouponEditPage(
  1283 + context);
  1284 + print(needRefresh);
  1285 + if (needRefresh != null && needRefresh) {
  1286 + _couponNetworkData();
  1287 + //刷新页面数据
  1288 + // _controller.callRefresh();
  1289 + // _couponNetworkData(tabController.index);
  1290 + }
  1291 + }
  1292 + // NavigatorUtil.goMarketingRecordsDetailPage(context);
  1293 + // bool needRefresh = await NavigatorUtil.goCouponEditPage(context);
  1294 + // print(needRefresh);
  1295 + // if (needRefresh != null && needRefresh) {
  1296 + // //刷新页面数据
  1297 + // // _controller.callRefresh();
  1298 + // _couponNetworkData();
  1299 + // }
  1300 + },
1252 selecteds: couponSelectIndex == null 1301 selecteds: couponSelectIndex == null
1253 ? [] 1302 ? []
1254 : [couponSelectIndex]) 1303 : [couponSelectIndex])
@@ -1430,6 +1479,7 @@ class TableManagerPageState extends State<TableManagerPage> { @@ -1430,6 +1479,7 @@ class TableManagerPageState extends State<TableManagerPage> {
1430 in tableManagerModel.tablesShow) { 1479 in tableManagerModel.tablesShow) {
1431 if (item.id == table.id) { 1480 if (item.id == table.id) {
1432 item.selected = false; 1481 item.selected = false;
  1482 + setState(() {});
1433 } 1483 }
1434 } 1484 }
1435 for (t.Table item 1485 for (t.Table item
@@ -1439,9 +1489,9 @@ class TableManagerPageState extends State<TableManagerPage> { @@ -1439,9 +1489,9 @@ class TableManagerPageState extends State<TableManagerPage> {
1439 .name]) { 1489 .name]) {
1440 if (item.id == table.id) { 1490 if (item.id == table.id) {
1441 item.selected = false; 1491 item.selected = false;
  1492 + setState(() {});
1442 } 1493 }
1443 } 1494 }
1444 - setState(() {});  
1445 }, 1495 },
1446 child: Container( 1496 child: Container(
1447 // color: Colors.red, 1497 // color: Colors.red,
@@ -1674,9 +1724,12 @@ class TableManagerPageState extends State<TableManagerPage> { @@ -1674,9 +1724,12 @@ class TableManagerPageState extends State<TableManagerPage> {
1674 radius: ScreenUtil().setWidth(8), 1724 radius: ScreenUtil().setWidth(8),
1675 isBold: false, 1725 isBold: false,
1676 onPressed: () async { 1726 onPressed: () async {
1677 - if (myModel.smsInfo.isEmpty) {  
1678 - return;  
1679 - } 1727 + // if (myModel.smsInfo == '0') {
  1728 + // setState(() {
  1729 + // showErro = smsErro;
  1730 + // });
  1731 + // return;
  1732 + // }
1680 if ((_baseIndoProvider.phoneController.text 1733 if ((_baseIndoProvider.phoneController.text
1681 .trim() 1734 .trim()
1682 .isEmpty || 1735 .isEmpty ||
@@ -1735,9 +1788,52 @@ class TableManagerPageState extends State<TableManagerPage> { @@ -1735,9 +1788,52 @@ class TableManagerPageState extends State<TableManagerPage> {
1735 params['Strtext'] = user.sellername; 1788 params['Strtext'] = user.sellername;
1736 } 1789 }
1737 */ 1790 */
  1791 + Guest guest = Guest(
  1792 + null,
  1793 + null,
  1794 + null,
  1795 + null,
  1796 + null,
  1797 + null,
  1798 + null,
  1799 + null,
  1800 + null,
  1801 + null,
  1802 + null,
  1803 + null,
  1804 + null,
  1805 + null,
  1806 + null,
  1807 + null,
  1808 + null);
  1809 + if (widget.guest == null) {
  1810 + guest.phone =
  1811 + _baseIndoProvider.phoneController.text; //预订人电话
  1812 +
  1813 + if (nameStr != null && nameStr.trim().length > 0) {
  1814 + String sex = '1';
  1815 + if (sexStr == '女士') {
  1816 + sex = '2';
  1817 + } else if (sexStr == '公司') {
  1818 + sex = '3';
  1819 + }
  1820 + guest.rname = nameStr; //预订人姓名
  1821 + guest.sex = sex; //预订人性别:1:男 2:女
  1822 +
  1823 + }
  1824 + }
  1825 + String pnum;
  1826 + if (actualPnum != '选填') {
  1827 + pnum = actualPnum;
  1828 + }
1738 SunReserveInfoModel _model = 1829 SunReserveInfoModel _model =
1739 await tableManagerModel.setReserveInfo(context, 1830 await tableManagerModel.setReserveInfo(context,
1740 - needKeep: true, guest: widget.guest); 1831 + needKeep: true,
  1832 + pnum: pnum,
  1833 + tempTime: ddateHm == '选填' ? null : ddateHm,
  1834 + guest: widget.guest == null
  1835 + ? guest
  1836 + : widget.guest);
1741 if (_model != null && 1837 if (_model != null &&
1742 ObjectUtil.isNotEmpty(_model.row) && 1838 ObjectUtil.isNotEmpty(_model.row) &&
1743 ObjectUtil.isNotEmpty(_model.row.id)) { 1839 ObjectUtil.isNotEmpty(_model.row.id)) {
@@ -1746,15 +1842,40 @@ class TableManagerPageState extends State<TableManagerPage> { @@ -1746,15 +1842,40 @@ class TableManagerPageState extends State<TableManagerPage> {
1746 // _homeEnterModel.clearData(); 1842 // _homeEnterModel.clearData();
1747 bus.emit("refresh_tablemanager"); //刷新当前页面 1843 bus.emit("refresh_tablemanager"); //刷新当前页面
1748 bus.emit("refresh_book_list"); //刷新已预订列表 1844 bus.emit("refresh_book_list"); //刷新已预订列表
1749 - UserModel userModel =  
1750 - Provider.of<UserModel>(context, listen: false);  
1751 - Map<String, String> params = {  
1752 - "rid": _model.row.id,  
1753 - "sid": userModel.user.sellerid  
1754 - };  
1755 - bool success = await couponProvider  
1756 - .sendSMSWxSendSms(context, params);  
1757 - print(success); 1845 + if (youhui != '选择优惠') {
  1846 + Map<String, String> params = {
  1847 + "rid": _model.row.id,
  1848 + "aid":
  1849 + '${couponProvider.couponListSelect[couponSelectIndex].id}'
  1850 + };
  1851 + bool isSuc = await couponProvider
  1852 + .setActivityAsReserve(context, params);
  1853 + if (isSuc) {
  1854 + couponProvider.hasModify = true;
  1855 + UserModel userModel = Provider.of<UserModel>(
  1856 + context,
  1857 + listen: false);
  1858 + Map<String, String> params = {
  1859 + "rid": _model.row.id,
  1860 + "sid": userModel.user.sellerid
  1861 + };
  1862 + bool success = await couponProvider
  1863 + .sendSMSWxSendSms(context, params);
  1864 + print(success);
  1865 + }
  1866 + } else {
  1867 + UserModel userModel = Provider.of<UserModel>(
  1868 + context,
  1869 + listen: false);
  1870 + Map<String, String> params = {
  1871 + "rid": _model.row.id,
  1872 + "sid": userModel.user.sellerid
  1873 + };
  1874 + bool success = await couponProvider
  1875 + .sendSMSWxSendSms(context, params);
  1876 + print(success);
  1877 + }
  1878 +
1758 // if (success) { 1879 // if (success) {
1759 // Utils.showToast('短信已经发送成功!'); 1880 // Utils.showToast('短信已经发送成功!');
1760 // } else { 1881 // } else {
@@ -277,7 +277,7 @@ class TableManagerModel with ChangeNotifier { @@ -277,7 +277,7 @@ class TableManagerModel with ChangeNotifier {
277 277
278 ///录入更改内部预订 278 ///录入更改内部预订
279 Future<SunReserveInfoModel> setReserveInfo(BuildContext context, 279 Future<SunReserveInfoModel> setReserveInfo(BuildContext context,
280 - {needKeep = false, Guest guest}) async { 280 + {needKeep = false, Guest guest, String pnum, String tempTime}) async {
281 if (selectTables.length == 0) { 281 if (selectTables.length == 0) {
282 Utils.showToast('请选择桌位'); 282 Utils.showToast('请选择桌位');
283 return null; 283 return null;
@@ -287,14 +287,16 @@ class TableManagerModel with ChangeNotifier { @@ -287,14 +287,16 @@ class TableManagerModel with ChangeNotifier {
287 if (sucess) { 287 if (sucess) {
288 UserModel userModel = Provider.of<UserModel>(context, listen: false); 288 UserModel userModel = Provider.of<UserModel>(context, listen: false);
289 // 289 //
290 - String tempTime;  
291 - if (currTimeIndex == 1) {  
292 - tempTime = '08:00';  
293 - } else if (currTimeIndex == 2) {  
294 - tempTime = '12:00';  
295 - } else if (currTimeIndex == 3) {  
296 - tempTime = '18:00'; 290 + if (tempTime == null) {
  291 + if (currTimeIndex == 1) {
  292 + tempTime = '08:00';
  293 + } else if (currTimeIndex == 2) {
  294 + tempTime = '12:00';
  295 + } else if (currTimeIndex == 3) {
  296 + tempTime = '18:00';
  297 + }
297 } 298 }
  299 +
298 String ymd = DateUtil.formatDate(dateTime, format: DateFormats.y_mo_d); 300 String ymd = DateUtil.formatDate(dateTime, format: DateFormats.y_mo_d);
299 String timeStr = ymd + ' ' + tempTime + ':00'; 301 String timeStr = ymd + ' ' + tempTime + ':00';
300 // int start = DateUtil.getDateMsByTimeStr(timeStr); 302 // int start = DateUtil.getDateMsByTimeStr(timeStr);
@@ -353,6 +355,10 @@ class TableManagerModel with ChangeNotifier { @@ -353,6 +355,10 @@ class TableManagerModel with ChangeNotifier {
353 // 'phone': '', 355 // 'phone': '',
354 // "cusdem": '' 356 // "cusdem": ''
355 }; 357 };
  358 + if (pnum != null && pnum != '') {
  359 + // params["actual_pum"] = pnum; //预定用餐人数
  360 + params["pnum"] = pnum; //预定用餐人数
  361 + }
356 if (guest != null) { 362 if (guest != null) {
357 if (guest.rnameStr != '') { 363 if (guest.rnameStr != '') {
358 params['rname'] = guest.rnameStr; 364 params['rname'] = guest.rnameStr;
@@ -3965,23 +3965,55 @@ class DialogUtil { @@ -3965,23 +3965,55 @@ class DialogUtil {
3965 //显示选择客户经理弹框 3965 //显示选择客户经理弹框
3966 static Future<List<int>> showSelectCusmanDialog( 3966 static Future<List<int>> showSelectCusmanDialog(
3967 BuildContext context, List<dynamic> data, ValueChanged valueChanged, 3967 BuildContext context, List<dynamic> data, ValueChanged valueChanged,
3968 - {List<int> selecteds}) { 3968 + {List<int> selecteds,
  3969 + Color cancelTextColor = const Color.fromRGBO(0, 0, 0, 0.6),
  3970 + String title = '',
  3971 + VoidCallback onCancel,
  3972 + String cancelText = '取消'}) {
3969 return Picker( 3973 return Picker(
3970 selecteds: selecteds, 3974 selecteds: selecteds,
3971 adapter: PickerDataAdapter<String>(pickerdata: data), 3975 adapter: PickerDataAdapter<String>(pickerdata: data),
3972 height: ScreenUtil().setWidth(480), 3976 height: ScreenUtil().setWidth(480),
3973 hideHeader: false, 3977 hideHeader: false,
3974 - cancelText: "取消",  
3975 - cancelTextStyle: TextStyle(  
3976 - color: MyColours.color_828282, fontSize: ScreenUtil().setSp(36)), 3978 + headerDecoration: BoxDecoration(
  3979 + color: MyColours.color_ffffff,
  3980 + border: Border(
  3981 + bottom: BorderSide(
  3982 + width: ScreenUtil().setWidth(2),
  3983 + color: MyColours.color_E7E7E7),
  3984 + )),
  3985 + title: Text(
  3986 + title,
  3987 + style: TextStyle(
  3988 + fontWeight: FontWeight.bold,
  3989 + color: Color.fromRGBO(0, 0, 0, 0.9),
  3990 + fontSize: ScreenUtil().setSp(32)),
  3991 + ),
  3992 + cancelText: cancelText,
  3993 + cancelTextStyle:
  3994 + TextStyle(color: cancelTextColor, fontSize: ScreenUtil().setSp(32)),
3977 confirmText: "确定", 3995 confirmText: "确定",
3978 itemExtent: ScreenUtil().setWidth(90), 3996 itemExtent: ScreenUtil().setWidth(90),
3979 confirmTextStyle: TextStyle( 3997 confirmTextStyle: TextStyle(
3980 - color: MyColours.color_2bb5b7, fontSize: ScreenUtil().setSp(36)), 3998 + color: MyColours.color_438E93, fontSize: ScreenUtil().setSp(32)),
3981 selectedTextStyle: TextStyle( 3999 selectedTextStyle: TextStyle(
3982 - color: MyColours.color_199095, fontSize: ScreenUtil().setSp(32)), 4000 + color: Color.fromRGBO(0, 0, 0, 0.9),
  4001 + fontSize: ScreenUtil().setSp(32)),
3983 textStyle: TextStyle( 4002 textStyle: TextStyle(
3984 - color: MyColours.color_353535, fontSize: ScreenUtil().setSp(32)), 4003 + color: Color.fromRGBO(0, 0, 0, 0.26),
  4004 + fontSize: ScreenUtil().setSp(32)),
  4005 + selectionOverlay: Container(
  4006 + height: ScreenUtil().setWidth(80),
  4007 + decoration: BoxDecoration(
  4008 + border: Border(
  4009 + bottom: BorderSide(
  4010 + width: ScreenUtil().setWidth(2),
  4011 + color: MyColours.color_E7E7E7),
  4012 + top: BorderSide(
  4013 + width: ScreenUtil().setWidth(2),
  4014 + color: MyColours.color_E7E7E7))),
  4015 + ),
  4016 + onCancel: onCancel,
3985 onConfirm: (Picker picker, List value) { 4017 onConfirm: (Picker picker, List value) {
3986 print(value.toString()); 4018 print(value.toString());
3987 if (valueChanged != null) { 4019 if (valueChanged != null) {