Parcourir la source

fix: 修改bug

shiyanyu il y a 1 jour
Parent
commit
d632816097

+ 86 - 23
src/components/task/taskComponents/auditNoticeTab.vue

@@ -379,6 +379,7 @@
   } from '@/api/taskCustomizedRelease.js'
   import { dictMixin, regionMixin } from '@/mixins/useDict'
   import { uploadFile } from '@/api/file'
+
   export default {
     components: { CostAuditTable, CostAuditDialog, TemplatePreviewEdit },
     mixins: [dictMixin, regionMixin],
@@ -510,6 +511,34 @@
       this.loadOpts()
     },
     methods: {
+      normalizeFileUrl(fileUrl) {
+        if (!fileUrl) return ''
+        const url = String(fileUrl).trim()
+        if (!url) return ''
+
+        // 已经是绝对地址
+        if (/^https?:\/\//i.test(url)) return url
+
+        // 相对地址:确保以 / 开头,避免拼接成 ...formapi/xxx 这种
+        const normalizedPath = url.startsWith('/') ? url : `/${url}`
+        return (window?.context?.form || '') + normalizedPath
+      },
+
+      // 根据URL推测文件扩展名
+      getFileExtFromUrl(url) {
+        try {
+          const clean = String(url || '')
+            .split('?')[0]
+            .split('#')[0]
+          const last = clean.substring(clean.lastIndexOf('/') + 1)
+          const idx = last.lastIndexOf('.')
+          if (idx > -1 && idx < last.length - 1) return last.substring(idx)
+        } catch (e) {
+          // ignore
+        }
+        return ''
+      },
+
       // 查看监审文书
       handleDocView(row) {
         this.document = {
@@ -520,19 +549,11 @@
           id: row.id,
         }).then((res) => {
           if (res.state) {
-            // this.fileUrl = res.value || ''
             this.handleViewScan(res.value || '')
           } else {
             this.$message.error('获取文件URL失败')
           }
         })
-        // this.handleTemplateChange()
-        // this.documentDialogVisible = true
-        // getCostProjectDocumentFile({
-        //   id: row.id,
-        // }).then((res) => {
-        //   this.costDocumentTemplateFiles = res.value || []
-        // })
       },
       handleDocumentTypeClick(data) {
         this.activeDocumentTypeId = data.id
@@ -810,16 +831,26 @@
 
             // 第四步:检查上传结果
             if (!uploadRes || !uploadRes.value) {
-              // this.$message.error('文件上传失败!');
+              this.$message.error('文件上传失败!')
               return
             }
 
             // 第五步:文件上传成功后,再更新数据
             const fileInfo = uploadRes.value
-            // 创建更新数据对象
+
+            // 兼容:后端返回 savePath/url/path 等字段
+            const uploadedPath =
+              fileInfo?.savePath || fileInfo?.url || fileInfo?.path || ''
+
+            if (!uploadedPath) {
+              this.$message.error('文件上传成功,但未返回文件路径!')
+              return
+            }
+
+            // 创建更新数据对象:按传入type写入对应字段
             const updateData = {
               ...row,
-              scanDocumentUrl: fileInfo?.savePath, // 更新扫描件URL
+              [type || 'scanDocumentUrl']: uploadedPath,
             }
 
             // 第六步:调用更新API
@@ -829,37 +860,34 @@
             this.$message.success('文件上传成功并更新数据!')
             this.$emit('refresh', this.project.projectId) // 通知父组件刷新
           } catch (error) {
-            // 错误处理
             console.log('操作失败:' + (error.message || '未知错误'))
-            // this.$message.error('操作失败:' + (error.message || '未知错误'))
+            this.$message.error('操作失败:' + (error.message || '未知错误'))
           } finally {
             // 关闭遮罩层
-            loading.close()
+            if (loading && typeof loading.close === 'function') loading.close()
           }
         }
         // 触发文件选择
         input.click()
       },
