Commit 75ee40be by Sweet Zhang

下载材料包在新增时保存

parent 6c53ba6f
......@@ -214,8 +214,32 @@ const progressFormat = (percentage) => `${currentCount.value}/${totalCount.value
// 2. 核心处理方法
const handleBatchDownloadSelected = async () => {
const selectedRows = fileTableList.value;
if (!selectedRows || selectedRows.length === 0) {
let apiMaterialDtoList = []
if (!props.idsObj.appointmentBizId) {
apiMaterialDtoList = fileTableList.value.map(item => {
return {
dataPerson: item.dataPerson, //资料人(字典)
dataPersonName: item.dataPersonName, //资料人(字典)
dataType: item.dataType, //资料类型(字典)
dataTypeName: item.dataTypeName, //资料类型(字典)
fileUrlList: item.fileBizIdList.map(item2 => ({
fileUrl: item2.url,
fileName: item2.originalName
}))
}
})
}else{
apiMaterialDtoList = fileTableList.value.map(item => {
return {
dataPerson: item.dataPerson, //资料人(字典)
dataPersonName: item.dataPersonName, //资料人(字典)
dataType: item.dataType, //资料类型(字典)
dataTypeName: item.dataTypeName, //资料类型(字典)
fileUrlList: item.fileUrlList
}
})
}
if (!apiMaterialDtoList || apiMaterialDtoList.length === 0) {
ElMessage.warning('没有要下载的材料');
return;
}
......@@ -223,10 +247,9 @@ const handleBatchDownloadSelected = async () => {
// --- 步骤 1: 数据清洗与扁平化 ---
const flatFileList = [];
let hasFiles = false;
selectedRows.forEach((row, index) => {
apiMaterialDtoList.forEach((item,index) => {
// 安全检查:确保 fileUrlList 存在且是数组
const urls = row.fileUrlList;
const urls = item.fileUrlList;
if (!urls || !Array.isArray(urls) || urls.length === 0) {
return; // 跳过没有文件的行
}
......@@ -236,11 +259,10 @@ const handleBatchDownloadSelected = async () => {
// 生成安全的业务前缀
// 规则:[人员类型]_[资料类型]_[业务ID]
// 例如:POLICYHOLDER_FRONT_2216
const safePerson = (row.dataPersonName || 'UNKNOWN').replace(/[\/\\:*?"<>|]/g, '_');
const safeType = (row.dataTypeName || 'FILE').replace(/[\/\\:*?"<>|]/g, '_');
const bizId = row.id || row.materialBizId || index; // 优先用数字ID
const safePerson = (item.dataPersonName || 'UNKNOWN').replace(/[\/\\:*?"<>|]/g, '_');
const safeType = (item.dataTypeName || 'FILE').replace(/[\/\\:*?"<>|]/g, '_');
const filePrefix = `${safePerson}_${safeType}_${bizId}`;
const filePrefix = `${safePerson}_${safeType}`;
urls.forEach((fileItem, fIndex) => {
// 兼容 fileUrlList 可能是字符串数组 或 对象数组
......@@ -257,9 +279,8 @@ const handleBatchDownloadSelected = async () => {
name: finalFileName,
// 可选:保留元数据用于调试
_meta: {
bizId: row.id,
type: row.dataType,
note: row.precautions
type: item.dataType,
note: item.precautions
}
});
}
......@@ -492,7 +513,7 @@ function handleBeforeUpload(file) {
proxy.$modal.msgError(`上传文件大小不能超过 ${fileSize.value} MB!`)
return false
}
// proxy.$modal.loading('正在上传文件,请稍候...')
proxy.$modal.loading('正在上传文件,请稍候...')
}
// 文件个数超出
function handleExceed() {
......@@ -501,6 +522,7 @@ function handleExceed() {
// 文件上传成功回调
const uploadSuccess = (res, file, fileList) => {
console.log('上传成功', res, file)
proxy.$modal.closeLoading();
if (res.code === 200) {
// 构造前端使用的文件对象(保留原始 file 信息 + 后端返回的 url 等)
const uploadedFile = {
......
......@@ -541,7 +541,7 @@ const policyInfoFormConfig = ref([
type: 'select',
prop: 'professionalInvestor',
label: '专业投资者',
value:'No',
defaultValue :'No',
options: [
{ label: '是', value: 'Yes' },
{ label: '否', value: 'No' }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment