@finema/core 2.10.1 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/components/Table/index.vue +112 -100
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,116 +1,116 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<div
|
|
4
|
-
v-if="options.isEnabledSearch"
|
|
2
|
+
<div ref="tableContainer">
|
|
3
|
+
<div
|
|
4
|
+
v-if="options.isEnabledSearch"
|
|
5
5
|
:class="theme.searchContainer({
|
|
6
6
|
class: [ui?.searchContainer]
|
|
7
|
-
})"
|
|
8
|
-
>
|
|
9
|
-
<Input
|
|
10
|
-
v-model="q"
|
|
11
|
-
icon="i-heroicons-magnifying-glass"
|
|
12
|
-
:placeholder="options.searchPlaceholder || '\u0E04\u0E49\u0E19\u0E2B\u0E32....'"
|
|
13
|
-
/>
|
|
14
|
-
</div>
|
|
15
|
-
<div
|
|
16
|
-
v-if="!options.isHideCaption || !options.isHideBottomPagination"
|
|
7
|
+
})"
|
|
8
|
+
>
|
|
9
|
+
<Input
|
|
10
|
+
v-model="q"
|
|
11
|
+
icon="i-heroicons-magnifying-glass"
|
|
12
|
+
:placeholder="options.searchPlaceholder || '\u0E04\u0E49\u0E19\u0E2B\u0E32....'"
|
|
13
|
+
/>
|
|
14
|
+
</div>
|
|
15
|
+
<div
|
|
16
|
+
v-if="!options.isHideCaption || !options.isHideBottomPagination"
|
|
17
17
|
:class="theme.captionContainer({
|
|
18
18
|
class: [ui?.captionContainer]
|
|
19
|
-
})"
|
|
20
|
-
>
|
|
21
|
-
<span
|
|
19
|
+
})"
|
|
20
|
+
>
|
|
21
|
+
<span
|
|
22
22
|
:class="theme.captionBoldText({
|
|
23
23
|
class: [ui?.captionBoldText]
|
|
24
|
-
})"
|
|
25
|
-
>
|
|
26
|
-
ผลลัพธ์ทั้งหมด:</span>
|
|
27
|
-
จำนวน
|
|
28
|
-
<span
|
|
24
|
+
})"
|
|
25
|
+
>
|
|
26
|
+
ผลลัพธ์ทั้งหมด:</span>
|
|
27
|
+
จำนวน
|
|
28
|
+
<span
|
|
29
29
|
:class="theme.captionBoldText({
|
|
30
30
|
class: [ui?.captionBoldText]
|
|
31
|
-
})"
|
|
32
|
-
>{{ options.pageOptions?.totalCount || 0 }}</span>
|
|
33
|
-
รายการ
|
|
34
|
-
</div>
|
|
35
|
-
|
|
36
|
-
<UTable
|
|
37
|
-
v-bind="$attrs"
|
|
38
|
-
:loading="options.status.isLoading"
|
|
39
|
-
:data="options.rawData"
|
|
40
|
-
:columns="options.columns"
|
|
41
|
-
>
|
|
42
|
-
<template #empty>
|
|
43
|
-
<slot
|
|
44
|
-
v-if="options.status.isLoading"
|
|
45
|
-
name="loading"
|
|
46
|
-
>
|
|
47
|
-
<Loader
|
|
48
|
-
:loading="true"
|
|
49
|
-
/>
|
|
50
|
-
</slot>
|
|
51
|
-
<slot
|
|
52
|
-
v-else-if="options.status.isError"
|
|
53
|
-
name="error"
|
|
54
|
-
>
|
|
55
|
-
<div
|
|
56
|
-
class="flex h-[200px] items-center justify-center text-2xl text-error-400"
|
|
57
|
-
>
|
|
58
|
-
{{ StringHelper.getError(options.status.errorData) }}
|
|
59
|
-
</div>
|
|
60
|
-
</slot>
|
|
61
|
-
|
|
62
|
-
<slot
|
|
63
|
-
v-else
|
|
64
|
-
name="error"
|
|
65
|
-
>
|
|
66
|
-
<Empty />
|
|
67
|
-
</slot>
|
|
68
|
-
</template>
|
|
69
|
-
<template
|
|
70
|
-
v-for="column in options.columns.filter((item) => !!item.type)"
|
|
71
|
-
#[`${column.accessorKey}-cell`]="{ row }"
|
|
72
|
-
:key="column.accessorKey"
|
|
73
|
-
>
|
|
74
|
-
<component
|
|
75
|
-
:is="column.type === COLUMN_TYPES.COMPONENT ? column.component : columnTypeComponents[column.type]"
|
|
76
|
-
v-if="column.type === COLUMN_TYPES.COMPONENT || columnTypeComponents[column.type]"
|
|
77
|
-
:value="transformValue(column, row)"
|
|
78
|
-
:column="column"
|
|
79
|
-
:row="row"
|
|
80
|
-
/>
|
|
81
|
-
</template>
|
|
82
|
-
<template
|
|
83
|
-
v-for="(_, slotName) of $slots"
|
|
84
|
-
#[slotName]="slotProps"
|
|
85
|
-
>
|
|
86
|
-
<slot
|
|
87
|
-
:name="slotName"
|
|
88
|
-
v-bind="slotProps || {}"
|
|
89
|
-
/>
|
|
90
|
-
</template>
|
|
91
|
-
</UTable>
|
|
92
|
-
|
|
93
|
-
<div
|
|
31
|
+
})"
|
|
32
|
+
>{{ options.pageOptions?.totalCount || 0 }}</span>
|
|
33
|
+
รายการ
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<UTable
|
|
37
|
+
v-bind="$attrs"
|
|
38
|
+
:loading="options.status.isLoading"
|
|
39
|
+
:data="options.rawData"
|
|
40
|
+
:columns="options.columns"
|
|
41
|
+
>
|
|
42
|
+
<template #empty>
|
|
43
|
+
<slot
|
|
44
|
+
v-if="options.status.isLoading"
|
|
45
|
+
name="loading"
|
|
46
|
+
>
|
|
47
|
+
<Loader
|
|
48
|
+
:loading="true"
|
|
49
|
+
/>
|
|
50
|
+
</slot>
|
|
51
|
+
<slot
|
|
52
|
+
v-else-if="options.status.isError"
|
|
53
|
+
name="error"
|
|
54
|
+
>
|
|
55
|
+
<div
|
|
56
|
+
class="flex h-[200px] items-center justify-center text-2xl text-error-400"
|
|
57
|
+
>
|
|
58
|
+
{{ StringHelper.getError(options.status.errorData) }}
|
|
59
|
+
</div>
|
|
60
|
+
</slot>
|
|
61
|
+
|
|
62
|
+
<slot
|
|
63
|
+
v-else
|
|
64
|
+
name="error"
|
|
65
|
+
>
|
|
66
|
+
<Empty />
|
|
67
|
+
</slot>
|
|
68
|
+
</template>
|
|
69
|
+
<template
|
|
70
|
+
v-for="column in options.columns.filter((item) => !!item.type)"
|
|
71
|
+
#[`${column.accessorKey}-cell`]="{ row }"
|
|
72
|
+
:key="column.accessorKey"
|
|
73
|
+
>
|
|
74
|
+
<component
|
|
75
|
+
:is="column.type === COLUMN_TYPES.COMPONENT ? column.component : columnTypeComponents[column.type]"
|
|
76
|
+
v-if="column.type === COLUMN_TYPES.COMPONENT || columnTypeComponents[column.type]"
|
|
77
|
+
:value="transformValue(column, row)"
|
|
78
|
+
:column="column"
|
|
79
|
+
:row="row"
|
|
80
|
+
/>
|
|
81
|
+
</template>
|
|
82
|
+
<template
|
|
83
|
+
v-for="(_, slotName) of $slots"
|
|
84
|
+
#[slotName]="slotProps"
|
|
85
|
+
>
|
|
86
|
+
<slot
|
|
87
|
+
:name="slotName"
|
|
88
|
+
v-bind="slotProps || {}"
|
|
89
|
+
/>
|
|
90
|
+
</template>
|
|
91
|
+
</UTable>
|
|
92
|
+
|
|
93
|
+
<div
|
|
94
94
|
:class="theme.paginationContainer({
|
|
95
95
|
class: [ui?.paginationContainer]
|
|
96
|
-
})"
|
|
97
|
-
>
|
|
98
|
-
<p
|
|
96
|
+
})"
|
|
97
|
+
>
|
|
98
|
+
<p
|
|
99
99
|
:class="theme.paginationInfo({
|
|
100
100
|
class: [ui?.paginationInfo]
|
|
101
|
-
})"
|
|
102
|
-
>
|
|
103
|
-
ผลลัพธ์ {{ pageBetween }} ของ {{ totalCountWithComma }} รายการ
|
|
104
|
-
</p>
|
|
105
|
-
<Pagination
|
|
106
|
-
v-model:page="page"
|
|
107
|
-
:default-page="options.pageOptions?.currentPage || 1"
|
|
108
|
-
:items-per-page="options.pageOptions.limit"
|
|
109
|
-
:total="options.pageOptions.totalCount"
|
|
110
|
-
@update:page="
|
|
111
|
-
/>
|
|
112
|
-
</div>
|
|
113
|
-
</div>
|
|
101
|
+
})"
|
|
102
|
+
>
|
|
103
|
+
ผลลัพธ์ {{ pageBetween }} ของ {{ totalCountWithComma }} รายการ
|
|
104
|
+
</p>
|
|
105
|
+
<Pagination
|
|
106
|
+
v-model:page="page"
|
|
107
|
+
:default-page="options.pageOptions?.currentPage || 1"
|
|
108
|
+
:items-per-page="options.pageOptions.limit"
|
|
109
|
+
:total="options.pageOptions.totalCount"
|
|
110
|
+
@update:page="onPageChange"
|
|
111
|
+
/>
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
114
|
</template>
|
|
115
115
|
|
|
116
116
|
<script setup>
|
|
@@ -139,6 +139,7 @@ const props = defineProps({
|
|
|
139
139
|
ui: { type: null, required: false }
|
|
140
140
|
});
|
|
141
141
|
const page = ref(props.options?.pageOptions?.currentPage || 1);
|
|
142
|
+
const tableContainer = ref();
|
|
142
143
|
const theme = computed(() => useUiConfig(tableTheme, "table")());
|
|
143
144
|
const q = ref(props.options?.pageOptions.search ?? "");
|
|
144
145
|
watch(
|
|
@@ -177,4 +178,15 @@ const transformValue = (column, row) => {
|
|
|
177
178
|
row
|
|
178
179
|
}) : row.getValue(column.accessorKey);
|
|
179
180
|
};
|
|
181
|
+
const onPageChange = (newPage) => {
|
|
182
|
+
if (tableContainer.value) {
|
|
183
|
+
const rect = tableContainer.value.getBoundingClientRect();
|
|
184
|
+
const scrollTop = window.pageYOffset + rect.top - 100;
|
|
185
|
+
window.scrollTo({
|
|
186
|
+
top: scrollTop,
|
|
187
|
+
behavior: "smooth"
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
emits("pageChange", newPage);
|
|
191
|
+
};
|
|
180
192
|
</script>
|