Browse Source

chore: 增加最后修改人和最后修改时间

xyh 2 years ago
parent
commit
ad0d30a7aa

+ 2 - 2
packages/app/src/models/request/user.ts

@@ -12,13 +12,13 @@ export type GetUserListParams = {
 /** 新增用户 */
 export type AddUserParams = Omit<
 UserListData,
-'departmentId' | 'roleId' | 'createTime' | 'id' | 'code'
+'departmentId' | 'roleId' | 'createTime' | 'id' | 'code' | 'modifyUser' | 'modifyTime'
 >;
 
 /** 修改用户 */
 export type EditUserParams = Omit<
 UserListData,
-'departmentId' | 'roleId' | 'createTime' | 'code' | 'password'
+'departmentId' | 'roleId' | 'createTime' | 'code' | 'password' | 'modifyUser' | 'modifyTime'
 >;
 
 /** 修改密码 */

+ 3 - 1
packages/app/src/models/response/container.ts

@@ -1,3 +1,5 @@
+import {ModifyData} from '.';
+
 export type ContainerListData = {
   id: string;
   /**
@@ -24,7 +26,7 @@ export type ContainerListData = {
   departmentId: string;
   /** 编号 */
   code: string;
-};
+} & ModifyData;
 
 /** 容器废弃日志 */
 export type ScrapContainerLogData = {

+ 2 - 2
packages/app/src/models/response/dictionary.ts

@@ -1,4 +1,4 @@
-import {BaseListData} from '.';
+import {BaseListData, ModifyData} from '.';
 
 export type DictionaryData = {
   /** 编号 */
@@ -27,7 +27,7 @@ export type DictionaryData = {
   maxNum: null | string;
   /** 最小存储数量 */
   minNum: null | string;
-};
+} & ModifyData;
 
 export type BaseResultContent<T> = {msg: '200'; data: T; amount: Record<string, number>}
 | {msg: '510'; errMsg: string};

+ 9 - 0
packages/app/src/models/response/index.ts

@@ -22,6 +22,15 @@ export type BaseListData<T> = {
   navigateFirstPage: number;
   navigateLastPage: number;
 };
+
+/** 最后修改信息 */
+export type ModifyData = {
+  /** 最后修改人 */
+  modifyUser: string;
+  /** 最后修改时间 */
+  modifyTime: string;
+};
+
 export type BaseListResult<T = any> = BaseResult<BaseListData<T>>;
 // eslint-disable-next-line @typescript-eslint/no-unused-vars
 export type GetBaseListType<T> = T extends BaseListResult<infer T> ? T : never;

+ 3 - 1
packages/app/src/models/response/material.ts

@@ -1,3 +1,5 @@
+import {ModifyData} from '.';
+
 export type MaterialListData = {
   id: string;
   tldId: string;
@@ -7,4 +9,4 @@ export type MaterialListData = {
   /** 物料信息 */
   wllbCode: string;
   wllbName: string;
-};
+} & ModifyData;

+ 3 - 1
packages/app/src/models/response/materialBind.ts

@@ -1,3 +1,5 @@
+import {ModifyData} from '.';
+
 /** 获取物料绑定列表 */
 export type MaterialBindListData = {
   id: string;
@@ -6,4 +8,4 @@ export type MaterialBindListData = {
   realName: string;
   wllbCode: string;
   userId: string;
-};
+} & ModifyData;

+ 3 - 1
packages/app/src/models/response/menu.ts

@@ -1,3 +1,5 @@
+import {ModifyData} from '.';
+
 /** 菜单列表 */
 export type MenuListData = {
   id: string;
@@ -11,7 +13,7 @@ export type MenuListData = {
   orderBy: string;
   /** 菜单图标 */
   img: string;
-};
+} & ModifyData;
 
 /** 属性菜单 */
 export type TreeMenuListData = {

+ 3 - 1
packages/app/src/models/response/role.ts

@@ -1,3 +1,5 @@
+import {ModifyData} from '.';
+
 /** 角色列表 */
 export type RoleListData = {
   id: number;
@@ -17,4 +19,4 @@ export type RoleListData = {
   menuPda: null | string;
   page: number;
   limit: number;
-};
+} & ModifyData;

+ 3 - 1
packages/app/src/models/response/storage.ts

@@ -1,3 +1,5 @@
+import {ModifyData} from '.';
+
 /** 库位列表数据 */
 export type StorageListData = {
   id: string,
@@ -22,4 +24,4 @@ export type StorageListData = {
   /** 仓库名称 */
   wareHouseName: string;
   /** 仓库id */
-};
+} & ModifyData;

+ 3 - 1
packages/app/src/models/response/user.ts

@@ -1,3 +1,5 @@
+import {ModifyData} from '.';
+
 /** 用户登录 */
 export type UserLoginData = {
   id: number,
@@ -39,4 +41,4 @@ export type UserListData = {
   roleId: string;
   /** 创建时间 */
   createTime: string;
-};
+} & ModifyData;

+ 2 - 0
packages/app/src/pages/container/table/hooks.tsx

@@ -129,6 +129,8 @@ export function useHandle(refetch: () => void) {
     {title: '类别', dataIndex: 'type', key: 'type', width: MIDDLE_TABLE_WIDTH},
     {title: '部门', dataIndex: 'department', key: 'department', width: NORMAL_TABLE_WIDTH},
     {title: '数量', dataIndex: 'num', key: 'num', width: SMALL_TABLE_WIDTH},
+    {title: '最后修改人', dataIndex: 'modifyUser', key: 'modifyUser', width: NORMAL_TABLE_WIDTH},
+    {title: '最后修改时间', dataIndex: 'modifyTime', key: 'modifyTime', width: MIDDLE_TABLE_WIDTH},
     {title: '创建时间', dataIndex: 'createTime', key: 'createTime', width: MIDDLE_TABLE_WIDTH},
     {
       title: '操作',

+ 2 - 0
packages/app/src/pages/goods/table/hooks.tsx

@@ -86,6 +86,8 @@ export function useHandle() {
       },
       width: SMALL_TABLE_WIDTH,
     },
+    {title: '最后修改人', dataIndex: 'modifyUser', key: 'modifyUser', width: NORMAL_TABLE_WIDTH},
+    {title: '最后修改时间', dataIndex: 'modifyTime', key: 'modifyTime', width: MIDDLE_TABLE_WIDTH},
     {
       title: '操作',
       dataIndex: 'tldId',

+ 9 - 1
packages/app/src/pages/material-bind/table/hooks.tsx

@@ -7,7 +7,13 @@ import {MaterialBindListData} from '@models';
 import {Button, message} from 'antd';
 import {useState} from 'react';
 import {useMutation} from '@tanstack/react-query';
-import {DOUBLE_BTN_WIDTH, HUGE_TABLE_WIDTH, MIDDLE_TABLE_WIDTH, deleteConfirm} from '@utils';
+import {
+  DOUBLE_BTN_WIDTH,
+  HUGE_TABLE_WIDTH,
+  MIDDLE_TABLE_WIDTH,
+  NORMAL_TABLE_WIDTH,
+  deleteConfirm,
+} from '@utils';
 
 export function useList() {
   const params = useContextSection(context, state => state[0]);
@@ -77,6 +83,8 @@ export function useHandle(refetch: () => void) {
     {title: '物料编号', dataIndex: 'wllbCode', key: 'wllbCode', width: MIDDLE_TABLE_WIDTH},
     {title: '物料名称', dataIndex: 'materialName', key: 'materialName', width: HUGE_TABLE_WIDTH},
     {title: '用户名称', dataIndex: 'realName', key: 'realName', width: MIDDLE_TABLE_WIDTH},
+    {title: '最后修改人', dataIndex: 'modifyUser', key: 'modifyUser', width: NORMAL_TABLE_WIDTH},
+    {title: '最后修改时间', dataIndex: 'modifyTime', key: 'modifyTime', width: MIDDLE_TABLE_WIDTH},
     {
       title: '操作',
       dataIndex: 'id',

+ 3 - 0
packages/app/src/pages/matter/table/hooks.tsx

@@ -11,6 +11,7 @@ import {
   DOUBLE_BTN_WIDTH,
   HUGE_TABLE_WIDTH,
   LARGE_TABLE_WIDTH,
+  MIDDLE_TABLE_WIDTH,
   NORMAL_TABLE_WIDTH,
   deleteConfirm,
 } from '@utils';
@@ -99,6 +100,8 @@ export function useHandle(refetch: () => void) {
       key: 'storageLocationName',
       width: NORMAL_TABLE_WIDTH,
     },
+    {title: '最后修改人', dataIndex: 'modifyUser', key: 'modifyUser', width: NORMAL_TABLE_WIDTH},
+    {title: '最后修改时间', dataIndex: 'modifyTime', key: 'modifyTime', width: MIDDLE_TABLE_WIDTH},
     {
       title: '操作',
       dataIndex: 'id',

+ 9 - 1
packages/app/src/pages/menu-id/table/hooks.tsx

@@ -7,7 +7,13 @@ import {MenuListData} from '@models';
 import {Button, message} from 'antd';
 import {ColumnsType} from 'antd/es/table';
 import {useContextSection, useQueryTableList} from '@hooks';
-import {DOUBLE_BTN_WIDTH, NORMAL_TABLE_WIDTH, SMALL_TABLE_WIDTH, deleteConfirm} from '@utils';
+import {
+  DOUBLE_BTN_WIDTH,
+  MIDDLE_TABLE_WIDTH,
+  NORMAL_TABLE_WIDTH,
+  SMALL_TABLE_WIDTH,
+  deleteConfirm,
+} from '@utils';
 
 export function useList() {
   const pId = useContextSection(pIdContext, ([pid]) => pid);
@@ -84,6 +90,8 @@ export function useHandle(data: MenuListData[], refetch: () => void) {
       key: 'orderBy',
       width: SMALL_TABLE_WIDTH,
     },
+    {title: '最后修改人', dataIndex: 'modifyUser', key: 'modifyUser', width: NORMAL_TABLE_WIDTH},
+    {title: '最后修改时间', dataIndex: 'modifyTime', key: 'modifyTime', width: MIDDLE_TABLE_WIDTH},
     {
       title: '操作',
       dataIndex: 'id',

+ 10 - 1
packages/app/src/pages/menu/table/hooks.tsx

@@ -7,7 +7,14 @@ import {MenuListData} from '@models';
 import {Button, message} from 'antd';
 import {ColumnsType} from 'antd/es/table';
 import {useContextSection, useQueryTableList} from '@hooks';
-import {HUGE_TABLE_WIDTH, LARGE_TABLE_WIDTH, SMALL_TABLE_WIDTH, deleteConfirm} from '@utils';
+import {
+  HUGE_TABLE_WIDTH,
+  LARGE_TABLE_WIDTH,
+  MIDDLE_TABLE_WIDTH,
+  NORMAL_TABLE_WIDTH,
+  SMALL_TABLE_WIDTH,
+  deleteConfirm,
+} from '@utils';
 import {FontIcon} from '@components';
 
 export function useList() {
@@ -100,6 +107,8 @@ export function useHandle(refetch: () => void) {
       },
       width: SMALL_TABLE_WIDTH,
     },
+    {title: '最后修改人', dataIndex: 'modifyUser', key: 'modifyUser', width: NORMAL_TABLE_WIDTH},
+    {title: '最后修改时间', dataIndex: 'modifyTime', key: 'modifyTime', width: MIDDLE_TABLE_WIDTH},
     {
       title: '操作',
       dataIndex: 'id',

+ 4 - 0
packages/app/src/pages/pda-menu/table/hooks.tsx

@@ -10,7 +10,9 @@ import {useContextSection, useQueryTableList} from '@hooks';
 import {
   DOUBLE_BTN_WIDTH,
   HUGE_TABLE_WIDTH,
+  MIDDLE_TABLE_WIDTH,
   MINIMAL_TABLE_WIDTH,
+  NORMAL_TABLE_WIDTH,
   SMALL_TABLE_WIDTH,
   deleteConfirm,
 } from '@utils';
@@ -94,6 +96,8 @@ export function useHandle(refetch: () => void) {
       key: 'orderBy',
       width: SMALL_TABLE_WIDTH,
     },
+    {title: '最后修改人', dataIndex: 'modifyUser', key: 'modifyUser', width: NORMAL_TABLE_WIDTH},
+    {title: '最后修改时间', dataIndex: 'modifyTime', key: 'modifyTime', width: MIDDLE_TABLE_WIDTH},
     {
       title: '操作',
       dataIndex: 'id',

+ 12 - 0
packages/app/src/pages/role/table/hooks.tsx

@@ -107,6 +107,18 @@ export function useHandle(data: RoleListData[], refetch: () => void) {
       key: 'roleName',
       width: NORMAL_TABLE_WIDTH,
     },
+    {
+      title: '最后修改人',
+      dataIndex: 'modifyUser',
+      key: 'modifyUser',
+      width: NORMAL_TABLE_WIDTH,
+    },
+    {
+      title: '最后修改时间',
+      dataIndex: 'modifyTime',
+      key: 'modifyTime',
+      width: MIDDLE_TABLE_WIDTH,
+    },
     {
       title: '创建时间',
       dataIndex: 'createTime',

+ 9 - 1
packages/app/src/pages/storage/table/hooks.tsx

@@ -7,7 +7,13 @@ import {ColumnsType} from 'antd/es/table';
 import {StorageListData} from '@models';
 import {Button, message} from 'antd';
 import {useBoolean} from 'ahooks';
-import {DOUBLE_BTN_WIDTH, NORMAL_TABLE_WIDTH, SMALL_TABLE_WIDTH, deleteConfirm} from '@utils';
+import {
+  DOUBLE_BTN_WIDTH,
+  MIDDLE_TABLE_WIDTH,
+  NORMAL_TABLE_WIDTH,
+  SMALL_TABLE_WIDTH,
+  deleteConfirm,
+} from '@utils';
 
 export function useList() {
   const params = useContextSection(
@@ -97,6 +103,8 @@ export function useHandle(reftch: () => void) {
       },
       width: NORMAL_TABLE_WIDTH,
     },
+    {title: '最后修改人', dataIndex: 'modifyUser', key: 'modifyUser', width: NORMAL_TABLE_WIDTH},
+    {title: '最后修改时间', dataIndex: 'modifyTime', key: 'modifyTime', width: MIDDLE_TABLE_WIDTH},
     {
       title: '创建时间',
       dataIndex: 'createTime',

+ 5 - 4
packages/app/src/pages/user/table/hooks.tsx

@@ -98,14 +98,15 @@ export function useHandle(onFetch: () => void) {
 
   const [isReseting, onResetClick] = useResetPassword();
   const columns: ColumnsType<UserListData> = [
-    {title: '用户编号', dataIndex: 'code', key: 'code', width: SMALL_TABLE_WIDTH},
+    {title: '用户编号', dataIndex: 'code', key: 'code', width: NORMAL_TABLE_WIDTH},
     {title: '用户名称', dataIndex: 'userName', key: 'userName', width: SMALL_TABLE_WIDTH},
-    {title: '真实姓名', dataIndex: 'realName', key: 'realName', width: SMALL_TABLE_WIDTH},
+    {title: '部门', dataIndex: 'department', key: 'department', width: SMALL_TABLE_WIDTH},
+    {title: '角色', dataIndex: 'role', key: 'role', width: NORMAL_TABLE_WIDTH},
     {title: '邮箱', dataIndex: 'email', key: 'email', width: NORMAL_TABLE_WIDTH},
     {title: '电话', dataIndex: 'landline', key: 'landline', width: NORMAL_TABLE_WIDTH},
     {title: '手机', dataIndex: 'phone', key: 'phone', width: NORMAL_TABLE_WIDTH},
-    {title: '部门', dataIndex: 'department', key: 'department', width: SMALL_TABLE_WIDTH},
-    {title: '角色', dataIndex: 'role', key: 'role', width: NORMAL_TABLE_WIDTH},
+    {title: '最后修改人', dataIndex: 'modifyUser', key: 'modifyUser', width: NORMAL_TABLE_WIDTH},
+    {title: '最后修改时间', dataIndex: 'modifyTime', key: 'modifyTime', width: MIDDLE_TABLE_WIDTH},
     {title: '创建时间', dataIndex: 'createTime', key: 'createTime', width: MIDDLE_TABLE_WIDTH},
     {
       title: '操作',

+ 0 - 6
packages/app/src/pages/user/table/modal/Info.tsx

@@ -31,12 +31,6 @@ const UserModalInfo: FC<Props> = function({id}) {
         type='password'
         disabled={Boolean(id)}
       />
-      <ModalField
-        control={control}
-        name='userRealName'
-        label='真实姓名'
-        width={width}
-      />
       <ModalSelect
         control={control}
         name='userDepartment'

+ 2 - 7
packages/app/src/pages/user/table/modal/hooks.ts

@@ -11,7 +11,6 @@ import {object, string} from 'yup';
 export type FormState = {
   userName: string;
   userPassword: string;
-  userRealName: string;
   userEmail: string;
   userLandline: string;
   userPhone: string;
@@ -22,7 +21,6 @@ export type FormState = {
 const validate = object({
   userName: string().required('请输入用户名'),
   userPassword: string().required('请输入用户密码'),
-  userRealName: string().required('请输入真实姓名'),
   userDepartment: string().required('请选择部门'),
   userRole: string().required('请选择角色'),
 });
@@ -69,7 +67,6 @@ export function useFormState(
     defaultValues: {
       userName: '',
       userPassword: '',
-      userRealName: '',
       userEmail: '',
       userLandline: '',
       userPhone: '',
@@ -91,16 +88,15 @@ export function useFormState(
   const onSubmit = handleSubmit(function({
     userName,
     userPassword,
-    userRealName,
     userEmail,
     userLandline,
     userPhone,
     userDepartment,
     userRole,
   }) {
-    const params: Omit<EditUserParams, 'id'> = {
+    const params: Omit<EditUserParams, 'id' | 'modifyTime' | 'modifyUser'> = {
       userName,
-      realName: userRealName,
+      realName: userName,
       email: userEmail,
       landline: userLandline,
       phone: userPhone,
@@ -132,7 +128,6 @@ export function useFetchUserInfo(id: string) {
   useEffect(function() {
     setValue('userName', data?.userName ?? '');
     setValue('userPassword', data?.password ?? '');
-    setValue('userRealName', data?.realName ?? '');
     setValue('userEmail', data?.email ?? '');
     setValue('userLandline', data?.landline ?? '');
     setValue('userPhone', data?.phone ?? '');

+ 19 - 0
packages/app/src/utils/calc-column-width/index.test.ts

@@ -0,0 +1,19 @@
+import {calcColumnsWidth} from '.';
+
+describe('calcColumnsWidth', function() {
+  it('声明', function() {
+    expect(calcColumnsWidth).toBeDefined();
+    expect(calcColumnsWidth).toBeInstanceOf(Function);
+  });
+
+  it('结果测试', function() {
+    let result = calcColumnsWidth([{title: '1'}, {title: '2'}, {title: '3'}]);
+    expect(result).toBe(0);
+
+    result = calcColumnsWidth([{title: '1', width: 100}, {title: '2', width: 30}, {title: '3'}]);
+    expect(result).toBe(130);
+
+    result = calcColumnsWidth([{title: '1', width: 100}, {title: '2', width: 30}, {title: '3', width: 50}]);
+    expect(result).toBe(180);
+  });
+});