20260927215912
This commit is contained in:
1 parent
27e49e2e45
commit
f22e67fc85
294 files changed
+29247
-3576
No files matched your search
@@ -41,24 +41,30 @@ describe('buildListConfig(view JSON → 列表列)', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('buildEditRender(edit JSON → 分组 + 编辑行)', () => {
|
||||
it('还原分组与行属性,嵌套分组生成独立分组', () => {
|
||||
describe('buildEditRender(edit JSON → 分组 + 行 + 编辑行)', () => {
|
||||
it('行节点 → lines,行属性与嵌套分组保留', () => {
|
||||
const edit = {
|
||||
schemaVersion: 1,
|
||||
schemaVersion: 2,
|
||||
children: [
|
||||
{ field: 'code', span: 24, required: true },
|
||||
{ type: 'row', children: [{ field: 'code', span: 24, required: true }] },
|
||||
{
|
||||
type: 'group',
|
||||
title: '基础',
|
||||
children: [
|
||||
{ field: 'name', span: 12, readonly: true, defaultValue: 'X' },
|
||||
{ type: 'group', title: '扩展', children: [{ field: 'remark', span: 24 }] },
|
||||
{
|
||||
type: 'row',
|
||||
children: [
|
||||
{ field: 'name', span: 12, readonly: true, defaultValue: 'X' },
|
||||
{ field: 'age', span: 12 },
|
||||
],
|
||||
},
|
||||
{ type: 'group', title: '扩展', children: [{ type: 'row', children: [{ field: 'remark', span: 24 }] }] },
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
const { groups, rows } = buildEditRender(edit)
|
||||
expect(rows.map((r) => r.b_field)).toEqual(['code', 'name', 'remark'])
|
||||
const { groups, rows, lines } = buildEditRender(edit)
|
||||
expect(rows.map((r) => r.b_field)).toEqual(['code', 'name', 'age', 'remark'])
|
||||
const outer = groups.find((g) => g.b_title === '基础')
|
||||
const inner = groups.find((g) => g.b_title === '扩展')
|
||||
expect(outer).toBeTruthy()
|
||||
@@ -71,6 +77,29 @@ describe('buildEditRender(edit JSON → 分组 + 编辑行)', () => {
|
||||
b_default_value: 'X',
|
||||
})
|
||||
expect(rows[2].b_group_id).toBe(inner.b_id)
|
||||
// 行是显式结构:同一行 b_line 相同、跨行不同,lines 按行聚合
|
||||
expect(rows[1].b_line).toBe(rows[2].b_line)
|
||||
expect(rows[0].b_line).not.toBe(rows[1].b_line)
|
||||
expect(lines.map((l) => l.rows.map((r) => r.b_field))).toEqual([
|
||||
['code'],
|
||||
['name', 'age'],
|
||||
['remark'],
|
||||
])
|
||||
expect(lines.every((l) => l.rows.every((r) => r.b_line === l.key))).toBe(true)
|
||||
})
|
||||
|
||||
it('老结构(平铺 + newline)容错折行,只读不回写', () => {
|
||||
const edit = {
|
||||
schemaVersion: 1,
|
||||
children: [
|
||||
{ field: 'a', span: 8 },
|
||||
{ field: 'b', span: 8 },
|
||||
{ field: 'c', span: 8, newline: true },
|
||||
{ field: 'd', span: 24 },
|
||||
],
|
||||
}
|
||||
const { lines } = buildEditRender(edit)
|
||||
expect(lines.map((l) => l.rows.map((r) => r.b_field))).toEqual([['a', 'b'], ['c'], ['d']])
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user