|
@@ -1,6 +1,4 @@
|
|
|
import React, { useState, useEffect, useRef, useMemo } from 'react'
|
|
import React, { useState, useEffect, useRef, useMemo } from 'react'
|
|
|
-import ProTable from '@ant-design/pro-table'
|
|
|
|
|
-import { useTableScroll } from '@/hooks/useAutoTable'
|
|
|
|
|
import { Input, Button, message, Tooltip } from 'antd'
|
|
import { Input, Button, message, Tooltip } from 'antd'
|
|
|
import { connect, useModel } from 'umi'
|
|
import { connect, useModel } from 'umi'
|
|
|
import consts from '@/consts'
|
|
import consts from '@/consts'
|
|
@@ -16,8 +14,8 @@ import { Add, Down, Check } from '@icon-park/react'
|
|
|
import { apiBatchLink } from '@/services/customer'
|
|
import { apiBatchLink } from '@/services/customer'
|
|
|
import styles from './index.less'
|
|
import styles from './index.less'
|
|
|
import { refactorSortField } from '@/utils/utils'
|
|
import { refactorSortField } from '@/utils/utils'
|
|
|
-import PermSelect from './components/PermSelect'
|
|
|
|
|
import { PermDataTypeEunm } from './components/PermSelect'
|
|
import { PermDataTypeEunm } from './components/PermSelect'
|
|
|
|
|
+import BasicTable from '@/components/Table'
|
|
|
|
|
|
|
|
const Company = props => {
|
|
const Company = props => {
|
|
|
const {
|
|
const {
|
|
@@ -35,12 +33,12 @@ const Company = props => {
|
|
|
|
|
|
|
|
const { toggleDrawer, setDrawerProps } = useModal()
|
|
const { toggleDrawer, setDrawerProps } = useModal()
|
|
|
const tRef = useRef(null)
|
|
const tRef = useRef(null)
|
|
|
- const [selectKeys, setSelectKeys] = useState([])
|
|
|
|
|
|
|
|
|
|
const [tagState, setTagState] = useState({
|
|
const [tagState, setTagState] = useState({
|
|
|
tagIds: [],
|
|
tagIds: [],
|
|
|
tagCooperationIds: []
|
|
tagCooperationIds: []
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
const tag = useMemo(() => {
|
|
const tag = useMemo(() => {
|
|
|
const personTagMap = {}
|
|
const personTagMap = {}
|
|
|
const teamTagMap = {}
|
|
const teamTagMap = {}
|
|
@@ -89,9 +87,7 @@ const Company = props => {
|
|
|
}, [loading])
|
|
}, [loading])
|
|
|
|
|
|
|
|
const [state, setState] = useState({
|
|
const [state, setState] = useState({
|
|
|
- id: '',
|
|
|
|
|
- params: { dataPermission: 'oneself', staffIds: null },
|
|
|
|
|
- visible: false,
|
|
|
|
|
|
|
+ params: {},
|
|
|
orderIds: []
|
|
orderIds: []
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -323,7 +319,7 @@ const Company = props => {
|
|
|
width: 80
|
|
width: 80
|
|
|
}
|
|
}
|
|
|
]
|
|
]
|
|
|
- const [columnsStateMap, setColumnsStateMap] = useState({
|
|
|
|
|
|
|
+ const columnsStateMap = {
|
|
|
address: {
|
|
address: {
|
|
|
show: false
|
|
show: false
|
|
|
},
|
|
},
|
|
@@ -351,46 +347,38 @@ const Company = props => {
|
|
|
staffName: {
|
|
staffName: {
|
|
|
show: false
|
|
show: false
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- const hanleRowSelectChange = selectedRowKeys => {
|
|
|
|
|
- setSelectKeys(selectedRowKeys)
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const toolbarOptionsChange = (type, ids) => {
|
|
const toolbarOptionsChange = (type, ids) => {
|
|
|
setTagState({ ...tagState, [type]: ids })
|
|
setTagState({ ...tagState, [type]: ids })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const { getScrollRef, redoHeight } = useTableScroll(columns, selectKeys)
|
|
|
|
|
-
|
|
|
|
|
// 批量设置-确认触发
|
|
// 批量设置-确认触发
|
|
|
const tagsSettingConfirm = async clientIds => {
|
|
const tagsSettingConfirm = async clientIds => {
|
|
|
|
|
+ let requestSuccess = true
|
|
|
if (tagState.tagIds.length) {
|
|
if (tagState.tagIds.length) {
|
|
|
- await apiBatchLink({
|
|
|
|
|
|
|
+ const { code = -1 } = await apiBatchLink({
|
|
|
tagIds: tagState.tagIds,
|
|
tagIds: tagState.tagIds,
|
|
|
dataIds: clientIds,
|
|
dataIds: clientIds,
|
|
|
dataType: TagDataTypeEnum.COMPANY,
|
|
dataType: TagDataTypeEnum.COMPANY,
|
|
|
tagType: TagTypeEnum.PERSONTAG
|
|
tagType: TagTypeEnum.PERSONTAG
|
|
|
})
|
|
})
|
|
|
|
|
+ if (code !== consts.RET_CODE.SUCCESS) {
|
|
|
|
|
+ requestSuccess = false
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
if (tagState.tagCooperationIds.length) {
|
|
if (tagState.tagCooperationIds.length) {
|
|
|
- await apiBatchLink({
|
|
|
|
|
|
|
+ const { code = -1 } = await apiBatchLink({
|
|
|
tagIds: tagState.tagCooperationIds,
|
|
tagIds: tagState.tagCooperationIds,
|
|
|
dataIds: clientIds,
|
|
dataIds: clientIds,
|
|
|
dataType: TagDataTypeEnum.COMPANY,
|
|
dataType: TagDataTypeEnum.COMPANY,
|
|
|
tagType: TagTypeEnum.TEAMTAG
|
|
tagType: TagTypeEnum.TEAMTAG
|
|
|
})
|
|
})
|
|
|
|
|
+ if (code !== consts.RET_CODE.SUCCESS) {
|
|
|
|
|
+ requestSuccess = false
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- 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 } })
|
|
|
|
|
|
|
+ requestSuccess && refreshData()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const renderTableAlert = ({ selectedRowKeys }) => {
|
|
const renderTableAlert = ({ selectedRowKeys }) => {
|
|
@@ -456,9 +444,11 @@ const Company = props => {
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<div className={styles.companyContent}>
|
|
<div className={styles.companyContent}>
|
|
|
- <ProTable
|
|
|
|
|
|
|
+ <BasicTable
|
|
|
rowKey={record => record.id}
|
|
rowKey={record => record.id}
|
|
|
actionRef={tRef}
|
|
actionRef={tRef}
|
|
|
|
|
+ mainMenuType="customer"
|
|
|
|
|
+ columnStateType="COMPANY"
|
|
|
params={state.params}
|
|
params={state.params}
|
|
|
request={async (params, sort, filter) => {
|
|
request={async (params, sort, filter) => {
|
|
|
const srotOrder = refactorSortField(sort)
|
|
const srotOrder = refactorSortField(sort)
|
|
@@ -471,7 +461,6 @@ const Company = props => {
|
|
|
total
|
|
total
|
|
|
}
|
|
}
|
|
|
}}
|
|
}}
|
|
|
- bordered
|
|
|
|
|
search={{ filterType: 'light' }}
|
|
search={{ filterType: 'light' }}
|
|
|
toolbar={{
|
|
toolbar={{
|
|
|
search: (
|
|
search: (
|
|
@@ -504,21 +493,12 @@ const Company = props => {
|
|
|
/>
|
|
/>
|
|
|
]
|
|
]
|
|
|
}}
|
|
}}
|
|
|
- headerTitle={
|
|
|
|
|
- <PermSelect onConfirm={handlePermChange} dataType={PermDataTypeEunm.CUSTOMER} />
|
|
|
|
|
- }
|
|
|
|
|
rowSelection={{
|
|
rowSelection={{
|
|
|
- onChange: hanleRowSelectChange,
|
|
|
|
|
type: 'checkbox',
|
|
type: 'checkbox',
|
|
|
columnWidth: 25
|
|
columnWidth: 25
|
|
|
}}
|
|
}}
|
|
|
- onLoadingChange={loadingStatus => {
|
|
|
|
|
- loadingStatus && redoHeight()
|
|
|
|
|
- }}
|
|
|
|
|
tableAlertRender={renderTableAlert}
|
|
tableAlertRender={renderTableAlert}
|
|
|
- scroll={getScrollRef}
|
|
|
|
|
columnsStateMap={columnsStateMap}
|
|
columnsStateMap={columnsStateMap}
|
|
|
- onColumnsStateChange={map => setColumnsStateMap(map)}
|
|
|
|
|
columns={columns}
|
|
columns={columns}
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|