|
@@ -1,3 +1,4 @@
|
|
|
|
|
+/* eslint-disable react-hooks/rules-of-hooks */
|
|
|
/* eslint-disable no-param-reassign */
|
|
/* eslint-disable no-param-reassign */
|
|
|
import { PERMISSION_SELECT_KEY } from '@/utils/cache/cacheEnum'
|
|
import { PERMISSION_SELECT_KEY } from '@/utils/cache/cacheEnum'
|
|
|
import PermSelect from '@/pages/Customer/Company/components/PermSelect'
|
|
import PermSelect from '@/pages/Customer/Company/components/PermSelect'
|
|
@@ -34,18 +35,28 @@ const BasicTable: {
|
|
|
const {
|
|
const {
|
|
|
initialState: { permData }
|
|
initialState: { permData }
|
|
|
} = useModel('@@initialState')
|
|
} = useModel('@@initialState')
|
|
|
|
|
+ // 如果数据权限不存在,就不渲染
|
|
|
|
|
+ if (isNullOrUnDef(permData)) return null
|
|
|
const permAuthCache = getAuthCache(PERMISSION_SELECT_KEY)
|
|
const permAuthCache = getAuthCache(PERMISSION_SELECT_KEY)
|
|
|
|
|
+ let defaultpermAuthCache = 'onself'
|
|
|
|
|
+ if (permAuthCache && permAuthCache[mainMenuType]) {
|
|
|
|
|
+ defaultpermAuthCache = permAuthCache[mainMenuType]
|
|
|
|
|
+ }
|
|
|
const tableElRef = useRef<HTMLElement>(null)
|
|
const tableElRef = useRef<HTMLElement>(null)
|
|
|
const { getScrollRef, redoHeight } = useTableScroll(tableElRef, columns)
|
|
const { getScrollRef, redoHeight } = useTableScroll(tableElRef, columns)
|
|
|
|
|
|
|
|
|
|
+ console.log('getScrollRef', getScrollRef)
|
|
|
|
|
+
|
|
|
const [state, setState] = useState({
|
|
const [state, setState] = useState({
|
|
|
columnsStateMap: {},
|
|
columnsStateMap: {},
|
|
|
- params: { staffIds: null, dataPermission: permAuthCache[mainMenuType] || null },
|
|
|
|
|
- dataSource: []
|
|
|
|
|
|
|
+ params: { staffIds: null, dataPermission: defaultpermAuthCache },
|
|
|
|
|
+ dataSource: null
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
useLayoutEffect(() => {
|
|
useLayoutEffect(() => {
|
|
|
- if (state.dataSource?.length) redoHeight(state.dataSource)
|
|
|
|
|
|
|
+ if (state.dataSource) {
|
|
|
|
|
+ redoHeight(state.dataSource)
|
|
|
|
|
+ }
|
|
|
}, [state.dataSource])
|
|
}, [state.dataSource])
|
|
|
|
|
|
|
|
useMount(() => {
|
|
useMount(() => {
|
|
@@ -59,9 +70,6 @@ const BasicTable: {
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- // 如果数据权限不存在,就不渲染
|
|
|
|
|
- if (isNullOrUnDef(permData)) return null
|
|
|
|
|
-
|
|
|
|
|
/** 增加头部 */
|
|
/** 增加头部 */
|
|
|
if (mainMenuType) {
|
|
if (mainMenuType) {
|
|
|
resetProps.headerTitle = (
|
|
resetProps.headerTitle = (
|
|
@@ -85,8 +93,6 @@ const BasicTable: {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const handleOnSizeChange = (size: DensitySize) => {
|
|
const handleOnSizeChange = (size: DensitySize) => {
|
|
|
- console.log('size', size)
|
|
|
|
|
-
|
|
|
|
|
if (onSizeChange) onSizeChange(size)
|
|
if (onSizeChange) onSizeChange(size)
|
|
|
redoHeight(state.dataSource, size)
|
|
redoHeight(state.dataSource, size)
|
|
|
}
|
|
}
|