fix CurrentPage ===> รายการตัวชี้วัดตามตำแหน่ง

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-07-15 12:13:19 +07:00
parent 6db8040e90
commit e8eec83e17
2 changed files with 97 additions and 97 deletions

View file

@ -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<string>("224");
const filter = ref<string>("");
const node = ref<any>([]);
const node = ref<DataStructureTree[]>([]);
const expanded = ref<string[]>([]);
const orgName = ref<string>("");
const nodeId = ref<string>("");
@ -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();
}
});
</script>
@ -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) "
>
<template v-slot:no-option>
<q-item>