zhoulisen 5 years ago
parent
commit
194ad9b6ee

+ 1
- 2
src/components/SelectButton/QrcodeType.jsx View File

13
     const all = props.all || false
13
     const all = props.all || false
14
 
14
 
15
     const visible = useMemo(() => (props.visible), [props.visible]);
15
     const visible = useMemo(() => (props.visible), [props.visible]);
16
-    console.log(visible, '123213')
17
-
16
+    
18
     const data = [
17
     const data = [
19
         {
18
         {
20
             name: '项目',
19
             name: '项目',

+ 23
- 23
src/pages/qrcode/qrcodelist/add.jsx View File

1
 import React, { useState, useEffect } from 'react';
1
 import React, { useState, useEffect } from 'react';
2
-import { Form, Input, Button, Switch, Icon, Select, Option, message, Table, Divider, Tag, Pagination, Modal, DatePicker, Row, Col } from 'antd';
2
+import { Form, Button, Switch, message } from 'antd';
3
 import router from 'umi/router';
3
 import router from 'umi/router';
4
-import moment from 'moment';
5
-import AuthButton from '@/components/AuthButton';
6
 import BuildSelect from '@/components/SelectButton/BuildSelect2'
4
 import BuildSelect from '@/components/SelectButton/BuildSelect2'
7
 import ChannelSelect from '@/components/SelectButton/channelSelect'
5
 import ChannelSelect from '@/components/SelectButton/channelSelect'
8
 import QrcodeType from '../../../components/SelectButton/QrcodeType'
6
 import QrcodeType from '../../../components/SelectButton/QrcodeType'
10
 import apis from '../../../services/apis';
8
 import apis from '../../../services/apis';
11
 import request from '../../../utils/request';
9
 import request from '../../../utils/request';
12
 
10
 
13
-
14
-
15
 const header = props => {
11
 const header = props => {
16
-
17
-    // const id = props.location.query.id
18
-
19
-    const [data, setData] = useState({})
20
-
12
+    // eslint-disable-next-line react-hooks/rules-of-hooks
21
     const [visible, setVisible] = useState(true)
13
     const [visible, setVisible] = useState(true)
22
 
14
 
15
+    // eslint-disable-next-line react-hooks/rules-of-hooks
23
     const [targetType, setTargetType] = useState()
16
     const [targetType, setTargetType] = useState()
24
 
17
 
18
+    // eslint-disable-next-line react-hooks/rules-of-hooks
25
     const [buildingId, setBuildingId] = useState()
19
     const [buildingId, setBuildingId] = useState()
26
 
20
 
21
+    // eslint-disable-next-line react-hooks/rules-of-hooks
27
     const [targetName, setTargetName] = useState()
22
     const [targetName, setTargetName] = useState()
28
 
23
 
24
+    // eslint-disable-next-line react-hooks/rules-of-hooks
29
     useEffect(() => {
25
     useEffect(() => {
30
 
26
 
31
     }, [])
27
     }, [])
32
 
28
 
33
     function addQrcode(params) {
29
     function addQrcode(params) {
34
-        request({ ...apis.qrcode.add, data: { ...params } }).then((data) => {
30
+        request({ ...apis.qrcode.add, data: { ...params } }).then(() => {
35
             //   setData(data)
31
             //   setData(data)
36
             router.go(-1)
32
             router.go(-1)
37
         }).catch((err) => {
33
         }).catch((err) => {
48
                 if (targetType === 'project') {
44
                 if (targetType === 'project') {
49
                     values.targetId = values.buildingId
45
                     values.targetId = values.buildingId
50
                     values.targetName = targetName
46
                     values.targetName = targetName
51
-                }else{
47
+                } else {
52
                     values.targetId = values.targetName.id
48
                     values.targetId = values.targetName.id
53
                     values.targetName = values.targetName.name
49
                     values.targetName = values.targetName.name
54
                 }
50
                 }
68
     function onTtypeChange(values) {
64
     function onTtypeChange(values) {
69
         console.log(`onTtypeChange to ${values}`);
65
         console.log(`onTtypeChange to ${values}`);
70
         setTargetType(values)
66
         setTargetType(values)
71
-        // props.form.setFields({
72
-        //     targetiId: values.id,
73
-        // })
67
+
68
+        props.form.setFieldsValue({
69
+            targetName: '',
70
+        });
74
     }
71
     }
75
 
72
 
76
     // BuildingChange
73
     // BuildingChange
77
-    function onBuildingChange(values, data) {
78
-        console.log(`onBuildingChange to ${values}`, data);
74
+    function onBuildingChange(values, e) {
75
+        console.log(`onBuildingChange to ${values}`, e);
79
         setBuildingId(values)
76
         setBuildingId(values)
80
-        setTargetName(data.buildingName)
77
+        setTargetName(e.buildingName)
78
+
79
+        props.form.setFieldsValue({
80
+            targetName: '',
81
+        });
81
     }
82
     }
82
 
83
 
83
     // BuildingChange
84
     // BuildingChange
84
-    function onTargetName(values, data) {
85
-        console.log(`onTargetName to ${values}`, data);
85
+    function onTargetName(value, data) {
86
+        console.log(`onTargetName to ${value}`, data);
86
 
87
 
87
     }
88
     }
88
 
89
 
112
                 {targetType !== 'project' && <Form.Item label="二维码内容">
113
                 {targetType !== 'project' && <Form.Item label="二维码内容">
113
                     {getFieldDecorator('targetName', {
114
                     {getFieldDecorator('targetName', {
114
                         rules: [{ required: true, message: '' }],
115
                         rules: [{ required: true, message: '' }],
115
-                    })(<QrText targetType={targetType} buildingId={buildingId} onChange={onTargetName}/>)}
116
+                    })(<QrText targetType={targetType} buildingId={buildingId} onChange={onTargetName} />)}
116
                 </Form.Item>}
117
                 </Form.Item>}
117
                 {targetType === 'project' && <div>
118
                 {targetType === 'project' && <div>
118
                     {getFieldDecorator('targetName')}
119
                     {getFieldDecorator('targetName')}
136
 }
137
 }
137
 
138
 
138
 
139
 
139
-
140
 const WrappedNormalLoginForm = Form.create({ name: 'header' })(header);
140
 const WrappedNormalLoginForm = Form.create({ name: 'header' })(header);
141
-export default WrappedNormalLoginForm
141
+export default WrappedNormalLoginForm

+ 14
- 16
src/pages/qrcode/qrcodelist/components/qrText.jsx View File

12
 const getNewsList = fetch(apis.news.getList)
12
 const getNewsList = fetch(apis.news.getList)
13
 const getSalesBatchList = fetch(apis.house.taSalesBatch)
13
 const getSalesBatchList = fetch(apis.house.taSalesBatch)
14
 
14
 
15
-const name = '324'
16
-
17
-const data = [
18
-    {
19
-        id: '12',
20
-        title: '234',
21
-    },
22
-]
15
+
23
 const qrText = props => {
16
 const qrText = props => {
24
     const {
17
     const {
25
         value,
18
         value,
30
     } = props;
23
     } = props;
31
     const [data, setData] = useState([])
24
     const [data, setData] = useState([])
32
     const [visible, setVisible] = useState(false);
25
     const [visible, setVisible] = useState(false);
33
-    const [info, setInfo] = useState({ title: value });
26
+    const [info, setInfo] = useState({ name: value }, [value]);
34
 
27
 
35
     // activity
28
     // activity
36
     const getActivitiesData = e => getActivities({
29
     const getActivitiesData = e => getActivities({
100
             delete obj['activityName'];
93
             delete obj['activityName'];
101
             obj['id'] = item['groupActivityId'];
94
             obj['id'] = item['groupActivityId'];
102
             delete obj['groupActivityId'];
95
             delete obj['groupActivityId'];
103
-            
96
+
104
             list.push(obj)
97
             list.push(obj)
105
         })
98
         })
106
         setData(list)
99
         setData(list)
124
             obj = item;
117
             obj = item;
125
             obj['id'] = item['drainageId'];
118
             obj['id'] = item['drainageId'];
126
             delete obj['drainageId'];
119
             delete obj['drainageId'];
127
-            
120
+
128
             list.push(obj)
121
             list.push(obj)
129
         })
122
         })
130
         setData(list)
123
         setData(list)
131
-        // updateGroup(buildingId ? undefined : value);
132
     })
124
     })
133
 
125
 
134
     //  live
126
     //  live
152
             list.push(obj)
144
             list.push(obj)
153
         })
145
         })
154
 
146
 
155
-        
147
+
156
         setData(list)
148
         setData(list)
157
     })
