|
@@ -1,5 +1,6 @@
|
|
|
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'
|
|
@@ -8,7 +9,7 @@ import { userStore } from '@/store/mobx'
|
|
|
import { iFile } from '@/types/file'
|
|
|
import consts from '@/utils/consts'
|
|
|
import { dayjsFomrat } from '@/utils/util'
|
|
|
-import { Button, Input, Tooltip } from 'antd'
|
|
|
+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'
|
|
@@ -24,13 +25,17 @@ interface iDetailState {
|
|
|
code: string
|
|
|
createTime: string | undefined
|
|
|
demand: string
|
|
|
- files: any[]
|
|
|
+ file: iFileState
|
|
|
id: string
|
|
|
inspection: string
|
|
|
inspectionDetail: string
|
|
|
position: string
|
|
|
status: number
|
|
|
}
|
|
|
+interface iFileState {
|
|
|
+ fileList: any[]
|
|
|
+ total: number
|
|
|
+}
|
|
|
const Detail:React.FC<RouteComponentProps> = (props) => {
|
|
|
const [ visible, setVisible ] = useState<boolean>(false)
|
|
|
const [ detail, setDetail ] = useState<iDetailState>({
|
|
@@ -40,7 +45,7 @@ const Detail:React.FC<RouteComponentProps> = (props) => {
|
|
|
code: "",
|
|
|
createTime: "",
|
|
|
demand: "",
|
|
|
- files: [],
|
|
|
+ file: { fileList: [], total: 0 },
|
|
|
id: "",
|
|
|
inspection: "",
|
|
|
inspectionDetail: "",
|
|
@@ -62,14 +67,20 @@ const Detail:React.FC<RouteComponentProps> = (props) => {
|
|
|
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.files.concat(fileList.map(file => {
|
|
|
+ const newFiles = detail.file.fileList.concat(fileList.map(file => {
|
|
|
return { ...file, accountName: userStore.userInfo.name }
|
|
|
}))
|
|
|
- setDetail({ ...detail, files: newFiles })
|
|
|
+ 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 } })
|
|
|
+ }
|
|
|
+ }
|
|
|
return (
|
|
|
<div className="wrap-contaniner">
|
|
|
<Header title="安全巡检">
|
|
@@ -98,6 +109,7 @@ const Detail:React.FC<RouteComponentProps> = (props) => {
|
|
|
</tr>
|
|
|
<tr><th style={{ width: "150px" }}>质检员</th><td>{detail.auditName}</td></tr>
|
|
|
</tbody>
|
|
|
+
|
|
|
</table>
|
|
|
<table className="pi-table pi-bordered mt-3">
|
|
|
<thead>
|
|
@@ -113,11 +125,11 @@ const Detail:React.FC<RouteComponentProps> = (props) => {
|
|
|
<tr><td colSpan={5}><ZhUploadButton size="small" icon={<SvgIcon type="xxh-cloud-upload"/>} onClick={() => setVisible(true)}>上传附件</ZhUploadButton></td></tr>
|
|
|
|
|
|
{
|
|
|
- detail.files.map((file, idx) => {
|
|
|
+ detail.file.fileList?.map((file, idx) => {
|
|
|
return (
|
|
|
<tr key={idx}>
|
|
|
<td className="pi-width-70">{idx+1}</td>
|
|
|
- <td><span className="pi-link-blue">{file.filename}</span></td>
|
|
|
+ <td><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">{dayjsFomrat(file.createTime)}</td>
|
|
|
<td className="pi-text-center pi-width-90">
|
|
|
<Tooltip title="移除">
|
|
@@ -128,6 +140,21 @@ const Detail:React.FC<RouteComponentProps> = (props) => {
|
|
|
)
|
|
|
})
|
|
|
}
|
|
|
+ <tr><td colSpan={5} className="pi-text-right">
|
|
|
+ {
|
|
|
+ detail.file.total ?
|
|
|
+ <Pagination
|
|
|
+ defaultCurrent={1}
|
|
|
+ size="small"
|
|
|
+ pageSize={consts.PAGE_SIZE}
|
|
|
+ hideOnSinglePage={true}
|
|
|
+ total={detail.file.total}
|
|
|
+ onChange={(page, pageSize) => fileListChange(page, pageSize)}
|
|
|
+ >
|
|
|
+ </Pagination>
|
|
|
+ : ''
|
|
|
+ }
|
|
|
+ </td></tr>
|
|
|
</tbody>
|
|
|
</table>
|
|
|
</div>
|