From bf4143ece4c0885f03ddeb7d0067cc1d042f0db0 Mon Sep 17 00:00:00 2001 From: setthawutttty Date: Thu, 31 Oct 2024 17:11:53 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=95=E0=B9=88=E0=B8=AD=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/probation/api.probation.ts | 1 + src/modules/15_probationReport/views/main.vue | 60 +++++++++---------- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/api/probation/api.probation.ts b/src/api/probation/api.probation.ts index 81f5742..274f2a1 100644 --- a/src/api/probation/api.probation.ts +++ b/src/api/probation/api.probation.ts @@ -22,6 +22,7 @@ export default { probationsGetAssign: (assignId: string) => `${probation}/assign/probation-assign?assign_id=${assignId}`, summarySurveyDetail: (id: string) => `${probation}/survey?assign_id=${id}`, + summaryDetail: () => `${probation}/survey`, saveEditAssign: (personalId: string) => `${probation}/assign/probation-assign?id=${personalId}`, saveFinish: (personalId: string) => diff --git a/src/modules/15_probationReport/views/main.vue b/src/modules/15_probationReport/views/main.vue index 5b2d002..ce8ab6e 100644 --- a/src/modules/15_probationReport/views/main.vue +++ b/src/modules/15_probationReport/views/main.vue @@ -38,9 +38,10 @@ const classBordered = ref(""); async function getSurveyData() { showLoader(); await http - .get(config.API.summarySurveyDetail(assignId.value)) + .get(config.API.summaryDetail()) .then(async (res: any) => { - const data = await res.data.data; + const data = await res.data.data.data; + assignId.value = res.data.data.assignId; if (data !== null) { answer1.value = data.answer1; answer2.value = data.answer2; @@ -56,33 +57,32 @@ async function getSurveyData() { /** save ข้อมูล */ async function save() { - await myForm.value!.validate().then((result: boolean) => { - if (result && answer3.value !== 0) { - const data = { - answer1: answer1.value, - answer2: answer2.value, - answer3: answer3.value, - }; - dialogConfirm($q, async () => { - showLoader(); - await http - .post(config.API.summarySurveyDetail(assignId.value), data) - .then((res: any) => { - success($q, "บันทึกสำเร็จ"); - getSurveyData(); - }) - .catch((e: any) => { - messageError($q, e); - }) - .finally(() => { - hideLoader(); - }); - }); - } else if (answer3.value == 0) { - classBordered.value = "border_custom"; - } - }); + if (answer3.value !== 0) { + const data = { + answer1: answer1.value, + answer2: answer2.value, + answer3: answer3.value, + }; + dialogConfirm($q, async () => { + showLoader(); + await http + .post(config.API.summarySurveyDetail(assignId.value), data) + .then((res: any) => { + success($q, "บันทึกสำเร็จ"); + getSurveyData(); + }) + .catch((e: any) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); + }); + } else if (answer3.value == 0) { + classBordered.value = "border_custom"; + } } + /** ถ้าเป็น 0 ใส่ class */ watch(answer3, () => { if (answer3.value == 0) { @@ -229,9 +229,9 @@ onMounted(() => { - + - + บันทึกข้อมูล