Bläddra i källkod

feat(complaint): 添加用户信息类型定义和获取方法

yz 2 veckor sedan
förälder
incheckning
964cad815b
2 ändrade filer med 77 tillägg och 2 borttagningar
  1. 60 0
      src/types/global.d.ts
  2. 17 2
      src/views/complaint/complaintMixin.js

+ 60 - 0
src/types/global.d.ts

@@ -35,6 +35,66 @@ declare global {
         success: boolean;
         data: T;
     }
+
+    /**
+     * 用户信息接口
+     * 描述登录成功后存储在Vuex中的用户信息结构
+     */
+    interface UserInfo {
+        /** 访问令牌 */
+        access_token: string;
+        /** 令牌类型 */
+        token_type: string;
+        /** 刷新令牌 */
+        refresh_token: string;
+        /** 令牌过期时间(秒) */
+        expires_in: number;
+        /** 权限范围 */
+        scope: string;
+        /** 租户ID */
+        tenant_id: string;
+        /** 用户名 */
+        user_name: string;
+        /** 部门父级ID */
+        dept_pid: string;
+        /** 真实姓名 */
+        real_name: string;
+        /** 头像URL */
+        avatar: string;
+        /** 公司名称 */
+        corp_name: string;
+        /** 客户端ID */
+        client_id: string;
+        /** 角色名称 */
+        role_name: string;
+        /** 许可证信息 */
+        license: string;
+        /** 岗位ID(逗号分隔的字符串) */
+        post_id: string;
+        /** 用户ID */
+        user_id: string;
+        /** 角色ID */
+        role_id: string;
+        /** 昵称 */
+        nick_name: string;
+        /** 公司地址 */
+        corp_address: string;
+        /** OAuth ID */
+        oauth_id: string;
+        /** 详细信息 */
+        detail: {
+            /** 类型 */
+            type: string;
+        };
+        /** 部门ID */
+        dept_id: string;
+        /** 公司ID */
+        corp_id: string | null;
+        /** 账号 */
+        account: string;
+        /** JWT ID */
+        jti: string;
+    }
 }
 
 export {};

+ 17 - 2
src/views/complaint/complaintMixin.js

@@ -12,6 +12,10 @@ import {
   addReply
 } from '@/api/complaint/reply'
 import { mapGetters } from 'vuex'
+
+/**
+ * @type {UserInfo} UserInfo - 用户信息类型
+ */
 import {
   COMPLAINANT_TYPE_OPTIONS,
   COMPLAINT_TYPE_OPTIONS,
@@ -232,6 +236,14 @@ export default {
   },
   computed: {
     ...mapGetters(['permission', 'userInfo']),
+
+    /**
+     * 获取用户信息
+     * @returns {UserInfo} 用户信息对象
+     */
+    getUserInfo() {
+      return this.userInfo
+    },
     permissionList() {
       return {
         // addBtn: this.vaildData(this.permission.complaint_add, false),
@@ -554,14 +566,17 @@ export default {
      * 打开新增回复对话框
      */
     handleAddReply() {
+      /** @type {UserInfo} */
+      const userInfo = this.getUserInfo
+
       this.replyForm = {
         complaintId: this.currentComplaintId,
         complaintNo: this.currentComplaintNo,
         replyType: REPLY_TYPE.SYSTEM,
         replyContent: '',
         replyAttachUrl: '',
-        replierId: this.userInfo.user_id || '',
-        replierName: this.userInfo.user_name || '',
+        replierId: userInfo.user_id || '',
+        replierName: userInfo.real_name || userInfo.user_name || '',
       }
       this.addReplyVisible = true
       this.$nextTick(() => {