Commit ca0ddcac authored by xiexiuxing's avatar xiexiuxing

素材库文件名优化

parent 5c929b45
...@@ -27,10 +27,18 @@ ...@@ -27,10 +27,18 @@
border: 1px solid #ccc; border: 1px solid #ccc;
border-radius: 5px; border-radius: 5px;
position: relative; position: relative;
img{ display: flex;
align-items: center;
justify-content: center;
background-color: #F5F6F7;
.Img{
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
img{
width: 48px;
height: 48px;
}
video{ video{
width: 100%; width: 100%;
height: 100%; height: 100%;
......
...@@ -8,6 +8,15 @@ import moment from 'moment'; ...@@ -8,6 +8,15 @@ import moment from 'moment';
import styles from './index.less'; import styles from './index.less';
import { UPLOAD_TYPE } from '@/constants' import { UPLOAD_TYPE } from '@/constants'
import { postManageMaterialLibraryPage, postManageMaterialLibraryAdd, postManageMaterialLibraryBatchDel } from '@/services/ManageV2Api'; import { postManageMaterialLibraryPage, postManageMaterialLibraryAdd, postManageMaterialLibraryBatchDel } from '@/services/ManageV2Api';
import Zip from './img/Zip.png';
import Doc from './img/Doc.png';
import Xlsx from './img/Excel.png';
import Video from './img/Video.png';
import PDF from './img/PDF.png';
import PPT from './img/PPT.png';
import Photo from './img/Photo.png';
import Others from './img/Others.png';
const { RangePicker } = DatePicker const { RangePicker } = DatePicker
const { Option } = Select; const { Option } = Select;
...@@ -72,10 +81,17 @@ const Materialmanagement = () => { ...@@ -72,10 +81,17 @@ const Materialmanagement = () => {
if (data.fileType == 0) { if (data.fileType == 0) {
data.fileType = '' data.fileType = ''
} }
const res = await postManageMaterialLibraryPage(data) const res = await postManageMaterialLibraryPage(data, { ctlType: 'none' })
console.log(res); const list = res.data.data.map((item: any) => {
const flieCode = item.fileUrl.split('.')
return {
...item,
flieCode: flieCode[flieCode.length - 1]
}
})
console.log(list)
if (res.code === 1000) { if (res.code === 1000) {
setdataSource(res.data.data) setdataSource(list)
settotal(res.data.totalCount) settotal(res.data.totalCount)
} }
} }
...@@ -97,7 +113,6 @@ const Materialmanagement = () => { ...@@ -97,7 +113,6 @@ const Materialmanagement = () => {
if (fileList[0].response) { if (fileList[0].response) {
if (fileList[0].response.code === 1000) { if (fileList[0].response.code === 1000) {
let fileType = 3; let fileType = 3;
console.log(fileList[0].type)
const isJpgOrPng = fileList[0].type === 'image/jpeg' || fileList[0].type === 'image/png' || fileList[0].type === 'image/jpg'; const isJpgOrPng = fileList[0].type === 'image/jpeg' || fileList[0].type === 'image/png' || fileList[0].type === 'image/jpg';
if (isJpgOrPng) { if (isJpgOrPng) {
fileType = 1 fileType = 1
...@@ -170,22 +185,53 @@ const Materialmanagement = () => { ...@@ -170,22 +185,53 @@ const Materialmanagement = () => {
materialList() materialList()
} }
const fileTypeDom = (type, item) => {
if (type == 1) { const fileTypeDom = (item) => {
const { flieCode } = item;
const isJpgOrPng = flieCode === 'jpeg' || flieCode === 'png' || flieCode === 'jpg';
console.log(isJpgOrPng)
if (isJpgOrPng) {
return (
<img className={styles.Img} src={item.fileUrl} alt="" />
)
}
if (flieCode == 'zip') {
return (
<img src={Zip} alt="" />
)
}
if (flieCode == 'docx') {
return (
<img src={Doc} alt="" />
)
}
if (flieCode == 'xlsx') {
return ( return (
<img src={item.fileUrl} alt="" /> <img src={Xlsx} alt="" />
) )
} }
if (type == 2) { if (flieCode == 'mp4') {
return ( return (
<video src={item.fileUrl}></video> <video src={item.fileUrl}></video>
// <img className={styles.Img} src={Video} alt="" />
) )
} }
else { if (flieCode == 'pptx') {
return ( return (
<img src="http://lingxi-mini.oss-cn-hangzhou.aliyuncs.com/Images/fujian@2x.png" alt="" /> <img src={PPT} alt="" />
) )
} }
if (flieCode == 'pdf') {
return (
<img src={PDF} alt="" />
)
} else {
return (
<img src={Others} alt="" />
)
}
} }
const download = (url, fileName) => { const download = (url, fileName) => {
...@@ -200,17 +246,7 @@ const Materialmanagement = () => { ...@@ -200,17 +246,7 @@ const Materialmanagement = () => {
a.click() a.click()
} }
x.send(); x.send();
// const eleLink = document.createElement('a');
// eleLink.download = fileName;
// eleLink.style.display = 'none';
// // 字符内容转变成blob地址
// const blob = new Blob([url]);
// eleLink.href = URL.createObjectURL(blob);
// // 触发点击
// document.body.appendChild(eleLink);
// eleLink.click();
// // 然后移除
// document.body.removeChild(eleLink);
} }
...@@ -267,7 +303,7 @@ const Materialmanagement = () => { ...@@ -267,7 +303,7 @@ const Materialmanagement = () => {
<div className={styles.listItem} > <div className={styles.listItem} >
<div onClick={() => setfalg(item, index)} className={[styles['Imgbox'], item.cheboxUrl ? styles['ImgboxAtive'] : ''].join(' ')} > <div onClick={() => setfalg(item, index)} className={[styles['Imgbox'], item.cheboxUrl ? styles['ImgboxAtive'] : ''].join(' ')} >
{fileTypeDom(item.fileType, item)} {fileTypeDom(item)}
{ {
item.cheboxUrl && item.cheboxUrl &&
......
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