feat: 优化评估审核页面数据展示逻辑,调整发票邮件发送附件处理并移除mock数据
This commit is contained in:
parent
a0e857b115
commit
e479bcfa97
@ -1,6 +1,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, watch } from 'vue'
|
import { ref, watch, computed } from 'vue'
|
||||||
import { NModal, NCard, NForm, NFormItem, NInput, NButton, NUpload, NSpace, NText } from 'naive-ui'
|
import { NModal, NCard, NForm, NFormItem, NInput, NButton, NUpload, NSpace, NText, useMessage } from 'naive-ui'
|
||||||
|
import { getToken } from '@/utils/auth/token'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
visible: {
|
visible: {
|
||||||
@ -27,6 +28,12 @@ const formData = ref({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const fileList = ref([])
|
const fileList = ref([])
|
||||||
|
const $message = useMessage()
|
||||||
|
|
||||||
|
const uploadUrl = `${import.meta.env.VITE_BASE_API}/upload/file`
|
||||||
|
const uploadHeaders = computed(() => ({
|
||||||
|
Authorization: `Bearer ${getToken()}`,
|
||||||
|
}))
|
||||||
|
|
||||||
// 监听弹窗打开,初始化数据
|
// 监听弹窗打开,初始化数据
|
||||||
watch(
|
watch(
|
||||||
@ -80,10 +87,42 @@ const beforeUpload = (data) => {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// 文件上传变化
|
// 文件上传完成
|
||||||
const handleUploadChange = ({ fileList: newFileList }) => {
|
const handleUploadFinish = ({ file, event }) => {
|
||||||
fileList.value = newFileList
|
try {
|
||||||
formData.value.attachments = newFileList.map(file => file.id || file.name)
|
const res = JSON.parse(event.target.response)
|
||||||
|
// 只要返回了 url 字段,就认为上传成功
|
||||||
|
if (res.url) {
|
||||||
|
// 显式查找 fileList 中的文件对象进行更新,确保响应式
|
||||||
|
const targetFile = fileList.value.find(f => f.id === file.id) || file
|
||||||
|
targetFile.url = res.url
|
||||||
|
targetFile.name = res.filename || targetFile.name
|
||||||
|
targetFile.status = 'finished' // 手动标记为完成
|
||||||
|
|
||||||
|
// 更新 formData.attachments
|
||||||
|
updateAttachments()
|
||||||
|
$message.success('上传成功')
|
||||||
|
} else {
|
||||||
|
$message.error(res.message || '上传失败')
|
||||||
|
// 从列表中移除失败的文件
|
||||||
|
const index = fileList.value.findIndex((item) => item.id === file.id)
|
||||||
|
if (index > -1) fileList.value.splice(index, 1)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('上传响应解析失败:', error)
|
||||||
|
$message.error('上传失败:服务器响应异常')
|
||||||
|
const index = fileList.value.findIndex((item) => item.id === file.id)
|
||||||
|
if (index > -1) fileList.value.splice(index, 1)
|
||||||
|
}
|
||||||
|
return file
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新附件列表
|
||||||
|
const updateAttachments = () => {
|
||||||
|
// 只要有 url 的都算作有效附件
|
||||||
|
formData.value.attachments = fileList.value
|
||||||
|
.map(file => file.url)
|
||||||
|
.filter(url => !!url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 移除文件
|
// 移除文件
|
||||||
@ -91,6 +130,7 @@ const handleRemove = ({ file }) => {
|
|||||||
const index = fileList.value.findIndex(item => item.id === file.id)
|
const index = fileList.value.findIndex(item => item.id === file.id)
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
fileList.value.splice(index, 1)
|
fileList.value.splice(index, 1)
|
||||||
|
updateAttachments()
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -157,8 +197,10 @@ const modalTitle = props.mode === 'invoice' ? '开票' : '查看发票'
|
|||||||
multiple
|
multiple
|
||||||
:max="2"
|
:max="2"
|
||||||
list-type="image-card"
|
list-type="image-card"
|
||||||
|
:action="uploadUrl"
|
||||||
|
:headers="uploadHeaders"
|
||||||
:before-upload="beforeUpload"
|
:before-upload="beforeUpload"
|
||||||
@change="handleUploadChange"
|
@finish="handleUploadFinish"
|
||||||
@remove="handleRemove"
|
@remove="handleRemove"
|
||||||
:disabled="mode === 'view'"
|
:disabled="mode === 'view'"
|
||||||
>
|
>
|
||||||
|
|||||||
@ -236,18 +236,25 @@ async function fetchDetail(row) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 确认发送邮件
|
// 确认发送邮件
|
||||||
async function handleInvoiceConfirm(data) {
|
// 确认发送邮件
|
||||||
|
async function handleInvoiceConfirm(formData) {
|
||||||
try {
|
try {
|
||||||
await api.sendInvoice({
|
// 根据报错 'loc': ('body', 'data'),后端确实需要 data 字段包裹
|
||||||
email: data.email,
|
const payload = {
|
||||||
subject: data.subject,
|
data: {
|
||||||
body: data.body,
|
email: formData.email,
|
||||||
file_url: data.file_url || currentInvoice.value?.receipt?.url,
|
subject: formData.email, // 用户要求 subject 传 email
|
||||||
})
|
body: formData.content, // 映射 content -> body
|
||||||
|
file_url: formData.attachments?.[0] || '', // 映射 attachments -> file_url
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await api.sendInvoice(payload)
|
||||||
$message.success('发送成功')
|
$message.success('发送成功')
|
||||||
invoiceModalVisible.value = false
|
invoiceModalVisible.value = false
|
||||||
$table.value?.handleSearch()
|
$table.value?.handleSearch()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
$message.error(error?.message || '操作失败')
|
$message.error(error?.message || '操作失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,9 +60,9 @@ const detailSections = computed(() => {
|
|||||||
fields: [
|
fields: [
|
||||||
{ label: '资产名称', type: 'text', value: detail.asset_name || '-' },
|
{ label: '资产名称', type: 'text', value: detail.asset_name || '-' },
|
||||||
{ label: '所属机构/权利人', type: 'text', value: detail.institution || '-' },
|
{ label: '所属机构/权利人', type: 'text', value: detail.institution || '-' },
|
||||||
{ label: '统一社会信用代码/身份证号', type: 'text', value: detail.credit_code || '-' },
|
{ label: '统一社会信用代码/身份证号', type: 'text', value: detail.credit_code || detail.credit_code_or_id || '-' },
|
||||||
{ label: '所属行业', type: 'text', value: detail.industry || '-' },
|
{ label: '所属行业', type: 'text', value: detail.industry || '-' },
|
||||||
{ label: '业务/传承介绍', type: 'text', value: detail.business_heritage_intro || '-' },
|
{ label: '业务/传承介绍', type: 'text', value: detail.business_heritage_intro || detail.biz_intro || '-' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -80,9 +80,13 @@ const detailSections = computed(() => {
|
|||||||
title: '非遗等级与技术',
|
title: '非遗等级与技术',
|
||||||
fields: [
|
fields: [
|
||||||
{ label: '非遗传承人等级', type: 'text', value: detail.inheritor_level || '-' },
|
{ label: '非遗传承人等级', type: 'text', value: detail.inheritor_level || '-' },
|
||||||
{ label: '非遗传承人年龄水平及数量', type: 'list', value: formatAgeDistribution(detail.inheritor_age_count) },
|
{
|
||||||
|
label: '非遗传承人年龄水平及数量',
|
||||||
|
type: 'list',
|
||||||
|
value: formatAgeDistribution(detail.inheritor_age_count || detail.inheritor_ages),
|
||||||
|
},
|
||||||
{ label: '非遗传承人等级证书', type: 'images', value: detail.inheritor_certificates || [] },
|
{ label: '非遗传承人等级证书', type: 'images', value: detail.inheritor_certificates || [] },
|
||||||
{ label: '非遗等级', type: 'text', value: detail.heritage_level || '-' },
|
{ label: '非遗等级', type: 'text', value: detail.heritage_level || detail.heritage_asset_level || '-' },
|
||||||
{ label: '非遗资产所用专利的申请号', type: 'text', value: detail.patent_application_no || '-' },
|
{ label: '非遗资产所用专利的申请号', type: 'text', value: detail.patent_application_no || '-' },
|
||||||
{ label: '非遗资产历史证明证据及数量', type: 'list', value: formatHistoricalEvidence(detail.historical_evidence) },
|
{ label: '非遗资产历史证明证据及数量', type: 'list', value: formatHistoricalEvidence(detail.historical_evidence) },
|
||||||
{
|
{
|
||||||
@ -99,7 +103,11 @@ const detailSections = computed(() => {
|
|||||||
{ label: '非遗资产应用成熟度', type: 'text', value: detail.application_maturity || detail.implementation_stage || '-' },
|
{ label: '非遗资产应用成熟度', type: 'text', value: detail.application_maturity || detail.implementation_stage || '-' },
|
||||||
{ label: '非遗资产应用覆盖范围', type: 'text', value: detail.application_coverage || detail.coverage_area || '-' },
|
{ label: '非遗资产应用覆盖范围', type: 'text', value: detail.application_coverage || detail.coverage_area || '-' },
|
||||||
{ label: '非遗资产跨界合作深度', type: 'text', value: detail.cooperation_depth || detail.collaboration_type || '-' },
|
{ label: '非遗资产跨界合作深度', type: 'text', value: detail.cooperation_depth || detail.collaboration_type || '-' },
|
||||||
{ label: '近12个月线下相关宣讲活动次数', type: 'text', value: formatNumberValue(detail.offline_activities) },
|
{
|
||||||
|
label: '近12个月线下相关宣讲活动次数',
|
||||||
|
type: 'text',
|
||||||
|
value: formatNumberValue(detail.offline_activities ?? detail.offline_teaching_count),
|
||||||
|
},
|
||||||
{ label: '线上相关宣传账号信息', type: 'list', value: formatPlatformAccounts(detail.platform_accounts) },
|
{ label: '线上相关宣传账号信息', type: 'list', value: formatPlatformAccounts(detail.platform_accounts) },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user