Commit 9a495d52 authored by 田翔's avatar 田翔

fix: 图片样式优化

parent e2c8da1b
import React, { useEffect, useState } from 'react' import React, { useEffect, useState } from 'react'
import styles from './index.less' import styles from './index.less'
import { Button, Upload, message } from 'antd' import { Button, Upload, message } from 'antd'
import { accepts,getFileType } from '../../../../../../constant' import { accepts, getFileType } from '../../../../../../constant'
import { uploadFileUrl, downloadFileUrl, downloadFile } from '../../../../../../apis/process' import { uploadFileUrl, downloadFileUrl, downloadFile } from '../../../../../../apis/process'
import { import {
SnippetsOutlined, SnippetsOutlined,
...@@ -42,9 +42,16 @@ const FileView = (props) => { ...@@ -42,9 +42,16 @@ const FileView = (props) => {
<div className={styles.fileView}> <div className={styles.fileView}>
<Viewer> <Viewer>
{ {
fileList.map(v => { fileList.map((v, i) => {
return ( return (
<img className={styles.img} src={`${window.origin}/PandaWorkFlow/WorkFlow/AccountManage/DownloadFiles?filePath=${v}`}></img> <span className={styles.imgSpan} style={{ display: i == 0 ? 'inline-block' : 'none' }}>
{fileList.length !== 1 ? <span className={styles.imgSub}>{fileList.length}</span> : null}
<img
className={styles.img}
src={`${window.origin}/PandaWorkFlow/WorkFlow/AccountManage/DownloadFiles?filePath=${v}`}
>
</img>
</span>
) )
}) })
} }
...@@ -89,26 +96,26 @@ const FileView = (props) => { ...@@ -89,26 +96,26 @@ const FileView = (props) => {
useEffect(() => { useEffect(() => {
let list = [] let list = []
fileList.forEach((item, index) => { fileList.forEach((item, index) => {
if (item) { // @Tips: 直接过滤掉名字中有异常字符的文件 if (item) { // @Tips: 直接过滤掉名字中有异常字符的文件
let uid = index + '_' + Math.random() let uid = index + '_' + Math.random()
let _obj = { let _obj = {
uid: uid, uid: uid,
value: item, value: item,
name: item.split('\\').reverse()[0], name: item.split('\\').reverse()[0],
type: fileType === '图片' ? 'image/jpeg' : 'file', type: fileType === '图片' ? 'image/jpeg' : 'file',
status: 'done', status: 'done',
url: `${downloadFileUrl}?filePath=${item}${site ? `&_site=${site}` : ''}`, url: `${downloadFileUrl}?filePath=${item}${site ? `&_site=${site}` : ''}`,
sourcePath: item.url, sourcePath: item.url,
originFileObj: { "uid": uid }, originFileObj: { "uid": uid },
"response": { "code": 0, "msg": "Ok", "data": item, "stackTrace": null }, "response": { "code": 0, "msg": "Ok", "data": item, "stackTrace": null },
"xhr": {}, "xhr": {},
}; };
// if (schema.renderTo === 'Image') _obj.thumbUrl = `${downloadFileUrl}?filePath=${item}${site ? `&_site=${site}` : ''}`; // if (schema.renderTo === 'Image') _obj.thumbUrl = `${downloadFileUrl}?filePath=${item}${site ? `&_site=${site}` : ''}`;
list.push(_obj) list.push(_obj)
} }
}) })
setShowList(JSON.stringify(list)) setShowList(JSON.stringify(list))
},[value]) }, [value])
return ( return (
<div className={styles.fileView}> <div className={styles.fileView}>
......
...@@ -3,14 +3,30 @@ ...@@ -3,14 +3,30 @@
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
.img { .imgSpan {
width: 65px; position: relative;
margin-right: 5px;
transition: all 0.2s ease-in; transition: all 0.2s ease-in;
&:hover { &:hover {
cursor: pointer; cursor: pointer;
transform: scale(1.2); transform: scale(1.2);
} }
.img {
width: 65px;
}
.imgSub {
position: absolute;
z-index: 99;
top: 0;
right: 0;
background: red;
color: white;
width: 14px;
height: 14px;
text-align: center;
line-height: 14px;
font-size: 12px;
border-radius: 50%;
}
} }
.iconImg { .iconImg {
width: 45px; width: 45px;
......
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