From e8eec83e17eb9acbd1b5c3918e0adcf39185d94f Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Tue, 15 Jul 2025 12:13:19 +0700 Subject: [PATCH] =?UTF-8?q?fix=20CurrentPage=20=20=3D=3D=3D>=20=E0=B8=A3?= =?UTF-8?q?=E0=B8=B2=E0=B8=A2=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=95=E0=B8=B1?= =?UTF-8?q?=E0=B8=A7=E0=B8=8A=E0=B8=B5=E0=B9=89=E0=B8=A7=E0=B8=B1=E0=B8=94?= =?UTF-8?q?=E0=B8=95=E0=B8=B2=E0=B8=A1=E0=B8=95=E0=B8=B3=E0=B9=81=E0=B8=AB?= =?UTF-8?q?=E0=B8=99=E0=B9=88=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Indicators/indicatorByRole/DetailView.vue | 128 ++++++++---------- .../01_masterdata/views/indicatorByRole.vue | 66 +++++---- 2 files changed, 97 insertions(+), 97 deletions(-) diff --git a/src/modules/01_masterdata/components/Indicators/indicatorByRole/DetailView.vue b/src/modules/01_masterdata/components/Indicators/indicatorByRole/DetailView.vue index c63aa27a3..7b0d923e7 100644 --- a/src/modules/01_masterdata/components/Indicators/indicatorByRole/DetailView.vue +++ b/src/modules/01_masterdata/components/Indicators/indicatorByRole/DetailView.vue @@ -8,8 +8,10 @@ import config from "@/app.config"; import { useCounterMixin } from "@/stores/mixin"; import { useStructureTree } from "@/stores/structureTree"; +import type { DataStructureTree } from "@/interface/main"; import type { FormDataRole } from "@/modules/01_masterdata/interface/request/Main"; import type { DataOption } from "@/modules/01_masterdata/interface/index/Main"; +import type { DataKPIPosition } from "@/modules/01_masterdata/interface/response/Main"; const $q = useQuasar(); const route = useRoute(); @@ -18,7 +20,7 @@ const { fetchStructureTree } = useStructureTree(); const heightSize = ref("224"); const filter = ref(""); -const node = ref([]); +const node = ref([]); const expanded = ref([]); const orgName = ref(""); const nodeId = ref(""); @@ -103,21 +105,20 @@ function filterOption(val: string, update: Function) { /** ดึงข้อมูลตำแหน่ง */ async function getOptions() { - // showLoader(); await http .get(config.API.orgSalaryPosition) .then((res) => { const dataOp = res.data.result; const uniqueNames = new Set(); const filteredData = dataOp - .filter((item: any) => { + .filter((item: DataKPIPosition) => { if (!uniqueNames.has(item.positionName)) { uniqueNames.add(item.positionName); return true; } return false; }) - .map((item: any) => ({ + .map((item: DataKPIPosition) => ({ id: item.positionName, name: item.positionName, })); @@ -126,17 +127,9 @@ async function getOptions() { }) .catch((e) => { messageError($q, e); - }) - .finally(() => { - // hideLoader(); }); } -/** เปิด Dialog หน่วยงาน */ -function selectAgency() { - modalDialogSelect.value = true; -} - /** บันทึกข้อมูล */ function onSubmit() { const url = id.value @@ -168,12 +161,14 @@ function onSubmit() { if (form.nodeId == null) { dialogMessageNotify($q, "กรุณาเลือกหน่วยงาน/ส่วนราชการ"); } else { - dialogConfirm($q, () => { + dialogConfirm($q, async () => { showLoader(); - http[id.value ? "put" : "post"](url, body) - .then(() => { + await http[id.value ? "put" : "post"](url, body) + .then(async () => { + id.value + ? await getDetail() + : router.push(`/masterdata/indicator-role`); success($q, "บันทึกสำเร็จ"); - id.value ? getDetail() : router.push(`/masterdata/indicator-role`); }) .catch((err) => { messageError($q, err); @@ -186,76 +181,73 @@ function onSubmit() { } async function getDetail() { - showLoader(); - await http - .get(config.API.kpiRoleMainEdit + `/${id.value}`) - .then(async (res) => { - const data = await res.data.result; - form.position = data.position; - form.year = data.year == null ? 0 : data.year; - form.round = data.round; - form.including = data.including; - form.includingName = data.includingName; - form.target = data.target; - form.unit = data.unit; - form.weight = data.weight; - form.meaning = data.meaning; - form.formula = data.formula; - form.documentInfoEvidence = data.documentInfoEvidence; - nodeDnaId.value = data.nodeDnaId; + if (id.value !== "") { + await http + .get(config.API.kpiRoleMainEdit + `/${id.value}`) + .then(async (res) => { + const data = await res.data.result; + form.position = data.position; + form.year = data.year == null ? 0 : data.year; + form.round = data.round; + form.including = data.including; + form.includingName = data.includingName; + form.target = data.target; + form.unit = data.unit; + form.weight = data.weight; + form.meaning = data.meaning; + form.formula = data.formula; + form.documentInfoEvidence = data.documentInfoEvidence; + nodeDnaId.value = data.nodeDnaId; - formScore.score1 = data.achievement1; - formScore.score2 = data.achievement2; - formScore.score3 = data.achievement3; - formScore.score4 = data.achievement4; - formScore.score5 = data.achievement5; + formScore.score1 = data.achievement1; + formScore.score2 = data.achievement2; + formScore.score3 = data.achievement3; + formScore.score4 = data.achievement4; + formScore.score5 = data.achievement5; - form.node = data.node; - form.nodeId = data.nodeId; - form.orgRevisionId = data.orgRevisionId; - const arrayExpanded = [ - data.root, - data.child1, - data.child2, - data.child3, - data.child4, - ]; - expanded.value = arrayExpanded.filter((e) => e !== null).slice(0, -1); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - hideLoader(); - }); + form.node = data.node; + form.nodeId = data.nodeId; + form.orgRevisionId = data.orgRevisionId; + const arrayExpanded = [ + data.root, + data.child1, + data.child2, + data.child3, + data.child4, + ]; + expanded.value = arrayExpanded.filter((e) => e !== null).slice(0, -1); + }) + .catch((e) => { + messageError($q, e); + }); + } } async function fetchStructure() { node.value = await fetchStructureTree(route.meta.Key as string, true); } -function updateSelected(data: any) { +function updateSelected(data: DataStructureTree) { nodeId.value = data.orgTreeId; orgName.value = data.orgTreeName; form.node = data.orgLevel; form.nodeId = data.orgTreeId; form.orgRevisionId = data.orgRevisionId; - nodeDnaId.value = data.orgTreeDnaId; + nodeDnaId.value = data.orgTreeDnaId ?? ""; } -function onResize(size: any) { +function onResize(size: { width: number; height: number }) { heightSize.value = `${size.height - 99}`; } -function setModel(val: string) { - form.position = val; -} +onMounted(async () => { + showLoader(); + try { + await Promise.all([fetchStructure(), getOptions()]); -onMounted(() => { - fetchStructure(); - getOptions(); - if (id.value !== "") { - getDetail(); + await getDetail(); + } finally { + hideLoader(); } }); @@ -295,7 +287,7 @@ onMounted(() => { class="inputgreen" :options="positionOp" use-input - @filter="(inputValue:any,doneFn:Function) => filterOption(inputValue, doneFn) " + @filter="(inputValue:string,doneFn:Function) => filterOption(inputValue, doneFn) " >