Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz-Vue-Mob-R7-Res
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7前端标准模板
iBiz-Vue-Mob-R7-Res
提交
8bea9781
提交
8bea9781
编写于
11月 23, 2020
作者:
KK
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
功能修复--关系界面加载异常
上级
6ed2cf1c
变更
1
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
437 行增加
和
397 行删除
+437
-397
app-form-druipart.vue
src/components/app-form-druipart/app-form-druipart.vue
+437
-397
未找到文件。
src/components/app-form-druipart/app-form-druipart.vue
浏览文件 @
8bea9781
...
...
@@ -24,6 +24,7 @@
<div
v-show=
"!blockUI"
>
<component
class=
"viewcontainer2"
ref=
"appFormDruipart"
:is=
"viewname"
:viewDefaultUsage=
"false"
:formDruipart=
"formDruipart"
...
...
@@ -48,414 +49,453 @@ import "./app-form-druipart.less";
@
Component
({})
export
default
class
AppFormDRUIPart
extends
Vue
{
/**
* 表单数据
*
* @type {string}
* @memberof AppFormDRUIPart
*/
@
Prop
()
public
data
!
:
string
;
/**
* 表单名称
*
* @type {string}
* @memberof AppFormDRUIPart
*/
@
Prop
()
public
caption
!
:
string
;
/**
* 关联视图
*
* @type {string}
* @memberof AppFormDRUIPart
*/
@
Prop
()
public
viewname
?:
string
;
/**
* 刷新关系项
*
* @type {string}
* @memberof AppFormDRUIPart
*/
@
Prop
({
default
:
""
})
public
refreshitems
!
:
string
;
/**
* 关系视图类型
*
* @type {string}
* @memberof AppFormDRUIPart
*/
@
Prop
()
public
refviewtype
?:
string
;
/**
* 临时数据模式:从数据模式:"2"、主数据模式:"1"、无临时数据模式:"0"
*
* @type {string}
* @memberof AppFormDRUIPart
*/
@
Prop
({
default
:
"0"
})
public
tempMode
?:
string
;
/**
* 父数据
*
* @type {*}
* @memberof AppFormDRUIPart
*/
@
Prop
()
public
parentdata
!
:
any
;
/**
* 传入参数项名称
*
* @type {string}
* @memberof AppFormDRUIPart
*/
@
Prop
()
public
paramItem
!
:
string
;
/**
* 是否忽略表单项值变化
*
* @type {boolean}
* @memberof AppFormDRUIPart
*/
@
Prop
()
public
ignorefieldvaluechange
!
:
boolean
;
/**
* 表单状态
*
* @type {Subject<any>}
* @memberof AppFormDRUIPart
*/
@
Prop
()
public
formState
!
:
Subject
<
any
>
;
/**
* 视图参数
*
* @type {any[]}
* @memberof AppFormDRUIPart
*/
@
Prop
()
public
parameters
!
:
any
[];
/**
* 视图上下文
*
* @type {*}
* @memberof AppFormDRUIPart
*/
@
Prop
()
public
context
!
:
any
;
/**
* 视图参数
*
* @type {*}
* @memberof AppFormDRUIPart
*/
@
Prop
()
public
viewparams
!
:
any
;
/**
* 应用实体参数名称
*
* @type {string}
* @memberof AppFormDRUIPart
*/
@
Prop
()
public
parameterName
!
:
string
;
/**
* 导航参数
*
* @type {*}
* @memberof AppSelect
*/
@
Prop
({
default
:
{}
})
protected
navigateParam
?:
any
;
/**
* 导航上下文
*
* @type {*}
* @memberof AppSelect
*/
@
Prop
({
default
:
{}
})
protected
navigateContext
?:
any
;
/**
* 关系界面向视图下发指令对象
*
* @private
* @type {Subject<any>}
* @memberof AppFormDRUIPart
*/
private
formDruipart
:
Subject
<
any
>
=
new
Subject
<
any
>
();
/**
* 表单状态事件
*
* @private
* @type {(Unsubscribable | undefined)}
* @memberof AppFormDRUIPart
*/
private
formStateEvent
:
Unsubscribable
|
undefined
;
/**
* 监控值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof AppFormDRUIPart
*/
@
Watch
(
"data"
)
onActivedataChange
(
newVal
:
any
,
oldVal
:
any
)
{
if
(
this
.
ignorefieldvaluechange
)
{
return
;
}
if
(
Object
.
is
(
newVal
,
oldVal
))
{
return
;
}
const
newFormData
:
any
=
JSON
.
parse
(
newVal
);
const
oldDormData
:
any
=
JSON
.
parse
(
oldVal
);
let
refreshRefview
=
false
;
this
.
hookItems
.
some
((
_hookItem
:
any
)
=>
{
if
(
!
Object
.
is
(
newFormData
[
_hookItem
],
oldDormData
[
_hookItem
]))
{
refreshRefview
=
true
;
return
refreshRefview
;
}
return
refreshRefview
;
});
if
(
refreshRefview
)
{
this
.
refreshDRUIPart
();
}
}
/**
* 是否启用遮罩
*
* @type {boolean}
* @memberof AppFormDRUIPart
*/
public
blockUI
:
boolean
=
false
;
/**
* 是否刷新关系数据
*
* @private
* @type {boolean}
* @memberof AppFormDRUIPart
*/
private
isRelationalData
:
boolean
=
true
;
/**
* 刷新节点
*
* @private
* @type {string[]}
* @memberof AppFormDRUIPart
*/
private
hookItems
:
string
[]
=
[];
/**
* 父视图参数
*
* @type {*}
* @memberof AppFormDRUIPart
*/
public
tempViewParams
:
any
=
{};
/**
* 父视图参数
*
* @type {*}
* @memberof AppFormDRUIPart
*/
public
tempContext
:
any
=
{};
/**
* 刷新关系页面
*
* @private
* @returns {void}
* @memberof AppFormDRUIPart
*/
private
refreshDRUIPart
(
data
?:
any
):
void
{
if
(
Object
.
is
(
this
.
parentdata
.
SRFPARENTTYPE
,
"CUSTOM"
))
{
this
.
isRelationalData
=
false
;
/**
* 表单数据
*
* @type {string}
* @memberof AppFormDRUIPart
*/
@
Prop
()
public
data
!
:
string
;
/**
* 表单名称
*
* @type {string}
* @memberof AppFormDRUIPart
*/
@
Prop
()
public
caption
!
:
string
;
/**
* 关联视图
*
* @type {string}
* @memberof AppFormDRUIPart
*/
@
Prop
()
public
viewname
?:
string
;
/**
* 刷新关系项
*
* @type {string}
* @memberof AppFormDRUIPart
*/
@
Prop
({
default
:
""
})
public
refreshitems
!
:
string
;
/**
* 关系视图类型
*
* @type {string}
* @memberof AppFormDRUIPart
*/
@
Prop
()
public
refviewtype
?:
string
;
/**
* 临时数据模式:从数据模式:"2"、主数据模式:"1"、无临时数据模式:"0"
*
* @type {string}
* @memberof AppFormDRUIPart
*/
@
Prop
({
default
:
"0"
})
public
tempMode
?:
string
;
/**
* 父数据
*
* @type {*}
* @memberof AppFormDRUIPart
*/
@
Prop
()
public
parentdata
!
:
any
;
/**
* 传入参数项名称
*
* @type {string}
* @memberof AppFormDRUIPart
*/
@
Prop
()
public
paramItem
!
:
string
;
/**
* 是否忽略表单项值变化
*
* @type {boolean}
* @memberof AppFormDRUIPart
*/
@
Prop
()
public
ignorefieldvaluechange
!
:
boolean
;
/**
* 表单状态
*
* @type {Subject<any>}
* @memberof AppFormDRUIPart
*/
@
Prop
()
public
formState
!
:
Subject
<
any
>
;
/**
* 视图参数
*
* @type {any[]}
* @memberof AppFormDRUIPart
*/
@
Prop
()
public
parameters
!
:
any
[];
/**
* 视图上下文
*
* @type {*}
* @memberof AppFormDRUIPart
*/
@
Prop
()
public
context
!
:
any
;
/**
* 视图参数
*
* @type {*}
* @memberof AppFormDRUIPart
*/
@
Prop
()
public
viewparams
!
:
any
;
/**
* 应用实体参数名称
*
* @type {string}
* @memberof AppFormDRUIPart
*/
@
Prop
()
public
parameterName
!
:
string
;
/**
* 导航参数
*
* @type {*}
* @memberof AppSelect
*/
@
Prop
({
default
:
{}
})
protected
navigateParam
?:
any
;
/**
* 导航上下文
*
* @type {*}
* @memberof AppSelect
*/
@
Prop
({
default
:
{}
})
protected
navigateContext
?:
any
;
/**
* 关系界面向视图下发指令对象
*
* @private
* @type {Subject<any>}
* @memberof AppFormDRUIPart
*/
private
formDruipart
:
Subject
<
any
>
=
new
Subject
<
any
>
();
/**
* 表单状态事件
*
* @private
* @type {(Unsubscribable | undefined)}
* @memberof AppFormDRUIPart
*/
private
formStateEvent
:
Unsubscribable
|
undefined
;
/**
* 监控值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof AppFormDRUIPart
*/
@
Watch
(
"data"
)
onActivedataChange
(
newVal
:
any
,
oldVal
:
any
)
{
if
(
this
.
ignorefieldvaluechange
)
{
return
;
}
if
(
Object
.
is
(
newVal
,
oldVal
))
{
return
;
}
const
newFormData
:
any
=
JSON
.
parse
(
newVal
);
const
oldDormData
:
any
=
JSON
.
parse
(
oldVal
);
let
refreshRefview
=
false
;
this
.
hookItems
.
some
((
_hookItem
:
any
)
=>
{
if
(
!
Object
.
is
(
newFormData
[
_hookItem
],
oldDormData
[
_hookItem
]))
{
refreshRefview
=
true
;
return
refreshRefview
;
}
return
refreshRefview
;
});
if
(
refreshRefview
)
{
this
.
refreshDRUIPart
();
}
}
const
formData
:
any
=
data
?
data
:
JSON
.
parse
(
this
.
data
);
const
_paramitem
=
formData
[
this
.
paramItem
];
let
_context
=
{};
Object
.
assign
(
_context
,
this
.
$viewTool
.
getIndexViewParam
());
const
_parameters
:
any
[]
=
[
...
this
.
$viewTool
.
getIndexParameters
(),
...
this
.
parameters
];
_parameters
.
forEach
((
parameter
:
any
)
=>
{
const
{
pathName
,
parameterName
}:
{
pathName
:
string
;
parameterName
:
string
}
=
parameter
;
if
(
formData
[
parameterName
]
&&
!
Object
.
is
(
formData
[
parameterName
],
""
))
{
Object
.
assign
(
_context
,
{
[
parameterName
]:
formData
[
parameterName
]
});
}
});
Object
.
assign
(
_context
,
{
[
this
.
paramItem
]:
_paramitem
});
//设置顶层视图唯一标识
Object
.
assign
(
_context
,
this
.
context
);
// 导航参数处理
const
{
context
,
param
}
=
this
.
$viewTool
.
formatNavigateParam
(
this
.
navigateContext
,
this
.
navigateParam
,
_context
,
this
.
viewparams
,
JSON
.
parse
(
this
.
data
));
Object
.
assign
(
this
.
tempContext
,
context
);
Object
.
assign
(
this
.
tempViewParams
,
param
);
if
(
this
.
isRelationalData
)
{
if
(
this
.
tempMode
&&
Object
.
is
(
this
.
tempMode
,
"2"
)){
this
.
blockUIStop
();
}
else
{
if
(
!
_paramitem
||
_paramitem
==
null
||
Object
.
is
(
_paramitem
,
''
))
{
this
.
blockUIStart
();
return
;
}
else
{
/**
* 是否启用遮罩
*
* @type {boolean}
* @memberof AppFormDRUIPart
*/
public
blockUI
:
boolean
=
false
;
/**
* 是否刷新关系数据
*
* @private
* @type {boolean}
* @memberof AppFormDRUIPart
*/
private
isRelationalData
:
boolean
=
true
;
/**
* 刷新节点
*
* @private
* @type {string[]}
* @memberof AppFormDRUIPart
*/
private
hookItems
:
string
[]
=
[];
/**
* 父视图参数
*
* @type {*}
* @memberof AppFormDRUIPart
*/
public
tempViewParams
:
any
=
{};
/**
* 父视图参数
*
* @type {*}
* @memberof AppFormDRUIPart
*/
public
tempContext
:
any
=
{};
/**
* 刷新关系页面
*
* @private
* @returns {void}
* @memberof AppFormDRUIPart
*/
private
refreshDRUIPart
(
data
?:
any
):
void
{
if
(
Object
.
is
(
this
.
parentdata
.
SRFPARENTTYPE
,
"CUSTOM"
))
{
this
.
isRelationalData
=
false
;
}
const
formData
:
any
=
data
?
data
:
JSON
.
parse
(
this
.
data
);
const
_paramitem
=
formData
[
this
.
paramItem
];
let
_context
=
{};
Object
.
assign
(
_context
,
this
.
$viewTool
.
getIndexViewParam
());
const
_parameters
:
any
[]
=
[
...
this
.
$viewTool
.
getIndexParameters
(),
...
this
.
parameters
];
_parameters
.
forEach
((
parameter
:
any
)
=>
{
const
{
pathName
,
parameterName
}:
{
pathName
:
string
;
parameterName
:
string
}
=
parameter
;
if
(
formData
[
parameterName
]
&&
!
Object
.
is
(
formData
[
parameterName
],
""
))
{
Object
.
assign
(
_context
,
{
[
parameterName
]:
formData
[
parameterName
]
});
}
});
Object
.
assign
(
_context
,
{
[
this
.
paramItem
]:
_paramitem
});
//设置顶层视图唯一标识
Object
.
assign
(
_context
,
this
.
context
);
// 导航参数处理
const
{
context
,
param
}
=
this
.
$viewTool
.
formatNavigateParam
(
this
.
navigateContext
,
this
.
navigateParam
,
_context
,
this
.
viewparams
,
JSON
.
parse
(
this
.
data
));
Object
.
assign
(
this
.
tempContext
,
context
);
Object
.
assign
(
this
.
tempViewParams
,
param
);
if
(
this
.
isRelationalData
)
{
if
(
this
.
tempMode
&&
Object
.
is
(
this
.
tempMode
,
"2"
))
{
this
.
blockUIStop
();
}
else
{
if
(
!
_paramitem
||
_paramitem
==
null
||
Object
.
is
(
_paramitem
,
''
))
{
this
.
blockUIStart
();
return
;
}
else
{
this
.
blockUIStop
();
}
}
}
this
.
partViewEvent
(
"load"
,
{}
);
}
/**
* vue 生命周期
*
* @memberof AppFormDRUIPart
*/
public
created
():
void
{
this
.
hookItems
=
[...
this
.
refreshitems
.
split
(
";"
)];
if
(
!
this
.
formState
)
{
return
;
}
if
(
!
Object
.
is
(
this
.
paramItem
,
this
.
parameterName
))
{
this
.
hookItems
.
push
(
this
.
paramItem
);
}
this
.
formStateEvent
=
this
.
formState
.
subscribe
((
$event
:
any
)
=>
{
// 表单加载完成
if
(
Object
.
is
(
$event
.
type
,
"load"
))
{
this
.
refreshDRUIPart
(
$event
.
data
);
}
// 表单保存之前
if
(
Object
.
is
(
$event
.
type
,
"beforesave"
))
{
if
(
Object
.
is
(
this
.
refviewtype
,
"DEMOBMEDITVIEW9"
)
||
Object
.
is
(
this
.
refviewtype
,
"DEGRIDVIEW9"
)
)
{
this
.
formDruipart
.
next
({
action
:
"save"
,
data
:
$event
.
data
});
}
else
{
// 不需要保存的界面也要抛出事件,供计数器计算
this
.
$emit
(
"drdatasaved"
,
$event
);
}
}
// 表单保存完成
if
(
Object
.
is
(
$event
.
type
,
"save"
))
{
this
.
refreshDRUIPart
(
$event
.
data
);
}
// 表单项更新
if
(
Object
.
is
(
$event
.
type
,
"updateformitem"
))
{
if
(
!
$event
.
data
)
{
return
;
}
let
refreshRefview
=
false
;
Object
.
keys
(
$event
.
data
).
some
((
name
:
string
)
=>
{
const
index
=
this
.
hookItems
.
findIndex
((
_name
:
string
)
=>
Object
.
is
(
_name
,
name
)
);
refreshRefview
=
index
!==
-
1
?
true
:
false
;
return
refreshRefview
;
});
if
(
refreshRefview
)
{
this
.
refreshDRUIPart
();
}
}
});
}
/**
* 部件销毁
*
* @memberof AppFormDRUIPart
*/
public
destroyed
():
void
{
if
(
this
.
formStateEvent
)
{
this
.
formStateEvent
.
unsubscribe
();
}
}
setTimeout
(()
=>
{
this
.
formDruipart
.
next
({
action
:
"load"
,
data
:
{}})},
500
)
}
/**
* vue 生命周期
*
* @memberof AppFormDRUIPart
*/
public
created
():
void
{
this
.
hookItems
=
[...
this
.
refreshitems
.
split
(
";"
)];
if
(
!
this
.
formState
)
{
return
;
/**
* 开启遮罩
*
* @private
* @memberof AppFormDRUIPart
*/
private
blockUIStart
():
void
{
this
.
blockUI
=
true
;
}
/**
* 关闭遮罩
*
* @private
* @memberof AppFormDRUIPart
*/
private
blockUIStop
():
void
{
this
.
blockUI
=
false
;
}
/**
* 多数据视图加载完成
*
* @public
* @memberof AppFormDRUIPart
*/
public
mditemsload
()
{
console
.
log
(
"多数据视图加载完成,触发后续表单项更新"
);
}
if
(
!
Object
.
is
(
this
.
paramItem
,
this
.
parameterName
))
{
this
.
hookItems
.
push
(
this
.
paramItem
);
/**
* DEMEDITVIEW9 关系数据保存完成
*
* @public
* @memberof AppFormDRUIPart
*/
public
drdatasaved
(
$event
:
any
)
{
this
.
$emit
(
"drdatasaved"
,
$event
);
console
.
log
(
this
.
viewname
+
"关系数据保存完成"
);
}
this
.
formStateEvent
=
this
.
formState
.
subscribe
((
$event
:
any
)
=>
{
// 表单加载完成
if
(
Object
.
is
(
$event
.
type
,
"load"
))
{
this
.
refreshDRUIPart
(
$event
.
data
);
}
// 表单保存之前
if
(
Object
.
is
(
$event
.
type
,
"beforesave"
))
{
if
(
Object
.
is
(
this
.
refviewtype
,
"DEMOBMEDITVIEW9"
)
||
Object
.
is
(
this
.
refviewtype
,
"DEGRIDVIEW9"
)
)
{
this
.
formDruipart
.
next
({
action
:
"save"
,
data
:
$event
.
data
});
}
else
{
// 不需要保存的界面也要抛出事件,供计数器计算
this
.
$emit
(
"drdatasaved"
,
$event
);
/**
* DEMEDITVIEW9 关系数据值变化
*
* @public
* @memberof AppFormDRUIPart
*/
public
drdatachange
()
{
console
.
log
(
"DEMEDITVIEW9 关系数据值变化"
);
}
/**
* 视图数据变化
*
* @public
* @memberof AppFormDRUIPart
*/
public
viewdataschange
()
{
console
.
log
(
"视图数据变化"
);
}
/**
* 视图加载完成
*
* @public
* @memberof AppFormDRUIPart
*/
public
viewload
()
{
console
.
log
(
"视图加载完成"
);
}
/**
* 定时器实例
*
* @type {[any]}
* @memberof AppFormDRUIPart
*/
protected
timer
?:
any
;
/**
* 向关系视图发送事件,采用轮询模式。避免异步视图出现加载慢情况
*
* @param {*} action 触发行为
* @param {*} data 数据
* @param {*} count 轮询计数
* @memberof AppFormDRUIPart
*/
protected
partViewEvent
(
action
:
string
,
data
:
any
,
count
:
number
=
0
):
void
{
if
(
count
>
100
)
{
return
;
}
}
// 表单保存完成
if
(
Object
.
is
(
$event
.
type
,
"save"
))
{
this
.
refreshDRUIPart
(
$event
.
data
);
}
// 表单项更新
if
(
Object
.
is
(
$event
.
type
,
"updateformitem"
))
{
if
(
!
$event
.
data
)
{
return
;
const
clearResource
:
Function
=
()
=>
{
if
(
this
.
timer
!==
undefined
)
{
clearTimeout
(
this
.
timer
);
this
.
timer
=
undefined
;
}
}
let
refreshRefview
=
false
;
Object
.
keys
(
$event
.
data
).
some
((
name
:
string
)
=>
{
const
index
=
this
.
hookItems
.
findIndex
((
_name
:
string
)
=>
Object
.
is
(
_name
,
name
)
);
refreshRefview
=
index
!==
-
1
?
true
:
false
;
return
refreshRefview
;
});
if
(
refreshRefview
)
{
this
.
refreshDRUIPart
();
if
(
count
===
0
)
{
clearResource
();
}
if
(
this
.
$refs
.
appFormDruipart
)
{
this
.
formDruipart
.
next
({
action
:
action
,
data
});
clearResource
();
return
;
}
}
});
this
.
refreshDRUIPart
();
}
/**
* 部件销毁
*
* @memberof AppFormDRUIPart
*/
public
destroyed
():
void
{
if
(
this
.
formStateEvent
)
{
this
.
formStateEvent
.
unsubscribe
();
this
.
timer
=
setTimeout
(()
=>
{
count
++
;
this
.
partViewEvent
(
action
,
data
,
count
);
},
30
);
}
}
/**
* 开启遮罩
*
* @private
* @memberof AppFormDRUIPart
*/
private
blockUIStart
():
void
{
this
.
blockUI
=
true
;
}
/**
* 关闭遮罩
*
* @private
* @memberof AppFormDRUIPart
*/
private
blockUIStop
():
void
{
this
.
blockUI
=
false
;
}
/**
* 多数据视图加载完成
*
* @public
* @memberof AppFormDRUIPart
*/
public
mditemsload
()
{
console
.
log
(
"多数据视图加载完成,触发后续表单项更新"
);
}
/**
* DEMEDITVIEW9 关系数据保存完成
*
* @public
* @memberof AppFormDRUIPart
*/
public
drdatasaved
(
$event
:
any
)
{
this
.
$emit
(
"drdatasaved"
,
$event
);
console
.
log
(
this
.
viewname
+
"关系数据保存完成"
);
}
/**
* DEMEDITVIEW9 关系数据值变化
*
* @public
* @memberof AppFormDRUIPart
*/
public
drdatachange
()
{
console
.
log
(
"DEMEDITVIEW9 关系数据值变化"
);
}
/**
* 视图数据变化
*
* @public
* @memberof AppFormDRUIPart
*/
public
viewdataschange
()
{
console
.
log
(
"视图数据变化"
);
}
/**
* 视图加载完成
*
* @public
* @memberof AppFormDRUIPart
*/
public
viewload
()
{
console
.
log
(
"视图加载完成"
);
}
}
</
script
>
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录