Commit af7d098f authored by 田翔's avatar 田翔

fix: 图片预览与导出模板问题

parent d1bfa69c
{
"name": "panda-xform",
"version": "5.8.1",
"description": "5.8.1 去掉site问题",
"version": "5.8.3",
"description": "5.8.3 图片预览与导出模板问题",
"keywords": [
"panda-xform"
],
......
......@@ -152,12 +152,16 @@ const Account = (props, ref) => {
content: keys.length > 0 ? `共选择${keys.length}条数据,确定要导出吗` : '确定要导出全部数据吗?',
onOk: async () => {
return await new Promise(async (resolve, reject) => {
let res = await ExportAccountData({ accountName: accountName, ids: keys.join(','), exportAll })
if (res && res.code === -1) {
message.error(res.msg)
const blob = await ExportAccountData({ accountName: accountName, ids: keys.join(','), exportAll })
const reader = new FileReader();
reader.onload = function () {
const text = reader.result;
if (text?.includes('code')) {
let obj = JSON.parse(text)
message.error(obj.msg)
reject()
} else {
const url = window.URL.createObjectURL(new Blob([res]))
const url = window.URL.createObjectURL(new Blob([blob]))
const a = document.createElement('a')
a.href = url
a.target = '_blank'
......@@ -166,6 +170,11 @@ const Account = (props, ref) => {
a.remove()
resolve()
}
};
reader.onerror = function (error) {
console.error('Error reading the blob', error);
};
reader.readAsText(blob, 'UTF-8'); // 指定编码
})
},
okText: '确定',
......
......@@ -73,12 +73,13 @@ const FileUpload = (props) => {
const [visible, setVisible] = useState(false)
const [showFile, setShowFile] = useState({ fileType: '', filePath: '' })
const [workbook, setWorkbook] = useState({ SheetNames: [] })
const [activeIndex, setActiveIndex] = useState(1)
const images = useMemo(() => {
let array = []
showList.forEach(v => {
if (['jpg', 'png', 'svg', 'jpeg'].includes(getFileType(v.name))) {
array.push({ src: v.url, alt: '' })
array.push({ src: v.url, alt: '', sourcePath: v.sourcePath })
}
})
return array
......@@ -142,6 +143,8 @@ const FileUpload = (props) => {
setShowFile({ name: file.name, fileType: fileType, filePath: file.url })
if (fileType) {
if (['jpg', 'png', 'svg', 'jpeg'].includes(fileType)) {
let index = images.findIndex(v => v.sourcePath === file.sourcePath)
setActiveIndex(index)
setImgVisible(true)
} else {
if (['xlsx', 'xls'].includes(fileType)) {
......@@ -332,7 +335,14 @@ const FileUpload = (props) => {
{elemet()}
</Drag>
{
images.length ? <Viewer visible={imgVisible} onClose={() => setImgVisible(false)} images={images} /> : null
images.length ? (
<Viewer
visible={imgVisible}
onClose={() => setImgVisible(false)}
images={images}
activeIndex={activeIndex}
/>
) : 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