Merge commit '561e82dca2' into develop

This commit is contained in:
Tanyalak 2024-04-22 17:09:30 +07:00
commit 3f6fceab3c
5 changed files with 63 additions and 17 deletions

View file

@ -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();

View file

@ -86,7 +86,7 @@ function onSubmit() {
class="q-mr-sm"
@click="router.go(-1)"
/>
<span class="toptitle text-dark">เพสมรรถนะ</span>
<span class="toptitle text-dark">เพ/แกไขสมรรถนะ</span>
</div>
<q-card flat bordered>
<!-- @submit.prevent @validation-success="onSubmit" -->

View file

@ -43,7 +43,7 @@ const planData = reactive<any>({
const filter = ref<string>("");
const filterAgency = ref<string>("");
const route = useRoute();
const id = ref<string>(route.params.id.toString());
const id = ref<string>(route.params.id ? route.params.id.toLocaleString() : "");
const year = ref<number>(0);
const roundOp = ref<any[]>([]);
@ -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);
});
</script>
@ -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"

View file

@ -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()"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
@ -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="`${'ปีงบประมาณ'}`"
>
<template v-slot:prepend>
<q-icon

View file

@ -74,7 +74,7 @@ function fetchList() {
http
.get(
config.API.kpiRoleMainList +
`?page=${formFilter.page}&pageSize=${formFilter.pageSize}&kpiPeriodId=${formFilter.round}&position=${formFilter.position}`
`?page=${formFilter.page}&pageSize=${formFilter.pageSize}&kpiPeriodId=${formFilter.round}&position=${formFilter.position}&year=2024`
)
.then((res) => {
console.log(res);
@ -306,6 +306,7 @@ onMounted(async () => {
option-value="id"
emit-value
map-options
@update:model-value="fetchList"
style="width: 200px;"
/>