import { ZhSubmitButton, ZhUploadButton } from '@/components/Button' import DatePicker from '@/components/DatePicker' import { apiGetFileList } from '@/components/FileModal/api' import Header from '@/components/Header' import Slot from '@/components/Header/slot' import OssUploadModal from '@/components/OssUpload' import SvgIcon from '@/components/SvgIcon' import { userStore } from '@/store/mobx' import { iFile } from '@/types/file' import { apiDelFile } from '@/utils/common/api' import consts from '@/utils/consts' import { dayjsFormat } from '@/utils/util' import { Button, Input, Pagination, Tooltip } from 'antd' import locale from 'antd/es/date-picker/locale/zh_CN' import dayjs from 'dayjs' import React, { useEffect, useState } from 'react' import { RouteComponentProps } from 'react-router' import { apiGetSafeDetail, apiSaveFileInfo } from './api' import styles from './index.module.scss' const { TextArea } = Input interface iDetailState { auditName: string auditors: any[] bidsectionId: string code: string createTime: string | undefined demand: string file: iFileState id: string inspection: string inspectionDetail: string position: string status: number } interface iFileState { fileList: any[] total: number } const Detail:React.FC = (props) => { const [ visible, setVisible ] = useState(false) const [ detail, setDetail ] = useState({ auditName: "", auditors: [], bidsectionId: "", code: "", createTime: "", demand: "", file: { fileList: [], total: 0 }, id: "", inspection: "", inspectionDetail: "", position: "", status: 0 }) useEffect(() => { initData() }, []) const initData = async() => { const { saveId = "" } = props.location.state as any const { code = -1, data = {} } = await apiGetSafeDetail(saveId) if (code === consts.RET_CODE.SUCCESS) { setDetail({ ...detail, ...data }) } } const onCreate = async (fileList: iFile[]) => { const { code = -1 } = await apiSaveFileInfo(fileList, consts.DATA_TYPE.SAFE, detail.id) if (code === consts.RET_CODE.SUCCESS) { const newFiles = detail.file.fileList.concat(fileList.map(file => { return { ...file, accountName: userStore.userInfo.name } })) setDetail({ ...detail, file: { ...detail.file, fileList: newFiles } }) setVisible(false) } } const onShow = (show: boolean) => setVisible(show) const fileListChange = async (pageNo: number = 1, pageSize: number = 10) => { const { code = -1, data } = await apiGetFileList(consts.DATA_TYPE.SAFE,detail.id, pageNo, pageSize) if (code === consts.RET_CODE.SUCCESS) { setDetail({ ...detail, file: { ...detail.file, fileList: data } }) } } const delFile = async(id: string) => { const { code = -1 } = await apiDelFile(id) if (code === consts.RET_CODE.SUCCESS) { const newFiles = detail.file.fileList.map(file => file.id !== id) setDetail({ ...detail, file: { ...detail.file, fileList: newFiles } }) } } return (
提交审批

{detail.code}

安全巡检单
检查项目
现场检查情况
处理要求及措施
检查日期 setDetail({ ...detail, createTime: value?.format() })}>
质检员{detail.auditName}
{ detail.file.fileList?.map((file, idx) => { return ( ) }) }
附件 上传者 上传时间 操作
} onClick={() => setVisible(true)}>上传附件
{idx+1} {file.filename} {file.accountName}{dayjsFormat(file.createTime)}
{ detail.file.total ? fileListChange(page, pageSize)} > : '' }
setVisible(false)} onCreate={onCreate} onShow={onShow} >
) } export default Detail