From bf666f9408e88aa2a552d7979d627857c870d9b6 Mon Sep 17 00:00:00 2001
From: ZhangXianQiang <1135831638@qq.com>
Date: 星期四, 04 七月 2024 15:35:23 +0800
Subject: [PATCH] feat:数据持久化

---
 src/views/grade-list/index.vue |   43 ++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/src/views/grade-list/index.vue b/src/views/grade-list/index.vue
index ef07006..5ea8724 100644
--- a/src/views/grade-list/index.vue
+++ b/src/views/grade-list/index.vue
@@ -16,19 +16,24 @@
                 </div>
                 <div class="header-search flex items-center">
                   <el-input v-model="searchText" placeholder="璇疯緭鍏ヨ�冭瘯鍚嶇О" :prefix-icon="Search" />
-                  <el-button type="primary" class="ml-4">鎼滅储</el-button>
+                  <el-button type="primary" class="ml-4" @click="searchData">鎼滅储</el-button>
                 </div>
 
               </div>
 
               <div class="card-main flex-1 my-5 relative">
-                <div class="main-content absolute top-0 bottom-0 left-0 right-0">
-                  <DataList></DataList>
+                <div class="main-content absolute top-0 bottom-0 left-0 right-0" v-loading="loading">
+                  <DataList :dataList="dataList"></DataList>
                 </div>
               </div>
 
               <div class="card-footer flex justify-center mb-7 shrink-0">
-                <el-pagination background layout="prev, pager, next" :total="1000" />
+                <el-pagination background layout="prev, pager, next" 
+                :total="dataList.length" 
+                :default-page-size="currentSize"
+                :currentPage="currentIndex"
+                :hide-on-single-page="true"
+                @current-change="handleCurrentChange" />
               </div>
             </div>
           </el-card>
@@ -43,8 +48,37 @@
 import NormalHeader from '@/components/NormalHeader/index.vue';
 import DataList from './data-list/index.vue';
 import { Search } from '@element-plus/icons-vue';
+import { getGradeList } from '@/api/modules/grade.js';
+
 const activeName = ref('1');
 const searchText = ref('');
+const loading = ref(false);
+
+const dataList = ref([]);
+
+const currentIndex = ref(1);
+const currentSize = ref(10);
+
+const getData = () => {
+  loading.value = true;
+  getGradeList({examName: searchText.value, pageIndex: currentIndex.value, pageSize: currentSize.value}).then(res => {
+    dataList.value = res.data.list;
+    loading.value = false;
+  }).catch(err => {
+    loading.value = false;
+  });
+};
+
+getData();
+
+const handleCurrentChange = () => {
+  getData();
+}
+
+const searchData = () => {
+  getData();
+}
+
 const handleClick = (tab, event) => {
 };
 </script>
@@ -53,5 +87,4 @@
 :deep(.el-tabs__nav-wrap:after) {
   display: none;
 }
-
 </style>
\ No newline at end of file

--
Gitblit v1.8.0