|
@@ -1,9 +1,11 @@
|
|
|
-import { ZhCloseButton, ZhSubmitButton, ZhUploadButton } from '@/components/Button'
|
|
|
+import { ZhSubmitButton, ZhUploadButton } from '@/components/Button'
|
|
|
import DatePicker from '@/components/DatePicker'
|
|
|
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 consts from '@/utils/consts'
|
|
|
import { dayjsFomrat } from '@/utils/util'
|
|
|
import { Button, Input, Tooltip } from 'antd'
|
|
@@ -12,7 +14,7 @@ import dayjs from 'dayjs'
|
|
|
import React, { useEffect, useState } from 'react'
|
|
|
import { useActivate } from 'react-activation'
|
|
|
import { RouteComponentProps } from 'react-router'
|
|
|
-import { apiGetSafeDetail } from './api'
|
|
|
+import { apiGetSafeDetail, apiSaveFileInfo } from './api'
|
|
|
import styles from './index.module.scss'
|
|
|
const { TextArea } = Input
|
|
|
interface iDetailState {
|
|
@@ -57,11 +59,17 @@ const Detail:React.FC<RouteComponentProps> = (props) => {
|
|
|
setDetail({ ...detail, ...data })
|
|
|
}
|
|
|
}
|
|
|
- // const onCreate = () => {
|
|
|
- // setDetail({
|
|
|
-
|
|
|
- // })
|
|
|
- // }
|
|
|
+ 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 => {
|
|
|
+ return { ...file, accountName: userStore.userInfo.name }
|
|
|
+ }))
|
|
|
+ setDetail({ ...detail, files: newFiles })
|
|
|
+ setVisible(false)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const onShow = (show: boolean) => setVisible(show)
|
|
|
return (
|
|
|
<div className="wrap-contaniner">
|
|
|
<Header title="安全巡检">
|
|
@@ -103,16 +111,23 @@ const Detail:React.FC<RouteComponentProps> = (props) => {
|
|
|
</thead>
|
|
|
<tbody>
|
|
|
<tr><td colSpan={5}><ZhUploadButton size="small" icon={<SvgIcon type="xxh-cloud-upload"/>} onClick={() => setVisible(true)}>上传附件</ZhUploadButton></td></tr>
|
|
|
- <tr>
|
|
|
- <td style={{ width: 70 }}>1</td>
|
|
|
- <td><span className="pi-link-blue">安全检查附件.pdf</span></td>
|
|
|
- <td className="pi-text-center">布尔</td><td className="pi-text-center">{dayjsFomrat("2020-08-01 13:21:33")}</td>
|
|
|
- <td style={{ width: 90 }} className="pi-text-center">
|
|
|
- <Tooltip title="移除">
|
|
|
- <Button size="small" type="text" icon={<SvgIcon type="xxh-times-circle1"/>} style={{ color: "#df3f45" }}></Button>
|
|
|
- </Tooltip>
|
|
|
- </td>
|
|
|
- </tr>
|
|
|
+
|
|
|
+ {
|
|
|
+ detail.files.map((file, idx) => {
|
|
|
+ return (
|
|
|
+ <tr key={idx}>
|
|
|
+ <td style={{ width: 70 }}>1</td>
|
|
|
+ <td><span className="pi-link-blue">{file.filename}</span></td>
|
|
|
+ <td className="pi-text-center">{file.accountName}</td><td className="pi-text-center">{dayjsFomrat(file.createTime)}</td>
|
|
|
+ <td style={{ width: 90 }} className="pi-text-center">
|
|
|
+ <Tooltip title="移除">
|
|
|
+ <Button size="small" type="text" icon={<SvgIcon type="xxh-times-circle1"/>} style={{ color: "#df3f45" }}></Button>
|
|
|
+ </Tooltip>
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
+ )
|
|
|
+ })
|
|
|
+ }
|
|
|
</tbody>
|
|
|
</table>
|
|
|
</div>
|
|
@@ -120,12 +135,8 @@ const Detail:React.FC<RouteComponentProps> = (props) => {
|
|
|
<OssUploadModal
|
|
|
visible={visible}
|
|
|
onCancel={() => setVisible(false)}
|
|
|
- // onOk={}
|
|
|
- footer={
|
|
|
- <div className="pi-flex-row pi-justify-end">
|
|
|
- <ZhCloseButton onClick={() => setVisible(false)} size="small" className="pi-mg-right-5">关闭</ZhCloseButton>
|
|
|
- <Button type="primary" size="small">确认</Button>
|
|
|
- </div>}
|
|
|
+ onCreate={onCreate}
|
|
|
+ onShow={onShow}
|
|
|
>
|
|
|
</OssUploadModal>
|
|
|
</div>
|