diff --git a/web/src/views/transaction/invoice/InvoiceModal.vue b/web/src/views/transaction/invoice/InvoiceModal.vue index 9fcd91e..7e46ba0 100644 --- a/web/src/views/transaction/invoice/InvoiceModal.vue +++ b/web/src/views/transaction/invoice/InvoiceModal.vue @@ -61,6 +61,7 @@ const handleConfirm = () => { if (!errors) { emit('confirm', { ...formData.value, + attachments: fileList.value?.map((file) => file.url) || [], id: props.invoiceData?.id, }) } @@ -93,15 +94,11 @@ const handleUploadFinish = ({ file, event }) => { const res = JSON.parse(event.target.response) // 只要返回了 url 字段,就认为上传成功 if (res.code === 200 && res.data?.url) { - // 显式查找 fileList 中的文件对象进行更新,确保响应式 - const targetFile = fileList.value.find(f => f.id === file.id) || file - targetFile.url = res.data.url - targetFile.name = res.data.filename || targetFile.name - targetFile.status = 'finished' // 手动标记为完成 - - // 更新 formData.attachments - updateAttachments() + file.url = res.data.url + file.name = res.data.filename || file.name + file.status = 'finished' $message.success('上传成功') + return file } else { $message.error(res.message || '上传失败') // 从列表中移除失败的文件 @@ -114,25 +111,6 @@ const handleUploadFinish = ({ file, event }) => { const index = fileList.value.findIndex((item) => item.id === file.id) if (index > -1) fileList.value.splice(index, 1) } - return file -} - -// 更新附件列表 -const updateAttachments = () => { - // 只要有 url 的都算作有效附件 - formData.value.attachments = fileList.value - .map(file => file.url) - .filter(url => !!url) -} - -// 移除文件 -const handleRemove = ({ file }) => { - const index = fileList.value.findIndex(item => item.id === file.id) - if (index > -1) { - fileList.value.splice(index, 1) - updateAttachments() - } - return true } const rules = { @@ -201,7 +179,6 @@ const modalTitle = props.mode === 'invoice' ? '开票' : '查看发票' :headers="uploadHeaders" :before-upload="beforeUpload" @finish="handleUploadFinish" - @remove="handleRemove" :disabled="mode === 'view'" >