|
@@ -25,7 +25,6 @@ type MyTypeType = 'thumb' | 'video' | 'audio' | 'model' | 'pdf'
|
|
|
type Props = {
|
|
type Props = {
|
|
|
fileCheck: boolean //有没有点击过确定
|
|
fileCheck: boolean //有没有点击过确定
|
|
|
size: number //上传附件大小(M)
|
|
size: number //上传附件大小(M)
|
|
|
- dirCode: string //文件的code码
|
|
|
|
|
myUrl: string //请求地址
|
|
myUrl: string //请求地址
|
|
|
format: string[] //上传格式 ["image/jpeg", "image/png"] ["video/mp4"] ,application/pdf
|
|
format: string[] //上传格式 ["image/jpeg", "image/png"] ["video/mp4"] ,application/pdf
|
|
|
formatTxt: string //上传图片提示
|
|
formatTxt: string //上传图片提示
|
|
@@ -41,7 +40,6 @@ function ZupOne(
|
|
|
{
|
|
{
|
|
|
fileCheck,
|
|
fileCheck,
|
|
|
size,
|
|
size,
|
|
|
- dirCode,
|
|
|
|
|
myUrl,
|
|
myUrl,
|
|
|
format,
|
|
format,
|
|
|
formatTxt,
|
|
formatTxt,
|
|
@@ -54,9 +52,9 @@ function ZupOne(
|
|
|
ref: any
|
|
ref: any
|
|
|
) {
|
|
) {
|
|
|
const [fileUrl, setFileUrl] = useState({
|
|
const [fileUrl, setFileUrl] = useState({
|
|
|
- fileName: '',
|
|
|
|
|
- filePath: '',
|
|
|
|
|
- thumb: ''
|
|
|
|
|
|
|
+ originalName: '',
|
|
|
|
|
+ originalUrl: '',
|
|
|
|
|
+ compressedUrl: ''
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
const myInput = useRef<HTMLInputElement>(null)
|
|
const myInput = useRef<HTMLInputElement>(null)
|
|
@@ -95,14 +93,8 @@ function ZupOne(
|
|
|
let myTypeRes: string = myType
|
|
let myTypeRes: string = myType
|
|
|
if (['pdf'].includes(myTypeRes)) myTypeRes = 'doc'
|
|
if (['pdf'].includes(myTypeRes)) myTypeRes = 'doc'
|
|
|
fd.append('type', myTypeRes)
|
|
fd.append('type', myTypeRes)
|
|
|
- fd.append('dirCode', dirCode)
|
|
|
|
|
fd.append('file', filesInfo)
|
|
fd.append('file', filesInfo)
|
|
|
|
|
|
|
|
- if (myType === 'thumb') {
|
|
|
|
|
- // 开启压缩图片
|
|
|
|
|
- fd.append('isCompress', 'true')
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
if (fromData) {
|
|
if (fromData) {
|
|
|
for (const k in fromData) {
|
|
for (const k in fromData) {
|
|
|
if (fromData[k]) fd.append(k, fromData[k])
|
|
if (fromData[k]) fd.append(k, fromData[k])
|
|
@@ -123,12 +115,12 @@ function ZupOne(
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- [dirCode, format, formatTxt, fromData, myType, myUrl, size]
|
|
|
|
|
|
|
+ [format, formatTxt, fromData, myType, myUrl, size]
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
// 让父组件调用的 回显 附件 地址
|
|
// 让父组件调用的 回显 附件 地址
|
|
|
const setFileComFileFu = useCallback(
|
|
const setFileComFileFu = useCallback(
|
|
|
- (valObj: { fileName: string; filePath: string; thumb: string }) => {
|
|
|
|
|
|
|
+ (valObj: { originalName: string; originalUrl: string; compressedUrl: string }) => {
|
|
|
setFileUrl(valObj)
|
|
setFileUrl(valObj)
|
|
|
},
|
|
},
|
|
|
[]
|
|
[]
|
|
@@ -159,11 +151,11 @@ function ZupOne(
|
|
|
(type: MyTypeType) => {
|
|
(type: MyTypeType) => {
|
|
|
if (type === 'pdf' || type === 'thumb') {
|
|
if (type === 'pdf' || type === 'thumb') {
|
|
|
// 新窗口打开
|
|
// 新窗口打开
|
|
|
- window.open(baseURL + fileUrl.filePath)
|
|
|
|
|
|
|
+ window.open(baseURL + fileUrl.originalUrl)
|
|
|
} else {
|
|
} else {
|
|
|
store.dispatch({
|
|
store.dispatch({
|
|
|
type: 'layout/lookDom',
|
|
type: 'layout/lookDom',
|
|
|
- payload: { src: fileUrl.filePath, type }
|
|
|
|
|
|
|
+ payload: { src: fileUrl.originalUrl, type }
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -171,7 +163,7 @@ function ZupOne(
|
|
|
// } else {
|
|
// } else {
|
|
|
// }
|
|
// }
|
|
|
},
|
|
},
|
|
|
- [fileUrl.filePath]
|
|
|
|
|
|
|
+ [fileUrl.originalUrl]
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
@@ -185,7 +177,7 @@ function ZupOne(
|
|
|
/>
|
|
/>
|
|
|
{myType === 'thumb' ? (
|
|
{myType === 'thumb' ? (
|
|
|
<div
|
|
<div
|
|
|
- hidden={fileUrl.filePath !== ''}
|
|
|
|
|
|
|
+ hidden={fileUrl.originalUrl !== ''}
|
|
|
className='file_upIcon'
|
|
className='file_upIcon'
|
|
|
onClick={() => myInput.current?.click()}
|
|
onClick={() => myInput.current?.click()}
|
|
|
>
|
|
>
|
|
@@ -193,7 +185,7 @@ function ZupOne(
|
|
|
</div>
|
|
</div>
|
|
|
) : (
|
|
) : (
|
|
|
<Button
|
|
<Button
|
|
|
- hidden={fileUrl.filePath !== ''}
|
|
|
|
|
|
|
+ hidden={fileUrl.originalUrl !== ''}
|
|
|
onClick={() => myInput.current?.click()}
|
|
onClick={() => myInput.current?.click()}
|
|
|
icon={<UploadOutlined rev={undefined} />}
|
|
icon={<UploadOutlined rev={undefined} />}
|
|
|
>
|
|
>
|
|
@@ -203,13 +195,13 @@ function ZupOne(
|
|
|
|
|
|
|
|
{/* 为图片的情况-------------- */}
|
|
{/* 为图片的情况-------------- */}
|
|
|
{myType === 'thumb' ? (
|
|
{myType === 'thumb' ? (
|
|
|
- <div className='file_img' hidden={fileUrl.filePath === ''}>
|
|
|
|
|
|
|
+ <div className='file_img' hidden={fileUrl.originalUrl === ''}>
|
|
|
{fileUrl ? (
|
|
{fileUrl ? (
|
|
|
<ImageLazy
|
|
<ImageLazy
|
|
|
width={100}
|
|
width={100}
|
|
|
height={100}
|
|
height={100}
|
|
|
- src={fileUrl.thumb || fileUrl.filePath}
|
|
|
|
|
- srcBig={fileUrl.filePath || fileUrl.thumb || ''}
|
|
|
|
|
|
|
+ src={fileUrl.compressedUrl || fileUrl.originalUrl}
|
|
|
|
|
+ srcBig={fileUrl.originalUrl || fileUrl.compressedUrl || ''}
|
|
|
noLook
|
|
noLook
|
|
|
/>
|
|
/>
|
|
|
) : null}
|
|
) : null}
|
|
@@ -218,7 +210,7 @@ function ZupOne(
|
|
|
<div className='file_closeBox' hidden={isLook}>
|
|
<div className='file_closeBox' hidden={isLook}>
|
|
|
<MyPopconfirm
|
|
<MyPopconfirm
|
|
|
txtK='删除'
|
|
txtK='删除'
|
|
|
- onConfirm={() => setFileUrl({ fileName: '', filePath: '', thumb: '' })}
|
|
|
|
|
|
|
+ onConfirm={() => setFileUrl({ originalName: '', originalUrl: '', compressedUrl: '' })}
|
|
|
Dom={<CloseOutlined rev={undefined} />}
|
|
Dom={<CloseOutlined rev={undefined} />}
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
@@ -229,30 +221,30 @@ function ZupOne(
|
|
|
onClick={() =>
|
|
onClick={() =>
|
|
|
store.dispatch({
|
|
store.dispatch({
|
|
|
type: 'layout/lookBigImg',
|
|
type: 'layout/lookBigImg',
|
|
|
- payload: { url: baseURL + fileUrl.filePath, show: true }
|
|
|
|
|
|
|
+ payload: { url: baseURL + fileUrl.originalUrl, show: true }
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
rev={undefined}
|
|
rev={undefined}
|
|
|
/>
|
|
/>
|
|
|
- <a href={baseURL + fileUrl.filePath} download target='_blank' rel='noreferrer'>
|
|
|
|
|
|
|
+ <a href={baseURL + fileUrl.originalUrl} download target='_blank' rel='noreferrer'>
|
|
|
<DownloadOutlined rev={undefined} />
|
|
<DownloadOutlined rev={undefined} />
|
|
|
</a>
|
|
</a>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
- ) : fileUrl.filePath ? (
|
|
|
|
|
|
|
+ ) : fileUrl.originalUrl ? (
|
|
|
<div className='fileInfo'>
|
|
<div className='fileInfo'>
|
|
|
- <div className='upSuccTxt'>{fileUrl.fileName}</div>
|
|
|
|
|
|
|
+ <div className='upSuccTxt'>{fileUrl.originalName}</div>
|
|
|
{/* 视频预览 */}
|
|
{/* 视频预览 */}
|
|
|
<div
|
|
<div
|
|
|
className='clearCover'
|
|
className='clearCover'
|
|
|
- hidden={!fileUrl.filePath}
|
|
|
|
|
|
|
+ hidden={!fileUrl.originalUrl}
|
|
|
onClick={() => lookFileNoImgFu(myType)}
|
|
onClick={() => lookFileNoImgFu(myType)}
|
|
|
>
|
|
>
|
|
|
<EyeOutlined rev={undefined} />
|
|
<EyeOutlined rev={undefined} />
|
|
|
</div>
|
|
</div>
|
|
|
{/* 视频下载 */}
|
|
{/* 视频下载 */}
|
|
|
<a
|
|
<a
|
|
|
- href={baseURL + fileUrl.filePath}
|
|
|
|
|
|
|
+ href={baseURL + fileUrl.originalUrl}
|
|
|
download
|
|
download
|
|
|
target='_blank'
|
|
target='_blank'
|
|
|
className='clearCover'
|
|
className='clearCover'
|
|
@@ -262,11 +254,13 @@ function ZupOne(
|
|
|
</a>
|
|
</a>
|
|
|
{/* 视频删除 */}
|
|
{/* 视频删除 */}
|
|
|
|
|
|
|
|
- <MyPopconfirm
|
|
|
|
|
- txtK='删除'
|
|
|
|
|
- onConfirm={() => setFileUrl({ fileName: '', filePath: '', thumb: '' })}
|
|
|
|
|
- Dom={<CloseOutlined className='clearCover' rev={undefined} />}
|
|
|
|
|
- />
|
|
|
|
|
|
|
+ {isLook ? null : (
|
|
|
|
|
+ <MyPopconfirm
|
|
|
|
|
+ txtK='删除'
|
|
|
|
|
+ onConfirm={() => setFileUrl({ originalName: '', originalUrl: '', compressedUrl: '' })}
|
|
|
|
|
+ Dom={<CloseOutlined className='clearCover' rev={undefined} />}
|
|
|
|
|
+ />
|
|
|
|
|
+ )}
|
|
|
</div>
|
|
</div>
|
|
|
) : null}
|
|
) : null}
|
|
|
|
|
|
|
@@ -274,7 +268,10 @@ function ZupOne(
|
|
|
格式要求:支持{formatTxt}格式;最大支持{size}M。{upTxt}
|
|
格式要求:支持{formatTxt}格式;最大支持{size}M。{upTxt}
|
|
|
<br />
|
|
<br />
|
|
|
<div
|
|
<div
|
|
|
- className={classNames('noUpThumb', !fileUrl.filePath && fileCheck ? 'noUpThumbAc' : '')}
|
|
|
|
|
|
|
+ className={classNames(
|
|
|
|
|
+ 'noUpThumb',
|
|
|
|
|
+ !fileUrl.originalUrl && fileCheck ? 'noUpThumbAc' : ''
|
|
|
|
|
+ )}
|
|
|
>
|
|
>
|
|
|
{checkTxt}
|
|
{checkTxt}
|
|
|
</div>
|
|
</div>
|