Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
bd80a6f3
authored
Jun 19, 2024
by
cherishsince
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【增加】image task 增加分页
parent
63f0a205
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
18 deletions
+39
-18
src/views/ai/image/ImageTask.vue
+39
-18
No files found.
src/views/ai/image/ImageTask.vue
View file @
bd80a6f3
<
template
>
<
template
>
<el-card
class=
"dr-task"
body-class=
"task-card"
shadow=
"never"
>
<el-card
class=
"dr-task"
body-class=
"task-card"
shadow=
"never"
>
<template
#
header
>
绘画任务
</
template
>
<template
#
header
>
绘画任务
</
template
>
<div
class=
"task-image-list"
ref=
"imageTaskRef"
@
scroll=
"handleTabsScroll"
>
<div
class=
"task-image-list"
ref=
"imageTaskRef"
>
<ImageTaskCard
<ImageTaskCard
v-for=
"image in imageList"
v-for=
"image in imageList"
:key=
"image"
:key=
"image"
...
@@ -10,6 +10,13 @@
...
@@ -10,6 +10,13 @@
@
on-btn-click=
"handlerImageBtnClick"
@
on-btn-click=
"handlerImageBtnClick"
@
on-mj-btn-click=
"handlerImageMjBtnClick"
/>
@
on-mj-btn-click=
"handlerImageMjBtnClick"
/>
</div>
</div>
<div
class=
"task-image-pagination"
>
<el-pagination
background
layout=
"prev, pager, next"
:default-page-size=
"pageSize"
:total=
"pageTotal"
@
change=
"handlerPageChange"
/>
</div>
</el-card>
</el-card>
<!-- 图片 detail 抽屉 -->
<!-- 图片 detail 抽屉 -->
<ImageDetailDrawer
<ImageDetailDrawer
...
@@ -34,7 +41,8 @@ const imageTaskRef = ref<any>() // ref
...
@@ -34,7 +41,8 @@ const imageTaskRef = ref<any>() // ref
const
imageTaskLoadingInstance
=
ref
<
any
>
()
// loading
const
imageTaskLoadingInstance
=
ref
<
any
>
()
// loading
const
imageTaskLoading
=
ref
<
boolean
>
(
false
)
// loading
const
imageTaskLoading
=
ref
<
boolean
>
(
false
)
// loading
const
pageNo
=
ref
<
number
>
(
1
)
// page no
const
pageNo
=
ref
<
number
>
(
1
)
// page no
const
pageSize
=
ref
<
number
>
(
20
)
// page size
const
pageSize
=
ref
<
number
>
(
10
)
// page size
const
pageTotal
=
ref
<
number
>
(
0
)
// page size
/** 抽屉 - close */
/** 抽屉 - close */
const
handlerDrawerClose
=
async
()
=>
{
const
handlerDrawerClose
=
async
()
=>
{
...
@@ -49,16 +57,20 @@ const handlerDrawerOpen = async () => {
...
@@ -49,16 +57,20 @@ const handlerDrawerOpen = async () => {
/**
/**
* 获取 - image 列表
* 获取 - image 列表
*/
*/
const
getImageList
=
async
()
=>
{
const
getImageList
=
async
(
apply
:
boolean
=
false
)
=>
{
imageTaskLoading
.
value
=
true
imageTaskLoading
.
value
=
true
try
{
try
{
imageTaskLoadingInstance
.
value
=
ElLoading
.
service
({
imageTaskLoadingInstance
.
value
=
ElLoading
.
service
({
target
:
imageTaskRef
.
value
,
target
:
imageTaskRef
.
value
,
text
:
'加载中...'
text
:
'加载中...'
})
})
const
{
list
}
=
await
ImageApi
.
getImageList
({
pageNo
:
pageNo
.
value
,
pageSize
:
pageSize
.
value
})
const
{
list
,
total
}
=
await
ImageApi
.
getImageList
({
pageNo
:
pageNo
.
value
,
pageSize
:
pageSize
.
value
})
// imageList.value.push.apply(imageList.value, list)
if
(
apply
)
{
imageList
.
value
=
list
imageList
.
value
=
[...
imageList
.
value
,
...
list
]
}
else
{
imageList
.
value
=
list
}
pageTotal
.
value
=
total
}
finally
{
}
finally
{
if
(
imageTaskLoadingInstance
.
value
)
{
if
(
imageTaskLoadingInstance
.
value
)
{
imageTaskLoadingInstance
.
value
.
close
();
imageTaskLoadingInstance
.
value
.
close
();
...
@@ -118,16 +130,10 @@ const downloadImage = async (imageUrl) => {
...
@@ -118,16 +130,10 @@ const downloadImage = async (imageUrl) => {
}
}
}
}
const
handleTabsScroll
=
async
()
=>
{
// page change
// todo 先不分页,只显示 top 前多少
const
handlerPageChange
=
async
(
page
)
=>
{
// if (imageTaskRef.value) {
pageNo
.
value
=
page
// const { scrollTop, scrollHeight, clientHeight } = imageTaskRef.value;
await
getImageList
(
false
)
// if (scrollTop + clientHeight >= scrollHeight - 20 && !imageTaskLoading.value) {
// console.log('分页')
// pageNo.value = pageNo.value + 1
// await getImageList();
// }
// }
}
}
/** 暴露组件方法 */
/** 暴露组件方法 */
...
@@ -139,7 +145,7 @@ onMounted(async () => {
...
@@ -139,7 +145,7 @@ onMounted(async () => {
await
getImageList
()
await
getImageList
()
// 自动刷新 image 列表
// 自动刷新 image 列表
imageListInterval
.
value
=
setInterval
(
async
()
=>
{
imageListInterval
.
value
=
setInterval
(
async
()
=>
{
await
getImageList
()
await
getImageList
(
false
)
},
1000
*
20
)
},
1000
*
20
)
})
})
...
@@ -168,7 +174,7 @@ onUnmounted(async () => {
...
@@ -168,7 +174,7 @@ onUnmounted(async () => {
height
:
100%
;
height
:
100%
;
overflow
:
auto
;
overflow
:
auto
;
padding
:
20px
;
padding
:
20px
;
padding-bottom
:
1
0
0px
;
padding-bottom
:
1
4
0px
;
box-sizing
:
border-box
;
/* 确保内边距不会增加高度 */
box-sizing
:
border-box
;
/* 确保内边距不会增加高度 */
>div
{
>div
{
...
@@ -179,6 +185,21 @@ onUnmounted(async () => {
...
@@ -179,6 +185,21 @@ onUnmounted(async () => {
//
margin-bottom
:
100px
;
//
margin-bottom
:
100px
;
}
}
}
}
.task-image-pagination
{
position
:
absolute
;
bottom
:
60px
;
height
:
50px
;
line-height
:
90px
;
width
:
100%
;
z-index
:
999
;
background-color
:
#ffffff
;
display
:
flex
;
flex-direction
:
row
;
justify-content
:
center
;
align-items
:
center
;
}
</
style
>
</
style
>
<
style
scoped
lang=
"scss"
>
<
style
scoped
lang=
"scss"
>
...
...
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