@ramathibodi/nuxt-commons 0.1.14 → 0.1.15
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/README.md +96 -96
- package/dist/module.json +1 -1
- package/dist/runtime/components/Alert.vue +53 -53
- package/dist/runtime/components/BarcodeReader.vue +98 -98
- package/dist/runtime/components/ExportCSV.vue +55 -55
- package/dist/runtime/components/FileBtn.vue +62 -62
- package/dist/runtime/components/ImportCSV.vue +64 -64
- package/dist/runtime/components/SplitterPanel.vue +59 -59
- package/dist/runtime/components/TabsGroup.vue +32 -32
- package/dist/runtime/components/TextBarcode.vue +52 -52
- package/dist/runtime/components/dialog/Confirm.vue +100 -100
- package/dist/runtime/components/dialog/Index.vue +72 -72
- package/dist/runtime/components/dialog/Loading.vue +39 -39
- package/dist/runtime/components/document/TemplateBuilder.vue +203 -216
- package/dist/runtime/components/form/Birthdate.vue +216 -216
- package/dist/runtime/components/form/CodeEditor.vue +37 -37
- package/dist/runtime/components/form/Date.vue +163 -163
- package/dist/runtime/components/form/DateTime.vue +107 -107
- package/dist/runtime/components/form/Dialog.vue +138 -138
- package/dist/runtime/components/form/File.vue +187 -187
- package/dist/runtime/components/form/Hidden.vue +32 -32
- package/dist/runtime/components/form/Login.vue +131 -131
- package/dist/runtime/components/form/Pad.vue +217 -217
- package/dist/runtime/components/form/SignPad.vue +186 -186
- package/dist/runtime/components/form/Table.vue +266 -266
- package/dist/runtime/components/form/Time.vue +158 -158
- package/dist/runtime/components/form/images/Capture.vue +230 -230
- package/dist/runtime/components/form/images/Edit.vue +114 -114
- package/dist/runtime/components/label/Date.vue +29 -29
- package/dist/runtime/components/label/Field.vue +42 -42
- package/dist/runtime/components/label/FormatMoney.vue +29 -29
- package/dist/runtime/components/label/Mask.vue +38 -38
- package/dist/runtime/components/master/Autocomplete.vue +159 -159
- package/dist/runtime/components/master/Combobox.vue +84 -84
- package/dist/runtime/components/master/RadioGroup.vue +78 -78
- package/dist/runtime/components/master/Select.vue +82 -82
- package/dist/runtime/components/model/Pad.vue +122 -122
- package/dist/runtime/components/model/Table.vue +242 -240
- package/dist/runtime/components/model/iterator.vue +312 -312
- package/dist/runtime/components/pdf/Print.vue +63 -63
- package/dist/runtime/components/pdf/View.vue +104 -104
- package/dist/runtime/composables/graphqlModel.mjs +1 -1
- package/dist/runtime/labs/Calendar.vue +99 -99
- package/dist/runtime/labs/form/EditMobile.vue +152 -152
- package/dist/runtime/labs/form/TextFieldMask.vue +43 -43
- package/dist/runtime/types/alert.d.ts +11 -11
- package/dist/runtime/types/formDialog.d.ts +4 -4
- package/dist/runtime/types/graphqlOperation.d.ts +23 -23
- package/dist/runtime/types/menu.d.ts +25 -25
- package/dist/runtime/types/modules.d.ts +7 -7
- package/package.json +120 -119
- package/scripts/postInstall.cjs +70 -70
- package/templates/.codegen/codegen.ts +32 -32
- package/templates/.codegen/plugin-schema-object.js +154 -154
|
@@ -1,312 +1,312 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import {computed, nextTick, ref, useAttrs, watch} from 'vue'
|
|
3
|
-
import {VDataIterator} from 'vuetify/components/VDataIterator'
|
|
4
|
-
import {omit} from 'lodash-es'
|
|
5
|
-
import type {GraphqlModelProps} from '../../composables/graphqlModel'
|
|
6
|
-
import {useGraphqlModel} from '../../composables/graphqlModel'
|
|
7
|
-
|
|
8
|
-
defineOptions({
|
|
9
|
-
inheritAttrs: false,
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
interface Props extends /* @vue-ignore */ InstanceType<typeof VDataIterator['$props']> {
|
|
13
|
-
title: string
|
|
14
|
-
noDataText?: string
|
|
15
|
-
dialogFullscreen?: boolean
|
|
16
|
-
initialData?: Record<string, any>
|
|
17
|
-
toolbarColor?: string
|
|
18
|
-
importable?: boolean
|
|
19
|
-
exportable?: boolean
|
|
20
|
-
cols?: string | number | boolean
|
|
21
|
-
xxl?: string | number | boolean
|
|
22
|
-
xl?: string | number | boolean
|
|
23
|
-
lg?: string | number | boolean
|
|
24
|
-
md?: string | number | boolean
|
|
25
|
-
sm?: string | number | boolean
|
|
26
|
-
itemsPerPage?: string | number
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const props = withDefaults(defineProps<Props & GraphqlModelProps>(), {
|
|
30
|
-
noDataText: 'ไม่พบข้อมูล',
|
|
31
|
-
dialogFullscreen: false,
|
|
32
|
-
toolbarColor: 'primary',
|
|
33
|
-
importable: false,
|
|
34
|
-
exportable: false,
|
|
35
|
-
modelKey: 'id',
|
|
36
|
-
modelBy: undefined,
|
|
37
|
-
fields: () => [],
|
|
38
|
-
cols: 12,
|
|
39
|
-
xxl: false,
|
|
40
|
-
xl: false,
|
|
41
|
-
lg: false,
|
|
42
|
-
md: 2,
|
|
43
|
-
sm: 6,
|
|
44
|
-
itemsPerPage: 12,
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
const attrs = useAttrs()
|
|
48
|
-
const plainAttrs = computed(() => {
|
|
49
|
-
const returnAttrs = omit(attrs, ['modelValue', 'onUpdate:modelValue'])
|
|
50
|
-
if (props.headers) returnAttrs['headers'] = props.headers
|
|
51
|
-
return returnAttrs
|
|
52
|
-
})
|
|
53
|
-
const currentItem = ref<Record<string, any> | undefined>(undefined)
|
|
54
|
-
const isDialogOpen = ref<boolean>(false)
|
|
55
|
-
|
|
56
|
-
const { items, itemsLength,
|
|
57
|
-
search, currentOptions,
|
|
58
|
-
canServerPageable, canServerSearch, canCreate, canUpdate, canDelete,
|
|
59
|
-
createItem, importItems, updateItem, deleteItem,
|
|
60
|
-
loadItems, reload,
|
|
61
|
-
isLoading } = useGraphqlModel(props)
|
|
62
|
-
|
|
63
|
-
function openDialog(item?: object) {
|
|
64
|
-
currentItem.value = item
|
|
65
|
-
nextTick(() => {
|
|
66
|
-
isDialogOpen.value = true
|
|
67
|
-
})
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const itemsPerPageInternal = ref<string | number>()
|
|
71
|
-
watch(() => props.itemsPerPage, (newValue) => {
|
|
72
|
-
if (newValue.toString().toLowerCase() == 'all') itemsPerPageInternal.value = '-1'
|
|
73
|
-
else if (newValue) itemsPerPageInternal.value = newValue
|
|
74
|
-
}, { immediate: true })
|
|
75
|
-
|
|
76
|
-
type SortItem = { key: string, order?: boolean | 'asc' | 'desc' }
|
|
77
|
-
const sortBy = ref<SortItem[]>()
|
|
78
|
-
|
|
79
|
-
const pageCount = computed(() => {
|
|
80
|
-
if (!itemsPerPageInternal.value || itemsPerPageInternal.value == 'All' || itemsPerPageInternal.value == '-1' || Number(itemsPerPageInternal.value) <= 0) return 1
|
|
81
|
-
else return Math.ceil(itemsLength.value / Number(itemsPerPageInternal.value))
|
|
82
|
-
})
|
|
83
|
-
const currentPage = ref<number>(1)
|
|
84
|
-
|
|
85
|
-
watch([currentPage, itemsPerPageInternal, sortBy], () => {
|
|
86
|
-
if (canServerPageable.value) {
|
|
87
|
-
loadItems({
|
|
88
|
-
page: currentPage.value,
|
|
89
|
-
itemsPerPage: (!itemsPerPageInternal.value || itemsPerPageInternal.value == 'All' || Number(itemsPerPageInternal.value) <= 0) ? '-1' : itemsPerPageInternal.value,
|
|
90
|
-
sortBy: sortBy.value,
|
|
91
|
-
})
|
|
92
|
-
}
|
|
93
|
-
}, { immediate: true })
|
|
94
|
-
|
|
95
|
-
const operation = ref({ openDialog, createItem, importItems, updateItem, deleteItem, reload, canServerPageable, canServerSearch, canCreate, canUpdate, canDelete })
|
|
96
|
-
|
|
97
|
-
const computedInitialData = computed(() => {
|
|
98
|
-
return Object.assign({}, props.initialData, props.modelBy)
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
const computedSkeletonPerPage = computed(() => {
|
|
102
|
-
if (!itemsPerPageInternal.value || itemsPerPageInternal.value == 'All' || Number(itemsPerPageInternal.value) <= 0) return 1
|
|
103
|
-
else return Number(itemsPerPageInternal.value)
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
defineExpose({ reload })
|
|
107
|
-
</script>
|
|
108
|
-
|
|
109
|
-
<template>
|
|
110
|
-
<v-card>
|
|
111
|
-
<v-data-iterator
|
|
112
|
-
v-bind="plainAttrs"
|
|
113
|
-
v-model:items-per-page="itemsPerPageInternal"
|
|
114
|
-
v-model:sort-by="sortBy"
|
|
115
|
-
:items="items"
|
|
116
|
-
:item-value="modelKey"
|
|
117
|
-
:search="search"
|
|
118
|
-
:loading="isLoading"
|
|
119
|
-
>
|
|
120
|
-
<template #default="defaultProps">
|
|
121
|
-
<slot
|
|
122
|
-
v-bind="defaultProps"
|
|
123
|
-
:operation="operation"
|
|
124
|
-
>
|
|
125
|
-
<v-container fluid>
|
|
126
|
-
<v-row>
|
|
127
|
-
<v-col
|
|
128
|
-
v-for="(item, index) in defaultProps.items"
|
|
129
|
-
:key="index"
|
|
130
|
-
:cols="cols"
|
|
131
|
-
:sm="sm"
|
|
132
|
-
:md="md"
|
|
133
|
-
:lg="lg"
|
|
134
|
-
:xl="xl"
|
|
135
|
-
:xxl="xxl"
|
|
136
|
-
>
|
|
137
|
-
<slot
|
|
138
|
-
name="item"
|
|
139
|
-
:item="item"
|
|
140
|
-
:operation="operation"
|
|
141
|
-
/>
|
|
142
|
-
</v-col>
|
|
143
|
-
</v-row>
|
|
144
|
-
</v-container>
|
|
145
|
-
</slot>
|
|
146
|
-
</template>
|
|
147
|
-
<template #loader="loaderProps">
|
|
148
|
-
<slot
|
|
149
|
-
name="loader"
|
|
150
|
-
v-bind="loaderProps"
|
|
151
|
-
>
|
|
152
|
-
<v-container fluid>
|
|
153
|
-
<v-row>
|
|
154
|
-
<v-col
|
|
155
|
-
v-for="key in computedSkeletonPerPage"
|
|
156
|
-
:key="key"
|
|
157
|
-
:cols="cols"
|
|
158
|
-
:sm="sm"
|
|
159
|
-
:md="md"
|
|
160
|
-
:lg="lg"
|
|
161
|
-
:xl="xl"
|
|
162
|
-
:xxl="xxl"
|
|
163
|
-
>
|
|
164
|
-
<slot name="loaderItem">
|
|
165
|
-
<v-skeleton-loader
|
|
166
|
-
type="paragraph"
|
|
167
|
-
/>
|
|
168
|
-
</slot>
|
|
169
|
-
</v-col>
|
|
170
|
-
</v-row>
|
|
171
|
-
</v-container>
|
|
172
|
-
</slot>
|
|
173
|
-
</template>
|
|
174
|
-
<template #header="headerProps">
|
|
175
|
-
<slot
|
|
176
|
-
name="header"
|
|
177
|
-
v-bind="headerProps"
|
|
178
|
-
:items="items"
|
|
179
|
-
:search="search"
|
|
180
|
-
:operation="operation"
|
|
181
|
-
>
|
|
182
|
-
<VToolbar :color="toolbarColor">
|
|
183
|
-
<v-row
|
|
184
|
-
justify="end"
|
|
185
|
-
class="ma-1"
|
|
186
|
-
dense
|
|
187
|
-
no-gutters
|
|
188
|
-
align="center"
|
|
189
|
-
>
|
|
190
|
-
<v-col cols="7">
|
|
191
|
-
<VToolbarTitle class="pl-3">
|
|
192
|
-
<slot
|
|
193
|
-
name="title"
|
|
194
|
-
:reload="reload"
|
|
195
|
-
>
|
|
196
|
-
{{ title }}
|
|
197
|
-
<v-icon
|
|
198
|
-
size="small"
|
|
199
|
-
@click="reload"
|
|
200
|
-
>
|
|
201
|
-
mdi mdi-refresh
|
|
202
|
-
</v-icon>
|
|
203
|
-
</slot>
|
|
204
|
-
</VToolbarTitle>
|
|
205
|
-
</v-col>
|
|
206
|
-
<v-col cols="5">
|
|
207
|
-
<slot name="search">
|
|
208
|
-
<VTextField
|
|
209
|
-
v-model="search"
|
|
210
|
-
class="justify-end w-100"
|
|
211
|
-
density="compact"
|
|
212
|
-
hide-details
|
|
213
|
-
placeholder="ค้นหา"
|
|
214
|
-
clearable
|
|
215
|
-
variant="solo"
|
|
216
|
-
/>
|
|
217
|
-
</slot>
|
|
218
|
-
</v-col>
|
|
219
|
-
</v-row>
|
|
220
|
-
|
|
221
|
-
<VToolbarItems>
|
|
222
|
-
<slot name="toolbarItems" />
|
|
223
|
-
<ImportCSV
|
|
224
|
-
v-if="props.importable"
|
|
225
|
-
icon="mdi mdi-file-upload"
|
|
226
|
-
variant="flat"
|
|
227
|
-
@import="importItems"
|
|
228
|
-
/>
|
|
229
|
-
<ExportCSV
|
|
230
|
-
v-if="props.exportable && items.length"
|
|
231
|
-
icon="mdi mdi-file-download"
|
|
232
|
-
variant="flat"
|
|
233
|
-
:file-name="title"
|
|
234
|
-
:model-value="items"
|
|
235
|
-
/>
|
|
236
|
-
<VBtn
|
|
237
|
-
v-if="canCreate"
|
|
238
|
-
:color="toolbarColor"
|
|
239
|
-
prepend-icon="mdi mdi-plus"
|
|
240
|
-
variant="flat"
|
|
241
|
-
@click="openDialog()"
|
|
242
|
-
>
|
|
243
|
-
add
|
|
244
|
-
</VBtn>
|
|
245
|
-
</VToolbarItems>
|
|
246
|
-
</VToolbar>
|
|
247
|
-
</slot>
|
|
248
|
-
</template>
|
|
249
|
-
<template #footer="footerProps">
|
|
250
|
-
<v-container fluid>
|
|
251
|
-
<v-row
|
|
252
|
-
align-content="center"
|
|
253
|
-
justify="end"
|
|
254
|
-
dense
|
|
255
|
-
>
|
|
256
|
-
<v-spacer />
|
|
257
|
-
<v-select
|
|
258
|
-
v-model="itemsPerPageInternal"
|
|
259
|
-
density="compact"
|
|
260
|
-
variant="outlined"
|
|
261
|
-
:items="[6, 12, 18, 24, 30, { title: 'All', value: '-1' }]"
|
|
262
|
-
min-width="220"
|
|
263
|
-
max-width="220"
|
|
264
|
-
hide-details
|
|
265
|
-
>
|
|
266
|
-
<template #prepend>
|
|
267
|
-
Items per page:
|
|
268
|
-
</template>
|
|
269
|
-
</v-select>
|
|
270
|
-
<v-pagination
|
|
271
|
-
v-if="!canServerPageable"
|
|
272
|
-
v-model="currentPage"
|
|
273
|
-
density="compact"
|
|
274
|
-
:length="footerProps.pageCount"
|
|
275
|
-
total-visible="6"
|
|
276
|
-
show-first-last-page
|
|
277
|
-
@first="footerProps.setPage(1)"
|
|
278
|
-
@last="footerProps.setPage(footerProps.pageCount)"
|
|
279
|
-
@next="footerProps.nextPage"
|
|
280
|
-
@prev="footerProps.prevPage"
|
|
281
|
-
@update:model-value="footerProps.setPage"
|
|
282
|
-
/>
|
|
283
|
-
<v-pagination
|
|
284
|
-
v-else
|
|
285
|
-
v-model="currentPage"
|
|
286
|
-
density="compact"
|
|
287
|
-
:length="pageCount"
|
|
288
|
-
total-visible="6"
|
|
289
|
-
show-first-last-page
|
|
290
|
-
/>
|
|
291
|
-
</v-row>
|
|
292
|
-
</v-container>
|
|
293
|
-
</template>
|
|
294
|
-
</v-data-iterator>
|
|
295
|
-
<FormDialog
|
|
296
|
-
v-model="isDialogOpen"
|
|
297
|
-
:title="title"
|
|
298
|
-
:fullscreen="dialogFullscreen"
|
|
299
|
-
:initial-data="computedInitialData"
|
|
300
|
-
:form-data="currentItem"
|
|
301
|
-
@create="createItem"
|
|
302
|
-
@update="updateItem"
|
|
303
|
-
>
|
|
304
|
-
<template #default="slotData">
|
|
305
|
-
<slot
|
|
306
|
-
name="form"
|
|
307
|
-
v-bind="slotData"
|
|
308
|
-
/>
|
|
309
|
-
</template>
|
|
310
|
-
</FormDialog>
|
|
311
|
-
</v-card>
|
|
312
|
-
</template>
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import {computed, nextTick, ref, useAttrs, watch} from 'vue'
|
|
3
|
+
import {VDataIterator} from 'vuetify/components/VDataIterator'
|
|
4
|
+
import {omit} from 'lodash-es'
|
|
5
|
+
import type {GraphqlModelProps} from '../../composables/graphqlModel'
|
|
6
|
+
import {useGraphqlModel} from '../../composables/graphqlModel'
|
|
7
|
+
|
|
8
|
+
defineOptions({
|
|
9
|
+
inheritAttrs: false,
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
interface Props extends /* @vue-ignore */ InstanceType<typeof VDataIterator['$props']> {
|
|
13
|
+
title: string
|
|
14
|
+
noDataText?: string
|
|
15
|
+
dialogFullscreen?: boolean
|
|
16
|
+
initialData?: Record<string, any>
|
|
17
|
+
toolbarColor?: string
|
|
18
|
+
importable?: boolean
|
|
19
|
+
exportable?: boolean
|
|
20
|
+
cols?: string | number | boolean
|
|
21
|
+
xxl?: string | number | boolean
|
|
22
|
+
xl?: string | number | boolean
|
|
23
|
+
lg?: string | number | boolean
|
|
24
|
+
md?: string | number | boolean
|
|
25
|
+
sm?: string | number | boolean
|
|
26
|
+
itemsPerPage?: string | number
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const props = withDefaults(defineProps<Props & GraphqlModelProps>(), {
|
|
30
|
+
noDataText: 'ไม่พบข้อมูล',
|
|
31
|
+
dialogFullscreen: false,
|
|
32
|
+
toolbarColor: 'primary',
|
|
33
|
+
importable: false,
|
|
34
|
+
exportable: false,
|
|
35
|
+
modelKey: 'id',
|
|
36
|
+
modelBy: undefined,
|
|
37
|
+
fields: () => [],
|
|
38
|
+
cols: 12,
|
|
39
|
+
xxl: false,
|
|
40
|
+
xl: false,
|
|
41
|
+
lg: false,
|
|
42
|
+
md: 2,
|
|
43
|
+
sm: 6,
|
|
44
|
+
itemsPerPage: 12,
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
const attrs = useAttrs()
|
|
48
|
+
const plainAttrs = computed(() => {
|
|
49
|
+
const returnAttrs = omit(attrs, ['modelValue', 'onUpdate:modelValue'])
|
|
50
|
+
if (props.headers) returnAttrs['headers'] = props.headers
|
|
51
|
+
return returnAttrs
|
|
52
|
+
})
|
|
53
|
+
const currentItem = ref<Record<string, any> | undefined>(undefined)
|
|
54
|
+
const isDialogOpen = ref<boolean>(false)
|
|
55
|
+
|
|
56
|
+
const { items, itemsLength,
|
|
57
|
+
search, currentOptions,
|
|
58
|
+
canServerPageable, canServerSearch, canCreate, canUpdate, canDelete,
|
|
59
|
+
createItem, importItems, updateItem, deleteItem,
|
|
60
|
+
loadItems, reload,
|
|
61
|
+
isLoading } = useGraphqlModel(props)
|
|
62
|
+
|
|
63
|
+
function openDialog(item?: object) {
|
|
64
|
+
currentItem.value = item
|
|
65
|
+
nextTick(() => {
|
|
66
|
+
isDialogOpen.value = true
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const itemsPerPageInternal = ref<string | number>()
|
|
71
|
+
watch(() => props.itemsPerPage, (newValue) => {
|
|
72
|
+
if (newValue.toString().toLowerCase() == 'all') itemsPerPageInternal.value = '-1'
|
|
73
|
+
else if (newValue) itemsPerPageInternal.value = newValue
|
|
74
|
+
}, { immediate: true })
|
|
75
|
+
|
|
76
|
+
type SortItem = { key: string, order?: boolean | 'asc' | 'desc' }
|
|
77
|
+
const sortBy = ref<SortItem[]>()
|
|
78
|
+
|
|
79
|
+
const pageCount = computed(() => {
|
|
80
|
+
if (!itemsPerPageInternal.value || itemsPerPageInternal.value == 'All' || itemsPerPageInternal.value == '-1' || Number(itemsPerPageInternal.value) <= 0) return 1
|
|
81
|
+
else return Math.ceil(itemsLength.value / Number(itemsPerPageInternal.value))
|
|
82
|
+
})
|
|
83
|
+
const currentPage = ref<number>(1)
|
|
84
|
+
|
|
85
|
+
watch([currentPage, itemsPerPageInternal, sortBy], () => {
|
|
86
|
+
if (canServerPageable.value) {
|
|
87
|
+
loadItems({
|
|
88
|
+
page: currentPage.value,
|
|
89
|
+
itemsPerPage: (!itemsPerPageInternal.value || itemsPerPageInternal.value == 'All' || Number(itemsPerPageInternal.value) <= 0) ? '-1' : itemsPerPageInternal.value,
|
|
90
|
+
sortBy: sortBy.value,
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
}, { immediate: true })
|
|
94
|
+
|
|
95
|
+
const operation = ref({ openDialog, createItem, importItems, updateItem, deleteItem, reload, canServerPageable, canServerSearch, canCreate, canUpdate, canDelete })
|
|
96
|
+
|
|
97
|
+
const computedInitialData = computed(() => {
|
|
98
|
+
return Object.assign({}, props.initialData, props.modelBy)
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
const computedSkeletonPerPage = computed(() => {
|
|
102
|
+
if (!itemsPerPageInternal.value || itemsPerPageInternal.value == 'All' || Number(itemsPerPageInternal.value) <= 0) return 1
|
|
103
|
+
else return Number(itemsPerPageInternal.value)
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
defineExpose({ reload })
|
|
107
|
+
</script>
|
|
108
|
+
|
|
109
|
+
<template>
|
|
110
|
+
<v-card>
|
|
111
|
+
<v-data-iterator
|
|
112
|
+
v-bind="plainAttrs"
|
|
113
|
+
v-model:items-per-page="itemsPerPageInternal"
|
|
114
|
+
v-model:sort-by="sortBy"
|
|
115
|
+
:items="items"
|
|
116
|
+
:item-value="modelKey"
|
|
117
|
+
:search="search"
|
|
118
|
+
:loading="isLoading"
|
|
119
|
+
>
|
|
120
|
+
<template #default="defaultProps">
|
|
121
|
+
<slot
|
|
122
|
+
v-bind="defaultProps"
|
|
123
|
+
:operation="operation"
|
|
124
|
+
>
|
|
125
|
+
<v-container fluid>
|
|
126
|
+
<v-row>
|
|
127
|
+
<v-col
|
|
128
|
+
v-for="(item, index) in defaultProps.items"
|
|
129
|
+
:key="index"
|
|
130
|
+
:cols="cols"
|
|
131
|
+
:sm="sm"
|
|
132
|
+
:md="md"
|
|
133
|
+
:lg="lg"
|
|
134
|
+
:xl="xl"
|
|
135
|
+
:xxl="xxl"
|
|
136
|
+
>
|
|
137
|
+
<slot
|
|
138
|
+
name="item"
|
|
139
|
+
:item="item"
|
|
140
|
+
:operation="operation"
|
|
141
|
+
/>
|
|
142
|
+
</v-col>
|
|
143
|
+
</v-row>
|
|
144
|
+
</v-container>
|
|
145
|
+
</slot>
|
|
146
|
+
</template>
|
|
147
|
+
<template #loader="loaderProps">
|
|
148
|
+
<slot
|
|
149
|
+
name="loader"
|
|
150
|
+
v-bind="loaderProps"
|
|
151
|
+
>
|
|
152
|
+
<v-container fluid>
|
|
153
|
+
<v-row>
|
|
154
|
+
<v-col
|
|
155
|
+
v-for="key in computedSkeletonPerPage"
|
|
156
|
+
:key="key"
|
|
157
|
+
:cols="cols"
|
|
158
|
+
:sm="sm"
|
|
159
|
+
:md="md"
|
|
160
|
+
:lg="lg"
|
|
161
|
+
:xl="xl"
|
|
162
|
+
:xxl="xxl"
|
|
163
|
+
>
|
|
164
|
+
<slot name="loaderItem">
|
|
165
|
+
<v-skeleton-loader
|
|
166
|
+
type="paragraph"
|
|
167
|
+
/>
|
|
168
|
+
</slot>
|
|
169
|
+
</v-col>
|
|
170
|
+
</v-row>
|
|
171
|
+
</v-container>
|
|
172
|
+
</slot>
|
|
173
|
+
</template>
|
|
174
|
+
<template #header="headerProps">
|
|
175
|
+
<slot
|
|
176
|
+
name="header"
|
|
177
|
+
v-bind="headerProps"
|
|
178
|
+
:items="items"
|
|
179
|
+
:search="search"
|
|
180
|
+
:operation="operation"
|
|
181
|
+
>
|
|
182
|
+
<VToolbar :color="toolbarColor">
|
|
183
|
+
<v-row
|
|
184
|
+
justify="end"
|
|
185
|
+
class="ma-1"
|
|
186
|
+
dense
|
|
187
|
+
no-gutters
|
|
188
|
+
align="center"
|
|
189
|
+
>
|
|
190
|
+
<v-col cols="7">
|
|
191
|
+
<VToolbarTitle class="pl-3">
|
|
192
|
+
<slot
|
|
193
|
+
name="title"
|
|
194
|
+
:reload="reload"
|
|
195
|
+
>
|
|
196
|
+
{{ title }}
|
|
197
|
+
<v-icon
|
|
198
|
+
size="small"
|
|
199
|
+
@click="reload"
|
|
200
|
+
>
|
|
201
|
+
mdi mdi-refresh
|
|
202
|
+
</v-icon>
|
|
203
|
+
</slot>
|
|
204
|
+
</VToolbarTitle>
|
|
205
|
+
</v-col>
|
|
206
|
+
<v-col cols="5">
|
|
207
|
+
<slot name="search">
|
|
208
|
+
<VTextField
|
|
209
|
+
v-model="search"
|
|
210
|
+
class="justify-end w-100"
|
|
211
|
+
density="compact"
|
|
212
|
+
hide-details
|
|
213
|
+
placeholder="ค้นหา"
|
|
214
|
+
clearable
|
|
215
|
+
variant="solo"
|
|
216
|
+
/>
|
|
217
|
+
</slot>
|
|
218
|
+
</v-col>
|
|
219
|
+
</v-row>
|
|
220
|
+
|
|
221
|
+
<VToolbarItems>
|
|
222
|
+
<slot name="toolbarItems" />
|
|
223
|
+
<ImportCSV
|
|
224
|
+
v-if="props.importable"
|
|
225
|
+
icon="mdi mdi-file-upload"
|
|
226
|
+
variant="flat"
|
|
227
|
+
@import="importItems"
|
|
228
|
+
/>
|
|
229
|
+
<ExportCSV
|
|
230
|
+
v-if="props.exportable && items.length"
|
|
231
|
+
icon="mdi mdi-file-download"
|
|
232
|
+
variant="flat"
|
|
233
|
+
:file-name="title"
|
|
234
|
+
:model-value="items"
|
|
235
|
+
/>
|
|
236
|
+
<VBtn
|
|
237
|
+
v-if="canCreate"
|
|
238
|
+
:color="toolbarColor"
|
|
239
|
+
prepend-icon="mdi mdi-plus"
|
|
240
|
+
variant="flat"
|
|
241
|
+
@click="openDialog()"
|
|
242
|
+
>
|
|
243
|
+
add
|
|
244
|
+
</VBtn>
|
|
245
|
+
</VToolbarItems>
|
|
246
|
+
</VToolbar>
|
|
247
|
+
</slot>
|
|
248
|
+
</template>
|
|
249
|
+
<template #footer="footerProps">
|
|
250
|
+
<v-container fluid>
|
|
251
|
+
<v-row
|
|
252
|
+
align-content="center"
|
|
253
|
+
justify="end"
|
|
254
|
+
dense
|
|
255
|
+
>
|
|
256
|
+
<v-spacer />
|
|
257
|
+
<v-select
|
|
258
|
+
v-model="itemsPerPageInternal"
|
|
259
|
+
density="compact"
|
|
260
|
+
variant="outlined"
|
|
261
|
+
:items="[6, 12, 18, 24, 30, { title: 'All', value: '-1' }]"
|
|
262
|
+
min-width="220"
|
|
263
|
+
max-width="220"
|
|
264
|
+
hide-details
|
|
265
|
+
>
|
|
266
|
+
<template #prepend>
|
|
267
|
+
Items per page:
|
|
268
|
+
</template>
|
|
269
|
+
</v-select>
|
|
270
|
+
<v-pagination
|
|
271
|
+
v-if="!canServerPageable"
|
|
272
|
+
v-model="currentPage"
|
|
273
|
+
density="compact"
|
|
274
|
+
:length="footerProps.pageCount"
|
|
275
|
+
total-visible="6"
|
|
276
|
+
show-first-last-page
|
|
277
|
+
@first="footerProps.setPage(1)"
|
|
278
|
+
@last="footerProps.setPage(footerProps.pageCount)"
|
|
279
|
+
@next="footerProps.nextPage"
|
|
280
|
+
@prev="footerProps.prevPage"
|
|
281
|
+
@update:model-value="footerProps.setPage"
|
|
282
|
+
/>
|
|
283
|
+
<v-pagination
|
|
284
|
+
v-else
|
|
285
|
+
v-model="currentPage"
|
|
286
|
+
density="compact"
|
|
287
|
+
:length="pageCount"
|
|
288
|
+
total-visible="6"
|
|
289
|
+
show-first-last-page
|
|
290
|
+
/>
|
|
291
|
+
</v-row>
|
|
292
|
+
</v-container>
|
|
293
|
+
</template>
|
|
294
|
+
</v-data-iterator>
|
|
295
|
+
<FormDialog
|
|
296
|
+
v-model="isDialogOpen"
|
|
297
|
+
:title="title"
|
|
298
|
+
:fullscreen="dialogFullscreen"
|
|
299
|
+
:initial-data="computedInitialData"
|
|
300
|
+
:form-data="currentItem"
|
|
301
|
+
@create="createItem"
|
|
302
|
+
@update="updateItem"
|
|
303
|
+
>
|
|
304
|
+
<template #default="slotData">
|
|
305
|
+
<slot
|
|
306
|
+
name="form"
|
|
307
|
+
v-bind="slotData"
|
|
308
|
+
/>
|
|
309
|
+
</template>
|
|
310
|
+
</FormDialog>
|
|
311
|
+
</v-card>
|
|
312
|
+
</template>
|