149
     })
158
 
150
 
178
             list.push(obj)
170
             list.push(obj)
179
         })
171
         })
180
 
172
 
181
-        
173
+
182
         setData(list)
174
         setData(list)
183
     })
175
     })
184
 
176
 
207
         // salesBatchNamesalesBatchId
199
         // salesBatchNamesalesBatchId
208
     })
200
     })
209
 
201
 
210
-    // getNewsList
202
+    useEffect(() => {
203
+        console.log(value, '23423333333334')
204
+        // eslint-disable-next-line default-case
205
+        setInfo({ name: value })
206
+    }, [value])
211
 
207
 
208
+    // getNewsList
212
     useEffect(() => {
209
     useEffect(() => {
213
         console.log(targetType, buildingId, '234234')
210
         console.log(targetType, buildingId, '234234')
214
         // eslint-disable-next-line default-case
211
         // eslint-disable-next-line default-case
244
     }
241
     }
245
 
242
 
246
     const onChoice = e => {
243
     const onChoice = e => {
244
+        console.log(e)
247
         setInfo(e)
245
         setInfo(e)
248
         setVisible(false)
246
         setVisible(false)
249
-        onChange(e)
247
+        props.onChange(e.name, e)
250
     }
248
     }
251
 
249
 
252
     const columns = [
250
     const columns = [

+ 48
- 16
src/pages/qrcode/qrcodelist/index.jsx View File

1
 import React, { useState, useEffect } from 'react';
1
 import React, { useState, useEffect } from 'react';
2
-import { Form, Input, Button, Icon, Select, message, Table, Divider, Tag, Pagination, Modal, DatePicker, notification } from 'antd';
2
+import { Form, Input, Button, Icon, message, Table, Pagination, Modal } from 'antd';
3
 import router from 'umi/router';
3
 import router from 'umi/router';
4
 import moment from 'moment';
4
 import moment from 'moment';
5
 import AuthButton from '@/components/AuthButton';
5
 import AuthButton from '@/components/AuthButton';
6
 import withActions from '@/components/ActionList';
6
 import withActions from '@/components/ActionList';
7
 import EditIcon from '@/components/EditIcon';
7
 import EditIcon from '@/components/EditIcon';
8
-import Navigate from '@/components/Navigate';
9
 import QrcodeType from '@/components/SelectButton/QrcodeType'
8
 import QrcodeType from '@/components/SelectButton/QrcodeType'
10
 import { ConfirmButton } from '@/components/ModalButton';
9
 import { ConfirmButton } from '@/components/ModalButton';
11
 import BuildSelect from '@/components/SelectButton/BuildSelect'
10
 import BuildSelect from '@/components/SelectButton/BuildSelect'
14
 import request from '../../../utils/request';
13
 import request from '../../../utils/request';
15
 
14
 
16
 // import RaiseHelpDoc from '../edit/components/RaiseHelpDoc';
15
 // import RaiseHelpDoc from '../edit/components/RaiseHelpDoc';
16
+// eslint-disable-next-line consistent-return
17
 const typeName = targetType => {
17
 const typeName = targetType => {
18
     // eslint-disable-next-line default-case
18
     // eslint-disable-next-line default-case
19
     switch (targetType) {
19
     switch (targetType) {
36
 
36
 
37
     // eslint-disable-next-line react-hooks/rules-of-hooks
37
     // eslint-disable-next-line react-hooks/rules-of-hooks
38
     useEffect(() => {
38
     useEffect(() => {
39
+        // eslint-disable-next-line @typescript-eslint/no-use-before-define
40
+        // eslint-disable-next-line no-use-before-define
39
         getList({ pageNum: 1, pageSize: 10 });
41
         getList({ pageNum: 1, pageSize: 10 });
40
     }, [])
42
     }, [])
41
 
43
 
48
     }
50
     }
49
 
51
 
50
     const batchDelete = () => {
52
     const batchDelete = () => {
51
-        request({ ...apis.qrcode.batchDelete, data: qrcodeList }).then(data => {
53
+        request({ ...apis.qrcode.batchDelete, data: qrcodeList }).then(() => {
52
             message.info('操作成功')
54
             message.info('操作成功')
53
             setBeforeCheck('请至少选择一条数据')
55
             setBeforeCheck('请至少选择一条数据')
54
             getList({ pageNum: 1, pageSize: 10 });
56
             getList({ pageNum: 1, pageSize: 10 });
55
-        }).catch((err) => {
57
+        }).catch(() => {
56
             // message.info(err.msg)
58
             // message.info(err.msg)
57
         })
59
         })
58
     }
60
     }
64
         });
66
         });
65
     }
67
     }
