|
|
@@ -63,9 +63,7 @@
|
|
|
<el-button
|
|
|
type="text"
|
|
|
size="mini"
|
|
|
- @click="
|
|
|
- handleViewScan(scope.row.scanDocumentUrl, 'scanDocumentUrl')
|
|
|
- "
|
|
|
+ @click="handleViewScan(scope.row.scanDocumentUrl)"
|
|
|
>
|
|
|
查看附件
|
|
|
</el-button>
|
|
|
@@ -82,12 +80,7 @@
|
|
|
<el-button
|
|
|
type="text"
|
|
|
size="mini"
|
|
|
- @click="
|
|
|
- handleViewScan(
|
|
|
- scope.row.feedbackDocumentUrl,
|
|
|
- 'feedbackDocumentUrl'
|
|
|
- )
|
|
|
- "
|
|
|
+ @click="handleViewScan(scope.row.feedbackDocumentUrl)"
|
|
|
>
|
|
|
查看附件
|
|
|
</el-button>
|
|
|
@@ -268,10 +261,28 @@
|
|
|
>
|
|
|
<template slot-scope="scope">
|
|
|
<el-input
|
|
|
+ v-if="scope.row.originalText !== '需要提供材料'"
|
|
|
v-model="scope.row.dataValue"
|
|
|
size="small"
|
|
|
placeholder="请输入数据值"
|
|
|
></el-input>
|
|
|
+ <!-- 否则显示上传按钮 -->
|
|
|
+ <div v-else>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ size="small"
|
|
|
+ @click="handleUploadClick(scope.row)"
|
|
|
+ >
|
|
|
+ 上传附件
|
|
|
+ </el-button>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ size="small"
|
|
|
+ @click="handleViewScan(scope.row.dataValue)"
|
|
|
+ >
|
|
|
+ 查看附件
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
@@ -407,13 +418,13 @@
|
|
|
selectDocumentWhSelection: [],
|
|
|
costDocumentTemplateFiles: [],
|
|
|
documentRules: {
|
|
|
- documentNumber: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- message: '请选择通知书文号',
|
|
|
- trigger: 'change',
|
|
|
- },
|
|
|
- ],
|
|
|
+ // documentNumber: [
|
|
|
+ // {
|
|
|
+ // required: true,
|
|
|
+ // message: '请选择通知书文号',
|
|
|
+ // trigger: 'change',
|
|
|
+ // },
|
|
|
+ // ],
|
|
|
enterpriseId: [
|
|
|
{
|
|
|
required: true,
|
|
|
@@ -436,6 +447,7 @@
|
|
|
},
|
|
|
],
|
|
|
},
|
|
|
+ dataUploadUrl: [],
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -479,7 +491,38 @@
|
|
|
]
|
|
|
},
|
|
|
},
|
|
|
- watch: {},
|
|
|
+ watch: {
|
|
|
+ costDocumentTemplateFiles: {
|
|
|
+ handler(newVal, oldVal) {
|
|
|
+ if (newVal.length > 0) {
|
|
|
+ console.log(this.costDocumentTemplateFiles)
|
|
|
+ this.costDocumentTemplateFiles.forEach((item) => {
|
|
|
+ if (
|
|
|
+ item.pinyin.includes('ShiJian') &&
|
|
|
+ (item.dataValue == null || item.dataValue == '')
|
|
|
+ ) {
|
|
|
+ // 获取当前时间,格式为YYYY-MM-DD HH:mm:ss
|
|
|
+ let date = new Date()
|
|
|
+ let year = date.getFullYear()
|
|
|
+ let month = String(date.getMonth() + 1).padStart(2, '0')
|
|
|
+ let day = String(date.getDate()).padStart(2, '0')
|
|
|
+ let hours = String(date.getHours()).padStart(2, '0')
|
|
|
+ let minutes = String(date.getMinutes()).padStart(2, '0')
|
|
|
+ let seconds = String(date.getSeconds()).padStart(2, '0')
|
|
|
+ item.dataValue = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ item.originalText.includes('需要提供材料') &&
|
|
|
+ item.dataValue
|
|
|
+ ) {
|
|
|
+ this.dataUploadUrl = item.dataValue
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ deep: true,
|
|
|
+ },
|
|
|
+ },
|
|
|
mounted() {},
|
|
|
methods: {
|
|
|
handleDocumentTypeClick(data) {
|
|
|
@@ -560,6 +603,7 @@
|
|
|
this.documentDialogTitle = '添加监审通知书'
|
|
|
this.documentDialogVisible = true
|
|
|
this.activeView = 'form'
|
|
|
+ this.costDocumentTemplateFiles = []
|
|
|
this.document = {
|
|
|
createBy: '',
|
|
|
createTime: '',
|
|
|
@@ -596,7 +640,6 @@
|
|
|
this.document.documentId = this.activeDocumentTypeId
|
|
|
this.handleTemplateChange()
|
|
|
}
|
|
|
- this.costProjectDocumentFiles = []
|
|
|
},
|
|
|
getDetail() {
|
|
|
getCostProjectDocumentDetail({
|
|
|
@@ -875,7 +918,7 @@
|
|
|
input.click()
|
|
|
},
|
|
|
// 查看扫描件
|
|
|
- handleViewScan(fileUrl, type) {
|
|
|
+ handleViewScan(fileUrl) {
|
|
|
if (!fileUrl) {
|
|
|
this.$message.error('暂无文件!')
|
|
|
return
|
|
|
@@ -1048,6 +1091,80 @@
|
|
|
console.error('获取文件URL失败:', error)
|
|
|
})
|
|
|
},
|
|
|
+ handleUploadClick(row) {
|
|
|
+ console.log('handleUploadClick', row)
|
|
|
+ let loading = null
|
|
|
+ // 第一步:创建文件选择器
|
|
|
+ const input = document.createElement('input')
|
|
|
+ input.type = 'file'
|
|
|
+ input.accept = '.pdf,.doc,.docx,.xls,.xlsx,.csv' // 允许的文件类型
|
|
|
+
|
|
|
+ input.onchange = async (event) => {
|
|
|
+ const file = event.target.files[0]
|
|
|
+ if (!file) return
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 校验文件大小(50MB)
|
|
|
+ const maxSize = 50 * 1024 * 1024 // 50MB
|
|
|
+ if (file.size > maxSize) {
|
|
|
+ this.$message.error('文件大小不能超过50MB!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 校验文件格式
|
|
|
+ const allowedFormats = [
|
|
|
+ '.pdf',
|
|
|
+ '.doc',
|
|
|
+ '.docx',
|
|
|
+ '.xls',
|
|
|
+ '.xlsx',
|
|
|
+ 'csv',
|
|
|
+ ]
|
|
|
+ const fileName = file.name.toLowerCase()
|
|
|
+ const isValidFormat = allowedFormats.some((format) =>
|
|
|
+ fileName.endsWith(format)
|
|
|
+ )
|
|
|
+
|
|
|
+ if (!isValidFormat) {
|
|
|
+ this.$message.error(
|
|
|
+ '只允许上传.pdf,.doc,.docx,.xls,.xlsx,.csv格式的文件!'
|
|
|
+ )
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 显示遮罩层
|
|
|
+ loading = this.$baseLoading(1, '文件上传中...')
|
|
|
+
|
|
|
+ // 第三步:创建FormData并上传文件
|
|
|
+ const formData = new FormData()
|
|
|
+ formData.append('file', file)
|
|
|
+
|
|
|
+ // 先调用上传API
|
|
|
+ const uploadRes = await uploadFile('/api/file/v1/upload', formData)
|
|
|
+
|
|
|
+ // 第四步:检查上传结果
|
|
|
+ if (!uploadRes || !uploadRes.value) {
|
|
|
+ // this.$message.error('文件上传失败!');
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 第五步:文件上传成功后,再更新数据
|
|
|
+ const fileInfo = uploadRes.value
|
|
|
+ this.costDocumentTemplateFiles.find(
|
|
|
+ (item) => item.originalText === row.originalText
|
|
|
+ ).dataValue = fileInfo.savePath
|
|
|
+ this.$message.success('文件上传成功!')
|
|
|
+ } catch (error) {
|
|
|
+ console.error('文件上传失败:', error)
|
|
|
+ } finally {
|
|
|
+ // 关闭遮罩层
|
|
|
+ loading.close()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 触发文件选择对话框显示
|
|
|
+ input.click()
|
|
|
+ },
|
|
|
},
|
|
|
}
|
|
|
</script>
|