Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataease
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
zhu
dataease
Commits
638ecb9b
提交
638ecb9b
authored
2月 23, 2021
作者:
fit2cloud-chenyw
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 解决组织机构树懒加载回显问题
上级
6d8158ff
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
67 行增加
和
7 行删除
+67
-7
dept.vue
frontend/src/business/components/settings/sys/dept.vue
+67
-7
没有找到文件。
frontend/src/business/components/settings/sys/dept.vue
浏览文件 @
638ecb9b
...
...
@@ -87,7 +87,7 @@
:load-options=
"loadDepts"
:options=
"depts"
style=
"width: 370px;"
placeholder=
"选择上级类目"
placeholder=
"选择上级类目"
/>
</el-form-item>
</el-form>
...
...
@@ -139,9 +139,8 @@ export default {
data
()
{
return
{
rootNodeLoaded
:
false
,
depts
:
null
,
formType
:
"add"
,
depts
:
null
,
formType
:
"add"
,
queryPath
:
'/api/dept/childNodes'
,
deletePath
:
'/api/dept/delete'
,
createPath
:
'/api/dept/create'
,
...
...
@@ -184,17 +183,51 @@ export default {
this
.
formType
=
"modify"
;
this
.
oldPid
=
row
.
pid
;
this
.
form
=
Object
.
assign
({},
row
);
//
this.treeByRow(row);
this
.
treeByRow
(
row
);
listenGoBack
(
this
.
closeFunc
);
},
treeByRow
(
row
){
!
this
.
depts
&&
(
this
.
depts
=
[])
if
(
!
this
.
depts
.
some
(
node
=>
node
.
id
==
row
.
deptId
))
{
this
.
depts
.
push
(
this
.
normalizer
(
row
));
if
(
!
this
.
depts
.
some
(
node
=>
node
.
id
==
row
.
pid
)
&&
row
.
pid
!=
0
)
{
const
arr
=
this
.
mapToArray
();
const
ids
=
arr
.
map
(
item
=>
item
.
id
);
const
tempTreeNodes
=
this
.
treeByArr
(
arr
);
const
pnodes
=
this
.
tableData
.
filter
(
node
=>
(
node
.
pid
==
0
)
&&
(
ids
.
indexOf
(
node
.
deptId
)
==-
1
)).
map
(
node
=>
this
.
normalizer
(
node
))
const
showNodes
=
tempTreeNodes
.
concat
(
pnodes
)
this
.
depts
=
this
.
depts
.
concat
(
showNodes
);
}
},
mapToArray
()
{
const
result
=
new
Array
();
this
.
maps
.
forEach
((
value
,
key
)
=>
{
if
(
value
.
hasOwnProperty
(
'row'
)){
result
.
push
(
this
.
editNormalizer
(
value
.
row
))
}
})
return
result
;
},
treeByArr
(
arr
){
if
(
!
Array
.
isArray
(
arr
)
||
!
arr
.
length
)
return
;
let
map
=
{};
arr
.
forEach
(
item
=>
map
[
item
.
id
]
=
item
);
let
roots
=
[];
arr
.
forEach
(
item
=>
{
const
parent
=
map
[
item
.
pid
];
if
(
parent
){
(
parent
.
children
||
(
parent
.
children
=
[])).
push
(
item
);
}
else
{
roots
.
push
(
item
);
}
})
return
roots
;
},
initTableData
(
row
,
treeNode
,
resolve
)
{
let
_self
=
this
;
...
...
@@ -222,6 +255,7 @@ export default {
this
.
initTableData
();
this
.
form
=
{};
this
.
oldPid
=
null
;
this
.
depts
=
null
;
removeGoBackListener
(
this
.
closeFunc
);
this
.
dialogOrgAddVisible
=
false
;
...
...
@@ -258,6 +292,14 @@ export default {
children
:
node
.
children
}
},
editNormalizer
(
node
)
{
return
{
id
:
node
.
deptId
,
pid
:
node
.
pid
,
label
:
node
.
name
,
children
:
node
.
children
}
},
// 改变状态
changeEnabled
(
data
,
val
)
{
this
.
$confirm
(
'此操作将 "停用" '
+
data
.
name
+
'部门, 是否继续?'
,
'提示'
,
{
...
...
@@ -324,7 +366,25 @@ export default {
this
.
$set
(
this
.
$refs
.
table
.
store
.
states
.
lazyTreeNodeMap
,
pid
,
[]);
this
.
initTableData
(
row
,
treeNode
,
resolve
);
}
},
array2Tree
(
arr
){
if
(
!
Array
.
isArray
(
arr
)
||
!
arr
.
length
)
return
;
let
map
=
{};
arr
.
forEach
(
item
=>
map
[
item
.
id
]
=
item
);
let
roots
=
[];
arr
.
forEach
(
item
=>
{
const
parent
=
map
[
item
.
pid
];
if
(
parent
){
(
parent
.
children
||
(
parent
.
children
=
[])).
push
(
item
);
}
else
{
roots
.
push
(
item
);
}
})
return
roots
;
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论