diff --git a/src/api/purchase/purchasingrequisition.ts b/src/api/purchase/purchasingrequisition.ts index 90c41a2..3fa6c95 100644 --- a/src/api/purchase/purchasingrequisition.ts +++ b/src/api/purchase/purchasingrequisition.ts @@ -86,7 +86,7 @@ export function assignAgent(applyId: number | string, mode: 'random' | 'designat return request({ url: '/purchase/purchasingapply/assign-agent', method: 'post', - data: { id: Number(applyId), mode, agentId: agentId || undefined } + data: { id: String(applyId), mode, agentId: agentId || undefined } }); } @@ -98,7 +98,7 @@ export function sendToAgent(applyId: number | string) { return request({ url: '/purchase/purchasingapply/sendToAgent', method: 'post', - data: { id: Number(applyId) } + data: { id: String(applyId) } }); } @@ -110,7 +110,7 @@ export function revokeAgent(applyId: number | string) { return request({ url: '/purchase/purchasingapply/revokeAgent', method: 'post', - data: { id: Number(applyId) } + data: { id: String(applyId) } }); } @@ -334,3 +334,16 @@ export function getDocList(applyId: number | string) { }); } +/** + * 根据文件ID下载采购附件(返回blob) + * @param fileId 文件ID + */ +export function downloadFileById(fileId: string) { + return request({ + url: '/purchase/purchasingfiles/downloadById', + method: 'get', + params: { fileId }, + responseType: 'blob' + }); +} + diff --git a/src/router/route.ts b/src/router/route.ts index db18310..8c46803 100644 --- a/src/router/route.ts +++ b/src/router/route.ts @@ -107,14 +107,6 @@ export const staticRoutes: Array = [ isAuth: false, // 不需要认证,纯页面展示 }, }, - { - path: '/purchase/purchasingrequisition/implement', - name: 'purchasingrequisition.implement', - component: () => import('/@/views/purchase/purchasingrequisition/implement.vue'), - meta: { - isAuth: false, // 供流程 iframe 嵌入 - }, - }, ...staticRoutesFlow ]; diff --git a/src/views/purchase/purchasingrequisition/add.vue b/src/views/purchase/purchasingrequisition/add.vue index 65660ac..6100480 100644 --- a/src/views/purchase/purchasingrequisition/add.vue +++ b/src/views/purchase/purchasingrequisition/add.vue @@ -1819,7 +1819,7 @@ const handleSubmit = async () => { type: 'purchasingrequisition:submitSuccess' }, '*'); } else { - router.push('/finance/purchasingrequisition'); + router.push('/purchase/purchasingrequisition'); } } catch (err: any) { // 全局拦截器已经显示了错误提示,这里不需要再次显示 @@ -1891,7 +1891,7 @@ const handleTempStore = async () => { type: 'purchasingrequisition:submitSuccess' }, '*'); } else { - router.push('/finance/purchasingrequisition'); + router.push('/purchase/purchasingrequisition'); } } } catch (err: any) { diff --git a/src/views/purchase/purchasingrequisition/agentDoc/AgentDocDialog.vue b/src/views/purchase/purchasingrequisition/agentDoc/AgentDocDialog.vue index 132abe1..f1adec1 100644 --- a/src/views/purchase/purchasingrequisition/agentDoc/AgentDocDialog.vue +++ b/src/views/purchase/purchasingrequisition/agentDoc/AgentDocDialog.vue @@ -93,7 +93,7 @@ import { ref, computed } from 'vue' import { useMessage } from '/@/hooks/message' import { Session } from '/@/utils/storage' -import { getAgentRequirementFiles, getAgentApplyDetail, uploadAgentDoc, reuploadAgentDoc, getDocList } from '/@/api/purchase/purchasingrequisition' +import { getAgentRequirementFiles, getAgentApplyDetail, uploadAgentDoc, reuploadAgentDoc, getDocList, downloadFileById } from '/@/api/purchase/purchasingrequisition' import type { UploadInstance, UploadProps, UploadUserFile } from 'element-plus' const emit = defineEmits(['refresh']) @@ -159,10 +159,24 @@ const loadRequirementFiles = async () => { } } -const handleDownload = (row: any) => { - // TODO: 实现下载功能 - const downloadUrl = `/purchase/purchasingdoc/download/${row.id}` - window.open(downloadUrl, '_blank') +const handleDownload = async (row: any) => { + try { + const res = await downloadFileById(row.id) + // 从响应头获取文件名,或使用原始文件名 + const fileName = row.fileName || row.fileTitle || 'download' + // 创建 blob 并下载 + const blob = new Blob([res]) + const url = window.URL.createObjectURL(blob) + const link = document.createElement('a') + link.href = url + link.download = fileName + document.body.appendChild(link) + link.click() + document.body.removeChild(link) + window.URL.revokeObjectURL(url) + } catch (e: any) { + useMessage().error(e?.msg || '下载失败') + } } const beforeUpload: UploadProps['beforeUpload'] = (rawFile) => { diff --git a/src/views/purchase/purchasingrequisition/form.vue b/src/views/purchase/purchasingrequisition/form.vue index 02df52c..c896d96 100644 --- a/src/views/purchase/purchasingrequisition/form.vue +++ b/src/views/purchase/purchasingrequisition/form.vue @@ -47,7 +47,7 @@ const dialogTitle = computed(() => { const iframeSrc = computed(() => { const baseUrl = window.location.origin + window.location.pathname - let src = `${baseUrl}#/finance/purchasingrequisition/add` + let src = `${baseUrl}#/purchase/purchasingrequisition/add` if (mode.value !== 'add' && rowId.value) { src += `?mode=${mode.value}&id=${rowId.value}` } diff --git a/src/views/purchase/purchasingrequisition/implement.vue b/src/views/purchase/purchasingrequisition/implement.vue index cc57c19..a6081d9 100644 --- a/src/views/purchase/purchasingrequisition/implement.vue +++ b/src/views/purchase/purchasingrequisition/implement.vue @@ -82,29 +82,18 @@ - - - - + \ No newline at end of file