Jelajahi Sumber

feat: 云版管理移除cld客户

outaozhen 4 tahun lalu
induk
melakukan
8f47696e50
1 mengubah file dengan 21 tambahan dan 11 penghapusan
  1. 21 11
      src/pages/Product/Cloud/components/Detail/index.jsx

+ 21 - 11
src/pages/Product/Cloud/components/Detail/index.jsx

@@ -1,5 +1,5 @@
 import React, { useState, useEffect } from 'react'
-import { Row, Col, Button, Tooltip, Modal } from 'antd'
+import { Row, Col, Button, Tooltip, Modal, message } from 'antd'
 import { LinkOne, LinkInterrupt } from '@icon-park/react'
 import { connect } from 'umi'
 import { useModal } from '@/components/Modal'
@@ -17,19 +17,20 @@ const Detail = props => {
     updateKey = 'cloud',
     refresh,
     visible,
-    actionPayload,
     dataId = '',
     projectType,
     filterTag = true
   } = props
   const { toggleModal, setModalProps } = useModal()
+  const shouldUpdate = refresh[updateKey] || false
   const refreshClient = () => {
-    dispatch({
-      type: 'refresh/commitAction',
-      payload: actionPayload
-    })
+    if (shouldUpdate) {
+      dispatch({
+        type: 'refresh/commitAction',
+        payload: updateKey
+      })
+    }
   }
-  const shouldUpdate = refresh[updateKey] || false
   const [state, setState] = useState({
     loading: false,
     cloudUser: {},
@@ -77,12 +78,15 @@ const Detail = props => {
       zIndex: 1002,
       title: '确认移除',
       onOk: async () => {
-        await apiRoadPricingUnLinkClient(actionPayload, {
+        const { code = -1 } = await apiRoadPricingUnLinkClient({
           id: dataId,
           clientId,
-          projectPype: projectType
+          projectType
         })
-        refreshClient()
+        if (code === consts.RET_CODE.SUCCESS) {
+          message.success('移除成功')
+          refreshClient()
+        }
       }
     })
   }
@@ -111,7 +115,13 @@ const Detail = props => {
                 </div>
                 <div className="text-center mt-6">
                   <Tooltip placement="right" title="移除CLD客户">
-                    <Button type="primary" ghost size="small" onClick={pricingUnLinkClient}>
+                    <Button
+                      type="primary"
+                      ghost
+                      size="small"
+                      onClick={() => {
+                        pricingUnLinkClient(state.cloudUser.cld?.clientId)
+                      }}>
                       <LinkInterrupt size="14" />
                       <span className="ml-5px">移除CLD客户</span>
                     </Button>