zhoulisen hace 5 años
padre
commit
675b65190c
Se han modificado 1 ficheros con 70 adiciones y 37 borrados
  1. 70
    37
      src/pages/channel/newCustomer/index.jsx

+ 70
- 37
src/pages/channel/newCustomer/index.jsx Ver fichero

15
 
15
 
16
 // import RaiseHelpDoc from '../edit/components/RaiseHelpDoc';
16
 // import RaiseHelpDoc from '../edit/components/RaiseHelpDoc';
17
 
17
 
18
+
18
 const { RangePicker } = DatePicker
19
 const { RangePicker } = DatePicker
19
 
20
 
20
 const qrcodelist = props => {
21
 const qrcodelist = props => {
21
     const { id, name, customerNum } = props.location.query
22
     const { id, name, customerNum } = props.location.query
22
     const [data, setData] = useState([])
23
     const [data, setData] = useState([])
23
     const [showHelp, setShowHelp] = useState(false)
24
     const [showHelp, setShowHelp] = useState(false)
25
+    const [endDate, setEndDate] = useState(new Date())
26
+    const [startDate, setStartDate] = useState(moment().subtract(7, 'day').toDate())
27
+
24
 
28
 
25
     // 查询列表
29
     // 查询列表
26
-      const getList = params => {
27
-        request({ ...apis.channelList.getIntroductionList, params: { ...params,channelId: id } }).then(data => {
28
-          console.log(data)
29
-          setData(data)
30
+    const getList = params => {
31
+        request({ ...apis.channelList.getIntroductionList, params: { ...params, channelId: id } }).then(data => {
32
+            console.log(data)
33
+            setData(data)
30
         })
34
         })
31
-      }
35
+    }
32
 
36
 
33
     // eslint-disable-next-line react-hooks/rules-of-hooks
37
     // eslint-disable-next-line react-hooks/rules-of-hooks
34
-      useEffect(() => {
35
-        getList({ pageNum: 1, pageSize: 10 });
36
-      }, [])
38
+    useEffect(() => {
39
+        setEndDate(new Date())
40
+        setStartDate(moment().subtract(7, 'day').toDate())
41
+        getList({ pageNum: 1, pageSize: 10, startDate, endDate });
42
+    }, [])
37
 
43
 
38
 
44
 
39
     const toNewuser = (record) => {
45
     const toNewuser = (record) => {
46
                 targetType: record.targetType,
52
                 targetType: record.targetType,
47
                 buildingId: record.buildingId,
53
                 buildingId: record.buildingId,
48
                 newCustomers: record.newCustomers,
54
                 newCustomers: record.newCustomers,
49
-              },
55
+            },
50
         });
56
         });
51
     }
57
     }
52
 
58
 
60
                 targetType: record.targetType,
66
                 targetType: record.targetType,
61
                 buildingId: record.buildingId,
67
                 buildingId: record.buildingId,
62
                 visitNum: record.visitNum,
68
                 visitNum: record.visitNum,
63
-              },
69
+            },
64
         });
70
         });
65
     }
71
     }
66
 
72
 
74
                 targetType: record.targetType,
80
                 targetType: record.targetType,
75
                 buildingId: record.buildingId,
81
                 buildingId: record.buildingId,
76
                 visitPersons: record.visitPersons,
82
                 visitPersons: record.visitPersons,
77
-              },
83
+            },
78
         });
84
         });
79
     }
85
     }
80
 
86
 
131
     ];
137
     ];
132
 
138
 
133
 
139
 
134
-      const changePageNum = pageNumber => {
140
+    const changePageNum = pageNumber => {
135
         getList({ pageNum: pageNumber, pageSize: 10, ...props.form.getFieldsValue() })
141
         getList({ pageNum: pageNumber, pageSize: 10, ...props.form.getFieldsValue() })
136
-      }
142
+    }
137
 
143
 
138
 
144
 
139
     // 提交事件
145
     // 提交事件
140
     const handleSubmit = e => {
146
     const handleSubmit = e => {
141
         e.preventDefault();
147
         e.preventDefault();
148
+
142
         props.form.validateFields((err, values) => {
149
         props.form.validateFields((err, values) => {
143
             if (!err) {
150
             if (!err) {
144
                 console.log(values, 'values')
151
                 console.log(values, 'values')
145
-                getList({ pageNum: 1, pageSize: 10, ...values })
152
+                getList({ pageNum: 1, pageSize: 10, ...values, startDate, endDate })
146
             }
153
             }
147
         });
154
         });
148
     }
155
     }
150
     //   // 重置搜索
157
     //   // 重置搜索
