jws-frontend/src/pages/02_personnel-management/MainPage.vue

983 lines
28 KiB
Vue
Raw Normal View History

2024-04-03 18:28:59 +07:00
<script setup lang="ts">
2024-04-10 14:00:55 +07:00
import { ref, onMounted, watch } from 'vue';
import { api } from 'src/boot/axios';
2024-04-11 09:37:18 +07:00
import { useRouter } from 'vue-router';
2024-04-05 17:26:40 +07:00
import { storeToRefs } from 'pinia';
2024-04-10 14:00:55 +07:00
import useUserStore from 'stores/user';
import useBranchStore from 'src/stores/branch';
2024-04-11 00:37:07 +07:00
import { dialog } from 'src/stores/utils';
2024-04-10 14:00:55 +07:00
import {
UserCreate,
UserTypeStats,
UserOption,
RoleData,
} from 'src/stores/user/types';
2024-04-10 14:00:55 +07:00
import { BranchUserStats } from 'src/stores/branch/types';
2024-04-04 15:03:39 +07:00
2024-04-05 17:36:54 +07:00
import PersonCard from 'components/home/PersonCard.vue';
2024-04-03 18:28:59 +07:00
import AppBox from 'components/app/AppBox.vue';
2024-04-05 17:36:54 +07:00
import StatCardComponent from 'components/StatCardComponent.vue';
import SelectorList from 'components/SelectorList.vue';
import AddButton from 'components/AddButton.vue';
2024-04-05 17:43:16 +07:00
import TooltipComponent from 'components/TooltipComponent.vue';
2024-04-05 19:05:51 +07:00
import FormDialog from 'src/components/FormDialog.vue';
2024-04-10 20:28:12 +07:00
import { dateFormat } from 'src/utils/datetime';
2024-04-04 15:03:39 +07:00
2024-04-11 09:37:18 +07:00
const router = useRouter();
2024-04-05 17:26:40 +07:00
const userStore = useUserStore();
const branchStore = useBranchStore();
2024-04-05 17:26:40 +07:00
const { data: userData } = storeToRefs(userStore);
2024-04-03 18:28:59 +07:00
2024-04-10 14:00:55 +07:00
const defaultFormData = {
provinceId: null,
districtId: null,
subDistrictId: null,
telephoneNo: '',
email: '',
zipCode: '',
gender: '',
addressEN: '',
address: '',
trainingPlace: null,
importNationality: null,
sourceNationality: null,
licenseExpireDate: null,
licenseIssueDate: null,
licenseNo: null,
discountCondition: '',
retireDate: null,
startDate: null,
registrationNo: null,
lastNameEN: '',
lastName: '',
firstNameEN: '',
firstName: '',
userRole: '',
userType: '',
keycloakId: '',
profileImage: null,
2024-04-11 00:37:07 +07:00
birthDate: '',
2024-04-10 14:00:55 +07:00
responsibleArea: '',
};
const urlProfile = ref<string>();
const isEdit = ref(false);
2024-04-05 19:05:51 +07:00
const modal = ref(false);
2024-04-10 14:00:55 +07:00
const status = ref(false);
const userId = ref('');
const code = ref('');
2024-04-10 14:00:55 +07:00
const selectorLabel = ref('');
2024-04-05 19:05:51 +07:00
const hqId = ref('');
2024-04-10 14:00:55 +07:00
const brId = ref('');
const username = ref('');
const age = ref<string>();
const formDialogRef = ref();
const userStats = ref<BranchUserStats[]>();
const typeStats = ref<UserTypeStats>();
const formData = ref<UserCreate>({
provinceId: null,
districtId: null,
subDistrictId: null,
telephoneNo: '',
email: '',
zipCode: '',
gender: '',
addressEN: '',
address: '',
trainingPlace: null,
importNationality: null,
sourceNationality: null,
licenseExpireDate: null,
licenseIssueDate: null,
licenseNo: null,
discountCondition: '',
retireDate: null,
startDate: null,
registrationNo: null,
lastNameEN: '',
lastName: '',
firstNameEN: '',
firstName: '',
userRole: '',
userType: '',
keycloakId: '',
profileImage: null,
birthDate: null,
responsibleArea: '',
});
2024-04-05 19:05:51 +07:00
2024-04-10 19:32:15 +07:00
const profileFile = ref<File | undefined>(undefined);
const inputFile = document.createElement('input');
inputFile.type = 'file';
inputFile.accept = 'image/*';
inputFile.addEventListener('change', (e) => {
profileFile.value = (e.currentTarget as HTMLInputElement).files?.[0];
});
2024-04-10 14:00:55 +07:00
const userTypeOpts = [
{ label: 'พนักงาน', value: 'USER' },
{ label: 'พนักงานส่งเอกสาร', value: 'MESSENGER' },
{ label: 'ตัวแทน', value: 'DELEGATE' },
{ label: 'เอเจนซี่', value: 'AGENCY' },
];
const genderOpts = [
{ label: 'ชาย', value: 'male' },
{ label: 'หญิง', value: 'female' },
];
const userOption = ref<UserOption>({
hqOpts: [],
brOpts: [],
roleOpts: [],
});
2024-04-04 15:03:39 +07:00
const selectorList = [
2024-04-05 17:31:29 +07:00
{ label: 'personnelSelector1', count: 0 },
{ label: 'personnelSelector2', count: 0 },
{ label: 'personnelSelector3', count: 0 },
{ label: 'personnelSelector4', count: 0 },
2024-04-10 14:00:55 +07:00
];
async function createKeycloak() {
const res = await api.post('/keycloak/user', {
lastName: formData.value.lastNameEN,
firstName: formData.value.firstNameEN,
password: username.value,
username: username.value,
});
return res.data;
}
async function fetchRoleOption() {
const res = await api.get<RoleData[]>('/keycloak/role');
res.data.map((item) => {
2024-04-11 11:11:46 +07:00
const formattedName = item.name
.replace(/_/g, ' ')
.toLowerCase()
.split(' ')
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
.join(' ');
userOption.value.roleOpts.push({
2024-04-11 11:11:46 +07:00
label: formattedName,
value: item.id,
});
});
}
async function fetchHqOption() {
if (userOption.value.hqOpts.length === 0) {
const res = await branchStore.fetchList({ pageSize: 999, filter: 'head' });
if (res) {
res.result.map((item) => {
userOption.value.hqOpts.push({
label: item.code,
value: item.id,
});
});
}
}
}
async function fetchBrOption(id: string) {
const res = await branchStore.fetchById(id, {
includeSubBranch: true,
});
2024-04-10 20:28:12 +07:00
if (res && res?.branch) {
res.branch.map((item) => {
userOption.value.brOpts.push({
label: item.code,
value: item.id,
});
});
}
}
2024-04-05 19:05:51 +07:00
async function openDialog(id?: string) {
await fetchHqOption();
await fetchRoleOption();
2024-04-05 19:05:51 +07:00
modal.value = true;
2024-04-11 00:37:07 +07:00
age.value = '';
if (id && userData.value) {
const foundUser = userData.value.result.find((user) => user.id === id);
2024-04-10 20:28:12 +07:00
if (foundUser) {
2024-04-10 20:28:12 +07:00
formData.value = {
2024-04-11 00:37:07 +07:00
provinceId: foundUser.provinceId,
districtId: foundUser.districtId,
subDistrictId: foundUser.subDistrictId,
telephoneNo: foundUser.telephoneNo,
email: foundUser.email,
zipCode: foundUser.zipCode,
gender: foundUser.gender,
addressEN: foundUser.addressEN,
address: foundUser.address,
trainingPlace: foundUser.trainingPlace,
importNationality: foundUser.importNationality,
sourceNationality: foundUser.sourceNationality,
licenseNo: foundUser.licenseNo,
discountCondition: foundUser.discountCondition,
registrationNo: foundUser.registrationNo,
lastNameEN: foundUser.lastNameEN,
lastName: foundUser.lastName,
firstNameEN: foundUser.firstNameEN,
firstName: foundUser.firstName,
userRole: foundUser.userRole,
userType: foundUser.userType,
keycloakId: foundUser.keycloakId,
responsibleArea: foundUser.responsibleArea,
2024-04-10 20:28:12 +07:00
licenseExpireDate:
(foundUser.licenseExpireDate &&
new Date(foundUser.licenseExpireDate)) ||
null,
licenseIssueDate:
(foundUser.licenseIssueDate &&
new Date(foundUser.licenseIssueDate)) ||
null,
retireDate:
(foundUser.retireDate && new Date(foundUser.retireDate)) || null,
startDate:
(foundUser.startDate && new Date(foundUser.startDate)) || null,
birthDate:
(foundUser.birthDate && new Date(foundUser.birthDate)) || null,
};
userId.value = foundUser.id;
hqId.value = foundUser.branch[0].headOfficeId as string;
brId.value = foundUser.branch[0].id;
code.value = foundUser.code;
urlProfile.value = foundUser.profileImageUrl;
isEdit.value = true;
await fetchBrOption(hqId.value);
await formDialogRef.value.fetchSubDistrict(formData.value.districtId);
await formDialogRef.value.fetchDistrict(formData.value.provinceId);
}
}
2024-04-05 19:05:51 +07:00
}
2024-04-10 14:00:55 +07:00
function onClose() {
modal.value = false;
2024-04-11 00:37:07 +07:00
age.value = '';
isEdit.value = false;
2024-04-10 14:00:55 +07:00
hqId.value = '';
brId.value = '';
username.value = '';
userId.value = '';
code.value = '';
urlProfile.value = '';
2024-04-11 00:37:07 +07:00
Object.assign(formData.value, defaultFormData);
mapUserType(selectorLabel.value);
2024-04-10 14:00:55 +07:00
}
async function onSubmit() {
2024-04-10 19:32:15 +07:00
formData.value.profileImage = profileFile.value as File;
if (isEdit.value === true && userId.value) {
2024-04-11 00:37:07 +07:00
dialog({
color: 'primary',
icon: 'mdi-pencil-outline',
title: 'ยืนยันการแก้ไขข้อมูล',
actionText: 'ตกลง',
persistent: true,
message: 'คุณต้องการแก้ไขข้อมูล ใช่หรือไม่',
action: async () => {
const formDataEdit = { ...formData.value };
delete formDataEdit.keycloakId;
delete formDataEdit.profileImage;
await userStore.editById(userId.value, formDataEdit);
onClose();
userStore.fetchList({ includeBranch: true });
},
});
} else {
2024-04-11 00:37:07 +07:00
dialog({
color: 'primary',
icon: 'mdi-account',
title: 'ยืนยันการเพิ่มบุคลากร',
actionText: 'ตกลง',
persistent: true,
message: 'คุณต้องการเพิ่มบุคลากร ใช่หรือไม่',
action: async () => {
formData.value.keycloakId = await createKeycloak();
if (formData.value.keycloakId) {
const result = await userStore.create(formData.value);
if (result) {
await branchStore.addUser(brId.value, result.id);
}
}
onClose();
userStore.fetchList({ includeBranch: true });
},
});
2024-04-10 14:00:55 +07:00
}
}
async function onDelete(id: string) {
2024-04-11 00:37:07 +07:00
dialog({
color: 'negative',
icon: 'mdi-trash-can-outline',
title: 'ยืนยันการลบข้อมูล',
actionText: 'ตกลง',
persistent: true,
message: 'คุณต้องการลบข้อมูล ใช่หรือไม่',
action: async () => {
await userStore.deleteById(id);
await userStore.fetchList({ includeBranch: true });
},
});
2024-04-10 14:00:55 +07:00
}
2024-04-11 09:37:18 +07:00
function cardClick(id: string) {
router.push({ name: 'PersonnelInfo', params: { id } });
}
2024-04-10 14:00:55 +07:00
function mapUserType(label: string) {
if (label === 'personnelSelector1') {
formData.value.userType = 'USER';
} else if (label === 'personnelSelector2') {
formData.value.userType = 'MESSENGER';
} else if (label === 'personnelSelector3') {
formData.value.userType = 'DELEGATE';
} else if (label === 'personnelSelector4') {
formData.value.userType = 'AGENCY';
}
}
2024-04-11 00:37:07 +07:00
function calculateAge(birthDate: Date | null): string {
if (!birthDate) return '';
const birthDateTimeStamp = new Date(birthDate).getTime();
const now = new Date();
const diff = now.getTime() - birthDateTimeStamp;
const ageDate = new Date(diff);
const years = ageDate.getUTCFullYear() - 1970;
2024-04-11 09:37:18 +07:00
// const months = ageDate.getUTCMonth();
// const days = ageDate.getUTCDate() - 1;
2024-04-11 00:37:07 +07:00
age.value = `${years} ปี`;
return `${years} ปี`;
}
async function selectHq(id: string) {
if (!id) return;
brId.value = '';
userOption.value.brOpts = [];
await fetchBrOption(id);
}
2024-04-10 14:00:55 +07:00
onMounted(async () => {
await userStore.fetchList({ includeBranch: true });
2024-04-10 14:00:55 +07:00
typeStats.value = await userStore.typeStats();
const res = await branchStore.userStats(formData.value.userType);
if (res) {
userStats.value = res;
2024-04-10 14:00:55 +07:00
}
});
watch(
() => selectorLabel.value,
async (label) => {
mapUserType(label);
const res = await branchStore.userStats(label);
if (res) {
userStats.value = res;
2024-04-10 14:00:55 +07:00
}
},
);
watch(
() => formData.value.birthDate,
(birthDate) => {
if (birthDate) {
calculateAge(birthDate);
2024-04-11 00:37:07 +07:00
} else {
age.value = '';
}
},
);
2024-04-03 18:28:59 +07:00
</script>
<template>
2024-04-04 15:03:39 +07:00
<div class="column q-pb-lg">
<div class="text-h6 text-weight-bold q-mb-md">
{{ $t('personnelManagement') }}
</div>
2024-04-04 15:03:39 +07:00
<div class="row full-width q-mb-md no-wrap">
<!-- selector -->
<SelectorList
:list="selectorList"
v-model:selector="selectorLabel"
class="q-mr-md col-4"
/>
2024-04-04 15:03:39 +07:00
<!-- stat -->
2024-04-05 10:37:57 +07:00
<AppBox bordered class="column full-width">
2024-04-05 19:05:51 +07:00
<div class="row q-pb-lg justify-between items-center">
<div class="text-weight-bold text-subtitle1">
{{ $t('personnelStatTitle') }}
{{ selectorLabel === '' ? '' : $t(selectorLabel) }}
2024-04-05 19:05:51 +07:00
</div>
<q-btn
dense
unelevated
label="+ เพิ่มบุคลากร"
padding="4px 16px"
@click="openDialog()"
2024-04-05 19:05:51 +07:00
style="background-color: var(--cyan-6); color: white"
/>
</div>
2024-04-05 10:37:57 +07:00
<div class="row col full-width" style="overflow-x: auto">
2024-04-10 14:00:55 +07:00
<StatCardComponent
v-if="userStats"
:branch="
userStats.map((v) => ({
amount: v.count,
label: $i18n.locale === 'en-US' ? v.nameEN : v.name,
}))
"
class="no-wrap"
/>
</div>
2024-04-04 15:03:39 +07:00
</AppBox>
</div>
2024-04-03 18:28:59 +07:00
2024-04-04 15:03:39 +07:00
<!-- main -->
<AppBox bordered style="width: 100%; height: 580px; overflow-y: auto">
2024-04-05 17:26:40 +07:00
<PersonCard
:list="
userData?.result.map((v) => ({
2024-04-10 14:00:55 +07:00
id: v.id,
2024-04-05 17:26:40 +07:00
img: `${v.profileImageUrl}`,
name: `${v.firstName} ${v.lastName}`,
male: v.gender === 'male',
female: v.gender === 'female',
detail: [
2024-04-10 14:00:55 +07:00
{ label: 'ตำแหน่ง', value: v.userType },
{ label: 'โทรศัพท์', value: v.telephoneNo },
{ label: 'อีเมล', value: v.email },
2024-04-11 00:37:07 +07:00
{ label: 'อายุ', value: calculateAge(v.birthDate as Date) },
2024-04-05 17:26:40 +07:00
],
2024-04-10 14:00:55 +07:00
badge: v.code,
2024-04-05 17:26:40 +07:00
disabled: v.status === 'INACTIVE',
})) || []
"
@updateCard="openDialog"
2024-04-10 14:00:55 +07:00
@deleteCard="onDelete"
2024-04-11 09:37:18 +07:00
@enterCard="cardClick"
2024-04-05 17:26:40 +07:00
/>
<div
class="column"
style="height: 100%"
v-if="userData && userData.total === 0"
>
<div class="col-1 self-end">
<div class="row">
2024-04-05 17:43:16 +07:00
<TooltipComponent
title="personnelTooltipTitle"
caption="personnelTooltipCaption"
imgSrc="personnel-table-"
/>
</div>
</div>
<div class="col self-center" style="display: flex; align-items: center">
<AddButton
2024-04-04 18:08:37 +07:00
:label="'personnelAdd'"
2024-04-05 09:24:10 +07:00
:cyanOn="true"
2024-04-05 19:05:51 +07:00
@trigger="openDialog"
/>
</div>
</div>
2024-04-03 18:28:59 +07:00
</AppBox>
</div>
2024-04-05 19:05:51 +07:00
2024-04-10 14:00:55 +07:00
<!-- form -->
2024-04-05 19:05:51 +07:00
<FormDialog
ref="formDialogRef"
2024-04-05 19:05:51 +07:00
v-model:modal="modal"
2024-04-10 14:00:55 +07:00
v-model:address="formData.address"
v-model:addressEN="formData.addressEN"
v-model:provinceId="formData.provinceId as string"
v-model:districtId="formData.districtId as string"
v-model:subDistrictId="formData.subDistrictId as string"
v-model:zipCode="formData.zipCode"
2024-04-05 19:05:51 +07:00
title="เพิ่มบุคลากร"
2024-04-10 14:00:55 +07:00
addressTitle="ที่อยู่พนักงาน"
addressENTitle="ที่อยู่พนักงาน ENG"
:submit="() => onSubmit()"
2024-04-10 14:00:55 +07:00
:close="() => onClose()"
2024-04-05 19:05:51 +07:00
>
<template #top>
<q-select
dense
outlined
emit-value
map-options
options-dense
2024-04-11 11:11:46 +07:00
hide-bottom-space
2024-04-05 19:05:51 +07:00
class="col-6"
2024-04-10 14:00:55 +07:00
bg-color="white"
2024-04-05 19:05:51 +07:00
option-label="label"
2024-04-10 14:00:55 +07:00
option-value="value"
2024-04-05 19:05:51 +07:00
label="รหัสสำนักงานใหญ่"
2024-04-10 14:00:55 +07:00
v-model="hqId"
:options="userOption.hqOpts"
2024-04-10 14:00:55 +07:00
:rules="[(val: string) => !!val || 'กรุณาเลือกสำนักงานใหญ่']"
@update:model-value="(val: string) => selectHq(val)"
2024-04-05 19:05:51 +07:00
/>
<q-select
dense
outlined
emit-value
map-options
options-dense
2024-04-11 11:11:46 +07:00
hide-bottom-space
2024-04-05 19:05:51 +07:00
class="col-6"
2024-04-10 14:00:55 +07:00
label="รหัสสาขา"
bg-color="white"
option-label="label"
option-value="value"
v-model="brId"
:options="userOption.brOpts"
2024-04-10 14:00:55 +07:00
:rules="[(val: string) => !!val || 'กรุณาเลือกสาขา']"
/>
<q-select
dense
outlined
emit-value
map-options
options-dense
2024-04-11 11:11:46 +07:00
hide-bottom-space
2024-04-10 14:00:55 +07:00
class="col-3"
bg-color="white"
2024-04-05 19:05:51 +07:00
option-value="value"
option-label="label"
2024-04-10 14:00:55 +07:00
label="ประเภทผู้ใช้งาน"
v-model="formData.userType"
:options="userTypeOpts"
:rules="[(val: string) => !!val || 'กรุณาเลือกประเภทผู้ใช้งาน']"
/>
<q-select
dense
outlined
emit-value
map-options
options-dense
2024-04-11 11:11:46 +07:00
hide-bottom-space
2024-04-10 14:00:55 +07:00
class="col-3"
2024-04-05 19:05:51 +07:00
bg-color="white"
2024-04-10 14:00:55 +07:00
label="สิทธิ์ผู้ใช้งาน"
option-label="label"
option-value="value"
v-model="formData.userRole"
:options="userOption.roleOpts"
2024-04-11 00:37:07 +07:00
:rules="[(val: string) => !!val || 'กรุณาเลือกสิทธิ์ผู้ใช้งาน']"
2024-04-05 19:05:51 +07:00
/>
2024-04-10 14:00:55 +07:00
<q-input
dense
outlined
2024-04-11 11:11:46 +07:00
hide-bottom-space
2024-04-10 14:00:55 +07:00
class="col-3"
bg-color="white"
label="ชื่อผู้ใช้งาน (Username)"
v-model="username"
:rules="[(val: string) => val.length > 2 || 'กรุณากรอกชื่อผู้ใช้งาน']"
/>
<q-input
dense
outlined
readonly
2024-04-11 11:11:46 +07:00
hide-bottom-space
2024-04-10 14:00:55 +07:00
class="col-3"
bg-color="white"
label="รหัสพนักงาน"
v-model="code"
2024-04-10 14:00:55 +07:00
/>
<!-- :rules="[(val: string) => !!val || 'กรุณากรอกรหัสพนักงาน']"
-->
2024-04-05 19:05:51 +07:00
</template>
<template #prepend>
2024-04-10 14:00:55 +07:00
<div class="q-pl-md text-center">
<div class="upload-img-preview">
<q-img
v-if="urlProfile"
:src="urlProfile"
style="object-fit: cover; width: 100%; height: 100%"
/>
2024-04-10 14:00:55 +07:00
<q-icon
v-else
2024-04-10 14:00:55 +07:00
name="mdi-account full-height"
size="3vw"
style="color: var(--border-color)"
/>
</div>
<q-btn
v-if="urlProfile"
dense
unelevated
outlined
padding="8px"
icon="mdi-pencil-outline"
class="edit-img-btn q-my-md full-width"
label="แก้ไขโปรไฟล์"
@click="inputFile.click()"
/>
<q-btn
v-else
2024-04-10 14:00:55 +07:00
dense
unelevated
outlined
padding="8px"
class="upload-img-btn q-my-md full-width"
label="อัปโหลดรูปภาพ"
:class="{ dark: $q.dark.isActive }"
2024-04-10 19:32:15 +07:00
@click="inputFile.click()"
2024-04-10 14:00:55 +07:00
/>
<div class="text-left">
<q-toggle
dense
size="md"
color="primary"
v-model="status"
padding="none"
class="q-pr-md"
/>
<span>สถานะผใชงาน</span>
</div>
</div>
2024-04-05 19:05:51 +07:00
</template>
<template #midTop>
2024-04-10 14:00:55 +07:00
<q-input
dense
outlined
2024-04-11 11:11:46 +07:00
hide-bottom-space
2024-04-10 14:00:55 +07:00
class="col-3"
label="ชื่อ ภาษาไทย"
v-model="formData.firstName"
:rules="[(val: string) => !!val || 'กรุณากรอกชื่อ ภาษาไทย']"
/>
<q-input
dense
outlined
2024-04-11 11:11:46 +07:00
hide-bottom-space
2024-04-10 14:00:55 +07:00
class="col-3"
label="นามสกุล ภาษาไทย"
v-model="formData.lastName"
:rules="[(val: string) => !!val || 'กรุณากรอกนามสกุล ภาษาไทย']"
/>
<q-input
dense
outlined
2024-04-11 11:11:46 +07:00
hide-bottom-space
2024-04-10 14:00:55 +07:00
class="col-3"
label="ชื่อ ภาษาอังกฤษ"
v-model="formData.firstNameEN"
:rules="[(val: string) => !!val || 'กรุณากรอกชื่อ ภาษาอังกฤษ']"
/>
<q-input
dense
outlined
2024-04-11 11:11:46 +07:00
hide-bottom-space
2024-04-10 14:00:55 +07:00
class="col-3"
label="นามสกุล ภาษาอังกฤษ"
v-model="formData.lastNameEN"
:rules="[(val: string) => !!val || 'กรุณากรอกนามสกุล ภาษาอังกฤษ']"
/>
2024-04-05 19:05:51 +07:00
</template>
<template #midBottom>
<q-input
dense
outlined
class="col-3"
2024-04-10 14:00:55 +07:00
label="เบอร์โทร"
v-model="formData.telephoneNo"
2024-04-11 00:37:07 +07:00
mask="##########"
2024-04-05 19:05:51 +07:00
/>
<q-select
dense
outlined
emit-value
map-options
label="เพศ"
2024-04-10 14:00:55 +07:00
class="col-3"
2024-04-05 19:05:51 +07:00
bg-color="white"
2024-04-10 14:00:55 +07:00
option-label="label"
option-value="value"
v-model="formData.gender"
:options="genderOpts"
2024-04-05 19:05:51 +07:00
/>
<q-input
dense
outlined
label="อีเมล"
class="col-6"
v-model="formData.email"
/>
2024-04-10 14:00:55 +07:00
<div
v-if="formData.userType === 'USER' || formData.userType === 'MESSENGER'"
class="row col-12 q-col-gutter-md"
style="margin-left: 0px; padding-left: 0px"
>
<q-input
dense
outlined
label="เลขประจำตัว นจ. 16 (เลขที่ขึ้นทะเบียน)"
class="col-12"
v-model="formData.registrationNo"
/>
<VueDatePicker
utc
autoApply
v-model="formData.startDate"
:locale="'th'"
:enableTimePicker="false"
class="col-6"
>
<template #year="{ value }">
{{ value + 543 }}
</template>
<template #trigger>
<q-input
dense
outlined
label="วันที่เริ่มงาน"
2024-04-11 09:37:18 +07:00
:model-value="
formData.startDate ? dateFormat(formData.startDate) : ''
"
2024-04-10 14:00:55 +07:00
>
<template v-slot:prepend>
<q-icon
size="xs"
name="mdi-calendar-blank-outline"
class="cursor-pointer"
color="primary"
/>
</template>
<template v-slot:append>
<q-icon
v-if="formData.startDate"
name="mdi-close"
class="cursor-pointer"
size="xs"
@click="formData.startDate = undefined"
/>
</template>
</q-input>
</template>
</VueDatePicker>
<VueDatePicker
utc
autoApply
v-model="formData.retireDate"
:locale="'th'"
:enableTimePicker="false"
class="col-6"
>
<template #year="{ value }">
{{ value + 543 }}
</template>
<template #trigger>
<q-input
dense
outlined
label="วันที่พ้นสภาพพนักงาน"
2024-04-11 09:37:18 +07:00
:model-value="
formData.retireDate ? dateFormat(formData.retireDate) : ''
"
2024-04-10 14:00:55 +07:00
>
<template v-slot:prepend>
<q-icon
size="xs"
name="mdi-calendar-blank-outline"
class="cursor-pointer"
color="primary"
/>
</template>
<template v-slot:append>
<q-icon
v-if="formData.retireDate"
name="mdi-close"
class="cursor-pointer"
size="xs"
@click="formData.retireDate = undefined"
/>
</template>
</q-input>
</template>
</VueDatePicker>
2024-04-05 19:05:51 +07:00
2024-04-10 14:00:55 +07:00
<VueDatePicker
utc
autoApply
v-model="formData.birthDate"
2024-04-10 14:00:55 +07:00
:locale="'th'"
:enableTimePicker="false"
class="col-3"
>
<template #year="{ value }">
{{ value + 543 }}
</template>
<template #trigger>
<q-input
dense
outlined
label="วันเดือนปีเกิด"
2024-04-11 09:37:18 +07:00
:model-value="
formData.birthDate ? dateFormat(formData.birthDate) : ''
"
2024-04-10 14:00:55 +07:00
>
<template v-slot:prepend>
<q-icon
size="xs"
name="mdi-calendar-blank-outline"
class="cursor-pointer"
color="positive"
/>
</template>
<template v-slot:append>
<q-icon
v-if="formData.birthDate"
2024-04-10 14:00:55 +07:00
name="mdi-close"
class="cursor-pointer"
size="xs"
@click="formData.birthDate = undefined"
2024-04-10 14:00:55 +07:00
/>
</template>
</q-input>
</template>
</VueDatePicker>
<q-input
dense
outlined
readonly
label="อายุ"
class="col-3"
v-model="age"
/>
2024-04-10 14:00:55 +07:00
<q-select
v-if="formData.userType === 'MESSENGER'"
dense
outlined
emit-value
map-options
label="พื้นที่ ที่รับผิดชอบในการส่งเอกสาร"
class="col-12"
bg-color="white"
option-label="label"
option-value="value"
v-model="formData.responsibleArea"
:options="genderOpts"
/>
</div>
<div
v-if="formData.userType === 'DELEGATE'"
class="row col-12"
style="row-gap: 16px"
>
<q-input
dense
outlined
label="เงื่อนไขส่วนลดบริการต่างๆ ของตัวแทน"
class="col-12"
v-model="formData.discountCondition"
type="textarea"
/>
</div>
<div
v-if="formData.userType === 'AGENCY'"
class="row col-12 q-col-gutter-md"
style="margin-left: 0px; padding-left: 0px"
>
<q-select
dense
outlined
emit-value
map-options
label="สัญชาติต้นทาง"
class="col-3"
bg-color="white"
option-label="label"
option-value="value"
v-model="formData.sourceNationality"
:options="genderOpts"
/>
<q-select
dense
outlined
emit-value
map-options
label="นำเข้าสัญชาติ"
class="col-3"
bg-color="white"
option-label="label"
option-value="value"
v-model="formData.importNationality"
:options="genderOpts"
/>
<q-input
dense
outlined
label="สถานที่อบรม"
class="col-6"
v-model="formData.trainingPlace"
/>
<q-input
dense
outlined
label="ด่าน"
class="col-6"
v-model="formData.trainingPlace"
/>
<q-input
dense
outlined
label="ด่าน ENG"
class="col-6"
v-model="formData.trainingPlace"
/>
<q-input
dense
outlined
label="แบบเอกสารประจำตัว"
class="col-12"
v-model="formData.discountCondition"
type="textarea"
/>
</div>
</template>
2024-04-05 19:05:51 +07:00
</FormDialog>
2024-04-03 18:28:59 +07:00
</template>
2024-04-05 19:05:51 +07:00
<style>
.bg-white {
background-color: var(--surface-1) !important;
}
2024-04-10 14:00:55 +07:00
.upload-img-preview {
border: 1px solid var(--border-color);
border-radius: var(--radius-2);
height: 12vw;
}
.upload-img-btn {
color: hsl(var(--info-bg));
border: 1px solid hsl(var(--info-bg));
background-color: hsla(var(--info-bg) / 0.1);
border-radius: var(--radius-2);
&.dark {
background-color: transparent;
}
}
.edit-img-btn {
color: hsl(var(--info-bg));
border: 1px solid hsl(var(--info-bg));
background-color: transparent;
border-radius: var(--radius-2);
}
2024-04-05 19:05:51 +07:00
</style>