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-05 17:26:40 +07:00
|
|
|
import { storeToRefs } from 'pinia';
|
2024-04-10 17:00:28 +07:00
|
|
|
import { dialog } from 'src/stores/utils';
|
2024-04-10 14:00:55 +07:00
|
|
|
import useUserStore from 'stores/user';
|
|
|
|
|
import useBranchStore from 'src/stores/branch';
|
|
|
|
|
|
2024-04-10 17:00:28 +07:00
|
|
|
import { UserCreate, UserTypeStats, UserOption } from 'src/stores/user/types';
|
2024-04-10 14:00:55 +07:00
|
|
|
import { BranchUserStats } from 'src/stores/branch/types';
|
|
|
|
|
// import { dateFormat } from 'src/utils/datetime';
|
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';
|
2024-04-10 20:26:32 +07:00
|
|
|
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-04 15:03:39 +07:00
|
|
|
|
2024-04-05 17:26:40 +07:00
|
|
|
const userStore = useUserStore();
|
2024-04-10 17:00:28 +07:00
|
|
|
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,
|
|
|
|
|
birthDate: null,
|
|
|
|
|
responsibleArea: '',
|
|
|
|
|
};
|
2024-04-10 17:00:28 +07:00
|
|
|
|
|
|
|
|
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);
|
2024-04-10 17:00:28 +07:00
|
|
|
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('');
|
2024-04-10 17:00:28 +07:00
|
|
|
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-10 14:00:55 +07:00
|
|
|
const userStats = ref<BranchUserStats[]>();
|
|
|
|
|
const typeStats = ref<UserTypeStats>();
|
|
|
|
|
const age = ref<number>();
|
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' },
|
|
|
|
|
];
|
2024-04-10 17:00:28 +07:00
|
|
|
|
|
|
|
|
const userOption = ref<UserOption>({
|
|
|
|
|
hqOpts: [],
|
|
|
|
|
brOpts: [],
|
|
|
|
|
});
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-10 17:00:28 +07:00
|
|
|
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 19:10:13 +07:00
|
|
|
if (res.branch) {
|
2024-04-10 17:00:28 +07:00
|
|
|
res.branch.map((item) => {
|
|
|
|
|
userOption.value.brOpts.push({
|
|
|
|
|
label: item.code,
|
|
|
|
|
value: item.id,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-04-05 19:05:51 +07:00
|
|
|
|
2024-04-10 17:00:28 +07:00
|
|
|
async function openDialog(id?: string) {
|
|
|
|
|
await fetchHqOption();
|
2024-04-05 19:05:51 +07:00
|
|
|
modal.value = true;
|
2024-04-10 17:00:28 +07:00
|
|
|
if (id && userData.value) {
|
|
|
|
|
const foundUser = userData.value.result.find((user) => user.id === id);
|
|
|
|
|
if (foundUser) {
|
|
|
|
|
formData.value.provinceId = foundUser.provinceId;
|
|
|
|
|
formData.value.districtId = foundUser.districtId;
|
|
|
|
|
formData.value.subDistrictId = foundUser.subDistrictId;
|
|
|
|
|
formData.value.telephoneNo = foundUser.telephoneNo;
|
|
|
|
|
formData.value.email = foundUser.email;
|
|
|
|
|
formData.value.zipCode = foundUser.zipCode;
|
|
|
|
|
formData.value.gender = foundUser.gender;
|
|
|
|
|
formData.value.addressEN = foundUser.addressEN;
|
|
|
|
|
formData.value.address = foundUser.address;
|
|
|
|
|
formData.value.trainingPlace = foundUser.trainingPlace;
|
|
|
|
|
formData.value.importNationality = foundUser.importNationality;
|
|
|
|
|
formData.value.sourceNationality = foundUser.sourceNationality;
|
|
|
|
|
formData.value.licenseExpireDate = foundUser.licenseExpireDate
|
|
|
|
|
? new Date(foundUser.licenseExpireDate)
|
|
|
|
|
: null;
|
|
|
|
|
formData.value.licenseIssueDate = foundUser.licenseIssueDate
|
|
|
|
|
? new Date(foundUser.licenseIssueDate)
|
|
|
|
|
: null;
|
|
|
|
|
formData.value.licenseNo = foundUser.licenseNo;
|
|
|
|
|
formData.value.discountCondition = foundUser.discountCondition;
|
|
|
|
|
formData.value.retireDate = foundUser.retireDate
|
|
|
|
|
? new Date(foundUser.retireDate)
|
|
|
|
|
: null;
|
|
|
|
|
formData.value.startDate = foundUser.startDate
|
|
|
|
|
? new Date(foundUser.startDate)
|
|
|
|
|
: null;
|
|
|
|
|
formData.value.registrationNo = foundUser.registrationNo;
|
|
|
|
|
formData.value.lastNameEN = foundUser.lastNameEN;
|
|
|
|
|
formData.value.lastName = foundUser.lastName;
|
|
|
|
|
formData.value.firstNameEN = foundUser.firstNameEN;
|
|
|
|
|
formData.value.firstName = foundUser.firstName;
|
|
|
|
|
formData.value.userRole = foundUser.userRole;
|
|
|
|
|
formData.value.userType = foundUser.userType;
|
|
|
|
|
formData.value.keycloakId = foundUser.keycloakId;
|
|
|
|
|
formData.value.profileImage = new File([], foundUser.profileImageUrl);
|
|
|
|
|
formData.value.birthDate = foundUser.birthDate
|
|
|
|
|
? new Date(foundUser.birthDate)
|
|
|
|
|
: null;
|
|
|
|
|
formData.value.responsibleArea = foundUser.responsibleArea;
|
|
|
|
|
userId.value = foundUser.id;
|
2024-04-10 19:10:13 +07:00
|
|
|
hqId.value = foundUser.branch[0].headOfficeId as string;
|
|
|
|
|
brId.value = foundUser.branch[0].id;
|
2024-04-10 17:00:28 +07:00
|
|
|
code.value = foundUser.code;
|
|
|
|
|
isEdit.value = true;
|
2024-04-10 19:10:13 +07:00
|
|
|
console.log(hqId.value);
|
2024-04-10 17:00:28 +07:00
|
|
|
}
|
|
|
|
|
}
|
2024-04-05 19:05:51 +07:00
|
|
|
}
|
2024-04-10 14:00:55 +07:00
|
|
|
|
|
|
|
|
function onClose() {
|
|
|
|
|
modal.value = false;
|
|
|
|
|
Object.assign(formData.value, defaultFormData);
|
|
|
|
|
hqId.value = '';
|
|
|
|
|
brId.value = '';
|
|
|
|
|
username.value = '';
|
|
|
|
|
userId.value = '';
|
2024-04-10 17:00:28 +07:00
|
|
|
code.value = '';
|
2024-04-10 14:00:55 +07:00
|
|
|
mapUserType(selectorLabel.value);
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-10 17:00:28 +07:00
|
|
|
async function onSubmit() {
|
2024-04-10 19:10:13 +07:00
|
|
|
console.log('enter');
|
2024-04-10 19:32:15 +07:00
|
|
|
formData.value.profileImage = profileFile.value as File;
|
2024-04-10 19:10:13 +07:00
|
|
|
if (isEdit.value === true && userId.value) {
|
|
|
|
|
console.log('edit');
|
|
|
|
|
await userStore.editById(userId.value, formData.value);
|
|
|
|
|
} else {
|
|
|
|
|
console.log('post');
|
|
|
|
|
formData.value.keycloakId = await createKeycloak();
|
2024-04-10 19:32:15 +07:00
|
|
|
if (formData.value.keycloakId !== '') {
|
|
|
|
|
console.log('keycloakOk');
|
2024-04-10 19:10:13 +07:00
|
|
|
const result = await userStore.create(formData.value);
|
|
|
|
|
console.log('Result after create:', result);
|
|
|
|
|
if (result) {
|
|
|
|
|
console.log('hi3');
|
|
|
|
|
console.log(result.id);
|
|
|
|
|
// await branchStore.addUser(result.id, userId.value);
|
|
|
|
|
}
|
2024-04-10 14:00:55 +07:00
|
|
|
}
|
|
|
|
|
}
|
2024-04-10 19:10:13 +07:00
|
|
|
onClose();
|
|
|
|
|
userStore.fetchList();
|
2024-04-10 14:00:55 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function onDelete(id: string) {
|
|
|
|
|
await userStore.deleteById(id);
|
|
|
|
|
await userStore.fetchList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
2024-04-10 17:00:28 +07:00
|
|
|
await userStore.fetchList({ includeBranch: true });
|
2024-04-10 14:00:55 +07:00
|
|
|
typeStats.value = await userStore.typeStats();
|
2024-04-10 19:10:13 +07:00
|
|
|
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);
|
2024-04-10 19:10:13 +07:00
|
|
|
const res = await branchStore.userStats(label);
|
|
|
|
|
if (res) {
|
|
|
|
|
userStats.value = res;
|
2024-04-10 14:00:55 +07:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
2024-04-10 17:00:28 +07:00
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
() => hqId.value,
|
|
|
|
|
async (id) => {
|
|
|
|
|
fetchBrOption(id);
|
|
|
|
|
brId.value = '';
|
|
|
|
|
userOption.value.brOpts = [];
|
|
|
|
|
},
|
|
|
|
|
);
|
2024-04-03 18:28:59 +07:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2024-04-04 15:03:39 +07:00
|
|
|
<div class="column q-pb-lg">
|
2024-04-04 16:39:50 +07:00
|
|
|
<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 -->
|
2024-04-04 16:39:50 +07:00
|
|
|
<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">
|
2024-04-10 19:10:13 +07:00
|
|
|
{{ $t('personnelStatTitle') }}
|
|
|
|
|
{{ selectorLabel === '' ? '' : $t(selectorLabel) }}
|
2024-04-05 19:05:51 +07:00
|
|
|
</div>
|
|
|
|
|
<q-btn
|
|
|
|
|
dense
|
|
|
|
|
unelevated
|
|
|
|
|
label="+ เพิ่มบุคลากร"
|
|
|
|
|
padding="4px 16px"
|
2024-04-10 17:00:28 +07:00
|
|
|
@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"
|
|
|
|
|
/>
|
2024-04-04 16:39:50 +07:00
|
|
|
</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-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',
|
|
|
|
|
})) || []
|
|
|
|
|
"
|
2024-04-10 17:00:28 +07:00
|
|
|
@updateCard="openDialog"
|
2024-04-10 14:00:55 +07:00
|
|
|
@deleteCard="onDelete"
|
2024-04-05 17:26:40 +07:00
|
|
|
/>
|
|
|
|
|
<div
|
|
|
|
|
class="column"
|
|
|
|
|
style="height: 100%"
|
|
|
|
|
v-if="userData && userData.total === 0"
|
|
|
|
|
>
|
2024-04-04 16:39:50 +07:00
|
|
|
<div class="col-1 self-end">
|
|
|
|
|
<div class="row">
|
2024-04-05 17:43:16 +07:00
|
|
|
<TooltipComponent
|
2024-04-04 16:39:50 +07:00
|
|
|
title="personnelTooltipTitle"
|
|
|
|
|
caption="personnelTooltipCaption"
|
|
|
|
|
imgSrc="personnel-table-"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col self-center" style="display: flex; align-items: center">
|
2024-04-10 20:26:32 +07:00
|
|
|
<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"
|
2024-04-04 16:39:50 +07:00
|
|
|
/>
|
|
|
|
|
</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
|
|
|
|
|
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"
|
2024-04-10 17:00:28 +07:00
|
|
|
: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
|
2024-04-10 17:00:28 +07:00
|
|
|
options-dense
|
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"
|
2024-04-10 17:00:28 +07:00
|
|
|
:options="userOption.hqOpts"
|
2024-04-10 14:00:55 +07:00
|
|
|
:rules="[(val: string) => !!val || 'กรุณาเลือกสำนักงานใหญ่']"
|
2024-04-05 19:05:51 +07:00
|
|
|
/>
|
|
|
|
|
<q-select
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
|
|
|
|
emit-value
|
|
|
|
|
map-options
|
2024-04-10 17:00:28 +07:00
|
|
|
options-dense
|
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"
|
2024-04-10 17:00:28 +07:00
|
|
|
:options="userOption.brOpts"
|
2024-04-10 14:00:55 +07:00
|
|
|
:rules="[(val: string) => !!val || 'กรุณาเลือกสาขา']"
|
|
|
|
|
/>
|
|
|
|
|
<q-select
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
|
|
|
|
emit-value
|
|
|
|
|
map-options
|
2024-04-10 17:00:28 +07:00
|
|
|
options-dense
|
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
|
2024-04-10 17:00:28 +07:00
|
|
|
options-dense
|
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"
|
2024-04-10 19:10:13 +07:00
|
|
|
:options="genderOpts"
|
2024-04-05 19:05:51 +07:00
|
|
|
/>
|
2024-04-10 19:10:13 +07:00
|
|
|
<!-- :rules="[(val: string) => !!val || 'กรุณาเลือกสิทธิ์ผู้ใช้งาน']" -->
|
2024-04-10 14:00:55 +07:00
|
|
|
<q-input
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
|
|
|
|
class="col-3"
|
|
|
|
|
bg-color="white"
|
|
|
|
|
label="ชื่อผู้ใช้งาน (Username)"
|
|
|
|
|
v-model="username"
|
|
|
|
|
:rules="[(val: string) => val.length > 2 || 'กรุณากรอกชื่อผู้ใช้งาน']"
|
|
|
|
|
/>
|
|
|
|
|
<q-input
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
|
|
|
|
readonly
|
|
|
|
|
class="col-3"
|
|
|
|
|
bg-color="white"
|
|
|
|
|
label="รหัสพนักงาน"
|
2024-04-10 17:00:28 +07:00
|
|
|
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-icon
|
|
|
|
|
name="mdi-account full-height"
|
|
|
|
|
size="3vw"
|
|
|
|
|
style="color: var(--border-color)"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<q-btn
|
|
|
|
|
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>
|
|
|
|
|
<q-file
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
|
|
|
|
ref="file"
|
|
|
|
|
style="visibility: hidden"
|
|
|
|
|
v-model="formData.profileImage"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2024-04-05 19:05:51 +07:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<template #midTop>
|
2024-04-10 14:00:55 +07:00
|
|
|
<q-input
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
|
|
|
|
class="col-3"
|
|
|
|
|
label="ชื่อ ภาษาไทย"
|
|
|
|
|
v-model="formData.firstName"
|
|
|
|
|
:rules="[(val: string) => !!val || 'กรุณากรอกชื่อ ภาษาไทย']"
|
|
|
|
|
/>
|
|
|
|
|
<q-input
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
|
|
|
|
class="col-3"
|
|
|
|
|
label="นามสกุล ภาษาไทย"
|
|
|
|
|
v-model="formData.lastName"
|
|
|
|
|
:rules="[(val: string) => !!val || 'กรุณากรอกนามสกุล ภาษาไทย']"
|
|
|
|
|
/>
|
|
|
|
|
<q-input
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
|
|
|
|
class="col-3"
|
|
|
|
|
label="ชื่อ ภาษาอังกฤษ"
|
|
|
|
|
v-model="formData.firstNameEN"
|
|
|
|
|
:rules="[(val: string) => !!val || 'กรุณากรอกชื่อ ภาษาอังกฤษ']"
|
|
|
|
|
/>
|
|
|
|
|
<q-input
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
|
|
|
|
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-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="วันที่เริ่มงาน"
|
|
|
|
|
v-model="formData.startDate"
|
|
|
|
|
>
|
|
|
|
|
<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="วันที่พ้นสภาพพนักงาน"
|
|
|
|
|
v-model="formData.retireDate"
|
|
|
|
|
>
|
|
|
|
|
<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.retireDate"
|
|
|
|
|
:locale="'th'"
|
|
|
|
|
:enableTimePicker="false"
|
|
|
|
|
class="col-3"
|
|
|
|
|
>
|
|
|
|
|
<template #year="{ value }">
|
|
|
|
|
{{ value + 543 }}
|
|
|
|
|
</template>
|
|
|
|
|
<template #trigger>
|
|
|
|
|
<q-input
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
|
|
|
|
label="วันที่พ้นสภาพพนักงาน"
|
|
|
|
|
v-model="formData.birthDate"
|
|
|
|
|
>
|
|
|
|
|
<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.retireDate"
|
|
|
|
|
name="mdi-close"
|
|
|
|
|
class="cursor-pointer"
|
|
|
|
|
size="xs"
|
|
|
|
|
@click="formData.retireDate = undefined"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
</q-input>
|
|
|
|
|
</template>
|
|
|
|
|
</VueDatePicker>
|
|
|
|
|
<q-input dense outlined label="อายุ" class="col-3" v-model="age" />
|
|
|
|
|
<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;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-04-05 19:05:51 +07:00
|
|
|
</style>
|