|
@@ -17,10 +17,10 @@ import { dayjsFormat } from '@/utils/util'
|
|
|
import { Button, Input, message, Pagination, Tooltip } from 'antd'
|
|
|
import locale from 'antd/es/date-picker/locale/zh_CN'
|
|
|
import dayjs from 'dayjs'
|
|
|
-import React, { useEffect, useState, useMemo } from 'react'
|
|
|
+import React, { useEffect, useState, useMemo, useCallback } from 'react'
|
|
|
import { RouteComponentProps } from 'react-router'
|
|
|
import { apiGetSafeDetail, apiResfulSafeAudit } from './api'
|
|
|
-import AuditModal from './components/Modal'
|
|
|
+import AuditModal from '@/pages/Quality/Content/Info/Detail/components/Modal'
|
|
|
import styles from './index.module.scss'
|
|
|
const { TextArea } = Input
|
|
|
interface iModalObj {
|
|
@@ -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>({
|
|
@@ -96,14 +98,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.SAFE, 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 } })
|
|
|
}
|
|
|
}
|
|
@@ -111,9 +113,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 }))
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -121,15 +122,37 @@ const Detail: React.FC<RouteComponentProps> = props => {
|
|
|
if (detail.auditors.find(item => item.progress === (type === 'check' ? '0' : '2') && item.audit_id === user.id)) {
|
|
|
return message.error('该审批组下已存在该审批人,请勿重复添加!')
|
|
|
}
|
|
|
- if (type === "check") {
|
|
|
+ if (type === 'check') {
|
|
|
const newAuditors = detail.auditors
|
|
|
- const len = detail.auditors.filter((item: iAuditor) => item.progress === "0").length
|
|
|
- newAuditors.push({ id: '', mobile:'', audit_id: user.id, audit_order: len + 1,position: user.position, progress: "0", name: user.name,accountGroup: user.accountGroup, company: user.company, status: 0 })
|
|
|
+ const len = detail.auditors.filter((item: iAuditor) => item.progress === '0').length
|
|
|
+ newAuditors.push({
|
|
|
+ id: '',
|
|
|
+ mobile: '',
|
|
|
+ audit_id: user.id,
|
|
|
+ audit_order: len + 1,
|
|
|
+ position: user.position,
|
|
|
+ progress: '0',
|
|
|
+ name: user.name,
|
|
|
+ accountGroup: user.accountGroup,
|
|
|
+ company: user.company,
|
|
|
+ status: 0
|
|
|
+ })
|
|
|
setDetail({ ...detail, auditors: newAuditors })
|
|
|
} else {
|
|
|
const newAuditors = detail.auditors
|
|
|
- const len = detail.auditors.filter((item: iAuditor) => item.progress === "2").length
|
|
|
- newAuditors.push({ id: '', audit_id: user.id, mobile:'', audit_order: len + 1,position: user.position, progress: "2", name: user.name, accountGroup: user.accountGroup, company: user.company, status: 0 })
|
|
|
+ const len = detail.auditors.filter((item: iAuditor) => item.progress === '2').length
|
|
|
+ newAuditors.push({
|
|
|
+ id: '',
|
|
|
+ audit_id: user.id,
|
|
|
+ mobile: '',
|
|
|
+ audit_order: len + 1,
|
|
|
+ position: user.position,
|
|
|
+ progress: '2',
|
|
|
+ name: user.name,
|
|
|
+ accountGroup: user.accountGroup,
|
|
|
+ company: user.company,
|
|
|
+ status: 0
|
|
|
+ })
|
|
|
setDetail({ ...detail, auditors: newAuditors })
|
|
|
}
|
|
|
}
|
|
@@ -145,11 +168,11 @@ 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) => {
|
|
|
let payload: any = { safe_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
|
|
@@ -162,11 +185,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) {
|
|
@@ -177,20 +200,23 @@ 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) => {
|
|
|
+ setModalObj({ ...modalObj, loading: true })
|
|
|
const { code } = await apiResfulSafeAudit(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) => {
|
|
@@ -222,6 +248,10 @@ const Detail: React.FC<RouteComponentProps> = props => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ const modalProps = { visible: modalObj.auditModal, loading: modalObj.loading, type: modalObj.auditType }
|
|
|
+
|
|
|
+ const auditData = { auditors: detail.auditors, auditHistory: detail.auditHistory, status: detail.status, uName: detail.auditName, uid: detail.uid }
|
|
|
+
|
|
|
return (
|
|
|
<div className="wrap-contaniner">
|
|
|
<Header title="安全巡检">
|
|
@@ -362,7 +392,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>
|
|
@@ -376,7 +406,7 @@ const Detail: React.FC<RouteComponentProps> = props => {
|
|
|
{file.filename}
|
|
|
</a>
|
|
|
</td>
|
|
|
- <td className="pi-text-center">{file.accountName}</td>
|
|
|
+ <td className="pi-text-center pi-width-100">{file.accountName}</td>
|
|
|
<td className="pi-text-center">{dayjsFormat(file.createTime)}</td>
|
|
|
<td className="pi-text-center pi-width-90">
|
|
|
<Tooltip title="移除">
|
|
@@ -389,7 +419,7 @@ const Detail: React.FC<RouteComponentProps> = props => {
|
|
|
<tr>
|
|
|
<td colSpan={5} className="pi-text-right">
|
|
|
<Pagination
|
|
|
- current={visible.curPage}
|
|
|
+ current={modalObj.curPage}
|
|
|
size="small"
|
|
|
pageSize={consts.PAGE_SIZE}
|
|
|
hideOnSinglePage={true}
|
|
@@ -400,31 +430,21 @@ const Detail: React.FC<RouteComponentProps> = props => {
|
|
|
) : null}
|
|
|
</tbody>
|
|
|
</table>
|
|
|
- <AuditContent
|
|
|
- auditors={detail.auditors}
|
|
|
- onSelect={addAuditor}
|
|
|
- onDelete={delAuditor}
|
|
|
- latest={detail.latestAuditor}
|
|
|
- auditHistory={detail.auditHistory}
|
|
|
- status={detail.status}
|
|
|
- uName={detail.auditName}
|
|
|
- ></AuditContent>
|
|
|
+ <AuditContent data={auditData} onSelect={addAuditor} onDelete={delAuditor}></AuditContent>
|
|
|
</div>
|
|
|
</div>
|
|
|
<OssUploadModal
|
|
|
- visible={visible.ossModal}
|
|
|
- onCancel={() => setVisible({ ...visible, ossModal: false })}
|
|
|
+ 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>
|
|
|
+ curAuditor={detail.latestAuditor}></AuditModal>
|
|
|
</div>
|
|
|
)
|
|
|
}
|