| | |
| | | |
| | | import { requestClient } from '#/api/request'; |
| | | |
| | | import { isPdMockEnabled } from '../mock/enabled'; |
| | | import { pdMockStore } from '../mock/store'; |
| | | |
| | | export namespace MesPdDocumentApi { |
| | | /** 设计资料 */ |
| | | export interface Document { |
| | | id?: number; |
| | | /** 设计项目ID */ |
| | | projectId?: number; |
| | | documentType?: number; |
| | | name?: string; |
| | | version?: string; |
| | | fileUrl?: string; |
| | | /** 资料类型(字典 mes_pd_document_type) */ |
| | | documentType?: string; |
| | | /** 资料名称 */ |
| | | documentName?: string; |
| | | /** 版本 */ |
| | | documentVersion?: string; |
| | | /** 文件名 */ |
| | | fileName?: string; |
| | | fileSize?: number; |
| | | uploaderId?: number; |
| | | uploaderName?: string; |
| | | /** 上传人(用户ID) */ |
| | | uploadUserId?: number; |
| | | /** 上传人名称 */ |
| | | uploadUserNickname?: string; |
| | | /** 上传时间 */ |
| | | uploadTime?: number; |
| | | /** 文件URL */ |
| | | fileUrl?: string; |
| | | /** 备注 */ |
| | | remark?: string; |
| | | /** 创建时间 */ |
| | | createTime?: number; |
| | | } |
| | | |
| | | export interface PageParams extends PageParam { |
| | | projectId: number; |
| | | documentType?: number; |
| | | name?: string; |
| | | version?: string; |
| | | documentType?: string; |
| | | documentName?: string; |
| | | documentVersion?: string; |
| | | } |
| | | } |
| | | |
| | | export function getPdDocumentPage(params: MesPdDocumentApi.PageParams) { |
| | | if (isPdMockEnabled()) { |
| | | return pdMockStore.getDocumentPage(params); |
| | | } |
| | | return requestClient.get<PageResult<MesPdDocumentApi.Document>>( |
| | | '/mes/pd/document/page', |
| | | { params }, |
| | |
| | | } |
| | | |
| | | export function getPdDocument(id: number) { |
| | | if (isPdMockEnabled()) { |
| | | return pdMockStore.getDocument(id); |
| | | } |
| | | return requestClient.get<MesPdDocumentApi.Document>( |
| | | `/mes/pd/document/get?id=${id}`, |
| | | ); |
| | | } |
| | | |
| | | export function createPdDocument(data: MesPdDocumentApi.Document) { |
| | | if (isPdMockEnabled()) { |
| | | return pdMockStore.createDocument(data); |
| | | } |
| | | return requestClient.post<number>('/mes/pd/document/create', data); |
| | | } |
| | | |
| | | export function updatePdDocument(data: MesPdDocumentApi.Document) { |
| | | if (isPdMockEnabled()) { |
| | | return pdMockStore.updateDocument(data); |
| | | } |
| | | return requestClient.put('/mes/pd/document/update', data); |
| | | } |
| | | |
| | | export function deletePdDocument(id: number) { |
| | | if (isPdMockEnabled()) { |
| | | return pdMockStore.deleteDocument(id); |
| | | } |
| | | return requestClient.delete(`/mes/pd/document/delete?id=${id}`); |
| | | } |
| | | |
| | | export function exportPdDocument(params: MesPdDocumentApi.PageParams) { |
| | | return requestClient.download('/mes/pd/document/export-excel', { params }); |
| | | } |