diff --git a/src/modules/15_probationReport/components/01_SurveyPage.vue b/src/modules/15_probationReport/components/01_SurveyPage.vue index f6fcaaf..f623bcc 100644 --- a/src/modules/15_probationReport/components/01_SurveyPage.vue +++ b/src/modules/15_probationReport/components/01_SurveyPage.vue @@ -45,6 +45,7 @@ async function getSurveyData() { .then(async (res: any) => { const data = await res.data.result.data; assignId.value = res.data.result.assignId; + store.assignId = res.data.result.assignId; if (data !== null) { answer1.value = data.answer1; answer2.value = data.answer2; diff --git a/src/modules/15_probationReport/components/02_ResultPage.vue b/src/modules/15_probationReport/components/02_ResultPage.vue index f5a4359..553f2c5 100644 --- a/src/modules/15_probationReport/components/02_ResultPage.vue +++ b/src/modules/15_probationReport/components/02_ResultPage.vue @@ -5,12 +5,13 @@ import { useRoute, useRouter } from "vue-router"; import http from "@/plugins/http"; import config from "@/app.config"; import { useQuasar } from "quasar"; +import { useProbationReport } from "@/modules/15_probationReport/store"; const mixin = useCounterMixin(); +const store = useProbationReport(); const { date2Thai, showLoader, hideLoader, messageError } = mixin; const route = useRoute(); -const assignId = ref("baa3d9f6-9d21-4c58-85f2-114abf8de25c"); const status = ref(false); const $q = useQuasar(); @@ -52,7 +53,7 @@ const result_option = reactive([ async function getReportScore() { showLoader(); await http - .get(config.API.summaryReportDetail(assignId.value)) + .get(config.API.summaryReportDetail(store.assignId)) .then((res) => { const data = res.data.result; develop_orientation_score.value = data.develop_orientation_score; @@ -95,8 +96,19 @@ async function getReportScore() { }); } +/** ดึง ข้อมูลแบบสำรวจ */ +async function getAssignId() { + await http.get(config.API.summaryDetail()).then(async (res: any) => { + store.assignId = res.data.result.assignId; + }); +} + /** get ค่า เมื่อโหลดหน้า */ -onMounted(() => { +onMounted(async () => { + if (!store.assignId) { + await getAssignId(); + } + getReportScore(); }); diff --git a/src/modules/15_probationReport/store.ts b/src/modules/15_probationReport/store.ts index 0d20211..8698668 100644 --- a/src/modules/15_probationReport/store.ts +++ b/src/modules/15_probationReport/store.ts @@ -4,5 +4,6 @@ import type { DataOption } from "@/modules/10_registry/interface/index/Main"; export const useProbationReport = defineStore("ProbationReportStore", () => { const tabMain = ref("SURVEY"); - return { tabMain }; + const assignId = ref(""); + return { tabMain, assignId }; });