fix fetch
This commit is contained in:
parent
1888ce2f8b
commit
6824988322
9 changed files with 111 additions and 61 deletions
|
|
@ -478,15 +478,17 @@ async function fetchProfileEvaluator(id: string) {
|
|||
|
||||
/** ดึงข้อมูลโปรไฟล์ */
|
||||
async function getProfile() {
|
||||
await http
|
||||
.get(config.API.profilePosition())
|
||||
.then(async (res) => {
|
||||
const data = await res.data.result;
|
||||
store.dataProfile = await data;
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
});
|
||||
if (store.dataProfile.profileId) {
|
||||
await http
|
||||
.get(config.API.profilePosition())
|
||||
.then(async (res) => {
|
||||
const data = await res.data.result;
|
||||
store.dataProfile = await data;
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function downloadReport() {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import http from "@/plugins/http";
|
|||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useKpiDataStore } from "@/modules/08_KPI/store";
|
||||
|
||||
import type { DataProfile } from "@/interface/Main";
|
||||
import type {
|
||||
DataOptions,
|
||||
MainListKpi,
|
||||
|
|
@ -285,26 +286,34 @@ function onSubmit() {
|
|||
}
|
||||
|
||||
/** ดึงข้อมูล */
|
||||
function getProfile() {
|
||||
http
|
||||
.get(config.API.profilePosition())
|
||||
.then(async (res) => {
|
||||
const data = await res.data.result;
|
||||
store.dataProfile = data;
|
||||
async function getProfile() {
|
||||
if (store.dataProfile.profileId) {
|
||||
assignProfileToForm(store.dataProfile);
|
||||
} else {
|
||||
await http
|
||||
.get(config.API.profilePosition())
|
||||
.then(async (res) => {
|
||||
const data = await res.data.result;
|
||||
store.dataProfile = data;
|
||||
assignProfileToForm(data);
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
formRound.profileId = data.profileId;
|
||||
formRound.prefix = data.prefix;
|
||||
formRound.firstName = data.firstName;
|
||||
formRound.lastName = data.lastName;
|
||||
formRound.position = data.position;
|
||||
formRound.posLevelName = data.posLevelName;
|
||||
formRound.posTypeName = data.posTypeName;
|
||||
formRound.posExecutiveName = data.posExecutiveName;
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {});
|
||||
function assignProfileToForm(profile: DataProfile) {
|
||||
formRound.profileId = profile.profileId ? profile.profileId : "";
|
||||
formRound.prefix = profile.prefix ? profile.prefix : "";
|
||||
formRound.firstName = profile.firstName ? profile.firstName : "";
|
||||
formRound.lastName = profile.lastName ? profile.lastName : "";
|
||||
formRound.position = profile.position ? profile.position : "";
|
||||
formRound.posLevelName = profile.posLevelName ? profile.posLevelName : "";
|
||||
formRound.posTypeName = profile.posTypeName ? profile.posTypeName : "";
|
||||
formRound.posExecutiveName = profile.posExecutiveName
|
||||
? profile.posExecutiveName
|
||||
: "";
|
||||
}
|
||||
|
||||
/** เช็ครอบการประเมิน ปิด */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue