Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
eb713f80
Commit
eb713f80
authored
Aug 26, 2016
by
Leopoldthecoder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update custom background table
parent
8a00aff7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
25 deletions
+30
-25
examples/docs/table.md
examples/docs/table.md
+3
-3
packages/table/src/table-body.js
packages/table/src/table-body.js
+23
-5
packages/table/src/table.vue
packages/table/src/table.vue
+4
-1
packages/theme-default/src/table.css
packages/theme-default/src/table.css
+0
-16
No files found.
examples/docs/table.md
View file @
eb713f80
...
...
@@ -248,9 +248,9 @@
## 带状态表格
通过在
`data`
对象数组中加入字段,可以给行加上状态,Element 提供了四种状态:
`$positive`
、
`$info`
、
`$warning`
以及
`$negative`
,在对象新增字段中把状态设为
`true`
表示启用该状态
。
可以为行添加自定义背景色,表明该行处于某种状态。若某一行拥有
`custom-criteria`
数组中的某个字段且值为
`true`
,则为该行添加
`custom-background-colors`
数组中对应的背景色
。
<el-table
:data=
"tableData2"
style=
"width: 520px"
>
<el-table
:data=
"tableData2"
style=
"width: 520px"
:custom-criteria=
"['$info', '$positive']"
:custom-background-colors=
"['#C9E5F5', '#E2F0E4']"
>
<el-table-column
property=
"date"
label=
"日期"
width=
"120"
></el-table-column>
<el-table-column
property=
"name"
label=
"姓名"
width=
"120"
></el-table-column>
<el-table-column
property=
"address"
label=
"地址"
></el-table-column>
...
...
@@ -258,7 +258,7 @@
```
html
<template>
<el-table
:data=
"tableData2"
>
<el-table
:data=
"tableData2"
:custom-criteria=
"['$info', '$positive']"
:custom-background-colors=
"['#C9E5F5', '#E2F0E4']"
>
<el-table-column
property=
"date"
label=
"日期"
width=
"120"
></el-table-column>
<el-table-column
property=
"name"
label=
"姓名"
width=
"120"
></el-table-column>
<el-table-column
property=
"address"
label=
"地址"
></el-table-column>
...
...
packages/table/src/table-body.js
View file @
eb713f80
...
...
@@ -43,13 +43,10 @@ export default {
<
tr
on
-
click
=
{
(
$event
)
=>
this
.
handleClick
(
$event
,
row
)
}
on
-
mouseenter
=
{
_
=>
this
.
handleMouseEnter
(
$index
)
}
style
=
{
this
.
getCustomStyle
(
row
)
}
class
=
{{
'
current-row
'
:
row
===
this
.
$parent
.
selected
,
'
hover
'
:
this
.
$parent
.
$parent
.
hoverRowIndex
===
$index
,
'
positive-row
'
:
row
.
$positive
,
'
info-row
'
:
row
.
$info
,
'
warning-row
'
:
row
.
$warning
,
'
negative-row
'
:
row
.
$negative
'
hover
'
:
this
.
$parent
.
$parent
.
hoverRowIndex
===
$index
}}
>
{
this
.
_l
(
this
.
columns
,
(
column
)
=>
...
...
@@ -75,6 +72,8 @@ export default {
data
()
{
return
{
criteria
:
this
.
$parent
.
customCriteria
,
colors
:
this
.
$parent
.
customBackgroundColors
,
tooltipDisabled
:
true
};
},
...
...
@@ -84,6 +83,25 @@ export default {
},
methods
:
{
checkProperty
(
row
)
{
if
(
this
.
criteria
&&
this
.
criteria
.
length
>
0
)
{
for
(
let
i
=
0
,
len
=
this
.
criteria
.
length
;
i
<
len
;
i
++
)
{
if
(
row
[
this
.
criteria
[
i
]]
===
true
)
{
return
i
;
}
}
}
return
-
1
;
},
getCustomStyle
(
row
)
{
if
(
!
this
.
criteria
||
!
this
.
colors
||
this
.
criteria
.
length
!==
this
.
colors
.
length
)
{
return
{};
}
let
criterionIndex
=
this
.
checkProperty
(
row
);
return
criterionIndex
>
-
1
?
{
'
background-color
'
:
this
.
colors
[
criterionIndex
]
}
:
{};
},
handleCellMouseEnter
(
event
,
row
)
{
let
grid
=
this
.
$parent
;
const
cell
=
getCell
(
event
);
...
...
packages/table/src/table.vue
View file @
eb713f80
...
...
@@ -81,7 +81,10 @@
gutterWidth
:
{
default
:
0
}
},
customCriteria
:
Array
,
customBackgroundColors
:
Array
},
components
:
{
...
...
packages/theme-default/src/table.css
View file @
eb713f80
...
...
@@ -253,22 +253,6 @@
}
}
&
tr
.positive-row
{
background
:
#E2F0E4
;
}
&
tr
.info-row
{
background
:
#C9E5F5
;
}
&
tr
.warning-row
{
background
:
#FEEED9
;
}
&
tr
.negative-row
{
background
:
#F7D2D3
;
}
&
tr
.current-row
{
background
:
#EFF7FF
;
}
...
...
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