生产/质检入库卡片展示样本状态并支持【样本废弃】;市场 Web 列表与移动市场部卡片补充样本状态及问号查看作废原因;样本表新增 void_desc,人工作废不联动接收但全部作废时自动作废协议(#131)。 Co-authored-by: Cursor <cursoragent@cursor.com>
103 lines
2.8 KiB
TypeScript
103 lines
2.8 KiB
TypeScript
import type { SampleFreight } from '@/api/sample-freight'
|
||
|
||
export type SampleFreightFlatRow = {
|
||
rowKey: string
|
||
freightId: string
|
||
/** 当前列表内批次序号(从 0 起,用于斑马纹) */
|
||
batchIndex: number
|
||
/** 运费批次号 YF+YYYYMMDD+001~999 */
|
||
batchNo: string
|
||
rowspan: number
|
||
isFirst: boolean
|
||
transportMode: string
|
||
transportModeLabel: string
|
||
freightAmount: number
|
||
linkedSampleCount: number
|
||
createBy?: string
|
||
createByName?: string
|
||
createTime: string
|
||
sampleSource?: string
|
||
protocolNo?: string
|
||
motherName?: string
|
||
newbornName?: string
|
||
sampleCode?: string
|
||
sampleStatus?: string
|
||
voidDesc?: string
|
||
sampleTypeName?: string
|
||
sampleId?: string
|
||
protocolId?: string
|
||
/** 原始批次,选中时回传 */
|
||
freight: SampleFreight
|
||
}
|
||
|
||
export function flattenSampleFreights(list: SampleFreight[]): SampleFreightFlatRow[] {
|
||
const rows: SampleFreightFlatRow[] = []
|
||
list.forEach((f, batchIndex) => {
|
||
const items = f.items?.length ? f.items : [null]
|
||
const batchNo = (f.freightNo || '').trim() || '—'
|
||
items.forEach((it, idx) => {
|
||
rows.push({
|
||
rowKey: `${f.id}|${it?.sampleId || idx}`,
|
||
freightId: f.id,
|
||
batchIndex,
|
||
batchNo,
|
||
rowspan: idx === 0 ? items.length : 0,
|
||
isFirst: idx === 0,
|
||
transportMode: f.transportMode,
|
||
transportModeLabel: f.transportModeLabel || f.transportMode,
|
||
freightAmount: f.freightAmount,
|
||
linkedSampleCount: f.linkedSampleCount ?? (f.items?.length || 0),
|
||
createBy: f.createBy || '',
|
||
createByName: f.createByName || f.createBy || '',
|
||
createTime: f.createTime || '',
|
||
sampleSource: it?.sampleSource,
|
||
protocolNo: it?.protocolNo,
|
||
motherName: it?.motherName,
|
||
newbornName: it?.newbornName,
|
||
sampleCode: it?.sampleCode,
|
||
sampleStatus: it?.sampleStatus,
|
||
voidDesc: it?.voidDesc,
|
||
sampleTypeName: it?.sampleTypeName,
|
||
sampleId: it?.sampleId,
|
||
protocolId: it?.protocolId,
|
||
freight: f
|
||
})
|
||
})
|
||
})
|
||
return rows
|
||
}
|
||
|
||
const DEFAULT_MERGE_PROPS = new Set([
|
||
'selection',
|
||
'radio',
|
||
'batchNo',
|
||
'transportMode',
|
||
'freightAmount',
|
||
'linkedSampleCount',
|
||
'createByName',
|
||
'createTime',
|
||
'actions'
|
||
])
|
||
|
||
export function sampleFreightSpanMethod(
|
||
{
|
||
column,
|
||
row
|
||
}: {
|
||
column: { type?: string; property?: string }
|
||
row: SampleFreightFlatRow
|
||
},
|
||
extraMergeProps: string[] = []
|
||
): { rowspan: number; colspan: number } {
|
||
const mergeProps =
|
||
extraMergeProps.length > 0
|
||
? new Set([...DEFAULT_MERGE_PROPS, ...extraMergeProps])
|
||
: DEFAULT_MERGE_PROPS
|
||
const prop = column.type === 'selection' ? 'selection' : column.property || ''
|
||
if (mergeProps.has(prop)) {
|
||
if (row.rowspan > 0) return { rowspan: row.rowspan, colspan: 1 }
|
||
return { rowspan: 0, colspan: 0 }
|
||
}
|
||
return { rowspan: 1, colspan: 1 }
|
||
}
|