瀏覽代碼

客户 导出数据

魏熙美 5 年之前
父節點
當前提交
4113626e8a

+ 27
- 1
src/pages/customer/customerlist/index.jsx 查看文件

24
  * @returns
24
  * @returns
25
  */
25
  */
26
 function body(props) {
26
 function body(props) {
27
-  const { getFieldDecorator } = props.form
27
+  const { getFieldDecorator, getFieldsValue } = props.form
28
 
28
 
29
   // eslint-disable-next-line react-hooks/rules-of-hooks
29
   // eslint-disable-next-line react-hooks/rules-of-hooks
30
   const [dataSource, setDataSource] = useState({ records: [] })
30
   const [dataSource, setDataSource] = useState({ records: [] })
145
     });
145
     });
146
   }
146
   }
147
 
147
 
148
+  function exportCustomer () {
149
+    const fieldsValue = getFieldsValue()
150
+    request({ ...apis.customer.customerRecommendExport, responseType: 'blob', params: { ...fieldsValue, customerType } })
151
+      .then(response => {
152
+        download(response)
153
+      }).catch(error => {
154
+
155
+      })
156
+  }
157
+
158
+  function download (data) {
159
+    if (!data) {
160
+      return
161
+    }
162
+    const url = window.URL.createObjectURL(new Blob([data]))
163
+    const link = document.createElement('a')
164
+    link.style.display = 'none'
165
+    link.href = url
166
+    link.setAttribute('download', '客户列表.xlsx')
167
+    document.body.append(link)
168
+    link.click()
169
+  }
170
+
148
   const columns = [
171
   const columns = [
149
     {
172
     {
150
       title: '头像',
173
       title: '头像',
289
             </Button>
312
             </Button>
290
         </Form.Item>
313
         </Form.Item>
291
       </Form>
314
       </Form>
315
+      <Button type="primary" onClick={() => exportCustomer()} style={{ float: 'right', margin: '20px 0', zIndex: 1 }}>
316
+        导出
317
+      </Button>
292
 
318
 
293
       <div style={{ margin: '20px 0'}}>
319
       <div style={{ margin: '20px 0'}}>
294
         <AuthButton name="admin.customer.recommend.get" noRight={null}>
320
         <AuthButton name="admin.customer.recommend.get" noRight={null}>

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

442
           </Button>
442
           </Button>
443
           <Button style={{ marginLeft: 8 }} onClick={handleReset}>
443
           <Button style={{ marginLeft: 8 }} onClick={handleReset}>
444
             重置
444
             重置
445
-            </Button>
445
+          </Button>
446
         </Form.Item>
446
         </Form.Item>
447
       </Form>
447
       </Form>
448
-      <Button type="primary" onClick={() => exportIndependen()} style={{ float: 'right', margin: '20px 0' }}>
448
+      <Button type="primary" onClick={() => exportIndependen()} style={{ float: 'right', margin: '20px 0', zIndex: 1 }}>
449
         导出
449
         导出
450
       </Button>
450
       </Button>
451
       <Table rowKey="independentIndex" dataSource={dataSource.records} columns={columns} pagination={{ total: dataSource.total, onChange }} />
451
       <Table rowKey="independentIndex" dataSource={dataSource.records} columns={columns} pagination={{ total: dataSource.total, onChange }} />

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

147
       title: '推荐人',
147
       title: '推荐人',
148
       dataIndex: 'consultantName',
148
       dataIndex: 'consultantName',
149
       key: 'consultantName',
149
       key: 'consultantName',
150
-      render: (_, record) => <><span>{ record.recommendName + " " + record.recommendTel }</span></>,
150
+      render: (_, record) => <><span>{ (record.recommendName !== null ? record.recommendName : '') + " " + (record.recommendTel !== null ? record.recommendTel : '') }</span></>,
151
     },
151
     },
152
     {
152
     {
153
       title: '推荐时间',
153
       title: '推荐时间',
224
             </Button>
224
             </Button>
225
         </Form.Item>
225
         </Form.Item>
226
       </Form>
226
       </Form>
227
-      <Button type="primary" onClick={() => exportRecommendCustomer()} style={{float:'right',margin:'20px 0'}}>
227
+      {/* style={{float:'right',margin:'20px 0'}} */}
228
+      <Button type="primary" onClick={() => exportRecommendCustomer()}>
228
         导出
229
         导出
229
       </Button>
230
       </Button>
230
       <Table rowKey="recommendCustomer" dataSource={dataSource.records} columns={columns} pagination={{ total: dataSource.total, onChange }} />
231
       <Table rowKey="recommendCustomer" dataSource={dataSource.records} columns={columns} pagination={{ total: dataSource.total, onChange }} />

+ 1
- 1
src/pages/customer/report/index.jsx 查看文件

197
         <div >
197
         <div >
198
         </div>
198
         </div>
199
       </Form>
199
       </Form>
200
-      <Button type="primary" onClick={() => exportReport()} style={{ float: 'right', margin: '20px 0' }}>
200
+      <Button type="primary" onClick={() => exportReport()} style={{ float: 'right', margin: '20px 0', zIndex: 1 }}>
201
         导出
201
         导出
202
       </Button>
202
       </Button>
203
       <Table rowKey="report" style={{ marginTop: '40px' }} dataSource={dataSource.records} columns={columns} pagination={{ total: dataSource.total, onChange }} />
203
       <Table rowKey="report" style={{ marginTop: '40px' }} dataSource={dataSource.records} columns={columns} pagination={{ total: dataSource.total, onChange }} />

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

266
       url: `${prefix}/customer/recommend/agents/export`,
266
       url: `${prefix}/customer/recommend/agents/export`,
267
       action: 'admin.customer.recommend.agents.export.get',
267
       action: 'admin.customer.recommend.agents.export.get',
268
     },
268
     },
269
+    customerRecommendExport: { // 导出数据(客户列表)
270
+      method: 'GET',
271
+      url: `${prefix}/customer/recommend/export`,
272
+      action: 'admin.customer.recommend.export.get',
273
+    },
269
   },
274
   },
270
   indexEcharts: {
275
   indexEcharts: {
271
     list:{
276
     list:{