Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
杨明
/
scrm-micro-config
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 0469d166
authored
Nov 25, 2021
by
李长胜
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
树特殊数据横向显示修改
1 parent
cb660fa3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
1 deletions
src/views/account/detailAccount.vue
src/views/account/detailAccount.vue
View file @
0469d16
...
@@ -69,7 +69,7 @@
...
@@ -69,7 +69,7 @@
<!-- powerDataArray.length > 0 && powerDataArray[currentIndex].products[subCurrentIndex]. -->
<!-- powerDataArray.length > 0 && powerDataArray[currentIndex].products[subCurrentIndex]. -->
<!-- powerDataArray[currentIndex].products[subCurrentIndex].merchantProTreeResponses这是树的数据 -->
<!-- powerDataArray[currentIndex].products[subCurrentIndex].merchantProTreeResponses这是树的数据 -->
<template
v-if=
"merchantProTreeResponses.length > 0"
>
<template
v-if=
"merchantProTreeResponses.length > 0"
>
<el-tree
default-expand-all
:data=
"merchantProTreeResponses
"
:props=
"defaultProps"
></el-tree>
<el-tree
:render-content=
"renderContent"
default-expand-all
:data=
"merchantProTreeResponsesArray
"
:props=
"defaultProps"
></el-tree>
</
template
>
</
template
>
<div
v-else
class=
"noDataContent"
>
<div
v-else
class=
"noDataContent"
>
<img
src=
"../../assets/img/empty.png"
alt=
""
/>
<img
src=
"../../assets/img/empty.png"
alt=
""
/>
...
@@ -229,6 +229,7 @@ export default {
...
@@ -229,6 +229,7 @@ export default {
firstPageObj
:
{},
firstPageObj
:
{},
powerDataArray
:
[],
powerDataArray
:
[],
merchantProTreeResponsesArray
:[],
defaultProps
:
{
defaultProps
:
{
children
:
'children'
,
children
:
'children'
,
label
:
'label'
label
:
'label'
...
@@ -322,6 +323,8 @@ export default {
...
@@ -322,6 +323,8 @@ export default {
}
else
if
(
this
.
powerDataArray
.
length
>
0
&&
this
.
powerDataArray
[
this
.
currentIndex
].
products
.
length
==
0
)
{
}
else
if
(
this
.
powerDataArray
.
length
>
0
&&
this
.
powerDataArray
[
this
.
currentIndex
].
products
.
length
==
0
)
{
return
[]
return
[]
}
}
// let newTreeList=this.powerDataArray[this.currentIndex].products[this.subCurrentIndex].merchantProTreeResponses
return
this
.
powerDataArray
[
this
.
currentIndex
].
products
[
this
.
subCurrentIndex
].
merchantProTreeResponses
return
this
.
powerDataArray
[
this
.
currentIndex
].
products
[
this
.
subCurrentIndex
].
merchantProTreeResponses
}
}
...
@@ -333,6 +336,14 @@ export default {
...
@@ -333,6 +336,14 @@ export default {
// },
// },
methods
:
{
methods
:
{
// 处理树横向
renderContent
(
h
,
{
node
,
data
})
{
let
className
=
''
if
(
data
.
perms
&&
data
.
count
>
this
.
maxval
)
{
className
=
'especially'
}
return
<
div
class
=
{
className
}
>
{
data
.
label
}
<
/div
>
},
//将后台返回数据中数值为空的字段全部替换为“-”
//将后台返回数据中数值为空的字段全部替换为“-”
formateNullFieldData
(
initialData
)
{
formateNullFieldData
(
initialData
)
{
const
isEmpty
=
function
(
val
)
{
const
isEmpty
=
function
(
val
)
{
...
@@ -393,9 +404,74 @@ export default {
...
@@ -393,9 +404,74 @@ export default {
if
(
res
)
{
if
(
res
)
{
console
.
log
(
res
,
'功能树的信息'
)
console
.
log
(
res
,
'功能树的信息'
)
this
.
powerDataArray
=
res
this
.
powerDataArray
=
res
this
.
handlerTreeDom
()
}
})
},
// 递归:处理某个值
traverse
(
arr
=
[],
count
=
0
)
{
count
++
arr
.
map
(
item
=>
{
if
(
item
.
children
&&
item
.
children
instanceof
Array
)
{
item
.
perms
=
false
this
.
traverse
(
item
.
children
,
count
)
}
else
if
(
!
item
.
children
&&
count
>
2
)
{
item
.
perms
=
true
}
item
.
count
=
count
return
item
})
return
arr
},
// 继续处理已经处理完的树
toContiuneTree
(
arr
=
[],
count
=
0
,
maxLevel
=
0
)
{
count
++
arr
.
map
(
item
=>
{
if
(
item
.
children
&&
item
.
children
instanceof
Array
)
{
item
.
perms
=
false
this
.
toContiuneTree
(
item
.
children
,
count
,
maxLevel
)
}
else
if
(
!
item
.
children
&&
count
>
maxLevel
-
1
)
{
item
.
perms
=
true
}
}
item
.
count
=
count
return
item
})
})
return
arr
},
},
// 调用此方法去重构树节点
handlerTreeDom
()
{
this
.
merchantProTreeResponsesArray
=
this
.
traverse
(
this
.
merchantProTreeResponses
)
let
temp
=
this
.
flattenDeep
(
this
.
merchantProTreeResponsesArray
)
let
maxval
=
Math
.
max
.
apply
(
Math
,
temp
.
map
(
item
=>
{
return
item
.
count
})
)
this
.
merchantProTreeResponsesArray
=
this
.
toContiuneTree
(
this
.
merchantProTreeResponsesArray
,
0
,
maxval
)
console
.
log
(
this
.
merchantProTreeResponsesArray
);
this
.
maxval
=
maxval
-
1
this
.
$nextTick
(()
=>
{
this
.
changeTreeClass
(
maxval
)
})
},
// 改变tree节点样式
changeTreeClass
(
maxval
)
{
let
piefix
=
(
maxval
-
1
)
*
20
var
classDomList
=
document
.
getElementsByClassName
(
'especially'
)
for
(
var
i
=
0
;
i
<
classDomList
.
length
;
i
++
)
{
classDomList
[
i
].
parentNode
.
style
.
cssText
=
'float:left'
// classDomList[i].parentNode.className = 'el-tree-node__content option-wrapper'
classDomList
[
i
].
parentNode
.
parentNode
.
parentNode
.
style
.
marginLeft
=
`
${
piefix
}
px`
}
},
flattenDeep
(
arr
=
[],
childs
=
'children'
,
pid
=
0
)
{
return
arr
.
reduce
((
flat
,
item
)
=>
{
item
.
pid
=
pid
return
flat
.
concat
(
item
,
item
[
childs
]
?
this
.
flattenDeep
(
item
[
childs
],
childs
,
item
.
id
)
:
[])
},
[])
},
getSecondInfo
()
{
getSecondInfo
()
{
this
.
$apis
.
merchant
.
getSecondInfo
({
id
:
this
.
merchantId
}).
then
(
res
=>
{
this
.
$apis
.
merchant
.
getSecondInfo
({
id
:
this
.
merchantId
}).
then
(
res
=>
{
if
(
res
)
{
if
(
res
)
{
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment