fix: 订单状态筛选不再发送 cancelled,工作台状态统计改用接口 counts
This commit is contained in:
+14
-1
@@ -114,10 +114,23 @@ export type EscortRecord = {
|
||||
}
|
||||
}
|
||||
|
||||
export type EscortListCounts = {
|
||||
all: number
|
||||
ongoing: number
|
||||
pending: number
|
||||
cancelRequested: number
|
||||
confirmed: number
|
||||
/** 后端字段名为 inProgress,对应 status=in_progress */
|
||||
inProgress: number
|
||||
completed: number
|
||||
/** 取消计数:含 cancelStatus=cancelled 与历史 status=cancelled 数据 */
|
||||
cancelled: number
|
||||
}
|
||||
|
||||
export type EscortListResult = {
|
||||
records: EscortRecord[]
|
||||
total: number
|
||||
counts: { all: number; ongoing: number }
|
||||
counts: EscortListCounts
|
||||
page: number
|
||||
pageSize: number
|
||||
}
|
||||
|
||||
+7
-1
@@ -23,11 +23,17 @@ export const shortId = (value?: string | null): string => (value ? value.slice(-
|
||||
|
||||
export const today = (): string => formatDate(new Date())
|
||||
|
||||
export const STATUS_LABELS: Record<string, string> = {
|
||||
// 服务状态(可筛选):取消不在 status 上,由 cancelStatus 单独表达
|
||||
export const SERVICE_STATUS_LABELS: Record<string, string> = {
|
||||
pending: '待确认',
|
||||
confirmed: '已确认',
|
||||
in_progress: '服务中',
|
||||
completed: '已完成',
|
||||
}
|
||||
|
||||
// 状态展示:兼容历史数据里把取消写在 status 中的旧订单
|
||||
export const STATUS_LABELS: Record<string, string> = {
|
||||
...SERVICE_STATUS_LABELS,
|
||||
cancelled: '已取消',
|
||||
}
|
||||
|
||||
|
||||
@@ -305,7 +305,6 @@ const shiftDate = (days: number) => {
|
||||
const load = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const statusKeys = Object.keys(STATUS_LABELS)
|
||||
const [
|
||||
todayRes,
|
||||
cancelRes,
|
||||
@@ -313,7 +312,6 @@ const load = async () => {
|
||||
recentRes,
|
||||
cancelListRes,
|
||||
trendRes,
|
||||
...statusResList
|
||||
] = await Promise.all([
|
||||
escortApi.list({ page: 1, pageSize: 1, appointmentDate: today() }),
|
||||
escortApi.list({ page: 1, pageSize: 1, cancelStatus: 'requested' }),
|
||||
@@ -328,7 +326,6 @@ const load = async () => {
|
||||
endDate: today(),
|
||||
includeCancelled: '1',
|
||||
}),
|
||||
...statusKeys.map((status) => escortApi.list({ page: 1, pageSize: 1, status })),
|
||||
])
|
||||
|
||||
summary.today = todayRes.total
|
||||
@@ -337,10 +334,15 @@ const load = async () => {
|
||||
recent.value = recentRes.records
|
||||
cancelRequests.value = cancelListRes.records
|
||||
|
||||
statusKeys.forEach((status, index) => {
|
||||
statusCounts[status] = statusResList[index]?.total || 0
|
||||
})
|
||||
summary.pending = statusCounts.pending || 0
|
||||
// 状态分布直接取列表接口的 counts:取消由 counts.cancelled 统计(含历史 status=cancelled 数据),
|
||||
// 不能按 status=cancelled 查询,取消不在服务状态枚举内
|
||||
const totals = recentRes.counts
|
||||
statusCounts.pending = totals.pending || 0
|
||||
statusCounts.confirmed = totals.confirmed || 0
|
||||
statusCounts.in_progress = totals.inProgress || 0
|
||||
statusCounts.completed = totals.completed || 0
|
||||
statusCounts.cancelled = totals.cancelled || 0
|
||||
summary.pending = statusCounts.pending
|
||||
|
||||
const countsByDate: Record<string, number> = {}
|
||||
trendRes.records.forEach((item) => {
|
||||
@@ -356,6 +358,8 @@ const load = async () => {
|
||||
}
|
||||
trend.dates = dates
|
||||
trend.counts = counts
|
||||
} catch {
|
||||
// 错误提示由请求层统一弹出;401 会跳转登录页
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
<div class="d-flex flex-wrap gap-1 mb-3">
|
||||
<BButton size="sm" :variant="filters.status === '' ? 'primary' : 'light'" @click="setStatus('')">全部</BButton>
|
||||
<BButton
|
||||
v-for="(label, value) in STATUS_LABELS"
|
||||
v-for="(label, value) in SERVICE_STATUS_LABELS"
|
||||
:key="value"
|
||||
size="sm"
|
||||
:variant="filters.status === value ? 'primary' : 'light'"
|
||||
@@ -54,7 +54,7 @@
|
||||
<label class="form-label fs-12 mb-1">服务状态</label>
|
||||
<BFormSelect v-model="filters.status">
|
||||
<option value="">全部</option>
|
||||
<option v-for="(label, value) in STATUS_LABELS" :key="value" :value="value">{{ label }}</option>
|
||||
<option v-for="(label, value) in SERVICE_STATUS_LABELS" :key="value" :value="value">{{ label }}</option>
|
||||
</BFormSelect>
|
||||
</BCol>
|
||||
<BCol md="6" xl="2">
|
||||
@@ -228,6 +228,7 @@ import {
|
||||
CHANNEL_LABELS,
|
||||
PAYMENT_LABELS,
|
||||
PAYMENT_VARIANTS,
|
||||
SERVICE_STATUS_LABELS,
|
||||
STATUS_LABELS,
|
||||
STATUS_VARIANTS,
|
||||
formatDate,
|
||||
@@ -242,10 +243,14 @@ const router = useRouter()
|
||||
|
||||
const queryText = (value: unknown) => (typeof value === 'string' ? value : '')
|
||||
|
||||
// 旧链接可能用 status=cancelled 表达「已取消」;取消现在由 cancelStatus 表达
|
||||
const initialStatus = queryText(route.query.status)
|
||||
const legacyCancelled = initialStatus === 'cancelled'
|
||||
|
||||
const filters = reactive({
|
||||
keyword: queryText(route.query.keyword),
|
||||
status: queryText(route.query.status),
|
||||
cancelStatus: queryText(route.query.cancelStatus),
|
||||
status: SERVICE_STATUS_LABELS[initialStatus] ? initialStatus : '',
|
||||
cancelStatus: queryText(route.query.cancelStatus) || (legacyCancelled ? 'cancelled' : ''),
|
||||
paymentStatus: queryText(route.query.paymentStatus),
|
||||
payChannel: queryText(route.query.payChannel),
|
||||
appointmentDate: queryText(route.query.appointmentDate),
|
||||
|
||||
Reference in New Issue
Block a user