소스 검색

导出数据

魏熙美 5 년 전
부모
커밋
e4a3bca324
4개의 변경된 파일46개의 추가작업 그리고 6개의 파일을 삭제
  1. 20
    1
      src/pages/customer/independentList/index.jsx
  2. 4
    5
      src/pages/customer/recommendCustomer/index.jsx
  3. 20
    0
      src/pages/customer/report/index.jsx
  4. 2
    0
      src/utils/request.js

+ 20
- 1
src/pages/customer/independentList/index.jsx 파일 보기

@@ -332,6 +332,23 @@ function body(props) {
332 332
     })
333 333
   }
334 334
 
335
+  function exportIndependen() {
336
+
337
+  }
338
+
339
+  function download(data) {
340
+    if (!data) {
341
+      return
342
+    }
343
+    const url = window.URL.createObjectURL(new Blob([data]))
344
+    const link = document.createElement('a')
345
+    link.style.display = 'none'
346
+    link.href = url
347
+    link.setAttribute('download', '经纪人.xlsx')
348
+    document.body.append(link)
349
+    link.click()
350
+  }
351
+
335 352
   const columns = [
336 353
     {
337 354
       title: '头像',
@@ -415,7 +432,9 @@ function body(props) {
415 432
             </Button>
416 433
         </Form.Item>
417 434
       </Form>
418
-
435
+      <Button type="primary" onClick={() => exportIndependen()} className={Styles.SubmitButton} style={{ marginTop: '5px', marginBottom: '5px', display: 'none' }}>
436
+        导出数据
437
+      </Button>
419 438
       <Table dataSource={dataSource.records} columns={columns} pagination={{ total: dataSource.total, onChange }} />
420 439
             {/* 调整归属 */}
421 440
         <ModalTable visibleData={gVisibleData} />

+ 4
- 5
src/pages/customer/recommendCustomer/index.jsx 파일 보기

@@ -6,7 +6,6 @@ import apis from '../../../services/apis';
6 6
 import Styles from './style.less';
7 7
 import { router } from 'umi';
8 8
 import AuthButton from '@/components/AuthButton';
9
-import axios from 'umi-request';
10 9
 
11 10
 
12 11
 const { Option } = Select;
@@ -83,8 +82,9 @@ function body(props) {
83 82
    *
84 83
    */
85 84
   function exportRecommendCustomer() {
86
-    axios(apis.customer.customerRecommendRecommenderExport.url, {
87
-      ...apis.customer.customerRecommendRecommenderExport, responseType: 'blob',
85
+    request({
86
+      ...apis.customer.customerRecommendRecommenderExport, 
87
+      responseType: 'blob',
88 88
     }).then(response => {
89 89
       // console.log('response: ', response)
90 90
       download(response)
@@ -213,10 +213,9 @@ function body(props) {
213 213
             </Button>
214 214
         </Form.Item>
215 215
       </Form>
216
-      <Button type="primary" onClick={() => exportRecommendCustomer()} className={Styles.SubmitButton} style={{ marginTop: '5px', marginBottom: '5px' }}>
216
+      <Button type="primary" onClick={() => exportRecommendCustomer()} className={Styles.SubmitButton} style={{ marginTop: '5px', marginBottom: '5px', display: 'none' }}>
217 217
         导出数据
218 218
       </Button>
219
-
220 219
       <Table dataSource={dataSource.records} columns={columns} pagination={{ total: dataSource.total, onChange }} />
221 220
     </>
222 221
   );

+ 20
- 0
src/pages/customer/report/index.jsx 파일 보기

@@ -70,6 +70,23 @@ function body(props) {
70 70
       getList({ pageNumber: pageNum, pageSize: 9 })
71 71
   }
72 72
 
73
+  function exportReport() {
74
+
75
+  }
76
+
77
+  function download(data) {
78
+    if (!data) {
79
+      return
80
+    }
81
+    const url = window.URL.createObjectURL(new Blob([data]))
82
+    const link = document.createElement('a')
83
+    link.style.display = 'none'
84
+    link.href = url
85
+    link.setAttribute('download', '报备客户.xlsx')
86
+    document.body.append(link)
87
+    link.click()
88
+  }
89
+
73 90
   const columns = [
74 91
     {
75 92
       title: '头像',
@@ -159,6 +176,9 @@ function body(props) {
159 176
             </Button>
160 177
         </Form.Item>
161 178
       </Form>
179
+      <Button type="primary" onClick={() => exportReport()} className={Styles.SubmitButton} style={{ marginTop: '5px', marginBottom: '5px', display: 'none' }}>
180
+        导出数据
181
+      </Button>
162 182
       <Table style={{marginTop:'40px'}} dataSource={dataSource.records} columns={columns} pagination={{ total: dataSource.total, onChange }} />
163 183
     </>
164 184
   );

+ 2
- 0
src/utils/request.js 파일 보기

@@ -75,6 +75,8 @@ request.interceptors.response.use(async (response, options) => {
75 75
       });
76 76
       throw new Error(response.statusText);
77 77
     } else {
78
+      console.log('response: ', response)
79
+      console.log('response.headers: ', response.headers)
78 80
       const { code, data, message } = await response.clone().json();
79 81
       if (code != 1000) {
80 82
         notification.error({