|
@ -9,7 +9,8 @@ import { RouteTable } from '$utils' |
|
|
import { Tabs, Form, Input, Space, Button, Table, Breadcrumb, message, Popconfirm } from 'antd'; |
|
|
import { Tabs, Form, Input, Space, Button, Table, Breadcrumb, message, Popconfirm } from 'antd'; |
|
|
const { Search } = Input; |
|
|
const { Search } = Input; |
|
|
import { CreditCardFilled, FilePdfOutlined } from '@ant-design/icons'; |
|
|
import { CreditCardFilled, FilePdfOutlined } from '@ant-design/icons'; |
|
|
import { agent } from 'superagent'; |
|
|
import JSZip from 'jszip' |
|
|
|
|
|
import { saveAs } from 'file-saver' |
|
|
|
|
|
|
|
|
let clicks = 0 |
|
|
let clicks = 0 |
|
|
function Approve ({ loading, clientHeight, actions, dispatch, }) { |
|
|
function Approve ({ loading, clientHeight, actions, dispatch, }) { |
|
@ -50,6 +51,53 @@ function Approve ({ 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 }) { |
|
|
|
|
|
let name = [] |
|
|
|
|
|
fileUrl.forEach(d => { |
|
|
|
|
|
if (name.filter(f => d.name == f.name)?.length) { |
|
|
|
|
|
name.filter(f => d.name == f.name)?.forEach(s => { |
|
|
|
|
|
s.number = s.number + 1 |
|
|
|
|
|
d.name = d.name.slice(0, d.name.lastIndexOf(".")) + '(' + s.number + ')' + d.name.slice(d.name.lastIndexOf("."), d.name.length) |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
name.push({ name: d.name, number: 0 }) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
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, `标准文档.zip`) |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return <> |
|
|
return <> |
|
|
|
|
|
|
|
@ -77,24 +125,56 @@ function Approve ({ loading, clientHeight, actions, dispatch, }) { |
|
|
<Button type="primary" onClick={() => { |
|
|
<Button type="primary" onClick={() => { |
|
|
setFileModal(true) |
|
|
setFileModal(true) |
|
|
}}>上传</Button> |
|
|
}}>上传</Button> |
|
|
<Button type="primary" onClick={() => { |
|
|
<Button type="primary" onClick={async () => { |
|
|
// let fileUrlList = fileData.filter(d => fileId.current.includes(d.id))?.map(s => s.path)
|
|
|
let fileUrl = [] |
|
|
|
|
|
if (fileId.current.length > 0) { |
|
|
// console.log(fileUrlList);
|
|
|
if (folderId.current.length > 0) { |
|
|
|
|
|
await dispatch(dataQuality.fetchFiles({ folderId: folderId.current })).then(res => { |
|
|
|
|
|
if (res.success) { |
|
|
|
|
|
res.payload.data?.map(s => fileUrl.push(s)) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
fileData?.map(d => { |
|
|
|
|
|
if (fileId.current.includes(d.id)) { |
|
|
|
|
|
fileUrl.push({ url: d.path, name: d.docName }) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
console.log(fileUrl); |
|
|
|
|
|
packBulk({ fileUrl: fileUrl }) |
|
|
|
|
|
} else { |
|
|
|
|
|
if (folderId.current.length > 0) { |
|
|
|
|
|
await dispatch(dataQuality.fetchFiles({ folderId: folderId.current })).then(res => { |
|
|
|
|
|
if (res.success) { |
|
|
|
|
|
if (res.payload.data?.length > 0) { |
|
|
|
|
|
res.payload.data?.map(s => fileUrl.push(s)) |
|
|
|
|
|
} else { |
|
|
|
|
|
message.warning({ |
|
|
|
|
|
duration: 1, |
|
|
|
|
|
content: '所选文件夹没有文件', |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
message.warning({ |
|
|
|
|
|
duration: 1, |
|
|
|
|
|
content: '未选择文件夹或文件', |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
packBulk({ fileUrl: fileUrl }) |
|
|
|
|
|
} |
|
|
}}>下载</Button> |
|
|
}}>下载</Button> |
|
|
|
|
|
|
|
|
<Popconfirm |
|
|
<Popconfirm |
|
|
title="是否删除文件夹或文件?当有创建的业务规则与标准文档关联时则不允许删除。" |
|
|
title="是否删除文件夹或文件?当有创建的业务规则与标准文档关联时则不允许删除。" |
|
|
onConfirm={() => { |
|
|
onConfirm={() => { |
|
|
console.log(folderId.current, fileId.current); |
|
|
|
|
|
if (folderId.current?.length || fileId.current?.length) { |
|
|
if (folderId.current?.length || fileId.current?.length) { |
|
|
dispatch(dataQuality.postFolderFile({ folderId: folderId.current, fileId: fileId.current })).then(res => { |
|
|
dispatch(dataQuality.postFolderFile({ folderId: folderId.current, fileId: fileId.current })).then(res => { |
|
|
if (res.success) { |
|
|
if (res.success) { |
|
|
resourceData(parent, keywords) |
|
|
resourceData(parent, keywords) |
|
|
setCheckAll(false) |
|
|
setCheckAll(false) |
|
|
console.log(res); |
|
|
|
|
|
res.payload.data?.map(v => { |
|
|
res.payload.data?.map(v => { |
|
|
RouteRequest.delete(RouteTable.cleanUpUploadTrash, { url: v }); |
|
|
RouteRequest.delete(RouteTable.cleanUpUploadTrash, { url: v }); |
|
|
}) |
|
|
}) |
|
@ -153,6 +233,7 @@ function Approve ({ loading, clientHeight, actions, dispatch, }) { |
|
|
setFileIds([]) |
|
|
setFileIds([]) |
|
|
folderId.current = [] |
|
|
folderId.current = [] |
|
|
setFolderIds([]) |
|
|
setFolderIds([]) |
|
|
|
|
|
setCheckAll(false) |
|
|
}}>{s.name}</Breadcrumb.Item> |
|
|
}}>{s.name}</Breadcrumb.Item> |
|
|
) |
|
|
) |
|
|
}) |
|
|
}) |
|
@ -192,8 +273,8 @@ function Approve ({ loading, clientHeight, actions, dispatch, }) { |
|
|
}} > |
|
|
}} > |
|
|
<CreditCardFilled style={{ fontSize: 96, color: 'rgb(238 200 44)', marginRight: 8 }} /> |
|
|
<CreditCardFilled style={{ fontSize: 96, color: 'rgb(238 200 44)', marginRight: 8 }} /> |
|
|
<div style={{ width: 200, display: 'flex', flexDirection: 'column', justifyContent: 'space-evenly' }}> |
|
|
<div style={{ width: 200, display: 'flex', flexDirection: 'column', justifyContent: 'space-evenly' }}> |
|
|
<div style={{ |
|
|
<div title={v.name} style={{ |
|
|
width: 100, whiteSpace: 'nowrap', overflow: 'hidden', fontWeight: 400, |
|
|
width: 200, whiteSpace: 'nowrap', overflow: 'hidden', fontWeight: 400, |
|
|
textOverflow: 'ellipsis', fontSize: 18, color: 'rgb(51 161 34)' |
|
|
textOverflow: 'ellipsis', fontSize: 18, color: 'rgb(51 161 34)' |
|
|
}}> |
|
|
}}> |
|
|
{v.name} |
|
|
{v.name} |
|
@ -218,13 +299,15 @@ function Approve ({ loading, clientHeight, actions, dispatch, }) { |
|
|
}}> |
|
|
}}> |
|
|
<FilePdfOutlined style={{ fontSize: 96, color: 'rgb(33 211 180)', marginRight: 8 }} /> |
|
|
<FilePdfOutlined style={{ fontSize: 96, color: 'rgb(33 211 180)', marginRight: 8 }} /> |
|
|
<div style={{ width: 200, display: 'flex', flexDirection: 'column', justifyContent: 'space-evenly' }}> |
|
|
<div style={{ width: 200, display: 'flex', flexDirection: 'column', justifyContent: 'space-evenly' }}> |
|
|
<div style={{ |
|
|
<div title={v.docName} style={{ |
|
|
width: 100, whiteSpace: 'nowrap', overflow: 'hidden', fontWeight: 400, |
|
|
width: 200, whiteSpace: 'nowrap', overflow: 'hidden', fontWeight: 400, |
|
|
textOverflow: 'ellipsis', fontSize: 18, color: 'rgb(51 161 34)' |
|
|
textOverflow: 'ellipsis', fontSize: 18, color: 'rgb(51 161 34)' |
|
|
}}> |
|
|
}}> |
|
|
{v.docName} |
|
|
{v.docName} |
|
|
</div> |
|
|
</div> |
|
|
<div>标签:{v.tags || '--'}</div> |
|
|
<div title={v.tags} style={{ |
|
|
|
|
|
width: 200, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' |
|
|
|
|
|
}}>标签:{v.tags || '--'}</div> |
|
|
<div>标准类型:{v.standardType}</div> |
|
|
<div>标准类型:{v.standardType}</div> |
|
|
<div>创建时间:{v.createAt && moment(v.createAt).format('YYYY-MM-DD HH:mm:ss') || '--'}</div> |
|
|
<div>创建时间:{v.createAt && moment(v.createAt).format('YYYY-MM-DD HH:mm:ss') || '--'}</div> |
|
|
</div> |
|
|
</div> |
|
|