Commit 8cb67fc6960cf0973311a6ef462356407807eca0

Authored by wdn127929
1 parent 51636af2

宴会看板----差桌子信息

class FeastBoardModel {
String title;
Map<String, List<FeastBoardSunModel>> data;
FeastBoardModel({this.title, this.data});
FeastBoardModel.fromJson(Map<String, dynamic> json) {
data = {};
json.forEach((key, value) {
List<FeastBoardSunModel> temp = [];
value.forEach((element) {
FeastBoardSunModel sunModel = new FeastBoardSunModel.fromJson(element);
temp.add(sunModel);
});
data[key] = temp;
});
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['title'] = this.title;
data['data'] = this.data;
return data;
}
}
class FeastBoardSunModel {
String rname;
String id;
String rid;
String className;
String nickName;
String account;
FeastBoardSunModel(
{this.rname,
this.id,
this.rid,
this.className,
this.nickName,
this.account});
FeastBoardSunModel.fromJson(Map<String, dynamic> json) {
rname = json['rname'];
id = json['id'];
rid = json['rid'];
className = json['class_name'];
nickName = json['nick_name'];
account = json['account'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['rname'] = this.rname;
data['id'] = this.id;
data['rid'] = this.rid;
data['class_name'] = this.className;
data['nick_name'] = this.nickName;
data['account'] = this.account;
return data;
}
}
... ...
... ... @@ -329,4 +329,7 @@ class HttpUrl {
static const String get_exits_banquet_by_date =
"?service=App.Banquet.GetExitsBanquetByDate"; //查看指定时间内是否有宴会预定
static const String get_banquet_by_date =
"?service=App.Banquet.GetBanquetByDate"; //指定日期、时段宴会预定
}
... ...
... ... @@ -2,8 +2,10 @@
* 宴会看板
*/
import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/get_board_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:provider/provider.dart';
... ... @@ -11,10 +13,12 @@ import 'package:table_calendar/table_calendar.dart';
import '../../provider/feast_model.dart';
import '../../provider/user_model.dart';
import '../../route/navigator_util.dart';
import '../../utils/screen_util.dart';
import '../../utils/utils.dart';
import '../../widgets/round_button.dart';
import '../../widgets/v_empty_view.dart';
import 'feast_board.item.dart';
import 'feast_board_item.dart';
class FeastBoardPage extends StatefulWidget {
FeastBoardPage({Key key}) : super(key: key);
... ... @@ -28,6 +32,7 @@ class _FeastBoardPageState extends State<FeastBoardPage> {
DateTime dateTimeNow; //当前日期
bool calendarShow = true; //日历展开
FeastModel feastModel;
ScrollController controller = ScrollController();
@override
void initState() {
... ... @@ -37,9 +42,40 @@ class _FeastBoardPageState extends State<FeastBoardPage> {
Utils.changeStatusColor(color: MyColours.color_438E93);
WidgetsBinding.instance.addPostFrameCallback((_) {
_getExitsBanquetByDate();
_getBanquetByDate();
});
}
///指定日期、时段宴会预定
_getBanquetByDate() async {
UserModel userModel = Provider.of<UserModel>(context, listen: false);
String timeStrStart = dateTimeNow.year.toString() +
"-" +
Utils.addZeroNumber(dateTimeNow.month) +
"-" +
Utils.addZeroNumber(dateTimeNow.day) +
" 00:00:00";
String timeStrEnd = dateTimeNow.year.toString() +
"-" +
Utils.addZeroNumber(dateTimeNow.month) +
"-" +
Utils.addZeroNumber(dateTimeNow.day) +
" 23:59:59";
String start =
(DateUtil.getDateMsByTimeStr(timeStrStart) / 1000).floor().toString();
String end =
(DateUtil.getDateMsByTimeStr(timeStrEnd) / 1000).floor().toString();
Map<String, String> pramas = {
'sid': userModel.user.sellerid,
'rdate': '${start}',
'edate': '${end}'
};
bool success =
await feastModel.getBanquetByDate(context, pramas, showLoading: true);
if (success) {}
}
//解析返回显示的日期
static String _parseDateDay(DateTime dateTime) {
DateTime now = DateTime.now();
... ... @@ -56,6 +92,46 @@ class _FeastBoardPageState extends State<FeastBoardPage> {
}
}
Widget _callButton(
{GestureTapCallback onPress,
content,
hasLeftBorder = true,
isSelect = false}) {
return InkWell(
onTap: onPress,
child: Container(
height: h(48),
decoration: BoxDecoration(
color: isSelect ? MyColours.color_438E93 : MyColours.color_ffffff,
border: Border(
bottom: BorderSide(
color: MyColours.color_438E93,
width: ScreenUtil().setWidth(2)),
top: BorderSide(
color: MyColours.color_438E93,
width: ScreenUtil().setWidth(2)),
left: hasLeftBorder
? BorderSide(
color: MyColours.color_438E93,
width: ScreenUtil().setWidth(2))
: BorderSide.none,
right: BorderSide(
color: MyColours.color_438E93,
width: ScreenUtil().setWidth(2)))),
child: Align(
alignment: Alignment.center,
child: Text(
content,
style: TextStyle(
color:
isSelect ? MyColours.color_F6F6F6 : MyColours.color_438E93,
fontSize: ScreenUtil().setSp(36)),
),
),
),
);
}
///查看指定时间内是否有宴会预定
_getExitsBanquetByDate() async {
UserModel userModel = Provider.of<UserModel>(context, listen: false);
... ... @@ -114,6 +190,7 @@ class _FeastBoardPageState extends State<FeastBoardPage> {
if (!Utils.isOneDay(day, dateTimeNow)) {
//不是一天
dateTimeNow = day;
_getBanquetByDate();
}
},
// holidays: _holidays,
... ... @@ -458,7 +535,6 @@ class _FeastBoardPageState extends State<FeastBoardPage> {
// },
),
),
VEmptyView(4),
InkWell(
onTap: () {
calendarShow = !calendarShow;
... ... @@ -472,57 +548,63 @@ class _FeastBoardPageState extends State<FeastBoardPage> {
}
setState(() {});
},
child: Image.asset(
Utils.getImgPath(calendarShow
? 'y_chevron_up_circle'
: 'y_chevron_down_circle'),
width: ScreenUtil().setWidth(32))),
VEmptyView(32),
child: Container(
width: double.infinity,
color: Colors.white,
child: Column(
children: [
VEmptyView(4),
Image.asset(
Utils.getImgPath(calendarShow
? 'y_chevron_up_circle'
: 'y_chevron_down_circle'),
width: ScreenUtil().setWidth(32)),
VEmptyView(32),
],
),
))
],
)),
VEmptyView(48),
Expanded(
child: ListView.builder(
padding: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(8)),
itemBuilder: (context, index) {
return FeastBoardItem();
},
itemCount: 100,
)),
shrinkWrap: true,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(8)),
controller: controller,
itemBuilder: (context, index) {
FeastBoardModel boardModel =
feastModel.banquetByDateData[index];
return FeastBoardItem(
boardModel: boardModel,
controller: controller,
isOpen: !calendarShow,
);
},
itemCount: feastModel.banquetByDateData.length)),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
RoundButton(
onPressed: () async {
_calendarController.setSelectedDay(DateTime.now());
setState(() {});
},
text: '回到今天',
fontSize: 28,
isBold: false,
height: ScreenUtil().setWidth(70),
width: ScreenUtil().setWidth(220),
gradientStart: MyColours.color_2bb5b7,
gradientEnd: MyColours.color_2bb5b7,
radius: ScreenUtil().setWidth(10),
),
RoundButton(
onPressed: () async {
Navigator.pop(context);
},
text: '取消',
fontSize: 28,
isBold: false,
textColor: MyColours.color_333333,
borderColor: Color.fromRGBO(119, 119, 119, 1),
height: ScreenUtil().setWidth(70),
width: ScreenUtil().setWidth(220),
gradientStart: Colors.transparent,
gradientEnd: Colors.transparent,
radius: ScreenUtil().setWidth(10),
)
Expanded(
child: _callButton(
onPress: () async {
_calendarController.setSelectedDay(DateTime.now());
dateTimeNow = DateTime.now();
setState(() {});
_getBanquetByDate();
},
content: '回到今天',
hasLeftBorder: true,
isSelect: false)),
Expanded(
child: _callButton(
onPress: () async {
NavigatorUtil.goFeastCreatePage(context);
},
content: '创建宴会',
hasLeftBorder: true,
isSelect: true))
],
),
)
],
),
);
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/widgets/MyDivider.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import '../../widgets/round_button.dart';
class FeastBoardItem extends StatefulWidget {
FeastBoardItem({Key key}) : super(key: key);
@override
_FeastBoardItemState createState() => _FeastBoardItemState();
}
class _FeastBoardItemState extends State<FeastBoardItem> {
Widget numWidget(String title, bool select, {bool needMargin = true}) {
return Container(
width: ScreenUtil().setWidth(32),
height: ScreenUtil().setWidth(32),
alignment: Alignment.center,
margin: needMargin
? EdgeInsets.only(right: ScreenUtil().setWidth(50))
: EdgeInsets.zero,
decoration: BoxDecoration(
color: select ? MyColours.color_438E93 : MyColours.color_BFC4D4,
borderRadius: BorderRadius.circular(ScreenUtil().radius(4))),
child: Text(
title,
style: TextStyle(
color: select ? MyColours.color_ffffff : MyColours.color_515151,
fontSize: ScreenUtil().setSp(16)),
),
);
}
Widget canduanWidget(String title) {
return Column(
children: [
VEmptyView(16),
Row(
children: [
Text(
title,
style: TextStyle(
fontSize: ScreenUtil().setSp(28),
color: MyColours.color_000000,
fontWeight: FontWeight.bold),
),
HEmptyView(56),
RoundButton(
onPressed: () async {},
text: '刘经理 30桌',
fontSize: 20,
isBold: false,
height: ScreenUtil().setWidth(36),
width: ScreenUtil().setWidth(64 * 2),
gradientStart: MyColours.color_438E93,
gradientEnd: MyColours.color_438E93,
radius: ScreenUtil().radius(10),
textColor: MyColours.color_F6F6F6,
),
],
),
VEmptyView(16),
MyDivider(
double.infinity,
ScreenUtil().setWidth(2),
color: MyColours.color_DBDBDB,
)
],
);
}
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(bottom: ScreenUtil().setWidth(40)),
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(24),
vertical: ScreenUtil().setWidth(16)),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(ScreenUtil().radius(10)),
border: Border.all(
color: MyColours.color_438E93, width: ScreenUtil().setWidth(2))),
child: Column(
children: [
Row(
children: [
Text(
'凤凰厅',
style: TextStyle(
color: MyColours.color_438E93,
fontSize: ScreenUtil().setSp(40),
fontWeight: FontWeight.bold),
),
Spacer(),
numWidget('空', false),
numWidget('1', true),
numWidget('空', false),
numWidget('空', false, needMargin: false),
],
),
VEmptyView(24),
canduanWidget('早餐'),
canduanWidget('午餐'),
canduanWidget('晚餐'),
canduanWidget('其他'),
],
),
);
}
}
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/widgets/MyDivider.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import '../../models/get_board_model.dart';
import '../../route/navigator_util.dart';
import '../../utils/screen_util.dart';
import '../../widgets/round_button.dart';
class FeastBoardItem extends StatefulWidget {
final FeastBoardModel boardModel;
final ScrollController controller;
final bool isOpen;
FeastBoardItem({Key key, this.boardModel, this.controller, this.isOpen})
: super(key: key);
@override
_FeastBoardItemState createState() => _FeastBoardItemState();
}
class _FeastBoardItemState extends State<FeastBoardItem> {
Widget numWidget(String title, bool select, String subTitle,
{bool needMargin = true}) {
return Container(
margin: needMargin
? EdgeInsets.only(right: ScreenUtil().setWidth(50))
: EdgeInsets.zero,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: ScreenUtil().setWidth(32),
height: ScreenUtil().setWidth(32),
alignment: Alignment.center,
decoration: BoxDecoration(
color:
select ? MyColours.color_438E93 : MyColours.color_BFC4D4,
borderRadius: BorderRadius.circular(ScreenUtil().radius(4))),
child: Text(
title,
style: TextStyle(
color: select
? MyColours.color_ffffff
: MyColours.color_515151,
fontSize: ScreenUtil().setSp(16)),
),
),
VEmptyView(4),
Container(
// width: ScreenUtil().setWidth(32),
child: Text(
subTitle,
style:
TextStyle(color: MyColours.color_515151, fontSize: font(14)),
))
],
));
}
Widget canduanWidget(String title) {
return Column(
children: [
VEmptyView(16),
Row(
children: [
Text(
title,
style: TextStyle(
fontSize: ScreenUtil().setSp(28),
color: MyColours.color_000000,
fontWeight: FontWeight.bold),
),
HEmptyView(56),
Expanded(
child: ListView.builder(
shrinkWrap: true,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(8)),
controller: widget.controller,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
FeastBoardSunModel boardSunModel =
widget.boardModel.data[title][index];
return InkWell(
onTap: () {
//点击进入宴会详情
NavigatorUtil.goFeastDetailPage(
context, boardSunModel.rid);
},
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Expanded(
flex: 3,
child: Container(
height: h(24),
// constraints: BoxConstraints.expand(),
alignment: Alignment.centerLeft,
margin: index ==
widget.boardModel.data[title]
.length -
1
? EdgeInsets.zero
: EdgeInsets.only(bottom: h(16)),
padding: EdgeInsets.symmetric(
horizontal: w(4), vertical: w(2)),
decoration: BoxDecoration(
color: MyColours.color_438E93,
borderRadius:
BorderRadius.circular(w(5)),
),
child: Text(
'${boardSunModel.className}-${boardSunModel.rname}-桌子名称顿号隔开',
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: TextStyle(
fontSize: font(14),
color: MyColours.color_F6F6F6),
),
)),
Expanded(child: SizedBox()),
]));
},
itemCount: widget.boardModel.data[title].length)),
],
),
VEmptyView(16),
MyDivider(
double.infinity,
ScreenUtil().setWidth(2),
color: MyColours.color_DBDBDB,
)
],
);
}
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(bottom: ScreenUtil().setWidth(40)),
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(24),
vertical: ScreenUtil().setWidth(16)),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(ScreenUtil().radius(10)),
border: Border.all(
color: MyColours.color_438E93, width: ScreenUtil().setWidth(2))),
child: Column(
children: [
Row(
children: [
Text(
widget.boardModel.title,
style: TextStyle(
color: MyColours.color_438E93,
fontSize: ScreenUtil().setSp(40),
fontWeight: FontWeight.bold),
),
Spacer(),
numWidget(
widget.boardModel.data['早餐'].length == 0
? '空'
: '${widget.boardModel.data['早餐'].length}',
widget.boardModel.data['早餐'].length == 0 ? false : true,
'早餐'),
numWidget(
widget.boardModel.data['午餐'].length == 0
? '空'
: '${widget.boardModel.data['午餐'].length}',
widget.boardModel.data['午餐'].length == 0 ? false : true,
'午餐'),
numWidget(
widget.boardModel.data['晚餐'].length == 0
? '空'
: '${widget.boardModel.data['晚餐'].length}',
widget.boardModel.data['晚餐'].length == 0 ? false : true,
'晚餐'),
numWidget(
widget.boardModel.data['其他'].length == 0
? '空'
: '${widget.boardModel.data['其他'].length}',
widget.boardModel.data['其他'].length == 0 ? false : true,
'其他',
needMargin: false),
],
),
widget.isOpen ? VEmptyView(24) : SizedBox(),
widget.isOpen ? canduanWidget('早餐') : SizedBox(),
widget.isOpen ? canduanWidget('午餐') : SizedBox(),
widget.isOpen ? canduanWidget('晚餐') : SizedBox(),
widget.isOpen ? canduanWidget('其他') : SizedBox(),
],
),
);
}
}
... ...
... ... @@ -13,6 +13,7 @@ import '../models/filter_btn_model.dart';
import '../models/get_banquet_be_follow_model.dart';
import '../models/get_banquet_by_id_new_model.dart';
import '../models/get_banquet_deposit_model.dart';
import '../models/get_board_model.dart';
import '../models/get_deposit_model.dart';
import '../models/get_seller_user_by_sellerid_model.dart';
import '../models/get_setmeal_class_by_id_model.dart';
... ... @@ -87,6 +88,8 @@ class FeastModel extends ChangeNotifier {
Map<String, String> fullStatusByTime = {}; // 宴会看板 ---- 日历显示红点数据
List<FeastBoardModel> banquetByDateData = []; //宴会看板数据
/**
* 宴会看板
*/
... ... @@ -118,6 +121,41 @@ class FeastModel extends ChangeNotifier {
return fullStatusByTime;
}
//指定日期、时段宴会预定
Future<bool> getBanquetByDate(
BuildContext context, Map<String, String> params,
{showLoading = false}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.get_banquet_by_date,
data: params, showLoading: showLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {}
return false;
});
if (baseResp == null) return false;
if (baseResp.code == Constant.status_success) {
if (baseResp.data is List) {
banquetByDateData = [];
notifyListeners();
return true;
}
banquetByDateData = [];
baseResp.data.forEach((key, value) {
FeastBoardModel boardModel = FeastBoardModel();
boardModel.title = key;
boardModel.data = FeastBoardModel.fromJson(value).data;
banquetByDateData.add(boardModel);
});
notifyListeners();
return true;
} else {
Utils.showToast(baseResp.msg ?? "");
}
return false;
}
/**
* 宴会定金管理
*/
... ...