diff --git a/src/pages/02_personnel-management/MainPage.vue b/src/pages/02_personnel-management/MainPage.vue index 764c7315..338aadb9 100644 --- a/src/pages/02_personnel-management/MainPage.vue +++ b/src/pages/02_personnel-management/MainPage.vue @@ -42,7 +42,7 @@ const defaultFormData = { licenseExpireDate: null, licenseIssueDate: null, licenseNo: null, - discountCondition: '', + discountCondition: null, retireDate: null, startDate: null, registrationNo: null, @@ -54,9 +54,11 @@ const defaultFormData = { userType: '', profileImage: null, birthDate: null, - responsibleArea: '', + responsibleArea: null, + username: '', }; +const profileSubmit = ref(false); const urlProfile = ref(); const isEdit = ref(false); const modal = ref(false); @@ -65,7 +67,6 @@ const userId = ref(''); const selectorLabel = ref(''); const hqId = ref(''); const brId = ref(''); -const username = ref(''); const code = ref(''); const formDialogRef = ref(); const userStats = ref(); @@ -98,7 +99,10 @@ const formData = ref({ userType: '', profileImage: null, birthDate: null, - responsibleArea: '', + responsibleArea: null, + checkpoint: null, + checkpointEN: null, + username: '', }); const profileFile = ref(undefined); @@ -131,6 +135,7 @@ const selectorList = computed(() => [ async function openDialog(idEdit?: string) { modal.value = true; + profileSubmit.value = false; userStore.userOption.brOpts = []; userStore.userOption.hqOpts.length === 0 @@ -166,6 +171,7 @@ async function openDialog(idEdit?: string) { firstName: foundUser.firstName, userRole: foundUser.userRole, userType: foundUser.userType, + username: foundUser.username, responsibleArea: foundUser.responsibleArea, licenseExpireDate: (foundUser.licenseExpireDate && @@ -192,9 +198,10 @@ async function openDialog(idEdit?: string) { code.value = foundUser.code; urlProfile.value = foundUser.profileImageUrl; isEdit.value = true; + profileSubmit.value = true; await userStore.fetchBrOption(hqId.value); - await formDialogRef.value.fetchSubDistrict(formData.value.districtId); - await formDialogRef.value.fetchDistrict(formData.value.provinceId); + // await formDialogRef.value.fetchSubDistrict(formData.value.districtId); + // await formDialogRef.value.fetchDistrict(formData.value.provinceId); } } } @@ -204,13 +211,13 @@ function onClose() { hqId.value = ''; brId.value = ''; userId.value = ''; - username.value = ''; urlProfile.value = ''; + profileSubmit.value = false; modal.value = false; status.value = false; isEdit.value = false; - mapUserType(selectorLabel.value); Object.assign(formData.value, defaultFormData); + mapUserType(selectorLabel.value); } async function onSubmit() { @@ -270,15 +277,14 @@ function cardClick(id: string) { } function mapUserType(label: string) { - if (label === 'personnelSelector1') { - formData.value.userType = 'USER'; - } else if (label === 'personnelSelector2') { - formData.value.userType = 'MESSENGER'; - } else if (label === 'personnelSelector3') { - formData.value.userType = 'DELEGATE'; - } else if (label === 'personnelSelector4') { - formData.value.userType = 'AGENCY'; - } + const userTypeMap: { [key: string]: string } = { + USER: 'USER', + MESSENGER: 'MESSENGER', + DELEGATE: 'DELEGATE', + AGENCY: 'AGENCY', + }; + + formData.value.userType = userTypeMap[label]; } onMounted(async () => { @@ -377,14 +383,6 @@ watch( female: v.gender === 'female', detail: [ { label: 'ประเภท', value: $t(v.userType) }, - { - label: 'ตำแหน่ง', - value: v.userRole - ? userStore.userOption.roleOpts.find( - (r) => r.value === v.userRole, - )?.label || '' - : '', - }, { label: 'โทรศัพท์', value: v.telephoneNo }, { label: 'อายุ', @@ -427,15 +425,17 @@ watch( @@ -454,33 +454,61 @@ watch( style="color: var(--border-color)" /> +
+
+ +
+
+ +
+
+ -
+ +
@@ -538,14 +566,11 @@ watch(