提交
This commit is contained in:
1 parent
aff71d296b
commit
68d96f87ff
34 files changed
+19587
-16249
No files matched your search
@@ -190,3 +190,69 @@ export function buildViewKvTableQuintRows(
|
||||
}
|
||||
return rows
|
||||
}
|
||||
|
||||
export type ViewKvTableHexRow =
|
||||
| { type: 'long'; field: ViewField }
|
||||
| { type: 'hex'; fields: ViewField[] }
|
||||
|
||||
/** KV 表格模式(六组十二列):长字段独占行,短字段最多六个一组 */
|
||||
export function buildViewKvTableHexRows(
|
||||
fields: ViewField[],
|
||||
formatValue: (val: unknown) => string
|
||||
): ViewKvTableHexRow[] {
|
||||
const rows: ViewKvTableHexRow[] = []
|
||||
let i = 0
|
||||
while (i < fields.length) {
|
||||
const field = fields[i]
|
||||
const text = getViewFieldDisplayText(field, formatValue)
|
||||
if (isViewFieldLong(field, text) || isViewFieldFullSpan(field, text)) {
|
||||
rows.push({ type: 'long', field })
|
||||
i += 1
|
||||
continue
|
||||
}
|
||||
const group: ViewField[] = [field]
|
||||
i += 1
|
||||
while (i < fields.length && group.length < 6) {
|
||||
const next = fields[i]
|
||||
const nextText = getViewFieldDisplayText(next, formatValue)
|
||||
if (isViewFieldLong(next, nextText) || isViewFieldFullSpan(next, nextText)) break
|
||||
group.push(next)
|
||||
i += 1
|
||||
}
|
||||
rows.push({ type: 'hex', fields: group })
|
||||
}
|
||||
return rows
|
||||
}
|
||||
|
||||
export type ViewKvTableSeptRow =
|
||||
| { type: 'long'; field: ViewField }
|
||||
| { type: 'sept'; fields: ViewField[] }
|
||||
|
||||
/** KV 表格模式(七组十四列):长字段独占行,短字段最多七个一组 */
|
||||
export function buildViewKvTableSeptRows(
|
||||
fields: ViewField[],
|
||||
formatValue: (val: unknown) => string
|
||||
): ViewKvTableSeptRow[] {
|
||||
const rows: ViewKvTableSeptRow[] = []
|
||||
let i = 0
|
||||
while (i < fields.length) {
|
||||
const field = fields[i]
|
||||
const text = getViewFieldDisplayText(field, formatValue)
|
||||
if (isViewFieldLong(field, text) || isViewFieldFullSpan(field, text)) {
|
||||
rows.push({ type: 'long', field })
|
||||
i += 1
|
||||
continue
|
||||
}
|
||||
const group: ViewField[] = [field]
|
||||
i += 1
|
||||
while (i < fields.length && group.length < 7) {
|
||||
const next = fields[i]
|
||||
const nextText = getViewFieldDisplayText(next, formatValue)
|
||||
if (isViewFieldLong(next, nextText) || isViewFieldFullSpan(next, nextText)) break
|
||||
group.push(next)
|
||||
i += 1
|
||||
}
|
||||
rows.push({ type: 'sept', fields: group })
|
||||
}
|
||||
return rows
|
||||
}
|
||||
Reference in new issue
Block a user