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