feat(主子表): 派生字段定义 UI + e2e

- MasterDetailShell step③ 派生字段 combo(目标列 + 公式),page data seed
  childDerived:[] 防 combo 未触碰时发出未解析占位串致 compile 反序列化 400
- e2e: 新增「派生字段全流程」用例(向导加派生 → 发布页含 tpl 预览+__derive →
  _ADD 服务端逐行落库 AMOUNT,经 _LOAD 回读验证;断言 quickEdit:false);
  原主子表用例补 _LOAD 级联实证(_SEARCH 列表不嵌充子数组,_LOAD 才填充)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-20 17:32:26 +08:00
parent 934c6464db
commit df0ac72225
2 changed files with 139 additions and 0 deletions

View File

@@ -35,6 +35,9 @@ function attrCombo(name: string): Record<string, unknown> {
function buildSchema(): Record<string, unknown> {
return {
type: 'page',
// seed childDerived=[] 使 ${childDerived} 恒解析为数组:派生字段 combo 未触碰时也不会发出
// 未解析占位串导致 compile 反序列化 400(后端已另做 Object 容错,此处双保险)。
data: { childDerived: [] },
body: {
type: 'wizard',
mode: 'horizontal',
@@ -82,12 +85,14 @@ function buildSchema(): Record<string, unknown> {
title: '③ 生成主子页',
subTitle: '编译落标准层',
// 后端 recipe=master-detail-v1:先 ensureLink(MASTERID/DETAILS) 接线,再编译出主 CRUD + 子表 input-table。
// childDerived:派生列(金额=数量×单价 类)→ 编译为只读 tpl 实时预览 + 写流 ?__derive= 服务端权威落库。
api: {
method: 'post', url: '/api/design/recipe/compile',
data: {
tableName: '${masterTable}', recipe: 'master-detail-v1', title: '${title}',
displayField: '${displayField}', childTable: '${childTablename}',
linkColumn: 'MASTERID', listColumn: 'DETAILS', listLabel: '${childName}',
childDerived: '${childDerived}',
},
responseData: { templateId: '${templateId}' },
},
@@ -95,6 +100,20 @@ function buildSchema(): Record<string, unknown> {
{ type: 'static', label: '主表 / 子表', tpl: '${masterTable} / ${childTablename}' },
{ type: 'input-text', name: 'title', label: '页面标题', required: true, placeholder: '采购申请(主子)' },
{ type: 'input-text', name: 'displayField', label: '主表显示字段', placeholder: '可选,默认主表显示列' },
{ type: 'static', label: '可用子表列', tpl: '${childAttributes|pick:column|join:"、"}',
visibleOn: '${childAttributes && childAttributes.length}' },
{
type: 'combo', name: 'childDerived', label: '派生字段', multiple: true,
addable: true, removable: true, addButtonText: '加派生字段', minLength: 0,
description: '可选。如 金额=数量×单价:目标列填 MONEY,公式填 QTY*PRICE。'
+ '公式仅用子表列名与 + - * / ( ),落库前服务端逐行权威求算(避免前端竞态),同时单元格实时预览。',
items: [
{ type: 'input-text', name: 'column', label: '目标列', required: true, placeholder: 'MONEY',
validations: { matchRegexp: '/^[A-Z][A-Z0-9_]{0,40}$/' },
validationErrors: { matchRegexp: '须为大写字母开头的子表真实列' } },
{ type: 'input-text', name: 'formula', label: '公式', required: true, placeholder: 'QTY*PRICE' },
],
},
],
},
{