提交 29d6294a 编写于 作者: zhangkang's avatar zhangkang

update:系统值规则和必填值规则

上级 d6a03f67
{{>@macro/front-end/editors/include-editor.hbs}}
{{#eq item.psLayoutPos 'FLEX'}}
<div style="flex-grow: {{#if item.psLayoutPos.grow}}{{item.psLayoutPos.grow}}{{else}}0{{/if}};">
<AppFormItem v-show="state.detailsModel.{{item.codeName}}.visible" name="{{item.codeName}}" label="{{item.caption}}">
<AppFormItem v-show="state.detailsModel.{{item.codeName}}.visible" name="{{item.codeName}}" :rules="state.rules.{{item.codeName}}" label="{{item.caption}}">
{{#if item.psEditor}}
{{>(lookup . 'item.psEditor.editorType') item=item ctrlType="form"}}
{{/if}}
......@@ -10,7 +10,7 @@
{{else}}
<a-col
{{> @macro/front-end/widgets/common/layout-pos.hbs item=item.psLayoutPos}} >
<AppFormItem v-show="state.detailsModel.{{item.codeName}}.visible" name="{{item.codeName}}" :required="state.detailsModel.{{item.codeName}}.required" label="{{item.caption}}">
<AppFormItem v-show="state.detailsModel.{{item.codeName}}.visible" name="{{item.codeName}}" :rules="state.rules.{{item.codeName}}" :required="state.detailsModel.{{item.codeName}}.required" label="{{item.caption}}">
{{#if item.psEditor}}
{{>(lookup . 'item.psEditor.editorType') item=item ctrlType="form"}}
{{/if}}
......
<script setup lang="ts">
import { IActionParam } from "@core";
import { IActionParam } from '@core';
interface FormGroupProps{
interface FormGroupProps {
name: string;
error?: string;
label: string;
required:boolean;
required: boolean;
rules?: any;
}
interface FormGroupEmit{
(name: 'componentEvent', value: IActionParam): void
interface FormGroupEmit {
(name: 'componentEvent', value: IActionParam): void;
}
const props = withDefaults(defineProps<FormGroupProps>(), {});
const emit = defineEmits<FormGroupEmit>();
onBeforeMount(() => {
initRules();
});
let itemRules: any = [];
const initRules = () => {
if (props.rules) {
itemRules.push(...props.rules);
}
if (props.required) {
itemRules.push({
trigger: ['change', 'blur'],
required: props.required,
message: props.label + '必须填写',
});
}
};
//
</script>
<template>
<a-form-item :name="name" :label="label" :help="error" :required="required" :validateStatus="error ? 'error': 'validating'">
<a-form-item
:name="name"
:rules="itemRules"
:label="label"
:help="error"
:required="required"
:validateStatus="error ? 'error' : 'validating'"
>
<slot></slot>
</a-form-item>
</template>
<style lang="scss">
</style>
\ No newline at end of file
......@@ -72,25 +72,17 @@ export const ctrlState = {
{{/each}}
},
rules: {
{{#each ctrl.psDEFormEditItemVRs as | ruleItem |}}
{{#neq ruleItem 2}}
{{#if ruleItem.valueRuleType 'DEFVALUERULE'}}
{{psDEFormEditItemName}}: [
{{#each ruleItem.psDEFVRGroupCondition as | condition |}}
{trigger: ['change', 'blur'],
validator: (_rule: RuleObject, value: string) => verifyRules(_rule,value,{
{{#condition.condType}}type: '{{condition.condType}}',{{/condition.condType}}
{{#condition.name}}name: '{{condition.name}}',{{/condition.name}}
{{#condition.maxValue}}maxValue: '{{condition.maxValue}}',{{/condition.maxValue}}
{{#condition.minValue}}minValue: '{{condition.minValue}}',{{/condition.minValue}}
{{#condition.ruleInfo}}ruleInfo: '{{condition.ruleInfo}}',{{/condition.ruleInfo}}
{{#condition.includeMaxValue}}includeMaxValue: '{{condition.includeMaxValue}}',{{/condition.includeMaxValue}}
{{#condition.includeMinValue}}includeMinValue: '{{condition.includeMinValue}}',{{/condition.includeMinValue}}
}) }
{{/each}}
]
{{/if}}
{{/neq}}
{{/each}}
{{#each ctrl.psDEFormItemVRs as | ruleItem |}}
{{#if ruleItem.valueRuleType 'SYSVALUERULE'}}
{{ruleItem.psDEFormItemName}}: [
{
trigger: ['change', 'blur'],
{{#eq ruleItem.psSysValueRule.ruleType 'REG'}}
pattern: /{{ruleItem.psSysValueRule.regExCode}}/,
{{/eq}}
message:'{{ruleItem.psSysValueRule.ruleInfo}}'
}],
{{/if}}
{{/each}}
},
};
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册