Browse Source

fix(compiler): 零售报备列表新增导出功能

shylock 11 months ago
parent
commit
23b9faa922
2 changed files with 48 additions and 1 deletions
  1. 36 1
      src/pages/ReportHomeManagement/index.tsx
  2. 12 0
      src/services/reportHome.ts

+ 36 - 1
src/pages/ReportHomeManagement/index.tsx

@@ -1,10 +1,16 @@
 import React, { useEffect, useState } from 'react';
 import { Button, Card, Form, Input, message, Modal, Space, Table } from 'antd';
-import { PlusCircleOutlined, ReloadOutlined, SearchOutlined } from '@ant-design/icons';
+import {
+  PlusCircleOutlined,
+  CloudDownloadOutlined,
+  ReloadOutlined,
+  SearchOutlined,
+} from '@ant-design/icons';
 import { PageContainer } from '@ant-design/pro-components';
 import type { ColumnsType } from 'antd/es/table';
 import Edit from './edit';
 import {
+  queryExport,
   queryReportHome,
   queryReportHomeDetail,
   reportHomeAbandon,
@@ -108,6 +114,25 @@ const CommunityManagement: React.FC = () => {
     setCheckVisible(false);
   };
 
+  // 导出
+  const onDownLoad = () => {
+    form.validateFields().then((data) => {
+      queryExport(data)
+        .then((res: any) => {
+          const link = document.createElement('a');
+          link.style.display = 'none';
+          link.href = window.URL.createObjectURL(new Blob([res]));
+          link.setAttribute('download', '零售报备列表.xlsx');
+          document.body.appendChild(link);
+          link.click();
+          document.body.removeChild(link);
+        })
+        .catch(() => {
+          message.error('导出失败');
+        });
+    });
+  };
+
   // 成交
   const toDeal = (record: any) => {
     Modal.confirm({
@@ -178,6 +203,12 @@ const CommunityManagement: React.FC = () => {
       title: '门牌号',
       dataIndex: 'doorplate',
       key: 'doorplate',
+      render: (_, res: any) =>
+        res && (
+          <span>
+            {res?.building}-{res?.unit}-{res?.doorplate}
+          </span>
+        ),
     },
     {
       title: '详细地址',
@@ -280,6 +311,10 @@ const CommunityManagement: React.FC = () => {
             <PlusCircleOutlined />
             新增报备
           </Button>
+          <Button htmlType="button" style={{ margin: '20px 10px' }} onClick={onDownLoad}>
+            <CloudDownloadOutlined />
+            导出
+          </Button>
           <Table
             columns={columns}
             dataSource={dataList}

+ 12 - 0
src/services/reportHome.ts

@@ -58,3 +58,15 @@ export async function editReportHome(params: any) {
 export async function queryReportHomeDetail(id: string) {
   return request(`/web/v1/report_homes/${id}`);
 }
+
+/**
+ * 导出
+ * @param params
+ */
+export async function queryExport(params: any) {
+  console.log('params', params);
+  return request(`/web/v1/reports/export?${stringify(params)}`, {
+    method: 'GET',
+    responseType: 'blob',
+  });
+}