@ramathibodi/nuxt-commons 0.1.66 → 0.1.68
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/runtime/components/form/ActionPad.vue +1 -1
- package/dist/runtime/components/form/Dialog.vue +1 -1
- package/dist/runtime/components/form/EditPad.vue +1 -1
- package/dist/runtime/components/form/Iterator.vue +0 -2
- package/dist/runtime/components/form/Pad.vue +1 -0
- package/dist/runtime/components/label/DateCount.vue +4 -3
- package/dist/runtime/components/pdf/View.vue +42 -32
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -85,7 +85,7 @@ const loadFormData = () => {
|
|
|
85
85
|
formDataOriginalValue.value = cloneDeep(props.formData)
|
|
86
86
|
}
|
|
87
87
|
else {
|
|
88
|
-
formData.value = Object.assign({}, props.initialData)
|
|
88
|
+
formData.value = Object.assign({}, cloneDeep(props.initialData))
|
|
89
89
|
}
|
|
90
90
|
isSavedAndStay.value = false
|
|
91
91
|
}
|
|
@@ -497,8 +497,6 @@ defineExpose({
|
|
|
497
497
|
show-first-last-page
|
|
498
498
|
@first="footerProps.setPage(1)"
|
|
499
499
|
@last="footerProps.setPage(footerProps.pageCount)"
|
|
500
|
-
@next="footerProps.nextPage"
|
|
501
|
-
@prev="footerProps.prevPage"
|
|
502
500
|
@update:model-value="footerProps.setPage"
|
|
503
501
|
/>
|
|
504
502
|
</v-row>
|
|
@@ -137,7 +137,8 @@ const outputText = computed(() => {
|
|
|
137
137
|
</script>
|
|
138
138
|
|
|
139
139
|
<template>
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
140
|
+
<span>
|
|
141
|
+
<i v-if="props.zeroBase" class="mdi mdi-clock-time-twelve-outline"></i>
|
|
142
|
+
<span v-if="props.zeroBase"> </span>{{ outputText }}
|
|
143
|
+
</span>
|
|
143
144
|
</template>
|
|
@@ -15,12 +15,12 @@ interface Props extends /* @vue-ignore */ InstanceType<typeof PDF['$props']> {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
const props = withDefaults(defineProps<Props>(), {
|
|
18
|
-
base64String:
|
|
19
|
-
title:
|
|
20
|
-
fileName:
|
|
18
|
+
base64String: '',
|
|
19
|
+
title: '',
|
|
20
|
+
fileName: '',
|
|
21
21
|
disabled: false,
|
|
22
22
|
isPrint: false,
|
|
23
|
-
showBackToTopBtn: false
|
|
23
|
+
showBackToTopBtn: false,
|
|
24
24
|
})
|
|
25
25
|
|
|
26
26
|
const emit = defineEmits(['closeDialog'])
|
|
@@ -33,25 +33,34 @@ const generateUniqueId = (): string => {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
const downloadPdf = (): void => {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
try {
|
|
37
|
+
if (!props.base64String) alert?.addAlert({ message: 'No Base64 provided', alertType: 'error' })
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
byteArray
|
|
41
|
-
}
|
|
39
|
+
const byteString = atob(props.base64String || '')
|
|
40
|
+
const byteArray = new Uint8Array(byteString.length)
|
|
42
41
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
42
|
+
for (let i = 0; i < byteString.length; i++) {
|
|
43
|
+
byteArray[i] = byteString.charCodeAt(i)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const blob = new Blob([byteArray], { type: 'application/pdf' })
|
|
47
|
+
const link = URL.createObjectURL(blob)
|
|
48
|
+
const anchorElement = document.createElement('a')
|
|
49
|
+
anchorElement.style.display = 'none'
|
|
50
|
+
anchorElement.href = link
|
|
51
|
+
anchorElement.download = `${generateUniqueId()}.pdf`
|
|
52
|
+
|
|
53
|
+
document.body.appendChild(anchorElement)
|
|
54
|
+
anchorElement.click()
|
|
55
|
+
URL.revokeObjectURL(link)
|
|
56
|
+
document.body.removeChild(anchorElement)
|
|
57
|
+
base64.value = ''
|
|
58
|
+
|
|
59
|
+
alert?.addAlert({ message: 'Download success', alertType: 'success' })
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
alert?.addAlert({ message: `Download unsuccess : ${error}`, alertType: 'error' })
|
|
63
|
+
}
|
|
55
64
|
}
|
|
56
65
|
|
|
57
66
|
const printPdf = () => {
|
|
@@ -60,7 +69,7 @@ const printPdf = () => {
|
|
|
60
69
|
type: 'pdf',
|
|
61
70
|
base64: true,
|
|
62
71
|
onPrintDialogClose: endLoadPdf,
|
|
63
|
-
onError: (error
|
|
72
|
+
onError: (error) => {
|
|
64
73
|
alert?.addAlert({ message: error, alertType: 'error' })
|
|
65
74
|
},
|
|
66
75
|
})
|
|
@@ -73,18 +82,19 @@ const endLoadPdf = () => {
|
|
|
73
82
|
}
|
|
74
83
|
|
|
75
84
|
const isMobile = () => {
|
|
76
|
-
return /Android|Mobi|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Macintosh/i.test(navigator.userAgent)
|
|
85
|
+
return /Android|Mobi|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Macintosh/i.test(navigator.userAgent)
|
|
77
86
|
}
|
|
78
87
|
|
|
79
88
|
const checkMobileAndPrint = computed(() => {
|
|
80
|
-
return !isMobile() && props.isPrint
|
|
81
|
-
})
|
|
89
|
+
return !isMobile() && props.isPrint
|
|
90
|
+
})
|
|
82
91
|
|
|
83
92
|
const setWidthPdf = computed(() => {
|
|
84
93
|
if (isMobile()) {
|
|
85
|
-
return
|
|
86
|
-
}
|
|
87
|
-
|
|
94
|
+
return '100%'
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
return '100dvh'
|
|
88
98
|
}
|
|
89
99
|
})
|
|
90
100
|
</script>
|
|
@@ -114,10 +124,10 @@ const setWidthPdf = computed(() => {
|
|
|
114
124
|
</v-toolbar>
|
|
115
125
|
<v-card-text class="justify-center h-screen">
|
|
116
126
|
<PDF
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
127
|
+
v-bind="$attrs"
|
|
128
|
+
:pdf-width="setWidthPdf"
|
|
129
|
+
:src="base64"
|
|
130
|
+
:show-back-to-top-btn="props.showBackToTopBtn"
|
|
121
131
|
/>
|
|
122
132
|
</v-card-text>
|
|
123
133
|
</v-card>
|