feat(richedit): 添加返回顶部按钮和加载状态提示
- 新增返回顶部按钮,滚动超过300px时显示 - 添加底部加载状态提示文本 - 修改排序字段为publishTime - 优化滚动容器样式为overflow-y - 添加滚动事件监听和清理逻辑
This commit is contained in:
parent
7e2d54fcce
commit
0e3acc365b
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="all" ref="mescrollRef" v-infinite-scroll="getDataByScoll" style="overflow: auto">
|
<div class="all" ref="mescrollRef" v-infinite-scroll="getDataByScoll" style="overflow-y: auto">
|
||||||
<div style="display: flex;align-items: center;">
|
<div style="display: flex;align-items: center;">
|
||||||
<el-input v-model="form.keyword" placeholder="输入关键字进行搜索(以空格隔开)" class="input-with-select"
|
<el-input v-model="form.keyword" placeholder="输入关键字进行搜索(以空格隔开)" class="input-with-select"
|
||||||
@keyup.enter="handleSearch" style="width: 80%">
|
@keyup.enter="handleSearch" style="width: 80%">
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
<SortButton ref="sortRef" @changeSort="changeSort"></SortButton>
|
<SortButton ref="sortRef" @changeSort="changeSort"></SortButton>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="r_list" v-loading="loading">
|
<div class="r_list" v-loading="loading" ref="listRef">
|
||||||
<el-card v-for="(item, index) in tableData.data" :key="index" class="card">
|
<el-card v-for="(item, index) in tableData.data" :key="index" class="card">
|
||||||
<template #header>
|
<template #header>
|
||||||
<div class="card_header" @click.stop="goDetail(1, item, true)">
|
<div class="card_header" @click.stop="goDetail(1, item, true)">
|
||||||
|
|
@ -81,8 +81,17 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
|
<text class="bottom_load_text" v-if="tableData.data.length < tableData.total">--- 正在加载中 ---</text>
|
||||||
|
<text class="bottom_load_text" v-else>--- 已经到底了 ---</text>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div v-if="isShowBackTop" class="back_top" @click="goTop">
|
||||||
|
<el-icon>
|
||||||
|
<CaretTop />
|
||||||
|
</el-icon>
|
||||||
|
</div>
|
||||||
<keep-alive>
|
<keep-alive>
|
||||||
<DetailDrawer v-model="drawer" :data="newsData" :readOnly="readOnly" :type="newstype"
|
<DetailDrawer v-model="drawer" :data="newsData" :readOnly="readOnly" :type="newstype"
|
||||||
@handleEditStatus="handleEditStatus" @doNewsPublishFn="doNewsPublishFn" @doDeleteNewsFn="doDeleteNewsFn"
|
@handleEditStatus="handleEditStatus" @doNewsPublishFn="doNewsPublishFn" @doDeleteNewsFn="doDeleteNewsFn"
|
||||||
|
|
@ -146,7 +155,7 @@ function changeTab(index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeSort(sort) {
|
function changeSort(sort) {
|
||||||
form.value.orderBy = 'updateTime$' + sort;
|
form.value.orderBy = 'publishTime$' + sort;
|
||||||
getData();
|
getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -330,11 +339,38 @@ function restData() {
|
||||||
function handleEditStatus(val: boolean) {
|
function handleEditStatus(val: boolean) {
|
||||||
readOnly.value = val;
|
readOnly.value = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const mescrollRef = ref()
|
||||||
|
function goTop() {
|
||||||
|
window.scrollTo({
|
||||||
|
top: 0,
|
||||||
|
behavior: 'smooth',
|
||||||
|
})
|
||||||
|
mescrollRef.value.scrollTo({
|
||||||
|
top: 0,
|
||||||
|
behavior: 'smooth',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const isShowBackTop = ref(false)
|
||||||
|
function handleScroll() {
|
||||||
|
if (mescrollRef.value.scrollTop > 300) {
|
||||||
|
isShowBackTop.value = true
|
||||||
|
} else {
|
||||||
|
isShowBackTop.value = false
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
changeTab(0)
|
changeTab(0)
|
||||||
|
mescrollRef.value.addEventListener('scroll', handleScroll);
|
||||||
// getData();
|
// getData();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
mescrollRef.value.removeEventListener('scroll', handleScroll);
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|
@ -347,6 +383,7 @@ onMounted(() => {
|
||||||
/* Firefox */
|
/* Firefox */
|
||||||
-ms-overflow-style: none;
|
-ms-overflow-style: none;
|
||||||
/* IE and Edge 旧版本 */
|
/* IE and Edge 旧版本 */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -450,4 +487,29 @@ onMounted(() => {
|
||||||
color: #ff0000;
|
color: #ff0000;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bottom_load_text {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #ccc;
|
||||||
|
width: 90vw;
|
||||||
|
height: 30px;
|
||||||
|
display: flex;
|
||||||
|
text-align: center;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.back_top {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 30px;
|
||||||
|
right: 30px;
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
background-color: white;
|
||||||
|
border-radius: 100px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
box-shadow: 0 0 10px rgba($color: #363636, $alpha: 0.2);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue