diff --git a/src/api/15_development/api.development.ts b/src/api/15_development/api.development.ts index c0e3329e7..f7649aa45 100644 --- a/src/api/15_development/api.development.ts +++ b/src/api/15_development/api.development.ts @@ -9,6 +9,8 @@ export default { /** history */ developmentHistoryList: (type: string) => `${development}/history/${type}/filter`, + developmentHistoryListByid: (type: string, id: string) => + `${development}/history/${type}/${id}`, developmentHistoryAdd: (type: string) => `${development}/history/${type}`, developmentProjectSearch: () => `${development}/main/search`, developmentHistoryListOrg: (type: string, year: number) => diff --git a/src/modules/15_development/components/BasicInfo.vue b/src/modules/15_development/components/BasicInfo.vue index 187812b5b..0ae8749a7 100644 --- a/src/modules/15_development/components/BasicInfo.vue +++ b/src/modules/15_development/components/BasicInfo.vue @@ -43,9 +43,9 @@ const node = ref([]); const filter = ref(""); const expanded = ref([]); -async function fetchData(id: string) { +function fetchData(id: string) { showLoader(); - await http + http .get(config.API.developmentMainTab("tab1", id)) .then(async (res) => { const data = res.data.result; @@ -60,8 +60,8 @@ async function fetchData(id: string) { if (nodeTree) { expanded.value = []; const parts = nodeTree?.orgName.split("/"); - for (let i = 0; i < parts.length; i++) { - const arrangedParts = parts[i - 1]; + for (let i = 1; i < parts.length; i++) { + const arrangedParts = parts[i]; expanded.value.push(arrangedParts); } updateSelected(nodeTree); @@ -137,17 +137,19 @@ function updateSelected(data: any) { formData.orgRevisionId = data.orgRevisionId; } -function searchAndReplace(orgTreeData: any, treeId: string | null) { - for (let orgTree of orgTreeData) { - if (orgTree.orgTreeId === treeId) { - return orgTree; - } - let foundOrg: any = searchAndReplace(orgTree.children, treeId); - if (foundOrg) { - return foundOrg; +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; } - return null; } onMounted(async () => { diff --git a/src/modules/15_development/components/history/AddPage.vue b/src/modules/15_development/components/history/AddPage.vue index a58694bfe..fd0edabba 100644 --- a/src/modules/15_development/components/history/AddPage.vue +++ b/src/modules/15_development/components/history/AddPage.vue @@ -95,7 +95,7 @@ function getClass() { /** save */ function onSubmit() { const url = id.value - ? config.API.developmentHistoryList("officer") + `${id.value}` + ? config.API.developmentHistoryListByid("officer", id.value) : config.API.developmentHistoryAdd("officer"); const body = { @@ -162,7 +162,7 @@ function upDateProject(data: any) { function getDataEdit() { showLoader(); http - .get(config.API.developmentHistoryList("officer") + `${id.value}`) + .get(config.API.developmentHistoryListByid("officer", id.value)) .then((res) => { const data = res.data.result; formMain.id = id.value; diff --git a/src/modules/15_development/components/historyEmployee/AddPage.vue b/src/modules/15_development/components/historyEmployee/AddPage.vue index 90a7776df..bdc937a19 100644 --- a/src/modules/15_development/components/historyEmployee/AddPage.vue +++ b/src/modules/15_development/components/historyEmployee/AddPage.vue @@ -94,7 +94,7 @@ function getClass() { /** save */ function onSubmit() { const url = id.value - ? config.API.developmentHistoryList("employee") + `${id.value}` + ? config.API.developmentHistoryListByid("employee", id.value) : config.API.developmentHistoryAdd("employee"); const body = { @@ -115,7 +115,7 @@ function onSubmit() { dialogConfirm($q, () => { showLoader(); http[id.value ? "put" : "post"](url, body) - .then((res) => { + .then(() => { router.push(`/development/employee-history`); }) .catch((e) => { @@ -150,7 +150,7 @@ function upDateProject(data: any) { function getDataEdit() { showLoader(); http - .get(config.API.developmentHistoryList("employee") + `${id.value}`) + .get(config.API.developmentHistoryListByid("employee", id.value)) .then((res) => { const data = res.data.result; formMain.id = id.value; diff --git a/src/modules/15_development/views/EmployeeHistory.vue b/src/modules/15_development/views/EmployeeHistory.vue index a18007bd0..9e1305eac 100644 --- a/src/modules/15_development/views/EmployeeHistory.vue +++ b/src/modules/15_development/views/EmployeeHistory.vue @@ -1,40 +1,19 @@ @@ -217,7 +208,7 @@ onMounted(() => { autoApply year-picker :enableTimePicker="false" - @update:model-value="getData()" + @update:model-value="fetchListOrg()" >