|
@@ -1,11 +1,13 @@
|
|
|
import { useModal } from '@/components/Modal'
|
|
import { useModal } from '@/components/Modal'
|
|
|
import { useModel } from 'umi'
|
|
import { useModel } from 'umi'
|
|
|
-import { Select } from 'antd'
|
|
|
|
|
|
|
+import { Select, Tooltip } from 'antd'
|
|
|
import CustomPerm from './CustomPerm'
|
|
import CustomPerm from './CustomPerm'
|
|
|
import { getAuthCache, setAuthCache } from '@/utils/auth'
|
|
import { getAuthCache, setAuthCache } from '@/utils/auth'
|
|
|
import { PERMISSION_SELECT_KEY } from '@/utils/cache/cacheEnum'
|
|
import { PERMISSION_SELECT_KEY } from '@/utils/cache/cacheEnum'
|
|
|
import type { SelectProps } from 'antd'
|
|
import type { SelectProps } from 'antd'
|
|
|
import type { MainMenuKeyEnum } from '@/utils/cache/cacheEnum'
|
|
import type { MainMenuKeyEnum } from '@/utils/cache/cacheEnum'
|
|
|
|
|
+import { SettingOutlined } from '@ant-design/icons'
|
|
|
|
|
+import { useState } from 'react'
|
|
|
|
|
|
|
|
export const PermDataTypeEunm = {
|
|
export const PermDataTypeEunm = {
|
|
|
CUSTOMER: 'customer',
|
|
CUSTOMER: 'customer',
|
|
@@ -21,6 +23,10 @@ interface PermSelectProps extends SelectProps {
|
|
|
const PermSelect: React.FC<PermSelectProps> = ({ dataType, onConfirm, ...resetProps }) => {
|
|
const PermSelect: React.FC<PermSelectProps> = ({ dataType, onConfirm, ...resetProps }) => {
|
|
|
const { initialState: { permData } = { permData: {} } } = useModel('@@initialState')
|
|
const { initialState: { permData } = { permData: {} } } = useModel('@@initialState')
|
|
|
const { toggleModal, setModalProps } = useModal()
|
|
const { toggleModal, setModalProps } = useModal()
|
|
|
|
|
+ const [state, setState] = useState({
|
|
|
|
|
+ staffIds: [],
|
|
|
|
|
+ showSetting: false
|
|
|
|
|
+ })
|
|
|
let defaultValue = 'oneself'
|
|
let defaultValue = 'oneself'
|
|
|
const options = [...(permData[dataType] || [])]
|
|
const options = [...(permData[dataType] || [])]
|
|
|
const permAuthCache = getAuthCache(PERMISSION_SELECT_KEY)
|
|
const permAuthCache = getAuthCache(PERMISSION_SELECT_KEY)
|
|
@@ -33,23 +39,41 @@ const PermSelect: React.FC<PermSelectProps> = ({ dataType, onConfirm, ...resetPr
|
|
|
if (e === 'custom') {
|
|
if (e === 'custom') {
|
|
|
setModalProps({
|
|
setModalProps({
|
|
|
width: '60vw',
|
|
width: '60vw',
|
|
|
- modalRender: () => <CustomPerm onConfirm={onConfirm} />,
|
|
|
|
|
- onCancel: toggleModal
|
|
|
|
|
|
|
+ modalRender: () => (
|
|
|
|
|
+ <CustomPerm
|
|
|
|
|
+ defaultValues={state.staffIds}
|
|
|
|
|
+ onConfirm={({ staffIds, dataPermission }) => {
|
|
|
|
|
+ setState({ ...state, staffIds, showSetting: true })
|
|
|
|
|
+ onConfirm({ staffIds, dataPermission })
|
|
|
|
|
+ }}
|
|
|
|
|
+ />
|
|
|
|
|
+ ),
|
|
|
|
|
+ onCancel: () => toggleModal()
|
|
|
})
|
|
})
|
|
|
toggleModal()
|
|
toggleModal()
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
onConfirm({ staffIds: null, dataPermission: e })
|
|
onConfirm({ staffIds: null, dataPermission: e })
|
|
|
setAuthCache(PERMISSION_SELECT_KEY, { ...permAuthCache, [dataType]: e })
|
|
setAuthCache(PERMISSION_SELECT_KEY, { ...permAuthCache, [dataType]: e })
|
|
|
|
|
+ // 将setting icon隐藏,非自定义option下不显示
|
|
|
|
|
+ state.showSetting && setState({ ...state, showSetting: false })
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
- <Select
|
|
|
|
|
- {...resetProps}
|
|
|
|
|
- defaultValue={defaultValue}
|
|
|
|
|
- dropdownMatchSelectWidth={false}
|
|
|
|
|
- onChange={handleOnChange}
|
|
|
|
|
- options={options}
|
|
|
|
|
- />
|
|
|
|
|
|
|
+ <>
|
|
|
|
|
+ <Select
|
|
|
|
|
+ {...resetProps}
|
|
|
|
|
+ defaultValue={defaultValue}
|
|
|
|
|
+ dropdownMatchSelectWidth={false}
|
|
|
|
|
+ onChange={handleOnChange}
|
|
|
|
|
+ options={options}
|
|
|
|
|
+ />
|
|
|
|
|
+ {state.showSetting ? (
|
|
|
|
|
+ <Tooltip title="自定义权限">
|
|
|
|
|
+ <SettingOutlined className="ml-3" onClick={() => handleOnChange('custom')} />
|
|
|
|
|
+ </Tooltip>
|
|
|
|
|
+ ) : null}
|
|
|
|
|
+ </>
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
|
|
|