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

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

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