Handle loading table data
This commit is contained in:
1 parent
24d4f2e577
commit
148c5b267d
1 file changed
+5
-2
+5
-2
@@ -2,6 +2,8 @@
|
|||||||
import { computed, ref, watch } from "vue"
|
import { computed, ref, watch } from "vue"
|
||||||
import { GET_AUDIO_FILE, GET_FILE } from "@/utils/file"
|
import { GET_AUDIO_FILE, GET_FILE } from "@/utils/file"
|
||||||
|
|
||||||
|
defineOptions({ inheritAttrs: false })
|
||||||
|
|
||||||
export type Row = {
|
export type Row = {
|
||||||
name: string
|
name: string
|
||||||
class?: string
|
class?: string
|
||||||
@@ -26,10 +28,11 @@ const props = withDefaults(defineProps<TableProps>(), {
|
|||||||
|
|
||||||
const currentPage = ref(1)
|
const currentPage = ref(1)
|
||||||
const query = ref("")
|
const query = ref("")
|
||||||
|
const data = computed(() => (Array.isArray(props.data) ? props.data : []))
|
||||||
const pageSize = computed(() => Math.max(1, Math.floor(props.pageSize)))
|
const pageSize = computed(() => Math.max(1, Math.floor(props.pageSize)))
|
||||||
const filteredData = computed(() => {
|
const filteredData = computed(() => {
|
||||||
const normalizedQuery = query.value.trim().toLocaleLowerCase()
|
const normalizedQuery = query.value.trim().toLocaleLowerCase()
|
||||||
const indexedData = props.data.map((item: any, index: number) => ({
|
const indexedData = data.value.map((item: any, index: number) => ({
|
||||||
item,
|
item,
|
||||||
index,
|
index,
|
||||||
}))
|
}))
|
||||||
@@ -71,7 +74,7 @@ watch(pageCount, (count) => {
|
|||||||
placeholder="Search table"
|
placeholder="Search table"
|
||||||
class="table-search"
|
class="table-search"
|
||||||
/>
|
/>
|
||||||
<table class="table">
|
<table v-bind="$attrs" class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th
|
<th
|
||||||
|
|||||||
Reference in new issue
Block a user