|
|
@ -1,9 +1,11 @@
|
|
|
|
|
|
|
|
import 'package:aku_new_community/widget/buttons/bee_long_button.dart';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:bot_toast/bot_toast.dart';
|
|
|
|
import 'package:bot_toast/bot_toast.dart';
|
|
|
|
import 'package:common_utils/common_utils.dart';
|
|
|
|
import 'package:common_utils/common_utils.dart';
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
|
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:aku_new_community/base/base_style.dart';
|
|
|
|
import 'package:aku_new_community/base/base_style.dart';
|
|
|
@ -22,6 +24,9 @@ import 'package:aku_new_community/widget/buttons/bottom_button.dart';
|
|
|
|
import 'package:aku_new_community/widget/picker/bee_date_picker.dart';
|
|
|
|
import 'package:aku_new_community/widget/picker/bee_date_picker.dart';
|
|
|
|
import '../../../constants/saas_api.dart';
|
|
|
|
import '../../../constants/saas_api.dart';
|
|
|
|
import '../../../models/facility/facility_type_model.dart';
|
|
|
|
import '../../../models/facility/facility_type_model.dart';
|
|
|
|
|
|
|
|
import '../../../widget/bee_avatar_widget.dart';
|
|
|
|
|
|
|
|
import '../../../widget/bee_image_network.dart';
|
|
|
|
|
|
|
|
import '../../../widget/others/user_tool.dart';
|
|
|
|
import '../../../widget/picker/bee_choose_date_picker.dart';
|
|
|
|
import '../../../widget/picker/bee_choose_date_picker.dart';
|
|
|
|
import '../../../widget/picker/bee_day_picker.dart';
|
|
|
|
import '../../../widget/picker/bee_day_picker.dart';
|
|
|
|
import '../../manager/advice/advice_house_page.dart';
|
|
|
|
import '../../manager/advice/advice_house_page.dart';
|
|
|
@ -30,184 +35,192 @@ class FacilityPreorderPage extends StatefulWidget {
|
|
|
|
final FacilityTypeModel facilityModel;
|
|
|
|
final FacilityTypeModel facilityModel;
|
|
|
|
final FacilityTypeDetailModel typeModel;
|
|
|
|
final FacilityTypeDetailModel typeModel;
|
|
|
|
|
|
|
|
|
|
|
|
FacilityPreorderPage({Key? key, required this.facilityModel,required this.typeModel}) : super(key: key);
|
|
|
|
FacilityPreorderPage(
|
|
|
|
|
|
|
|
{Key? key, required this.facilityModel, required this.typeModel})
|
|
|
|
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
_FacilityPreorderPageState createState() => _FacilityPreorderPageState();
|
|
|
|
_FacilityPreorderPageState createState() => _FacilityPreorderPageState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class _FacilityPreorderPageState extends State<FacilityPreorderPage> {
|
|
|
|
class _FacilityPreorderPageState extends State<FacilityPreorderPage> {
|
|
|
|
DateTime? startDate;
|
|
|
|
List<int> dateList = [];
|
|
|
|
DateTime? endDate;
|
|
|
|
DateTime? date;
|
|
|
|
|
|
|
|
|
|
|
|
bool get canTap => startDate != null && endDate != null;
|
|
|
|
bool get canTap => dateList.isNotEmpty;
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final userProvider = Provider.of<UserProvider>(context);
|
|
|
|
final userProvider = Provider.of<UserProvider>(context);
|
|
|
|
return BeeScaffold(
|
|
|
|
return BeeScaffold(
|
|
|
|
title: '添加预订',
|
|
|
|
title: '添加预约',
|
|
|
|
bodyColor: Colors.white,
|
|
|
|
|
|
|
|
systemStyle: SystemStyle.yellowBottomBar,
|
|
|
|
systemStyle: SystemStyle.yellowBottomBar,
|
|
|
|
body: ListView(
|
|
|
|
body: ListView(
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 32.w),
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 20.w),
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
Text('业主房屋').pSymmetric(h: 32.w),
|
|
|
|
Container(
|
|
|
|
ListTile(
|
|
|
|
padding: EdgeInsets.all(10.w),
|
|
|
|
leading: Image.asset(
|
|
|
|
color: Colors.white,
|
|
|
|
R.ASSETS_ICONS_HOUSE_PNG,
|
|
|
|
child: ListTile(
|
|
|
|
height: 60.w,
|
|
|
|
leading: BeeAvatarWidget(
|
|
|
|
width: 60.w,
|
|
|
|
width: 90.w,
|
|
|
|
|
|
|
|
height: 90.w,
|
|
|
|
|
|
|
|
imgs: UserTool.userProvider.userInfoModel!.imgList,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
onTap: () => Get.to(() => AdviceHousePage()),
|
|
|
|
|
|
|
|
title: Text(
|
|
|
|
|
|
|
|
UserTool.userProvider.userInfoModel!.name!,
|
|
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
|
|
fontSize: 30.sp,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
subtitle: Text(
|
|
|
|
|
|
|
|
'租户 ' +
|
|
|
|
|
|
|
|
userProvider.defaultHouse!.communityName +
|
|
|
|
|
|
|
|
userProvider.defaultHouseString,
|
|
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
|
|
color: Colors.black.withOpacity(0.45),
|
|
|
|
|
|
|
|
fontSize: 26.sp,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
trailing: Icon(
|
|
|
|
|
|
|
|
CupertinoIcons.chevron_forward,
|
|
|
|
|
|
|
|
size: 35.w,
|
|
|
|
|
|
|
|
color: Colors.black.withOpacity(0.25),
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onTap: () => Get.to(() => AdviceHousePage()),
|
|
|
|
|
|
|
|
title: Text(S.of(context)!.tempPlotName),
|
|
|
|
|
|
|
|
subtitle: Text(userProvider.defaultHouse!.addressName),
|
|
|
|
|
|
|
|
trailing: Icon(CupertinoIcons.chevron_forward),
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
BeeDivider(
|
|
|
|
20.hb,
|
|
|
|
indent: 32.w,
|
|
|
|
Container(
|
|
|
|
endIndent: 32.w,
|
|
|
|
padding: EdgeInsets.all(40.w),
|
|
|
|
),
|
|
|
|
color: Colors.white,
|
|
|
|
32.hb,
|
|
|
|
child: Column(
|
|
|
|
Text('选择设施').pSymmetric(h: 32.w),
|
|
|
|
|
|
|
|
ListTile(
|
|
|
|
|
|
|
|
leading: Image.asset(
|
|
|
|
|
|
|
|
R.ASSETS_ICONS_FACILITY_PNG,
|
|
|
|
|
|
|
|
height: 60.w,
|
|
|
|
|
|
|
|
width: 60.w,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
onTap: () async {await Get.to(() =>
|
|
|
|
|
|
|
|
FacilityTypeDetailPage(facilityModel: widget.facilityModel));
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
title: Text(S.of(context)!.tempPlotName),
|
|
|
|
|
|
|
|
subtitle: Text(widget.typeModel.name),
|
|
|
|
|
|
|
|
trailing: Icon(CupertinoIcons.chevron_forward),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
BeeDivider(
|
|
|
|
|
|
|
|
indent: 32.w,
|
|
|
|
|
|
|
|
endIndent: 32.w,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
32.hb,
|
|
|
|
|
|
|
|
Text('预约时间').pSymmetric(h: 32.w),
|
|
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
|
|
height: 120.w,
|
|
|
|
|
|
|
|
child: Row(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
MaterialButton(
|
|
|
|
GestureDetector(
|
|
|
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
|
|
onTap: () async {
|
|
|
|
height: 120.w,
|
|
|
|
await Get.to(() => FacilityTypeDetailPage(
|
|
|
|
onPressed: () async {
|
|
|
|
facilityModel: widget.facilityModel));
|
|
|
|
DateTime? date = await BeeDayPicker.pick(DateTime.now());
|
|
|
|
setState(() {});
|
|
|
|
await Get.bottomSheet(FacilityPreorderDatePicker(typeModel: widget.typeModel,));
|
|
|
|
|
|
|
|
if (date != null) {
|
|
|
|
|
|
|
|
startDate = date;
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
child: Text(
|
|
|
|
child: Material(
|
|
|
|
startDate == null
|
|
|
|
color: Colors.transparent,
|
|
|
|
? '请选择开始时间'
|
|
|
|
child: Row(
|
|
|
|
: DateUtil.formatDate(
|
|
|
|
children: [
|
|
|
|
startDate,
|
|
|
|
SizedBox(
|
|
|
|
format: 'yyyy/MM/dd',
|
|
|
|
width: 170.w,
|
|
|
|
),
|
|
|
|
child: '选择设施'
|
|
|
|
style: TextStyle(
|
|
|
|
.text
|
|
|
|
color: ktextSubColor,
|
|
|
|
.size(28.sp)
|
|
|
|
|
|
|
|
.color(Colors.black.withOpacity(0.50))
|
|
|
|
|
|
|
|
.make(),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
'${widget.typeModel.name}'
|
|
|
|
|
|
|
|
.text
|
|
|
|
|
|
|
|
.size(28.sp)
|
|
|
|
|
|
|
|
.color(Colors.black.withOpacity(0.85))
|
|
|
|
|
|
|
|
.make(),
|
|
|
|
|
|
|
|
Spacer(),
|
|
|
|
|
|
|
|
Icon(
|
|
|
|
|
|
|
|
CupertinoIcons.chevron_right,
|
|
|
|
|
|
|
|
size: 35.w,
|
|
|
|
|
|
|
|
color: Colors.black.withOpacity(0.25),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
).expand(),
|
|
|
|
),
|
|
|
|
Icon(Icons.arrow_forward),
|
|
|
|
30.hb,
|
|
|
|
MaterialButton(
|
|
|
|
BeeDivider(),
|
|
|
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
|
|
30.hb,
|
|
|
|
height: 120.w,
|
|
|
|
GestureDetector(
|
|
|
|
onPressed: () async {
|
|
|
|
onTap: () async {
|
|
|
|
DateTime? date = await BeeDatePicker.pick(
|
|
|
|
date = await BeeDayPicker.pick(DateTime.now());
|
|
|
|
startDate == null
|
|
|
|
|
|
|
|
? DateTime.now().add(Duration(minutes: 90))
|
|
|
|
|
|
|
|
: startDate!.add(Duration(minutes: 30)),
|
|
|
|
|
|
|
|
min: startDate == null
|
|
|
|
|
|
|
|
? DateTime.now().add(Duration(minutes: 60))
|
|
|
|
|
|
|
|
: startDate!.add(Duration(minutes: 30)),
|
|
|
|
|
|
|
|
max: startDate == null
|
|
|
|
|
|
|
|
? DateTime.now().add(Duration(days: 2))
|
|
|
|
|
|
|
|
: (startDate!).add(Duration(days: 2)),
|
|
|
|
|
|
|
|
mode: CupertinoDatePickerMode.dateAndTime,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
if (date != null) {
|
|
|
|
if (date != null) {
|
|
|
|
endDate = date;
|
|
|
|
dateList =
|
|
|
|
|
|
|
|
await FacilityPreorderDate.choose(widget.typeModel);
|
|
|
|
|
|
|
|
dateList.sort();
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
child: Text(
|
|
|
|
child: Material(
|
|
|
|
endDate == null
|
|
|
|
color: Colors.transparent,
|
|
|
|
? '请选择结束时间'
|
|
|
|
child: Row(
|
|
|
|
: DateUtil.formatDate(
|
|
|
|
children: [
|
|
|
|
endDate,
|
|
|
|
SizedBox(
|
|
|
|
format: 'yyyy-MM-dd HH:mm',
|
|
|
|
width: 170.w,
|
|
|
|
),
|
|
|
|
child: '预约时间'
|
|
|
|
style: TextStyle(
|
|
|
|
.text
|
|
|
|
color: ktextSubColor,
|
|
|
|
.size(28.sp)
|
|
|
|
|
|
|
|
.color(Colors.black.withOpacity(0.50))
|
|
|
|
|
|
|
|
.make(),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
date != null
|
|
|
|
|
|
|
|
? '${DateUtil.formatDate(date, format: 'yyyy/MM/dd')} ${dateString(dateList)}'
|
|
|
|
|
|
|
|
.text
|
|
|
|
|
|
|
|
.size(28.sp)
|
|
|
|
|
|
|
|
.color(Colors.black.withOpacity(0.85))
|
|
|
|
|
|
|
|
.make()
|
|
|
|
|
|
|
|
: '请选择预约时段'
|
|
|
|
|
|
|
|
.text
|
|
|
|
|
|
|
|
.size(28.sp)
|
|
|
|
|
|
|
|
.color(Colors.black.withOpacity(0.85))
|
|
|
|
|
|
|
|
.make(),
|
|
|
|
|
|
|
|
Spacer(),
|
|
|
|
|
|
|
|
Icon(
|
|
|
|
|
|
|
|
CupertinoIcons.chevron_right,
|
|
|
|
|
|
|
|
size: 35.w,
|
|
|
|
|
|
|
|
color: Colors.black.withOpacity(0.25),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
).expand(),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
BeeDivider(
|
|
|
|
|
|
|
|
indent: 32.w,
|
|
|
|
|
|
|
|
endIndent: 32.w,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
bottomNavi: BottomButton(
|
|
|
|
bottomNavi: Padding(
|
|
|
|
onPressed: canTap
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
? () async {
|
|
|
|
left: 32.w,
|
|
|
|
// if (dateDifferenceIsTrue) {
|
|
|
|
right: 32.w,
|
|
|
|
final cancel = BotToast.showLoading();
|
|
|
|
bottom: MediaQuery.of(context).padding.bottom + 32.w),
|
|
|
|
var model = await NetUtil().post(
|
|
|
|
child: BeeLongButton(
|
|
|
|
SAASAPI.facilities.insert,
|
|
|
|
onPressed: canTap
|
|
|
|
params: {
|
|
|
|
? () async {
|
|
|
|
'estateId': userProvider.defaultHouse!.id,
|
|
|
|
// if (dateDifferenceIsTrue) {
|
|
|
|
'type':widget.facilityModel.type,
|
|
|
|
final cancel = BotToast.showLoading();
|
|
|
|
'facilitiesCategoryId':widget.facilityModel.id,
|
|
|
|
var model = await NetUtil().post(
|
|
|
|
'facilitiesManageId':widget.typeModel.id,
|
|
|
|
SAASAPI.facilities.insert,
|
|
|
|
'appointmentDate':1,
|
|
|
|
params: {
|
|
|
|
'appointmentPeriodList':1,
|
|
|
|
'estateId': userProvider.defaultHouse!.id,
|
|
|
|
},
|
|
|
|
'type': widget.facilityModel.type,
|
|
|
|
);
|
|
|
|
'facilitiesCategoryId': widget.facilityModel.id,
|
|
|
|
cancel();
|
|
|
|
'facilitiesManageId': widget.typeModel.id,
|
|
|
|
if (model.success == true) {
|
|
|
|
'appointmentDate': DateUtil.formatDate(date,format: 'yyyy-MM-dd HH:mm:ss'),
|
|
|
|
BotToast.showText(text: '预约成功');
|
|
|
|
'appointmentPeriodList': dateList,
|
|
|
|
Get.back(result: true);
|
|
|
|
},
|
|
|
|
} else if (model.msg == '该时段已被预约') {
|
|
|
|
);
|
|
|
|
await Get.dialog(_hasBeenOrder());
|
|
|
|
cancel();
|
|
|
|
} else {
|
|
|
|
if (model.success == true) {
|
|
|
|
BotToast.showText(text: '预约失败');
|
|
|
|
BotToast.showText(text: '预约成功');
|
|
|
|
|
|
|
|
Get.back(result: true);
|
|
|
|
|
|
|
|
} else if (model.msg == '该时段已被预约') {
|
|
|
|
|
|
|
|
await Get.dialog(_hasBeenOrder());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
BotToast.showText(text: '预约失败');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// BotToast.showText(text: '预约时间必须为半小时的整数倍');
|
|
|
|
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// } else {
|
|
|
|
: null,
|
|
|
|
// BotToast.showText(text: '预约时间必须为半小时的整数倍');
|
|
|
|
text: '确认提交',
|
|
|
|
// }
|
|
|
|
),
|
|
|
|
}
|
|
|
|
|
|
|
|
: null,
|
|
|
|
|
|
|
|
child: Text('确认提交'),
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool get dateDifferenceIsTrue {
|
|
|
|
|
|
|
|
if (startDate != null && endDate != null) {
|
|
|
|
|
|
|
|
int _diff = endDate!.difference(startDate!).inMinutes;
|
|
|
|
|
|
|
|
if (_diff < 30) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
} else if (_diff % 30 != 0) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Widget _hasBeenOrder() {
|
|
|
|
Widget _hasBeenOrder() {
|
|
|
|
return CupertinoAlertDialog(
|
|
|
|
return CupertinoAlertDialog(
|
|
|
|
title: '此设施已被预约'
|
|
|
|
title: '此设施已被预约'
|
|
|
@ -232,8 +245,8 @@ class _FacilityPreorderPageState extends State<FacilityPreorderPage> {
|
|
|
|
'取消'.text.size(30.sp).color(ktextPrimary).isIntrinsic.make()),
|
|
|
|
'取消'.text.size(30.sp).color(ktextPrimary).isIntrinsic.make()),
|
|
|
|
CupertinoActionSheetAction(
|
|
|
|
CupertinoActionSheetAction(
|
|
|
|
onPressed: () {
|
|
|
|
onPressed: () {
|
|
|
|
Get.off(
|
|
|
|
Get.off(() =>
|
|
|
|
() => FacilityOrderDateListPage(facilitiesId: widget.typeModel.id));
|
|
|
|
FacilityOrderDateListPage(facilitiesId: widget.typeModel.id));
|
|
|
|
},
|
|
|
|
},
|
|
|
|
child:
|
|
|
|
child:
|
|
|
|
'查看'.text.size(30.sp).color(kPrimaryColor).isIntrinsic.make()),
|
|
|
|
'查看'.text.size(30.sp).color(kPrimaryColor).isIntrinsic.make()),
|
|
|
@ -241,3 +254,17 @@ class _FacilityPreorderPageState extends State<FacilityPreorderPage> {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DateTime getDate(int dateNum) {
|
|
|
|
|
|
|
|
DateTime startDate = DateTime(
|
|
|
|
|
|
|
|
DateTime.now().year, DateTime.now().month, DateTime.now().day, 0, 0, 0);
|
|
|
|
|
|
|
|
return startDate.add(Duration(minutes: 30 * (dateNum - 1)));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String dateString(List<int> dates){
|
|
|
|
|
|
|
|
if(dates.length==1)
|
|
|
|
|
|
|
|
return '${DateUtil.formatDate(getDate(dates.first), format: 'HH:mm')}-${DateUtil.formatDate(getDate(dates.first).add(Duration(minutes: 30)), format: 'HH:mm')}';
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
return '${DateUtil.formatDate(getDate(dates.first), format: 'HH:mm')}-${DateUtil.formatDate(getDate(dates.first).add(Duration(minutes: 30)), format: 'HH:mm')}等';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|