Browse Source

feat(api): remove user字段变更

gemercheung 3 years ago
parent
commit
b0389189f0

+ 4 - 2
src/api/sys/model/userModel.ts

@@ -51,9 +51,11 @@ export interface LoginResultModel {
 export interface GetUserInfoModel {
   roles: RoleInfo[];
   // 用户id
-  userId: string | number;
+  id: string | number;
+
+  // userId: string | number;
   // 用户名
-  username: string;
+  userName: string;
   // 真实名字
   realName: string;
   // 头像

+ 2 - 2
src/api/sys/user.ts

@@ -9,7 +9,7 @@ enum Api {
   // Login = '/basic-api/sys/login',
   Login = '/zfb-api/zfb/loginBackground',
   Logout = '/logout',
-  GetUserInfo = '/basic-api/sys/user/infoAnon',
+  GetUserInfo = '/zfb-api/zfb/shop/sys/user/infoAnon',
   GetPermCode = '/getPermCode',
 }
 
@@ -45,7 +45,7 @@ export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal')
  * @description: getUserInfo
  */
 export function getUserInfo(id: number) {
-  return defHttp.get<GetUserInfoModel>(
+  return defHttp.post<GetUserInfoModel>(
     { url: `${Api.GetUserInfo}/${id}` },
     { errorMessageMode: 'none' },
   );

+ 2 - 0
src/api/system/system.ts

@@ -21,6 +21,7 @@ enum Api {
   saveMenu = '/zfb-api/zfb/shop/sys/menu/save',
   updateMenu = '/zfb-api/zfb/shop/sys/menu/update',
   deleteMenu = '/zfb-api/zfb/shop/sys/menu/delete',
+  MenuUser = '/zfb-api/zfb/shop/sys/menu/delete',
 
   AccountList = '/zfb-api/zfb/shop/sys/user/list',
   IsAccountExist = '/basic-api/system/accountExist',
@@ -28,6 +29,7 @@ enum Api {
   RolePageList = '/zfb-api/zfb/shop/sys/role/list',
   setRoleStatus = '/basic-api/system/setRoleStatus',
   GetAllRoleList = '/basic-api/system/getAllRoleList',
+  roleSelectList = '/zfb-api/zfb/shop/sys/role/select',
 
   DeptList = '/zfb-api/zfb/shop/sys/company/list',
   // DeptTree = 'sys/dept/list',

+ 3 - 0
src/components/Upload/src/UploadModal.vue

@@ -196,6 +196,7 @@
           );
           item.status = UploadResultStatus.SUCCESS;
           item.responseData = data;
+
           return {
             success: true,
             error: null,
@@ -226,6 +227,8 @@
               return uploadApiByItem(item);
             }),
           );
+          debugger;
+
           isUploadingRef.value = false;
           // 生产环境:抛出错误
           const errorList = data.filter((item: any) => !item.success);

+ 1 - 1
src/store/modules/user.ts

@@ -131,7 +131,7 @@ export const useUserStore = defineStore({
     },
     async getUserInfoAction(id?: number): Promise<UserInfo | null> {
       if (!this.getToken) return null;
-      const userId: number = id || Number(this.getUserInfoCache.userId);
+      const userId: number = id || Number(this.getUserInfoCache.id);
       // debugger;
       const userInfo = await getUserInfo(userId);
       const { roles = [] } = userInfo;

+ 1 - 1
src/views/dashboard/scenes/list.vue

@@ -110,7 +110,7 @@
           title: '操作',
           dataIndex: '',
           slots: { customRender: 'action' },
-          width: 200,
+          width: 180,
           fixed: 'right',
         },
       ];

+ 34 - 24
src/views/dashboard/system/account/account.data.ts

@@ -1,27 +1,37 @@
-import { getAllRoleList, isAccountExist } from '/@/api/system/system';
+// isAccountExist
+import { getAllRoleList } from '/@/api/system/system';
 import { BasicColumn } from '/@/components/Table';
 import { FormSchema } from '/@/components/Table';
+import { h } from 'vue';
+// import { Switch } from 'ant-design-vue';
+import { Time } from '/@/components/Time';
 
 export const columns: BasicColumn[] = [
   {
     title: '用户名',
-    dataIndex: 'account',
+    dataIndex: 'userName',
     width: 120,
   },
   {
     title: '昵称',
-    dataIndex: 'nickname',
+    dataIndex: 'nickName',
     width: 120,
   },
   {
-    title: '邮箱',
-    dataIndex: 'email',
-    width: 120,
+    title: '手机',
+    dataIndex: 'phone',
+    width: 140,
   },
   {
     title: '创建时间',
     dataIndex: 'createTime',
     width: 180,
+    customRender: ({ record }) => {
+      return h(Time, {
+        value: record.createTime,
+        mode: 'datetime',
+      });
+    },
   },
   {
     title: '角色',
@@ -54,24 +64,24 @@ export const accountFormSchema: FormSchema[] = [
     field: 'account',
     label: '用户名',
     component: 'Input',
-    helpMessage: ['本字段演示异步验证', '不能输入带有admin的用户名'],
-    rules: [
-      {
-        required: true,
-        message: '请输入用户名',
-      },
-      {
-        validator(_, value) {
-          return new Promise((resolve, reject) => {
-            isAccountExist(value)
-              .then(() => resolve())
-              .catch((err) => {
-                reject(err.message || '验证失败');
-              });
-          });
-        },
-      },
-    ],
+    // helpMessage: ['本字段演示异步验证', '不能输入带有admin的用户名'],
+    // rules: [
+    //   {
+    //     required: true,
+    //     message: '请输入用户名',
+    //   },
+    //   {
+    //     validator(_, value) {
+    //       return new Promise((resolve, reject) => {
+    //         isAccountExist(value)
+    //           .then(() => resolve())
+    //           .catch((err) => {
+    //             reject(err.message || '验证失败');
+    //           });
+    //       });
+    //     },
+    //   },
+    // ],
   },
   {
     field: 'pwd',

+ 12 - 4
src/views/dashboard/system/account/index.vue

@@ -1,7 +1,11 @@
 <template>
   <PageWrapper dense contentFullHeight fixedHeight contentClass="flex">
     <!-- <DeptTree class="w-1/4 xl:w-1/5" @select="handleSelect" /> -->
-    <BasicTable @register="registerTable" :searchInfo="searchInfo">
+    <BasicTable
+      @register="registerTable"
+      :searchInfo="searchInfo"
+      :rowSelection="{ type: 'checkbox' }"
+    >
       <template #toolbar>
         <a-button type="primary" @click="handleCreate">新增账号</a-button>
       </template>
@@ -55,7 +59,7 @@
       const go = useGo();
       const [registerModal, { openModal }] = useModal();
       const searchInfo = reactive<Recordable>({});
-      const [registerTable, { reload, updateTableDataRecord }] = useTable({
+      const [registerTable, { reload }] = useTable({
         title: '账号列表',
         api: getAccountList,
         rowKey: 'id',
@@ -67,7 +71,11 @@
         },
         useSearchForm: true,
         showTableSetting: true,
+        clickToRowSelect: false,
+        tableSetting: { fullScreen: true },
+        showIndexColumn: true,
         bordered: true,
+
         handleSearchInfoFn(info) {
           console.log('handleSearchInfoFn', info);
           return info;
@@ -102,8 +110,8 @@
         if (isUpdate) {
           // 演示不刷新表格直接更新内部数据。
           // 注意:updateTableDataRecord要求表格的rowKey属性为string并且存在于每一行的record的keys中
-          const result = updateTableDataRecord(values.id, values);
-          console.log(result);
+          // const result = updateTableDataRecord(values.id, values);
+          console.log(values);
         } else {
           reload();
         }

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

@@ -189,7 +189,7 @@
       if (userInfo) {
         notification.success({
           message: t('sys.login.loginSuccessTitle'),
-          description: `${t('sys.login.loginSuccessDesc')}: ${userInfo.username}`,
+          description: `${t('sys.login.loginSuccessDesc')}: ${userInfo.userName}`,
           duration: 3,
         });
       }

+ 2 - 2
types/store.d.ts

@@ -31,8 +31,8 @@ export interface ErrorLogInfo {
 }
 
 export interface UserInfo {
-  userId: string | number;
-  username: string;
+  id: string | number;
+  userName: string;
   realName: string;
   avatar: string;
   desc?: string;