Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
E
ec-report-refactor
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
lihuizhen
ec-report-refactor
Commits
70bb629f
Commit
70bb629f
authored
May 11, 2022
by
root
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update table first column & cell to fixed
parent
941401b8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
186 additions
and
112 deletions
+186
-112
Table.vue
components/Table/Table.vue
+186
-112
No files found.
components/Table/Table.vue
View file @
70bb629f
<
template
>
<view
class=
"
normal-table"
:style=
"
{ transform: `scaleY(${scale}) translate(0px, ${elementInfo.height * (scale - 1) /2}px)`}"
>
<view
class=
"
analysis-group"
>
<NormalTitle
:elementInfo=
"elementInfo"
></NormalTitle>
<scroll-view
scroll-x=
"true"
class=
"scroll-view_H"
>
<view
class=
"table"
:style=
"[tableStyle]"
>
<view
class=
"tr"
v-if=
"elementInfo.table.tableHeader.showHeader"
>
<view
:class=
"[elementInfo.table.column.length > 10 ? 'th' :'th-large']"
v-for=
"(item, index) in elementInfo.table.column"
:key=
"index"
:style=
"[thStyle]"
>
{{
item
.
title
}}
</view>
</view>
<view
class=
"tr"
v-for=
"(cell, cellIndex) in chartTables"
:key=
"cellIndex"
@
tap=
"cellClick(cell)"
>
<view
:class=
"[elementInfo.table.column.length > 10 ? 'td' :'td-large']"
:style=
"[tdStyle]"
v-for=
"(item, index) in elementInfo.table.column"
:key=
"index"
>
<template
v-if=
"item.slots.customRender == 'rank'"
>
{{
index
+
1
}}
</
template
>
<
template
v-else-if=
"item.slots.customRender == 'picture'"
>
<u-image
:height=
"100"
mode=
"aspectFit"
:src=
"`$
{cell[item.dataIndex]}?${new Date().getTime()}`"
crossOrigin="anonymous"
style="width:100%"
@click="imageClick(cellIndex, item.dataIndex)"
>
</u-image>
</
template
>
<
template
v-else-if=
"item.slots.customRender == 'toThousands'"
>
{{
$u
.
common
.
toThousands
(
cell
[
item
.
dataIndex
])
}}
</
template
>
<
template
v-else-if=
"item.slots.customRender == 'percentage'"
>
{{
Number
(
cell
[
item
.
dataIndex
]
*
100
).
toFixed
(
0
)
}}
%
</
template
>
<
template
v-else-if=
"item.slots.customRender == 'Integer'"
>
{{
parseInt
(
cell
[
item
.
dataIndex
])
}}
</
template
>
<
template
v-else-if=
"item.slots.customRender == 'price'"
>
{{
`¥${Number(cell[item.dataIndex]).toFixed(2)
}
`
}}
<
/template
>
<
template
v
-
else
>
{{
cell
[
item
.
dataIndex
]
}}
<
/template
>
<scroll-view
scroll-x
scroll-y
>
<view
class=
"table"
:style=
"tableStyle"
>
<view
class=
"table-header"
>
<view
class=
"title-cell"
>
<view
v-for=
"(item, index) in elementInfo.table.column"
:key=
"index"
>
<view
class=
"column"
v-if =
"item.title == 'Store' "
>
{{
item
.
title
}}
</view>
</view>
</view>
<view
class=
"content-cell"
v-for=
"(item, index) in elementInfo.table.column"
:key=
"index"
>
<view
class=
"cell"
v-if =
"item.title != 'Store' "
>
{{
item
.
title
}}
</view>
<view
style=
"left: 100px;"
></view>
</view>
<
/view>
<
/view
>
</view>
<view
class=
"table-content"
:style=
"tableStyle"
>
<view
class=
"table-content__item"
v-for=
"(cell, cellIndex) in chartTables"
:key=
"cellIndex"
@
tap=
"cellClick(cell)"
>
<view
class=
"title-cell"
>
<view
class=
"cell"
>
{{
cell
.
shopName
}}
</view>
</view>
<view
class=
"content-cell"
v-for=
"(item, index) in elementInfo.table.column"
:key=
"index"
>
<view
v-if=
"item.dataIndex != 'shopName'"
>
<template
class=
"cell"
v-if=
"item.slots.customRender == 'rank'"
>
{{
index
+
1
}}
</
template
>
<
template
class=
"cell"
v-else-if=
"item.slots.customRender == 'picture'"
>
<u-image
:height=
"100"
mode=
"aspectFit"
:src=
"`$
{cell[item.dataIndex]}?${new Date().getTime()}`"
crossOrigin="anonymous"
style="width:100%"
@click="imageClick(cellIndex, item.dataIndex)"
>
</u-image>
</
template
>
<
template
class=
"cell"
v-else-if=
"item.slots.customRender == 'toThousands'"
>
{{
$u
.
common
.
toThousands
(
cell
[
item
.
dataIndex
])
}}
</
template
>
<
template
class=
"cell"
v-else-if=
"item.slots.customRender == 'percentage'"
>
{{
Number
(
cell
[
item
.
dataIndex
]
*
100
).
toFixed
(
0
)
}}
%
</
template
>
<
template
class=
"cell"
v-else-if=
"item.slots.customRender == 'Integer'"
>
{{
parseInt
(
cell
[
item
.
dataIndex
])
}}
</
template
>
<
template
class=
"cell"
v-else-if=
"item.slots.customRender == 'price'"
>
{{
`¥${Number(cell[item.dataIndex]).toFixed(2)
}
`
}}
<
/template
>
<
template
class
=
"cell"
v
-
else
>
{{
cell
[
item
.
dataIndex
]
}}
<
/template
>
<
/view
>
<
/view
>
<
/view>
<
/view
>
<
/view
>
<
/scroll-view
>
<
/view
>
<
/template
>
<
/template
>
-->
<!--
<
script
>
export
default
{
data
()
{
return
{
tableColumn
:
[
{
id
:
'language'
,
name
:
'语文'
}
,
{
id
:
'math'
,
name
:
'数学'
}
,
{
id
:
'english'
,
name
:
'英语'
}
,
{
id
:
'politics'
,
name
:
'政治'
}
,
{
id
:
'biology'
,
name
:
'生物'
}
,
],
person
:
[
'宋江'
,
'卢俊义'
,
'吴用'
,
'公孙胜'
,
'关胜'
,
'林冲'
,
'花容'
,
'柴进'
,
'李逵'
,
'宋江'
,
'卢俊义'
,
'吴用'
,
'公孙胜'
,
'关胜'
,
'林冲'
,
'花容'
,
'柴进'
,
'李逵'
],
min
:
60
,
max
:
100
,
titleWidth
:
200
,
contentWidth
:
250
}
}
,
computed
:
{
tableStyle
()
{
const
width
=
this
.
titleWidth
+
this
.
tableColumn
.
length
*
this
.
contentWidth
;
return
`width: ${width
}
rpx`
;
}
,
tableData
()
{
const
tableData
=
this
.
person
.
map
((
name
,
index
)
=>
{
const
obj
=
this
.
tableColumn
.
reduce
((
result
,
item
)
=>
{
result
[
item
.
id
]
=
Math
.
ceil
(
Math
.
random
()
*
(
this
.
max
-
this
.
min
)
+
this
.
min
);
return
result
;
}
,
{
}
);
return
{
id
:
String
(
index
+
1
),
name
,
...
obj
}
;
}
);
console
.
log
(
tableData
);
// [
{
"id"
:
1
,
"name"
:
"宋江"
,
"language"
:
90
,
"math"
:
69
,
"english"
:
98
,
"politics"
:
89
,
"biology"
:
85
}
]
return
tableData
;
}
}
}
<
/script
>
-->
<
script
>
import
echartElementData
from
'@/mixins/echartElementData.js'
...
...
@@ -58,45 +126,16 @@
tableStyle
()
{
const
{
frameStyle
,
frameWidth
,
frameColor
,
bordered
}
=
this
.
elementInfo
.
table
const
{
backgroundColor
}
=
this
.
elementInfo
.
table
.
tableCell
return
{
'width'
:
`${110 * this.elementInfo.table.column.length
}
rpx`
,
'border-left'
:
'none'
,
'border-top'
:
'none'
,
'background-color'
:
backgroundColor
}
}
,
thStyle
()
{
const
{
frameStyle
,
frameWidth
,
frameColor
,
bordered
}
=
this
.
elementInfo
.
table
const
{
headerRowHeight
,
titleColor
,
backgroundColor
,
titlePostion
,
titleFontSize
}
=
this
.
elementInfo
.
table
.
tableHeader
return
{
'lineHeight'
:
`${headerRowHeight
}
px`
,
'color'
:
titleColor
,
'background-color'
:
backgroundColor
,
'font-size'
:
`${this.$u.common.pxToRpx(titleFontSize)
}
rpx`
,
'text-align'
:
titlePostion
||
'center'
,
'border-bottom'
:
bordered
?
`${frameStyle || 'solid'
}
${frameWidth || 1
}
px ${frameColor || '#e4e7ed'
}
`
:
'none'
,
'border-right'
:
'none'
}
}
,
tdStyle
()
{
const
{
frameStyle
,
frameWidth
,
frameColor
,
bordered
}
=
this
.
elementInfo
.
table
const
{
titlePostion
,
titleFontSize
,
cellRowHeight
,
titleColor
}
=
this
.
elementInfo
.
table
.
tableCell
return
{
'text-align'
:
titlePostion
,
'justify-content'
:
this
.
align
[
titlePostion
],
'font-size'
:
`${titleFontSize || 14
}
px`
,
'lineHeight'
:
`${cellRowHeight || 30
}
px`
,
'color'
:
titleColor
,
'border-bottom'
:
bordered
?
`${frameStyle || 'solid'
}
${frameWidth || 1
}
px ${frameColor || '#e4e7ed'
}
`
:
'none'
,
'border-right'
:
'none'
}
const
width
=
200
+
this
.
elementInfo
.
table
.
column
.
length
*
250
;
console
.
log
(
'width'
,
width
)
return
`width: ${width
}
rpx`
;
}
}
,
methods
:
{
initChart
()
{
const
that
=
this
that
.
$nextTick
(()
=>
{
that
.
calculateScale
()
//
that.calculateScale()
that
.
chartTables
=
that
.
elementData
.
dataList
.
chartTables
that
.
elementInfo
.
table
.
column
.
forEach
(
item
=>
{
if
(
item
.
slots
.
customRender
===
'picture'
)
{
...
...
@@ -169,58 +208,93 @@
}
<
/script
>
<
style
scoped
lang
=
"scss"
>
.
normal
-
table
{
width
:
100
%
;
<
style
lang
=
"scss"
scoped
>
.
analysis
-
group
{
margin
-
top
:
20
px
;
width
:
100
%
;;
height
:
100
%
;
scroll
-
view
{
width
:
100
vw
;
height
:
40
vh
;
}
}
.
scroll
-
view_H
{
display
:
flex
;
flex
-
wrap
:
nowrap
;
}
$title
-
width
:
200
rpx
;
$content
-
width
:
250
rpx
;
$border
-
color
:
#
f6f6f6
;
$border
:
1
rpx
solid
$border
-
color
;
$white
:
#
FFFFFF
;
$title
-
color
:
#
f6f6f6
;
.
table
{
width
:
100
%
;
box
-
sizing
:
border
-
box
;
}
.
tr
{
display
:
flex
;
flex
-
direction
:
row
;
}
.
th
{
flex
:
0
0
110
rpx
;
font
-
size
:
28
rpx
;
color
:
$u
-
main
-
color
;
padding
:
10
px
0
px
;
background
-
color
:
rgb
(
245
,
246
,
248
);
}
.
th
-
large
{
flex
:
0
0
220
rpx
;
font
-
size
:
28
rpx
;
color
:
$u
-
main
-
color
;
font
-
weight
:
bold
;
padding
:
10
px
0
px
;
background
-
color
:
rgb
(
245
,
246
,
248
);
}
.
td
{
flex
:
0
0
110
rpx
;
align
-
self
:
stretch
;
padding
:
10
px
0
px
;
font
-
size
:
28
rpx
;
color
:
$u
-
content
-
color
;
display
:
flex
;
align
-
items
:
center
;
justify
-
content
:
center
;
}
display
:
table
;
.
table
-
header
{
// display: table-row;
// font-weight: bold;
background
-
color
:
$title
-
color
;
position
:
sticky
;
top
:
0
;
z
-
index
:
2
;
.
title
-
cell
{
// background-image: linear-gradient(to top right, transparent 48%, $border-color, transparent 52%);
border
:
$border
;
position
:
relative
;
position
:
sticky
;
left
:
0
;
z
-
index
:
1
;
.
row
{
position
:
absolute
;
right
:
10
rpx
;
top
:
5
rpx
;
}
.
column
{
position
:
absolute
;
left
:
10
rpx
;
bottom
:
25
rpx
;
}
}
.
content
-
cell
{
// border-top: $border;
// border-bottom: $border;
// border-right: $border;
}
}
.
table
-
content
{
&
__item
{
display
:
table
-
row
;
.
title
-
cell
{
border
-
left
:
$border
;
border
-
right
:
$border
;
border
-
bottom
:
$border
;
position
:
sticky
;
left
:
0
;
z
-
index
:
1
;
align
-
items
:
center
;
justify
-
content
:
center
;
}
.
content
-
cell
{
border
-
bottom
:
$border
;
border
-
right
:
$border
;
}
}
}
.
title
-
cell
{
display
:
table
-
cell
;
width
:
$title
-
width
;
background
-
color
:
$title
-
color
;
align
-
items
:
center
;
justify
-
content
:
center
;
}
.
content
-
cell
{
display
:
table
-
cell
;
width
:
$content
-
width
;
}
.
cell
{
padding
:
10
px
0
px
;
line
-
height
:
1.6
;
font
-
size
:
28
rpx
;
align
-
items
:
center
;
justify
-
content
:
center
;
.
td
-
large
{
flex
:
0
0
220
rpx
;
align
-
self
:
stretch
;
padding
:
10
px
0
px
;
font
-
size
:
28
rpx
;
color
:
$u
-
content
-
color
;
display
:
flex
;
align
-
items
:
center
;
justify
-
content
:
center
;
}
}
<
/style>
\ No newline at end of file
<
/style
>
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