dingxin 5 年前
父节点
当前提交
76339f6a1c

+ 2
- 2
src/pages/customer/recommendCustomer/index.jsx 查看文件

@@ -86,7 +86,7 @@ function body(props) {
86 86
       ...apis.customer.customerRecommendRecommenderExport, 
87 87
       responseType: 'blob',
88 88
     }).then(response => {
89
-      // console.log('response: ', response)
89
+      console.log('exportRecommendCustomer: ', response.body())
90 90
       download(response)
91 91
     }).catch(error => {
92 92
 
@@ -213,7 +213,7 @@ function body(props) {
213 213
             </Button>
214 214
         </Form.Item>
215 215
       </Form>
216
-      <Button type="primary" onClick={() => exportRecommendCustomer()} className={Styles.SubmitButton} style={{ marginTop: '5px', marginBottom: '5px', display: 'none' }}>
216
+      <Button type="primary" onClick={() => exportRecommendCustomer()} className={Styles.SubmitButton} style={{ marginTop: '5px', marginBottom: '5px' }}>
217 217
         导出数据
218 218
       </Button>
219 219
       <Table dataSource={dataSource.records} columns={columns} pagination={{ total: dataSource.total, onChange }} />

+ 4
- 1
src/pages/indexEcharts/components/UserSex.jsx 查看文件

@@ -42,7 +42,10 @@ const UserSource = (props) => {
42 42
     },
43 43
     legend: {},
44 44
     color: ['#FF7E48', '#dcdcdc'],
45
-    tooltip: {},
45
+    tooltip: {
46
+      trigger: 'item',
47
+      formatter: "{b}: ({d}%)"
48
+    },
46 49
     series: {
47 50
       type: 'pie',
48 51
       name: '性别比例',

+ 20
- 17
src/pages/indexEcharts/components/UserSourcepie.jsx 查看文件

@@ -19,18 +19,18 @@ const UserSource = (props) => {
19 19
 
20 20
   useEffect(() => {
21 21
     userResource(formatDate(props.startDate, props.endDate))
22
-   }, [props.startDate, props.endDate])
23
- 
24
-   function userResource (params) {
25
-     request({
26
-       ...apis.indexEcharts.userResource,
27
-       params,
28
-     }).then((data) => {
29
-       setData(data)
30
-     })
31
-   }
32
-
33
-  function toEdit () {
22
+  }, [props.startDate, props.endDate])
23
+
24
+  function userResource(params) {
25
+    request({
26
+      ...apis.indexEcharts.userResource,
27
+      params,
28
+    }).then((data) => {
29
+      setData(data)
30
+    })
31
+  }
32
+
33
+  function toEdit() {
34 34
     router.push({
35 35
       pathname: '/indexEcharts/userSource',
36 36
     });
@@ -47,7 +47,10 @@ const UserSource = (props) => {
47 47
       x: 'left',
48 48
       data: ['来源置业顾问', '来源全民经纪人', '自主进入'],
49 49
     },
50
-    tooltip: {},
50
+    tooltip: {
51
+      // trigger: 'item',
52
+      // formatter: "{a} <br/>{b} : {c} ({d}%)"
53
+    },
51 54
     series: [
52 55
       {
53 56
         type: 'pie',
@@ -55,24 +58,24 @@ const UserSource = (props) => {
55 58
         radius: ['34%', '52%'],
56 59
       },
57 60
     ],
61
+
58 62
     dataset: {
59 63
       id: 'pie',
60 64
       source: [
61
-        { '用户来源': '来源置业顾问', value: person_realty_consultant,},
65
+        { '用户来源': '来源置业顾问', value: person_realty_consultant, },
62 66
         { '用户来源': '来源全民经纪人', value: person_estate_agent },
63 67
         { '用户来源': '自主进入', value: person_null },
64 68
       ]
65 69
     },
66 70
   }
67
- 
71
+
68 72
 
69 73
   const piestyles = {
70 74
     width: '100%',
71 75
     height: '400px',
72
-    minWidth:'350px',
76
+    minWidth: '350px',
73 77
   }
74 78
 
75
-
76 79
   return (
77 80
     <>
78 81
       <div>

+ 136
- 123
src/pages/indexEcharts/userSource.jsx 查看文件

@@ -9,64 +9,107 @@ import request from '../../utils/request';
9 9
 import apis from '../../services/apis';
10 10
 
11 11
 
12
+
13
+const { RangePicker } = DatePicker;
14
+const { Option } = Select
15
+
16
+
12 17
 // const formatDate = (start, end) => {
13 18
 //   const startDate = moment(start).format('YYYY-MM-DDT00:00:00.000') + 'Z'
14 19
 //   const endDate = moment(end).format('YYYY-MM-DDT23:59:59.999') + 'Z'
15 20
 //   return { startDate, endDate }
16 21
 // }
17 22
 
23
+let daterange = []
24
+let tableTitle = ['日期']
25
+
26
+const columns = [
27
+  {
28
+    title: '日期',
29
+    dataIndex: 'label',
30
+    key: 'label',
31
+    width:'20%'
32
+  },
33
+  {
34
+    title: '名片分享',
35
+    dataIndex: '名片分享',
36
+    key: '名片分享',
37
+  },
38
+  {
39
+    title: '生成海报',
40
+    dataIndex: '生成海报',
41
+    key: '生成海报',
42
+  },
43
+  {
44
+    title: '小程序搜索',
45
+    dataIndex: '小程序搜索',
46
+    key: '小程序搜索',
47
+  },
48
+  {
49
+    title: '好友分享',
50
+    dataIndex: '好友分享',
51
+    key: '好友分享',
52
+
53
+  },
54
+
55
+
56
+]
57
+
58
+class Header extends React.Component {
59
+
60
+  constructor(props) {
61
+    super(props)
62
+    this.state = {
63
+      dataSoures: [],
64
+      tableData: [],
65
+      userType: 'all',
66
+      endDate: {},
67
+      startDate: {}
68
+    }
69
+  }
18 70
 
19
-const header = props => {
20
-
21
-  const [tableData, setTableData] = useState([])
22
-  const [userType, setuserType] = useState([])
23
-  const [endDate, setEndDate] = useState({})
24
-  const [startDate, setStartDate] = useState({})
25
-  let daterange = []
71
+  componentDidMount() {
72
+    this.setState({ endDate: new Date(), startDate: moment().subtract(7, 'day').toDate() })
73
+  }
26 74
 
27
-  useEffect(() => {
28
-    setEndDate(new Date())
29
-    setStartDate(moment().subtract(7, 'day').toDate())
30
-    setuserType('all')
31
-  }, [])
32 75
 
33
-  const { RangePicker } = DatePicker;
34 76
 
35
-  function onChangetime(dates, dateStrings) {
77
+  formatDate = (start, end) => {
78
+    const tempStartDate = `${moment(start).format('YYYY-MM-DDT00:00:00.000')}Z`
79
+    const tempEndDate = `${moment(end).format('YYYY-MM-DDT23:59:59.999')}Z`
80
+    return { startDate: tempStartDate, endDate: tempEndDate }
81
+  }
36 82
 
83
+  onChangetime = (_dates, dateStrings) => {
37 84
     daterange[1] = dateStrings[1]
38 85
     daterange[0] = dateStrings[0]
39
-
40 86
   }
41 87
 
42
-  const handleSubmit = (e, props) => {
88
+  handleSubmit = (e, props) => {
43 89
 
44 90
     e.preventDefault();
45 91
 
46 92
   }
47 93
 
48
-  const getDataOf = (days) => () => {
49
-
50
-    setEndDate(new Date())
51
-    setStartDate(moment().subtract(days, 'day').toDate())
52
-
94
+  getDataOf = (days) => {
95
+    this.setState({ endDate: new Date(), startDate: moment().subtract(days, 'day').toDate() })
53 96
   }
54 97
 
55
-  function datalist() {
56
-
57
-    setEndDate(daterange[1])
58
-    setStartDate(daterange[0])
59
-
98
+  datalist = () => {
99
+    this.setState({ endDate: daterange[1], startDate: daterange[0] })
60 100
   }
61 101
 
102
+  onSuccess = e => {
103
+    this.setState({ dataSoures: e }, () => {
104
+      this.onTabledatas(e)
105
+    })
106
+  }
62 107
 
63
-  let tableTitle = ['日期']
64
-
65
-
66
-  function onTabledatas(e) {
67
-    const data = (e.data || []).reduce((acc, item, index) => {
108
+  onTabledatas = (e) => {
109
+    console.log('this.state.userType: ', this.state.userType)
110
+    const data = (e.data || []).reduce((acc, item) => {
68 111
       const { date, fromName, count, registered } = item
69
-      const num = userType === 'registered' ? registered : count
112
+      const num = this.state.userType === 'registered' ? registered : count
70 113
 
71 114
       tableTitle = tableTitle.indexOf(fromName) > -1 ? tableTitle : tableTitle.concat(fromName) // eslint-disable-line
72 115
       acc[date] = { ...acc[date], [`${fromName}`]: !num ? 0 : num }
@@ -74,105 +117,75 @@ const header = props => {
74 117
       return acc
75 118
     }, {})
76 119
 
77
-    setTableData(Object.keys(data).map(x => ({ label: x, ...data[x] })))
120
+    this.setState({ tableData: Object.keys(data).map(x => ({ label: x, ...data[x] })) })
78 121
 
79 122
   }
80 123
 
81
-  const columns = [
82
-    {
83
-      title: '日期',
84
-      dataIndex: 'label',
85
-      key: 'label',
86
-      width:'20%'
87
-    },
88
-    {
89
-      title: '名片分享',
90
-      dataIndex: '名片分享',
91
-      key: '名片分享',
92
-    },
93
-    {
94
-      title: '生成海报',
95
-      dataIndex: '生成海报',
96
-      key: '生成海报',
97
-    },
98
-    {
99
-      title: '小程序搜索',
100
-      dataIndex: '小程序搜索',
101
-      key: '小程序搜索',
102
-    },
103
-    {
104
-      title: '好友分享',
105
-      dataIndex: '好友分享',
106
-      key: '好友分享',
107
-
108
-    },
109
-
110
-
111
-  ]
112
-
113
-  function handleSelectChange(e) {
114
-
115
-    console.log(e)
116
-    setuserType(e)
124
+  handleSelectChange = (e) => {
125
+    this.setState({ userType: e }, () => {
126
+      this.onTabledatas(this.state.dataSoures)
127
+    })
117 128
   }
118 129
 
119 130
 
120
-
121
-  return (<>
122
-    <div style={{
123
-      backgroundColor: '#fff',
124
-      padding: '32PX 28px',
125
-      boxShadow: '0px 0px 16px 2px rgba(0,0,0,0.12)',
126
-      borderRadius: '12px',
127
-      minHeight: '60vh'
128
-    }}>
129
-      <Radio.Group buttonStyle="solid" defaultValue="a">
130
-        <Radio.Button value="a" onClick={getDataOf(7)}>最近7天</Radio.Button>
131
-        <Radio.Button value="b" onClick={getDataOf(30)}>最近1月</Radio.Button>
132
-      </Radio.Group>
133
-      <RangePicker
134
-        style={{ paddingLeft: '30px' }}
135
-        ranges={{
136
-          Today: [moment(), moment()],
137
-          'This Month': [moment().startOf('month'), moment().endOf('month')],
138
-        }}
139
-        showTime
140
-        // format="YYYY/MM/DD HH:mm:ss"
141
-        onChange={onChangetime}
142
-      />
143
-      <Button type="primary" htmlType="submit" style={{ marginLeft: '30px' }} onClick={datalist}>
144
-        查询
145
-          </Button>
146
-      <div>
147
-
148
-        <div style={{ display: 'flex' }}>
149
-          <div style={{
150
-            width: '1060px',
151
-            height: '560px',
152
-            paddingTop: '40px',
153
-            marginRight: ' 40px',
154
-          }}>
155
-            <UserSource BuildSelectHide={true} endDate={endDate} startDate={startDate} onSuccess={(e) => onTabledatas(e)}></UserSource>
156
-          </div>
157
-          <div style={{
158
-            width: '509px',
159
-            height: '600px',
160
-            paddingTop: '40px',
161
-
162
-          }}>
163
-            <UserSourcepie endDate={endDate} startDate={startDate}></UserSourcepie>
131
+  render() {
132
+    return (
133
+    <>
134
+      <div style={{
135
+        backgroundColor: '#fff',
136
+        padding: '32PX 28px',
137
+        boxShadow: '0px 0px 16px 2px rgba(0,0,0,0.12)',
138
+        borderRadius: '12px',
139
+        minHeight: '60vh'
140
+      }}>
141
+        <Radio.Group buttonStyle="solid" defaultValue="a">
142
+          <Radio.Button value="a" onClick={() => this.getDataOf(7)}>最近7天</Radio.Button>
143
+          <Radio.Button value="b" onClick={() => this.getDataOf(30)}>最近1月</Radio.Button>
144
+        </Radio.Group>
145
+        <RangePicker
146
+          style={{ paddingLeft: '30px' }}
147
+          ranges={{
148
+            Today: [moment(), moment()],
149
+            'This Month': [moment().startOf('month'), moment().endOf('month')],
150
+          }}
151
+          showTime
152
+          // format="YYYY/MM/DD HH:mm:ss"
153
+          onChange={(_dates, dateStrings) => this.onChangetime(_dates, dateStrings)}
154
+        />
155
+        <Button type="primary" htmlType="submit" style={{ marginLeft: '30px' }} onClick={() => this.datalist()}>
156
+          查询
157
+        </Button>
158
+        <div>
159
+  
160
+          <div style={{ display: 'flex' }}>
161
+            <div style={{
162
+              width: '1060px',
163
+              height: '560px',
164
+              paddingTop: '40px',
165
+              marginRight: ' 40px',
166
+            }}>
167
+              <UserSource BuildSelectHide={true} endDate={this.state.endDate} startDate={this.state.startDate} onSuccess={(e) => this.onSuccess(e)}></UserSource>
168
+            </div>
169
+            <div style={{
170
+              width: '509px',
171
+              height: '600px',
172
+              paddingTop: '40px',
173
+  
174
+            }}>
175
+              <UserSourcepie endDate={this.state.endDate} startDate={this.state.startDate}></UserSourcepie>
176
+            </div>
164 177
           </div>
178
+          <Select style={{ width: '180px' }} placeholder="所有用户" onChange={(e) => this.handleSelectChange(e)}>
179
+            <Option value='all'>所有用户</Option>
180
+            <Option value='registered'>注册用户</Option>
181
+          </Select>
182
+  
183
+          <Table style={{marginTop:'20px'}} dataSource={this.state.tableData} columns={columns} pagination={false} scroll={{ y: 500 }}></Table>
165 184
         </div>
166
-        <Select style={{ width: '180px' }} placeholder="所有用户" onChange={handleSelectChange}>
167
-          <Option value='all'>所有用户</Option>
168
-          <Option value='registered'>注册用户</Option>
169
-        </Select>
170
-
171
-        <Table style={{marginTop:'20px'}} dataSource={tableData} columns={columns} pagination={false} scroll={{ y: 500 }}></Table>
172 185
       </div>
173
-    </div>
174
-  </>
175
-  )
186
+    </>
187
+    )
188
+  }
176 189
 }
177 190
 
178
-export default header
191
+export default Header

+ 1
- 1
src/utils/request.js 查看文件

@@ -58,7 +58,7 @@ request.interceptors.request.use((url, options) => {
58 58
         requestType: data instanceof FormData ? 'form' : 'json',
59 59
         credentials: 'include', // 带 cookie
60 60
         interceptors: true,
61
-        getResponse: true
61
+        getResponse: true,
62 62
       },
63 63
     }
64 64
   );