Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibizlab-generator
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibizlab-generator
提交
47f388ff
提交
47f388ff
编写于
3月 02, 2022
作者:
Mosher
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update:新增树节点上下文菜单权限计算逻辑
上级
a278cdd1
变更
2
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
97 行增加
和
20 行删除
+97
-20
tree-control.ts
...s}}/src/core/modules/widgets/tree-control/tree-control.ts
+94
-18
{{ctrls@TREEVIEW}}-tree.vue.hbs
...}/{{ctrls@TREEVIEW}}-tree/{{ctrls@TREEVIEW}}-tree.vue.hbs
+3
-2
未找到文件。
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/core/modules/widgets/tree-control/tree-control.ts
浏览文件 @
47f388ff
import
{
deepCopy
,
deepObjectMerge
,
IActionParam
,
IParam
,
isEmpty
,
MDContro
l
}
from
"@core"
;
import
{
deepCopy
,
deepObjectMerge
,
IActionParam
,
IParam
,
isEmpty
,
isExistAndNotEmpty
,
MDControl
,
UIUti
l
}
from
"@core"
;
import
{
TreeControlProps
}
from
"./tree-control-prop"
;
import
{
TreeControlState
}
from
"./tree-control-state"
;
...
...
@@ -88,7 +88,7 @@ export class TreeControl extends MDControl {
public
useLoad
()
{
const
{
viewSubject
,
controlName
}
=
this
.
state
;
const
load
=
async
(
node
?:
any
,
isFirst
:
boolean
=
false
):
Promise
<
any
>
=>
{
if
(
node
?.
dataRef
?.
children
)
{
if
(
node
?.
children
&&
node
.
children
.
length
)
{
return
null
;
}
const
{
...
...
@@ -98,22 +98,22 @@ export class TreeControl extends MDControl {
let
curNode
:
any
=
{};
curNode
=
deepObjectMerge
(
curNode
,
node
);
const
params
:
any
=
{
srfnodeid
:
node
?.
dataRef
&&
node
.
dataRef
.
id
?
node
.
dataRef
.
id
:
'#'
,
srfnodeid
:
node
&&
node
.
id
?
node
.
id
:
'#'
,
srfnodefilter
:
srfnodefilter
,
parentData
:
curNode
.
dataRef
?.
curData
parentData
:
curNode
?.
curData
}
let
tempContext
:
any
=
this
.
computecurNodeContext
(
curNode
);
if
(
curNode
.
dataRef
&&
curNode
.
dataRef
.
sefparentdename
)
{
Object
.
assign
(
tempContext
,
{
srfparentdename
:
curNode
.
dataRef
.
srfparentdename
});
Object
.
assign
(
tempViewParams
,
{
srfparentdename
:
curNode
.
dataRef
.
srfparentdename
});
if
(
curNode
&&
curNode
.
sefparentdename
)
{
Object
.
assign
(
tempContext
,
{
srfparentdename
:
curNode
.
srfparentdename
});
Object
.
assign
(
tempViewParams
,
{
srfparentdename
:
curNode
.
srfparentdename
});
}
if
(
curNode
.
dataRef
&&
curNode
.
dataRef
.
srfparentdemapname
)
{
Object
.
assign
(
tempContext
,
{
srfparentdemapname
:
curNode
.
dataRef
.
srfparentdemapname
});
Object
.
assign
(
tempViewParams
,
{
srfparentdemapname
:
curNode
.
dataRef
.
srfparentdemapname
});
if
(
curNode
&&
curNode
.
srfparentdemapname
)
{
Object
.
assign
(
tempContext
,
{
srfparentdemapname
:
curNode
.
srfparentdemapname
});
Object
.
assign
(
tempViewParams
,
{
srfparentdemapname
:
curNode
.
srfparentdemapname
});
}
if
(
curNode
.
dataRef
&&
curNode
.
dataRef
.
srfparentkey
)
{
Object
.
assign
(
tempContext
,
{
srfparentkey
:
curNode
.
dataRef
.
srfparentkey
});
Object
.
assign
(
tempViewParams
,
{
srfparentkey
:
curNode
.
dataRef
.
srfparentkey
});
if
(
curNode
&&
curNode
.
srfparentkey
)
{
Object
.
assign
(
tempContext
,
{
srfparentkey
:
curNode
.
srfparentkey
});
Object
.
assign
(
tempViewParams
,
{
srfparentkey
:
curNode
.
srfparentkey
});
}
Object
.
assign
(
params
,
{
viewParams
:
tempViewParams
});
try
{
...
...
@@ -132,7 +132,13 @@ export class TreeControl extends MDControl {
items
.
value
.
push
(
item
);
});
}
else
{
node
.
dataRef
.
children
=
data
;
const
nodeData
=
this
.
getTreeNodeById
(
node
.
id
);
data
.
forEach
((
item
:
any
)
=>
{
item
.
parentNodeId
=
node
.
id
;
});
if
(
nodeData
)
{
nodeData
.
children
=
data
;
}
}
const
isSelectedAll
=
node
?.
checked
;
this
.
setDefaultSelection
(
data
,
isRoot
,
isSelectedAll
);
...
...
@@ -205,12 +211,19 @@ export class TreeControl extends MDControl {
protected
refreshParent
()
{
const
{
currentSelectedNode
}
=
this
.
state
;
console
.
log
(
1111
,
"刷新父"
,
currentSelectedNode
);
if
(
currentSelectedNode
&&
currentSelectedNode
.
parentNodeId
)
{
// 父节点
const
parentNode
=
this
.
getTreeNodeById
(
currentSelectedNode
.
parentNodeId
);
if
(
parentNode
)
{
delete
parentNode
.
children
;
// this.load(parentNode);
}
}
}
protected
refreshAll
()
{
const
{
currentSelectedNode
}
=
this
.
state
;
console
.
log
(
1111
,
"刷新全部"
,
currentSelectedNod
e
);
// this.load({}, tru
e);
}
/**
...
...
@@ -222,7 +235,7 @@ export class TreeControl extends MDControl {
protected
formatExpanded
(
items
:
IParam
[])
{
const
{
expandedKeys
}
=
this
.
state
;
items
.
forEach
((
item
:
any
)
=>
{
if
(
item
.
expanded
)
{
if
(
item
.
expanded
&&
expandedKeys
.
findIndex
((
key
:
string
)
=>
key
===
item
.
id
)
===
-
1
)
{
expandedKeys
.
push
(
item
.
id
);
}
})
...
...
@@ -381,6 +394,7 @@ export class TreeControl extends MDControl {
protected
onContextMenuClick
(
node
:
any
,
{
key
,
domEvent
:
event
}:
any
)
{
const
{
context
,
viewParams
,
contextMenus
}
=
this
.
state
;
const
action
=
contextMenus
[
node
.
nodeType
]?.
find
((
item
:
IParam
)
=>
item
.
name
===
key
);
this
.
state
.
currentSelectedNode
=
node
;
if
(
!
action
)
{
console
.
warn
(
"上下文菜单执行参数不足"
);
return
;
...
...
@@ -395,6 +409,68 @@ export class TreeControl extends MDControl {
App
.
getAppActionService
().
execute
(
action
,
inputParam
);
}
/**
* @description 树节点右键点击
* @protected
* @param {*} { event, node }
* @memberof TreeControl
*/
protected
onRightClick
({
event
,
node
}:
any
)
{
// 计算节点上下文菜单权限
this
.
computeNodeContextMenuState
(
node
,
event
);
}
/**
* @description 计算节点上下文菜单权限
* @private
* @param {*} node
* @param {MouseEvent} event
* @memberof TreeControl
*/
private
computeNodeContextMenuState
(
node
:
any
,
event
:
MouseEvent
)
{
const
{
contextMenus
,
UIService
}
=
this
.
state
;
if
(
contextMenus
&&
contextMenus
[
node
.
nodeType
])
{
UIUtil
.
calcActionItemAuthState
(
node
,
contextMenus
[
node
.
nodeType
],
UIService
);
}
}
/**
* @description 根据节点标识获取父节点
* @private
* @param {string} id 节点标识
* @return {*}
* @memberof TreeControl
*/
private
getTreeNodeById
(
id
:
string
):
any
{
const
{
items
}
=
toRefs
(
this
.
state
);
if
(
!
isExistAndNotEmpty
(
id
)
||
(
!
items
.
value
||
items
.
value
.
length
===
0
))
{
return
null
;
}
let
node
:
any
=
null
;
const
getNode
=
(
item
:
any
):
boolean
=>
{
let
flag
:
boolean
=
false
;
if
(
item
.
id
===
id
)
{
node
=
item
;
flag
=
true
;
}
if
(
item
.
children
&&
item
.
children
.
length
>
0
)
{
for
(
const
child
of
item
.
children
)
{
if
(
getNode
(
child
))
{
flag
=
true
;
break
;
}
}
}
return
flag
;
}
for
(
const
item
of
items
.
value
)
{
if
(
getNode
(
item
))
{
break
;
}
}
return
node
;
}
/**
* @description 安装部件所有功能模块的方法
* @return {*}
...
...
@@ -406,7 +482,7 @@ export class TreeControl extends MDControl {
...
superParams
,
onTreeNodeSelect
:
this
.
onTreeNodeSelect
.
bind
(
this
),
onContextMenuClick
:
this
.
onContextMenuClick
.
bind
(
this
),
load
:
this
.
useLoad
(),
onRightClick
:
this
.
onRightClick
.
bind
(
this
)
};
}
}
\ No newline at end of file
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/widgets/{{appEntities}}/{{ctrls@TREEVIEW}}-tree/{{ctrls@TREEVIEW}}-tree.vue.hbs
浏览文件 @
47f388ff
...
...
@@ -47,7 +47,7 @@ const getCustomText = (scriptCode: any) => {
}
// 安装功能模块,提供状态和能力方法
const
{
name
,
state
,
load
,
onTreeNodeSelect
,
onContextMenuClick
}
=
new
TreeControl
(
ctrlState
,
props
,
emit
).
moduleInstall
();
const
{
name
,
state
,
load
,
onTreeNodeSelect
,
onContextMenuClick
,
onRightClick
}
=
new
TreeControl
(
ctrlState
,
props
,
emit
).
moduleInstall
();
{{#
and
ctrl
.
psAppCounterRef
ctrl
.
psAppCounterRef
.
psAppCounter
}}
// 获取计数器数据
...
...
@@ -75,7 +75,8 @@ defineExpose({ name, state });
show-icon
v-model:expandedKeys=
"state.expandedKeys"
v-model:selectedKeys=
"state.selectedKeys"
@
select=
"onTreeNodeSelect"
>
@
select=
"onTreeNodeSelect"
@
rightClick=
"onRightClick"
>
<template
#
icon=
"node"
>
<span
class=
"app-tree-node__icon"
>
<template
v-if=
"node.iconCustomCode && node.iconScriptCode"
>
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录