Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 10x 10x 10x 6x 20x 20x 20x 20x 5x | import type { PipelineItem } from '@/api/types'
export interface PipelineFilter {
/** 保单号关键字,大小写不敏感,首尾空格忽略 */
query?: string
/** 出账月 yyyy-MM,空串表示全部 */
month?: string
}
/**
* 在途佣金筛选。逻辑原先内联在 PipelineView 的 computed 里,无法单测,抽成纯函数。
*/
export function filterPipeline(
items: readonly PipelineItem[],
filter: PipelineFilter
): PipelineItem[] {
const keyword = (filter.query ?? '').trim().toUpperCase()
const month = filter.month ?? ''
if (!keyword && !month) return [...items]
return items.filter((item) => {
const policyNo = (item.policyNo ?? '').toUpperCase()
const matchPolicy = !keyword || policyNo.includes(keyword)
const matchMonth = !month || item.payoutMonth === month
return matchPolicy && matchMonth
})
}
/** 月份下拉候选:去重、去空、倒序(yyyy-MM 可直接字典序比较) */
export function payoutMonths(items: readonly PipelineItem[]): string[] {
return Array.from(new Set(items.map((x) => x.payoutMonth).filter(Boolean))).sort().reverse()
}
|