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

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

上级 adc3ef6a
...@@ -25,7 +25,11 @@ ...@@ -25,7 +25,11 @@
:localViewParams="{{> @macro/front-end/common/navparam.hbs appNavParams=item.psNavigateParams}}" :localViewParams="{{> @macro/front-end/common/navparam.hbs appNavParams=item.psNavigateParams}}"
{{/if}} {{/if}}
:data="state.data" :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"> <template #default="druipartParams">
<{{item.psAppView.codeName}} <{{item.psAppView.codeName}}
:class="['app-view-layout--from-druipart']" :class="['app-view-layout--from-druipart']"
......
...@@ -7,8 +7,6 @@ interface FormDruipartProps { ...@@ -7,8 +7,6 @@ interface FormDruipartProps {
name: string; name: string;
// 布局配置项 // 布局配置项
layoutOpts: ILayoutOpts; layoutOpts: ILayoutOpts;
// 刷新关系项
tempMode?: string;
// 禁止加载 // 禁止加载
isForbidLoad?: boolean; isForbidLoad?: boolean;
// 传入参数项名称 // 传入参数项名称
...@@ -43,6 +41,8 @@ interface FormDruipartProps { ...@@ -43,6 +41,8 @@ interface FormDruipartProps {
localContext?: IParam; localContext?: IParam;
// 导航视图参数 // 导航视图参数
localViewParams?: IParam; localViewParams?: IParam;
// 临时模式
tempMode?: 0 | 1 | 2 | number;
} }
interface FormDruipartEmit { interface FormDruipartEmit {
(name: 'componentEvent', value: IActionParam): void; (name: 'componentEvent', value: IActionParam): void;
...@@ -91,6 +91,18 @@ onBeforeMount(() => { ...@@ -91,6 +91,18 @@ onBeforeMount(() => {
); );
druipartInit(); 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 = () => { const druipartInit = () => {
if (!props.viewSubject) { if (!props.viewSubject) {
...@@ -101,10 +113,17 @@ const druipartInit = () => { ...@@ -101,10 +113,17 @@ const druipartInit = () => {
}); });
formSubjectEvent = props.formSubject.subscribe(({ type, data }) => { formSubjectEvent = props.formSubject.subscribe(({ type, data }) => {
if (!type) {
return;
}
// 表单加载完成 // 表单加载完成
if (type && Object.is(type, 'load')) { if (Object.is(type, 'load')) {
refreshDRUIPart(data); refreshDRUIPart(data);
} }
// 表单保存之前
if (Object.is(type, 'beforesave')) {
beforeSave(data);
}
}) })
}; };
...@@ -164,7 +183,14 @@ const refreshDRUIPart = (data?: any) => { ...@@ -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> </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 { ...@@ -38,6 +38,11 @@ export class MainView extends ViewBase {
if (action === 'viewRefresh') { if (action === 'viewRefresh') {
this.refresh(data); 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 { ...@@ -195,7 +200,7 @@ export class MainView extends ViewBase {
const { tag, action, data } = actionParam; const { tag, action, data } = actionParam;
if (tag === this.state.xDataControlName) { if (tag === this.state.xDataControlName) {
if (action === 'save') { 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 { ...@@ -45,6 +45,23 @@ export class FormControl extends MainControl {
public setState() { public setState() {
super.setState(); super.setState();
this.state.formSubject = new Subject(); 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 { ...@@ -549,6 +566,11 @@ export class FormControl extends MainControl {
Object.assign(arg, data.getDo()); Object.assign(arg, data.getDo());
Object.assign(arg, _viewParams); Object.assign(arg, _viewParams);
if (isStateNext && this.state.drCount > 0) { 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) { if (_viewParams && _viewParams.copyMode) {
...@@ -760,6 +782,9 @@ export class FormControl extends MainControl { ...@@ -760,6 +782,9 @@ export class FormControl extends MainControl {
case 'formButtonAction': case 'formButtonAction':
this.handleFormButtonAction(tag, data); this.handleFormButtonAction(tag, data);
break; break;
case 'formDruipartAction':
this.handleFormDruipartAction(tag, data);
break;
default: default:
break; break;
} }
...@@ -787,6 +812,20 @@ export class FormControl extends MainControl { ...@@ -787,6 +812,20 @@ export class FormControl extends MainControl {
this.handleUIAction(data); 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 处理界面行为 * @description 处理界面行为
* @private * @private
...@@ -811,6 +850,22 @@ export class FormControl extends MainControl { ...@@ -811,6 +850,22 @@ export class FormControl extends MainControl {
App.getAppActionService().execute(data, inputParam); 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 表单值规则校验状态 * @description 表单值规则校验状态
* @private * @private
......
...@@ -161,6 +161,7 @@ export class MDControl extends MainControl { ...@@ -161,6 +161,7 @@ export class MDControl extends MainControl {
if (response.status && response.status == 200) { if (response.status && response.status == 200) {
} }
} }
this.emit('ctrlEvent', { tag: this.props.name, action: 'save', data: items });
} catch (error) { } catch (error) {
// TODO 错误异常处理 // TODO 错误异常处理
console.log(error); console.log(error);
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册