Compare commits
No commits in common. "695769076af697b4aab679123d92c03950751c11" and "c19b0167e4c684473657174b308bfad129262d2f" have entirely different histories.
695769076a
...
c19b0167e4
@ -14,8 +14,6 @@ import {
|
|||||||
import { formatDate } from '@/utils'
|
import { formatDate } from '@/utils'
|
||||||
import TheIcon from '@/components/icon/TheIcon.vue'
|
import TheIcon from '@/components/icon/TheIcon.vue'
|
||||||
import CertificateModal from './CertificateModal.vue'
|
import CertificateModal from './CertificateModal.vue'
|
||||||
import api from '@/api'
|
|
||||||
import { useMessage } from 'naive-ui'
|
|
||||||
|
|
||||||
import { getStatusConfig } from '../constants'
|
import { getStatusConfig } from '../constants'
|
||||||
import {
|
import {
|
||||||
@ -36,7 +34,6 @@ const props = defineProps({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits(['back', 'approve', 'reject'])
|
const emit = defineEmits(['back', 'approve', 'reject'])
|
||||||
const $message = useMessage()
|
|
||||||
|
|
||||||
const activeDetailTab = ref('audit')
|
const activeDetailTab = ref('audit')
|
||||||
|
|
||||||
@ -316,30 +313,11 @@ const handleViewCertificate = () => {
|
|||||||
certificateModalVisible.value = true
|
certificateModalVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleCertificateConfirm = async (data) => {
|
const handleCertificateConfirm = (data) => {
|
||||||
console.log('证书数据:', data)
|
console.log('证书数据:', data)
|
||||||
|
// 这里可以调用 API 保存证书数据
|
||||||
try {
|
$message?.success('证书上传成功')
|
||||||
const certificateUrl = data.certificateFiles?.map(f => f.url).filter(Boolean) || []
|
|
||||||
const reportUrl = data.reportFiles?.map(f => f.url).filter(Boolean) || []
|
|
||||||
|
|
||||||
|
|
||||||
const payload = {
|
|
||||||
...props.detailData,
|
|
||||||
certificate_url: certificateUrl,
|
|
||||||
report_url: reportUrl,
|
|
||||||
status: 'success'
|
|
||||||
}
|
|
||||||
|
|
||||||
await api.updateValuation(payload)
|
|
||||||
|
|
||||||
$message.success('上传并通知成功')
|
|
||||||
certificateModalVisible.value = false
|
certificateModalVisible.value = false
|
||||||
emit('back') // 或者 emit('refresh') 取决于需求,这里假设返回列表或刷新
|
|
||||||
} catch (error) {
|
|
||||||
console.error('更新失败:', error)
|
|
||||||
$message.error('操作失败')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -7,14 +7,11 @@ import {
|
|||||||
NUpload,
|
NUpload,
|
||||||
NText,
|
NText,
|
||||||
NImage,
|
NImage,
|
||||||
NImageGroup,
|
NImageGroup
|
||||||
useMessage
|
|
||||||
} from 'naive-ui'
|
} from 'naive-ui'
|
||||||
// 临时移除图标导入以解决模块解析问题
|
// 临时移除图标导入以解决模块解析问题
|
||||||
// import { DownloadIcon } from '@vicons/tabler'
|
// import { DownloadIcon } from '@vicons/tabler'
|
||||||
|
|
||||||
import { getToken } from '@/utils/auth/token'
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
visible: {
|
visible: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@ -31,17 +28,15 @@ const props = defineProps({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits(['update:visible', 'confirm'])
|
const emit = defineEmits(['update:visible', 'confirm'])
|
||||||
const message = useMessage()
|
|
||||||
|
const formData = ref({
|
||||||
|
reportFiles: [],
|
||||||
|
certificateFiles: [],
|
||||||
|
})
|
||||||
|
|
||||||
const reportFileList = ref([])
|
const reportFileList = ref([])
|
||||||
const certificateFileList = ref([])
|
const certificateFileList = ref([])
|
||||||
|
|
||||||
const uploadUrl = `${import.meta.env.VITE_BASE_API}/upload/file`
|
|
||||||
const uploadHeaders = computed(() => ({
|
|
||||||
Authorization: `Bearer ${getToken()}`,
|
|
||||||
}))
|
|
||||||
|
|
||||||
// 监听弹窗打开,初始化数据
|
|
||||||
// 监听弹窗打开,初始化数据
|
// 监听弹窗打开,初始化数据
|
||||||
watch(
|
watch(
|
||||||
() => props.visible,
|
() => props.visible,
|
||||||
@ -49,10 +44,14 @@ watch(
|
|||||||
if (val) {
|
if (val) {
|
||||||
if (props.mode === 'view') {
|
if (props.mode === 'view') {
|
||||||
// 查看模式,加载已有数据
|
// 查看模式,加载已有数据
|
||||||
reportFileList.value = (props.certificateData?.reportFiles || []).map(f => ({ ...f, status: 'finished' }))
|
reportFileList.value = props.certificateData?.reportFiles || []
|
||||||
certificateFileList.value = (props.certificateData?.certificateFiles || []).map(f => ({ ...f, status: 'finished' }))
|
certificateFileList.value = props.certificateData?.certificateFiles || []
|
||||||
} else {
|
} else {
|
||||||
// 上传模式,清空数据
|
// 上传模式,清空数据
|
||||||
|
formData.value = {
|
||||||
|
reportFiles: [],
|
||||||
|
certificateFiles: [],
|
||||||
|
}
|
||||||
reportFileList.value = []
|
reportFileList.value = []
|
||||||
certificateFileList.value = []
|
certificateFileList.value = []
|
||||||
}
|
}
|
||||||
@ -65,19 +64,11 @@ const handleClose = () => {
|
|||||||
emit('update:visible', false)
|
emit('update:visible', false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 确认操作
|
|
||||||
// 确认操作
|
// 确认操作
|
||||||
const handleConfirm = () => {
|
const handleConfirm = () => {
|
||||||
const getFiles = (list) => list.map(f => ({
|
|
||||||
id: f.id,
|
|
||||||
name: f.name,
|
|
||||||
url: f.url,
|
|
||||||
type: f.type
|
|
||||||
})).filter(f => f.url)
|
|
||||||
|
|
||||||
emit('confirm', {
|
emit('confirm', {
|
||||||
reportFiles: getFiles(reportFileList.value),
|
reportFiles: formData.value.reportFiles,
|
||||||
certificateFiles: getFiles(certificateFileList.value)
|
certificateFiles: formData.value.certificateFiles,
|
||||||
})
|
})
|
||||||
handleClose()
|
handleClose()
|
||||||
}
|
}
|
||||||
@ -91,74 +82,56 @@ const beforeUpload = (data) => {
|
|||||||
const isVideo = file.type.startsWith('video/')
|
const isVideo = file.type.startsWith('video/')
|
||||||
|
|
||||||
if (!isImage && !isPdf && !isWord && !isVideo) {
|
if (!isImage && !isPdf && !isWord && !isVideo) {
|
||||||
message.error('只能上传图片、PDF、Word文档或视频文件')
|
$message.error('只能上传图片、PDF、Word文档或视频文件')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const isLt50M = file.size / 1024 / 1024 < 50
|
const isLt50M = file.size / 1024 / 1024 < 50
|
||||||
if (!isLt50M) {
|
if (!isLt50M) {
|
||||||
message.error('文件大小不能超过50MB')
|
$message.error('文件大小不能超过50MB')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// 报告上传完成
|
// 报告文件上传变化
|
||||||
// 报告上传完成
|
const handleReportUploadChange = ({ fileList: newFileList }) => {
|
||||||
const handleReportUploadFinish = ({ file, event }) => {
|
reportFileList.value = newFileList
|
||||||
try {
|
formData.value.reportFiles = newFileList.map(file => ({
|
||||||
const res = JSON.parse(event.target.response)
|
id: file.id,
|
||||||
if (res.code === 200 && res.data?.url) {
|
name: file.name,
|
||||||
file.url = res.data.url
|
url: file.url,
|
||||||
file.name = res.data.filename || file.name
|
type: file.type
|
||||||
file.status = 'finished'
|
}))
|
||||||
message.success('报告上传成功')
|
|
||||||
return file
|
|
||||||
} else {
|
|
||||||
message.error(res.message || '上传失败')
|
|
||||||
const index = reportFileList.value.findIndex((item) => item.id === file.id)
|
|
||||||
if (index > -1) reportFileList.value.splice(index, 1)
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('上传响应解析失败:', error)
|
|
||||||
message.error('上传失败:服务器响应异常')
|
|
||||||
const index = reportFileList.value.findIndex((item) => item.id === file.id)
|
|
||||||
if (index > -1) reportFileList.value.splice(index, 1)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 证书上传完成
|
// 证书文件上传变化
|
||||||
// 证书上传完成
|
const handleCertificateUploadChange = ({ fileList: newFileList }) => {
|
||||||
const handleCertificateUploadFinish = ({ file, event }) => {
|
certificateFileList.value = newFileList
|
||||||
try {
|
formData.value.certificateFiles = newFileList.map(file => ({
|
||||||
const res = JSON.parse(event.target.response)
|
id: file.id,
|
||||||
if (res.code === 200 && res.data?.url) {
|
name: file.name,
|
||||||
file.url = res.data.url
|
url: file.url,
|
||||||
file.name = res.data.filename || file.name
|
type: file.type
|
||||||
file.status = 'finished'
|
}))
|
||||||
message.success('证书上传成功')
|
|
||||||
return file
|
|
||||||
} else {
|
|
||||||
message.error(res.message || '上传失败')
|
|
||||||
const index = certificateFileList.value.findIndex((item) => item.id === file.id)
|
|
||||||
if (index > -1) certificateFileList.value.splice(index, 1)
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('上传响应解析失败:', error)
|
|
||||||
message.error('上传失败:服务器响应异常')
|
|
||||||
const index = certificateFileList.value.findIndex((item) => item.id === file.id)
|
|
||||||
if (index > -1) certificateFileList.value.splice(index, 1)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 移除文件
|
||||||
|
const handleRemove = () => {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 移除证书文件
|
||||||
const modalTitle = computed(() => {
|
const removeCertificateFile = (index) => {
|
||||||
return props.mode === 'upload' ? '上传' : '查看'
|
certificateFileList.value.splice(index, 1)
|
||||||
})
|
formData.value.certificateFiles = certificateFileList.value.map(file => ({
|
||||||
|
id: file.id,
|
||||||
const isUploadMode = computed(() => props.mode === 'upload')
|
name: file.name,
|
||||||
|
url: file.url || '',
|
||||||
|
type: file.type || ''
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 下载报告
|
// 下载报告
|
||||||
@ -172,12 +145,37 @@ const handleDownloadReport = () => {
|
|||||||
const handlePreview = (file) => {
|
const handlePreview = (file) => {
|
||||||
// 对于非图片文件,显示提示
|
// 对于非图片文件,显示提示
|
||||||
if (!file.type?.startsWith('image/')) {
|
if (!file.type?.startsWith('image/')) {
|
||||||
message.info('此文件类型不支持预览,请下载查看')
|
$message.info('此文件类型不支持预览,请下载查看')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// 图片文件返回 true,让 NUpload 使用内置预览
|
// 图片文件返回 true,让 NUpload 使用内置预览
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 文件下载
|
||||||
|
const handleDownload = (file) => {
|
||||||
|
const link = document.createElement('a')
|
||||||
|
link.href = file.url || ''
|
||||||
|
link.download = file.name || 'download'
|
||||||
|
document.body.appendChild(link)
|
||||||
|
link.click()
|
||||||
|
document.body.removeChild(link)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 自定义上传预览
|
||||||
|
const customRequest = ({ file, onFinish, onError }) => {
|
||||||
|
// 这里可以实现自定义上传逻辑
|
||||||
|
// 暂时模拟上传成功
|
||||||
|
setTimeout(() => {
|
||||||
|
onFinish()
|
||||||
|
}, 1000)
|
||||||
|
}
|
||||||
|
|
||||||
|
const modalTitle = computed(() => {
|
||||||
|
return props.mode === 'upload' ? '上传' : '查看'
|
||||||
|
})
|
||||||
|
|
||||||
|
const isUploadMode = computed(() => props.mode === 'upload')
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -203,13 +201,12 @@ const handlePreview = (file) => {
|
|||||||
<div class="upload-content">
|
<div class="upload-content">
|
||||||
<NUpload
|
<NUpload
|
||||||
v-model:file-list="reportFileList"
|
v-model:file-list="reportFileList"
|
||||||
multiple
|
:max="5"
|
||||||
list-type="image-card"
|
list-type="image-card"
|
||||||
:action="uploadUrl"
|
|
||||||
:headers="uploadHeaders"
|
|
||||||
:before-upload="beforeUpload"
|
:before-upload="beforeUpload"
|
||||||
@finish="handleReportUploadFinish"
|
@change="handleReportUploadChange"
|
||||||
|
@remove="handleRemove"
|
||||||
|
:custom-request="customRequest"
|
||||||
:disabled="!isUploadMode"
|
:disabled="!isUploadMode"
|
||||||
show-preview-button
|
show-preview-button
|
||||||
show-download-button
|
show-download-button
|
||||||
@ -225,13 +222,12 @@ const handlePreview = (file) => {
|
|||||||
<div class="upload-content">
|
<div class="upload-content">
|
||||||
<NUpload
|
<NUpload
|
||||||
v-model:file-list="certificateFileList"
|
v-model:file-list="certificateFileList"
|
||||||
multiple
|
:max="5"
|
||||||
list-type="image-card"
|
list-type="image-card"
|
||||||
:action="uploadUrl"
|
|
||||||
:headers="uploadHeaders"
|
|
||||||
:before-upload="beforeUpload"
|
:before-upload="beforeUpload"
|
||||||
@finish="handleCertificateUploadFinish"
|
@change="handleCertificateUploadChange"
|
||||||
|
@remove="handleRemove"
|
||||||
|
:custom-request="customRequest"
|
||||||
:disabled="!isUploadMode"
|
:disabled="!isUploadMode"
|
||||||
show-preview-button
|
show-preview-button
|
||||||
show-download-button
|
show-download-button
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user