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