|
@@ -10,33 +10,40 @@
|
|
|
<div>
|
|
|
<van-checkbox-group v-model="checked" ref="checkboxGroup">
|
|
|
<van-cell-group>
|
|
|
- <van-swipe-cell
|
|
|
- v-for="(item, index) in list"
|
|
|
- :key="index"
|
|
|
- :disabled="isChoose"
|
|
|
+ <van-list
|
|
|
+ v-model="loading"
|
|
|
+ :finished="finished"
|
|
|
+ finished-text="没有更多了"
|
|
|
+ @load="onLoad"
|
|
|
>
|
|
|
- <van-cell clickable :title="`${item.id}. ${item.issue}`" @click="">
|
|
|
- <template #icon v-if="isChoose">
|
|
|
- <van-checkbox :name="item.id" class="checkbox" />
|
|
|
+ <van-swipe-cell
|
|
|
+ v-for="(item, index) in list"
|
|
|
+ :key="index"
|
|
|
+ :disabled="isChoose"
|
|
|
+ >
|
|
|
+ <van-cell clickable :title="`${item.id}. ${item.issue}`" @click="">
|
|
|
+ <template #icon v-if="isChoose">
|
|
|
+ <van-checkbox :name="item.id" class="checkbox" />
|
|
|
+ </template>
|
|
|
+ </van-cell>
|
|
|
+ <template #right>
|
|
|
+ <van-button
|
|
|
+ square
|
|
|
+ style="height: 100%"
|
|
|
+ type="danger"
|
|
|
+ text="删除"
|
|
|
+ @click="deleteClick(item.id)"
|
|
|
+ />
|
|
|
+ <van-button
|
|
|
+ square
|
|
|
+ style="height: 100%"
|
|
|
+ type="primary"
|
|
|
+ text="收藏"
|
|
|
+ v-if="isType == 0"
|
|
|
+ />
|
|
|
</template>
|
|
|
- </van-cell>
|
|
|
- <template #right>
|
|
|
- <van-button
|
|
|
- square
|
|
|
- style="height: 100%"
|
|
|
- type="danger"
|
|
|
- text="删除"
|
|
|
- @click="deleteClick(item.id)"
|
|
|
- />
|
|
|
- <van-button
|
|
|
- square
|
|
|
- style="height: 100%"
|
|
|
- type="primary"
|
|
|
- text="收藏"
|
|
|
- v-if="isType == 0"
|
|
|
- />
|
|
|
- </template>
|
|
|
- </van-swipe-cell>
|
|
|
+ </van-swipe-cell>
|
|
|
+ </van-list>
|
|
|
</van-cell-group>
|
|
|
</van-checkbox-group>
|
|
|
</div>
|
|
@@ -78,7 +85,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts">
|
|
|
-import { onBeforeMount } from "vue";
|
|
|
+import { onBeforeMount, computed } from "vue";
|
|
|
import { getQuestionInfoByIds, CollectionAndWrong } from "@/api";
|
|
|
|
|
|
/**
|
|
@@ -87,7 +94,8 @@ import { getQuestionInfoByIds, CollectionAndWrong } from "@/api";
|
|
|
const useQuestionList = (type: CollectionAndWrongType.type) => {
|
|
|
const QuestionApi = new CollectionAndWrong(type);
|
|
|
const questionList = ref<Test.QuestionInfo[]>([]);
|
|
|
- const collectionList = ref<CollectionAndWrongType.ListRes[]>([]);
|
|
|
+ const collectionList = ref<CollectionAndWrongType.QuestionRes[]>([]);
|
|
|
+ const total = ref(0);
|
|
|
const pageNum = ref(0);
|
|
|
const pageSize = ref(10);
|
|
|
/**
|
|
@@ -112,25 +120,31 @@ const useQuestionList = (type: CollectionAndWrongType.type) => {
|
|
|
pageNum: pageNum.value,
|
|
|
pageSize: pageSize.value,
|
|
|
});
|
|
|
- collectionList.value = collectionListRes;
|
|
|
- const ids = collectionListRes.map((item) => item.questionId);
|
|
|
+ collectionList.value = collectionListRes.rows;
|
|
|
+ total.value = collectionListRes.total;
|
|
|
+ const ids = collectionListRes.rows.map((item) => item.questionId);
|
|
|
const questions = await getQuestionInfoByIds({
|
|
|
ids,
|
|
|
});
|
|
|
questionList.value = questions.rows;
|
|
|
};
|
|
|
+
|
|
|
+ const finished = computed(() => {
|
|
|
+ return questionList.value.length === total.value;
|
|
|
+ });
|
|
|
onBeforeMount(() => {
|
|
|
setData();
|
|
|
});
|
|
|
return {
|
|
|
questionList,
|
|
|
deletes,
|
|
|
+ finished,
|
|
|
};
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { nextTick, ref, watch, computed } from "vue";
|
|
|
+import { nextTick, ref, watch } from "vue";
|
|
|
import { useRouter } from "vue-router";
|
|
|
const router = useRouter();
|
|
|
const onClickLeft = () => {
|
|
@@ -152,6 +166,11 @@ const list = computed(() => {
|
|
|
return currentView.value.questionList.value;
|
|
|
});
|
|
|
|
|
|
+//是否全部加载完成
|
|
|
+const finished = computed(() => {
|
|
|
+ return currentView.value.finished.value;
|
|
|
+});
|
|
|
+
|
|
|
const isChoose = ref(false); //开启批量选中
|
|
|
const isSelectAll = ref(false); //是否全选
|
|
|
const checked = ref([]); //选中内容
|
|
@@ -186,11 +205,13 @@ const unSelectAll = () => {
|
|
|
const deleteClick = (id: number) => {
|
|
|
currentView.value.deletes([id]);
|
|
|
};
|
|
|
-//单个收藏
|
|
|
//批量删除
|
|
|
const deletesClick = () => {
|
|
|
currentView.value.deletes(checked.value);
|
|
|
};
|
|
|
+
|
|
|
+//单个收藏
|
|
|
+
|
|
|
//批量收藏
|
|
|
</script>
|
|
|
|