zcloud_gbs_qualifications-r.../src/components/ViewProjectReviewUserModal/index.js

264 lines
9.8 KiB
JavaScript

import { Connect } from "@cqsjjb/jjb-dva-runtime";
import { Button, Descriptions, Divider, Form, Modal } from "antd";
import { useEffect, useState } from "react";
import PreviewImg from "zy-react-library/components/PreviewImg";
import Search from "zy-react-library/components/Search";
import DictionarySelect from "zy-react-library/components/Select/Dictionary";
import Table from "zy-react-library/components/Table";
import TooltipPreviewImg from "zy-react-library/components/TooltipPreviewImg";
import { UPLOAD_FILE_TYPE_ENUM } from "zy-react-library/enum/uploadFile/gwj";
import useGetFile from "zy-react-library/hooks/useGetFile";
import useTable from "zy-react-library/hooks/useTable";
import { getLabelName } from "zy-react-library/utils";
import { NS_QUALIFICATION_STATISTICS } from "~/enumerate/namespace";
const EMPLOYMENT_STATUS_ENUM = [
// { bianma: "离职", name: 0 },
{ name: "离职", bianma: 0 },
{ name: "在职", bianma: 1 },
{ name: "信息变更中", bianma: 2 },
{ name: "未入职", bianma: 3 },
{ name: "实习生", bianma: 4 },
{ name: "实习结束", bianma: 5 },
{ name: "退休", bianma: 6 },
{ name: "劳务派遣", bianma: 7 },
{ name: "劳务派遣结束", bianma: 8 },
{ name: "入职待审核", bianma: 11 },
{ name: "离职待审核", bianma: 10 },
];
const ViewProjectReviewUserModal = (props) => {
const [form] = Form.useForm();
const [realData, setRealData] = useState([]);
const [viewInfoModalVisible, setViewInfoModalVisible] = useState(false);
const [currentId, setCurrentId] = useState("");
const { loading: getFileLoading, getFile } = useGetFile();
const { tableProps, getData } = useTable(props["userQualificationList"], {
form,
params: {
eqUserId: props.data.userRealId ? props.data.userRealId : props.data.id,
},
useStorageQueryCriteria: false,
onSuccess: async (data) => {
for (let i = 0; i < data.list.length; i++) {
const item = data.list[i];
let getFileType = "";
if (item.type === "aqscglry")
getFileType = UPLOAD_FILE_TYPE_ENUM["162"];
else if (item.type === "tezhongzuoye")
getFileType = UPLOAD_FILE_TYPE_ENUM["159"];
else if (item.type === "tzsbczry")
getFileType = UPLOAD_FILE_TYPE_ENUM["160"];
else if (item.type === "zyfzr")
getFileType = UPLOAD_FILE_TYPE_ENUM["161"];
const fileItems = await getFile({ eqType: getFileType, eqForeignKey: item.userCertificateId });
item.files = fileItems;
}
setRealData(data.list);
},
});
return (
<div>
<Modal
title="特种证书"
width={1200}
open
maskClosable={false}
onCancel={props.onCancel}
footer={[
<Button key="cancel" onClick={props.onCancel}>取消</Button>,
]}
>
<Search
labelCol={{ span: 8 }}
options={[
// { name: "likeUserName", label: "姓名" },
{ name: "eqType", label: "证书类型", render: (<DictionarySelect dictValue="zslx" />) },
]}
form={form}
onFinish={getData}
/>
<Table
options={false}
disabledResizer={true}
columns={[
{ title: "姓名", dataIndex: "name" },
{ title: "证书类型", dataIndex: "typeName" },
{ title: "证书名称", dataIndex: "certificateName" },
{ title: "证书编号", dataIndex: "certificateCode" },
{
title: "有效期",
dataIndex: "certificateDateStart",
render: (_, record) => `${record.certificateDateStart}${record.certificateDateEnd}`,
},
{ title: "图片", dataIndex: "files", width: 100, render: (_, record) => (<TooltipPreviewImg files={record.files} />) },
{
title: "操作",
width: 100,
fixed: "right",
render: (_, record) => (
<Button
type="link"
onClick={() => {
setViewInfoModalVisible(true);
setCurrentId(record.id);
}}
>
查看
</Button>
),
},
]}
{...tableProps}
dataSource={realData}
loading={getFileLoading || tableProps.loading}
/>
</Modal>
{viewInfoModalVisible && (
<ViewInfoModal
id={currentId}
onCancel={() => {
setViewInfoModalVisible(false);
setCurrentId("");
}}
/>
)}
</div>
);
};
const ViewInfoModalComponent = (props) => {
const [info, setInfo] = useState({});
const { getFile } = useGetFile();
const getData = async () => {
const { data } = await props["userQualificationInfo"]({ id: props.id });
let getFileType = "";
if (data.type === "aqscglry")
getFileType = UPLOAD_FILE_TYPE_ENUM["162"];
else if (data.type === "tezhongzuoye")
getFileType = UPLOAD_FILE_TYPE_ENUM["159"];
else if (data.type === "tzsbczry")
getFileType = UPLOAD_FILE_TYPE_ENUM["160"];
else if (data.type === "zyfzr")
getFileType = UPLOAD_FILE_TYPE_ENUM["161"];
const fileItems = await getFile({ eqType: getFileType, eqForeignKey: data.userCertificateId });
setInfo({ ...data, files: fileItems });
};
useEffect(() => {
getData();
}, []);
return (
<Modal
title="特种证书"
width={1200}
open
maskClosable={false}
onCancel={props.onCancel}
footer={[
<Button key="cancel" onClick={props.onCancel}>取消</Button>,
]}
>
<Divider orientation="left">人员信息</Divider>
<Descriptions
column={1}
bordered
styles={{ label: { width: 200 } }}
items={[
{ label: "姓名", children: info.name },
{ label: "企业名称", children: info.corpinfoName },
{ label: "部门名称", children: info.departmentName },
{ label: "岗位名称", children: info.userPostName },
{ label: "就职状态", children: getLabelName({ list: EMPLOYMENT_STATUS_ENUM, status: info.employmentStatus }) },
]}
/>
<Divider orientation="left">证书信息</Divider>
{
info.type === "tezhongzuoye" && (
<Descriptions
column={1}
bordered
styles={{ label: { width: 200 } }}
items={[
{ label: "证书名称", children: info.certificateName },
{ label: "证书编号", children: info.certificateCode },
{ label: "发证机构", children: info.issuingAuthority },
{ label: "行业类别", children: info.industryCategoryName },
{ label: "操作项目", children: info.industryOperatingItemsName },
{ label: "发证日期", children: info.dateIssue },
{ label: "有效期至", children: `${info.certificateDateStart} - ${info.certificateDateEnd}` },
{ label: "复审日期", children: info.reviewDate },
{ label: "证书照片", children: (<PreviewImg files={info.files} />) },
]}
/>
)
}
{
info.type === "tzsbczry" && (
<Descriptions
column={1}
bordered
styles={{ label: { width: 200 } }}
items={[
{ label: "证书名称", children: info.certificateName },
{ label: "证书编号", children: info.certificateCode },
{ label: "操作项目", children: info.assignmentCategoryName },
{ label: "作业类别", children: info.assignmentOperatingItemsName },
{ label: "发证机构", children: info.issuingAuthority },
{ label: "发证日期", children: info.dateIssue },
{ label: "复审日期", children: info.reviewDate },
{ label: "有效期至", children: `${info.certificateDateStart} - ${info.certificateDateEnd}` },
{ label: "证书照片", children: (<PreviewImg files={info.files} />) },
]}
/>
)
}
{
info.type === "zyfzr" && (
<Descriptions
column={1}
bordered
styles={{ label: { width: 200 } }}
items={[
{ label: "证书名称", children: info.certificateName },
{ label: "证书编号", children: info.certificateCode },
{ label: "岗位名称", children: info.postName },
{ label: "发证机构", children: info.issuingAuthority },
{ label: "发证日期", children: info.dateIssue },
{ label: "有效期至", children: `${info.certificateDateStart} - ${info.certificateDateEnd}` },
{ label: "证书照片", children: (<PreviewImg files={info.files} />) },
]}
/>
)
}
{
info.type === "aqscglry" && (
<Descriptions
column={1}
bordered
styles={{ label: { width: 200 } }}
items={[
{ label: "证书名称", children: info.certificateName },
{ label: "证书编号", children: info.certificateCode },
{ label: "岗位名称", children: info.postName },
{ label: "发证机构", children: info.issuingAuthority },
{ label: "发证日期", children: info.dateIssue },
{ label: "有效期至", children: `${info.certificateDateStart} - ${info.certificateDateEnd}` },
{ label: "证书照片", children: (<PreviewImg files={info.files} />) },
]}
/>
)
}
</Modal>
);
};
const ViewInfoModal = Connect([NS_QUALIFICATION_STATISTICS], true)(ViewInfoModalComponent);
export default Connect([NS_QUALIFICATION_STATISTICS], true)(ViewProjectReviewUserModal);