Commit 74f5bfa7 authored by 田翔's avatar 田翔

fix: 预览图片优化

parent ee3e199a
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "5.5.6", "version": "5.5.7",
"description": "5.5.6 台账搜索条件修改", "description": "5.5.7 预览图片优化",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
...@@ -133,4 +133,4 @@ ...@@ -133,4 +133,4 @@
"publishConfig": { "publishConfig": {
"registry": "https://g.civnet.cn:4873" "registry": "https://g.civnet.cn:4873"
} }
} }
\ No newline at end of file
import React, { useEffect, useRef, useState } from 'react' import React, { useEffect, useMemo, useRef, useState } from 'react'
import styles from './index.less' import styles from './index.less'
import { Upload, Button, message, Tabs } from 'antd' import { Upload, Button, message, Tabs } from 'antd'
import { UploadOutlined, FileOutlined } from '@ant-design/icons' import { UploadOutlined, FileOutlined } from '@ant-design/icons'
...@@ -72,7 +72,17 @@ const FileUpload = (props) => { ...@@ -72,7 +72,17 @@ const FileUpload = (props) => {
const [visible, setVisible] = useState(false) const [visible, setVisible] = useState(false)
const [showFile, setShowFile] = useState({ fileType: '', filePath: '' }) const [showFile, setShowFile] = useState({ fileType: '', filePath: '' })
const [workbook, setWorkbook] = useState({ SheetNames: [] }) const [workbook, setWorkbook] = useState({ SheetNames: [] })
const viewerRef = useRef(null)
const images = useMemo(() => {
let array = []
console.log('showList', showList)
showList.forEach(v => {
if (['jpg', 'png', 'svg', 'jpeg'].includes(getFileType(v.name))) {
array.push({ src: v.url, alt: '' })
}
})
return array
}, [showList])
const showType = fileType === '图片' ? 'picture-card' : 'picture' const showType = fileType === '图片' ? 'picture-card' : 'picture'
...@@ -291,6 +301,8 @@ const FileUpload = (props) => { ...@@ -291,6 +301,8 @@ const FileUpload = (props) => {
} }
}, [presetValue]) }, [presetValue])
console.log('images', images)
return ( return (
<div className={fileType === '图片' ? styles.uploadBoxImg : styles.uploadBox}> <div className={fileType === '图片' ? styles.uploadBoxImg : styles.uploadBox}>
<Upload <Upload
...@@ -316,11 +328,9 @@ const FileUpload = (props) => { ...@@ -316,11 +328,9 @@ const FileUpload = (props) => {
> >
{elemet()} {elemet()}
</Drag> </Drag>
<Viewer {
visible={imgVisible} images.length ? <Viewer visible={imgVisible} onClose={() => setImgVisible(false)} images={images} /> : null
onClose={() => setImgVisible(false)} }
images={[{ src: showFile.filePath, alt: '' }]}
/>
</div> </div>
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment