|
|
@@ -1,17 +1,32 @@
|
|
|
import React from 'react'
|
|
|
-import { Switch } from '@icon-park/react'
|
|
|
+import { Switch, LinkInterrupt, LinkOne } from '@icon-park/react'
|
|
|
import { useModal } from '@/components/Modal'
|
|
|
import { Card, Tooltip } from 'antd'
|
|
|
import consts from '@/basic/consts'
|
|
|
import { useDispatch } from 'dva'
|
|
|
import StaffModal from '@/pages/Staff/Employee/components/StaffModal'
|
|
|
import styles from './index.less'
|
|
|
+import { apiChangeSupervisor } from '@/services/staff'
|
|
|
+
|
|
|
+export const ChangeCompMap = {
|
|
|
+ STAFF: {
|
|
|
+ key: 'staff',
|
|
|
+ title: '员工'
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
const ChangeSupervisor = props => {
|
|
|
const dispatch = useDispatch()
|
|
|
const { toggleModal, setModalProps } = useModal()
|
|
|
const {
|
|
|
- dataSource: { staffId, clientId, staffName }
|
|
|
+ dataSource: {
|
|
|
+ staffId,
|
|
|
+ clientId,
|
|
|
+ staffName,
|
|
|
+ targetName,
|
|
|
+ actionPayload = ChangeCompMap.STAFF.key,
|
|
|
+ title = '员工'
|
|
|
+ }
|
|
|
} = props
|
|
|
const refreshStaff = () => {
|
|
|
dispatch({
|
|
|
@@ -22,7 +37,35 @@ const ChangeSupervisor = props => {
|
|
|
const handleConnectStaff = () => {
|
|
|
setModalProps({
|
|
|
width: '60vw',
|
|
|
- modalRender: () => <StaffModal onSelect={refreshStaff} id={clientId} />,
|
|
|
+ modalRender: () => (
|
|
|
+ <StaffModal onSelect={refreshStaff} id={clientId} postUrl={actionPayload} />
|
|
|
+ ),
|
|
|
+ onCancel: () => toggleModal()
|
|
|
+ })
|
|
|
+ toggleModal()
|
|
|
+ }
|
|
|
+ const notValueRender = (
|
|
|
+ <div onClick={handleConnectStaff} className={styles.notCompanyContent}>
|
|
|
+ <LinkOne size="14" />
|
|
|
+ <span className="ml-5px">关联客户</span>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+
|
|
|
+ const removeSupervisor = () => {
|
|
|
+ setModalProps({
|
|
|
+ title: '确认移除',
|
|
|
+ children: (
|
|
|
+ <p>
|
|
|
+ 为{title}
|
|
|
+ <span className="mr-3px ml-3px font-600">{targetName}</span>移除
|
|
|
+ <span className="mr-3px ml-3px font-600">{staffName}</span>
|
|
|
+ </p>
|
|
|
+ ),
|
|
|
+ onOk: async () => {
|
|
|
+ await apiChangeSupervisor(actionPayload, { id: clientId, dataId: '0' })
|
|
|
+ refreshStaff()
|
|
|
+ toggleModal()
|
|
|
+ },
|
|
|
onCancel: () => toggleModal()
|
|
|
})
|
|
|
toggleModal()
|
|
|
@@ -31,7 +74,12 @@ const ChangeSupervisor = props => {
|
|
|
<Card size="small">
|
|
|
<div className="flex justify-between">
|
|
|
<div className={styles.nameContent}>{staffName}</div>
|
|
|
- <div className="w-30px">
|
|
|
+ <div className="w-55px">
|
|
|
+ <Tooltip placement="right" title="移除上司">
|
|
|
+ <span className={styles.unlinkIcon} onClick={removeSupervisor}>
|
|
|
+ <LinkInterrupt />
|
|
|
+ </span>
|
|
|
+ </Tooltip>
|
|
|
<Tooltip
|
|
|
placement="right"
|
|
|
title="更换上司"
|
|
|
@@ -47,7 +95,8 @@ const ChangeSupervisor = props => {
|
|
|
)
|
|
|
return (
|
|
|
<div className={styles.companyInput}>
|
|
|
- {staffId === consts.ENCRYPTION_ZERO && normalValueRender}
|
|
|
+ {staffId !== consts.ENCRYPTION_ZERO ? normalValueRender : notValueRender}
|
|
|
+ {/* {staffId === consts.ENCRYPTION_ZERO && normalValueRender} */}
|
|
|
</div>
|
|
|
)
|
|
|
}
|