文件编辑问题修复,添加文件预览功能

This commit is contained in:
LHD_HY 2025-11-18 14:52:37 +08:00
parent 82bab0ea11
commit df332f8138
12 changed files with 323 additions and 358 deletions

View File

@ -105,7 +105,8 @@ export default {
name: item.fileName || '未知文件',
filePath: item.filePath || '',
lsFilePath: item.lsFilePath || '', //
fileType: item.fileType || '2' //
fileType: item.fileType || '2', //
id: item.sourceId + ''
}))
},

View File

@ -1,5 +1,4 @@
<template>
<!-- 模板部分保持不变 -->
<div>
<div class="basic-info-title">
<img src="@/assets/enterpriseLibrary/basic-info.png" alt="财务报告">
@ -13,12 +12,11 @@
label-width="110px"
label-position="top"
>
<!-- 财务报告上传 -->
<el-row :gutter="24">
<el-col :span="8">
<el-form-item label="财务报告附件" prop="fileList">
<UploadFile
:fileList="formatFileList()"
:fileList="formData.fileList"
:fileUploadRule="financeReportUploadRule"
@file-change="(files, type) => handleFileChange(files, type)"
@del-file="handleDelFile"
@ -32,7 +30,6 @@
</el-col>
</el-row>
<!-- 文件名 -->
<el-row :gutter="24" class="info-row">
<el-col :span="8" class="info-col">
<el-form-item label="文件名" prop="fileName">
@ -46,7 +43,6 @@
</el-form-item>
</el-col>
<!-- 报告年份 -->
<el-col :span="8" class="info-col">
<el-form-item label="报告年份" prop="reportYear">
<el-date-picker
@ -81,10 +77,10 @@ export default {
"报告年份": "reportYear"
},
formData: {
fileList: [], //
fileList: [],
fileName: '',
reportYear: '', // "2023"
delFileList: [] //
reportYear: '',
delFileList: []
},
rules: {
fileList: [
@ -96,7 +92,8 @@ export default {
reportYear: [
{ required: true, message: '请选择报告年份', trigger: 'change' }
]
}
},
isReplacingFile: false //
}
},
computed: {
@ -115,51 +112,33 @@ export default {
}
},
methods: {
//
setFormData(data) {
// uid
const financeFiles = Array.isArray(data.fileList)
? data.fileList.filter(file => file && file.businessType === 'finance_report')
: []
.map(file => ({
name: file.name || file.fileName || '未知文件',
filePath: file.filePath,
lsFilePath: file.lsFilePath,
fileType: file.fileType || '2',
businessType: 'finance_report'
}))
: [];
this.formData = {
...data,
...(data || {}),
fileList: financeFiles,
fileName: financeFiles.length > 0 ? this.getFileName(financeFiles[0]) : '',
delFileList: []
}
},
// UploadFile
formatFileList() {
return this.formData.fileList.map((file, index) => {
const fileExt = this.getFileExt(file)
return {
...file,
uid: file.uid || file.filePath || `${Date.now()}-${index}`,
name: this.getFileName(file), // 使
status: file.status || 'success',
percentage: file.percentage || 100,
fileType: file.fileType || '2'
}
})
},
//
getFileName(file) {
//
const fullName = file.name || file.fileName || `未命名文件.${this.getFileExt(file)}`
//
const fullName = file.name || file.fileName || '未知文件'
const lastDotIndex = fullName.lastIndexOf('.')
//
if (lastDotIndex > 0) {
return fullName.substring(0, lastDotIndex)
}
return fullName
return lastDotIndex > 0 ? fullName.substring(0, lastDotIndex) : fullName
},
//
getFileExt(file) {
if (!file) return ''
const fileName = file.name || file.fileName || ''
@ -167,37 +146,53 @@ export default {
return extMatch ? extMatch[1].toLowerCase() : ''
},
//
handleFileChange(files, type) {
if (type === 'finance_report') {
const markedFiles = files.map(file => ({
...file,
businessType: 'finance_report',
name: file.name || file.fileName || '未知文件'
}))
this.formData.fileList = markedFiles
if (type === 'finance_report' && files instanceof Array) {
//
if (files.length > 0 && files[0].response) { //
//
this.isReplacingFile = false;
if (markedFiles.length > 0) {
const originalFileName = this.getFileName(markedFiles[0]) // 使
const safeFileName = originalFileName.replace(/--+/g, '-')
this.formData.fileName = safeFileName
this.$refs.financeReportForm.validateField('fileName')
this.$message.success(`文件名已自动提取:${safeFileName}`)
//
if (this.formData.fileList.length > 0) {
const oldFile = this.formData.fileList[0];
const delPath = oldFile?.response?.fileRes?.filePath || oldFile?.filePath || null;
if (delPath && !this.formData.delFileList.includes(delPath)) {
this.formData.delFileList.push(delPath);
}
}
const markedFiles = files.map(file => ({
...file,
businessType: 'finance_report'
})).slice(-1);
this.formData.fileList = markedFiles;
//
if (markedFiles.length > 0) {
const originalFileName = this.getFileName(markedFiles[0])
const safeFileName = originalFileName.replace(/--+/g, '-')
this.formData.fileName = safeFileName
this.$refs.financeReportForm.validateField('fileName')
}
this.handleOcrResult(markedFiles)
} else if (!this.isReplacingFile) {
//
this.formData.fileList = [];
this.formData.fileName = '';
}
this.handleOcrResult(markedFiles)
}
},
//
handleDelFile(file) {
const filePath = file.filePath || file.response?.fileRes?.uploadPath
if (filePath && !this.formData.delFileList.includes(filePath)) {
this.formData.delFileList.push(filePath)
//
this.isReplacingFile = true;
const delPath = file?.response?.fileRes?.filePath || file?.filePath || null;
if (delPath && !this.formData.delFileList.includes(delPath)) {
this.formData.delFileList.push(delPath);
}
this.formData.fileList = []
this.formData.fileName = ''
this.formData.reportYear = ''
},
handleOcrResult(files) {
@ -264,6 +259,7 @@ export default {
reportYear: '',
delFileList: []
}
this.isReplacingFile = false;
},
addOcrRule() {
@ -292,7 +288,6 @@ export default {
</script>
<style scoped lang="scss">
/* 样式部分保持不变 */
.basic-info-title {
display: flex;
align-items: center;

View File

@ -12,12 +12,11 @@
label-width="110px"
label-position="top"
>
<!-- 财务报表上传 -->
<el-row :gutter="24" class="data-row">
<el-col :span="8" class="data-col">
<el-form-item label="财务报表附件" prop="fileList" class="data-item">
<UploadFile
:fileList="formatFileList()"
:fileList="formData.fileList"
:fileUploadRule="financialStatementUploadRule"
@file-change="(files, type) => handleFileChange(files, type)"
@del-file="handleDelFile"
@ -31,7 +30,6 @@
</el-col>
</el-row>
<!-- 财务数据字段三列布局 -->
<el-row :gutter="24" class="data-row">
<el-col :span="8" class="data-col">
<el-form-item label="营业收入" prop="operatingIncome" class="data-item">
@ -163,7 +161,7 @@ export default {
"资产负债率": "assetLiabilityRatio"
},
formData: {
fileList: [], //
fileList: [],
operatingIncome: '',
currentAssets: '',
currentLiabilities: '',
@ -174,7 +172,7 @@ export default {
totalLiabilities: '',
totalAssets: '',
assetLiabilityRatio: '',
delFileList: [] //
delFileList: []
},
rules: {
fileList: [
@ -213,7 +211,8 @@ export default {
{ required: true, message: '资产负债率为必填项', trigger: 'blur' },
{ pattern: /^\d+(\.\d+)?%?$/, message: '请输入有效的资产负债率如1或1%', trigger: 'blur' }
]
}
},
isReplacingFile: false //
}
},
computed: {
@ -232,43 +231,30 @@ export default {
}
},
methods: {
//
setFormData(data) {
// businessType=financial_statement
// uid
const financialFiles = Array.isArray(data.fileList)
? data.fileList.filter(file => file && file.businessType === 'financial_statement')
: []
.map(file => ({
name: file.name || file.fileName || '未知文件',
filePath: file.filePath,
lsFilePath: file.lsFilePath,
fileType: file.fileType || '2',
businessType: 'financial_statement'
}))
: [];
this.formData = {
...data,
fileList: financialFiles, //
delFileList: [] //
...(data || {}),
fileList: financialFiles,
delFileList: []
}
},
// UploadFile
formatFileList() {
return this.formData.fileList.map((file, index) => {
//
const fileExt = this.getFileExt(file)
return {
...file,
//
uid: file.uid || file.filePath || `${Date.now()}-${index}`, //
name: this.getFileName(file), //
status: file.status || 'success', //
percentage: file.percentage || 100, // 100%
fileType: file.fileType || '2' //
}
})
},
//
getFileName(file) {
return file.name || file.fileName || `未命名文件.${this.getFileExt(file)}`
return file.name || file.fileName || '未知文件'
},
//
getFileExt(file) {
if (!file) return ''
const fileName = file.name || file.fileName || ''
@ -276,25 +262,39 @@ export default {
return extMatch ? extMatch[1].toLowerCase() : ''
},
//
handleFileChange(files, type) {
if (type === 'financial_statement') {
// businessTypename
const markedFiles = files.map(file => ({
...file,
businessType: 'financial_statement',
name: file.name || file.fileName || '未知文件' // name
}))
this.formData.fileList = markedFiles //
this.handleOcrResult(markedFiles)
if (type === 'financial_statement' && files instanceof Array) {
//
if (files.length > 0 && files[0].response) { //
//
this.isReplacingFile = false;
//
if (this.formData.fileList.length > 0) {
const oldFile = this.formData.fileList[0];
const delPath = oldFile?.response?.fileRes?.filePath || oldFile?.filePath || null;
if (delPath && !this.formData.delFileList.includes(delPath)) {
this.formData.delFileList.push(delPath);
}
}
const markedFiles = files.map(file => ({
...file,
businessType: 'financial_statement'
})).slice(-1);
this.formData.fileList = markedFiles;
this.handleOcrResult(markedFiles)
} else if (!this.isReplacingFile) {
//
this.formData.fileList = [];
}
}
},
// OCR
handleOcrResult(files) {
if (!files || !Array.isArray(files) || files.length === 0) return
//
this.$bus.$emit('startUpload', '正在识别财务数据')
try {
@ -307,7 +307,6 @@ export default {
Object.keys(chat_res).forEach(key => {
const formField = this.ocrResultParams[key]
if (formField && chat_res[key]) {
//
if (['operatingIncome', 'currentAssets', 'currentLiabilities', 'currentRatio',
'netProfit', 'shareholdersEquity', 'returnOnNetAssets', 'totalLiabilities',
'totalAssets', 'assetLiabilityRatio'].includes(formField)) {
@ -327,23 +326,20 @@ export default {
} catch (error) {
this.$message.error(`处理识别结果失败: ${error.message}`)
} finally {
//
this.$bus.$emit('endUpload')
}
},
//
handleDelFile(file) {
//
const filePath = file.filePath || file.response?.fileRes?.uploadPath
if (filePath && !this.formData.delFileList.includes(filePath)) {
this.formData.delFileList.push(filePath)
//
this.isReplacingFile = true;
const delPath = file?.response?.fileRes?.filePath || file?.filePath || null;
if (delPath && !this.formData.delFileList.includes(delPath)) {
this.formData.delFileList.push(delPath);
}
//
this.formData.fileList = []
},
//
validate() {
return new Promise((resolve, reject) => {
if (!this.$refs.financialStatementForm) {
@ -361,7 +357,6 @@ export default {
})
},
//
resetForm() {
if (this.$refs.financialStatementForm) {
this.$refs.financialStatementForm.resetFields()
@ -380,16 +375,15 @@ export default {
assetLiabilityRatio: '',
delFileList: []
}
this.isReplacingFile = false;
},
// OCR
addOcrRule() {
this.ocrRuleList.forEach(item => {
this.ocrRule(item)
})
},
// OCR
ocrRule(type) {
const foundItem = this.dict.type.identification_tag?.find(item => item.value === type)
if (!foundItem) {
@ -468,7 +462,6 @@ export default {
margin-top: 5px;
}
/* 优化上传组件样式,确保文件列表正确显示 */
::v-deep .upload-container {
::v-deep .el-upload-dragger {
height: 180px;

View File

@ -208,7 +208,8 @@ export default {
name: item.fileName || '未知文件',
filePath: item.filePath || '',
lsFilePath: item.lsFilePath || '', //
fileType: item.fileType || '2' //
fileType: item.fileType || '2', //
id: item.sourceId + ''
}))
},

View File

@ -139,18 +139,6 @@ export default {
this.$refs.otherInfo.validate()
])
// 2.
if (this.type === 'add' || (this.type === 'edit' && contractData.proName !== this.originalProName)) {
const isUnique = await checkProNameUnique({
proName: contractData.proName,
enterpriseId: this.enterpriseId,
performanceId: this.id || null
})
if (!isUnique) {
throw new Error('同一企业下项目名称已存在,请更换')
}
}
// 3.
const formData = {
...contractData,
@ -193,15 +181,15 @@ export default {
}
// 7.
// if (otherData.performanceFileList && otherData.performanceFileList.length) {
// const performanceFiles = otherData.performanceFileList.map(file =>
// file.response?.fileRes ? { ...file.response.fileRes, businessType: 'team_performance' } : null
// ).filter(Boolean)
// formData.files.push(...performanceFiles)
// }
// if (otherData.delFileList && otherData.delFileList.length) {
// formData.delFiles.push(...otherData.delFileList)
// }
if (otherData.performanceFileList && otherData.performanceFileList.length) {
const performanceFiles = otherData.performanceFileList.map(file =>
file.response?.fileRes ? { ...file.response.fileRes, businessType: 'team_performance' } : null
).filter(Boolean)
formData.files.push(...performanceFiles)
}
if (otherData.delFileList && otherData.delFileList.length) {
formData.delFiles.push(...otherData.delFileList)
}
// 8.
['fileList', 'completionReportFileList', 'bidNoticeFileList', 'performanceFileList', 'delFileList'].forEach(key => {
@ -242,6 +230,7 @@ export default {
const bidFiles = fileList.filter(f => f.businessType === 'bid_notice')
const teamFiles = fileList.filter(f => f.businessType === 'team_performance')
//
this.$refs.contractInfo.setFormData({
...performanceData,

View File

@ -12,12 +12,11 @@
label-width="110px"
label-position="top"
>
<!-- 竣工报告 -->
<el-row :gutter="24">
<el-col :span="8">
<el-form-item label="竣工报告附件" prop="completionReportFileList">
<UploadFile
:fileList="formatFileList('completionReportFileList')"
:fileList="formData.completionReportFileList"
:fileUploadRule="completionReportUploadRule"
@file-change="(files, type) => handleFileChange('completionReportFileList', files, type)"
@del-file="(file) => handleDelFile('completionReportFileList', file)"
@ -30,11 +29,10 @@
</el-form-item>
</el-col>
<!-- 中标通知书 -->
<el-col :span="8">
<el-form-item label="中标通知书附件" prop="bidNoticeFileList">
<UploadFile
:fileList="formatFileList('bidNoticeFileList')"
:fileList="formData.bidNoticeFileList"
:fileUploadRule="bidNoticeUploadRule"
@file-change="(files, type) => handleFileChange('bidNoticeFileList', files, type)"
@del-file="(file) => handleDelFile('bidNoticeFileList', file)"
@ -48,7 +46,6 @@
</el-col>
</el-row>
<!-- 时间信息 -->
<el-row :gutter="24">
<el-col :span="8">
<el-form-item label="开工时间" prop="startTime">
@ -119,6 +116,10 @@ export default {
bidNoticeFileList: [
{ required: true, message: '请上传中标通知书附件', trigger: 'change' }
]
},
replacingFiles: {
completionReportFileList: false,
bidNoticeFileList: false
}
}
},
@ -142,48 +143,43 @@ export default {
}
},
methods: {
//
setFormData(data) {
const completionFiles = Array.isArray(data.completionReportFileList)
? data.completionReportFileList.filter(file => file && file.businessType === 'completion_report')
: []
const bidFiles = Array.isArray(data.bidNoticeFileList)
? data.bidNoticeFileList.filter(file => file && file.businessType === 'bid_notice')
: []
// uid
const completionFiles = Array.isArray(data.fileList)
? data.fileList.filter(file => file && file.businessType === 'completion_report')
.map(file => ({
name: file.name || file.fileName || '未知文件',
filePath: file.filePath,
lsFilePath: file.lsFilePath,
fileType: file.fileType || '2',
businessType: 'completion_report'
}))
: [];
// uid
const bidFiles = Array.isArray(data.fileList)
? data.fileList.filter(file => file && file.businessType === 'bid_notice')
.map(file => ({
name: file.name || file.fileName || '未知文件',
filePath: file.filePath,
lsFilePath: file.lsFilePath,
fileType: file.fileType || '2',
businessType: 'bid_notice'
}))
: [];
this.formData = {
...data,
...(data || {}),
completionReportFileList: completionFiles,
bidNoticeFileList: bidFiles,
delFileList: []
}
},
//
formatFileList(field) {
return this.formData[field].map((file, index) => {
const fileExt = this.getFileExt(file)
const businessType = field === 'completionReportFileList' ? 'completion_report' : 'bid_notice'
return {
...file,
uid: file.uid || file.filePath || `${Date.now()}-${index}-${field}`,
name: this.getFileName(file),
status: file.status || 'success',
percentage: file.percentage || 100,
fileType: file.fileType || '2',
businessType
}
})
},
//
getFileName(file) {
const fullName = file.name || file.fileName || `未命名文件.${this.getFileExt(file)}`
const lastDotIndex = fullName.lastIndexOf('.')
return lastDotIndex > 0 ? fullName.substring(0, lastDotIndex) : fullName
return file.name || file.fileName || '未知文件'
},
//
getFileExt(file) {
if (!file) return ''
const fileName = file.name || file.fileName || ''
@ -191,22 +187,43 @@ export default {
return extMatch ? extMatch[1].toLowerCase() : ''
},
//
handleFileChange(field, files, type) {
const markedFiles = files.map(file => ({
...file,
businessType: type,
name: file.name || file.fileName || '未知文件'
}))
this.formData[field] = markedFiles
if (files instanceof Array) {
//
if (files.length > 0) {
//
this.replacingFiles[field] = false;
// OCR
if (field === 'completionReportFileList' && type === 'completion_report') {
this.handleOcrResult(markedFiles)
const markedFiles = files
.map(file => ({
...file,
businessType: type
}))
.slice(-1); // 1
//
if (this.formData[field].length > 0) {
const oldFile = this.formData[field][0];
const delPath = oldFile?.response?.fileRes?.filePath || oldFile?.filePath || null;
if (delPath && !this.formData.delFileList.includes(delPath)) {
this.formData.delFileList.push(delPath);
}
}
//
this.formData[field] = markedFiles;
// OCR
if (field === 'completionReportFileList' && type === 'completion_report' && markedFiles[0].response) {
this.handleOcrResult(markedFiles)
}
} else if (!this.replacingFiles[field]) {
//
this.formData[field] = [];
}
}
},
// OCR
handleOcrResult(files) {
if (!files?.length) return
@ -235,17 +252,16 @@ export default {
}
},
//
handleDelFile(field, file) {
const filePath = file.filePath || file.response?.fileRes?.uploadPath
if (filePath && !this.formData.delFileList.includes(filePath)) {
this.formData.delFileList.push(filePath)
//
this.replacingFiles[field] = true;
const delPath = file?.response?.fileRes?.filePath || file?.filePath || null;
if (delPath && !this.formData.delFileList.includes(delPath)) {
this.formData.delFileList.push(delPath);
}
//
this.formData[field] = []
},
//
disabledFutureDate(date) {
return date > new Date()
},
@ -265,7 +281,6 @@ export default {
}
},
//
validate() {
return new Promise((resolve, reject) => {
if (!this.$refs.completionForm) {
@ -288,7 +303,6 @@ export default {
})
},
//
resetForm() {
if (this.$refs.completionForm) {
this.$refs.completionForm.resetFields()
@ -300,9 +314,12 @@ export default {
completionTime: '',
delFileList: []
}
this.replacingFiles = {
completionReportFileList: false,
bidNoticeFileList: false
}
},
// OCR
addOcrRule() {
this.ocrRuleList.forEach(item => this.ocrRule(item))
},

View File

@ -112,7 +112,8 @@ export default {
name: item.fileName || '未知文件',
filePath: item.filePath || '',
lsFilePath: item.lsFilePath || '',
fileType: item.fileType || '2'
fileType: item.fileType || '2',
id: item.sourceId + ''
}))
},

View File

@ -16,7 +16,7 @@
<el-col :span="8">
<el-form-item label="合同附件" prop="fileList">
<UploadFile
:fileList="formatFileList()"
:fileList="formData.fileList"
:fileUploadRule="contractUploadRule"
@file-change="(files, type) => handleFileChange(files, type)"
@del-file="handleDelFile"
@ -24,6 +24,7 @@
:maxFileTips="maxFileTips"
type="contract"
:show-file-list="true"
:limitUploadNum="1"
/>
</el-form-item>
</el-col>
@ -42,7 +43,6 @@
</el-form-item>
</el-col>
<!-- 合同签订时间 -->
<el-col :span="8">
<el-form-item label="合同签订时间" prop="contractSigningTime">
<el-date-picker
@ -56,7 +56,6 @@
</el-form-item>
</el-col>
<!-- 合同金额 -->
<el-col :span="8">
<el-form-item label="合同金额" prop="contractAmount">
<el-input
@ -72,7 +71,6 @@
</el-col>
</el-row>
<!-- 建设地点 -->
<el-row :gutter="24">
<el-col :span="8">
<el-form-item label="建设地点" prop="constructionSite">
@ -81,12 +79,11 @@
placeholder="请输入建设地点"
class="form-control"
show-word-limit
maxlength="32"
maxlength="100"
></el-input>
</el-form-item>
</el-col>
<!-- 建设单位 -->
<el-col :span="8">
<el-form-item label="建设单位" prop="constructionUnit">
<el-input
@ -94,12 +91,11 @@
placeholder="请输入建设单位"
class="form-control"
show-word-limit
maxlength="32"
maxlength="100"
></el-input>
</el-form-item>
</el-col>
<!-- 建设单位联系方式 -->
<el-col :span="8">
<el-form-item label="建设单位联系方式" prop="constructionPhone">
<el-input
@ -137,14 +133,14 @@ export default {
"建设单位联系方式": "constructionPhone"
},
formData: {
fileList: [], //
fileList: [],
proName: '',
contractSigningTime: '',
contractAmount: '',
constructionSite: '',
constructionUnit: '',
constructionPhone: '',
delFileList: [] //
delFileList: []
},
rules: {
proName: [
@ -169,7 +165,8 @@ export default {
{ required: true, message: '请输入建设单位联系方式', trigger: 'blur' },
{ pattern: /^1[3-9]\d{9}$/, message: '请输入有效的手机号码', trigger: 'blur' }
]
}
},
isReplacingFile: false //
}
},
computed: {
@ -188,43 +185,30 @@ export default {
}
},
methods: {
//
setFormData(data) {
// uid
const contractFiles = Array.isArray(data.fileList)
? data.fileList.filter(file => file && file.businessType === 'contract')
: []
.map(file => ({
name: file.name || file.fileName || '未知文件',
filePath: file.filePath,
lsFilePath: file.lsFilePath,
fileType: file.fileType || '2',
businessType: 'contract'
}))
: [];
this.formData = {
...data,
...(data || {}),
fileList: contractFiles,
delFileList: []
}
},
//
formatFileList() {
return this.formData.fileList.map((file, index) => {
const fileExt = this.getFileExt(file)
return {
...file,
uid: file.uid || file.filePath || `${Date.now()}-${index}`,
name: this.getFileName(file),
status: file.status || 'success',
percentage: file.percentage || 100,
fileType: file.fileType || '2',
businessType: 'contract'
}
})
},
//
getFileName(file) {
const fullName = file.name || file.fileName || `未命名文件.${this.getFileExt(file)}`
const lastDotIndex = fullName.lastIndexOf('.')
return lastDotIndex > 0 ? fullName.substring(0, lastDotIndex) : fullName
return file.name || file.fileName || '未知文件'
},
//
getFileExt(file) {
if (!file) return ''
const fileName = file.name || file.fileName || ''
@ -232,20 +216,31 @@ export default {
return extMatch ? extMatch[1].toLowerCase() : ''
},
//
handleFileChange(files, type) {
if (type === 'contract') {
const markedFiles = files.map(file => ({
...file,
businessType: 'contract',
name: file.name || file.fileName || '未知文件'
}))
this.formData.fileList = markedFiles
this.handleOcrResult(markedFiles)
if (type === 'contract' && files instanceof Array) {
//
if (files.length > 0) {
//
this.isReplacingFile = false;
const markedFiles = files.map(file => ({
...file,
businessType: 'contract'
})).slice(-1); // 1
this.formData.fileList = markedFiles;
// responseOCR
if (markedFiles.length > 0 && markedFiles[0].response) {
this.handleOcrResult(markedFiles);
}
} else if (!this.isReplacingFile) {
//
this.formData.fileList = [];
}
}
},
// OCR
handleOcrResult(files) {
if (!files || !Array.isArray(files) || files.length === 0) return
@ -259,7 +254,6 @@ export default {
const formField = this.ocrResultParams[key]
if (formField && chatRes[key]) {
let value = chatRes[key]
//
if (formField === 'contractAmount') {
value = value.replace(/[^\d.]/g, '')
}
@ -279,21 +273,20 @@ export default {
}
},
//
handleDelFile(file) {
const filePath = file.filePath || file.response?.fileRes?.uploadPath
if (filePath && !this.formData.delFileList.includes(filePath)) {
this.formData.delFileList.push(filePath)
//
this.isReplacingFile = true;
const delPath = file?.response?.fileRes?.filePath || file?.filePath || null;
if (delPath && !this.formData.delFileList.includes(delPath)) {
this.formData.delFileList.push(delPath);
}
this.formData.fileList = []
},
//
disabledFutureDate(date) {
return date > new Date()
},
//
validate() {
return new Promise((resolve, reject) => {
if (!this.$refs.contractForm) {
@ -311,7 +304,6 @@ export default {
})
},
//
resetForm() {
if (this.$refs.contractForm) {
this.$refs.contractForm.resetFields()
@ -326,16 +318,15 @@ export default {
constructionPhone: '',
delFileList: []
}
this.isReplacingFile = false
},
// OCR
addOcrRule() {
this.ocrRuleList.forEach(item => {
this.ocrRule(item)
})
},
// OCR
ocrRule(type) {
const foundItem = this.dict.type.identification_tag?.find(item => item.value === type)
if (!foundItem) {

View File

@ -153,7 +153,8 @@ export default {
name: item.fileName || '未知文件',
filePath: item.filePath || '', //
lsFilePath: item.lsFilePath || '', //
fileType: item.fileType || '2' // 2
fileType: item.fileType || '2', // 2
id: item.sourceId + ''
}))
}
}

View File

@ -13,22 +13,22 @@
label-position="top"
>
<!-- 团队业绩证明 -->
<!-- <el-row :gutter="24">-->
<!-- <el-col :span="8">-->
<!-- <el-form-item label="团队业绩证明" prop="performanceFileList">-->
<!-- <UploadFile-->
<!-- :fileList="formatFileList()"-->
<!-- @file-change="(files, type) => handleFileChange(files, type)"-->
<!-- @del-file="handleDelFile"-->
<!-- :uploadType="uploadType"-->
<!-- :maxFileTips="maxFileTips"-->
<!-- :limitUploadNum="3"-->
<!-- type="team_performance"-->
<!-- :show-file-list="true"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<!-- </el-row>-->
<el-row :gutter="24">
<el-col :span="8">
<el-form-item label="团队业绩证明" prop="performanceFileList">
<UploadFile
ref="uploadFileComp"
:fileList="formData.performanceFileList"
@file-change="handleFileChange"
@del-file="handleDelFile"
:uploadType="uploadType"
:maxFileTips="maxFileTips"
:limitUploadNum="1"
type="team_performance"
/>
</el-form-item>
</el-col>
</el-row>
<!-- 项目信息 -->
<el-row :gutter="24">
@ -107,6 +107,9 @@
<script>
import UploadFile from '@/views/common/UploadFile.vue'
//
const safeGetArray = (value) => Array.isArray(value) ? value : []
export default {
name: 'OtherInfo',
components: { UploadFile },
@ -125,8 +128,8 @@ export default {
proType: '',
voltageLevel: '',
projectOverview: '',
performanceFileList: [], //
delFileList: [] //
performanceFileList: [], // UploadFile
delFileList: [] // /
},
rules: {
projectManager: [
@ -143,7 +146,7 @@ export default {
{ max: 500, message: '项目概况不能超过500个字符', trigger: 'blur' }
],
performanceFileList: [
{ required: true, message: '请上传团队业绩证明', trigger: 'change' }
{ required: true, message: '请上传团队业绩证明', trigger: ['change', 'blur'] }
]
},
proTypeOptions: [],
@ -155,48 +158,24 @@ export default {
this.loadProjcetTypeDict()
},
methods: {
//
// getFileList
setFormData(data) {
const teamFiles = Array.isArray(data.performanceFileList)
? data.performanceFileList.filter(file => file && file.businessType === 'team_performance')
: []
const teamFiles = Array.isArray(data.fileList)
? data.fileList.filter(file => file && file.businessType === 'team_performance')
.map(file => ({
name: file.fileName,
filePath: file.filePath,
lsFilePath: file.lsFilePath,
fileType: file.fileType,
// uidUploadFile
}))
: [];
this.formData = {
...data,
performanceFileList: teamFiles,
delFileList: []
}
},
// UploadFile
formatFileList() {
return this.formData.performanceFileList.map((file, index) => {
const fileExt = this.getFileExt(file)
return {
...file,
uid: file.uid || file.filePath || `${Date.now()}-${index}`,
name: this.getFileName(file), //
status: file.status || 'success',
percentage: file.percentage || 100,
fileType: file.fileType || '2',
businessType: 'team_performance'
}
})
},
//
getFileName(file) {
const fullName = file.name || file.fileName || `未命名文件.${this.getFileExt(file)}`
const lastDotIndex = fullName.lastIndexOf('.')
return lastDotIndex > 0 ? fullName.substring(0, lastDotIndex) : fullName
},
//
getFileExt(file) {
if (!file) return ''
const fileName = file.name || file.fileName || ''
const extMatch = fileName.match(/\.([a-zA-Z0-9]+)$/)
return extMatch ? extMatch[1].toLowerCase() : ''
};
},
//
@ -222,32 +201,22 @@ export default {
})
},
//
// response
handleFileChange(files, type) {
if (type === 'team_performance') {
const markedFiles = files.map(file => ({
...file,
businessType: 'team_performance',
name: file.name || file.fileName || '未知文件'
}))
this.formData.performanceFileList = markedFiles
if (markedFiles.length > 0) {
this.$message.success(`成功上传${markedFiles.length}个团队业绩证明文件`)
if (type === 'team_performance' && files instanceof Array) {
//
if (files.length > 0 && files[0].response) {
this.formData.performanceFileList = files;
}
}
},
//
//
handleDelFile(file) {
const filePath = file.filePath || file.response?.fileRes?.uploadPath
if (filePath && !this.formData.delFileList.includes(filePath)) {
this.formData.delFileList.push(filePath)
const delPath = file?.response?.fileRes?.filePath || file?.filePath || null;
if (delPath) {
this.formData.delFileList.push(delPath);
}
//
this.formData.performanceFileList = this.formData.performanceFileList.filter(
item => item.uid !== file.uid
)
},
//
@ -270,17 +239,22 @@ export default {
//
resetForm() {
if (this.$refs.otherForm) {
this.$refs.otherForm.resetFields()
}
this.formData = {
projectManager: '',
proType: '',
voltageLevel: '',
projectOverview: '',
performanceFileList: [],
delFileList: []
}
this.$nextTick(() => {
if (this.$refs.uploadFileComp) {
this.$refs.uploadFileComp.clearFiles();
}
if (this.$refs.otherForm) {
this.$refs.otherForm.resetFields()
}
this.formData = {
projectManager: '',
proType: '',
voltageLevel: '',
projectOverview: '',
performanceFileList: [],
delFileList: []
}
});
}
}
}

View File

@ -11,18 +11,18 @@
class="detail-form"
>
<!-- <el-row :gutter="24">-->
<!-- <el-col :span="12">-->
<!-- <el-form-item label="团队业绩证明" class="form-item">-->
<!-- <FileOrImageDisplay-->
<!-- :label="''"-->
<!-- :file="form.fileList[0]"-->
<!-- :image-url="form.url"-->
<!-- />-->
<!-- <span v-if="form.fileList.length === 0" class="no-file-tip">无附件</span>-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<!-- </el-row>-->
<el-row :gutter="24">
<el-col :span="8">
<el-form-item label="团队业绩证明" class="form-item">
<FileOrImageDisplay
:label="''"
:file="form.fileList[0]"
:image-url="form.url"
/>
<span v-if="form.fileList.length === 0" class="no-file-tip">无附件</span>
</el-form-item>
</el-col>
</el-row>
<!-- 项目经理 + 项目类型使用输入框禁用 -->
<el-row :gutter="24">
@ -126,14 +126,15 @@ export default {
getFileList() {
// detailData
const rawFileList = Array.isArray(this.detailData.fileList) ? this.detailData.fileList : []
const performanceFiles = rawFileList.filter(file => file && file.businessType === 'performance')
const performanceFiles = rawFileList.filter(file => file && file.businessType === 'team_performance')
//
return performanceFiles.map(item => ({
name: item.fileName || '未知文件',
filePath: item.filePath || '', //
lsFilePath: item.lsFilePath || '', //
fileType: item.fileType || '2' // 2
fileType: item.fileType || '2', // 2
id: item.sourceId + ''
}))
}
}

View File

@ -221,7 +221,8 @@ export default {
name: item.fileName || item.name || '未知文件',
filePath: item.filePath || '',
lsFilePath: item.lsFilePath || item.fileUrl || '',
fileType: item.fileType || '2'
fileType: item.fileType || '2',
id: item.sourceId + ''
}))
this.form = {