66
 
68
 
67
-    const toDataRecord = (id) => {
69
+    const toDataRecord = id => {
70
+        // eslint-disable-next-line no-console
68
         console.log(id)
71
         console.log(id)
69
         router.push({
72
         router.push({
70
             pathname: '/qrcode/qrcodelist/dataRecord',
73
             pathname: '/qrcode/qrcodelist/dataRecord',
71
-            query: { id, }
74
+            query: { id },
72
         });
75
         });
73
     }
76
     }
74
 
77
 
78
+    const downloadQrcode = row => {
79
+        const x = new XMLHttpRequest();
80
+        const resourceUrl = row.qrCodeUrl
81
+        // const name = `${row.targetName}二维码.png`
82
+        console.log(resourceUrl);
83
+        x.open('GET', resourceUrl, true);
84
+        x.responseType = 'blob';
85
+        x.onload = function (e) {
86
+            const url = window.URL.createObjectURL(x.response)
87
+            const a = document.createElement('a');
88
+            a.href = url;
89
+            a.style.display = 'none'
90
+            a.download = `${row.targetName}二维码.png`
91
+            a.click();
92
+        }
93
+        x.send();
94
+    }
95
+
75
     /**
96
     /**
76
      *
97
      *
77
      *
98
      *
126
             dataIndex: '',
147
             dataIndex: '',
127
             key: '',
148
             key: '',
128
             align: 'center',
149
             align: 'center',
129
-            render: withActions((text, record) => [
130
-                <EditIcon type="download" text="下载二维码" ></EditIcon>,
131
-
132
-                <EditIcon type="data" text="数据" onClick={() => toDataRecord(record.qrCodeId)} ></EditIcon>,
150
+            render: withActions((text, row) => [
151
+                <AuthButton name="admin.qrcode.download" noRight={null}>
152
+                    <EditIcon type="download" text="下载二维码" onClick={() => downloadQrcode(row)}> </EditIcon>
153
+                </AuthButton>,
154
+                <AuthButton name="admin.qrcode.dataRecord" noRight={null}>
155
+                    <EditIcon type="data" text="数据" onClick={() => toDataRecord(row.qrCodeId)} ></EditIcon>
156
+                </AuthButton>,
157
+                
133
 
158
 
134
             ]),
159
             ]),
135
         },
160
         },
141
     }
166
     }
142
 
167
 
143
 
168
 
144
-
145
     const rowSelection = {
169
     const rowSelection = {
146
         onChange: (selectedRowKeys, selectedRows) => {
170
         onChange: (selectedRowKeys, selectedRows) => {
147
             console.log('selectedRowKeys:', selectedRowKeys, 'selectedRows: ', selectedRows);
171
             console.log('selectedRowKeys:', selectedRowKeys, 'selectedRows: ', selectedRows);
205
                 </Form.Item>
229
                 </Form.Item>
206
             </Form>
230
             </Form>
207
             {/* title="确认删除?" */}
