Browse Source

fix: 修改bug

shiyanyu 1 month ago
parent
commit
450adee2f9

+ 3 - 1
src/components/task/taskInfo.vue

@@ -466,7 +466,9 @@
                     <template v-if="scope.row.formatRequired == '3'">
                       <el-button
                         v-if="
-                          scope.row.isUpload === 1 || scope.row.isUpload === '1'
+                          (scope.row.isUpload === 1 ||
+                            scope.row.isUpload === '1') &&
+                          scope.row.templateType !== '1'
                         "
                         type="text"
                         size="small"

+ 1 - 0
src/views/EntDeclaration/auditTaskManagement/components/CostSurveyTab.vue

@@ -303,6 +303,7 @@
 
         // 如果表格类型是"单记录",弹出调查表填报弹窗
         if (row.tableType === '单记录') {
+          console.log(this.auditedUnitId, 'this.auditedUnitId')
           // 如果该行有 id,先调用接口获取详情数据
           if (row.id && this.auditedUnitId) {
             try {

+ 6 - 0
src/views/EntDeclaration/auditTaskManagement/taskFillIn.vue

@@ -947,6 +947,7 @@
         this.taskId = (info.userTask && info.userTask.id) || info.taskId || ''
         this.tabCheck = info.status || ''
         this.auditedUnitId = info.auditedUnitId || ''
+        console.log(this.auditedUnitId, 'this.auditedUnitId 122')
         this.currentNode = info.currentNode || ''
 
         if (this.tabCheck === 'jtsy') {
@@ -1269,6 +1270,10 @@
               })
               // 更新 costSurveyData(完整数据)
               this.formData.costSurveyData = mappedData
+              console.log(
+                'this.formData.costSurveyData',
+                this.formData.costSurveyData
+              )
               // 更新 paginatedData(用于传递给子组件,如果接口返回的是分页数据,直接使用;否则使用全部数据)
               this.formData.paginatedData = mappedData
               // 更新分页信息
@@ -1374,6 +1379,7 @@
 
           const submitData = {
             taskId: this.taskId,
+            id: this.formData.auditOpinion.id,
             // 成本监审意见数据
             basicSituation: this.formData.auditOpinion?.basicSituation || '',
             currentPriceStandard:

+ 82 - 6
src/views/costAudit/auditInfo/auditManage/auditOpinion.vue

@@ -179,11 +179,11 @@
     computed: {
       // 判断初步意见是否需要置灰(currentNode === 'yjfk' && status === '已反馈')
       isPreliminaryDisabled() {
-        return this.currentNode === 'yjfk' && this.currentStatus === '已反馈'
+        return this.currentNode === 'yjfk' && this.currentStatus === '260'
       },
       // 判断结论意见是否可编辑(currentNode === 'yjfk' && status === '已反馈')
       isConclusionEditable() {
-        return this.currentNode === 'yjfk' && this.currentStatus === '已反馈'
+        return this.currentNode === 'yjfk' && this.currentStatus === '260'
       },
     },
     watch: {
@@ -195,6 +195,7 @@
       },
     },
     mounted() {
+      console.log(this.currentStatus, '意见反馈this.currentStatus')
       // 组件挂载时,如果有 id,获取数据
       if (this.id) {
         this.getPreliminaryOpinionData()
@@ -418,10 +419,85 @@
           fileUrl = file.savePath
         }
 
-        if (fileUrl) {
-          window.open(fileUrl, '_blank')
-        } else {
-          this.$message.warning('文件地址无效')
+        if (!fileUrl) {
+          this.$message &&
+            this.$message.warning &&
+            this.$message.warning('文件地址无效')
+          return
+        }
+
+        const normalized = this.normalizeUrl(fileUrl)
+        const suggestName =
+          (file && (file.name || file.fileName)) ||
+          this.getFileName(file) ||
+          '下载文件'
+        this.downloadByFetch(normalized, suggestName).catch((e) => {
+          console.error('文件下载失败: ', e)
+        })
+      },
+      normalizeUrl(u) {
+        if (!u) return ''
+        if (/^https?:\/\//i.test(u)) return u
+        const base = (window.context && window.context.form) || ''
+        if (!base) return u
+        if (u.startsWith('/')) return base + u
+        return base.replace(/\/$/, '') + '/' + u
+      },
+      extractFileName(contentDisposition) {
+        if (!contentDisposition) return ''
+        const match = /filename[^;=\n]*=((['"])?.*?\2|[^;\n]*)/i.exec(
+          contentDisposition
+        )
+        if (match && match[1]) {
+          try {
+            return decodeURIComponent(match[1].replace(/['"]/g, ''))
+          } catch (e) {
+            return match[1].replace(/['"]/g, '')
+          }
+        }
+        return ''
+      },
+      async downloadByFetch(rawUrl, fallbackName) {
+        const url = this.normalizeUrl(rawUrl)
+        let loading
+        try {
+          loading = this.$baseLoading
+            ? this.$baseLoading(1, '文件下载中...')
+            : this.$loading({
+                lock: true,
+                text: '文件下载中...',
+                spinner: 'el-icon-loading',
+                background: 'rgba(0,0,0,0.7)',
+              })
+          const res = await fetch(url, { method: 'GET' })
+          if (!res.ok) throw new Error('下载失败')
+          const blob = await res.blob()
+          let fileName =
+            this.extractFileName(res.headers.get('content-disposition')) ||
+            fallbackName ||
+            '下载文件'
+          if (!/\.[a-zA-Z0-9]+$/.test(fileName)) {
+            const extFromUrl = (
+              url.split('?')[0].split('#')[0].split('.').pop() || ''
+            ).toLowerCase()
+            fileName = extFromUrl ? `${fileName}.${extFromUrl}` : fileName
+          }
+          const objectUrl = window.URL.createObjectURL(blob)
+          const link = document.createElement('a')
+          link.style.display = 'none'
+          link.href = objectUrl
+          link.download = fileName
+          document.body.appendChild(link)
+          link.click()
+          document.body.removeChild(link)
+          window.URL.revokeObjectURL(objectUrl)
+          this.$message &&
+            this.$message.success &&
+            this.$message.success('开始下载文件')
+        } catch (e) {
+          console.log(e.message || '文件下载失败')
+        } finally {
+          if (loading && loading.close) loading.close()
         }
       },
     },