diff --git a/src/modules/05_placement/components/probation/FormEvaluation/FormReport.vue b/src/modules/05_placement/components/probation/FormEvaluation/FormReport.vue index 7615798f8..b2b082108 100644 --- a/src/modules/05_placement/components/probation/FormEvaluation/FormReport.vue +++ b/src/modules/05_placement/components/probation/FormEvaluation/FormReport.vue @@ -88,6 +88,7 @@ const optionsResult = ref([ const props = defineProps({ tab: { type: String, require: true }, data: { type: Object, require: true }, + fetchData: { type: Function, require: true }, }); const isCheckFile = ref(false); @@ -98,11 +99,22 @@ const isCheckFile = ref(false); async function fecthAssign() { const data = props.data; + const foundData = props?.data?.result.find( + (e: any) => + (e.evaluate_no === 1 && props?.tab === "save1") || + (e.evaluate_no === 2 && props?.tab === "save2") + ); + + console.log(foundData); + + if (foundData) { + date_start.value = foundData.start_date; + date_finish.value = foundData.end_date; + } + assign.value = data?.assign; person.value = data?.person; mentors.value = data?.mentors; - date_start.value = data?.assign.date_start; - date_finish.value = data?.assign.date_finish; if ( data?.result.develop_complete != null && data?.result.evaluate_result != null @@ -118,40 +130,6 @@ async function fecthAssign() { } commander.value = data?.commander; optionDirector.value = mentors.value; - - // showLoader(); - // await http - // .get(config.API.evaluateReportcreate(id)) - // .then((res) => { - // assign.value = res.data.result.assign; - // person.value = res.data.result.person; - // mentors.value = res.data.result.mentors; - // date_start.value = res.data.result.assign.date_start; - // date_finish.value = res.data.result.assign.date_finish; - - // if ( - // res.data.result.result.develop_complete != null && - // res.data.result.result.evaluate_result != null - // ) { - // develop.value = res.data.result.result.develop_complete; - // result.value = res.data.result.result.evaluate_result; - // changeReson52(Number(res.data.result.result.evaluate_result)); - // } - - // director_id.value = res.data.result.chairman; - // director_id2.value = res.data.result.commander; - // if (mentors.value.length != 0) { - // director_id3.value = mentors.value[0]; - // } - // commander.value = res.data.result.commander; - // optionDirector.value = mentors.value; - // }) - // .catch((e) => { - // // messageError($q, e); - // }) - // .finally(() => { - // hideLoader(); - // }); } /** get ข้อมูล เก็บไว้ตัวแปร @@ -229,9 +207,10 @@ async function postData(action: string) { showLoader(); await http .post(config.API.createformReport(assignId.value), data) - .then(() => { + .then(async () => { + await props.fetchData?.(assignId.value); + // await fecthResult(assignId.value); success($q, "บันทึกสำเร็จ"); - fecthResult(assignId.value); router.push(`/probation/detail/${personalId.value}/${assignId.value}`); status.value = false; }) diff --git a/src/modules/05_placement/components/probation/FormEvaluation/Header.vue b/src/modules/05_placement/components/probation/FormEvaluation/Header.vue index cad752085..b99272c20 100644 --- a/src/modules/05_placement/components/probation/FormEvaluation/Header.vue +++ b/src/modules/05_placement/components/probation/FormEvaluation/Header.vue @@ -82,7 +82,18 @@ function nextPage() {
ครั้งที่ {{ i }}
import( @@ -48,6 +51,12 @@ async function fecthAssign(id: string) { tabs.value = res.data.result.result.map((e: any, index: number) => { return { no: index + 1, ...e }; }); + + const report1 = tabs.value.find((e) => e.evaluate_no === 1); + const report2 = tabs.value.find((e) => e.evaluate_no === 2); + + DataStore.isCheckFormReport1 = report1?.isResult ?? false; + DataStore.isCheckFormReport2 = report2?.isResult ?? false; }) .catch((e) => { messageError($q, e); @@ -119,7 +128,13 @@ onMounted(() => { class="mt" > - + diff --git a/src/modules/05_placement/storeProbation.ts b/src/modules/05_placement/storeProbation.ts index bda3edaae..b90f63c57 100644 --- a/src/modules/05_placement/storeProbation.ts +++ b/src/modules/05_placement/storeProbation.ts @@ -17,6 +17,8 @@ export const useProbationDataStore = defineStore("probationStore", () => { const assignOutput = ref([]); const director = ref([]); const person = ref([]); + const isCheckFormReport1 = ref(false); + const isCheckFormReport2 = ref(false); const fecthdataAssign = async (data: any) => { checkLoad.value = data.evaluate.length == 0 ? true : false; @@ -114,5 +116,7 @@ export const useProbationDataStore = defineStore("probationStore", () => { behavior_no3, dataPermissions, checkLoad, + isCheckFormReport1, + isCheckFormReport2, }; });