Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pptist
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
viitto
pptist
Commits
f71ebb2e
Commit
f71ebb2e
authored
Feb 27, 2024
by
罗超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增v-load-more 指令,新增分享列表分页功能
parent
c768b0b9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
4 deletions
+52
-4
index.ts
src/plugins/directive/index.ts
+2
-0
loadMore.ts
src/plugins/directive/loadMore.ts
+39
-0
common.ts
src/utils/common.ts
+0
-1
Share.vue
src/views/SellTemplate/Share.vue
+11
-3
No files found.
src/plugins/directive/index.ts
View file @
f71ebb2e
...
...
@@ -3,11 +3,13 @@ import type { App } from 'vue'
import
Contextmenu
from
'./contextmenu'
import
ClickOutside
from
'./clickOutside'
import
Tooltip
from
'./tooltip'
import
LoadMore
from
'./loadMore'
export
default
{
install
(
app
:
App
)
{
app
.
directive
(
'contextmenu'
,
Contextmenu
)
app
.
directive
(
'click-outside'
,
ClickOutside
)
app
.
directive
(
'tooltip'
,
Tooltip
)
app
.
directive
(
'load-more'
,
LoadMore
)
}
}
src/plugins/directive/loadMore.ts
0 → 100644
View file @
f71ebb2e
import
{
Directive
,
DirectiveBinding
}
from
"vue"
const
CTX_SCROLL_LOADMORE_HANDLER
=
'CTX_SCROLL_LOADMORE_HANDLER'
let
LAST_TRIGGER_EVENT
=
0
interface
CustomHTMLElement
extends
HTMLElement
{
[
CTX_SCROLL_LOADMORE_HANDLER
]?:
(
event
:
Event
)
=>
void
}
const
callbackEvent
=
(
event
:
any
,
binding
:
DirectiveBinding
<
any
>
)
=>
{
const
that
=
event
.
target
if
(
that
.
scrollHeight
-
Math
.
ceil
(
that
.
scrollTop
)
-
that
.
clientHeight
<=
3
){
if
(
LAST_TRIGGER_EVENT
==
0
||
(
new
Date
()).
getTime
()
-
LAST_TRIGGER_EVENT
>=
300
){
binding
.
value
()
LAST_TRIGGER_EVENT
=
(
new
Date
()).
getTime
()
}
}
}
const
LoadMoreDirective
:
Directive
=
{
mounted
(
el
:
CustomHTMLElement
,
binding
)
{
let
obj
=
el
.
querySelector
(
'.el-scrollbar__wrap'
)
if
(
obj
){
console
.
log
(
'找到元素'
)
el
[
CTX_SCROLL_LOADMORE_HANDLER
]
=
(
event
:
Event
)
=>
callbackEvent
(
event
,
binding
)
obj
.
addEventListener
(
'scroll'
,
el
[
CTX_SCROLL_LOADMORE_HANDLER
])
}
else
{
console
.
log
(
'没有找到元素'
)
}
},
unmounted
(
el
:
CustomHTMLElement
)
{
if
(
el
[
CTX_SCROLL_LOADMORE_HANDLER
])
{
document
.
removeEventListener
(
'scroll'
,
el
[
CTX_SCROLL_LOADMORE_HANDLER
])
delete
el
[
CTX_SCROLL_LOADMORE_HANDLER
]
}
},
}
export
default
LoadMoreDirective
\ No newline at end of file
src/utils/common.ts
View file @
f71ebb2e
...
...
@@ -59,7 +59,6 @@ export const getDaysBetween = (date1:any, date2:any) => {
}
export
const
formatDateTimeToRead
=
(
dateStr
:
string
,
prefix
:
string
=
''
)
=>
{
console
.
log
(
dateStr
)
let
minute
=
1000
*
60
;
let
hour
=
minute
*
60
;
let
day
=
hour
*
24
;
...
...
src/views/SellTemplate/Share.vue
View file @
f71ebb2e
...
...
@@ -29,7 +29,7 @@
</div>
</div>
<div
class=
"col full-width q-ml-md"
>
<el-table
class=
"sample-table"
:data=
"data"
style=
"width: 100%"
height=
"100%"
v-loading=
"loading"
@
sort-change=
"sortHandler"
:default-sort=
"
{ prop: 'CreateTime', order: 'descending' }">
<el-table
class=
"sample-table"
v-load-more=
"tableScrollHandler"
:data=
"data"
style=
"width: 100%"
height=
"100%"
v-loading=
"loading"
@
sort-change=
"sortHandler"
:default-sort=
"
{ prop: 'CreateTime', order: 'descending' }">
<!--
<el-table-column
type=
"selection"
width=
"20"
/>
-->
<el-table-column
className=
"indentLeft"
>
<template
#
header
>
...
...
@@ -225,8 +225,9 @@ const clearNavigationHandler = async () => {
await
refreshHandler
()
}
const
refreshHandler
=
async
()
=>
{
queryObj
.
pageIndex
=
0
queryObj
.
pageCount
=
0
queryObj
.
pageIndex
=
1
queryObj
.
pageCount
=
1
pageCount
.
value
=
1
data
.
value
=
[]
refreshLoading
.
value
=
true
await
getDocumentData
()
...
...
@@ -288,6 +289,13 @@ const checkPositionHandler = (n:any)=>{
emit
(
'destroy-position'
)
}
}
const
tableScrollHandler
=
()
=>
{
console
.
log
(
'share 通知到底底部'
)
if
(
pageCount
.
value
>
queryObj
.
pageIndex
){
queryObj
.
pageIndex
++
getDocumentData
()
}
}
watch
(()
=>
props
.
position
,(
n
,
o
)
=>
{
if
(
n
){
...
...
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