@finema/core 1.4.21 → 1.4.22
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 +60 -60
- package/dist/module.d.mts +4 -4
- package/dist/module.d.ts +4 -4
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/components/Alert.vue +49 -49
- package/dist/runtime/components/Avatar.vue +27 -27
- package/dist/runtime/components/Badge.vue +54 -54
- package/dist/runtime/components/Breadcrumb.vue +45 -45
- package/dist/runtime/components/Button/Group.vue +37 -37
- package/dist/runtime/components/Button/index.vue +77 -77
- package/dist/runtime/components/Card.vue +38 -38
- package/dist/runtime/components/Core.vue +13 -13
- package/dist/runtime/components/Dialog/index.vue +98 -98
- package/dist/runtime/components/Dropdown/index.vue +81 -81
- package/dist/runtime/components/Form/FieldWrapper.vue +21 -21
- package/dist/runtime/components/Form/Fields.vue +129 -129
- package/dist/runtime/components/Form/InputCheckbox/index.vue +21 -21
- package/dist/runtime/components/Form/InputDateTime/index.vue +51 -51
- package/dist/runtime/components/Form/InputRadio/index.vue +27 -27
- package/dist/runtime/components/Form/InputSelect/index.vue +37 -37
- package/dist/runtime/components/Form/InputStatic/index.vue +16 -16
- package/dist/runtime/components/Form/InputText/index.vue +27 -27
- package/dist/runtime/components/Form/InputTextarea/index.vue +25 -25
- package/dist/runtime/components/Form/InputToggle/index.vue +14 -14
- package/dist/runtime/components/Form/InputUploadFileClassic/index.vue +36 -36
- package/dist/runtime/components/Form/index.vue +6 -6
- package/dist/runtime/components/Icon.vue +23 -23
- package/dist/runtime/components/Image.vue +36 -36
- package/dist/runtime/components/Loader.vue +4 -4
- package/dist/runtime/components/Modal/index.vue +146 -146
- package/dist/runtime/components/Slideover/index.vue +110 -110
- package/dist/runtime/components/Table/Base.vue +6 -2
- package/dist/runtime/components/Table/ColumnDate.vue +16 -16
- package/dist/runtime/components/Table/ColumnDateTime.vue +30 -30
- package/dist/runtime/components/Table/ColumnImage.vue +13 -13
- package/dist/runtime/components/Table/ColumnNumber.vue +14 -14
- package/dist/runtime/components/Table/Simple.vue +57 -53
- package/dist/runtime/components/Table/index.vue +51 -47
- package/dist/runtime/components/Table/types.d.ts +0 -1
- package/dist/runtime/components/Tabs/index.vue +65 -65
- package/dist/runtime/types/utils.d.ts +29 -29
- package/dist/runtime/ui.css +32 -32
- package/package.json +83 -83
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<USlideover
|
|
3
|
-
v-bind="attrs"
|
|
4
|
-
:model-value="modelValue"
|
|
5
|
-
:class="$props.class"
|
|
6
|
-
:prevent-close="preventClose"
|
|
7
|
-
:overlay="overlay"
|
|
8
|
-
:transition="transition"
|
|
9
|
-
:side="side"
|
|
10
|
-
:initial-focus="emptyFocusRef"
|
|
11
|
-
:ui="ui"
|
|
12
|
-
@update:model-value="$emit('update:modelValue', $event)"
|
|
13
|
-
>
|
|
14
|
-
<div v-if="!isHideCloseBtn && preventClose" class="absolute right-0 m-4">
|
|
15
|
-
<Icon
|
|
16
|
-
v-if="!isHideCloseBtn"
|
|
17
|
-
name="i-heroicons-x-mark"
|
|
18
|
-
class="h-6 w-6 cursor-pointer"
|
|
19
|
-
@click="close"
|
|
20
|
-
/>
|
|
21
|
-
</div>
|
|
22
|
-
|
|
23
|
-
<div :class="['overflow-y-auto', ui.bodyWrapper]">
|
|
24
|
-
<slot />
|
|
25
|
-
</div>
|
|
26
|
-
</USlideover>
|
|
27
|
-
|
|
28
|
-
<div ref="emptyFocusRef" />
|
|
29
|
-
</template>
|
|
30
|
-
|
|
31
|
-
<script lang="ts" setup>
|
|
32
|
-
import { ref, type PropType, toRef, defineShortcuts, watch } from '#imports'
|
|
33
|
-
import type { Strategy } from '#core/types/utils'
|
|
34
|
-
import { useUI } from '#ui/composables/useUI'
|
|
35
|
-
import { slideover } from '#core/ui.config'
|
|
36
|
-
import { useUiConfig } from '#core/composables/useConfig'
|
|
37
|
-
|
|
38
|
-
const config = useUiConfig<typeof slideover>(slideover, 'slideover')
|
|
39
|
-
|
|
40
|
-
const props = defineProps({
|
|
41
|
-
modelValue: {
|
|
42
|
-
type: Boolean as PropType<boolean>,
|
|
43
|
-
default: false,
|
|
44
|
-
},
|
|
45
|
-
side: {
|
|
46
|
-
type: String as PropType<'left' | 'right'>,
|
|
47
|
-
default: 'right',
|
|
48
|
-
validator: (value: string) => ['left', 'right'].includes(value),
|
|
49
|
-
},
|
|
50
|
-
overlay: {
|
|
51
|
-
type: Boolean,
|
|
52
|
-
default: true,
|
|
53
|
-
},
|
|
54
|
-
preventClose: {
|
|
55
|
-
type: Boolean,
|
|
56
|
-
default: false,
|
|
57
|
-
},
|
|
58
|
-
isHideCloseBtn: {
|
|
59
|
-
type: Boolean,
|
|
60
|
-
default: false,
|
|
61
|
-
},
|
|
62
|
-
transition: {
|
|
63
|
-
type: Boolean,
|
|
64
|
-
default: true,
|
|
65
|
-
},
|
|
66
|
-
size: {
|
|
67
|
-
type: String as PropType<keyof typeof slideover.size>,
|
|
68
|
-
default: () => slideover.default.size,
|
|
69
|
-
},
|
|
70
|
-
class: {
|
|
71
|
-
type: [String, Array, Object] as PropType<any>,
|
|
72
|
-
default: undefined,
|
|
73
|
-
},
|
|
74
|
-
ui: {
|
|
75
|
-
type: Object as PropType<Partial<typeof config & { strategy?: Strategy }>>,
|
|
76
|
-
default: undefined,
|
|
77
|
-
},
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
const emits = defineEmits(['update:modelValue'])
|
|
81
|
-
|
|
82
|
-
const emptyFocusRef = ref<HTMLElement | null>(null)
|
|
83
|
-
|
|
84
|
-
defineShortcuts({
|
|
85
|
-
escape: {
|
|
86
|
-
usingInput: true,
|
|
87
|
-
handler: () => {
|
|
88
|
-
if (props.preventClose) return
|
|
89
|
-
emits('update:modelValue', false)
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
const close = () => {
|
|
95
|
-
emits('update:modelValue', false)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const { ui, attrs } = useUI('slideover', toRef(props, 'ui'), config, toRef(props, 'class'))
|
|
99
|
-
|
|
100
|
-
watch(
|
|
101
|
-
() => props.modelValue,
|
|
102
|
-
() => {
|
|
103
|
-
if (props.modelValue) {
|
|
104
|
-
const size = config.size[props.size]
|
|
105
|
-
|
|
106
|
-
ui.value.width = size
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
)
|
|
110
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<USlideover
|
|
3
|
+
v-bind="attrs"
|
|
4
|
+
:model-value="modelValue"
|
|
5
|
+
:class="$props.class"
|
|
6
|
+
:prevent-close="preventClose"
|
|
7
|
+
:overlay="overlay"
|
|
8
|
+
:transition="transition"
|
|
9
|
+
:side="side"
|
|
10
|
+
:initial-focus="emptyFocusRef"
|
|
11
|
+
:ui="ui"
|
|
12
|
+
@update:model-value="$emit('update:modelValue', $event)"
|
|
13
|
+
>
|
|
14
|
+
<div v-if="!isHideCloseBtn && preventClose" class="absolute right-0 m-4">
|
|
15
|
+
<Icon
|
|
16
|
+
v-if="!isHideCloseBtn"
|
|
17
|
+
name="i-heroicons-x-mark"
|
|
18
|
+
class="h-6 w-6 cursor-pointer"
|
|
19
|
+
@click="close"
|
|
20
|
+
/>
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
<div :class="['overflow-y-auto', ui.bodyWrapper]">
|
|
24
|
+
<slot />
|
|
25
|
+
</div>
|
|
26
|
+
</USlideover>
|
|
27
|
+
|
|
28
|
+
<div ref="emptyFocusRef" />
|
|
29
|
+
</template>
|
|
30
|
+
|
|
31
|
+
<script lang="ts" setup>
|
|
32
|
+
import { ref, type PropType, toRef, defineShortcuts, watch } from '#imports'
|
|
33
|
+
import type { Strategy } from '#core/types/utils'
|
|
34
|
+
import { useUI } from '#ui/composables/useUI'
|
|
35
|
+
import { slideover } from '#core/ui.config'
|
|
36
|
+
import { useUiConfig } from '#core/composables/useConfig'
|
|
37
|
+
|
|
38
|
+
const config = useUiConfig<typeof slideover>(slideover, 'slideover')
|
|
39
|
+
|
|
40
|
+
const props = defineProps({
|
|
41
|
+
modelValue: {
|
|
42
|
+
type: Boolean as PropType<boolean>,
|
|
43
|
+
default: false,
|
|
44
|
+
},
|
|
45
|
+
side: {
|
|
46
|
+
type: String as PropType<'left' | 'right'>,
|
|
47
|
+
default: 'right',
|
|
48
|
+
validator: (value: string) => ['left', 'right'].includes(value),
|
|
49
|
+
},
|
|
50
|
+
overlay: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
default: true,
|
|
53
|
+
},
|
|
54
|
+
preventClose: {
|
|
55
|
+
type: Boolean,
|
|
56
|
+
default: false,
|
|
57
|
+
},
|
|
58
|
+
isHideCloseBtn: {
|
|
59
|
+
type: Boolean,
|
|
60
|
+
default: false,
|
|
61
|
+
},
|
|
62
|
+
transition: {
|
|
63
|
+
type: Boolean,
|
|
64
|
+
default: true,
|
|
65
|
+
},
|
|
66
|
+
size: {
|
|
67
|
+
type: String as PropType<keyof typeof slideover.size>,
|
|
68
|
+
default: () => slideover.default.size,
|
|
69
|
+
},
|
|
70
|
+
class: {
|
|
71
|
+
type: [String, Array, Object] as PropType<any>,
|
|
72
|
+
default: undefined,
|
|
73
|
+
},
|
|
74
|
+
ui: {
|
|
75
|
+
type: Object as PropType<Partial<typeof config & { strategy?: Strategy }>>,
|
|
76
|
+
default: undefined,
|
|
77
|
+
},
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
const emits = defineEmits(['update:modelValue'])
|
|
81
|
+
|
|
82
|
+
const emptyFocusRef = ref<HTMLElement | null>(null)
|
|
83
|
+
|
|
84
|
+
defineShortcuts({
|
|
85
|
+
escape: {
|
|
86
|
+
usingInput: true,
|
|
87
|
+
handler: () => {
|
|
88
|
+
if (props.preventClose) return
|
|
89
|
+
emits('update:modelValue', false)
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
const close = () => {
|
|
95
|
+
emits('update:modelValue', false)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const { ui, attrs } = useUI('slideover', toRef(props, 'ui'), config, toRef(props, 'class'))
|
|
99
|
+
|
|
100
|
+
watch(
|
|
101
|
+
() => props.modelValue,
|
|
102
|
+
() => {
|
|
103
|
+
if (props.modelValue) {
|
|
104
|
+
const size = config.size[props.size]
|
|
105
|
+
|
|
106
|
+
ui.value.width = size
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
)
|
|
110
|
+
</script>
|
|
@@ -37,10 +37,12 @@
|
|
|
37
37
|
:column="column"
|
|
38
38
|
:row="row"
|
|
39
39
|
/>
|
|
40
|
+
|
|
40
41
|
<template v-else>
|
|
41
42
|
<span :title="row[column.key]">{{ row[column.key] ?? '-' }}</span>
|
|
42
43
|
</template>
|
|
43
44
|
</template>
|
|
45
|
+
|
|
44
46
|
<template v-for="(_, slot) of $slots" #[slot]="scope">
|
|
45
47
|
<slot :name="slot" v-bind="scope" />
|
|
46
48
|
</template>
|
|
@@ -97,14 +99,16 @@ const pageBetween = computed((): string => {
|
|
|
97
99
|
return '0'
|
|
98
100
|
}
|
|
99
101
|
|
|
100
|
-
const start = (props.pageOptions
|
|
102
|
+
const start = (props.pageOptions!.currentPage - 1) * props.pageOptions!.limit + 1
|
|
101
103
|
const end = start + length - 1
|
|
102
104
|
|
|
103
105
|
return `${start} - ${end}`
|
|
104
106
|
})
|
|
105
107
|
|
|
106
108
|
const totalCountWithComma = computed((): string => {
|
|
107
|
-
return !props.pageOptions
|
|
109
|
+
return !props.pageOptions!.totalCount
|
|
110
|
+
? '0'
|
|
111
|
+
: StringHelper.withComma(props.pageOptions!.totalCount)
|
|
108
112
|
})
|
|
109
113
|
|
|
110
114
|
watch(page, () => {
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
{{ getValue }}
|
|
3
|
-
</template>
|
|
4
|
-
<script lang="ts" setup>
|
|
5
|
-
import { computed } from 'vue'
|
|
6
|
-
import { type IColumn } from '#core/components/Table/types'
|
|
7
|
-
import { TimeHelper } from '#core/utils/TimeHelper'
|
|
8
|
-
|
|
9
|
-
const props = defineProps<{
|
|
10
|
-
value: any
|
|
11
|
-
row: any
|
|
12
|
-
column: IColumn
|
|
13
|
-
}>()
|
|
14
|
-
|
|
15
|
-
const getValue = computed<string>(() => TimeHelper.getDateFormTime(props.value))
|
|
16
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
{{ getValue }}
|
|
3
|
+
</template>
|
|
4
|
+
<script lang="ts" setup>
|
|
5
|
+
import { computed } from 'vue'
|
|
6
|
+
import { type IColumn } from '#core/components/Table/types'
|
|
7
|
+
import { TimeHelper } from '#core/utils/TimeHelper'
|
|
8
|
+
|
|
9
|
+
const props = defineProps<{
|
|
10
|
+
value: any
|
|
11
|
+
row: any
|
|
12
|
+
column: IColumn
|
|
13
|
+
}>()
|
|
14
|
+
|
|
15
|
+
const getValue = computed<string>(() => TimeHelper.getDateFormTime(props.value))
|
|
16
|
+
</script>
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<p :title="`${getValue.date} ${getValue.time}`" class="flex flex-col whitespace-nowrap px-4">
|
|
3
|
-
<span>
|
|
4
|
-
{{ getValue.date }}
|
|
5
|
-
</span>
|
|
6
|
-
<span class="text-gray text-xs">
|
|
7
|
-
{{ getValue.time }}
|
|
8
|
-
</span>
|
|
9
|
-
</p>
|
|
10
|
-
</template>
|
|
11
|
-
<script lang="ts" setup>
|
|
12
|
-
import { computed } from 'vue'
|
|
13
|
-
import { type IColumn } from '#core/components/Table/types'
|
|
14
|
-
import { TimeHelper } from '#core/utils/TimeHelper'
|
|
15
|
-
|
|
16
|
-
const props = defineProps<{
|
|
17
|
-
value: any
|
|
18
|
-
row: any
|
|
19
|
-
column: IColumn
|
|
20
|
-
}>()
|
|
21
|
-
|
|
22
|
-
const getValue = computed<{ date: string; time: string }>(() => {
|
|
23
|
-
return props.value
|
|
24
|
-
? {
|
|
25
|
-
date: TimeHelper.getDateFormTime(props.value),
|
|
26
|
-
time: TimeHelper.getTimeFormTime(props.value),
|
|
27
|
-
}
|
|
28
|
-
: { date: '-', time: '-' }
|
|
29
|
-
})
|
|
30
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<p :title="`${getValue.date} ${getValue.time}`" class="flex flex-col whitespace-nowrap px-4">
|
|
3
|
+
<span>
|
|
4
|
+
{{ getValue.date }}
|
|
5
|
+
</span>
|
|
6
|
+
<span class="text-gray text-xs">
|
|
7
|
+
{{ getValue.time }}
|
|
8
|
+
</span>
|
|
9
|
+
</p>
|
|
10
|
+
</template>
|
|
11
|
+
<script lang="ts" setup>
|
|
12
|
+
import { computed } from 'vue'
|
|
13
|
+
import { type IColumn } from '#core/components/Table/types'
|
|
14
|
+
import { TimeHelper } from '#core/utils/TimeHelper'
|
|
15
|
+
|
|
16
|
+
const props = defineProps<{
|
|
17
|
+
value: any
|
|
18
|
+
row: any
|
|
19
|
+
column: IColumn
|
|
20
|
+
}>()
|
|
21
|
+
|
|
22
|
+
const getValue = computed<{ date: string; time: string }>(() => {
|
|
23
|
+
return props.value
|
|
24
|
+
? {
|
|
25
|
+
date: TimeHelper.getDateFormTime(props.value),
|
|
26
|
+
time: TimeHelper.getTimeFormTime(props.value),
|
|
27
|
+
}
|
|
28
|
+
: { date: '-', time: '-' }
|
|
29
|
+
})
|
|
30
|
+
</script>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
<template><img class="h-12" :src="getValue" /></template>
|
|
2
|
-
<script lang="ts" setup>
|
|
3
|
-
import { computed } from 'vue'
|
|
4
|
-
import { type IColumn } from '#core/components/Table/types'
|
|
5
|
-
|
|
6
|
-
const props = defineProps<{
|
|
7
|
-
value: any
|
|
8
|
-
row: any
|
|
9
|
-
column: IColumn
|
|
10
|
-
}>()
|
|
11
|
-
|
|
12
|
-
const getValue = computed(() => props.value)
|
|
13
|
-
</script>
|
|
1
|
+
<template><img class="h-12" :src="getValue" /></template>
|
|
2
|
+
<script lang="ts" setup>
|
|
3
|
+
import { computed } from 'vue'
|
|
4
|
+
import { type IColumn } from '#core/components/Table/types'
|
|
5
|
+
|
|
6
|
+
const props = defineProps<{
|
|
7
|
+
value: any
|
|
8
|
+
row: any
|
|
9
|
+
column: IColumn
|
|
10
|
+
}>()
|
|
11
|
+
|
|
12
|
+
const getValue = computed(() => props.value)
|
|
13
|
+
</script>
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
<template>{{ getValue }}</template>
|
|
2
|
-
<script lang="ts" setup>
|
|
3
|
-
import { StringHelper } from '../../utils/StringHelper'
|
|
4
|
-
import { computed } from 'vue'
|
|
5
|
-
import { type IColumn } from '#core/components/Table/types'
|
|
6
|
-
|
|
7
|
-
const props = defineProps<{
|
|
8
|
-
value: any
|
|
9
|
-
row: any
|
|
10
|
-
column: IColumn
|
|
11
|
-
}>()
|
|
12
|
-
|
|
13
|
-
const getValue = computed(() => StringHelper.withComma(props.value))
|
|
14
|
-
</script>
|
|
1
|
+
<template>{{ getValue }}</template>
|
|
2
|
+
<script lang="ts" setup>
|
|
3
|
+
import { StringHelper } from '../../utils/StringHelper'
|
|
4
|
+
import { computed } from 'vue'
|
|
5
|
+
import { type IColumn } from '#core/components/Table/types'
|
|
6
|
+
|
|
7
|
+
const props = defineProps<{
|
|
8
|
+
value: any
|
|
9
|
+
row: any
|
|
10
|
+
column: IColumn
|
|
11
|
+
}>()
|
|
12
|
+
|
|
13
|
+
const getValue = computed(() => StringHelper.withComma(props.value))
|
|
14
|
+
</script>
|
|
@@ -1,53 +1,57 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<Base
|
|
3
|
-
v-bind="$attrs"
|
|
4
|
-
:columns="options.columns"
|
|
5
|
-
:raw-data="itemsByPage"
|
|
6
|
-
:status="options.status"
|
|
7
|
-
:page-options="pageOptions"
|
|
8
|
-
@page-change="onPageChange"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<Base
|
|
3
|
+
v-bind="$attrs"
|
|
4
|
+
:columns="options.columns"
|
|
5
|
+
:raw-data="itemsByPage"
|
|
6
|
+
:status="options.status"
|
|
7
|
+
:page-options="pageOptions"
|
|
8
|
+
@page-change="onPageChange"
|
|
9
|
+
>
|
|
10
|
+
<template v-for="(_, slot) of $slots" #[slot]="slotProps">
|
|
11
|
+
<slot :name="slot" v-bind="slotProps || {}" />
|
|
12
|
+
</template>
|
|
13
|
+
</Base>
|
|
14
|
+
</template>
|
|
15
|
+
<script lang="ts" setup>
|
|
16
|
+
import { computed, type PropType, ref } from 'vue'
|
|
17
|
+
import { type ISimpleTableOptions } from '#core/components/Table/types'
|
|
18
|
+
import Base from '#core/components/Table/Base.vue'
|
|
19
|
+
import { initPageOptions } from '#core/composables/loaderPage'
|
|
20
|
+
|
|
21
|
+
const props = defineProps({
|
|
22
|
+
options: { type: Object as PropType<ISimpleTableOptions>, required: true },
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
const currentPage = ref(1)
|
|
26
|
+
|
|
27
|
+
const pageOptions = computed(() => {
|
|
28
|
+
if (!props.options?.limit) {
|
|
29
|
+
return undefined
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
...initPageOptions({
|
|
34
|
+
limit: props.options.limit,
|
|
35
|
+
primary: props.options.primary,
|
|
36
|
+
}),
|
|
37
|
+
totalCount: props.options.rawData.length,
|
|
38
|
+
totalPage: Math.ceil(props.options.rawData.length / props.options.limit),
|
|
39
|
+
currentPage: currentPage.value,
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
const onPageChange = (page: number) => {
|
|
44
|
+
currentPage.value = page
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const itemsByPage = computed(() => {
|
|
48
|
+
if (!pageOptions.value) {
|
|
49
|
+
return props.options?.rawData
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const start = (pageOptions.value.currentPage - 1) * pageOptions.value.limit
|
|
53
|
+
const end = start + pageOptions.value.limit
|
|
54
|
+
|
|
55
|
+
return props.options?.rawData.slice(start, end)
|
|
56
|
+
})
|
|
57
|
+
</script>
|
|
@@ -1,47 +1,51 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<div v-if="options.isEnabledSearch" class="mb-4 flex justify-end">
|
|
4
|
-
<UInput
|
|
5
|
-
v-model="q"
|
|
6
|
-
icon="i-heroicons-magnifying-glass"
|
|
7
|
-
:placeholder="options.searchPlaceholder || 'ค้นหา...'"
|
|
8
|
-
/>
|
|
9
|
-
</div>
|
|
10
|
-
<Base
|
|
11
|
-
v-bind="$attrs"
|
|
12
|
-
:columns="options.columns"
|
|
13
|
-
:raw-data="options.rawData"
|
|
14
|
-
:status="options.status"
|
|
15
|
-
:page-options="options.pageOptions"
|
|
16
|
-
@page-change="onPageChange"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<div v-if="options.isEnabledSearch" class="mb-4 flex justify-end">
|
|
4
|
+
<UInput
|
|
5
|
+
v-model="q"
|
|
6
|
+
icon="i-heroicons-magnifying-glass"
|
|
7
|
+
:placeholder="options.searchPlaceholder || 'ค้นหา...'"
|
|
8
|
+
/>
|
|
9
|
+
</div>
|
|
10
|
+
<Base
|
|
11
|
+
v-bind="$attrs"
|
|
12
|
+
:columns="options.columns"
|
|
13
|
+
:raw-data="options.rawData"
|
|
14
|
+
:status="options.status"
|
|
15
|
+
:page-options="options.pageOptions"
|
|
16
|
+
@page-change="onPageChange"
|
|
17
|
+
>
|
|
18
|
+
<template v-for="(_, slot) of $slots" #[slot]="slotProps">
|
|
19
|
+
<slot :name="slot" v-bind="slotProps || {}" />
|
|
20
|
+
</template>
|
|
21
|
+
</Base>
|
|
22
|
+
</div>
|
|
23
|
+
</template>
|
|
24
|
+
<script lang="ts" setup>
|
|
25
|
+
import { type PropType } from 'vue'
|
|
26
|
+
import { type ITableOptions } from '#core/components/Table/types'
|
|
27
|
+
import { _debounce, ref, watch } from '#imports'
|
|
28
|
+
import Base from '#core/components/Table/Base.vue'
|
|
29
|
+
|
|
30
|
+
const emits = defineEmits<{
|
|
31
|
+
(event: 'pageChange', page: number): void
|
|
32
|
+
(event: 'search', q: string): void
|
|
33
|
+
}>()
|
|
34
|
+
|
|
35
|
+
const props = defineProps({
|
|
36
|
+
options: { type: Object as PropType<ITableOptions>, required: true },
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
const q = ref(props.options?.pageOptions.search ?? '')
|
|
40
|
+
|
|
41
|
+
watch(
|
|
42
|
+
q,
|
|
43
|
+
_debounce((value) => {
|
|
44
|
+
emits('search', value)
|
|
45
|
+
}, 500)
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
const onPageChange = (page: number) => {
|
|
49
|
+
emits('pageChange', page)
|
|
50
|
+
}
|
|
51
|
+
</script>
|