Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
sts网站
Project
Project
Details
Activity
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
liyang
sts网站
Commits
18c8d4ec
Commit
18c8d4ec
authored
Aug 09, 2025
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
显示列信息支持对象格式
parent
191fd293
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
34 deletions
+65
-34
index.vue
ruoyi-ui/src/components/RightToolbar/index.vue
+49
-18
index.vue
ruoyi-ui/src/views/system/user/index.vue
+16
-16
No files found.
ruoyi-ui/src/components/RightToolbar/index.vue
View file @
18c8d4ec
...
...
@@ -17,9 +17,9 @@
<el-checkbox
:indeterminate=
"isIndeterminate"
v-model=
"isChecked"
@
change=
"toggleCheckAll"
>
列展示
</el-checkbox>
</el-dropdown-item>
<div
class=
"check-line"
></div>
<template
v-for=
"
item
in columns"
>
<el-dropdown-item
:key=
"
item.
key"
>
<el-checkbox
v-model=
"item.visible"
@
change=
"checkboxChange($event,
item.label
)"
:label=
"item.label"
/>
<template
v-for=
"
(item, key)
in columns"
>
<el-dropdown-item
:key=
"key"
>
<el-checkbox
v-model=
"item.visible"
@
change=
"checkboxChange($event,
key
)"
:label=
"item.label"
/>
</el-dropdown-item>
</
template
>
</el-dropdown-menu>
...
...
@@ -30,12 +30,13 @@
<el-transfer
:titles=
"['显示', '隐藏']"
v-model=
"value"
:data=
"
columns
"
:data=
"
transferData
"
@
change=
"dataChange"
></el-transfer>
</el-dialog>
</div>
</template>
<
script
>
export
default
{
name
:
"RightToolbar"
,
...
...
@@ -55,9 +56,9 @@ export default {
type
:
Boolean
,
default
:
true
},
/* 显隐列信息 */
/* 显隐列信息
(数组格式、对象格式)
*/
columns
:
{
type
:
Array
type
:
[
Array
,
Object
]
},
/* 是否显示检索图标 */
search
:
{
...
...
@@ -85,21 +86,36 @@ export default {
},
isChecked
:
{
get
()
{
return
this
.
columns
.
every
((
col
)
=>
col
.
visible
)
return
Array
.
isArray
(
this
.
columns
)
?
this
.
columns
.
every
((
col
)
=>
col
.
visible
)
:
Object
.
values
(
this
.
columns
)
.
every
((
col
)
=>
col
.
visible
)
},
set
()
{}
},
isIndeterminate
()
{
return
this
.
columns
.
some
((
col
)
=>
col
.
visible
)
&&
!
this
.
isChecked
return
Array
.
isArray
(
this
.
columns
)
?
this
.
columns
.
some
((
col
)
=>
col
.
visible
)
&&
!
this
.
isChecked
:
Object
.
values
(
this
.
columns
).
some
((
col
)
=>
col
.
visible
)
&&
!
this
.
isChecked
},
transferData
()
{
if
(
Array
.
isArray
(
this
.
columns
))
{
return
this
.
columns
.
map
((
item
,
index
)
=>
({
key
:
index
,
label
:
item
.
label
}))
}
else
{
return
Object
.
keys
(
this
.
columns
).
map
((
key
,
index
)
=>
({
key
:
index
,
label
:
this
.
columns
[
key
].
label
}))
}
}
},
created
()
{
if
(
this
.
showColumnsType
==
'transfer'
)
{
// 显隐列初始默认隐藏列
for
(
let
item
in
this
.
columns
)
{
if
(
this
.
columns
[
item
].
visible
===
false
)
{
this
.
value
.
push
(
parseInt
(
item
))
// transfer穿梭显隐列初始默认隐藏列
if
(
Array
.
isArray
(
this
.
columns
))
{
for
(
let
item
in
this
.
columns
)
{
if
(
this
.
columns
[
item
].
visible
===
false
)
{
this
.
value
.
push
(
parseInt
(
item
))
}
}
}
else
{
Object
.
keys
(
this
.
columns
).
forEach
((
key
,
index
)
=>
{
if
(
this
.
columns
[
key
].
visible
===
false
)
{
this
.
value
.
push
(
index
)
}
})
}
}
},
...
...
@@ -114,9 +130,15 @@ export default {
},
// 右侧列表元素变化
dataChange
(
data
)
{
for
(
let
item
in
this
.
columns
)
{
const
key
=
this
.
columns
[
item
].
key
this
.
columns
[
item
].
visible
=
!
data
.
includes
(
key
)
if
(
Array
.
isArray
(
this
.
columns
))
{
for
(
let
item
in
this
.
columns
)
{
const
key
=
this
.
columns
[
item
].
key
this
.
columns
[
item
].
visible
=
!
data
.
includes
(
key
)
}
}
else
{
Object
.
keys
(
this
.
columns
).
forEach
((
key
,
index
)
=>
{
this
.
columns
[
key
].
visible
=
!
data
.
includes
(
index
)
})
}
},
// 打开显隐列dialog
...
...
@@ -124,17 +146,26 @@ export default {
this
.
open
=
true
},
// 单勾选
checkboxChange
(
event
,
label
)
{
this
.
columns
.
filter
(
item
=>
item
.
label
==
label
)[
0
].
visible
=
event
checkboxChange
(
event
,
key
)
{
if
(
Array
.
isArray
(
this
.
columns
))
{
this
.
columns
.
filter
(
item
=>
item
.
key
==
key
)[
0
].
visible
=
event
}
else
{
this
.
columns
[
key
].
visible
=
event
}
},
// 切换全选/反选
toggleCheckAll
()
{
const
newValue
=
!
this
.
isChecked
this
.
columns
.
forEach
((
col
)
=>
(
col
.
visible
=
newValue
))
if
(
Array
.
isArray
(
this
.
columns
))
{
this
.
columns
.
forEach
((
col
)
=>
(
col
.
visible
=
newValue
))
}
else
{
Object
.
values
(
this
.
columns
).
forEach
((
col
)
=>
(
col
.
visible
=
newValue
))
}
}
},
}
</
script
>
<
style
lang=
"scss"
scoped
>
::v-deep
.el-transfer__button
{
border-radius
:
50%
;
...
...
ruoyi-ui/src/views/system/user/index.vue
View file @
18c8d4ec
...
...
@@ -58,17 +58,17 @@
<el-table
v-loading=
"loading"
:data=
"userList"
@
selection-change=
"handleSelectionChange"
>
<el-table-column
type=
"selection"
width=
"50"
align=
"center"
/>
<el-table-column
label=
"用户编号"
align=
"center"
key=
"userId"
prop=
"userId"
v-if=
"columns
[0]
.visible"
/>
<el-table-column
label=
"用户名称"
align=
"center"
key=
"userName"
prop=
"userName"
v-if=
"columns
[1]
.visible"
:show-overflow-tooltip=
"true"
/>
<el-table-column
label=
"用户昵称"
align=
"center"
key=
"nickName"
prop=
"nickName"
v-if=
"columns
[2]
.visible"
:show-overflow-tooltip=
"true"
/>
<el-table-column
label=
"部门"
align=
"center"
key=
"deptName"
prop=
"dept.deptName"
v-if=
"columns
[3]
.visible"
:show-overflow-tooltip=
"true"
/>
<el-table-column
label=
"手机号码"
align=
"center"
key=
"phonenumber"
prop=
"phonenumber"
v-if=
"columns
[4]
.visible"
width=
"120"
/>
<el-table-column
label=
"状态"
align=
"center"
key=
"status"
v-if=
"columns
[5]
.visible"
>
<el-table-column
label=
"用户编号"
align=
"center"
key=
"userId"
prop=
"userId"
v-if=
"columns
.userId
.visible"
/>
<el-table-column
label=
"用户名称"
align=
"center"
key=
"userName"
prop=
"userName"
v-if=
"columns
.userName
.visible"
:show-overflow-tooltip=
"true"
/>
<el-table-column
label=
"用户昵称"
align=
"center"
key=
"nickName"
prop=
"nickName"
v-if=
"columns
.nickName
.visible"
:show-overflow-tooltip=
"true"
/>
<el-table-column
label=
"部门"
align=
"center"
key=
"deptName"
prop=
"dept.deptName"
v-if=
"columns
.deptName
.visible"
:show-overflow-tooltip=
"true"
/>
<el-table-column
label=
"手机号码"
align=
"center"
key=
"phonenumber"
prop=
"phonenumber"
v-if=
"columns
.phonenumber
.visible"
width=
"120"
/>
<el-table-column
label=
"状态"
align=
"center"
key=
"status"
v-if=
"columns
.status
.visible"
>
<template
slot-scope=
"scope"
>
<el-switch
v-model=
"scope.row.status"
active-value=
"0"
inactive-value=
"1"
@
change=
"handleStatusChange(scope.row)"
></el-switch>
</
template
>
</el-table-column>
<el-table-column
label=
"创建时间"
align=
"center"
prop=
"createTime"
v-if=
"columns
[6]
.visible"
width=
"160"
>
<el-table-column
label=
"创建时间"
align=
"center"
prop=
"createTime"
v-if=
"columns
.createTime
.visible"
width=
"160"
>
<
template
slot-scope=
"scope"
>
<span>
{{
parseTime
(
scope
.
row
.
createTime
)
}}
</span>
</
template
>
...
...
@@ -277,15 +277,15 @@ export default {
deptId
:
undefined
},
// 列信息
columns
:
[
{
key
:
0
,
label
:
`用户编号`
,
visible
:
true
},
{
key
:
1
,
label
:
`用户名称`
,
visible
:
true
},
{
key
:
2
,
label
:
`用户昵称`
,
visible
:
true
},
{
key
:
3
,
label
:
`部门`
,
visible
:
true
},
{
key
:
4
,
label
:
`手机号码`
,
visible
:
true
},
{
key
:
5
,
label
:
`状态`
,
visible
:
true
},
{
key
:
6
,
label
:
`创建时间`
,
visible
:
true
}
]
,
columns
:
{
userId
:
{
label
:
'用户编号'
,
visible
:
true
},
userName
:
{
label
:
'用户名称'
,
visible
:
true
},
nickName
:
{
label
:
'用户昵称'
,
visible
:
true
},
deptName
:
{
label
:
'部门'
,
visible
:
true
},
phonenumber
:
{
label
:
'手机号码'
,
visible
:
true
},
status
:
{
label
:
'状态'
,
visible
:
true
},
createTime
:
{
label
:
'创建时间'
,
visible
:
true
}
}
,
// 表单校验
rules
:
{
userName
:
[
...
...
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