浏览代码

feat 添加获取当前登录用户所属公司名称的功能(当basicInfoData中不存在时使用)

xieyong 2 周之前
父节点
当前提交
96e5b5c6a3

+ 34 - 2
src/views/bpm/handleTask/components/qualityReportApproval/template/inspection_report3.vue

@@ -18,7 +18,7 @@
           margin-bottom: 5px;
           margin-bottom: 5px;
           font-weight: bold;
           font-weight: bold;
         "
         "
-        >{{ basicInfoData.groupName || '湖南特瑞精密医疗器器械有限公司' }}</div
+        >{{ groupName }}</div
       >
       >
       <div style="text-align: center; font-size: 18px; margin-bottom: 5px"
       <div style="text-align: center; font-size: 18px; margin-bottom: 5px"
         >不合格品通知及评审处置表</div
         >不合格品通知及评审处置表</div
@@ -489,7 +489,7 @@
           margin-bottom: 5px;
           margin-bottom: 5px;
           font-weight: bold;
           font-weight: bold;
         "
         "
-        >{{ basicInfoData.groupName || '湖南特瑞精密医疗器器械有限公司' }}</div
+        >{{ groupName }}</div
       >
       >
       <div style="text-align: center; font-size: 18px; margin-bottom: 5px"
       <div style="text-align: center; font-size: 18px; margin-bottom: 5px"
         >不合格品通知及评审处置表</div
         >不合格品通知及评审处置表</div
@@ -1106,6 +1106,7 @@
 <script>
 <script>
   import imageUpload from '@/components/upload/imageUpload.vue';
   import imageUpload from '@/components/upload/imageUpload.vue';
   import { getFmImagePath } from '@/utils/file';
   import { getFmImagePath } from '@/utils/file';
+  import { getCurrentUser } from '@/utils/token-util';
 
 
   export default {
   export default {
     name: 'QualityReport',
     name: 'QualityReport',
@@ -1125,6 +1126,8 @@
           // 表单编号、版本(两处共用)
           // 表单编号、版本(两处共用)
           reportNumber: '',
           reportNumber: '',
           version: '',
           version: '',
+          // 表单抬头公司名称,为空时默认取当前登录用户所属公司
+          groupName: '',
           // 处置编号
           // 处置编号
           disposalNumber: '',
           disposalNumber: '',
           remark: '',
           remark: '',
@@ -1204,6 +1207,31 @@
         }
         }
       };
       };
     },
     },
+    computed: {
+      /**
+       * 当前登录用户所属公司(集团)名称
+       * 优先取当前切换后的分组,兼容多公司切换场景
+       */
+      currentUserGroupName() {
+        const userInfo = this.$store.state.user.info || {};
+        const currentGroupId = getCurrentUser()?.currentGroupId;
+        const currentGroup = (userInfo.loginChangeGroupVOList || []).find(
+          (item) => item.groupId == currentGroupId
+        );
+        return currentGroup?.groupName || userInfo.groupName || '';
+      },
+      /**
+       * 表单抬头公司名称
+       * 优先取表单数据,不存在时默认取当前登录用户所属公司
+       */
+      groupName() {
+        return (
+          this.basicInfoData.groupName ||
+          this.currentUserGroupName ||
+          '湖南特瑞精密医疗器器械有限公司'
+        );
+      }
+    },
     methods: {
     methods: {
       /* 打开质检报告 */
       /* 打开质检报告 */
       async init(basicInfoData) {
       async init(basicInfoData) {
@@ -1214,6 +1242,10 @@
             ...basicInfoData
             ...basicInfoData
           });
           });
         }
         }
+        // 表单未带公司名称时,默认使用当前登录用户所属公司
+        if (!this.basicInfoData.groupName) {
+          this.basicInfoData.groupName = this.currentUserGroupName || '';
+        }
       },
       },
       /* 保存编辑 */
       /* 保存编辑 */
       async getValue() {
       async getValue() {