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

2166 lines
65 KiB
Vue
Raw Normal View History

2024-04-03 18:28:59 +07:00
<script setup lang="ts">
2024-06-27 08:32:31 +00:00
import { ref, onMounted, watch, computed } from 'vue';
import { storeToRefs } from 'pinia';
2024-06-27 08:32:31 +00:00
import { useI18n } from 'vue-i18n';
2024-09-12 15:41:54 +07:00
2024-04-10 14:00:55 +07:00
import useUserStore from 'stores/user';
2024-09-12 15:41:54 +07:00
import useFlowStore from 'stores/flow';
2024-08-09 15:06:41 +07:00
import useBranchStore from 'stores/branch';
2024-09-12 15:41:54 +07:00
import useOptionStore from 'stores/options';
import useAddressStore from 'stores/address';
import useMyBranch from 'src/stores/my-branch';
import { calculateAge } from 'src/utils/datetime';
import { useQuasar, type QTableProps } from 'quasar';
import { dialog, baseUrl } from 'stores/utils';
import { useNavigator } from 'src/stores/navigator';
2024-09-05 10:37:14 +07:00
import { isRoleInclude, resetScrollBar } from 'src/stores/utils';
2024-09-12 15:41:54 +07:00
import { BranchUserStats } from 'stores/branch/types';
2024-04-10 14:00:55 +07:00
2024-04-19 13:54:57 +07:00
import {
User,
UserAttachmentCreate,
UserCreate,
UserTypeStats,
2024-08-09 15:06:41 +07:00
} from 'stores/user/types';
2024-08-16 17:55:44 +07:00
import {
EditButton,
DeleteButton,
SaveButton,
UndoButton,
} from 'components/button';
2024-09-12 15:41:54 +07:00
import NoData from 'components/NoData.vue';
import { AddressForm } from 'components/form';
import SideMenu from 'components/SideMenu.vue';
import AddButton from 'components/AddButton.vue';
2024-09-12 15:41:54 +07:00
import DialogForm from 'components/DialogForm.vue';
2024-06-28 14:14:23 +07:00
import DrawerInfo from 'components/DrawerInfo.vue';
2024-08-09 14:02:40 +07:00
import ProfileBanner from 'components/ProfileBanner.vue';
2024-09-12 15:41:54 +07:00
import PersonCard from 'components/shared/PersonCard.vue';
import KebabAction from 'components/shared/KebabAction.vue';
import TooltipComponent from 'components/TooltipComponent.vue';
import StatCardComponent from 'components/StatCardComponent.vue';
2024-08-09 14:02:40 +07:00
import ImageUploadDialog from 'components/ImageUploadDialog.vue';
2024-10-30 09:34:46 +07:00
import FloatingActionButton from 'components/FloatingActionButton.vue';
2024-09-12 15:41:54 +07:00
import PaginationComponent from 'components/PaginationComponent.vue';
import InfoForm from 'components/02_personnel-management/InfoForm.vue';
import FormPerson from 'components/02_personnel-management/FormPerson.vue';
import FormByType from 'components/02_personnel-management/FormByType.vue';
import FormInformation from 'components/02_personnel-management/FormInformation.vue';
2024-11-15 11:36:51 +07:00
import PaginationPageSize from 'src/components/PaginationPageSize.vue';
2024-04-04 15:03:39 +07:00
const { locale, t } = useI18n();
2024-07-18 09:10:51 +00:00
const $q = useQuasar();
2024-06-26 17:03:49 +07:00
2024-04-05 17:26:40 +07:00
const userStore = useUserStore();
2024-09-12 15:41:54 +07:00
const flowStore = useFlowStore();
const navigatorStore = useNavigator();
2024-09-12 15:41:54 +07:00
const optionStore = useOptionStore();
const branchStore = useBranchStore();
2024-04-18 18:27:22 +07:00
const adrressStore = useAddressStore();
const useMyBranchStore = useMyBranch();
2024-04-05 17:26:40 +07:00
const { data: userData } = storeToRefs(userStore);
const { myBranch } = storeToRefs(useMyBranchStore);
2024-04-03 18:28:59 +07:00
2024-09-12 15:41:54 +07:00
// state & control
const modal = ref(false);
const isEdit = ref(false);
const hideStat = ref(false);
const modeView = ref(false);
const infoDrawer = ref(false);
const isImageEdit = ref(false);
const imageDialog = ref(false);
const infoDrawerEdit = ref(false);
const refreshImageState = ref(false);
const inputSearch = ref('');
const currentTab = ref<string>('ALL');
const statusFilter = ref<'all' | 'statusACTIVE' | 'statusINACTIVE'>('all');
const currentPage = ref(1);
const pageSize = ref(30);
const currentMaxPage = computed(() =>
userData.value ? Math.ceil(userData.value?.total / pageSize.value) : 1,
);
// form & data
const hqId = ref<string>();
const brId = ref<string>();
const currentUser = ref<User>();
const userCode = ref<string>();
const statusToggle = ref(true);
const agencyFile = ref<File[]>([]);
const agencyFileList = ref<{ name: string; url: string }[]>([]);
const typeStats = ref<UserTypeStats>();
const userStats = ref<BranchUserStats[]>();
const urlProfile = ref<string>();
const profileFileImg = ref<File | null>(null);
const imageList = ref<{ selectedImage: string; list: string[] }>();
const onCreateImageList = ref<{
selectedImage: string;
list: { url: string; imgFile: File | null; name: string }[];
}>({ selectedImage: '', list: [] });
2024-04-10 14:00:55 +07:00
const defaultFormData = {
provinceId: null,
districtId: null,
subDistrictId: null,
telephoneNo: '',
email: '',
zipCode: '',
gender: '',
addressEN: '',
address: '',
2024-09-12 15:41:54 +07:00
mooEN: '',
moo: '',
soiEN: '',
soi: '',
streetEN: '',
street: '',
2024-04-10 14:00:55 +07:00
trainingPlace: null,
importNationality: null,
sourceNationality: null,
licenseExpireDate: null,
licenseIssueDate: null,
licenseNo: null,
2024-04-18 09:06:21 +07:00
discountCondition: null,
2024-04-10 14:00:55 +07:00
retireDate: null,
startDate: null,
registrationNo: null,
lastNameEN: '',
lastName: '',
firstNameEN: '',
firstName: '',
userRole: '',
userType: '',
birthDate: null,
2024-04-18 09:06:21 +07:00
responsibleArea: null,
username: '',
2024-04-18 18:27:22 +07:00
status: 'CREATED',
2024-04-19 13:54:57 +07:00
checkpoint: null,
checkpointEN: null,
2024-08-30 14:36:48 +07:00
namePrefix: null,
middleNameEN: '',
middleName: '',
2024-09-12 15:41:54 +07:00
citizenExpire: null,
citizenIssue: null,
citizenId: '',
2024-04-10 14:00:55 +07:00
};
2024-09-12 15:41:54 +07:00
const formData = ref<UserCreate>({
selectedImage: '',
branchId: '',
provinceId: null,
districtId: null,
subDistrictId: null,
telephoneNo: '',
email: '',
zipCode: '',
gender: '',
addressEN: '',
address: '',
mooEN: '',
moo: '',
soiEN: '',
soi: '',
streetEN: '',
street: '',
trainingPlace: null,
importNationality: null,
sourceNationality: null,
licenseExpireDate: null,
licenseIssueDate: null,
licenseNo: null,
discountCondition: null,
retireDate: null,
startDate: null,
registrationNo: null,
lastNameEN: '',
lastName: '',
middleNameEN: '',
middleName: '',
firstNameEN: '',
firstName: '',
namePrefix: null,
userRole: '',
userType: '',
birthDate: null,
responsibleArea: null,
checkpoint: null,
checkpointEN: null,
username: '',
status: 'CREATED',
citizenExpire: null,
citizenIssue: null,
citizenId: '',
});
const fieldSelectedOption = ref<{ label: string; value: string }[]>([
2024-08-07 11:30:28 +07:00
{
2024-08-26 16:24:08 +07:00
label: 'general.order',
2024-08-20 17:59:49 +07:00
value: 'orderNumber',
2024-08-07 11:30:28 +07:00
},
{
2024-08-26 16:24:08 +07:00
label: 'general.fullName',
value: 'name',
},
{
2024-08-26 16:24:08 +07:00
label: 'general.telephone',
value: 'telephoneNo',
},
{
2024-08-26 16:24:08 +07:00
label: 'personnel.age',
value: 'birthDate',
},
{
2024-08-26 16:24:08 +07:00
label: 'form.email',
value: 'email',
},
{
2024-08-26 16:24:08 +07:00
label: 'personnel.form.userRole',
value: 'userRole',
},
]);
const fieldSelected = ref<
2024-08-07 11:30:28 +07:00
(
2024-08-20 17:59:49 +07:00
| 'orderNumber'
2024-08-07 11:30:28 +07:00
| 'name'
| 'type'
| 'telephoneNo'
| 'birthDate'
| 'email'
| 'userRole'
)[]
>([
2024-08-20 17:59:49 +07:00
'orderNumber',
2024-08-07 11:30:28 +07:00
'name',
'type',
'telephoneNo',
'birthDate',
'email',
'userRole',
]);
2024-08-02 15:32:51 +07:00
const columns = [
2024-08-07 11:30:28 +07:00
{
2024-08-20 17:59:49 +07:00
name: 'orderNumber',
2024-08-07 11:30:28 +07:00
align: 'center',
2024-08-26 16:24:08 +07:00
label: 'general.order',
2024-08-07 11:30:28 +07:00
field: 'branchNo',
},
{
name: 'name',
align: 'left',
2024-08-26 16:24:08 +07:00
label: 'general.fullName',
field: 'firstName',
},
2024-11-08 11:57:08 +07:00
{
name: 'telephoneNo',
align: 'left',
2024-08-26 16:24:08 +07:00
label: 'general.telephone',
field: 'telephoneNo',
},
{
name: 'birthDate',
align: 'left',
2024-08-26 16:24:08 +07:00
label: 'personnel.age',
field: 'birthDate',
},
{
name: 'email',
align: 'left',
2024-08-26 16:24:08 +07:00
label: 'form.email',
field: 'email',
},
{
name: 'userRole',
align: 'left',
2024-08-26 16:24:08 +07:00
label: 'personnel.form.userRole',
field: 'userRole',
},
] satisfies QTableProps['columns'];
2024-09-12 15:41:54 +07:00
function undo() {
if (!currentUser.value) return;
isImageEdit.value = false;
infoDrawerEdit.value = false;
assignFormData(currentUser.value.id);
}
function mapRole(value: string) {
const option = userStore.userOption.roleOpts.find(
(option) => option.value === value,
);
return option ? option.label : '-';
}
function mapUserType(label: string) {
const userTypeMap: { [key: string]: string } = {
USER: 'USER',
MESSENGER: 'MESSENGER',
DELEGATE: 'DELEGATE',
AGENCY: 'AGENCY',
};
formData.value.userType = userTypeMap[label];
}
function onClose(excludeDialog?: boolean) {
if (excludeDialog) {
infoDrawer.value = excludeDialog || false;
return;
}
hqId.value = '';
brId.value = '';
userCode.value = '';
urlProfile.value = '';
profileFileImg.value = null;
infoDrawerEdit.value = false;
agencyFile.value = [];
modal.value = false;
isEdit.value = false;
statusToggle.value = true;
isImageEdit.value = false;
currentUser.value = undefined;
Object.assign(formData.value, defaultFormData);
mapUserType(currentTab.value);
imageList.value = { selectedImage: '', list: [] };
onCreateImageList.value = { selectedImage: '', list: [] };
flowStore.rotate();
}
2024-04-17 11:32:18 +07:00
async function openDialog(
action?: 'FORM' | 'INFO',
2024-07-05 16:29:06 +07:00
id?: string,
isPersonEdit: boolean = false,
) {
2024-04-22 14:04:06 +07:00
if (userStore.userOption.hqOpts.length === 0) {
await userStore.fetchHqOption();
}
if (userStore.userOption.roleOpts.length === 0) {
await userStore.fetchRoleOption();
}
2024-07-05 16:29:06 +07:00
if (id && userData.value) {
2024-04-22 14:04:06 +07:00
isEdit.value = true;
2024-07-23 10:33:34 +00:00
await assignFormData(id);
2024-04-22 14:04:06 +07:00
if (formData.value.userType === 'AGENCY') {
2024-07-05 16:29:06 +07:00
const result = await userStore.fetchAttachment(id);
2024-04-22 14:04:06 +07:00
if (result) {
agencyFileList.value = result;
}
}
2024-07-16 02:11:18 +00:00
}
2024-07-23 09:18:34 +00:00
if (userStore.userOption.hqOpts.length !== 0 && !id) {
hqId.value = userStore.userOption.hqOpts[0].value;
}
2024-07-16 02:11:18 +00:00
if (userStore.userOption.hqOpts.length === 0) {
dialog({
color: 'warning',
icon: 'mdi-alert',
2024-08-28 18:05:01 +07:00
title: t('form.warning.title'),
actionText: t('ok'),
2024-07-16 02:11:18 +00:00
persistent: true,
2024-08-28 18:05:01 +07:00
message: t('dialog.message.headquartersNotEstablished'),
2024-07-16 02:11:18 +00:00
action: async () => {},
});
return;
}
2024-04-18 18:27:22 +07:00
if (action === 'FORM') {
modal.value = true;
if (currentTab.value === 'MESSENGER') {
formData.value.userRole = 'messenger';
}
if (isRoleInclude(['branch_manager'])) {
2024-09-02 10:56:29 +07:00
hqId.value =
myBranch.value?.[0].isHeadOffice === true
? myBranch.value?.[0].id
: myBranch.value?.[0].headOfficeId || '';
brId.value =
myBranch.value?.[0].isHeadOffice === true ? '' : myBranch.value?.[0].id;
}
2024-04-18 18:27:22 +07:00
} else if (action === 'INFO') {
2024-04-22 14:04:06 +07:00
if (!userData.value) return;
infoDrawerEdit.value = isPersonEdit ? true : false;
2024-04-18 18:27:22 +07:00
infoDrawer.value = true;
}
statusToggle.value = true;
userStore.userOption.brOpts = [];
2024-04-05 19:05:51 +07:00
}
2024-04-10 14:00:55 +07:00
Squashed commit of the following: commit eb6c7b164a9f182f8d1ce73cc5354866c6d6b10e Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:29:44 2024 +0700 refactor: no img close to default on create commit eae9eb26071cc2985624bb1c6ce551bf5eb6eb8b Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:04:04 2024 +0700 refactor/feat: save => apply, disabled selected img, no img close to default commit ccbf80fc53db3144873c049bd6dbd37b4e2e9ff3 Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 09:31:32 2024 +0700 fix(01): use submit function commit 36b4f6ca15e5966f37dfefc9fdb744feec60dd27 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:45:19 2024 +0700 fix: imgList error commit bac0eaf3ab955672ae0c78d3295b4a839827c5f2 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:18:03 2024 +0700 refactor(03): customer new upload img dialog commit 9d7398e9613a738c33e265482cdb7d7bb250ea9f Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:40:39 2024 +0700 refactor(02): new upload dialog commit 8b91d43f41eae3ba2442f6c742d617c25ee180cb Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:25:21 2024 +0700 refactor(01): new upload dialog, confirm remove, individual action commit 61caf1919168bc5635568d7ca246574fdc43cd04 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(01): branch new img upload commit e791b7316d001d839c8afb1950f7331c62d9e81a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(02): personnel new img upload commit af4d11312b9cb666338901efa9971117cb7738c4 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 feat(02): new image upload commit e4d7afdb8c74d65a550644f2c60f70909d51d4a8 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock select image function commit 5ab3f045b9c7d2c821920c12114da15eed09655a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock new image preview
2024-09-11 16:43:41 +07:00
async function onSubmit(excludeDialog?: boolean) {
2024-09-12 15:41:54 +07:00
if (isEdit.value && currentUser.value) {
if (!currentUser.value.id) return;
2024-06-27 08:32:31 +00:00
2024-07-03 09:21:53 +00:00
formData.value.branchId = brId.value
? brId.value
: hqId.value
? hqId.value
: '';
2024-06-27 08:32:31 +00:00
const formDataEdit = {
...formData.value,
status: !statusToggle.value ? 'INACTIVE' : 'ACTIVE',
} as const;
2024-09-12 15:41:54 +07:00
await userStore.editById(currentUser.value.id, formDataEdit);
2024-06-27 08:32:31 +00:00
2024-09-12 15:41:54 +07:00
if (currentUser.value.id && formDataEdit.userType === 'AGENCY') {
2024-06-27 08:32:31 +00:00
if (!agencyFile.value) return;
const payload: UserAttachmentCreate = {
file: agencyFile.value,
};
if (payload?.file) {
2024-09-12 15:41:54 +07:00
await userStore.addAttachment(currentUser.value.id, payload);
2024-06-27 08:32:31 +00:00
}
}
2024-06-28 14:19:46 +07:00
await fetchUserList();
2024-06-27 08:32:31 +00:00
typeStats.value = await userStore.typeStats();
const res = await branchStore.userStats(formData.value.userType);
if (res) {
userStats.value = res;
}
Squashed commit of the following: commit eb6c7b164a9f182f8d1ce73cc5354866c6d6b10e Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:29:44 2024 +0700 refactor: no img close to default on create commit eae9eb26071cc2985624bb1c6ce551bf5eb6eb8b Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:04:04 2024 +0700 refactor/feat: save => apply, disabled selected img, no img close to default commit ccbf80fc53db3144873c049bd6dbd37b4e2e9ff3 Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 09:31:32 2024 +0700 fix(01): use submit function commit 36b4f6ca15e5966f37dfefc9fdb744feec60dd27 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:45:19 2024 +0700 fix: imgList error commit bac0eaf3ab955672ae0c78d3295b4a839827c5f2 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:18:03 2024 +0700 refactor(03): customer new upload img dialog commit 9d7398e9613a738c33e265482cdb7d7bb250ea9f Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:40:39 2024 +0700 refactor(02): new upload dialog commit 8b91d43f41eae3ba2442f6c742d617c25ee180cb Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:25:21 2024 +0700 refactor(01): new upload dialog, confirm remove, individual action commit 61caf1919168bc5635568d7ca246574fdc43cd04 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(01): branch new img upload commit e791b7316d001d839c8afb1950f7331c62d9e81a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(02): personnel new img upload commit af4d11312b9cb666338901efa9971117cb7738c4 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 feat(02): new image upload commit e4d7afdb8c74d65a550644f2c60f70909d51d4a8 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock select image function commit 5ab3f045b9c7d2c821920c12114da15eed09655a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock new image preview
2024-09-11 16:43:41 +07:00
onClose(excludeDialog);
} else {
2024-06-27 08:32:31 +00:00
if (!hqId.value) return;
if (statusToggle.value) {
formData.value.status = 'CREATED';
} else {
formData.value.status = 'INACTIVE';
}
2024-06-27 08:32:31 +00:00
2024-07-03 09:21:53 +00:00
formData.value.branchId = brId.value
? brId.value
: hqId.value
? hqId.value
: '';
Squashed commit of the following: commit eb6c7b164a9f182f8d1ce73cc5354866c6d6b10e Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:29:44 2024 +0700 refactor: no img close to default on create commit eae9eb26071cc2985624bb1c6ce551bf5eb6eb8b Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:04:04 2024 +0700 refactor/feat: save => apply, disabled selected img, no img close to default commit ccbf80fc53db3144873c049bd6dbd37b4e2e9ff3 Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 09:31:32 2024 +0700 fix(01): use submit function commit 36b4f6ca15e5966f37dfefc9fdb744feec60dd27 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:45:19 2024 +0700 fix: imgList error commit bac0eaf3ab955672ae0c78d3295b4a839827c5f2 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:18:03 2024 +0700 refactor(03): customer new upload img dialog commit 9d7398e9613a738c33e265482cdb7d7bb250ea9f Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:40:39 2024 +0700 refactor(02): new upload dialog commit 8b91d43f41eae3ba2442f6c742d617c25ee180cb Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:25:21 2024 +0700 refactor(01): new upload dialog, confirm remove, individual action commit 61caf1919168bc5635568d7ca246574fdc43cd04 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(01): branch new img upload commit e791b7316d001d839c8afb1950f7331c62d9e81a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(02): personnel new img upload commit af4d11312b9cb666338901efa9971117cb7738c4 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 feat(02): new image upload commit e4d7afdb8c74d65a550644f2c60f70909d51d4a8 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock select image function commit 5ab3f045b9c7d2c821920c12114da15eed09655a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock new image preview
2024-09-11 16:43:41 +07:00
const result = await userStore.create(
formData.value,
onCreateImageList.value,
);
2024-06-27 08:32:31 +00:00
if (result && formData.value.userType === 'AGENCY') {
if (!agencyFile.value) return;
const payload: UserAttachmentCreate = {
file: agencyFile.value,
};
if (payload?.file) {
await userStore.addAttachment(result.id, payload);
}
}
2024-09-12 15:41:54 +07:00
currentTab.value = formData.value.userType;
2024-06-28 14:19:46 +07:00
await fetchUserList();
2024-06-27 08:32:31 +00:00
typeStats.value = await userStore.typeStats();
const res = await branchStore.userStats(formData.value.userType);
if (res) {
userStats.value = res;
}
onClose();
2024-04-10 14:00:55 +07:00
}
2024-06-26 17:03:49 +07:00
flowStore.rotate();
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',
2024-08-27 11:46:26 +07:00
title: t('dialog.title.confirmDelete'),
actionText: t('general.delete'),
2024-04-11 00:37:07 +07:00
persistent: true,
2024-08-27 11:46:26 +07:00
message: t('dialog.message.confirmDelete'),
2024-04-11 00:37:07 +07:00
action: async () => {
await userStore.deleteById(id);
2024-06-28 14:19:46 +07:00
await fetchUserList();
2024-04-18 18:27:22 +07:00
typeStats.value = await userStore.typeStats();
infoDrawer.value = false;
2024-06-26 17:03:49 +07:00
flowStore.rotate();
2024-04-11 00:37:07 +07:00
},
cancel: () => {},
2024-04-11 00:37:07 +07:00
});
2024-04-10 14:00:55 +07:00
}
2024-04-18 16:35:47 +07:00
async function toggleStatus(id: string) {
const record = userData.value?.result.find((v) => v.id === id);
if (!record) return;
const res = await userStore.editById(record.id, {
status: record.status !== 'INACTIVE' ? 'INACTIVE' : 'ACTIVE',
});
if (res) {
record.status = res.status;
formData.value.status = res.status;
await fetchUserList();
}
2024-04-18 16:35:47 +07:00
}
2024-07-25 10:49:43 +00:00
async function triggerChangeStatus(id: string, status: string) {
return await new Promise((resolve, reject) => {
dialog({
color: status !== 'INACTIVE' ? 'warning' : 'info',
2024-08-09 06:18:26 +00:00
icon:
status !== 'INACTIVE' ? 'mdi-alert' : 'mdi-message-processing-outline',
2024-08-26 16:24:08 +07:00
title: t('dialog.title.confirmChangeStatus'),
2024-07-25 10:49:43 +00:00
actionText:
2024-08-26 16:24:08 +07:00
status !== 'INACTIVE' ? t('general.close') : t('general.open'),
2024-07-25 10:49:43 +00:00
message:
status !== 'INACTIVE'
2024-08-26 16:24:08 +07:00
? t('dialog.message.confirmChangeStatusOff')
: t('dialog.message.confirmChangeStatusOn'),
2024-07-25 10:49:43 +00:00
action: async () => {
await toggleStatus(id).then(resolve).catch(reject);
},
cancel: () => {},
});
});
}
2024-04-18 18:27:22 +07:00
async function assignFormData(idEdit: string) {
if (!userData.value) return;
const foundUser = userData.value.result.find((user) => user.id === idEdit);
2024-04-22 14:04:06 +07:00
2024-04-18 18:27:22 +07:00
if (foundUser) {
currentUser.value = foundUser;
formData.value = {
2024-07-05 16:29:06 +07:00
branchId: foundUser.branch[0]?.id,
2024-04-18 18:27:22 +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,
2024-09-12 15:41:54 +07:00
moo: foundUser.moo,
mooEN: foundUser.mooEN,
soi: foundUser.soi,
soiEN: foundUser.soiEN,
street: foundUser.street,
streetEN: foundUser.streetEN,
2024-04-18 18:27:22 +07:00
trainingPlace: foundUser.trainingPlace,
importNationality: foundUser.importNationality,
sourceNationality: foundUser.sourceNationality,
licenseNo: foundUser.licenseNo,
discountCondition: foundUser.discountCondition,
registrationNo: foundUser.registrationNo,
lastNameEN: foundUser.lastNameEN,
lastName: foundUser.lastName,
2024-08-15 10:52:18 +07:00
middleNameEN: foundUser.middleNameEN,
middleName: foundUser.middleName,
2024-04-18 18:27:22 +07:00
firstNameEN: foundUser.firstNameEN,
firstName: foundUser.firstName,
2024-08-15 10:52:18 +07:00
namePrefix: foundUser.namePrefix,
2024-04-18 18:27:22 +07:00
userRole: foundUser.userRole,
userType: foundUser.userType,
username: foundUser.username,
2024-04-19 13:54:57 +07:00
checkpoint: foundUser.checkpoint,
checkpointEN: foundUser.checkpointEN,
2024-04-18 18:27:22 +07:00
responsibleArea: foundUser.responsibleArea,
status: foundUser.status,
Squashed commit of the following: commit eb6c7b164a9f182f8d1ce73cc5354866c6d6b10e Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:29:44 2024 +0700 refactor: no img close to default on create commit eae9eb26071cc2985624bb1c6ce551bf5eb6eb8b Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:04:04 2024 +0700 refactor/feat: save => apply, disabled selected img, no img close to default commit ccbf80fc53db3144873c049bd6dbd37b4e2e9ff3 Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 09:31:32 2024 +0700 fix(01): use submit function commit 36b4f6ca15e5966f37dfefc9fdb744feec60dd27 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:45:19 2024 +0700 fix: imgList error commit bac0eaf3ab955672ae0c78d3295b4a839827c5f2 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:18:03 2024 +0700 refactor(03): customer new upload img dialog commit 9d7398e9613a738c33e265482cdb7d7bb250ea9f Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:40:39 2024 +0700 refactor(02): new upload dialog commit 8b91d43f41eae3ba2442f6c742d617c25ee180cb Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:25:21 2024 +0700 refactor(01): new upload dialog, confirm remove, individual action commit 61caf1919168bc5635568d7ca246574fdc43cd04 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(01): branch new img upload commit e791b7316d001d839c8afb1950f7331c62d9e81a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(02): personnel new img upload commit af4d11312b9cb666338901efa9971117cb7738c4 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 feat(02): new image upload commit e4d7afdb8c74d65a550644f2c60f70909d51d4a8 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock select image function commit 5ab3f045b9c7d2c821920c12114da15eed09655a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock new image preview
2024-09-11 16:43:41 +07:00
selectedImage: foundUser.selectedImage,
2024-04-18 18:27:22 +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,
2024-09-12 15:41:54 +07:00
citizenId: foundUser.citizenId,
citizenIssue:
(foundUser.citizenIssue && new Date(foundUser.citizenIssue)) || null,
citizenExpire:
(foundUser.citizenExpire && new Date(foundUser.citizenExpire)) || null,
2024-04-18 18:27:22 +07:00
};
formData.value.status === 'ACTIVE' || 'CREATED'
? (statusToggle.value = true)
: (statusToggle.value = false);
2024-04-22 10:54:32 +07:00
2024-07-23 09:18:34 +00:00
if (foundUser.branch) {
2024-08-02 15:32:51 +07:00
if (foundUser.branch?.[0].isHeadOffice) {
2024-04-22 10:54:32 +07:00
hqId.value = foundUser.branch[0].id as string;
} else {
hqId.value = foundUser.branch[0].headOfficeId as string;
brId.value = foundUser.branch[0].id;
}
2024-04-18 18:27:22 +07:00
}
2024-04-22 10:54:32 +07:00
2024-04-22 14:04:06 +07:00
userCode.value = foundUser.code;
Squashed commit of the following: commit eb6c7b164a9f182f8d1ce73cc5354866c6d6b10e Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:29:44 2024 +0700 refactor: no img close to default on create commit eae9eb26071cc2985624bb1c6ce551bf5eb6eb8b Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:04:04 2024 +0700 refactor/feat: save => apply, disabled selected img, no img close to default commit ccbf80fc53db3144873c049bd6dbd37b4e2e9ff3 Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 09:31:32 2024 +0700 fix(01): use submit function commit 36b4f6ca15e5966f37dfefc9fdb744feec60dd27 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:45:19 2024 +0700 fix: imgList error commit bac0eaf3ab955672ae0c78d3295b4a839827c5f2 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:18:03 2024 +0700 refactor(03): customer new upload img dialog commit 9d7398e9613a738c33e265482cdb7d7bb250ea9f Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:40:39 2024 +0700 refactor(02): new upload dialog commit 8b91d43f41eae3ba2442f6c742d617c25ee180cb Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:25:21 2024 +0700 refactor(01): new upload dialog, confirm remove, individual action commit 61caf1919168bc5635568d7ca246574fdc43cd04 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(01): branch new img upload commit e791b7316d001d839c8afb1950f7331c62d9e81a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(02): personnel new img upload commit af4d11312b9cb666338901efa9971117cb7738c4 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 feat(02): new image upload commit e4d7afdb8c74d65a550644f2c60f70909d51d4a8 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock select image function commit 5ab3f045b9c7d2c821920c12114da15eed09655a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock new image preview
2024-09-11 16:43:41 +07:00
urlProfile.value = `${baseUrl}/user/${foundUser.id}/profile-image/${foundUser.selectedImage}`;
2024-06-27 08:32:31 +00:00
2024-04-18 18:27:22 +07:00
isEdit.value = true;
2024-04-22 10:54:32 +07:00
hqId.value && (await userStore.fetchBrOption(hqId.value));
Squashed commit of the following: commit eb6c7b164a9f182f8d1ce73cc5354866c6d6b10e Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:29:44 2024 +0700 refactor: no img close to default on create commit eae9eb26071cc2985624bb1c6ce551bf5eb6eb8b Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:04:04 2024 +0700 refactor/feat: save => apply, disabled selected img, no img close to default commit ccbf80fc53db3144873c049bd6dbd37b4e2e9ff3 Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 09:31:32 2024 +0700 fix(01): use submit function commit 36b4f6ca15e5966f37dfefc9fdb744feec60dd27 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:45:19 2024 +0700 fix: imgList error commit bac0eaf3ab955672ae0c78d3295b4a839827c5f2 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:18:03 2024 +0700 refactor(03): customer new upload img dialog commit 9d7398e9613a738c33e265482cdb7d7bb250ea9f Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:40:39 2024 +0700 refactor(02): new upload dialog commit 8b91d43f41eae3ba2442f6c742d617c25ee180cb Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:25:21 2024 +0700 refactor(01): new upload dialog, confirm remove, individual action commit 61caf1919168bc5635568d7ca246574fdc43cd04 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(01): branch new img upload commit e791b7316d001d839c8afb1950f7331c62d9e81a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(02): personnel new img upload commit af4d11312b9cb666338901efa9971117cb7738c4 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 feat(02): new image upload commit e4d7afdb8c74d65a550644f2c60f70909d51d4a8 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock select image function commit 5ab3f045b9c7d2c821920c12114da15eed09655a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock new image preview
2024-09-11 16:43:41 +07:00
await fetchImageList(foundUser.id, foundUser.selectedImage);
2024-04-18 18:27:22 +07:00
if (formData.value.districtId) {
await adrressStore.fetchSubDistrictByProvinceId(
formData.value.districtId,
);
}
}
}
async function fetchImageList(id: string, selectedName?: string) {
if (!selectedName) return;
2024-09-12 15:41:54 +07:00
const res = await userStore.fetchImageListById(id);
imageList.value = {
selectedImage: selectedName,
list: res.map((n: string) => `user/${id}/profile-image/${n}`),
};
return res;
}
async function fetchUserList() {
await userStore.fetchList({
includeBranch: true,
pageSize: pageSize.value,
page: currentPage.value,
query: !!inputSearch.value ? inputSearch.value : undefined,
userType: currentTab.value === 'ALL' ? undefined : currentTab.value,
status:
statusFilter.value === 'all'
? undefined
: statusFilter.value === 'statusACTIVE'
? 'ACTIVE'
: 'INACTIVE',
});
}
function noPersonnel() {
const number =
typeStats.value &&
Object.entries(typeStats.value).reduce(
(acc, [key, value]) => acc + value,
0,
);
return number === 0;
}
2024-04-10 14:00:55 +07:00
onMounted(async () => {
navigatorStore.current.title = 'personnel.title';
navigatorStore.current.path = [{ text: 'personnel.caption', i18n: true }];
2024-07-18 09:10:51 +00:00
modeView.value = $q.screen.lt.md ? true : false;
2024-07-02 09:11:39 +00:00
2024-06-28 14:19:46 +07:00
await fetchUserList();
2024-07-23 10:33:34 +00:00
if (optionStore.globalOption) {
userStore.userOption.genderOpts = optionStore.globalOption.gender;
userStore.userOption.responsibleAreaOpts = optionStore.globalOption.area;
userStore.userOption.nationalityOpts = optionStore.globalOption.nationality;
userStore.userOption.trainingPlaceOpts = optionStore.globalOption.training;
}
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
}
2024-06-26 17:03:49 +07:00
flowStore.rotate();
2024-04-10 14:00:55 +07:00
});
watch(
2024-09-12 15:41:54 +07:00
() => currentTab.value,
2024-04-10 14:00:55 +07:00
async (label) => {
mapUserType(label);
2024-06-28 14:19:46 +07:00
await fetchUserList();
const res = await branchStore.userStats(label);
if (res) {
userStats.value = res;
2024-04-10 14:00:55 +07:00
}
},
);
2024-04-19 11:45:51 +07:00
watch(
() => formData.value.userType,
async () => {
2024-07-17 10:49:21 +00:00
if (!infoDrawerEdit.value) return;
formData.value.registrationNo = null;
formData.value.startDate = null;
formData.value.retireDate = null;
formData.value.responsibleArea = null;
formData.value.discountCondition = null;
formData.value.sourceNationality = null;
formData.value.importNationality = null;
formData.value.trainingPlace = null;
formData.value.checkpoint = null;
formData.value.checkpointEN = null;
agencyFile.value = [];
},
);
2024-06-28 14:19:46 +07:00
2024-08-02 16:30:18 +07:00
watch(
() => profileFileImg.value,
() => {
if (profileFileImg.value !== null) isImageEdit.value = true;
},
);
2024-11-15 11:36:51 +07:00
watch([inputSearch, statusFilter, pageSize], async () => await fetchUserList());
2024-07-18 09:10:51 +00:00
watch(
() => $q.screen.lt.md,
(v) => {
if (v) modeView.value = true;
},
);
2024-04-03 18:28:59 +07:00
</script>
<template>
2024-10-30 09:34:46 +07:00
<FloatingActionButton
2024-10-22 10:51:44 +07:00
style="z-index: 999"
hide-icon
@click="openDialog('FORM')"
2024-10-30 09:34:46 +07:00
></FloatingActionButton>
2024-07-04 13:14:21 +07:00
<!-- stat -->
2024-07-04 09:53:33 +00:00
<div class="column full-height no-wrap">
2024-07-05 03:29:33 +00:00
<div class="text-body-2 q-mb-xs flex items-center">
2024-08-26 16:24:08 +07:00
{{ $t('general.dataSum') }}
2024-07-05 11:01:40 +00:00
<q-badge
v-if="typeStats"
rounded
class="q-ml-sm"
style="
background-color: hsla(var(--info-bg) / 0.15);
color: hsl(var(--info-bg));
"
>
{{
2024-09-12 15:41:54 +07:00
currentTab === 'ALL'
2024-07-05 11:01:40 +00:00
? Object.values(typeStats).reduce((acc, val) => acc + val, 0)
2024-09-12 15:41:54 +07:00
: typeStats[currentTab]
2024-07-05 11:01:40 +00:00
}}
</q-badge>
2024-07-05 03:29:33 +00:00
<q-btn
2024-07-05 11:01:40 +00:00
class="q-ml-sm"
2024-08-08 06:41:15 +00:00
icon="mdi-pin-outline"
2024-07-05 03:29:33 +00:00
color="primary"
size="sm"
flat
dense
rounded
@click="hideStat = !hideStat"
:style="hideStat ? 'rotate: 90deg' : ''"
style="transition: 0.1s ease-in-out"
/>
2024-07-04 13:14:21 +07:00
</div>
2024-07-02 09:11:39 +00:00
2024-07-05 03:29:33 +00:00
<transition name="slide">
<div v-if="!hideStat" class="scroll q-mb-md">
<div style="display: inline-block">
<StatCardComponent
2024-07-05 11:01:40 +00:00
v-if="typeStats && userData?.result"
2024-10-02 14:04:23 +07:00
label-i18n
2024-07-05 03:29:33 +00:00
:branch="
2024-09-12 15:41:54 +07:00
currentTab === 'ALL'
2024-07-05 11:01:40 +00:00
? Object.entries(typeStats).map(([key, val]) => ({
count: val,
2024-08-26 16:24:08 +07:00
label: `personnel.${key}`,
2024-08-20 10:44:30 +07:00
icon: 'mdi-account-outline',
2024-07-05 11:01:40 +00:00
color:
(
{
USER: 'cyan',
MESSENGER: 'yellow',
DELEGATE: 'red',
AGENCY: 'magenta',
} as const
)[key] || 'pink',
}))
: [
2024-07-05 16:29:06 +07:00
{
2024-09-12 15:41:54 +07:00
label: `personnel.${currentTab}`,
count: typeStats[currentTab],
2024-08-20 10:44:30 +07:00
icon: 'mdi-account-outline',
2024-07-05 11:01:40 +00:00
color:
2024-09-12 15:41:54 +07:00
currentTab === 'USER'
2024-07-05 11:01:40 +00:00
? 'cyan'
2024-09-12 15:41:54 +07:00
: currentTab === 'MESSENGER'
2024-07-05 11:01:40 +00:00
? 'yellow'
2024-09-12 15:41:54 +07:00
: currentTab === 'DELEGATE'
2024-07-05 11:01:40 +00:00
? 'red'
: 'magenta',
},
]
2024-07-05 03:29:33 +00:00
"
:dark="$q.dark.isActive"
/>
</div>
</div>
</transition>
2024-07-04 09:53:33 +00:00
<!-- main -->
<div
class="col surface-2 rounded justify-between column no-wrap bordered full-height overflow-hidden"
>
2024-07-05 11:01:40 +00:00
<div class="column">
<div
2024-07-17 08:31:31 +00:00
class="row surface-3 justify-between full-width items-center bordered-b"
2024-07-05 11:01:40 +00:00
style="z-index: 1"
>
<div class="row q-py-sm q-px-md justify-between full-width">
<q-input
for="input-search"
outlined
dense
2024-08-26 16:24:08 +07:00
:label="$t('general.search')"
2024-07-16 02:52:53 +00:00
class="q-mr-md col-12 col-md-3"
2024-07-05 11:01:40 +00:00
:bg-color="$q.dark.isActive ? 'dark' : 'white'"
v-model="inputSearch"
debounce="200"
>
<template #prepend>
<q-icon name="mdi-magnify" />
</template>
</q-input>
2024-07-16 02:52:53 +00:00
<div
2024-07-17 08:19:21 +00:00
class="row col-12 col-md-5"
2024-07-16 02:52:53 +00:00
:class="{ 'q-pt-xs': $q.screen.lt.md }"
2024-07-17 08:19:21 +00:00
style="white-space: nowrap"
2024-07-16 02:52:53 +00:00
>
2024-07-05 11:01:40 +00:00
<q-select
v-model="statusFilter"
outlined
dense
option-value="value"
option-label="label"
2024-07-16 02:52:53 +00:00
class="col"
2024-07-30 04:17:51 +00:00
:class="{ 'offset-md-5': modeView }"
2024-07-05 11:01:40 +00:00
map-options
emit-value
autocomplete="off"
2024-07-30 16:18:37 +07:00
:for="'field-select-status'"
2024-07-18 04:51:09 +00:00
:hide-dropdown-icon="$q.screen.lt.sm"
2024-07-05 11:01:40 +00:00
:options="[
2024-08-26 16:24:08 +07:00
{ label: $t('general.all'), value: 'all' },
{ label: $t('general.active'), value: 'statusACTIVE' },
{ label: $t('general.inactive'), value: 'statusINACTIVE' },
2024-07-05 11:01:40 +00:00
]"
></q-select>
<q-select
v-if="!modeView"
autocomplete="off"
2024-07-05 11:01:40 +00:00
id="select-field"
for="select-field"
2024-07-18 09:10:51 +00:00
class="col q-ml-sm"
:options="
fieldSelectedOption.map((v) => ({
...v,
label: $t(v.label),
}))
"
2024-08-26 16:24:08 +07:00
:display-value="$t('general.displayField')"
2024-07-18 04:51:09 +00:00
:hide-dropdown-icon="$q.screen.lt.sm"
2024-07-05 11:01:40 +00:00
v-model="fieldSelected"
option-label="label"
option-value="value"
map-options
emit-value
outlined
multiple
dense
/>
<q-btn-toggle
id="btn-mode"
v-model="modeView"
dense
2024-07-18 09:10:51 +00:00
class="no-shadow bordered rounded surface-1 q-ml-sm"
2024-07-05 11:01:40 +00:00
:toggle-color="$q.dark.isActive ? 'grey-9' : 'grey-2'"
size="xs"
:options="[
{ value: true, slot: 'folder' },
{ value: false, slot: 'list' },
]"
>
<template v-slot:folder>
<q-icon
name="mdi-view-grid-outline"
size="16px"
class="q-px-sm q-py-xs rounded"
:style="{
color: $q.dark.isActive
? modeView
? '#C9D3DB '
: '#787B7C'
: modeView
? '#787B7C'
: '#C9D3DB',
}"
/>
</template>
<template v-slot:list>
<q-icon
name="mdi-format-list-bulleted"
class="q-px-sm q-py-xs rounded"
size="16px"
:style="{
color: $q.dark.isActive
? modeView === false
? '#C9D3DB'
: '#787B7C'
: modeView === false
? '#787B7C'
: '#C9D3DB',
}"
/>
</template>
</q-btn-toggle>
</div>
</div>
</div>
2024-07-18 09:10:51 +00:00
<div class="surface-2 bordered-b q-px-md full-width">
2024-07-05 11:01:40 +00:00
<q-tabs
2024-07-18 09:10:51 +00:00
inline-label
mobile-arrows
2024-07-04 09:53:33 +00:00
dense
2024-09-12 15:41:54 +07:00
v-model="currentTab"
2024-07-05 11:01:40 +00:00
align="left"
2024-07-18 09:10:51 +00:00
class="full-width"
2024-07-05 11:01:40 +00:00
active-color="info"
2024-07-04 09:53:33 +00:00
>
2024-07-05 11:01:40 +00:00
<q-tab
2024-07-05 11:10:46 +00:00
name="ALL"
2024-07-05 11:01:40 +00:00
@click="
async () => {
currentPage = 1;
inputSearch = '';
2024-09-12 15:41:54 +07:00
currentTab = 'ALL';
2024-07-05 11:01:40 +00:00
statusFilter = 'all';
flowStore.rotate();
}
"
>
<div
2024-08-26 16:24:08 +07:00
class="row text-capitalize"
2024-09-12 15:41:54 +07:00
:class="currentTab === 'ALL' ? 'text-bold' : 'app-text-muted'"
2024-07-05 11:01:40 +00:00
>
2024-08-26 16:24:08 +07:00
{{ $t('general.all') }}
2024-07-05 11:01:40 +00:00
</div>
</q-tab>
<q-tab
2024-07-05 11:10:46 +00:00
name="USER"
2024-07-05 11:01:40 +00:00
@click="
async () => {
2024-09-12 15:41:54 +07:00
currentTab = 'USER';
2024-07-05 11:01:40 +00:00
statusFilter = 'all';
currentPage = 1;
inputSearch = '';
flowStore.rotate();
}
"
>
<div
2024-08-26 16:24:08 +07:00
class="row text-capitalize"
2024-09-12 15:41:54 +07:00
:class="currentTab === 'USER' ? 'text-bold' : 'app-text-muted'"
2024-07-05 11:01:40 +00:00
>
2024-08-26 16:24:08 +07:00
{{ $t('personnel.USER') }}
2024-07-05 11:01:40 +00:00
</div>
</q-tab>
<q-tab
name="MESSENGER"
@click="
async () => {
2024-09-12 15:41:54 +07:00
currentTab = 'MESSENGER';
2024-07-05 11:01:40 +00:00
statusFilter = 'all';
currentPage = 1;
inputSearch = '';
flowStore.rotate();
}
"
>
<div
2024-08-26 16:24:08 +07:00
class="row text-capitalize"
2024-07-05 11:01:40 +00:00
:class="
2024-09-12 15:41:54 +07:00
currentTab === 'MESSENGER' ? 'text-bold' : 'app-text-muted'
2024-07-05 11:01:40 +00:00
"
>
2024-08-26 16:24:08 +07:00
{{ $t('personnel.MESSENGER') }}
2024-07-05 11:01:40 +00:00
</div>
</q-tab>
<q-tab
name="DELEGATE"
@click="
async () => {
2024-09-12 15:41:54 +07:00
currentTab = 'DELEGATE';
2024-07-05 11:01:40 +00:00
statusFilter = 'all';
currentPage = 1;
inputSearch = '';
flowStore.rotate();
}
"
>
<div
2024-08-26 16:24:08 +07:00
class="row text-capitalize"
2024-07-05 11:01:40 +00:00
:class="
2024-09-12 15:41:54 +07:00
currentTab === 'DELEGATE' ? 'text-bold' : 'app-text-muted'
2024-07-05 11:01:40 +00:00
"
>
2024-08-26 16:24:08 +07:00
{{ $t('personnel.DELEGATE') }}
2024-07-05 11:01:40 +00:00
</div>
</q-tab>
<q-tab
name="AGENCY"
@click="
async () => {
2024-09-12 15:41:54 +07:00
currentTab = 'AGENCY';
2024-07-05 11:01:40 +00:00
statusFilter = 'all';
currentPage = 1;
inputSearch = '';
flowStore.rotate();
}
"
>
<div
2024-08-26 16:24:08 +07:00
class="row text-capitalize"
2024-07-05 11:01:40 +00:00
:class="
2024-09-12 15:41:54 +07:00
currentTab === 'AGENCY' ? 'text-bold' : 'app-text-muted'
2024-07-05 11:01:40 +00:00
"
>
2024-08-26 16:24:08 +07:00
{{ $t('personnel.AGENCY') }}
2024-07-05 11:01:40 +00:00
</div>
</q-tab>
</q-tabs>
2024-07-04 09:53:33 +00:00
</div>
2024-07-05 11:10:16 +07:00
</div>
2024-07-05 11:01:40 +00:00
2024-08-19 15:49:45 +07:00
<div
class="flex full-width full-height q-pa-md surface-2 column col scroll"
>
2024-10-24 09:27:51 +07:00
<template v-if="userData && userData.total > 0">
<q-table
flat
bordered
:grid="modeView"
:rows="userData.result"
:columns="columns"
2024-08-19 14:43:05 +07:00
class="full-width"
2024-07-18 09:10:51 +00:00
card-container-class="q-col-gutter-md"
row-key="name"
:rows-per-page-options="[0]"
hide-pagination
:visible-columns="fieldSelected"
>
<template v-slot:header="props">
2024-07-31 06:18:52 +00:00
<q-tr
style="background-color: hsla(var(--info-bg) / 0.07)"
:props="props"
>
<q-th v-for="col in props.cols" :key="col.name" :props="props">
{{ $t(col.label) }}
</q-th>
<q-th auto-width />
</q-tr>
</template>
<template v-slot:body="props">
<q-tr
:class="{
'app-text-muted': props.row.status === 'INACTIVE',
'status-active': props.row.status !== 'INACTIVE',
'status-inactive': props.row.status === 'INACTIVE',
}"
:props="props"
2024-08-09 10:05:31 +00:00
:style="
props.rowIndex % 2 !== 0
? $q.dark.isActive
? 'background: hsl(var(--gray-11-hsl)/0.2)'
: `background: #f9fafc`
: ''
"
>
2024-08-07 11:30:28 +07:00
<q-td
class="text-center"
2024-08-20 17:59:49 +07:00
v-if="fieldSelected.includes('orderNumber')"
2024-08-07 11:30:28 +07:00
>
{{ (currentPage - 1) * pageSize + props.rowIndex + 1 }}
</q-td>
2024-08-19 14:43:05 +07:00
<q-td v-if="fieldSelected.includes('name')">
2024-08-15 09:47:23 +07:00
<div class="row items-center" style="flex-wrap: nowrap">
<div style="display: flex">
2024-08-19 14:43:05 +07:00
<div class="q-mr-md">
2024-09-06 17:54:27 +07:00
<div
:style="`
border-radius: 50%;
border-style: solid;
border-width: 2px;
border-color: hsl(var(${
{
USER: '--cyan-7-hsl',
MESSENGER: '--orange-4-hsl',
DELEGATE: '--red-6-hsl',
AGENCY: '--pink-8-hsl',
}[props.row.userType as string] ||
'--pink-8-hsl'
}
`"
class="q-pa-xs"
>
<q-avatar size="md">
<q-img
class="text-center"
:ratio="1"
Squashed commit of the following: commit eb6c7b164a9f182f8d1ce73cc5354866c6d6b10e Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:29:44 2024 +0700 refactor: no img close to default on create commit eae9eb26071cc2985624bb1c6ce551bf5eb6eb8b Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:04:04 2024 +0700 refactor/feat: save => apply, disabled selected img, no img close to default commit ccbf80fc53db3144873c049bd6dbd37b4e2e9ff3 Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 09:31:32 2024 +0700 fix(01): use submit function commit 36b4f6ca15e5966f37dfefc9fdb744feec60dd27 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:45:19 2024 +0700 fix: imgList error commit bac0eaf3ab955672ae0c78d3295b4a839827c5f2 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:18:03 2024 +0700 refactor(03): customer new upload img dialog commit 9d7398e9613a738c33e265482cdb7d7bb250ea9f Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:40:39 2024 +0700 refactor(02): new upload dialog commit 8b91d43f41eae3ba2442f6c742d617c25ee180cb Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:25:21 2024 +0700 refactor(01): new upload dialog, confirm remove, individual action commit 61caf1919168bc5635568d7ca246574fdc43cd04 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(01): branch new img upload commit e791b7316d001d839c8afb1950f7331c62d9e81a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(02): personnel new img upload commit af4d11312b9cb666338901efa9971117cb7738c4 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 feat(02): new image upload commit e4d7afdb8c74d65a550644f2c60f70909d51d4a8 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock select image function commit 5ab3f045b9c7d2c821920c12114da15eed09655a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock new image preview
2024-09-11 16:43:41 +07:00
:src="`${baseUrl}/user/${props.row.id}/profile-image/${props.row.selectedImage}?ts=${Date.now()}`"
2024-09-06 17:54:27 +07:00
>
<template #error>
<div
class="no-padding full-width full-height flex items-center justify-center"
:style="`${props.row.gender ? 'background: white' : 'background: linear-gradient(135deg,rgba(43, 137, 223, 1) 0%, rgba(230, 51, 81, 1) 100%);'}`"
>
<q-img
v-if="props.row.gender"
:src="
props.row.gender === 'male'
? '/no-img-man.png'
: '/no-img-female.png'
"
/>
<q-icon
v-else
size="sm"
name="mdi-account-outline"
style="color: white"
/>
</div>
</template>
</q-img>
<q-badge
class="absolute-bottom-right no-padding"
style="
border-radius: 50%;
min-width: 8px;
min-height: 8px;
"
:style="{
background: `var(--${props.row.status === 'INACTIVE' ? 'stone-5' : 'green-6'})`,
}"
></q-badge>
</q-avatar>
</div>
</div>
</div>
2024-08-15 09:47:23 +07:00
<div class="column">
2024-08-19 14:43:05 +07:00
<div class="col ellipsis" style="max-width: 20vw">
{{
2024-09-12 15:41:54 +07:00
locale === 'eng'
? `${props.row.firstNameEN} ${props.row.lastNameEN}`.trim()
: `${props.row.firstName} ${props.row.lastName}`.trim()
}}
2024-08-19 14:43:05 +07:00
<q-tooltip
anchor="bottom left"
self="center left"
:delay="300"
>
{{
2024-09-12 15:41:54 +07:00
locale === 'eng'
2024-08-19 14:43:05 +07:00
? `${props.row.firstNameEN} ${props.row.lastNameEN}`.trim()
: `${props.row.firstName} ${props.row.lastName}`.trim()
}}
</q-tooltip>
<q-icon
class="q-pl-xs"
:class="{
'symbol-gender': props.row.gender,
'symbol-gender__male': props.row.gender === 'male',
'symbol-gender__female':
props.row.gender === 'female',
}"
:name="`mdi-gender-${props.row.gender === 'male' ? 'male' : 'female'}`"
width="24px"
/>
</div>
2024-08-15 09:47:23 +07:00
<div class="app-text-muted">
{{ props.row.code || '-' }}
</div>
</div>
</div>
</q-td>
2024-08-19 14:43:05 +07:00
<q-td v-if="fieldSelected.includes('telephoneNo')">
{{ props.row.telephoneNo || '-' }}
</q-td>
<q-td v-if="fieldSelected.includes('birthDate')">
{{ calculateAge(props.row.birthDate) || '-' }}
</q-td>
<q-td v-if="fieldSelected.includes('email')">
{{ props.row.email || '-' }}
</q-td>
<q-td v-if="fieldSelected.includes('userRole')">
2024-08-02 13:45:01 +07:00
<span class="tags tags__purple">
2024-08-09 10:05:31 +00:00
{{ mapRole(props.row.userRole) }}
2024-08-02 13:45:01 +07:00
</span>
</q-td>
<q-td>
<q-btn
2024-07-30 15:49:38 +07:00
:id="`btn-view-${props.row.username}`"
icon="mdi-eye-outline"
size="sm"
dense
round
flat
@click.stop="
() => {
openDialog('INFO', props.row.id);
}
"
/>
2024-08-27 11:46:26 +07:00
<KebabAction
:id-name="props.row.username"
:status="props.row.status"
@view="
() => {
openDialog('INFO', props.row.id);
}
"
@edit="
() => {
openDialog('INFO', props.row.id, true);
}
"
@delete="onDelete(props.row.id)"
@change-status="
async () => {
triggerChangeStatus(props.row.id, props.row.status);
}
"
/>
</q-td>
</q-tr>
</template>
<template v-slot:item="props">
2024-07-19 07:39:23 +00:00
<div class="col-md-3 col-sm-6 col-12">
<PersonCard
2024-07-30 15:49:38 +07:00
:prefix-id="props.row.username"
:data="{
code: props.row.code,
name:
2024-09-12 15:41:54 +07:00
locale === 'eng'
? `${props.row.firstNameEN} ${props.row.lastNameEN}`.trim()
: `${props.row.firstName} ${props.row.lastName}`.trim(),
2024-08-08 04:17:11 +00:00
img: props.row.profileImageUrl
? props.row.profileImageUrl
: props.row.userRole.includes('system')
? '/img-admin.png'
2024-08-07 14:14:25 +07:00
: props.row.gender === 'male'
? '/no-img-man.png'
: '/no-img-female.png',
male: props.row.gender === 'male',
female: props.row.gender === 'female',
detail: [
{
2024-08-08 06:41:15 +00:00
icon: 'mdi-phone-outline',
value: props.row.telephoneNo,
},
{
icon: 'mdi-clock-outline',
value:
(props.row.birthDate &&
calculateAge(props.row.birthDate)) ||
'-',
},
],
}"
:tag="[
{
color:
{
USER: 'cyan',
MESSENGER: 'yellow',
DELEGATE: 'red',
AGENCY: 'magenta',
}[props.row.userType as string] || 'pink',
2024-08-26 16:24:08 +07:00
value: $t(`personnel.${props.row.userType}`),
},
]"
:disabled="props.row.status === 'INACTIVE'"
@update-card="(a, b) => openDialog(a, props.row.id, b)"
@delete-card="onDelete(props.row.id)"
@enter-card="(a) => openDialog(a, props.row.id)"
2024-07-25 10:49:43 +00:00
@toggle-status="
triggerChangeStatus(props.row.id, props.row.status)
"
2024-08-20 18:04:42 +07:00
>
<template #img>
<q-img
class="text-center"
:ratio="1"
Squashed commit of the following: commit eb6c7b164a9f182f8d1ce73cc5354866c6d6b10e Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:29:44 2024 +0700 refactor: no img close to default on create commit eae9eb26071cc2985624bb1c6ce551bf5eb6eb8b Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:04:04 2024 +0700 refactor/feat: save => apply, disabled selected img, no img close to default commit ccbf80fc53db3144873c049bd6dbd37b4e2e9ff3 Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 09:31:32 2024 +0700 fix(01): use submit function commit 36b4f6ca15e5966f37dfefc9fdb744feec60dd27 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:45:19 2024 +0700 fix: imgList error commit bac0eaf3ab955672ae0c78d3295b4a839827c5f2 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:18:03 2024 +0700 refactor(03): customer new upload img dialog commit 9d7398e9613a738c33e265482cdb7d7bb250ea9f Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:40:39 2024 +0700 refactor(02): new upload dialog commit 8b91d43f41eae3ba2442f6c742d617c25ee180cb Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:25:21 2024 +0700 refactor(01): new upload dialog, confirm remove, individual action commit 61caf1919168bc5635568d7ca246574fdc43cd04 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(01): branch new img upload commit e791b7316d001d839c8afb1950f7331c62d9e81a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(02): personnel new img upload commit af4d11312b9cb666338901efa9971117cb7738c4 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 feat(02): new image upload commit e4d7afdb8c74d65a550644f2c60f70909d51d4a8 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock select image function commit 5ab3f045b9c7d2c821920c12114da15eed09655a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock new image preview
2024-09-11 16:43:41 +07:00
:src="`${baseUrl}/user/${props.row.id}/profile-image/${props.row.selectedImage}?ts=${Date.now()}`"
2024-08-20 18:04:42 +07:00
style="
object-fit: cover;
width: 100%;
height: 100%;
border-radius: 50%;
"
>
<template #error>
<div
class="no-padding full-width full-height flex items-center justify-center"
style="
background: linear-gradient(
135deg,
rgba(43, 137, 223, 1) 0%,
rgba(230, 51, 81, 1) 100%
);
"
>
<q-img
v-if="props.row.gender"
:src="
props.row.gender === 'male'
? '/no-img-man.png'
: '/no-img-female.png'
"
/>
<q-icon
v-else
size="lg"
name="mdi-account-outline"
style="color: white"
/>
</div>
</template>
</q-img>
</template>
</PersonCard>
</div>
</template>
</q-table>
2024-08-15 09:53:34 +07:00
</template>
2024-07-05 11:01:40 +00:00
<div
v-if="
userData && userData.total === 0 && !inputSearch && noPersonnel()
"
2024-07-18 02:26:03 +00:00
class="full-height column"
2024-07-05 11:01:40 +00:00
>
2024-07-17 08:19:21 +00:00
<div class="flex justify-end">
2024-07-05 11:01:40 +00:00
<TooltipComponent
2024-08-26 16:24:08 +07:00
title="personnel.tooltipTitle"
caption="personnel.tooltipCaption"
2024-07-05 11:01:40 +00:00
imgSrc="personnel-table-"
/>
</div>
2024-07-05 11:01:40 +00:00
<div class="col items-center flex justify-center">
2024-07-04 09:53:33 +00:00
<AddButton
2024-08-26 16:24:08 +07:00
:label="'personnel.addTitle'"
2024-07-04 09:53:33 +00:00
:cyanOn="true"
@trigger="openDialog('FORM')"
/>
</div>
2024-07-05 11:01:40 +00:00
</div>
2024-07-04 09:53:33 +00:00
<div
v-if="
(userData?.total === 0 && !!inputSearch) ||
2024-11-07 10:51:53 +07:00
(userData?.total === 0 && !!statusFilter && !noPersonnel())
"
2024-07-05 11:01:40 +00:00
class="row col full-width items-center justify-center"
2024-07-04 09:53:33 +00:00
style="min-height: 250px"
>
<NoData :not-found="!!inputSearch" />
</div>
</div>
2024-07-04 09:53:33 +00:00
<div
2024-07-05 11:10:16 +07:00
class="row justify-between items-center q-px-md q-py-sm"
2024-07-04 09:53:33 +00:00
v-if="currentMaxPage > 0"
>
<div class="col-4">
2024-07-18 09:10:51 +00:00
<div class="row items-center no-wrap">
2024-08-26 16:24:08 +07:00
<div class="app-text-muted q-mr-sm" v-if="$q.screen.gt.sm">
{{ $t('general.recordPerPage') }}
2024-07-04 09:53:33 +00:00
</div>
2024-11-15 11:36:51 +07:00
<div><PaginationPageSize v-model="pageSize" /></div>
2024-07-04 09:53:33 +00:00
</div>
</div>
<div class="col-4 row justify-center app-text-muted">
{{
2024-08-26 16:24:08 +07:00
$t('general.recordsPage', {
2024-07-04 09:53:33 +00:00
resultcurrentPage: userData?.result.length,
total: userData?.total,
})
}}
</div>
<div class="col-4 row justify-end">
<PaginationComponent
v-model:current-page="currentPage"
v-model:max-page="currentMaxPage"
:fetch-data="async () => await fetchUserList()"
/>
</div>
</div>
2024-07-02 09:11:39 +00:00
</div>
2024-04-03 18:28:59 +07:00
</div>
2024-04-05 19:05:51 +07:00
2024-04-18 18:27:22 +07:00
<DrawerInfo
v-if="currentUser"
2024-08-26 16:24:08 +07:00
:category="$t('personnel.personnel')"
bg-on
2024-08-19 09:47:50 +07:00
hide-action
2024-10-02 14:04:23 +07:00
:is-edit="infoDrawerEdit"
2024-04-18 18:27:22 +07:00
:title="
2024-09-12 15:41:54 +07:00
locale === 'eng'
? `${currentUser.firstNameEN} ${currentUser.lastNameEN}`
: `${currentUser.firstName} ${currentUser.lastName}`
2024-04-18 18:27:22 +07:00
"
v-model:drawerOpen="infoDrawer"
:submit="() => onSubmit()"
2024-09-05 10:37:14 +07:00
:close="
() => {
onClose();
resetScrollBar('user-form-content');
}
"
2024-04-18 18:27:22 +07:00
>
2024-08-19 14:43:05 +07:00
<InfoForm>
2024-09-27 15:22:13 +07:00
<div
:class="{
'q-mx-lg q-my-md': $q.screen.gt.sm,
'q-mx-md q-my-sm': !$q.screen.gt.sm,
}"
>
2024-08-02 15:32:51 +07:00
<ProfileBanner
2024-11-19 10:53:30 +07:00
:prefix="currentUser.firstName"
:active="formData.status !== 'INACTIVE'"
useToggle
2024-08-19 14:43:05 +07:00
color="white"
2024-08-20 10:44:30 +07:00
icon="mdi-account-outline"
2024-08-22 17:05:07 +07:00
:bgColor="
formData.gender
? 'white'
: 'linear-gradient(135deg, rgba(43,137,223,1) 0%, rgba(230,51,81,1) 100%)'
"
v-model:toggle-status="formData.status"
2024-08-07 10:12:13 +00:00
hideFade
2024-10-02 14:04:23 +07:00
:toggle-title="$t('status.title')"
2024-09-12 15:41:54 +07:00
:title="`${locale === 'eng' ? `${formData.firstNameEN} ${formData.lastNameEN}` : `${formData.firstName} ${formData.lastName}`}`"
:caption="userCode"
2024-08-02 15:32:51 +07:00
:img="
Squashed commit of the following: commit eb6c7b164a9f182f8d1ce73cc5354866c6d6b10e Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:29:44 2024 +0700 refactor: no img close to default on create commit eae9eb26071cc2985624bb1c6ce551bf5eb6eb8b Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:04:04 2024 +0700 refactor/feat: save => apply, disabled selected img, no img close to default commit ccbf80fc53db3144873c049bd6dbd37b4e2e9ff3 Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 09:31:32 2024 +0700 fix(01): use submit function commit 36b4f6ca15e5966f37dfefc9fdb744feec60dd27 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:45:19 2024 +0700 fix: imgList error commit bac0eaf3ab955672ae0c78d3295b4a839827c5f2 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:18:03 2024 +0700 refactor(03): customer new upload img dialog commit 9d7398e9613a738c33e265482cdb7d7bb250ea9f Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:40:39 2024 +0700 refactor(02): new upload dialog commit 8b91d43f41eae3ba2442f6c742d617c25ee180cb Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:25:21 2024 +0700 refactor(01): new upload dialog, confirm remove, individual action commit 61caf1919168bc5635568d7ca246574fdc43cd04 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(01): branch new img upload commit e791b7316d001d839c8afb1950f7331c62d9e81a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(02): personnel new img upload commit af4d11312b9cb666338901efa9971117cb7738c4 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 feat(02): new image upload commit e4d7afdb8c74d65a550644f2c60f70909d51d4a8 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock select image function commit 5ab3f045b9c7d2c821920c12114da15eed09655a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock new image preview
2024-09-11 16:43:41 +07:00
`${baseUrl}/user/${currentUser.id}/profile-image/${formData.selectedImage}`.concat(
refreshImageState ? `?ts=${Date.now()}` : '',
) ||
2024-08-02 15:32:51 +07:00
{
male: '/no-img-man.png',
female: '/no-img-female.png',
}[formData.gender]
"
2024-10-02 14:04:23 +07:00
:fallback-img="
{
male: '/no-img-man.png',
female: '/no-img-female.png',
}[formData.gender]
"
Squashed commit of the following: commit eb6c7b164a9f182f8d1ce73cc5354866c6d6b10e Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:29:44 2024 +0700 refactor: no img close to default on create commit eae9eb26071cc2985624bb1c6ce551bf5eb6eb8b Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:04:04 2024 +0700 refactor/feat: save => apply, disabled selected img, no img close to default commit ccbf80fc53db3144873c049bd6dbd37b4e2e9ff3 Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 09:31:32 2024 +0700 fix(01): use submit function commit 36b4f6ca15e5966f37dfefc9fdb744feec60dd27 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:45:19 2024 +0700 fix: imgList error commit bac0eaf3ab955672ae0c78d3295b4a839827c5f2 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:18:03 2024 +0700 refactor(03): customer new upload img dialog commit 9d7398e9613a738c33e265482cdb7d7bb250ea9f Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:40:39 2024 +0700 refactor(02): new upload dialog commit 8b91d43f41eae3ba2442f6c742d617c25ee180cb Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:25:21 2024 +0700 refactor(01): new upload dialog, confirm remove, individual action commit 61caf1919168bc5635568d7ca246574fdc43cd04 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(01): branch new img upload commit e791b7316d001d839c8afb1950f7331c62d9e81a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(02): personnel new img upload commit af4d11312b9cb666338901efa9971117cb7738c4 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 feat(02): new image upload commit e4d7afdb8c74d65a550644f2c60f70909d51d4a8 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock select image function commit 5ab3f045b9c7d2c821920c12114da15eed09655a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock new image preview
2024-09-11 16:43:41 +07:00
@view="
() => {
imageDialog = true;
isImageEdit = false;
}
"
@edit="imageDialog = isImageEdit = true"
@update:toggle-status="
async (v) => {
2024-09-12 15:41:54 +07:00
if (!currentUser) return;
await triggerChangeStatus(currentUser.id, v);
}
"
2024-08-02 15:32:51 +07:00
/>
</div>
<!-- อนกล -->
2024-08-02 03:41:33 +00:00
<div
2024-08-19 09:47:50 +07:00
style="flex: 1; width: 100%; overflow-y: auto"
id="drawer-user-form"
2024-09-27 15:22:13 +07:00
:class="{
'q-px-lg q-pb-lg': $q.screen.gt.sm,
'q-px-md q-pb-sm': !$q.screen.gt.sm,
}"
2024-08-02 15:32:51 +07:00
>
<div
class="col surface-1 full-height rounded bordered scroll row relative-position"
>
<div
2024-09-27 15:22:13 +07:00
class="rounded row"
:class="{
'q-py-md q-px-lg': $q.screen.gt.sm,
'q-py-sm q-px-lg': !$q.screen.gt.sm,
}"
style="position: absolute; z-index: 999; top: 0; right: 0"
>
2024-09-27 15:22:13 +07:00
<div
v-if="formData.status !== 'INACTIVE'"
class="surface-1 row rounded"
>
<UndoButton
v-if="infoDrawerEdit"
id="btn-info-basic-undo"
icon-only
@click="
() => {
undo();
}
"
type="button"
/>
<SaveButton
v-if="infoDrawerEdit"
id="btn-info-basic-save"
icon-only
type="submit"
/>
<EditButton
v-if="!infoDrawerEdit"
id="btn-info-basic-edit"
icon-only
@click="
() => {
infoDrawerEdit = true;
isImageEdit = true;
}
"
type="button"
/>
<DeleteButton
v-if="!infoDrawerEdit"
id="btn-info-basic-delete"
icon-only
@click="
() => {
if (!currentUser) return;
onDelete(currentUser.id);
}
"
type="button"
/>
</div>
</div>
2024-08-19 09:47:50 +07:00
<div
class="col"
2024-08-20 17:59:49 +07:00
style="height: 100%; overflow-y: auto"
2024-08-19 09:47:50 +07:00
v-if="$q.screen.gt.sm"
>
<div class="q-py-md q-pl-md q-pr-sm">
<SideMenu
2024-08-19 11:02:30 +07:00
:menu="
[
{
2024-08-26 16:24:08 +07:00
name: $t('form.field.basicInformation'),
2024-08-19 11:02:30 +07:00
anchor: 'info-information',
},
{
2024-08-26 16:24:08 +07:00
name: $t('personnel.form.personalInformation'),
2024-08-19 11:02:30 +07:00
anchor: 'info-personal',
},
{
2024-08-26 16:24:08 +07:00
name: $t('personnel.form.addressInformation'),
2024-08-19 11:02:30 +07:00
anchor: 'info-address',
},
].concat(
!!formData.userType
? [
{
2024-08-26 16:24:08 +07:00
name: $t('personnel.form.workInformation'),
2024-08-19 11:02:30 +07:00
anchor: 'info-work',
},
]
: [],
)
"
2024-08-19 09:47:50 +07:00
background="transparent"
:active="{
background: 'hsla(var(--blue-6-hsl) / .2)',
foreground: 'var(--blue-6)',
}"
scroll-element="#user-form-content"
/>
</div>
2024-08-02 15:32:51 +07:00
</div>
2024-08-19 09:47:50 +07:00
<div
2024-09-27 15:22:13 +07:00
class="col-12 col-md-10 relative-position"
:class="{
'q-py-md q-pr-md ': $q.screen.gt.sm,
'q-py-md q-px-lg': !$q.screen.gt.sm,
}"
2024-08-19 09:47:50 +07:00
id="user-form-content"
style="height: 100%; max-height: 100; overflow-y: auto"
>
<FormInformation
id="info-information"
v-model:hq-id="hqId"
v-model:br-id="brId"
v-model:user-type="formData.userType"
v-model:user-role="formData.userRole"
v-model:username="formData.username"
v-model:user-code="userCode"
dense
outlined
separator
2024-08-26 16:24:08 +07:00
:title="'form.field.basicInformation'"
2024-08-19 09:47:50 +07:00
:readonly="!infoDrawerEdit"
2024-10-02 14:04:23 +07:00
:username-readonly="isEdit"
2024-08-19 11:03:47 +07:00
class="q-mb-xl"
2024-08-19 09:47:50 +07:00
/>
2024-08-02 15:32:51 +07:00
2024-08-19 09:47:50 +07:00
<FormPerson
id="info-personal"
2024-10-02 14:04:23 +07:00
v-model:first-name="formData.firstName"
v-model:last-name="formData.lastName"
v-model:mid-name="formData.middleName"
v-model:mid-name-en="formData.middleNameEN"
v-model:prefix-name="formData.namePrefix"
v-model:prefix-name-en="formData.namePrefix"
v-model:first-name-en="formData.firstNameEN"
v-model:last-name-en="formData.lastNameEN"
2024-08-19 09:47:50 +07:00
v-model:telephone-no="formData.telephoneNo"
v-model:email="formData.email"
v-model:gender="formData.gender"
v-model:birth-date="formData.birthDate"
2024-09-12 15:41:54 +07:00
v-model:citizen-id="formData.citizenId"
v-model:citizen-issue="formData.citizenIssue"
v-model:citizen-expire="formData.citizenExpire"
2024-08-26 16:24:08 +07:00
:title="'personnel.form.personalInformation'"
2024-08-19 09:47:50 +07:00
prefix-id="drawer-info-personnel"
dense
outlined
separator
:readonly="!infoDrawerEdit"
2024-08-19 11:03:47 +07:00
class="q-mb-xl"
2024-08-19 09:47:50 +07:00
/>
<AddressForm
id="info-address"
v-model:address="formData.address"
2024-10-02 11:39:56 +07:00
v-model:address-en="formData.addressEN"
2024-09-12 15:41:54 +07:00
v-model:moo="formData.moo"
2024-10-02 11:39:56 +07:00
v-model:moo-en="formData.mooEN"
2024-09-12 15:41:54 +07:00
v-model:soi="formData.soi"
2024-10-02 11:39:56 +07:00
v-model:soi-en="formData.soiEN"
2024-09-12 15:41:54 +07:00
v-model:street="formData.street"
2024-10-02 11:39:56 +07:00
v-model:street-en="formData.streetEN"
v-model:province-id="formData.provinceId"
v-model:district-id="formData.districtId"
v-model:sub-district-id="formData.subDistrictId"
v-model:zip-code="formData.zipCode"
2024-08-19 09:47:50 +07:00
:readonly="!infoDrawerEdit"
prefix-id="drawer-info-personnel"
2024-08-26 16:24:08 +07:00
:title="'personnel.form.addressInformation'"
2024-08-19 09:47:50 +07:00
dense
2024-08-19 11:03:47 +07:00
class="q-mb-xl"
2024-08-19 09:47:50 +07:00
/>
<FormByType
dense
outlined
separator
id="info-work"
:readonly="!infoDrawerEdit"
2024-10-02 14:04:23 +07:00
v-model:user-type="formData.userType"
v-model:registration-no="formData.registrationNo"
v-model:start-date="formData.startDate"
v-model:retire-date="formData.retireDate"
v-model:responsible-area="formData.responsibleArea"
v-model:discount-condition="formData.discountCondition"
v-model:source-nationality="formData.sourceNationality"
v-model:import-nationality="formData.importNationality"
v-model:training-place="formData.trainingPlace"
2024-08-19 09:47:50 +07:00
v-model:checkpoint="formData.checkpoint"
2024-10-02 14:04:23 +07:00
v-model:checkpoint-en="formData.checkpointEN"
v-model:agency-file="agencyFile"
v-model:agency-file-list="agencyFileList"
v-model:user-id="currentUser.id"
2024-08-19 09:47:50 +07:00
/>
</div>
2024-08-02 03:41:33 +00:00
</div>
</div>
2024-08-02 03:41:33 +00:00
</InfoForm>
2024-04-18 18:27:22 +07:00
</DrawerInfo>
2024-04-10 14:00:55 +07:00
<!-- form -->
<DialogForm
2024-08-16 17:55:44 +07:00
hideFooter
2024-04-18 18:27:22 +07:00
removeDialog
2024-04-22 14:04:06 +07:00
:badgeClass="formData.gender === 'male' ? 'app-bg-male' : 'app-bg-female'"
:badgeLabel="userCode"
2024-08-26 16:24:08 +07:00
:title="$t('personnel.addTitle')"
2024-04-18 09:06:21 +07:00
v-model:modal="modal"
:addressSeparator="formData.userType !== ''"
:submit="() => onSubmit()"
2024-04-10 14:00:55 +07:00
:close="() => onClose()"
2024-04-05 19:05:51 +07:00
>
<!-- :title="formData.name"
:caption="formData.nameEN" -->
2024-09-27 15:22:13 +07:00
<div
:class="{
'q-mx-lg q-my-md': $q.screen.gt.sm,
'q-mx-md q-my-sm': !$q.screen.gt.sm,
}"
>
<ProfileBanner
active
useToggle
color="white"
2024-08-20 10:44:30 +07:00
icon="mdi-account-plus-outline"
bgColor="linear-gradient(135deg, rgba(43,137,223,1) 0%, rgba(230,51,81,1) 100%)"
v-model:toggle-status="formData.status"
:img="
urlProfile ||
{
male: '/no-img-man.png',
female: '/no-img-female.png',
}[formData.gender]
"
2024-08-26 16:24:08 +07:00
:toggleTitle="$t('status.title')"
2024-09-12 15:41:54 +07:00
:title="`${locale === 'eng' ? `${formData.firstNameEN} ${formData.lastNameEN}` : `${formData.firstName} ${formData.lastName}`}`"
:fallbackImg="
{
male: '/no-img-man.png',
female: '/no-img-female.png',
}[formData.gender]
"
2024-08-07 10:12:13 +00:00
hideFade
Squashed commit of the following: commit eb6c7b164a9f182f8d1ce73cc5354866c6d6b10e Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:29:44 2024 +0700 refactor: no img close to default on create commit eae9eb26071cc2985624bb1c6ce551bf5eb6eb8b Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:04:04 2024 +0700 refactor/feat: save => apply, disabled selected img, no img close to default commit ccbf80fc53db3144873c049bd6dbd37b4e2e9ff3 Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 09:31:32 2024 +0700 fix(01): use submit function commit 36b4f6ca15e5966f37dfefc9fdb744feec60dd27 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:45:19 2024 +0700 fix: imgList error commit bac0eaf3ab955672ae0c78d3295b4a839827c5f2 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:18:03 2024 +0700 refactor(03): customer new upload img dialog commit 9d7398e9613a738c33e265482cdb7d7bb250ea9f Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:40:39 2024 +0700 refactor(02): new upload dialog commit 8b91d43f41eae3ba2442f6c742d617c25ee180cb Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:25:21 2024 +0700 refactor(01): new upload dialog, confirm remove, individual action commit 61caf1919168bc5635568d7ca246574fdc43cd04 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(01): branch new img upload commit e791b7316d001d839c8afb1950f7331c62d9e81a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(02): personnel new img upload commit af4d11312b9cb666338901efa9971117cb7738c4 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 feat(02): new image upload commit e4d7afdb8c74d65a550644f2c60f70909d51d4a8 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock select image function commit 5ab3f045b9c7d2c821920c12114da15eed09655a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock new image preview
2024-09-11 16:43:41 +07:00
@view="
() => {
imageDialog = true;
isImageEdit = false;
}
"
@edit="imageDialog = isImageEdit = true"
2024-08-05 11:22:22 +00:00
@update:toggle-status="
() => {
formData.status =
formData.status === 'CREATED' ? 'INACTIVE' : 'CREATED';
}
"
/>
</div>
<div
2024-09-27 15:22:13 +07:00
class="col"
id="personnel-form"
2024-09-27 15:22:13 +07:00
:class="{
'q-px-lg q-pb-lg': $q.screen.gt.sm,
'q-px-md q-pb-sm': !$q.screen.gt.sm,
}"
>
<div
2024-09-27 15:22:13 +07:00
style="overflow-y: auto"
class="row full-width full-height surface-1 rounded bordered relative-position"
>
2024-09-27 15:22:13 +07:00
<div
class="rounded row"
style="position: absolute; z-index: 999; right: 0; top: 0"
:class="{
'q-py-md q-px-lg': $q.screen.gt.sm,
'q-py-sm q-px-lg': !$q.screen.gt.sm,
}"
>
<div
v-if="formData.status !== 'INACTIVE'"
class="surface-1 row rounded"
>
<SaveButton id="btn-info-basic-save" icon-only type="submit" />
</div>
</div>
<div class="col full-height scroll" v-if="$q.screen.gt.sm">
2024-10-24 17:29:43 +07:00
<div style="position: sticky; top: 0" class="q-py-md q-pl-md q-pr-sm">
2024-09-27 15:22:13 +07:00
<SideMenu
:menu="
[
{
name: $t('form.field.basicInformation'),
anchor: 'dialog-form-information',
},
{
name: $t('personnel.form.personalInformation'),
anchor: 'dialog-form-personal',
},
{
name: $t('personnel.form.addressInformation'),
anchor: 'dialog-form-address',
},
].concat(
!!formData.userType
? [
{
name: $t('personnel.form.workInformation'),
anchor: 'dialog-info-work',
},
]
: [],
)
"
background="transparent"
:active="{
background: 'hsla(var(--blue-6-hsl) / .2)',
foreground: 'var(--blue-6)',
}"
scroll-element="#personnel-form"
/>
</div>
</div>
<div
class="col-md-10 col-12 full-height scroll"
:class="{
'q-py-md q-pr-md ': $q.screen.gt.sm,
'q-py-md q-px-lg': !$q.screen.gt.sm,
}"
>
<FormInformation
id="dialog-form-information"
dense
outlined
separator
:title="'form.field.basicInformation'"
:usernameReadonly="isEdit"
2024-10-02 14:04:23 +07:00
v-model:hq-id="hqId"
v-model:br-id="brId"
v-model:user-type="formData.userType"
v-model:user-role="formData.userRole"
2024-09-27 15:22:13 +07:00
v-model:username="formData.username"
2024-10-02 14:04:23 +07:00
v-model:user-code="userCode"
2024-09-27 15:22:13 +07:00
class="q-mb-xl"
/>
<FormPerson
id="dialog-form-personal"
prefix-id="form-dialog-personnel"
dense
outlined
separator
:title="'personnel.form.personalInformation'"
2024-10-02 14:04:23 +07:00
v-model:first-name="formData.firstName"
v-model:last-name="formData.lastName"
v-model:mid-name="formData.middleName"
v-model:mid-name-en="formData.middleNameEN"
v-model:prefix-name="formData.namePrefix"
v-model:prefix-name-en="formData.namePrefix"
v-model:first-name-en="formData.firstNameEN"
v-model:last-name-en="formData.lastNameEN"
2024-09-27 15:22:13 +07:00
v-model:telephone-no="formData.telephoneNo"
v-model:email="formData.email"
v-model:gender="formData.gender"
v-model:birth-date="formData.birthDate"
v-model:citizen-id="formData.citizenId"
v-model:citizen-issue="formData.citizenIssue"
v-model:citizen-expire="formData.citizenExpire"
class="q-mb-xl"
/>
<AddressForm
id="dialog-form-address"
v-model:address="formData.address"
2024-10-02 11:39:56 +07:00
v-model:address-en="formData.addressEN"
2024-09-27 15:22:13 +07:00
v-model:moo="formData.moo"
2024-10-02 11:39:56 +07:00
v-model:moo-en="formData.mooEN"
2024-09-27 15:22:13 +07:00
v-model:soi="formData.soi"
2024-10-02 11:39:56 +07:00
v-model:soi-en="formData.soiEN"
2024-09-27 15:22:13 +07:00
v-model:street="formData.street"
2024-10-02 11:39:56 +07:00
v-model:street-en="formData.streetEN"
v-model:province-id="formData.provinceId"
v-model:district-id="formData.districtId"
v-model:sub-district-id="formData.subDistrictId"
v-model:zip-code="formData.zipCode"
2024-09-27 15:22:13 +07:00
prefix-id="drawer-info-personnel"
dense
class="q-mb-xl"
/>
<FormByType
id="dialog-form-work"
dense
outlined
separator
2024-10-02 14:04:23 +07:00
v-model:user-type="formData.userType"
v-model:registration-no="formData.registrationNo"
v-model:start-date="formData.startDate"
v-model:retire-date="formData.retireDate"
v-model:responsible-area="formData.responsibleArea"
v-model:discount-condition="formData.discountCondition"
v-model:source-nationality="formData.sourceNationality"
v-model:import-nationality="formData.importNationality"
v-model:training-place="formData.trainingPlace"
2024-09-27 15:22:13 +07:00
v-model:checkpoint="formData.checkpoint"
2024-10-02 14:04:23 +07:00
v-model:checkpoint-en="formData.checkpointEN"
v-model:agency-file="agencyFile"
/>
</div>
</div>
</div>
</DialogForm>
2024-08-02 16:30:18 +07:00
<ImageUploadDialog
2024-10-02 14:04:23 +07:00
v-model:dialog-state="imageDialog"
v-model:file="profileFileImg"
v-model:image-url="urlProfile"
Squashed commit of the following: commit eb6c7b164a9f182f8d1ce73cc5354866c6d6b10e Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:29:44 2024 +0700 refactor: no img close to default on create commit eae9eb26071cc2985624bb1c6ce551bf5eb6eb8b Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:04:04 2024 +0700 refactor/feat: save => apply, disabled selected img, no img close to default commit ccbf80fc53db3144873c049bd6dbd37b4e2e9ff3 Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 09:31:32 2024 +0700 fix(01): use submit function commit 36b4f6ca15e5966f37dfefc9fdb744feec60dd27 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:45:19 2024 +0700 fix: imgList error commit bac0eaf3ab955672ae0c78d3295b4a839827c5f2 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:18:03 2024 +0700 refactor(03): customer new upload img dialog commit 9d7398e9613a738c33e265482cdb7d7bb250ea9f Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:40:39 2024 +0700 refactor(02): new upload dialog commit 8b91d43f41eae3ba2442f6c742d617c25ee180cb Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:25:21 2024 +0700 refactor(01): new upload dialog, confirm remove, individual action commit 61caf1919168bc5635568d7ca246574fdc43cd04 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(01): branch new img upload commit e791b7316d001d839c8afb1950f7331c62d9e81a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(02): personnel new img upload commit af4d11312b9cb666338901efa9971117cb7738c4 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 feat(02): new image upload commit e4d7afdb8c74d65a550644f2c60f70909d51d4a8 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock select image function commit 5ab3f045b9c7d2c821920c12114da15eed09655a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock new image preview
2024-09-11 16:43:41 +07:00
v-model:data-list="imageList"
v-model:on-create-data-list="onCreateImageList"
:on-create="modal"
:hiddenFooter="!isImageEdit"
@add-image="
async (v) => {
if (!v) return;
if (!currentUser) return;
const res = await userStore.addImageList(
v,
currentUser?.id,
Date.now().toString(),
Squashed commit of the following: commit eb6c7b164a9f182f8d1ce73cc5354866c6d6b10e Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:29:44 2024 +0700 refactor: no img close to default on create commit eae9eb26071cc2985624bb1c6ce551bf5eb6eb8b Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:04:04 2024 +0700 refactor/feat: save => apply, disabled selected img, no img close to default commit ccbf80fc53db3144873c049bd6dbd37b4e2e9ff3 Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 09:31:32 2024 +0700 fix(01): use submit function commit 36b4f6ca15e5966f37dfefc9fdb744feec60dd27 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:45:19 2024 +0700 fix: imgList error commit bac0eaf3ab955672ae0c78d3295b4a839827c5f2 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:18:03 2024 +0700 refactor(03): customer new upload img dialog commit 9d7398e9613a738c33e265482cdb7d7bb250ea9f Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:40:39 2024 +0700 refactor(02): new upload dialog commit 8b91d43f41eae3ba2442f6c742d617c25ee180cb Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:25:21 2024 +0700 refactor(01): new upload dialog, confirm remove, individual action commit 61caf1919168bc5635568d7ca246574fdc43cd04 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(01): branch new img upload commit e791b7316d001d839c8afb1950f7331c62d9e81a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(02): personnel new img upload commit af4d11312b9cb666338901efa9971117cb7738c4 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 feat(02): new image upload commit e4d7afdb8c74d65a550644f2c60f70909d51d4a8 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock select image function commit 5ab3f045b9c7d2c821920c12114da15eed09655a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock new image preview
2024-09-11 16:43:41 +07:00
);
await fetchImageList(currentUser?.id, res);
}
"
@remove-image="
async (v) => {
if (!v) return;
if (!currentUser) return;
const name = v.split('/').pop() || '';
await userStore.deleteImageByName(currentUser?.id, name);
await fetchImageList(currentUser?.id, currentUser.selectedImage || '');
Squashed commit of the following: commit eb6c7b164a9f182f8d1ce73cc5354866c6d6b10e Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:29:44 2024 +0700 refactor: no img close to default on create commit eae9eb26071cc2985624bb1c6ce551bf5eb6eb8b Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:04:04 2024 +0700 refactor/feat: save => apply, disabled selected img, no img close to default commit ccbf80fc53db3144873c049bd6dbd37b4e2e9ff3 Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 09:31:32 2024 +0700 fix(01): use submit function commit 36b4f6ca15e5966f37dfefc9fdb744feec60dd27 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:45:19 2024 +0700 fix: imgList error commit bac0eaf3ab955672ae0c78d3295b4a839827c5f2 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:18:03 2024 +0700 refactor(03): customer new upload img dialog commit 9d7398e9613a738c33e265482cdb7d7bb250ea9f Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:40:39 2024 +0700 refactor(02): new upload dialog commit 8b91d43f41eae3ba2442f6c742d617c25ee180cb Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:25:21 2024 +0700 refactor(01): new upload dialog, confirm remove, individual action commit 61caf1919168bc5635568d7ca246574fdc43cd04 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(01): branch new img upload commit e791b7316d001d839c8afb1950f7331c62d9e81a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(02): personnel new img upload commit af4d11312b9cb666338901efa9971117cb7738c4 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 feat(02): new image upload commit e4d7afdb8c74d65a550644f2c60f70909d51d4a8 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock select image function commit 5ab3f045b9c7d2c821920c12114da15eed09655a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock new image preview
2024-09-11 16:43:41 +07:00
}
"
@submit="
async (v) => {
if (modal) {
urlProfile = v;
imageDialog = false;
} else {
refreshImageState = true;
formData.selectedImage = v;
imageList ? (imageList.selectedImage = v) : '';
urlProfile = `${baseUrl}/user/${currentUser && currentUser.id}/profile-image/${v}`;
await onSubmit(true);
imageDialog = false;
refreshImageState = false;
}
}
"
2024-08-02 16:30:18 +07:00
>
Squashed commit of the following: commit eb6c7b164a9f182f8d1ce73cc5354866c6d6b10e Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:29:44 2024 +0700 refactor: no img close to default on create commit eae9eb26071cc2985624bb1c6ce551bf5eb6eb8b Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:04:04 2024 +0700 refactor/feat: save => apply, disabled selected img, no img close to default commit ccbf80fc53db3144873c049bd6dbd37b4e2e9ff3 Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 09:31:32 2024 +0700 fix(01): use submit function commit 36b4f6ca15e5966f37dfefc9fdb744feec60dd27 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:45:19 2024 +0700 fix: imgList error commit bac0eaf3ab955672ae0c78d3295b4a839827c5f2 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:18:03 2024 +0700 refactor(03): customer new upload img dialog commit 9d7398e9613a738c33e265482cdb7d7bb250ea9f Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:40:39 2024 +0700 refactor(02): new upload dialog commit 8b91d43f41eae3ba2442f6c742d617c25ee180cb Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:25:21 2024 +0700 refactor(01): new upload dialog, confirm remove, individual action commit 61caf1919168bc5635568d7ca246574fdc43cd04 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(01): branch new img upload commit e791b7316d001d839c8afb1950f7331c62d9e81a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(02): personnel new img upload commit af4d11312b9cb666338901efa9971117cb7738c4 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 feat(02): new image upload commit e4d7afdb8c74d65a550644f2c60f70909d51d4a8 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock select image function commit 5ab3f045b9c7d2c821920c12114da15eed09655a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock new image preview
2024-09-11 16:43:41 +07:00
<template #title>
<span v-if="!modal" class="justify-center flex text-bold">
{{ $t('general.image') }}
{{
2024-09-12 15:41:54 +07:00
locale === 'eng'
Squashed commit of the following: commit eb6c7b164a9f182f8d1ce73cc5354866c6d6b10e Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:29:44 2024 +0700 refactor: no img close to default on create commit eae9eb26071cc2985624bb1c6ce551bf5eb6eb8b Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:04:04 2024 +0700 refactor/feat: save => apply, disabled selected img, no img close to default commit ccbf80fc53db3144873c049bd6dbd37b4e2e9ff3 Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 09:31:32 2024 +0700 fix(01): use submit function commit 36b4f6ca15e5966f37dfefc9fdb744feec60dd27 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:45:19 2024 +0700 fix: imgList error commit bac0eaf3ab955672ae0c78d3295b4a839827c5f2 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:18:03 2024 +0700 refactor(03): customer new upload img dialog commit 9d7398e9613a738c33e265482cdb7d7bb250ea9f Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:40:39 2024 +0700 refactor(02): new upload dialog commit 8b91d43f41eae3ba2442f6c742d617c25ee180cb Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:25:21 2024 +0700 refactor(01): new upload dialog, confirm remove, individual action commit 61caf1919168bc5635568d7ca246574fdc43cd04 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(01): branch new img upload commit e791b7316d001d839c8afb1950f7331c62d9e81a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(02): personnel new img upload commit af4d11312b9cb666338901efa9971117cb7738c4 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 feat(02): new image upload commit e4d7afdb8c74d65a550644f2c60f70909d51d4a8 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock select image function commit 5ab3f045b9c7d2c821920c12114da15eed09655a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock new image preview
2024-09-11 16:43:41 +07:00
? `${formData.firstNameEN} ${formData.lastNameEN}`
: `${formData.firstName} ${formData.lastName}`
}}
</span>
</template>
2024-08-02 16:30:18 +07:00
<template #error>
<div class="full-height full-width" style="background: white">
<div
class="full-height full-width flex justify-center items-center"
:style="`background: ${
2024-08-30 14:36:48 +07:00
formData.gender
? formData.gender === 'male'
? '#78afb0'
: '#c0bfe2'
2024-08-30 14:36:48 +07:00
: 'linear-gradient(135deg,rgba(43, 137, 223, 1) 0%,rgba(230, 51, 81, 1) 100%)'
}`"
2024-08-02 16:30:18 +07:00
>
<q-img
2024-08-30 14:36:48 +07:00
v-if="formData.gender"
2024-08-05 07:13:46 +00:00
fit="contain"
:src="`/no-img-${formData.gender === 'male' ? 'man' : 'female'}.png`"
2024-08-05 07:13:46 +00:00
style="height: 100%"
/>
2024-08-02 16:30:18 +07:00
<q-icon
v-else
Squashed commit of the following: commit eb6c7b164a9f182f8d1ce73cc5354866c6d6b10e Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:29:44 2024 +0700 refactor: no img close to default on create commit eae9eb26071cc2985624bb1c6ce551bf5eb6eb8b Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 11:04:04 2024 +0700 refactor/feat: save => apply, disabled selected img, no img close to default commit ccbf80fc53db3144873c049bd6dbd37b4e2e9ff3 Author: puriphatt <puriphat@frappet.com> Date: Wed Sep 11 09:31:32 2024 +0700 fix(01): use submit function commit 36b4f6ca15e5966f37dfefc9fdb744feec60dd27 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:45:19 2024 +0700 fix: imgList error commit bac0eaf3ab955672ae0c78d3295b4a839827c5f2 Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 17:18:03 2024 +0700 refactor(03): customer new upload img dialog commit 9d7398e9613a738c33e265482cdb7d7bb250ea9f Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:40:39 2024 +0700 refactor(02): new upload dialog commit 8b91d43f41eae3ba2442f6c742d617c25ee180cb Author: puriphatt <puriphat@frappet.com> Date: Tue Sep 10 15:25:21 2024 +0700 refactor(01): new upload dialog, confirm remove, individual action commit 61caf1919168bc5635568d7ca246574fdc43cd04 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(01): branch new img upload commit e791b7316d001d839c8afb1950f7331c62d9e81a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 refactor(02): personnel new img upload commit af4d11312b9cb666338901efa9971117cb7738c4 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:42 2024 +0700 feat(02): new image upload commit e4d7afdb8c74d65a550644f2c60f70909d51d4a8 Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock select image function commit 5ab3f045b9c7d2c821920c12114da15eed09655a Author: puriphatt <puriphat@frappet.com> Date: Mon Sep 9 17:08:41 2024 +0700 refactor: mock new image preview
2024-09-11 16:43:41 +07:00
size="3rem"
2024-08-20 10:44:30 +07:00
:name="
infoDrawer ? 'mdi-account-outline' : 'mdi-account-plus-outline'
"
style="color: white"
2024-08-02 17:06:54 +07:00
/>
2024-08-02 16:30:18 +07:00
</div>
</div>
</template>
</ImageUploadDialog>
2024-04-03 18:28:59 +07:00
</template>
<style scoped>
2024-04-10 14:00:55 +07:00
.upload-img-preview {
border: 1px solid var(--border-color);
border-radius: var(--radius-2);
height: 12vw;
2024-04-18 09:06:21 +07:00
background-color: var(--surface-1);
2024-04-10 14:00:55 +07:00
}
.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-18 09:06:21 +07:00
.cancel-img-btn {
color: hsl(var(--negative-bg));
border: 1px solid hsl(var(--negative-bg));
background-color: transparent;
border-radius: var(--radius-2);
}
.submit-img-btn {
color: var(--surface-1);
border: 1px solid hsl(var(--positive-bg));
background-color: hsl(var(--positive-bg));
border-radius: var(--radius-2);
}
2024-07-05 03:29:33 +00:00
.slide-enter-active {
transition: all 0.1s ease-out;
}
.slide-leave-active {
transition: all 0.1s cubic-bezier(1, 0.5, 0.8, 1);
}
.slide-enter-from,
.slide-leave-to {
transform: translateY(-20px);
opacity: 0;
}
.status-active {
--_branch-status-color: var(--green-6-hsl);
}
.status-inactive {
2024-08-05 11:22:22 +00:00
--_branch-status-color: var(--stone-5-hsl);
--_branch-badge-bg: var(--stone-5-hsl);
filter: grayscale(0.5);
opacity: 0.5;
}
.branch-card__icon {
background-color: hsla(var(--_branch-card-bg) / 0.15);
border-radius: 50%;
2024-08-19 14:43:05 +07:00
position: relative;
transform: rotate(45deg);
&::after {
content: ' ';
display: block;
block-size: 0.5rem;
aspect-ratio: 1;
position: absolute;
border-radius: 50%;
right: -0.1rem;
top: calc(50% - 0.25rem);
bottom: calc(50% - 0.25rem);
background-color: hsla(var(--_branch-status-color) / 1);
}
& :deep(.q-avatar) {
transform: rotate(-45deg);
color: hsla(var(--_branch-card-bg) / 1);
}
}
.tags {
display: inline-block;
color: hsla(var(--_color) / 1);
background: hsla(var(--_color) / 0.15);
border-radius: var(--radius-2);
padding-inline: var(--size-2);
}
.tags__cyan {
--_color: var(--cyan-7-hsl);
}
2024-08-02 13:45:01 +07:00
.dark .tags__cyan {
--_color: var(--cyan-4-hsl);
}
.tags__yellow {
--_color: var(--orange-4-hsl);
}
.tags__red {
--_color: var(--red-6-hsl);
}
.tags__magenta {
--_color: var(--pink-8-hsl);
}
.tags__pink {
--_color: var(--pink-6-hsl);
}
.dark .tags__magenta {
2024-08-02 13:45:01 +07:00
--_color: var(--pink-6-hsl);
}
.tags__purple {
--_color: var(--indigo-8-hsl);
}
.dark .tags__purple {
--_color: var(--indigo-3-hsl);
}
& .symbol-gender {
color: hsla(var(--_fg));
&.symbol-gender__male {
--_fg: var(--gender-male);
}
&.symbol-gender__female {
--_fg: var(--gender-female);
}
}
2024-04-05 19:05:51 +07:00
</style>