Files
shanxia2.0/web-admin/src/composables/columnFacetContext.ts
T
wuzilongandCursor 6a8cd90b98 feat: cascade column facet options by current list context
Make dynamic column-facet values respect other active filters (Excel-style), with backend facet context helpers, list-page wiring, slip print/sidebar fixes, and refreshed graphify graphs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-11 22:04:20 +08:00

68 lines
2.1 KiB
TypeScript

import type { ColumnFilterDef } from '@/composables/useClientColumnFilters'
/** 从列表上下文参数中去掉当前列对应的过滤键(Excel:打开本列漏斗不受自身勾选约束)。 */
export function stripSelfColumnParams(
params: Record<string, unknown>,
prop: string,
defs: ColumnFilterDef[]
): Record<string, unknown> {
const out: Record<string, unknown> = { ...params }
const def = defs.find((d) => d.prop === prop)
if (!def) return out
const keys = new Set<string>()
const add = (...names: Array<string | undefined | null>) => {
for (const name of names) {
const key = String(name || '').trim()
if (key) keys.add(key)
}
}
add(def.prop, `${def.prop}In`)
if (def.type === 'datetime') {
const base = def.queryKey || def.prop
add(def.queryKeyFrom, def.queryKeyTo, `${base}From`, `${base}To`)
} else if (def.type === 'number') {
const prefix = def.queryKeyPrefix || def.queryKey || def.prop
add(prefix, `${prefix}Op`, `${prefix}Min`, `${prefix}Max`)
} else {
const key = def.queryKey || def.prop
add(key, `${key}In`)
}
// 装/送货客户:queryKey 与 prop 不一致,以及列表合并后的 stopCustomers
if (prop === 'loadCustomer' || def.queryKey === 'loadCustomers') {
add(
'loadCustomer',
'loadCustomerIn',
'loadCustomers',
'loadCustomersIn',
'stopCustomers',
'customerKeyword'
)
}
if (prop === 'deliveryCustomer' || def.queryKey === 'deliveryCustomers') {
add(
'deliveryCustomer',
'deliveryCustomerIn',
'deliveryCustomers',
'deliveryCustomersIn',
'stopCustomers',
'customerKeyword'
)
}
// 合同列:productContract ↔ contractNo
if (prop === 'productContract' || def.queryKey === 'contractNo') {
add('productContract', 'productContractIn', 'contractNo', 'contractNoIn', 'stopKindIn')
}
if (prop === 'productPackageSpec' || def.queryKey === 'packageSpec') {
add('productPackageSpec', 'productPackageSpecIn', 'packageSpec', 'packageSpecIn')
}
for (const key of keys) {
delete out[key]
}
return out
}