|
|
@@ -1,17 +1,17 @@
|
|
|
import React, { useState, useEffect, useRef } from 'react'
|
|
|
import ProTable from '@ant-design/pro-table'
|
|
|
-import { connect, useModel } from 'umi'
|
|
|
+import { useModel } from 'umi'
|
|
|
import { Row, Col, Select, Card, Skeleton } from 'antd'
|
|
|
import { AddressBook, City, Finance, Comment } from '@icon-park/react'
|
|
|
-import { DualAxes } from '@ant-design/charts'
|
|
|
import consts from '@/consts'
|
|
|
import { useModal } from '@/components/Modal'
|
|
|
import { queryDashboard } from '@/services/dashboard'
|
|
|
import ReminderList from './components/ReminderList'
|
|
|
import LeaderBoard from './components/LeaderBoard'
|
|
|
import { cyclicalOp } from './consts'
|
|
|
+import BusinessChar from './components/BusinessChar'
|
|
|
|
|
|
-const Dashboard = ({ dispatch, groupList = [] }) => {
|
|
|
+const Dashboard = () => {
|
|
|
const timer = useRef(null)
|
|
|
const { initialState: { permData } = { permData: {} } } = useModel('@@initialState')
|
|
|
const [state, setState] = useState({
|
|
|
@@ -86,16 +86,7 @@ const Dashboard = ({ dispatch, groupList = [] }) => {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- useEffect(() => {
|
|
|
- if (!groupList) {
|
|
|
- dispatch({
|
|
|
- type: 'business/fetchGroup'
|
|
|
- })
|
|
|
- }
|
|
|
- if (groupList?.length) {
|
|
|
- setState({ ...state, params: { ...state.params, businessGroupId: groupList[0]?.value } })
|
|
|
- }
|
|
|
- }, [groupList])
|
|
|
+
|
|
|
useEffect(() => {
|
|
|
initData(state.params)
|
|
|
}, [state.params.businessGroupId, state.params.dataPermission, state.params.cyclical])
|
|
|
@@ -172,53 +163,9 @@ const Dashboard = ({ dispatch, groupList = [] }) => {
|
|
|
}
|
|
|
]
|
|
|
|
|
|
- const { char, thread } = state.businessChar
|
|
|
- const config = {
|
|
|
- data: [char, thread],
|
|
|
- legend: { position: 'top' },
|
|
|
- height: 230,
|
|
|
- xField: 'time',
|
|
|
- yField: ['value', 'increment'],
|
|
|
- yAxis: {
|
|
|
- value: {
|
|
|
- label: {
|
|
|
- formatter: text => `${text}个`
|
|
|
- }
|
|
|
- },
|
|
|
- increment: {
|
|
|
- label: {
|
|
|
- formatter: text => `${text}%`
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- meta: {
|
|
|
- increment: {
|
|
|
- alias: '增幅'
|
|
|
- }
|
|
|
- },
|
|
|
- geometryOptions: [
|
|
|
- {
|
|
|
- geometry: 'column',
|
|
|
- isGroup: true,
|
|
|
- seriesField: 'type',
|
|
|
- color: ['#A088C4', '#605B67']
|
|
|
- },
|
|
|
- {
|
|
|
- geometry: 'line',
|
|
|
- lineStyle: { lineWidth: 2 },
|
|
|
- smooth: true,
|
|
|
- color: '#FEB51A',
|
|
|
- point: {
|
|
|
- size: 3,
|
|
|
- style: {
|
|
|
- fill: 'white',
|
|
|
- stroke: '#5B8FF9',
|
|
|
- lineWidth: 2
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
+ const handleChangeGroupId = e =>
|
|
|
+ setState({ ...state, immediate: true, params: { ...state.params, businessGroupId: e } })
|
|
|
+
|
|
|
return (
|
|
|
<div>
|
|
|
<div className="shadow-card">
|
|
|
@@ -410,27 +357,11 @@ const Dashboard = ({ dispatch, groupList = [] }) => {
|
|
|
<div className="mt-4">
|
|
|
<Row gutter={16}>
|
|
|
<Col className="gutter-row" span={16}>
|
|
|
- <Card
|
|
|
+ <BusinessChar
|
|
|
loading={state.loading}
|
|
|
- bodyStyle={{ minHeight: '230px' }}
|
|
|
- title={
|
|
|
- <div className="relative">
|
|
|
- <span>销售漏斗</span>
|
|
|
- <div className="absolute right-1 top-0">
|
|
|
- {groupList ? (
|
|
|
- <Select
|
|
|
- defaultValue={groupList[0]?.value}
|
|
|
- options={groupList}
|
|
|
- onChange={e =>
|
|
|
- setState({ ...state, params: { ...state.params, businessGroupId: e } })
|
|
|
- }
|
|
|
- />
|
|
|
- ) : null}
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- }>
|
|
|
- {char && thread && <DualAxes {...config} />}
|
|
|
- </Card>
|
|
|
+ data={state.businessChar}
|
|
|
+ changeGroupId={handleChangeGroupId}
|
|
|
+ />
|
|
|
</Col>
|
|
|
|
|
|
<Col className="gutter-row" span={8}>
|
|
|
@@ -470,6 +401,4 @@ const Dashboard = ({ dispatch, groupList = [] }) => {
|
|
|
)
|
|
|
}
|
|
|
|
|
|
-export default connect(({ business }) => ({
|
|
|
- groupList: business.groupList
|
|
|
-}))(Dashboard)
|
|
|
+export default Dashboard
|