-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: optimize ui async code, qeury data and loading ui
- Loading branch information
Showing
6 changed files
with
112 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/renderer/views/student-department/student/components/Row.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<template> | ||
<tr | ||
ref="endOftable" | ||
class="hover:!bg-secondary-100 cursor-pointer" | ||
@click="handleRowClick" | ||
> | ||
<td>{{ student.id }}</td> | ||
<td>{{ student.name }}</td> | ||
<td>{{ resolveGender(student.gender) }}</td> | ||
<td>{{ student.major.name }}</td> | ||
<td>{{ student.priority.name }}</td> | ||
</tr> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { ref, defineProps, defineEmits, onMounted } from 'vue'; | ||
import type { Student } from '../stores/student'; | ||
import { useStudentStore } from '../stores/student'; | ||
const studentStore = useStudentStore(); | ||
const props = defineProps({ | ||
student: Object as () => Student, | ||
isLast: Boolean, | ||
}); | ||
const endOftable = ref(null); | ||
const emit = defineEmits(['row-click']); | ||
const handleRowClick = () => { | ||
emit('row-click', props.student); | ||
}; | ||
const resolveGender = (gender: string) => { | ||
return gender === 'male' ? 'Nam' : 'Nữ'; | ||
}; | ||
onMounted(() => { | ||
const observer = new IntersectionObserver((entries) => { | ||
if (entries[0].isIntersecting && props.isLast) { | ||
studentStore.page++; | ||
studentStore.fetchStudents(studentStore.search.query, false); | ||
observer.unobserve(entries[0].target); | ||
} | ||
}); | ||
observer.observe(endOftable.value); | ||
}); | ||
</script> | ||
|
||
<style scoped></style> |
30 changes: 30 additions & 0 deletions
30
src/renderer/views/student-department/student/components/SkeletonTable.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<script lang="ts" setup> | ||
import Row from './Row.vue'; | ||
</script> | ||
|
||
<template> | ||
<div class="overflow-x-auto w-full h-[calc(100vh-300px)]"> | ||
<table class="table table-pin-rows table-zebra"> | ||
<thead> | ||
<tr> | ||
<th>MSSV</th> | ||
<th>Họ và tên</th> | ||
<th>Giới tính</th> | ||
<th>Chuyên ngành</th> | ||
<th>Đối tượng ưu tiên</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr v-for="index in new Array(12).fill(0)" class="skeleton"> | ||
<td></td> | ||
<td></td> | ||
<td></td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</template> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters