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