Commit 489fc3c6 authored by cellee's avatar cellee

预约时间大改

Signed-off-by: cellee's avatarcellee <893264950@qq.com>
parent 60587c01
import React from 'react';
import { TimePicker } from 'antd';
const { RangePicker } = TimePicker;
import moment from 'moment';
const OnTime = (porps: any) => {
// disabled 是否禁止
// limit 默认开放时间
// inhibitTime 禁止选择时间
// onChanges 时间选择事件
let { disabled, limit, inhibitTime, onChanges } = porps;
// 禁止时间 数组格式
const disabledHours = () => {
// 禁止的小时数组
let result = [];
// 设施默认的开放时间
let lim = limit ? limit.split('-') : [];
for (var i = 0; i < 24; i++) {
if (
i < parseInt(moment(lim[0], 'HH:ss').format('HH')) ||
i > parseInt(moment(lim[1], 'HH:ss').format('HH'))
) {
result.push(i);
}
}
// 选择日期禁止的时间
if (inhibitTime) {
for (let j in inhibitTime) {
result.push(parseInt(moment(inhibitTime[j], 'HH:ss').format('HH')));
}
}
// 去重排序
return [...new Set(result)].sort((x, y) => x - y);
};
return (
<>
<RangePicker
minuteStep={60}
format="HH:mm"
onChange={(time: any, timeString: any) => {
onChanges(time, timeString);
}}
allowClear={false}
disabled={disabled}
disabledHours={disabledHours}
/>
</>
);
};
export default OnTime;
...@@ -192,12 +192,7 @@ export default { ...@@ -192,12 +192,7 @@ export default {
} break; } break;
// 时间查询 // 时间查询
case 50:{ case 50:{
let resultTime = []; let resultTime = resp.data;
let data = resp.data;
for (var i = 0; i < data.length; i += 2){
let a = data[i] + '-' + data[i+1];
resultTime.push(a);
}
yield put({ type: 'onResult', resultTime }); yield put({ type: 'onResult', resultTime });
} break; } break;
......
...@@ -58,9 +58,9 @@ const BugDetail = (props: any) => { ...@@ -58,9 +58,9 @@ const BugDetail = (props: any) => {
</Descriptions.Item> </Descriptions.Item>
<Descriptions.Item label="Submission time" style={{ paddingBottom: 16 }}> <Descriptions.Item label="Submission time" style={{ paddingBottom: 16 }}>
{DataSave {DataSave
? moment(DataSave.updateTime.time).format('YYYY-MM-DD hh') + ? moment(DataSave.updateTime.time).format('YYYY-MM-DD hh:mm') +
':00' + // ':00' +
(parseInt(moment(DataSave.updateTime.time).format('HH')) > 11 ? 'PM' : 'AM') (parseInt(moment(DataSave.updateTime.time).format('HH')) > 11 ? ' PM' : ' AM')
: '-'} : '-'}
</Descriptions.Item> </Descriptions.Item>
</Descriptions> </Descriptions>
......
...@@ -31,9 +31,9 @@ const SystemFeedback = (props: any) => { ...@@ -31,9 +31,9 @@ const SystemFeedback = (props: any) => {
dataIndex: 'createTime', dataIndex: 'createTime',
render: (text: any) => { render: (text: any) => {
let data = let data =
moment(text.time).format('YYYY-MM-DD hh') + moment(text.time).format('YYYY-MM-DD hh:mm') +
':00' + // ':00' +
(parseInt(moment(text.time).format('HH')) > 11 ? 'PM' : 'AM'); (parseInt(moment(text.time).format('HH')) > 11 ? ' PM' : ' AM');
// let data = moment(text.time).calendar(); // let data = moment(text.time).calendar();
return data; return data;
......
...@@ -17,7 +17,7 @@ import { validateMessages } from '@/utils/params'; ...@@ -17,7 +17,7 @@ import { validateMessages } from '@/utils/params';
import moment from 'moment'; import moment from 'moment';
import { BookingsTip } from '@/utils/tip'; import { BookingsTip } from '@/utils/tip';
// 自定义时间段 // 自定义时间段
import OnTime from '@/components/OnTime/OnTime'; import OnTime from '@/components/OnTime/OnTimeTow';
const Bookings = (props: any) => { const Bookings = (props: any) => {
const { dispatch, Data3, Result, DataSave, token, load, resultTime, Remaining } = props; const { dispatch, Data3, Result, DataSave, token, load, resultTime, Remaining } = props;
...@@ -50,15 +50,23 @@ const Bookings = (props: any) => { ...@@ -50,15 +50,23 @@ const Bookings = (props: any) => {
const [prohibit, setProhibit] = useState(true); // 输入框是否不可选 const [prohibit, setProhibit] = useState(true); // 输入框是否不可选
const [result, setResultTime] = useState(null as any); // 已预约时间段 const [result, setResultTime] = useState(null as any); // 已预约时间段
const [soltTime, setSoltTime] = useState(['', '']); // 已选时间
const [bookTime, setBookTime] = useState(1); // 默认延后预订时间 const [bookTime, setBookTime] = useState(1); // 默认延后预订时间
const [Unit, setUnit] = useState({} as any); // 输入框的值 const [Unit, setUnit] = useState({} as any); // 输入框的值
const [UnitName, setUnitName] = useState([] as any); // 楼栋搜索的家庭成员
// 表单标识 // 表单标识
const [form] = Form.useForm(); const [form] = Form.useForm();
// 输入楼栋搜索 后台返回的值 Remaining
useEffect(() => {
if (Remaining) {
setUnitName(Remaining.owerList);
}
}, [Remaining]);
// 选择的小区名 // 选择的小区名
useEffect(() => { useEffect(() => {
if (DataSave != null) { if (DataSave != null) {
...@@ -96,7 +104,6 @@ const Bookings = (props: any) => { ...@@ -96,7 +104,6 @@ const Bookings = (props: any) => {
setCurString({ communityManagerFee: null }); setCurString({ communityManagerFee: null });
setProhibit(true); setProhibit(true);
setResultTime(null); setResultTime(null);
setSoltTime([]);
} }
}, [Data3]); }, [Data3]);
...@@ -123,8 +130,14 @@ const Bookings = (props: any) => { ...@@ -123,8 +130,14 @@ const Bookings = (props: any) => {
// 保存提交 // 保存提交
const onFinish = (value: any) => { const onFinish = (value: any) => {
var tmp = value; var tmp = value;
// 没有次数
if (Remaining.canReservationNum == 0) {
message.error('No bookable times');
return false;
}
// 判断时间选择 // 判断时间选择
if (soltTime.length < 2 || !soltTime[0]) { if (value.Time == null) {
message.error('Please Fill In The Appointment Period!'); message.error('Please Fill In The Appointment Period!');
return false; return false;
} }
...@@ -133,45 +146,38 @@ const Bookings = (props: any) => { ...@@ -133,45 +146,38 @@ const Bookings = (props: any) => {
message.error('Please Fill In The Contact Information Correctly!'); message.error('Please Fill In The Contact Information Correctly!');
return false; return false;
} }
// 小区信息
// 没有次数
if (Remaining.canReservationNum == 0) {
message.error('No bookable times');
return false;
}
if (value.categoriesName != null) { if (value.categoriesName != null) {
tmp.categoriesId = value.categoriesName.categoriesId; tmp.categoriesId = value.categoriesName.categoriesId;
tmp.facilitiesId = value.categoriesName.facilitiesId; tmp.facilitiesId = value.categoriesName.facilitiesId;
tmp.categoriesName = value.categoriesName.categoriesName; tmp.categoriesName = value.categoriesName.categoriesName;
} }
// 日期
if (value.subscribeDate != null) { if (value.subscribeDate != null) {
tmp.subscribeDate = value.subscribeDate.format('YYYY-MM-DD'); tmp.subscribeDate = value.subscribeDate.format('YYYY-MM-DD');
} }
if (value.reservedTimeList != null) { // 小区名
}
if (comminityValues != null) { if (comminityValues != null) {
tmp.communityName = comminityValues; tmp.communityName = comminityValues;
} }
// 设施费用
if (curString != null) { if (curString != null) {
tmp.communityManagerFee = numberToString(curString.communityManagerFee); tmp.communityManagerFee = numberToString(curString.communityManagerFee);
tmp.communityMargin = numberToString(curString.communityMargin); tmp.communityMargin = numberToString(curString.communityMargin);
} }
// 姓名长度
if (tmp.accountName && tmp.accountName.length < 2) { if (tmp.accountName && tmp.accountName.length < 2) {
message.error('User Name Should be limit 2~30!', 3); message.error('User Name Should be limit 2~30!', 3);
} else if (
soltTime &&
moment(soltTime[0], 'HH:mm').format('HH') > moment(soltTime[1], 'HH:mm').format('HH')
) {
// 判断选的时间 是不是结束时间小于开始时间
message.error('Appointment time range error');
} else { } else {
tmp.reservedTimeList = soltTime; // 预约时间 tmp.reservedTimeList = [
moment(value.Time[0]).format('HH:mm'),
moment(value.Time[1]).format('HH:mm'),
]; // 预约时间
// 选择的总时间段 // 选择的总时间段
let times = [] as any; let times = [] as any;
for (let i = 0; i <= parseInt(moment(soltTime[1], 'HH:mm').format('HH')); i++) { for (let i = 0; i <= parseInt(moment(value.Time[1], 'HH:mm').format('HH')); i++) {
if (i >= parseInt(moment(soltTime[0], 'HH:mm').format('HH'))) { if (i >= parseInt(moment(value.Time[0], 'HH:mm').format('HH'))) {
times.push(moment(i, 'HH').format('HH:mm')); times.push(moment(i, 'HH').format('HH:mm'));
} }
} }
...@@ -195,6 +201,7 @@ const Bookings = (props: any) => { ...@@ -195,6 +201,7 @@ const Bookings = (props: any) => {
message.error('Reservation period already exists!'); message.error('Reservation period already exists!');
return false; return false;
} else { } else {
console.log(tmp);
RA(11, tmp); RA(11, tmp);
} }
} }
...@@ -210,8 +217,7 @@ const Bookings = (props: any) => { ...@@ -210,8 +217,7 @@ const Bookings = (props: any) => {
floorNumber: '', floorNumber: '',
roomNumber: '', roomNumber: '',
subscribeDate: '', subscribeDate: '',
startTime: '', Time: null,
endTime: '',
}); });
// 再把提示时间删除 // 再把提示时间删除
setResultTime(null); setResultTime(null);
...@@ -245,19 +251,17 @@ const Bookings = (props: any) => { ...@@ -245,19 +251,17 @@ const Bookings = (props: any) => {
const getFacility = (values: any) => { const getFacility = (values: any) => {
SAClear(); SAClear();
setComminityValues(values); setComminityValues(values);
RA(1, { userToken: token, communityName: values });
setLoading(true);
// 如果切换了小区 再次把下方判断的内容清空 和 禁用 // 如果切换了小区 再次把下方判断的内容清空 和 禁用
setCurString({ setCurString({
communityManagerFee: null, communityManagerFee: null,
}); });
setProhibit(true);
setResultTime(null); setResultTime(null);
setSoltTime([]); RA(1, { userToken: token, communityName: values });
// formRef.current.resetFields({ accountName: null }); // 清空已填写的表单 setLoading(true);
setProhibit(true);
}; };
// 设置之前时间不能选择 // 设置之前日期不能选择
function disabledDate(current: any) { function disabledDate(current: any) {
return current && current <= moment().subtract(bookTime, 'days').endOf('day'); return current && current <= moment().subtract(bookTime, 'days').endOf('day');
} }
...@@ -273,19 +277,6 @@ const Bookings = (props: any) => { ...@@ -273,19 +277,6 @@ const Bookings = (props: any) => {
RA(50, data); RA(50, data);
}; };
// 下拉选择
const startTimes = (value: any) => {
let s = soltTime;
s[0] = value;
setSoltTime(s);
};
// 结束时间
const endTimes = (value: any) => {
let s = soltTime;
s[1] = value;
setSoltTime(s);
};
// 鼠标移走 // 鼠标移走
const onBlur = (e: any) => { const onBlur = (e: any) => {
switch (e.target.id) { switch (e.target.id) {
...@@ -300,6 +291,27 @@ const Bookings = (props: any) => { ...@@ -300,6 +291,27 @@ const Bookings = (props: any) => {
} }
}; };
// 姓名判断
const onBlurName = (e: any) => {
for (let i in UnitName) {
if (e.target.value == UnitName[i].owerName) {
formRef.current.setFieldsValue({
accountPhone: UnitName[i].owerPhone,
});
}
}
};
// 点击确定时间
const onChanges = (value: any, b: any) => {
// console.log(value);
// console.log(b);
// 修改后的时间
formRef.current.setFieldsValue({
Time: [moment(b[0], 'HH:mm'), moment(b[1], 'HH:mm')],
});
};
return ( return (
<div className={styles.base}> <div className={styles.base}>
{/* 头部组件v1.2 */} {/* 头部组件v1.2 */}
...@@ -318,7 +330,6 @@ const Bookings = (props: any) => { ...@@ -318,7 +330,6 @@ const Bookings = (props: any) => {
disabled={DataSave && DataSave.type == 2 ? true : false} disabled={DataSave && DataSave.type == 2 ? true : false}
/> />
</Spin> </Spin>
{/* <Input.Search style={{ width: 200, height: 32 }} onSearch={getFacility} loading={loading} defaultValue={}/> */}
</div> </div>
</div> </div>
{Data3 && Data3.length > 0 ? ( {Data3 && Data3.length > 0 ? (
...@@ -329,27 +340,11 @@ const Bookings = (props: any) => { ...@@ -329,27 +340,11 @@ const Bookings = (props: any) => {
name="basic" name="basic"
onFinish={onFinish} onFinish={onFinish}
validateMessages={validateMessages} validateMessages={validateMessages}
// autocomplete="off"
> >
<div className="box2 required"> <div className="box2 required">
<div className={styles.box2item1}>Facilities Available: </div> <div className={styles.box2item1}>Facilities Available: </div>
<div className={styles.box2item2}> <div className={styles.box2item2}>
<Form.Item name="categoriesName"> <Form.Item name="categoriesName">
{/* <Radio.Group defaultValue={1} onChange={RadioChoose}>
{Data3.map((item: any, index: any) => {
var tmp = new Array();
item.categorieList.map((thing: any, i: any) => {
tmp.push(
<Radio key={thing.categoriesId} value={thing}>
{thing.categoriesName}
</Radio>,
);
});
return tmp;
})}
</Radio.Group> */}
<Radio.Group onChange={RadioChoose}> <Radio.Group onChange={RadioChoose}>
{Data3.map((item: any, index: any) => { {Data3.map((item: any, index: any) => {
return ( return (
...@@ -427,6 +422,7 @@ const Bookings = (props: any) => { ...@@ -427,6 +422,7 @@ const Bookings = (props: any) => {
placeholder="Name Of Subscriber" placeholder="Name Of Subscriber"
disabled={prohibit} disabled={prohibit}
maxLength={30} maxLength={30}
onBlur={onBlurName}
/> />
</Form.Item> </Form.Item>
</div> </div>
...@@ -459,50 +455,19 @@ const Bookings = (props: any) => { ...@@ -459,50 +455,19 @@ const Bookings = (props: any) => {
</Form.Item> </Form.Item>
</Col> </Col>
<Col> <Col>
<Form.Item label="Opening Hours" className="required"> <Form.Item label="Reserve Time" name="Time" noStyle>
<Form.Item name="startTime" noStyle>
<OnTime <OnTime
placeholder={'Start Time'}
disabled={prohibit} disabled={prohibit}
limit={curString.categoriesOpenTime} limit={curString.categoriesOpenTime} // 设施默认禁止时间段
openSelect={startTimes} inhibitTime={result} // 选择日期后的禁止时间
type={0} onChanges={onChanges}
inhibitTime={result}
/> />
</Form.Item> </Form.Item>
<span className="diyspan"> </span>
<Form.Item name="endTime" noStyle>
<OnTime
placeholder={'Closing Time'} // 默认值
disabled={prohibit} // 是否禁止
limit={curString.categoriesOpenTime} // 禁止时间段
openSelect={endTimes} // 时间类型
type={0}
inhibitTime={result}
/>
</Form.Item>
</Form.Item>
</Col> </Col>
</Row> </Row>
</div> </div>
</div> </div>
{/* 提示已选时间段 */}
{/* {result != null && result.length > 0 ? (
<div className={styles.box3}>
<div className={styles.box3item1}>Reserved Time Period:</div>
<div className="boxdiyitem">
{result.map((item: any, index: any) => {
return (
<span className="diyspan3" key={index}>
{item}
</span>
);
})}
</div>
</div>
) : null} */}
{curString.communityManagerFee != null && Data3 ? ( {curString.communityManagerFee != null && Data3 ? (
<> <>
<div className={styles.box6}> <div className={styles.box6}>
...@@ -531,7 +496,7 @@ const Bookings = (props: any) => { ...@@ -531,7 +496,7 @@ const Bookings = (props: any) => {
<div className={styles.box6}> <div className={styles.box6}>
<div className={styles.box6item1}>Remaining times : </div> <div className={styles.box6item1}>Remaining times : </div>
<div className={styles.box6item2}> <div className={styles.box6item2}>
<BarChartOutlined style={{ color: '#999', marginRight: 10 }} /> <BarChartOutlined style={{ color: '#999' }} />
<span style={{ color: '#f00' }}>{Remaining.canReservationNum}</span> times <span style={{ color: '#f00' }}>{Remaining.canReservationNum}</span> times
</div> </div>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment