fix fetch
This commit is contained in:
parent
1888ce2f8b
commit
6824988322
9 changed files with 111 additions and 61 deletions
|
|
@ -10,7 +10,7 @@ interface ProfileData {
|
|||
posNo: string;
|
||||
profileId: string;
|
||||
citizenId?: string;
|
||||
salary?: number|null;
|
||||
salary?: number | null;
|
||||
birthDate?: string;
|
||||
keycloakId?: string;
|
||||
org?: string;
|
||||
|
|
@ -35,4 +35,36 @@ interface InformationData {
|
|||
email: string;
|
||||
}
|
||||
|
||||
export type { ProfileData, InformationData };
|
||||
interface DataProfile {
|
||||
profileId: string | null;
|
||||
prefix: string;
|
||||
rank: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
citizenId: string;
|
||||
position: string;
|
||||
posMaster: string | null;
|
||||
posLevelName: string | null;
|
||||
posLevelRank: string | null;
|
||||
posLevelId: string | null;
|
||||
posTypeName: string | null;
|
||||
posTypeRank: string | null;
|
||||
posTypeId: string | null;
|
||||
posExecutiveName: string;
|
||||
posExecutivePriority: string | null;
|
||||
posExecutiveId: string | null;
|
||||
rootId: string | null;
|
||||
root: string;
|
||||
child1Id: string | null;
|
||||
child1: string | null;
|
||||
child2Id: string | null;
|
||||
child2: string | null;
|
||||
child3Id: string | null;
|
||||
child3: string | null;
|
||||
child4Id: string | null;
|
||||
child4: string | null;
|
||||
node: string | null;
|
||||
nodeId: string | null;
|
||||
}
|
||||
|
||||
export type { ProfileData, InformationData, DataProfile };
|
||||
|
|
|
|||
|
|
@ -86,7 +86,6 @@ async function fetchEvaluteList() {
|
|||
);
|
||||
total.value = res.data.result.total;
|
||||
store.fetchEvaluateList(res.data.result.data);
|
||||
await getProfileCheck();
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
|
|
@ -191,6 +190,7 @@ watch(
|
|||
/** hook lifecycle*/
|
||||
onMounted(async () => {
|
||||
await fetchEvaluteList();
|
||||
await getProfileCheck();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
: "";
|
||||
}
|
||||
|
||||
/** เช็ครอบการประเมิน ปิด */
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { useQuasar, type QTableProps } from "quasar";
|
|||
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
import { useDataStore } from "@/stores/data";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
import type {
|
||||
|
|
@ -17,7 +18,7 @@ const { showLoader, hideLoader, messageError } = mixin;
|
|||
const router = useRouter();
|
||||
|
||||
const $q = useQuasar();
|
||||
|
||||
const dataStore = useDataStore();
|
||||
const profilId = ref<string>("");
|
||||
const currentPage = ref<number>(1);
|
||||
const page = ref<number>(1);
|
||||
|
|
@ -123,19 +124,22 @@ function onEdit(id: string) {
|
|||
// );
|
||||
|
||||
async function getProfileId() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.profilePosition())
|
||||
.then(async (res) => {
|
||||
profilId.value = res.data.result.profileId;
|
||||
await getData();
|
||||
})
|
||||
.catch((e) => {
|
||||
if (dataStore.profileId) {
|
||||
profilId.value = dataStore.profileId;
|
||||
} else {
|
||||
showLoader();
|
||||
try {
|
||||
const res = await http.get(config.API.profilePosition());
|
||||
dataStore.profileId = res.data.result.profileId;
|
||||
profilId.value = dataStore.profileId;
|
||||
} catch (e) {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
} finally {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
await getData();
|
||||
}
|
||||
|
||||
function convertType(val: string) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import { useCounterMixin } from "@/stores/mixin";
|
|||
* use
|
||||
*/
|
||||
const $q = useQuasar();
|
||||
const link = ref<string>('')
|
||||
const link = ref<string>("");
|
||||
const store = useRequestEditStore();
|
||||
const dataStore = useDataStore();
|
||||
const { dialogConfirm, showLoader, hideLoader, messageError, success } =
|
||||
|
|
@ -167,20 +167,16 @@ function filterOption(val: string, update: Function) {
|
|||
/**
|
||||
* function fetch profileId
|
||||
*/
|
||||
function fetchProfile() {
|
||||
showLoader();
|
||||
http
|
||||
.get(config.API.profilePosition())
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
profileId.value = data.profileId;
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
async function fetchProfile() {
|
||||
try {
|
||||
isReadOnly.value = dataStore.officerType === "OFFICER";
|
||||
const res = await http.get(config.API.profilePosition());
|
||||
return res.data.result.profileId;
|
||||
} catch (err) {
|
||||
messageError($q, err);
|
||||
} finally {
|
||||
hideLoader();
|
||||
}
|
||||
}
|
||||
|
||||
/** popup รายละเอียดของ ขอปรับปรุงข้อมูลจากกรมการปกครอง */
|
||||
|
|
@ -194,7 +190,10 @@ function onInfo(val: string) {
|
|||
watch(
|
||||
() => modal.value,
|
||||
async () => {
|
||||
modal.value && fetchProfile();
|
||||
profileId.value = dataStore.profileId
|
||||
? dataStore.profileId
|
||||
: await fetchProfile();
|
||||
|
||||
link.value = await dataStore.getProFileType();
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ const {
|
|||
showLoader,
|
||||
hideLoader,
|
||||
date2Thai,
|
||||
onSearchDataTable
|
||||
onSearchDataTable,
|
||||
} = mixin;
|
||||
|
||||
const filter = ref<string>("");
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ export const useDataStore = defineStore("dataMain", () => {
|
|||
const { messageError, showLoader, hideLoader, findPosMasterNo, findOrgName } =
|
||||
mixin;
|
||||
// ref() คือการประกาศ state เหมือน vuex
|
||||
const profileId = ref<string>("");
|
||||
const formData = reactive<ProfileData>({
|
||||
profileId: "",
|
||||
rank: "",
|
||||
|
|
@ -101,6 +102,7 @@ export const useDataStore = defineStore("dataMain", () => {
|
|||
|
||||
async function getData(dataPerson: any) {
|
||||
const data = await dataPerson;
|
||||
profileId.value = data.profileId;
|
||||
isProbation.value = data.isProbation;
|
||||
formData.profileId = data.profileId;
|
||||
formData.rank = data.rank;
|
||||
|
|
@ -166,6 +168,7 @@ export const useDataStore = defineStore("dataMain", () => {
|
|||
officerLink,
|
||||
getProFileType,
|
||||
dataProfile,
|
||||
profileId,
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue