diff --git a/src/modules/14_KPI/components/competency/04ListCriteria.vue b/src/modules/14_KPI/components/competency/04ListCriteria.vue
index f78c0e2d3..b4cca12a9 100644
--- a/src/modules/14_KPI/components/competency/04ListCriteria.vue
+++ b/src/modules/14_KPI/components/competency/04ListCriteria.vue
@@ -55,7 +55,7 @@ function getData() {
http
.get(config.API.kpiEvaluation)
.then((res) => {
- dataLevel.value = res.data.result;
+ dataLevel.value = res.data.result.data;
})
.finally(() => {
hideLoader();
diff --git a/src/modules/14_KPI/components/competency/AddPage.vue b/src/modules/14_KPI/components/competency/AddPage.vue
index 22ae8abe1..a618ecb82 100644
--- a/src/modules/14_KPI/components/competency/AddPage.vue
+++ b/src/modules/14_KPI/components/competency/AddPage.vue
@@ -86,7 +86,7 @@ function onSubmit() {
class="q-mr-sm"
@click="router.go(-1)"
/>
- เพิ่มสมรรถนะ
+ เพิ่ม/แก้ไขสมรรถนะ
diff --git a/src/modules/14_KPI/components/indicatorByPlan/IndicatorByPlan.vue b/src/modules/14_KPI/components/indicatorByPlan/IndicatorByPlan.vue
index 132b65e0b..75d971a54 100644
--- a/src/modules/14_KPI/components/indicatorByPlan/IndicatorByPlan.vue
+++ b/src/modules/14_KPI/components/indicatorByPlan/IndicatorByPlan.vue
@@ -43,7 +43,7 @@ const planData = reactive({
const filter = ref("");
const filterAgency = ref("");
const route = useRoute();
-const id = ref(route.params.id.toString());
+const id = ref(route.params.id ? route.params.id.toLocaleString() : "");
const year = ref(0);
const roundOp = ref([]);
@@ -85,7 +85,6 @@ function fetchRoundOption(isId: number | null = null) {
: "",
}));
roundOp.value = list;
- console.log(isId);
if (isId) {
planData.kpiPeriodId = "";
@@ -120,11 +119,26 @@ async function fetchDataTree(id: string) {
showLoader();
await http
.get(config.API.orgByid(id.toString()))
- .then((res) => {
+ .then(async (res) => {
const data = res.data.result;
nodeAgency.value = data;
-
store.treeId = "";
+
+ if (nodeAgency.value && planData.nodeId) {
+ const nodeTree = await searchAndReplace(
+ nodeAgency.value,
+ planData.nodeId
+ );
+ if (nodeTree) {
+ expandedAgency.value = [];
+ const parts = nodeTree?.orgName.split("/");
+ for (let i = 1; i < parts.length; i++) {
+ const arrangedParts = parts[i];
+ expandedAgency.value.push(arrangedParts);
+ }
+ updateSelectedAgency(nodeTree, true);
+ }
+ }
})
.catch((err) => {
messageError($q, err);
@@ -179,6 +193,8 @@ async function fetchDataById(id: any) {
planData.orgRevisionId = data.orgRevisionId;
planData.strategy = data.strategy;
planData.strategyId = data.strategyId;
+ console.log(data);
+
fetchRoundOption();
})
.catch((err) => {
@@ -194,13 +210,19 @@ function updateSelected(data: any) {
planData.strategy = data.level;
}
-function updateSelectedAgency(data: any) {
- if (planData.node === data.orgLevel && planData.nodeId === data.orgTreeId) {
+function updateSelectedAgency(data: any, isUpdate: boolean = false) {
+ if (
+ planData.node === data.orgLevel &&
+ planData.nodeId === data.orgTreeId &&
+ !isUpdate
+ ) {
planData.node = null;
planData.nodeId = null;
+ console.log("1");
} else {
planData.node = data.orgLevel;
planData.nodeId = data.orgTreeId;
+ console.log("2");
}
planData.orgRevisionId = data.orgRevisionId;
}
@@ -234,16 +256,37 @@ async function editData(id: string) {
});
}
+/**
+ * function หาหน่วยงานที่รับผิดชอบ
+ * @param orgTreeData ข้อมูล nodeTree
+ * @param treeId tree ID
+ */
+async function searchAndReplace(orgTreeData: any, treeId: string | null) {
+ if (orgTreeData) {
+ for (let orgTree of orgTreeData) {
+ if (orgTree.orgTreeId === treeId) {
+ return orgTree;
+ }
+ let foundOrg: any = await searchAndReplace(orgTree.children, treeId);
+ if (foundOrg) {
+ return foundOrg;
+ }
+ }
+ return false;
+ }
+}
+
onMounted(async () => {
// fetchData();
- await fetchTree();
+
await fetchOrganizationActive();
- if (id.value !== undefined) {
+ if (id.value) {
editStatus.value = true;
fetchDataById(id.value);
}
setTimeout(async () => {
store.activeId && (await fetchDataTree(store.activeId));
+ await fetchTree();
}, 200);
});
@@ -520,7 +563,7 @@ onMounted(async () => {
style="height: 350px; overflow: scroll"
dense
:nodes="nodeAgency"
- node-key="orgTreeId"
+ node-key="orgTreeName"
label-key="labelName"
selected-color="primary"
:filter="filterAgency"
diff --git a/src/modules/14_KPI/components/indicatorByRole/DetailView.vue b/src/modules/14_KPI/components/indicatorByRole/DetailView.vue
index d0287e96e..3e1bc03e7 100644
--- a/src/modules/14_KPI/components/indicatorByRole/DetailView.vue
+++ b/src/modules/14_KPI/components/indicatorByRole/DetailView.vue
@@ -126,8 +126,7 @@ function onSubmit() {
const body = {
position: form.position, //ตำแหน่ง
- year: form.year, //ปีงบประมาณ
- round: form.round, //รอบการประเมิน(เมษา->APR, ตุลา->OCT)
+ kpiPeriodId: form.round, //รอบการประเมิน(เมษา->APR, ตุลา->OCT)
including: form.including, //รหัสตัวชี้วัด
includingName: form.includingName, //ชื่อตัวชี้วัด
target: form.target, //ค่าเป้าหมาย
@@ -165,7 +164,7 @@ function getDetail() {
.then((res) => {
const data = res.data.result;
form.position = data.position;
- form.year = data.year;
+ form.year = data.year == null ? 0:data.year;
form.round = data.round;
form.including = data.including;
form.includingName = data.includingName;
@@ -259,6 +258,7 @@ function getRound() {
});
}
+
function statusTothai(val: string) {
switch (val) {
case "SPECIAL":
@@ -273,9 +273,9 @@ function statusTothai(val: string) {
}
onMounted(() => {
- getRound()
fetchActive();
getOptions();
+ getRound()
if (id.value !== "") {
console.log("edit");
getDetail();
@@ -334,6 +334,7 @@ onMounted(() => {
autoApply
year-picker
:enableTimePicker="false"
+ @update:model-value="form.round = '',getRound()"
>
{{ year + 543 }}
{{
@@ -347,9 +348,10 @@ onMounted(() => {
hide-bottom-space
outlined
:model-value="
- form.year === null ? null : Number(form.year) + 543
+ form.year === 0 ? null : Number(form.year) + 543
"
:label="`${'ปีงบประมาณ'}`"
+
>
{
console.log(res);
@@ -306,6 +306,7 @@ onMounted(async () => {
option-value="id"
emit-value
map-options
+
@update:model-value="fetchList"
style="width: 200px;"
/>