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

fix: 预览图片优化

parent ee3e199a
{
"name": "panda-xform",
"version": "5.5.6",
"description": "5.5.6 台账搜索条件修改",
"version": "5.5.7",
"description": "5.5.7 预览图片优化",
"keywords": [
"panda-xform"
],
......
import React, { useEffect, useRef, useState } from 'react'
import React, { useEffect, useMemo, useRef, useState } from 'react'
import styles from './index.less'
import { Upload, Button, message, Tabs } from 'antd'
import { UploadOutlined, FileOutlined } from '@ant-design/icons'
......@@ -72,7 +72,17 @@ const FileUpload = (props) => {
const [visible, setVisible] = useState(false)
const [showFile, setShowFile] = useState({ fileType: '', filePath: '' })
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'
......@@ -291,6 +301,8 @@ const FileUpload = (props) => {
}
}, [presetValue])
console.log('images', images)
return (
<div className={fileType === '图片' ? styles.uploadBoxImg : styles.uploadBox}>
<Upload
......@@ -316,11 +328,9 @@ const FileUpload = (props) => {
>
{elemet()}
</Drag>
<Viewer
visible={imgVisible}
onClose={() => setImgVisible(false)}
images={[{ src: showFile.filePath, alt: '' }]}
/>
{
images.length ? <Viewer visible={imgVisible} onClose={() => setImgVisible(false)} images={images} /> : null
}
</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