|
@@ -28,13 +28,15 @@ interface iModalObj {
|
|
|
auditModal: boolean
|
|
|
auditType: string
|
|
|
curPage: number
|
|
|
+ loading: boolean
|
|
|
}
|
|
|
const Detail: React.FC<RouteComponentProps> = props => {
|
|
|
const { saveId = '' } = props.location.state as any
|
|
|
- const [ visible, setVisible ] = useState<iModalObj>({
|
|
|
+ const [ modalObj, setModalObj ] = useState<iModalObj>({
|
|
|
ossModal: false,
|
|
|
auditModal: false,
|
|
|
auditType: '',
|
|
|
+ loading: false,
|
|
|
curPage: 1
|
|
|
})
|
|
|
const [ detail, setDetail ] = useState<iDetailState>({
|
|
@@ -97,14 +99,14 @@ const Detail: React.FC<RouteComponentProps> = props => {
|
|
|
})
|
|
|
)
|
|
|
setDetail({ ...detail, file: { ...detail.file, total: newFiles.length } })
|
|
|
- await fileListChange(visible.curPage)
|
|
|
+ await fileListChange(modalObj.curPage)
|
|
|
}
|
|
|
}
|
|
|
- const onOssModalShow = (show: boolean) => setVisible({ ...visible, ossModal: show })
|
|
|
+ const onOssModalShow = (show: boolean) => setModalObj({ ...modalObj, ossModal: show })
|
|
|
const fileListChange = async (pageNo: number = 1, pageSize: number = 10) => {
|
|
|
const { code = -1, data, total } = await apiGetFileList(consts.DATA_TYPE.QUALITY, detail.id, pageNo, pageSize)
|
|
|
if (code === consts.RET_CODE.SUCCESS) {
|
|
|
- setVisible({ ...visible, curPage: pageNo, ossModal: false })
|
|
|
+ setModalObj({ ...modalObj, curPage: pageNo, ossModal: false })
|
|
|
setDetail({ ...detail, file: { ...detail.file, fileList: data, total } })
|
|
|
}
|
|
|
}
|
|
@@ -112,9 +114,8 @@ const Detail: React.FC<RouteComponentProps> = props => {
|
|
|
const delFile = async (id: string, isLast: boolean) => {
|
|
|
const { code = -1 } = await apiDelFile(id)
|
|
|
if (code === consts.RET_CODE.SUCCESS) {
|
|
|
- console.log(visible.curPage - 1)
|
|
|
- await fileListChange(isLast ? visible.curPage - 1 : visible.curPage)
|
|
|
- isLast && (setVisible({ ...visible, curPage: visible.curPage - 1 }))
|
|
|
+ await fileListChange(isLast ? modalObj.curPage - 1 : modalObj.curPage)
|
|
|
+ isLast && setModalObj({ ...modalObj, curPage: modalObj.curPage - 1 })
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -168,11 +169,16 @@ const Detail: React.FC<RouteComponentProps> = props => {
|
|
|
}
|
|
|
|
|
|
const btnClick = (type: string) => {
|
|
|
- setVisible({ ...visible, auditType: type, auditModal: true })
|
|
|
+ setModalObj({ ...modalObj, auditType: type, auditModal: true })
|
|
|
}
|
|
|
const onModalConfirm = (values?: object) => {
|
|
|
+ setModalObj({ ...modalObj, loading: true })
|
|
|
let payload: any = { quality_id: detail.id, bidsection_id: detail.bidsectionId, ...values }
|
|
|
- if (visible.auditType === 'start') {
|
|
|
+ if (modalObj.auditType === 'start') {
|
|
|
+ payload.inspection = detail.inspection
|
|
|
+ payload.inspectionDetail = detail.inspectionDetail
|
|
|
+ payload.demand = detail.demand
|
|
|
+ payload.createTime = detail.createTime
|
|
|
payload.auditors = detail.auditors.filter(item => item.progress === '0').map(item => item.audit_id)
|
|
|
payload.reAuditors = detail.auditors.filter(item => item.progress === '2').map(item => item.audit_id)
|
|
|
payload.times = detail.times
|
|
@@ -181,11 +187,11 @@ const Detail: React.FC<RouteComponentProps> = props => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (visible.auditType === 'delete') {
|
|
|
+ if (modalObj.auditType === 'delete') {
|
|
|
payload = { id: detail.id }
|
|
|
}
|
|
|
|
|
|
- if (visible.auditType === 'pass' || visible.auditType === 'back') {
|
|
|
+ if (modalObj.auditType === 'pass' || modalObj.auditType === 'back') {
|
|
|
payload.id = detail.latestAuditor.id
|
|
|
if (detail.latestAuditor.progress === '1') {
|
|
|
if (!detail.checkOrder.opinion) {
|
|
@@ -196,20 +202,22 @@ const Detail: React.FC<RouteComponentProps> = props => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (visible.auditType === 'close') {
|
|
|
+ if (modalObj.auditType === 'close') {
|
|
|
payload.id = detail.latestAuditor.id
|
|
|
}
|
|
|
- apiResful(visible.auditType, payload)
|
|
|
+ apiResful(modalObj.auditType, payload)
|
|
|
}
|
|
|
const apiResful = async (type: string, payload: any) => {
|
|
|
const { code } = await apiResfulQualityAudit(type, payload)
|
|
|
if (code === consts.RET_CODE.SUCCESS) {
|
|
|
- setVisible({ ...visible, auditModal: false })
|
|
|
+ setModalObj({ ...modalObj, auditModal: false, loading: false })
|
|
|
if (type === 'delete') {
|
|
|
props.history.goBack()
|
|
|
} else {
|
|
|
initData()
|
|
|
}
|
|
|
+ } else {
|
|
|
+ setModalObj({ ...modalObj, loading: false })
|
|
|
}
|
|
|
}
|
|
|
const renderHeaderBtn = (status: number) => {
|
|
@@ -254,6 +262,9 @@ const Detail: React.FC<RouteComponentProps> = props => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ const modalProps = useMemo(() => {
|
|
|
+ return { visible: modalObj.auditModal, loading: modalObj.loading, type: modalObj.auditType }
|
|
|
+ }, [ modalObj.auditType ])
|
|
|
return (
|
|
|
<div className="wrap-contaniner">
|
|
|
<Header title="质量巡检">
|
|
@@ -273,15 +284,45 @@ const Detail: React.FC<RouteComponentProps> = props => {
|
|
|
<tbody>
|
|
|
<tr>
|
|
|
<th style={{ width: '150px' }}>检查项目</th>
|
|
|
- <td>{isEdited ? <span>{detail.inspection}</span> : <TextArea value={detail.inspection}></TextArea>}</td>
|
|
|
+ <td>
|
|
|
+ {isEdited ? (
|
|
|
+ <span>{detail.inspection}</span>
|
|
|
+ ) : (
|
|
|
+ <TextArea
|
|
|
+ value={detail.inspection}
|
|
|
+ onChange={e => {
|
|
|
+ setDetail({ ...detail, inspection: e.currentTarget.value })
|
|
|
+ }}></TextArea>
|
|
|
+ )}
|
|
|
+ </td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
<th style={{ width: '150px' }}>现场检查情况</th>
|
|
|
- <td>{isEdited ? <span>{detail.inspectionDetail}</span> : <TextArea value={detail.inspectionDetail}></TextArea>}</td>
|
|
|
+ <td>
|
|
|
+ {isEdited ? (
|
|
|
+ <span>{detail.inspectionDetail}</span>
|
|
|
+ ) : (
|
|
|
+ <TextArea
|
|
|
+ value={detail.inspectionDetail}
|
|
|
+ onChange={e => {
|
|
|
+ setDetail({ ...detail, inspectionDetail: e.currentTarget.value })
|
|
|
+ }}></TextArea>
|
|
|
+ )}
|
|
|
+ </td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
<th style={{ width: '150px' }}>处理要求及措施</th>
|
|
|
- <td>{isEdited ? <span>{detail.demand}</span> : <TextArea value={detail.demand}></TextArea>}</td>
|
|
|
+ <td>
|
|
|
+ {isEdited ? (
|
|
|
+ <span>{detail.demand}</span>
|
|
|
+ ) : (
|
|
|
+ <TextArea
|
|
|
+ value={detail.demand}
|
|
|
+ onChange={e => {
|
|
|
+ setDetail({ ...detail, demand: e.currentTarget.value })
|
|
|
+ }}></TextArea>
|
|
|
+ )}
|
|
|
+ </td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
<th style={{ width: '150px' }}>检查日期</th>
|
|
@@ -304,7 +345,7 @@ const Detail: React.FC<RouteComponentProps> = props => {
|
|
|
</tr>
|
|
|
</tbody>
|
|
|
</table>
|
|
|
- {detail.status === auditProgress.checked && detail.latestAuditor.progress === '1' ? (
|
|
|
+ {detail.status === auditProgress.checked && detail.latestAuditor.audit_id === userStore.userInfo.id ? (
|
|
|
<table className="pi-table pi-bordered">
|
|
|
<thead>
|
|
|
<tr>
|
|
@@ -381,7 +422,7 @@ const Detail: React.FC<RouteComponentProps> = props => {
|
|
|
<tbody>
|
|
|
<tr>
|
|
|
<td colSpan={5}>
|
|
|
- <ZhUploadButton size="small" icon={<SvgIcon type="xxh-cloud-upload" />} onClick={() => setVisible({ ...visible, ossModal: true })}>
|
|
|
+ <ZhUploadButton size="small" icon={<SvgIcon type="xxh-cloud-upload" />} onClick={() => setModalObj({ ...modalObj, ossModal: true })}>
|
|
|
上传附件
|
|
|
</ZhUploadButton>
|
|
|
</td>
|
|
@@ -389,26 +430,26 @@ const Detail: React.FC<RouteComponentProps> = props => {
|
|
|
|
|
|
{detail.file.fileList?.map((file, idx) => (
|
|
|
<tr key={idx}>
|
|
|
- <td className="pi-width-70">{idx + 1}</td>
|
|
|
- <td style={{ width: 383, maxWidth: 383, overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' }}>
|
|
|
- <a href={consts.OSS_PATH.REVIEW + file.filepath} target="_blank" rel="noopener noreferrer">
|
|
|
- {file.filename}
|
|
|
- </a>
|
|
|
- </td>
|
|
|
- <td className="pi-text-center">{file.accountName}</td>
|
|
|
- <td className="pi-text-center">{dayjsFormat(file.createTime)}</td>
|
|
|
- <td className="pi-text-center pi-width-90">
|
|
|
- <Tooltip title="移除">
|
|
|
- <Button size="small" type="text" icon={<SvgIcon type="xxh-times-circle1" />} style={{ color: '#df3f45' }} onClick={() => delFile(file.id, !idx)}></Button>
|
|
|
- </Tooltip>
|
|
|
- </td>
|
|
|
- </tr>
|
|
|
+ <td className="pi-width-70">{idx + 1}</td>
|
|
|
+ <td style={{ width: 383, maxWidth: 383, overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' }}>
|
|
|
+ <a href={consts.OSS_PATH.REVIEW + file.filepath} target="_blank" rel="noopener noreferrer">
|
|
|
+ {file.filename}
|
|
|
+ </a>
|
|
|
+ </td>
|
|
|
+ <td className="pi-text-center">{file.accountName}</td>
|
|
|
+ <td className="pi-text-center">{dayjsFormat(file.createTime)}</td>
|
|
|
+ <td className="pi-text-center pi-width-90">
|
|
|
+ <Tooltip title="移除">
|
|
|
+ <Button size="small" type="text" icon={<SvgIcon type="xxh-times-circle1" />} style={{ color: '#df3f45' }} onClick={() => delFile(file.id, !idx)}></Button>
|
|
|
+ </Tooltip>
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
))}
|
|
|
{detail.file.total > consts.PAGE_SIZE ? (
|
|
|
<tr>
|
|
|
<td colSpan={5} className="pi-text-right">
|
|
|
<Pagination
|
|
|
- current={visible.curPage}
|
|
|
+ current={modalObj.curPage}
|
|
|
size="small"
|
|
|
pageSize={consts.PAGE_SIZE}
|
|
|
hideOnSinglePage={true}
|
|
@@ -429,11 +470,10 @@ const Detail: React.FC<RouteComponentProps> = props => {
|
|
|
uName={detail.auditName}></AuditContent>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <OssUploadModal visible={visible.ossModal} onCancel={() => setVisible({ ...visible, ossModal: false })} onCreate={onCreate} onShow={onOssModalShow}></OssUploadModal>
|
|
|
+ <OssUploadModal visible={modalObj.ossModal} onCancel={() => setModalObj({ ...modalObj, ossModal: false })} onCreate={onCreate} onShow={onOssModalShow}></OssUploadModal>
|
|
|
<AuditModal
|
|
|
- type={visible.auditType}
|
|
|
- visible={visible.auditModal}
|
|
|
- onCancel={() => setVisible({ ...visible, auditModal: false })}
|
|
|
+ modalObj = {modalProps}
|
|
|
+ onCancel={() => setModalObj({ ...modalObj, auditModal: false })}
|
|
|
onCreate={onModalConfirm}
|
|
|
auditors={detail.auditors}
|
|
|
curAuditor={detail.latestAuditor}></AuditModal>
|