提交 601a40e8 编写于 作者: Mosher's avatar Mosher

update:更新表单值规则

上级 f1c2bb55
......@@ -58,6 +58,7 @@ const initRules = () => {
<template v-slot:default="{slotStyle, slotClass}">
<a-form-item
:class="slotClass"
:colon="false"
:style="slotStyle"
:name="name"
:rules="itemRules"
......
import { ControlVOBase, EditFormService } from '@core';
import { ControlVOBase, EditFormService, Verify, isEmpty } from '@core';
import { {{pascalCase ctrl.psAppDataEntity.codeName}}Service } from '@api/{{spinalCase ctrl.psAppDataEntity.codeName}}/{{spinalCase ctrl.psAppDataEntity.codeName}}-service';
/**
......@@ -115,16 +115,49 @@ export const ctrlState = {
},
rules: {
{{#each ctrl.psDEFormItemVRs as | ruleItem |}}
{{#if (eq ruleItem.valueRuleType 'SYSVALUERULE')}}
{{ruleItem.psDEFormItemName}}: [
{{#if (eq ruleItem.valueRuleType 'SYSVALUERULE')}}
{
trigger: ['change', 'blur'],
{{#eq ruleItem.psSysValueRule.ruleType 'REG'}}
trigger: ['change', 'blur'],
pattern: /{{ruleItem.psSysValueRule.regExCode}}/,
{{/eq}}
message:'{{ruleItem.psSysValueRule.ruleInfo}}'
}],
{{/eq}}
{{#eq ruleItem.psSysValueRule.ruleType 'SCRIPT'}}
validator: (rule: any, value: any, callback: any) => {
if (isEmpty(value)) {
return Promise.resolve();
}
let source: any = { '{{ruleItem.getPSDEFormItemName}}': value };
try {
eval(`{{ruleItem.psSysValueRule.scriptCode}}`);
} catch (error: any) {
App.getNotificationService().error({ message: '校验脚本值规则异常' });
}
return Promise.resolve();
}
{{/eq}}
},
{{else if (eq ruleItem.valueRuleType 'DEFVALUERULE')}}
{
validator: async (rule: any, value: any, callback: any) => {
if (isEmpty(value)) {
return Promise.resolve();
}
let source: any = { '{{ruleItem.getPSDEFormItemName}}': value };
const { isPast, infoMessage } = Verify.verifyDeRules(
'{{ruleItem.getPSDEFormItemName}}',
source,
{{> @macro/front-end/common/derules.hbs item=ruleItem.psDEFValueRule.getPSDEFVRGroupCondition}}
);
if (!isPast) {
return Promise.reject(infoMessage || '{{ruleItem.psDEFValueRule.ruleInfo}}');
}
return Promise.resolve();
}
}
{{/if}}
],
{{/each}}
},
};
\ No newline at end of file
......@@ -209,11 +209,24 @@ export const ctrlState = {
{{ruleItem.psDEGridEditItemName}}: [
{{#if (eq ruleItem.valueRuleType 'SYSVALUERULE')}}
{
trigger: ['change', 'blur'],
{{#eq ruleItem.psSysValueRule.ruleType 'REG'}}
trigger: ['change', 'blur'],
pattern: /{{ruleItem.psSysValueRule.regExCode}}/,
{{/eq}}
message:'{{ruleItem.psSysValueRule.ruleInfo}}'
{{/eq}}
{{#eq ruleItem.psSysValueRule.ruleType 'SCRIPT'}}
validator: (rule: any, value: any, callback: any, source: any) => {
if (isEmpty(value)) {
return Promise.resolve();
}
try {
eval(`{{ruleItem.psSysValueRule.scriptCode}}`);
} catch (error: any) {
App.getNotificationService().error({ message: '校验脚本值规则异常' });
}
return Promise.resolve();
}
{{/eq}}
},
{{else if (eq ruleItem.valueRuleType 'DEFVALUERULE')}}
{{#each ctrl.psDEGridEditItems as | editItem |}}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册