|
@@ -10,6 +10,8 @@ const visible = ref(false);
|
|
|
const pageNum = ref(0);
|
|
|
const pageSize = 10;
|
|
|
|
|
|
+const scrollRef = ref(null);
|
|
|
+
|
|
|
const totalPages = Math.ceil(allBookData.length / pageSize);
|
|
|
|
|
|
watch(pageNum, (num) => {
|
|
@@ -27,17 +29,32 @@ const changeVisible = () => {
|
|
|
visible.value = !visible.value;
|
|
|
}
|
|
|
|
|
|
+const handlePrePage = () => {
|
|
|
+ if ( pageNum.value === 1 ) {
|
|
|
+ return alert("已经是第一页了");
|
|
|
+ }
|
|
|
+ pageNum.value -= 1;
|
|
|
+ scroolToTop();
|
|
|
+ localStorage.setItem('pageNum', pageNum.value);
|
|
|
+}
|
|
|
+
|
|
|
const handleNextPage = () => {
|
|
|
if ( pageNum.value === totalPages ) return alert("已经是最后一页了");
|
|
|
pageNum.value += 1;
|
|
|
- localStorage.setItem('pageNum', pageNum.value)
|
|
|
+ scroolToTop();
|
|
|
+ localStorage.setItem('pageNum', pageNum.value);
|
|
|
}
|
|
|
|
|
|
const handleError = item => {
|
|
|
- item.isDisable = true;
|
|
|
-
|
|
|
- errIds.value.push(item.id);
|
|
|
+ item.isDisable = !item.isDisable;
|
|
|
+ item.isDisable ? (errIds.value.push(item.id)) : (errIds.value = errIds.value.filter(id => item.id !== id));
|
|
|
localStorage.setItem('errIds', JSON.stringify( errIds.value ));
|
|
|
+ // console.log(errIds.value);
|
|
|
+}
|
|
|
+
|
|
|
+// 返回顶部
|
|
|
+const scroolToTop = () => {
|
|
|
+ scrollRef.value?.scrollTo({ top: 0, behavior: 'smooth' });
|
|
|
}
|
|
|
|
|
|
onMounted(() => {
|
|
@@ -55,6 +72,7 @@ onMounted(() => {
|
|
|
<section class="page-container">
|
|
|
<header class="header flex items-center">
|
|
|
<NSpace>
|
|
|
+ <n-button @click="handlePrePage">上一页</n-button>
|
|
|
<n-button @click="handleNextPage">下一页</n-button>
|
|
|
<n-button @click="changeVisible">显示错误id</n-button>
|
|
|
</NSpace>
|
|
@@ -64,7 +82,7 @@ onMounted(() => {
|
|
|
<span>{{ totalPages }}</span>
|
|
|
</p>
|
|
|
</header>
|
|
|
- <div class="main">
|
|
|
+ <div class="main" ref="scrollRef">
|
|
|
<NCard :title="item.id" v-for="item in dataSource" :key="item.id" class="mb-[20px]">
|
|
|
<div v-for="arr, i in item.history" :key="i + item.id" class="pt-[40px]">
|
|
|
<ChatAsk :content="arr[0]"></ChatAsk>
|
|
@@ -73,7 +91,8 @@ onMounted(() => {
|
|
|
</div>
|
|
|
<div class="answer-btns pt-[20px]">
|
|
|
<NSpace>
|
|
|
- <NButton :type="item.isDisable? '' : 'error'" @click="handleError(item)" :disabled="item.isDisable">
|
|
|
+ <!-- :disabled="item.isDisable" -->
|
|
|
+ <NButton :type="item.isDisable? '' : 'error'" @click="handleError(item)">
|
|
|
{{ item.isDisable ? '已审核' : '错' }}
|
|
|
</NButton>
|
|
|
</NSpace>
|