支持客户、对话记录与统计报告 CSV 导出

- 新增 /customers/export、/sessions/export、/statistics/export
- 沿用列表筛选与角色可见范围,UTF-8 BOM 便于 Excel 打开
- 前端三处导出按钮接入真实下载
This commit is contained in:
yml2213
2026-07-15 15:10:46 +08:00
parent 216ab2c85a
commit c43f420875
8 changed files with 571 additions and 11 deletions
+14 -2
View File
@@ -8,7 +8,7 @@ import {
DeleteOutlined, ExportOutlined, CloseOutlined, GlobalOutlined, MessageOutlined,
} from '@ant-design/icons'
import {
createCustomer, deleteCustomer, getCustomer, getCustomers, updateCustomer,
createCustomer, deleteCustomer, exportCustomersCSV, getCustomer, getCustomers, updateCustomer,
type Customer, type Session,
} from '@/services/api'
import { useAuth } from '@/stores/auth'
@@ -140,6 +140,7 @@ const Customers = () => {
const [page, setPage] = useState(1)
const [pageSize, setPageSize] = useState(10)
const [search, setSearch] = useState('')
const [exporting, setExporting] = useState(false)
const [tagFilter, setTagFilter] = useState('all')
const [selectedCustomer, setSelectedCustomer] = useState<Customer | null>(null)
const [editingId, setEditingId] = useState<number | null>(null)
@@ -321,8 +322,19 @@ const Customers = () => {
<div className="flex items-center gap-2 ml-auto">
<Button
icon={<ExportOutlined />}
loading={exporting}
className="!text-[13px] !h-8 !px-3 !font-medium !text-neutral-600 !border-neutral-200"
onClick={() => message.info('导出功能后续版本提供')}
onClick={async () => {
setExporting(true)
try {
await exportCustomersCSV({ search: search || undefined })
message.success('客户列表已导出')
} catch (e) {
message.error(e instanceof Error ? e.message : '导出失败')
} finally {
setExporting(false)
}
}}
>
</Button>