|
@@ -1,32 +1,26 @@
|
|
|
-import React, { useState } from 'react'
|
|
|
|
|
|
|
+import React, { useState, useEffect, useRef } from 'react'
|
|
|
import { Select } from 'antd'
|
|
import { Select } from 'antd'
|
|
|
-import { useRequest } from 'umi'
|
|
|
|
|
-import { getBusinessGroupList, getBusinessList } from '@/services/customer'
|
|
|
|
|
|
|
+import { connect } from 'umi'
|
|
|
|
|
+import { getBusinessList } from '@/services/customer'
|
|
|
import ProTable from '@ant-design/pro-table'
|
|
import ProTable from '@ant-design/pro-table'
|
|
|
import consts from '@/consts'
|
|
import consts from '@/consts'
|
|
|
import AddBusiness from './components/AddBusiness'
|
|
import AddBusiness from './components/AddBusiness'
|
|
|
import Detail from './components/BusinessDetail'
|
|
import Detail from './components/BusinessDetail'
|
|
|
import { useModal } from '@/components/Modal'
|
|
import { useModal } from '@/components/Modal'
|
|
|
|
|
|
|
|
-const Business = () => {
|
|
|
|
|
|
|
+const Business = ({ dispatch, groupList }) => {
|
|
|
|
|
+ const tableRef = useRef(null)
|
|
|
const { toggleDrawer, setDrawerProps } = useModal()
|
|
const { toggleDrawer, setDrawerProps } = useModal()
|
|
|
const [state, setState] = useState({
|
|
const [state, setState] = useState({
|
|
|
- groupList: [],
|
|
|
|
|
- activeItem: null
|
|
|
|
|
|
|
+ orderIds: []
|
|
|
})
|
|
})
|
|
|
- useRequest(getBusinessGroupList, {
|
|
|
|
|
- onSuccess: result => {
|
|
|
|
|
- setState({
|
|
|
|
|
- ...state,
|
|
|
|
|
- groupList: result.map(item => ({
|
|
|
|
|
- label: item.name,
|
|
|
|
|
- value: item.id,
|
|
|
|
|
- items: item.status
|
|
|
|
|
- })),
|
|
|
|
|
- activeItem: result[0]?.id
|
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ if (!groupList.length) {
|
|
|
|
|
+ dispatch({
|
|
|
|
|
+ type: 'business/fetchGroup'
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
|
|
+ }, [])
|
|
|
|
|
|
|
|
// 展示drawer
|
|
// 展示drawer
|
|
|
const showDrawer = id => {
|
|
const showDrawer = id => {
|
|
@@ -37,7 +31,7 @@ const Business = () => {
|
|
|
height: '100vh',
|
|
height: '100vh',
|
|
|
overflowY: 'hidden'
|
|
overflowY: 'hidden'
|
|
|
},
|
|
},
|
|
|
- children: <Detail dataId={id} orderIds={state.orderIds} />
|
|
|
|
|
|
|
+ children: <Detail dataId={id} orderIds={state.orderIds} group={groupList} />
|
|
|
})
|
|
})
|
|
|
toggleDrawer()
|
|
toggleDrawer()
|
|
|
}
|
|
}
|
|
@@ -60,7 +54,8 @@ const Business = () => {
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
dataIndex: 'businessGroupName',
|
|
dataIndex: 'businessGroupName',
|
|
|
- title: '装机状态组'
|
|
|
|
|
|
|
+ title: '装机状态组',
|
|
|
|
|
+ width: '20%'
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
dataIndex: 'name',
|
|
dataIndex: 'name',
|
|
@@ -79,7 +74,7 @@ const Business = () => {
|
|
|
title: '最后跟进时间'
|
|
title: '最后跟进时间'
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- dataIndex: 'createTime ',
|
|
|
|
|
|
|
+ dataIndex: 'createTime',
|
|
|
title: '创建时间'
|
|
title: '创建时间'
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
@@ -93,13 +88,13 @@ const Business = () => {
|
|
|
<div className="p-4 border-b-1 border-solid border-black border-opacity-10 bg-[#f7f9fa] flex justify-around items-center">
|
|
<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 text-md">商机漏斗</div>
|
|
|
<div className="w-1/2">
|
|
<div className="w-1/2">
|
|
|
- {state.activeItem && (
|
|
|
|
|
|
|
+ {groupList[0]?.value && (
|
|
|
<Select
|
|
<Select
|
|
|
size="small"
|
|
size="small"
|
|
|
className="w-full"
|
|
className="w-full"
|
|
|
bordered={false}
|
|
bordered={false}
|
|
|
- options={state.groupList}
|
|
|
|
|
- defaultValue={state.activeItem}
|
|
|
|
|
|
|
+ options={groupList}
|
|
|
|
|
+ defaultValue={groupList[0]?.value}
|
|
|
/>
|
|
/>
|
|
|
)}
|
|
)}
|
|
|
</div>
|
|
</div>
|
|
@@ -112,6 +107,7 @@ const Business = () => {
|
|
|
<div className="ml-8 bg-white p-4 shadow-card">
|
|
<div className="ml-8 bg-white p-4 shadow-card">
|
|
|
<ProTable
|
|
<ProTable
|
|
|
bordered
|
|
bordered
|
|
|
|
|
+ actionRef={tableRef}
|
|
|
rowKey={record => record.id}
|
|
rowKey={record => record.id}
|
|
|
columns={columns}
|
|
columns={columns}
|
|
|
request={async (params, sort, filter) => {
|
|
request={async (params, sort, filter) => {
|
|
@@ -119,6 +115,7 @@ const Business = () => {
|
|
|
code = -1,
|
|
code = -1,
|
|
|
data: { business = [], total = 0 }
|
|
data: { business = [], total = 0 }
|
|
|
} = await getBusinessList({ ...params, ...sort, ...filter })
|
|
} = await getBusinessList({ ...params, ...sort, ...filter })
|
|
|
|
|
+ setState({ ...state, orderIds: business.map(item => item.id) })
|
|
|
return {
|
|
return {
|
|
|
data: business,
|
|
data: business,
|
|
|
success: code === consts.RET_CODE.SUCCESS,
|
|
success: code === consts.RET_CODE.SUCCESS,
|
|
@@ -127,7 +124,13 @@ const Business = () => {
|
|
|
}}
|
|
}}
|
|
|
search={false}
|
|
search={false}
|
|
|
toolbar={{
|
|
toolbar={{
|
|
|
- actions: [<AddBusiness key="add" groupList={state.groupList} />]
|
|
|
|
|
|
|
+ actions: [
|
|
|
|
|
+ <AddBusiness
|
|
|
|
|
+ key="add"
|
|
|
|
|
+ groupList={state.groupList}
|
|
|
|
|
+ reload={() => tableRef.current?.reload()}
|
|
|
|
|
+ />
|
|
|
|
|
+ ]
|
|
|
}}
|
|
}}
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
@@ -136,4 +139,6 @@ const Business = () => {
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-export default Business
|
|
|
|
|
|
|
+export default connect(({ business }) => ({
|
|
|
|
|
+ groupList: business.groupList
|
|
|
|
|
+}))(Business)
|