feat(form): step machine v0.11e+ 严格镜像 web 端校验链 (10 错误一次性暴露)
dacli/src/commands/form/_validate.ts (241 → ~440 行):
- 新增 ENCODE_REGEXP / FULLNAME_REGEXP / FOLDER_REGEXP / STARTNUMBER_REGEXP / NO_VMODEL_LIST 常量
(镜像 web formValidate.ts:24-28 + FormGenerator/helper/config.ts:4-8)
- 新增 VALID_TYPES = {1,2,3,4} (镜像 Form.vue:107)
- step 0 加: fullName 长度+字符 + enCode 长度+禁下划线 + category 必填 + type 合法性
- step 1 加: billRule + relationForm 三必填 + popupSelect 三必填 + autoComplete 二必填
+ relationQuery + rowFormItem + uploadFile/uploadImg + link/iframe URL
- step 2 加: tree type=2 (treeDictionary/props/relation/sync) + group type=3 + parent type=5
+ card type=6 + uploadTpl + printTpl
- 新增 isUrl() helper
- 新增错误码 (25+): VS-CATEGORY / VS-RELATION-MODEL/PROPS/FIELD / VS-POPUP-IFACE/PROPS/FIELD
/ VS-AUTO-IFACE/FIELD / VS-RELQUERY-MODEL/COLS / VS-BILLRULE-DIGIT/START/START-FORMAT/RULE
/ VS-ROW-CHILDREN / VS-UPLOAD-BTN/PATH/FOLDER/FOLDER-FMT / VS-UPLOAD-TPL / VS-PRINT-TPL
/ VS-LINK-URL / VS-TREE-DICT/PROPS-VALUE/PROPS-LABEL/PROPS-CHILDREN/RELATION/SYNC-IFACE
/ VS-GROUP-FIELD / VS-PARENT-FIELD / VS-CARD-TITLE/DISPLAY / VS-VMODEL/FORMAT
/ VS-TYPE / VS030-FORMAT/LEN / VS032-LEN/FORMAT
dacli/src/commands/form/create.ts:901-909: validateFormCreate 调用透传 category
E2E 验证 (10 错误一次性暴露):
- step0 (4 errs): fullName 字符 + enCode 下划线 + category 空 + type=5 非法
- step1 (4 errs): relationForm 缺 modelId/propsValue/relationField + popupSelect 缺 interfaceId
- step2 (2 errs): tree type=2 缺 dictionary + treeRelation
回归: developSystem 5 form + workSystem 82 form list/info 全部正常
派子代理四步法执行, 详见 .claude/memory/dacli-step-machine-strict-mirror-2026-06-28.md
This commit is contained in:
1 parent
e131e3398b
commit
634ae10288
2 files changed
+229
-28
No files matched your search
+228
-28
@@ -4,16 +4,17 @@
|
||||
* 镜像 web Form.vue handleNext + handleSubmit 的前端校验逻辑 (Generator.getData + ColumnDesign.getData)
|
||||
* 让 dacli form create 在发 API 之前暴露问题, AI 不用去浏览器试错
|
||||
*
|
||||
* 设计原则 (2026-06-26 v0.11d+):
|
||||
* 设计原则 (2026-06-26 v0.11d+ → 2026-06-28 v0.11e+):
|
||||
* - 不是复刻 web UI 行为 (drag/drop/click), 而是 mirror JNPF 业务规则
|
||||
* - 跟 BS-50/BS-44/BS-42 等盲点守卫一致: 在发 API 前校验
|
||||
* - 校验失败 → 返回 step N + 错误列表, 不发 API
|
||||
* - 校验通过 → 1 次 create API call (不拆步骤)
|
||||
* - v0.11e+ 严格镜像 web 端 formValidate('enCode') (禁下划线) + Form.vue schemas 6 字段必填
|
||||
*
|
||||
* step 镜像对应:
|
||||
* step 0: 基础信息 (fullName, enCode 格式, tables.length, 子表外键/关联字段)
|
||||
* step 1: formData 字段 (formFields ≥ 1, vmodel 格式, 关联控件 modelId 等)
|
||||
* step 2: columnData (columnList ≥ 1 当 webType≠1)
|
||||
* step 0: 基础信息 (fullName, enCode 格式禁下划线, category 必填, type 合法性, tables.length, 子表外键)
|
||||
* step 1: formData 字段 (formFields ≥ 1, vmodel 格式, billRule/popupSelect/relationForm/autoComplete/upload 控件级)
|
||||
* step 2: columnData (columnList ≥ 1 当 webType≠1, 树形 treeDataSource/props/relation/sync 必填, 卡片/分组/父级字段)
|
||||
*/
|
||||
|
||||
export interface ValidationError {
|
||||
@@ -34,14 +35,50 @@ export interface StepValidation {
|
||||
errors: ValidationError[]
|
||||
}
|
||||
|
||||
/** vmodel 格式正则 — 镜像 Generator.getData() line 241 */
|
||||
/** vmodel 格式正则 — 镜像 Generator.getData() line 241 (字段 vmodel 允许下划线, 只给控件字段用) */
|
||||
// eslint-disable-next-line regexp/no-unused-capturing-group
|
||||
const VMODEL_REGEXP = /(^_([a-z0-9]_?)*$)|(^[a-z](_?[a-z0-9])*_?$)/i
|
||||
|
||||
/** v0.11e+ enCode 格式正则 — 镜像 web 端 formValidate('enCode') (formValidate.ts:24-28)
|
||||
* 禁下划线, 禁小数点首尾; 只允许字母数字和小数点 (小数点不能放首尾)
|
||||
* 区别于 VMODEL_REGEXP: 表单编码 (enCode/tableName) 严格禁下划线, 字段 vmodel 允许下划线
|
||||
*/
|
||||
// eslint-disable-next-line regexp/no-unused-capturing-group
|
||||
const ENCODE_REGEXP = /^[a-z0-9]((([a-z0-9])*)|(([a-z0-9]+|\.)*[a-z0-9]))$/i
|
||||
|
||||
/** v0.11e+ fullName 格式正则 — 镜像 web 端 formValidate('fullName') (formValidate.ts:33-36)
|
||||
* 中文/字母/数字, 禁特殊符号 */
|
||||
// eslint-disable-next-line regexp/no-unused-capturing-group
|
||||
const FULLNAME_REGEXP = /^([一-龥a-z0-9])+$/i
|
||||
|
||||
/** v0.11e+ upload folder name 正则 — 镜像 Generator.getData() line 295 */
|
||||
// eslint-disable-next-line regexp/no-unused-capturing-group
|
||||
const FOLDER_REGEXP = /^[a-z0-9][\w-]{0,99}$/i
|
||||
|
||||
/** v0.11e+ billRule startNumber 正则 — 镜像 Generator.getData() line 263
|
||||
* 数字, 不能为 0 */
|
||||
// eslint-disable-next-line regexp/no-unused-capturing-group
|
||||
const STARTNUMBER_REGEXP = /^\d*[1-9]$/
|
||||
|
||||
/** v0.11e+ 合法 type 集合 — 镜像 Form.vue:107 type 默认 1, 合法 {1,2,3,4} */
|
||||
const VALID_TYPES = [1, 2, 3, 4] as const
|
||||
|
||||
/** v0.11e+ noVModelList — 镜像 web FormGenerator helper/config.ts:4-8
|
||||
* 这些控件无 vmodel, 跳过 vmodel 必填校验 (但 isStorage=true 例外)
|
||||
* vModelIgnoreList + dyStorageList
|
||||
*/
|
||||
const NO_VMODEL_LIST = [
|
||||
'divider', 'text', 'link', 'alert', 'groupTitle', 'button', 'barcode', 'qrcode', 'iframe',
|
||||
'relationQuery', 'carousel',
|
||||
'relationFormAttr', 'popupAttr', 'calculate', 'dateCalculate',
|
||||
]
|
||||
|
||||
/** step 0: 基础信息校验 (镜像 Form.vue handleNext step 0: validate() + state.tables 检查 + exist()) */
|
||||
export function validateBasicInfo(opts: {
|
||||
fullName?: string
|
||||
enCode?: string
|
||||
/** v0.11e+ 新增: 表单分类 (镜像 Form.vue:60-66 schemas required) */
|
||||
category?: string
|
||||
type: number
|
||||
webType: number
|
||||
tables: any[]
|
||||
@@ -49,14 +86,46 @@ export function validateBasicInfo(opts: {
|
||||
const errors: ValidationError[] = []
|
||||
|
||||
// validate() 基础信息必填 (Form.vue:324 handleNext step 0)
|
||||
// fullName: 必填 + 长度 ≤ 100 + fullName 正则 (formValidate.ts:33-36)
|
||||
if (!opts.fullName || !opts.fullName.trim()) {
|
||||
errors.push({ field: 'fullName', message: '表单名称不能为空' })
|
||||
} else if (opts.fullName.length > 100) {
|
||||
errors.push({ field: 'fullName', message: '表单名称最多 100 字符', code: 'VS032-LEN' })
|
||||
} else if (!FULLNAME_REGEXP.test(opts.fullName)) {
|
||||
errors.push({ field: 'fullName', message: '名称不能含有特殊符号', code: 'VS032-FORMAT' })
|
||||
}
|
||||
|
||||
// enCode: 必填 + 长度 ≤ 50 + formValidate('enCode') 禁下划线 (formValidate.ts:24-28)
|
||||
// v0.11e+ 重要修正: 之前用 VMODEL_REGEXP (允许下划线, 给字段 vmodel 用), 错!
|
||||
if (!opts.enCode || !opts.enCode.trim()) {
|
||||
errors.push({ field: 'enCode', message: '表单编码不能为空' })
|
||||
} else if (!VMODEL_REGEXP.test(opts.enCode)) {
|
||||
// 镜像 Generator.getData() line 247-249: tableName RegExp 校验 (enCode 也走同一规则)
|
||||
errors.push({ field: 'enCode', message: '只能由字母、数字、下划线组成,且以字母开头', code: 'VS030' })
|
||||
errors.push({ field: 'enCode', message: '表单编码不能为空', code: 'VS030' })
|
||||
} else if (opts.enCode.length > 50) {
|
||||
errors.push({ field: 'enCode', message: '表单编码最多 50 字符', code: 'VS030-LEN' })
|
||||
} else if (!ENCODE_REGEXP.test(opts.enCode)) {
|
||||
// 镜像 formValidate.ts:26-27: '只能输入英文、数字和小数点且小数点不能放在首尾'
|
||||
errors.push({
|
||||
field: 'enCode',
|
||||
message: '只能输入英文、数字和小数点且小数点不能放在首尾',
|
||||
code: 'VS030-FORMAT',
|
||||
})
|
||||
}
|
||||
|
||||
// v0.11e+ 新增 category 必填校验 (镜像 Form.vue:60-66 schemas required: true)
|
||||
if (!opts.category || !opts.category.trim()) {
|
||||
errors.push({
|
||||
field: 'category',
|
||||
message: '表单分类不能为空 (镜像 web Form.vue:60-66 schemas required)',
|
||||
code: 'VS-CATEGORY',
|
||||
})
|
||||
}
|
||||
|
||||
// v0.11e+ 新增 type 合法性校验 (合法集合 {1,2,3,4})
|
||||
if (!VALID_TYPES.includes(opts.type as any)) {
|
||||
errors.push({
|
||||
field: 'type',
|
||||
message: `type 必须是 1=表单/2=列表/3=树/4=视图 之一, 当前=${opts.type}`,
|
||||
code: 'VS-TYPE',
|
||||
})
|
||||
}
|
||||
|
||||
// state.tables 检查 (Form.vue:329-345 handleNext step 0)
|
||||
@@ -132,50 +201,106 @@ export function validateFormData(formData: { fields?: any[] } | null, type: numb
|
||||
const label = config.label || parentLabel || '(未命名)'
|
||||
|
||||
// colFormItem 控件: vmodel 必填 + 格式 (line 256-259)
|
||||
// v0.11e+ 镜像 web: noVModelList 跳过 (但 isStorage=true 例外)
|
||||
if (config.layout === 'colFormItem') {
|
||||
if (!e.__vModel__) {
|
||||
errors.push({ field: formId, message: '控件字段不能为空' })
|
||||
} else if (!VMODEL_REGEXP.test(e.__vModel__)) {
|
||||
errors.push({ field: formId, message: `控件字段不规范: ${e.__vModel__}` })
|
||||
const skipVModel = NO_VMODEL_LIST.includes(config.jnpfKey) && !e.isStorage
|
||||
if (!skipVModel) {
|
||||
if (!e.__vModel__) {
|
||||
errors.push({ field: formId, message: '控件字段不能为空', code: 'VS-VMODEL' })
|
||||
} else if (!VMODEL_REGEXP.test(e.__vModel__)) {
|
||||
errors.push({ field: formId, message: `控件字段不规范: ${e.__vModel__}`, code: 'VS-VMODEL-FORMAT' })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// relationForm: modelId/propsValue/relationField 必填 (line 272-276)
|
||||
if (config.jnpfKey === 'relationForm') {
|
||||
if (!e.modelId) errors.push({ field: formId, message: `关联功能不能为空 (label: ${label})` })
|
||||
if (!e.propsValue) errors.push({ field: formId, message: `存储字段不能为空 (label: ${label})` })
|
||||
if (!e.relationField) errors.push({ field: formId, message: `回显字段不能为空 (label: ${label})` })
|
||||
if (!e.modelId) errors.push({ field: formId, message: `关联功能不能为空 (label: ${label})`, code: 'VS-RELATION-MODEL' })
|
||||
if (!e.propsValue) errors.push({ field: formId, message: `存储字段不能为空 (label: ${label})`, code: 'VS-RELATION-PROPS' })
|
||||
if (!e.relationField) errors.push({ field: formId, message: `回显字段不能为空 (label: ${label})`, code: 'VS-RELATION-FIELD' })
|
||||
}
|
||||
|
||||
// popupSelect / popupTableSelect (line 277-281)
|
||||
if (config.jnpfKey === 'popupSelect' || config.jnpfKey === 'popupTableSelect') {
|
||||
if (!e.interfaceId) errors.push({ field: formId, message: `数据接口不能为空 (label: ${label})` })
|
||||
if (!e.propsValue) errors.push({ field: formId, message: `存储字段不能为空 (label: ${label})` })
|
||||
if (!e.relationField) errors.push({ field: formId, message: `回显字段不能为空 (label: ${label})` })
|
||||
if (!e.interfaceId) errors.push({ field: formId, message: `数据接口不能为空 (label: ${label})`, code: 'VS-POPUP-IFACE' })
|
||||
if (!e.propsValue) errors.push({ field: formId, message: `存储字段不能为空 (label: ${label})`, code: 'VS-POPUP-PROPS' })
|
||||
if (!e.relationField) errors.push({ field: formId, message: `回显字段不能为空 (label: ${label})`, code: 'VS-POPUP-FIELD' })
|
||||
}
|
||||
|
||||
// autoComplete (line 282-285)
|
||||
if (config.jnpfKey === 'autoComplete') {
|
||||
if (!e.interfaceId) errors.push({ field: formId, message: `数据接口不能为空 (label: ${label})` })
|
||||
if (!e.relationField) errors.push({ field: formId, message: `回显字段不能为空 (label: ${label})` })
|
||||
if (!e.interfaceId) errors.push({ field: formId, message: `数据接口不能为空 (label: ${label})`, code: 'VS-AUTO-IFACE' })
|
||||
if (!e.relationField) errors.push({ field: formId, message: `回显字段不能为空 (label: ${label})`, code: 'VS-AUTO-FIELD' })
|
||||
}
|
||||
|
||||
// relationQuery (v0.11e+ 新镜像 line 317-320): modelId + columnOptions 二必填
|
||||
if (config.jnpfKey === 'relationQuery') {
|
||||
if (!e.modelId) errors.push({ field: formId, message: `关联功能不能为空 (label: ${label})`, code: 'VS-RELQUERY-MODEL' })
|
||||
if (!e.columnOptions || e.columnOptions.length === 0) {
|
||||
errors.push({ field: formId, message: `显示字段不能为空 (label: ${label})`, code: 'VS-RELQUERY-COLS' })
|
||||
}
|
||||
}
|
||||
|
||||
// billRule: 规则类型校验 (line 260-271)
|
||||
if (config.jnpfKey === 'billRule') {
|
||||
if (config.ruleType === 2) {
|
||||
if (config.ruleConfig?.type === 1) {
|
||||
const reg = /^\d*[1-9]$/
|
||||
if (!config.ruleConfig?.digit) errors.push({ field: formId, message: `中位数不能为空 (label: ${label})` })
|
||||
if (!config.ruleConfig?.startNumber) errors.push({ field: formId, message: `起始值不能为空 (label: ${label})` })
|
||||
else if (!reg.test(config.ruleConfig.startNumber)) {
|
||||
errors.push({ field: formId, message: `起始值只能输入数字且不能为0 (label: ${label})` })
|
||||
if (!config.ruleConfig?.digit) errors.push({ field: formId, message: `中位数不能为空 (label: ${label})`, code: 'VS-BILLRULE-DIGIT' })
|
||||
if (!config.ruleConfig?.startNumber) errors.push({ field: formId, message: `起始值不能为空 (label: ${label})`, code: 'VS-BILLRULE-START' })
|
||||
else if (!STARTNUMBER_REGEXP.test(config.ruleConfig.startNumber)) {
|
||||
errors.push({ field: formId, message: `起始值只能输入数字且不能为0 (label: ${label})`, code: 'VS-BILLRULE-START-FORMAT' })
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!config.rule) errors.push({ field: formId, message: `单据模板不能为空 (label: ${label})` })
|
||||
if (!config.rule) errors.push({ field: formId, message: `单据模板不能为空 (label: ${label})`, code: 'VS-BILLRULE-RULE' })
|
||||
}
|
||||
}
|
||||
|
||||
// rowFormItem 子控件 (line 286)
|
||||
if (config.layout === 'rowFormItem' && !config.children?.length) {
|
||||
errors.push({ field: formId, message: `控件中没有组件 (label: ${label})`, code: 'VS-ROW-CHILDREN' })
|
||||
}
|
||||
|
||||
// uploadFile / uploadImg 校验 (line 287-312)
|
||||
if (config.jnpfKey === 'uploadFile' || config.jnpfKey === 'uploadImg') {
|
||||
// 按钮文字 (uploadImg showType=button 或 uploadFile)
|
||||
if (((config.jnpfKey === 'uploadImg' && e.showType === 'button') || config.jnpfKey === 'uploadFile') && !e.buttonText) {
|
||||
errors.push({ field: formId, message: `按钮文字不能为空 (label: ${label})`, code: 'VS-UPLOAD-BTN' })
|
||||
}
|
||||
// 自定义路径 (pathType=selfPath)
|
||||
if (e.pathType === 'selfPath') {
|
||||
if (!e.sortRule || !e.sortRule.length) {
|
||||
errors.push({ field: formId, message: `自定义路径不能为空 (label: ${label})`, code: 'VS-UPLOAD-PATH' })
|
||||
}
|
||||
if (e.sortRule?.includes('3')) {
|
||||
if (e.folder) {
|
||||
const folderList = String(e.folder).split('/')
|
||||
let badFolder = ''
|
||||
for (const el of folderList) {
|
||||
if (!el || !FOLDER_REGEXP.test(el)) {
|
||||
badFolder = el
|
||||
break
|
||||
}
|
||||
}
|
||||
if (badFolder) {
|
||||
errors.push({ field: formId, message: `文件夹名不正确 (label: ${label}, segment: ${badFolder})`, code: 'VS-UPLOAD-FOLDER-FMT' })
|
||||
}
|
||||
} else {
|
||||
errors.push({ field: formId, message: `文件夹名不能为空 (label: ${label})`, code: 'VS-UPLOAD-FOLDER' })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// link / iframe href URL 校验 (line 313)
|
||||
if ((config.jnpfKey === 'link' || config.jnpfKey === 'iframe') && e.href && !isUrl(e.href)) {
|
||||
errors.push({ field: formId, message: `请输入正确的链接地址 (label: ${label})`, code: 'VS-LINK-URL' })
|
||||
}
|
||||
|
||||
// formAttr: 打印模板/业务主键 (Form.vue line 245-246 镜像)
|
||||
// 注意: formConf 在 formData.formConf 里 (顶层), 不是 fields. 此校验在 caller 层做.
|
||||
// dacli 这里不重复, 因为 formConf 已由 web buildFormData 镜像保证完整性.
|
||||
|
||||
// 递归子表 children
|
||||
if (Array.isArray(config.children) && config.children.length > 0) {
|
||||
loop(config.children, label)
|
||||
@@ -193,7 +318,9 @@ export function validateFormData(formData: { fields?: any[] } | null, type: numb
|
||||
}
|
||||
}
|
||||
|
||||
/** step 2: columnData 校验 (镜像 ColumnDesign.getData() 核心规则: columnList ≥ 1 当 webType≠1) */
|
||||
/** step 2: columnData 校验 (镜像 ColumnDesign.getData() 核心规则: columnList ≥ 1 当 webType≠1)
|
||||
* v0.11e+ 严格镜像 Main.vue:283-340 树形/分组/父级/卡片/导入模板/打印模板 7 类校验
|
||||
*/
|
||||
export function validateColumnData(columnData: any | null, webType: number): StepValidation {
|
||||
const errors: ValidationError[] = []
|
||||
|
||||
@@ -208,6 +335,69 @@ export function validateColumnData(columnData: any | null, webType: number): Ste
|
||||
message: '列表字段不允许为空 (webType≠1 必须勾选至少一个列表列)',
|
||||
code: 'VS402',
|
||||
})
|
||||
// 没有 columnList 时其他校验无意义, 直接返回
|
||||
return { ok: false, step: 2, stepName: '列表设计', errors }
|
||||
}
|
||||
|
||||
// v0.11e+ 严格镜像 ColumnDesign.getData() line 283-310 树形校验
|
||||
// type=2 是树形列表 (Main.vue columnConfig column.type=2)
|
||||
if (columnData.type == 2) {
|
||||
if (columnData.treeDataSource === 'dictionary' && !columnData.treeDictionary) {
|
||||
errors.push({
|
||||
field: 'columnData.treeDictionary',
|
||||
message: '请选择数据字典 (镜像 ColumnDesign.Main.vue:284-287)',
|
||||
code: 'VS-TREE-DICT',
|
||||
})
|
||||
}
|
||||
if (columnData.treeDataSource === 'api') {
|
||||
if (!columnData.treePropsValue) {
|
||||
errors.push({ field: 'columnData.treePropsValue', message: '请输入主键字段', code: 'VS-TREE-PROPS-VALUE' })
|
||||
}
|
||||
if (!columnData.treePropsLabel) {
|
||||
errors.push({ field: 'columnData.treePropsLabel', message: '请输入回显字段', code: 'VS-TREE-PROPS-LABEL' })
|
||||
}
|
||||
if (!columnData.treePropsChildren) {
|
||||
errors.push({ field: 'columnData.treePropsChildren', message: '请输入子级字段', code: 'VS-TREE-PROPS-CHILDREN' })
|
||||
}
|
||||
}
|
||||
if (!columnData.treeRelation) {
|
||||
errors.push({ field: 'columnData.treeRelation', message: '请选择关联字段', code: 'VS-TREE-RELATION' })
|
||||
}
|
||||
if (!columnData.treeSyncInterfaceId && columnData.treeSyncType == 1) {
|
||||
errors.push({ field: 'columnData.treeSyncInterfaceId', message: '请选择异步数据接口', code: 'VS-TREE-SYNC-IFACE' })
|
||||
}
|
||||
}
|
||||
|
||||
// type=3 分组列表 (line 311-314)
|
||||
if (columnData.type == 3 && !columnData.groupField) {
|
||||
errors.push({ field: 'columnData.groupField', message: '请选择分组字段', code: 'VS-GROUP-FIELD' })
|
||||
}
|
||||
|
||||
// type=5 父级字段 (line 315-318)
|
||||
if (columnData.type == 5 && !columnData.parentField) {
|
||||
errors.push({ field: 'columnData.parentField', message: '请选择父级字段', code: 'VS-PARENT-FIELD' })
|
||||
}
|
||||
|
||||
// 导入模板 (line 319-326): 非 type=5, 列表含 upload 按钮 + selectKey 空
|
||||
if (columnData.type !== 5 && Array.isArray(columnData.btnsList)) {
|
||||
const hasUploadBtn = columnData.btnsList.some((o: any) => o.value === 'upload' && o.show)
|
||||
if (hasUploadBtn && !columnData.uploaderTemplateJson?.selectKey) {
|
||||
errors.push({ field: 'columnData.uploaderTemplateJson.selectKey', message: '请设置导入模板', code: 'VS-UPLOAD-TPL' })
|
||||
}
|
||||
const hasPrintBtn = columnData.btnsList.some((o: any) => o.value === 'batchPrint' && o.show)
|
||||
if (hasPrintBtn && (!columnData.printIds || !columnData.printIds.length)) {
|
||||
errors.push({ field: 'columnData.printIds', message: '请选择打印模板', code: 'VS-PRINT-TPL' })
|
||||
}
|
||||
}
|
||||
|
||||
// type=6 卡片列表 (line 331-340)
|
||||
if (columnData.type == 6) {
|
||||
if (!columnData?.cardListConfig?.titleField) {
|
||||
errors.push({ field: 'columnData.cardListConfig.titleField', message: '请选择卡片标题字段', code: 'VS-CARD-TITLE' })
|
||||
}
|
||||
if (!columnData?.cardListConfig?.displayFields) {
|
||||
errors.push({ field: 'columnData.cardListConfig.displayFields', message: '请选择卡片显示字段', code: 'VS-CARD-DISPLAY' })
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -222,6 +412,8 @@ export function validateColumnData(columnData: any | null, webType: number): Ste
|
||||
export function validateFormCreate(opts: {
|
||||
fullName?: string
|
||||
enCode?: string
|
||||
/** v0.11e+ 新增: 表单分类 (镜像 Form.vue:60-66 schemas required) */
|
||||
category?: string
|
||||
type: number
|
||||
webType: number
|
||||
tables: any[]
|
||||
@@ -239,3 +431,11 @@ export function validateFormCreate(opts: {
|
||||
steps: [s0, s1, s2],
|
||||
}
|
||||
}
|
||||
|
||||
/** v0.11e+ URL 校验 — 镜像 web Generator.getData() line 313 的 isUrl 简化版
|
||||
* web 端 isUrl 走 utils 包, 这里给一份最简实现覆盖 95% 场景
|
||||
*/
|
||||
function isUrl(url: string): boolean {
|
||||
if (!url || typeof url !== 'string') return false
|
||||
return /^(http|https):\/\/[\w-]+(\.[\w-]+)+([\w\-.,@?^=%&:/~+#]*[\w\-@?^=%&/~+#])?/i.test(url)
|
||||
}
|
||||
@@ -901,6 +901,7 @@ export function buildFormCreateCommand(): Command {
|
||||
const validation = validateFormCreate({
|
||||
fullName: opts.fullName,
|
||||
enCode: opts.enCode,
|
||||
category: opts.category,
|
||||
type,
|
||||
webType,
|
||||
tables,
|
||||
|
||||
Reference in new issue
Block a user