|
@@ -1,34 +1,43 @@
|
1
|
1
|
import React, { useState, useEffect, useRef } from 'react'
|
2
|
2
|
import withLayout from '@/layout'
|
|
3
|
+import Taro from '@tarojs/taro'
|
3
|
4
|
import { ScrollView, Image } from '@tarojs/components'
|
4
|
|
-import { getChannelRank } from '@/services/agent'
|
|
5
|
+import { getChannelRank, getChannelStatReport } from '@/services/agent'
|
5
|
6
|
import { fetch } from '@/utils/request'
|
6
|
7
|
import { API_GET_AGENT_BUILDINGS } from '@/constants/api'
|
7
|
|
-import { } from '@/constants/user'
|
|
8
|
+// import { } from '@/constants/user'
|
8
|
9
|
import DateRangePicker from '@/components/DateRangePicker'
|
9
|
10
|
import Picker from '@/components/Picker'
|
10
|
11
|
import LineChat from './components/LineChat'
|
|
12
|
+import useRank from './hooks/useRank'
|
|
13
|
+import useReport from './hooks/useReport'
|
|
14
|
+import useChart from './hooks/useChart'
|
11
|
15
|
// import '@/assets/css/iconfont.css'
|
12
|
16
|
import './index.scss'
|
13
|
17
|
|
14
|
|
-const lineXDicts = [
|
|
18
|
+const statTypeDicts = [
|
15
|
19
|
{name: '按天', id: 'day'},
|
16
|
20
|
{name: '按月', id: 'month'},
|
17
|
21
|
]
|
18
|
|
-
|
19
|
|
-const padMonth = m => m > 9 ? m : `0${m}`
|
|
22
|
+const custTypeDicts = [
|
|
23
|
+ {name: '新增人员', id: 'new'},
|
|
24
|
+ {name: '跟进', id: 'follow'},
|
|
25
|
+ {name: '成交', id: 'success'},
|
|
26
|
+]
|
20
|
27
|
|
21
|
28
|
export default withLayout((props) => {
|
22
|
29
|
|
23
|
30
|
const [showPicker, setShowPicker] = useState(false)
|
24
|
|
- const [rankDateRange, setRankDateRange] = useState([])
|
25
|
|
- const [reportDateRange, setReportDateRange] = useState([])
|
|
31
|
+ const pickerTrigger = useRef()
|
26
|
32
|
const [buildingId, setBuildingId] = useState()
|
27
|
33
|
const [buildingList, setBuildingList] = useState([])
|
28
|
|
- const [rankList, setRankList] = useState([])
|
29
|
|
- const [lineXType, setLineXType] = useState('day')
|
30
|
|
- const [lingeDateRange, seteLineDateRange] = useState([])
|
31
|
|
- const pickerTrigger = useRef()
|
|
34
|
+ const [,setRankDateRange, rankList] = useRank(buildingId)
|
|
35
|
+ const [,setReportDateRange, reportInfo] = useReport(buildingId)
|
|
36
|
+ const [statType, setStatType, custType, setCustType, chartData] = useChart(buildingId)
|
|
37
|
+
|
|
38
|
+ const handleMore = () => {
|
|
39
|
+ Taro.navigateTo({ url: '/pages/mine/myCustomer/index' })
|
|
40
|
+ }
|
32
|
41
|
|
33
|
42
|
const handleRankDate = () => {
|
34
|
43
|
pickerTrigger.current = 'rank'
|
|
@@ -60,35 +69,6 @@ export default withLayout((props) => {
|
60
|
69
|
})
|
61
|
70
|
}, [])
|
62
|
71
|
|
63
|
|
- useEffect(() => {
|
64
|
|
- if (buildingId) {
|
65
|
|
- getChannelRank({buildingId}).then((res) => {
|
66
|
|
- setRankList(res || [])
|
67
|
|
- })
|
68
|
|
- }
|
69
|
|
- }, [buildingId])
|
70
|
|
-
|
71
|
|
- useEffect(() => {
|
72
|
|
- const now = new Date()
|
73
|
|
- const endDay = now.toJSON().substring(0, 10)
|
74
|
|
- if (lineXType === 'day') {
|
75
|
|
- const cutDay = 7 * 24 * 60 * 60 * 1000
|
76
|
|
- const start = new Date(now - cutDay)
|
77
|
|
- seteLineDateRange([start.toJSON().substring(0, 10), endDay])
|
78
|
|
- } else {
|
79
|
|
- const cutMonth = 6
|
80
|
|
- const curMonth = now.getMonth() + 1
|
81
|
|
- const startMonth = curMonth - cutMonth + 1
|
82
|
|
- if (startMonth <= 0) {
|
83
|
|
- const startYear = now.getFullYear() - 1
|
84
|
|
- seteLineDateRange([`${startYear}-${padMonth(startMonth + 12)}-01`, endDay])
|
85
|
|
- } else {
|
86
|
|
- seteLineDateRange([`${now.getFullYear()}-${padMonth(startMonth)}-01`, endDay])
|
87
|
|
- }
|
88
|
|
- }
|
89
|
|
-
|
90
|
|
- }, [lineXType])
|
91
|
|
-
|
92
|
72
|
return (
|
93
|
73
|
<view className='Page partnerChannel'>
|
94
|
74
|
<DateRangePicker visable={showPicker} close={() => setShowPicker(false)} change={handlePickerChange} />
|
|
@@ -126,7 +106,7 @@ export default withLayout((props) => {
|
126
|
106
|
</view>
|
127
|
107
|
<view className='Num'>
|
128
|
108
|
<text></text>
|
129
|
|
- <text>{item.number}</text>
|
|
109
|
+ <text>{`到访 ${item.number||0} 人`}</text>
|
130
|
110
|
</view>
|
131
|
111
|
</view>
|
132
|
112
|
))
|
|
@@ -140,23 +120,23 @@ export default withLayout((props) => {
|
140
|
120
|
<text>销售简报</text>
|
141
|
121
|
<Image mode='heightFix' src={require('../../../assets/mine-icon23.png')} onClick={handleReportDate}></Image>
|
142
|
122
|
<view className='flex-item'></view>
|
143
|
|
- <text>更多</text>
|
|
123
|
+ <text onClick={handleMore}>更多</text>
|
144
|
124
|
<text className='iconfont icon-jiantouright'></text>
|
145
|
125
|
</view>
|
146
|
126
|
<view className='List'>
|
147
|
127
|
<view className='flex-h'>
|
148
|
128
|
<text className='flex-item'>新增客户</text>
|
149
|
|
- <text>34人</text>
|
|
129
|
+ <text>{`${reportInfo.newCustomerNum||0}人`}</text>
|
150
|
130
|
<text className='iconfont icon-jiantouright'></text>
|
151
|
131
|
</view>
|
152
|
132
|
<view className='flex-h'>
|
153
|
133
|
<text className='flex-item'>跟进客户</text>
|
154
|
|
- <text>34人</text>
|
|
134
|
+ <text>{`${reportInfo.followCustomerNum||0}人`}</text>
|
155
|
135
|
<text className='iconfont icon-jiantouright'></text>
|
156
|
136
|
</view>
|
157
|
137
|
<view className='flex-h'>
|
158
|
138
|
<text className='flex-item'>成交客户</text>
|
159
|
|
- <text>34人</text>
|
|
139
|
+ <text>{`${reportInfo.successCustomerNum||0}人`}</text>
|
160
|
140
|
<text className='iconfont icon-jiantouright'></text>
|
161
|
141
|
</view>
|
162
|
142
|
</view>
|
|
@@ -168,16 +148,16 @@ export default withLayout((props) => {
|
168
|
148
|
<text>销售趋势</text>
|
169
|
149
|
<view className='flex-item'></view>
|
170
|
150
|
<view className='Type'>
|
171
|
|
- <text>新增客户</text>
|
|
151
|
+ <Picker kv={['name', 'id']} dicts={custTypeDicts} value={custType} onChange={setCustType} />
|
172
|
152
|
<text className='iconfont icon-sanjiaoxingdown'></text>
|
173
|
153
|
</view>
|
174
|
154
|
<view className='Sort'>
|
175
|
|
- <Picker kv={['name', 'id']} dicts={lineXDicts} value={lineXType} onChange={setLineXType} />
|
|
155
|
+ <Picker kv={['name', 'id']} dicts={statTypeDicts} value={statType} onChange={setStatType} />
|
176
|
156
|
<text className='iconfont icon-sanjiaoxingdown'></text>
|
177
|
157
|
</view>
|
178
|
158
|
</view>
|
179
|
159
|
<view className='LineChart'>
|
180
|
|
- <LineChat buildingId={buildingId} xType={lineXType} dateRange={lingeDateRange} />
|
|
160
|
+ <LineChat dataSource={chartData} />
|
181
|
161
|
</view>
|
182
|
162
|
</view>
|
183
|
163
|
|