|
|
@@ -646,25 +646,24 @@ const openForm = async (project?: any) => {
|
|
|
if (project?.id) {
|
|
|
const data = await getProject(project.id)
|
|
|
|
|
|
- // 关键:先把三个附件字段从 data 中摘出来,避免 ...data 污染 formData
|
|
|
- const {
|
|
|
- applicationFile: applicationFileData,
|
|
|
- openingReportFile: openingReportFileData,
|
|
|
- otherFile: otherFileData,
|
|
|
- ...restData
|
|
|
- } = data
|
|
|
+ // ⭐ 从 attachments 里按 type 拆出 3 个数组
|
|
|
+ const attachments = data.attachments || []
|
|
|
+ const applicationFileData = attachments.filter((a: any) => a.type === 'APPLICATION')
|
|
|
+ const openingReportFileData = attachments.filter((a: any) => a.type === 'OPENING_REPORT')
|
|
|
+ const otherFileData = attachments.filter((a: any) => a.type === 'OTHER')
|
|
|
|
|
|
+ // formData 不含附件字段,直接展开
|
|
|
formData.value = {
|
|
|
...createForm(),
|
|
|
- ...restData,
|
|
|
- scheduleList: restData.scheduleList?.length ? restData.scheduleList : [createSchedule()],
|
|
|
- budgetList: restData.budgetList?.length ? restData.budgetList : [createBudgetDetail()]
|
|
|
+ ...data,
|
|
|
+ scheduleList: data.scheduleList?.length ? data.scheduleList : [createSchedule()],
|
|
|
+ budgetList: data.budgetList?.length ? data.budgetList : [createBudgetDetail()]
|
|
|
}
|
|
|
|
|
|
- // 附件回显到独立 ref(与 index2.vue 一致)
|
|
|
- applicationFile.value = normalizeAttachments(applicationFileData, 'APPLICATION')
|
|
|
- openingReportFile.value = normalizeAttachments(openingReportFileData, 'OPENING_REPORT')
|
|
|
- otherFile.value = normalizeAttachments(otherFileData, 'OTHER')
|
|
|
+ // ⭐ 附件回显到独立 ref
|
|
|
+ applicationFile.value = applicationFileData
|
|
|
+ openingReportFile.value = openingReportFileData
|
|
|
+ otherFile.value = otherFileData
|
|
|
} else {
|
|
|
formData.value = createForm()
|
|
|
resetAttachments()
|