feat(consignment): 寄售仓库新增对接客服多选筛选

This commit is contained in:
2026-11-19 11:28:30 +08:00
parent 587ac1cd00
commit a6e15f582e
5 changed files with 122 additions and 2 deletions
@@ -149,6 +149,8 @@ export default function ConsignmentInventoryPanel() {
const [categoryExpandedKeys, setCategoryExpandedKeys] = useState<Array<string | number>>([])
const [specFilters, setSpecFilters] = useState<Record<string, string>>({})
const [allowMatching, setAllowMatching] = useState<string>('')
// 对接客服多选:0 作为「未指定」哨兵值,与真实客服 id 分开。
const [contactSupporterIds, setContactSupporterIds] = useState<number[]>([])
const [inboundRange, setInboundRange] = useState<[string, string] | null>(null)
const [keyword, setKeyword] = useState<string>('')
const [page, setPage] = useState<number>(1)
@@ -295,6 +297,9 @@ export default function ConsignmentInventoryPanel() {
}, [dynamicFilters, specFilters])
const specFilterParams =
Object.keys(specFilterPayload).length > 0 ? JSON.stringify(specFilterPayload) : undefined
// 对接客服筛选只按 id 传参;未指定单独标记,后端与多选 id 取并集。
const contactSupporterIdsParam = contactSupporterIds.filter((id) => id > 0).join(',') || undefined
const includeUnassignedContactSupporter = contactSupporterIds.includes(0)
function updateSpecFilter(field: ConsignmentInventoryFilterField, value: string) {
setSpecFilters((current) => {
@@ -314,6 +319,8 @@ export default function ConsignmentInventoryPanel() {
categoryId,
specFilterParams,
allowMatching,
contactSupporterIdsParam,
includeUnassignedContactSupporter,
inboundRange?.[0],
inboundRange?.[1],
keyword,
@@ -326,6 +333,8 @@ export default function ConsignmentInventoryPanel() {
categoryId: categoryId ?? undefined,
specFilters: specFilterParams,
allowMatching: allowMatching === 'yes' ? true : allowMatching === 'no' ? false : undefined,
contactSupporterIds: contactSupporterIdsParam,
contactSupporterUnassigned: includeUnassignedContactSupporter || undefined,
dateFrom: inboundRange?.[0],
dateTo: inboundRange?.[1],
keyword: keyword || undefined,
@@ -1107,6 +1116,23 @@ export default function ConsignmentInventoryPanel() {
}}
/>
{/* 对接客服筛选:多选 + 未指定;只按客服 id 匹配,与寄售人严格分开。 */}
<Select
mode="multiple"
allowClear
showSearch
optionFilterProp="label"
maxTagCount="responsive"
style={{ width: 220, maxWidth: '100%' }}
value={contactSupporterIds}
placeholder="对接客服(可多选)"
onChange={(values) => {
setContactSupporterIds(values)
setPage(1)
}}
options={[{ label: '未指定', value: 0 }, ...contactSupporterOptions]}
/>
<Input.Search
placeholder="搜索物品名/编号/收购人/店铺/卖家"
allowClear
@@ -0,0 +1,40 @@
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import test from 'node:test'
const source = readFileSync(
join(
dirname(fileURLToPath(import.meta.url)),
'../src/pages/admin/panels/ConsignmentInventoryPanel.tsx',
),
'utf8',
)
test('寄售仓库提供对接客服多选筛选,并与未指定取并集', () => {
assert.ok(source.includes('mode="multiple"'))
assert.ok(source.includes('placeholder="对接客服(可多选)"'))
assert.ok(source.includes('optionFilterProp="label"'))
assert.ok(source.includes('contactSupporterIdsParam'))
assert.ok(source.includes('contactSupporterIds: contactSupporterIdsParam'))
assert.ok(
source.includes('contactSupporterUnassigned: includeUnassignedContactSupporter || undefined'),
)
assert.ok(source.includes("{ label: '未指定', value: 0 }"))
// 对接客服筛选必须排在搜索框前面。
const contactIndex = source.indexOf('placeholder="对接客服(可多选)"')
const searchIndex = source.indexOf('placeholder="搜索物品名/编号/收购人/店铺/卖家"')
assert.ok(contactIndex > 0 && searchIndex > 0 && contactIndex < searchIndex)
})
test('对接客服筛选进入列表 queryKey,统计卡片不跟随', () => {
assert.ok(source.includes('includeUnassignedContactSupporter,'))
const statsStart = source.indexOf("'admin-consignment-stats'")
assert.ok(statsStart > 0, '未找到寄售统计查询')
const statsBlock = source.slice(statsStart, statsStart + 600)
assert.ok(
!statsBlock.includes('contactSupporterIdsParam'),
'统计卡片不应跟随对接客服筛选,保持原有统计口径',
)
})