fix fetch
This commit is contained in:
parent
1888ce2f8b
commit
6824988322
9 changed files with 111 additions and 61 deletions
|
|
@ -2,6 +2,7 @@ import { defineStore } from "pinia";
|
|||
import { ref, reactive } from "vue";
|
||||
import type { DataOptions } from "./interface/index/Main";
|
||||
import type { FormQuery } from "@/modules/08_KPI/interface/request/index";
|
||||
import type { DataProfile } from "@/interface/Main";
|
||||
|
||||
export const useKpiDataStore = defineStore("KPIDate", () => {
|
||||
const mainRowData = ref<any>();
|
||||
|
|
@ -17,7 +18,7 @@ export const useKpiDataStore = defineStore("KPIDate", () => {
|
|||
const selected = ref([]);
|
||||
const work = ref<boolean>(false);
|
||||
const tabMain = ref<string>("");
|
||||
const dataProfile = ref<any>({
|
||||
const dataProfile = ref<DataProfile>({
|
||||
profileId: null,
|
||||
prefix: "",
|
||||
rank: "",
|
||||
|
|
|
|||
|
|
@ -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