|
|
@ -5,13 +5,12 @@ import { RouteRequest } from '@peace/utils'; |
|
|
|
import { RouteTable } from '$utils' |
|
|
|
import SimpleBar from 'simplebar-react'; |
|
|
|
import FileModal from '../components/fileModal'; |
|
|
|
import { Tabs, Form, Input, Space, Button, Table, Checkbox, message, Pagination } from 'antd'; |
|
|
|
import { Input, Space, Button, message, Pagination } from 'antd'; |
|
|
|
const { Search } = Input; |
|
|
|
import { CreditCardFilled, FilePdfOutlined } from '@ant-design/icons'; |
|
|
|
import { agent } from 'superagent'; |
|
|
|
const CheckboxGroup = Checkbox.Group; |
|
|
|
import { FilePdfOutlined } from '@ant-design/icons'; |
|
|
|
|
|
|
|
import JSZip from 'jszip' |
|
|
|
import { savAes } from 'file-saver' |
|
|
|
import { saveAs } from 'file-saver' |
|
|
|
|
|
|
|
function SpecificationLibrary ({ loading, clientHeight, actions, dispatch, }) { |
|
|
|
|
|
|
@ -40,7 +39,44 @@ function SpecificationLibrary ({ loading, clientHeight, actions, dispatch, }) { |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const getFileBlob = (url) => { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
let request = new XMLHttpRequest() |
|
|
|
request.responseType = "blob" |
|
|
|
request.open("GET", url, true) |
|
|
|
request.onload = (res) => { |
|
|
|
if (res.target.status == 200) { |
|
|
|
resolve(res.target.response) |
|
|
|
} else { |
|
|
|
reject(res) |
|
|
|
} |
|
|
|
} |
|
|
|
request.send() |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function packBulk ({ fileUrl, folderId }) { |
|
|
|
const zip = new JSZip() |
|
|
|
let result = [] |
|
|
|
fileUrl.map(d => { |
|
|
|
let url = d?.url?.replace(/\\/g, '/') |
|
|
|
let promise = getFileBlob(url).then((res) => { |
|
|
|
zip.file(d.name, res, { binary: true }) |
|
|
|
}) |
|
|
|
result.push(promise) |
|
|
|
}) |
|
|
|
Promise.all(result).then(() => { |
|
|
|
zip.generateAsync({ type: "blob" }).then((res) => { |
|
|
|
saveAs(res, `${111}.zip`) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return <> |
|
|
|
|
|
|
@ -61,11 +97,17 @@ function SpecificationLibrary ({ loading, clientHeight, actions, dispatch, }) { |
|
|
|
setFileModal(true) |
|
|
|
}}>上传</Button> |
|
|
|
<Button type="primary" onClick={() => { |
|
|
|
// let fileUrlList = fileData?.data?.filter(d => fileId.current.includes(d.id))?.map(s => s.path)
|
|
|
|
|
|
|
|
// RouteRequest.post(RouteTable.packBulk, { fileUrl: fileUrlList });
|
|
|
|
|
|
|
|
|
|
|
|
if (fileId.current.length > 0) { |
|
|
|
let fileUrlList = fileData?.data?.filter(d => fileId.current.includes(d.id))?.map(s => ({ |
|
|
|
url: s.path, name: s.fileName |
|
|
|
})) || [] |
|
|
|
packBulk({ fileUrl: fileUrlList }) |
|
|
|
} else { |
|
|
|
message.warning({ |
|
|
|
duration: 1, |
|
|
|
content: '未选择文件', |
|
|
|
}); |
|
|
|
} |
|
|
|
}}>下载</Button> |
|
|
|
<Button type="primary" onClick={() => { |
|
|
|
if (fileId.current?.length) { |
|
|
@ -80,7 +122,7 @@ function SpecificationLibrary ({ loading, clientHeight, actions, dispatch, }) { |
|
|
|
url.map(d => { |
|
|
|
RouteRequest.delete(RouteTable.cleanUpUploadTrash, { url: d }); |
|
|
|
}) |
|
|
|
resourceData({ page: 0, limit: 20 }) |
|
|
|
resourceData({ page: 0, limit: 20, keyword: keyword }) |
|
|
|
fileId.current = [] |
|
|
|
setFileIds([]) |
|
|
|
setFileIds(false) |
|
|
|