Преглед изворни кода

feat: 大司空2.0关联和移除cld单位

outaozhen пре 4 година
родитељ
комит
7a3d720150

+ 2 - 1
src/models/refresh.js

@@ -10,7 +10,8 @@ export default {
     staff: false, // 部门与员工
     business: false, // 商机
     cloud: false,
-    personal: false
+    personal: false,
+    enterprise: false
   },
   effects: {
     *commitAction({ payload }, { put }) {

+ 6 - 9
src/pages/Customer/Company/components/ConnectCompany/index.jsx

@@ -15,7 +15,7 @@ const ConnectCompany = ({
   onCancel,
   dataId,
   onSelect,
-  preUrl,
+  preUrl = 'Client',
   defaultAddibleValue,
   ...resetModalProps
 }) => {
@@ -81,6 +81,7 @@ const ConnectCompany = ({
   // 客户/商机关联单位
   const connectCustomer = async customerId => {
     const { code = -1 } = await apiChangeCustomer(preUrl, { id: dataId, customerId })
+    console.log(preUrl)
     if (code === consts.RET_CODE.SUCCESS) {
       onSelect()
       onCancel()
@@ -128,19 +129,16 @@ const ConnectCompany = ({
                 dataType: preUrl,
                 defaultValue: defaultAddibleValue
               })
-            }
-          >
+            }>
             添加单位
           </Button>
         )
-      }
-    >
+      }>
       <div
         className={styles.modalContent}
         ref={scrollRef}
         onScroll={handleListScroll}
-        style={{ paddingBottom: 0 }}
-      >
+        style={{ paddingBottom: 0 }}>
         <Spin spinning={state.laoding}>
           {state.customer.map(item => (
             <div key={item.id} className={styles.card}>
@@ -151,8 +149,7 @@ const ConnectCompany = ({
                   title="确认关联ta"
                   onConfirm={() => connectCustomer(item.id)}
                   okText="确认"
-                  cancelText="取消"
-                >
+                  cancelText="取消">
                   <Button type="primary" size="small">
                     关联
                   </Button>

+ 3 - 4
src/pages/Product/Cloud/components/Detail/index.jsx

@@ -7,7 +7,7 @@ import Form from './Form'
 import ClientDetail from '@/pages/Customer/Client/components/ClientDetail/Form'
 import LowerList from './LowerList'
 import TabList from './TabList'
-import { apiRoadpricingDetail, apiRoadPricingUnLinkClient } from '@/services/product'
+import { apiRoadpricingDetail, apiRoadPricingUnLinkCustomer } from '@/services/product'
 import { useModal } from '@/components/ModalStore'
 import CardClientDetail from '../CardDetail'
 
@@ -67,7 +67,7 @@ const CloudDetail = props => {
     Modal.confirm({
       title: '确认移除',
       onOk: async () => {
-        const { code = -1 } = await apiRoadPricingUnLinkClient({
+        const { code = -1 } = await apiRoadPricingUnLinkCustomer({
           id: dataId,
           clientId,
           projectType
@@ -116,8 +116,7 @@ const CloudDetail = props => {
                           type="primary"
                           ghost
                           size="small"
-                          onClick={() => pricingUnLinkClient(state.cloudUser.cld?.clientId)}
-                        >
+                          onClick={() => pricingUnLinkClient(state.cloudUser.cld?.clientId)}>
                           <LinkInterrupt size="14" />
                           <span className="ml-5px">移除CLD客户</span>
                         </Button>

+ 36 - 0
src/pages/Product/Road/Enterprise/components/ComapnyDetail/index.jsx

@@ -0,0 +1,36 @@
+import { Card } from 'antd'
+import React, { useState } from 'react'
+import { useModal } from '@/components/ModalStore'
+import styles from '@/pages/Product/Cloud/components/CardDetail/index.less'
+
+const CardComapnyDetail = props => {
+  const { company } = props
+  const dispatchModal = useModal()
+  const [state, setState] = useState({
+    orderIds: []
+  })
+  return (
+    <div className="pt-3 border-t-1px border-hex-f3f3f3">
+      <Card title="CLD单位信息" size="small" type="inner" className={styles.cardBoxBg}>
+        <div className="py-3">
+          单位全称:
+          <span
+            onClick={() =>
+              dispatchModal('D_COMPANY_DETAIL', {
+                dataId: company.id,
+                orderIds: state.orderIds
+              })
+            }
+            className="text-primary cursor-pointer hover:text-[#967bbd]">
+            {company.companyName}
+          </span>
+        </div>
+        <div className="py-3">单位地区:{company.districtName}</div>
+        <div className="py-3">单位电话:{company.phone}</div>
+        <div className="py-3">单位性质:{company.tagCooperationName}</div>
+      </Card>
+    </div>
+  )
+}
+
+export default CardComapnyDetail

+ 1 - 0
src/pages/Product/Road/Enterprise/components/Detail/LowerList.jsx

@@ -1,5 +1,6 @@
 import { List, Tabs } from 'antd'
 import React from 'react'
+import { dayjsFormat } from '@/utils/utils'
 
 const EnterpriseLowerList = props => {
   const {

+ 75 - 4
src/pages/Product/Road/Enterprise/components/Detail/index.jsx

@@ -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">

+ 18 - 2
src/services/customer.js

@@ -134,8 +134,21 @@ export async function apiAddBusiService(payload) {
  * @param {*} payload
  * @returns
  */
-export async function apiChangeCustomer(preUrl, payload) {
-  return request(`/${preUrl}/change/customer`, { method: 'POST', data: { ...payload } })
+// export async function apiChangeCustomer(preUrl, payload) {
+//   return request(`/${preUrl}/change/customer`, { method: 'POST', data: { ...payload } })
+// }
+export async function apiChangeCustomer(preUrl, params) {
+  let url = '/business/change/customer'
+  if (preUrl === 'client') {
+    url = '/client/change/customer'
+  }
+  if (preUrl === 'RoadEnterprise') {
+    url = '/RoadPricingv2/company/link/customer'
+  }
+  return request(url, {
+    method: 'POST',
+    data: params
+  })
 }
 
 /**
@@ -234,6 +247,9 @@ export async function apiChangeClient(preUrl, params) {
   if (preUrl === 'RoadPersonal') {
     url = '/RoadPricingv2/link/client'
   }
+  if (preUrl === 'RoadEnterprise') {
+    url = '/RoadPricingv2/company/link/customer'
+  }
   return request(url, {
     method: 'POST',
     data: params

+ 14 - 0
src/services/product.js

@@ -172,3 +172,17 @@ export async function apiRoadcompanyDetail(params) {
 export async function apiRoadAddCompany(payload) {
   return request('/RoadPricingv2/company/add', { method: 'POST', data: { ...payload } })
 }
+/** 大司空2.0企业版关联单位 */
+export async function apiRoadPricingLinkCustomer(params) {
+  return request('/RoadPricingv2/link/customer', {
+    method: 'POST',
+    data: params
+  })
+}
+/** 大司空2.0企业版移除单位 */
+export async function apiRoadPricingUnLinkCustomer(params) {
+  return request('/RoadPricingv2/company/unlink/customer', {
+    method: 'POST',
+    data: params
+  })
+}