231
             {/* title="确认删除?" */}
208
-            <Button type="danger" onClick={() => toAdd()}>新增</Button>
209
-            <ConfirmButton type="link" title="确认删除选中数据?" beforeCheck={beforeCheck} onClick={() => batchDelete()}>
210
-                <Button type="primary" style={{ marginLeft: '30px' }}>删除</Button>
211
-            </ConfirmButton>
232
+
233
+            <AuthButton name="admin.qrcode.add" noRight={null}>
234
+                <Button type="danger" onClick={() => toAdd()}>新增</Button>
235
+            </AuthButton>
236
+            <AuthButton name="admin.qrcode.delete" noRight={null}>
237
+                <ConfirmButton type="link" title="确认删除选中数据?" beforeCheck={beforeCheck} onClick={() => batchDelete()}>
238
+                    <Button type="primary" style={{ marginLeft: '30px' }}>删除</Button>
239
+                </ConfirmButton>
240
+            </AuthButton>
212
             <Icon type="question-circle" theme="filled" style={{ fontSize: '25px', color: '#F00', marginLeft: '30px' }} onClick={() => setShowHelp(true)} />
241
             <Icon type="question-circle" theme="filled" style={{ fontSize: '25px', color: '#F00', marginLeft: '30px' }} onClick={() => setShowHelp(true)} />
