fix: 修复上传问题,报告和凭证限制 1 条,开票附件限制 2 条,需要后端修改接收数组

This commit is contained in:
Wei_佳 2025-11-25 18:10:11 +08:00
parent 9657901339
commit 0694ec28fb
3 changed files with 10 additions and 35 deletions

View File

@ -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'"
>
<div class="upload-trigger">

View File

@ -335,11 +335,11 @@ const handleCertificateConfirm = async (data) => {
const certificateUrl = data.certificateFiles?.map(f => f.url).filter(Boolean) || []
const reportUrl = data.reportFiles?.map(f => f.url).filter(Boolean) || []
// 1
const payload = {
...props.detailData,
certificate_url: certificateUrl,
report_url: reportUrl,
certificate_url: certificateUrl?.[0],
report_url: reportUrl?.[0],
status: 'success'
}

View File

@ -203,13 +203,12 @@ const handlePreview = (file) => {
<div class="upload-content">
<NUpload
v-model:file-list="reportFileList"
multiple
max="1"
list-type="image-card"
:action="uploadUrl"
:headers="uploadHeaders"
:before-upload="beforeUpload"
@finish="handleReportUploadFinish"
:disabled="!isUploadMode"
show-preview-button
show-download-button
@ -225,13 +224,12 @@ const handlePreview = (file) => {
<div class="upload-content">
<NUpload
v-model:file-list="certificateFileList"
multiple
list-type="image-card"
:action="uploadUrl"
:headers="uploadHeaders"
:before-upload="beforeUpload"
@finish="handleCertificateUploadFinish"
max="1"
:disabled="!isUploadMode"
show-preview-button
show-download-button