Explorar o código

fix: 修复refresh导致的栈溢出

lanjianrong %!s(int64=5) %!d(string=hai) anos
pai
achega
eb7b211d60

+ 10 - 11
src/pages/Customer/Business/index.jsx

@@ -20,19 +20,12 @@ const Business = ({ dispatch, groupList, shouldUpdate, loading }) => {
     funnelData: []
   })
   useEffect(() => {
-    if (!groupList.length) {
+    if (!groupList) {
       dispatch({
         type: 'business/fetchGroup'
       })
     }
-    if (shouldUpdate) {
-      tRef.current.reload()
-      dispatch({
-        type: 'refresh/commitAction',
-        payload: 'business '
-      })
-    }
-    if (groupList.length) {
+    if (groupList) {
       const group = groupList[0]
       setState({
         ...state,
@@ -42,6 +35,11 @@ const Business = ({ dispatch, groupList, shouldUpdate, loading }) => {
           ?.map(item => ({ ...item, percentage: parseInt(item.percentage, 10) }))
       })
     }
+  }, [groupList])
+  useEffect(() => {
+    if (shouldUpdate) {
+      tRef.current.reload()
+    }
   }, [loading, shouldUpdate])
 
   // 展示drawer
@@ -125,7 +123,8 @@ const Business = ({ dispatch, groupList, shouldUpdate, loading }) => {
     xField: 'name',
     yField: 'count',
     legend: false,
-    shape: 'pyramid'
+    shape: 'pyramid',
+    conversionTag: false
   }
   const { getScrollRef, redoHeight } = useTableScroll(columns)
   return (
@@ -134,7 +133,7 @@ const Business = ({ dispatch, groupList, shouldUpdate, loading }) => {
         <div className="p-4 border-b-1 border-solid border-black border-opacity-10 bg-[#f7f9fa] flex justify-around items-center">
           <div className="w-1/2 text-md">商机漏斗</div>
           <div className="w-1/2">
-            {groupList[0]?.value && (
+            {groupList && (
               <Select
                 size="small"
                 className="w-full"

+ 0 - 4
src/pages/Customer/Client/index.jsx

@@ -441,10 +441,6 @@ const Client = props => {
     }
     if (shouldUpdate) {
       tRef.current.reload()
-      dispatch({
-        type: 'refresh/commitAction',
-        payload: 'client '
-      })
     }
   }, [shouldUpdate])
 

+ 0 - 4
src/pages/Customer/Company/index.jsx

@@ -120,10 +120,6 @@ const Company = props => {
     }
     if (shouldUpdate) {
       tRef.current.reload()
-      dispatch({
-        type: 'refresh/company',
-        payload: 'company'
-      })
     }
   }, [shouldUpdate])
   const handleSearch = value => {