213
             <Modal
242
             <Modal
214
                 title="相关说明"
243
                 title="相关说明"
228
             <Table rowSelection={rowSelection}
257
             <Table rowSelection={rowSelection}
229
                 dataSource={data.records} columns={columns} pagination={false} rowKey={r => r.qrCodeId} style={{ marginTop: '20px' }} />
258
                 dataSource={data.records} columns={columns} pagination={false} rowKey={r => r.qrCodeId} style={{ marginTop: '20px' }} />
230
             <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
259
             <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
231
-                <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={e => changePageNum(e)} current={data.current} />
260
+                <Pagination
261
+                    showQuickJumper
262
+                    defaultCurrent={1}
263
+                    total={data.total} onChange={e => changePageNum(e)} current={data.current} />
232
             </div>
264
             </div>
233
         </>
265
         </>
234
     )
266
     )

+ 3
- 5
src/pages/qrcode/qrcodelist/table/index.jsx View File

1
 import React, { useState, useEffect } from 'react';
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';
2
+import { Button, Table, Pagination } from 'antd';
3
+import moment from 'moment';
4
 import apis from '../../../../services/apis';
4
 import apis from '../../../../services/apis';
5
 import request from '../../../../utils/request';
5
 import request from '../../../../utils/request';
6
 import AuthButton from '../../../../components/AuthButton';
6
 import AuthButton from '../../../../components/AuthButton';
7
-import WxDictSelect from '@/components/SelectButton/WxDictSelect';
8
-import moment from 'moment';
9
 
7
 
10
 const table = props => {
8
 const table = props => {
11
     const { id, type } = props
9
     const { id, type } = props
23
         request({ ...apis.qrcode.getStatisticRecord, params: { ...params } }).then(data => {
21
         request({ ...apis.qrcode.getStatisticRecord, params: { ...params } }).then(data => {
24
             console.log(data)
22
             console.log(data)
25
 
23
 
26
-            //   setData(data)
24
+            setData(data)
27
         }).catch(e => {
25
         }).catch(e => {
28
             console.log(e)
26
             console.log(e)
29
         })
27
         })

+ 2
- 2
src/services/apis.js View File

1844
     add: {
1844
     add: {
1845
       method: 'post',
1845
       method: 'post',
1846
       url: `${prefix}/taQrcode`,
1846
       url: `${prefix}/taQrcode`,
1847
-      action: 'admin.qrcode.add.post',
1847
+      action: 'admin.qrcode.add',
1848
     },
1848
     },
1849
     batchDelete: {
1849
     batchDelete: {
1850
       method: 'DELETE',
1850
       method: 'DELETE',
1851
       url: `${prefix}/qrCode/batchDelete`,
1851
       url: `${prefix}/qrCode/batchDelete`,
1852
-      action: 'admin.qrcode.batchDelete.DELETE',
1852
+      action: 'admin.qrcode.delete',
1853
     },
1853
     },
1854
     getStatisticData: {
1854
     getStatisticData: {
1855
       method: 'GET',
1855
       method: 'GET',