From 1e02f42b58b2a9b73588d0a07596293e29cfa264 Mon Sep 17 00:00:00 2001 From: Thanit Konmek Date: Fri, 7 Jul 2023 15:29:37 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=A5=E0=B8=B0?= =?UTF-8?q?=E0=B9=80=E0=B8=AD=E0=B8=B5=E0=B8=A2=E0=B8=94=E0=B8=97=E0=B8=B0?= =?UTF-8?q?=E0=B9=80=E0=B8=9A=E0=B8=B5=E0=B8=A2=E0=B8=99=E0=B8=9B=E0=B8=A3?= =?UTF-8?q?=E0=B8=B0=E0=B8=A7=E0=B8=B1=E0=B8=95=E0=B8=B4=E0=B8=A5=E0=B8=B9?= =?UTF-8?q?=E0=B8=81=E0=B8=88=E0=B9=89=E0=B8=B2=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../04_registry/components/Assessment.vue | 106 +- src/modules/04_registry/components/Coin.vue | 86 +- .../04_registry/components/Discipline.vue | 94 +- .../04_registry/components/Document.vue | 100 +- .../04_registry/components/Education.vue | 149 +-- .../components/Information/Address.vue | 155 ++- .../components/Information/Certicate.vue | 98 +- .../components/Information/Family.vue | 148 ++- .../components/Information/Information.vue | 226 ++-- .../components/Information/OldName.vue | 128 ++- .../components/Information/top.vue | 7 +- .../04_registry/components/Insignia.vue | 120 +- src/modules/04_registry/components/Leave.vue | 159 +-- src/modules/04_registry/components/Other.vue | 82 +- .../04_registry/components/Profile.vue | 88 +- src/modules/04_registry/components/Record.vue | 86 +- .../04_registry/components/SalaryEmployee.vue | 140 +-- src/modules/04_registry/components/Talent.vue | 98 +- src/modules/04_registry/components/Train.vue | 114 +- src/modules/04_registry/components/Work.vue | 90 +- .../04_registry/components/profileType.ts | 2 +- .../PersonalDetail/Information/Certicate.vue | 99 +- src/modules/08_registryEmployee/router.ts | 24 +- .../08_registryEmployee/views/Detail.vue | 1012 +++++++++++++++++ .../08_registryEmployee/views/Main.vue | 11 +- src/views/MainLayout.vue | 28 +- 26 files changed, 2419 insertions(+), 1031 deletions(-) create mode 100644 src/modules/08_registryEmployee/views/Detail.vue diff --git a/src/modules/04_registry/components/Assessment.vue b/src/modules/04_registry/components/Assessment.vue index c93364503..5f171a8d6 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([]); @@ -595,34 +597,36 @@ onMounted(async () => { }); const fetchData = async () => { - loaderPage(true); - await http - .get(config.API.profileAssessmentId(profileId.value)) - .then((res) => { - let data = res.data.result; - rows.value = []; - data.map((e: ResponseObject) => { - rows.value.push({ - id: e.id, - name: e.name, - point1Total: e.point1Total, - point1: e.point1, - point2Total: e.point2Total, - point2: e.point2, - pointSumTotal: e.pointSumTotal, - pointSum: e.pointSum, - date: new Date(e.date), - createdAt: new Date(e.createdAt), - createdFullName: e.createdFullName, + if (profileId.value !== "") { + loaderPage(true); + await http + .get(config.API.profileAssessmentId(profileId.value)) + .then((res) => { + let data = res.data.result; + rows.value = []; + data.map((e: ResponseObject) => { + rows.value.push({ + id: e.id, + name: e.name, + point1Total: e.point1Total, + point1: e.point1, + point2Total: e.point2Total, + point2: e.point2, + pointSumTotal: e.pointSumTotal, + pointSum: e.pointSum, + date: new Date(e.date), + createdAt: new Date(e.createdAt), + createdFullName: e.createdFullName, + }); }); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + loaderPage(false); }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - loaderPage(false); - }); + } }; /** @@ -712,29 +716,31 @@ const clickSave = async () => { * บันทึกเพิ่มข้อมูล */ const saveData = async () => { - loaderPage(true); - await http - .post(config.API.profileAssessmentId(profileId.value), { - id: id.value, - name: name.value, - point1Total: point1Total.value, - point1: point1.value, - point2Total: point2Total.value, - point2: point2.value, - pointSumTotal: pointSumTotal.value, - pointSum: pointSum.value, - date: dateToISO(date.value), - }) - .then((res) => { - success($q, "บันทึกข้อมูลสำเร็จ"); - modal.value = false; - }) - .catch((e) => { - messageError($q, e); - }) - .finally(async () => { - await fetchData(); - }); + if (profileId.value !== "") { + loaderPage(true); + await http + .post(config.API.profileAssessmentId(profileId.value), { + id: id.value, + name: name.value, + point1Total: point1Total.value, + point1: point1.value, + point2Total: point2Total.value, + point2: point2.value, + pointSumTotal: pointSumTotal.value, + pointSum: pointSum.value, + date: dateToISO(date.value), + }) + .then((res) => { + success($q, "บันทึกข้อมูลสำเร็จ"); + modal.value = false; + }) + .catch((e) => { + messageError($q, e); + }) + .finally(async () => { + await fetchData(); + }); + } }; /** diff --git a/src/modules/04_registry/components/Coin.vue b/src/modules/04_registry/components/Coin.vue index 84089f940..b30a37c71 100644 --- a/src/modules/04_registry/components/Coin.vue +++ b/src/modules/04_registry/components/Coin.vue @@ -244,7 +244,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([]); @@ -360,29 +362,31 @@ onMounted(async () => { }); const fetchData = async () => { - loaderPage(true); - await http - .get(config.API.profileHonorId(profileId.value)) - .then((res) => { - let data = res.data.result; - rows.value = []; - data.map((e: ResponseObject) => { - rows.value.push({ - id: e.id, - issuer: e.issuer, - detail: e.detail, - issueDate: new Date(e.issueDate), - createdAt: new Date(e.createdAt), - createdFullName: e.createdFullName, + if (profileId.value !== "") { + loaderPage(true); + await http + .get(config.API.profileHonorId(profileId.value)) + .then((res) => { + let data = res.data.result; + rows.value = []; + data.map((e: ResponseObject) => { + rows.value.push({ + id: e.id, + issuer: e.issuer, + detail: e.detail, + issueDate: new Date(e.issueDate), + createdAt: new Date(e.createdAt), + createdFullName: e.createdFullName, + }); }); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + loaderPage(false); }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - loaderPage(false); - }); + } }; /** @@ -467,24 +471,26 @@ const clickSave = async () => { * บันทึกเพิ่มข้อมูล */ const saveData = async () => { - loaderPage(true); - await http - .post(config.API.profileHonorId(profileId.value), { - id: id.value, - issuer: issuer.value, - detail: detail.value, - issueDate: dateToISO(issueDate.value), - }) - .then((res) => { - success($q, "บันทึกข้อมูลสำเร็จ"); - modal.value = false; - }) - .catch((e) => { - messageError($q, e); - }) - .finally(async () => { - await fetchData(); - }); + if (profileId.value !== "") { + loaderPage(true); + await http + .post(config.API.profileHonorId(profileId.value), { + id: id.value, + issuer: issuer.value, + detail: detail.value, + issueDate: dateToISO(issueDate.value), + }) + .then((res) => { + success($q, "บันทึกข้อมูลสำเร็จ"); + modal.value = false; + }) + .catch((e) => { + messageError($q, e); + }) + .finally(async () => { + await fetchData(); + }); + } }; /** diff --git a/src/modules/04_registry/components/Discipline.vue b/src/modules/04_registry/components/Discipline.vue index f4f0e8fd2..5571ad3fa 100644 --- a/src/modules/04_registry/components/Discipline.vue +++ b/src/modules/04_registry/components/Discipline.vue @@ -363,7 +363,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([]); @@ -545,31 +547,33 @@ const filterSelector = (val: string, update: Function, refData: string) => { }; const fetchData = async () => { - loaderPage(true); - await http - .get(config.API.profileDisId(profileId.value)) - .then((res) => { - let data = res.data.result; - rows.value = []; - data.map((e: ResponseObject) => { - rows.value.push({ - id: e.id, - level: e.level, - detail: e.detail, - refCommandNo: e.refCommandNo, - refCommandDate: new Date(e.refCommandDate), - date: new Date(e.date), - createdFullName: e.createdFullName, - createdAt: new Date(e.createdAt), + if (profileId.value !== "") { + loaderPage(true); + await http + .get(config.API.profileDisId(profileId.value)) + .then((res) => { + let data = res.data.result; + rows.value = []; + data.map((e: ResponseObject) => { + rows.value.push({ + id: e.id, + level: e.level, + detail: e.detail, + refCommandNo: e.refCommandNo, + refCommandDate: new Date(e.refCommandDate), + date: new Date(e.date), + createdFullName: e.createdFullName, + createdAt: new Date(e.createdAt), + }); }); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + loaderPage(false); }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - loaderPage(false); - }); + } }; /** @@ -656,26 +660,28 @@ const clickSave = async () => { * บันทึกเพิ่มข้อมูล */ const saveData = async () => { - loaderPage(true); - await http - .post(config.API.profileDisId(profileId.value), { - id: id.value, - level: level.value, - detail: detail.value, - refCommandNo: refCommandNo.value, - refCommandDate: dateToISO(refCommandDate.value), - date: dateToISO(date.value), - }) - .then((res) => { - success($q, "บันทึกข้อมูลสำเร็จ"); - modal.value = false; - }) - .catch((e) => { - messageError($q, e); - }) - .finally(async () => { - await fetchData(); - }); + if (profileId.value !== "") { + loaderPage(true); + await http + .post(config.API.profileDisId(profileId.value), { + id: id.value, + level: level.value, + detail: detail.value, + refCommandNo: refCommandNo.value, + refCommandDate: dateToISO(refCommandDate.value), + date: dateToISO(date.value), + }) + .then((res) => { + success($q, "บันทึกข้อมูลสำเร็จ"); + modal.value = false; + }) + .catch((e) => { + messageError($q, e); + }) + .finally(async () => { + await fetchData(); + }); + } }; /** diff --git a/src/modules/04_registry/components/Document.vue b/src/modules/04_registry/components/Document.vue index f539f31d9..12d9671b1 100644 --- a/src/modules/04_registry/components/Document.vue +++ b/src/modules/04_registry/components/Document.vue @@ -8,6 +8,7 @@ :changeBtn="changeBtn" :disable="statusEdit" :save="uploadData" + :addEmployee="statusAdd()" />
@@ -153,6 +154,10 @@ const props = defineProps({ type: Function, default: () => console.log("not function"), }, + statusAdd: { + type: Boolean, + default: false, + }, }); const emit = defineEmits(["update:statusEdit"]); @@ -162,7 +167,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([]); @@ -171,22 +178,37 @@ const name = ref(""); onMounted(async () => { await getData(); + defaultAdd(); }); const getData = async () => { - loaderPage(true); - await http - .get(config.API.profilePaperId(profileId.value)) - .then((res) => { - const data = res.data.result; - files.value = data; - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - loaderPage(false); - }); + if (profileId.value !== "") { + loaderPage(true); + await http + .get(config.API.profilePaperId(profileId.value)) + .then((res) => { + const data = res.data.result; + files.value = data; + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + loaderPage(false); + }); + } +}; + +const statusAdd = () => props.statusAdd; + +const defaultAdd = () => { + if (props.statusAdd) { + edit.value = props.statusAdd; + name.value = ""; + if (uploader.value !== null) { + uploader.value.reset(); + } + } }; const deleteData = async (id: string) => { @@ -206,31 +228,33 @@ const deleteData = async (id: string) => { const uploadData = async () => { if (file.value.length > 0) { - const blob = file.value.slice(0, file.value[0].size); - const newFile = new File(blob, name.value, { - type: file.value[0].type, - }); - const formData = new FormData(); - formData.append("avatar", newFile); - formData.append("moss", "newFile"); - console.log(formData); - loaderPage(true); - await http - .post(config.API.profilePaperId(profileId.value), formData) - .then((res) => { - const data = res.data.result; - success($q, "บันทึกข้อมูลสำเร็จ"); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(async () => { - uploader.value.reset(); - name.value = ""; - edit.value = false; - emit("update:statusEdit", false); - await getData(); + if (profileId.value !== "") { + const blob = file.value.slice(0, file.value[0].size); + const newFile = new File(blob, name.value, { + type: file.value[0].type, }); + const formData = new FormData(); + formData.append("avatar", newFile); + formData.append("moss", "newFile"); + console.log(formData); + loaderPage(true); + await http + .post(config.API.profilePaperId(profileId.value), formData) + .then((res) => { + const data = res.data.result; + success($q, "บันทึกข้อมูลสำเร็จ"); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(async () => { + uploader.value.reset(); + name.value = ""; + edit.value = false; + emit("update:statusEdit", false); + await getData(); + }); + } } else { // modalError( // $q, diff --git a/src/modules/04_registry/components/Education.vue b/src/modules/04_registry/components/Education.vue index c73e11aa6..83e947985 100644 --- a/src/modules/04_registry/components/Education.vue +++ b/src/modules/04_registry/components/Education.vue @@ -506,7 +506,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([]); @@ -960,42 +962,44 @@ const filterSelector = (val: any, update: Function, refData: string) => { }; const fetchData = async () => { - loaderPage(true); - await http - .get(config.API.profileEduId(profileId.value)) - .then((res) => { - let data = res.data.result; - rows.value = []; - data.map((e: ResponseObject) => { - rows.value.push({ - id: e.id, - level: e.educationLevel, - levelId: e.educationLevelId, - positionPath: e.positionPath, - positionPathId: e.positionPathId, - institute: e.institute, - degree: e.degree, - field: e.field, - gpa: e.gpa, - country: e.country, - duration: e.duration, - durationYear: e.durationYear, - other: e.other, - fundName: e.fundName, - finishDate: new Date(e.finishDate), - startDate: new Date(e.startDate).getFullYear(), - endDate: new Date(e.endDate).getFullYear(), - createdFullName: e.createdFullName, - createdAt: new Date(e.createdAt), + if (profileId.value !== "") { + loaderPage(true); + await http + .get(config.API.profileEduId(profileId.value)) + .then((res) => { + let data = res.data.result; + rows.value = []; + data.map((e: ResponseObject) => { + rows.value.push({ + id: e.id, + level: e.educationLevel, + levelId: e.educationLevelId, + positionPath: e.positionPath, + positionPathId: e.positionPathId, + institute: e.institute, + degree: e.degree, + field: e.field, + gpa: e.gpa, + country: e.country, + duration: e.duration, + durationYear: e.durationYear, + other: e.other, + fundName: e.fundName, + finishDate: new Date(e.finishDate), + startDate: new Date(e.startDate).getFullYear(), + endDate: new Date(e.endDate).getFullYear(), + createdFullName: e.createdFullName, + createdAt: new Date(e.createdAt), + }); }); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + loaderPage(false); }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - loaderPage(false); - }); + } }; /** @@ -1090,43 +1094,46 @@ const clickSave = async () => { /** * บันทึกเพิ่มข้อมูล */ + const saveData = async () => { - // const filter = OpsFilter.value.levelOptions.filter( - // (r: any) => r.id == levelId.value - // ); - // const filterPositionPath = OpsFilter.value.positionPathOptions.filter( - // (r: any) => r.id == positionPathId.value - // ); - loaderPage(true); - await http - .post(config.API.profileEduId(profileId.value), { - id: id.value, - // educationLevel: filter[0].name, - educationLevelId: levelId.value, - positionPathId: positionPathId.value, - institute: institute.value, - degree: degree.value, - field: field.value, - gpa: gpa.value, - country: country.value, - duration: duration.value, - durationYear: durationYear.value, - other: other.value, - fundName: fundName.value, - finishDate: dateToISO(finishDate.value), - startDate: new Date(`${startDate.value}-01-01`), - endDate: new Date(`${endDate.value}-01-01`), - }) - .then((res) => { - success($q, "บันทึกข้อมูลสำเร็จ"); - modal.value = false; - }) - .catch((e) => { - messageError($q, e); - }) - .finally(async () => { - await fetchData(); - }); + if (profileId.value !== "") { + // const filter = OpsFilter.value.levelOptions.filter( + // (r: any) => r.id == levelId.value + // ); + // const filterPositionPath = OpsFilter.value.positionPathOptions.filter( + // (r: any) => r.id == positionPathId.value + // ); + loaderPage(true); + await http + .post(config.API.profileEduId(profileId.value), { + id: id.value, + // educationLevel: filter[0].name, + educationLevelId: levelId.value, + positionPathId: positionPathId.value, + institute: institute.value, + degree: degree.value, + field: field.value, + gpa: gpa.value, + country: country.value, + duration: duration.value, + durationYear: durationYear.value, + other: other.value, + fundName: fundName.value, + finishDate: dateToISO(finishDate.value), + startDate: new Date(`${startDate.value}-01-01`), + endDate: new Date(`${endDate.value}-01-01`), + }) + .then((res) => { + success($q, "บันทึกข้อมูลสำเร็จ"); + modal.value = false; + }) + .catch((e) => { + messageError($q, e); + }) + .finally(async () => { + await fetchData(); + }); + } }; /** diff --git a/src/modules/04_registry/components/Information/Address.vue b/src/modules/04_registry/components/Information/Address.vue index 64f63ecf4..99192c26b 100644 --- a/src/modules/04_registry/components/Information/Address.vue +++ b/src/modules/04_registry/components/Information/Address.vue @@ -5,11 +5,12 @@ header="ข้อมูลที่อยู่" icon="mdi-map-marker" :save="saveData" - :history="true" + :history="!statusAdd()" :changeBtn="changeBtn" :disable="statusEdit" :cancel="refreshData" :historyClick="clickHistory" + :addEmployee="statusAdd()" />
@@ -311,6 +312,10 @@ const props = defineProps({ type: Boolean, required: true, }, + statusAdd: { + type: Boolean, + default: false, + }, }); const emit = defineEmits(["update:statusEdit"]); @@ -507,8 +512,28 @@ const visibleColumnsHistory = ref([ onMounted(async () => { await getNewData(); emit("update:statusEdit", false); + defaultAdd(); }); +const statusAdd = () => props.statusAdd; + +const defaultAdd = () => { + if (props.statusAdd) { + edit.value = props.statusAdd; + addressData.value = { + address: null, + provinceId: null, + districtId: null, + subdistrictId: null, + addressC: null, + provinceIdC: null, + districtIdC: null, + subdistrictIdC: null, + same: "0", + }; + } +}; + const filterSelector = (val: any, update: Function, refData: string) => { switch (refData) { case "provinceOps": @@ -556,37 +581,39 @@ const filterSelector = (val: any, update: Function, refData: string) => { * ฟังชั้นดูข้อมูลประวัติแก้ไขข้อมูลที่เลือก */ const clickHistory = async () => { - modalHistory.value = true; - loaderPage(true); - await http - .get(config.API.profileAdrsHisId(route.params.id.toString())) - .then((res) => { - let data = res.data.result; - rowsHistory.value = []; - data.map((e: RequestItemsHistoryObject) => { - rowsHistory.value.push({ - currentAddress: e.currentAddress, - currentDistrict: e.currentDistrict, - currentProvince: e.currentProvince, - currentSubDistrict: e.currentSubDistrict, - currentZipCode: e.currentZipCode, - registrationSame: e.registrationSame, - registrationAddress: e.registrationAddress, - registrationDistrict: e.registrationDistrict, - registrationProvince: e.registrationProvince, - registrationSubDistrict: e.registrationSubDistrict, - registrationZipCode: e.registrationZipCode, - createdFullName: e.createdFullName, - createdAt: new Date(e.createdAt), + if (route.params.id) { + modalHistory.value = true; + loaderPage(true); + await http + .get(config.API.profileAdrsHisId(route.params.id.toString())) + .then((res) => { + let data = res.data.result; + rowsHistory.value = []; + data.map((e: RequestItemsHistoryObject) => { + rowsHistory.value.push({ + currentAddress: e.currentAddress, + currentDistrict: e.currentDistrict, + currentProvince: e.currentProvince, + currentSubDistrict: e.currentSubDistrict, + currentZipCode: e.currentZipCode, + registrationSame: e.registrationSame, + registrationAddress: e.registrationAddress, + registrationDistrict: e.registrationDistrict, + registrationProvince: e.registrationProvince, + registrationSubDistrict: e.registrationSubDistrict, + registrationZipCode: e.registrationZipCode, + createdFullName: e.createdFullName, + createdAt: new Date(e.createdAt), + }); }); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + loaderPage(false); }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - loaderPage(false); - }); + } }; const refreshData = async () => { @@ -606,27 +633,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 () => { @@ -676,12 +705,34 @@ const editData = async () => { const saveData = async () => { await myform.value.validate().then(async (success: boolean) => { if (success) { - await editData(); + if (props.statusAdd) { + await addData(); + } else { + await editData(); + } } else { } }); }; +const addData = async () => { + // loaderPage(true); + // await http + // .put(config.API.profileInforId(route.params.id.toString()), body) + // .then((res) => { + // success($q, "บันทึกข้อมูลสำเร็จ"); + // }) + // .catch((e) => { + // messageError($q, e); + // }) + // .finally(async () => { + // edit.value = false; + // emit("update:statusEdit", false); + // await fetchData(); + // await changeBirth(informaData.value.birthDate ?? new Date()); + // }); +}; + const selectProvince = async (e: string | null, name: string) => { if (e != null) { if (name == "1") { diff --git a/src/modules/04_registry/components/Information/Certicate.vue b/src/modules/04_registry/components/Information/Certicate.vue index 721bf17c0..a2025677f 100644 --- a/src/modules/04_registry/components/Information/Certicate.vue +++ b/src/modules/04_registry/components/Information/Certicate.vue @@ -285,6 +285,10 @@ const props = defineProps({ type: String, required: true, }, + statusAdd: { + type: Boolean, + default: false, + }, }); const $q = useQuasar(); @@ -316,7 +320,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([]); @@ -484,31 +490,33 @@ onMounted(async () => { }); const fetchData = async () => { - loaderPage(true); - await http - .get(config.API.profileCertId(profileId.value)) - .then((res) => { - let data = res.data.result; - rows.value = []; - data.map((e: ResponseObject) => { - rows.value.push({ - id: e.id, - certificateNo: e.certificateNo, - issuer: e.issuer, - issueDate: new Date(e.issueDate), - expireDate: new Date(e.expireDate), - certificateType: e.certificateType, - createdFullName: e.createdFullName, - createdAt: new Date(e.createdAt), + if (profileId.value !== "") { + loaderPage(true); + await http + .get(config.API.profileCertId(profileId.value)) + .then((res) => { + let data = res.data.result; + rows.value = []; + data.map((e: ResponseObject) => { + rows.value.push({ + id: e.id, + certificateNo: e.certificateNo, + issuer: e.issuer, + issueDate: new Date(e.issueDate), + expireDate: new Date(e.expireDate), + certificateType: e.certificateType, + createdFullName: e.createdFullName, + createdAt: new Date(e.createdAt), + }); }); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + loaderPage(false); }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - loaderPage(false); - }); + } }; /** @@ -595,26 +603,28 @@ const clickSave = async () => { * บันทึกเพิ่มข้อมูล */ const saveData = async () => { - loaderPage(true); - await http - .post(config.API.profileCertId(profileId.value), { - id: id.value, - certificateNo: certificateNo.value, - issuer: issuer.value, - issueDate: dateToISO(issueDate.value), - expireDate: dateToISO(expireDate.value), - certificateType: certificateType.value, - }) - .then((res) => { - success($q, "บันทึกข้อมูลสำเร็จ"); - modal.value = false; - }) - .catch((e) => { - messageError($q, e); - }) - .finally(async () => { - await fetchData(); - }); + if (profileId.value !== "") { + loaderPage(true); + await http + .post(config.API.profileCertId(profileId.value), { + id: id.value, + certificateNo: certificateNo.value, + issuer: issuer.value, + issueDate: dateToISO(issueDate.value), + expireDate: dateToISO(expireDate.value), + certificateType: certificateType.value, + }) + .then((res) => { + success($q, "บันทึกข้อมูลสำเร็จ"); + modal.value = false; + }) + .catch((e) => { + messageError($q, e); + }) + .finally(async () => { + await fetchData(); + }); + } }; /** diff --git a/src/modules/04_registry/components/Information/Family.vue b/src/modules/04_registry/components/Information/Family.vue index b80ff9ede..d07de77a7 100644 --- a/src/modules/04_registry/components/Information/Family.vue +++ b/src/modules/04_registry/components/Information/Family.vue @@ -5,11 +5,12 @@ header="ข้อมูลครอบครัว" icon="mdi-account-group" :save="saveData" - :history="true" + :history="!statusAdd()" :changeBtn="changeBtn" :disable="statusEdit" :cancel="refreshData" :historyClick="historyData" + :addEmployee="statusAdd()" />
@@ -784,6 +785,10 @@ const props = defineProps({ type: Function, default: () => console.log("not function"), }, + statusAdd: { + type: Boolean, + default: false, + }, }); const emit = defineEmits(["update:statusEdit"]); @@ -835,8 +840,37 @@ onMounted(async () => { await fetchPrefix(); await fetchData(); emit("update:statusEdit", false); + defaultAdd(); }); +const statusAdd = () => props.statusAdd; + +const defaultAdd = () => { + if (props.statusAdd) { + edit.value = props.statusAdd; + familyData.value = { + prefixC: null, + prefixIdC: null, + firstnameC: null, + lastnameC: null, + lastnameCOld: null, + occupationC: null, + prefixM: null, + prefixIdM: null, + firstnameM: null, + lastnameM: null, + occupationM: null, + prefixF: null, + prefixIdF: null, + firstnameF: null, + lastnameF: null, + occupationF: null, + same: "0", + childrens: [], + }; + } +}; + const historyData = async () => { await fetchHistory(); }; @@ -955,53 +989,55 @@ 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.prefixM = ""; - familyData.value.prefixIdM = data.fatherPrefixId; + 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.prefixM = ""; + familyData.value.prefixIdM = data.fatherPrefixId; - familyData.value.firstnameM = data.fatherFirstName; - familyData.value.lastnameM = data.fatherLastName; - familyData.value.occupationM = data.fatherCareer; - familyData.value.prefixF = ""; - familyData.value.prefixIdF = data.motherPrefixId; + familyData.value.firstnameM = data.fatherFirstName; + familyData.value.lastnameM = data.fatherLastName; + familyData.value.occupationM = data.fatherCareer; + 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.same = data.couple ? "1" : "0"; + familyData.value.firstnameF = data.motherFirstName; + familyData.value.lastnameF = data.motherLastName; + familyData.value.occupationF = data.motherCareer; + 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, + 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, + }); }); - }); - 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 () => { @@ -1040,10 +1076,32 @@ const editData = async () => { }); }; +const addData = async () => { + // loaderPage(true); + // await http + // .put(config.API.profileInforId(route.params.id.toString()), body) + // .then((res) => { + // success($q, "บันทึกข้อมูลสำเร็จ"); + // }) + // .catch((e) => { + // messageError($q, e); + // }) + // .finally(async () => { + // edit.value = false; + // emit("update:statusEdit", false); + // await fetchData(); + // await changeBirth(informaData.value.birthDate ?? new Date()); + // }); +}; + const saveData = async () => { await myform.value?.validate().then(async (success: boolean) => { if (success) { - await editData(); + if (props.statusAdd) { + await addData(); + } else { + await editData(); + } } else { } }); diff --git a/src/modules/04_registry/components/Information/Information.vue b/src/modules/04_registry/components/Information/Information.vue index 13d630bf8..a73bf477b 100644 --- a/src/modules/04_registry/components/Information/Information.vue +++ b/src/modules/04_registry/components/Information/Information.vue @@ -5,11 +5,12 @@ header="ข้อมูลส่วนตัว" icon="mdi-account" :save="saveData" - :history="true" + :history="!statusAdd()" :changeBtn="changeBtn" :disable="statusEdit" :cancel="onCancel" :historyClick="clickHistory" + :addEmployee="statusAdd()" />
@@ -438,6 +439,10 @@ const props = defineProps({ type: Function, default: () => console.log("not function"), }, + statusAdd: { + type: Boolean, + default: false, + }, }); const emit = defineEmits(["update:statusEdit"]); @@ -692,8 +697,36 @@ onMounted(async () => { await fetchPerson(); await fetchData(); emit("update:statusEdit", false); + defaultAdd(); }); +const statusAdd = () => props.statusAdd; + +const defaultAdd = () => { + if (props.statusAdd) { + edit.value = props.statusAdd; + informaData.value = { + cardid: null, + age: null, + prefix: null, + prefixId: null, + firstname: null, + lastname: null, + birthDate: null, + genderId: null, + bloodId: null, + nationality: null, + ethnicity: null, + statusId: null, + religionId: null, + tel: null, + employeeType: null, + employeeClass: null, + profileType: null, + }; + } +}; + const onCancel = async () => { if (myform.value != null) { myform.value.reset(); @@ -821,50 +854,52 @@ const checkCitizen = async (id: string) => { * ฟังชั้นดูข้อมูลประวัติแก้ไขข้อมูลที่เลือก */ const clickHistory = async () => { - modalHistory.value = true; - loaderPage(true); - await http - .get(config.API.profileInforHisId(route.params.id.toString())) - .then((res) => { - let data = res.data.result; - rowsHistory.value = []; - data.map((e: RequestItemsHistoryObject) => { - rowsHistory.value.push({ - citizenId: e.citizenId, - prefix: e.prefix, - firstName: e.firstName, - lastName: e.lastName, - birthDate: new Date(e.birthDate), - gender: e.gender, - relationship: e.relationship, - bloodGroup: e.bloodGroup, - nationality: e.nationality, - race: e.race, - religion: e.religion, - telephoneNumber: e.telephoneNumber, - employeeType: - e.employeeType == "gov" - ? "งบประมาณเงินอุดหนุนรัฐบาล" - : e.employeeType == "bkk" - ? "งบประมาณกรุงเทพมหานคร" - : "-", - employeeClass: - e.employeeClass == "perm" - ? "ลูกจ้างประจำ" - : e.employeeClass == "temp" - ? "ลูกจ้างชั่วคราว" - : "-", - createdFullName: e.createdFullName, - createdAt: new Date(e.createdAt), + if (route.params.id) { + modalHistory.value = true; + loaderPage(true); + await http + .get(config.API.profileInforHisId(route.params.id.toString())) + .then((res) => { + let data = res.data.result; + rowsHistory.value = []; + data.map((e: RequestItemsHistoryObject) => { + rowsHistory.value.push({ + citizenId: e.citizenId, + prefix: e.prefix, + firstName: e.firstName, + lastName: e.lastName, + birthDate: new Date(e.birthDate), + gender: e.gender, + relationship: e.relationship, + bloodGroup: e.bloodGroup, + nationality: e.nationality, + race: e.race, + religion: e.religion, + telephoneNumber: e.telephoneNumber, + employeeType: + e.employeeType == "gov" + ? "งบประมาณเงินอุดหนุนรัฐบาล" + : e.employeeType == "bkk" + ? "งบประมาณกรุงเทพมหานคร" + : "-", + employeeClass: + e.employeeClass == "perm" + ? "ลูกจ้างประจำ" + : e.employeeClass == "temp" + ? "ลูกจ้างชั่วคราว" + : "-", + createdFullName: e.createdFullName, + createdAt: new Date(e.createdAt), + }); }); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + loaderPage(false); }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - loaderPage(false); - }); + } }; const filterSelector = (val: any, update: Function, refData: string) => { @@ -961,44 +996,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 () => { @@ -1039,11 +1079,33 @@ const editData = async () => { }); }; +const addData = async () => { + // loaderPage(true); + // await http + // .put(config.API.profileInforId(route.params.id.toString()), body) + // .then((res) => { + // success($q, "บันทึกข้อมูลสำเร็จ"); + // }) + // .catch((e) => { + // messageError($q, e); + // }) + // .finally(async () => { + // edit.value = false; + // emit("update:statusEdit", false); + // await fetchData(); + // await changeBirth(informaData.value.birthDate ?? new Date()); + // }); +}; + const saveData = async () => { if (myform.value != null) { await myform.value.validate().then(async (success: boolean) => { if (success) { - await editData(); + if (props.statusAdd) { + await addData(); + } else { + await editData(); + } } else { } }); diff --git a/src/modules/04_registry/components/Information/OldName.vue b/src/modules/04_registry/components/Information/OldName.vue index f82dd50c4..62bf2056b 100644 --- a/src/modules/04_registry/components/Information/OldName.vue +++ b/src/modules/04_registry/components/Information/OldName.vue @@ -362,7 +362,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 file = ref(null); const fileUpload = ref([]); const rows = ref([]); @@ -538,32 +540,34 @@ onMounted(async () => { }); const fetchData = async () => { - loaderPage(true); - await http - .get(config.API.profileChangeNameId(profileId.value)) - .then((res) => { - let data = res.data.result; - rows.value = []; - data.map((e: ResponseObject) => { - rows.value.push({ - id: e.id, - prefix: e.prefix, - prefixId: e.prefixId, - firstName: e.firstName, - lastName: e.lastName, - status: e.status, - file: e.file, - createdFullName: e.createdFullName, - createdAt: new Date(e.createdAt), + if (profileId.value !== "") { + loaderPage(true); + await http + .get(config.API.profileChangeNameId(profileId.value)) + .then((res) => { + let data = res.data.result; + rows.value = []; + data.map((e: ResponseObject) => { + rows.value.push({ + id: e.id, + prefix: e.prefix, + prefixId: e.prefixId, + firstName: e.firstName, + lastName: e.lastName, + status: e.status, + file: e.file, + createdFullName: e.createdFullName, + createdAt: new Date(e.createdAt), + }); }); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + loaderPage(false); }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - loaderPage(false); - }); + } }; /** @@ -665,44 +669,19 @@ const clickSave = async () => { if (modalEdit.value) { await editData(); } else { - await saveData(); + await checkSave(); } } }); }; -/** - * บันทึกเพิ่มข้อมูล - */ -const saveData = async () => { +const checkSave = async () => { if (fileUpload.value.length > 0) { - const blob = fileUpload.value.slice(0, fileUpload.value[0].size); - const newFile = new File(blob, nameFile.value, { - type: fileUpload.value[0].type, - }); - const formData = new FormData(); - formData.append("", newFile); - if (prefixId.value != undefined) - formData.append("prefixId", prefixId.value); - if (firstName.value != undefined) - formData.append("firstName", firstName.value); - if (lastName.value != undefined) - formData.append("lastName", lastName.value); - if (status.value != undefined) formData.append("status", status.value); - loaderPage(true); - await http - .post(config.API.profileChangeNameId(profileId.value), formData) - .then((res) => { - success($q, "บันทึกข้อมูลสำเร็จ"); - modal.value = false; - }) - .catch((e) => { - messageError($q, e); - }) - .finally(async () => { - await fetchData(); - await props.fetchDataInformation(); - }); + if (profileId.value !== "") { + await saveData(); + } else { + await saveDataEmployee(); + } } else { dialogMessage( $q, @@ -718,6 +697,41 @@ const saveData = async () => { } }; +/** + * บันทึกเพิ่มข้อมูล + */ +const saveData = async () => { + const blob = fileUpload.value.slice(0, fileUpload.value[0].size); + const newFile = new File(blob, nameFile.value, { + type: fileUpload.value[0].type, + }); + const formData = new FormData(); + formData.append("", newFile); + if (prefixId.value != undefined) formData.append("prefixId", prefixId.value); + if (firstName.value != undefined) + formData.append("firstName", firstName.value); + if (lastName.value != undefined) formData.append("lastName", lastName.value); + if (status.value != undefined) formData.append("status", status.value); + loaderPage(true); + await http + .post(config.API.profileChangeNameId(profileId.value), formData) + .then((res) => { + success($q, "บันทึกข้อมูลสำเร็จ"); + modal.value = false; + }) + .catch((e) => { + messageError($q, e); + }) + .finally(async () => { + await fetchData(); + await props.fetchDataInformation(); + }); +}; + +const saveDataEmployee = async () => { + console.log("saveDataEmployee"); +}; + /** * บันทึกแก้ไขข้อมูล */ diff --git a/src/modules/04_registry/components/Information/top.vue b/src/modules/04_registry/components/Information/top.vue index 2a8221cf9..157698119 100644 --- a/src/modules/04_registry/components/Information/top.vue +++ b/src/modules/04_registry/components/Information/top.vue @@ -43,7 +43,7 @@ size="12px" flat round - v-if="edit" + v-if="edit && !addEmployee" :color="!edit ? 'grey-7' : 'red'" @click="ClickCancel" icon="mdi-undo" @@ -125,6 +125,7 @@ const props = defineProps({ type: Boolean, defualt: false, }, + disable: { type: Boolean, defualt: false, @@ -157,6 +158,10 @@ const props = defineProps({ type: Function, default: () => console.log("not function"), }, + addEmployee: { + type: Boolean, + defualt: false, + }, }); const emit = defineEmits(["update:edit"]); diff --git a/src/modules/04_registry/components/Insignia.vue b/src/modules/04_registry/components/Insignia.vue index 641800865..a025efc25 100644 --- a/src/modules/04_registry/components/Insignia.vue +++ b/src/modules/04_registry/components/Insignia.vue @@ -454,7 +454,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([]); @@ -816,38 +818,40 @@ const fetchInsignia = async () => { }; const fetchData = async () => { - loaderPage(true); - await http - .get(config.API.profileInsignId(profileId.value)) - .then((res) => { - let data = res.data.result; - rows.value = []; - data.map((e: ResponseObject) => { - rows.value.push({ - id: e.id, - insignia: e.insignia, - insigniaId: e.insigniaId, - insigniaType: e.insigniaType, - year: e.year, - no: e.no, - issue: e.issue, - volumeNo: e.volumeNo, - volume: e.volume, - section: e.section, - page: e.page, - receiveDate: new Date(e.receiveDate), - dateAnnounce: new Date(e.dateAnnounce), - createdFullName: e.createdFullName, - createdAt: new Date(e.createdAt), + if (profileId.value !== "") { + loaderPage(true); + await http + .get(config.API.profileInsignId(profileId.value)) + .then((res) => { + let data = res.data.result; + rows.value = []; + data.map((e: ResponseObject) => { + rows.value.push({ + id: e.id, + insignia: e.insignia, + insigniaId: e.insigniaId, + insigniaType: e.insigniaType, + year: e.year, + no: e.no, + issue: e.issue, + volumeNo: e.volumeNo, + volume: e.volume, + section: e.section, + page: e.page, + receiveDate: new Date(e.receiveDate), + dateAnnounce: new Date(e.dateAnnounce), + createdFullName: e.createdFullName, + createdAt: new Date(e.createdAt), + }); }); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + loaderPage(false); }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - loaderPage(false); - }); + } }; /** @@ -940,32 +944,34 @@ const clickSave = async () => { * บันทึกเพิ่มข้อมูล */ const saveData = async () => { - loaderPage(true); - await http - .post(config.API.profileInsignId(profileId.value), { - id: id.value, - insigniaId: insigniaId.value, - insigniaType: insigniaType.value, - year: year.value, - no: no.value, - issue: issue.value, - volumeNo: volumeNo.value, - volume: volume.value, - section: section.value, - page: page.value, - receiveDate: dateToISO(receiveDate.value), - dateAnnounce: dateToISO(dateAnnounce.value), - }) - .then((res) => { - success($q, "บันทึกข้อมูลสำเร็จ"); - modal.value = false; - }) - .catch((e) => { - messageError($q, e); - }) - .finally(async () => { - await fetchData(); - }); + if (profileId.value !== "") { + loaderPage(true); + await http + .post(config.API.profileInsignId(profileId.value), { + id: id.value, + insigniaId: insigniaId.value, + insigniaType: insigniaType.value, + year: year.value, + no: no.value, + issue: issue.value, + volumeNo: volumeNo.value, + volume: volume.value, + section: section.value, + page: page.value, + receiveDate: dateToISO(receiveDate.value), + dateAnnounce: dateToISO(dateAnnounce.value), + }) + .then((res) => { + success($q, "บันทึกข้อมูลสำเร็จ"); + modal.value = false; + }) + .catch((e) => { + messageError($q, e); + }) + .finally(async () => { + await fetchData(); + }); + } }; /** diff --git a/src/modules/04_registry/components/Leave.vue b/src/modules/04_registry/components/Leave.vue index aef5b92aa..37acb3bf6 100644 --- a/src/modules/04_registry/components/Leave.vue +++ b/src/modules/04_registry/components/Leave.vue @@ -263,11 +263,7 @@ > + diff --git a/src/modules/08_registryEmployee/views/Main.vue b/src/modules/08_registryEmployee/views/Main.vue index f2ffa8b03..c1c465c70 100644 --- a/src/modules/08_registryEmployee/views/Main.vue +++ b/src/modules/08_registryEmployee/views/Main.vue @@ -169,6 +169,7 @@ import { ref, onMounted } from "vue"; import { useQuasar } from "quasar"; import { useCounterMixin } from "@/stores/mixin"; import type { QInput, QForm } from "quasar"; +import { useRouter } from "vue-router"; import http from "@/plugins/http"; import config from "@/app.config"; @@ -187,6 +188,7 @@ const $q = useQuasar(); const mixin = useCounterMixin(); //เรียกฟังก์ชันกลาง const { dialogMessage, messageError, showLoader, hideLoader } = mixin; +const router = useRouter(); const myForm = ref(); const filterRef = ref(); const filter = ref(""); @@ -488,6 +490,10 @@ onMounted(async () => { await nodeTree(); }); +const next = (id: string) => { + router.push(`/registryEmployee/${id}`); +}; + const paginationLabel = (start: number, end: number, total: number) => { // if (props.paging == true) // return " " + start + " ใน " + end + " จากจำนวน " + total + " รายการ"; @@ -528,7 +534,10 @@ const clickClose = async () => { }; const clickAdd = () => { - modal.value = true; + // modal.value = true; + + router.push(`/registryEmployee/add`); + // router.push(`/placement/detail`); }; const clickDelete = (id: string) => { diff --git a/src/views/MainLayout.vue b/src/views/MainLayout.vue index f3794c327..270be3495 100644 --- a/src/views/MainLayout.vue +++ b/src/views/MainLayout.vue @@ -68,7 +68,7 @@ const options = ref([ * ให้แสดง แทปด้านขวา เมื่อเข้าหน้า รายละเอียดทะเบียนประวัติ */ const tabScroll = () => { - return route.name == "registryDetail"; + return route.name == "registryDetail" || route.name == "registryEmployeeAdd"; }; /** @@ -96,8 +96,11 @@ const toggleBtnLeft = () => { */ const onScroll = (scroll: ScrollType) => { const { position } = scroll; - updateScroll(position); - updateScrollPlacement(position); + if (route.name == "PlacementPersonalDetail") { + updateScrollPlacement(position); + } else { + updateScroll(position); + } }; /** @@ -154,7 +157,10 @@ const updateScroll = (position: number) => { * ให้แสดง แทปด้านขวา เมื่อเข้าหน้า รายละเอียดทะเบียนประวัติ และ rightActive เท่ากับ true */ const activeBtn = () => { - return route.name == "registryDetail" && rightActive.value; + return ( + (route.name == "registryDetail" || route.name == "registryEmployeeAdd") && + rightActive.value + ); }; /** @@ -218,6 +224,9 @@ const myEventHandler = (e: any, setSCroll: boolean) => { */ const activeMenu = (path: string) => { if (path == "dashboard" && route.fullPath == "/") return true; + + if (path == "registry" && route.fullPath.includes("registryEmployee")) + return false; const bool = route.fullPath.includes(path); return bool; }; @@ -780,9 +789,9 @@ if (keycloak.tokenParsed != null) {