diff --git a/src/renderer/views/student-department/student/Student.vue b/src/renderer/views/student-department/student/Student.vue index fa9245a..fa2627f 100644 --- a/src/renderer/views/student-department/student/Student.vue +++ b/src/renderer/views/student-department/student/Student.vue @@ -2,13 +2,19 @@ import Table from './components/Table.vue'; import FunctionBar from './components/FunctionBar.vue'; import EditModal from './components/EditModal.vue'; +import SkeletonTable from './components/SkeletonTable.vue'; import { Suspense } from 'vue'; - + + + + + + diff --git a/src/renderer/views/student-department/student/components/FunctionBar.vue b/src/renderer/views/student-department/student/components/FunctionBar.vue index 506b4f8..e131d68 100644 --- a/src/renderer/views/student-department/student/components/FunctionBar.vue +++ b/src/renderer/views/student-department/student/components/FunctionBar.vue @@ -12,9 +12,9 @@ class="bg-base-silver pl-4 rounded-l" /> @@ -37,19 +37,18 @@ function debounce(fn, delay) { }; } -const searchQuery = ref(studentStore.search.query); - const debouncedSearch = debounce(async (query) => { - await studentStore.fetchStudents(query); + await studentStore.fetchStudents(query, true); }, 500); watchEffect(() => { - debouncedSearch(searchQuery.value); + debouncedSearch(studentStore.search.query); + console.log(studentStore.search.query); }); watch( () => studentStore.search.typeQuery, () => { - searchQuery.value = ''; + studentStore.search.query = ''; } ); diff --git a/src/renderer/views/student-department/student/components/Row.vue b/src/renderer/views/student-department/student/components/Row.vue new file mode 100644 index 0000000..9278fc7 --- /dev/null +++ b/src/renderer/views/student-department/student/components/Row.vue @@ -0,0 +1,47 @@ + + + {{ student.id }} + {{ student.name }} + {{ resolveGender(student.gender) }} + {{ student.major.name }} + {{ student.priority.name }} + + + + + + diff --git a/src/renderer/views/student-department/student/components/SkeletonTable.vue b/src/renderer/views/student-department/student/components/SkeletonTable.vue new file mode 100644 index 0000000..5948a0b --- /dev/null +++ b/src/renderer/views/student-department/student/components/SkeletonTable.vue @@ -0,0 +1,30 @@ + + + + + + + + MSSV + Họ và tên + Giới tính + Chuyên ngành + Đối tượng ưu tiên + + + + + + + + + + + + + + + + diff --git a/src/renderer/views/student-department/student/components/Table.vue b/src/renderer/views/student-department/student/components/Table.vue index f8656c9..f831e12 100644 --- a/src/renderer/views/student-department/student/components/Table.vue +++ b/src/renderer/views/student-department/student/components/Table.vue @@ -1,6 +1,6 @@ - + MSSV @@ -11,18 +11,14 @@ - handleRowClick(student)" + :isLast="index === studentStore.students.length - 1" + :student="student" + @click="handleRowClick" > - {{ student.id }} - {{ student.name }} - {{ resolveGender(student.gender) }} - {{ student.major.name }} - {{ student.priority.name }} - + @@ -30,6 +26,7 @@ diff --git a/src/renderer/views/student-department/student/stores/student.ts b/src/renderer/views/student-department/student/stores/student.ts index 3c2bbe4..3b43fd6 100644 --- a/src/renderer/views/student-department/student/stores/student.ts +++ b/src/renderer/views/student-department/student/stores/student.ts @@ -65,6 +65,7 @@ export const useStudentStore = defineStore('student', { provinces: [] as Province[], districts: [] as District[], majors: [] as Major[], + page: 1, errorMessages: {} as Record, search: { query: '', @@ -75,12 +76,22 @@ export const useStudentStore = defineStore('student', { getErrorMessages() { return this.errorMessages; }, + getQuery() { + return this.search.query; + }, }, actions: { - async fetchStudents(queryString: string) { + async fetchStudents(queryString: string, isSeach = false) { const query = `?${this.search.typeQuery}=${queryString}`; - const response = await axiosClient.get(`/student${query}`); - this.students = response.data; + if (isSeach) { + this.page = 1; + this.students = []; + } + const response = await axiosClient.get( + `/student${query}&page=${this.page}` + ); + + this.students.push(...response.data); }, async getPriorities() { @@ -103,9 +114,7 @@ export const useStudentStore = defineStore('student', { const response = await axiosClient.get( `/province/district/${provinceId}` ); - this.districts = response.data; - console.log(this.districts); }, async updateStudent(student: Partial) { try {