diff --git a/src/api/probation/api.probation.ts b/src/api/probation/api.probation.ts index fdd102b..003d1eb 100644 --- a/src/api/probation/api.probation.ts +++ b/src/api/probation/api.probation.ts @@ -57,4 +57,6 @@ export default { `${reportProbation}/14/${type}/${id}`, kpiCapacity, + + appointMainList: (id: string) => `${probation}/appoint/list/${id}`, }; diff --git a/src/interface/Main.ts b/src/interface/Main.ts index d330ce4..6c3f1f5 100644 --- a/src/interface/Main.ts +++ b/src/interface/Main.ts @@ -8,6 +8,7 @@ interface ProfileData { posTypeName: string; posLevelName: string; posNo: string; + profileId: string; } interface InformationData { diff --git a/src/modules/15_probationReport/components/01_SurveyPage.vue b/src/modules/15_probationReport/components/01_SurveyPage.vue index 6a06c7a..57456f5 100644 --- a/src/modules/15_probationReport/components/01_SurveyPage.vue +++ b/src/modules/15_probationReport/components/01_SurveyPage.vue @@ -10,6 +10,7 @@ import config from "@/app.config"; import { useProbationReport } from "@/modules/15_probationReport/store"; import type { ListDataText } from "@/modules/15_probationReport/interface/Main"; +import type { DataSurvey } from "@/modules/15_probationReport/interface/Main"; const store = useProbationReport(); const router = useRouter(); @@ -28,8 +29,13 @@ const mixin = useCounterMixin(); const { messageError, success, dialogConfirm, showLoader, hideLoader } = mixin; const route = useRoute(); -const assignId = ref("baa3d9f6-9d21-4c58-85f2-114abf8de25c"); +const props = defineProps({ + dataSurvey: Object, + getSurveyData: Function, +}); const isData = defineModel("isData", { required: true }); +const dataSurvey = defineModel("dataSurvey", { required: true }); + const status = ref(true); const answer1 = ref(""); @@ -38,32 +44,6 @@ const answer3 = ref(0); const classBordered = ref(""); -/** ดึง ข้อมูลแบบสำรวจ */ -async function getSurveyData() { - isData.value = true; - showLoader(); - await http - .get(config.API.summaryDetail()) - .then(async (res: any) => { - const data = await res.data.result.data; - isData.value = true; - assignId.value = res.data.result.assignId; - store.assignId = res.data.result.assignId; - if (data !== null) { - answer1.value = data.answer1; - answer2.value = data.answer2; - answer3.value = data.answer3; - status.value = false; - } - hideLoader(); - }) - .catch((e) => { - // messageError($q, e); - isData.value = false; - hideLoader(); - }); -} - /** save ข้อมูล */ async function save() { if (answer3.value !== 0) { @@ -75,10 +55,10 @@ async function save() { dialogConfirm($q, async () => { showLoader(); await http - .post(config.API.summarySurveyDetail(assignId.value), data) + .post(config.API.summarySurveyDetail(store.assignId), data) .then((res: any) => { success($q, "บันทึกสำเร็จ"); - getSurveyData(); + props.getSurveyData?.(); }) .catch((e: any) => { messageError($q, e); @@ -99,11 +79,31 @@ watch(answer3, () => { } else classBordered.value = ""; }); +watch( + () => dataSurvey.value, + () => { + if (store.tabMain === "SURVEY") { + if (dataSurvey.value !== null) { + answer1.value = dataSurvey.value.answer1; + answer2.value = dataSurvey.value.answer2; + answer3.value = dataSurvey.value.answer3; + status.value = false; + } + } + } +); + + /** get ค่า เมื่อโหลดหน้า */ onMounted(() => { if (store.tabMain === "SURVEY") { - getSurveyData(); - } + if (dataSurvey.value !== null) { + answer1.value = dataSurvey.value.answer1; + answer2.value = dataSurvey.value.answer2; + answer3.value = dataSurvey.value.answer3; + status.value = false; + } + } });