diff --git a/src/components/02_personnel-management/FormPerson.vue b/src/components/02_personnel-management/FormPerson.vue index 4f658264..610e79da 100644 --- a/src/components/02_personnel-management/FormPerson.vue +++ b/src/components/02_personnel-management/FormPerson.vue @@ -12,7 +12,7 @@ import { useI18n } from 'vue-i18n'; const { locale } = useI18n(); const optionStore = useOptionStore(); - +const prefixNameTh = defineModel('prefixName'); const firstName = defineModel('firstName'); const lastName = defineModel('lastName'); const firstNameEN = defineModel('firstNameEN'); @@ -23,6 +23,13 @@ const gender = defineModel('gender'); const birthDate = defineModel('birthDate'); const nationality = defineModel('nationality'); +const prefixNameOptions = ref[]>([]); +const prefixNameFilter = selectFilterOptionRefMod( + ref(optionStore.globalOption.prefix), + prefixNameOptions, + 'label', +); + const genderOptions = ref[]>([]); const genderFilter = selectFilterOptionRefMod( ref(optionStore.globalOption.gender), @@ -48,274 +55,348 @@ defineProps<{ }>(); diff --git a/src/components/TabComponent.vue b/src/components/TabComponent.vue index 69f6e458..bd21fbef 100644 --- a/src/components/TabComponent.vue +++ b/src/components/TabComponent.vue @@ -145,9 +145,10 @@ onMounted(() => { @click.stop=" () => { if (v.statusSave) { - $emit('remove', index , v.id ); + $emit('remove', index, v.id); + } else { + close(index); } - close(index); } " /> diff --git a/src/pages/02_personnel-management/MainPage.vue b/src/pages/02_personnel-management/MainPage.vue index 21bd3969..c508b79a 100644 --- a/src/pages/02_personnel-management/MainPage.vue +++ b/src/pages/02_personnel-management/MainPage.vue @@ -32,7 +32,8 @@ import NoData from 'components/NoData.vue'; import ProfileUpload from 'components/ProfileUpload.vue'; import PaginationComponent from 'src/components/PaginationComponent.vue'; import useOptionStore from 'src/stores/options'; -status; +import ProfileBanner from 'src/components/ProfileBanner.vue'; +import SideMenu from 'src/components/SideMenu.vue'; const { locale, t } = useI18n(); const $q = useQuasar(); @@ -109,9 +110,29 @@ const fieldSelectedOption = ref<{ label: string; value: string }[]>([ }, ]); +const formMenuIcon = ref<{ icon: string; color: string; bgColor: string }[]>([ + { + icon: 'mdi-account', + color: 'hsl(var(--info-bg))', + bgColor: 'var(--surface-1)', + }, + + { + icon: 'mdi-map-marker-radius', + color: 'hsl(var(--info-bg))', + bgColor: 'var(--surface-1)', + }, + { + icon: 'mdi-briefcase', + color: 'hsl(var(--info-bg))', + bgColor: 'var(--surface-1)', + }, +]); + const fieldSelected = ref< ('name' | 'type' | 'telephoneNo' | 'birthDate' | 'email' | 'userRole')[] >(['name', 'type', 'telephoneNo', 'birthDate', 'email', 'userRole']); + const fieldDisplay = ref(); const hideStat = ref(false); const userCode = ref(); @@ -175,20 +196,22 @@ const formData = ref({ status: 'CREATED', }); -const profileUrl = ref(''); -const profileFile = ref(undefined); +const isImageEdit = ref(false); +const imageUrl = ref(''); +const profileFileImg = ref(null); +const imageDialog = ref(false); -const inputFile = (() => { +const inputFileImg = (() => { const element = document.createElement('input'); element.type = 'file'; element.accept = 'image/*'; const reader = new FileReader(); reader.addEventListener('load', () => { - if (typeof reader.result === 'string') profileUrl.value = reader.result; + if (typeof reader.result === 'string') imageUrl.value = reader.result; if (infoDrawerEdit.value && currentUser.value) - currentUser.value.profileImageUrl = profileUrl.value as string; + currentUser.value.profileImageUrl = imageUrl.value as string; // profileUrl.value = currentUser.value?.profileImageUrl as string; // if (infoDrawerEmployeeEdit.value && infoEmployeePersonCard.value) @@ -196,9 +219,9 @@ const inputFile = (() => { }); element.addEventListener('change', () => { - profileFile.value = element.files?.[0]; - if (profileFile.value) { - reader.readAsDataURL(profileFile.value); + profileFileImg.value = element.files?.[0]; + if (profileFileImg.value) { + reader.readAsDataURL(profileFileImg.value); } }); @@ -259,12 +282,12 @@ reader.addEventListener('load', () => { if (infoDrawerEdit.value) infoPersonCard.value[0].img = urlProfile.value; }); -watch(profileFile, () => { - if (profileFile.value) reader.readAsDataURL(profileFile.value); +watch(profileFileImg, () => { + if (profileFileImg.value) reader.readAsDataURL(profileFileImg.value); }); -inputFile.addEventListener('change', (e) => { - profileFile.value = (e.currentTarget as HTMLInputElement).files?.[0]; +inputFileImg.addEventListener('change', (e) => { + profileFileImg.value = (e.currentTarget as HTMLInputElement).files?.[0]; }); const selectorList = computed(() => [ @@ -360,7 +383,7 @@ function onClose() { userId.value = ''; userCode.value = ''; urlProfile.value = undefined; - profileFile.value = undefined; + profileFileImg.value = null; infoDrawerEdit.value = false; agencyFile.value = []; modal.value = false; @@ -375,7 +398,7 @@ function onClose() { async function onSubmit() { if (profileSubmit.value) { - formData.value.profileImage = profileFile.value as File; + formData.value.profileImage = profileFileImg.value as File; } else { formData.value.profileImage = null; } @@ -520,7 +543,7 @@ async function assignFormData(idEdit: string) { if (foundUser) { currentUser.value = foundUser; infoPersonId.value = currentUser.value.id; - profileUrl.value = currentUser.value.profileImageUrl; + imageUrl.value = currentUser.value.profileImageUrl; formData.value = { branchId: foundUser.branch[0]?.id, provinceId: foundUser.provinceId, @@ -568,7 +591,7 @@ async function assignFormData(idEdit: string) { userId.value = foundUser.id; if (foundUser.branch) { - if (foundUser.branch[0].isHeadOffice) { + if (foundUser.branch?.[0].isHeadOffice) { hqId.value = foundUser.branch[0].id as string; } else { hqId.value = foundUser.branch[0].headOfficeId as string; @@ -593,6 +616,12 @@ async function assignFormData(idEdit: string) { } } +function openImageDialog(isEdit?: boolean) { + if (isEdit) isImageEdit.value = true; + else isImageEdit.value = false; + imageDialog.value = true; +} + onMounted(async () => { utilsStore.currentTitle.title = 'personnelManagement'; utilsStore.currentTitle.path = [{ text: 'personnelManagementCaption' }]; @@ -1472,11 +1501,111 @@ watch( v-model:subDistrictId="formData.subDistrictId" v-model:zipCode="formData.zipCode" > +
+ +
+ +
+
+
+ +
+
+ +
+ + + +
+
+ + + - + --> @@ -1581,8 +1710,8 @@ watch( v-model:url-profile="urlProfile" v-model:status-toggle="statusToggle" v-model:profile-submit="profileSubmit" - @input-file="inputFile.click()" - @cancel-file="inputFile.value = ''" + @input-file="inputFileImg.click()" + @cancel-file="inputFileImg.value = ''" />