2024-04-17 15:44:13 +07:00
|
|
|
<script setup lang="ts">
|
2024-04-18 18:18:31 +07:00
|
|
|
import { storeToRefs } from 'pinia';
|
2024-04-17 15:44:13 +07:00
|
|
|
import useUserStore from 'src/stores/user';
|
2024-04-18 18:18:31 +07:00
|
|
|
import { watch } from 'vue';
|
2024-04-17 15:44:13 +07:00
|
|
|
|
|
|
|
|
const userStore = useUserStore();
|
2024-04-18 18:18:31 +07:00
|
|
|
const { userOption } = storeToRefs(userStore);
|
2024-04-17 15:44:13 +07:00
|
|
|
|
|
|
|
|
const hqId = defineModel<string | null | undefined>('hqId');
|
|
|
|
|
const brId = defineModel<string | null | undefined>('brId');
|
|
|
|
|
const userType = defineModel<string>('userType');
|
|
|
|
|
const userRole = defineModel<string>('userRole');
|
2024-04-18 09:05:32 +07:00
|
|
|
const username = defineModel<string | null | undefined>('username');
|
2024-04-17 15:44:13 +07:00
|
|
|
const userCode = defineModel<string>('userCode');
|
|
|
|
|
|
|
|
|
|
defineProps<{
|
|
|
|
|
dense?: boolean;
|
|
|
|
|
outlined?: boolean;
|
|
|
|
|
readonly?: boolean;
|
|
|
|
|
separator?: boolean;
|
2024-04-18 09:05:32 +07:00
|
|
|
usernameReadonly?: boolean;
|
2024-04-17 15:44:13 +07:00
|
|
|
}>();
|
|
|
|
|
|
|
|
|
|
async function selectHq(id: string) {
|
|
|
|
|
if (!id) return;
|
|
|
|
|
brId.value = '';
|
|
|
|
|
userStore.userOption.brOpts = [];
|
|
|
|
|
await userStore.fetchBrOption(id);
|
2024-04-18 18:18:31 +07:00
|
|
|
if (userStore.userOption.brOpts.length === 1) {
|
|
|
|
|
brId.value = userStore.userOption.brOpts[0].value;
|
|
|
|
|
}
|
2024-04-17 15:44:13 +07:00
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
<template>
|
|
|
|
|
<div class="col-3 app-text-muted">• ข้อมูลพื้นฐาน</div>
|
|
|
|
|
<div class="col-9 row q-col-gutter-md">
|
|
|
|
|
<q-select
|
|
|
|
|
:dense="dense"
|
|
|
|
|
:outlined="outlined"
|
|
|
|
|
:readonly="readonly"
|
|
|
|
|
:hide-dropdown-icon="readonly"
|
|
|
|
|
emit-value
|
|
|
|
|
map-options
|
|
|
|
|
options-dense
|
|
|
|
|
hide-bottom-space
|
|
|
|
|
class="col-6"
|
2024-04-18 18:18:31 +07:00
|
|
|
v-model="hqId"
|
2024-04-17 15:44:13 +07:00
|
|
|
option-label="label"
|
|
|
|
|
option-value="value"
|
|
|
|
|
label="รหัสสำนักงานใหญ่"
|
|
|
|
|
:options="userStore.userOption.hqOpts"
|
|
|
|
|
:rules="[(val: string) => !!val || 'กรุณาเลือกสำนักงานใหญ่']"
|
|
|
|
|
@update:model-value="(val: string) => selectHq(val)"
|
|
|
|
|
/>
|
|
|
|
|
<q-select
|
|
|
|
|
:dense="dense"
|
|
|
|
|
:outlined="outlined"
|
|
|
|
|
:readonly="readonly"
|
|
|
|
|
:hide-dropdown-icon="readonly"
|
|
|
|
|
emit-value
|
|
|
|
|
map-options
|
|
|
|
|
options-dense
|
2024-04-18 18:18:31 +07:00
|
|
|
clearable
|
2024-04-17 15:44:13 +07:00
|
|
|
hide-bottom-space
|
|
|
|
|
class="col-6"
|
2024-04-18 18:18:31 +07:00
|
|
|
v-model="brId"
|
2024-04-17 15:44:13 +07:00
|
|
|
label="รหัสสาขา"
|
|
|
|
|
option-label="label"
|
|
|
|
|
option-value="value"
|
|
|
|
|
:options="userStore.userOption.brOpts"
|
|
|
|
|
/>
|
|
|
|
|
<q-select
|
|
|
|
|
:dense="dense"
|
|
|
|
|
:outlined="outlined"
|
|
|
|
|
:readonly="readonly"
|
|
|
|
|
:hide-dropdown-icon="readonly"
|
|
|
|
|
emit-value
|
|
|
|
|
map-options
|
|
|
|
|
options-dense
|
|
|
|
|
hide-bottom-space
|
|
|
|
|
class="col-3"
|
|
|
|
|
option-value="value"
|
|
|
|
|
option-label="label"
|
|
|
|
|
label="ประเภทผู้ใช้งาน"
|
|
|
|
|
v-model="userType"
|
|
|
|
|
:options="userStore.userOption.userTypeOpts"
|
|
|
|
|
:rules="[(val: string) => !!val || 'กรุณาเลือกประเภทผู้ใช้งาน']"
|
|
|
|
|
/>
|
|
|
|
|
<q-select
|
|
|
|
|
:dense="dense"
|
|
|
|
|
:outlined="outlined"
|
|
|
|
|
:readonly="readonly"
|
|
|
|
|
:hide-dropdown-icon="readonly"
|
|
|
|
|
emit-value
|
|
|
|
|
map-options
|
|
|
|
|
options-dense
|
|
|
|
|
hide-bottom-space
|
|
|
|
|
class="col-3"
|
|
|
|
|
label="สิทธิ์ผู้ใช้งาน"
|
|
|
|
|
option-label="label"
|
|
|
|
|
option-value="value"
|
|
|
|
|
v-model="userRole"
|
|
|
|
|
:options="userStore.userOption.roleOpts"
|
|
|
|
|
:rules="[(val: string) => !!val || 'กรุณาเลือกสิทธิ์ผู้ใช้งาน']"
|
|
|
|
|
/>
|
|
|
|
|
<q-input
|
|
|
|
|
:dense="dense"
|
|
|
|
|
:outlined="outlined"
|
2024-04-18 09:05:32 +07:00
|
|
|
:readonly="usernameReadonly"
|
2024-04-17 15:44:13 +07:00
|
|
|
emit-value
|
|
|
|
|
map-options
|
|
|
|
|
options-dense
|
|
|
|
|
hide-bottom-space
|
|
|
|
|
class="col-3"
|
|
|
|
|
label="ชื่อผู้ใช้งาน (Username)"
|
2024-04-18 09:05:32 +07:00
|
|
|
v-model="username"
|
2024-04-17 15:44:13 +07:00
|
|
|
:rules="[(val: string) => val.length > 2 || 'กรุณากรอกชื่อผู้ใช้งาน']"
|
|
|
|
|
/>
|
|
|
|
|
<q-input
|
|
|
|
|
:dense="dense"
|
|
|
|
|
:outlined="outlined"
|
|
|
|
|
readonly
|
|
|
|
|
hide-bottom-space
|
|
|
|
|
class="col-3"
|
|
|
|
|
label="รหัสพนักงาน"
|
|
|
|
|
v-model="userCode"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<q-separator
|
|
|
|
|
v-if="separator"
|
|
|
|
|
class="col-12 q-mb-md"
|
|
|
|
|
style="padding-block: 0.5px; margin-top: 32px"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|