feat: 管理端补充工作台图表、列表导出与批量操作

- 工作台新增近 7 日预约趋势与订单状态分布图

- 订单/用户/就诊人/陪诊师支持 CSV 导出,逐页拉取规避接口分页上限

- 订单列表增加状态快筛、筛选条件同步地址栏、加载失败重试

- 订单详情支持指派/更换陪诊师,性别值归一到订单枚举

- 用户列表支持批量锁定/解锁,导出补齐就诊人数量与归属信息

- 抽取 useTableQuery 统一分页、搜索与删除后页码回退

- ESLint 开启 vue/no-undef-properties,修复 EChart 扩展只注册一次的问题
This commit is contained in:
lik
2026-11-08 11:12:38 +08:00
parent b8b5c81352
commit c30ca3ed41
18 changed files with 1324 additions and 187 deletions
+58
View File
@@ -0,0 +1,58 @@
import { ref, watch, type Ref } from 'vue'
export type TableFetcher<T> = (page: number, pageSize: number) => Promise<{ items: T[]; total: number }>
type Options = {
pageSize?: number
/** 为 false 时不自动监听页码变化(如同一页面存在多个列表) */
autoWatch?: boolean
}
/**
* 列表页通用状态:分页、加载、失败标记与重试、删除后停留有效页码。
* 错误提示由请求层统一弹出,这里只负责记录失败态供页面展示重试按钮。
*/
export function useTableQuery<T>(fetcher: TableFetcher<T>, options: Options = {}) {
const items: Ref<T[]> = ref([])
const total = ref(0)
const page = ref(1)
const pageSize = ref(options.pageSize ?? 20)
const loading = ref(false)
const loadError = ref(false)
const load = async () => {
loading.value = true
loadError.value = false
try {
const data = await fetcher(page.value, pageSize.value)
items.value = data.items
total.value = data.total
const maxPage = Math.max(1, Math.ceil(data.total / pageSize.value))
if (page.value > maxPage) {
page.value = maxPage
return
}
} catch {
loadError.value = true
} finally {
loading.value = false
}
}
const search = () => {
if (page.value === 1) load()
else page.value = 1
}
/** 删除一条后刷新,并保证页码停留在有效范围内 */
const refreshAfterRemove = () => {
const remaining = Math.max(0, total.value - 1)
const nextPage = Math.max(1, Math.min(page.value, Math.ceil(remaining / pageSize.value) || 1))
if (nextPage !== page.value) page.value = nextPage
else load()
}
if (options.autoWatch !== false) watch(page, () => load())
return { items, total, page, pageSize, loading, loadError, load, search, refreshAfterRemove }
}