@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,63 +1,63 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import printJS from 'print-js'
|
|
3
|
-
import { ref, watch } from 'vue'
|
|
4
|
-
import { useAlert } from '../../composables/alert'
|
|
5
|
-
|
|
6
|
-
interface Props {
|
|
7
|
-
base64String?: string
|
|
8
|
-
fileName?: string
|
|
9
|
-
print?: boolean
|
|
10
|
-
title?: string
|
|
11
|
-
disabled?: boolean
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const props = withDefaults(defineProps<Props>(), {
|
|
15
|
-
print: false,
|
|
16
|
-
disabled: false,
|
|
17
|
-
})
|
|
18
|
-
const emit = defineEmits(['update:print'])
|
|
19
|
-
|
|
20
|
-
const isMobile = ref(false)
|
|
21
|
-
const alert = useAlert()
|
|
22
|
-
|
|
23
|
-
const openPdf = () => {
|
|
24
|
-
if (/Android|Mobi|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Macintosh/i.test(navigator.userAgent)) {
|
|
25
|
-
isMobile.value = true
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
printJS({
|
|
29
|
-
printable: props.base64String,
|
|
30
|
-
type: 'pdf',
|
|
31
|
-
base64: true,
|
|
32
|
-
onPrintDialogClose: endLoadPdf,
|
|
33
|
-
onError: (error: any) => {
|
|
34
|
-
alert?.addAlert({ message: error, alertType: 'error' })
|
|
35
|
-
},
|
|
36
|
-
})
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const endLoadPdf = () => {
|
|
41
|
-
emit('update:print', false)
|
|
42
|
-
isMobile.value = false
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
watch(() => props.print, () => {
|
|
46
|
-
if (props.print) openPdf()
|
|
47
|
-
})
|
|
48
|
-
</script>
|
|
49
|
-
|
|
50
|
-
<template>
|
|
51
|
-
<v-dialog
|
|
52
|
-
v-model="isMobile"
|
|
53
|
-
fullscreen
|
|
54
|
-
>
|
|
55
|
-
<PdfView
|
|
56
|
-
:base64-string="props.base64String"
|
|
57
|
-
:disabled="props.disabled"
|
|
58
|
-
:title="props.title"
|
|
59
|
-
:file-name="props.fileName"
|
|
60
|
-
@close-dialog="endLoadPdf"
|
|
61
|
-
/>
|
|
62
|
-
</v-dialog>
|
|
63
|
-
</template>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import printJS from 'print-js'
|
|
3
|
+
import { ref, watch } from 'vue'
|
|
4
|
+
import { useAlert } from '../../composables/alert'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
base64String?: string
|
|
8
|
+
fileName?: string
|
|
9
|
+
print?: boolean
|
|
10
|
+
title?: string
|
|
11
|
+
disabled?: boolean
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
15
|
+
print: false,
|
|
16
|
+
disabled: false,
|
|
17
|
+
})
|
|
18
|
+
const emit = defineEmits(['update:print'])
|
|
19
|
+
|
|
20
|
+
const isMobile = ref(false)
|
|
21
|
+
const alert = useAlert()
|
|
22
|
+
|
|
23
|
+
const openPdf = () => {
|
|
24
|
+
if (/Android|Mobi|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Macintosh/i.test(navigator.userAgent)) {
|
|
25
|
+
isMobile.value = true
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
printJS({
|
|
29
|
+
printable: props.base64String,
|
|
30
|
+
type: 'pdf',
|
|
31
|
+
base64: true,
|
|
32
|
+
onPrintDialogClose: endLoadPdf,
|
|
33
|
+
onError: (error: any) => {
|
|
34
|
+
alert?.addAlert({ message: error, alertType: 'error' })
|
|
35
|
+
},
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const endLoadPdf = () => {
|
|
41
|
+
emit('update:print', false)
|
|
42
|
+
isMobile.value = false
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
watch(() => props.print, () => {
|
|
46
|
+
if (props.print) openPdf()
|
|
47
|
+
})
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<template>
|
|
51
|
+
<v-dialog
|
|
52
|
+
v-model="isMobile"
|
|
53
|
+
fullscreen
|
|
54
|
+
>
|
|
55
|
+
<PdfView
|
|
56
|
+
:base64-string="props.base64String"
|
|
57
|
+
:disabled="props.disabled"
|
|
58
|
+
:title="props.title"
|
|
59
|
+
:file-name="props.fileName"
|
|
60
|
+
@close-dialog="endLoadPdf"
|
|
61
|
+
/>
|
|
62
|
+
</v-dialog>
|
|
63
|
+
</template>
|
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import PDF from 'pdf-vue3'
|
|
3
|
-
import { uid } from 'uid'
|
|
4
|
-
import printJS from 'print-js'
|
|
5
|
-
import { ref, computed } from 'vue'
|
|
6
|
-
import { useAlert } from '../../composables/alert'
|
|
7
|
-
|
|
8
|
-
const props = defineProps<{
|
|
9
|
-
base64String?: string
|
|
10
|
-
title?: string
|
|
11
|
-
fileName?: string
|
|
12
|
-
disabled?: boolean
|
|
13
|
-
}>()
|
|
14
|
-
|
|
15
|
-
const emit = defineEmits(['closeDialog'])
|
|
16
|
-
const base64 = ref(props.base64String)
|
|
17
|
-
const alert = useAlert()
|
|
18
|
-
|
|
19
|
-
const generateUniqueId = (): string => {
|
|
20
|
-
const uniqueId: string = uid()
|
|
21
|
-
return props.fileName ? `${props.fileName}` : uniqueId
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const downloadPdf = (): void => {
|
|
25
|
-
const byteString = atob(props.base64String || '')
|
|
26
|
-
const byteArray = new Uint8Array(byteString.length)
|
|
27
|
-
|
|
28
|
-
for (let i = 0; i < byteString.length; i++) {
|
|
29
|
-
byteArray[i] = byteString.charCodeAt(i)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const blob = new Blob([byteArray], { type: 'application/pdf' })
|
|
33
|
-
const link = URL.createObjectURL(blob)
|
|
34
|
-
const anchorElement = document.createElement('a')
|
|
35
|
-
anchorElement.style.display = 'none'
|
|
36
|
-
anchorElement.href = link
|
|
37
|
-
anchorElement.download = `${generateUniqueId()}.pdf`
|
|
38
|
-
|
|
39
|
-
document.body.appendChild(anchorElement)
|
|
40
|
-
anchorElement.click()
|
|
41
|
-
URL.revokeObjectURL(link)
|
|
42
|
-
document.body.removeChild(anchorElement)
|
|
43
|
-
base64.value = ''
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const printPdf = () => {
|
|
47
|
-
printJS({
|
|
48
|
-
printable: props.base64String,
|
|
49
|
-
type: 'pdf',
|
|
50
|
-
base64: true,
|
|
51
|
-
onPrintDialogClose: endLoadPdf,
|
|
52
|
-
onError: (error: any) => {
|
|
53
|
-
alert?.addAlert({ message: error, alertType: 'error' })
|
|
54
|
-
},
|
|
55
|
-
})
|
|
56
|
-
base64.value = ''
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const endLoadPdf = () => {
|
|
60
|
-
emit('closeDialog', false)
|
|
61
|
-
base64.value = ''
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const isMobile = computed(() => {
|
|
65
|
-
if (/Android|Mobi|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Macintosh/i.test(navigator.userAgent)) {
|
|
66
|
-
return true
|
|
67
|
-
}
|
|
68
|
-
})
|
|
69
|
-
</script>
|
|
70
|
-
|
|
71
|
-
<template>
|
|
72
|
-
<v-card>
|
|
73
|
-
<v-toolbar density="compact">
|
|
74
|
-
<v-toolbar-title>{{ props.title }}</v-toolbar-title>
|
|
75
|
-
<v-spacer />
|
|
76
|
-
<v-btn
|
|
77
|
-
v-if="!isMobile"
|
|
78
|
-
icon="mdi mdi-printer"
|
|
79
|
-
variant="plain"
|
|
80
|
-
@click="printPdf"
|
|
81
|
-
/>
|
|
82
|
-
<v-btn
|
|
83
|
-
v-if="!props.disabled"
|
|
84
|
-
icon="mdi mdi-download"
|
|
85
|
-
variant="plain"
|
|
86
|
-
@click="downloadPdf"
|
|
87
|
-
/>
|
|
88
|
-
<v-btn
|
|
89
|
-
icon="mdi mdi-close"
|
|
90
|
-
variant="plain"
|
|
91
|
-
@click="endLoadPdf"
|
|
92
|
-
/>
|
|
93
|
-
</v-toolbar>
|
|
94
|
-
<v-card-text class="justify-center">
|
|
95
|
-
<PDF
|
|
96
|
-
:show-progress="true"
|
|
97
|
-
pdf-width="100%"
|
|
98
|
-
:src="base64"
|
|
99
|
-
:show-page-tooltip="false"
|
|
100
|
-
:show-back-to-top-btn="false"
|
|
101
|
-
/>
|
|
102
|
-
</v-card-text>
|
|
103
|
-
</v-card>
|
|
104
|
-
</template>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import PDF from 'pdf-vue3'
|
|
3
|
+
import { uid } from 'uid'
|
|
4
|
+
import printJS from 'print-js'
|
|
5
|
+
import { ref, computed } from 'vue'
|
|
6
|
+
import { useAlert } from '../../composables/alert'
|
|
7
|
+
|
|
8
|
+
const props = defineProps<{
|
|
9
|
+
base64String?: string
|
|
10
|
+
title?: string
|
|
11
|
+
fileName?: string
|
|
12
|
+
disabled?: boolean
|
|
13
|
+
}>()
|
|
14
|
+
|
|
15
|
+
const emit = defineEmits(['closeDialog'])
|
|
16
|
+
const base64 = ref(props.base64String)
|
|
17
|
+
const alert = useAlert()
|
|
18
|
+
|
|
19
|
+
const generateUniqueId = (): string => {
|
|
20
|
+
const uniqueId: string = uid()
|
|
21
|
+
return props.fileName ? `${props.fileName}` : uniqueId
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const downloadPdf = (): void => {
|
|
25
|
+
const byteString = atob(props.base64String || '')
|
|
26
|
+
const byteArray = new Uint8Array(byteString.length)
|
|
27
|
+
|
|
28
|
+
for (let i = 0; i < byteString.length; i++) {
|
|
29
|
+
byteArray[i] = byteString.charCodeAt(i)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const blob = new Blob([byteArray], { type: 'application/pdf' })
|
|
33
|
+
const link = URL.createObjectURL(blob)
|
|
34
|
+
const anchorElement = document.createElement('a')
|
|
35
|
+
anchorElement.style.display = 'none'
|
|
36
|
+
anchorElement.href = link
|
|
37
|
+
anchorElement.download = `${generateUniqueId()}.pdf`
|
|
38
|
+
|
|
39
|
+
document.body.appendChild(anchorElement)
|
|
40
|
+
anchorElement.click()
|
|
41
|
+
URL.revokeObjectURL(link)
|
|
42
|
+
document.body.removeChild(anchorElement)
|
|
43
|
+
base64.value = ''
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const printPdf = () => {
|
|
47
|
+
printJS({
|
|
48
|
+
printable: props.base64String,
|
|
49
|
+
type: 'pdf',
|
|
50
|
+
base64: true,
|
|
51
|
+
onPrintDialogClose: endLoadPdf,
|
|
52
|
+
onError: (error: any) => {
|
|
53
|
+
alert?.addAlert({ message: error, alertType: 'error' })
|
|
54
|
+
},
|
|
55
|
+
})
|
|
56
|
+
base64.value = ''
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const endLoadPdf = () => {
|
|
60
|
+
emit('closeDialog', false)
|
|
61
|
+
base64.value = ''
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const isMobile = computed(() => {
|
|
65
|
+
if (/Android|Mobi|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Macintosh/i.test(navigator.userAgent)) {
|
|
66
|
+
return true
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
<template>
|
|
72
|
+
<v-card>
|
|
73
|
+
<v-toolbar density="compact">
|
|
74
|
+
<v-toolbar-title>{{ props.title }}</v-toolbar-title>
|
|
75
|
+
<v-spacer />
|
|
76
|
+
<v-btn
|
|
77
|
+
v-if="!isMobile"
|
|
78
|
+
icon="mdi mdi-printer"
|
|
79
|
+
variant="plain"
|
|
80
|
+
@click="printPdf"
|
|
81
|
+
/>
|
|
82
|
+
<v-btn
|
|
83
|
+
v-if="!props.disabled"
|
|
84
|
+
icon="mdi mdi-download"
|
|
85
|
+
variant="plain"
|
|
86
|
+
@click="downloadPdf"
|
|
87
|
+
/>
|
|
88
|
+
<v-btn
|
|
89
|
+
icon="mdi mdi-close"
|
|
90
|
+
variant="plain"
|
|
91
|
+
@click="endLoadPdf"
|
|
92
|
+
/>
|
|
93
|
+
</v-toolbar>
|
|
94
|
+
<v-card-text class="justify-center">
|
|
95
|
+
<PDF
|
|
96
|
+
:show-progress="true"
|
|
97
|
+
pdf-width="100%"
|
|
98
|
+
:src="base64"
|
|
99
|
+
:show-page-tooltip="false"
|
|
100
|
+
:show-back-to-top-btn="false"
|
|
101
|
+
/>
|
|
102
|
+
</v-card-text>
|
|
103
|
+
</v-card>
|
|
104
|
+
</template>
|
|
@@ -131,7 +131,7 @@ export function useGraphqlModel(props) {
|
|
|
131
131
|
sortBy: options.sortBy
|
|
132
132
|
};
|
|
133
133
|
isLoading.value = true;
|
|
134
|
-
operationReadPageable.value?.call([{ data: fields.value }, "meta"], Object.assign(props.modelBy
|
|
134
|
+
operationReadPageable.value?.call([{ data: fields.value }, "meta"], Object.assign({}, props.modelBy, { pageable: pageableVariable })).then((result) => {
|
|
135
135
|
items.value = result.data;
|
|
136
136
|
itemsLength.value = result.meta.totalItems;
|
|
137
137
|
}).catch((error) => {
|
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import FullCalendar from '@fullcalendar/vue3'
|
|
3
|
-
import dayGridPlugin from '@fullcalendar/daygrid'
|
|
4
|
-
import timeGridPlugin from '@fullcalendar/timegrid'
|
|
5
|
-
import listPlugin from '@fullcalendar/list'
|
|
6
|
-
import interactionPlugin from '@fullcalendar/interaction'
|
|
7
|
-
import { ref, computed, withDefaults } from 'vue'
|
|
8
|
-
import { type CalendarOptions } from '@fullcalendar/core'
|
|
9
|
-
|
|
10
|
-
type Event = {
|
|
11
|
-
id: string | undefined
|
|
12
|
-
title: string
|
|
13
|
-
start: string // YYYY-MM-DD | YYYY-MM-DD HH:mm:ss
|
|
14
|
-
end: string // YYYY-MM-DD
|
|
15
|
-
color: string
|
|
16
|
-
detail?: string
|
|
17
|
-
props: Record<string, any> | any[]
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface CalendarProps {
|
|
21
|
-
modelValue: Event[]
|
|
22
|
-
locale?: 'th' | 'en'
|
|
23
|
-
toolBarLeft?: string
|
|
24
|
-
toolBarCenter?: string
|
|
25
|
-
toolBarRight?: string
|
|
26
|
-
height?: string | number
|
|
27
|
-
selectViewDay?: string
|
|
28
|
-
mode: 'dayGridMonth' | 'timeGridDay'
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const props = withDefaults(defineProps<CalendarProps>(), {
|
|
32
|
-
locale: 'th',
|
|
33
|
-
height: 1200,
|
|
34
|
-
toolBarLeft: 'today prev,next',
|
|
35
|
-
toolBarCenter: 'title',
|
|
36
|
-
toolBarRight: 'timeGridDay,timeGridWeek,dayGridMonth',
|
|
37
|
-
mode: 'dayGridMonth',
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
const emit = defineEmits(['select', 'dialog'])
|
|
41
|
-
|
|
42
|
-
const buttonText = computed(() => {
|
|
43
|
-
return {
|
|
44
|
-
today: props.locale === 'th' ? 'วันนี้' : 'today',
|
|
45
|
-
month: props.locale === 'th' ? 'เดือน' : 'month',
|
|
46
|
-
week: props.locale === 'th' ? 'สัปดาห์' : 'week',
|
|
47
|
-
day: props.locale === 'th' ? 'วัน' : 'day',
|
|
48
|
-
list: props.locale === 'th' ? 'รายการ' : 'list',
|
|
49
|
-
year: props.locale === 'th' ? 'ปี' : 'year',
|
|
50
|
-
}
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
const calendarRef = ref<InstanceType<typeof FullCalendar>>()
|
|
54
|
-
const dateViewDay = ref({ date: '', props: {} })
|
|
55
|
-
|
|
56
|
-
const handleDateClick = (info: any) => {
|
|
57
|
-
emit('select', info.event)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const handleEventClick = (info: any) => {
|
|
61
|
-
emit('dialog', true)
|
|
62
|
-
emit('select', info.event)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const eventContentDay = (arg: any) => {
|
|
66
|
-
const list = document.createElement('div')
|
|
67
|
-
list.innerHTML = document.getElementById(arg.event.id.toString())?.innerHTML || ''
|
|
68
|
-
return { domNodes: [list] }
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// @ts-expect-error
|
|
72
|
-
const calendarOptions = ref<CalendarOptions>({
|
|
73
|
-
plugins: [dayGridPlugin, timeGridPlugin, listPlugin, interactionPlugin],
|
|
74
|
-
initialView: props.mode,
|
|
75
|
-
locale: props.locale,
|
|
76
|
-
dayMaxEvents: true,
|
|
77
|
-
timeZone: 'UTC',
|
|
78
|
-
headerToolbar: {
|
|
79
|
-
left: props.toolBarLeft,
|
|
80
|
-
center: props.toolBarCenter,
|
|
81
|
-
right: props.toolBarRight,
|
|
82
|
-
},
|
|
83
|
-
buttonText: buttonText.value,
|
|
84
|
-
events: props.modelValue,
|
|
85
|
-
initialDate: props.selectViewDay,
|
|
86
|
-
dateClick: handleDateClick,
|
|
87
|
-
eventClick: handleEventClick,
|
|
88
|
-
nowIndicator: true,
|
|
89
|
-
height: props.height,
|
|
90
|
-
eventColor: '#378006',
|
|
91
|
-
})
|
|
92
|
-
</script>
|
|
93
|
-
|
|
94
|
-
<template>
|
|
95
|
-
<FullCalendar
|
|
96
|
-
ref="calendarRef"
|
|
97
|
-
:options="calendarOptions as CalendarOptions"
|
|
98
|
-
/>
|
|
99
|
-
</template>
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import FullCalendar from '@fullcalendar/vue3'
|
|
3
|
+
import dayGridPlugin from '@fullcalendar/daygrid'
|
|
4
|
+
import timeGridPlugin from '@fullcalendar/timegrid'
|
|
5
|
+
import listPlugin from '@fullcalendar/list'
|
|
6
|
+
import interactionPlugin from '@fullcalendar/interaction'
|
|
7
|
+
import { ref, computed, withDefaults } from 'vue'
|
|
8
|
+
import { type CalendarOptions } from '@fullcalendar/core'
|
|
9
|
+
|
|
10
|
+
type Event = {
|
|
11
|
+
id: string | undefined
|
|
12
|
+
title: string
|
|
13
|
+
start: string // YYYY-MM-DD | YYYY-MM-DD HH:mm:ss
|
|
14
|
+
end: string // YYYY-MM-DD
|
|
15
|
+
color: string
|
|
16
|
+
detail?: string
|
|
17
|
+
props: Record<string, any> | any[]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface CalendarProps {
|
|
21
|
+
modelValue: Event[]
|
|
22
|
+
locale?: 'th' | 'en'
|
|
23
|
+
toolBarLeft?: string
|
|
24
|
+
toolBarCenter?: string
|
|
25
|
+
toolBarRight?: string
|
|
26
|
+
height?: string | number
|
|
27
|
+
selectViewDay?: string
|
|
28
|
+
mode: 'dayGridMonth' | 'timeGridDay'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const props = withDefaults(defineProps<CalendarProps>(), {
|
|
32
|
+
locale: 'th',
|
|
33
|
+
height: 1200,
|
|
34
|
+
toolBarLeft: 'today prev,next',
|
|
35
|
+
toolBarCenter: 'title',
|
|
36
|
+
toolBarRight: 'timeGridDay,timeGridWeek,dayGridMonth',
|
|
37
|
+
mode: 'dayGridMonth',
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const emit = defineEmits(['select', 'dialog'])
|
|
41
|
+
|
|
42
|
+
const buttonText = computed(() => {
|
|
43
|
+
return {
|
|
44
|
+
today: props.locale === 'th' ? 'วันนี้' : 'today',
|
|
45
|
+
month: props.locale === 'th' ? 'เดือน' : 'month',
|
|
46
|
+
week: props.locale === 'th' ? 'สัปดาห์' : 'week',
|
|
47
|
+
day: props.locale === 'th' ? 'วัน' : 'day',
|
|
48
|
+
list: props.locale === 'th' ? 'รายการ' : 'list',
|
|
49
|
+
year: props.locale === 'th' ? 'ปี' : 'year',
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
const calendarRef = ref<InstanceType<typeof FullCalendar>>()
|
|
54
|
+
const dateViewDay = ref({ date: '', props: {} })
|
|
55
|
+
|
|
56
|
+
const handleDateClick = (info: any) => {
|
|
57
|
+
emit('select', info.event)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const handleEventClick = (info: any) => {
|
|
61
|
+
emit('dialog', true)
|
|
62
|
+
emit('select', info.event)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const eventContentDay = (arg: any) => {
|
|
66
|
+
const list = document.createElement('div')
|
|
67
|
+
list.innerHTML = document.getElementById(arg.event.id.toString())?.innerHTML || ''
|
|
68
|
+
return { domNodes: [list] }
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// @ts-expect-error
|
|
72
|
+
const calendarOptions = ref<CalendarOptions>({
|
|
73
|
+
plugins: [dayGridPlugin, timeGridPlugin, listPlugin, interactionPlugin],
|
|
74
|
+
initialView: props.mode,
|
|
75
|
+
locale: props.locale,
|
|
76
|
+
dayMaxEvents: true,
|
|
77
|
+
timeZone: 'UTC',
|
|
78
|
+
headerToolbar: {
|
|
79
|
+
left: props.toolBarLeft,
|
|
80
|
+
center: props.toolBarCenter,
|
|
81
|
+
right: props.toolBarRight,
|
|
82
|
+
},
|
|
83
|
+
buttonText: buttonText.value,
|
|
84
|
+
events: props.modelValue,
|
|
85
|
+
initialDate: props.selectViewDay,
|
|
86
|
+
dateClick: handleDateClick,
|
|
87
|
+
eventClick: handleEventClick,
|
|
88
|
+
nowIndicator: true,
|
|
89
|
+
height: props.height,
|
|
90
|
+
eventColor: '#378006',
|
|
91
|
+
})
|
|
92
|
+
</script>
|
|
93
|
+
|
|
94
|
+
<template>
|
|
95
|
+
<FullCalendar
|
|
96
|
+
ref="calendarRef"
|
|
97
|
+
:options="calendarOptions as CalendarOptions"
|
|
98
|
+
/>
|
|
99
|
+
</template>
|