zhoulisen 5 年之前
父節點
當前提交
194ad9b6ee

+ 1
- 2
src/components/SelectButton/QrcodeType.jsx 查看文件

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

+ 23
- 23
src/pages/qrcode/qrcodelist/add.jsx 查看文件

@@ -1,8 +1,6 @@
1 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 3
 import router from 'umi/router';
4
-import moment from 'moment';
5
-import AuthButton from '@/components/AuthButton';
6 4
 import BuildSelect from '@/components/SelectButton/BuildSelect2'
7 5
 import ChannelSelect from '@/components/SelectButton/channelSelect'
8 6
 import QrcodeType from '../../../components/SelectButton/QrcodeType'
@@ -10,28 +8,26 @@ import QrText from './components/qrText'
10 8
 import apis from '../../../services/apis';
11 9
 import request from '../../../utils/request';
12 10
 
13
-
14
-
15 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 13
     const [visible, setVisible] = useState(true)
22 14
 
15
+    // eslint-disable-next-line react-hooks/rules-of-hooks
23 16
     const [targetType, setTargetType] = useState()
24 17
 
18
+    // eslint-disable-next-line react-hooks/rules-of-hooks
25 19
     const [buildingId, setBuildingId] = useState()
26 20
 
21
+    // eslint-disable-next-line react-hooks/rules-of-hooks
27 22
     const [targetName, setTargetName] = useState()
28 23
 
24
+    // eslint-disable-next-line react-hooks/rules-of-hooks
29 25
     useEffect(() => {
30 26
 
31 27
     }, [])
32 28
 
33 29
     function addQrcode(params) {
34
-        request({ ...apis.qrcode.add, data: { ...params } }).then((data) => {
30
+        request({ ...apis.qrcode.add, data: { ...params } }).then(() => {
35 31
             //   setData(data)
36 32
             router.go(-1)
37 33
         }).catch((err) => {
@@ -48,7 +44,7 @@ const header = props => {
48 44
                 if (targetType === 'project') {
49 45
                     values.targetId = values.buildingId
50 46
                     values.targetName = targetName
51
-                }else{
47
+                } else {
52 48
                     values.targetId = values.targetName.id
53 49
                     values.targetName = values.targetName.name
54 50
                 }
@@ -68,21 +64,26 @@ const header = props => {
68 64
     function onTtypeChange(values) {
69 65
         console.log(`onTtypeChange to ${values}`);
70 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 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 76
         setBuildingId(values)
80
-        setTargetName(data.buildingName)
77
+        setTargetName(e.buildingName)
78
+
79
+        props.form.setFieldsValue({
80
+            targetName: '',
81
+        });
81 82
     }
82 83
 
83 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,7 +113,7 @@ const header = props => {
112 113
                 {targetType !== 'project' && <Form.Item label="二维码内容">
113 114
                     {getFieldDecorator('targetName', {
114 115
                         rules: [{ required: true, message: '' }],
115
-                    })(<QrText targetType={targetType} buildingId={buildingId} onChange={onTargetName}/>)}
116
+                    })(<QrText targetType={targetType} buildingId={buildingId} onChange={onTargetName} />)}
116 117
                 </Form.Item>}
117 118
                 {targetType === 'project' && <div>
118 119
                     {getFieldDecorator('targetName')}
@@ -136,6 +137,5 @@ const header = props => {
136 137
 }
137 138
 
138 139
 
139
-
140 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 查看文件

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

+ 48
- 16
src/pages/qrcode/qrcodelist/index.jsx 查看文件

@@ -1,11 +1,10 @@
1 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 3
 import router from 'umi/router';
4 4
 import moment from 'moment';
5 5
 import AuthButton from '@/components/AuthButton';
6 6
 import withActions from '@/components/ActionList';
7 7
 import EditIcon from '@/components/EditIcon';
8
-import Navigate from '@/components/Navigate';
9 8
 import QrcodeType from '@/components/SelectButton/QrcodeType'
10 9
 import { ConfirmButton } from '@/components/ModalButton';
11 10
 import BuildSelect from '@/components/SelectButton/BuildSelect'
@@ -14,6 +13,7 @@ import apis from '../../../services/apis';
14 13
 import request from '../../../utils/request';
15 14
 
16 15
 // import RaiseHelpDoc from '../edit/components/RaiseHelpDoc';
16
+// eslint-disable-next-line consistent-return
17 17
 const typeName = targetType => {
18 18
     // eslint-disable-next-line default-case
19 19
     switch (targetType) {
@@ -36,6 +36,8 @@ const qrcodelist = props => {
36 36
 
37 37
     // eslint-disable-next-line react-hooks/rules-of-hooks
38 38
     useEffect(() => {
39
+        // eslint-disable-next-line @typescript-eslint/no-use-before-define
40
+        // eslint-disable-next-line no-use-before-define
39 41
         getList({ pageNum: 1, pageSize: 10 });
40 42
     }, [])
41 43
 
@@ -48,11 +50,11 @@ const qrcodelist = props => {
48 50
     }
49 51
 
50 52
     const batchDelete = () => {
51
-        request({ ...apis.qrcode.batchDelete, data: qrcodeList }).then(data => {
53
+        request({ ...apis.qrcode.batchDelete, data: qrcodeList }).then(() => {
52 54
             message.info('操作成功')
53 55
             setBeforeCheck('请至少选择一条数据')
54 56
             getList({ pageNum: 1, pageSize: 10 });
55
-        }).catch((err) => {
57
+        }).catch(() => {
56 58
             // message.info(err.msg)
57 59
         })
58 60
     }
@@ -64,14 +66,33 @@ const qrcodelist = props => {
64 66
         });
65 67
     }
66 68
 
67
-    const toDataRecord = (id) => {
69
+    const toDataRecord = id => {
70
+        // eslint-disable-next-line no-console
68 71
         console.log(id)
69 72
         router.push({
70 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,10 +147,14 @@ const qrcodelist = props => {
126 147
             dataIndex: '',
127 148
             key: '',
128 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,7 +166,6 @@ const qrcodelist = props => {
141 166
     }
142 167
 
143 168
 
144
-
145 169
     const rowSelection = {
146 170
         onChange: (selectedRowKeys, selectedRows) => {
147 171
             console.log('selectedRowKeys:', selectedRowKeys, 'selectedRows: ', selectedRows);
@@ -205,10 +229,15 @@ const qrcodelist = props => {
205 229
                 </Form.Item>
206 230
             </Form>
207 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 241
             <Icon type="question-circle" theme="filled" style={{ fontSize: '25px', color: '#F00', marginLeft: '30px' }} onClick={() => setShowHelp(true)} />
213 242
             <Modal
214 243
                 title="相关说明"
@@ -228,7 +257,10 @@ const qrcodelist = props => {
228 257
             <Table rowSelection={rowSelection}
229 258
                 dataSource={data.records} columns={columns} pagination={false} rowKey={r => r.qrCodeId} style={{ marginTop: '20px' }} />
230 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 264
             </div>
233 265
         </>
234 266
     )

+ 3
- 5
src/pages/qrcode/qrcodelist/table/index.jsx 查看文件

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

+ 2
- 2
src/services/apis.js 查看文件

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