zhoulisen 5 anos atrás
pai
commit
b6cd30cdd8

+ 4
- 1
src/components/ModalButton/ModalButton.jsx Ver arquivo

@@ -1,5 +1,5 @@
1 1
 import React from 'react';
2
-import { Modal, Button } from 'antd';
2
+import { Modal, Button, message } from 'antd';
3 3
 
4 4
 export default function ModalButton(props) {
5 5
   const {
@@ -9,12 +9,15 @@ export default function ModalButton(props) {
9 9
     modalConfigs = {},
10 10
     onClick,
11 11
     onCancel,
12
+    // 未选数据弹出提示
13
+    beforeCheck = '',
12 14
     okText = '确认',
13 15
     cancelText = '取消',
14 16
     ...btnProps
15 17
   } = props || {}
16 18
 
17 19
   const handleClick = e => {
20
+    if (!!beforeCheck) { message.info(beforeCheck); return }
18 21
     Modal[method]({
19 22
       title,
20 23
       content,

+ 3
- 3
src/pages/qrcode/qrcodelist/dataRecord.jsx Ver arquivo

@@ -89,9 +89,9 @@ const DataRecord = props => {
89 89
         </div>
90 90
         <div>
91 91
             <Tabs type="card" value={tab} buttonStyle="solid" onChange={e => tabsCallback(e)}>
92
-                <TabPane tab="访问人数" key="visitors" ></TabPane>
93
-                <TabPane tab="访问次数" key="visitNum" ></TabPane>
94
-                <TabPane tab="新增注册用户" key="newuser" ></TabPane>
92
+                <TabPane tab="访问人数" key="1" ></TabPane>
93
+                <TabPane tab="访问次数" key="2" ></TabPane>
94
+                <TabPane tab="新增注册用户" key="3" ></TabPane>
95 95
             </Tabs>
96 96
             <div style={{ marginTop: '20px' }}>
97 97
                 <Tables id={id} type={tab} />

+ 12
- 27
src/pages/qrcode/qrcodelist/index.jsx Ver arquivo

@@ -8,7 +8,6 @@ import EditIcon from '@/components/EditIcon';
8 8
 import Navigate from '@/components/Navigate';
9 9
 import QrcodeType from '@/components/SelectButton/QrcodeType'
10 10
 import { ConfirmButton } from '@/components/ModalButton';
11
-import styles from '../../style/GoodsList.less';
12 11
 import BuildSelect from '@/components/SelectButton/BuildSelect'
13 12
 import ChannelSelect from '@/components/SelectButton/channelSelect'
14 13
 import apis from '../../../services/apis';
@@ -28,24 +27,12 @@ const typeName = targetType => {
28 27
         case 'salesBatch': return '销售批次';
29 28
     }
30 29
 }
31
-// const typeName = {
32
-//     project: '项目',
33
-//     activity: '常规活动',
34
-//     help: '常规活动',
35
-//     group: '拼团活动',
36
-//     h5: 'H5活动',
37
-//     live: '直播活动',
38
-//     news: '资讯',
39
-//     salesBatch: '销售批次',
40
-// }
41
-
42
-
43 30
 
44 31
 const qrcodelist = props => {
45 32
     const [data, setData] = useState([])
46 33
     const [showHelp, setShowHelp] = useState(false)
47 34
     const [qrcodeList, setQrcodeList] = useState([])
48
-
35
+    const [beforeCheck, setBeforeCheck] = useState('请至少选择一条数据')
49 36
 
50 37
     // eslint-disable-next-line react-hooks/rules-of-hooks
51 38
     useEffect(() => {
@@ -61,8 +48,9 @@ const qrcodelist = props => {
61 48
     }
62 49
 
63 50
     const batchDelete = () => {
64
-        request({ ...apis.qrcode.batchDelete, data: qrcodeList, }).then((data) => {
65
-            message.info("操作成功")
51
+        request({ ...apis.qrcode.batchDelete, data: qrcodeList }).then(data => {
52
+            message.info('操作成功')
53
+            setBeforeCheck('请至少选择一条数据')
66 54
             getList({ pageNum: 1, pageSize: 10 });
67 55
         }).catch((err) => {
68 56
             // message.info(err.msg)
@@ -158,6 +146,11 @@ const qrcodelist = props => {
158 146
         onChange: (selectedRowKeys, selectedRows) => {
159 147
             console.log('selectedRowKeys:', selectedRowKeys, 'selectedRows: ', selectedRows);
160 148
             setQrcodeList(selectedRows)
149
+            if (selectedRowKeys.length <= 0) {
150
+                setBeforeCheck('请至少选择一条数据')
151
+            } else {
152
+                setBeforeCheck('')
153
+            }
161 154
         },
162 155
     };
163 156
 
@@ -178,14 +171,6 @@ const qrcodelist = props => {
178 171
         getList({ pageNum: 1, pageSize: 10 })
179 172
     }
180 173
 
181
-    function before() {
182
-        if (qrcodeList.length <= 0) {
183
-            message.info('请至少选择一条数据');
184
-            return true
185
-        }
186
-
187
-        return false
188
-    }
189 174
 
190 175
     const { getFieldDecorator } = props.form
191 176
     return (
@@ -215,13 +200,13 @@ const qrcodelist = props => {
215 200
                     )}
216 201
                 </Form.Item>
217 202
                 <Form.Item>
218
-                    <Button type="primary" htmlType="submit" className={styles.searchBtn}>搜索</Button>
203
+                    <Button type="primary" htmlType="submit">搜索</Button>
219 204
                     <Button style={{ marginLeft: 8 }} onClick={handleReset}>重置</Button>
220 205
                 </Form.Item>
221 206
             </Form>
222 207
             {/* title="确认删除?" */}
223 208
             <Button type="danger" onClick={() => toAdd()}>新增</Button>
224
-            <ConfirmButton type="link" title="确认删除选中数据?" before={before} onClick={() => batchDelete()}>
209
+            <ConfirmButton type="link" title="确认删除选中数据?" beforeCheck={beforeCheck} onClick={() => batchDelete()}>
225 210
                 <Button type="primary" style={{ marginLeft: '30px' }}>删除</Button>
226 211
             </ConfirmButton>
227 212
             <Icon type="question-circle" theme="filled" style={{ fontSize: '25px', color: '#F00', marginLeft: '30px' }} onClick={() => setShowHelp(true)} />
@@ -241,7 +226,7 @@ const qrcodelist = props => {
241 226
             </Modal>
242 227
 
243 228
             <Table rowSelection={rowSelection}
244
-                dataSource={data.records} columns={columns} pagination={false} rowKey={r => r.qrCodeId} style={{ marginTop: '20px' }}/>
229
+                dataSource={data.records} columns={columns} pagination={false} rowKey={r => r.qrCodeId} style={{ marginTop: '20px' }} />
245 230
             <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
246 231
                 <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={e => changePageNum(e)} current={data.current} />
247 232
             </div>

+ 50
- 23
src/pages/qrcode/qrcodelist/table/index.jsx Ver arquivo

@@ -9,24 +9,24 @@ import moment from 'moment';
9 9
 
10 10
 const table = props => {
11 11
     const { id, type } = props
12
-    const [data, setData] = useState({})
12
+    const [data, setData] = useState([])
13 13
 
14 14
 
15 15
     useEffect(() => {
16 16
         // console.log(activityId, activityType)
17
-        // getList({ pageNum: 1, pageSize: 10 })
17
+        getList({ pageNum: 1, pageSize: 10, qrCodeId: id, type })
18 18
 
19
-    }, [])
19
+    }, [type])
20 20
 
21 21
     const getList = params => {
22 22
         // console.log(params)
23
-        // request({ ...apis.activityDataStatis.activityVisitNum, params: { ...params, activityId: activityId, activityType: activityType, ...date } }).then(data => {
24
-        //   console.log(data)
25
-        //   props.getData()
26
-        //   setData(data)
27
-        // }).catch(e => {
28
-        //   console.log(e)
29
-        // })
23
+        request({ ...apis.qrcode.getStatisticRecord, params: { ...params } }).then(data => {
24
+            console.log(data)
25
+
26
+            //   setData(data)
27
+        }).catch(e => {
28
+            console.log(e)
29
+        })
30 30
     }
31 31
 
32 32
     const visitNum = {
@@ -71,25 +71,52 @@ const table = props => {
71 71
             key: 'province',
72 72
         },
73 73
         // eslint-disable-next-line no-nested-ternary
74
-        type === 'visitNum' ? visitNum : type === 'visitors' ? visitors : newuser,
75
-        // visitNum,
76
-        // visitors,
77
-        // newuser,
74
+        type === '1' ? visitors : type === '2' ? visitNum : newuser,
78 75
     ]
79 76
 
80 77
 
81 78
     const changePageNum = pageNumber => {
82
-        getList({ pageNum: pageNumber, pageSize: 10, ...props.form.getFieldsValue() })
79
+        getList({ pageNum: pageNumber, pageSize: 10 })
83 80
     }
84 81
 
82
+    // 下载文档
83
+    function download(data) {
84
+        if (!data) {
85
+            console.log('234')
86
+            return
87
+        }
88
+        const url = window.URL.createObjectURL(new Blob([data]))
89
+        const link = document.createElement('a')
90
+        link.style.display = 'none'
91
+        link.href = url
92
+        if (type === 1) {
93
+            link.setAttribute('download', '访问人数.xlsx')
94
+        } else if (type === 2) {
95
+            link.setAttribute('download', '访问次数.xlsx')
96
+        } else {
97
+            link.setAttribute('download', '新增注册用户.xlsx')
98
+        }
99
+
100
+        document.body.append(link)
101
+        link.click()
102
+    }
85 103
 
86
-
87
-    const exportActivityStats = () => {
88
-
89
-        // request({ ...apis.activityDataStatis.activityVisitNumExport, params: { activityId: activityId, activityType: activityType, ...props.form.getFieldsValue(), ...date } }).then(data => {
90
-        //   if (!data) {
91
-        //     return
92
-        //   }
104
+    const exportStatisticRecord = () => {
105
+
106
+        request({ ...apis.qrcode.getStatisticRecordExport, responseType: 'blob', params: { qrCodeId: id, type } }).then(data => {
107
+            console.log(data, '22222222')
108
+            download(data)
109
+
110
+            // const url = window.URL.createObjectURL(new Blob([data]))responseType: 'blob',
111
+            // const link = document.createElement('a')
112
+            // link.style.display = 'none'
113
+            // link.href = url
114
+            // link.setAttribute('download', '访问统计.xlsx')
115
+            // document.body.append(link)
116
+            // link.click()
117
+        }).catch((err) => {
118
+            console.log(err, '3333333333')
119
+        })
93 120
         //   const url = window.URL.createObjectURL(new Blob([data]))
94 121
         //   const link = document.createElement('a')
95 122
         //   link.style.display = 'none'
@@ -105,7 +132,7 @@ const table = props => {
105 132
             <div>
106 133
 
107 134
 
108
-                <Button type="primary" style={{ float: 'right', marginBottom: '20px', zIndex: 1 }} onClick={exportActivityStats} >
135
+                <Button type="primary" style={{ float: 'right', marginBottom: '20px', zIndex: 1 }} onClick={exportStatisticRecord} >
109 136
                     导出
110 137
             </Button>
111 138
 

+ 0
- 97
src/pages/qrcode/qrcodelist/table/newuser.jsx Ver arquivo

@@ -1,97 +0,0 @@
1
-import React, { useState, useEffect } from 'react';
2
-import { Form, Input, Button, Icon, Select, message, Table, Divider, Tag, Pagination, Modal, DatePicker } from 'antd';
3
-import router from 'umi/router';
4
-import apis from '../../../../services/apis';
5
-import request from '../../../../utils/request';
6
-import AuthButton from '../../../../components/AuthButton';
7
-import WxDictSelect from '@/components/SelectButton/WxDictSelect';
8
-import moment from 'moment';
9
-
10
-
11
-const newuser = props => {
12
-  const [showHelp, setShowHelp] = useState(false)
13
-  const [data, setData] = useState({})
14
-
15
-
16
-  useEffect(() => {
17
-    // console.log(activityId, activityType)
18
-    // getList({ pageNum: 1, pageSize: 10 })
19
-
20
-  }, [])
21
-
22
-  const getList = params => {
23
-    // console.log(params)
24
-    // request({ ...apis.activityDataStatis.activityAddRegist, params: { ...params, activityId: activityId, activityType: activityType, ...date } }).then(data => {
25
-    //   console.log(data)
26
-    //   props.getData()
27
-    //   setData(data)
28
-    // }).catch(e => {
29
-    //   console.log(e)
30
-    // })
31
-  }
32
-
33
-  const columns = [
34
-    {
35
-      title: '姓名',
36
-      dataIndex: 'nickName',
37
-      key: 'nickName',
38
-    },
39
-    {
40
-      title: '电话',
41
-      dataIndex: 'phone',
42
-      key: 'phone',
43
-    },
44
-    {
45
-      title: '性别',
46
-      dataIndex: 'gender',
47
-      key: 'gender',
48
-    },
49
-    {
50
-      title: '归属地',
51
-      dataIndex: 'province',
52
-      key: 'province',
53
-    },
54
-    {
55
-      title: '注册时间',
56
-      dataIndex: 'visitDate',
57
-      key: 'visitDate',
58
-      render: (x, row) => <><span>{`${moment(row.visitDate).format('YYYY-MM-DD HH:mm:ss')}`}</span></>,
59
-    },
60
-  ]
61
-
62
-
63
-  const changePageNum = pageNumber => {
64
-    getList({ pageNum: pageNumber, pageSize: 10, ...props.form.getFieldsValue() })
65
-  }
66
-
67
-
68
-  const exportActivityStats = () => {
69
-
70
-    request({ ...apis.activityDataStatis.activityAddRegistNumExport, params: { activityId: activityId, activityType: activityType, ...props.form.getFieldsValue(), ...date } }).then(data => {
71
-      if (!data) {
72
-        return
73
-      }
74
-      const url = window.URL.createObjectURL(new Blob([data]))
75
-      const link = document.createElement('a')
76
-      link.style.display = 'none'
77
-      link.href = url
78
-      link.setAttribute('download', '访问统计.xlsx')
79
-      document.body.append(link)
80
-      link.click()
81
-    }).catch()
82
-  }
83
-
84
-  return <>
85
-    <div>
86
-      <div>
87
-        <Button type="primary" style={{ float: 'right', marginBottom: '20px', zIndex: 1 }} onClick={exportActivityStats}>导出</Button>
88
-      </div>
89
-      <Table style={{ marginTop: '30px' }} dataSource={data.records} columns={columns} pagination={false} rowKey="activityList" />
90
-      <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
91
-        <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={changePageNum} current={data.current} />
92
-      </div>
93
-    </div>
94
-  </>
95
-}
96
-
97
-export default newuser

+ 0
- 102
src/pages/qrcode/qrcodelist/table/visitNum.jsx Ver arquivo

@@ -1,102 +0,0 @@
1
-import React, { useState, useEffect } from 'react';
2
-import { Form, Input, Button, Icon, Select, message, Table, Divider, Tag, Pagination, Modal, DatePicker } from 'antd';
3
-import router from 'umi/router';
4
-import apis from '../../../../services/apis';
5
-import request from '../../../../utils/request';
6
-import AuthButton from '../../../../components/AuthButton';
7
-import WxDictSelect from '@/components/SelectButton/WxDictSelect';
8
-import moment from 'moment';
9
-
10
-const visitNum = props => {
11
-  const [data, setData] = useState({})
12
-
13
-
14
-  useEffect(() => {
15
-    // console.log(activityId, activityType)
16
-    // getList({ pageNum: 1, pageSize: 10 })
17
-
18
-  }, [])
19
-
20
-  const getList = params => {
21
-    // console.log(params)
22
-    // request({ ...apis.activityDataStatis.activityVisitNum, params: { ...params, activityId: activityId, activityType: activityType, ...date } }).then(data => {
23
-    //   console.log(data)
24
-    //   props.getData()
25
-    //   setData(data)
26
-    // }).catch(e => {
27
-    //   console.log(e)
28
-    // })
29
-  }
30
-
31
-
32
-  const columns = [
33
-    {
34
-      title: '姓名',
35
-      dataIndex: 'nickName',
36
-      key: 'nickName',
37
-    },
38
-    {
39
-      title: '电话',
40
-      dataIndex: 'phone',
41
-      key: 'phone',
42
-    },
43
-    {
44
-      title: '性别',
45
-      dataIndex: 'gender',
46
-      key: 'gender',
47
-    },
48
-    {
49
-      title: '归属地',
50
-      dataIndex: 'province',
51
-      key: 'province',
52
-    },
53
-    {
54
-      title: '访问时间',
55
-      dataIndex: 'visitDate',
56
-      key: 'visitDate',
57
-      render: (x, row) => <><span>{`${moment(row.visitDate).format('YYYY-MM-DD HH:mm:ss')}`}</span></>,
58
-    },
59
-  ]
60
-
61
-
62
-  const changePageNum = pageNumber => {
63
-    getList({ pageNum: pageNumber, pageSize: 10, ...props.form.getFieldsValue() })
64
-  }
65
-
66
-
67
-
68
-  const exportActivityStats = () => {
69
-
70
-    request({ ...apis.activityDataStatis.activityVisitNumExport, params: { activityId: activityId, activityType: activityType, ...props.form.getFieldsValue(), ...date } }).then(data => {
71
-      if (!data) {
72
-        return
73
-      }
74
-      const url = window.URL.createObjectURL(new Blob([data]))
75
-      const link = document.createElement('a')
76
-      link.style.display = 'none'
77
-      link.href = url
78
-      link.setAttribute('download', '访问统计.xlsx')
79
-      document.body.append(link)
80
-      link.click()
81
-    }).catch()
82
-  }
83
-
84
-  return <>
85
-    <div>
86
-      <div>
87
-
88
-
89
-        <Button type="primary" style={{ float: 'right', marginBottom: '20px', zIndex: 1 }} onClick={exportActivityStats} >
90
-          导出
91
-            </Button>
92
-
93
-      </div>
94
-      <Table style={{ marginTop: '30px' }} dataSource={data.records} columns={columns} pagination={false} rowKey="activityList" />
95
-      <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
96
-        <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={changePageNum} current={data.current} />
97
-      </div>
98
-    </div>
99
-  </>
100
-}
101
-
102
-export default visitNum

+ 0
- 126
src/pages/qrcode/qrcodelist/table/visitors.jsx Ver arquivo

@@ -1,126 +0,0 @@
1
-import React, { useState, useEffect } from 'react';
2
-import { Form, Input, Button, Icon, Select, message, Table, Divider, Tag, Pagination, Modal, DatePicker } from 'antd';
3
-import router from 'umi/router';
4
-import apis from '../../../../services/apis';
5
-import request from '../../../../utils/request';
6
-import AuthButton from '../../../../components/AuthButton';
7
-import WxDictSelect from '@/components/SelectButton/WxDictSelect';
8
-import moment from 'moment';
9
-
10
-
11
-
12
-const visitors = props => {
13
-
14
-  // const [id,type] = props
15
-
16
-  const [data, setData] = useState({})
17
-
18
-
19
-  useEffect(() => {
20
-
21
-    // getList({ pageNum: 1, pageSize: 10 })
22
-
23
-  }, [])
24
-
25
-  const getList = params => {
26
-    console.log(params)
27
-    // request({ ...apis.activityDataStatis.activityVisitPersonNum, params: { ...params, activityId: activityId, activityType: activityType, ...date } }).then(data => {
28
-    //   console.log(data)
29
-    //   props.getData()
30
-    //   setData(data)
31
-    // }).catch(e => {
32
-    //   console.log(e)
33
-    // })
34
-  }
35
-
36
-  // getTableList () {
37
-
38
-  //   console.log(formData)
39
-  //   request({ ...apis.activityDataStatis.activityVisitPersonNum, params: formData }).then(data => {
40
-  //     console.log(data)
41
-  //     this.setState({ tableData: data.records, total: data.total})
42
-  //   }).catch()
43
-  // }
44
-
45
-  const visitorsa = {
46
-    title: '访问次数',
47
-    dataIndex: 'visitNum',
48
-    key: 'visitNum',
49
-  }
50
-
51
-  const columns = [
52
-    {
53
-      title: '姓名',
54
-      dataIndex: 'nickName',
55
-      key: 'nickName',
56
-    },
57
-    {
58
-      title: '电话',
59
-      dataIndex: 'phone',
60
-      key: 'phone',
61
-    },
62
-    {
63
-      title: '性别',
64
-      dataIndex: 'gender',
65
-      key: 'gender',
66
-    },
67
-    {
68
-      title: '归属地',
69
-      dataIndex: 'province',
70
-      key: 'province',
71
-    },
72
-    visitorsa,
73
-  ]
74
-
75
-  // {
76
-  //   title: '访问时间',
77
-  //   dataIndex: 'visitDate',
78
-  //   key: 'visitDate',
79
-  //   render: (x, row) => <><span>{`${moment(row.visitDate).format('YYYY-MM-DD HH:mm:ss')}`}</span></>,
80
-  // },
81
-
82
-
83
-  const changePageNum = pageNumber => {
84
-    getList({ pageNum: pageNumber, pageSize: 10, ...props.form.getFieldsValue() })
85
-  }
86
-
87
-
88
-
89
-  const exportActivityStats = () => {
90
-
91
-    request({ ...apis.activityDataStatis.activityVisitPersonNumExport, params: { activityId: activityId, activityType: activityType, ...props.form.getFieldsValue(), ...date } }).then(data => {
92
-      if (!data) {
93
-        return
94
-      }
95
-      const url = window.URL.createObjectURL(new Blob([data]))
96
-      const link = document.createElement('a')
97
-      link.style.display = 'none'
98
-      link.href = url
99
-      link.setAttribute('download', '访问统计.xlsx')
100
-      document.body.append(link)
101
-      link.click()
102
-    }).catch()
103
-  }
104
-
105
-
106
-  return <>
107
-    <div >
108
-
109
-      <div>
110
-
111
-
112
-        <Button type="primary" style={{ float: 'right', marginBottom: '20px', zIndex: 1 }} onClick={exportActivityStats}>
113
-          导出
114
-            </Button>
115
-
116
-      </div>
117
-      <Table style={{ marginTop: '30px' }} dataSource={data.records} columns={columns} pagination={false} rowKey="activityList" />
118
-      <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
119
-        <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={changePageNum} current={data.current} />
120
-      </div>
121
-    </div>
122
-  </>
123
-}
124
-
125
-
126
-export default visitors

+ 10
- 0
src/services/apis.js Ver arquivo

@@ -1826,5 +1826,15 @@ export default {
1826 1826
       url: `${prefix}/qrCode/getStatisticData`,
1827 1827
       action: 'admin.qrcode.getStatisticData.get',
1828 1828
     },
1829
+    getStatisticRecord: {
1830
+      method: 'GET',
1831
+      url: `${prefix}/qrCode/getStatisticRecord`,
1832
+      action: 'admin.qrcode.getStatisticRecord.get',
1833
+    },
1834
+    getStatisticRecordExport: {
1835
+      method: 'GET',
1836
+      url: `${prefix}/qrCode/getStatisticRecordExport`,
1837
+      action: 'admin.qrcode.getStatisticRecordExport.get',
1838
+    },
1829 1839
   },
1830 1840
 }