|
|
@@ -1,11 +1,14 @@
|
|
|
-import { apiRoadcompanyDetail } from '@/services/product'
|
|
|
-import { Col, Drawer, Row, Spin } from 'antd'
|
|
|
+import { apiRoadcompanyDetail, apiRoadPricingUnLinkCustomer } from '@/services/product'
|
|
|
+import { Button, Col, Drawer, Row, Spin, Tooltip, Modal } from 'antd'
|
|
|
import React, { useState, useEffect } from 'react'
|
|
|
import { connect } from 'umi'
|
|
|
import consts from '@/consts'
|
|
|
import EnterpriseForm from './Form'
|
|
|
import EnterpriseLowerList from './LowerList'
|
|
|
import EnterpriseTabList from './TabList'
|
|
|
+import CardComapnyDetail from '@/pages/Product/Road/Enterprise/components/ComapnyDetail'
|
|
|
+import { LinkInterrupt, LinkOne } from '@icon-park/react'
|
|
|
+import { useModal } from '@/components/ModalStore'
|
|
|
|
|
|
const EnterpriseDetail = props => {
|
|
|
const {
|
|
|
@@ -19,24 +22,36 @@ const EnterpriseDetail = props => {
|
|
|
const [state, setState] = useState({
|
|
|
loading: false,
|
|
|
company: {},
|
|
|
+ customer: {},
|
|
|
compilationList: [],
|
|
|
authUsers: {},
|
|
|
client: [],
|
|
|
serviceLog: [],
|
|
|
log: {}
|
|
|
})
|
|
|
+ const dispatchModal = useModal()
|
|
|
const shouldUpdate = refresh?.[updateKey] || false
|
|
|
- const refreshClient = () => {
|
|
|
+ const refreshDetail = () => {
|
|
|
dispatch({
|
|
|
type: 'refresh/commitAction',
|
|
|
- payload: updateKey
|
|
|
+ payload: {
|
|
|
+ main: updateKey,
|
|
|
+ target: dataId
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
+ // const refreshClient = () => {
|
|
|
+ // dispatch({
|
|
|
+ // type: 'refresh/commitAction',
|
|
|
+ // payload: updateKey
|
|
|
+ // })
|
|
|
+ // }
|
|
|
const initData = async id => {
|
|
|
setState({ ...state, loading: true })
|
|
|
const {
|
|
|
data: {
|
|
|
company = {},
|
|
|
+ customer = {},
|
|
|
compilationList = [],
|
|
|
authUsers = {},
|
|
|
client = [],
|
|
|
@@ -55,6 +70,7 @@ const EnterpriseDetail = props => {
|
|
|
setState({
|
|
|
...state,
|
|
|
company,
|
|
|
+ customer,
|
|
|
compilationList,
|
|
|
authUsers,
|
|
|
client,
|
|
|
@@ -64,6 +80,35 @@ const EnterpriseDetail = props => {
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
+ // 关联CLD单位信息
|
|
|
+ const handleConnectCompany = () => {
|
|
|
+ dispatchModal('M_CONNECT_COMPANY', {
|
|
|
+ onSelect: refreshDetail,
|
|
|
+ dataId: state.company.companyId,
|
|
|
+ preUrl: 'RoadEnterprise',
|
|
|
+ showFooter: false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // 移除CLD单位信息
|
|
|
+ const pricingUnLinkCompany = id => {
|
|
|
+ Modal.confirm({
|
|
|
+ title: '确认移除',
|
|
|
+ onOk: async () => {
|
|
|
+ const { code = -1 } = await apiRoadPricingUnLinkCustomer({
|
|
|
+ id
|
|
|
+ })
|
|
|
+ if (code === consts.RET_CODE.SUCCESS) {
|
|
|
+ dispatch({
|
|
|
+ type: 'refresh/commitAction',
|
|
|
+ payload: {
|
|
|
+ main: updateKey,
|
|
|
+ target: dataId
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
useEffect(() => {
|
|
|
shouldUpdate && initData(dataId)
|
|
|
}, [shouldUpdate])
|
|
|
@@ -78,6 +123,32 @@ const EnterpriseDetail = props => {
|
|
|
<Col span={9} className="sheet-box-left">
|
|
|
<div className="sheet-left-panel pr-4">
|
|
|
<EnterpriseForm company={state.company} updateKey={updateKey} />
|
|
|
+ {state.company.cld?.customerId ? (
|
|
|
+ <>
|
|
|
+ <div className="mt-4">
|
|
|
+ <CardComapnyDetail company={state.customer} />
|
|
|
+ </div>
|
|
|
+ <div className="text-center mt-6">
|
|
|
+ <Tooltip placement="right" title="移除CLD客户">
|
|
|
+ <Button
|
|
|
+ type="primary"
|
|
|
+ ghost
|
|
|
+ size="small"
|
|
|
+ onClick={() => pricingUnLinkCompany(state.company.cld?.customerId)}>
|
|
|
+ <LinkInterrupt size="14" />
|
|
|
+ <span className="ml-5px">移除CLD单位信息</span>
|
|
|
+ </Button>
|
|
|
+ </Tooltip>
|
|
|
+ </div>
|
|
|
+ </>
|
|
|
+ ) : (
|
|
|
+ <div className="text-center mt-6">
|
|
|
+ <Button type="primary" ghost size="small" onClick={handleConnectCompany}>
|
|
|
+ <LinkOne size="14" />
|
|
|
+ <span className="ml-5px">关联CLD单位信息</span>
|
|
|
+ </Button>
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
</div>
|
|
|
</Col>
|
|
|
<Col span={15} className="sheet-box-right">
|