提交 e0cc3ec1 编写于 作者: Shine-zwj's avatar Shine-zwj

update:更新表单逻辑

上级 b78dc23c
{{#each items as | formDetail |}}
{{#if (and (eq formDetail.detailType "BUTTON") (formDetail.psUIAction))}}
{{#formDetail.psUIAction}}
{{uIActionTag}}: { disabled: false, visible: true, noPrivDisplayMode: {{noPrivDisplayMode}}, dataAccessAction: '{{dataAccessAction}}', actionTarget: '{{actionTarget}}' },
{{/formDetail.psUIAction}}
{{/if}}
{{#if (and (eq formDetail.detailType "GROUPPANEL") (formDetail.psSUIActionGroup.psUIActionGroupDetails))}}
{{#each formDetail.psSUIActionGroup.psUIActionGroupDetails as | detail | }}
{{#detail.psUIAction}}
{{uIActionTag}}: { disabled: false, visible: true, noPrivDisplayMode: {{noPrivDisplayMode}}, dataAccessAction: '{{dataAccessAction}}', actionTarget: '{{actionTarget}}' },
{{/detail.psUIAction}}
{{/each}}
{{/if}}
{{#if formDetail.psDEFormDetails}}
{{>(lookup 'FORMACTIONMODEL') items=formDetail.psDEFormDetails}}
{{/if}}
{{/each}}
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<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}};">
<a-button <a-button
type="primary" type="primary"
v-show="state.detailsModel.{{item.codeName}}.visible"
class="ibiz-form-button{{#if item.psSysCss}}{{item.psSysCss.cssName}}{{/if}}" class="ibiz-form-button{{#if item.psSysCss}}{{item.psSysCss.cssName}}{{/if}}"
style="{{#if item.width}}width: {{item.width}}px;{{/if}}{{#if item.height}}height: {{item.height}}px;{{/if}}"> style="{{#if item.width}}width: {{item.width}}px;{{/if}}{{#if item.height}}height: {{item.height}}px;{{/if}}">
{{#if item.psSysImage}} {{#if item.psSysImage}}
...@@ -19,6 +20,7 @@ ...@@ -19,6 +20,7 @@
{{> @macro/front-end/ctrl/common/layoutPos.hbs item=item.psLayoutPos}} > {{> @macro/front-end/ctrl/common/layoutPos.hbs item=item.psLayoutPos}} >
<a-button <a-button
type="primary" type="primary"
v-show="state.detailsModel.{{item.codeName}}.visible"
class="ibiz-form-button{{#if item.psSysCss}}{{item.psSysCss.cssName}}{{/if}}" class="ibiz-form-button{{#if item.psSysCss}}{{item.psSysCss.cssName}}{{/if}}"
style="{{#if item.width}}width: {{item.width}}px;{{/if}}{{#if item.height}}height: {{item.height}}px;{{/if}}"> style="{{#if item.width}}width: {{item.width}}px;{{/if}}{{#if item.height}}height: {{item.height}}px;{{/if}}">
{{#if item.psSysImage}} {{#if item.psSysImage}}
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
showCaption: {{#if formDetail.showCaption}}true{{else}}false{{/if}}, showCaption: {{#if formDetail.showCaption}}true{{else}}false{{/if}},
{{#if (eq formDetail.detailType "FORMITEM")}} {{#if (eq formDetail.detailType "FORMITEM")}}
dataType: '{{formDetail.dataType}}', dataType: '{{formDetail.dataType}}',
required: {{#if formDetail.allowEmpty}}false{{else}}true{{/if}},
enableCond: {{formDetail.enableCond}},
{{#if formDetail.resetItemName}} {{#if formDetail.resetItemName}}
resetItemName: '{{formDetail.resetItemName}}', resetItemName: '{{formDetail.resetItemName}}',
{{/if}} {{/if}}
...@@ -16,19 +18,23 @@ ...@@ -16,19 +18,23 @@
valueItemName: '{{formDetail.valueItemName}}', valueItemName: '{{formDetail.valueItemName}}',
{{/if}} {{/if}}
{{/if}} {{/if}}
{{#if (and (eq formDetail.detailType "BUTTON") formDetail.psUIAction)}} {{#if (and (eq formDetail.detailType "BUTTON") (formDetail.psUIAction))}}
{{#formDetail.psUIAction}} uIActionTag: '{{formDetail.psUIAction.uIActionTag}}',
uIAction: {
uIActionType: '{{uIActionType}}',
uIActionTag: '{{uIActionTag}}',
}
{{/formDetail.psUIAction}}
{{/if}} {{/if}}
{{#if (eq formDetail.detailType "GROUPPANEL")}} {{#if (and (eq formDetail.detailType "GROUPPANEL") (formDetail.psUIActionGroup))}}
uIActionGroup: {
extractMode: '{{formDetail.psUIActionGroup.actionGroupExtractMode}}',
details: [
{{#each formDetail.psUIActionGroup.psUIActionGroupDetails as | detail | }}
{ caption: '{{detail.caption}}', disabled: false, visible: true, uIActionTag: '{{detail.psUIAction.uIActionTag}}', showCaption: {{detail.showCaption}}, showIcon: {{detail.showIcon}}, {{#if detail.psUIAction.psSysImage}}{{#if detail.psUIAction.psSysImage.imagePath}} imgPath: "{{detail.psUIAction.psSysImage.imagePath}}",{{/if}}{{#if detail.psUIAction.psSysImage.cssClass}} iconClass: "{{detail.psUIAction.psSysImage.cssClass}}",{{/if}}{{/if}} },
{{/each}}
],
},
{{/if}} {{/if}}
{{#if formDetail.psDEFDGroupLogics}}
groupLogics: [
{{#each formDetail.psDEFDGroupLogics as | groupLogic |}} {{#each formDetail.psDEFDGroupLogics as | groupLogic |}}
groupLogics: { {
name: '{{groupLogic.name}}', name: '{{groupLogic.name}}',
groupOP: '{{groupLogic.groupOP}}', groupOP: '{{groupLogic.groupOP}}',
relatedDetailNames: '{{groupLogic.relatedDetailNames}}', relatedDetailNames: '{{groupLogic.relatedDetailNames}}',
...@@ -42,6 +48,8 @@ ...@@ -42,6 +48,8 @@
], ],
} }
{{/each}} {{/each}}
],
{{/if}}
}, },
{{#if formDetail.psDEFormDetails}} {{#if formDetail.psDEFormDetails}}
{{>(lookup 'FORMDETAILSMODEL') items=formDetail.psDEFormDetails}} {{>(lookup 'FORMDETAILSMODEL') items=formDetail.psDEFormDetails}}
......
{{#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}};">
<IbizFormGroup name="{{item.codeName}}" title="{{item.caption}}"> <IbizFormGroup v-show="state.detailsModel.{{item.codeName}}.visible" name="{{item.codeName}}" title="{{item.caption}}">
{{#eq item.psLayout.layout "FLEX"}} {{#eq item.psLayout.layout "FLEX"}}
<div class="app-form-layout-flex" style="{{#if item.psLayout.dir}}flex-direction: {{item.psLayout.dir}};{{/if}}{{#if item.psLayout.align}}justify-content: {{item.psLayout.align}};{{/if}}{{#if item.psLayout.vAlign}}align-items: {{item.psLayout.vAlign}};{{/if}}"> <div class="app-form-layout-flex" style="{{#if item.psLayout.dir}}flex-direction: {{item.psLayout.dir}};{{/if}}{{#if item.psLayout.align}}justify-content: {{item.psLayout.align}};{{/if}}{{#if item.psLayout.vAlign}}align-items: {{item.psLayout.vAlign}};{{/if}}">
{{#each item.psDEFormDetails as | formDetail |}} {{#each item.psDEFormDetails as | formDetail |}}
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
{{else}} {{else}}
<a-col <a-col
{{> @macro/front-end/ctrl/common/layoutPos.hbs item=item.psLayoutPos}} > {{> @macro/front-end/ctrl/common/layoutPos.hbs item=item.psLayoutPos}} >
<IbizFormGroup name="{{item.codeName}}" title="{{item.caption}}"> <IbizFormGroup v-show="state.detailsModel.{{item.codeName}}.visible" name="{{item.codeName}}" title="{{item.caption}}">
{{#eq item.psLayout.layout "FLEX"}} {{#eq item.psLayout.layout "FLEX"}}
<div class="app-form-layout-flex" style="{{#if item.psLayout.dir}}flex-direction: {{item.psLayout.dir}};{{/if}}{{#if item.psLayout.align}}justify-content: {{item.psLayout.align}};{{/if}}{{#if item.psLayout.vAlign}}align-items: {{item.psLayout.vAlign}};{{/if}}"> <div class="app-form-layout-flex" style="{{#if item.psLayout.dir}}flex-direction: {{item.psLayout.dir}};{{/if}}{{#if item.psLayout.align}}justify-content: {{item.psLayout.align}};{{/if}}{{#if item.psLayout.vAlign}}align-items: {{item.psLayout.vAlign}};{{/if}}">
{{#each item.psDEFormDetails as | formDetail |}} {{#each item.psDEFormDetails as | formDetail |}}
......
{{#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}};">
<div class="ibiz-form-iframe" style="{{#if item.contentHeight}}height: {{item.contentHeight}}px;{{/if}}{{#if item.contentWidth}}width: {{item.contentWidth}}px{{/if}}"> <div v-show="state.detailsModel.{{item.codeName}}.visible" class="ibiz-form-iframe" style="{{#if item.contentHeight}}height: {{item.contentHeight}}px;{{/if}}{{#if item.contentWidth}}width: {{item.contentWidth}}px{{/if}}">
<iframe src="{{item.iFrameUrl}}" style="height: 100%;width: 100%;border: 0"></iframe> <iframe src="{{item.iFrameUrl}}" style="height: 100%;width: 100%;border: 0"></iframe>
</div> </div>
</div> </div>
{{else}} {{else}}
<a-col <a-col
{{> @macro/front-end/ctrl/common/layoutPos.hbs item=item.psLayoutPos}} > {{> @macro/front-end/ctrl/common/layoutPos.hbs item=item.psLayoutPos}} >
<div class="ibiz-form-iframe" style="{{#if item.contentHeight}}height: {{item.contentHeight}}px;{{/if}}{{#if item.contentWidth}}width: {{item.contentWidth}}px{{/if}}"> <div v-show="state.detailsModel.{{item.codeName}}.visible" class="ibiz-form-iframe" style="{{#if item.contentHeight}}height: {{item.contentHeight}}px;{{/if}}{{#if item.contentWidth}}width: {{item.contentWidth}}px{{/if}}">
<iframe src="{{item.iFrameUrl}}" style="height: 100%;width: 100%;border: 0"></iframe> <iframe src="{{item.iFrameUrl}}" style="height: 100%;width: 100%;border: 0"></iframe>
</div> </div>
</a-col> </a-col>
......
{{>@macro/editor/include-editor.hbs}} {{>@macro/editor/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}};">
<IbizFormItem name="{{item.codeName}}" label="{{item.caption}}"> <IbizFormItem v-show="state.detailsModel.{{item.codeName}}.visible" name="{{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/ctrl/common/layoutPos.hbs item=item.psLayoutPos}} > {{> @macro/front-end/ctrl/common/layoutPos.hbs item=item.psLayoutPos}} >
<IbizFormItem name="{{item.codeName}}" label="{{item.caption}}"> <IbizFormItem v-show="state.detailsModel.{{item.codeName}}.visible" name="{{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}}
......
<a-tab-pane key="{{item.codeName}}" tab="{{item.caption}}"> <a-tab-pane v-show="state.detailsModel.{{item.codeName}}.visible" key="{{item.codeName}}" tab="{{item.caption}}">
{{#eq item.psLayout.layout "FLEX"}} {{#eq item.psLayout.layout "FLEX"}}
<div class="app-form-layout-flex" style="{{#if item.psLayout.dir}}flex-direction: {{item.psLayout.dir}};{{/if}}{{#if item.psLayout.align}}justify-content: {{item.psLayout.align}};{{/if}}{{#if item.psLayout.vAlign}}align-items: {{item.psLayout.vAlign}};{{/if}}"> <div class="app-form-layout-flex" style="{{#if item.psLayout.dir}}flex-direction: {{item.psLayout.dir}};{{/if}}{{#if item.psLayout.align}}justify-content: {{item.psLayout.align}};{{/if}}{{#if item.psLayout.vAlign}}align-items: {{item.psLayout.vAlign}};{{/if}}">
{{#each item.psDEFormDetails as | formDetail |}} {{#each item.psDEFormDetails as | formDetail |}}
......
{{#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}};">
<IbizRaw <IbizRaw
v-show="state.detailsModel.{{item.codeName}}.visible"
{{#if item.psSysCss}}class="{{item.psSysCss.cssName}}"{{/if}} {{#if item.psSysCss}}class="{{item.psSysCss.cssName}}"{{/if}}
{{#if item.psSysImage}}{{#if item.psSysImage.cssClass}}iconClass="{{item.psSysImage.cssClass}}"{{/if}}{{#if item.psSysImage.imagePath}}imgPath="{{item.psSysImage.imagePath}}"{{/if}}{{/if}} {{#if item.psSysImage}}{{#if item.psSysImage.cssClass}}iconClass="{{item.psSysImage.cssClass}}"{{/if}}{{#if item.psSysImage.imagePath}}imgPath="{{item.psSysImage.imagePath}}"{{/if}}{{/if}}
contentType="{{item.contentType}}" contentType="{{item.contentType}}"
...@@ -10,11 +11,12 @@ ...@@ -10,11 +11,12 @@
{{else}} {{else}}
<a-col <a-col
{{> @macro/front-end/ctrl/common/layoutPos.hbs item=item.psLayoutPos}} > {{> @macro/front-end/ctrl/common/layoutPos.hbs item=item.psLayoutPos}} >
<IbizRaw <IbizRaw
v-show="state.detailsModel.{{item.codeName}}.visible"
{{#if item.psSysCss}}class="{{item.psSysCss.cssName}}"{{/if}} {{#if item.psSysCss}}class="{{item.psSysCss.cssName}}"{{/if}}
{{#if item.psSysImage}}{{#if item.psSysImage.cssClass}}iconClass="{{item.psSysImage.cssClass}}"{{/if}}{{#if item.psSysImage.imagePath}}imgPath="{{item.psSysImage.imagePath}}"{{/if}}{{/if}} {{#if item.psSysImage}}{{#if item.psSysImage.cssClass}}iconClass="{{item.psSysImage.cssClass}}"{{/if}}{{#if item.psSysImage.imagePath}}imgPath="{{item.psSysImage.imagePath}}"{{/if}}{{/if}}
contentType="{{item.contentType}}" contentType="{{item.contentType}}"
style="{{#if item.rawItemHeight}}height: {{item.rawItemHeight}}px;{{/if}}{{#if item.rawItemWidth}}width: {{item.rawItemWidth}}px{{/if}}" style="{{#if item.rawItemHeight}}height: {{item.rawItemHeight}}px;{{/if}}{{#if item.rawItemWidth}}width: {{item.rawItemWidth}}px{{/if}}"
{{#if (eq item.contentType 'RAW')}}value="{{item.rawContent}}"{{else if (eq item.contentType 'HTML')}}:value="`{{item.htmlContent}}`"{{/if}}/> {{#if (eq item.contentType 'RAW')}}value="{{item.rawContent}}"{{else if (eq item.contentType 'HTML')}}:value="`{{item.htmlContent}}`"{{/if}}/>
</a-col> </a-col>
{{/eq}} {{/eq}}
<a-tab-pane key="{{item.codeName}}" tab="{{item.caption}}"> <a-tab-pane v-show="state.detailsModel.{{item.codeName}}.visible" key="{{item.codeName}}" tab="{{item.caption}}">
{{#eq item.psLayout.layout "FLEX"}} {{#eq item.psLayout.layout "FLEX"}}
<div class="app-form-layout-flex" style="{{#if item.psLayout.dir}}flex-direction: {{item.psLayout.dir}};{{/if}}{{#if item.psLayout.align}}justify-content: {{item.psLayout.align}};{{/if}}{{#if item.psLayout.vAlign}}align-items: {{item.psLayout.vAlign}};{{/if}}"> <div class="app-form-layout-flex" style="{{#if item.psLayout.dir}}flex-direction: {{item.psLayout.dir}};{{/if}}{{#if item.psLayout.align}}justify-content: {{item.psLayout.align}};{{/if}}{{#if item.psLayout.vAlign}}align-items: {{item.psLayout.vAlign}};{{/if}}">
{{#each item.psDEFormDetails as | formDetail |}} {{#each item.psDEFormDetails as | formDetail |}}
......
...@@ -9,3 +9,4 @@ ...@@ -9,3 +9,4 @@
{{#*inline "TABPAGE"}}{{>@macro/form-detail/form-tabpage.hbs}}{{/inline}} {{#*inline "TABPAGE"}}{{>@macro/form-detail/form-tabpage.hbs}}{{/inline}}
{{#*inline "DRUIPART"}}{{>@macro/form-detail/form-druipart.hbs}}{{/inline}} {{#*inline "DRUIPART"}}{{>@macro/form-detail/form-druipart.hbs}}{{/inline}}
{{#*inline "FORMDETAILSMODEL"}}{{>@macro/form-detail/form-details-model.hbs}}{{/inline}} {{#*inline "FORMDETAILSMODEL"}}{{>@macro/form-detail/form-details-model.hbs}}{{/inline}}
{{#*inline "FORMACTIONMODEL"}}{{>@macro/form-detail/form-action-model.hbs}}{{/inline}}
\ No newline at end of file
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
{{else if (eq item.columnType 'UAGRIDCOLUMN')}} {{else if (eq item.columnType 'UAGRIDCOLUMN')}}
{{#each item.psDEUIActionGroup.psUIActionGroupDetails as | action |}} {{#each item.psDEUIActionGroup.psUIActionGroupDetails as | action |}}
{{#action}} {{#action}}
{ name: "{{name}}", caption: "{{psUIAction.caption}}", showIcon: {{showIcon}}, showCaption: {{showCaption}}, separator: {{addSeparator}}, uIActionTag: "{{psUIAction.uIActionTag}}", noPrivDisplayMode: {{#if psUIAction.noPrivDisplayMode}}{{psUIAction.noPrivDisplayMode}}{{else}}6{{/if}}, disabled: false, visible: true,{{#if psUIAction.psSysImage}}{{#if psUIAction.psSysImage.imagePath}} imgPath: "{{psUIAction.psSysImage.imagePath}}",{{/if}}{{#if psUIAction.psSysImage.cssClass}} iconClass: "{{psUIAction.psSysImage.cssClass}}",{{/if}}{{/if}} }, { name: "{{name}}", caption: "{{psUIAction.caption}}", showIcon: {{showIcon}}, showCaption: {{showCaption}}, separator: {{addSeparator}}, uIActionTag: "{{psUIAction.uIActionTag}}", noPrivDisplayMode: {{psUIAction.noPrivDisplayMode}}, dataAccessAction: '{{psUIAction.dataAccessAction}}', actionTarget: '{{psUIAction.actionTarget}}', disabled: false, visible: true,{{#if psUIAction.psSysImage}}{{#if psUIAction.psSysImage.imagePath}} imgPath: "{{psUIAction.psSysImage.imagePath}}",{{/if}}{{#if psUIAction.psSysImage.cssClass}} iconClass: "{{psUIAction.psSysImage.cssClass}}",{{/if}}{{/if}} },
{{/action}} {{/action}}
{{/each}} {{/each}}
{{/if}} {{/if}}
\ No newline at end of file
...@@ -19,7 +19,7 @@ const emit = defineEmits<FormGroupEmit>(); ...@@ -19,7 +19,7 @@ const emit = defineEmits<FormGroupEmit>();
:title="title" :title="title"
:bordered="false"> :bordered="false">
<template #extra> <template #extra>
<a href="#">行为</a> <!-- <a href="#">行为</a> -->
</template> </template>
<slot></slot> <slot></slot>
</a-card> </a-card>
......
import { deepCopy, FormControlProps, FormControlState, IActionParam, MainControl } from '@core'; import { deepCopy, FormControlProps, FormControlState, IActionParam, IParam, MainControl, UIUtil, verifyValue } from '@core';
/** /**
* @description 表单部件 * @description 表单部件
...@@ -16,21 +16,49 @@ export class FormControl extends MainControl { ...@@ -16,21 +16,49 @@ export class FormControl extends MainControl {
public declare controlState: FormControlState; public declare controlState: FormControlState;
/** /**
* 在表单数据改变(单一属性变化)时被调用。会依次执行以下逻辑: * @description 检验表单动态逻辑
* @param {IParam} data 表单数据
* @param {IParam} logic 动态逻辑
* @return {*}
* @memberof FormControl
*/
public verifyGroupLogic(data: IParam, logic: IParam) {
if (logic.logicType == 'GROUP' && logic.logics?.length > 0) {
let result: boolean = true;
if (logic.groupOP == 'AND') {
const falseItem = logic.logics.find((childLogic: IParam)=> {
return !this.verifyGroupLogic(data, childLogic);
})
result = falseItem ? false : true;
} else if (logic.groupOP == 'OR') {
const trueItem = logic.logics.find((childLogic: IParam)=> {
return this.verifyGroupLogic(data, childLogic);
})
result = trueItem ? true : false;
}
// 是否取反
return logic.notMode ? !result : result;
} else if (logic.logicType == 'SINGLE') {
return verifyValue(data[logic.name], logic.condOP, logic.value);
}
return false;
}
/**
* @description 在表单数据改变(单一属性变化)时被调用。会依次执行以下逻辑:
* 1. 重置项逻辑 * 1. 重置项逻辑
* 2. 表单项更新 * 2. 表单项更新
* 3. 动态控制逻辑 * 3. 动态控制逻辑
* 4. 自动保存逻辑 * 4. 自动保存逻辑
* * @param {string} name 表单项名称
* @param {string} name 属性名称 * @param {*} value 表单项值
* @param {*} value 属性值
* @memberof FormControl * @memberof FormControl
*/ */
public formDataChange(name: string, value: any) { public formDataChange(name: string, value: any) {
this.controlState.data[name] = value; this.controlState.data[name] = value;
this.resetFormData(name); this.resetFormData(name);
// TODO 表单项更新 // TODO 表单项更新
// TODO 动态控制逻辑 this.formDynamicLogic(name);
// TODO 自动保存(可以单独做一个逻辑块,监听data的变化) // TODO 自动保存(可以单独做一个逻辑块,监听data的变化)
} }
...@@ -40,62 +68,149 @@ export class FormControl extends MainControl { ...@@ -40,62 +68,149 @@ export class FormControl extends MainControl {
* @memberof FormControl * @memberof FormControl
*/ */
public resetFormData(name: string) { public resetFormData(name: string) {
const formItems: any[] = this.controlState.formDetails; const { detailsModel } = this.controlState;
if (formItems && formItems.length > 0) { Object.values(detailsModel).forEach((item: IParam) => {
for (const item of formItems) { if (item.resetItemName && Object.is(name, item.resetItemName)) {
if (item.resetItemName && item.resetItemName == name) { this.formDataChange(item.name, null);
this.formDataChange( item.name, null);
if (item.valueItemName) { if (item.valueItemName) {
this.formDataChange(item.valueItemName, null); this.formDataChange(item.valueItemName, null);
} }
} }
})
} }
/**
* @description 表单动态逻辑
* @param {string} name 表单项名称
* @memberof FormControl
*/
public formDynamicLogic(name: string) {
const { data } = this.controlState;
const { detailsModel } = toRefs(this.controlState);
Object.values(detailsModel.value).forEach((item: IParam) => {
if (item.groupLogics?.length > 0) {
item.groupLogics.forEach((logic: IParam) => {
let relatedNames = logic.relatedDetailNames || [];
if (Object.is(name, '') || relatedNames.indexOf(name) != -1) {
let ret = this.verifyGroupLogic(data, logic);
switch (logic.logicCat) {
// 动态空输入,不满足则必填
case 'ITEMBLANK':
item.required = !ret;
break;
// 动态启用,满足则启用
case 'ITEMENABLE':
item.disabled = !ret;
break;
// 动态显示,满足则显示
case 'PANELVISIBLE':
item.visible = ret;
break;
} }
} }
});
}
});
}
/** /**
* @description 动态显示逻辑 * @description 表单执行某些整体数据发生变化行为之后,依次执行以下逻辑
* 1.根据行为类型将主键合并到context中
* 2.设置新建默认值和更新默认值
* 4.计算行为权限状态
* 5.设置表单项启用
* 6.表单动态逻辑
* @param {string} action
* @memberof FormControl * @memberof FormControl
*/ */
public displayLogic(name: string) { public afterFormAction(action: string) {
const formItems: any[] = this.controlState.formDetails; const { appDeCodeName, data } = this.controlState;
// 表单动态逻辑 const { context } = toRefs(this.controlState);
// allFormDetails?.forEach((detail: IPSDEFormDetail) => { if (appDeCodeName) {
// detail.getPSDEFDGroupLogics()?.forEach((logic: IPSDEFDCatGroupLogic) => { if (Object.is(action, 'save') || Object.is(action, 'autoSave') || Object.is(action, 'submit')) {
// // todo lxm 缺少getRelatedDetailNames if (data[appDeCodeName]) {
// let relatedNames = logic.getRelatedDetailNames() || []; Object.assign(context.value, { [appDeCodeName]: data[appDeCodeName] });
// if (Object.is(name, '') || relatedNames.indexOf(name) != -1) { }
// let ret = this.verifyGroupLogic(this.data, logic); }
// switch (logic.logicCat) { }
// // 动态空输入,不满足则必填 this.setDefaultValue(action);
// case 'ITEMBLANK': this.calcActionAuthState();
// this.detailsModel[detail.name].required = !ret; this.setFormEnableCond();
// break; this.formDynamicLogic('');
// // 动态启用,满足则启用
// case 'ITEMENABLE':
// this.detailsModel[detail.name].setDisabled(!ret);
// break;
// // 动态显示,满足则显示
// case 'PANELVISIBLE':
// this.detailsModel[detail.name].setVisible(ret);
// break;
// }
// }
// })
// })
} }
/** /**
* 在表单执行某些行为能力后,表单整体数据发生改变后被调用。会依次执行以下逻辑: * @description 设置表单启用项
* 1. * @memberof FormControl
*
* @param {string} action 调用的表单行为方法
*/ */
public afterFormLoad(action: string) { public setFormEnableCond() {
// 改变context当前实体主键,并抛出抽屉脏值的事件 const { data } = this.controlState;
// TODO 设置表单项启用(如果可以响应式变化则不用处理) const { detailsModel } = toRefs(this.controlState);
// 新建默认值和更新默认值 Object.values(detailsModel.value).forEach((item: IParam) => {
// TODO 动态控制逻辑 if (Object.is(item.detailType, 'FORMITEM')) {
switch (item.enableCond) {
case 0:
// 不启用
item.disabled = false;
break;
case 1:
// 新建
if (Object.is(data.srfuf, '0')) {
item.disabled = true;
} else {
item.disabled = false;
}
break;
case 2:
// 更新
if (Object.is(data.srfuf, '1')) {
item.disabled = true;
} else {
item.disabled = false;
}
break;
case 3:
// 启用
item.disabled = true;
break;
default:
break;
}
}
});
}
/**
* @description 计算行为权限状态
* @memberof FormControl
*/
public calcActionAuthState() {
const { data, UIService, actionModel } = this.controlState;
const { detailsModel } = toRefs(this.controlState);
const tempModel = deepCopy(actionModel);
UIUtil.calcActionItemAuthState(data, tempModel, UIService);
Object.values(detailsModel.value).forEach((item: IParam) => {
if (Object.is(item.detailType, 'BUTTON') && item.uIActionTag) {
// 更新按钮的权限状态值
item.visible = tempModel[item.uIActionTag].visible;
item.disabled = tempModel[item.uIActionTag].disabled;
item.isPower = tempModel[item.uIActionTag].dataActionResult === 1 ? true : false;
} else if (Object.is(item.detailType, 'GROUPPANEL') && item.uIActionGroup?.details?.length > 0) {
// 更新分组面板界面行为组的权限状态值
item.uiActionGroup.details.forEach((actionDetail: any) => {
actionDetail.visible = tempModel[actionDetail.uIActionTag].visible;
actionDetail.disabled = tempModel[actionDetail.uIActionTag].disabled;
});
}
});
}
/**
* @description 设置默认值
* @param {string} action 表单行为
* @memberof FormControl
*/
public setDefaultValue(action: string) {
// TODO 新建默认值和更新默认值
} }
/** /**
...@@ -115,15 +230,11 @@ export class FormControl extends MainControl { ...@@ -115,15 +230,11 @@ export class FormControl extends MainControl {
*/ */
const load = async (opt: any = {}) => { const load = async (opt: any = {}) => {
try { try {
// 获取需要的状态变量 const { controlService, context, viewParams, showBusyIndicator, controlAction } = this.controlState;
const { controlService, context, viewParams, showBusyIndicator } = this.controlState; const { data } = toRefs(this.controlState);
if (!controlAction.loadAction) {
// 判断实体行为
const loadAction = this.controlState.controlAction.loadAction;
if (!loadAction) {
return; return;
} }
// 处理请求参数 // 处理请求参数
let _context = deepCopy(context); let _context = deepCopy(context);
let _viewParams = deepCopy(viewParams); let _viewParams = deepCopy(viewParams);
...@@ -132,17 +243,12 @@ export class FormControl extends MainControl { ...@@ -132,17 +243,12 @@ export class FormControl extends MainControl {
const response = await controlService.get( const response = await controlService.get(
_context, _context,
{ viewParams: _viewParams }, { viewParams: _viewParams },
{ { action: controlAction.loadAction, isLoading: showBusyIndicator },
action: loadAction,
isLoading: showBusyIndicator,
},
); );
if (!response.status || response.status !== 200) { if (response.status && response.status == 200) {
return; data.value = response.data;
this.afterFormAction('load');
} }
// 请求后处理
this.controlState.data = response.data;
} catch (error) { } catch (error) {
// TODO 错误异常处理 // TODO 错误异常处理
console.log(error); console.log(error);
......
...@@ -35,4 +35,11 @@ export interface MainControlState extends ControlStateBase { ...@@ -35,4 +35,11 @@ export interface MainControlState extends ControlStateBase {
* @memberof MainControlState * @memberof MainControlState
*/ */
UIService: IParam; UIService: IParam;
/**
* @description 应用实体名称
* @type {string}
* @memberof MainControlState
*/
appDeCodeName: string;
} }
\ No newline at end of file
...@@ -274,139 +274,4 @@ export class RouteUtil { ...@@ -274,139 +274,4 @@ export class RouteUtil {
public static getIndexViewParam(): any { public static getIndexViewParam(): any {
return this.indexViewParam; return this.indexViewParam;
} }
/**
* 计算界面行为项权限状态
*
* @static
* @param {*} [data] 传入数据
* @param {*} [ActionModel] 界面行为模型
* @param {*} [UIService] 界面行为服务
* @memberof RouteUtil
*/
public static calcActionItemAuthState(data: any, ActionModel: any, UIService: any) {
let result: any[] = [];
if (!UIService) return;
for (const key in ActionModel) {
if (!ActionModel.hasOwnProperty(key)) {
return result;
}
const _item = ActionModel[key];
let dataActionResult: any;
if (_item && _item['dataAccessAction']) {
if (Object.is(_item['actionTarget'], 'NONE') || Object.is(_item['actionTarget'], '')) {
dataActionResult = UIService.getAllOPPrivs(undefined, _item['dataAccessAction']);
} else {
if (data && Object.keys(data).length > 0) {
dataActionResult = UIService.getAllOPPrivs(data, _item['dataAccessAction']);
}
}
} else {
dataActionResult = 1;
}
// 无权限:0;有权限:1
if (dataActionResult === 0) {
// 禁用:1;隐藏:2;隐藏且默认隐藏:6
if (_item.getNoPrivDisplayMode === 1) {
_item.disabled = true;
}
if (_item.getNoPrivDisplayMode === 2 || _item.getNoPrivDisplayMode === 6) {
_item.visabled = false;
} else {
_item.visabled = true;
}
}
if (dataActionResult === 1) {
_item.visabled = true;
_item.disabled = false;
}
// 返回权限验证的结果
_item.dataActionResult = dataActionResult;
result.push(dataActionResult);
}
return result;
}
/**
* 计算界面行为项权限状态(树节点版本)
*
* @static
* @param {*} [data] 传入数据
* @param {*} [ActionModel] 界面行为模型
* @param {*} [UIService] 界面行为服务
* @memberof RouteUtil
*/
public static calcTreeActionItemAuthState(data: any, ActionModel: any, UIService: any) {
let result: any[] = [];
if (!UIService) return;
for (const key in ActionModel) {
if (!ActionModel.hasOwnProperty(key)) {
return result;
}
const _item = ActionModel[key];
let dataActionResult: any;
if (Object.is(_item['actiontarget'], 'NONE') || Object.is(_item['actiontarget'], '')) {
dataActionResult = UIService.getAllOPPrivs(undefined, _item['dataaccaction']);
} else {
if (_item && _item['dataaccaction'] && UIService.isEnableDEMainState) {
if (data && Object.keys(data).length > 0) {
dataActionResult = UIService.getAllOPPrivs(data, _item['dataaccaction']);
}
}
}
// 无权限:0;有权限:1
if (dataActionResult === 0) {
// 禁用:1;隐藏:2;隐藏且默认隐藏:6
if (_item.noprivdisplaymode === 1) {
_item.disabled = true;
}
if (_item.noprivdisplaymode === 2 || _item.noprivdisplaymode === 6) {
_item.visabled = false;
} else {
_item.visabled = true;
}
}
if (dataActionResult === 1) {
_item.visabled = true;
_item.disabled = false;
}
// 返回权限验证的结果
_item.dataActionResult = dataActionResult;
result.push(dataActionResult);
}
return result;
}
/**
* 计算重定向上下文
*
* @static
* @param {*} [tempContext] 上下文
* @param {*} [data] 传入数据
* @param {*} [redirectAppEntity] 应用实体对象
* @memberof RouteUtil
*/
public static async calcRedirectContext(tempContext: any, data: any, redirectAppEntity: any) {
if (
redirectAppEntity &&
redirectAppEntity.getMinorPSAppDERSs() &&
(redirectAppEntity.getMinorPSAppDERSs() as []).length > 0
) {
for (const item of redirectAppEntity.getMinorPSAppDERSs()) {
const parentPSAppDEFieldCodeName: string = item.M.getParentPSAppDEField?.codeName;
if (parentPSAppDEFieldCodeName) {
const curData: any = data;
if (curData && curData[parentPSAppDEFieldCodeName.toLowerCase()]) {
const majorAppEntity: any = item.getMajorPSAppDataEntity();
await majorAppEntity.fill();
if (!tempContext[majorAppEntity.codeName.toLowerCase()]) {
Object.assign(tempContext, {
[majorAppEntity.codeName.toLowerCase()]: curData[parentPSAppDEFieldCodeName.toLowerCase()],
});
}
}
}
}
}
}
} }
...@@ -38,17 +38,17 @@ export class UIUtil { ...@@ -38,17 +38,17 @@ export class UIUtil {
// 无权限:0;有权限:1 // 无权限:0;有权限:1
if (dataActionResult === 0) { if (dataActionResult === 0) {
// 禁用:1;隐藏:2;隐藏且默认隐藏:6 // 禁用:1;隐藏:2;隐藏且默认隐藏:6
if (item.getNoPrivDisplayMode === 1) { if (item.noPrivDisplayMode === 1) {
item.disabled = true; item.disabled = true;
} }
if (item.getNoPrivDisplayMode === 2 || item.getNoPrivDisplayMode === 6) { if (item.noPrivDisplayMode === 2 || item.noPrivDisplayMode === 6) {
item.visabled = false; item.visible = false;
} else { } else {
item.visabled = true; item.visible = true;
} }
} }
if (dataActionResult === 1) { if (dataActionResult === 1) {
item.visabled = true; item.visible = true;
item.disabled = false; item.disabled = false;
} }
// 返回权限验证的结果 // 返回权限验证的结果
......
...@@ -52,11 +52,16 @@ export const CtrlConfig = { ...@@ -52,11 +52,16 @@ export const CtrlConfig = {
controlName: '{{ctrl.name}}', controlName: '{{ctrl.name}}',
controlService: new EditFormService<ControlVO>(ControlVO, new {{pascalCase ctrl.psAppDataEntity.codeName}}Service() ), controlService: new EditFormService<ControlVO>(ControlVO, new {{pascalCase ctrl.psAppDataEntity.codeName}}Service() ),
data: new ControlVO({}), data: new ControlVO({}),
formDetails: { detailsModel: {
{{#each ctrl.psDEFormPages as | FormPage | }} {{#each ctrl.psDEFormPages as | FormPage | }}
{{>(lookup 'FORMDETAILSMODEL') items=FormPage.psDEFormDetails}} {{>(lookup 'FORMDETAILSMODEL') items=FormPage.psDEFormDetails}}
{{/each}} {{/each}}
}, },
actionModel: {
{{#each ctrl.psDEFormPages as | FormPage | }}
{{>(lookup 'FORMACTIONMODEL') items=FormPage.psDEFormDetails}}
{{/each}}
},
rules: { rules: {
{{#each ctrl.psDEFormEditItemVRs as | ruleItem |}} {{#each ctrl.psDEFormEditItemVRs as | ruleItem |}}
{{#neq ruleItem 2}} {{#neq ruleItem 2}}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册