+
       // 查看扫描件
       handleViewScan(fileUrl, type) {
-        if (!fileUrl) {
+        const normalized = this.normalizeFileUrl(fileUrl)
+        if (!normalized) {
           this.$message.error('暂无文件!')
           return
         }
-        let _fileUrl = ''
-        if (fileUrl.startsWith('http')) {
-          _fileUrl = fileUrl
-        } else {
-          _fileUrl = window.context.form + fileUrl
-        }
+
         // 对文件URL进行Base64编码
-        const encodedUrl = encodeURIComponent(Base64.encode(_fileUrl))
+        const encodedUrl = encodeURIComponent(Base64.encode(normalized))
 
         // 构建 kkFileView 预览URL
         // onlinePreview - 在线预览
         // onlinePreview?type=pdf - 强制使用PDF模式预览
         window.open(`${host}:8012/onlinePreview?url=${encodedUrl}`)
       },
+
       // 编辑文档
       handleEditDocument(row) {
         this.documentDialogVisible = true
@@ -907,7 +935,42 @@
       },
 
       // 下载文档
-      handleDownloadDocument(row) {},
+      handleDownloadDocument(row) {
+        if (!row || !row.id) {
+          this.$message.error('缺少文书ID,无法下载!')
+          return
+        }
+
+        downDocument({ id: row.id })
+          .then((res) => {
+            if (!res || !res.state || !res.value) {
+              this.$message.error('获取下载地址失败!')
+              return
+            }
+
+            const url = this.normalizeFileUrl(res.value)
+            if (!url) {
+              this.$message.error('获取下载地址失败!')
+              return
+            }
+
+            const nameBase =
+              row.documentName || this.getDocumenType(row) || '电子文书'
+            const ext = this.getFileExtFromUrl(url)
+            const fileName = `${nameBase}${ext || ''}`
+
+            const a = document.createElement('a')
+            a.href = url
+            a.download = fileName
+            a.target = '_blank'
+            document.body.appendChild(a)
+            a.click()
+            document.body.removeChild(a)
+          })
+          .catch(() => {
+            this.$message.error('下载失败!')
+          })
+      },
     },
   }
 </script>

+ 31 - 2
src/views/costAudit/auditInfo/auditManage/mainDetails.vue

@@ -112,11 +112,33 @@
           v-if="currentProcessType === 'next'"
           class="form-item process-form-item"
         >
-          <label class="form-label">下一步办理人:</label>
+          <label class="form-label">从办人员:</label>
           <div class="form-content">
             <el-select
               v-model="processParams.userIds"
-              placeholder="请选择下一步环节办理人员"
+              placeholder="请选择从办人员"
+              style="width: 100%"
+              filterable
+              clearable
+            >
+              <el-option
+                v-for="(item, index) in nextUserList"
+                :key="index"
+                :label="item.fullname"
+                :value="item.userId"
+              />
+            </el-select>
+          </div>
+        </div>
+        <div
+          v-if="currentProcessType === 'next'"
+          class="form-item process-form-item"
+        >
+          <label class="form-label">主办人员:</label>
+          <div class="form-content">
+            <el-select
+              v-model="processParams.leaderIds"
+              placeholder="请选择主办人员"
               style="width: 100%"
               filterable
               clearable
@@ -270,6 +292,7 @@
         processParams: {
           content: '', // 意见
           userIds: '', // 下一步环节办理人员
+          leaderIds: '',
           // sendType: [], // 发送方式
         },
         // 当前操作类型:'next' 流转下一步, 'prev' 退回上一步
@@ -404,6 +427,7 @@
         this.processParams = {
           content: '',
           userIds: '',
+          leaderIds: '',
           userIdNames: '',
         }
       },
@@ -490,6 +514,7 @@
         this.processParams = {
           content: '',
           userIds: '',
+          leaderIds: '',
           userIdNames: '',
           // sendType: [],
         }
@@ -503,6 +528,7 @@
         this.processParams = {
           content: '',
           userIds: '',
+          leaderIds: '',
           userIdNames: '',
           // userIds: [],
         }
@@ -515,6 +541,7 @@
         this.processParams = {
           content: '',
           userIds: '',
+          leaderIds: '',
           userIdNames: '',
           // sendType: [],
         }
@@ -560,6 +587,7 @@
             // sendType: this.processParams.sendType.join(','), // 发送方式用","分割
             content: this.processParams.content || '', // 意见
             userIds: this.processParams.userIds || '',
+            leaderIds: this.processParams.leaderIds || '',
           }
 
           // 流转下一步:带上下一步办理人姓名(后端需要 userIdNames)
@@ -588,6 +616,7 @@
             this.processParams = {
               content: '',
               userIds: '',
+              leaderIds: '',
               userIdNames: '',
               // sendType: [],
             }