提交 9aef90da 编写于 作者: Mosher's avatar Mosher

update:更新

上级 6065e79b
{
name: '{{logic.name}}',
logicType: '{{logic.logicType}}',
logicCat: '{{logic.logicCat}}',
{{#eq logic.logicType 'GROUP'}}
notMode: {{logic.notMode}},
groupOP: '{{logic.groupOP}}',
relatedDetailNames: [{{#each logic.relatedDetailNames as | name |}}"{{name}}"{{#unless @last}},{{/unless}}{{/each}}],
{{#if logic.psDEFDLogics}}
childLogics: [
{{#each logic.psDEFDLogics as | childLogic |}}
{{> @macro/front-end/common/delogic.hbs logic=childLogic}}
{{/each}}
]
{{/if}}
{{/eq}}
{{#eq logic.logicType 'SINGLE'}}
condOP: "{{logic.condOP}}",
dEFDName: "{{lowerCase logic.dEFDName}}",
value: "{{logic.value}}"
{{/eq}}
},
{{#each item.psDEFormDetails as | tempDetail |}} {{#each item.psDEFormDetails as | detail |}}
{{#if (and (eq tempDetail.detailType "BUTTON") tempDetail.psUIAction)}} {{#if (and (eq detail.detailType "BUTTON") detail.psUIAction)}}
{{#tempDetail.psUIAction}} {{#detail.psUIAction}}
'{{uIActionTag}}': { disabled: false, visible: true, noPrivDisplayMode: "{{noPrivDisplayMode}}", dataAccessAction: '{{dataAccessAction}}', actionTarget: '{{actionTarget}}' }, '{{uIActionTag}}': { disabled: false, visible: true, noPrivDisplayMode: "{{noPrivDisplayMode}}", dataAccessAction: '{{dataAccessAction}}', actionTarget: '{{actionTarget}}' },
{{/tempDetail.psUIAction}} {{/detail.psUIAction}}
{{/if}} {{/if}}
{{#if (and (eq tempDetail.detailType "GROUPPANEL") tempDetail.psSUIActionGroup tempDetail.psSUIActionGroup.psUIActionGroupDetails)}} {{#if (and (eq detail.detailType "GROUPPANEL") detail.psUIActionGroup detail.psUIActionGroup.psUIActionGroupDetails)}}
{{#each tempDetail.psSUIActionGroup.psUIActionGroupDetails as | detail | }} {{#each detail.psUIActionGroup.psUIActionGroupDetails as | detail | }}
{{#detail.psUIAction}} {{#detail.psUIAction}}
'{{uIActionTag}}': { disabled: false, visible: true, noPrivDisplayMode: "{{noPrivDisplayMode}}", dataAccessAction: '{{dataAccessAction}}', actionTarget: '{{actionTarget}}' }, '{{uIActionTag}}': { disabled: false, visible: true, noPrivDisplayMode: "{{noPrivDisplayMode}}", dataAccessAction: '{{dataAccessAction}}', actionTarget: '{{actionTarget}}' },
{{/detail.psUIAction}} {{/detail.psUIAction}}
{{/each}} {{/each}}
{{/if}} {{/if}}
{{#if tempDetail.psDEFormDetails}} {{#if detail.psDEFormDetails}}
{{> @macro/front-end/widgets/form-detail/form-action-model.hbs item=tempDetail}} {{> @macro/front-end/widgets/form-detail/form-action-model.hbs item=detail}}
{{/if}} {{/if}}
{{/each}} {{/each}}
...@@ -21,4 +21,6 @@ ...@@ -21,4 +21,6 @@
{{#if item.caption}} {{#if item.caption}}
caption="{{item.caption}}" caption="{{item.caption}}"
{{/if}} {{/if}}
/> :uIAction="state.detailsModel.{{item.codeName}}.uIAction"
\ No newline at end of file @action="onComponentEvent"
/>
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
scriptCode: `{{item.psDEFormItemUpdate.scriptCode}}`, scriptCode: `{{item.psDEFormItemUpdate.scriptCode}}`,
{{else}} {{else}}
showBusyIndicator: "{{item.psDEFormItemUpdate.showBusyIndicator}}", showBusyIndicator: "{{item.psDEFormItemUpdate.showBusyIndicator}}",
{{!-- appDEMethod: "{{item.psDEFormItemUpdate.psAppDEMethod.codeName}}", --}} appDEMethod: "{{item.psDEFormItemUpdate.psAppDEMethod.codeName}}",
updateDetails: [ updateDetails: [
{{#each item.psDEFormItemUpdate.psDEFIUpdateDetails as | updateDetails | }} {{#each item.psDEFormItemUpdate.psDEFIUpdateDetails as | updateDetails | }}
"{{updateDetails.name}}", "{{updateDetails.name}}",
...@@ -33,14 +33,6 @@ ...@@ -33,14 +33,6 @@
{{/if}} {{/if}}
}, },
{{/if}} {{/if}}
{{#if item.createDVT}}
createDVT: "{{item.createDVT}}",
createDV: "{{item.createDV}}",
{{/if}}
{{#if item.updateDVT}}
updateDVT: "{{item.updateDVT}}",
updateDV: "{{item.updateDV}}",
{{/if}}
{{#if item.resetItemName}} {{#if item.resetItemName}}
resetItemName: '{{item.resetItemName}}', resetItemName: '{{item.resetItemName}}',
{{/if}} {{/if}}
...@@ -49,7 +41,8 @@ ...@@ -49,7 +41,8 @@
{{/if}} {{/if}}
{{/if}} {{/if}}
{{#if (and (eq item.detailType "BUTTON") item.psUIAction)}} {{#if (and (eq item.detailType "BUTTON") item.psUIAction)}}
uIActionTag: '{{item.psUIAction.uIActionTag}}', {{!-- TODO 补充显示图标和文字模式 --}}
uIAction: { caption: '{{item.psUIAction.caption}}', uIActionMode: "{{item.psUIAction.uIActionMode}}", disabled: false, visible: true, uIActionTag: '{{detail.psUIAction.uIActionTag}}', showCaption: {{item.showCaption}}, {{#if item.psUIAction.psSysImage}}{{#if item.psUIAction.psSysImage.imagePath}} imgPath: "{{item.psUIAction.psSysImage.imagePath}}",{{/if}}{{#if item.psUIAction.psSysImage.cssClass}} iconClass: "{{item.psUIAction.psSysImage.cssClass}}",{{/if}}{{/if}} },
{{/if}} {{/if}}
{{#if (and (eq item.detailType "GROUPPANEL") item.psUIActionGroup)}} {{#if (and (eq item.detailType "GROUPPANEL") item.psUIActionGroup)}}
uIActionGroup: { uIActionGroup: {
...@@ -57,7 +50,7 @@ ...@@ -57,7 +50,7 @@
caption: '{{item.psUIActionGroup.name}}', caption: '{{item.psUIActionGroup.name}}',
details: [ details: [
{{#each item.psUIActionGroup.psUIActionGroupDetails as | detail | }} {{#each item.psUIActionGroup.psUIActionGroupDetails as | detail | }}
{ caption: '{{detail.psUIAction.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}} }, { caption: '{{detail.psUIAction.caption}}', uIActionMode: "{{detail.psUIAction.uIActionMode}}", 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}} {{/each}}
], ],
}, },
...@@ -65,19 +58,7 @@ ...@@ -65,19 +58,7 @@
{{#if item.psDEFDGroupLogics}} {{#if item.psDEFDGroupLogics}}
groupLogics: [ groupLogics: [
{{#each item.psDEFDGroupLogics as | groupLogic |}} {{#each item.psDEFDGroupLogics as | groupLogic |}}
{ {{> @macro/front-end/common/delogic.hbs logic=groupLogic}}
name: '{{groupLogic.name}}',
groupOP: '{{groupLogic.groupOP}}',
relatedDetailNames: '{{groupLogic.relatedDetailNames}}',
logicCat: '{{groupLogic.logicCat}}',
logicType: '{{groupLogic.logicType}}',
notMode: {{groupLogic.notMode}},
logics: [
{{#each groupLogic.psDEFDLogics as | logic |}}
{condOP: '{{logic.condOP}}',dEFDName: '{{logic.dEFDName}}',logicType: '{{logic.logicType}}',name: '{{logic.name}}',value:'{{logic.value}}'},
{{/each}}
],
},
{{/each}} {{/each}}
], ],
{{/if}} {{/if}}
......
<AppFormGroup <AppFormGroup
name="{{item.codeName}}" name="{{item.codeName}}"
{{#if item.captionItemName}}
:title="state.data.{{lowerCase item.captionItemName}}"
{{else}}
title="{{item.caption}}" title="{{item.caption}}"
{{/if}}
:visible="state.detailsModel.{{item.codeName}}.visible" :visible="state.detailsModel.{{item.codeName}}.visible"
:layoutOpts="{{> @macro/front-end/common/layoutPos.hbs layout=item.psLayout layoutPos=item.psLayoutPos}}" :layoutOpts="{{> @macro/front-end/common/layoutPos.hbs layout=item.psLayout layoutPos=item.psLayoutPos}}"
{{#if item.psSysCss}} {{#if item.psSysCss}}
......
{{#neq item.psEditor.editorType "HIDDEN"}} {{#neq item.psEditor.editorType "HIDDEN"}}
<AppFormItem <AppFormItem
name="{{item.codeName}}" name="{{item.codeName}}"
{{#if item.captionItemName}}
:label="state.data.{{lowerCase item.captionItemName}}"
{{else}}
label="{{item.caption}}" label="{{item.caption}}"
{{/if}}
{{#if item.labelPos}}
labelPos="{{item.labelPos}}"
{{/if}}
:labelWidth="{{item.labelWidth}}" :labelWidth="{{item.labelWidth}}"
:showLabel="{{item.showCaption}}"
:rules="state.rules.{{item.codeName}}" :rules="state.rules.{{item.codeName}}"
:required="state.detailsModel.{{item.codeName}}.required" :required="state.detailsModel.{{item.codeName}}.required"
:visible="state.detailsModel.{{item.codeName}}.visible" :visible="state.detailsModel.{{item.codeName}}.visible"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
name="{{item.codeName}}" name="{{item.codeName}}"
:visible="state.detailsModel.{{item.codeName}}.visible" :visible="state.detailsModel.{{item.codeName}}.visible"
:layoutOpts="{{> @macro/front-end/common/layoutPos.hbs layout=item.psLayout layoutPos=item.psLayoutPos}}" :layoutOpts="{{> @macro/front-end/common/layoutPos.hbs layout=item.psLayout layoutPos=item.psLayoutPos}}"
name={{item.name}}> >
{{#each item.psDEFormPages as | formPage | }} {{#each item.psDEFormPages as | formPage | }}
{{> @macro/front-end/widgets/form-detail/include-form.hbs type=formPage.detailType item=formPage}} {{> @macro/front-end/widgets/form-detail/include-form.hbs type=formPage.detailType item=formPage}}
{{/each}} {{/each}}
......
<script setup lang="ts"> <script setup lang="ts">
import { IActionParam, ILayoutOpts, IParam } from "@core"; import { IActionParam, ILayoutOpts, deepCopy } from "@core";
interface FormButtonProps{ interface FormButtonProps{
name: string; name: string;
...@@ -9,22 +9,36 @@ interface FormButtonProps{ ...@@ -9,22 +9,36 @@ interface FormButtonProps{
imgPath?: string; imgPath?: string;
showCaption?: boolean; showCaption?: boolean;
labelCssName?: string; labelCssName?: string;
caption: string caption: string,
uIAction: any;
} }
const props = withDefaults(defineProps<FormButtonProps>(), { const props = withDefaults(defineProps<FormButtonProps>(), {
visible: true, visible: true,
showCaption: true, showCaption: true,
}); });
interface FormButtonEmits {
(name: 'action', event: IActionParam): void
}
const emit = defineEmits<FormButtonEmits>();
// 点击
const click = (event: MouseEvent) => {
const data = deepCopy(props.uIAction);
Object.assign(data, { event: event });
emit('action', { tag: name, action: 'formButtonAction', data: data });
}
</script> </script>
<template> <template>
<AppCol :visible="visible" noRoot :layoutOpts="layoutOpts" class="app-formButton"> <AppCol :visible="visible" noRoot :layoutOpts="layoutOpts" class="app-form-button">
<template #default="{slotStyle, slotClass}"> <template #default="{slotStyle, slotClass}">
<a-button <a-button
:class="slotClass" :class="slotClass"
:style="slotStyle" :style="slotStyle"
type="primary"> type="primary"
@click="click">
<AppIconText :class="labelCssName" :iconClass="iconClass" :imgPath="imagePath" :text="showCaption ? caption : '' "/> <AppIconText :class="labelCssName" :iconClass="iconClass" :imgPath="imagePath" :text="showCaption ? caption : '' "/>
</a-button> </a-button>
</template> </template>
......
<script setup lang="ts"> <script setup lang="ts">
import { Ref, ref } from 'vue';
import { IActionParam, ILayoutOpts } from '@core'; import { IActionParam, ILayoutOpts } from '@core';
interface FormGroupProps { interface FormGroupProps {
...@@ -9,6 +10,7 @@ interface FormGroupProps { ...@@ -9,6 +10,7 @@ interface FormGroupProps {
required?: boolean; required?: boolean;
visible?: boolean; visible?: boolean;
labelWidth?: number; labelWidth?: number;
labelPos?: string | 'LEFT' | 'TOP' | 'RIGHT' | 'BOTTOM' | 'NONE';
rules?: any; rules?: any;
error?: string; error?: string;
labelClass?: string; labelClass?: string;
...@@ -19,21 +21,29 @@ interface FormGroupEmit { ...@@ -19,21 +21,29 @@ interface FormGroupEmit {
const props = withDefaults(defineProps<FormGroupProps>(), { const props = withDefaults(defineProps<FormGroupProps>(), {
required: false, required: false,
visible: true, visible: true,
showLabel: true showLabel: true,
labelPos: 'LEFT'
}); });
const emit = defineEmits<FormGroupEmit>(); const emit = defineEmits<FormGroupEmit>();
onBeforeMount(() => { onBeforeMount(() => {
watch(
() => props.required,
(newVal: boolean, oldVal: boolean) => {
initRules();
}
)
initRules(); initRules();
}); });
let itemRules: any = []; const itemRules: Ref<any[]> = ref([]);
const initRules = () => { const initRules = () => {
itemRules.value.splice(0, itemRules.value.length);
if (props.rules) { if (props.rules) {
itemRules.push(...props.rules); itemRules.value.push(...props.rules);
} }
if (props.required) { if (props.required) {
itemRules.push({ itemRules.value.push({
trigger: ['change', 'blur'], trigger: ['change', 'blur'],
required: props.required, required: props.required,
message: props.label + '必须填写', message: props.label + '必须填写',
...@@ -56,7 +66,7 @@ const initRules = () => { ...@@ -56,7 +66,7 @@ const initRules = () => {
:labelCol="{ style: { width: `${labelWidth}px` } }" :labelCol="{ style: { width: `${labelWidth}px` } }"
:validateStatus="error ? 'error' : 'validating'" :validateStatus="error ? 'error' : 'validating'"
> >
<template #label v-if="showLabel"> <template #label v-if="showLabel && labelPos !== 'NONE'">
<label :class="labelClass"> <label :class="labelClass">
<div class="label-title">{{ label }}</div> <div class="label-title">{{ label }}</div>
</label> </label>
......
...@@ -97,7 +97,8 @@ const { handleEditorNavParams, loadCodeListData } = new EditorBase(); ...@@ -97,7 +97,8 @@ const { handleEditorNavParams, loadCodeListData } = new EditorBase();
const { navContext, navViewParam } = handleEditorNavParams(props); const { navContext, navViewParam } = handleEditorNavParams(props);
let text: Ref<string> = ref(""); let text: Ref<string> = ref("");
let textFormat: Ref<string> = ref(""); let textFormat: Ref<string> = ref("");
onBeforeMount(() => { // 初始化值
const initText = () => {
if (props.codeListTag) { if (props.codeListTag) {
loadCodeListData( loadCodeListData(
props.codeListTag as string, props.codeListTag as string,
...@@ -110,11 +111,11 @@ onBeforeMount(() => { ...@@ -110,11 +111,11 @@ onBeforeMount(() => {
if (item) { if (item) {
text.value = item.label; text.value = item.label;
} else { } else {
text.value = props.value; text.value = props.value as string;
} }
}); });
} else { } else {
text.value = props.value; text.value = props.value as string;
} }
if (props.valueFormat) { if (props.valueFormat) {
textFormat.value = props.valueFormat; textFormat.value = props.valueFormat;
...@@ -128,6 +129,12 @@ onBeforeMount(() => { ...@@ -128,6 +129,12 @@ onBeforeMount(() => {
} else if (Object.is(props.dataType, "NUMBER")) { } else if (Object.is(props.dataType, "NUMBER")) {
textFormat.value = `#${props.unitName}`; textFormat.value = `#${props.unitName}`;
} }
}
onBeforeMount(() => {
// 监听值变化
watch(() => props.value, (newVal: any, oldVal: any) => { if (newVal !== oldVal) initText(); });
initText();
}); });
</script> </script>
......
import { IParam, MainControlState } from '@core'; import { ControlVOBase, IParam, MainControlState } from '@core';
/** /**
* @description 表单部件状态 * @description 表单部件状态
...@@ -9,25 +9,25 @@ import { IParam, MainControlState } from '@core'; ...@@ -9,25 +9,25 @@ import { IParam, MainControlState } from '@core';
export interface FormControlState extends MainControlState { export interface FormControlState extends MainControlState {
/** /**
* @description 表单数据对象 * @description 新建默认值集合
* @type {IParam} * @type {IParam[]}
* @memberof FormControlState * @memberof FormControlState
*/ */
data: IParam; createDefaultItems: IParam[];
/** /**
* @description 表单成员模型 * @description 表单数据对象
* @type {IParam} * @type {IParam}
* @memberof FormControlState * @memberof FormControlState
*/ */
detailsModel: IParam; data: ControlVOBase;
/** /**
* @description 表单界面行为模型 * @description 表单成员模型
* @type {IParam} * @type {IParam}
* @memberof FormControlState * @memberof FormControlState
*/ */
actionModel: IParam; detailsModel: IParam;
/** /**
* @description 值规则 * @description 值规则
...@@ -42,4 +42,11 @@ export interface FormControlState extends MainControlState { ...@@ -42,4 +42,11 @@ export interface FormControlState extends MainControlState {
* @memberof FormControlState * @memberof FormControlState
*/ */
enableAutoSave: boolean; enableAutoSave: boolean;
/**
* @description 更新默认值集合
* @type {IParam[]}
* @memberof FormControlState
*/
updateDefaultItems: IParam[];
} }
...@@ -43,15 +43,15 @@ export class FormControl extends MainControl { ...@@ -43,15 +43,15 @@ export class FormControl extends MainControl {
* @memberof FormControl * @memberof FormControl
*/ */
public verifyGroupLogic(data: IParam, logic: IParam) { public verifyGroupLogic(data: IParam, logic: IParam) {
if (logic.logicType == 'GROUP' && logic.logics?.length > 0) { if (logic.logicType == 'GROUP' && logic.childLogics?.length > 0) {
let result: boolean = true; let result: boolean = true;
if (logic.groupOP == 'AND') { if (logic.groupOP == 'AND') {
const falseItem = logic.logics.find((childLogic: IParam) => { const falseItem = logic.childLogics.find((childLogic: IParam) => {
return !this.verifyGroupLogic(data, childLogic); return !this.verifyGroupLogic(data, childLogic);
}); });
result = falseItem ? false : true; result = falseItem ? false : true;
} else if (logic.groupOP == 'OR') { } else if (logic.groupOP == 'OR') {
const trueItem = logic.logics.find((childLogic: IParam) => { const trueItem = logic.childLogics.find((childLogic: IParam) => {
return this.verifyGroupLogic(data, childLogic); return this.verifyGroupLogic(data, childLogic);
}); });
result = trueItem ? true : false; result = trueItem ? true : false;
...@@ -77,6 +77,10 @@ export class FormControl extends MainControl { ...@@ -77,6 +77,10 @@ export class FormControl extends MainControl {
public handleFormDataChange(name: string, value: any) { public handleFormDataChange(name: string, value: any) {
const { enableAutoSave } = this.state; const { enableAutoSave } = this.state;
const { data } = toRefs(this.state); const { data } = toRefs(this.state);
// 无标识或数据未变化不触发后续逻辑
if (!name || Object.is(value, data.value[name])) {
return;
}
data.value[name] = value; data.value[name] = value;
this.resetFormData(name); this.resetFormData(name);
this.formItemUpdate(name); this.formItemUpdate(name);
...@@ -110,24 +114,26 @@ export class FormControl extends MainControl { ...@@ -110,24 +114,26 @@ export class FormControl extends MainControl {
*/ */
public async formItemUpdate(name: string) { public async formItemUpdate(name: string) {
const { detailsModel, context, viewParams, controlService } = this.state; const { detailsModel, context, viewParams, controlService } = this.state;
const { data } = toRefs(this.state);
if (detailsModel[name] && detailsModel[name].formItemUpdate) { if (detailsModel[name] && detailsModel[name].formItemUpdate) {
const formItemUpdate = detailsModel[name].formItemUpdate; const formItemUpdate = detailsModel[name].formItemUpdate;
if (formItemUpdate.customCode) { if (formItemUpdate.customCode) {
if (formItemUpdate.scriptCode) { if (formItemUpdate.scriptCode) {
const { data: _data } = toRefs(this.state);
let data: any = _data.value;
eval(formItemUpdate.scriptCode); eval(formItemUpdate.scriptCode);
} }
} else { } else {
const arg = Object.assign(deepCopy(viewParams), data.value); const { data } = toRefs(this.state);
const arg = Object.assign(deepCopy(viewParams), data.value.getDo());
const tempContext = deepCopy(context); const tempContext = deepCopy(context);
const response = await controlService.frontLogic( const response = await controlService.frontLogic(
tempContext, tempContext,
{ viewParams: arg }, arg,
{ action: formItemUpdate.appDEMethod, isLoading: formItemUpdate.showBusyIndicator }, { action: formItemUpdate.appDEMethod, isLoading: formItemUpdate.showBusyIndicator },
); );
if (response.status && response.status == 200) { if (response.status && response.status == 200) {
formItemUpdate.updateDetails?.forEach((detailsName: string) => { formItemUpdate.updateDetails?.forEach((detailsName: string) => {
if (data.value.hasOwnProperty(detailsName)) { if (data.value.hasKey(detailsName)) {
data.value[detailsName] = response.data[detailsName]; data.value[detailsName] = response.data[detailsName];
} }
}); });
...@@ -209,7 +215,7 @@ export class FormControl extends MainControl { ...@@ -209,7 +215,7 @@ export class FormControl extends MainControl {
switch (item.enableCond) { switch (item.enableCond) {
case 0: case 0:
// 不启用 // 不启用
item.disabled = false; item.disabled = true;
break; break;
case 1: case 1:
// 新建 // 新建
...@@ -221,7 +227,7 @@ export class FormControl extends MainControl { ...@@ -221,7 +227,7 @@ export class FormControl extends MainControl {
break; break;
case 3: case 3:
// 启用 // 启用
item.disabled = true; item.disabled = false;
break; break;
default: default:
break; break;
...@@ -247,7 +253,7 @@ export class FormControl extends MainControl { ...@@ -247,7 +253,7 @@ export class FormControl extends MainControl {
item.isPower = tempModel[item.uIActionTag].dataActionResult === 1 ? true : false; item.isPower = tempModel[item.uIActionTag].dataActionResult === 1 ? true : false;
} else if (Object.is(item.detailType, 'GROUPPANEL') && item.uIActionGroup?.details?.length > 0) { } else if (Object.is(item.detailType, 'GROUPPANEL') && item.uIActionGroup?.details?.length > 0) {
// 更新分组面板界面行为组的权限状态值 // 更新分组面板界面行为组的权限状态值
item.uiActionGroup.details.forEach((actionDetail: any) => { item.uIActionGroup.details.forEach((actionDetail: any) => {
actionDetail.visible = tempModel[actionDetail.uIActionTag].visible; actionDetail.visible = tempModel[actionDetail.uIActionTag].visible;
actionDetail.disabled = tempModel[actionDetail.uIActionTag].disabled; actionDetail.disabled = tempModel[actionDetail.uIActionTag].disabled;
}); });
...@@ -276,42 +282,43 @@ export class FormControl extends MainControl { ...@@ -276,42 +282,43 @@ export class FormControl extends MainControl {
* @memberof FormControl * @memberof FormControl
*/ */
public setCreateDefault() { public setCreateDefault() {
const { detailsModel, context, viewParams, controlService } = this.state; const { createDefaultItems, context, viewParams, controlService } = this.state;
const { data } = toRefs(this.state); const { data } = toRefs(this.state);
Object.values(detailsModel).forEach((detail: IParam) => { if (createDefaultItems && createDefaultItems.length) {
if (Object.is(detail.detailType, 'FORMITEM')) { createDefaultItems.forEach((item: IParam) => {
if ((detail.createDV || detail.createDVT) && data.value.hasOwnProperty(detail.codeName)) { const { createDV, createDVT, property, dataType, valueFormat } = item;
switch (detail.createDVT) { if ((createDV || createDVT) && data.value.hasKey(property)) {
switch (createDVT) {
case 'CONTEXT': case 'CONTEXT':
data.value[detail.codeName] = viewParams[detail.createDV]; data.value[property] = viewParams[createDV];
break; break;
case 'SESSION': case 'SESSION':
data.value[detail.codeName] = context[detail.createDV]; data.value[property] = context[createDV];
break; break;
case 'APPDATA': case 'APPDATA':
data.value[detail.codeName] = context[detail.createDV]; data.value[property] = context[createDV];
break; break;
case 'OPERATORNAME': case 'OPERATORNAME':
data.value[detail.codeName] = context['srfusername']; data.value[property] = context['srfusername'];
break; break;
case 'OPERATOR': case 'OPERATOR':
data.value[detail.codeName] = context['srfuserid']; data.value[property] = context['srfuserid'];
break; break;
case 'CURTIME': case 'CURTIME':
data.value[detail.codeName] = dateFormat(new Date(), detail.valueFormat); data.value[property] = dateFormat(new Date(), valueFormat);
break; break;
case 'PARAM': case 'PARAM':
data.value[detail.codeName] = controlService.getRemoteCopyData()?.[detail.codeName] || null; data.value[property] = controlService.getRemoteCopyData()?.[property] || null;
break; break;
default: default:
data.value[detail.codeName] = DataTypes.isNumber(detail.dataType) data.value[property] = DataTypes.isNumber(dataType)
? Number(detail?.createDV) ? Number(createDV)
: detail?.createDV; : createDV;
break; break;
} }
} }
} });
}); }
} }
/** /**
...@@ -319,42 +326,43 @@ export class FormControl extends MainControl { ...@@ -319,42 +326,43 @@ export class FormControl extends MainControl {
* @memberof FormControl * @memberof FormControl
*/ */
public setUpdateDefault() { public setUpdateDefault() {
const { detailsModel, context, viewParams, controlService } = this.state; const { updateDefaultItems, context, viewParams, controlService } = this.state;
const { data } = toRefs(this.state); const { data } = toRefs(this.state);
Object.values(detailsModel).forEach((detail: IParam) => { if (updateDefaultItems && updateDefaultItems.length) {
if (Object.is(detail.detailType, 'FORMITEM')) { updateDefaultItems.forEach((item: IParam) => {
if ((detail.updateDV || detail.updateDVT) && data.value.hasOwnProperty(detail.codeName)) { const { updateDV, updateDVT, property, dataType, valueFormat } = item;
switch (detail.updateDVT) { if ((updateDV || updateDVT) && data.value.hasKey(property)) {
switch (updateDVT) {
case 'CONTEXT': case 'CONTEXT':
data.value[detail.codeName] = viewParams[detail.updateDV]; data.value[property] = viewParams[updateDV];
break; break;
case 'SESSION': case 'SESSION':
data.value[detail.codeName] = context[detail.updateDV]; data.value[property] = context[updateDV];
break; break;
case 'APPDATA': case 'APPDATA':
data.value[detail.codeName] = context[detail.updateDV]; data.value[property] = context[updateDV];
break; break;
case 'OPERATORNAME': case 'OPERATORNAME':
data.value[detail.codeName] = context['srfusername']; data.value[property] = context['srfusername'];
break; break;
case 'OPERATOR': case 'OPERATOR':
data.value[detail.codeName] = context['srfuserid']; data.value[property] = context['srfuserid'];
break; break;
case 'CURTIME': case 'CURTIME':
data.value[detail.codeName] = dateFormat(new Date(), detail.valueFormat); data.value[property] = dateFormat(new Date(), valueFormat);
break; break;
case 'PARAM': case 'PARAM':
data.value[detail.codeName] = controlService.getRemoteCopyData()?.[detail.codeName] || null; data.value[property] = controlService.getRemoteCopyData()?.[property] || null;
break; break;
default: default:
data.value[detail.codeName] = DataTypes.isNumber(detail.dataType) data.value[property] = DataTypes.isNumber(dataType)
? Number(detail.updateDV) ? Number(updateDV)
: detail.updateDV; : updateDV;
break; break;
} }
} }
} })
}); }
} }
/** /**
...@@ -726,6 +734,9 @@ export class FormControl extends MainControl { ...@@ -726,6 +734,9 @@ export class FormControl extends MainControl {
case 'formGroupAction': case 'formGroupAction':
this.handleFormGroupAction(tag, data); this.handleFormGroupAction(tag, data);
break; break;
case 'formButtonAction':
this.handleFormButtonAction(tag, data);
break;
default: default:
break; break;
} }
...@@ -733,12 +744,48 @@ export class FormControl extends MainControl { ...@@ -733,12 +744,48 @@ export class FormControl extends MainControl {
/** /**
* @description 处理表单分组行为 * @description 处理表单分组行为
* @param {string} tag * @protected
* @param {string} 标识
* @param {*} data 数据
* @memberof FormControl
*/
protected handleFormGroupAction(tag: string, data: any) {
this.handleUIAction(data);
}
/**
* @description 处理表单按钮界面行为
* @protected
* @param {string} tag 按钮标识
* @param {*} data 数据
* @memberof FormControl
*/
protected handleFormButtonAction(tag: string, data: any) {
this.handleUIAction(data);
}
/**
* @description 处理界面行为
* @private
* @param {*} data * @param {*} data
* @return {*}
* @memberof FormControl * @memberof FormControl
*/ */
public handleFormGroupAction(tag: string, data: any) { private handleUIAction(data: any) {
console.log(tag, data); if (!data) {
console.warn("工具栏执行参数不足");
return;
}
// 准备参数
const inputParam = {
context: this.state.context,
viewParams: this.state.viewParams,
data: this.getData(),
event: data.event,
actionEnvironment: this
};
// 执行行为
App.getAppActionService().execute(data, inputParam);
} }
/** /**
......
...@@ -509,7 +509,7 @@ export class GridControl extends MDControl { ...@@ -509,7 +509,7 @@ export class GridControl extends MDControl {
const { groupField } = gridGroup; const { groupField } = gridGroup;
let autoGroup: string[] = []; let autoGroup: string[] = [];
items.value.forEach((item: IParam) => { items.value.forEach((item: IParam) => {
if (item.hasOwnProperty(groupField)) { if (item.hasKey(groupField)) {
autoGroup.push(item[groupField]); autoGroup.push(item[groupField]);
} }
}) })
...@@ -652,13 +652,13 @@ export class GridControl extends MDControl { ...@@ -652,13 +652,13 @@ export class GridControl extends MDControl {
* @memberof GridControl * @memberof GridControl
*/ */
protected setCreateDefault(row: IParam = {}): void { protected setCreateDefault(row: IParam = {}): void {
const { createDefaultItems, viewParams, context, items } = this.state; const { createDefaultItems, viewParams, context } = this.state;
if (createDefaultItems.length === 0) { if (createDefaultItems.length === 0) {
return; return;
} }
createDefaultItems.forEach((item: IParam) => { createDefaultItems.forEach((item: IParam) => {
const { createDVT, createDV, property, valueFormat, fieldType } = item; const { createDVT, createDV, property, valueFormat, dataType } = item;
if (createDVT && (row.hasOwnProperty(property) || property in row)) { if (createDVT && row.hasKey(property)) {
switch (createDVT) { switch (createDVT) {
case "CONTEXT": case "CONTEXT":
if (createDV) { if (createDV) {
...@@ -686,8 +686,8 @@ export class GridControl extends MDControl { ...@@ -686,8 +686,8 @@ export class GridControl extends MDControl {
} }
break; break;
} }
} else if (createDV && (row.hasOwnProperty(property) || property in row)) { } else if (createDV && row.hasKey(property)) {
row[property] = fieldType && DataTypes.isNumber(fieldType) ? Number(createDV) : createDV; row[property] = dataType && DataTypes.isNumber(dataType) ? Number(createDV) : createDV;
} }
}); });
} }
...@@ -700,14 +700,14 @@ export class GridControl extends MDControl { ...@@ -700,14 +700,14 @@ export class GridControl extends MDControl {
* @memberof GridControl * @memberof GridControl
*/ */
protected setUpdateDefault(): void { protected setUpdateDefault(): void {
const { updateDefaultItems, viewParams, context, items, controlService } = this.state; const { updateDefaultItems, viewParams, context, items } = this.state;
if (updateDefaultItems.length === 0 || items.length === 0) { if (updateDefaultItems.length === 0 || items.length === 0) {
return; return;
} }
const setDefault = (row: IParam = {}) => { const setDefault = (row: IParam = {}) => {
updateDefaultItems.forEach((item: IParam) => { updateDefaultItems.forEach((item: IParam) => {
const { updateDV, updateDVT, property, valueFormat, fieldType } = item; const { updateDV, updateDVT, property, valueFormat, dataType } = item;
if (updateDVT && (row.hasOwnProperty(property) || property in row)) { if (updateDVT && row.hasKey(property)) {
switch (updateDVT) { switch (updateDVT) {
case "CONTEXT": case "CONTEXT":
if (updateDV) { if (updateDV) {
...@@ -735,8 +735,8 @@ export class GridControl extends MDControl { ...@@ -735,8 +735,8 @@ export class GridControl extends MDControl {
} }
break; break;
} }
} else if (updateDV && row.hasOwnProperty(property)) { } else if (updateDV && row.hasKey(property)) {
row[property] = fieldType && DataTypes.isNumber(fieldType) ? Number(updateDV) : updateDV; row[property] = dataType && DataTypes.isNumber(dataType) ? Number(updateDV) : updateDV;
} }
}); });
} }
......
import { IParam, MainControlState } from '@core'; import { ControlVOBase, IParam, MainControlState } from '@core';
/** /**
* @description 多数据部件状态 * @description 多数据部件状态
...@@ -20,7 +20,7 @@ export interface MDControlState extends MainControlState { ...@@ -20,7 +20,7 @@ export interface MDControlState extends MainControlState {
* @type {IParam[]} * @type {IParam[]}
* @memberof MDControlState * @memberof MDControlState
*/ */
items: IParam[]; items: ControlVOBase[];
/** /**
* @description 是否多选 * @description 是否多选
......
import { deepCopy } from '@core'; import { deepCopy, IParam } from '@core';
export class ControlVOBase { export class ControlVOBase {
/** /**
* 后台数据对象 * @description 后台数据对象
* @protected * @protected
* @type {*}
* @memberof ControlVOBase
*/ */
protected $DO: any = {}; protected $DO: any = {};
/** /**
* 自有属性名称集合 * @description 自有属性名称集合
* @type {string[]}
* @memberof ControlVOBase
*/ */
public $ownKeys: string[] = []; public $ownKeys: string[] = [];
...@@ -91,6 +95,19 @@ export class ControlVOBase { ...@@ -91,6 +95,19 @@ export class ControlVOBase {
return {}; return {};
} }
/**
* @description 是否含有属性
* @param {string} key 属性名
* @return {*} {boolean}
* @memberof ControlVOBase
*/
public hasKey(key: string): boolean {
if (this.hasOwnProperty(key) || key in this) {
return true;
}
return false;
}
/** /**
* 用后台数据重置数据对象 * 用后台数据重置数据对象
* @param data 后台数据 * @param data 后台数据
......
...@@ -51,15 +51,56 @@ export const ctrlState = { ...@@ -51,15 +51,56 @@ export const ctrlState = {
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({}),
{{#each ctrl.psAppDataEntity.allPSAppDEFields as | appDEField | }} appEntityCodeName: '{{ctrl.appEntity.codeName}}',
{{#if appDEField.keyField}} appDeCodeName:'{{ctrl.appEntity.codeName}}',
appDeKeyFieldName: '{{appDEField.codeName}}', appDeLogicName: '{{ctrl.appEntity.logicName}}',
{{/if}} appDeKeyFieldName: '{{#if ctrl.appEntity.keyPSAppDEField}}{{ctrl.appEntity.keyPSAppDEField.codeName}}{{/if}}',
{{#if appDEField.majorField}} appDeMajorFieldName: '{{#if ctrl.appEntity.majorPSAppDEField}}{{ctrl.appEntity.majorPSAppDEField.codeName}}{{/if}}',
appDeMajorFieldName: '{{appDEField.codeName}}',
{{/if}}
{{/each}}
enableAutoSave: {{ctrl.enableAutoSave}}, enableAutoSave: {{ctrl.enableAutoSave}},
// 新建默认值
createDefaultItems: [
{{#each ctrl.psDEFormItems as | formItem |}}
{{#formItem}}
{{#if (or createDV createDVT)}}
{
createDV: "{{createDV}}",
createDVT: "{{createDVT}}",
property: "{{lowerCase id}}",
{{#if (and psEditor psEditor.dateTimeFormat)}}
valueFormat: "{{editItem.psEditor.dateTimeFormat}}",
{{else if psAppDEField}}
valueFormat: "{{psAppDEField.valueFormat}}",
{{/if}}
{{#if psAppDEField}}
dataType: "{{psAppDEField.stdDataType}}"
{{/if}}
}{{#unless @last}},{{/unless}}
{{/if}}
{{/formItem}}
{{/each}}
],
// 更新默认值
updateDefaultItems: [
{{#each ctrl.psDEFormItems as | formItem |}}
{{#formItem}}
{{#if (or updateDV updateDVT)}}
{
updateDV: "{{updateDV}}",
updateDVT: "{{updateDVT}}",
property: "{{lowerCase id}}",
{{#if (and psEditor psEditor.dateTimeFormat)}}
valueFormat: "{{editItem.psEditor.dateTimeFormat}}",
{{else if psAppDEField}}
valueFormat: "{{psAppDEField.valueFormat}}",
{{/if}}
{{#if psAppDEField}}
dataType: "{{psAppDEField.stdDataType}}"
{{/if}}
}{{#unless @last}},{{/unless}}
{{/if}}
{{/formItem}}
{{/each}}
],
detailsModel: { detailsModel: {
{{#if ctrl.psDEFormPages}} {{#if ctrl.psDEFormPages}}
{{#each ctrl.psDEFormPages as | FormPage | }} {{#each ctrl.psDEFormPages as | FormPage | }}
...@@ -73,17 +114,17 @@ export const ctrlState = { ...@@ -73,17 +114,17 @@ export const ctrlState = {
{{/each}} {{/each}}
}, },
rules: { rules: {
{{#each ctrl.psDEFormItemVRs as | ruleItem |}} {{#each ctrl.psDEFormItemVRs as | ruleItem |}}
{{#if (eq ruleItem.valueRuleType 'SYSVALUERULE')}} {{#if (eq ruleItem.valueRuleType 'SYSVALUERULE')}}
{{ruleItem.psDEFormItemName}}: [ {{ruleItem.psDEFormItemName}}: [
{ {
trigger: ['change', 'blur'], trigger: ['change', 'blur'],
{{#eq ruleItem.psSysValueRule.ruleType 'REG'}} {{#eq ruleItem.psSysValueRule.ruleType 'REG'}}
pattern: /{{ruleItem.psSysValueRule.regExCode}}/, pattern: /{{ruleItem.psSysValueRule.regExCode}}/,
{{/eq}} {{/eq}}
message:'{{ruleItem.psSysValueRule.ruleInfo}}' message:'{{ruleItem.psSysValueRule.ruleInfo}}'
}], }],
{{/if}} {{/if}}
{{/each}} {{/each}}
}, },
}; };
\ No newline at end of file
...@@ -48,7 +48,7 @@ export const ctrlState = { ...@@ -48,7 +48,7 @@ export const ctrlState = {
valueFormat: "{{editItem.psAppDEField.valueFormat}}", valueFormat: "{{editItem.psAppDEField.valueFormat}}",
{{/if}} {{/if}}
{{#if editItem.psAppDEField}} {{#if editItem.psAppDEField}}
fieldType: "{{editItem.psAppDEField.stdDataType}}" dataType: "{{editItem.psAppDEField.stdDataType}}"
{{/if}} {{/if}}
}{{#unless @last}},{{/unless}} }{{#unless @last}},{{/unless}}
{{/if}} {{/if}}
...@@ -180,7 +180,7 @@ export const ctrlState = { ...@@ -180,7 +180,7 @@ export const ctrlState = {
valueFormat: "{{editItem.psAppDEField.valueFormat}}", valueFormat: "{{editItem.psAppDEField.valueFormat}}",
{{/if}} {{/if}}
{{#if editItem.psAppDEField}} {{#if editItem.psAppDEField}}
fieldType: "{{editItem.psAppDEField.stdDataType}}" dataType: "{{editItem.psAppDEField.stdDataType}}"
{{/if}} {{/if}}
}{{#unless @last}},{{/unless}} }{{#unless @last}},{{/unless}}
{{/if}} {{/if}}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册