8.30 预约评标室
This commit is contained in:
@ -1,16 +1,19 @@
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import { Col, DatePicker, Form, Input, message, Modal, Row } from 'antd';
|
||||
import { Col, DatePicker, Descriptions, Form, Input, message, Modal, Row } from 'antd';
|
||||
import ProTable, { ActionType, ProColumns } from '@ant-design/pro-table';
|
||||
import { getBidEvalRoom } from './service';
|
||||
import { getBidEvalRoom, saveAppointmentEdit } from './service';
|
||||
import { dateFormat, disabledDate, disabledDateTime, validateMessages } from './MeetingReservation';
|
||||
import moment from 'moment';
|
||||
import { dateTimeFormatter } from '@/utils/DateUtils';
|
||||
import { getProId } from '@/utils/session';
|
||||
|
||||
interface BidEvalAppointmentProps {
|
||||
modalVisible: boolean;
|
||||
onCancel: () => void;
|
||||
onSubmit: (value: any) => void;
|
||||
reload: () => void;
|
||||
values: any;
|
||||
type: string; //0-选择评标室 1-修改预约
|
||||
}
|
||||
|
||||
export const proviceEnum = {
|
||||
@ -51,9 +54,11 @@ export const proviceEnum = {
|
||||
const modalHeight = window.innerHeight * 96 / 100;
|
||||
|
||||
const BidEvalAppointment: React.FC<BidEvalAppointmentProps> = (props) => {
|
||||
const { modalVisible, onCancel, onSubmit, values } = props;
|
||||
const { modalVisible, onCancel, onSubmit, reload, values, type } = props;
|
||||
const actionRef = useRef<ActionType>();
|
||||
const [form] = Form.useForm();
|
||||
//项目id
|
||||
const proId = getProId();
|
||||
//当前选择行areaId
|
||||
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
|
||||
//当前选择行数据
|
||||
@ -106,51 +111,78 @@ const BidEvalAppointment: React.FC<BidEvalAppointmentProps> = (props) => {
|
||||
return;
|
||||
}
|
||||
form.validateFields().then(value => {
|
||||
if (value.reserveStartDate < moment().format(dateTimeFormatter)) {
|
||||
message.info("开始时间不可早于当前时间");
|
||||
if (moment(value.reserveStartDate).format(dateTimeFormatter) < moment().format(dateTimeFormatter)) {
|
||||
message.info("开始时间需晚于当前时间");
|
||||
return;
|
||||
}
|
||||
value["areaId"] = selectedRecord.id;
|
||||
value["placeId"] = selectedRecord.placeId;
|
||||
value["evalLocation"] = selectedRecord.areaName;
|
||||
onSubmit(value);
|
||||
if (moment(value.reserveEndDate).format(dateTimeFormatter) <= moment(value.reserveStartDate).format(dateTimeFormatter)) {
|
||||
message.info("结束时间需晚于开始时间");
|
||||
return;
|
||||
}
|
||||
if (type == "0") {//选择评标室
|
||||
value["areaId"] = selectedRecord.id;
|
||||
value["placeId"] = selectedRecord.placeId;
|
||||
value["areaAddress"] = selectedRecord.areaAddress;
|
||||
value["areaName"] = selectedRecord.areaName;
|
||||
value["contactName"] = selectedRecord.contactName;
|
||||
value["contactTel"] = selectedRecord.contactTel;
|
||||
value["areaNumber"] = selectedRecord.areaNumber;
|
||||
onSubmit(value);
|
||||
} else {//修改预约
|
||||
const params = {
|
||||
...values,
|
||||
areaId: selectedRecord.id,
|
||||
placeId: selectedRecord.placeId,
|
||||
reserveStartDate: moment(value.reserveStartDate).format(dateTimeFormatter),
|
||||
reserveEndDate: moment(value.reserveEndDate).format(dateTimeFormatter),
|
||||
reserveBy: value.reserveBy,
|
||||
reserveContactNumber: value.reserveContactNumber,
|
||||
}
|
||||
saveAppointmentEdit(params).then(res => {
|
||||
if (res?.code == 200) {
|
||||
message.success("预约成功");
|
||||
onCancel();
|
||||
reload();
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (values) {
|
||||
if (values?.areaId) {
|
||||
setSelectedRowKeys([values.areaId])
|
||||
setSelectedRecord({
|
||||
...values,
|
||||
id: values.areaId,
|
||||
})
|
||||
}
|
||||
form.setFieldsValue({
|
||||
...values,
|
||||
})
|
||||
}
|
||||
return () => {
|
||||
setSelectedRowKeys([]);
|
||||
setSelectedRecord(void 0);
|
||||
}
|
||||
setSelectedRowKeys([]);
|
||||
setSelectedRecord(void 0);
|
||||
}, [values])
|
||||
|
||||
return (
|
||||
<Modal
|
||||
destroyOnClose
|
||||
title="选择评标室"
|
||||
title={type == "0" ? "选择评标室" : "修改预约"}
|
||||
visible={modalVisible}
|
||||
maskClosable={false}
|
||||
onCancel={() => onCancel()}
|
||||
onOk={() => onOk()}
|
||||
okText="确认"
|
||||
okText={type == "0" ? "确认" : "保存"}
|
||||
width={"70%"}
|
||||
style={{ maxHeight: modalHeight }}
|
||||
bodyStyle={{ maxHeight: modalHeight - 107, overflowY: 'auto', }}
|
||||
className="confirm table-no-alert"
|
||||
centered
|
||||
>
|
||||
{values?.areaId && (
|
||||
<>
|
||||
<h3 className='first-title'>{type == "0" ? "已选择评标室" : "已预约评标室"}</h3>
|
||||
<Descriptions size="middle">
|
||||
<Descriptions.Item label="评标室名称">{values?.areaName}</Descriptions.Item>
|
||||
<Descriptions.Item label="联系人">{values?.contactName}</Descriptions.Item>
|
||||
<Descriptions.Item label="联系电话">{values?.contactTel}</Descriptions.Item>
|
||||
<Descriptions.Item label="可容纳人数">{values?.areaNumber ? values?.areaNumber : values?.numberInMeeting}</Descriptions.Item>
|
||||
<Descriptions.Item label="预计评标开始时间">{moment(values?.reserveStartDate).format(dateTimeFormatter)}</Descriptions.Item>
|
||||
<Descriptions.Item label="预计评标结束时间">{moment(values?.reserveEndDate).format(dateTimeFormatter)}</Descriptions.Item>
|
||||
</Descriptions>
|
||||
<h3 className='first-title'>选择评标室</h3>
|
||||
</>
|
||||
)}
|
||||
<ProTable<any>
|
||||
columns={columns}
|
||||
actionRef={actionRef}
|
||||
@ -201,6 +233,22 @@ const BidEvalAppointment: React.FC<BidEvalAppointmentProps> = (props) => {
|
||||
preserve={false}
|
||||
validateMessages={validateMessages}
|
||||
>
|
||||
<Form.Item
|
||||
label="是否预约评标室"
|
||||
name="reserveStatus"
|
||||
initialValue={"1"}
|
||||
hidden
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="项目id"
|
||||
name="projectId"
|
||||
initialValue={proId}
|
||||
hidden
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
{selectedRowKeys.length > 0 && (
|
||||
<Row>
|
||||
<Col span={12}>
|
||||
@ -208,6 +256,7 @@ const BidEvalAppointment: React.FC<BidEvalAppointmentProps> = (props) => {
|
||||
label="预计评标开始时间"
|
||||
name="reserveStartDate"
|
||||
rules={[{ required: true, message: '请选择' }]}
|
||||
extra={<span style={{ color: "#b30000" }}>预约时间范围 7:00 ~ 18:00</span>}
|
||||
>
|
||||
<DatePicker showTime={{ defaultValue: moment().hour(7) }} showNow={false} disabledDate={disabledDate} disabledTime={disabledDateTime} showMinute={false} showSecond={false} format={dateFormat} style={{ width: '100%' }} />
|
||||
</Form.Item>
|
||||
|
Reference in New Issue
Block a user