浏览代码

请求info修改

wangwei 4 年之前
父节点
当前提交
6f3d9a1fab

+ 1 - 1
src/api/sys/model/userModel.ts

@@ -65,7 +65,7 @@ export interface GetUserListModel {}
 export interface GetUserInfoByUserIdModel {
   roles: RoleInfo[];
   // 用户id
-  userId: string | number;
+  id: string | number;
   // 用户名
   username: string;
   // 真实名字

+ 6 - 3
src/api/sys/user.ts

@@ -13,7 +13,7 @@ import { ErrorMessageMode } from '/@/utils/http/axios/types';
 
 enum Api {
   Login = '/login',
-  GetUserInfoById = '/info',
+  GetUserInfoById = '/info/',
   GetUserList = '/getUserList',
   AddUser = '/addUser',
   EditUser = '/editUser',
@@ -41,10 +41,13 @@ export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal')
  * @description: getUserInfoById
  */
 export function getUserInfoById(params: GetUserInfoByUserIdParams) {
+  console.log('=============params===============');
+  console.log(params);
+
+  console.log('=============params===============');
   return defHttp.request<GetUserInfoByUserIdModel>({
-    url: Api.GetUserInfoById,
+    url: Api.GetUserInfoById + params.userId,
     method: 'GET',
-    params,
   });
 }
 

+ 15 - 4
src/store/modules/user.ts

@@ -111,9 +111,11 @@ class User extends VuexModule {
 
       // save token
       this.commitTokenState(token);
-
+      console.log('=========save token =============');
       // get user info
       const userInfo = await this.getUserInfoAction({ userId });
+      console.log(userInfo);
+
       console.log('========route=========');
       console.log(goHome);
       console.log(PageEnum.BASE_HOME);
@@ -128,9 +130,18 @@ class User extends VuexModule {
   @Action
   async getUserInfoAction({ userId }: GetUserInfoByUserIdParams) {
     const userInfo = await getUserInfoById({ userId });
-    const { roles } = userInfo;
-    const roleList = roles.map((item) => item.value) as RoleEnum[];
-    this.commitUserInfoState(userInfo);
+    console.log('======console.log(userInfo);========');
+    console.log(userInfo);
+    const roles: any = userInfo;
+    console.log(roles);
+
+    // const roleList = roles.map((item) => item.value) as RoleEnum[];
+    const roleList = roles.map((item) => ({ value: item.username })) as RoleEnum[];
+    console.log(roleList);
+
+    console.log('==========console.log(userInfo);======');
+
+    this.commitUserInfoState(userInfo[0]);
     this.commitRoleListState(roleList);
     return userInfo;
   }

+ 54 - 51
src/views/permission/admin_log/popup.vue

@@ -1,22 +1,27 @@
 <template>
-  <BasicModal v-bind="$attrs" @register="register" :showOkBtn='false' cancelText='关闭' :title="title">
+  <BasicModal
+    v-bind="$attrs"
+    @register="register"
+    :showOkBtn="false"
+    cancelText="关闭"
+    :title="title"
+  >
     <Description
-    :collapseOptions="{ canExpand: false, helpMessage: '日志详情' }"
-    :column="1"
-    :data="model"
-    :schema="schema"
+      :collapseOptions="{ canExpand: false, helpMessage: '日志详情' }"
+      :column="1"
+      :data="model"
+      :schema="schema"
     />
   </BasicModal>
 </template>
 <script lang="ts">
-
   import { defineComponent, PropType, ref, toRefs } from 'vue';
   import { BasicModal, useModalInner } from '/@/components/Modal';
   import { Description, DescItem } from '/@/components/Description/index';
-  import { adapt } from '/@/utils/adapt'
+  import { adapt } from '/@/utils/adapt';
 
   interface ModelData {
-    title: string,
+    title: string;
   }
 
   export default defineComponent({
@@ -28,48 +33,47 @@
       },
     },
     setup(props) {
-      const modelData:ModelData = props.modelData
+      const modelData: ModelData = props.modelData;
 
       const modelRef = ref({});
-      const adaptWidth = adapt()
+      const adaptWidth = adapt();
       const schema: DescItem[] = [
         {
-            field: 'id',
-            label: 'id',
+          field: 'id',
+          label: 'id',
         },
         {
-            field: 'admin_id',
-            label: 'admin_id',
+          field: 'admin_id',
+          label: 'admin_id',
         },
         {
-            field: 'username',
-            label: '用户名',
+          field: 'username',
+          label: '用户名',
         },
         {
-            field: 'title',
-            label: '标题',
+          field: 'title',
+          label: '标题',
         },
         {
-            field: 'url',
-            label: 'Url',
+          field: 'url',
+          label: 'Url',
         },
         {
-            field: 'ip',
-            label: 'IP',
+          field: 'ip',
+          label: 'IP',
         },
         {
-            field: 'browser',
-            label: 'Browser',
+          field: 'browser',
+          label: 'Browser',
         },
         {
-            field: 'time',
-            label: '创建时间',
+          field: 'time',
+          label: '创建时间',
         },
       ];
-      const [register ] = useModalInner((data) => {
-
+      const [register] = useModalInner((data) => {
         // 方式2
-        modelRef.value = data
+        modelRef.value = data;
       });
 
       return {
@@ -77,39 +81,38 @@
         adaptWidth,
         schema,
         model: modelRef,
-        ...toRefs(modelData)
+        ...toRefs(modelData),
       };
     },
   });
 </script>
-<style lang='less'>
-.ant-form-item-label {
-  text-align: center !important;
-}
-
-.tree-label {
-  width: 20.6%;
-  margin-top: 8px;
-  margin-bottom: 1em;
-  text-align: center;
-}
-
-@media (max-width: 639px) {
+<style lang="less">
   .ant-form-item-label {
-    line-height: 2.5715 !important;
     text-align: center !important;
- }
+  }
 
   .tree-label {
-    width: 33%;
+    width: 20.6%;
     margin-top: 8px;
     margin-bottom: 1em;
     text-align: center;
-}
+  }
 
-.ant-descriptions-item-content {
-  font-size: 12px !important;
+  @media (max-width: 639px) {
+    .ant-form-item-label {
+      line-height: 2.5715 !important;
+      text-align: center !important;
+    }
 
-}
-}
+    .tree-label {
+      width: 33%;
+      margin-top: 8px;
+      margin-bottom: 1em;
+      text-align: center;
+    }
+
+    .ant-descriptions-item-content {
+      font-size: 12px !important;
+    }
+  }
 </style>

+ 1 - 1
src/views/sys/login/LoginForm.vue

@@ -145,7 +145,7 @@
           if (userInfo) {
             notification.success({
               message: t('sys.login.loginSuccessTitle'),
-              description: `${t('sys.login.loginSuccessDesc')}: ${userInfo.nickname}`,
+              description: `${t('sys.login.loginSuccessDesc')}: ${userInfo[0].nickname}`,
               duration: 3,
             });
           }