Compare commits
4 Commits
c19b0167e4
...
695769076a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
695769076a | ||
|
|
db31e25c61 | ||
|
|
28a5607dad | ||
|
|
3db6b38e2e |
@ -14,6 +14,8 @@ 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 {
|
||||||
@ -34,6 +36,7 @@ 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')
|
||||||
|
|
||||||
@ -313,11 +316,30 @@ const handleViewCertificate = () => {
|
|||||||
certificateModalVisible.value = true
|
certificateModalVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleCertificateConfirm = (data) => {
|
const handleCertificateConfirm = async (data) => {
|
||||||
console.log('证书数据:', data)
|
console.log('证书数据:', data)
|
||||||
// 这里可以调用 API 保存证书数据
|
|
||||||
$message?.success('证书上传成功')
|
try {
|
||||||
certificateModalVisible.value = false
|
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
|
||||||
|
emit('back') // 或者 emit('refresh') 取决于需求,这里假设返回列表或刷新
|
||||||
|
} catch (error) {
|
||||||
|
console.error('更新失败:', error)
|
||||||
|
$message.error('操作失败')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -7,11 +7,14 @@ 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,
|
||||||
@ -28,15 +31,17 @@ 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,
|
||||||
@ -44,14 +49,10 @@ watch(
|
|||||||
if (val) {
|
if (val) {
|
||||||
if (props.mode === 'view') {
|
if (props.mode === 'view') {
|
||||||
// 查看模式,加载已有数据
|
// 查看模式,加载已有数据
|
||||||
reportFileList.value = props.certificateData?.reportFiles || []
|
reportFileList.value = (props.certificateData?.reportFiles || []).map(f => ({ ...f, status: 'finished' }))
|
||||||
certificateFileList.value = props.certificateData?.certificateFiles || []
|
certificateFileList.value = (props.certificateData?.certificateFiles || []).map(f => ({ ...f, status: 'finished' }))
|
||||||
} else {
|
} else {
|
||||||
// 上传模式,清空数据
|
// 上传模式,清空数据
|
||||||
formData.value = {
|
|
||||||
reportFiles: [],
|
|
||||||
certificateFiles: [],
|
|
||||||
}
|
|
||||||
reportFileList.value = []
|
reportFileList.value = []
|
||||||
certificateFileList.value = []
|
certificateFileList.value = []
|
||||||
}
|
}
|
||||||
@ -64,11 +65,19 @@ 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: formData.value.reportFiles,
|
reportFiles: getFiles(reportFileList.value),
|
||||||
certificateFiles: formData.value.certificateFiles,
|
certificateFiles: getFiles(certificateFileList.value)
|
||||||
})
|
})
|
||||||
handleClose()
|
handleClose()
|
||||||
}
|
}
|
||||||
@ -82,56 +91,74 @@ 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 }) => {
|
// 报告上传完成
|
||||||
reportFileList.value = newFileList
|
const handleReportUploadFinish = ({ file, event }) => {
|
||||||
formData.value.reportFiles = newFileList.map(file => ({
|
try {
|
||||||
id: file.id,
|
const res = JSON.parse(event.target.response)
|
||||||
name: file.name,
|
if (res.code === 200 && res.data?.url) {
|
||||||
url: file.url,
|
file.url = res.data.url
|
||||||
type: file.type
|
file.name = res.data.filename || file.name
|
||||||
}))
|
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 }) => {
|
// 证书上传完成
|
||||||
certificateFileList.value = newFileList
|
const handleCertificateUploadFinish = ({ file, event }) => {
|
||||||
formData.value.certificateFiles = newFileList.map(file => ({
|
try {
|
||||||
id: file.id,
|
const res = JSON.parse(event.target.response)
|
||||||
name: file.name,
|
if (res.code === 200 && res.data?.url) {
|
||||||
url: file.url,
|
file.url = res.data.url
|
||||||
type: file.type
|
file.name = res.data.filename || file.name
|
||||||
}))
|
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 removeCertificateFile = (index) => {
|
const modalTitle = computed(() => {
|
||||||
certificateFileList.value.splice(index, 1)
|
return props.mode === 'upload' ? '上传' : '查看'
|
||||||
formData.value.certificateFiles = certificateFileList.value.map(file => ({
|
})
|
||||||
id: file.id,
|
|
||||||
name: file.name,
|
const isUploadMode = computed(() => props.mode === 'upload')
|
||||||
url: file.url || '',
|
|
||||||
type: file.type || ''
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 下载报告
|
// 下载报告
|
||||||
@ -145,37 +172,12 @@ 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>
|
||||||
@ -201,12 +203,13 @@ const isUploadMode = computed(() => props.mode === 'upload')
|
|||||||
<div class="upload-content">
|
<div class="upload-content">
|
||||||
<NUpload
|
<NUpload
|
||||||
v-model:file-list="reportFileList"
|
v-model:file-list="reportFileList"
|
||||||
:max="5"
|
multiple
|
||||||
list-type="image-card"
|
list-type="image-card"
|
||||||
|
:action="uploadUrl"
|
||||||
|
:headers="uploadHeaders"
|
||||||
:before-upload="beforeUpload"
|
:before-upload="beforeUpload"
|
||||||
@change="handleReportUploadChange"
|
@finish="handleReportUploadFinish"
|
||||||
@remove="handleRemove"
|
|
||||||
:custom-request="customRequest"
|
|
||||||
:disabled="!isUploadMode"
|
:disabled="!isUploadMode"
|
||||||
show-preview-button
|
show-preview-button
|
||||||
show-download-button
|
show-download-button
|
||||||
@ -222,12 +225,13 @@ const isUploadMode = computed(() => props.mode === 'upload')
|
|||||||
<div class="upload-content">
|
<div class="upload-content">
|
||||||
<NUpload
|
<NUpload
|
||||||
v-model:file-list="certificateFileList"
|
v-model:file-list="certificateFileList"
|
||||||
:max="5"
|
multiple
|
||||||
list-type="image-card"
|
list-type="image-card"
|
||||||
|
:action="uploadUrl"
|
||||||
|
:headers="uploadHeaders"
|
||||||
:before-upload="beforeUpload"
|
:before-upload="beforeUpload"
|
||||||
@change="handleCertificateUploadChange"
|
@finish="handleCertificateUploadFinish"
|
||||||
@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