Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qr-consistency-vue3
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
刘怀志
qr-consistency-vue3
Commits
18dbcd05
Commit
18dbcd05
authored
Apr 27, 2025
by
yanzhengyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
选择用户公共组件修改BUG
parent
846b2a34
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
index.vue
src/components/SelectRole/index.vue
+8
-8
No files found.
src/components/SelectRole/index.vue
View file @
18dbcd05
...
...
@@ -12,8 +12,8 @@
</el-form>
<div
class=
"demo-collapse"
>
<el-collapse
v-model=
"activeNames"
>
<el-collapse-item
:title=
"item[deptKey]"
:name=
"item.
i
d"
v-for=
"(item, index) in filteredDeptList"
:key=
"index"
style=
"margin-left: 20px"
>
<div
v-for=
"
it in (Array.isArray(item[nameKey]) ? item[nameKey] : [item[nameKey]])"
:key=
"it[nameKey]
"
>
<el-collapse-item
:title=
"item[deptKey]"
:name=
"item.
deptI
d"
v-for=
"(item, index) in filteredDeptList"
:key=
"index"
style=
"margin-left: 20px"
>
<div
v-for=
"
(it,idx) in (Array.isArray(item[nameKey]) ? item[nameKey] : [item[nameKey]])"
:key=
"idx
"
>
<el-checkbox
v-model=
"checked1"
:label=
"it[nameKey]"
...
...
@@ -32,7 +32,7 @@
</div>
<div
class=
"box-right-content"
>
<div
class=
"content-item"
v-for=
"(item, index) in selectedItems"
:key=
"index"
>
<span
style=
"font-size: 14px;font-weight: 400"
>
{{
item
}}
</span>
<span
style=
"
width: 100px;
font-size: 14px;font-weight: 400"
>
{{
item
}}
</span>
<el-button
icon=
"Delete"
@
click=
"removeItem(index)"
type=
"primary"
circle
></el-button>
</div>
</div>
...
...
@@ -83,16 +83,16 @@ const allRole = ref('');
const
checked1
=
ref
([]);
const
selectedItems
=
ref
([]);
const
filteredDeptList
=
ref
(
props
.
deptList
);
const
activeNames
=
ref
([
props
.
deptList
[
0
].
i
d
]);
// 新增展开项绑定
const
activeNames
=
ref
([
props
.
deptList
[
0
].
deptI
d
]);
// 新增展开项绑定
// 计算左侧总项数:遍历deptList并计算所有成员数量
const
totalItems
=
computed
(()
=>
{
return
props
.
deptList
.
reduce
((
total
,
dept
)
=>
total
+
dept
.
name
.
length
,
0
);
return
props
.
deptList
.
reduce
((
total
,
dept
)
=>
total
+
dept
[
props
.
nameKey
]
.
length
,
0
);
});
// 搜索功能:根据输入内容过滤部门列表
const
selectSearch
=
()
=>
{
if
(
!
allRole
.
value
)
{
filteredDeptList
.
value
=
props
.
deptList
;
// 如果搜索框为空,恢复所有项
activeNames
.
value
=
[
props
.
deptList
[
0
].
i
d
];
activeNames
.
value
=
[
props
.
deptList
[
0
].
deptI
d
];
checked1
.
value
=
[];
// 清空展开项
}
else
{
const
searchTerm
=
allRole
.
value
.
toLowerCase
();
...
...
@@ -111,7 +111,7 @@ const selectSearch = () => {
// 自动添加匹配的成员到选中列表(去重)
checked1
.
value
=
[...
new
Set
([...
checked1
.
value
,
...
matchedNames
])];
activeNames
.
value
=
filteredDeptList
.
value
.
map
(
item
=>
item
.
i
d
);
activeNames
.
value
=
filteredDeptList
.
value
.
map
(
item
=>
item
.
deptI
d
);
}
};
...
...
@@ -146,7 +146,7 @@ const closeDialog = () => {
clearAllSelected
();
// 清空已选项
allRole
.
value
=
''
;
// 清空搜索框
filteredDeptList
.
value
=
props
.
deptList
;
activeNames
.
value
=
[
props
.
deptList
[
0
].
i
d
]
// 重置展开项绑定
activeNames
.
value
=
[
props
.
deptList
[
0
].
deptI
d
]
// 重置展开项绑定
};
// 提交选择
...
...
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