feat: select first
This commit is contained in:
parent
095a2bb268
commit
430ff80129
1 changed files with 9 additions and 2 deletions
|
|
@ -1,7 +1,10 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { storeToRefs } from 'pinia';
|
||||||
import useUserStore from 'src/stores/user';
|
import useUserStore from 'src/stores/user';
|
||||||
|
import { watch } from 'vue';
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
const { userOption } = storeToRefs(userStore);
|
||||||
|
|
||||||
const hqId = defineModel<string | null | undefined>('hqId');
|
const hqId = defineModel<string | null | undefined>('hqId');
|
||||||
const brId = defineModel<string | null | undefined>('brId');
|
const brId = defineModel<string | null | undefined>('brId');
|
||||||
|
|
@ -23,6 +26,9 @@ async function selectHq(id: string) {
|
||||||
brId.value = '';
|
brId.value = '';
|
||||||
userStore.userOption.brOpts = [];
|
userStore.userOption.brOpts = [];
|
||||||
await userStore.fetchBrOption(id);
|
await userStore.fetchBrOption(id);
|
||||||
|
if (userStore.userOption.brOpts.length === 1) {
|
||||||
|
brId.value = userStore.userOption.brOpts[0].value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -38,10 +44,10 @@ async function selectHq(id: string) {
|
||||||
options-dense
|
options-dense
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
class="col-6"
|
class="col-6"
|
||||||
|
v-model="hqId"
|
||||||
option-label="label"
|
option-label="label"
|
||||||
option-value="value"
|
option-value="value"
|
||||||
label="รหัสสำนักงานใหญ่"
|
label="รหัสสำนักงานใหญ่"
|
||||||
v-model="hqId"
|
|
||||||
:options="userStore.userOption.hqOpts"
|
:options="userStore.userOption.hqOpts"
|
||||||
:rules="[(val: string) => !!val || 'กรุณาเลือกสำนักงานใหญ่']"
|
:rules="[(val: string) => !!val || 'กรุณาเลือกสำนักงานใหญ่']"
|
||||||
@update:model-value="(val: string) => selectHq(val)"
|
@update:model-value="(val: string) => selectHq(val)"
|
||||||
|
|
@ -54,12 +60,13 @@ async function selectHq(id: string) {
|
||||||
emit-value
|
emit-value
|
||||||
map-options
|
map-options
|
||||||
options-dense
|
options-dense
|
||||||
|
clearable
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
class="col-6"
|
class="col-6"
|
||||||
|
v-model="brId"
|
||||||
label="รหัสสาขา"
|
label="รหัสสาขา"
|
||||||
option-label="label"
|
option-label="label"
|
||||||
option-value="value"
|
option-value="value"
|
||||||
v-model="brId"
|
|
||||||
:options="userStore.userOption.brOpts"
|
:options="userStore.userOption.brOpts"
|
||||||
/>
|
/>
|
||||||
<q-select
|
<q-select
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue