Merge branch 'dev/phatt' into develop
This commit is contained in:
commit
d1edfb4f44
8 changed files with 496 additions and 281 deletions
BIN
public/personnel-info-bg-dark.png
Normal file
BIN
public/personnel-info-bg-dark.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 36 KiB |
BIN
public/personnel-info-bg-light.png
Normal file
BIN
public/personnel-info-bg-light.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
|
|
@ -2,4 +2,7 @@ export default {
|
||||||
firstname: 'First Name',
|
firstname: 'First Name',
|
||||||
lastname: 'Last Name',
|
lastname: 'Last Name',
|
||||||
fullname: 'Full Name',
|
fullname: 'Full Name',
|
||||||
|
userType: 'User Type',
|
||||||
|
userRole: 'User Role',
|
||||||
|
userCode: 'User Id',
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,7 @@ export default {
|
||||||
firstname: 'ชื่อ',
|
firstname: 'ชื่อ',
|
||||||
lastname: 'นามสกุล',
|
lastname: 'นามสกุล',
|
||||||
fullname: 'ชื่อ-นามสกุล',
|
fullname: 'ชื่อ-นามสกุล',
|
||||||
|
userType: 'ประเภทผู้ใช้งาน',
|
||||||
|
userRole: 'สิทธิ์ผู้ใช้งาน',
|
||||||
|
userCode: 'รหัสพนักงาน',
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,7 @@ import useUserStore from 'stores/user';
|
||||||
import useBranchStore from 'src/stores/branch';
|
import useBranchStore from 'src/stores/branch';
|
||||||
import { dialog } from 'src/stores/utils';
|
import { dialog } from 'src/stores/utils';
|
||||||
|
|
||||||
import {
|
import { UserCreate, UserTypeStats, RoleData } from 'src/stores/user/types';
|
||||||
UserCreate,
|
|
||||||
UserTypeStats,
|
|
||||||
UserOption,
|
|
||||||
RoleData,
|
|
||||||
} from 'src/stores/user/types';
|
|
||||||
import { BranchUserStats } from 'src/stores/branch/types';
|
import { BranchUserStats } from 'src/stores/branch/types';
|
||||||
|
|
||||||
import PersonCard from 'components/home/PersonCard.vue';
|
import PersonCard from 'components/home/PersonCard.vue';
|
||||||
|
|
@ -116,23 +111,6 @@ inputFile.addEventListener('change', (e) => {
|
||||||
profileFile.value = (e.currentTarget as HTMLInputElement).files?.[0];
|
profileFile.value = (e.currentTarget as HTMLInputElement).files?.[0];
|
||||||
});
|
});
|
||||||
|
|
||||||
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: [],
|
|
||||||
});
|
|
||||||
|
|
||||||
const selectorList = [
|
const selectorList = [
|
||||||
{ label: 'personnelSelector1', count: 0 },
|
{ label: 'personnelSelector1', count: 0 },
|
||||||
{ label: 'personnelSelector2', count: 0 },
|
{ label: 'personnelSelector2', count: 0 },
|
||||||
|
|
@ -150,28 +128,12 @@ async function createKeycloak() {
|
||||||
return res.data;
|
return res.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchRoleOption() {
|
|
||||||
const res = await api.get<RoleData[]>('/keycloak/role');
|
|
||||||
res.data.map((item) => {
|
|
||||||
const formattedName = item.name
|
|
||||||
.replace(/_/g, ' ')
|
|
||||||
.toLowerCase()
|
|
||||||
.split(' ')
|
|
||||||
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
||||||
.join(' ');
|
|
||||||
userOption.value.roleOpts.push({
|
|
||||||
label: formattedName,
|
|
||||||
value: item.id,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchHqOption() {
|
async function fetchHqOption() {
|
||||||
if (userOption.value.hqOpts.length === 0) {
|
if (userStore.userOption.hqOpts.length === 0) {
|
||||||
const res = await branchStore.fetchList({ pageSize: 999, filter: 'head' });
|
const res = await branchStore.fetchList({ pageSize: 999, filter: 'head' });
|
||||||
if (res) {
|
if (res) {
|
||||||
res.result.map((item) => {
|
res.result.map((item) => {
|
||||||
userOption.value.hqOpts.push({
|
userStore.userOption.hqOpts.push({
|
||||||
label: item.code,
|
label: item.code,
|
||||||
value: item.id,
|
value: item.id,
|
||||||
});
|
});
|
||||||
|
|
@ -186,7 +148,7 @@ async function fetchBrOption(id: string) {
|
||||||
});
|
});
|
||||||
if (res && res?.branch) {
|
if (res && res?.branch) {
|
||||||
res.branch.map((item) => {
|
res.branch.map((item) => {
|
||||||
userOption.value.brOpts.push({
|
userStore.userOption.brOpts.push({
|
||||||
label: item.code,
|
label: item.code,
|
||||||
value: item.id,
|
value: item.id,
|
||||||
});
|
});
|
||||||
|
|
@ -194,13 +156,17 @@ async function fetchBrOption(id: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function openDialog(id?: string) {
|
async function openDialog(idEdit?: string) {
|
||||||
await fetchHqOption();
|
|
||||||
await fetchRoleOption();
|
|
||||||
modal.value = true;
|
modal.value = true;
|
||||||
age.value = '';
|
age.value = '';
|
||||||
if (id && userData.value) {
|
if (userStore.userOption.hqOpts.length === 0) {
|
||||||
const foundUser = userData.value.result.find((user) => user.id === id);
|
await fetchHqOption();
|
||||||
|
}
|
||||||
|
if (userStore.userOption.roleOpts.length === 0) {
|
||||||
|
await userStore.fetchRoleOption();
|
||||||
|
}
|
||||||
|
if (idEdit && userData.value) {
|
||||||
|
const foundUser = userData.value.result.find((user) => user.id === idEdit);
|
||||||
|
|
||||||
if (foundUser) {
|
if (foundUser) {
|
||||||
formData.value = {
|
formData.value = {
|
||||||
|
|
@ -249,7 +215,9 @@ async function openDialog(id?: string) {
|
||||||
code.value = foundUser.code;
|
code.value = foundUser.code;
|
||||||
urlProfile.value = foundUser.profileImageUrl;
|
urlProfile.value = foundUser.profileImageUrl;
|
||||||
isEdit.value = true;
|
isEdit.value = true;
|
||||||
|
if (userStore.userOption.brOpts.length === 0) {
|
||||||
await fetchBrOption(hqId.value);
|
await fetchBrOption(hqId.value);
|
||||||
|
}
|
||||||
await formDialogRef.value.fetchSubDistrict(formData.value.districtId);
|
await formDialogRef.value.fetchSubDistrict(formData.value.districtId);
|
||||||
await formDialogRef.value.fetchDistrict(formData.value.provinceId);
|
await formDialogRef.value.fetchDistrict(formData.value.provinceId);
|
||||||
}
|
}
|
||||||
|
|
@ -283,7 +251,7 @@ async function onSubmit() {
|
||||||
action: async () => {
|
action: async () => {
|
||||||
const formDataEdit = { ...formData.value };
|
const formDataEdit = { ...formData.value };
|
||||||
delete formDataEdit.keycloakId;
|
delete formDataEdit.keycloakId;
|
||||||
delete formDataEdit.profileImage;
|
// delete formDataEdit.profileImage;
|
||||||
await userStore.editById(userId.value, formDataEdit);
|
await userStore.editById(userId.value, formDataEdit);
|
||||||
onClose();
|
onClose();
|
||||||
userStore.fetchList({ includeBranch: true });
|
userStore.fetchList({ includeBranch: true });
|
||||||
|
|
@ -361,7 +329,7 @@ function calculateAge(birthDate: Date | null): string {
|
||||||
async function selectHq(id: string) {
|
async function selectHq(id: string) {
|
||||||
if (!id) return;
|
if (!id) return;
|
||||||
brId.value = '';
|
brId.value = '';
|
||||||
userOption.value.brOpts = [];
|
userStore.userOption.brOpts = [];
|
||||||
await fetchBrOption(id);
|
await fetchBrOption(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -450,7 +418,10 @@ watch(
|
||||||
userData?.result.map((v) => ({
|
userData?.result.map((v) => ({
|
||||||
id: v.id,
|
id: v.id,
|
||||||
img: `${v.profileImageUrl}`,
|
img: `${v.profileImageUrl}`,
|
||||||
name: `${v.firstName} ${v.lastName}`,
|
name:
|
||||||
|
$i18n.locale === 'en-US'
|
||||||
|
? `${v.firstNameEN} ${v.lastNameEN}`
|
||||||
|
: `${v.firstName} ${v.lastName}`,
|
||||||
male: v.gender === 'male',
|
male: v.gender === 'male',
|
||||||
female: v.gender === 'female',
|
female: v.gender === 'female',
|
||||||
detail: [
|
detail: [
|
||||||
|
|
@ -522,7 +493,7 @@ watch(
|
||||||
option-value="value"
|
option-value="value"
|
||||||
label="รหัสสำนักงานใหญ่"
|
label="รหัสสำนักงานใหญ่"
|
||||||
v-model="hqId"
|
v-model="hqId"
|
||||||
:options="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)"
|
||||||
/>
|
/>
|
||||||
|
|
@ -539,7 +510,7 @@ watch(
|
||||||
option-label="label"
|
option-label="label"
|
||||||
option-value="value"
|
option-value="value"
|
||||||
v-model="brId"
|
v-model="brId"
|
||||||
:options="userOption.brOpts"
|
:options="userStore.userOption.brOpts"
|
||||||
:rules="[(val: string) => !!val || 'กรุณาเลือกสาขา']"
|
:rules="[(val: string) => !!val || 'กรุณาเลือกสาขา']"
|
||||||
/>
|
/>
|
||||||
<q-select
|
<q-select
|
||||||
|
|
@ -555,7 +526,7 @@ watch(
|
||||||
option-label="label"
|
option-label="label"
|
||||||
label="ประเภทผู้ใช้งาน"
|
label="ประเภทผู้ใช้งาน"
|
||||||
v-model="formData.userType"
|
v-model="formData.userType"
|
||||||
:options="userTypeOpts"
|
:options="userStore.userOption.userTypeOpts"
|
||||||
:rules="[(val: string) => !!val || 'กรุณาเลือกประเภทผู้ใช้งาน']"
|
:rules="[(val: string) => !!val || 'กรุณาเลือกประเภทผู้ใช้งาน']"
|
||||||
/>
|
/>
|
||||||
<q-select
|
<q-select
|
||||||
|
|
@ -571,7 +542,7 @@ watch(
|
||||||
option-label="label"
|
option-label="label"
|
||||||
option-value="value"
|
option-value="value"
|
||||||
v-model="formData.userRole"
|
v-model="formData.userRole"
|
||||||
:options="userOption.roleOpts"
|
:options="userStore.userOption.roleOpts"
|
||||||
:rules="[(val: string) => !!val || 'กรุณาเลือกสิทธิ์ผู้ใช้งาน']"
|
:rules="[(val: string) => !!val || 'กรุณาเลือกสิทธิ์ผู้ใช้งาน']"
|
||||||
/>
|
/>
|
||||||
<q-input
|
<q-input
|
||||||
|
|
@ -708,7 +679,7 @@ watch(
|
||||||
option-label="label"
|
option-label="label"
|
||||||
option-value="value"
|
option-value="value"
|
||||||
v-model="formData.gender"
|
v-model="formData.gender"
|
||||||
:options="genderOpts"
|
:options="userStore.userOption.genderOpts"
|
||||||
/>
|
/>
|
||||||
<q-input
|
<q-input
|
||||||
dense
|
dense
|
||||||
|
|
@ -865,13 +836,14 @@ watch(
|
||||||
outlined
|
outlined
|
||||||
emit-value
|
emit-value
|
||||||
map-options
|
map-options
|
||||||
|
options-dense
|
||||||
label="พื้นที่ ที่รับผิดชอบในการส่งเอกสาร"
|
label="พื้นที่ ที่รับผิดชอบในการส่งเอกสาร"
|
||||||
class="col-12"
|
class="col-12"
|
||||||
bg-color="white"
|
bg-color="white"
|
||||||
option-label="label"
|
option-label="label"
|
||||||
option-value="value"
|
option-value="value"
|
||||||
v-model="formData.responsibleArea"
|
v-model="formData.responsibleArea"
|
||||||
:options="genderOpts"
|
:options="userStore.userOption.responsibleAreaOpts"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
|
|
@ -898,48 +870,43 @@ watch(
|
||||||
outlined
|
outlined
|
||||||
emit-value
|
emit-value
|
||||||
map-options
|
map-options
|
||||||
|
options-dense
|
||||||
label="สัญชาติต้นทาง"
|
label="สัญชาติต้นทาง"
|
||||||
class="col-3"
|
class="col-3"
|
||||||
bg-color="white"
|
bg-color="white"
|
||||||
option-label="label"
|
option-label="label"
|
||||||
option-value="value"
|
option-value="label"
|
||||||
v-model="formData.sourceNationality"
|
v-model="formData.sourceNationality"
|
||||||
:options="genderOpts"
|
:options="userStore.userOption.nationalityOpts"
|
||||||
/>
|
/>
|
||||||
<q-select
|
<q-select
|
||||||
dense
|
dense
|
||||||
outlined
|
outlined
|
||||||
emit-value
|
emit-value
|
||||||
map-options
|
map-options
|
||||||
|
options-dense
|
||||||
label="นำเข้าสัญชาติ"
|
label="นำเข้าสัญชาติ"
|
||||||
class="col-3"
|
class="col-3"
|
||||||
bg-color="white"
|
|
||||||
option-label="label"
|
option-label="label"
|
||||||
option-value="value"
|
option-value="label"
|
||||||
v-model="formData.importNationality"
|
v-model="formData.importNationality"
|
||||||
:options="genderOpts"
|
:options="userStore.userOption.nationalityOpts"
|
||||||
/>
|
/>
|
||||||
<q-input
|
<q-select
|
||||||
dense
|
dense
|
||||||
outlined
|
outlined
|
||||||
|
emit-value
|
||||||
|
map-options
|
||||||
|
options-dense
|
||||||
label="สถานที่อบรม"
|
label="สถานที่อบรม"
|
||||||
class="col-6"
|
class="col-6"
|
||||||
|
option-label="label"
|
||||||
|
option-value="label"
|
||||||
v-model="formData.trainingPlace"
|
v-model="formData.trainingPlace"
|
||||||
|
:options="userStore.userOption.trainingPlaceOpts"
|
||||||
/>
|
/>
|
||||||
<q-input
|
<q-input dense outlined label="ด่าน" class="col-6" />
|
||||||
dense
|
<q-input dense outlined label="ด่าน ENG" class="col-6" />
|
||||||
outlined
|
|
||||||
label="ด่าน"
|
|
||||||
class="col-6"
|
|
||||||
v-model="formData.trainingPlace"
|
|
||||||
/>
|
|
||||||
<q-input
|
|
||||||
dense
|
|
||||||
outlined
|
|
||||||
label="ด่าน ENG"
|
|
||||||
class="col-6"
|
|
||||||
v-model="formData.trainingPlace"
|
|
||||||
/>
|
|
||||||
<q-input
|
<q-input
|
||||||
dense
|
dense
|
||||||
outlined
|
outlined
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { onMounted, ref, watch } from 'vue';
|
import { onMounted, ref, watch } from 'vue';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
import useUserStore from 'stores/user';
|
import useUserStore from 'stores/user';
|
||||||
import useBranchStore from 'stores/branch';
|
import useBranchStore from 'stores/branch';
|
||||||
|
|
@ -20,6 +21,7 @@ import { reactive } from 'vue';
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const addrStore = useAddressStore();
|
const addrStore = useAddressStore();
|
||||||
const branchStore = useBranchStore();
|
const branchStore = useBranchStore();
|
||||||
|
|
@ -115,6 +117,9 @@ onMounted(async () => {
|
||||||
getCurrentUser();
|
getCurrentUser();
|
||||||
getHQ();
|
getHQ();
|
||||||
getProvince();
|
getProvince();
|
||||||
|
if (userStore.userOption.roleOpts.length === 0) {
|
||||||
|
userStore.fetchRoleOption();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(() => route.params.id, getCurrentUser);
|
watch(() => route.params.id, getCurrentUser);
|
||||||
|
|
@ -125,6 +130,25 @@ watch(() => currentUser.value?.districtId, getSubDistrict);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
<div class="text-h6 text-weight-bold q-mb-md" v-if="currentUser">
|
||||||
|
<q-btn
|
||||||
|
flat
|
||||||
|
round
|
||||||
|
padding="xs"
|
||||||
|
icon="mdi-arrow-left"
|
||||||
|
style="color: hsl(var(--info-bg))"
|
||||||
|
@click="router.go(-1)"
|
||||||
|
/>
|
||||||
|
{{
|
||||||
|
$i18n.locale === 'en-US'
|
||||||
|
? `${currentUser.firstNameEN} ${currentUser.lastNameEN}`
|
||||||
|
: `${currentUser.firstName} ${currentUser.lastName}`
|
||||||
|
}}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="q-pa-md info-bg"
|
||||||
|
:style="`background-image: url(/personnel-info-bg-${$q.dark.isActive ? 'dark' : 'light'}.png)`"
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
class="info-container"
|
class="info-container"
|
||||||
:class="{ desktop: $q.screen.gt.sm, dark: $q.dark.isActive }"
|
:class="{ desktop: $q.screen.gt.sm, dark: $q.dark.isActive }"
|
||||||
|
|
@ -135,7 +159,10 @@ watch(() => currentUser.value?.districtId, getSubDistrict);
|
||||||
{
|
{
|
||||||
id: currentUser.id,
|
id: currentUser.id,
|
||||||
img: `${currentUser.profileImageUrl}`,
|
img: `${currentUser.profileImageUrl}`,
|
||||||
name: `${currentUser.firstName} ${currentUser.lastName}`,
|
name:
|
||||||
|
$i18n.locale === 'en-US'
|
||||||
|
? `${currentUser.firstNameEN} ${currentUser.lastNameEN}`
|
||||||
|
: `${currentUser.firstName} ${currentUser.lastName}`,
|
||||||
male: currentUser.gender === 'male',
|
male: currentUser.gender === 'male',
|
||||||
female: currentUser.gender === 'female',
|
female: currentUser.gender === 'female',
|
||||||
detail: [
|
detail: [
|
||||||
|
|
@ -151,16 +178,43 @@ watch(() => currentUser.value?.districtId, getSubDistrict);
|
||||||
:grid-columns="1"
|
:grid-columns="1"
|
||||||
no-hover
|
no-hover
|
||||||
no-action
|
no-action
|
||||||
|
style="box-shadow: var(--shadow-2)"
|
||||||
/>
|
/>
|
||||||
|
<div class="col-12 row items-center q-pt-md q-col-gutter-x-md">
|
||||||
|
<div class="col-6">
|
||||||
|
<q-btn class="btn-edt full-width" padding="8px 8px">
|
||||||
|
<q-icon size="16px" name="mdi-pencil-outline" class="q-pr-xs" />
|
||||||
|
<span class="text-caption">แก้ไขข้อมูล</span>
|
||||||
|
</q-btn>
|
||||||
</div>
|
</div>
|
||||||
<AppBox class="surface-1" rounded bordered v-if="currentUser">
|
<div class="col-6">
|
||||||
|
<q-btn class="btn-delete full-width" padding="8px 8px">
|
||||||
|
<q-icon
|
||||||
|
size="16px"
|
||||||
|
name="mdi-trash-can-outline"
|
||||||
|
class="q-pr-xs"
|
||||||
|
/>
|
||||||
|
<span class="text-caption">ลบข้อมูล</span>
|
||||||
|
</q-btn>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<AppBox
|
||||||
|
class="surface-1"
|
||||||
|
rounded
|
||||||
|
bordered
|
||||||
|
v-if="currentUser"
|
||||||
|
style="box-shadow: var(--shadow-2)"
|
||||||
|
>
|
||||||
<div class="row q-col-gutter-md">
|
<div class="row q-col-gutter-md">
|
||||||
<q-select
|
<q-select
|
||||||
dense
|
dense
|
||||||
outlined
|
borderless
|
||||||
emit-value
|
emit-value
|
||||||
map-options
|
map-options
|
||||||
readonly
|
readonly
|
||||||
|
hide-dropdown-icon
|
||||||
class="col-6"
|
class="col-6"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
option-label="code"
|
option-label="code"
|
||||||
|
|
@ -173,10 +227,11 @@ watch(() => currentUser.value?.districtId, getSubDistrict);
|
||||||
<q-select
|
<q-select
|
||||||
v-model="currentBR"
|
v-model="currentBR"
|
||||||
dense
|
dense
|
||||||
outlined
|
borderless
|
||||||
emit-value
|
emit-value
|
||||||
map-options
|
map-options
|
||||||
readonly
|
readonly
|
||||||
|
hide-dropdown-icon
|
||||||
class="col-6"
|
class="col-6"
|
||||||
id="selectBR"
|
id="selectBR"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
|
|
@ -184,21 +239,110 @@ watch(() => currentUser.value?.districtId, getSubDistrict);
|
||||||
:label="$t('branchLabel')"
|
:label="$t('branchLabel')"
|
||||||
:options="br"
|
:options="br"
|
||||||
/>
|
/>
|
||||||
|
<q-select
|
||||||
|
dense
|
||||||
|
borderless
|
||||||
|
emit-value
|
||||||
|
map-options
|
||||||
|
options-dense
|
||||||
|
hide-bottom-space
|
||||||
|
readonly
|
||||||
|
hide-dropdown-icon
|
||||||
|
class="col-3"
|
||||||
|
option-value="value"
|
||||||
|
option-label="label"
|
||||||
|
:label="$t('userType')"
|
||||||
|
v-model="currentUser.userType"
|
||||||
|
:options="userStore.userOption.userTypeOpts"
|
||||||
|
:rules="[(val: string) => !!val || 'กรุณาเลือกประเภทผู้ใช้งาน']"
|
||||||
|
/>
|
||||||
|
<q-select
|
||||||
|
dense
|
||||||
|
borderless
|
||||||
|
emit-value
|
||||||
|
map-options
|
||||||
|
options-dense
|
||||||
|
hide-bottom-space
|
||||||
|
readonly
|
||||||
|
hide-dropdown-icon
|
||||||
|
class="col-3"
|
||||||
|
:label="$t('userRole')"
|
||||||
|
option-label="label"
|
||||||
|
option-value="value"
|
||||||
|
v-model="currentUser.userRole"
|
||||||
|
:options="userStore.userOption.roleOpts"
|
||||||
|
:rules="[(val: string) => !!val || 'กรุณาเลือกสิทธิ์ผู้ใช้งาน']"
|
||||||
|
/>
|
||||||
<q-input
|
<q-input
|
||||||
dense
|
dense
|
||||||
readonly
|
readonly
|
||||||
outlined
|
borderless
|
||||||
:label="$t('firstname')"
|
:label="$t('userCode')"
|
||||||
|
class="col-6"
|
||||||
|
v-model="currentUser.code"
|
||||||
|
/>
|
||||||
|
<q-input
|
||||||
|
dense
|
||||||
|
borderless
|
||||||
|
hide-bottom-space
|
||||||
|
readonly
|
||||||
class="col-3"
|
class="col-3"
|
||||||
|
label="ชื่อ ภาษาไทย"
|
||||||
v-model="currentUser.firstName"
|
v-model="currentUser.firstName"
|
||||||
|
:rules="[(val: string) => !!val || 'กรุณากรอกชื่อ ภาษาไทย']"
|
||||||
|
/>
|
||||||
|
<q-input
|
||||||
|
dense
|
||||||
|
borderless
|
||||||
|
hide-bottom-space
|
||||||
|
readonly
|
||||||
|
class="col-3"
|
||||||
|
label="นามสกุล ภาษาไทย"
|
||||||
|
v-model="currentUser.lastName"
|
||||||
|
:rules="[(val: string) => !!val || 'กรุณากรอกนามสกุล ภาษาไทย']"
|
||||||
|
/>
|
||||||
|
<q-input
|
||||||
|
dense
|
||||||
|
borderless
|
||||||
|
hide-bottom-space
|
||||||
|
readonly
|
||||||
|
class="col-3"
|
||||||
|
label="ชื่อ ภาษาอังกฤษ"
|
||||||
|
v-model="currentUser.firstNameEN"
|
||||||
|
:rules="[(val: string) => !!val || 'กรุณากรอกชื่อ ภาษาอังกฤษ']"
|
||||||
|
/>
|
||||||
|
<q-input
|
||||||
|
dense
|
||||||
|
borderless
|
||||||
|
hide-bottom-space
|
||||||
|
readonly
|
||||||
|
class="col-3"
|
||||||
|
label="นามสกุล ภาษาอังกฤษ"
|
||||||
|
v-model="currentUser.lastNameEN"
|
||||||
|
:rules="[(val: string) => !!val || 'กรุณากรอกนามสกุล ภาษาอังกฤษ']"
|
||||||
|
/>
|
||||||
|
<q-input
|
||||||
|
dense
|
||||||
|
readonly
|
||||||
|
borderless
|
||||||
|
label="เบอร์โทร"
|
||||||
|
class="col-6"
|
||||||
|
v-model="currentUser.zipCode"
|
||||||
|
/>
|
||||||
|
<q-input
|
||||||
|
dense
|
||||||
|
readonly
|
||||||
|
borderless
|
||||||
|
label="อีเมล"
|
||||||
|
class="col-6"
|
||||||
|
v-model="currentUser.zipCode"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div class="col-12 group-label">{{ $t('address') }}</div>
|
<div class="col-12 group-label">{{ $t('address') }}</div>
|
||||||
|
|
||||||
<q-input
|
<q-input
|
||||||
dense
|
dense
|
||||||
outlined
|
borderless
|
||||||
readonly
|
readonly
|
||||||
id="address"
|
id="address"
|
||||||
label="ที่อยู่"
|
label="ที่อยู่"
|
||||||
|
|
@ -207,10 +351,11 @@ watch(() => currentUser.value?.districtId, getSubDistrict);
|
||||||
/>
|
/>
|
||||||
<q-select
|
<q-select
|
||||||
dense
|
dense
|
||||||
outlined
|
borderless
|
||||||
emit-value
|
emit-value
|
||||||
map-options
|
map-options
|
||||||
readonly
|
readonly
|
||||||
|
hide-dropdown-icon
|
||||||
id="selectProvince"
|
id="selectProvince"
|
||||||
v-model="currentUser.provinceId"
|
v-model="currentUser.provinceId"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
|
|
@ -218,16 +363,18 @@ watch(() => currentUser.value?.districtId, getSubDistrict);
|
||||||
:label="$t('province')"
|
:label="$t('province')"
|
||||||
class="col-3"
|
class="col-3"
|
||||||
@update:model-value="
|
@update:model-value="
|
||||||
(currentUser.districtId = null), (currentUser.subDistrictId = null)
|
(currentUser.districtId = null),
|
||||||
|
(currentUser.subDistrictId = null)
|
||||||
"
|
"
|
||||||
:options="opts.province"
|
:options="opts.province"
|
||||||
/>
|
/>
|
||||||
<q-select
|
<q-select
|
||||||
dense
|
dense
|
||||||
outlined
|
borderless
|
||||||
emit-value
|
emit-value
|
||||||
map-options
|
map-options
|
||||||
readonly
|
readonly
|
||||||
|
hide-dropdown-icon
|
||||||
id="selectDistrict"
|
id="selectDistrict"
|
||||||
v-model="currentUser.districtId"
|
v-model="currentUser.districtId"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
|
|
@ -239,10 +386,11 @@ watch(() => currentUser.value?.districtId, getSubDistrict);
|
||||||
/>
|
/>
|
||||||
<q-select
|
<q-select
|
||||||
dense
|
dense
|
||||||
outlined
|
borderless
|
||||||
readonly
|
readonly
|
||||||
emit-value
|
emit-value
|
||||||
map-options
|
map-options
|
||||||
|
hide-dropdown-icon
|
||||||
id="SelectSubDistrict"
|
id="SelectSubDistrict"
|
||||||
v-model="currentUser.subDistrictId"
|
v-model="currentUser.subDistrictId"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
|
|
@ -254,7 +402,7 @@ watch(() => currentUser.value?.districtId, getSubDistrict);
|
||||||
<q-input
|
<q-input
|
||||||
dense
|
dense
|
||||||
readonly
|
readonly
|
||||||
outlined
|
borderless
|
||||||
:label="$t('zipCode')"
|
:label="$t('zipCode')"
|
||||||
class="col-3"
|
class="col-3"
|
||||||
v-model="currentUser.zipCode"
|
v-model="currentUser.zipCode"
|
||||||
|
|
@ -264,7 +412,8 @@ watch(() => currentUser.value?.districtId, getSubDistrict);
|
||||||
|
|
||||||
<q-input
|
<q-input
|
||||||
dense
|
dense
|
||||||
outlined
|
borderless
|
||||||
|
hide-dropdown-icon
|
||||||
readonly
|
readonly
|
||||||
id="addressEN"
|
id="addressEN"
|
||||||
label="ที่อยู่"
|
label="ที่อยู่"
|
||||||
|
|
@ -273,9 +422,10 @@ watch(() => currentUser.value?.districtId, getSubDistrict);
|
||||||
/>
|
/>
|
||||||
<q-select
|
<q-select
|
||||||
dense
|
dense
|
||||||
outlined
|
borderless
|
||||||
emit-value
|
emit-value
|
||||||
map-options
|
map-options
|
||||||
|
hide-dropdown-icon
|
||||||
readonly
|
readonly
|
||||||
id="selectProvinceEN"
|
id="selectProvinceEN"
|
||||||
v-model="currentUser.provinceId"
|
v-model="currentUser.provinceId"
|
||||||
|
|
@ -284,16 +434,18 @@ watch(() => currentUser.value?.districtId, getSubDistrict);
|
||||||
:label="$t('province')"
|
:label="$t('province')"
|
||||||
class="col-3"
|
class="col-3"
|
||||||
@update:model-value="
|
@update:model-value="
|
||||||
(currentUser.districtId = null), (currentUser.subDistrictId = null)
|
(currentUser.districtId = null),
|
||||||
|
(currentUser.subDistrictId = null)
|
||||||
"
|
"
|
||||||
:options="opts.province"
|
:options="opts.province"
|
||||||
/>
|
/>
|
||||||
<q-select
|
<q-select
|
||||||
dense
|
dense
|
||||||
outlined
|
|
||||||
emit-value
|
emit-value
|
||||||
map-options
|
map-options
|
||||||
|
borderless
|
||||||
readonly
|
readonly
|
||||||
|
hide-dropdown-icon
|
||||||
id="selectDistrictEN"
|
id="selectDistrictEN"
|
||||||
v-model="currentUser.districtId"
|
v-model="currentUser.districtId"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
|
|
@ -305,8 +457,9 @@ watch(() => currentUser.value?.districtId, getSubDistrict);
|
||||||
/>
|
/>
|
||||||
<q-select
|
<q-select
|
||||||
dense
|
dense
|
||||||
outlined
|
borderless
|
||||||
readonly
|
readonly
|
||||||
|
hide-dropdown-icon
|
||||||
emit-value
|
emit-value
|
||||||
map-options
|
map-options
|
||||||
id="SelectSubDistrictEN"
|
id="SelectSubDistrictEN"
|
||||||
|
|
@ -320,7 +473,7 @@ watch(() => currentUser.value?.districtId, getSubDistrict);
|
||||||
<q-input
|
<q-input
|
||||||
dense
|
dense
|
||||||
readonly
|
readonly
|
||||||
outlined
|
borderless
|
||||||
zip="zipEN"
|
zip="zipEN"
|
||||||
:label="$t('zipCode')"
|
:label="$t('zipCode')"
|
||||||
class="col-3"
|
class="col-3"
|
||||||
|
|
@ -329,6 +482,7 @@ watch(() => currentUser.value?.districtId, getSubDistrict);
|
||||||
</div>
|
</div>
|
||||||
</AppBox>
|
</AppBox>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|
@ -350,4 +504,24 @@ watch(() => currentUser.value?.districtId, getSubDistrict);
|
||||||
grid-template-columns: 1fr 4fr;
|
grid-template-columns: 1fr 4fr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.info-bg {
|
||||||
|
background-color: var(--surface-1);
|
||||||
|
height: 45vw;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-size: cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-edt {
|
||||||
|
color: white;
|
||||||
|
background-color: hsl(var(--info-bg));
|
||||||
|
border-radius: var(--radius-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-delete {
|
||||||
|
color: hsl(var(--info-bg));
|
||||||
|
background-color: var(--surface-1);
|
||||||
|
border-radius: var(--radius-2);
|
||||||
|
border: 1px solid hsl(var(--info-bg));
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -3,18 +3,77 @@ import { defineStore } from 'pinia';
|
||||||
import { Pagination } from '../types';
|
import { Pagination } from '../types';
|
||||||
import { api } from 'src/boot/axios';
|
import { api } from 'src/boot/axios';
|
||||||
import {
|
import {
|
||||||
|
RoleData,
|
||||||
User,
|
User,
|
||||||
UserAttachment,
|
UserAttachment,
|
||||||
UserAttachmentCreate,
|
UserAttachmentCreate,
|
||||||
UserAttachmentDelete,
|
UserAttachmentDelete,
|
||||||
UserCreate,
|
UserCreate,
|
||||||
|
UserOption,
|
||||||
} from './types';
|
} from './types';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { Branch } from '../branch/types';
|
import { Branch } from '../branch/types';
|
||||||
|
|
||||||
const useUserStore = defineStore('api-user', () => {
|
const useUserStore = defineStore('api-user', () => {
|
||||||
|
const userOption = ref<UserOption>({
|
||||||
|
hqOpts: [],
|
||||||
|
brOpts: [],
|
||||||
|
roleOpts: [],
|
||||||
|
userTypeOpts: [
|
||||||
|
{ label: 'พนักงาน', value: 'USER' },
|
||||||
|
{ label: 'พนักงานส่งเอกสาร', value: 'MESSENGER' },
|
||||||
|
{ label: 'ตัวแทน', value: 'DELEGATE' },
|
||||||
|
{ label: 'เอเจนซี่', value: 'AGENCY' },
|
||||||
|
],
|
||||||
|
genderOpts: [
|
||||||
|
{ label: 'ชาย', value: 'male' },
|
||||||
|
{ label: 'หญิง', value: 'female' },
|
||||||
|
],
|
||||||
|
responsibleAreaOpts: [
|
||||||
|
{ label: 'เขตพื้นที่ 1 บางรัก ปทุมวัน ยานนาวสาทร และบางคอแหลม' },
|
||||||
|
{ label: 'เขตพื้นที่ 2 จอมทอง ทุ่งครุ บางขุนเทียน บางบอน และราษฎร์บูรณะ' },
|
||||||
|
{ label: 'เขตพื้นที่ 3 คลองเตย บางนา ประเวศ พระโขนง วัฒนา และสวนหลวง' },
|
||||||
|
{ label: 'เขตพื้นที่ 4 คันนายาว บางกะปิ ลาดพร้าว บึงกุ่ม และวังทางหลาง' },
|
||||||
|
{ label: 'เขตพื้นที่ 5 คลองสามวา มีนบุรี ลาดกระบัง สะพานสูง หนองจอก และสายไหม' },
|
||||||
|
{ label: 'เขตพื้นที่ 6 คลองสาน ธนบุรี บางกอกน้อย บางกอกใหญ่ และบางพลัด' },
|
||||||
|
{ label: 'เขตพื้นที่ 7 ตลิ่งชัน ทวีวัฒนา บางแค ภาษีเจริญ และหนองแขม' },
|
||||||
|
{ label: 'เขตพื้นที่ 8 ดุสิต พระนครป้อมปราบศัตรูพ่าย และสัมพันธวงศ์' },
|
||||||
|
{ label: 'เขตพื้นที่ 9 จตุจักร ดอนเมือง บางชื่อ บางเขน และหลักส' },
|
||||||
|
{ label: 'เขตพื้นที่ 10 ดินแดง พญาไท ราชเทวี และห้วยขวาง' },
|
||||||
|
],
|
||||||
|
nationalityOpts: [
|
||||||
|
{ label: 'ไทย', value: 'th' },
|
||||||
|
{ label: 'เมียนมา', value: 'mm' },
|
||||||
|
{ label: 'ลาว', value: 'lo' },
|
||||||
|
{ label: 'กัมพูชา', value: 'kh' },
|
||||||
|
{ label: 'เวียดนาม', value: 'vn' },
|
||||||
|
],
|
||||||
|
trainingPlaceOpts: [
|
||||||
|
{ label: 'สถานที่อบรมแรงงานเมียนมา-แม่สอด จ.ตาก' },
|
||||||
|
{ label: 'สถานที่อบรมแรงงานเมียนมา- เกาะสอง จ.ระนอง' },
|
||||||
|
{ label: 'สถานที่อบรมแรงงานลาว-หนองคาย จ.หนองคาย' },
|
||||||
|
{ label: 'สถานที่อบรมแรงงานกัมพูชา- อรัญประเทศ จ.สระแก้ว' },
|
||||||
|
{ label: 'สถานที่อบรมแรงงานกัมพูชา-บ้านแหลม จ.จันทบุร' },
|
||||||
|
],
|
||||||
|
});
|
||||||
const data = ref<Pagination<User[]>>();
|
const data = ref<Pagination<User[]>>();
|
||||||
|
|
||||||
|
async function fetchRoleOption() {
|
||||||
|
const res = await api.get<RoleData[]>('/keycloak/role');
|
||||||
|
res.data.map((item) => {
|
||||||
|
const formattedName = item.name
|
||||||
|
.replace(/_/g, ' ')
|
||||||
|
.toLowerCase()
|
||||||
|
.split(' ')
|
||||||
|
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
||||||
|
.join(' ');
|
||||||
|
userOption.value.roleOpts.push({
|
||||||
|
label: formattedName,
|
||||||
|
value: item.id,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async function fetchAttachment(
|
async function fetchAttachment(
|
||||||
userId: string,
|
userId: string,
|
||||||
flow?: {
|
flow?: {
|
||||||
|
|
@ -228,9 +287,10 @@ const useUserStore = defineStore('api-user', () => {
|
||||||
transactionId: string;
|
transactionId: string;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
|
const { profileImage, ...payload } = data
|
||||||
const res = await api.put<User & { profileImageUploadUrl: string }>(
|
const res = await api.put<User & { profileImageUploadUrl: string }>(
|
||||||
`/user/${id}`,
|
`/user/${id}`,
|
||||||
data,
|
payload,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
'X-Session-Id': flow?.sessionId,
|
'X-Session-Id': flow?.sessionId,
|
||||||
|
|
@ -240,10 +300,10 @@ const useUserStore = defineStore('api-user', () => {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (data.profileImage)
|
if (profileImage)
|
||||||
await axios
|
await axios
|
||||||
.put(res.data.profileImageUploadUrl, data.profileImage, {
|
.put(res.data.profileImageUploadUrl, profileImage, {
|
||||||
headers: { 'Content-Type': data.profileImage.type },
|
headers: { 'Content-Type': profileImage.type },
|
||||||
onUploadProgress: (e) => console.log(e),
|
onUploadProgress: (e) => console.log(e),
|
||||||
})
|
})
|
||||||
.catch((e) => console.error(e));
|
.catch((e) => console.error(e));
|
||||||
|
|
@ -368,6 +428,9 @@ const useUserStore = defineStore('api-user', () => {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data,
|
data,
|
||||||
|
userOption,
|
||||||
|
fetchRoleOption,
|
||||||
|
|
||||||
fetchList,
|
fetchList,
|
||||||
fetchById,
|
fetchById,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,12 +100,17 @@ export type UserTypeStats = {
|
||||||
export type UserOption = {
|
export type UserOption = {
|
||||||
hqOpts: Option[];
|
hqOpts: Option[];
|
||||||
brOpts: Option[];
|
brOpts: Option[];
|
||||||
|
genderOpts: Option[];
|
||||||
|
userTypeOpts: Option[];
|
||||||
roleOpts: Option[];
|
roleOpts: Option[];
|
||||||
|
responsibleAreaOpts: Option[];
|
||||||
|
nationalityOpts: Option[];
|
||||||
|
trainingPlaceOpts: Option[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Option = {
|
export type Option = {
|
||||||
label: string;
|
label: string;
|
||||||
value: string;
|
value?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type RoleData = {
|
export type RoleData = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue