Przeglądaj źródła

feat: BasicTable增加onPermChange事件

lanjianrong 4 lat temu
rodzic
commit
34c544f7be
2 zmienionych plików z 11 dodań i 3 usunięć
  1. 5 3
      src/components/Table/src/BasicTable.tsx
  2. 6 0
      src/types/typing.d.ts

+ 5 - 3
src/components/Table/src/BasicTable.tsx

@@ -10,7 +10,7 @@ import { getAuthCache, getPermAuthCache, setAuthCache } from '@/utils/auth'
 import React, { useRef, useState, useLayoutEffect, useMemo } from 'react'
 import { useMount } from 'ahooks'
 import { useTableScroll } from './hooks/useTableScroll'
-import type { BasicTableProps } from '@/types/typing'
+import type { BasicTableProps, PermStateEnum } from '@/types/typing'
 import type { ParamsType } from '@ant-design/pro-provider'
 import type { DensitySize } from '@ant-design/pro-table/lib/components/ToolBar/DensityIcon'
 // import { Resizable } from 'react-resizable'
@@ -50,6 +50,7 @@ const BasicTable: {
   Summary: typeof import('rc-table/lib/Footer/Summary').default
 } = ({
   // resizable = false,
+  onPermChange,
   rowKey,
   headerTitle,
   params,
@@ -120,9 +121,10 @@ const BasicTable: {
       <>
         <PermSelect
           dataType={mainMenuType}
-          onConfirm={({ staffIds, dataPermission }) =>
+          onConfirm={({ staffIds, dataPermission }: PermStateEnum) => {
+            if (onPermChange) onPermChange({ staffIds, dataPermission })
             setState({ ...state, params: { ...state.params, staffIds, dataPermission } })
-          }
+          }}
         />
         <div className="ml-4">{headerTitle}</div>
       </>

+ 6 - 0
src/types/typing.d.ts

@@ -19,7 +19,13 @@ import type { ProFieldEmptyText } from '@ant-design/pro-field'
 import type { Bordered } from '@ant-design/pro-table/lib/typing'
 import type { ReactNode } from 'react-router/node_modules/@types/react'
 
+export type PermStateEnum = {
+  staffIds: string[] | null
+  dataPermission: string | null
+}
+
 export type BasicTableProps<T, U extends ParamsType, ValueType = 'text'> = {
+  onPermChange?: (map: PermStateEnum) => void
   /** @name 配置search栏tooltip的title属性 */
   searchTooptip?: boolean | string | ReactNode
   /** @name 启用列可伸缩功能 */