refactor(04): input select
This commit is contained in:
parent
05651af9a8
commit
48c1bd9987
3 changed files with 107 additions and 47 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { getRole } from 'src/services/keycloak';
|
import { getRole } from 'src/services/keycloak';
|
||||||
|
import { selectFilterOptionRefMod } from 'src/stores/utils';
|
||||||
import { ref, onMounted } from 'vue';
|
import { ref, onMounted } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
const { locale } = useI18n({ useScope: 'global' });
|
const { locale } = useI18n({ useScope: 'global' });
|
||||||
|
|
@ -12,14 +13,17 @@ const code = defineModel<string>('code');
|
||||||
|
|
||||||
const registeredBranchId = defineModel<string>('registeredBranchId');
|
const registeredBranchId = defineModel<string>('registeredBranchId');
|
||||||
const codeOption = ref<{ id: string; name: string }[]>([]);
|
const codeOption = ref<{ id: string; name: string }[]>([]);
|
||||||
|
const optionsBranch = defineModel<{ id: string; name: string }[]>(
|
||||||
|
'optionsBranch',
|
||||||
|
{ required: true },
|
||||||
|
);
|
||||||
|
|
||||||
const props = defineProps<{
|
defineProps<{
|
||||||
dense?: boolean;
|
dense?: boolean;
|
||||||
outlined?: boolean;
|
outlined?: boolean;
|
||||||
readonly?: boolean;
|
readonly?: boolean;
|
||||||
separator?: boolean;
|
separator?: boolean;
|
||||||
isType?: boolean;
|
isType?: boolean;
|
||||||
optionsBranch: { id: string; name: string }[];
|
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
|
@ -32,11 +36,17 @@ onMounted(async () => {
|
||||||
if (locale.value === 'th-th') {
|
if (locale.value === 'th-th') {
|
||||||
codeOption.value = option.tha.typeProduct;
|
codeOption.value = option.tha.typeProduct;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!!props.optionsBranch) {
|
|
||||||
registeredBranchId.value = props.optionsBranch[0].id;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const codeOptions = ref<Record<string, unknown>[]>([]);
|
||||||
|
const codeFilter = selectFilterOptionRefMod(codeOption, codeOptions, 'label');
|
||||||
|
|
||||||
|
const branchOptions = ref<Record<string, unknown>[]>([]);
|
||||||
|
const branchFilter = selectFilterOptionRefMod(
|
||||||
|
optionsBranch,
|
||||||
|
branchOptions,
|
||||||
|
'name',
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -46,43 +56,59 @@ onMounted(async () => {
|
||||||
|
|
||||||
<div class="col-9 row q-col-gutter-md">
|
<div class="col-9 row q-col-gutter-md">
|
||||||
<q-select
|
<q-select
|
||||||
lazy-rules="ondemand"
|
|
||||||
id="select-br-id"
|
|
||||||
:dense="dense"
|
|
||||||
outlined
|
outlined
|
||||||
:readonly="readonly"
|
clearable
|
||||||
:hide-dropdown-icon="readonly"
|
use-input
|
||||||
|
fill-input
|
||||||
emit-value
|
emit-value
|
||||||
map-options
|
map-options
|
||||||
options-dense
|
hide-selected
|
||||||
clearable
|
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
|
input-debounce="0"
|
||||||
class="col-3"
|
class="col-3"
|
||||||
v-model="code"
|
v-model="code"
|
||||||
:label="$t('productCode')"
|
id="select-br-id"
|
||||||
option-label="label"
|
option-label="label"
|
||||||
option-value="value"
|
option-value="value"
|
||||||
:options="codeOption"
|
lazy-rules="ondemand"
|
||||||
|
:dense="dense"
|
||||||
|
:readonly="readonly"
|
||||||
|
:options="codeOptions"
|
||||||
|
:label="$t('productCode')"
|
||||||
|
:hide-dropdown-icon="readonly"
|
||||||
:rules="[(val: string) => !!val]"
|
:rules="[(val: string) => !!val]"
|
||||||
/>
|
@filter="codeFilter"
|
||||||
|
>
|
||||||
|
<template v-slot:no-option>
|
||||||
|
<q-item>
|
||||||
|
<q-item-section class="text-grey">
|
||||||
|
{{ $t('noResults') }}
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</template>
|
||||||
|
</q-select>
|
||||||
|
|
||||||
<q-select
|
<q-select
|
||||||
lazy-rules="ondemand"
|
|
||||||
id="input-source-nationality"
|
|
||||||
:dense="dense"
|
|
||||||
outlined
|
outlined
|
||||||
:readonly="readonly"
|
clearable
|
||||||
:hide-dropdown-icon="readonly"
|
use-input
|
||||||
hide-bottom-space
|
fill-input
|
||||||
emit-value
|
emit-value
|
||||||
map-options
|
map-options
|
||||||
options-dense
|
hide-selected
|
||||||
:label="$t('registeredBranch')"
|
hide-bottom-space
|
||||||
|
input-debounce="0"
|
||||||
class="col-3"
|
class="col-3"
|
||||||
option-label="name"
|
|
||||||
option-value="id"
|
option-value="id"
|
||||||
|
option-label="name"
|
||||||
|
lazy-rules="ondemand"
|
||||||
|
id="input-source-nationality"
|
||||||
v-model="registeredBranchId"
|
v-model="registeredBranchId"
|
||||||
:options="optionsBranch"
|
:dense="dense"
|
||||||
|
:readonly="readonly"
|
||||||
|
:options="branchOptions"
|
||||||
|
:hide-dropdown-icon="readonly"
|
||||||
|
:label="$t('registeredBranch')"
|
||||||
:rules="[
|
:rules="[
|
||||||
(val) => {
|
(val) => {
|
||||||
const roles = getRole() || [];
|
const roles = getRole() || [];
|
||||||
|
|
@ -92,8 +118,16 @@ onMounted(async () => {
|
||||||
return isSpecialRole || !!val || 'กรุณากรอกข้อมูล';
|
return isSpecialRole || !!val || 'กรุณากรอกข้อมูล';
|
||||||
},
|
},
|
||||||
]"
|
]"
|
||||||
clearable
|
@filter="branchFilter"
|
||||||
/>
|
>
|
||||||
|
<template v-slot:no-option>
|
||||||
|
<q-item>
|
||||||
|
<q-item-section class="text-grey">
|
||||||
|
{{ $t('noResults') }}
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</template>
|
||||||
|
</q-select>
|
||||||
|
|
||||||
<q-input
|
<q-input
|
||||||
lazy-rules="ondemand"
|
lazy-rules="ondemand"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { getRole } from 'src/services/keycloak';
|
import { getRole } from 'src/services/keycloak';
|
||||||
import useOptionStore from 'src/stores/options';
|
import useOptionStore from 'src/stores/options';
|
||||||
import { onMounted } from 'vue';
|
import { selectFilterOptionRefMod } from 'src/stores/utils';
|
||||||
|
import { ref } from 'vue';
|
||||||
|
|
||||||
const optionStore = useOptionStore();
|
const optionStore = useOptionStore();
|
||||||
|
|
||||||
|
|
@ -15,15 +16,27 @@ const serviceName = defineModel<string>('serviceNameTh');
|
||||||
const serviceDescription = defineModel<string>('serviceDescription');
|
const serviceDescription = defineModel<string>('serviceDescription');
|
||||||
|
|
||||||
const registeredBranchId = defineModel<string | null>('registeredBranchId');
|
const registeredBranchId = defineModel<string | null>('registeredBranchId');
|
||||||
const props = defineProps<{
|
|
||||||
|
const optionsBranch = defineModel<{ id: string; name: string }[]>(
|
||||||
|
'optionsBranch',
|
||||||
|
{ required: true },
|
||||||
|
);
|
||||||
|
|
||||||
|
defineProps<{
|
||||||
dense?: boolean;
|
dense?: boolean;
|
||||||
outlined?: boolean;
|
outlined?: boolean;
|
||||||
readonly?: boolean;
|
readonly?: boolean;
|
||||||
separator?: boolean;
|
separator?: boolean;
|
||||||
isType?: boolean;
|
isType?: boolean;
|
||||||
service?: boolean;
|
service?: boolean;
|
||||||
optionsBranch?: { id: string; name: string }[];
|
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const branchOptions = ref<Record<string, unknown>[]>([]);
|
||||||
|
const branchFilter = selectFilterOptionRefMod(
|
||||||
|
optionsBranch,
|
||||||
|
branchOptions,
|
||||||
|
'name',
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -84,22 +97,25 @@ const props = defineProps<{
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<q-select
|
<q-select
|
||||||
lazy-rules="ondemand"
|
|
||||||
id="input-source-nationality"
|
|
||||||
:dense="dense"
|
|
||||||
outlined
|
outlined
|
||||||
:readonly="readonly"
|
clearable
|
||||||
:hide-dropdown-icon="readonly"
|
use-input
|
||||||
hide-bottom-space
|
fill-input
|
||||||
emit-value
|
emit-value
|
||||||
map-options
|
map-options
|
||||||
options-dense
|
hide-selected
|
||||||
:label="$t('registeredBranch')"
|
hide-bottom-space
|
||||||
class="col-3"
|
class="col-3"
|
||||||
option-label="name"
|
|
||||||
option-value="id"
|
option-value="id"
|
||||||
|
option-label="name"
|
||||||
|
lazy-rules="ondemand"
|
||||||
v-model="registeredBranchId"
|
v-model="registeredBranchId"
|
||||||
:options="optionsBranch"
|
id="input-source-nationality"
|
||||||
|
:dense="dense"
|
||||||
|
:readonly="readonly"
|
||||||
|
:options="branchOptions"
|
||||||
|
:hide-dropdown-icon="readonly"
|
||||||
|
:label="$t('registeredBranch')"
|
||||||
:rules="[
|
:rules="[
|
||||||
(val) => {
|
(val) => {
|
||||||
const roles = getRole() || [];
|
const roles = getRole() || [];
|
||||||
|
|
@ -109,8 +125,16 @@ const props = defineProps<{
|
||||||
return isSpecialRole || !!val || 'กรุณากรอกข้อมูล';
|
return isSpecialRole || !!val || 'กรุณากรอกข้อมูล';
|
||||||
},
|
},
|
||||||
]"
|
]"
|
||||||
clearable
|
@filter="branchFilter"
|
||||||
/>
|
>
|
||||||
|
<template v-slot:no-option>
|
||||||
|
<q-item>
|
||||||
|
<q-item-section class="text-grey">
|
||||||
|
{{ $t('noResults') }}
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</template>
|
||||||
|
</q-select>
|
||||||
|
|
||||||
<q-input
|
<q-input
|
||||||
lazy-rules="ondemand"
|
lazy-rules="ondemand"
|
||||||
|
|
|
||||||
|
|
@ -3200,6 +3200,7 @@ watch(
|
||||||
<BasicInformation
|
<BasicInformation
|
||||||
dense
|
dense
|
||||||
:isType="productMode === 'type'"
|
:isType="productMode === 'type'"
|
||||||
|
v-model:options-branch="branchOption"
|
||||||
v-model:remark="formDataGroup.remark"
|
v-model:remark="formDataGroup.remark"
|
||||||
v-model:name="formDataGroup.name"
|
v-model:name="formDataGroup.name"
|
||||||
v-model:detail="formDataGroup.detail"
|
v-model:detail="formDataGroup.detail"
|
||||||
|
|
@ -3259,6 +3260,7 @@ watch(
|
||||||
dense
|
dense
|
||||||
:isType="productMode === 'type'"
|
:isType="productMode === 'type'"
|
||||||
:readonly="!isEdit"
|
:readonly="!isEdit"
|
||||||
|
v-model:options-branch="branchOption"
|
||||||
v-model:remark="formDataGroup.remark"
|
v-model:remark="formDataGroup.remark"
|
||||||
v-model:name="formDataGroup.name"
|
v-model:name="formDataGroup.name"
|
||||||
v-model:code="formDataGroup.code"
|
v-model:code="formDataGroup.code"
|
||||||
|
|
@ -3448,7 +3450,7 @@ watch(
|
||||||
|
|
||||||
<template #information>
|
<template #information>
|
||||||
<BasicInfoProduct
|
<BasicInfoProduct
|
||||||
:options-branch="branchOption"
|
v-model:options-branch="branchOption"
|
||||||
v-model:registered-branch-id="formDataProduct.registeredBranchId"
|
v-model:registered-branch-id="formDataProduct.registeredBranchId"
|
||||||
v-model:detail="formDataProduct.detail"
|
v-model:detail="formDataProduct.detail"
|
||||||
v-model:remark="formDataProduct.remark"
|
v-model:remark="formDataProduct.remark"
|
||||||
|
|
@ -3516,8 +3518,8 @@ watch(
|
||||||
|
|
||||||
<template #information>
|
<template #information>
|
||||||
<BasicInfoProduct
|
<BasicInfoProduct
|
||||||
:options-branch="branchOption"
|
|
||||||
:readonly="!infoProductEdit"
|
:readonly="!infoProductEdit"
|
||||||
|
v-model:options-branch="branchOption"
|
||||||
v-model:registered-branch-id="formDataProduct.registeredBranchId"
|
v-model:registered-branch-id="formDataProduct.registeredBranchId"
|
||||||
v-model:detail="formDataProduct.detail"
|
v-model:detail="formDataProduct.detail"
|
||||||
v-model:remark="formDataProduct.remark"
|
v-model:remark="formDataProduct.remark"
|
||||||
|
|
@ -3581,7 +3583,7 @@ watch(
|
||||||
<BasicInformation
|
<BasicInformation
|
||||||
dense
|
dense
|
||||||
service
|
service
|
||||||
:options-branch="branchOption"
|
v-model:options-branch="branchOption"
|
||||||
v-model:registered-branch-id="
|
v-model:registered-branch-id="
|
||||||
formDataProductService.registeredBranchId
|
formDataProductService.registeredBranchId
|
||||||
"
|
"
|
||||||
|
|
@ -3746,7 +3748,7 @@ watch(
|
||||||
v-if="currentServiceTab === 'serviceInformation'"
|
v-if="currentServiceTab === 'serviceInformation'"
|
||||||
dense
|
dense
|
||||||
service
|
service
|
||||||
:options-branch="branchOption"
|
v-model:options-branch="branchOption"
|
||||||
v-model:registered-branch-id="
|
v-model:registered-branch-id="
|
||||||
formDataProductService.registeredBranchId
|
formDataProductService.registeredBranchId
|
||||||
"
|
"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue