|
@@ -12,12 +12,13 @@ import { iUserInfo } from '@/types/setting'
|
|
|
import { apiDelFile, apiGetFileList, apiSaveFileInfo } from '@/utils/common/api'
|
|
|
import consts from '@/utils/consts'
|
|
|
import { dayjsFormat } from '@/utils/util'
|
|
|
-import { Button, Input, Pagination, Tooltip } from 'antd'
|
|
|
+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 } from 'react'
|
|
|
import { RouteComponentProps } from 'react-router'
|
|
|
-import { apiGetSafeDetail } from './api'
|
|
|
+import { apiGetSafeDetail, apiResfulSafeAudit } from './api'
|
|
|
+import AuditModal from './components/Modal'
|
|
|
import styles from './index.module.scss'
|
|
|
const { TextArea } = Input
|
|
|
interface iDetailState {
|
|
@@ -49,9 +50,19 @@ interface iFileState {
|
|
|
fileList: any[]
|
|
|
total: number
|
|
|
}
|
|
|
+
|
|
|
+interface iModalObj {
|
|
|
+ ossModal: boolean
|
|
|
+ auditModal: boolean
|
|
|
+ auditType: string
|
|
|
+}
|
|
|
const Detail: React.FC<RouteComponentProps> = props => {
|
|
|
const { saveId = '' } = props.location.state as any
|
|
|
- const [ visible, setVisible ] = useState<boolean>(false)
|
|
|
+ const [ visible, setVisible ] = useState<iModalObj>({
|
|
|
+ ossModal: false,
|
|
|
+ auditModal: false,
|
|
|
+ auditType: ''
|
|
|
+ })
|
|
|
const [ detail, setDetail ] = useState<iDetailState>({
|
|
|
auditName: '',
|
|
|
auditors: [],
|
|
@@ -79,7 +90,6 @@ const Detail: React.FC<RouteComponentProps> = props => {
|
|
|
progress: ''
|
|
|
}
|
|
|
})
|
|
|
-
|
|
|
useEffect(() => {
|
|
|
initData()
|
|
|
}, [ saveId ])
|
|
@@ -98,10 +108,10 @@ const Detail: React.FC<RouteComponentProps> = props => {
|
|
|
})
|
|
|
)
|
|
|
setDetail({ ...detail, file: { ...detail.file, fileList: newFiles } })
|
|
|
- setVisible(false)
|
|
|
+ setVisible({ ...visible, ossModal: false })
|
|
|
}
|
|
|
}
|
|
|
- const onShow = (show: boolean) => setVisible(show)
|
|
|
+ const onOssModalShow = (show: boolean) => setVisible({ ...visible, ossModal: 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) {
|
|
@@ -118,6 +128,9 @@ const Detail: React.FC<RouteComponentProps> = props => {
|
|
|
}
|
|
|
|
|
|
const addAuditor = (type: string, user: iUserInfo) => {
|
|
|
+ if (detail.auditors.find(item => item.progress === (type === 'check' ? '0' : '2') && item.audit_id === user.id)) {
|
|
|
+ return message.error('该审批组下已存在该审批人,请勿重复添加!')
|
|
|
+ }
|
|
|
if (type === "check") {
|
|
|
const newAuditors = detail.auditors
|
|
|
const len = detail.auditors.filter((item: iAuditor) => item.progress === "0").length
|
|
@@ -131,36 +144,69 @@ const Detail: React.FC<RouteComponentProps> = props => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- const delAuditor = (id: string) => {
|
|
|
- const newAuditors = detail.auditors.filter(item => item.audit_id !== id)
|
|
|
+ const delAuditor = (id: string, progress: string) => {
|
|
|
+ const newAuditors = detail.auditors.filter(item => item.progress !== progress)
|
|
|
+ const auditor = detail.auditors.find(item => item.progress === progress && item.audit_id !== id)
|
|
|
+
|
|
|
+ if (auditor) {
|
|
|
+ newAuditors.push(auditor)
|
|
|
+ }
|
|
|
setDetail({ ...detail, auditors: newAuditors })
|
|
|
}
|
|
|
|
|
|
+ const btnClick = (type: string) => {
|
|
|
+ setVisible({ ...visible, auditType: type, auditModal: true })
|
|
|
+ }
|
|
|
+ const onModalConfirm = () => {
|
|
|
+ let payload: any = { safe_id: detail.id, bidsection_id: detail.bidsectionId }
|
|
|
+ if (visible.auditType === 'start') {
|
|
|
+ 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)
|
|
|
+ if (!payload.auditors.length || !payload.reAuditors.length) {
|
|
|
+ return message.error('审批人或整改人不能为空!')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (visible.auditType === 'delete') {
|
|
|
+ payload = { id: detail.id }
|
|
|
+ }
|
|
|
+ apiResful(visible.auditType, payload)
|
|
|
+ }
|
|
|
+ const apiResful = async (type: string, payload: any) => {
|
|
|
+ const { code } = await apiResfulSafeAudit(type, payload)
|
|
|
+ if (code === consts.RET_CODE.SUCCESS) {
|
|
|
+ if (type === 'delete') {
|
|
|
+ props.history.goBack()
|
|
|
+ } else {
|
|
|
+ initData()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
const renderHeaderBtn = (status: number) => {
|
|
|
if (!status) {
|
|
|
return (
|
|
|
<div className="pi-flex-row pi-align-center">
|
|
|
- <ZhCloseButton size="small">删除巡检</ZhCloseButton>
|
|
|
- <ZhSubmitButton size="small" className="pi-mg-left-5">提交审批</ZhSubmitButton>
|
|
|
+ <ZhCloseButton size="small" onClick={() => btnClick('delete')}>删除巡检</ZhCloseButton>
|
|
|
+ <ZhSubmitButton size="small" className="pi-mg-left-5" onClick={() => btnClick('start')}>提交审批</ZhSubmitButton>
|
|
|
</div>
|
|
|
)
|
|
|
} else if(status === 1) {
|
|
|
return (
|
|
|
<div className="pi-flex-row pi-align-center">
|
|
|
- <Button type="primary" danger size="small">关闭</Button>
|
|
|
- <ZhAuditBackButton size="small" className="pi-mg-left-5">审批退回</ZhAuditBackButton>
|
|
|
- <ZhSubmitButton size="small" className="pi-mg-left-5">审批通过</ZhSubmitButton>
|
|
|
+ <Button type="primary" danger size="small" onClick={() => btnClick('sclose')}>关闭</Button>
|
|
|
+ <ZhAuditBackButton size="small" className="pi-mg-left-5" onClick={() => btnClick('back')}>审批退回</ZhAuditBackButton>
|
|
|
+ <ZhSubmitButton size="small" className="pi-mg-left-5" onClick={() => btnClick('pass')}>审批通过</ZhSubmitButton>
|
|
|
</div>
|
|
|
)
|
|
|
} else {
|
|
|
return (
|
|
|
<div className="pi-flex-row pi-align-center">
|
|
|
- <ZhAuditBackButton size="small">审批退回</ZhAuditBackButton>
|
|
|
- <ZhSubmitButton size="small" className="pi-mg-left-5">整改</ZhSubmitButton>
|
|
|
+ <ZhAuditBackButton size="small" onClick={() => btnClick('back')}>审批退回</ZhAuditBackButton>
|
|
|
+ <ZhSubmitButton size="small" className="pi-mg-left-5" onClick={() => btnClick('pass')}>整改完成</ZhSubmitButton>
|
|
|
</div>
|
|
|
)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
return (
|
|
|
<div className="wrap-contaniner">
|
|
|
<Header title="安全巡检">
|
|
@@ -266,7 +312,7 @@ const Detail: React.FC<RouteComponentProps> = props => {
|
|
|
<tbody>
|
|
|
<tr>
|
|
|
<td colSpan={5}>
|
|
|
- <ZhUploadButton size="small" icon={<SvgIcon type="xxh-cloud-upload" />} onClick={() => setVisible(true)}>
|
|
|
+ <ZhUploadButton size="small" icon={<SvgIcon type="xxh-cloud-upload" />} onClick={() => setVisible({ ...visible, ossModal: true })}>
|
|
|
上传附件
|
|
|
</ZhUploadButton>
|
|
|
</td>
|
|
@@ -318,7 +364,18 @@ const Detail: React.FC<RouteComponentProps> = props => {
|
|
|
></AuditContent>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <OssUploadModal visible={visible} onCancel={() => setVisible(false)} onCreate={onCreate} onShow={onShow}></OssUploadModal>
|
|
|
+ <OssUploadModal
|
|
|
+ visible={visible.ossModal}
|
|
|
+ onCancel={() => setVisible({ ...visible, ossModal: false })}
|
|
|
+ onCreate={onCreate}
|
|
|
+ onShow={onOssModalShow}>
|
|
|
+ </OssUploadModal>
|
|
|
+ <AuditModal
|
|
|
+ type={visible.auditType}
|
|
|
+ visible={visible.auditModal}
|
|
|
+ onCancel={() => setVisible({ ...visible, auditModal: false })}
|
|
|
+ onCreate={onModalConfirm}
|
|
|
+ ></AuditModal>
|
|
|
</div>
|
|
|
)
|
|
|
}
|