From 4c4b36e7337385ff15ff66a0ad487cdffaf9c86b Mon Sep 17 00:00:00 2001
From: zjk <852185829@qq.com>
Date: 星期四, 24 九月 2026 17:22:50 +0800
Subject: [PATCH] feat: 新增APP启动页功能,完善多项业务优化
---
tcm-training-admin/src/pages/member/agent/index.tsx | 41 +++++++++++++++++++++++++++++++++--------
1 files changed, 33 insertions(+), 8 deletions(-)
diff --git a/tcm-training-admin/src/pages/member/agent/index.tsx b/tcm-training-admin/src/pages/member/agent/index.tsx
index e64bb1c..1267c77 100644
--- a/tcm-training-admin/src/pages/member/agent/index.tsx
+++ b/tcm-training-admin/src/pages/member/agent/index.tsx
@@ -1,15 +1,25 @@
import RegionCascader from '@/components/RegionCascader';
-import { PlusOutlined } from '@ant-design/icons';
+import { DownloadOutlined, PlusOutlined } from '@ant-design/icons';
import { history, useAccess } from '@umijs/max';
import { Button, Descriptions, Form, Input, Modal, Pagination, Select, Space, Table, message } from 'antd';
import React, { useEffect, useState } from 'react';
-import { createAgent, deleteAgent, getAgentDetail, getAgentPage, updateAgent } from './service';
+import { createAgent, deleteAgent, exportAgents, getAgentDetail, getAgentPage, updateAgent } from './service';
+import { downloadBlob } from '../../trade/points-exchange/shared';
type RegionValue = { regionCode?: string[] };
type SearchValues = { regionPath?: string[]; clinicName?: string; contactInfo?: string; status?: number };
type AgentItem = { id: number; agentName: string; contactInfo?: string; address?: string; regionNames?: string[]; clinicCount?: number; status?: number; createdAt?: string };
const statusOptions = [{ label: '启用', value: 1 }, { label: '禁用', value: 0 }, { label: '注销', value: 2 }];
const statusText = (value?: number) => value === 1 ? '启用' : value === 2 ? '注销' : '禁用';
+
+function buildSearchParams(search: SearchValues) {
+ return {
+ regionCode: search.regionPath?.[search.regionPath.length - 1],
+ clinicName: search.clinicName?.trim() || undefined,
+ contactInfo: search.contactInfo?.trim() || undefined,
+ status: search.status,
+ };
+}
const AgentPage: React.FC = () => {
const access = useAccess();
@@ -18,6 +28,7 @@
const [list, setList] = useState<AgentItem[]>([]);
const [pagination, setPagination] = useState({ page: 1, pageSize: 10, total: 0 });
const [loading, setLoading] = useState(false);
+ const [exporting, setExporting] = useState(false);
const [open, setOpen] = useState(false);
const [detail, setDetail] = useState<any>();
const [editingId, setEditingId] = useState<number>();
@@ -29,14 +40,25 @@
try {
const response = await getAgentPage({
page, pageSize,
- regionCode: search.regionPath?.[search.regionPath.length - 1],
- clinicName: search.clinicName?.trim() || undefined,
- contactInfo: search.contactInfo?.trim() || undefined,
- status: search.status,
+ ...buildSearchParams(search),
});
setList(response.data?.list || []);
setPagination({ page: Number(response.data?.page || page), pageSize: Number(response.data?.pageSize || pageSize), total: Number(response.data?.total || 0) });
} finally { setLoading(false); }
+ };
+
+ const handleExport = async () => {
+ setExporting(true);
+ try {
+ const blob = await exportAgents(buildSearchParams(searchForm.getFieldsValue()));
+ downloadBlob(blob, '省代用户列表.xlsx');
+ message.success('导出成功');
+ } catch (error) {
+ console.error('省代用户导出失败', error);
+ message.error((error as Error)?.message || '导出失败');
+ } finally {
+ setExporting(false);
+ }
};
useEffect(() => { if (!canView) history.replace('/Welcome'); else void load(); }, [canView]);
@@ -85,7 +107,10 @@
<Button onClick={() => { searchForm.resetFields(); void load(1); }}>重置</Button>
<Button type="primary" htmlType="submit" style={{ marginLeft: 8 }}>查询</Button>
</Form>
- <div style={{ margin: '16px 0' }}>{access['member:agent:add'] && <Button type="primary" icon={<PlusOutlined />} onClick={() => openForm()}>新增</Button>}</div>
+ <Space style={{ margin: '16px 0' }}>
+ {access['member:agent:add'] && <Button type="primary" icon={<PlusOutlined />} onClick={() => openForm()}>新增</Button>}
+ {canView && <Button type="primary" loading={exporting} onClick={handleExport}>导出</Button>}
+ </Space>
<Table rowKey="id" columns={columns as any} dataSource={list} loading={loading} pagination={false} scroll={{ x: 1200 }} />
<Pagination style={{ marginTop: 16, textAlign: 'right' }} current={pagination.page} pageSize={pagination.pageSize} total={pagination.total} showSizeChanger onChange={load} />
<Modal open={open} title={detail ? '省代理详情' : editingId ? '编辑省代理' : '新增省代理'} width={760} onCancel={() => setOpen(false)} footer={detail ? null : <><Button onClick={() => setOpen(false)}>取消</Button><Button type="primary" onClick={submit}>确定</Button></>}>
@@ -113,4 +138,4 @@
</Modal>
</div>;
};
-export default AgentPage;
\ No newline at end of file
+export default AgentPage;
--
Gitblit v1.7.1