feat: 优化评估审核页面数据展示逻辑,调整发票邮件发送附件处理并移除mock数据

This commit is contained in:
Wei_佳 2025-11-21 10:55:31 +08:00
parent a0e857b115
commit e479bcfa97
3 changed files with 76 additions and 19 deletions

View File

@ -1,6 +1,7 @@
<script setup>
import { ref, watch } from 'vue'
import { NModal, NCard, NForm, NFormItem, NInput, NButton, NUpload, NSpace, NText } from 'naive-ui'
import { ref, watch, computed } from 'vue'
import { NModal, NCard, NForm, NFormItem, NInput, NButton, NUpload, NSpace, NText, useMessage } from 'naive-ui'
import { getToken } from '@/utils/auth/token'
const props = defineProps({
visible: {
@ -27,6 +28,12 @@ const formData = ref({
})
const fileList = ref([])
const $message = useMessage()
const uploadUrl = `${import.meta.env.VITE_BASE_API}/upload/file`
const uploadHeaders = computed(() => ({
Authorization: `Bearer ${getToken()}`,
}))
//
watch(
@ -80,10 +87,42 @@ const beforeUpload = (data) => {
return true
}
//
const handleUploadChange = ({ fileList: newFileList }) => {
fileList.value = newFileList
formData.value.attachments = newFileList.map(file => file.id || file.name)
//
const handleUploadFinish = ({ file, event }) => {
try {
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)
if (index > -1) {
fileList.value.splice(index, 1)
updateAttachments()
}
return true
}
@ -157,8 +197,10 @@ const modalTitle = props.mode === 'invoice' ? '开票' : '查看发票'
multiple
:max="2"
list-type="image-card"
:action="uploadUrl"
:headers="uploadHeaders"
:before-upload="beforeUpload"
@change="handleUploadChange"
@finish="handleUploadFinish"
@remove="handleRemove"
:disabled="mode === 'view'"
>

View File

@ -236,18 +236,25 @@ async function fetchDetail(row) {
}
//
async function handleInvoiceConfirm(data) {
//
async function handleInvoiceConfirm(formData) {
try {
await api.sendInvoice({
email: data.email,
subject: data.subject,
body: data.body,
file_url: data.file_url || currentInvoice.value?.receipt?.url,
})
// 'loc': ('body', 'data') data
const payload = {
data: {
email: formData.email,
subject: formData.email, // subject email
body: formData.content, // content -> body
file_url: formData.attachments?.[0] || '', // attachments -> file_url
}
}
await api.sendInvoice(payload)
$message.success('发送成功')
invoiceModalVisible.value = false
$table.value?.handleSearch()
} catch (error) {
console.error(error)
$message.error(error?.message || '操作失败')
}
}

View File

@ -60,9 +60,9 @@ const detailSections = computed(() => {
fields: [
{ label: '资产名称', type: 'text', value: detail.asset_name || '-' },
{ 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.business_heritage_intro || '-' },
{ label: '业务/传承介绍', type: 'text', value: detail.business_heritage_intro || detail.biz_intro || '-' },
],
},
{
@ -80,9 +80,13 @@ const detailSections = computed(() => {
title: '非遗等级与技术',
fields: [
{ 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: '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: '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_coverage || detail.coverage_area || '-' },
{ 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) },
],
},