147 lines
5.8 KiB
JavaScript
147 lines
5.8 KiB
JavaScript
|
|
import { Button } from 'antd';
|
|||
|
|
import { message } from "antd/lib/index";
|
|||
|
|
import React from 'react';
|
|||
|
|
import FormPage from '../../components/FormPage';
|
|||
|
|
import config from '../../config';
|
|||
|
|
export default {
|
|||
|
|
// getFileDown(params) {
|
|||
|
|
// const { record} = params ? params : {};
|
|||
|
|
// if (record && record.Nav_Files) {
|
|||
|
|
// // return {
|
|||
|
|
// // content:
|
|||
|
|
// record.Nav_Files.map(t=>{
|
|||
|
|
// if(t.Nav_File)
|
|||
|
|
// {
|
|||
|
|
// const imgSrc = config.serviceHost('api/PF/File/GetFile?id=' + t.Nav_File.FILE_ID)
|
|||
|
|
// return (
|
|||
|
|
// <a
|
|||
|
|
// target="_blank"
|
|||
|
|
// href={imgSrc}
|
|||
|
|
// >
|
|||
|
|
// {t.Nav_File.Nav_File.FILE_NAME}
|
|||
|
|
// </a>
|
|||
|
|
// );
|
|||
|
|
|
|||
|
|
// // return <tr>
|
|||
|
|
// // <div><a href={imgSrc}>t.Nav_File.Nav_File.FILE_NAME</a></div>
|
|||
|
|
// // </tr>
|
|||
|
|
|
|||
|
|
// }
|
|||
|
|
// })
|
|||
|
|
|
|||
|
|
// // }
|
|||
|
|
|
|||
|
|
// }
|
|||
|
|
// },
|
|||
|
|
singleFileDown(params) {
|
|||
|
|
const { record, dispatch } = params ? params : {};
|
|||
|
|
//下载单个文件
|
|||
|
|
const handlerDown = (url, name) => {
|
|||
|
|
const link = document.createElement("a");
|
|||
|
|
link.href = url;
|
|||
|
|
link.download = name;
|
|||
|
|
link.click();
|
|||
|
|
};
|
|||
|
|
//下载多个文件
|
|||
|
|
const allLoad=(excelList)=> {
|
|||
|
|
for(let i=0;i<excelList.length;i++){
|
|||
|
|
const iframe = document.createElement("iframe");
|
|||
|
|
iframe.style.display = "none"; // 防止影响页面
|
|||
|
|
iframe.style.height = 0; // 防止影响页面
|
|||
|
|
iframe.src = excelList[i];
|
|||
|
|
document.body.appendChild(iframe); // 这一行必须,iframe挂在到dom树上才会发请求
|
|||
|
|
// 5分钟之后删除
|
|||
|
|
setTimeout(()=>{
|
|||
|
|
iframe.remove();
|
|||
|
|
}, 5 * 60 * 1000);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
const confirmRevert = (event) => {
|
|||
|
|
if (record && record.Nav_Files) {
|
|||
|
|
let excelList=[];
|
|||
|
|
for (let i = 0; i < record.Nav_Files.length; i++) {
|
|||
|
|
let tempFile = record.Nav_Files[i].Nav_ImgFile;
|
|||
|
|
if (tempFile) {
|
|||
|
|
// const urls = config.serviceHost('api/PF/File/GetFile?id=' + tempFile.FILE_ID);
|
|||
|
|
// const name = tempFile.FILE_NAME;
|
|||
|
|
// fetch(urls).then(res => res.blob()).then(blob => {
|
|||
|
|
// const a = document.createElement('a');
|
|||
|
|
// document.body.appendChild(a)
|
|||
|
|
// a.style.display = 'none'
|
|||
|
|
// // 使用获取到的blob对象创建的url
|
|||
|
|
// const url = window.URL.createObjectURL(blob);
|
|||
|
|
// a.href = url;
|
|||
|
|
// // 指定下载的文件名
|
|||
|
|
// a.download = name;
|
|||
|
|
// a.click();
|
|||
|
|
// document.body.removeChild(a)
|
|||
|
|
// // 移除blob对象的url
|
|||
|
|
// window.URL.revokeObjectURL(url);
|
|||
|
|
// });
|
|||
|
|
var hrefs = config.picServerHost + tempFile.Nav_File.FILE_PATH;
|
|||
|
|
excelList.push(hrefs);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(excelList&&excelList.length>0){
|
|||
|
|
allLoad(excelList);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
//const isReturn = record.STATUS >2;disabled={isReturn}
|
|||
|
|
return {
|
|||
|
|
content:
|
|||
|
|
<Button onClick={confirmRevert}
|
|||
|
|
type={'link'} icon={'download'} size={'small'} title="附件下载" />
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
allFileDown(params) {
|
|||
|
|
const { record, dispatch,getSelectedRecords } = params ? params : {};
|
|||
|
|
//下载多个文件
|
|||
|
|
const allLoad=(excelList)=> {
|
|||
|
|
for(let i=0;i<excelList.length;i++){
|
|||
|
|
const iframe = document.createElement("iframe");
|
|||
|
|
iframe.style.display = "none"; // 防止影响页面
|
|||
|
|
iframe.style.height = 0; // 防止影响页面
|
|||
|
|
iframe.src = excelList[i];
|
|||
|
|
document.body.appendChild(iframe); // 这一行必须,iframe挂在到dom树上才会发请求
|
|||
|
|
// 5分钟之后删除
|
|||
|
|
setTimeout(()=>{
|
|||
|
|
iframe.remove();
|
|||
|
|
}, 5 * 60 * 1000);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
const confirmRevert=()=>{
|
|||
|
|
//下载多个文件
|
|||
|
|
let DetailCheck = getSelectedRecords();
|
|||
|
|
if (DetailCheck && DetailCheck.length > 0) {
|
|||
|
|
let excelList=[];
|
|||
|
|
for (let i = 0; i < DetailCheck.length; i++) {
|
|||
|
|
let files=DetailCheck[i].Nav_Files;
|
|||
|
|
if(files.length>0)
|
|||
|
|
{
|
|||
|
|
for (let index = 0; index < files.length; index++) {
|
|||
|
|
let element = files[index].Nav_ImgFile;
|
|||
|
|
if(element)
|
|||
|
|
{
|
|||
|
|
var hrefs = config.picServerHost + element.Nav_File.FILE_PATH;
|
|||
|
|
excelList.push(hrefs);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if(excelList&&excelList.length>0){
|
|||
|
|
allLoad(excelList);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return {
|
|||
|
|
content:
|
|||
|
|
<Button onClick={confirmRevert}
|
|||
|
|
type={'primary'} icon={'download'} title="附件下载">批量附件下载</Button>
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|