PermSelect.jsx 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { useModal } from '@/components/Modal'
  2. import { useModel } from 'umi'
  3. import { Select } from 'antd'
  4. import CustomPerm from './CustomPerm'
  5. export const PermDataTypeEunm = {
  6. CUSTOMER: 'customer',
  7. PRODUCT: 'product',
  8. HR: 'hr',
  9. WORKBENCH: 'workbench'
  10. }
  11. const PermSelect = ({ dataType, onConfirm, ...resetProps }) => {
  12. const { initialState: { permData } = { permData: {} } } = useModel('@@initialState')
  13. const { toggleModal, setModalProps } = useModal()
  14. const options = [...(permData[dataType] || [])]
  15. return (
  16. <Select
  17. {...resetProps}
  18. defaultValue="oneself"
  19. dropdownMatchSelectWidth={false}
  20. onChange={e => {
  21. if (e === 'custom') {
  22. setModalProps({
  23. width: '60vw',
  24. modalRender: () => <CustomPerm onConfirm={onConfirm} />,
  25. onCancel: toggleModal
  26. })
  27. toggleModal()
  28. return
  29. }
  30. onConfirm({ staffIds: null, dataPermission: e })
  31. }}
  32. options={options}
  33. />
  34. )
  35. }
  36. export default PermSelect