Commit a7260a9592b0af7e4b1ab4fa7335be6e36cfa0ab

Authored by wdn127929
1 parent 0e649f19

包间类型置满 - 按钮点击置满与否时刷新日历包间置满UI未做

... ... @@ -36,7 +36,10 @@ class SellerTableClassEntity extends Object {
@JsonKey(name: 'cdate')
String cdate;
SellerTableClassEntity(this.id,this.sellerid,this.tableid,this.name,this.max,this.low,this.status,this.isFull,this.isorderFull,this.cdate,);
@JsonKey(name: 'fid')
String fid;
SellerTableClassEntity(this.id,this.sellerid,this.tableid,this.name,this.max,this.low,this.status,this.isFull,this.isorderFull,this.cdate,this.fid);
factory SellerTableClassEntity.fromJson(Map<String, dynamic> srcJson) => _$SellerTableClassEntityFromJson(srcJson);
... ...
... ... @@ -9,16 +9,18 @@ part of 'seller_table_class_entity.dart';
SellerTableClassEntity _$SellerTableClassEntityFromJson(
Map<String, dynamic> json) {
return SellerTableClassEntity(
json['id'] as String,
json['sellerid'] as String,
json['tableid'] as String,
json['name'] as String,
json['max'] as String,
json['low'] as String,
json['status'] as dynamic,
json['isFull'] as dynamic,
json['isorderFull'] as dynamic,
json['cdate'] as String);
json['id'] as String,
json['sellerid'] as String,
json['tableid'] as String,
json['name'] as String,
json['max'] as String,
json['low'] as String,
json['status'] as dynamic,
json['isFull'] as dynamic,
json['isorderFull'] as dynamic,
json['cdate'] as String,
json['fid'] as String,
);
}
Map<String, dynamic> _$SellerTableClassEntityToJson(
... ... @@ -31,7 +33,8 @@ Map<String, dynamic> _$SellerTableClassEntityToJson(
'max': instance.max,
'low': instance.low,
'status': instance.status,
'isFull':instance.isFull,
'isorderFull':instance.isorderFull,
'cdate': instance.cdate
'isFull': instance.isFull,
'isorderFull': instance.isorderFull,
'cdate': instance.cdate,
'fid': instance.fid,
};
... ...
import 'package:json_annotation/json_annotation.dart';
part 'table_fill_up_date_model.g.dart';
@JsonSerializable()
class TableFillUpDateModel extends Object {
@JsonKey(name: 'ret')
int ret;
@JsonKey(name: 'data')
List<String> data;
@JsonKey(name: 'msg')
String msg;
TableFillUpDateModel(this.ret,this.data,this.msg,);
factory TableFillUpDateModel.fromJson(Map<String, dynamic> srcJson) => _$TableFillUpDateModelFromJson(srcJson);
Map<String, dynamic> toJson() => _$TableFillUpDateModelToJson(this);
}
... ...
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'table_fill_up_date_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
TableFillUpDateModel _$TableFillUpDateModelFromJson(Map<String, dynamic> json) {
return TableFillUpDateModel(
json['ret'] as int,
(json['data'] as List)?.map((e) => e as String)?.toList(),
json['msg'] as String,
);
}
Map<String, dynamic> _$TableFillUpDateModelToJson(
TableFillUpDateModel instance) =>
<String, dynamic>{
'ret': instance.ret,
'data': instance.data,
'msg': instance.msg,
};
... ...
... ... @@ -126,4 +126,10 @@ class HttpUrl {
static const String get_seller_tableclass =
"?service=App.Seller.GetSellerTableClass"; //获取商家包间类型
static const String set_table_class_full =
"?service=App.Seller.SetTableClassFull"; // 在线预订配置-置满包间分类
static const String get_table_fill_update =
"?service=App.Customer.GetTableFillUpDate"; // 根据指定日期,返回当前商家包间类型置满情况的日期
}
... ...
... ... @@ -321,7 +321,9 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver {
title: "包间类型置满管理",
content: "",
callback: () {
Utils.goMiniProgramZm(context, "roomtype/roomtype");
// Utils.goMiniProgramZm(context, "roomtype/roomtype");
NavigatorUtil.goStoreTypeFillManagePage(context);
},
),
MyDivider(
... ...
... ... @@ -5,6 +5,7 @@ import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
import 'package:table_calendar/table_calendar.dart';
... ... @@ -13,11 +14,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../../app.dart';
class StoreTypeFillManagePage extends StatefulWidget {
int timeMills; //日期
int ddate_solt; //时段
StoreTypeFillManagePage({Key key, this.timeMills, this.ddate_solt})
: super(key: key);
StoreTypeFillManagePage({Key key}) : super(key: key);
@override
State<StatefulWidget> createState() {
... ... @@ -41,6 +38,9 @@ class StoreTypeFillManagePageState extends State<StoreTypeFillManagePage> {
int timeIndex = 0; //当前时段
int enableIndex = 0; //最早可用时段
int timeMills;
List<String> fillTimes = [];
//早市,午市,晚市时间段
Map<String, String> daily = {"morning": "", "noon": "", "night": ""};
... ... @@ -49,16 +49,30 @@ class StoreTypeFillManagePageState extends State<StoreTypeFillManagePage> {
List<SellerTableClassEntity> tables = [];
//已选包间数量
Map<int, int> roomNum = {0: 0, 1: 0, 2: 0, 3: 0};
// Map<int, int> roomNum = {0: 0, 1: 0, 2: 0, 3: 0};
//已选包间下标
List<int> rooms = [];
// List<int> rooms = [];
//获取店铺详情
_getStoreDetail() {
_initTime();
_currTimeIndex();
_getSellerTableClass();
_getTableFillUpDate();
}
_getTableFillUpDate() async {
Map<String, String> params = {
"sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
"type": 'month',
"date":
"${_selectDateTime.year}-${Utils.addZeroNumber(_selectDateTime.month)}"
};
StoreDetailModel detailModel =
Provider.of<StoreDetailModel>(context, listen: false);
fillTimes = await detailModel.getTableFillUpDate(context, params);
setState(() {});
}
//当前选中时间段
... ... @@ -90,18 +104,6 @@ class StoreTypeFillManagePageState extends State<StoreTypeFillManagePage> {
timeIndex = -1;
enableIndex = 3;
}
if (widget.timeMills != 0 && widget.ddate_solt != 0) {
_selectDateTime = DateTime.fromMillisecondsSinceEpoch(widget.timeMills);
timeIndex = widget.ddate_solt;
if (!Utils.isOneDay(_selectDateTime, DateTime.now())) {
//不是今天
enableIndex = 0;
}
widget.timeMills = 0;
widget.ddate_solt = 0;
}
setState(() {});
}
... ... @@ -120,10 +122,8 @@ class StoreTypeFillManagePageState extends State<StoreTypeFillManagePage> {
StoreDetailModel detailModel =
Provider.of<StoreDetailModel>(context, listen: false);
tables = await detailModel.getSellerTableClass(context, params);
for (int i = 0; i < tables.length; i++) {
roomNum[i] = 0;
}
rooms.clear();
// tables.any((element) => element.isFull == 1);
// rooms.clear();
setState(() {});
}
... ... @@ -134,7 +134,9 @@ class StoreTypeFillManagePageState extends State<StoreTypeFillManagePage> {
tables = [];
_calendarController = CalendarController();
_events = {};
_getStoreDetail();
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
_getStoreDetail();
});
}
@override
... ... @@ -156,80 +158,16 @@ class StoreTypeFillManagePageState extends State<StoreTypeFillManagePage> {
daily = {"morning": morning, "noon": noon, "night": night};
}
//构建已选包间
_buildSelectRooms() {
List<Widget> selectRooms = [];
for (int i in rooms) {
selectRooms.add(Container(
margin: EdgeInsets.only(right: ScreenUtil().setWidth(10)),
child: Stack(
children: <Widget>[
Container(
width: ScreenUtil().setWidth(150),
height: ScreenUtil().setWidth(70),
margin: EdgeInsets.only(
right: ScreenUtil().setWidth(12),
top: ScreenUtil().setWidth(12)),
alignment: Alignment.center,
decoration: BoxDecoration(
color: MyColours.color_199095,
border: Border.all(
color: MyColours.color_199095,
width: ScreenUtil().setWidth(2)),
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(10))),
child: Text(
"${tables[i].name}",
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: ScreenUtil().setSp(30),
color: MyColours.color_199095,
fontWeight: FontWeight.bold,
),
),
),
Positioned(
top: 0,
right: 0,
child: GestureDetector(
onTap: () {
rooms.remove(i);
roomNum[i]--;
setState(() {});
},
child: Image.asset(
"assets/icon_clear.png",
width: ScreenUtil().setWidth(36),
height: ScreenUtil().setWidth(36),
),
),
)
],
),
));
}
return selectRooms;
}
//构建时段
Widget _buildShiduan() {
return Container(
padding: EdgeInsets.only(
left: ScreenUtil().setWidth(30),
top: ScreenUtil().setWidth(80),
top: ScreenUtil().setWidth(60),
right: ScreenUtil().setWidth(30)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"预订时段",
style: TextStyle(
fontSize: ScreenUtil().setSp(36),
color: MyColours.color_333333,
fontWeight: FontWeight.bold),
),
VEmptyView(30),
Stack(
children: <Widget>[
Container(
... ... @@ -439,6 +377,11 @@ class StoreTypeFillManagePageState extends State<StoreTypeFillManagePage> {
//解析返回显示的日期
_parseDateDay(DateTime dateTime) {
DateTime now = DateTime.now();
String dateTimeStr =
"${dateTime.year}-${Utils.addZeroNumber(dateTime.month)}-${Utils.addZeroNumber(dateTime.day)}";
if (fillTimes.length > 0 && fillTimes.contains(dateTimeStr)) {
return "置";
}
if (Utils.isOneDay(dateTime, now)) {
return "今";
} else if (Utils.isOneDay(dateTime, now.add(Duration(days: 1)))) {
... ... @@ -454,10 +397,15 @@ class StoreTypeFillManagePageState extends State<StoreTypeFillManagePage> {
Widget build(BuildContext context) {
userModel = Provider.of<UserModel>(context, listen: false);
return Scaffold(
appBar: SystemAppBar(
userModel.user.sellername,
onTap: () {
Navigator.pop(context);
},
),
body: Consumer<StoreDetailModel>(
builder: (context, model, child) {
Widget widget = Container();
Container(
return Container(
width: double.infinity,
height: double.infinity,
color: MyColours.color_ffffff,
... ... @@ -484,14 +432,13 @@ class StoreTypeFillManagePageState extends State<StoreTypeFillManagePage> {
availableGestures: AvailableGestures.none,
events: _events,
locale: "zh_CN",
initialCalendarFormat:
CalendarFormat.twoWeeks,
initialCalendarFormat: CalendarFormat.month,
headerStyle: HeaderStyle(
decoration: BoxDecoration(
color: MyColours.color_F9F9F9),
headerPadding: EdgeInsets.zero,
formatButtonVisible: false,
centerHeaderTitle: true,
centerHeaderTitle: false,
titleTextBuilder: (dateTime, _) {
return dateTime.year.toString() +
"年-" +
... ... @@ -652,32 +599,12 @@ class StoreTypeFillManagePageState extends State<StoreTypeFillManagePage> {
width: double.infinity,
padding: EdgeInsets.only(
left: ScreenUtil().setWidth(30),
top: ScreenUtil().setWidth(48),
top: ScreenUtil().setWidth(20),
right: ScreenUtil().setWidth(30)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
height: ScreenUtil().setWidth(82),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.end,
children: <Widget>[
Text(
"选择包间",
style: TextStyle(
fontSize: ScreenUtil().setSp(36),
color: MyColours.color_333333,
fontWeight: FontWeight.bold),
),
HEmptyView(24),
Wrap(
children: _buildSelectRooms(),
)
],
),
),
VEmptyView(30),
VEmptyView(60),
Selector<StoreDetailModel,
List<SellerTableClassEntity>>(
shouldRebuild: (pre, next) => true,
... ... @@ -695,39 +622,57 @@ class StoreTypeFillManagePageState extends State<StoreTypeFillManagePage> {
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
if (tables[index]
.status
.toString() ==
"0") return;
if ((tables[index]
.status
.toString() ==
"1" &&
((tables[index].isFull !=
null &&
tables[index]
.isFull
.toString() ==
"1") ||
(tables[index]
.isorderFull !=
null &&
tables[index]
.isorderFull
.toString() ==
"1")))) return;
int selectNum = 0;
roomNum.forEach((index, value) {
selectNum += value;
});
if (selectNum >= 3) {
Utils.showToast("最多可选3个包间");
return;
// if (tables[index]
// .status
// .toString() ==
// "0") return;
// if ((tables[index]
// .status
// .toString() ==
// "1" &&
// ((tables[index].isFull !=
// null &&
// tables[index]
// .isFull
// .toString() ==
// "1") ||
// (tables[index]
// .isorderFull !=
// null &&
// tables[index]
// .isorderFull
// .toString() ==
// "1")))) return;
// int selectNum = 0;
// roomNum.forEach((index, value) {
// selectNum += value;
// });
// if (selectNum >= 3) {
// Utils.showToast("最多可选3个包间");
// return;
// }
// setState(() {
// roomNum[index]++;
// rooms.add(index);
// });
Map<String, String> params = {
"classid": tables[index].id,
"day": (DateTime.parse(
"${_selectDateTime.year}-${Utils.addZeroNumber(_selectDateTime.month)}-${Utils.addZeroNumber(_selectDateTime.day)} 00:00:00")
.millisecondsSinceEpoch /
1000)
.floor()
.toString(),
"interval":
(timeIndex + 1).toString()
};
if (tables[index].isFull == 1 &&
tables[index].fid != null) {
params['id'] =
tables[index].fid;
}
setState(() {
roomNum[index]++;
rooms.add(index);
});
model.setTableClassFull(
context, params, index);
},
child: Stack(
children: <Widget>[
... ... @@ -750,12 +695,8 @@ class StoreTypeFillManagePageState extends State<StoreTypeFillManagePage> {
ScreenUtil()
.setWidth(10)),
border: Border.all(
color: roomNum[index] >
0
? MyColours
.color_199095
: MyColours
.color_cccccc,
color: MyColours
.color_cccccc,
width: ScreenUtil()
.setWidth(2)),
),
... ... @@ -824,7 +765,10 @@ class StoreTypeFillManagePageState extends State<StoreTypeFillManagePage> {
Positioned(
right: 0,
top: 0,
child: roomNum[index] > 0
child: tables[index].isFull !=
null &&
tables[index].isFull >
0
? Container(
width: ScreenUtil()
.setWidth(92),
... ... @@ -835,14 +779,7 @@ class StoreTypeFillManagePageState extends State<StoreTypeFillManagePage> {
decoration:
BoxDecoration(
color: MyColours
.color_F4FAFF,
border: Border.all(
color: MyColours
.color_199095,
width:
ScreenUtil()
.setWidth(
2)),
.color_dfdfdf,
borderRadius: BorderRadius.only(
topRight: Radius.circular(
ScreenUtil()
... ... @@ -854,71 +791,18 @@ class StoreTypeFillManagePageState extends State<StoreTypeFillManagePage> {
10))),
),
child: Text(
"已选${roomNum[index]}",
"置满",
style: TextStyle(
fontSize:
ScreenUtil()
.setSp(
24),
color: MyColours
.color_199095),
),
)
fontSize:
ScreenUtil()
.setSp(
24),
color: MyColours
.color_333333,
),
))
: Container(),
),
(tables[index]
.status
.toString() ==
"1" &&
((tables[index].isFull !=
null &&
tables[index]
.isFull
.toString() ==
"1") ||
(tables[index]
.isorderFull !=
null &&
tables[index]
.isorderFull
.toString() ==
"1")))
? Positioned(
right: 0,
bottom: 0,
child: Container(
width: ScreenUtil()
.setWidth(90),
height: ScreenUtil()
.setWidth(76),
child: Container(
child: Text(
"订满",
style: TextStyle(
color: MyColours
.color_999999,
fontSize:
ScreenUtil()
.setSp(
24)),
),
margin: EdgeInsets.only(
left: ScreenUtil()
.setWidth(
28),
top: ScreenUtil()
.setWidth(
28)),
),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
"assets/icon_man.png"),
fit: BoxFit
.cover)),
),
)
: Container()
],
),
);
... ... @@ -938,57 +822,8 @@ class StoreTypeFillManagePageState extends State<StoreTypeFillManagePage> {
),
),
),
Offstage(
offstage: enableIndex > 2,
child: Container(
height: ScreenUtil().setWidth(116),
alignment: Alignment.center,
decoration: BoxDecoration(
color: MyColours.color_ffffff,
boxShadow: [
BoxShadow(
color: MyColours.color_EEF0F2,
blurRadius: ScreenUtil().setWidth(8))
]),
child: GestureDetector(
onTap: () {
if (rooms.length <= 0) {
Utils.showToast("请选择包间");
return;
}
},
child: Container(
width: ScreenUtil().setWidth(670),
height: ScreenUtil().setWidth(84),
decoration: rooms.length > 0
? BoxDecoration(
gradient: LinearGradient(colors: [
MyColours.color_2bb5b7,
MyColours.color_199095
]),
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(44)),
)
: BoxDecoration(
color: MyColours.color_cccccc,
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(44)),
),
alignment: Alignment.center,
child: Text(
"选好了",
style: TextStyle(
fontSize: ScreenUtil().setSp(36),
color: MyColours.color_ffffff,
fontWeight: FontWeight.bold),
),
),
),
),
)
],
));
return widget;
},
),
);
... ...
import 'package:flutter/material.dart';
import 'package:one_key/constant/constant.dart';
import 'package:one_key/models/seller_table_class_entity.dart';
import 'package:one_key/models/table_fill_up_date_model.dart';
import 'package:one_key/net/base_resp.dart';
import 'package:one_key/net/dio_util.dart';
import 'package:one_key/net/http_url.dart';
... ... @@ -17,40 +18,71 @@ class StoreDetailModel with ChangeNotifier {
//获取商家包间类型
Future<List<SellerTableClassEntity>> getSellerTableClass(
BuildContext context, Map<String, String> params) async {
// pageState=PageState.Loading;
// notifyListeners();
BaseResp<List> baseResp = await DioUtil()
.request<List>(context, Method.get, HttpUrl.get_seller_tableclass,
data: params, showLoading: false)
.catchError((error) {
print(error.toString());
// if(error is MyError){
// switch(error.type){
// case 1:
// pageState=PageState.ConnectivityError;
// break;
// case 2:
// pageState=PageState.ConnectivityTimeOut;
// break;
// default:
// pageState=PageState.ConnectivityError;
// break;
// }
// }
// notifyListeners();
});
if (baseResp != null && baseResp.code == Constant.status_success) {
tables.clear();
tables.addAll(baseResp.data.map<SellerTableClassEntity>((value) {
return SellerTableClassEntity.fromJson(value);
}).toList());
// pageState=PageState.Success;
} else {
tables.clear();
// pageState=PageState.ConnectivityError;
Utils.showToast(baseResp.msg ?? "");
}
notifyListeners();
return tables;
}
//在线预订配置-置满包间分类
Future<bool> setTableClassFull(
BuildContext context, Map<String, String> params, int index) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.set_table_class_full,
data: params, showLoading: false)
.catchError((error) {
print(error.toString());
});
if (baseResp != null && baseResp.code == Constant.status_success) {
if (params.containsKey('id')) {
if (baseResp.data == true) {
tables[index].isFull = null;
tables[index].fid = null;
}
} else {
if (baseResp.data != null) {
tables[index].isFull = 1;
tables[index].fid = baseResp.data;
}
}
notifyListeners();
} else {
Utils.showToast(baseResp.msg ?? "");
}
return false;
}
// 根据指定日期,返回当前商家包间类型置满情况的日期
Future<List<String>> getTableFillUpDate(
BuildContext context, Map<String, String> params) async {
BaseResp<List> baseResp = await DioUtil()
.request<List>(context, Method.get, HttpUrl.get_table_fill_update,
data: params, showLoading: false)
.catchError((error) {
print(error.toString());
});
List<String> fillTimes = []; //置满的时间 2020-11-01
if (baseResp != null && baseResp.code == Constant.status_success) {
if (baseResp.data.length > 0) {
fillTimes = TableFillUpDateModel.fromJson(baseResp.responseData).data;
}
} else {
Utils.showToast(baseResp.msg ?? "");
}
return fillTimes;
}
}
... ...
... ... @@ -334,4 +334,11 @@ class NavigatorUtil {
"${Routes.statistics_sms_page}?selectData=${FluroConvertUtils.object2string(selectData)}",
replace: replace);
}
/// 包间类型置满
static Future<dynamic> goStoreTypeFillManagePage(BuildContext context,
{replace = false}) {
return _navigateTo(context, "${Routes.store_type_fill_manage_page}",
replace: replace);
}
}
... ...