文件上传无法刷新问题

This commit is contained in:
Ledo 2025-05-12 22:41:08 +08:00
parent 999f2d487f
commit 6c69e4fbc6

View File

@ -81,13 +81,13 @@
ref="uploadRef" :file-list="uploadFiles" multiple :action="uploadUrl" :headers="{ ref="uploadRef" :file-list="uploadFiles" multiple :action="uploadUrl" :headers="{
Authorization: 'Bearer ' + getAccessToken(), Authorization: 'Bearer ' + getAccessToken(),
'tenant-id': getTenantId() 'tenant-id': getTenantId()
}" name="files" :show-file-list="false" :auto-upload="false" :data="uploadData" :on-change="uploadChange" class="upload-file-uploader"> }" name="files" :show-file-list="false" :auto-upload="false" :on-success="handleAvatarSuccess" :data="uploadData" :on-change="uploadChange" class="upload-file-uploader">
<el-button type="primary"> <el-button type="primary">
<Icon icon="ep:upload-filled" />上传 <Icon icon="ep:upload-filled" />上传
</el-button> </el-button>
</el-upload> </el-upload>
</el-col> </el-col>
<el-table :data="formData.attachments" v-loading.fullscreen.lock="uploading" element-loading-text="附件上传中..." element-loading-background="rgba(122, 122, 122, 0.6)" class="hl-table"> <el-table :key="tableKey" :data="formData.attachments" v-loading.fullscreen.lock="uploading" element-loading-text="附件上传中..." element-loading-background="rgba(122, 122, 122, 0.6)" class="hl-table">
<el-table-column fixed type="index" width="100" label="序号" align="center" /> <el-table-column fixed type="index" width="100" label="序号" align="center" />
<el-table-column prop="name" label="文件名称" align="center" /> <el-table-column prop="name" label="文件名称" align="center" />
<el-table-column prop="createTime" align="center" label="上传时间" :formatter="dateFormatter" /> <el-table-column prop="createTime" align="center" label="上传时间" :formatter="dateFormatter" />
@ -134,7 +134,7 @@ import download from '@/utils/download'
import {Search} from "@element-plus/icons-vue" import {Search} from "@element-plus/icons-vue"
import ProjectDialog from "@/views/heli/invoice/projectDialog.vue" import ProjectDialog from "@/views/heli/invoice/projectDialog.vue"
import PurchaseDialog from "@/views/heli/invoice/purchaseDialog.vue" import PurchaseDialog from "@/views/heli/invoice/purchaseDialog.vue"
import type { UploadProps } from 'element-plus'
defineOptions({ name: 'InvoiceDetail' }) defineOptions({ name: 'InvoiceDetail' })
@ -173,6 +173,7 @@ const formData: any = ref({
active: undefined, active: undefined,
activeOpinion: '' activeOpinion: ''
}) })
const tableKey = ref(0);
const formRef = ref() // Ref const formRef = ref() // Ref
const subFormRef = ref() const subFormRef = ref()
@ -247,7 +248,6 @@ const submitForm = async (operate) => {
if (uploadFiles.value.length > 0) { if (uploadFiles.value.length > 0) {
uploadData.value.businessId = dataId uploadData.value.businessId = dataId
await uploadRef.value!.submit() await uploadRef.value!.submit()
}
message.success(t('common.operationSuccess')) message.success(t('common.operationSuccess'))
let jumpActive = 'update' let jumpActive = 'update'
@ -257,7 +257,19 @@ const submitForm = async (operate) => {
commonStore.setStore('id', dataId) commonStore.setStore('id', dataId)
commonStore.setStore('active', jumpActive) commonStore.setStore('active', jumpActive)
commonStore.setStore('businessType', businessType.value) commonStore.setStore('businessType', businessType.value)
reload() await reload()
}else{
message.success(t('common.operationSuccess'))
let jumpActive = 'update'
if(operate == 'SUBMIT' || operate == 'CANCEL'){
jumpActive = 'detail'
}
commonStore.setStore('id', dataId)
commonStore.setStore('active', jumpActive)
commonStore.setStore('businessType', businessType.value)
await reload()
}
} finally { } finally {
formLoading.value = false formLoading.value = false
} }
@ -277,6 +289,23 @@ const uploadData = ref({
businessId: formData.value.id, businessId: formData.value.id,
businessFileType:businessType.value businessFileType:businessType.value
}) })
const handleAvatarSuccess: UploadProps['onSuccess'] = async (
response,
uploadFile
) => {
let attParams = {
pageNo: 1,
pageSize: 99,
businessId: currentId.value,
businessType: businessType.value,
businessFileType:businessType.value
}
uploading.value = true;
formData.value.attachments = (await getFilePage(attParams)).list
tableKey.value += 1;
uploading.value = false;
}
// //
const downloadAttachment = async (name, url) => { const downloadAttachment = async (name, url) => {
const baseUrl = import.meta.env.VITE_BASE_URL; const baseUrl = import.meta.env.VITE_BASE_URL;