lanjianrong il y a 5 ans
Parent
commit
93de1245fe

+ 2 - 2
src/hooks/useAutoTable.js

@@ -109,11 +109,11 @@ export function useTableScroll(columnsRef, selectKeysRef) {
 
   useUpdateLayoutEffect(() => {
     debounceRedoHeight()
-  }, [selectKeysRef.length])
+  }, [selectKeysRef?.length])
 
   const getSrollX = useMemo(() => {
     let width = 0
-    if (selectKeysRef.length) {
+    if (selectKeysRef?.length) {
       width += 60
     }
 

+ 29 - 4
src/pages/Customer/Business/components/BusinessDetail/TabList.jsx

@@ -9,14 +9,31 @@ import AddRecord from '@/pages/Customer/Client/components/ContactDetail/AddRecor
 import ConnectClient from '@/pages/Customer/Client/components/ConnectClient'
 import { ChangeCompMap } from '@/pages/Customer/Company/components/ChangeCompany'
 import { useModal } from '@/components/Modal'
+import ContactDetail from '@/pages/Customer/Client/components/ContactDetail'
 
 const ContanctTabList = ({ businessId, clientList }) => {
-  const { toggleModal, setModalProps } = useModal()
+  const { toggleModal, setModalProps, toggleDrawer, setDrawerProps } = useModal()
   const dispatch = useDispatch()
   const [state, setState] = useState({
     params: {},
     visible: false
   })
+
+  // 展示drawer
+  const showDrawer = id => {
+    toggleDrawer()
+    setDrawerProps({
+      closable: true,
+      onClose: () => toggleDrawer(),
+      bodyStyle: {
+        height: '100vh',
+        overflowY: 'hidden'
+      },
+      children: <ContactDetail dataId={id} />
+    })
+    toggleDrawer()
+  }
+
   // const tRef = useRef()
   const columns = [
     {
@@ -26,7 +43,14 @@ const ContanctTabList = ({ businessId, clientList }) => {
     },
     {
       title: '姓名',
-      dataIndex: 'clientName'
+      dataIndex: 'clientName',
+      render: (clientName, record) => (
+        <span
+          onClick={() => showDrawer(record.id)}
+          className="text-primary cursor-pointer hover:text-[#967bbd]">
+          {clientName}
+        </span>
+      )
     },
     {
       title: '昵称',
@@ -96,6 +120,7 @@ const ContanctTabList = ({ businessId, clientList }) => {
           <TabPane tab="联系人" key="1">
             <div className="sheet-right-panel">
               <ProTable
+                size="small"
                 columns={columns}
                 search={false}
                 toolBarRender={false}
@@ -106,9 +131,9 @@ const ContanctTabList = ({ businessId, clientList }) => {
               />
             </div>
           </TabPane>
-          <TabPane tab="发票" key="2">
+          {/* <TabPane tab="发票" key="2">
             <div className="sheet-right-panel">通行账号</div>
-          </TabPane>
+          </TabPane> */}
         </Tabs>
       </div>
       <div className="sheet-btns pl-15px pt-15px">

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

@@ -7,9 +7,11 @@ import consts from '@/consts'
 import AddBusiness from './components/AddBusiness'
 import Detail from './components/BusinessDetail'
 import { useModal } from '@/components/Modal'
+import { useTableScroll } from '@/hooks/useAutoTable'
+import CompanyDetail from '../Company/components/CompanyDetail'
 
-const Business = ({ dispatch, groupList }) => {
-  const tableRef = useRef(null)
+const Business = ({ dispatch, groupList, shouldUpdate }) => {
+  const tRef = useRef(null)
   const { toggleDrawer, setDrawerProps } = useModal()
   const [state, setState] = useState({
     orderIds: []
@@ -20,10 +22,17 @@ const Business = ({ dispatch, groupList }) => {
         type: 'business/fetchGroup'
       })
     }
-  }, [])
+    if (shouldUpdate) {
+      tRef.current.reload()
+      dispatch({
+        type: 'refresh/commitAction',
+        payload: 'business '
+      })
+    }
+  }, [shouldUpdate])
 
   // 展示drawer
-  const showDrawer = id => {
+  const showDrawer = (id, isCompany = false) => {
     setDrawerProps({
       closable: true,
       onClose: () => toggleDrawer(),
@@ -31,7 +40,11 @@ const Business = ({ dispatch, groupList }) => {
         height: '100vh',
         overflowY: 'hidden'
       },
-      children: <Detail dataId={id} orderIds={state.orderIds} group={groupList} />
+      children: isCompany ? (
+        <CompanyDetail dataId={id} />
+      ) : (
+        <Detail dataId={id} orderIds={state.orderIds} group={groupList} />
+      )
     })
     toggleDrawer()
   }
@@ -50,7 +63,18 @@ const Business = ({ dispatch, groupList }) => {
     },
     {
       dataIndex: 'customerName',
-      title: '客户名称'
+      title: '客户名称',
+      render: (text, record) => {
+        return record.customerId !== consts.ENCRYPTION_ZERO ? (
+          <span
+            onClick={() => showDrawer(record.customerId, true)}
+            className="text-primary cursor-pointer hover:text-[#967bbd]">
+            {text}
+          </span>
+        ) : (
+          '-'
+        )
+      }
     },
     {
       dataIndex: 'businessGroupName',
@@ -82,6 +106,7 @@ const Business = ({ dispatch, groupList }) => {
       title: '创建人'
     }
   ]
+  const { getScrollRef, redoHeight } = useTableScroll(columns)
   return (
     <div className="h-full w-full flex flex-row justify-between">
       <div className="h-full w-3/20 rounded-4px shadow-card">
@@ -104,12 +129,16 @@ const Business = ({ dispatch, groupList }) => {
         </div>
       </div>
       <div className="w-17/20">
-        <div className="ml-8 bg-white p-4 shadow-card">
+        <div className="ml-8 bg-white shadow-card">
           <ProTable
             bordered
-            actionRef={tableRef}
+            actionRef={tRef}
             rowKey={record => record.id}
             columns={columns}
+            onLoadingChange={loadingStatus => {
+              loadingStatus && redoHeight()
+            }}
+            scroll={getScrollRef}
             request={async (params, sort, filter) => {
               const {
                 code = -1,
@@ -128,7 +157,7 @@ const Business = ({ dispatch, groupList }) => {
                 <AddBusiness
                   key="add"
                   groupList={state.groupList}
-                  reload={() => tableRef.current?.reload()}
+                  reload={() => tRef.current?.reload()}
                 />
               ]
             }}
@@ -139,6 +168,7 @@ const Business = ({ dispatch, groupList }) => {
   )
 }
 
-export default connect(({ business }) => ({
-  groupList: business.groupList
+export default connect(({ business, refresh }) => ({
+  groupList: business.groupList,
+  shouldUpdate: refresh.business
 }))(Business)

+ 1 - 1
src/pages/Customer/Company/components/CompanyDetail/TabList.jsx

@@ -29,7 +29,7 @@ const CompanyTabList = ({ initData, customerId, client, software }) => {
         height: '100vh',
         overflowY: 'hidden'
       },
-      children: <ContactDetail dataId={id} orderIds={[]} />
+      children: <ContactDetail dataId={id} />
     })
     toggleDrawer()
   }