提交 c1d6db61 编写于 作者: tony001's avatar tony001

修复关系界面内嵌视图出现不加载的情况

上级 19c862e7
<template> <template>
<div class='form-druipart'> <div class='form-druipart'>
<component <component
ref="appFormDruipart"
:is="viewname" :is="viewname"
class="viewcontainer2" class="viewcontainer2"
:viewdata ="viewdata" :viewdata ="viewdata"
...@@ -178,6 +179,14 @@ export default class AppFormDRUIPart extends Vue { ...@@ -178,6 +179,14 @@ export default class AppFormDRUIPart extends Vue {
*/ */
private formStateEvent: Unsubscribable | undefined; private formStateEvent: Unsubscribable | undefined;
/**
* 定时器实例
*
* @type {[any]}
* @memberof AppFormDRUIPart
*/
protected timer?: any;
/** /**
* 监控值 * 监控值
* *
...@@ -308,11 +317,43 @@ export default class AppFormDRUIPart extends Vue { ...@@ -308,11 +317,43 @@ export default class AppFormDRUIPart extends Vue {
} }
if(!this.isForbidLoad){ if(!this.isForbidLoad){
setTimeout(() => { setTimeout(() => {
this.formDruipart.next({action:'load',data:{srfparentdename:this.parentName,srfparentkey:_paramitem}}); this.partViewEvent('load',{data:{srfparentdename:this.parentName,srfparentkey:_paramitem}},0);
}, 0); }, 0);
} }
} }
/**
* 向关系视图发送事件,采用轮询模式。避免异步视图出现加载慢情况
*
* @param {*} action 触发行为
* @param {*} data 数据
* @param {*} count 轮询计数
* @memberof AppFormDRUIPart
*/
protected partViewEvent(action: string, data: any, count: number = 0): void {
if (count > 100) {
return;
}
const clearResource:Function = () =>{
if(this.timer !== undefined){
clearTimeout(this.timer);
this.timer = undefined;
}
}
if (count === 0) {
clearResource();
}
if (this.$refs.appFormDruipart) {
this.formDruipart.next({ action: action, data });
clearResource();
return;
}
this.timer = setTimeout(() => {
count++;
this.partViewEvent(action, data, count);
}, 30);
}
/** /**
* vue 生命周期 * vue 生命周期
* *
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册