| | |
| | | if (!formData.value.id) return |
| | | const res = await gdDataObjectionDetailApi({ id: formData.value.id }) |
| | | formData.value = res?.data?.data ?? {} |
| | | if (formData.value.attachIds) { |
| | | getAttachDetail(formData.value.attachIds) |
| | | } |
| | | } |
| | | // 获取附件详情 |
| | | async function getAttachDetail() { |
| | | if (!formData.value.id) return |
| | | const res = await getAttachDetailApi({ id: formData.value.id }) |
| | | console.log('附件详情',res.data.data) |
| | | attachmentDetailsList.value=res.data.data |
| | | async function getAttachDetail(attachIds) { |
| | | // 如果 attachIds 是字符串,尝试分割成数组 |
| | | const ids = typeof attachIds === 'string' ? attachIds.split(',') : Array.isArray(attachIds) ? attachIds : [attachIds] |
| | | const detailPromises = ids.map(id => getAttachDetailApi({ id })) |
| | | const results = await Promise.all(detailPromises) |
| | | attachmentDetailsList.value = results.map(res => res.data.data).filter(Boolean) |
| | | console.log('附件详情', attachmentDetailsList.value) |
| | | } |
| | | // 处理附件下载 |
| | | async function handleDownloadAttach() { |
| | | console.log('附件'); |
| | | |
| | | |
| | | if (attachmentDetailsList.value.length === 0) { |
| | | ElMessage.warning('没有可下载的附件') |
| | | return |
| | | } |
| | | |
| | | // 遍历所有附件并下载 |
| | | attachmentDetailsList.value.forEach(attach => { |
| | | if (attach.link) { |
| | | const link = document.createElement('a') |
| | | link.href = attach.link |
| | | link.download = attach.originalName || attach.name |
| | | link.style.display = 'none' |
| | | document.body.appendChild(link) |
| | | link.click() |
| | | document.body.removeChild(link) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | |
| | |
| | | feedbackFormData.value = initFeedbackForm() |
| | | if (dialogMode.value !== 'add') { |
| | | await loadDetail() |
| | | await getAttachDetail() |
| | | } |
| | | } |
| | | |