TDD 红绿重构:
- 红: tests/unit/field-builder-bs54.test.ts 6 FAIL
- 绿: FieldBuilder.build() select/relationForm 自动补默认字段
- select: dataType='static', dictionaryType='', propsUrl='', options=[2项占位], props={label, value}
- relationForm: modelId='' 占位 (用户必填)
- 重构: 抽通用占位 → src/schema/field-defaults.ts
(避免应用特定信息入 dacli/src, jxcj 36 套模板/vmodel→enCode 仍留在 docs/jxcj/scripts/)
字段形状来源: web componentMap.ts:324-376 (select) + 1363-1406 (relationForm)
Co-Authored-By: Claude <[email protected]>
30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
/**
|
|
* schema/field-defaults.ts — 通用字段默认值 (BS-54, 2026-06-24)
|
|
*
|
|
* 设计: 仅放通用占位, 不放应用特定语义.
|
|
* - 应用特定 (jxcj 36 套 select 模板 + vmodel→enCode 映射) → docs/<app>/scripts/
|
|
* - 通用占位 (空 modelId / 2 项 select) → dacli/src (本文件)
|
|
*
|
|
* 数据来源: web componentMap.ts:324-376 (select) + 1363-1406 (relationForm)
|
|
* - select 默认 'static' + 2 项占位 (选项一/选项二)
|
|
* - relationForm 默认空 modelId (用户必填)
|
|
*/
|
|
export interface SelectOption {
|
|
fullName: string
|
|
id: string
|
|
}
|
|
|
|
/** select 字段默认 options (2 项占位, 用户必改) */
|
|
export const DEFAULT_SELECT_OPTIONS: SelectOption[] = [
|
|
{ fullName: '选项一', id: '1' },
|
|
{ fullName: '选项二', id: '2' },
|
|
]
|
|
|
|
/** select 字段默认 props.label / props.value 映射 */
|
|
export const DEFAULT_SELECT_PROPS = {
|
|
label: 'fullName',
|
|
value: 'id',
|
|
} as const
|
|
|
|
/** relationForm 字段默认 modelId (空字符串, 用户必填目标 form enCode/id) */
|
|
export const PLACEHOLDER_MODEL_ID = '' |