@ramathibodi/nuxt-commons 0.1.7 → 0.1.9
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
CHANGED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { VCombobox } from "vuetify/components/VCombobox";
|
|
3
|
+
import {ref, watch, computed} from "vue";
|
|
4
|
+
import {useAlert} from "../../composables/alert";
|
|
5
|
+
import {concat} from "lodash-es";
|
|
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
|
+
<v-list-item v-bind="props" :title="item.raw.itemValue"></v-list-item>
|
|
76
|
+
</template>
|
|
77
|
+
</v-combobox>
|
|
78
|
+
</template>
|
|
79
|
+
|
|
80
|
+
<style scoped>
|
|
81
|
+
|
|
82
|
+
</style>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import {VRadioGroup} from 'vuetify/components/VRadioGroup'
|
|
3
|
+
import {computed, ref, watch} from 'vue'
|
|
4
|
+
import {useAlert} from "../../composables/alert";
|
|
5
|
+
import {useGraphQl} from "../../composables/graphql";
|
|
6
|
+
import {concat} from "lodash-es";
|
|
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
|
+
|
|
46
|
+
}, {deep: true, immediate: true})
|
|
47
|
+
|
|
48
|
+
const itemTitleField = computed(() => {
|
|
49
|
+
if (props.lang == 'TH') return 'itemValue'
|
|
50
|
+
else return 'itemValueAlternative'
|
|
51
|
+
})
|
|
52
|
+
</script>
|
|
53
|
+
<template>
|
|
54
|
+
<v-radio-group v-model="value" v-bind="$attrs" @update:model-value="emit('update:modelValue', value.value)">
|
|
55
|
+
<template
|
|
56
|
+
v-for="(_, name, index) in ($slots as {})"
|
|
57
|
+
:key="index"
|
|
58
|
+
#[name]="slotData"
|
|
59
|
+
>
|
|
60
|
+
<slot
|
|
61
|
+
:name="name"
|
|
62
|
+
v-bind="(slotData as object)"
|
|
63
|
+
:operation="operation"
|
|
64
|
+
/>
|
|
65
|
+
</template>
|
|
66
|
+
<v-radio v-for="i in items" :key="i.itemCode" v-bind="$attrs" :label="i[itemTitleField]" :value="returnObject ? i : i.itemCode"></v-radio>
|
|
67
|
+
</v-radio-group>
|
|
68
|
+
</template>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { VSelect } from "vuetify/components/VSelect";
|
|
3
|
+
import { useGraphQl } from '../../composables/graphql'
|
|
4
|
+
import { concat } from "lodash-es";
|
|
5
|
+
import { useAlert } from "../../composables/alert";
|
|
6
|
+
import {computed, ref, watch} from "vue";
|
|
7
|
+
interface Props extends /* @vue-ignore */ InstanceType<typeof VSelect['$props']> {
|
|
8
|
+
modelValue?: string
|
|
9
|
+
groupKey: string
|
|
10
|
+
fields?:string[]
|
|
11
|
+
}
|
|
12
|
+
const props = withDefaults(defineProps<Props>(),{
|
|
13
|
+
lang: 'TH'
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
const emit = defineEmits(['update:modelValue'])
|
|
17
|
+
const items = ref<Array<any>>([])
|
|
18
|
+
const alert = useAlert()
|
|
19
|
+
const selectedItem = ref<any>()
|
|
20
|
+
function query() {
|
|
21
|
+
const variables: Record<string, any> = { groupKey: { value: props.groupKey, required: true } }
|
|
22
|
+
let fields: any[] = ['itemCode', 'itemValue', 'itemValueAlternative']
|
|
23
|
+
if (props.fields) fields = concat(fields, props.fields)
|
|
24
|
+
|
|
25
|
+
useGraphQl().queryPromise('masterItemByGroupKey',fields, variables).then((result : any)=>{
|
|
26
|
+
items.value = result
|
|
27
|
+
}).catch((error)=>{
|
|
28
|
+
alert?.addAlert({
|
|
29
|
+
message : `${error.message}`,
|
|
30
|
+
alertType:"error"
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
watch(() => props.groupKey, () => {
|
|
36
|
+
query()
|
|
37
|
+
}, { immediate: true })
|
|
38
|
+
|
|
39
|
+
watch(selectedItem, (newValue) => {
|
|
40
|
+
emit('update:modelValue', newValue)
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
const itemTitleField = computed(() => {
|
|
44
|
+
if (props.lang == 'TH') return 'itemValue'
|
|
45
|
+
else return 'itemValueAlternative'
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
query()
|
|
49
|
+
</script>
|
|
50
|
+
<template>
|
|
51
|
+
<v-select v-model="selectedItem" :item-title="itemTitleField" :items="items" item-value="itemCode">
|
|
52
|
+
<template
|
|
53
|
+
v-for="(_, name, index) in ($slots as {})"
|
|
54
|
+
:key="index"
|
|
55
|
+
#[name]="slotData"
|
|
56
|
+
>
|
|
57
|
+
<slot
|
|
58
|
+
:name="name"
|
|
59
|
+
v-bind="(slotData as object)"
|
|
60
|
+
:operation="operation"
|
|
61
|
+
/>
|
|
62
|
+
</template>
|
|
63
|
+
<template
|
|
64
|
+
v-if="!$slots.item"
|
|
65
|
+
#item="{ props, item }">
|
|
66
|
+
<v-list-item v-bind="props" :title="item.raw.itemValue"></v-list-item>
|
|
67
|
+
</template>
|
|
68
|
+
</v-select>
|
|
69
|
+
</template>
|
|
70
|
+
|
|
71
|
+
<style scoped>
|
|
72
|
+
|
|
73
|
+
</style>
|