151
     function handleReset() {
158
     function handleReset() {
152
         props.form.resetFields();
159
         props.form.resetFields();
153
-        setTime('')
154
-        getList({ pageNum: 1, pageSize: 10 })
160
+        setEndDate(new Date())
161
+        setStartDate(moment().subtract(7, 'day').toDate())
162
+        getList({ pageNum: 1, pageSize: 10, startDate: moment().subtract(7, 'day').toDate(), endDate: new Date() })
163
+    }
164
+
165
+    function onChangetime(dates, dateStrings) {
166
+        setEndDate(`${moment(dateStrings[1]).format('YYYY-MM-DDT00:00:00.000')}Z`)
167
+        setStartDate(`${moment(dateStrings[0]).format('YYYY-MM-DDT00:00:00.000')}Z`)
168
+        // daterange[1] = `${moment(dateStrings[1]).format('YYYY-MM-DDT00:00:00.000')}Z`
169
+        // daterange[0] = `${moment(dateStrings[0]).format('YYYY-MM-DDT00:00:00.000')}Z`
170
+
171
+    }
172
+
173
+    const getDataOf = days => {
174
+
175
+        setEndDate(new Date())
176
+        setStartDate(moment().subtract(days, 'day').toDate())
177
+
178
+        getList({ pageNum: 1, pageSize: 10, startDate: moment().subtract(days, 'day').toDate(), endDate: new Date() })
179
+        // userResource({ startDate: moment().subtract(days, 'day').toDate(), endDate: new Date() })
155
     }
180
     }
156
 
181
 
182
+    const dateRange = [moment(startDate), moment(endDate)]
183
+
157
     const { getFieldDecorator } = props.form
184
     const { getFieldDecorator } = props.form
158
     return (
185
     return (
159
 
186
 
184
             </Modal>
211
             </Modal>
185
             <Form layout="inline" style={{ marginBottom: '10px' }} onSubmit={e => handleSubmit(e)}>
212
             <Form layout="inline" style={{ marginBottom: '10px' }} onSubmit={e => handleSubmit(e)}>
186
                 <Form.Item>
213
                 <Form.Item>
187
-                    <Radio.Group buttonStyle="solid" value="a">
214
+                    {getFieldDecorator('state', {
215
+                        initialValue: 'a'
216
+                    })(
217
+                        <Radio.Group buttonStyle="solid" defaultValue="a" >
218
+                            <Radio.Button value="a" onClick={() => getDataOf(7)}>最近7天</Radio.Button>
219
+                            <Radio.Button value="b" onClick={() => getDataOf(30)}>最近1月</Radio.Button>
220
+                        </Radio.Group>,
221
+                    )}
188
 
222
 
189
-                        <Radio.Button value="a" onClick={e => handleSubmit(e)}>最近7天</Radio.Button>
190
-                        <Radio.Button value="b" onClick={e => handleSubmit(e)}>最近1月</Radio.Button>
191
-                    </Radio.Group>
192
                 </Form.Item>
223
                 </Form.Item>
224
+                {/* <Form.Item>
225
+                        <RangePicker value={dateRange} onChange={handleDateChange} placeholder={['开始日期', '结束日期']} />
226
+                    </Form.Item> */}
193
                 <Form.Item>
227
                 <Form.Item>
194
-                    {getFieldDecorator('time', {
195
-                        initialValue: [],
196
-                    })(
197
-                        <RangePicker
198
-                            style={{ paddingLeft: '30px' }}
199
-                            ranges={{
200
-                                Today: [moment(), moment()],
201
-                                'This Month': [moment().startOf('month'), moment().endOf('month')],
202
-                            }}
203
-                        // onChange={(_dates, dateStrings) => onChangetime(_dates, dateStrings)}
204
-                        />,
205
-                    )}
228
+
229
+                    <RangePicker
230
+                        ranges={{
231
+                            Today: [moment(), moment()],
232
+                            'This Month': [moment().startOf('month'), moment().endOf('month')],
233
+                        }}
234
+                        value={dateRange}
235
+                        onChange={(_dates, dateStrings) => onChangetime(_dates, dateStrings)}
236
+                        allowClear={false}
237
+                    />,
238
+
206
                 </Form.Item>
239
                 </Form.Item>
207
                 <Form.Item>
240
                 <Form.Item>
208
-                    {getFieldDecorator('build')(
241
+                    {getFieldDecorator('buildingId')(
209
                         <BuildSelect style={{ width: '200px' }} />,
242
                         <BuildSelect style={{ width: '200px' }} />,
210
                     )}
243
                     )}
211
                 </Form.Item>
244
                 </Form.Item>
212
                 <Form.Item>
245
                 <Form.Item>
213
-                    {getFieldDecorator('qrcodetype')(
214
-                        <QrcodeType all visible/>,
246
+                    {getFieldDecorator('targetType')(
247
+                        <QrcodeType all visible />,
215
                     )}
248
                     )}
216
                 </Form.Item>
249
                 </Form.Item>
217
                 <Form.Item>
250
                 <Form.Item>
222
             <Button type="primary" style={{ float: 'right', marginBottom: '20px', zIndex: 1 }} onClick={() => { }}>导出</Button>
255
             <Button type="primary" style={{ float: 'right', marginBottom: '20px', zIndex: 1 }} onClick={() => { }}>导出</Button>
223
             <Table dataSource={data.records} columns={columns} pagination={false} rowKey={r => r.serialNo} />
256
             <Table dataSource={data.records} columns={columns} pagination={false} rowKey={r => r.serialNo} />
224
             <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
257
             <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
225
-        <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={e => changePageNum(e)} current={data.current}/>
226
-      </div>
258
+                <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={e => changePageNum(e)} current={data.current} />
259
+            </div>
227
         </>
260
         </>
228
     )
261
     )
229
 }
262
 }