Ver Fonte

fix: 修改督办及bug

shiyanyu há 3 dias atrás
pai
commit
850bd32baf

+ 39 - 5
src/components/costAudit/FilePreview.vue

@@ -1,6 +1,13 @@
 <template>
   <div class="file-preview">
-    <iframe :src="url" frameborder="0" class="preview-frame"></iframe>
+    <iframe
+      id="myIframe"
+      ref="previewFrame"
+      :src="url"
+      frameborder="0"
+      class="preview-frame"
+      @load="handleFrameLoad"
+    ></iframe>
   </div>
 </template>
 <script>
@@ -28,21 +35,48 @@
           // 对文件URL进行Base64编码
           const encodedUrl = encodeURIComponent(Base64.encode(fileUrl))
 
-          // 构建 kkFileView 预览URL,添加参数隐藏工具栏
-          // officePreviewType=doc:使用文档预览模式
-          // hideTopbar=true:隐藏顶部工具栏
+          // 构建 kkFileView 预览URL
           return `${host}:8012/onlinePreview?url=${encodedUrl}`
         } catch (error) {
           return ''
         }
       },
     },
+    watch: {
+      url() {
+        // URL 变化时,等待 iframe load 后再处理
+        this.$nextTick(() => {
+          this.handleFrameLoad()
+        })
+      },
+    },
+    methods: {
+      handleFrameLoad() {
+        // 仅同域可注入样式;跨域会触发安全限制,直接忽略
+        try {
+          const iframe = document.getElementById('myIframe')
+          const iframeDocument =
+            iframe.contentDocument || iframe.contentWindow.document
+          console.log('iframeDocument', iframeDocument)
+          const imgElement = iframeDocument.querySelector('img')
+          if (imgElement) {
+            imgElement.style.height = '100%'
+          }
+        } catch (e) {
+          // ignore: cross-origin
+        }
+      },
+    },
   }
 </script>
 <style lang="scss" scoped>
   .preview-frame {
     width: 100%;
-    height: 100vh;
+    height: 78vh;
     border: none;
   }
+  #myIframe img {
+    width: 100%; /* 例如,将图片宽度设置为父容器的100% */
+    height: auto; /* 保持图片的原始宽高比 */
+  }
 </style>

+ 85 - 38
src/views/costAudit/auditInfo/auditManage/auditDocumentsMain.vue

@@ -283,13 +283,6 @@
                   <template slot-scope="scope">
                     <div v-if="scope.row.originalText !== '需要提供材料'">
                       <el-input
-                        v-if="scope.row.originalText.includes('时间')"
-                        v-model="scope.row.dataValue.split(' ')[0]"
-                        size="small"
-                        placeholder="请输入数据值"
-                      ></el-input>
-                      <el-input
-                        v-else
                         v-model="scope.row.dataValue"
                         size="small"
                         placeholder="请输入数据值"
