|
@@ -1,44 +1,81 @@
|
|
|
import { useModal } from '@/components/Modal'
|
|
import { useModal } from '@/components/Modal'
|
|
|
import { IconPark } from '@/components/SvgIcon'
|
|
import { IconPark } from '@/components/SvgIcon'
|
|
|
import { Card, Tooltip } from 'antd'
|
|
import { Card, Tooltip } from 'antd'
|
|
|
-import React, { useState } from 'react'
|
|
|
|
|
|
|
+import React from 'react'
|
|
|
import styles from './index.less'
|
|
import styles from './index.less'
|
|
|
import SearchModal from '@/components/Modal/src/components/customerModal'
|
|
import SearchModal from '@/components/Modal/src/components/customerModal'
|
|
|
|
|
+import { apiDelCustomer } from '@/services/contact'
|
|
|
|
|
+import { useDispatch } from 'dva'
|
|
|
|
|
|
|
|
const ChangeCompanyInput = props => {
|
|
const ChangeCompanyInput = props => {
|
|
|
|
|
+ const dispatch = useDispatch()
|
|
|
const { toggleModal, setModalProps } = useModal()
|
|
const { toggleModal, setModalProps } = useModal()
|
|
|
- const { value = '', clientId } = props
|
|
|
|
|
- const [companyName, setCompanyName] = useState(value)
|
|
|
|
|
- const changeCompany = name => {
|
|
|
|
|
- setCompanyName(name)
|
|
|
|
|
|
|
+ const {
|
|
|
|
|
+ dataSource: { customerId, clientId, customerName, clientName }
|
|
|
|
|
+ } = props
|
|
|
|
|
+ // const [companyName, setCompanyName] = useState('')
|
|
|
|
|
+ // useEffect(() => {
|
|
|
|
|
+ // setCompanyName(customerName)
|
|
|
|
|
+ // }, [customerName])
|
|
|
|
|
+ // const changeCompany = name => {
|
|
|
|
|
+ // setCompanyName(name)
|
|
|
|
|
+ // }
|
|
|
|
|
+ const refreshClient = () => {
|
|
|
|
|
+ dispatch({
|
|
|
|
|
+ type: 'refresh/commitAction',
|
|
|
|
|
+ payload: 'contact'
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
- const handleConnectContract = () => {
|
|
|
|
|
|
|
+ const handleConnectCustomer = () => {
|
|
|
setModalProps({
|
|
setModalProps({
|
|
|
width: '60vw',
|
|
width: '60vw',
|
|
|
- modalRender: node => <SearchModal node={node} onSelect={changeCompany} clientId={clientId} />,
|
|
|
|
|
|
|
+ modalRender: node => <SearchModal onSelect={refreshClient} node={node} clientId={clientId} />,
|
|
|
onCancel: () => toggleModal()
|
|
onCancel: () => toggleModal()
|
|
|
})
|
|
})
|
|
|
toggleModal()
|
|
toggleModal()
|
|
|
}
|
|
}
|
|
|
const notValueRender = (
|
|
const notValueRender = (
|
|
|
- <div onClick={handleConnectContract} className={styles.notCompanyContent}>
|
|
|
|
|
|
|
+ <div onClick={handleConnectCustomer} className={styles.notCompanyContent}>
|
|
|
{/* style={{ transform: 'rotate(-90deg)' }} */}
|
|
{/* style={{ transform: 'rotate(-90deg)' }} */}
|
|
|
<IconPark type="link-one" size="14" />
|
|
<IconPark type="link-one" size="14" />
|
|
|
<span className="zh-mg-left-5">关联客户</span>
|
|
<span className="zh-mg-left-5">关联客户</span>
|
|
|
</div>
|
|
</div>
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+ const removeCustomer = () => {
|
|
|
|
|
+ setModalProps({
|
|
|
|
|
+ title: '确认移除',
|
|
|
|
|
+ children: (
|
|
|
|
|
+ <p>
|
|
|
|
|
+ 为联系人<span className="zh-mg-lr-3 zh-fw-600">{clientName}</span>移除
|
|
|
|
|
+ <span className="zh-mg-lr-3 zh-fw-600">{customerName}</span>
|
|
|
|
|
+ </p>
|
|
|
|
|
+ ),
|
|
|
|
|
+ onOk: async () => {
|
|
|
|
|
+ await apiDelCustomer({ id: clientId, customerId })
|
|
|
|
|
+ refreshClient()
|
|
|
|
|
+ toggleModal()
|
|
|
|
|
+ },
|
|
|
|
|
+ onCancel: () => toggleModal()
|
|
|
|
|
+ })
|
|
|
|
|
+ toggleModal()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const normalValueRender = (
|
|
const normalValueRender = (
|
|
|
<Card size="small">
|
|
<Card size="small">
|
|
|
<div className="zh-flex-row zh-justify-between">
|
|
<div className="zh-flex-row zh-justify-between">
|
|
|
- <div className={styles.nameContent}>{companyName}</div>
|
|
|
|
|
|
|
+ <div className={styles.nameContent}>{customerName}</div>
|
|
|
<div>
|
|
<div>
|
|
|
<Tooltip placement="left" title="移除客户">
|
|
<Tooltip placement="left" title="移除客户">
|
|
|
- <span className={styles.unlinkIcon}>
|
|
|
|
|
|
|
+ <span className={styles.unlinkIcon} onClick={removeCustomer}>
|
|
|
<IconPark type="link-interrupt" />
|
|
<IconPark type="link-interrupt" />
|
|
|
</span>
|
|
</span>
|
|
|
</Tooltip>
|
|
</Tooltip>
|
|
|
- <Tooltip placement="left" title="移除客户" className="zh-mg-left-5">
|
|
|
|
|
|
|
+ <Tooltip
|
|
|
|
|
+ placement="left"
|
|
|
|
|
+ title="更换客户"
|
|
|
|
|
+ className="zh-mg-left-5"
|
|
|
|
|
+ onClick={handleConnectCustomer}>
|
|
|
<span className={styles.switchIcon}>
|
|
<span className={styles.switchIcon}>
|
|
|
<IconPark type="switch" />
|
|
<IconPark type="switch" />
|
|
|
</span>
|
|
</span>
|
|
@@ -48,7 +85,7 @@ const ChangeCompanyInput = props => {
|
|
|
</Card>
|
|
</Card>
|
|
|
)
|
|
)
|
|
|
return (
|
|
return (
|
|
|
- <div className={styles.companyInput}>{companyName ? normalValueRender : notValueRender}</div>
|
|
|
|
|
|
|
+ <div className={styles.companyInput}>{customerId ? normalValueRender : notValueRender}</div>
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
|
|
|