fix fetch profilePosition
This commit is contained in:
parent
efcfda8b0e
commit
7d95116c25
3 changed files with 118 additions and 73 deletions
|
|
@ -36,35 +36,63 @@ interface 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;
|
||||
amountSpecial: number;
|
||||
avatar: string;
|
||||
avatarName: string;
|
||||
birthDate: string;
|
||||
child1: string;
|
||||
child1DnaId: string;
|
||||
child1Id: string;
|
||||
child1ShortName: string;
|
||||
child2: string;
|
||||
child2DnaId: string;
|
||||
child2Id: string;
|
||||
child2ShortName: string;
|
||||
child3: string;
|
||||
child3DnaId: string;
|
||||
child3Id: string;
|
||||
child3ShortName: string;
|
||||
child4: string | null;
|
||||
node: string | null;
|
||||
nodeId: string | null;
|
||||
child4DnaId: string | null;
|
||||
child4Id: string | null;
|
||||
child4ShortName: string | null;
|
||||
citizenId: string;
|
||||
dateRetireLaw: string;
|
||||
dateStart: string;
|
||||
firstName: string;
|
||||
isDirector: boolean;
|
||||
isProbation: boolean;
|
||||
keycloak: string;
|
||||
lastName: string;
|
||||
leaveDate: string | null;
|
||||
node: number;
|
||||
nodeDnaId: string;
|
||||
nodeId: string;
|
||||
nodeShortName: string;
|
||||
posExecutiveId: string | null;
|
||||
posExecutiveName: string | null;
|
||||
posExecutivePriority: number | null;
|
||||
posLevelId: string;
|
||||
posLevelName: string;
|
||||
posLevelRank: number;
|
||||
posMaster: number;
|
||||
posMasterNo: number;
|
||||
posNo: string;
|
||||
posTypeId: string;
|
||||
posTypeName: string;
|
||||
posTypeRank: number;
|
||||
position: string;
|
||||
positionArea: string | null;
|
||||
positionExecutiveField: string | null;
|
||||
prefix: string;
|
||||
profileId: string;
|
||||
profileType: string;
|
||||
rank: string | null;
|
||||
root: string;
|
||||
rootDnaId: string;
|
||||
rootId: string;
|
||||
rootShortName: string;
|
||||
salary: number;
|
||||
}
|
||||
|
||||
export type { ProfileData, InformationData, DataProfile };
|
||||
|
|
|
|||
|
|
@ -9,8 +9,10 @@ import config from "@/app.config";
|
|||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useEvaluateDetailStore } from "@/modules/06_evaluate/stores/evaluteDetail";
|
||||
import { useEvaluateStore } from "@/modules/06_evaluate/store";
|
||||
import { useDataStore } from "@/stores/data";
|
||||
|
||||
/** importType*/
|
||||
import type { DataProfile } from "@/interface/Main";
|
||||
import type {
|
||||
EducationForm,
|
||||
CertificatesForm,
|
||||
|
|
@ -24,6 +26,7 @@ import HeaderDialog from "@/components/DialogHeader.vue";
|
|||
const mixin = useCounterMixin();
|
||||
const store = useEvaluateDetailStore();
|
||||
const storeEva = useEvaluateStore();
|
||||
const storeData = useDataStore();
|
||||
const $q = useQuasar();
|
||||
const route = useRoute();
|
||||
const { showLoader, hideLoader, messageError, date2Thai, findOrgNameHtml } =
|
||||
|
|
@ -75,34 +78,39 @@ const formDetail = reactive<any>({
|
|||
|
||||
/** function เรียกข้อมูลตรวจสอบคุณสมบัติ*/
|
||||
async function fetchDetail() {
|
||||
await http
|
||||
.get(config.API.profilePosition())
|
||||
.then(async (res) => {
|
||||
const data = await res.data.result;
|
||||
formDetail.root = data.root;
|
||||
formDetail.rootId = data.rootId;
|
||||
formDetail.userId = data.id;
|
||||
formDetail.citizenId = data.citizenId;
|
||||
formDetail.prefix = data.prefix;
|
||||
formDetail.fullName = `${data.firstName} ${data.lastName}`;
|
||||
formDetail.firstName = data.firstName;
|
||||
formDetail.lastName = data.lastName;
|
||||
formDetail.position = data.position;
|
||||
formDetail.oc = data.rootShortName;
|
||||
formDetail.positionLevel = data.posLevelName;
|
||||
formDetail.posNo = data.posNo ?? "";
|
||||
formDetail.birthDate = data.birthDate;
|
||||
// formDetail.govAge = data.govAge; // ยังไม่มี
|
||||
formDetail.salary = data.salary;
|
||||
formDetail.posExecutive = data.posExecutive;
|
||||
formDetail.positionArea = data.positionArea;
|
||||
await fetchDataAllDetail();
|
||||
try {
|
||||
if (!storeData.dataprofilePosition) {
|
||||
const res = await http.get(config.API.profilePosition());
|
||||
await updateFormDetail(res.data.result);
|
||||
} else {
|
||||
await updateFormDetail(storeData.dataprofilePosition);
|
||||
}
|
||||
} catch (error) {
|
||||
messageError($q, error);
|
||||
}
|
||||
}
|
||||
|
||||
emit("update:formDeital", formDetail);
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
});
|
||||
async function updateFormDetail(data: DataProfile) {
|
||||
formDetail.root = data.root;
|
||||
formDetail.rootId = data.rootId;
|
||||
formDetail.userId = data.profileId;
|
||||
formDetail.citizenId = data.citizenId;
|
||||
formDetail.prefix = data.prefix;
|
||||
formDetail.fullName = `${data.firstName} ${data.lastName}`;
|
||||
formDetail.firstName = data.firstName;
|
||||
formDetail.lastName = data.lastName;
|
||||
formDetail.position = data.position;
|
||||
formDetail.oc = data.rootShortName;
|
||||
formDetail.positionLevel = data.posLevelName;
|
||||
formDetail.posNo = data.posNo ?? "";
|
||||
formDetail.birthDate = data.birthDate;
|
||||
// formDetail.govAge = data.govAge; // ยังไม่มี
|
||||
formDetail.salary = data.salary;
|
||||
formDetail.posExecutive = data.posExecutiveName;
|
||||
formDetail.positionArea = data.positionArea;
|
||||
await fetchDataAllDetail();
|
||||
|
||||
emit("update:formDeital", formDetail);
|
||||
}
|
||||
|
||||
async function fetchDataAllDetail() {
|
||||
|
|
|
|||
|
|
@ -6,15 +6,20 @@ import { useRouter, useRoute } from "vue-router";
|
|||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useDataStore } from "@/stores/data";
|
||||
|
||||
import Form from "@/modules/07_appealComplain/views/Form.vue";
|
||||
|
||||
import type { DataProfile } from "@/interface/Main";
|
||||
import type {
|
||||
FormProfile,
|
||||
FormDataType,
|
||||
} from "@/modules/07_appealComplain/interface/response/mainType";
|
||||
|
||||
const router = useRouter();
|
||||
const $q = useQuasar();
|
||||
const mixin = useCounterMixin();
|
||||
const storeData = useDataStore();
|
||||
|
||||
const { findOrgName, success, messageError, showLoader, hideLoader } = mixin;
|
||||
|
||||
|
|
@ -27,24 +32,28 @@ const formProfile = reactive<FormProfile>({
|
|||
});
|
||||
|
||||
/** ดึงข้อมูลจาก keycloak*/
|
||||
function getProFile() {
|
||||
showLoader();
|
||||
http
|
||||
.get(config.API.profilePosition())
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
formProfile.profileId = data.profileId;
|
||||
formProfile.fullname = `${data.prefix}${data.firstName} ${data.lastName}`;
|
||||
formProfile.citizenId = data.citizenId;
|
||||
formProfile.oc = findOrgName(data);
|
||||
formProfile.position = data.position;
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
async function getProFile() {
|
||||
try {
|
||||
showLoader();
|
||||
if (!storeData.dataprofilePosition) {
|
||||
const res = await http.get(config.API.profilePosition());
|
||||
await updateFormProfile(res.data.result);
|
||||
} else {
|
||||
await updateFormProfile(storeData.dataprofilePosition);
|
||||
}
|
||||
} catch (error) {
|
||||
messageError($q, error);
|
||||
} finally {
|
||||
hideLoader();
|
||||
}
|
||||
}
|
||||
|
||||
async function updateFormProfile(data: DataProfile) {
|
||||
formProfile.profileId = data.profileId;
|
||||
formProfile.fullname = `${data.prefix}${data.firstName} ${data.lastName}`;
|
||||
formProfile.citizenId = data.citizenId;
|
||||
formProfile.oc = findOrgName(data);
|
||||
formProfile.position = data.position;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue