|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
<template>
|
|
|
- <div style="display: flex; justify-content: center">
|
|
|
|
|
|
|
+ <div style="display: flex; justify-content: center" class="main-content-wrapper">
|
|
|
<a-card :bordered="false" style="width: 1200px" class="formMount">
|
|
<a-card :bordered="false" style="width: 1200px" class="formMount">
|
|
|
<a-space>
|
|
<a-space>
|
|
|
<a-input-search
|
|
<a-input-search
|
|
@@ -33,7 +33,15 @@
|
|
|
创建新主题
|
|
创建新主题
|
|
|
</a-button>
|
|
</a-button>
|
|
|
</a-space>
|
|
</a-space>
|
|
|
- <s-table ref="table" :columns="columns" :data="loadData" :row-key="(record) => record.id" :custom-row="customRow">
|
|
|
|
|
|
|
+ <a-table
|
|
|
|
|
+ ref="table"
|
|
|
|
|
+ class="mt-2"
|
|
|
|
|
+ :columns="columns"
|
|
|
|
|
+ :dataSource="tableData"
|
|
|
|
|
+ :row-key="(record) => record.id"
|
|
|
|
|
+ :custom-row="customRow"
|
|
|
|
|
+ :pagination="false"
|
|
|
|
|
+ >
|
|
|
<template #bodyCell="{ column, record }">
|
|
<template #bodyCell="{ column, record }">
|
|
|
<template v-if="column.dataIndex === 'postTitle'">
|
|
<template v-if="column.dataIndex === 'postTitle'">
|
|
|
<div class="forum-list-title">{{ record.postTitle }}</div>
|
|
<div class="forum-list-title">{{ record.postTitle }}</div>
|
|
@@ -49,8 +57,9 @@
|
|
|
<div>{{ formatDateTime(record.lastReplyTime) }}</div>
|
|
<div>{{ formatDateTime(record.lastReplyTime) }}</div>
|
|
|
</template>
|
|
</template>
|
|
|
</template>
|
|
</template>
|
|
|
- </s-table>
|
|
|
|
|
- <Form ref="formRef" @successful="table.refresh(true)" />
|
|
|
|
|
|
|
+ </a-table>
|
|
|
|
|
+ <div style="text-align: center; cursor: pointer" class="mt-2" @click="moreList">{{ moreText }}</div>
|
|
|
|
|
+ <Form ref="formRef" @successful="loadData(pagination.value)" />
|
|
|
</a-card>
|
|
</a-card>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
@@ -116,7 +125,7 @@
|
|
|
title: '最后回复人',
|
|
title: '最后回复人',
|
|
|
dataIndex: 'lastReplyUserAvatar',
|
|
dataIndex: 'lastReplyUserAvatar',
|
|
|
align: 'center',
|
|
align: 'center',
|
|
|
- width: 100
|
|
|
|
|
|
|
+ width: 120
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
title: '回复量',
|
|
title: '回复量',
|
|
@@ -142,7 +151,7 @@
|
|
|
const handleChange = (value) => {
|
|
const handleChange = (value) => {
|
|
|
exType.value = false
|
|
exType.value = false
|
|
|
searchFormState.typeId = value
|
|
searchFormState.typeId = value
|
|
|
- table.value.refresh(true)
|
|
|
|
|
|
|
+ loadData(pagination.value)
|
|
|
}
|
|
}
|
|
|
const filterOption = (input, option) => {
|
|
const filterOption = (input, option) => {
|
|
|
return option.value.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
|
return option.value.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
|
@@ -154,7 +163,7 @@
|
|
|
// 查询
|
|
// 查询
|
|
|
const onSearch = () => {
|
|
const onSearch = () => {
|
|
|
exType.value = false
|
|
exType.value = false
|
|
|
- table.value.refresh(true)
|
|
|
|
|
|
|
+ loadData(pagination.value)
|
|
|
}
|
|
}
|
|
|
function customRow(record) {
|
|
function customRow(record) {
|
|
|
return {
|
|
return {
|
|
@@ -184,55 +193,106 @@
|
|
|
getTypeList()
|
|
getTypeList()
|
|
|
|
|
|
|
|
const exType = ref(false)
|
|
const exType = ref(false)
|
|
|
-
|
|
|
|
|
- const loadData = (parameter) => {
|
|
|
|
|
|
|
+ const tableData = ref([])
|
|
|
|
|
+ const tableTotal = ref(0)
|
|
|
|
|
+ const loadData = (parameter, a) => {
|
|
|
if (exType.value) {
|
|
if (exType.value) {
|
|
|
let postExtend = moduleTypeList.value.filter((r) => r.id == searchFormState.sortOrder)[0]?.state
|
|
let postExtend = moduleTypeList.value.filter((r) => r.id == searchFormState.sortOrder)[0]?.state
|
|
|
return forumApi.moreList(Object.assign(parameter, { postExtend: postExtend })).then((data) => {
|
|
return forumApi.moreList(Object.assign(parameter, { postExtend: postExtend })).then((data) => {
|
|
|
- if (data) {
|
|
|
|
|
- return data
|
|
|
|
|
|
|
+ tableTotal.value = data.total
|
|
|
|
|
+ if (a) {
|
|
|
|
|
+ tableData.value = Object.assign(tableData.value, data.records)
|
|
|
} else {
|
|
} else {
|
|
|
- return []
|
|
|
|
|
|
|
+ if (data) {
|
|
|
|
|
+ tableData.value = data.records
|
|
|
|
|
+ } else {
|
|
|
|
|
+ tableData.value = []
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
} else {
|
|
} else {
|
|
|
return forumApi.forumList(Object.assign(parameter, searchFormState)).then((data) => {
|
|
return forumApi.forumList(Object.assign(parameter, searchFormState)).then((data) => {
|
|
|
- if (data) {
|
|
|
|
|
- return data
|
|
|
|
|
|
|
+ tableTotal.value = data.total
|
|
|
|
|
+ if (a) {
|
|
|
|
|
+ tableData.value = tableData.value.concat(data.records)
|
|
|
} else {
|
|
} else {
|
|
|
- return []
|
|
|
|
|
|
|
+ if (data) {
|
|
|
|
|
+ tableData.value = data.records
|
|
|
|
|
+ } else {
|
|
|
|
|
+ tableData.value = []
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ const pagination = ref({
|
|
|
|
|
+ current: 1,
|
|
|
|
|
+ size: 10
|
|
|
|
|
+ })
|
|
|
|
|
+ loadData(pagination.value)
|
|
|
// 切换应用标签查询菜单列表
|
|
// 切换应用标签查询菜单列表
|
|
|
const moduleClock = (value, t) => {
|
|
const moduleClock = (value, t) => {
|
|
|
exType.value = false
|
|
exType.value = false
|
|
|
searchFormState.sortOrder = value
|
|
searchFormState.sortOrder = value
|
|
|
|
|
+ pagination.value.current = 1
|
|
|
|
|
+ moreText.value = '加载更多'
|
|
|
if (t == 2) {
|
|
if (t == 2) {
|
|
|
exType.value = true
|
|
exType.value = true
|
|
|
}
|
|
}
|
|
|
- table.value.refresh(true)
|
|
|
|
|
|
|
+ loadData(pagination.value)
|
|
|
}
|
|
}
|
|
|
- // 触底函数
|
|
|
|
|
- const onReachBottom = () => {
|
|
|
|
|
- window.addEventListener('scroll', onBottom())
|
|
|
|
|
|
|
+ const moreText = ref()
|
|
|
|
|
+
|
|
|
|
|
+ const moreList = () => {
|
|
|
|
|
+ if (tableTotal.value > pagination.value.current * pagination.value.size) {
|
|
|
|
|
+ pagination.value.current += 1
|
|
|
|
|
+ loadData(pagination.value, 1)
|
|
|
|
|
+ moreText.value = '加载更多'
|
|
|
|
|
+ } else {
|
|
|
|
|
+ moreText.value = '全部加载完成'
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- // 触底相应函数
|
|
|
|
|
- const onBottom = () => {
|
|
|
|
|
- // 获取可视高度
|
|
|
|
|
- let clientHeight = document.documentElement.clientHeight
|
|
|
|
|
- // 获取滚动高度
|
|
|
|
|
- let scrollTop = document.documentElement.scrollTop
|
|
|
|
|
- // 滚动条高度
|
|
|
|
|
- let scrollHeight = document.documentElement.scrollHeight
|
|
|
|
|
- if (clientHeight + scrollTop + 180 > scrollHeight) {
|
|
|
|
|
- console.log('触底了')
|
|
|
|
|
|
|
+ // 定义滚动函数
|
|
|
|
|
+ const handleScroll = () => {
|
|
|
|
|
+ const tableContainer = window.document.querySelector('.main-content-wrapper')
|
|
|
|
|
+ const scrollPosition = tableContainer.scrollTop
|
|
|
|
|
+ const isTop = scrollPosition === 0
|
|
|
|
|
+ const isBottom = tableContainer.scrollHeight - scrollPosition - 20 < tableContainer.clientHeight
|
|
|
|
|
+ if (isTop) {
|
|
|
|
|
+ // pagination.value.current = 1
|
|
|
|
|
+ // loadData(pagination.value);
|
|
|
|
|
+ console.log('重新加载')
|
|
|
|
|
+ }
|
|
|
|
|
+ if (isBottom) {
|
|
|
|
|
+ if (tableTotal.value > pagination.value.current * pagination.value.size) {
|
|
|
|
|
+ pagination.value.current += 1
|
|
|
|
|
+ loadData(pagination.value, 1)
|
|
|
|
|
+ moreText.value = '加载更多'
|
|
|
|
|
+ } else {
|
|
|
|
|
+ moreText.value = '全部加载完成'
|
|
|
|
|
+ }
|
|
|
|
|
+ console.log('加载更多')
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- onReachBottom()
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 添加scroll监听
|
|
|
|
|
+ onMounted(() => {
|
|
|
|
|
+ nextTick(() => {
|
|
|
|
|
+ if (table.value) {
|
|
|
|
|
+ const tableContainer = window.document.querySelector('.main-content-wrapper')
|
|
|
|
|
+ tableContainer.addEventListener('scroll', handleScroll)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ // 移除scroll监听
|
|
|
onBeforeUnmount(() => {
|
|
onBeforeUnmount(() => {
|
|
|
- window.removeEventListener('mousemove', onBottom())
|
|
|
|
|
|
|
+ nextTick(() => {
|
|
|
|
|
+ if (table.value) {
|
|
|
|
|
+ const tableContainer = window.document.querySelector('.main-content-wrapper')
|
|
|
|
|
+ tableContainer.removeEventListener('scroll', handleScroll)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
</script>
|
|
</script>
|
|
|
<style scoped>
|
|
<style scoped>
|