diff --git a/src/api/quality/knowledgeDocument/index.ts b/src/api/quality/knowledgeDocument/index.ts new file mode 100644 index 0000000..d704bdc --- /dev/null +++ b/src/api/quality/knowledgeDocument/index.ts @@ -0,0 +1,79 @@ +import request from '@/utils/request'; +import { AxiosPromise } from 'axios'; +import { KnowledgeDocumentVO, KnowledgeDocumentForm, KnowledgeDocumentQuery } from '@/api/quality/knowledgeDocument/types'; + +/** + * 查询质量知识库列表 + * @param query + * @returns {*} + */ + +export const listKnowledgeDocument = (query?: KnowledgeDocumentQuery): AxiosPromise => { + return request({ + url: '/quality/knowledgeDocument/list', + method: 'get', + params: query + }); +}; + +/** + * 查询质量知识库详细 + * @param id + */ +export const getKnowledgeDocument = (id: string | number): AxiosPromise => { + return request({ + url: '/quality/knowledgeDocument/' + id, + method: 'get' + }); +}; + +/** + * 新增质量知识库 + * @param data + */ +export const addKnowledgeDocument = (data: KnowledgeDocumentForm) => { + return request({ + url: '/quality/knowledgeDocument', + method: 'post', + data: data + }); +}; + +/** + * 修改质量知识库 + * @param data + */ +export const updateKnowledgeDocument = (data: KnowledgeDocumentForm) => { + return request({ + url: '/quality/knowledgeDocument', + method: 'put', + data: data + }); +}; + +/** + * 删除质量知识库 + * @param id + */ +export const delKnowledgeDocument = (id: string | number | Array) => { + return request({ + url: '/quality/knowledgeDocument/' + id, + method: 'delete' + }); +}; + +/** + * 查询质量知识库文件树列表 + * @param id + */ +export const treeStructureData = (projectId: string | number): AxiosPromise => { + return request({ + url: '/quality/knowledgeDocument/folder/tree/list', + method: 'get', + params: { projectId } + }); +}; + +export const uniFolderDownload = (data: any): AxiosPromise => { + return request({}); +}; diff --git a/src/api/quality/knowledgeDocument/types.ts b/src/api/quality/knowledgeDocument/types.ts new file mode 100644 index 0000000..4e13b30 --- /dev/null +++ b/src/api/quality/knowledgeDocument/types.ts @@ -0,0 +1,180 @@ +export interface KnowledgeDocumentVO { + /** + * 主键id + */ + id: string | number; + + /** + * 项目id + */ + projectId: string | number; + + /** + * 父级(0代表顶级) + */ + pid: string | number; + + /** + * 文件名称 + */ + fileName: string; + + /** + * 文件路径 + */ + filePath: string; + + /** + * 文件访问路径 + */ + fileUrl: string; + + /** + * 文件类型(1文件夹 2文件 3图片) + */ + fileType: string; + + /** + * 文件后缀 + */ + fileSuffix: string; + + /** + * 状态(0正常 1删除) + */ + fileStatus: string; + + /** + * 原文件名 + */ + originalName: string; + + /** + * 备注 + */ + remark: string; + + /** + * 创建时间 + */ + createTime: string; + + /** + * 子对象 + */ + children: KnowledgeDocumentVO[]; +} + +export interface KnowledgeDocumentForm extends BaseEntity { + /** + * 主键id + */ + id?: string | number; + + /** + * 项目id + */ + projectId?: string | number; + + /** + * 父级(0代表顶级) + */ + pid?: string | number; + + /** + * 文件名称 + */ + fileName?: string; + + /** + * 文件路径 + */ + filePath?: string; + + /** + * 文件访问路径 + */ + fileUrl?: string; + + /** + * 文件类型(1文件夹 2文件 3图片) + */ + fileType?: string; + + /** + * 文件后缀 + */ + fileSuffix?: string; + + /** + * 状态(0正常 1删除) + */ + fileStatus?: string; + + /** + * 原文件名 + */ + originalName?: string; + + /** + * 备注 + */ + remark?: string; + +} + +export interface KnowledgeDocumentQuery { + + /** + * 项目id + */ + projectId?: string | number; + + /** + * 父级(0代表顶级) + */ + pid?: string | number; + + /** + * 文件名称 + */ + fileName?: string; + + /** + * 文件路径 + */ + filePath?: string; + + /** + * 文件访问路径 + */ + fileUrl?: string; + + /** + * 文件类型(1文件夹 2文件 3图片) + */ + fileType?: string; + + /** + * 文件后缀 + */ + fileSuffix?: string; + + /** + * 状态(0正常 1删除) + */ + fileStatus?: string; + + /** + * 原文件名 + */ + originalName?: string; + + /** + * 日期范围参数 + */ + params?: any; +} + + + diff --git a/src/api/safety/knowledgeDocument/index.ts b/src/api/safety/knowledgeDocument/index.ts new file mode 100644 index 0000000..928b3ac --- /dev/null +++ b/src/api/safety/knowledgeDocument/index.ts @@ -0,0 +1,101 @@ +import request from '@/utils/request'; +import { AxiosPromise } from 'axios'; +import { + KnowledgeDocumentVO, + KnowledgeDocumentForm, + KnowledgeDocumentQuery, + KnowledgeDocumentPutFileNameQuery +} from '@/api/safety/knowledgeDocument/types'; + +/** + * 查询安全知识库列表 + * @param query + * @returns {*} + */ + +export const listKnowledgeDocument = (query?: KnowledgeDocumentQuery): AxiosPromise => { + return request({ + url: '/safety/knowledgeDocument/file/list', + method: 'get', + params: query + }); +}; + +/** + * 查询安全知识库详细 + * @param id + */ +export const getKnowledgeDocument = (id: string | number): AxiosPromise => { + return request({ + url: '/safety/knowledgeDocument/' + id, + method: 'get' + }); +}; + +/** + * 新增安全知识库 + * @param data + */ +export const addKnowledgeDocument = (data: { file: string }, query: { projectId: string; pid: string }) => { + return request({ + url: '/safety/knowledgeDocument/file', + method: 'post', + data: data, + params: query + }); +}; + +/** + * 修改安全知识库 + * @param data + */ +export const updateKnowledgeDocument = (data: KnowledgeDocumentForm) => { + return request({ + url: '/safety/knowledgeDocument', + method: 'put', + data: data + }); +}; + +/** + * 删除安全知识库 + * @param id + */ +export const delKnowledgeDocument = (id: string | number | Array) => { + return request({ + url: '/safety/knowledgeDocument/file/' + id, + method: 'delete' + }); +}; + +/** + * 查询安全知识库文件树列表 + * @param id + */ +export const treeStructureData = (projectId: string | number): AxiosPromise => { + return request({ + url: '/safety/knowledgeDocument/folder/tree/list', + method: 'get', + params: { projectId } + }); +}; + +/** + * 修改安全知识库 + * @param data + */ +export const documentDataEdit = (data: KnowledgeDocumentPutFileNameQuery) => { + return request({ + url: '/safety/knowledgeDocument/file', + method: 'put', + data: data + }); +}; + +export const uniFolderDownload = (data: any): AxiosPromise => { + return request({}); +}; + +export const getProfileDetail = (data: any): AxiosPromise => { + return request({}); +}; diff --git a/src/api/safety/knowledgeDocument/types.ts b/src/api/safety/knowledgeDocument/types.ts new file mode 100644 index 0000000..f8921b7 --- /dev/null +++ b/src/api/safety/knowledgeDocument/types.ts @@ -0,0 +1,175 @@ +export interface KnowledgeDocumentVO { + /** + * 主键id + */ + id: string | number; + + /** + * 项目id + */ + projectId: string | number; + + /** + * 父级(0代表顶级) + */ + pid: string | number; + + /** + * 文件名称 + */ + fileName: string; + + /** + * 文件路径 + */ + filePath: string; + + /** + * 文件访问路径 + */ + fileUrl: string; + + /** + * 文件类型(1文件夹 2文件 3图片) + */ + fileType: string; + + /** + * 文件后缀 + */ + fileSuffix: string; + + /** + * 状态(0正常 1删除) + */ + fileStatus: string; + + /** + * 原文件名 + */ + originalName: string; + + /** + * 备注 + */ + remark: string; + + /** + * 子对象 + */ + children: KnowledgeDocumentVO[]; +} + +export interface KnowledgeDocumentForm extends BaseEntity { + /** + * 主键id + */ + id?: string | number; + + /** + * 项目id + */ + projectId?: string | number; + + /** + * 父级(0代表顶级) + */ + pid?: string | number; + + /** + * 文件名称 + */ + fileName?: string; + + /** + * 文件路径 + */ + filePath?: string; + + /** + * 文件访问路径 + */ + fileUrl?: string; + + /** + * 文件类型(1文件夹 2文件 3图片) + */ + fileType?: string; + + /** + * 文件后缀 + */ + fileSuffix?: string; + + /** + * 状态(0正常 1删除) + */ + fileStatus?: string; + + /** + * 原文件名 + */ + originalName?: string; + + /** + * 备注 + */ + remark?: string; +} + +export interface KnowledgeDocumentPutFileNameQuery { + id: string | number; + fileName: string; +} + +export interface KnowledgeDocumentQuery { + /** + * 项目id + */ + projectId?: string | number; + + /** + * 父级(0代表顶级) + */ + pid?: string | number; + + /** + * 文件名称 + */ + fileName?: string; + + /** + * 文件路径 + */ + filePath?: string; + + /** + * 文件访问路径 + */ + fileUrl?: string; + + /** + * 文件类型(1文件夹 2文件 3图片) + */ + fileType?: string; + + /** + * 文件后缀 + */ + fileSuffix?: string; + + /** + * 状态(0正常 1删除) + */ + fileStatus?: string; + + /** + * 原文件名 + */ + originalName?: string; + + /** + * 日期范围参数 + */ + params?: any; +} diff --git a/src/components/FileUpload/index.vue b/src/components/FileUpload/index.vue index 382bc24..2248df7 100644 --- a/src/components/FileUpload/index.vue +++ b/src/components/FileUpload/index.vue @@ -3,7 +3,7 @@ void>, + default: undefined + }, + params: { + type: Object, + default: () => ({}) + } }); const { proxy } = getCurrentInstance() as ComponentInternalInstance; @@ -115,6 +123,10 @@ const baseUrl = import.meta.env.VITE_APP_BASE_API; const uploadFileUrl = ref(baseUrl + props.uploadUrl); // 上传文件服务器地址 const headers = ref(globalHeaders()); +const realUploadUrl = computed(() => { + const search = new URLSearchParams(props.params).toString(); + return search ? `${baseUrl}${props.uploadUrl}?${search}` : `${baseUrl}${props.uploadUrl}`; +}); const fileList = ref([]); const showTip = computed(() => props.isShowTip && (props.fileType || props.fileSize)); @@ -256,6 +268,7 @@ const uploadedSuccessfully = () => { emit('update:modelValue', listToString(fileList.value)); proxy?.$modal.closeLoading(); + props.onUploadSuccess?.(fileList.value); } }; diff --git a/src/plugins/download.ts b/src/plugins/download.ts index ef66b3a..afa827b 100644 --- a/src/plugins/download.ts +++ b/src/plugins/download.ts @@ -61,5 +61,24 @@ export default { const rspObj = JSON.parse(resText); const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default']; ElMessage.error(errMsg); + }, + async direct(fileUrl: string, filename?: string) { + downloadLoadingInstance = ElLoading.service({ text: '正在下载文件,请稍候...', background: 'rgba(0, 0, 0, 0.7)' }); + try { + const res = await axios({ + method: 'get', + url: fileUrl, + responseType: 'blob', + headers: globalHeaders() // 可根据是否跨域决定是否保留 + }); + const blob = new Blob([res.data], { type: 'application/octet-stream' }); + const name = filename || decodeURIComponent(fileUrl.split('/').pop()!); + FileSaver.saveAs(blob, name); + } catch (error) { + console.error(error); + ElMessage.error('下载文件失败,请检查链接或联系管理员'); + } finally { + downloadLoadingInstance.close(); + } } }; diff --git a/src/views/quality/knowledgeDocument/index.vue b/src/views/quality/knowledgeDocument/index.vue new file mode 100644 index 0000000..138647e --- /dev/null +++ b/src/views/quality/knowledgeDocument/index.vue @@ -0,0 +1,726 @@ + + + + + diff --git a/src/views/safety/knowledgeDocument/component/recyclingStation.vue b/src/views/safety/knowledgeDocument/component/recyclingStation.vue new file mode 100644 index 0000000..e69de29 diff --git a/src/views/safety/knowledgeDocument/index.vue b/src/views/safety/knowledgeDocument/index.vue new file mode 100644 index 0000000..07e4c0b --- /dev/null +++ b/src/views/safety/knowledgeDocument/index.vue @@ -0,0 +1,735 @@ + + + + +