feat: i18n, edit branch
This commit is contained in:
parent
82d3c893f2
commit
4bd2a08cb5
1 changed files with 46 additions and 21 deletions
|
|
@ -198,6 +198,7 @@ async function openDialog(action?: 'FORM' | 'INFO', idEdit?: string) {
|
|||
}
|
||||
|
||||
if (idEdit && userData.value) {
|
||||
isEdit.value = true;
|
||||
assignFormData(idEdit);
|
||||
|
||||
if (formData.value.userType === 'AGENCY') {
|
||||
|
|
@ -239,7 +240,7 @@ async function onSubmit() {
|
|||
formData.value.profileImage = null;
|
||||
}
|
||||
|
||||
if (isEdit.value === true && userId.value) {
|
||||
if (isEdit.value && userId.value) {
|
||||
dialog({
|
||||
color: 'primary',
|
||||
icon: 'mdi-pencil-outline',
|
||||
|
|
@ -262,7 +263,10 @@ async function onSubmit() {
|
|||
hqId.value !== currentUser.value.branch[0].id &&
|
||||
brId.value !== currentUser.value.branch[0].id
|
||||
) {
|
||||
userStore.removeBranch(userId.value, currentUser.value.branch[0].id);
|
||||
await branchStore.removeUser(
|
||||
currentUser.value.branch[0].id,
|
||||
userId.value,
|
||||
);
|
||||
|
||||
await branchStore.addUser(
|
||||
!!brId.value ? brId.value : hqId.value,
|
||||
|
|
@ -270,6 +274,15 @@ async function onSubmit() {
|
|||
);
|
||||
}
|
||||
|
||||
if (!currentUser.value?.branch[0]) {
|
||||
if (brId.value || hqId.value) {
|
||||
await branchStore.addUser(
|
||||
(!!brId.value ? brId.value : hqId.value)!,
|
||||
userId.value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (userId.value && formDataEdit.userType === 'AGENCY') {
|
||||
if (!agencyFile.value) return;
|
||||
const payload: UserAttachmentCreate = {
|
||||
|
|
@ -433,17 +446,21 @@ async function assignFormData(idEdit: string) {
|
|||
? (statusToggle.value = true)
|
||||
: (statusToggle.value = false);
|
||||
userId.value = foundUser.id;
|
||||
if (foundUser.branch[0].isHeadOffice) {
|
||||
hqId.value = foundUser.branch[0].id as string;
|
||||
} else {
|
||||
hqId.value = foundUser.branch[0].headOfficeId as string;
|
||||
brId.value = foundUser.branch[0].id;
|
||||
|
||||
if (foundUser.branch[0]) {
|
||||
if (foundUser.branch[0].isHeadOffice) {
|
||||
hqId.value = foundUser.branch[0].id as string;
|
||||
} else {
|
||||
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;
|
||||
profileSubmit.value = true;
|
||||
await userStore.fetchBrOption(hqId.value);
|
||||
hqId.value && (await userStore.fetchBrOption(hqId.value));
|
||||
if (formData.value.districtId) {
|
||||
await adrressStore.fetchSubDistrictByProvinceId(
|
||||
formData.value.districtId,
|
||||
|
|
@ -538,9 +555,10 @@ watch(
|
|||
{{ selectorLabel === '' ? '' : $t(selectorLabel) }}
|
||||
</div>
|
||||
<q-btn
|
||||
id="btn-add-personnel"
|
||||
dense
|
||||
unelevated
|
||||
label="+ เพิ่มบุคลากร"
|
||||
:label="'+ ' + $t('personnelAdd')"
|
||||
padding="4px 16px"
|
||||
@click="openDialog('FORM')"
|
||||
style="background-color: var(--cyan-6); color: white"
|
||||
|
|
@ -566,6 +584,7 @@ watch(
|
|||
<AppBox bordered class="column" style="width: 100%; min-height: 70vh">
|
||||
<div class="row q-mb-md justify-between">
|
||||
<q-btn
|
||||
id="btn-filter"
|
||||
icon="mdi-tune-vertical-variant"
|
||||
size="sm"
|
||||
class="bordered rounded"
|
||||
|
|
@ -609,7 +628,7 @@ watch(
|
|||
style="width: 250px"
|
||||
outlined
|
||||
dense
|
||||
label="ค้นหา"
|
||||
:label="$t('search')"
|
||||
debounce="500"
|
||||
v-model="inputSearch"
|
||||
></q-input>
|
||||
|
|
@ -639,10 +658,10 @@ watch(
|
|||
male: v.gender === 'male',
|
||||
female: v.gender === 'female',
|
||||
detail: [
|
||||
{ label: 'ประเภท', value: $t(v.userType) },
|
||||
{ label: 'โทรศัพท์', value: v.telephoneNo },
|
||||
{ label: $t('personnelCardUserType'), value: $t(v.userType) },
|
||||
{ label: $t('personnelCardTelephone'), value: v.telephoneNo },
|
||||
{
|
||||
label: 'อายุ',
|
||||
label: $t('personnelCardAge'),
|
||||
value: userStore.calculateAge(v.birthDate as Date),
|
||||
},
|
||||
],
|
||||
|
|
@ -697,6 +716,8 @@ watch(
|
|||
>
|
||||
<template #info>
|
||||
<InfoForm
|
||||
:addressTitle="$t('formDialogTitleAddressPure')"
|
||||
:addressTitleEN="$t('formDialogTitleAddressPure') + ' ENG'"
|
||||
:readonly="!infoPersonCardEdit"
|
||||
v-model:address="formData.address"
|
||||
v-model:addressEN="formData.addressEN"
|
||||
|
|
@ -780,9 +801,9 @@ watch(
|
|||
<FormDialog
|
||||
removeDialog
|
||||
ref="formDialogRef"
|
||||
title="เพิ่มบุคลากร"
|
||||
addressTitle="ที่อยู่พนักงาน"
|
||||
addressENTitle="ที่อยู่พนักงาน ENG"
|
||||
:title="$t('personnelAdd')"
|
||||
:addressTitle="$t('formDialogTitleAddressPure')"
|
||||
:addressTitleEN="$t('formDialogTitleAddressPure') + ' ENG'"
|
||||
v-model:modal="modal"
|
||||
v-model:address="formData.address"
|
||||
v-model:addressEN="formData.addressEN"
|
||||
|
|
@ -815,28 +836,31 @@ watch(
|
|||
>
|
||||
<div class="col-6">
|
||||
<q-btn
|
||||
id="btn-profile-cancel"
|
||||
dense
|
||||
unelevated
|
||||
outlined
|
||||
padding="8px"
|
||||
class="cancel-img-btn full-width"
|
||||
label="ยกเลิก"
|
||||
:label="$t('cancel')"
|
||||
@click="urlProfile = ''"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<q-btn
|
||||
id="btn-profile-save"
|
||||
dense
|
||||
unelevated
|
||||
outlined
|
||||
padding="8px"
|
||||
class="submit-img-btn full-width"
|
||||
label="บันทึก"
|
||||
:label="$t('save')"
|
||||
@click="profileSubmit = true"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<q-btn
|
||||
id="btn-profile-edit"
|
||||
v-else-if="urlProfile && profileSubmit"
|
||||
dense
|
||||
unelevated
|
||||
|
|
@ -844,18 +868,19 @@ watch(
|
|||
padding="8px"
|
||||
icon="mdi-pencil-outline"
|
||||
class="edit-img-btn q-mt-md full-width"
|
||||
label="แก้ไขโปรไฟล์"
|
||||
:label="$t('formDialogBtnEditProfile')"
|
||||
@click.prevent="inputFile.click(), (profileSubmit = false)"
|
||||
/>
|
||||
|
||||
<q-btn
|
||||
id="btn-profile-upload"
|
||||
v-else
|
||||
dense
|
||||
unelevated
|
||||
outlined
|
||||
padding="8px"
|
||||
class="upload-img-btn q-mt-md full-width"
|
||||
label="อัปโหลดรูปภาพ"
|
||||
:label="$t('formDialogBtnUploadProfile')"
|
||||
:class="{ dark: $q.dark.isActive }"
|
||||
@click="inputFile.click()"
|
||||
/>
|
||||
|
|
@ -868,7 +893,7 @@ watch(
|
|||
padding="none"
|
||||
class="q-pr-md"
|
||||
/>
|
||||
<span>สถานะผู้ใช้งาน</span>
|
||||
<span>{{ $t('formDialogTitleUserStatus') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue