From 695769076af697b4aab679123d92c03950751c11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wei=5F=E4=BD=B3?= Date: Tue, 25 Nov 2025 10:26:28 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E8=AF=81?= =?UTF-8?q?=E4=B9=A6=E4=B8=8A=E4=BC=A0=E6=A8=A1=E6=80=81=E6=A1=86=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91=E5=B9=B6=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E5=BC=BA=E5=88=B6=E4=B8=8A=E4=BC=A0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../audit/components/AuditDetail.vue | 9 -- .../audit/components/CertificateModal.vue | 82 ++++++------------- 2 files changed, 26 insertions(+), 65 deletions(-) diff --git a/web/src/views/valuation/audit/components/AuditDetail.vue b/web/src/views/valuation/audit/components/AuditDetail.vue index 31f334d..96e1065 100644 --- a/web/src/views/valuation/audit/components/AuditDetail.vue +++ b/web/src/views/valuation/audit/components/AuditDetail.vue @@ -323,15 +323,6 @@ const handleCertificateConfirm = async (data) => { const certificateUrl = data.certificateFiles?.map(f => f.url).filter(Boolean) || [] const reportUrl = data.reportFiles?.map(f => f.url).filter(Boolean) || [] - if (!certificateUrl.length) { - $message.warning('请上传证书') - return - } - - if (!reportUrl.length) { - $message.warning('请上传报告') - return - } const payload = { ...props.detailData, diff --git a/web/src/views/valuation/audit/components/CertificateModal.vue b/web/src/views/valuation/audit/components/CertificateModal.vue index 348a26c..10dd178 100644 --- a/web/src/views/valuation/audit/components/CertificateModal.vue +++ b/web/src/views/valuation/audit/components/CertificateModal.vue @@ -33,11 +33,6 @@ const props = defineProps({ const emit = defineEmits(['update:visible', 'confirm']) const message = useMessage() -const formData = ref({ - reportFiles: [], - certificateFiles: [], -}) - const reportFileList = ref([]) const certificateFileList = ref([]) @@ -46,6 +41,7 @@ const uploadHeaders = computed(() => ({ Authorization: `Bearer ${getToken()}`, })) +// 监听弹窗打开,初始化数据 // 监听弹窗打开,初始化数据 watch( () => props.visible, @@ -53,14 +49,10 @@ watch( if (val) { if (props.mode === 'view') { // 查看模式,加载已有数据 - reportFileList.value = props.certificateData?.reportFiles || [] - certificateFileList.value = props.certificateData?.certificateFiles || [] + reportFileList.value = (props.certificateData?.reportFiles || []).map(f => ({ ...f, status: 'finished' })) + certificateFileList.value = (props.certificateData?.certificateFiles || []).map(f => ({ ...f, status: 'finished' })) } else { // 上传模式,清空数据 - formData.value = { - reportFiles: [], - certificateFiles: [], - } reportFileList.value = [] certificateFileList.value = [] } @@ -73,11 +65,19 @@ const handleClose = () => { emit('update:visible', false) } +// 确认操作 // 确认操作 const handleConfirm = () => { + const getFiles = (list) => list.map(f => ({ + id: f.id, + name: f.name, + url: f.url, + type: f.type + })).filter(f => f.url) + emit('confirm', { - reportFiles: formData.value.reportFiles, - certificateFiles: formData.value.certificateFiles, + reportFiles: getFiles(reportFileList.value), + certificateFiles: getFiles(certificateFileList.value) }) handleClose() } @@ -104,23 +104,17 @@ const beforeUpload = (data) => { return true } +// 报告上传完成 // 报告上传完成 const handleReportUploadFinish = ({ file, event }) => { try { const res = JSON.parse(event.target.response) if (res.code === 200 && res.data?.url) { - const targetFile = reportFileList.value.find(f => f.id === file.id) || file - targetFile.url = res.data.url - targetFile.name = res.data.filename || targetFile.name - targetFile.status = 'finished' - - formData.value.reportFiles = reportFileList.value.map(f => ({ - id: f.id, - name: f.name, - url: f.url, - type: f.type - })) + file.url = res.data.url + file.name = res.data.filename || file.name + file.status = 'finished' message.success('报告上传成功') + return file } else { message.error(res.message || '上传失败') const index = reportFileList.value.findIndex((item) => item.id === file.id) @@ -132,26 +126,19 @@ const handleReportUploadFinish = ({ file, event }) => { const index = reportFileList.value.findIndex((item) => item.id === file.id) if (index > -1) reportFileList.value.splice(index, 1) } - return file } +// 证书上传完成 // 证书上传完成 const handleCertificateUploadFinish = ({ file, event }) => { try { const res = JSON.parse(event.target.response) if (res.code === 200 && res.data?.url) { - const targetFile = certificateFileList.value.find(f => f.id === file.id) || file - targetFile.url = res.data.url - targetFile.name = res.data.filename || targetFile.name - targetFile.status = 'finished' - - formData.value.certificateFiles = certificateFileList.value.map(f => ({ - id: f.id, - name: f.name, - url: f.url, - type: f.type - })) + file.url = res.data.url + file.name = res.data.filename || file.name + file.status = 'finished' message.success('证书上传成功') + return file } else { message.error(res.message || '上传失败') const index = certificateFileList.value.findIndex((item) => item.id === file.id) @@ -163,26 +150,9 @@ const handleCertificateUploadFinish = ({ file, event }) => { const index = certificateFileList.value.findIndex((item) => item.id === file.id) if (index > -1) certificateFileList.value.splice(index, 1) } - return file } -// 移除文件 -const handleRemove = () => { - // 更新 formData - formData.value.reportFiles = reportFileList.value.map(f => ({ - id: f.id, - name: f.name, - url: f.url, - type: f.type - })) - formData.value.certificateFiles = certificateFileList.value.map(f => ({ - id: f.id, - name: f.name, - url: f.url, - type: f.type - })) - return true -} + const modalTitle = computed(() => { return props.mode === 'upload' ? '上传' : '查看' @@ -239,7 +209,7 @@ const handlePreview = (file) => { :headers="uploadHeaders" :before-upload="beforeUpload" @finish="handleReportUploadFinish" - @remove="handleRemove" + :disabled="!isUploadMode" show-preview-button show-download-button @@ -261,7 +231,7 @@ const handlePreview = (file) => { :headers="uploadHeaders" :before-upload="beforeUpload" @finish="handleCertificateUploadFinish" - @remove="handleRemove" + :disabled="!isUploadMode" show-preview-button show-download-button