diff --git a/src/modules/08_KPI/components/Tab/Dialog/DialogCommentProblem.vue b/src/modules/08_KPI/components/Tab/Dialog/DialogCommentProblem.vue index b8cb841..55bfe23 100644 --- a/src/modules/08_KPI/components/Tab/Dialog/DialogCommentProblem.vue +++ b/src/modules/08_KPI/components/Tab/Dialog/DialogCommentProblem.vue @@ -13,6 +13,9 @@ import type { import { useRoute } from "vue-router"; import { useQuasar } from "quasar"; +import { useKpiDataStore } from "@/modules/08_KPI/store"; + +const store = useKpiDataStore(); const $q = useQuasar(); const route = useRoute(); const id = ref(route.params.id as string); @@ -30,6 +33,7 @@ const modal = defineModel("modal", { required: true }); const type = defineModel("type", { required: true }); const idList = defineModel("idList", { required: true }); const modalAdd = ref(false); +const sendId = ref(""); const splitterModel = ref(40); const listTarget = ref([]); @@ -60,6 +64,9 @@ const formDataView = reactive({ let count = ref(0); function clickList(index: string, data: any) { + // if (data.status == "DRAFT") { + + // } listCheck.value = index as string; formDataView.id = data.id; @@ -86,22 +93,40 @@ function clickList(index: string, data: any) { }, 100); } +function onEdit(index: string, data: any) { + modalAdd.value = true; + sendId.value = data.id; + formDataAdd.topic = data.topic; + formDataAdd.reason = data.reason; +} + function onSubmitAdd() { dialogConfirm($q, () => { showLoader(); http .put( - config.API.kpiCommentP("problem", type.value+sendType.value, "user", idList.value), + config.API.kpiCommentP( + "problem", + type.value + sendType.value, + "user", + sendId.value ? sendId.value : idList.value + ), { reason: formDataAdd.reason, topic: formDataAdd.topic, } ) - .then((res) => { - console.log(res.data); + .then(async (res) => { success($q, "บันทึกข้อมูลสำเร็จ"); - getList(); - closeAdd(); + if (sendId.value) { + const id = res.data.result; + await closeAdd(); + const data = listTarget.value.find((item: any) => item.id == id); + clickList(id, data); + } else { + sendId.value = res.data.result; + getList(); + } }) .catch((e) => { messageError($q, e); @@ -130,6 +155,8 @@ function closeAdd() { modalAdd.value = false; formDataAdd.topic = ""; formDataAdd.reason = ""; + sendId.value = ""; + getList(); } function getList() { @@ -189,6 +216,28 @@ function onSubmitComment(role: string) { }); } +function statusText(val: string) { + switch (val) { + case "DRAFT": + return "แบบร่าง"; + case "EVALUATOR": + return "ผู้ประเมิน"; + case "COMMANDER": + return "ผู้บังคับบัญชาเหนือขึ้นไป"; + case "COMMANDERHIGH": + return "ผู้บังคับบัญชาเหนือขึ้นไปอีกขั้นหนึ่ง"; + case "DONE": + return "เสร็จสิ้น"; + + default: + return ""; + } +} + +function onNoti() { + listCheck.value = ""; + count.value = 0; +} watch( () => modal.value, () => { @@ -214,6 +263,7 @@ watch(