@@ -610,6 +603,41 @@
       this.loadOpts()
     },
     methods: {
+      // 安全 includes:避免字段为 null/undefined 时调用 includes 报错
+      strIncludes(val, keyword) {
+        return String(val || '').includes(keyword)
+      },
+
+      // 将 enterpriseId 统一转换为数组(兼容:数组 / 逗号分隔字符串 / 单值)
+      normalizeEnterpriseIds(enterpriseId) {
+        if (!enterpriseId) return []
+        if (Array.isArray(enterpriseId)) return enterpriseId.filter(Boolean)
+        if (typeof enterpriseId === 'string') {
+          return enterpriseId
+            .split(',')
+            .map((id) => String(id).trim())
+            .filter(Boolean)
+        }
+        return [enterpriseId]
+      },
+
+      // 获取当前选择的被监审单位名称(多选用逗号拼接)
+      getSelectedEnterpriseNames() {
+        const ids = this.normalizeEnterpriseIds(this.document.enterpriseId)
+        if (!ids.length) return ''
+        return ids
+          .map((id) => this.allUnits.find((u) => u.unitId == id)?.unitName)
+          .filter(Boolean)
+          .join(', ')
+      },
+
+      // 获取第一个被监审单位(多选场景下,诸如联系人/地址等字段取第一个单位信息)
+      getPrimaryEnterpriseUnit() {
+        const ids = this.normalizeEnterpriseIds(this.document.enterpriseId)
+        if (!ids.length) return null
+        return this.allUnits.find((u) => u.unitId == ids[0]) || null
+      },
+
       handleDocumentTypeClick(data) {
         this.activeDocumentTypeId = data.id
         this.getData(data)
@@ -837,9 +865,10 @@
           JSON.parse(JSON.stringify(res.value || [])) || []
         this.resCostDocumentTemplateFiles =
           JSON.parse(JSON.stringify(res.value || [])) || []
-        let unit = this.allUnits.find(
-          (item) => item.unitId === this.document.enterpriseId
-        )
+
+        const primaryUnit = this.getPrimaryEnterpriseUnit()
+        const selectedEnterpriseNames = this.getSelectedEnterpriseNames()
+
         this.costDocumentTemplateFiles = this.costDocumentTemplateFiles.filter(
           (row) => row.pinyin !== 'ChengBenXiangMu' && row.pinyin !== 'XingCi'
         )
@@ -848,19 +877,30 @@
         )
         let documenName =
           document.documentTypeName || document.documentName || ''
+
         this.costDocumentTemplateFiles.forEach((item) => {
-          if (item.pinyin.includes('BeiJianShenDanWei')) {
-            item.dataValue = unit.unitName
+          // 被监审单位名称:多选时用逗号拼接
+          if (this.strIncludes(item.pinyin, 'BeiJianShenDanWei')) {
+            item.dataValue = selectedEnterpriseNames
           }
-          if (item.pinyin.includes('ShouSongDaRen')) {
-            item.dataValue = unit.contactName
-          }
-          if (item.pinyin.includes('BeiJianShenDanWeiBanGongDiDian')) {
-            item.dataValue = unit.address
-          }
-          if (item.pinyin.includes('BeiJianShenDanWeiLianXiRenDianHua')) {
-            item.dataValue = unit.contactMobile
+
+          // 以下字段依赖单位详情,多选场景取第一个单位
+          if (primaryUnit) {
+            if (this.strIncludes(item.pinyin, 'ShouSongDaRen')) {
+              item.dataValue = primaryUnit.contactName
+            }
+            if (
+              this.strIncludes(item.pinyin, 'BeiJianShenDanWeiBanGongDiDian')
+            ) {
+              item.dataValue = primaryUnit.address
+            }
+            if (
+              this.strIncludes(item.pinyin, 'BeiJianShenDanWeiLianXiRenDianHua')
+            ) {
+              item.dataValue = primaryUnit.contactMobile
+            }
           }
+
           if (item.originalText.includes('需要提供材料') && item.dataValue) {
             this.dataUploadUrl = item.dataValue
           }
@@ -889,11 +929,13 @@
             item.dataValue = item.dataValue.replace(/<[^>]+>/g, '')
           }
           if (documenName.includes('成本监审通知书')) {
-            if (item.pinyin.includes('DanWeiMingCheng')) {
-              item.dataValue = unit.unitName
-            }
-            if (item.pinyin.includes('FaRenDaiBiao')) {
-              item.dataValue = unit?.corporateRepresentative || ''
+            if (primaryUnit) {
+              if (item.pinyin.includes('DanWeiMingCheng')) {
+                item.dataValue = primaryUnit.unitName
+              }
+              if (item.pinyin.includes('FaRenDaiBiao')) {
+                item.dataValue = primaryUnit?.corporateRepresentative || ''
+              }
             }
             if (
               item.pinyin.includes(
@@ -945,10 +987,12 @@
             if (item.pinyin.includes('JianShenRenWuFaBuShiJian')) {
               let dataValue = this.resCostDocumentTemplateFiles.find(
                 (item2) => item2.pinyin === 'JianShenRenWuFaBuShiJian'
-              ).dataValue
-              item.dataValue = !dataValue.includes('年')
-                ? moment(dataValue).format('YYYY年MM月DD日')
-                : dataValue
+              )?.dataValue
+              if (dataValue) {
+                item.dataValue = !dataValue.includes('年')
+                  ? moment(dataValue).format('YYYY年MM月DD日')
+                  : dataValue
+              }
             }
             if (
               item.pinyin.includes(
@@ -958,18 +1002,22 @@
               let dataValue = this.resCostDocumentTemplateFiles.find(
                 (item2) =>
                   item2.pinyin === 'ChengBenJianShenTongZhiShuShengChengShiJian'
-              ).dataValue
-              item.dataValue = !dataValue.includes('年')
-                ? moment(dataValue).format('YYYY年MM月DD日')
-                : dataValue
+              )?.dataValue
+              if (dataValue) {
+                item.dataValue = !dataValue.includes('年')
+                  ? moment(dataValue).format('YYYY年MM月DD日')
+                  : dataValue
+              }
             }
             if (item.pinyin.includes('ChengBenZiLiaoShangBaoShiJian')) {
               let dataValue = this.resCostDocumentTemplateFiles.find(
                 (item2) => item2.pinyin === 'ChengBenZiLiaoShangBaoShiJian'
-              ).dataValue
-              item.dataValue = !dataValue.includes('年')
-                ? moment(dataValue).format('YYYY年MM月DD日')
-                : dataValue
+              )?.dataValue
+              if (dataValue) {
+                item.dataValue = !dataValue.includes('年')
+                  ? moment(dataValue).format('YYYY年MM月DD日')
+                  : dataValue
+              }
             }
           }
           if (documenName.includes('成本审核初步意见告知书')) {
@@ -1449,7 +1497,6 @@
           })
       },
       handleUploadClick(row) {
-        console.log('handleUploadClick', row)
         let loading = null
         // 第一步:创建文件选择器
         const input = document.createElement('input')

+ 32 - 10
src/views/costAudit/projectInfo/taskSuperviseManage/superviseMattersManage/index.vue

@@ -261,7 +261,10 @@
   import cbjsInfo from '@/components/task/cbjsInfo.vue'
   import { dictMixin } from '@/mixins/useDict'
   import UploadComponent from '@/components/costAudit/UploadComponent.vue'
-  import { updateSuperviseTask } from '@/api/audit/supervise'
+  import {
+    createSuperviseTask,
+    updateSuperviseTask,
+  } from '@/api/audit/supervise'
   import TaskDetail from '@/components/task/taskDetail.vue'
   import TaskCustomizedReleaseDialog from '@/components/task/TaskCustomizedReleaseDialog.vue'
   import { getCostProjectDetail } from '@/api/taskCustomizedRelease.js'
@@ -468,14 +471,12 @@
           return
         }
 
-        const id =
-          (this.currentTask &&
-            (this.currentTask.superviseId || this.currentTask.ID)) ||
-          ''
-        if (!id) {
-          this.$message.warning('缺少ID,无法提交督办报告')
-          return
-        }
+        const id = this.currentTask.superviseId
+        const projectId = this.currentTask.projectId
+        // if (!id) {
+        //   this.$message.warning('缺少ID,无法提交督办报告')
+        //   return
+        // }
 
         const loading = this.$loading({
           lock: true,
@@ -484,7 +485,8 @@
           background: 'rgba(0, 0, 0, 0.3)',
         })
 
-        updateSuperviseTask({ id, reportContent, attachmentUrls })
+        // if(!id){
+        createSuperviseTask({ reportContent, attachmentUrls, projectId })
           .then((res) => {
             if (res && Number(res.code) === 200) {
               this.$message.success('提交成功')
@@ -502,6 +504,26 @@
           .finally(() => {
             loading && loading.close && loading.close()
           })
+        // }else{
+        //   updateSuperviseTask({ id, reportContent, attachmentUrls, projectId })
+        //   .then((res) => {
+        //     if (res && Number(res.code) === 200) {
+        //       this.$message.success('提交成功')
+        //       this.isReport = false
+        //       this.reportForm = { content: '', uploadUrl: [] }
+        //       this.currentTask = null
+        //       this.generateTableData()
+        //     } else {
+        //       this.$message.error((res && res.message) || '提交失败')
+        //     }
+        //   })
+        //   .catch(() => {
+        //     this.$message.error('提交失败')
+        //   })
+        //   .finally(() => {
+        //     loading && loading.close && loading.close()
+        //   })
+        // }
       },
       handleCancel() {
         console.log('取消')

+ 31 - 17
src/views/costAudit/projectInfo/taskSuperviseManage/superviseResultManage/index.vue

@@ -112,7 +112,7 @@
         </template>
       </el-table-column>
       <el-table-column
-        prop="expectedDeadline"
+        prop="requireTime"
         label="预计截止时间"
         width="150"
         header-align="center"
@@ -130,20 +130,25 @@
         </template>
       </el-table-column>
       <el-table-column
-        prop="supervisor"
+        prop="supervisorName"
         label="督办人"
         width="100"
         header-align="center"
         align="center"
       ></el-table-column>
       <el-table-column
-        prop="supervisionStatus"
+        prop="superviseStatus"
         label="督办状态"
         width="100"
         header-align="center"
         align="center"
-      ></el-table-column>
-      <el-table-column
+      >
+        <template slot-scope="scope">
+          <span v-if="scope.row.superviseStatus === '0'">在办</span>
+          <span v-if="scope.row.superviseStatus === '1'">办结</span>
+        </template>
+      </el-table-column>
+      <!-- <el-table-column
         prop="supervisionMessage"
         label="督办消息"
         width="150"
@@ -159,7 +164,14 @@
           </span>
           <span v-else>{{ scope.row.supervisionMessage }}</span>
         </template>
-      </el-table-column>
+      </el-table-column> -->
+      <el-table-column
+        prop="requireContent"
+        label="督办消息"
+        width="260"
+        header-align="center"
+        align="left"
+      ></el-table-column>
       <el-table-column
         label="操作"
         width="260"
@@ -192,7 +204,7 @@
               督办情况
             </el-button>
             <el-button
-              v-if="scope.row.supervisionStatus === '0'"
+              v-if="scope.row.superviseStatus === '0'"
               size="mini"
               type="text"
               @click="handleEndSupervision(scope.row)"
@@ -591,6 +603,7 @@
         this.isSupervisionDetail = true
         this.currentTask = row
         const id = row && (row.superviseId || row.id || row.ID)
+        const projectId = row.projectId
         if (!id) {
           this.supervisionRecords = []
           return
@@ -601,7 +614,7 @@
           spinner: 'el-icon-loading',
           background: 'rgba(0, 0, 0, 0.3)',
         })
-        getSuperviseReportDetail({ id })
+        getSuperviseReportDetail({ id, projectId })
           .then((res) => {
             const raw = (res && (res.value || res.data)) || []
             const arr = Array.isArray(raw)
@@ -612,8 +625,8 @@
             this.supervisionRecords = arr.map((it, idx) => ({
               serialNumber: idx + 1,
               supervisor: it.supervisor || it.supervisorName || '',
-              reportTime: it.reportTime || it.createTime || it.reportDate || '',
-              reportContent: it.reportContent || it.content || '',
+              reportTime: it.requireTime || '',
+              reportContent: it.requireContent || '',
               relatedFiles:
                 it.attachmentUrls || it.attachmentIds || it.relatedFiles || '',
             }))
@@ -653,13 +666,14 @@
               spinner: 'el-icon-loading',
               background: 'rgba(0, 0, 0, 0.3)',
             })
-            const id = row && (row.superviseId || row.ID)
-            if (!id) {
-              loading && loading.close && loading.close()
-              this.$message.error('缺少ID,无法结束督办')
-              return
-            }
-            deleteSuperviseTask({ id })
+            // const id = row && (row.superviseId || row.ID)
+            // if (!id) {
+            //   loading && loading.close && loading.close()
+            //   this.$message.error('缺少ID,无法结束督办')
+            //   return
+            // }
+            const projectId = row.projectId
+            deleteSuperviseTask({ projectId })
               .then((res) => {
                 if (res && Number(res.code) === 200) {
                   this.$message.success('已结束督办')