v0.11: 加 form create --autoTable 选项 (对齐 web formDesign UX)
This commit is contained in:
1 parent
ebaed7a516
commit
af518ba077
2 files changed
+48
-8
No files matched your search
@@ -176,6 +176,28 @@ export function wrapSimplifiedFields(
|
||||
return { wrapped, converted: wrapped.length, total: fields.length }
|
||||
}
|
||||
|
||||
/**
|
||||
* FullField → SimpleField 反向映射 (供 buildTablesFromFields 等期望 SimpleField 的函数复用).
|
||||
* 全包 schema (__vModel__/__config__/options 等) → 简化的 vmodel/label/required 形式.
|
||||
*/
|
||||
export function toSimpleField(field: FullField): SimpleField {
|
||||
const cfg = (field.__config__ || {}) as Record<string, unknown>
|
||||
const result: Record<string, unknown> = {
|
||||
vmodel: String(field.__vModel__ || ''),
|
||||
label: String(cfg.label || ''),
|
||||
jnpfKey: String(cfg.jnpfKey || 'input'),
|
||||
required: cfg.required === true,
|
||||
}
|
||||
if (field.dataType) result.dataType = String(field.dataType)
|
||||
if (field.dataLength) result.dataLength = String(field.dataLength)
|
||||
if (field.options) result.options = field.options
|
||||
if (field.relationTable) result.relationTable = String(field.relationTable)
|
||||
if (field.columnOptions) result.columnOptions = field.columnOptions
|
||||
if (field.relationField) result.relationField = String(field.relationField)
|
||||
if (field.dictionaryType) result.dictionaryType = String(field.dictionaryType)
|
||||
return result as unknown as SimpleField
|
||||
}
|
||||
|
||||
/** 从 fields 推导 tables 默认值 (D-2 自动推断) */
|
||||
export function buildTablesFromFields(
|
||||
enCode: string,
|
||||
|
||||
@@ -12,7 +12,7 @@ import { JnpfClient } from '../../core/client.ts'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { log, printJson } from '../../core/log.ts'
|
||||
import { callAiForm, printAiFormResult } from './_ai.ts'
|
||||
import { wrapSimplifiedFields, buildTablesFromFields, type SimpleField } from './_simplify.ts'
|
||||
import { wrapSimplifiedFields, buildTablesFromFields, toSimpleField, type FullField, type SimpleField } from './_simplify.ts'
|
||||
import { browserVerify } from './_browser_verify.ts'
|
||||
import { createFormViaUi } from './_create_ui.ts'
|
||||
import { preCheckFormCreate, handlePreCheckResult } from '../_precheck.ts'
|
||||
@@ -32,6 +32,8 @@ interface CreateOpts {
|
||||
enableFlow?: string
|
||||
flowId?: string
|
||||
autoRelease?: boolean
|
||||
/** v0.11: --autoTable 强制从 --fields 推导 --tables (覆盖 --tables, 对齐 web formDesign Form.vue) */
|
||||
autoTable?: boolean
|
||||
/** v0.7.3 (盲点 47): 建完发布后自动挂菜单到指定父目录, 避免浏览器验证 step check-list 找不到 vxe-table */
|
||||
autoCreateMenu?: boolean
|
||||
/** 父菜单 id (--autoCreateMenu 时必传, 用 dacli menu list --keyword=... 拿) */
|
||||
@@ -63,6 +65,7 @@ export function buildFormCreateCommand(): Command {
|
||||
.option('--enableFlow <0|1>', '是否绑工作流', '0')
|
||||
.option('--flowId <id>', '工作流 id (enableFlow=1 时必传)')
|
||||
.option('--autoRelease', '建完立刻发布 (type=4 自动跳过)', false)
|
||||
.option('--autoTable', '从 --fields 自动推导 --tables JSON (web formDesign Form.vue 行为一致; 覆盖 --tables)', false)
|
||||
.option('--autoCreateMenu', '发布后自动挂菜单 (需传 --menuParentId, 避免浏览器验证找不到 list 页)', false)
|
||||
.option('--menuParentId <id>', '挂菜单的父目录 id (--autoCreateMenu 时必传; 走 dacli menu list --keyword=... 拿)')
|
||||
.option('--ai <desc>', '白皮书 5.10.1 AI 快速建表 — 自然语言描述, 平台 LLM 生成 enCode/fullName/fields, 走 type=4 视图兜底')
|
||||
@@ -178,6 +181,7 @@ export function buildFormCreateCommand(): Command {
|
||||
webType,
|
||||
enableFlow: enableFlowBool,
|
||||
autoRelease: opts.autoRelease === true,
|
||||
autoTable: opts.autoTable === true,
|
||||
}
|
||||
if (opts.tables) {
|
||||
try { guardOpts.tables = JSON.parse(opts.tables) } catch { /* JSON 解析失败留给后续步骤 */ }
|
||||
@@ -448,14 +452,27 @@ export function buildFormCreateCommand(): Command {
|
||||
hasDefaultValue: false, // dacli 自有
|
||||
hasSuperQuery: false,
|
||||
}
|
||||
const tables = opts.tables
|
||||
? JSON.parse(opts.tables)
|
||||
: type === 4
|
||||
const tables = opts.autoTable
|
||||
? type === 4
|
||||
// type=4 视图不能带物理表 (后端会 Database exception), 强制空数组
|
||||
? []
|
||||
: converted > 0
|
||||
// D-2: --fields 给了简化格式, 自动从 fields 推导 tables 默认值 (避免盲点 39)
|
||||
? buildTablesFromFields(opts.enCode, opts.fullName, rawFields as SimpleField[])
|
||||
: [
|
||||
: buildTablesFromFields(
|
||||
opts.enCode,
|
||||
opts.fullName,
|
||||
(fieldsArr as FullField[]).map(toSimpleField),
|
||||
)
|
||||
: opts.tables
|
||||
? JSON.parse(opts.tables)
|
||||
: type === 4
|
||||
? []
|
||||
: converted > 0
|
||||
// D-2: --fields 给了简化格式, 自动从 fields 推导 tables 默认值 (避免盲点 39)
|
||||
? buildTablesFromFields(
|
||||
opts.enCode,
|
||||
opts.fullName,
|
||||
(fieldsArr as FullField[]).map(toSimpleField),
|
||||
)
|
||||
: [
|
||||
{
|
||||
table: opts.enCode,
|
||||
typeId: '1',
|
||||
@@ -604,6 +621,7 @@ export function buildFormCreateCommand(): Command {
|
||||
'--enableFlow': '0|1',
|
||||
'--flowId': '工作流 id',
|
||||
'--autoRelease': '建完立刻发布 (type=4 自动跳过)',
|
||||
'--autoTable': 'v0.11 强制从 --fields 推导 --tables JSON (覆盖 --tables, 对齐 web formDesign Form.vue UX)',
|
||||
'--autoCreateMenu': 'v0.7.3 (盲点 47) 发布后自动挂菜单 (需 --menuParentId, 避免浏览器验证失败)',
|
||||
'--menuParentId': '挂菜单的父目录 id (--autoCreateMenu 时必传; 用 dacli menu list 拿)',
|
||||
'--ai': '白皮书 5.10.1 AI 快速建表 — 自然语言描述生成 enCode/fullName/fields',
|
||||
|
||||
Reference in new issue
Block a user