Browse Source

fix(compiler): fixed

shylock 5 months ago
parent
commit
aa23de16c6

+ 22 - 2
src/pages/AfterSales/AfterSalesSupport/index.tsx

@@ -1,10 +1,11 @@
 import React, { useEffect, useState } from 'react';
 import { PageContainer } from '@ant-design/pro-components';
-import { Button, Card, Form, Input, Space, Table } from 'antd';
+import { Button, Card, Form, Input, message, Space, Table } from 'antd';
 import { ReloadOutlined, SearchOutlined, DownloadOutlined } from '@ant-design/icons';
 import type { ColumnsType } from 'antd/es/table';
 import { queryAfterSalesSupport } from '@/services/afterSales/afterSalesSupport';
 import moment from 'moment';
+import { queryExport } from '@/services/afterSales/afterSalesSupport';
 
 interface DataType {
   name: string;
@@ -86,6 +87,25 @@ const AfterSalesSupport: React.FC = () => {
     });
   };
 
+  // 导出
+  const onExport = () => {
+    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 columns: ColumnsType<DataType> = [
     {
       title: '序号',
@@ -185,7 +205,7 @@ const AfterSalesSupport: React.FC = () => {
                   <ReloadOutlined />
                   重置
                 </Button>
-                <Button type="dashed">
+                <Button type="dashed" onClick={onExport}>
                   <DownloadOutlined />
                   导出
                 </Button>

+ 12 - 0
src/services/afterSales/afterSalesSupport.ts

@@ -8,3 +8,15 @@ import { stringify } from 'qs';
 export async function queryAfterSalesSupport(param: object) {
   return request(`/web/v1/after_sales?${stringify(param)}`);
 }
+
+/**
+ * 导出售后支持列表
+ * @param params
+ */
+export async function queryExport(params: any) {
+  console.log('params', params);
+  return request(`/web/v1/after_sales/export?${stringify(params)}`, {
+    method: 'GET',
+    responseType: 'blob',
+  });
+}