diff --git a/index.html b/index.html index d1d62af..4e225e1 100644 --- a/index.html +++ b/index.html @@ -209,6 +209,8 @@
正在加载系统资源,请耐心等待
+ diff --git a/package.json b/package.json index d989a01..4b801c2 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "element-plus": "2.8.8", "esbuild": "^0.25.0", "ezuikit-js": "^8.1.10", - "file-saver": "2.0.5", + "file-saver": "^2.0.5", "fuse.js": "7.0.0", "gcoord": "^1.0.7", "geotiff": "^2.1.3", diff --git a/src/api/quality/knowledgeDocument/index.ts b/src/api/quality/knowledgeDocument/index.ts index d704bdc..a1fb2ad 100644 --- a/src/api/quality/knowledgeDocument/index.ts +++ b/src/api/quality/knowledgeDocument/index.ts @@ -1,6 +1,7 @@ import request from '@/utils/request'; import { AxiosPromise } from 'axios'; import { KnowledgeDocumentVO, KnowledgeDocumentForm, KnowledgeDocumentQuery } from '@/api/quality/knowledgeDocument/types'; +import { KnowledgeDocumentPutFileNameQuery } from '@/api/safety/knowledgeDocument/types'; /** * 查询质量知识库列表 @@ -10,7 +11,7 @@ import { KnowledgeDocumentVO, KnowledgeDocumentForm, KnowledgeDocumentQuery } fr export const listKnowledgeDocument = (query?: KnowledgeDocumentQuery): AxiosPromise => { return request({ - url: '/quality/knowledgeDocument/list', + url: '/quality/knowledgeDocument/file/page', method: 'get', params: query }); @@ -31,9 +32,9 @@ export const getKnowledgeDocument = (id: string | number): AxiosPromise { +export const addKnowledgeDocument = (data: { file: string }, query: { projectId: string; pid: string }) => { return request({ - url: '/quality/knowledgeDocument', + url: '/quality/knowledgeDocument/file', method: 'post', data: data }); @@ -57,7 +58,7 @@ export const updateKnowledgeDocument = (data: KnowledgeDocumentForm) => { */ export const delKnowledgeDocument = (id: string | number | Array) => { return request({ - url: '/quality/knowledgeDocument/' + id, + url: '/quality/knowledgeDocument/file/' + id, method: 'delete' }); }; @@ -74,6 +75,57 @@ export const treeStructureData = (projectId: string | number): AxiosPromise => { +/** + * 修改安全知识库 + * @param data + */ +export const documentDataEdit = (data: KnowledgeDocumentPutFileNameQuery) => { + return request({ + url: '/quality/knowledgeDocument/file', + method: 'put', + data: data + }); +}; + +//查询质量知识库文件下载列表 +export const getUniFolderDownloadList = (id: string): AxiosPromise => { + return request({ + url: '/quality/knowledgeDocument/file/list/' + id, + method: 'get' + }); +}; + +//查询安全知识库回收站文件列表 +export const documentDataAllList = (query: any) => { + return request({ + url: '/quality/knowledgeDocument/recycleBin/list', + method: 'get', + params: query + }); +}; + +/** + * 根据主键id批量恢复 + * @param data + */ +export const dataRecyclingStation = (ids: string) => { + return request({ + url: '/quality/knowledgeDocument/recovery/' + ids, + method: 'post' + }); +}; + +/** + * 根据主键id批量删除 + * @param data + */ +export const templateRecycleBin = (ids: string) => { + return request({ + url: '/quality/knowledgeDocument/file/recycleBin/' + ids, + method: 'delete' + }); +}; + +export const getProfileDetail = (data: any): AxiosPromise => { return request({}); }; diff --git a/src/api/safety/knowledgeDocument/index.ts b/src/api/safety/knowledgeDocument/index.ts index 928b3ac..9bceb8b 100644 --- a/src/api/safety/knowledgeDocument/index.ts +++ b/src/api/safety/knowledgeDocument/index.ts @@ -13,9 +13,9 @@ import { * @returns {*} */ -export const listKnowledgeDocument = (query?: KnowledgeDocumentQuery): AxiosPromise => { +export const listKnowledgeDocument = (query?: any): AxiosPromise => { return request({ - url: '/safety/knowledgeDocument/file/list', + url: '/safety/knowledgeDocument/file/page', method: 'get', params: query }); @@ -92,8 +92,43 @@ export const documentDataEdit = (data: KnowledgeDocumentPutFileNameQuery) => { }); }; -export const uniFolderDownload = (data: any): AxiosPromise => { - return request({}); +//查询质量知识库文件下载列表 +export const getUniFolderDownloadList = (id: string): AxiosPromise => { + return request({ + url: '/safety/knowledgeDocument/file/list/' + id, + method: 'get' + }); +}; + +//查询安全知识库回收站文件列表 +export const documentDataAllList = (query: any) => { + return request({ + url: '/safety/knowledgeDocument/recycleBin/list', + method: 'get', + params: query + }); +}; + +/** + * 根据主键id批量恢复 + * @param data + */ +export const dataRecyclingStation = (ids: string) => { + return request({ + url: '/safety/knowledgeDocument/recovery/' + ids, + method: 'post' + }); +}; + +/** + * 根据主键id批量删除 + * @param data + */ +export const templateRecycleBin = (ids: string) => { + return request({ + url: '/safety/knowledgeDocument/file/recycleBin/' + ids, + method: 'delete' + }); }; export const getProfileDetail = (data: any): AxiosPromise => { diff --git a/src/assets/styles/index.scss b/src/assets/styles/index.scss index bdf9b03..7d0cfa9 100644 --- a/src/assets/styles/index.scss +++ b/src/assets/styles/index.scss @@ -163,7 +163,7 @@ aside { } .pagination-container { - margin-top: 30px; + margin-top: 15px; } .text-center { diff --git a/src/components/FileUpload/index.vue b/src/components/FileUpload/index.vue index 2248df7..e8af99e 100644 --- a/src/components/FileUpload/index.vue +++ b/src/components/FileUpload/index.vue @@ -67,7 +67,7 @@ - + @@ -147,7 +147,7 @@ watch( if (Array.isArray(val)) { list = val; } else { - const res = await listByIds(val); + const res = await listByIds(val as any); list = res.data.map((oss) => { return { name: oss.originalName, @@ -211,7 +211,11 @@ const handleUploadError = () => { }; // 上传成功回调 -const handleUploadSuccess = (res: any, file: UploadFile) => { +interface UploadFileWithOssId extends UploadFile { + ossId?: string; +} + +const handleUploadSuccess = (res: any, file: UploadFileWithOssId) => { if (res.code === 200) { if (res.data) { uploadList.value.push({ diff --git a/src/components/Pagination/index.vue b/src/components/Pagination/index.vue index 9f96001..ade17e0 100644 --- a/src/components/Pagination/index.vue +++ b/src/components/Pagination/index.vue @@ -30,7 +30,7 @@ const props = defineProps({ page: propTypes.number.def(1), limit: propTypes.number.def(20), pageSizes: { - type: Array, + type: Array, default: () => [10, 20, 30, 50] }, // 移动端页码按钮的数量端默认值5 diff --git a/src/plugins/download.ts b/src/plugins/download.ts index afa827b..036b19b 100644 --- a/src/plugins/download.ts +++ b/src/plugins/download.ts @@ -1,5 +1,6 @@ import axios from 'axios'; import FileSaver from 'file-saver'; +import JSZip from 'jszip'; import errorCode from '@/utils/errorCode'; import { blobValidate } from '@/utils/ruoyi'; import { LoadingInstance } from 'element-plus/es/components/loading/src/loading'; @@ -80,5 +81,49 @@ export default { } finally { downloadLoadingInstance.close(); } + }, + /** + * 下载多个文件并打包成 zip + * @param files 文件信息列表,包含 { url, name } + * @param zipName 压缩包名称 + */ + async downloadFilesAsZip( + files: any[], + options: { + urlKey?: string; // 默认为 'url' + nameKey?: string; // 默认为 'name' + zipName?: string; // 默认为 '打包下载.zip' + } = {} + ) { + const { urlKey = 'url', nameKey = 'name', zipName = '打包下载.zip' } = options; + + if (!files.length) { + ElMessage.warning('没有可下载的文件'); + return; + } + + const zip = new JSZip(); + const folder = zip.folder('files'); + const loading = ElLoading.service({ text: '正在打包文件,请稍候...', background: 'rgba(0,0,0,0.7)' }); + + try { + for (const file of files) { + const fileUrl = file[urlKey]; + const fileName = file[nameKey] || '未命名文件'; + + if (!fileUrl) continue; + + const res = await axios.get(fileUrl, { responseType: 'blob' }); + folder?.file(fileName, res.data); + } + + const content = await zip.generateAsync({ type: 'blob' }); + FileSaver.saveAs(content, zipName); + } catch (error) { + console.error(error); + ElMessage.error('打包下载失败,请联系管理员'); + } finally { + loading.close(); + } } }; diff --git a/src/views/quality/knowledgeDocument/component/bookFile.vue b/src/views/quality/knowledgeDocument/component/bookFile.vue new file mode 100644 index 0000000..008de99 --- /dev/null +++ b/src/views/quality/knowledgeDocument/component/bookFile.vue @@ -0,0 +1,154 @@ + + + + + diff --git a/src/views/quality/knowledgeDocument/component/recyclingStation.vue b/src/views/quality/knowledgeDocument/component/recyclingStation.vue new file mode 100644 index 0000000..d32ba7d --- /dev/null +++ b/src/views/quality/knowledgeDocument/component/recyclingStation.vue @@ -0,0 +1,161 @@ + + + + + diff --git a/src/views/quality/knowledgeDocument/index.vue b/src/views/quality/knowledgeDocument/index.vue index 138647e..f9d6062 100644 --- a/src/views/quality/knowledgeDocument/index.vue +++ b/src/views/quality/knowledgeDocument/index.vue @@ -1,153 +1,138 @@ @@ -670,7 +572,6 @@ onMounted(() => { padding: 4px; border-bottom: 1px solid #f1f1f1; .box_btn { - width: 360px; margin: 0 10px 0 20px; position: relative; > span { diff --git a/src/views/safety/knowledgeDocument/component/bookFile.vue b/src/views/safety/knowledgeDocument/component/bookFile.vue new file mode 100644 index 0000000..bf1f99d --- /dev/null +++ b/src/views/safety/knowledgeDocument/component/bookFile.vue @@ -0,0 +1,154 @@ + + + + + diff --git a/src/views/safety/knowledgeDocument/component/documentsDeails.vue b/src/views/safety/knowledgeDocument/component/documentsDeails.vue new file mode 100644 index 0000000..9a195fa --- /dev/null +++ b/src/views/safety/knowledgeDocument/component/documentsDeails.vue @@ -0,0 +1,194 @@ + + + diff --git a/src/views/safety/knowledgeDocument/component/documentsEdit.vue b/src/views/safety/knowledgeDocument/component/documentsEdit.vue new file mode 100644 index 0000000..c41cd39 --- /dev/null +++ b/src/views/safety/knowledgeDocument/component/documentsEdit.vue @@ -0,0 +1,198 @@ + + + diff --git a/src/views/safety/knowledgeDocument/component/recyclingStation.vue b/src/views/safety/knowledgeDocument/component/recyclingStation.vue index e69de29..2c62ac4 100644 --- a/src/views/safety/knowledgeDocument/component/recyclingStation.vue +++ b/src/views/safety/knowledgeDocument/component/recyclingStation.vue @@ -0,0 +1,161 @@ + + + + + diff --git a/src/views/safety/knowledgeDocument/index.vue b/src/views/safety/knowledgeDocument/index.vue index 07e4c0b..bb76ef6 100644 --- a/src/views/safety/knowledgeDocument/index.vue +++ b/src/views/safety/knowledgeDocument/index.vue @@ -1,153 +1,153 @@ @@ -679,7 +558,6 @@ onMounted(() => { padding: 4px; border-bottom: 1px solid #f1f1f1; .box_btn { - width: 360px; margin: 0 10px 0 20px; position: relative; > span {