ตัวชี้วัด => ปรับตัวชี้วัดตามแผนฯ
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 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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue