|
|
@@ -1,7 +1,7 @@
|
|
|
import React, { useState, useEffect, useRef, useMemo } from 'react'
|
|
|
import ProTable from '@ant-design/pro-table'
|
|
|
import { useTableScroll } from '@/hooks/useAutoTable'
|
|
|
-import { Input, Button, message, Select, Tooltip } from 'antd'
|
|
|
+import { Input, Button, message, Tooltip } from 'antd'
|
|
|
import { connect, useModel } from 'umi'
|
|
|
import consts from '@/consts'
|
|
|
import { queryCompany, apiAddCompany } from '@/services/customer'
|
|
|
@@ -16,7 +16,8 @@ import { Add, Down, Check } from '@icon-park/react'
|
|
|
import { apiBatchLink } from '@/services/customer'
|
|
|
import styles from './index.less'
|
|
|
import { refactorSortField } from '@/utils/utils'
|
|
|
-import CustomPerm from './components/CustomPerm'
|
|
|
+import PermSelect from './components/PermSelect'
|
|
|
+import { PermDataTypeEunm } from './components/PermSelect'
|
|
|
|
|
|
const Company = props => {
|
|
|
const {
|
|
|
@@ -31,7 +32,7 @@ const Company = props => {
|
|
|
|
|
|
const { initialState: { permData } = { permData: {} } } = useModel('@@initialState')
|
|
|
|
|
|
- const { toggleDrawer, setDrawerProps, toggleModal, setModalProps } = useModal()
|
|
|
+ const { toggleDrawer, setDrawerProps } = useModal()
|
|
|
const tRef = useRef(null)
|
|
|
const [selectKeys, setSelectKeys] = useState([])
|
|
|
|
|
|
@@ -78,7 +79,7 @@ const Company = props => {
|
|
|
|
|
|
const [state, setState] = useState({
|
|
|
id: '',
|
|
|
- params: { dataPermission: 'oneself' },
|
|
|
+ params: { dataPermission: 'oneself', staffIds: null },
|
|
|
visible: false,
|
|
|
orderIds: []
|
|
|
})
|
|
|
@@ -379,6 +380,15 @@ const Company = props => {
|
|
|
refreshData()
|
|
|
}
|
|
|
|
|
|
+ // 处理权限Select下拉组件OnChange事件
|
|
|
+ const handlePermChange = ({ staffIds = [], dataPermission }) => {
|
|
|
+ if (staffIds?.length) {
|
|
|
+ setState({ ...state, params: { ...state.params, staffIds, dataPermission: null } })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ setState({ ...state, params: { ...state.params, staffIds: null, dataPermission } })
|
|
|
+ }
|
|
|
+
|
|
|
const renderTableAlert = ({ selectedRowKeys }) => {
|
|
|
return (
|
|
|
<div className="flex flex-row">
|
|
|
@@ -466,8 +476,9 @@ const Company = props => {
|
|
|
style={{ width: '300px' }}
|
|
|
allowClear={true}
|
|
|
placeholder={`在${
|
|
|
- permData?.customer?.find(item => item.value === state.params.dataPermission)
|
|
|
- ?.label
|
|
|
+ permData[PermDataTypeEunm.CUSTOMER]?.find(
|
|
|
+ item => item.value === state.params.dataPermission
|
|
|
+ )?.label || '自定义'
|
|
|
}下搜索`}
|
|
|
onSearch={handleSearch}
|
|
|
/>
|
|
|
@@ -486,29 +497,7 @@ const Company = props => {
|
|
|
]
|
|
|
}}
|
|
|
headerTitle={
|
|
|
- <Select
|
|
|
- defaultValue="oneself"
|
|
|
- dropdownMatchSelectWidth={false}
|
|
|
- onChange={e => {
|
|
|
- if (e === 'custom') {
|
|
|
- setModalProps({
|
|
|
- width: '60vw',
|
|
|
- modalRender: () => (
|
|
|
- <CustomPerm
|
|
|
- onConfirm={staffIds =>
|
|
|
- setState({ ...state, params: { ...state.params, staffIds } })
|
|
|
- }
|
|
|
- />
|
|
|
- ),
|
|
|
- onCancel: toggleModal
|
|
|
- })
|
|
|
- toggleModal()
|
|
|
- return
|
|
|
- }
|
|
|
- setState({ ...state, params: { ...state.params, dataPermission: e, staffIds: null } })
|
|
|
- }}
|
|
|
- options={[...(permData?.customer || []), { value: 'custom', label: '自定义' }]}
|
|
|
- />
|
|
|
+ <PermSelect onConfirm={handlePermChange} dataType={PermDataTypeEunm.CUSTOMER} />
|
|
|
}
|
|
|
rowSelection={{
|
|
|
onChange: hanleRowSelectChange,
|