fix(supply-chain): 限价筛选候选值联动

This commit is contained in:
居居 2026-10-19 14:15:05 +08:00
parent ee4afbb875
commit f9594a4260
2 changed files with 25 additions and 0 deletions

View File

@ -277,6 +277,25 @@ describe('限价管理', () => {
expect(screen.queryByRole('button', { name: '导出明细' })).not.toBeInTheDocument()
})
it('条码候选值跟随已选商品状态,避免选出与明细条件冲突的条码', async () => {
render(<CustomTableView canEdit userId="user-a" />)
await screen.findByText('测试岩板餐桌')
fireEvent.click(screen.getByRole('button', { name: '筛选条码', exact: true }))
await screen.findByRole('dialog', { name: '筛选条码' })
let optionRequest = ''
await waitFor(() => {
optionRequest = (global.fetch as jest.Mock).mock.calls
.map((call) => String(call[0]))
.filter((url) => url.includes('/limit-management/options') && url.includes('field=barcode'))
.at(-1) ?? ''
expect(optionRequest).not.toBe('')
})
const filters = new URL(optionRequest, 'http://localhost').searchParams.get('filters') ?? '{}'
expect(JSON.parse(filters)).toEqual({ productStatus: ['销售'] })
})
it('限价页按《限价抬头及逻辑》显示分组表头,并展示产品全量档案数据', async () => {
render(<CustomTableView canEdit userId="user-a" />)

View File

@ -430,6 +430,10 @@ export function LimitPriceTab({ userId, canExport = false }: { userId: string; c
const visibleFilterFields = settings.filterFields
.map((key) => LIMIT_TABLE_FILTER_FIELD_MAP.get(key))
.filter((field): field is NonNullable<typeof field> => Boolean(field))
const filterContext = useMemo(
() => filters as Record<string, string[]>,
[filters],
)
return (
<section className={styles.tabPanel} aria-label="限价商品列表">
@ -526,6 +530,7 @@ export function LimitPriceTab({ userId, canExport = false }: { userId: string; c
key={field.key}
field={field}
selected={(filters as Record<string, string[] | undefined>)[field.key] ?? []}
contextFilters={filterContext}
onChange={(values) => updateFilterValue(field.key, values)}
/>
))}
@ -622,6 +627,7 @@ export function LimitPriceTab({ userId, canExport = false }: { userId: string; c
filterValues={column.filterKey
? ((filters as Record<string, string[] | undefined>)[column.filterKey] ?? [])
: undefined}
filterContext={filterContext}
filterOpen={openFilterKey === column.key}
onToggleFilter={() => setOpenFilterKey((current) => (current === column.key ? null : column.key))}
onCloseFilter={() => setOpenFilterKey(null)}