Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
ElectricitySheep
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄媛媛
ElectricitySheep
Commits
0045a0b1
Commit
0045a0b1
authored
Aug 04, 2020
by
zhengke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改
parent
242face2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
59 deletions
+45
-59
chooseMenu.vue
src/components/common/chooseMenu.vue
+45
-59
No files found.
src/components/common/chooseMenu.vue
View file @
0045a0b1
...
...
@@ -5,27 +5,20 @@
<div
style=
"height:450px;overflow:scroll"
v-if=
"item.PageTypeId!=6"
>
<template
v-for=
"(subItem,subIndex) in item.SubMenuList"
>
<div
:key=
"subIndex"
style=
"margin-bottom:10px;"
>
<el-checkbox
v-model=
"subItem.IsChecked"
:key=
"subIndex"
@
change=
"checkMenuChange(subItem)"
>
<span
v-if=
"subItem.SelfPageName"
>
{{
subItem
.
SelfPageName
}}
</span>
<span
v-else
>
{{
subItem
.
PageName
}}
</span>
</el-checkbox>
<el-checkbox
v-model=
"subItem.IsChecked"
:key=
"subIndex"
@
change=
"checkMenuChange(subItem)"
>
<span
v-if=
"subItem.SelfPageName"
>
{{
subItem
.
SelfPageName
}}
</span>
<span
v-else
>
{{
subItem
.
PageName
}}
</span>
</el-checkbox>
</div>
</
template
>
</div>
<div
style=
"height:450px;overflow:scroll"
v-else
>
<el-input
placeholder=
"输入关键字进行过滤"
v-model=
"filterText"
>
</el-input>
<el-tree
:data=
"treeData"
node-key=
"PageId"
ref=
"tree"
:props=
"defaultProps"
filter
:filter-node-method=
"filterNode"
show-checkbox
>
</el-tree>
<el-input
placeholder=
"输入关键字进行过滤"
v-model=
"filterText"
>
</el-input>
<el-tree
:data=
"item.SubMenuList"
node-key=
"PageId"
ref=
"tree"
:props=
"defaultProps"
filter
:filter-node-method=
"filterNode"
@
check=
"handleCheck"
:check-strictly=
"true"
show-checkbox
>
</el-tree>
</div>
</el-tab-pane>
</el-tabs>
...
...
@@ -37,18 +30,18 @@
return
{
dataList
:
[],
activeName
:
"1"
,
treeData
:
[],
filterText
:
''
,
filterText
:
''
,
defaultProps
:
{
children
:
'children'
,
label
:
'label'
}
children
:
'SubMenuList'
,
label
:
'PageName'
},
checkedObj
:{}
};
},
created
()
{},
watch
:
{
filterText
(
val
)
{
this
.
$refs
.
tree
.
filter
(
val
.
trim
());
this
.
$refs
.
tree
[
0
]
.
filter
(
val
.
trim
());
}
},
methods
:
{
...
...
@@ -73,19 +66,26 @@
ParameterValue
:
""
,
PageName
:
""
};
if
(
this
.
dataList
&&
this
.
dataList
.
length
>
0
)
{
this
.
dataList
.
forEach
(
item
=>
{
if
(
item
.
SubMenuList
&&
item
.
SubMenuList
.
length
>
0
)
{
item
.
SubMenuList
.
forEach
(
subItem
=>
{
if
(
subItem
.
IsChecked
)
{
obj
.
PageUrl
=
subItem
.
PageUrl
;
obj
.
IsParameter
=
subItem
.
IsParameter
;
obj
.
ParameterValue
=
subItem
.
ParameterValue
;
obj
.
PageName
=
subItem
.
PageName
;
}
})
}
});
if
(
this
.
activeName
!=
6
){
if
(
this
.
dataList
&&
this
.
dataList
.
length
>
0
)
{
this
.
dataList
.
forEach
(
item
=>
{
if
(
item
.
SubMenuList
&&
item
.
SubMenuList
.
length
>
0
)
{
item
.
SubMenuList
.
forEach
(
subItem
=>
{
if
(
subItem
.
IsChecked
)
{
obj
.
PageUrl
=
subItem
.
PageUrl
;
obj
.
IsParameter
=
subItem
.
IsParameter
;
obj
.
ParameterValue
=
subItem
.
ParameterValue
;
obj
.
PageName
=
subItem
.
PageName
;
}
})
}
});
}
}
else
{
obj
.
PageUrl
=
this
.
checkedObj
.
PageUrl
obj
.
IsParameter
=
this
.
checkedObj
.
IsParameter
obj
.
ParameterValue
=
this
.
checkedObj
.
ParameterValue
obj
.
PageName
=
this
.
checkedObj
.
PageName
;
}
return
obj
;
},
...
...
@@ -102,40 +102,26 @@
subItem
.
IsChecked
=
false
;
})
}
if
(
item
.
PageTypeId
==
6
)
{
this
.
treeData
=
this
.
getTree
(
item
.
SubMenuList
);
}
});
}
this
.
dataList
=
dataArray
;
console
.
log
(
this
.
dataList
,
'datalist'
);
console
.
log
(
this
.
treeData
,
'treeData'
);
}
else
{
this
.
Info
(
res
.
data
.
message
);
}
})
},
//递归改变label children
getTree
(
data
)
{
if
(
data
)
{
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
data
[
i
].
label
=
data
[
i
].
PageName
;
if
(
data
[
i
].
SubMenuList
&&
data
[
i
].
SubMenuList
.
length
>
0
)
{
data
[
i
].
children
=
data
[
i
].
SubMenuList
;
}
data
[
i
].
IsChecked
=
false
;
this
.
getTree
(
data
[
i
].
SubMenuList
)
}
}
return
data
;
},
filterNode
(
value
,
data
)
{
console
.
log
(
value
,
'value'
);
console
.
log
(
data
,
'data'
);
if
(
!
value
)
return
true
;
return
data
.
label
.
indexOf
(
value
)
!==
-
1
;
}
},
//check单选
handleCheck
(
a
,
b
)
{
//a为传递给 data 属性的数组中该节点所对应的对象;b为树目前的选中状态对象
if
(
b
.
checkedKeys
.
length
>
0
)
{
this
.
$refs
.
tree
[
0
].
setCheckedKeys
([
a
.
PageId
]);
this
.
checkedObj
=
a
;
}
},
},
mounted
()
{
this
.
getList
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment