index.jsx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import React from 'react'
  2. import { LinkOne, Switch } from '@icon-park/react'
  3. import { Card, Tooltip } from 'antd'
  4. import { useDispatch } from 'dva'
  5. import consts from '@/consts'
  6. import styles from './index.less'
  7. import { useModal } from '@/components/ModalStore'
  8. const ChangeStaff = props => {
  9. const dispatch = useDispatch()
  10. const dispatchModal = useModal()
  11. const { text = '', dataId, responsibleId, actionPayload = 'business' } = props?.dataSource || {}
  12. const refreshClient = () => {
  13. dispatch({
  14. type: 'refresh/commitAction',
  15. payload: actionPayload
  16. })
  17. }
  18. const handleConnectCustomer = () => {
  19. dispatchModal('M_CONNECT_STAFF', {
  20. onSelect: refreshClient,
  21. id: dataId,
  22. postUrl: '/business/change/responsible'
  23. })
  24. }
  25. const notValueRender = (
  26. <div onClick={handleConnectCustomer} className={styles.notBusinessContent}>
  27. <LinkOne size="14" />
  28. <span className="ml-5px">关联负责人</span>
  29. </div>
  30. )
  31. const handleCompanyClick = () => {
  32. dispatchModal('D_EMPLOYEE_DETAIL', { dataId })
  33. }
  34. const normalValueRender = (
  35. <Card size="small">
  36. <div className="flex justify-between">
  37. <div className={styles.nameContent} onClick={handleCompanyClick}>
  38. {text}
  39. </div>
  40. <div className="max-w-55px">
  41. <Tooltip placement="right" title="更换负责人" className="ml-5px" onClick={handleConnectCustomer}>
  42. <span className={styles.switchIcon}>
  43. <Switch />
  44. </span>
  45. </Tooltip>
  46. </div>
  47. </div>
  48. </Card>
  49. )
  50. return (
  51. <div className={styles.businessInput}>
  52. {responsibleId && responsibleId !== consts.ENCRYPTION_ZERO ? normalValueRender : notValueRender}
  53. </div>
  54. )
  55. }
  56. export default ChangeStaff