提交 3ab34835 编写于 作者: RedPig97's avatar RedPig97

update: 更新

上级 8aa372b1
{{#each items as | formDetail |}}
{
caption: '{{formDetail.caption}}',
codeName: '{{formDetail.codeName}}',
name: '{{formDetail.name}}',
{{#if (eq formDetail.detailType "FORMITEM")}}
dataType: '{{formDetail.dataType}}',
detailStyle: '{{formDetail.detailStyle}}',
resetItemName: '{{formDetail.resetItemName}}',
valueItemName: '{{formDetail.valueItemName}}',
{{/if}}
},
{{#if formDetail.psDEFormDetails}}
{{>(lookup 'FORMDETAILSMODEL') items=formDetail.psDEFormDetails}}
{{/if}}
{{/each}}
{{#*inline "FORMPAGE"}}{{>@macro/form-detail/form-page.hbs}}{{/inline}} {{#*inline "FORMPAGE"}}{{>@macro/form-detail/form-page.hbs}}{{/inline}}
{{#*inline "GROUPPANEL"}}{{>@macro/form-detail/form-group.hbs}}{{/inline}} {{#*inline "GROUPPANEL"}}{{>@macro/form-detail/form-group.hbs}}{{/inline}}
{{#*inline "FORMITEM"}}{{>@macro/form-detail/form-item.hbs}}{{/inline}} {{#*inline "FORMITEM"}}{{>@macro/form-detail/form-item.hbs}}{{/inline}}
\ No newline at end of file {{#*inline "FORMDETAILSMODEL"}}{{>@macro/form-detail/form-details-model.hbs}}{{/inline}}
\ No newline at end of file
...@@ -28,12 +28,31 @@ export class FormControl extends MainControl { ...@@ -28,12 +28,31 @@ export class FormControl extends MainControl {
*/ */
public formDataChange(name: string, value: any) { public formDataChange(name: string, value: any) {
this.controlState.data[name] = value; this.controlState.data[name] = value;
// TODO 重置项逻辑 this.resetFormData(name);
// TODO 表单项更新 // TODO 表单项更新
// TODO 动态控制逻辑 // TODO 动态控制逻辑
// TODO 自动保存(可以单独做一个逻辑块,监听data的变化) // TODO 自动保存(可以单独做一个逻辑块,监听data的变化)
} }
/**
* @description 表单项重置
* @param {string} name
* @memberof FormControl
*/
public resetFormData(name: string) {
const formItems: any[] = this.controlState.itemsModel;
if (formItems && formItems.length > 0) {
for (const item of formItems) {
if (item.resetItemName && item.resetItemName == name) {
this.formDataChange( item.name, null);
if (item.valueItemName) {
this.formDataChange(item.valueItemName, null);
}
}
}
}
}
/** /**
* 在表单执行某些行为能力后,表单整体数据发生改变后被调用。会依次执行以下逻辑: * 在表单执行某些行为能力后,表单整体数据发生改变后被调用。会依次执行以下逻辑:
* 1. * 1.
...@@ -301,17 +320,12 @@ export class FormControl extends MainControl { ...@@ -301,17 +320,12 @@ export class FormControl extends MainControl {
const { load } = this.useLoad(props); const { load } = this.useLoad(props);
const { save } = this.useSave(props); const { save } = this.useSave(props);
const handleEditorEvent = this.handleEditorEvent.bind(this);
this.handleEditorEvent = (actionParam: IActionParam) => {
handleEditorEvent(actionParam);
};
return { return {
...superParams, ...superParams,
state: this.controlState, state: this.controlState,
load, load,
save, save,
handleEditorEvent: this.handleEditorEvent, handleEditorEvent: this.handleEditorEvent.bind(this),
}; };
} }
} }
{{>@macro/form-detail/include-form.hbs}}
import { ControlVOBase, verifyRules } from '@ibiz-core'; import { ControlVOBase, verifyRules } from '@ibiz-core';
import { ControlService } from './{{spinalCase ctrl.codeName}}-form-service'; import { ControlService } from './{{spinalCase ctrl.codeName}}-form-service';
...@@ -6,6 +7,11 @@ export const CtrlConfig = { ...@@ -6,6 +7,11 @@ export const CtrlConfig = {
controlName: '{{ctrl.name}}', controlName: '{{ctrl.name}}',
controlService: new ControlService(), controlService: new ControlService(),
data: {}, data: {},
itemsModel: [
{{#each ctrl.psDEFormPages as | FormPage | }}
{{>(lookup 'FORMDETAILSMODEL') items=FormPage.psDEFormDetails}}
{{/each}}
],
rules: { rules: {
{{#each ctrl.psDEFormEditItemVRs as | ruleItem |}} {{#each ctrl.psDEFormEditItemVRs as | ruleItem |}}
{{#neq ruleItem 2}} {{#neq ruleItem 2}}
...@@ -14,20 +20,20 @@ export const CtrlConfig = { ...@@ -14,20 +20,20 @@ export const CtrlConfig = {
{{#each ruleItem.psDEFVRGroupCondition as | condition |}} {{#each ruleItem.psDEFVRGroupCondition as | condition |}}
{trigger: ['change', 'blur'], {trigger: ['change', 'blur'],
validator: (_rule: RuleObject, value: string) => verifyRules(_rule,value,{ validator: (_rule: RuleObject, value: string) => verifyRules(_rule,value,{
{{#condition.condType}}'Type': {{condition.condType}},{{/condition.condType}} {{#condition.condType}}type: {{condition.condType}},{{/condition.condType}}
{{#condition.name}}'name': {{condition.name}},{{/condition.name}} {{#condition.name}}name: {{condition.name}},{{/condition.name}}
{{#condition.maxValue}}'maxValue': {{condition.maxValue}},{{/condition.maxValue}} {{#condition.maxValue}}maxValue: {{condition.maxValue}},{{/condition.maxValue}}
{{#condition.minValue}}'minValue': {{condition.minValue}},{{/condition.minValue}} {{#condition.minValue}}minValue: {{condition.minValue}},{{/condition.minValue}}
{{#condition.ruleInfo}}'ruleInfo': {{condition.ruleInfo}},{{/condition.ruleInfo}} {{#condition.ruleInfo}}ruleInfo: {{condition.ruleInfo}},{{/condition.ruleInfo}}
{{#condition.includeMaxValue}}'includeMaxValue': {{condition.includeMaxValue}},{{/condition.includeMaxValue}} {{#condition.includeMaxValue}}includeMaxValue: {{condition.includeMaxValue}},{{/condition.includeMaxValue}}
{{#condition.includeMinValue}}'includeMinValue': {{condition.includeMinValue}},{{/condition.includeMinValue}} {{#condition.includeMinValue}}includeMinValue: {{condition.includeMinValue}},{{/condition.includeMinValue}}
}) } }) }
{{/each}} {{/each}}
] ]
{{/if}} {{/if}}
{{/neq}} {{/neq}}
{{/each}} {{/each}}
} },
}; };
/** /**
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册