Browse Source

FWHL-322

hella_online_20250328
王宇飞 2 weeks ago
parent
commit
9eca02b514
  1. 14
      src/components/UploadFile/src/UploadFile.vue

14
src/components/UploadFile/src/UploadFile.vue

@ -75,6 +75,7 @@ const props = defineProps({
const valueRef = ref(props.modelValue)
const uploadRef = ref<UploadInstance>()
const uploadList = ref<UploadUserFile[]>([])
const allUploadList = ref<UploadUserFile[]>([])
const fileList = props.modelValue && props.modelValue.length > 0 ? ref<UploadUserFile[]>(props.modelValue) : ref<UploadUserFile[]>([])
const uploadNumber = ref<number>(0)
const uploadHeaders = ref({
@ -124,13 +125,15 @@ const handleFileSuccess: UploadProps['onSuccess'] = async (res: any,uploadFile:
if(checkRes['fileExists']=="YES"){
ElMessage.closeAll()
message.success(t('ts.上传成功'))
const fileListNew = fileList.value
fileListNew.pop()
fileList.value = fileListNew
uploadList.value.push({ name: uploadFile.name, url: res.data })
uploadList.value.push({ name: uploadFile.name, url: res.data.data.url })
// if (uploadList.value.length == uploadNumber.value) {
if(fileList.value.every(it => it.status == 'success')) {
fileList.value = fileList.value.concat(uploadList.value)
allUploadList.value = allUploadList.value.concat(uploadList.value)
fileList.value.forEach(item=>{
if(!item.url){
item.url = item.response.data.data.url
}
})
uploadList.value = []
uploadNumber.value = 0
emit('update:modelValue', listToString(fileList.value),res,uploadFile)
@ -186,6 +189,7 @@ const handlePreview: UploadProps['onPreview'] = (uploadFile) => {
}
//
const listToString = (list: UploadUserFile[], separator?: string) => {
let strs = ''
separator = separator || ','
for (let i in list) {

Loading…
Cancel
Save