2022-08-16 08:41:21 +08:00
|
|
|
|
import React, { useEffect, useState } from 'react';
|
2022-08-23 09:15:26 +08:00
|
|
|
|
import { Form, Input, Modal, Spin, Select, Button, Radio, RadioChangeEvent } from 'antd';
|
|
|
|
|
import ExtendUpload from "@/utils/ExtendUpload";
|
|
|
|
|
import { getFileListByBid } from '@/utils/DownloadUtils';
|
2022-08-16 08:41:21 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface SitePersonModalProps {
|
|
|
|
|
title: any;
|
|
|
|
|
modalVisible: boolean;
|
2022-08-23 09:15:26 +08:00
|
|
|
|
formDisabled: boolean;
|
2022-08-16 08:41:21 +08:00
|
|
|
|
values: any;
|
|
|
|
|
onSubmit: any;
|
|
|
|
|
type: string;
|
|
|
|
|
onCancel: () => void;
|
2022-08-23 09:15:26 +08:00
|
|
|
|
placeList: any[];
|
2022-08-16 08:41:21 +08:00
|
|
|
|
}
|
|
|
|
|
const layout = {
|
|
|
|
|
labelCol: { span: 7 },
|
|
|
|
|
wrapperCol: { span: 12 },
|
|
|
|
|
};
|
|
|
|
|
const SitePersonModal: React.FC<SitePersonModalProps> = (props) => {
|
|
|
|
|
const [form] = Form.useForm();
|
2022-08-23 09:15:26 +08:00
|
|
|
|
// const weboffice = useRef<Weboffice>(null);
|
|
|
|
|
const { title, modalVisible, formDisabled, type, values, onSubmit: handleUpdate, onCancel, placeList } = props;
|
2022-08-16 08:41:21 +08:00
|
|
|
|
//loading
|
|
|
|
|
const [loading, setLoading] = useState<boolean>(false);
|
2022-08-23 09:15:26 +08:00
|
|
|
|
const [value, setValue] = useState<string>("1");
|
2022-08-16 08:41:21 +08:00
|
|
|
|
|
|
|
|
|
const onChange = (e: RadioChangeEvent) => {
|
|
|
|
|
console.log('radio checked', e.target.value);
|
|
|
|
|
setValue(e.target.value);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (JSON.stringify(values) !== "{}") {
|
|
|
|
|
form.setFieldsValue({
|
|
|
|
|
"id": values.id,
|
2022-08-23 09:15:26 +08:00
|
|
|
|
"evalPlaceId": {label: values.eroomName,value: values.evalPlaceId},
|
|
|
|
|
"facePic": values.facePic,
|
|
|
|
|
"sex": values.sex,
|
|
|
|
|
"personName": values.personName,
|
|
|
|
|
"identityCard": values.identityCard
|
2022-08-16 08:41:21 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, [values])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const onOk = async () => {
|
|
|
|
|
const fieldsValue = await form.validateFields();
|
|
|
|
|
setLoading(true)
|
2022-08-23 09:15:26 +08:00
|
|
|
|
fieldsValue["evalPlaceId"] = fieldsValue.evalPlaceId.value
|
|
|
|
|
console.log(fieldsValue)
|
|
|
|
|
|
|
|
|
|
await getFileListByBid(fieldsValue.facePic).then(res => {
|
|
|
|
|
fieldsValue["facePicName"] = res[0].name
|
|
|
|
|
})
|
|
|
|
|
console.log(fieldsValue)
|
|
|
|
|
await handleUpdate({ ...fieldsValue }).finally(() => {
|
2022-08-16 08:41:21 +08:00
|
|
|
|
setLoading(false)
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const renderFooter = () => {
|
|
|
|
|
if (type == "read") {
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Button onClick={onCancel}>关闭</Button>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Button type="primary" loading={loading} onClick={onOk}>确认</Button>
|
|
|
|
|
<Button onClick={onCancel}>取消</Button>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Modal
|
|
|
|
|
destroyOnClose={true}
|
|
|
|
|
title={title}
|
|
|
|
|
visible={modalVisible}
|
|
|
|
|
onCancel={() => onCancel()}
|
|
|
|
|
width={"60%"}
|
|
|
|
|
centered
|
|
|
|
|
footer={renderFooter()}
|
|
|
|
|
>
|
|
|
|
|
<Spin spinning={loading}>
|
|
|
|
|
<Form
|
|
|
|
|
{...layout}
|
|
|
|
|
name="nest-messages"
|
|
|
|
|
form={form}
|
|
|
|
|
preserve={false}
|
|
|
|
|
>
|
|
|
|
|
<Form.Item name="id" label="id" hidden>
|
|
|
|
|
<Input hidden />
|
|
|
|
|
</Form.Item>
|
2022-08-23 09:15:26 +08:00
|
|
|
|
<Form.Item name="evalPlaceId" label="选择评标场所" >
|
|
|
|
|
<Select placeholder="请选择评标场所" labelInValue disabled={formDisabled}>
|
|
|
|
|
{
|
|
|
|
|
placeList.map((item: any, index: any) => {
|
|
|
|
|
return (
|
|
|
|
|
<Select.Option value={item.id}>{item.placeName}</Select.Option>
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
</Select>
|
2022-08-16 08:41:21 +08:00
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
|
<Form.Item
|
2022-08-23 09:15:26 +08:00
|
|
|
|
label="人员姓名"
|
|
|
|
|
name="personName"
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: '当前项不可为空',
|
|
|
|
|
},
|
|
|
|
|
]}
|
2022-08-16 08:41:21 +08:00
|
|
|
|
>
|
2022-08-23 09:15:26 +08:00
|
|
|
|
<Input />
|
2022-08-16 08:41:21 +08:00
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item
|
2022-08-23 09:15:26 +08:00
|
|
|
|
label="身份证号"
|
|
|
|
|
name="identityCard"
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: '当前项不可为空',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
pattern: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,
|
|
|
|
|
message: '输入的身份证号不正确',
|
|
|
|
|
},
|
|
|
|
|
]}
|
2022-08-16 08:41:21 +08:00
|
|
|
|
>
|
|
|
|
|
<Input />
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item
|
2022-08-23 09:15:26 +08:00
|
|
|
|
label="性别"
|
|
|
|
|
name="sex"
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: '当前项不可为空',
|
|
|
|
|
},
|
|
|
|
|
]}
|
2022-08-16 08:41:21 +08:00
|
|
|
|
>
|
2022-08-23 09:15:26 +08:00
|
|
|
|
{/* 1-男性,2-女性 */}
|
2022-08-16 08:41:21 +08:00
|
|
|
|
<Radio.Group onChange={onChange} value={value}>
|
2022-08-23 09:15:26 +08:00
|
|
|
|
<Radio value="1">男性</Radio>
|
|
|
|
|
<Radio value="2">女性 </Radio>
|
2022-08-16 08:41:21 +08:00
|
|
|
|
</Radio.Group>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item
|
2022-08-23 09:15:26 +08:00
|
|
|
|
label="人脸照片"
|
|
|
|
|
name="facePic"
|
|
|
|
|
extra="请上传清晰人脸正面照片,要求.jpg格式图片,文件大下不得超过60kb"
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: '当前项不可为空',
|
|
|
|
|
},
|
2022-08-16 08:41:21 +08:00
|
|
|
|
]}
|
|
|
|
|
>
|
2022-08-23 09:15:26 +08:00
|
|
|
|
<ExtendUpload bid={values.facePic} btnName="上传" maxCount={1} maxSize={0.057} uploadProps={{ accept: ".jpg" }}>
|
|
|
|
|
{/* maxSize={0.057} */}
|
|
|
|
|
</ExtendUpload>
|
2022-08-16 08:41:21 +08:00
|
|
|
|
</Form.Item>
|
|
|
|
|
</Form>
|
|
|
|
|
</Spin>
|
|
|
|
|
</Modal>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default SitePersonModal;
|