提交 c5f14fb3 编写于 作者: MosYCo's avatar MosYCo

update:更新表单关系界面保存

上级 adc3ef6a
......@@ -25,7 +25,11 @@
:localViewParams="{{> @macro/front-end/common/navparam.hbs appNavParams=item.psNavigateParams}}"
{{/if}}
:data="state.data"
:viewSubject="state.viewSubject">
:viewSubject="state.viewSubject"
{{#or (eq item.psAppView.tempMode 0) (eq item.psAppView.tempMode 1) eq item.psAppView.tempMode 2}}
:tempMode="{{item.psAppView.tempMode}}"
{{/or}}
@componentEvent="onComponentEvent">
<template #default="druipartParams">
<{{item.psAppView.codeName}}
:class="['app-view-layout--from-druipart']"
......
......@@ -7,8 +7,6 @@ interface FormDruipartProps {
name: string;
// 布局配置项
layoutOpts: ILayoutOpts;
// 刷新关系项
tempMode?: string;
// 禁止加载
isForbidLoad?: boolean;
// 传入参数项名称
......@@ -43,6 +41,8 @@ interface FormDruipartProps {
localContext?: IParam;
// 导航视图参数
localViewParams?: IParam;
// 临时模式
tempMode?: 0 | 1 | 2 | number;
}
interface FormDruipartEmit {
(name: 'componentEvent', value: IActionParam): void;
......@@ -91,6 +91,18 @@ onBeforeMount(() => {
);
druipartInit();
});
const beforeSave = (data: any) => {
if (props.tempMode == 2) {
props.viewSubject.next({ tag: props.viewCodeName, action: 'viewSave', data: data });
} else {
if (data && data.srfuf !== '0') {
props.viewSubject.next({ tag: props.viewCodeName, action: 'viewSave', data: data });
} else {
emit("componentEvent", { tag: props.name, action: 'formDruipartAction', data: { type: 'drDataSaved' } });
}
}
}
// 关系界面初始化
const druipartInit = () => {
if (!props.viewSubject) {
......@@ -101,10 +113,17 @@ const druipartInit = () => {
});
formSubjectEvent = props.formSubject.subscribe(({ type, data }) => {
if (!type) {
return;
}
// 表单加载完成
if (type && Object.is(type, 'load')) {
if (Object.is(type, 'load')) {
refreshDRUIPart(data);
}
// 表单保存之前
if (Object.is(type, 'beforesave')) {
beforeSave(data);
}
})
};
......@@ -164,7 +183,14 @@ const refreshDRUIPart = (data?: any) => {
});
};
const onViewEvent = (action:any) => {
// 处理视图事件
const onViewEvent = (actionParam: IActionParam) => {
const { tag, action, data } = actionParam;
if (tag && tag === props.viewCodeName) {
if (action === 'save') {
emit("componentEvent", { tag: props.name, action: 'formDruipartAction', data: { type: 'drDataSaved' } });
}
}
};
</script>
......
import { ViewBase, MainViewState, IActionParam, IParam, isExistAndNotEmpty } from '@core';
import { ViewBase, MainViewState, IActionParam, IParam, isExistAndNotEmpty, hasFunction } from '@core';
/**
* 实体视图
......@@ -38,6 +38,11 @@ export class MainView extends ViewBase {
if (action === 'viewRefresh') {
this.refresh(data);
}
if (action === 'viewSave') {
if (this.xDataControl && hasFunction(this.xDataControl, 'save')) {
this.xDataControl.save(data);
}
}
})
}
}
......@@ -195,7 +200,7 @@ export class MainView extends ViewBase {
const { tag, action, data } = actionParam;
if (tag === this.state.xDataControlName) {
if (action === 'save') {
this.emit('viewEvent', { tag: this.state.viewName, action: 'viewsave', data: data });
this.emit('viewEvent', { tag: this.state.viewName, action: 'save', data: data });
}
}
}
......
......@@ -45,6 +45,23 @@ export class FormControl extends MainControl {
public setState() {
super.setState();
this.state.formSubject = new Subject();
this.computeDrCount();
}
/**
* @description 计算关系界面个数
* @private
* @memberof FormControl
*/
private computeDrCount() {
const { detailsModel } = this.state;
if (detailsModel && Object.values(detailsModel).length) {
Object.values(detailsModel).forEach((item: IParam) => {
if (item.detailType === 'DRUIPART') {
this.state.drCount += 1;
}
})
}
}
/**
......@@ -549,6 +566,11 @@ export class FormControl extends MainControl {
Object.assign(arg, data.getDo());
Object.assign(arg, _viewParams);
if (isStateNext && this.state.drCount > 0) {
this.state.drCounter = this.state.drCount;
this.state.drSaveOpt = opt;
// 通知关系界面保存
formSubject.next({ type: 'beforesave', data: arg });
return;
}
// 拷贝模式
if (_viewParams && _viewParams.copyMode) {
......@@ -760,6 +782,9 @@ export class FormControl extends MainControl {
case 'formButtonAction':
this.handleFormButtonAction(tag, data);
break;
case 'formDruipartAction':
this.handleFormDruipartAction(tag, data);
break;
default:
break;
}
......@@ -787,6 +812,20 @@ export class FormControl extends MainControl {
this.handleUIAction(data);
}
/**
* @description 处理表单关系界面行为
* @protected
* @param {string} tag
* @param {*} data
* @memberof FormControl
*/
protected handleFormDruipartAction(tag: string, data: any) {
// 关系界面保存完成
if (data?.type == 'drDataSaved') {
this.onDrDataSaved();
}
}
/**
* @description 处理界面行为
* @private
......@@ -811,6 +850,22 @@ export class FormControl extends MainControl {
App.getAppActionService().execute(data, inputParam);
}
/**
* @description 表单关系界面保存完成
* @protected
* @memberof FormControl
*/
protected onDrDataSaved() {
let { drCounter, drSaveOpt, showBusyIndicator } = this.state;
drCounter--;
if (drCounter == 0) {
this.save(drSaveOpt, showBusyIndicator, false).then(() => {
// TODO 待补充保存并关闭、保存并新建后续操作
drSaveOpt = {};
});
}
}
/**
* @description 表单值规则校验状态
* @private
......
......@@ -161,6 +161,7 @@ export class MDControl extends MainControl {
if (response.status && response.status == 200) {
}
}
this.emit('ctrlEvent', { tag: this.props.name, action: 'save', data: items });
} catch (error) {
// TODO 错误异常处理
console.log(error);
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册