@ramathibodi/nuxt-commons 0.1.14 → 0.1.16
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 +294 -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 +161 -154
|
@@ -1,159 +1,159 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import {VAutocomplete} from 'vuetify/components/VAutocomplete'
|
|
3
|
-
import {concat, isEmpty} from 'lodash-es'
|
|
4
|
-
import {computed, ref, watch} from 'vue'
|
|
5
|
-
import {watchDebounced} from '@vueuse/core'
|
|
6
|
-
import {useFuzzy} from '../../composables/utils/fuzzy'
|
|
7
|
-
import {useGraphQl} from '../../composables/graphql'
|
|
8
|
-
|
|
9
|
-
interface Props extends /* @vue-ignore */ InstanceType<typeof VAutocomplete['$props']> {
|
|
10
|
-
fuzzy?: boolean
|
|
11
|
-
groupKey: string
|
|
12
|
-
lang?: 'TH' | 'EN'
|
|
13
|
-
fields?: string[]
|
|
14
|
-
noDataText?: string
|
|
15
|
-
filterText?: string
|
|
16
|
-
waitForFilter?: boolean
|
|
17
|
-
waitForFilterText?: string
|
|
18
|
-
modelValue?: string
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const props = withDefaults(defineProps<Props>(), {
|
|
22
|
-
fuzzy: true,
|
|
23
|
-
noDataText: 'ไม่พบข้อมูล',
|
|
24
|
-
lang: 'TH',
|
|
25
|
-
waitForFilter: false,
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
const emit = defineEmits(['update:modelValue'])
|
|
29
|
-
|
|
30
|
-
const masterItems = ref<Array<any>>([])
|
|
31
|
-
const items = ref<Array<any>>([])
|
|
32
|
-
const selectedItem = ref<any>()
|
|
33
|
-
|
|
34
|
-
const searchData = ref<string>('')
|
|
35
|
-
|
|
36
|
-
const isLoading = ref(false)
|
|
37
|
-
const isErrorLoading = ref(false)
|
|
38
|
-
|
|
39
|
-
function query(groupKey: string, filterText: string | undefined) {
|
|
40
|
-
let operation = 'masterItemByGroupKey'
|
|
41
|
-
|
|
42
|
-
const variables: Record<string, any> = { groupKey: { value: groupKey, required: true } }
|
|
43
|
-
if (filterText) {
|
|
44
|
-
variables['filterText'] = { value: filterText }
|
|
45
|
-
operation = 'masterItemByGroupKeyAndFilterText'
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
let fields: any[] = ['itemCode', 'itemValue', 'itemValueAlternative']
|
|
49
|
-
if (props.fields) fields = concat(fields, props.fields)
|
|
50
|
-
|
|
51
|
-
isLoading.value = true
|
|
52
|
-
|
|
53
|
-
useGraphQl().queryPromise(operation, fields, variables).then((result: any) => {
|
|
54
|
-
masterItems.value = result
|
|
55
|
-
items.value = result
|
|
56
|
-
isErrorLoading.value = false
|
|
57
|
-
}).catch((error) => {
|
|
58
|
-
console.log(error)
|
|
59
|
-
isErrorLoading.value = true
|
|
60
|
-
}).finally(() => {
|
|
61
|
-
isLoading.value = false
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
watch(() => props.waitForFilter && !props.filterText, (newValue) => {
|
|
66
|
-
if (newValue) {
|
|
67
|
-
masterItems.value = []
|
|
68
|
-
items.value = []
|
|
69
|
-
selectedItem.value = undefined
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
query(props.groupKey, props.filterText)
|
|
73
|
-
}
|
|
74
|
-
}, { immediate: true })
|
|
75
|
-
|
|
76
|
-
watch(() => props.modelValue, (newValue) => {
|
|
77
|
-
selectedItem.value = newValue
|
|
78
|
-
}, { immediate: true })
|
|
79
|
-
|
|
80
|
-
watch(selectedItem, (newValue) => {
|
|
81
|
-
emit('update:modelValue', newValue)
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
async function fuzzySearch() {
|
|
85
|
-
if (props.fuzzy) {
|
|
86
|
-
if (isEmpty(searchData.value)) {
|
|
87
|
-
items.value = masterItems.value
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
let fields: any[] = ['itemCode', 'itemValue', 'itemValueAlternative']
|
|
91
|
-
if (props.fields) fields = concat(fields, props.fields)
|
|
92
|
-
|
|
93
|
-
const results: any = useFuzzy(searchData.value, masterItems.value, fields)
|
|
94
|
-
items.value = []
|
|
95
|
-
if (results.value.length) {
|
|
96
|
-
for (let i = 0; results.value.length > i; i++) {
|
|
97
|
-
if (results.value[i].item) items.value.push(results.value[i].item)
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
watchDebounced(searchData, fuzzySearch, { debounce: 1000, maxWait: 5000 })
|
|
105
|
-
|
|
106
|
-
const itemTitleField = computed(() => {
|
|
107
|
-
if (props.lang == 'TH') return 'itemValue'
|
|
108
|
-
else return 'itemValueAlternative'
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
const computedNoDataText = computed(() => {
|
|
112
|
-
if (props.waitForFilter && !props.filterText) return props.waitForFilterText
|
|
113
|
-
return props.noDataText
|
|
114
|
-
})
|
|
115
|
-
</script>
|
|
116
|
-
|
|
117
|
-
<template>
|
|
118
|
-
<v-autocomplete
|
|
119
|
-
v-model="selectedItem"
|
|
120
|
-
v-model:search="searchData"
|
|
121
|
-
v-bind="$attrs"
|
|
122
|
-
:items="items"
|
|
123
|
-
:no-filter="props.fuzzy"
|
|
124
|
-
:item-title="itemTitleField"
|
|
125
|
-
item-value="itemCode"
|
|
126
|
-
:no-data-text="computedNoDataText"
|
|
127
|
-
:loading="isLoading"
|
|
128
|
-
>
|
|
129
|
-
<!-- @ts-ignore -->
|
|
130
|
-
<template
|
|
131
|
-
v-for="(_, name, index) in ($slots as {})"
|
|
132
|
-
:key="index"
|
|
133
|
-
#[name]="slotData"
|
|
134
|
-
>
|
|
135
|
-
<slot
|
|
136
|
-
:name="name"
|
|
137
|
-
v-bind="((slotData || {}) as object)"
|
|
138
|
-
:operation="operation"
|
|
139
|
-
/>
|
|
140
|
-
</template>
|
|
141
|
-
<template
|
|
142
|
-
v-if="!$slots.item"
|
|
143
|
-
#item="{ props, item }"
|
|
144
|
-
>
|
|
145
|
-
<v-list-item
|
|
146
|
-
v-bind="props"
|
|
147
|
-
:title="item.title || item.raw.itemValue || item.raw.itemCode"
|
|
148
|
-
/>
|
|
149
|
-
</template>
|
|
150
|
-
<template
|
|
151
|
-
v-if="isErrorLoading"
|
|
152
|
-
#append
|
|
153
|
-
>
|
|
154
|
-
<v-icon color="error">
|
|
155
|
-
mdi mdi-alert
|
|
156
|
-
</v-icon>
|
|
157
|
-
</template>
|
|
158
|
-
</v-autocomplete>
|
|
159
|
-
</template>
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import {VAutocomplete} from 'vuetify/components/VAutocomplete'
|
|
3
|
+
import {concat, isEmpty} from 'lodash-es'
|
|
4
|
+
import {computed, ref, watch} from 'vue'
|
|
5
|
+
import {watchDebounced} from '@vueuse/core'
|
|
6
|
+
import {useFuzzy} from '../../composables/utils/fuzzy'
|
|
7
|
+
import {useGraphQl} from '../../composables/graphql'
|
|
8
|
+
|
|
9
|
+
interface Props extends /* @vue-ignore */ InstanceType<typeof VAutocomplete['$props']> {
|
|
10
|
+
fuzzy?: boolean
|
|
11
|
+
groupKey: string
|
|
12
|
+
lang?: 'TH' | 'EN'
|
|
13
|
+
fields?: string[]
|
|
14
|
+
noDataText?: string
|
|
15
|
+
filterText?: string
|
|
16
|
+
waitForFilter?: boolean
|
|
17
|
+
waitForFilterText?: string
|
|
18
|
+
modelValue?: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
22
|
+
fuzzy: true,
|
|
23
|
+
noDataText: 'ไม่พบข้อมูล',
|
|
24
|
+
lang: 'TH',
|
|
25
|
+
waitForFilter: false,
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
const emit = defineEmits(['update:modelValue'])
|
|
29
|
+
|
|
30
|
+
const masterItems = ref<Array<any>>([])
|
|
31
|
+
const items = ref<Array<any>>([])
|
|
32
|
+
const selectedItem = ref<any>()
|
|
33
|
+
|
|
34
|
+
const searchData = ref<string>('')
|
|
35
|
+
|
|
36
|
+
const isLoading = ref(false)
|
|
37
|
+
const isErrorLoading = ref(false)
|
|
38
|
+
|
|
39
|
+
function query(groupKey: string, filterText: string | undefined) {
|
|
40
|
+
let operation = 'masterItemByGroupKey'
|
|
41
|
+
|
|
42
|
+
const variables: Record<string, any> = { groupKey: { value: groupKey, required: true } }
|
|
43
|
+
if (filterText) {
|
|
44
|
+
variables['filterText'] = { value: filterText }
|
|
45
|
+
operation = 'masterItemByGroupKeyAndFilterText'
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let fields: any[] = ['itemCode', 'itemValue', 'itemValueAlternative']
|
|
49
|
+
if (props.fields) fields = concat(fields, props.fields)
|
|
50
|
+
|
|
51
|
+
isLoading.value = true
|
|
52
|
+
|
|
53
|
+
useGraphQl().queryPromise(operation, fields, variables).then((result: any) => {
|
|
54
|
+
masterItems.value = result
|
|
55
|
+
items.value = result
|
|
56
|
+
isErrorLoading.value = false
|
|
57
|
+
}).catch((error) => {
|
|
58
|
+
console.log(error)
|
|
59
|
+
isErrorLoading.value = true
|
|
60
|
+
}).finally(() => {
|
|
61
|
+
isLoading.value = false
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
watch(() => props.waitForFilter && !props.filterText, (newValue) => {
|
|
66
|
+
if (newValue) {
|
|
67
|
+
masterItems.value = []
|
|
68
|
+
items.value = []
|
|
69
|
+
selectedItem.value = undefined
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
query(props.groupKey, props.filterText)
|
|
73
|
+
}
|
|
74
|
+
}, { immediate: true })
|
|
75
|
+
|
|
76
|
+
watch(() => props.modelValue, (newValue) => {
|
|
77
|
+
selectedItem.value = newValue
|
|
78
|
+
}, { immediate: true })
|
|
79
|
+
|
|
80
|
+
watch(selectedItem, (newValue) => {
|
|
81
|
+
emit('update:modelValue', newValue)
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
async function fuzzySearch() {
|
|
85
|
+
if (props.fuzzy) {
|
|
86
|
+
if (isEmpty(searchData.value)) {
|
|
87
|
+
items.value = masterItems.value
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
let fields: any[] = ['itemCode', 'itemValue', 'itemValueAlternative']
|
|
91
|
+
if (props.fields) fields = concat(fields, props.fields)
|
|
92
|
+
|
|
93
|
+
const results: any = useFuzzy(searchData.value, masterItems.value, fields)
|
|
94
|
+
items.value = []
|
|
95
|
+
if (results.value.length) {
|
|
96
|
+
for (let i = 0; results.value.length > i; i++) {
|
|
97
|
+
if (results.value[i].item) items.value.push(results.value[i].item)
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
watchDebounced(searchData, fuzzySearch, { debounce: 1000, maxWait: 5000 })
|
|
105
|
+
|
|
106
|
+
const itemTitleField = computed(() => {
|
|
107
|
+
if (props.lang == 'TH') return 'itemValue'
|
|
108
|
+
else return 'itemValueAlternative'
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
const computedNoDataText = computed(() => {
|
|
112
|
+
if (props.waitForFilter && !props.filterText) return props.waitForFilterText
|
|
113
|
+
return props.noDataText
|
|
114
|
+
})
|
|
115
|
+
</script>
|
|
116
|
+
|
|
117
|
+
<template>
|
|
118
|
+
<v-autocomplete
|
|
119
|
+
v-model="selectedItem"
|
|
120
|
+
v-model:search="searchData"
|
|
121
|
+
v-bind="$attrs"
|
|
122
|
+
:items="items"
|
|
123
|
+
:no-filter="props.fuzzy"
|
|
124
|
+
:item-title="itemTitleField"
|
|
125
|
+
item-value="itemCode"
|
|
126
|
+
:no-data-text="computedNoDataText"
|
|
127
|
+
:loading="isLoading"
|
|
128
|
+
>
|
|
129
|
+
<!-- @ts-ignore -->
|
|
130
|
+
<template
|
|
131
|
+
v-for="(_, name, index) in ($slots as {})"
|
|
132
|
+
:key="index"
|
|
133
|
+
#[name]="slotData"
|
|
134
|
+
>
|
|
135
|
+
<slot
|
|
136
|
+
:name="name"
|
|
137
|
+
v-bind="((slotData || {}) as object)"
|
|
138
|
+
:operation="operation"
|
|
139
|
+
/>
|
|
140
|
+
</template>
|
|
141
|
+
<template
|
|
142
|
+
v-if="!$slots.item"
|
|
143
|
+
#item="{ props, item }"
|
|
144
|
+
>
|
|
145
|
+
<v-list-item
|
|
146
|
+
v-bind="props"
|
|
147
|
+
:title="item.title || item.raw.itemValue || item.raw.itemCode"
|
|
148
|
+
/>
|
|
149
|
+
</template>
|
|
150
|
+
<template
|
|
151
|
+
v-if="isErrorLoading"
|
|
152
|
+
#append
|
|
153
|
+
>
|
|
154
|
+
<v-icon color="error">
|
|
155
|
+
mdi mdi-alert
|
|
156
|
+
</v-icon>
|
|
157
|
+
</template>
|
|
158
|
+
</v-autocomplete>
|
|
159
|
+
</template>
|
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import {VCombobox} from 'vuetify/components/VCombobox'
|
|
3
|
-
import {computed, ref, watch} from 'vue'
|
|
4
|
-
import {concat} from 'lodash-es'
|
|
5
|
-
import {useAlert} from '../../composables/alert'
|
|
6
|
-
import {useGraphQl} from '../../composables/graphql'
|
|
7
|
-
|
|
8
|
-
interface Props extends /* @vue-ignore */ InstanceType<typeof VCombobox['$props']> {
|
|
9
|
-
modelValue?: string
|
|
10
|
-
groupKey: string
|
|
11
|
-
fields?: string[]
|
|
12
|
-
lang?: 'TH' | 'EN'
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const props = withDefaults(defineProps<Props>(), {
|
|
16
|
-
lang: 'TH',
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
const emit = defineEmits(['update:modelValue'])
|
|
20
|
-
const items = ref<Array<any>>([])
|
|
21
|
-
const alert = useAlert()
|
|
22
|
-
const selectedItem = ref<any>()
|
|
23
|
-
function query() {
|
|
24
|
-
const variables: Record<string, any> = { groupKey: { value: props.groupKey, required: true } }
|
|
25
|
-
let fields: any[] = ['itemCode', 'itemValue', 'itemValueAlternative']
|
|
26
|
-
if (props.fields) fields = concat(fields, props.fields)
|
|
27
|
-
|
|
28
|
-
useGraphQl().queryPromise('masterItemByGroupKey', fields, variables).then((result: any) => {
|
|
29
|
-
items.value = result
|
|
30
|
-
}).catch((error) => {
|
|
31
|
-
alert?.addAlert({
|
|
32
|
-
message: `${error.message}`,
|
|
33
|
-
alertType: 'error',
|
|
34
|
-
})
|
|
35
|
-
})
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
watch(() => props.groupKey, () => {
|
|
39
|
-
query()
|
|
40
|
-
}, { immediate: true })
|
|
41
|
-
|
|
42
|
-
watch(selectedItem, (newValue) => {
|
|
43
|
-
emit('update:modelValue', newValue.itemCode)
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
const itemTitleField = computed(() => {
|
|
47
|
-
if (props.lang == 'TH') return 'itemValue'
|
|
48
|
-
else return 'itemValueAlternative'
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
query()
|
|
52
|
-
</script>
|
|
53
|
-
|
|
54
|
-
<template>
|
|
55
|
-
<v-combobox
|
|
56
|
-
v-model="selectedItem"
|
|
57
|
-
:items="items"
|
|
58
|
-
:item-title="itemTitleField"
|
|
59
|
-
item-value="itemCode"
|
|
60
|
-
>
|
|
61
|
-
<template
|
|
62
|
-
v-for="(_, name, index) in ($slots as {})"
|
|
63
|
-
:key="index"
|
|
64
|
-
#[name]="slotData"
|
|
65
|
-
>
|
|
66
|
-
<slot
|
|
67
|
-
:name="name"
|
|
68
|
-
v-bind="((slotData || {}) as object)"
|
|
69
|
-
:operation="operation"
|
|
70
|
-
/>
|
|
71
|
-
</template>
|
|
72
|
-
<template
|
|
73
|
-
v-if="!$slots.item"
|
|
74
|
-
#item="{ props, item }"
|
|
75
|
-
>
|
|
76
|
-
<v-list-item
|
|
77
|
-
v-bind="props"
|
|
78
|
-
:title="item.raw.itemValue"
|
|
79
|
-
/>
|
|
80
|
-
</template>
|
|
81
|
-
</v-combobox>
|
|
82
|
-
</template>
|
|
83
|
-
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import {VCombobox} from 'vuetify/components/VCombobox'
|
|
3
|
+
import {computed, ref, watch} from 'vue'
|
|
4
|
+
import {concat} from 'lodash-es'
|
|
5
|
+
import {useAlert} from '../../composables/alert'
|
|
6
|
+
import {useGraphQl} from '../../composables/graphql'
|
|
7
|
+
|
|
8
|
+
interface Props extends /* @vue-ignore */ InstanceType<typeof VCombobox['$props']> {
|
|
9
|
+
modelValue?: string
|
|
10
|
+
groupKey: string
|
|
11
|
+
fields?: string[]
|
|
12
|
+
lang?: 'TH' | 'EN'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
16
|
+
lang: 'TH',
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
const emit = defineEmits(['update:modelValue'])
|
|
20
|
+
const items = ref<Array<any>>([])
|
|
21
|
+
const alert = useAlert()
|
|
22
|
+
const selectedItem = ref<any>()
|
|
23
|
+
function query() {
|
|
24
|
+
const variables: Record<string, any> = { groupKey: { value: props.groupKey, required: true } }
|
|
25
|
+
let fields: any[] = ['itemCode', 'itemValue', 'itemValueAlternative']
|
|
26
|
+
if (props.fields) fields = concat(fields, props.fields)
|
|
27
|
+
|
|
28
|
+
useGraphQl().queryPromise('masterItemByGroupKey', fields, variables).then((result: any) => {
|
|
29
|
+
items.value = result
|
|
30
|
+
}).catch((error) => {
|
|
31
|
+
alert?.addAlert({
|
|
32
|
+
message: `${error.message}`,
|
|
33
|
+
alertType: 'error',
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
watch(() => props.groupKey, () => {
|
|
39
|
+
query()
|
|
40
|
+
}, { immediate: true })
|
|
41
|
+
|
|
42
|
+
watch(selectedItem, (newValue) => {
|
|
43
|
+
emit('update:modelValue', newValue.itemCode)
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const itemTitleField = computed(() => {
|
|
47
|
+
if (props.lang == 'TH') return 'itemValue'
|
|
48
|
+
else return 'itemValueAlternative'
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
query()
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<template>
|
|
55
|
+
<v-combobox
|
|
56
|
+
v-model="selectedItem"
|
|
57
|
+
:items="items"
|
|
58
|
+
:item-title="itemTitleField"
|
|
59
|
+
item-value="itemCode"
|
|
60
|
+
>
|
|
61
|
+
<template
|
|
62
|
+
v-for="(_, name, index) in ($slots as {})"
|
|
63
|
+
:key="index"
|
|
64
|
+
#[name]="slotData"
|
|
65
|
+
>
|
|
66
|
+
<slot
|
|
67
|
+
:name="name"
|
|
68
|
+
v-bind="((slotData || {}) as object)"
|
|
69
|
+
:operation="operation"
|
|
70
|
+
/>
|
|
71
|
+
</template>
|
|
72
|
+
<template
|
|
73
|
+
v-if="!$slots.item"
|
|
74
|
+
#item="{ props, item }"
|
|
75
|
+
>
|
|
76
|
+
<v-list-item
|
|
77
|
+
v-bind="props"
|
|
78
|
+
:title="item.raw.itemValue"
|
|
79
|
+
/>
|
|
80
|
+
</template>
|
|
81
|
+
</v-combobox>
|
|
82
|
+
</template>
|
|
83
|
+
|
|
84
84
|
<style scoped>
|
|
85
85
|
|
|
86
|
-
</style>
|
|
86
|
+
</style>
|
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import {VRadioGroup} from 'vuetify/components/VRadioGroup'
|
|
3
|
-
import {computed, ref, watch} from 'vue'
|
|
4
|
-
import {concat} from 'lodash-es'
|
|
5
|
-
import {useAlert} from '../../composables/alert'
|
|
6
|
-
import {useGraphQl} from '../../composables/graphql'
|
|
7
|
-
|
|
8
|
-
interface Props extends /* @vue-ignore */ InstanceType<typeof VRadioGroup['$props']> {
|
|
9
|
-
returnObject?: boolean
|
|
10
|
-
groupKey: string
|
|
11
|
-
modelValue?: any
|
|
12
|
-
fields?: string[]
|
|
13
|
-
lang?: 'TH' | 'EN'
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const props = withDefaults(defineProps<Props>(), {
|
|
17
|
-
lang: 'TH',
|
|
18
|
-
})
|
|
19
|
-
const emit = defineEmits(['update:modelValue'])
|
|
20
|
-
const items: any = ref([])
|
|
21
|
-
const value = ref()
|
|
22
|
-
const alert = useAlert()
|
|
23
|
-
const query = () => {
|
|
24
|
-
const variables = { groupKey: {
|
|
25
|
-
name: 'groupKey',
|
|
26
|
-
type: 'String!',
|
|
27
|
-
value: props.groupKey,
|
|
28
|
-
} }
|
|
29
|
-
let fields: any[] = ['itemCode', 'itemValue', 'itemValueAlternative']
|
|
30
|
-
if (props.fields) fields = concat(fields, props.fields)
|
|
31
|
-
|
|
32
|
-
useGraphQl().queryPromise('masterItemByGroupKey', fields, variables).then((result: any) => {
|
|
33
|
-
items.value = result
|
|
34
|
-
}).catch((error) => {
|
|
35
|
-
alert?.addAlert({
|
|
36
|
-
message: `${error.message}`,
|
|
37
|
-
alertType: 'error',
|
|
38
|
-
})
|
|
39
|
-
})
|
|
40
|
-
}
|
|
41
|
-
query()
|
|
42
|
-
|
|
43
|
-
watch(() => props.modelValue, (newValue) => {
|
|
44
|
-
value.value = props.modelValue
|
|
45
|
-
}, { deep: true, immediate: true })
|
|
46
|
-
|
|
47
|
-
const itemTitleField = computed(() => {
|
|
48
|
-
if (props.lang == 'TH') return 'itemValue'
|
|
49
|
-
else return 'itemValueAlternative'
|
|
50
|
-
})
|
|
51
|
-
</script>
|
|
52
|
-
|
|
53
|
-
<template>
|
|
54
|
-
<v-radio-group
|
|
55
|
-
v-model="value"
|
|
56
|
-
v-bind="$attrs"
|
|
57
|
-
@update:model-value="emit('update:modelValue', value.value)"
|
|
58
|
-
>
|
|
59
|
-
<template
|
|
60
|
-
v-for="(_, name, index) in ($slots as {})"
|
|
61
|
-
:key="index"
|
|
62
|
-
#[name]="slotData"
|
|
63
|
-
>
|
|
64
|
-
<slot
|
|
65
|
-
:name="name"
|
|
66
|
-
v-bind="((slotData || {}) as object)"
|
|
67
|
-
:operation="operation"
|
|
68
|
-
/>
|
|
69
|
-
</template>
|
|
70
|
-
<v-radio
|
|
71
|
-
v-for="i in items"
|
|
72
|
-
:key="i.itemCode"
|
|
73
|
-
v-bind="$attrs"
|
|
74
|
-
:label="i[itemTitleField]"
|
|
75
|
-
:value="returnObject ? i : i.itemCode"
|
|
76
|
-
/>
|
|
77
|
-
</v-radio-group>
|
|
78
|
-
</template>
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import {VRadioGroup} from 'vuetify/components/VRadioGroup'
|
|
3
|
+
import {computed, ref, watch} from 'vue'
|
|
4
|
+
import {concat} from 'lodash-es'
|
|
5
|
+
import {useAlert} from '../../composables/alert'
|
|
6
|
+
import {useGraphQl} from '../../composables/graphql'
|
|
7
|
+
|
|
8
|
+
interface Props extends /* @vue-ignore */ InstanceType<typeof VRadioGroup['$props']> {
|
|
9
|
+
returnObject?: boolean
|
|
10
|
+
groupKey: string
|
|
11
|
+
modelValue?: any
|
|
12
|
+
fields?: string[]
|
|
13
|
+
lang?: 'TH' | 'EN'
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
17
|
+
lang: 'TH',
|
|
18
|
+
})
|
|
19
|
+
const emit = defineEmits(['update:modelValue'])
|
|
20
|
+
const items: any = ref([])
|
|
21
|
+
const value = ref()
|
|
22
|
+
const alert = useAlert()
|
|
23
|
+
const query = () => {
|
|
24
|
+
const variables = { groupKey: {
|
|
25
|
+
name: 'groupKey',
|
|
26
|
+
type: 'String!',
|
|
27
|
+
value: props.groupKey,
|
|
28
|
+
} }
|
|
29
|
+
let fields: any[] = ['itemCode', 'itemValue', 'itemValueAlternative']
|
|
30
|
+
if (props.fields) fields = concat(fields, props.fields)
|
|
31
|
+
|
|
32
|
+
useGraphQl().queryPromise('masterItemByGroupKey', fields, variables).then((result: any) => {
|
|
33
|
+
items.value = result
|
|
34
|
+
}).catch((error) => {
|
|
35
|
+
alert?.addAlert({
|
|
36
|
+
message: `${error.message}`,
|
|
37
|
+
alertType: 'error',
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
query()
|
|
42
|
+
|
|
43
|
+
watch(() => props.modelValue, (newValue) => {
|
|
44
|
+
value.value = props.modelValue
|
|
45
|
+
}, { deep: true, immediate: true })
|
|
46
|
+
|
|
47
|
+
const itemTitleField = computed(() => {
|
|
48
|
+
if (props.lang == 'TH') return 'itemValue'
|
|
49
|
+
else return 'itemValueAlternative'
|
|
50
|
+
})
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<template>
|
|
54
|
+
<v-radio-group
|
|
55
|
+
v-model="value"
|
|
56
|
+
v-bind="$attrs"
|
|
57
|
+
@update:model-value="emit('update:modelValue', value.value)"
|
|
58
|
+
>
|
|
59
|
+
<template
|
|
60
|
+
v-for="(_, name, index) in ($slots as {})"
|
|
61
|
+
:key="index"
|
|
62
|
+
#[name]="slotData"
|
|
63
|
+
>
|
|
64
|
+
<slot
|
|
65
|
+
:name="name"
|
|
66
|
+
v-bind="((slotData || {}) as object)"
|
|
67
|
+
:operation="operation"
|
|
68
|
+
/>
|
|
69
|
+
</template>
|
|
70
|
+
<v-radio
|
|
71
|
+
v-for="i in items"
|
|
72
|
+
:key="i.itemCode"
|
|
73
|
+
v-bind="$attrs"
|
|
74
|
+
:label="i[itemTitleField]"
|
|
75
|
+
:value="returnObject ? i : i.itemCode"
|
|
76
|
+
/>
|
|
77
|
+
</v-radio-group>
|
|
78
|
+
</template>
|