diff --git a/src/modules/14_KPI/components/indicatorByPlan/IndicatorByPlan.vue b/src/modules/14_KPI/components/indicatorByPlan/IndicatorByPlan.vue index 590dbfdd6..c90313790 100644 --- a/src/modules/14_KPI/components/indicatorByPlan/IndicatorByPlan.vue +++ b/src/modules/14_KPI/components/indicatorByPlan/IndicatorByPlan.vue @@ -18,7 +18,14 @@ const route = useRoute(); const router = useRouter(); const store = usePositionEmp(); const mixin = useCounterMixin(); -const { dialogConfirm, showLoader, hideLoader, messageError, success } = mixin; +const { + dialogConfirm, + showLoader, + hideLoader, + messageError, + success, + dialogMessageNotify, +} = mixin; const id = ref(route.params.id ? route.params.id.toLocaleString() : ""); @@ -211,30 +218,37 @@ function updateSelectedAgency(data: any, isUpdate: boolean = false) { /**function ยืนยันการบันทึกข้อมูล */ function onSubmit() { - dialogConfirm( - $q, - async () => { - showLoader(); - // editStatus.value ? editData(id.value) : addData(); - try { - const url = editStatus.value - ? config.API.kpiPlanById(id.value) - : config.API.kpiPlan; - const method = editStatus.value ? "put" : "post"; - const res = await http[method](url, planData); - success($q, "บันทึกข้อมูลสำเร็จ"); - editStatus.value - ? fetchDataById(id.value) - : router.push(`/KPI-indicator-plan/${res.data.result}`); - } catch (e) { - messageError($q, e); - } finally { - hideLoader(); - } - }, - "ยืนยันการบันทึกข้อมูล", - "ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?" - ); + if (planData.nodeId == null || planData.strategyId == "") { + dialogMessageNotify( + $q, + `กรุณาเลือกหน่วยงาน/ส่วนราชการ หรือ ยุทธศาสตร์ / แผน` + ); + } else { + dialogConfirm( + $q, + async () => { + showLoader(); + // editStatus.value ? editData(id.value) : addData(); + try { + const url = editStatus.value + ? config.API.kpiPlanById(id.value) + : config.API.kpiPlan; + const method = editStatus.value ? "put" : "post"; + const res = await http[method](url, planData); + success($q, "บันทึกข้อมูลสำเร็จ"); + editStatus.value + ? fetchDataById(id.value) + : router.push(`/KPI-indicator-plan/${res.data.result}`); + } catch (e) { + messageError($q, e); + } finally { + hideLoader(); + } + }, + "ยืนยันการบันทึกข้อมูล", + "ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?" + ); + } } /**