@finema/finework-layer 0.2.65 → 0.2.66
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/.husky/pre-commit +1 -1
- package/.playground/app/pages/layout-admin/[id]/index.vue +145 -145
- package/.playground/app/pages/layout-admin/test/[id]/index.vue +286 -286
- package/.playground/app/pages/layout-admin.vue +275 -275
- package/.playground/app/pages/submenu/layout-admin.vue +210 -210
- package/.vscode/extensions.json +0 -1
- package/CHANGELOG.md +336 -334
- package/app/app.config.ts +136 -136
- package/app/app.vue +10 -10
- package/app/assets/css/main.css +75 -75
- package/app/components/Button/ActionIcon.vue +29 -29
- package/app/components/Button/Back.vue +22 -22
- package/app/components/InfoItemList.vue +196 -196
- package/app/components/Layout/Admin/Sidebar.vue +329 -329
- package/app/components/Layout/Admin/index.vue +224 -224
- package/app/components/Layout/Apps.vue +45 -45
- package/app/components/Layout/User/index.vue +99 -99
- package/app/components/StatusBox.vue +56 -56
- package/app/composables/useRequestOptions.ts +50 -50
- package/app/constants/routes.ts +86 -86
- package/app/error.vue +218 -218
- package/app/middleware/auth.ts +45 -45
- package/app/middleware/common.ts +12 -12
- package/app/middleware/guest.ts +7 -7
- package/app/middleware/permissions.ts +29 -29
- package/bun.lock +2 -2
- package/index.d.ts +16 -16
- package/nuxt.config.ts +41 -41
- package/package.json +2 -2
|
@@ -1,196 +1,196 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
:class="[
|
|
4
|
-
'grid w-full gap-4',
|
|
5
|
-
{
|
|
6
|
-
'lg:grid-cols-2': !vertical,
|
|
7
|
-
},
|
|
8
|
-
customClass,
|
|
9
|
-
]"
|
|
10
|
-
>
|
|
11
|
-
<div
|
|
12
|
-
v-for="item in items"
|
|
13
|
-
:key="item.label"
|
|
14
|
-
:class="[
|
|
15
|
-
'lg:flex',
|
|
16
|
-
{
|
|
17
|
-
'flex-col': !inline,
|
|
18
|
-
'flex-row': inline,
|
|
19
|
-
},
|
|
20
|
-
item.customClass,
|
|
21
|
-
|
|
22
|
-
]"
|
|
23
|
-
>
|
|
24
|
-
<template v-if="!item.hide">
|
|
25
|
-
<p
|
|
26
|
-
v-if="item.type !== TYPE_INFO_ITEM.BOOLEAN"
|
|
27
|
-
:class="[
|
|
28
|
-
'mb-1',
|
|
29
|
-
{
|
|
30
|
-
'mb-1 block text-sm text-gray-500': !inline,
|
|
31
|
-
'mr-2 text-gray-500': inline,
|
|
32
|
-
},
|
|
33
|
-
]"
|
|
34
|
-
>
|
|
35
|
-
{{ item.label }}
|
|
36
|
-
</p>
|
|
37
|
-
<component
|
|
38
|
-
:is="item.component"
|
|
39
|
-
v-if="item.component"
|
|
40
|
-
v-bind="item.props"
|
|
41
|
-
/>
|
|
42
|
-
<slot
|
|
43
|
-
v-else-if="item.key && $slots[`${item.key}-item`]"
|
|
44
|
-
:name="`${item.key}-item`"
|
|
45
|
-
:row="item"
|
|
46
|
-
:item="item"
|
|
47
|
-
:value="item.value"
|
|
48
|
-
:label="item.label"
|
|
49
|
-
/>
|
|
50
|
-
<div
|
|
51
|
-
v-else
|
|
52
|
-
class="break-words whitespace-pre-line text-gray-900"
|
|
53
|
-
>
|
|
54
|
-
<span
|
|
55
|
-
v-if="shouldTruncateText(item)"
|
|
56
|
-
v-show="!expandedItems[item.label]"
|
|
57
|
-
>
|
|
58
|
-
{{ truncateText(item.value || '-', item.max || 0) }}
|
|
59
|
-
<button
|
|
60
|
-
class="
|
|
61
|
-
text-info-600 ml-1 cursor-pointer text-sm
|
|
62
|
-
hover:text-info-800
|
|
63
|
-
"
|
|
64
|
-
@click="toggleExpanded(item.label)"
|
|
65
|
-
>
|
|
66
|
-
เพิ่มเติม
|
|
67
|
-
</button>
|
|
68
|
-
</span>
|
|
69
|
-
<span
|
|
70
|
-
v-if="shouldTruncateText(item)"
|
|
71
|
-
v-show="expandedItems[item.label]"
|
|
72
|
-
>
|
|
73
|
-
{{ item.value || '-' }}
|
|
74
|
-
<button
|
|
75
|
-
class="
|
|
76
|
-
text-info-600 ml-1 cursor-pointer text-sm
|
|
77
|
-
hover:text-info-800
|
|
78
|
-
"
|
|
79
|
-
@click="toggleExpanded(item.label)"
|
|
80
|
-
>
|
|
81
|
-
แสดงน้อยลง
|
|
82
|
-
</button>
|
|
83
|
-
</span>
|
|
84
|
-
<!-- <span >
|
|
85
|
-
<Icon
|
|
86
|
-
class="size-5"
|
|
87
|
-
:class="item.value ? 'text-success' : 'text-error'"
|
|
88
|
-
:name="item.value
|
|
89
|
-
? 'material-symbols:check-circle-outline-rounded'
|
|
90
|
-
: 'material-symbols:cancel-outline-rounded'"
|
|
91
|
-
/>
|
|
92
|
-
</span> -->
|
|
93
|
-
<Checkbox
|
|
94
|
-
v-if="item.type === TYPE_INFO_ITEM.BOOLEAN"
|
|
95
|
-
v-model="item.value"
|
|
96
|
-
:label="item.label"
|
|
97
|
-
class="pointer-events-none"
|
|
98
|
-
/>
|
|
99
|
-
<span
|
|
100
|
-
v-else-if="!shouldTruncateText(item)"
|
|
101
|
-
:class="[
|
|
102
|
-
{
|
|
103
|
-
'font-bold': item.label,
|
|
104
|
-
},
|
|
105
|
-
]"
|
|
106
|
-
>
|
|
107
|
-
{{ getValue(item) }}
|
|
108
|
-
</span>
|
|
109
|
-
</div>
|
|
110
|
-
</template>
|
|
111
|
-
</div>
|
|
112
|
-
</div>
|
|
113
|
-
</template>
|
|
114
|
-
|
|
115
|
-
<script lang="ts" setup>
|
|
116
|
-
import { reactive } from 'vue'
|
|
117
|
-
|
|
118
|
-
enum TYPE_INFO_ITEM {
|
|
119
|
-
TEXT = 'text',
|
|
120
|
-
NUMBER = 'number',
|
|
121
|
-
CURRENCY = 'currency',
|
|
122
|
-
DATE = 'date',
|
|
123
|
-
DATE_TIME = 'date_time',
|
|
124
|
-
BOOLEAN = 'boolean',
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
defineProps<{
|
|
128
|
-
items: Array<{
|
|
129
|
-
label: string
|
|
130
|
-
value?: any
|
|
131
|
-
component?: any
|
|
132
|
-
props?: Record<string, any>
|
|
133
|
-
max?: number
|
|
134
|
-
key?: string
|
|
135
|
-
type?: TYPE_INFO_ITEM
|
|
136
|
-
customClass?: string
|
|
137
|
-
hide?: boolean
|
|
138
|
-
}>
|
|
139
|
-
vertical?: boolean
|
|
140
|
-
inline?: boolean
|
|
141
|
-
customClass?: string
|
|
142
|
-
|
|
143
|
-
}>()
|
|
144
|
-
|
|
145
|
-
const expandedItems = reactive<Record<string, boolean>>({})
|
|
146
|
-
|
|
147
|
-
const shouldTruncateText = (item: any): boolean => {
|
|
148
|
-
return item.max && item.value && item.value.length > item.max
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const truncateText = (text: string, maxLength: number): string => {
|
|
152
|
-
if (!maxLength || text.length <= maxLength) return text
|
|
153
|
-
|
|
154
|
-
return text.slice(0, maxLength) + '...'
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const toggleExpanded = (label: string): void => {
|
|
158
|
-
expandedItems[label] = !expandedItems[label]
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
const getValue = (item: any): string => {
|
|
162
|
-
if (item.type === TYPE_INFO_ITEM.DATE) {
|
|
163
|
-
return item.value
|
|
164
|
-
? TimeHelper.displayDate(item.value) ?? '-'
|
|
165
|
-
: '-'
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
if (item.type === TYPE_INFO_ITEM.DATE_TIME) {
|
|
169
|
-
return item.value
|
|
170
|
-
? TimeHelper.displayDateTime(item.value) ?? '-'
|
|
171
|
-
: '-'
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (item.value === undefined || item.value === null) {
|
|
175
|
-
return '-'
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if (typeof item.value === 'number') {
|
|
179
|
-
if (item.type === 'currency') {
|
|
180
|
-
return NumberHelper.toCurrency(item.value)
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return NumberHelper.withFixed(item.value)
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
if (item.type === 'currency') {
|
|
187
|
-
return NumberHelper.toCurrency(item.value)
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (item.type === 'number') {
|
|
191
|
-
return NumberHelper.withFixed(item.value)
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return item.value || '-'
|
|
195
|
-
}
|
|
196
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:class="[
|
|
4
|
+
'grid w-full gap-4',
|
|
5
|
+
{
|
|
6
|
+
'lg:grid-cols-2': !vertical,
|
|
7
|
+
},
|
|
8
|
+
customClass,
|
|
9
|
+
]"
|
|
10
|
+
>
|
|
11
|
+
<div
|
|
12
|
+
v-for="item in items"
|
|
13
|
+
:key="item.label"
|
|
14
|
+
:class="[
|
|
15
|
+
'lg:flex',
|
|
16
|
+
{
|
|
17
|
+
'flex-col': !inline,
|
|
18
|
+
'flex-row': inline,
|
|
19
|
+
},
|
|
20
|
+
item.customClass,
|
|
21
|
+
|
|
22
|
+
]"
|
|
23
|
+
>
|
|
24
|
+
<template v-if="!item.hide">
|
|
25
|
+
<p
|
|
26
|
+
v-if="item.type !== TYPE_INFO_ITEM.BOOLEAN"
|
|
27
|
+
:class="[
|
|
28
|
+
'mb-1',
|
|
29
|
+
{
|
|
30
|
+
'mb-1 block text-sm text-gray-500': !inline,
|
|
31
|
+
'mr-2 text-gray-500': inline,
|
|
32
|
+
},
|
|
33
|
+
]"
|
|
34
|
+
>
|
|
35
|
+
{{ item.label }}
|
|
36
|
+
</p>
|
|
37
|
+
<component
|
|
38
|
+
:is="item.component"
|
|
39
|
+
v-if="item.component"
|
|
40
|
+
v-bind="item.props"
|
|
41
|
+
/>
|
|
42
|
+
<slot
|
|
43
|
+
v-else-if="item.key && $slots[`${item.key}-item`]"
|
|
44
|
+
:name="`${item.key}-item`"
|
|
45
|
+
:row="item"
|
|
46
|
+
:item="item"
|
|
47
|
+
:value="item.value"
|
|
48
|
+
:label="item.label"
|
|
49
|
+
/>
|
|
50
|
+
<div
|
|
51
|
+
v-else
|
|
52
|
+
class="break-words whitespace-pre-line text-gray-900"
|
|
53
|
+
>
|
|
54
|
+
<span
|
|
55
|
+
v-if="shouldTruncateText(item)"
|
|
56
|
+
v-show="!expandedItems[item.label]"
|
|
57
|
+
>
|
|
58
|
+
{{ truncateText(item.value || '-', item.max || 0) }}
|
|
59
|
+
<button
|
|
60
|
+
class="
|
|
61
|
+
text-info-600 ml-1 cursor-pointer text-sm
|
|
62
|
+
hover:text-info-800
|
|
63
|
+
"
|
|
64
|
+
@click="toggleExpanded(item.label)"
|
|
65
|
+
>
|
|
66
|
+
เพิ่มเติม
|
|
67
|
+
</button>
|
|
68
|
+
</span>
|
|
69
|
+
<span
|
|
70
|
+
v-if="shouldTruncateText(item)"
|
|
71
|
+
v-show="expandedItems[item.label]"
|
|
72
|
+
>
|
|
73
|
+
{{ item.value || '-' }}
|
|
74
|
+
<button
|
|
75
|
+
class="
|
|
76
|
+
text-info-600 ml-1 cursor-pointer text-sm
|
|
77
|
+
hover:text-info-800
|
|
78
|
+
"
|
|
79
|
+
@click="toggleExpanded(item.label)"
|
|
80
|
+
>
|
|
81
|
+
แสดงน้อยลง
|
|
82
|
+
</button>
|
|
83
|
+
</span>
|
|
84
|
+
<!-- <span >
|
|
85
|
+
<Icon
|
|
86
|
+
class="size-5"
|
|
87
|
+
:class="item.value ? 'text-success' : 'text-error'"
|
|
88
|
+
:name="item.value
|
|
89
|
+
? 'material-symbols:check-circle-outline-rounded'
|
|
90
|
+
: 'material-symbols:cancel-outline-rounded'"
|
|
91
|
+
/>
|
|
92
|
+
</span> -->
|
|
93
|
+
<Checkbox
|
|
94
|
+
v-if="item.type === TYPE_INFO_ITEM.BOOLEAN"
|
|
95
|
+
v-model="item.value"
|
|
96
|
+
:label="item.label"
|
|
97
|
+
class="pointer-events-none"
|
|
98
|
+
/>
|
|
99
|
+
<span
|
|
100
|
+
v-else-if="!shouldTruncateText(item)"
|
|
101
|
+
:class="[
|
|
102
|
+
{
|
|
103
|
+
'font-bold': item.label,
|
|
104
|
+
},
|
|
105
|
+
]"
|
|
106
|
+
>
|
|
107
|
+
{{ getValue(item) }}
|
|
108
|
+
</span>
|
|
109
|
+
</div>
|
|
110
|
+
</template>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
</template>
|
|
114
|
+
|
|
115
|
+
<script lang="ts" setup>
|
|
116
|
+
import { reactive } from 'vue'
|
|
117
|
+
|
|
118
|
+
enum TYPE_INFO_ITEM {
|
|
119
|
+
TEXT = 'text',
|
|
120
|
+
NUMBER = 'number',
|
|
121
|
+
CURRENCY = 'currency',
|
|
122
|
+
DATE = 'date',
|
|
123
|
+
DATE_TIME = 'date_time',
|
|
124
|
+
BOOLEAN = 'boolean',
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
defineProps<{
|
|
128
|
+
items: Array<{
|
|
129
|
+
label: string
|
|
130
|
+
value?: any
|
|
131
|
+
component?: any
|
|
132
|
+
props?: Record<string, any>
|
|
133
|
+
max?: number
|
|
134
|
+
key?: string
|
|
135
|
+
type?: TYPE_INFO_ITEM
|
|
136
|
+
customClass?: string
|
|
137
|
+
hide?: boolean
|
|
138
|
+
}>
|
|
139
|
+
vertical?: boolean
|
|
140
|
+
inline?: boolean
|
|
141
|
+
customClass?: string
|
|
142
|
+
|
|
143
|
+
}>()
|
|
144
|
+
|
|
145
|
+
const expandedItems = reactive<Record<string, boolean>>({})
|
|
146
|
+
|
|
147
|
+
const shouldTruncateText = (item: any): boolean => {
|
|
148
|
+
return item.max && item.value && item.value.length > item.max
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const truncateText = (text: string, maxLength: number): string => {
|
|
152
|
+
if (!maxLength || text.length <= maxLength) return text
|
|
153
|
+
|
|
154
|
+
return text.slice(0, maxLength) + '...'
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const toggleExpanded = (label: string): void => {
|
|
158
|
+
expandedItems[label] = !expandedItems[label]
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const getValue = (item: any): string => {
|
|
162
|
+
if (item.type === TYPE_INFO_ITEM.DATE) {
|
|
163
|
+
return item.value
|
|
164
|
+
? TimeHelper.displayDate(item.value) ?? '-'
|
|
165
|
+
: '-'
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (item.type === TYPE_INFO_ITEM.DATE_TIME) {
|
|
169
|
+
return item.value
|
|
170
|
+
? TimeHelper.displayDateTime(item.value) ?? '-'
|
|
171
|
+
: '-'
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (item.value === undefined || item.value === null) {
|
|
175
|
+
return '-'
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (typeof item.value === 'number') {
|
|
179
|
+
if (item.type === 'currency') {
|
|
180
|
+
return NumberHelper.toCurrency(item.value)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return NumberHelper.withFixed(item.value)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (item.type === 'currency') {
|
|
187
|
+
return NumberHelper.toCurrency(item.value)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (item.type === 'number') {
|
|
191
|
+
return NumberHelper.withFixed(item.value)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return item.value || '-'
|
|
195
|
+
}
|
|
196
|
+
</script>
|