This commit is contained in:
ivamp 2023-12-06 23:24:54 +08:00
parent 9b4cc54a50
commit dbc35063bb
2 changed files with 54 additions and 32 deletions

View File

@ -3,7 +3,7 @@
class="d-flex text-center" class="d-flex text-center"
style=" style="
width: 100%; width: 100%;
height: 100%; height: 50%;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
" "

View File

@ -1,13 +1,14 @@
<template> <template>
<LoadingComponent v-if="loading"> <LoadingComponent v-if="loading"> </LoadingComponent>
</LoadingComponent>
<v-container v-else> <v-container v-else>
<h1>资料库</h1> <h1>资料库</h1>
<div>
{{ selected_ids }} {{ selected_ids }}
</div>
<v-card> <v-btn @click="selectAll">全选</v-btn>
<v-card class="mt-3">
<v-list> <v-list>
<v-list-item <v-list-item
v-for="item in libraries.Data" v-for="item in libraries.Data"
@ -36,6 +37,9 @@
</v-list> </v-list>
</v-card> </v-card>
</v-container>
<div class="text-center"> <div class="text-center">
<v-container> <v-container>
<v-row justify="center"> <v-row justify="center">
@ -45,6 +49,8 @@
v-model="page" v-model="page"
class="my-4" class="my-4"
:length="libraries.Total" :length="libraries.Total"
:disabled="loading"
@update:model-value="load"
></v-pagination> ></v-pagination>
</v-container> </v-container>
</v-col> </v-col>
@ -52,8 +58,6 @@
</v-container> </v-container>
</div> </div>
</v-container>
</template> </template>
@ -62,19 +66,22 @@ import { library } from "@/plugins/api";
import { ref } from "vue"; import { ref } from "vue";
import LoadingComponent from "@/components/Loading.vue"; import LoadingComponent from "@/components/Loading.vue";
const loading = ref(false) const loading = ref(false);
const page = ref(1); const page = ref(1);
const libraries = ref({}); const libraries = ref({});
const load = () => { const load = () => {
loading.value = true loading.value = true;
library.librariesGet(page.value).then((r) => { library
.librariesGet(page.value)
.then((r) => {
libraries.value = r.data; libraries.value = r.data;
console.log(r.data.Data); console.log(r.data.Data);
}).finally(() => {
loading.value = false
}) })
.finally(() => {
loading.value = false;
});
}; };
load(); load();
@ -85,7 +92,6 @@ const goto = (libraryId) => {
const selected_ids = ref([]); const selected_ids = ref([]);
function isSelected(id) { function isSelected(id) {
return this.selected_ids.includes(id); return this.selected_ids.includes(id);
} }
@ -100,4 +106,20 @@ function toggleSelection(id) {
this.selected_ids.push(id); this.selected_ids.push(id);
} }
} }
/**
* Selects all items if none are selected, otherwise clears the selection.
*
* @return {void}
*/
function selectAll() {
if (selected_ids.value.length > 0) {
selected_ids.value = [];
} else {
const data = libraries.value.Data;
if (data.length > 0) {
data.forEach((item) => selected_ids.value.push(item.ID));
}
}
}
</script> </script>