@finema/core 1.4.194 → 1.4.195
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
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -5,13 +5,7 @@
|
|
|
5
5
|
<span class="font-bold">{{ pageOptions?.totalCount || 0 }}</span>
|
|
6
6
|
รายการ
|
|
7
7
|
</div>
|
|
8
|
-
<UTable
|
|
9
|
-
:loading="status.isLoading"
|
|
10
|
-
:columns="columns"
|
|
11
|
-
:rows="rawData"
|
|
12
|
-
:progress="null as unknown as any"
|
|
13
|
-
v-bind="$attrs"
|
|
14
|
-
>
|
|
8
|
+
<UTable :loading="status.isLoading" :columns="columns" :rows="rawData" v-bind="$attrs">
|
|
15
9
|
<template #loading-state>
|
|
16
10
|
<div class="flex h-60 items-center justify-center">
|
|
17
11
|
<Icon name="i-svg-spinners:180-ring-with-bg" class="text-primary size-8" />
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="!isHideCaption || !isHideBottomPagination" class="mb-4 text-gray-500">
|
|
3
|
+
<span class="font-bold">ผลลัพธ์ทั้งหมด:</span>
|
|
4
|
+
จำนวน
|
|
5
|
+
<span class="font-bold">{{ pageOptions?.totalCount || 0 }}</span>
|
|
6
|
+
รายการ
|
|
7
|
+
</div>
|
|
8
|
+
<UTable
|
|
9
|
+
:loading="status.isLoading"
|
|
10
|
+
:columns="columns"
|
|
11
|
+
:rows="rawData"
|
|
12
|
+
v-bind="$attrs"
|
|
13
|
+
>
|
|
14
|
+
<template #loading-state>
|
|
15
|
+
<div class="flex h-60 items-center justify-center">
|
|
16
|
+
<Icon name="i-svg-spinners:180-ring-with-bg" class="text-primary size-8" />
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
<template #empty-state>
|
|
20
|
+
<div class="flex flex-col items-center justify-center gap-3 py-6">
|
|
21
|
+
<span class="text-sm italic">ไม่พบข้อมูล!</span>
|
|
22
|
+
</div>
|
|
23
|
+
</template>
|
|
24
|
+
<template v-for="column in columns" #[`${column.key}-data`]="{ row }" :key="column.key">
|
|
25
|
+
<ColumnNumber
|
|
26
|
+
v-if="column.type === COLUMN_TYPES.NUMBER"
|
|
27
|
+
:value="transformValue(column, row)"
|
|
28
|
+
:column="column"
|
|
29
|
+
:class="column.class"
|
|
30
|
+
:row="row"
|
|
31
|
+
/>
|
|
32
|
+
<ColumnImage
|
|
33
|
+
v-else-if="column.type === COLUMN_TYPES.IMAGE"
|
|
34
|
+
:value="transformValue(column, row)"
|
|
35
|
+
:column="column"
|
|
36
|
+
:class="column.class"
|
|
37
|
+
:row="row"
|
|
38
|
+
/>
|
|
39
|
+
<ColumnDateTime
|
|
40
|
+
v-else-if="column.type === COLUMN_TYPES.DATE_TIME"
|
|
41
|
+
:value="transformValue(column, row)"
|
|
42
|
+
:column="column"
|
|
43
|
+
:class="column.class"
|
|
44
|
+
:row="row"
|
|
45
|
+
/>
|
|
46
|
+
<ColumnDate
|
|
47
|
+
v-else-if="column.type === COLUMN_TYPES.DATE"
|
|
48
|
+
:value="transformValue(column, row)"
|
|
49
|
+
:column="column"
|
|
50
|
+
:class="column.class"
|
|
51
|
+
:row="row"
|
|
52
|
+
/>
|
|
53
|
+
<component
|
|
54
|
+
:is="column.component"
|
|
55
|
+
v-else-if="column.type === COLUMN_TYPES.COMPONENT"
|
|
56
|
+
:value="transformValue(column, row)"
|
|
57
|
+
:column="column"
|
|
58
|
+
:class="column.class"
|
|
59
|
+
:row="row"
|
|
60
|
+
/>
|
|
61
|
+
<ColumnText v-else :value="transformValue(column, row)" :column="column" :row="row" />
|
|
62
|
+
</template>
|
|
63
|
+
|
|
64
|
+
<template v-for="(_, slot) of $slots" #[slot]="scope">
|
|
65
|
+
<slot :name="slot" v-bind="scope" />
|
|
66
|
+
</template>
|
|
67
|
+
</UTable>
|
|
68
|
+
<div v-if="pageOptions" class="mt-4 flex justify-between px-3">
|
|
69
|
+
<p class="text-xs text-gray-500">
|
|
70
|
+
ผลลัพธ์ {{ pageBetween }} ของ {{ totalCountWithComma }} รายการ
|
|
71
|
+
</p>
|
|
72
|
+
<UPagination
|
|
73
|
+
v-if="pageOptions.totalPage > 1 && !isSimplePagination && !isHideBottomPagination"
|
|
74
|
+
v-model="page"
|
|
75
|
+
:page-count="pageOptions.limit"
|
|
76
|
+
:total="pageOptions.totalCount"
|
|
77
|
+
/>
|
|
78
|
+
<SimplePagination
|
|
79
|
+
v-if="pageOptions.totalPage > 1 && isSimplePagination"
|
|
80
|
+
v-model="page"
|
|
81
|
+
:page-count="pageOptions.limit"
|
|
82
|
+
:total="pageOptions.totalCount"
|
|
83
|
+
/>
|
|
84
|
+
</div>
|
|
85
|
+
</template>
|
|
86
|
+
|
|
87
|
+
<script lang="ts" setup>
|
|
88
|
+
import { COLUMN_TYPES, type IColumn, type ITableOptions } from '#core/components/Table/types'
|
|
89
|
+
import ColumnNumber from '#core/components/Table/ColumnNumber.vue'
|
|
90
|
+
import ColumnImage from '#core/components/Table/ColumnImage.vue'
|
|
91
|
+
import { computed, type PropType } from 'vue'
|
|
92
|
+
import { StringHelper } from '#core/utils/StringHelper'
|
|
93
|
+
import { ref, watch } from '#imports'
|
|
94
|
+
import ColumnDateTime from '#core/components/Table/ColumnDateTime.vue'
|
|
95
|
+
import ColumnDate from '#core/components/Table/ColumnDate.vue'
|
|
96
|
+
import ColumnText from '#core/components/Table/ColumnText.vue'
|
|
97
|
+
|
|
98
|
+
const emits = defineEmits(['pageChange'])
|
|
99
|
+
|
|
100
|
+
const props = defineProps({
|
|
101
|
+
status: {
|
|
102
|
+
type: Object as PropType<ITableOptions['status']>,
|
|
103
|
+
required: true,
|
|
104
|
+
},
|
|
105
|
+
pageOptions: {
|
|
106
|
+
type: Object as PropType<ITableOptions['pageOptions']>,
|
|
107
|
+
required: false,
|
|
108
|
+
},
|
|
109
|
+
columns: {
|
|
110
|
+
type: Array as PropType<ITableOptions['columns']>,
|
|
111
|
+
required: true,
|
|
112
|
+
},
|
|
113
|
+
rawData: {
|
|
114
|
+
type: Array as PropType<ITableOptions['rawData']>,
|
|
115
|
+
required: true,
|
|
116
|
+
},
|
|
117
|
+
isSimplePagination: {
|
|
118
|
+
type: Boolean as PropType<ITableOptions['isSimplePagination']>,
|
|
119
|
+
default: false,
|
|
120
|
+
},
|
|
121
|
+
isHideBottomPagination: {
|
|
122
|
+
type: Boolean as PropType<ITableOptions['isHideBottomPagination']>,
|
|
123
|
+
default: false,
|
|
124
|
+
},
|
|
125
|
+
isHideCaption: {
|
|
126
|
+
type: Boolean as PropType<ITableOptions['isHideCaption']>,
|
|
127
|
+
default: false,
|
|
128
|
+
},
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
const page = ref(props.pageOptions?.currentPage || 1)
|
|
132
|
+
|
|
133
|
+
const pageBetween = computed((): string => {
|
|
134
|
+
const length = props.rawData?.length
|
|
135
|
+
|
|
136
|
+
if (length === 0) {
|
|
137
|
+
return '0'
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const start = (props.pageOptions!.currentPage - 1) * props.pageOptions!.limit + 1
|
|
141
|
+
const end = start + length - 1
|
|
142
|
+
|
|
143
|
+
return `${start} - ${end}`
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
const transformValue = (column: IColumn, row: any) => {
|
|
147
|
+
return column.transform ? column.transform(row[column.key], row, column) : row[column.key]
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const totalCountWithComma = computed((): string => {
|
|
151
|
+
return !props.pageOptions!.totalCount
|
|
152
|
+
? '0'
|
|
153
|
+
: StringHelper.withComma(props.pageOptions!.totalCount)
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
watch(page, () => {
|
|
157
|
+
emits('pageChange', page.value)
|
|
158
|
+
})
|
|
159
|
+
</script>
|