ตัวชี้วัด => ปรับตัวชี้วัดตามแผนฯ
This commit is contained in:
parent
56c009cc8a
commit
9542bb2edc
1 changed files with 52 additions and 9 deletions
|
|
@ -43,7 +43,7 @@ const planData = reactive<any>({
|
||||||
const filter = ref<string>("");
|
const filter = ref<string>("");
|
||||||
const filterAgency = ref<string>("");
|
const filterAgency = ref<string>("");
|
||||||
const route = useRoute();
|
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 year = ref<number>(0);
|
||||||
|
|
||||||
const roundOp = ref<any[]>([]);
|
const roundOp = ref<any[]>([]);
|
||||||
|
|
@ -85,7 +85,6 @@ function fetchRoundOption(isId: number | null = null) {
|
||||||
: "",
|
: "",
|
||||||
}));
|
}));
|
||||||
roundOp.value = list;
|
roundOp.value = list;
|
||||||
console.log(isId);
|
|
||||||
|
|
||||||
if (isId) {
|
if (isId) {
|
||||||
planData.kpiPeriodId = "";
|
planData.kpiPeriodId = "";
|
||||||
|
|
@ -120,11 +119,26 @@ async function fetchDataTree(id: string) {
|
||||||
showLoader();
|
showLoader();
|
||||||
await http
|
await http
|
||||||
.get(config.API.orgByid(id.toString()))
|
.get(config.API.orgByid(id.toString()))
|
||||||
.then((res) => {
|
.then(async (res) => {
|
||||||
const data = res.data.result;
|
const data = res.data.result;
|
||||||
nodeAgency.value = data;
|
nodeAgency.value = data;
|
||||||
|
|
||||||
store.treeId = "";
|
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) => {
|
.catch((err) => {
|
||||||
messageError($q, err);
|
messageError($q, err);
|
||||||
|
|
@ -179,6 +193,8 @@ async function fetchDataById(id: any) {
|
||||||
planData.orgRevisionId = data.orgRevisionId;
|
planData.orgRevisionId = data.orgRevisionId;
|
||||||
planData.strategy = data.strategy;
|
planData.strategy = data.strategy;
|
||||||
planData.strategyId = data.strategyId;
|
planData.strategyId = data.strategyId;
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
fetchRoundOption();
|
fetchRoundOption();
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
|
@ -194,13 +210,19 @@ function updateSelected(data: any) {
|
||||||
planData.strategy = data.level;
|
planData.strategy = data.level;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateSelectedAgency(data: any) {
|
function updateSelectedAgency(data: any, isUpdate: boolean = false) {
|
||||||
if (planData.node === data.orgLevel && planData.nodeId === data.orgTreeId) {
|
if (
|
||||||
|
planData.node === data.orgLevel &&
|
||||||
|
planData.nodeId === data.orgTreeId &&
|
||||||
|
!isUpdate
|
||||||
|
) {
|
||||||
planData.node = null;
|
planData.node = null;
|
||||||
planData.nodeId = null;
|
planData.nodeId = null;
|
||||||
|
console.log("1");
|
||||||
} else {
|
} else {
|
||||||
planData.node = data.orgLevel;
|
planData.node = data.orgLevel;
|
||||||
planData.nodeId = data.orgTreeId;
|
planData.nodeId = data.orgTreeId;
|
||||||
|
console.log("2");
|
||||||
}
|
}
|
||||||
planData.orgRevisionId = data.orgRevisionId;
|
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 () => {
|
onMounted(async () => {
|
||||||
// fetchData();
|
// fetchData();
|
||||||
await fetchTree();
|
|
||||||
await fetchOrganizationActive();
|
await fetchOrganizationActive();
|
||||||
if (id.value !== undefined) {
|
if (id.value) {
|
||||||
editStatus.value = true;
|
editStatus.value = true;
|
||||||
fetchDataById(id.value);
|
fetchDataById(id.value);
|
||||||
}
|
}
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
store.activeId && (await fetchDataTree(store.activeId));
|
store.activeId && (await fetchDataTree(store.activeId));
|
||||||
|
await fetchTree();
|
||||||
}, 200);
|
}, 200);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -520,7 +563,7 @@ onMounted(async () => {
|
||||||
style="height: 350px; overflow: scroll"
|
style="height: 350px; overflow: scroll"
|
||||||
dense
|
dense
|
||||||
:nodes="nodeAgency"
|
:nodes="nodeAgency"
|
||||||
node-key="orgTreeId"
|
node-key="orgTreeName"
|
||||||
label-key="labelName"
|
label-key="labelName"
|
||||||
selected-color="primary"
|
selected-color="primary"
|
||||||
:filter="filterAgency"
|
:filter="filterAgency"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue