diff --git a/src/views/purchase/purchasingrequisition/agentDoc/AgentDocDialog.vue b/src/views/purchase/purchasingrequisition/agentDoc/AgentDocDialog.vue
index f1adec1..6736044 100644
--- a/src/views/purchase/purchasingrequisition/agentDoc/AgentDocDialog.vue
+++ b/src/views/purchase/purchasingrequisition/agentDoc/AgentDocDialog.vue
@@ -41,33 +41,63 @@
-
-
- 选择文件
-
- 支持 .doc, .docx, .pdf 格式,文件大小不超过 50MB
-
-
+
+
+
已上传的采购文件
+
+
+
+
+
+
+
+
+
+ {{ getStatusLabel(scope.row.status) }}
+
+
+
+
+
+ 下载
+
+
+
+
-
- {{ projectInfo.status === 'RETURNED' ? '重新上传招标文件' : '上传招标文件' }}
-
+
+
+
{{ projectInfo.status === 'RETURNED' ? '重新上传招标文件' : '上传招标文件' }}
+
+ 选择文件
+
+ 支持 .doc, .docx, .pdf 格式,文件大小不超过 50MB
+
+
+
+
+
+ {{ projectInfo.status === 'RETURNED' ? '重新上传并提交' : '上传并提交' }}
+
+
+
@@ -93,7 +123,7 @@
import { ref, computed } from 'vue'
import { useMessage } from '/@/hooks/message'
import { Session } from '/@/utils/storage'
-import { getAgentRequirementFiles, getAgentApplyDetail, uploadAgentDoc, reuploadAgentDoc, getDocList, downloadFileById } from '/@/api/purchase/purchasingrequisition'
+import { getAgentRequirementFiles, getAgentApplyDetail, getDocList, downloadFileById, uploadAgentDoc, reuploadAgentDoc } from '/@/api/purchase/purchasingrequisition'
import type { UploadInstance, UploadProps, UploadUserFile } from 'element-plus'
const emit = defineEmits(['refresh'])
@@ -106,11 +136,13 @@ const requirementLoading = ref(false)
const uploadSubmitting = ref(false)
const uploadRef = ref()
const fileList = ref([])
+const uploadedDocList = ref([])
+const docListLoading = ref(false)
-// 上传配置
+// 上传配置 - 使用采购文件上传接口
const uploadAction = computed(() => {
const baseUrl = import.meta.env.VITE_API_URL || ''
- return `${baseUrl}/admin/sys-file/upload`
+ return `${baseUrl}/purchase/purchasingfiles/upload`
})
const uploadHeaders = computed(() => {
@@ -121,6 +153,12 @@ const uploadHeaders = computed(() => {
}
})
+// 上传时附带的额外参数
+const uploadData = computed(() => ({
+ fileType: '130', // 招标文件类型
+ purchaseId: projectInfo.value.applyId || ''
+}))
+
// 是否可以上传
const canUpload = computed(() => {
const status = projectInfo.value.status
@@ -132,8 +170,10 @@ const open = async (row: any) => {
visible.value = true
activeTab.value = 'info'
fileList.value = []
+ uploadedDocList.value = []
await loadProjectDetail()
await loadRequirementFiles()
+ await loadUploadedDocList()
}
const loadProjectDetail = async () => {
@@ -159,12 +199,22 @@ const loadRequirementFiles = async () => {
}
}
+const loadUploadedDocList = async () => {
+ docListLoading.value = true
+ try {
+ const res = await getDocList(projectInfo.value.applyId)
+ uploadedDocList.value = res?.data || []
+ } catch (e: any) {
+ uploadedDocList.value = []
+ } finally {
+ docListLoading.value = false
+ }
+}
+
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')
@@ -179,6 +229,19 @@ const handleDownload = async (row: any) => {
}
}
+const handleDownloadDoc = async (row: any) => {
+ try {
+ // 使用采购文件下载接口
+ const baseUrl = import.meta.env.VITE_API_URL || ''
+ const token = Session.getToken()
+ const tenantId = Session.getTenant() || '1'
+ const url = `${baseUrl}/purchase/purchasingdoc/download/${row.id}?Authorization=Bearer ${token}&TENANT-ID=${tenantId}`
+ window.open(url, '_blank')
+ } catch (e: any) {
+ useMessage().error(e?.msg || '下载失败')
+ }
+}
+
const beforeUpload: UploadProps['beforeUpload'] = (rawFile) => {
const allowedTypes = ['application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/pdf']
const allowedExtensions = ['.doc', '.docx', '.pdf']
@@ -197,11 +260,40 @@ const beforeUpload: UploadProps['beforeUpload'] = (rawFile) => {
return true
}
-const handleUploadSuccess: UploadProps['onSuccess'] = (response: any, uploadFile: any) => {
+const handleFileChange: UploadProps['onChange'] = (uploadFile, uploadFiles) => {
+ fileList.value = uploadFiles
+}
+
+const handleUploadSuccess: UploadProps['onSuccess'] = async (response: any, uploadFile: any) => {
if (response?.code === 0 || response?.code === 200) {
- const fileUrl = response.data?.url || response.data?.fileUrl || response.data?.filePath
- const fileName = uploadFile.name
- submitUpload(fileName, fileUrl)
+ // 文件上传成功后,调用采购文件提交接口
+ const fileData = response.data
+ try {
+ const submitData = {
+ applyId: projectInfo.value.applyId,
+ fileName: fileData.fileTitle || uploadFile.name,
+ filePath: fileData.remark || fileData.filePath
+ }
+ let submitRes
+ if (projectInfo.value.status === 'RETURNED') {
+ submitRes = await reuploadAgentDoc(submitData)
+ } else {
+ submitRes = await uploadAgentDoc(submitData)
+ }
+ if (submitRes?.code === 0 || submitRes?.code === 200) {
+ useMessage().success('招标文件提交成功')
+ emit('refresh')
+ await loadProjectDetail()
+ await loadUploadedDocList()
+ fileList.value = []
+ } else {
+ useMessage().error(submitRes?.msg || '提交失败')
+ }
+ } catch (e: any) {
+ useMessage().error(e?.msg || '提交失败')
+ } finally {
+ uploadSubmitting.value = false
+ }
} else {
useMessage().error(response?.msg || '上传失败')
uploadSubmitting.value = false
@@ -213,31 +305,6 @@ const handleUploadError: UploadProps['onError'] = (error: any) => {
uploadSubmitting.value = false
}
-const submitUpload = async (fileName: string, filePath: string) => {
- try {
- const data = {
- applyId: projectInfo.value.applyId,
- fileName,
- filePath
- }
-
- if (projectInfo.value.status === 'RETURNED') {
- await reuploadAgentDoc(data)
- } else {
- await uploadAgentDoc(data)
- }
-
- useMessage().success('招标文件上传成功')
- emit('refresh')
- await loadProjectDetail()
- fileList.value = []
- } catch (e: any) {
- useMessage().error(e?.msg || '上传失败')
- } finally {
- uploadSubmitting.value = false
- }
-}
-
const handleUploadSubmit = async () => {
if (fileList.value.length === 0) {
useMessage().warning('请先选择文件')
@@ -299,4 +366,32 @@ defineExpose({ open })
.mt-4 {
margin-top: 16px;
}
+
+.section-title {
+ font-size: 14px;
+ font-weight: 600;
+ color: #303133;
+ margin-bottom: 12px;
+ padding-left: 8px;
+ border-left: 3px solid #409eff;
+}
+
+.uploaded-docs {
+ background-color: #f5f7fa;
+ padding: 12px;
+ border-radius: 4px;
+}
+
+.upload-area {
+ background-color: #fff;
+ padding: 12px;
+ border: 1px dashed #dcdfe6;
+ border-radius: 4px;
+}
+
+.action-buttons {
+ display: flex;
+ justify-content: flex-start;
+ gap: 12px;
+}
\ No newline at end of file