Browse Source

feat: 云版详情关联cld客户

outaozhen 4 years ago
parent
commit
0a0bf8d7c8

+ 8 - 2
src/pages/Customer/Client/components/ConnectClient/index.jsx

@@ -10,7 +10,13 @@ import { formatValues } from '@/components/LazyCascader'
 import AddClient from '../AddClient'
 import CustomModal from '@/components/Modal/src/components/CustomModal'
 
-const ConnectClient = ({ dataId, onSelect, preUrl = 'client', showFooter = true }) => {
+const ConnectClient = ({
+  dataId,
+  onSelect,
+  preUrl = 'client',
+  showFooter = true,
+  otherParams = {}
+}) => {
   const dispatch = useDispatch()
   const scrollRef = useRef()
   const [state, setState] = useState({
@@ -77,7 +83,7 @@ const ConnectClient = ({ dataId, onSelect, preUrl = 'client', showFooter = true
 
   // 商机/软件锁关联客户
   const connectClient = async clientId => {
-    const { code = -1 } = await apiChangeClient(preUrl, { id: dataId, clientId })
+    const { code = -1 } = await apiChangeClient(preUrl, { id: dataId, clientId, ...otherParams })
     if (code === consts.RET_CODE.SUCCESS) {
       onSelect()
       closeModal()

+ 56 - 6
src/pages/Product/Cloud/components/Detail/index.jsx

@@ -2,12 +2,14 @@ import React, { useState, useEffect } from 'react'
 import { Row, Col, Button } from 'antd'
 import { LinkOne, LinkInterrupt } from '@icon-park/react'
 import { connect } from 'umi'
+import { useModal } from '@/components/Modal'
 import consts from '@/consts'
 import Form from './Form'
 import ClientDetail from '@/pages/Customer/Client/components/ClientDetail/Form'
 import LowerList from './LowerList'
 import TabList from './TabList'
-import { apiRoadpricingDetail } from '@/services/product'
+import ConnectClient from '@/pages/Customer/Client/components/ConnectClient'
+import { apiRoadpricingDetail, apiRoadPricingUnLinkClient } from '@/services/product'
 
 const Detail = props => {
   const {
@@ -19,6 +21,13 @@ const Detail = props => {
     projectType,
     filterTag = true
   } = props
+  const { toggleModal, setModalProps } = useModal()
+  const refreshClient = () => {
+    dispatch({
+      type: 'refresh/commitAction',
+      payload: actionPayload
+    })
+  }
   const shouldUpdate = refresh[updateKey] || false
   const [state, setState] = useState({
     loading: false,
@@ -44,6 +53,49 @@ const Detail = props => {
       setState({ ...state, cloudUser, compilationList, log, serviceLog, client, loading: false })
     }
   }
+  const handleConnectClient = () => {
+    setModalProps({
+      zIndex: 1200,
+      width: '60vw',
+      modalRender: () => (
+        <ConnectClient
+          onSelect={refreshClient}
+          dataId={state.cloudUser.ssoId}
+          // preUrl="RoadPricing"
+          showFooter={false}
+          otherParams={{ projectType }}
+        />
+      ),
+      onCancel: () => toggleModal()
+    })
+    toggleModal(true)
+  }
+  // 关联cld客户
+  // const connectPricingLinkClient = async ssoId => {
+  //   const { code = -1 } = await apiRoadPricingLinkClient(preUrl, {
+  //     id: dataId,
+  //     ssoId,
+  //     client_id,
+  //     projectPype
+  //   })
+  //   if (code === consts.RET_CODE.SUCCESS) {
+  //     onSelect()
+  //     closeModal()
+  //   }
+  // }
+  // 移除cld客户
+  // const connectPricingUnLinkClient = async ssoId => {
+  //   const { code = -1 } = await apiRoadPricingUnLinkClient(preUrl, {
+  //     id: dataId,
+  //     ssoId,
+  //     client_id,
+  //     projectPype
+  //   })
+  //   if (code === consts.RET_CODE.SUCCESS) {
+  //     onSelect()
+  //     closeModal()
+  //   }
+  // }
   useEffect(() => {
     shouldUpdate && initData(dataId)
   }, [shouldUpdate])
@@ -58,8 +110,7 @@ const Detail = props => {
           md={{ span: 24 }}
           lg={{ span: 9 }}
           xl={{ span: 9 }}
-          className="sheet-box-left"
-        >
+          className="sheet-box-left">
           <div className="sheet-left-panel pr-4">
             <Form cloudUser={state.cloudUser} updateKey={updateKey} projectType={projectType} />
             {state.cloudUser.cld?.clientId ? (
@@ -76,7 +127,7 @@ const Detail = props => {
               </>
             ) : (
               <div className="text-center mt-6">
-                <Button type="primary" ghost size="small">
+                <Button type="primary" ghost size="small" onClick={handleConnectClient}>
                   <LinkOne size="14" />
                   <span className="ml-5px">关联CLD客户</span>
                 </Button>
@@ -90,8 +141,7 @@ const Detail = props => {
           lg={{ span: 15 }}
           xl={{ span: 15 }}
           flex={{ flexDirection: 'column' }}
-          className="sheet-box-right"
-        >
+          className="sheet-box-right">
           <TabList
             compilationList={state.compilationList}
             cloudUser={state.cloudUser}

+ 4 - 1
src/services/customer.js

@@ -211,12 +211,15 @@ export async function getBusinessDetailById(params) {
   })
 }
 
-/** 商机/锁库关联客户 */
+/** 商机/锁库/云版关联客户 */
 export async function apiChangeClient(preUrl, params) {
   let url = '/business/link/client'
   if (preUrl === 'software') {
     url = '/software/change/client'
   }
+  if (preUrl === 'RoadPricing') {
+    url = '/RoadPricing/link/client'
+  }
   return request.post(url, {
     data: params
   })

+ 7 - 0
src/services/product.js

@@ -87,3 +87,10 @@ export async function apiRoadPricingLinkClient(params) {
     data: params
   })
 }
+
+/** 移除客户 */
+export async function apiRoadPricingUnLinkClient(params) {
+  return request.post('/RoadPricing/unlink/client', {
+    data: params
+  })
+}