|
|
|
@ -25,7 +25,8 @@ class FacilityPreorderDatePicker extends StatefulWidget {
|
|
|
|
|
_FacilityPreorderDatePickerState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _FacilityPreorderDatePickerState extends State<FacilityPreorderDatePicker> {
|
|
|
|
|
class _FacilityPreorderDatePickerState
|
|
|
|
|
extends State<FacilityPreorderDatePicker> {
|
|
|
|
|
List<int> get _num => List.generate(
|
|
|
|
|
getNum(widget.typeModel.openEndDT!) -
|
|
|
|
|
getNum(widget.typeModel.openStartDT!),
|
|
|
|
@ -33,17 +34,7 @@ class _FacilityPreorderDatePickerState extends State<FacilityPreorderDatePicker>
|
|
|
|
|
DateTime? start;
|
|
|
|
|
List<int> models = [];
|
|
|
|
|
|
|
|
|
|
static Future<List<int>> getPreorderData(int id) async {
|
|
|
|
|
BaseModel model =
|
|
|
|
|
await NetUtil().get(SAASAPI.facilities.allAppointmentPeriod, params: {
|
|
|
|
|
'facilitiesManageId': id,
|
|
|
|
|
'todayDate': DateTime.now(),
|
|
|
|
|
});
|
|
|
|
|
if (model.success) {
|
|
|
|
|
return (model.data as List<int>).toList();
|
|
|
|
|
}
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
List<int> _selectIndex = [];
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
@ -62,7 +53,10 @@ class _FacilityPreorderDatePickerState extends State<FacilityPreorderDatePicker>
|
|
|
|
|
children: [
|
|
|
|
|
_datesList(index),
|
|
|
|
|
20.hb,
|
|
|
|
|
Divider(height: 1.0,color: Colors.black12,),
|
|
|
|
|
Divider(
|
|
|
|
|
height: 1.0,
|
|
|
|
|
color: Colors.black12,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
@ -87,15 +81,23 @@ class _FacilityPreorderDatePickerState extends State<FacilityPreorderDatePicker>
|
|
|
|
|
};
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
onTap: () {
|
|
|
|
|
|
|
|
|
|
print(getNum(start)+index);
|
|
|
|
|
if(!models.contains(getNum(start)+index)||start.add(Duration(minutes: 30 * index)).isAfter(DateTime.now())){
|
|
|
|
|
if (_selectIndex.contains(index)) {
|
|
|
|
|
_selectIndex.remove(index);
|
|
|
|
|
} else {
|
|
|
|
|
_selectIndex.add(index);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
child: Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
BeeCheckRadio(
|
|
|
|
|
value: getNum(start)+index,
|
|
|
|
|
groupValue: models,
|
|
|
|
|
backColor: start.isAfter(DateTime.now())?Colors.grey:Colors.white,
|
|
|
|
|
value: index,
|
|
|
|
|
groupValue: _selectIndex,
|
|
|
|
|
canCheck: models.contains(getNum(start)+index),
|
|
|
|
|
),
|
|
|
|
|
30.wb,
|
|
|
|
|
Text(
|
|
|
|
@ -106,20 +108,41 @@ class _FacilityPreorderDatePickerState extends State<FacilityPreorderDatePicker>
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Spacer(),
|
|
|
|
|
start.isAfter(DateTime.now())?'已过期'.text.size(30.sp).color(Colors.black.withOpacity(0.45)).make():
|
|
|
|
|
models.contains(getNum(start))?'已被他人预约'.text.size(30.sp).color(Colors.black.withOpacity(0.45)).make():SizedBox(),
|
|
|
|
|
isPass(start.add(Duration(minutes: 30 * index)))
|
|
|
|
|
? '已过期'
|
|
|
|
|
.text
|
|
|
|
|
.size(30.sp)
|
|
|
|
|
.color(Colors.black.withOpacity(0.45))
|
|
|
|
|
.make()
|
|
|
|
|
: models.contains(getNum(start)+index)
|
|
|
|
|
? '已被他人预约'
|
|
|
|
|
.text
|
|
|
|
|
.size(30.sp)
|
|
|
|
|
.color(Colors.black.withOpacity(0.45))
|
|
|
|
|
.make()
|
|
|
|
|
: SizedBox(),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isPass(DateTime date){
|
|
|
|
|
if(date.hour<DateTime.now().hour||(date.minute<DateTime.now().minute&&date.hour==DateTime.now().hour)){
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int getNum(DateTime dateTime) {
|
|
|
|
|
int hour, minute;
|
|
|
|
|
hour = dateTime.hour;
|
|
|
|
|
minute = dateTime.minute;
|
|
|
|
|
if (minute > 0) {
|
|
|
|
|
return hour * 2 + 1;
|
|
|
|
|
}
|
|
|
|
|
return hour * 2;
|
|
|
|
|
}
|
|
|
|
|
return hour * 2 + 1;
|
|
|
|
|
}
|
|
|
|
|