diff --git a/src/modules/04_registry/components/Assessment.vue b/src/modules/04_registry/components/Assessment.vue index c93364503..de8f0a5ae 100644 --- a/src/modules/04_registry/components/Assessment.vue +++ b/src/modules/04_registry/components/Assessment.vue @@ -366,7 +366,9 @@ const tittleHistory = ref("ประวัติแก้ไขผลก const filterHistory = ref(""); //search data table history const modalHistory = ref(false); //modal ประวัติการแก้ไขข้อมูล const checkValidate = ref(false); //validate data ผ่านหรือไม่ -const profileId = ref(route.params.id.toString()); +const profileId = ref( + route.params.id ? route.params.id.toString() : "" +); const rows = ref([]); const filter = ref(""); //search data table const visibleColumns = ref([]); diff --git a/src/modules/04_registry/components/Coin.vue b/src/modules/04_registry/components/Coin.vue index 122508ea6..df57bec8e 100644 --- a/src/modules/04_registry/components/Coin.vue +++ b/src/modules/04_registry/components/Coin.vue @@ -319,7 +319,9 @@ const tittleHistory = ref("ประวัติแก้ไขประ const filterHistory = ref(""); //search data table history const modalHistory = ref(false); //modal ประวัติการแก้ไขข้อมูล const checkValidate = ref(false); //validate data ผ่านหรือไม่ -const profileId = ref(route.params.id.toString()); +const profileId = ref( + route.params.id ? route.params.id.toString() : "" +); const rows = ref([]); const filter = ref(""); //search data table const visibleColumns = ref([]); diff --git a/src/modules/04_registry/components/Discipline.vue b/src/modules/04_registry/components/Discipline.vue index 2299c82ab..77dbd1879 100644 --- a/src/modules/04_registry/components/Discipline.vue +++ b/src/modules/04_registry/components/Discipline.vue @@ -381,7 +381,9 @@ const tittleHistory = ref("ประวัติแก้ไขวิน const filterHistory = ref(""); //search data table history const modalHistory = ref(false); //modal ประวัติการแก้ไขข้อมูล const checkValidate = ref(false); //validate data ผ่านหรือไม่ -const profileId = ref(route.params.id.toString()); +const profileId = ref( + route.params.id ? route.params.id.toString() : "" +); const rows = ref([]); const filter = ref(""); //search data table const visibleColumns = ref([]); diff --git a/src/modules/04_registry/components/Document.vue b/src/modules/04_registry/components/Document.vue index f539f31d9..74e4c1a48 100644 --- a/src/modules/04_registry/components/Document.vue +++ b/src/modules/04_registry/components/Document.vue @@ -162,7 +162,9 @@ const $q = useQuasar(); // show dialog const mixin = useCounterMixin(); const route = useRoute(); const { success, messageError } = mixin; -const profileId = ref(route.params.id.toString()); +const profileId = ref( + route.params.id ? route.params.id.toString() : "" +); const edit = ref(false); const uploader = ref(); const files = ref([]); diff --git a/src/modules/04_registry/components/Education.vue b/src/modules/04_registry/components/Education.vue index ed081db6f..b47d3567f 100644 --- a/src/modules/04_registry/components/Education.vue +++ b/src/modules/04_registry/components/Education.vue @@ -655,7 +655,9 @@ const tittleHistory = ref("ประวัติแก้ไขประ const filterHistory = ref(""); //search data table history const modalHistory = ref(false); //modal ประวัติการแก้ไขข้อมูล const checkValidate = ref(false); //validate data ผ่านหรือไม่ -const profileId = ref(route.params.id.toString()); +const profileId = ref( + route.params.id ? route.params.id.toString() : "" +); const rows = ref([]); const filter = ref(""); //search data table const visibleColumns = ref([]); diff --git a/src/modules/04_registry/components/Information/Address.vue b/src/modules/04_registry/components/Information/Address.vue index 64f63ecf4..111cda831 100644 --- a/src/modules/04_registry/components/Information/Address.vue +++ b/src/modules/04_registry/components/Information/Address.vue @@ -606,27 +606,29 @@ const getNewData = async () => { }; const fetchData = async () => { - loaderPage(true); - await http - .get(config.API.profileAdrsId(route.params.id.toString())) - .then((res) => { - const data: ResponseObject = res.data.result; - addressData.value.address = data.registrationAddress; - addressData.value.addressC = data.currentAddress; - addressData.value.districtId = data.registrationDistrictId; - addressData.value.districtIdC = data.currentDistrictId; - addressData.value.provinceId = data.registrationProvinceId; - addressData.value.provinceIdC = data.currentProvinceId; - addressData.value.subdistrictId = data.registrationSubDistrictId; - addressData.value.subdistrictIdC = data.currentSubDistrictId; - addressData.value.same = data.registrationSame ? "1" : "0"; - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - loaderPage(false); - }); + if (route.params.id) { + loaderPage(true); + await http + .get(config.API.profileAdrsId(route.params.id.toString())) + .then((res) => { + const data: ResponseObject = res.data.result; + addressData.value.address = data.registrationAddress; + addressData.value.addressC = data.currentAddress; + addressData.value.districtId = data.registrationDistrictId; + addressData.value.districtIdC = data.currentDistrictId; + addressData.value.provinceId = data.registrationProvinceId; + addressData.value.provinceIdC = data.currentProvinceId; + addressData.value.subdistrictId = data.registrationSubDistrictId; + addressData.value.subdistrictIdC = data.currentSubDistrictId; + addressData.value.same = data.registrationSame ? "1" : "0"; + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + loaderPage(false); + }); + } }; const editData = async () => { diff --git a/src/modules/04_registry/components/Information/Certicate.vue b/src/modules/04_registry/components/Information/Certicate.vue index 721bf17c0..3706fb326 100644 --- a/src/modules/04_registry/components/Information/Certicate.vue +++ b/src/modules/04_registry/components/Information/Certicate.vue @@ -316,7 +316,9 @@ const tittleHistory = ref("ประวัติแก้ไขใบอ const filterHistory = ref(""); //search data table history const modalHistory = ref(false); //modal ประวัติการแก้ไขข้อมูล const checkValidate = ref(false); //validate data ผ่านหรือไม่ -const profileId = ref(route.params.id.toString()); +const profileId = ref( + route.params.id ? route.params.id.toString() : "" +); const rows = ref([]); const filter = ref(""); //search data table const visibleColumns = ref([]); diff --git a/src/modules/04_registry/components/Information/Family.vue b/src/modules/04_registry/components/Information/Family.vue index 6c49531e0..8c49f6c88 100644 --- a/src/modules/04_registry/components/Information/Family.vue +++ b/src/modules/04_registry/components/Information/Family.vue @@ -1299,61 +1299,63 @@ const fetchHistory = async () => { }; const fetchData = async () => { - loaderPage(true); - await http - .get(config.API.profileFamiId(route.params.id.toString())) - .then((res) => { - const data: ResponseObject = res.data.result; - familyData.value.prefixC = ""; - familyData.value.prefixIdC = data.couplePrefixId; - familyData.value.firstnameC = data.coupleFirstName; - familyData.value.lastnameC = data.coupleLastName; - familyData.value.lastnameCOld = data.coupleLastNameOld; - familyData.value.occupationC = data.coupleCareer; - familyData.value.liveC = data.coupleLive ? "1" : "0"; - familyData.value.citizenIdC = data.coupleCitizenId; + if (route.params.id) { + loaderPage(true); + await http + .get(config.API.profileFamiId(route.params.id.toString())) + .then((res) => { + const data: ResponseObject = res.data.result; + familyData.value.prefixC = ""; + familyData.value.prefixIdC = data.couplePrefixId; + familyData.value.firstnameC = data.coupleFirstName; + familyData.value.lastnameC = data.coupleLastName; + familyData.value.lastnameCOld = data.coupleLastNameOld; + familyData.value.occupationC = data.coupleCareer; + familyData.value.liveC = data.coupleLive ? "1" : "0"; + familyData.value.citizenIdC = data.coupleCitizenId; - familyData.value.prefixM = ""; - familyData.value.prefixIdM = data.fatherPrefixId; - familyData.value.firstnameM = data.fatherFirstName; - familyData.value.lastnameM = data.fatherLastName; - familyData.value.occupationM = data.fatherCareer; - familyData.value.liveM = data.fatherLive ? "1" : "0"; - familyData.value.citizenIdM = data.fatherCitizenId; + familyData.value.prefixM = ""; + familyData.value.prefixIdM = data.fatherPrefixId; + familyData.value.firstnameM = data.fatherFirstName; + familyData.value.lastnameM = data.fatherLastName; + familyData.value.occupationM = data.fatherCareer; + familyData.value.liveM = data.fatherLive ? "1" : "0"; + familyData.value.citizenIdM = data.fatherCitizenId; - familyData.value.prefixF = ""; - familyData.value.prefixIdF = data.motherPrefixId; - familyData.value.firstnameF = data.motherFirstName; - familyData.value.lastnameF = data.motherLastName; - familyData.value.occupationF = data.motherCareer; - familyData.value.liveF = data.motherLive ? "1" : "0"; - familyData.value.citizenIdF = data.motherCitizenId; - familyData.value.same = data.couple ? "1" : "0"; + familyData.value.prefixF = ""; + familyData.value.prefixIdF = data.motherPrefixId; + familyData.value.firstnameF = data.motherFirstName; + familyData.value.lastnameF = data.motherLastName; + familyData.value.occupationF = data.motherCareer; + familyData.value.liveF = data.motherLive ? "1" : "0"; + familyData.value.citizenIdF = data.motherCitizenId; + familyData.value.same = data.couple ? "1" : "0"; - if (data.childrens.length > 0) { - let dataChild: childrenFamily[] = []; - data.childrens.map((row: childrenFamily, index: number) => { - dataChild.push({ - id: `${index + 1}`, - childrenPrefixId: row.childrenPrefixId, - childrenFirstName: row.childrenFirstName, - childrenLastName: row.childrenLastName, - childrenCareer: row.childrenCareer, - childrenLive: row.childrenLive, - childrenCitizenId: row.childrenCitizenId, + if (data.childrens.length > 0) { + let dataChild: childrenFamily[] = []; + data.childrens.map((row: childrenFamily, index: number) => { + dataChild.push({ + id: `${index + 1}`, + childrenPrefixId: row.childrenPrefixId, + childrenFirstName: row.childrenFirstName, + childrenLastName: row.childrenLastName, + childrenCareer: row.childrenCareer, + childrenLive: row.childrenLive, + childrenCitizenId: row.childrenCitizenId, + }); }); - }); - familyData.value.childrens = dataChild; - } else { - familyData.value.childrens = []; - } - }) - .catch((e) => { - messageError($q, e); - }) - .finally(async () => { - loaderPage(false); - }); + familyData.value.childrens = dataChild; + } else { + familyData.value.childrens = []; + } + }) + .catch((e) => { + messageError($q, e); + }) + .finally(async () => { + loaderPage(false); + }); + } }; const editData = async () => { diff --git a/src/modules/04_registry/components/Information/Information.vue b/src/modules/04_registry/components/Information/Information.vue index ad6287718..2ffe97cbb 100644 --- a/src/modules/04_registry/components/Information/Information.vue +++ b/src/modules/04_registry/components/Information/Information.vue @@ -962,44 +962,49 @@ const calRetire = async (birth: Date) => { }; const fetchData = async () => { - loaderPage(true); - await http - .get(config.API.profileInforId(route.params.id.toString())) - .then(async (res: any) => { - const data: ResponseObject = res.data.result; - defaultCitizenData.value = data.citizenId; - informaData.value.cardid = data.citizenId; - informaData.value.prefix = ""; - informaData.value.prefixId = data.prefixId; - informaData.value.firstname = data.firstName; - informaData.value.lastname = data.lastName; - informaData.value.birthDate = new Date(data.birthDate); - informaData.value.genderId = data.genderId; - informaData.value.bloodId = data.bloodGroupId; - informaData.value.nationality = data.nationality; - informaData.value.ethnicity = data.race; - informaData.value.statusId = data.relationshipId; - informaData.value.religionId = data.religionId; - informaData.value.tel = data.telephoneNumber; - informaData.value.age = data.age; - informaData.value.employeeType = data.employeeType; - informaData.value.employeeClass = data.employeeClass; - informaData.value.profileType = data.profileType; - dateBefore.value = new Date(data.birthDate); - same.value = data.changeName == true ? "1" : "0"; - await calRetire(new Date(dateToISO(new Date(data.birthDate)))); - if (data.profileType == "officer" && columnsHistory.value.length >= 15) { - columnsHistory.value.splice(13, 1); - columnsHistory.value.splice(12, 1); - } - }) - .catch((e) => { - messageError($q, e); - }) - .finally(async () => { - // loaderPage(false); - await props.fetchDataProfile(); - }); + if (route.params.id) { + loaderPage(true); + await http + .get(config.API.profileInforId(route.params.id.toString())) + .then(async (res: any) => { + const data: ResponseObject = res.data.result; + defaultCitizenData.value = data.citizenId; + informaData.value.cardid = data.citizenId; + informaData.value.prefix = ""; + informaData.value.prefixId = data.prefixId; + informaData.value.firstname = data.firstName; + informaData.value.lastname = data.lastName; + informaData.value.birthDate = new Date(data.birthDate); + informaData.value.genderId = data.genderId; + informaData.value.bloodId = data.bloodGroupId; + informaData.value.nationality = data.nationality; + informaData.value.ethnicity = data.race; + informaData.value.statusId = data.relationshipId; + informaData.value.religionId = data.religionId; + informaData.value.tel = data.telephoneNumber; + informaData.value.age = data.age; + informaData.value.employeeType = data.employeeType; + informaData.value.employeeClass = data.employeeClass; + informaData.value.profileType = data.profileType; + dateBefore.value = new Date(data.birthDate); + same.value = data.changeName == true ? "1" : "0"; + await calRetire(new Date(dateToISO(new Date(data.birthDate)))); + if ( + data.profileType == "officer" && + columnsHistory.value.length >= 15 + ) { + columnsHistory.value.splice(13, 1); + columnsHistory.value.splice(12, 1); + } + }) + .catch((e) => { + messageError($q, e); + }) + .finally(async () => { + // loaderPage(false); + await props.fetchDataProfile(); + }); + } }; const editData = async () => { diff --git a/src/modules/04_registry/components/Insignia.vue b/src/modules/04_registry/components/Insignia.vue index b3ebf22ec..efd170a76 100644 --- a/src/modules/04_registry/components/Insignia.vue +++ b/src/modules/04_registry/components/Insignia.vue @@ -527,7 +527,9 @@ const tittleHistory = ref("ประวัติแก้ไขเคร const filterHistory = ref(""); //search data table history const modalHistory = ref(false); //modal ประวัติการแก้ไขข้อมูล const checkValidate = ref(false); //validate data ผ่านหรือไม่ -const profileId = ref(route.params.id.toString()); +const profileId = ref( + route.params.id ? route.params.id.toString() : "" +); const rows = ref([]); const filter = ref(""); //search data table const visibleColumns = ref([]); diff --git a/src/modules/04_registry/components/Leave.vue b/src/modules/04_registry/components/Leave.vue index fc4d1ae29..2bed01b6d 100644 --- a/src/modules/04_registry/components/Leave.vue +++ b/src/modules/04_registry/components/Leave.vue @@ -444,7 +444,9 @@ const tittleHistory = ref("ประวัติแก้ไขการ const filterHistory = ref(""); //search data table history const modalHistory = ref(false); //modal ประวัติการแก้ไขข้อมูล const checkValidate = ref(false); //validate data ผ่านหรือไม่ -const profileId = ref(route.params.id.toString()); +const profileId = ref( + route.params.id ? route.params.id.toString() : "" +); const rows = ref([]); const filterTotal = ref(""); const rowsTotal = ref([]); //select data history diff --git a/src/modules/04_registry/components/Other.vue b/src/modules/04_registry/components/Other.vue index 9dd6f1094..08b75d635 100644 --- a/src/modules/04_registry/components/Other.vue +++ b/src/modules/04_registry/components/Other.vue @@ -213,7 +213,9 @@ const tittleHistory = ref("ประวัติแก้ไขอื่ const filterHistory = ref(""); //search data table history const modalHistory = ref(false); //modal ประวัติการแก้ไขข้อมูล const checkValidate = ref(false); //validate data ผ่านหรือไม่ -const profileId = ref(route.params.id.toString()); +const profileId = ref( + route.params.id ? route.params.id.toString() : "" +); const rows = ref([]); const filter = ref(""); //search data table const visibleColumns = ref([]); diff --git a/src/modules/04_registry/components/Salary.vue b/src/modules/04_registry/components/Salary.vue index e1e324155..e57d96705 100644 --- a/src/modules/04_registry/components/Salary.vue +++ b/src/modules/04_registry/components/Salary.vue @@ -909,7 +909,7 @@ const tittleHistory = ref("ประวัติแก้ไขตำแ const filterHistory = ref(""); //search data table history const modalHistory = ref(false); //modal ประวัติการแก้ไขข้อมูล const checkValidate = ref(false); //validate data ผ่านหรือไม่ -const profileId = ref(route.params.id.toString()); +const profileId = ref(route.params.id ? route.params.id.toString() : ""); const rows = ref([]); const filter = ref(""); //search data table const visibleColumns = ref([]); diff --git a/src/modules/04_registry/components/SalaryEmployee.vue b/src/modules/04_registry/components/SalaryEmployee.vue index f85c2e02a..51dddd43b 100644 --- a/src/modules/04_registry/components/SalaryEmployee.vue +++ b/src/modules/04_registry/components/SalaryEmployee.vue @@ -918,7 +918,7 @@ const tittleHistory = ref("ประวัติแก้ไขตำแ const filterHistory = ref(""); //search data table history const modalHistory = ref(false); //modal ประวัติการแก้ไขข้อมูล const checkValidate = ref(false); //validate data ผ่านหรือไม่ -const profileId = ref(route.params.id.toString()); +const profileId = ref(route.params.id ? route.params.id.toString() : ""); const rows = ref([]); const filter = ref(""); //search data table const visibleColumns = ref([]); diff --git a/src/modules/04_registry/components/SalaryEmployeeTemp.vue b/src/modules/04_registry/components/SalaryEmployeeTemp.vue index 64bc1f4de..a999160aa 100644 --- a/src/modules/04_registry/components/SalaryEmployeeTemp.vue +++ b/src/modules/04_registry/components/SalaryEmployeeTemp.vue @@ -941,7 +941,7 @@ const tittleHistory = ref("ประวัติแก้ไขตำแ const filterHistory = ref(""); //search data table history const modalHistory = ref(false); //modal ประวัติการแก้ไขข้อมูล const checkValidate = ref(false); //validate data ผ่านหรือไม่ -const profileId = ref(route.params.id.toString()); +const profileId = ref(route.params.id ? route.params.id.toString() : ""); const rows = ref([]); const filter = ref(""); //search data table const visibleColumns = ref([]); diff --git a/src/modules/04_registry/components/Talent.vue b/src/modules/04_registry/components/Talent.vue index 4f4b981b0..71d5f2e9e 100644 --- a/src/modules/04_registry/components/Talent.vue +++ b/src/modules/04_registry/components/Talent.vue @@ -213,7 +213,9 @@ const tittleHistory = ref("ประวัติแก้ไขควา const filterHistory = ref(""); //search data table history const modalHistory = ref(false); //modal ประวัติการแก้ไขข้อมูล const checkValidate = ref(false); //validate data ผ่านหรือไม่ -const profileId = ref(route.params.id.toString()); +const profileId = ref( + route.params.id ? route.params.id.toString() : "" +); const rows = ref([]); const filter = ref(""); //search data table const visibleColumns = ref([]); diff --git a/src/modules/04_registry/components/Train.vue b/src/modules/04_registry/components/Train.vue index 822494e7b..7593acf6a 100644 --- a/src/modules/04_registry/components/Train.vue +++ b/src/modules/04_registry/components/Train.vue @@ -459,7 +459,9 @@ const tittleHistory = ref("ประวัติแก้ไขการ const filterHistory = ref(""); //search data table history const modalHistory = ref(false); //modal ประวัติการแก้ไขข้อมูล const checkValidate = ref(false); //validate data ผ่านหรือไม่ -const profileId = ref(route.params.id.toString()); +const profileId = ref( + route.params.id ? route.params.id.toString() : "" +); const rows = ref([]); const filter = ref(""); //search data table const visibleColumns = ref([]); diff --git a/src/modules/04_registry/components/Work.vue b/src/modules/04_registry/components/Work.vue index c474f0597..bceac348e 100644 --- a/src/modules/04_registry/components/Work.vue +++ b/src/modules/04_registry/components/Work.vue @@ -356,7 +356,9 @@ const tittleHistory = ref("ประวัติแก้ไขปฏิ const filterHistory = ref(""); //search data table history const modalHistory = ref(false); //modal ประวัติการแก้ไขข้อมูล const checkValidate = ref(false); //validate data ผ่านหรือไม่ -const profileId = ref(route.params.id.toString()); +const profileId = ref( + route.params.id ? route.params.id.toString() : "" +); const rows = ref([]); const filter = ref(""); //search data table const visibleColumns = ref([]);