|
@@ -5,9 +5,10 @@ import { useDispatch } from 'dva'
|
|
|
import { useDebounceFn } from 'ahooks'
|
|
import { useDebounceFn } from 'ahooks'
|
|
|
import { SearchOutlined, CloseOutlined } from '@ant-design/icons'
|
|
import { SearchOutlined, CloseOutlined } from '@ant-design/icons'
|
|
|
import { queryStaff } from '@/services/staff'
|
|
import { queryStaff } from '@/services/staff'
|
|
|
|
|
+import { apiChangeSupervisor } from '@/services/staff'
|
|
|
import styles from './index.less'
|
|
import styles from './index.less'
|
|
|
|
|
|
|
|
-const StaffModal = () => {
|
|
|
|
|
|
|
+const StaffModal = ({ clientId, onSelect }) => {
|
|
|
const scrollRef = useRef()
|
|
const scrollRef = useRef()
|
|
|
const dispatch = useDispatch()
|
|
const dispatch = useDispatch()
|
|
|
const [state, setState] = useState({
|
|
const [state, setState] = useState({
|
|
@@ -21,15 +22,17 @@ const StaffModal = () => {
|
|
|
const { data: { list, total } = { list: [], total: 0 }, code = -1 } = await queryStaff(params)
|
|
const { data: { list, total } = { list: [], total: 0 }, code = -1 } = await queryStaff(params)
|
|
|
if (code === consts.RET_CODE.SUCCESS) {
|
|
if (code === consts.RET_CODE.SUCCESS) {
|
|
|
if (params?.page === 1) {
|
|
if (params?.page === 1) {
|
|
|
|
|
+ scrollRef.current?.scrollTo({ top: 0 })
|
|
|
// 请求的是第一页
|
|
// 请求的是第一页
|
|
|
- setState({ ...state, list, total, loading: false })
|
|
|
|
|
|
|
+ setState({ ...state, list, total, loading: false, searchVal: params?.search })
|
|
|
} else {
|
|
} else {
|
|
|
setState({
|
|
setState({
|
|
|
...state,
|
|
...state,
|
|
|
list: state.list.concat(list),
|
|
list: state.list.concat(list),
|
|
|
total,
|
|
total,
|
|
|
|
|
+ searchVal: params?.search,
|
|
|
loading: false,
|
|
loading: false,
|
|
|
- pageSize: params?.pageSize || 1
|
|
|
|
|
|
|
+ current: params?.current || 1
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -40,7 +43,7 @@ const StaffModal = () => {
|
|
|
}, [])
|
|
}, [])
|
|
|
const onChange = e => {
|
|
const onChange = e => {
|
|
|
const { value = '' } = e.target || e.currentTarget
|
|
const { value = '' } = e.target || e.currentTarget
|
|
|
- initData({ search: value, current: state.current, pageSize: state.pageSize })
|
|
|
|
|
|
|
+ initData({ search: value, current: 1, pageSize: state.pageSize })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const { run: handleInputChange } = useDebounceFn(onChange)
|
|
const { run: handleInputChange } = useDebounceFn(onChange)
|
|
@@ -51,6 +54,15 @@ const StaffModal = () => {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 关联上司
|
|
|
|
|
+ const connectStaff = async supervisorId => {
|
|
|
|
|
+ const { code = -1 } = await apiChangeSupervisor({ id: clientId, supervisorId })
|
|
|
|
|
+ if (code === consts.RET_CODE.SUCCESS) {
|
|
|
|
|
+ onSelect()
|
|
|
|
|
+ closeModal()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const handleListScroll = () => {
|
|
const handleListScroll = () => {
|
|
|
// 未滚动到底部
|
|
// 未滚动到底部
|
|
|
if (
|
|
if (
|
|
@@ -58,7 +70,8 @@ const StaffModal = () => {
|
|
|
scrollRef.current.scrollTop
|
|
scrollRef.current.scrollTop
|
|
|
) {
|
|
) {
|
|
|
// 已到底部
|
|
// 已到底部
|
|
|
- initData({ current: state.current + 1, pageSize: state.pageSize })
|
|
|
|
|
|
|
+ state.current * state.pageSize < state.total &&
|
|
|
|
|
+ initData({ current: state.current + 1, pageSize: state.pageSize, search: state.searchVal })
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return (
|
|
return (
|
|
@@ -83,7 +96,7 @@ const StaffModal = () => {
|
|
|
<span className="w-1/6">{item.position}</span>
|
|
<span className="w-1/6">{item.position}</span>
|
|
|
<span className="w-1/2 zh-justify-between">
|
|
<span className="w-1/2 zh-justify-between">
|
|
|
<span>{item.emergencyContacts}</span>
|
|
<span>{item.emergencyContacts}</span>
|
|
|
- <Button type="primary" size="small">
|
|
|
|
|
|
|
+ <Button type="primary" size="small" onClick={() => connectStaff(item.id)}>
|
|
|
关联
|
|
关联
|
|
|
</Button>
|
|
</Button>
|
|
|
</span>
|
|
</span>
|