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
8028086b
Commit
8028086b
authored
May 18, 2022
by
leon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:table add sticky
parent
92c58a54
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
10 deletions
+50
-10
NormalTable.vue
components/NormalTable/NormalTable.vue
+17
-3
index.vue
pages/index/index.vue
+33
-7
No files found.
components/NormalTable/NormalTable.vue
View file @
8028086b
...
@@ -3,11 +3,11 @@
...
@@ -3,11 +3,11 @@
<NormalTitle
:elementInfo=
"elementInfo"
></NormalTitle>
<NormalTitle
:elementInfo=
"elementInfo"
></NormalTitle>
<scroll-view
scroll-x
scroll-y
class=
"scroll-view_H"
:style=
"[tableConfigStyle]"
>
<scroll-view
scroll-x
scroll-y
class=
"scroll-view_H"
:style=
"[tableConfigStyle]"
>
<view
class=
"table"
>
<view
class=
"table"
>
<view
class=
"tr table_header
"
v-if=
"elementInfo.table.tableHeader.showHeader"
>
<view
class=
'tr'
:class=
"[sticky ? 'table_header_sticky' : 'table_header']
"
v-if=
"elementInfo.table.tableHeader.showHeader"
>
<template
v-for=
"(item, index) in elementInfo.table.column"
>
<template
v-for=
"(item, index) in elementInfo.table.column"
>
<view
<view
class=
"th th_style"
class=
"th th_style"
:class=
"[index == 0 ? 'row_fixed': '']"
:class=
"[index == 0
&& !sticky
? 'row_fixed': '']"
:key=
"index"
:key=
"index"
>
{{
item
.
title
}}
</view>
>
{{
item
.
title
}}
</view>
</
template
>
</
template
>
...
@@ -62,7 +62,8 @@
...
@@ -62,7 +62,8 @@
left
:
'start'
,
left
:
'start'
,
center
:
'center'
,
center
:
'center'
,
right
:
'flex-end'
right
:
'flex-end'
}
}
,
sticky
:
false
}
;
}
;
}
,
}
,
computed
:
{
computed
:
{
...
@@ -91,6 +92,14 @@
...
@@ -91,6 +92,14 @@
}
}
}
,
}
,
}
,
}
,
mounted
()
{
uni
.
$on
(
this
.
elementInfo
.
id
,
({
sticky
}
)
=>
{
this
.
sticky
=
sticky
}
)
}
,
destroy
()
{
uni
.
$off
(
elementInfo
.
id
)
}
,
methods
:
{
methods
:
{
initChart
()
{
initChart
()
{
const
that
=
this
const
that
=
this
...
@@ -172,6 +181,11 @@
...
@@ -172,6 +181,11 @@
top
:
0
;
top
:
0
;
z
-
index
:
2
;
z
-
index
:
2
;
}
}
.
table_header_sticky
{
position
:
fixed
;
top
:
0
;
z
-
index
:
2
;
}
.
row_fixed
{
.
row_fixed
{
position
:
sticky
;
position
:
sticky
;
left
:
0
;
left
:
0
;
...
...
pages/index/index.vue
View file @
8028086b
...
@@ -68,7 +68,8 @@
...
@@ -68,7 +68,8 @@
return
{
return
{
reportInfo
:
{},
reportInfo
:
{},
timename
:
null
,
timename
:
null
,
pageScrollTop
:
0
pageScrollTop
:
0
,
stickyTables
:
[]
// 设置了吸顶的table
}
}
},
},
computed
:
{
computed
:
{
...
@@ -215,12 +216,8 @@
...
@@ -215,12 +216,8 @@
},
parseInt
(
info
.
dataPollingInterval
)
*
1000
)
},
parseInt
(
info
.
dataPollingInterval
)
*
1000
)
}
}
}
}
res
.
data
.
Result
.
list
.
forEach
(
item
=>
{
if
(
item
.
type
===
'DateTimePicker'
&&
item
.
option
.
dateTime
.
showTime
)
{
item
.
option
.
dateTime
.
date
=
this
.
dateTimeFormat
(
item
.
option
.
dateTime
.
date
)
}
})
that
.
reportInfo
=
res
.
data
.
Result
that
.
reportInfo
=
res
.
data
.
Result
that
.
getStickyTables
()
}
}
},
},
/**
/**
...
@@ -256,12 +253,41 @@
...
@@ -256,12 +253,41 @@
return
item
return
item
})
})
}
}
},
getStickyTables
()
{
this
.
reportInfo
.
list
.
forEach
(
item
=>
{
// 后端会增加一个表头吸顶的配置,headerSticky=true
if
(
item
.
type
===
'NormalTable'
&&
item
.
table
.
tableHeader
.
headerSticky
)
{
this
.
stickyTables
.
push
(
item
)
}
}
})
},
},
},
onPullDownRefresh
()
{
onPullDownRefresh
()
{
this
.
getReportCharts
()
this
.
getReportCharts
()
},
},
onPageScroll
(
res
)
{
onPageScroll
(
res
)
{
if
(
res
.
scrollTop
>
this
.
pageScrollTop
)
{
// 向上滑动
this
.
stickyTables
.
forEach
(
item
=>
{
if
(
res
.
scrollTop
>=
item
.
top
*
this
.
scale
)
{
uni
.
$emit
(
item
.
id
,{
sticky
:
true
})
}
if
(
res
.
scrollTop
>=
item
.
top
*
this
.
scale
+
item
.
height
*
this
.
scale
)
{
uni
.
$emit
(
item
.
id
,{
sticky
:
false
})
}
})
}
else
{
this
.
stickyTables
.
forEach
(
item
=>
{
if
(
res
.
scrollTop
<
item
.
top
*
this
.
scale
+
item
.
height
*
this
.
scale
)
{
uni
.
$emit
(
item
.
id
,{
sticky
:
true
})
}
if
(
res
.
scrollTop
<
item
.
top
*
this
.
scale
)
{
uni
.
$emit
(
item
.
id
,{
sticky
:
false
})
}
})
}
this
.
pageScrollTop
=
res
.
scrollTop
this
.
pageScrollTop
=
res
.
scrollTop
},
},
}
}
...
...
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