上传组件优化

This commit is contained in:
‘huanghaiixia’
2025-12-18 10:03:25 +08:00
parent 21a8fae538
commit fa88795dbd
3 changed files with 17 additions and 10 deletions

View File

@ -225,7 +225,8 @@ import { methodOf } from 'lodash-es';
} }
}, },
{ {
immediate: true immediate: true,
deep: true,
} }
); );

View File

@ -2,7 +2,7 @@
<div> <div>
<Upload v-if="!disabled" style="margin-bottom: 10px;" :file-list="dataFile" :showUploadList="false" <Upload v-if="!disabled" style="margin-bottom: 10px;" :file-list="dataFile" :showUploadList="false"
v-model:value="tableId" v-model:tableName="tableName" v-model:columnName="columnName" v-model:value="tableId" v-model:tableName="tableName" v-model:columnName="columnName"
:btnTip="btnTip" @change="changeUplod" :multiple="true" :dataDelete="true" :btnTip="btnTip" @change="changeUpload" :multiple="true" :dataDelete="true"
:showDownloadIcon="false"/> :showDownloadIcon="false"/>
<a-table :columns="columns" :data-source="dataFile" > <a-table :columns="columns" :data-source="dataFile" >
<template #bodyCell="{ column,record,index, text }"> <template #bodyCell="{ column,record,index, text }">
@ -62,10 +62,10 @@
default: '上传' default: '上传'
}, },
tip: String, tip: String,
fileList: Array, list: Array,
}); });
const emit = defineEmits(['update:value', 'change', 'click', 'update:tableName', 'update:columnName']); const emit = defineEmits(['update:value', 'change', 'click', 'update:tableName', 'update:columnName']);
function changeUplod (val) { function changeUpload (val) {
dataFile.value = [] dataFile.value = []
val.forEach(v => { val.forEach(v => {
v.fileOrg = v.fileOrg || v.fileName, v.fileOrg = v.fileOrg || v.fileName,
@ -73,6 +73,7 @@
v.fileSize = v.fileSize v.fileSize = v.fileSize
dataFile.value.push(v) dataFile.value.push(v)
}) })
emit('change', dataFile.value);
console.log(val, 532, dataFile.value) console.log(val, 532, dataFile.value)
} }
const handleDownload = (info) => { const handleDownload = (info) => {
@ -96,6 +97,7 @@
} }
dataFile.value[index] = dataFile.value.splice(index+1, 1, dataFile.value[index])[0]; dataFile.value[index] = dataFile.value.splice(index+1, 1, dataFile.value[index])[0];
} }
emit('change', dataFile.value);
} }
const getFileList = () => { const getFileList = () => {
@ -110,11 +112,12 @@
} }
}, },
{ {
immediate: true immediate: true,
deep: true,
} }
); );
watch( watch(
() => props.fileList, () => props.list,
async (val) => { async (val) => {
dataFile.value = val || [] dataFile.value = val || []
tableId.value = props.value tableId.value = props.value
@ -122,7 +125,8 @@
columnName.value = props.columnName columnName.value = props.columnName
}, },
{ {
immediate: true immediate: true,
deep: true,
} }
); );
defineExpose({ defineExpose({

View File

@ -284,7 +284,7 @@
<span style="font-size: 12px;font-weight: normal;">上传公司财报等附件</span> <span style="font-size: 12px;font-weight: normal;">上传公司财报等附件</span>
</div> </div>
</template> </template>
<UploadList ref="uploadFile" :disabled="isDisable" :file-list="dataFile" :value="formState.filePath" :tableName="tableName" :columnName="columnName"/> <UploadList :disabled="isDisable" :list="dataFile" :value="formState.filePath" :tableName="tableName" :columnName="columnName" @change="uploadListChange"/>
</a-card> </a-card>
</a-form> </a-form>
</div> </div>
@ -455,6 +455,9 @@
} }
}); });
const uploadListChange = (val) => {
dataFile.value = val
}
async function getList(id) { async function getList(id) {
spinning.value = true spinning.value = true
try { try {
@ -617,13 +620,12 @@
v.dateFrom = v.dateFrom ? dayjs(v.dateFrom ).format('YYYY-MM-DD HH:mm:ss') : ''; v.dateFrom = v.dateFrom ? dayjs(v.dateFrom ).format('YYYY-MM-DD HH:mm:ss') : '';
v.dateTo = v.dateTo ? dayjs(v.dateTo ).format('YYYY-MM-DD HH:mm:ss'): ''; v.dateTo = v.dateTo ? dayjs(v.dateTo ).format('YYYY-MM-DD HH:mm:ss'): '';
}) })
let file = await uploadFile.value.getFileList()
let obj = { let obj = {
...formState, ...formState,
lngCustomerBankList: dataBank, lngCustomerBankList: dataBank,
lngCustomerDocList: arrCertificate, lngCustomerDocList: arrCertificate,
lngCustomerContactList: dataContact, lngCustomerContactList: dataContact,
lngFileUploadList: file lngFileUploadList: dataFile.value
} }
spinning.value = true; spinning.value = true;