接单工单状态筛选支持多选

- 前端:状态筛选改为多选(Select mode=multiple),可一次筛选多个状态
- 后端:listWorkOrders 支持 statuses 数组查询(ANY 匹配),兼容旧单状态参数
- 批量验收入口仅在单独筛选待验收时显示,避免多选误操作
This commit is contained in:
yml2213
2026-08-16 15:48:15 +08:00
parent 31f134579c
commit 737f9ddcbe
6 changed files with 83 additions and 31 deletions
@@ -209,7 +209,10 @@ export type GrabWorkOrderResult = {
export type ListInput = {
page?: number
pageSize?: number
/** 单状态筛选(兼容 worker 用户等其他列表) */
status?: string
/** 支持多个状态同时筛选(空数组表示全部状态) */
statuses?: string[]
keyword?: string
workerId?: number
categoryId?: number
@@ -737,6 +737,7 @@ export async function listWorkOrdersByPlatformOrderId(
export async function listWorkOrders({
page = 1,
pageSize = 20,
statuses = [],
status = '',
keyword = '',
workerId = 0,
@@ -745,8 +746,10 @@ export async function listWorkOrders({
visibleAfterIso = '',
sort = 'id_desc',
}: ListInput = {}): Promise<{ items: WorkOrderRow[]; total: number }> {
const effectiveStatuses =
statuses.length > 0 ? statuses : status.trim() ? [status.trim()] : []
const { whereClause, params } = buildWorkOrderWhere({
status,
statuses: effectiveStatuses,
keyword,
workerId,
categoryId,
@@ -2522,7 +2525,7 @@ async function getWorkOrderByIdWithClient(
}
function buildWorkOrderWhere({
status = '',
statuses = [],
keyword = '',
workerId = 0,
categoryId = 0,
@@ -2531,9 +2534,16 @@ function buildWorkOrderWhere({
}: ListInput) {
const filters: string[] = []
const params: unknown[] = []
if (status) {
params.push(status)
filters.push(`wo.status = $${params.length}`)
const normalizedStatuses = [
...new Set(
statuses
.map((item) => String(item || '').trim())
.filter(Boolean),
),
]
if (normalizedStatuses.length > 0) {
params.push(normalizedStatuses)
filters.push(`wo.status = ANY($${params.length}::text[])`)
}
if (keyword) {
params.push(`%${keyword}%`)