Commit 75ee40be by Sweet Zhang

下载材料包在新增时保存

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