diff --git a/src/api/appeal/api.appeal.ts b/src/api/appeal/api.appeal.ts index 0f1348c..7fb0a1f 100644 --- a/src/api/appeal/api.appeal.ts +++ b/src/api/appeal/api.appeal.ts @@ -5,7 +5,7 @@ const profile = `${env.API_URI}/profile/keycloak`; export default { profileBykeycloak: () => `${profile}`, - positionBykeycloak: () => `${env.API_URI}/org/profile/keycloak/position`, + // positionBykeycloak: () => `${env.API_URI}/org/profile/keycloak/position`, appealMainList: ( status: string, diff --git a/src/components/SkeletonTable.vue b/src/components/SkeletonTable.vue new file mode 100644 index 0000000..652d9f4 --- /dev/null +++ b/src/components/SkeletonTable.vue @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/interface/Main.ts b/src/interface/Main.ts index d73d63f..59249cb 100644 --- a/src/interface/Main.ts +++ b/src/interface/Main.ts @@ -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,64 @@ interface InformationData { email: string; } -export type { ProfileData, InformationData }; +interface DataProfile { + 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; + 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 }; diff --git a/src/modules/06_evaluate/components/viewstep/viewStep1.vue b/src/modules/06_evaluate/components/viewstep/viewStep1.vue index a3057f8..7834f54 100644 --- a/src/modules/06_evaluate/components/viewstep/viewStep1.vue +++ b/src/modules/06_evaluate/components/viewstep/viewStep1.vue @@ -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({ /** function เรียกข้อมูลตรวจสอบคุณสมบัติ*/ async function fetchDetail() { - await http - .get(config.API.positionBykeycloak()) - .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() { diff --git a/src/modules/06_evaluate/views/EvaluateMain.vue b/src/modules/06_evaluate/views/EvaluateMain.vue index 6c44144..43d520d 100644 --- a/src/modules/06_evaluate/views/EvaluateMain.vue +++ b/src/modules/06_evaluate/views/EvaluateMain.vue @@ -7,6 +7,7 @@ import http from "@/plugins/http"; import config from "@/app.config"; import { useEvaluateStore } from "@/modules/06_evaluate/store"; import { useCounterMixin } from "@/stores/mixin"; +import { useDataStore } from "@/stores/data"; /** import Components*/ import TableListEvaluate from "@/modules/06_evaluate/components/TableListEvaluate.vue"; // ตารางประเมิน @@ -20,6 +21,7 @@ import type { OptionStatus } from "@/modules/06_evaluate/interface/main"; const $q = useQuasar(); const mixin = useCounterMixin(); const store = useEvaluateStore(); +const dataStore = useDataStore(); const router = useRouter(); const { showLoader, hideLoader, messageError } = mixin; @@ -86,7 +88,6 @@ async function fetchEvaluteList() { ); total.value = res.data.result.total; store.fetchEvaluateList(res.data.result.data); - await getProfileCheck(); }) .catch((err) => { messageError($q, err); @@ -99,24 +100,33 @@ async function fetchEvaluteList() { /** function เรียกรายการประเมิน*/ const statusSubmit = ref(true); async function getProfileCheck() { - await http - .get(config.API.profilePosition()) - .then(async (res: any) => { - const data = res.data.result; - if ( - data.posTypeRank != 2 || - (data.posTypeRank == 2 && data.posLevelRank >= 4) - ) { - statusSubmit.value = false; - } else { - listMenu.value = await listMenu.value.filter( - (x: ListMenu) => x.level > data.posLevelRank - ); - } - }) - .catch((err) => { - messageError($q, err); - }); + if (!dataStore.dataprofilePosition) { + await http + .get(config.API.profilePosition()) + .then(async (res: any) => { + const data = res.data.result; + checkProfilePosition(data); + }) + .catch((err) => { + messageError($q, err); + }); + } else { + const data = dataStore.dataprofilePosition; + checkProfilePosition(data); + } +} + +function checkProfilePosition(data: any) { + if ( + data.posTypeRank != 2 || + (data.posTypeRank == 2 && data.posLevelRank >= 4) + ) { + statusSubmit.value = false; + } else { + listMenu.value = listMenu.value.filter( + (x: ListMenu) => x.level > data.posLevelRank + ); + } } const selectedStatus = ref([ @@ -191,6 +201,7 @@ watch( /** hook lifecycle*/ onMounted(async () => { await fetchEvaluteList(); + await getProfileCheck(); }); diff --git a/src/modules/07_appealComplain/views/Add.vue b/src/modules/07_appealComplain/views/Add.vue index 52932a8..dba72b8 100644 --- a/src/modules/07_appealComplain/views/Add.vue +++ b/src/modules/07_appealComplain/views/Add.vue @@ -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({ }); /** ดึงข้อมูลจาก keycloak*/ -function getProFile() { - showLoader(); - http - .get(config.API.positionBykeycloak()) - .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; } /** diff --git a/src/modules/08_KPI/store.ts b/src/modules/08_KPI/store.ts index 25eb139..d18861d 100644 --- a/src/modules/08_KPI/store.ts +++ b/src/modules/08_KPI/store.ts @@ -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(); @@ -17,36 +18,64 @@ export const useKpiDataStore = defineStore("KPIDate", () => { const selected = ref([]); const work = ref(false); const tabMain = ref(""); - const dataProfile = ref({ - profileId: null, - prefix: "", - rank: "", - firstName: "", - lastName: "", + const dataProfile = ref({ + amountSpecial: 0, + avatar: "", + avatarName: "", + birthDate: "", + child1: "", + child1DnaId: "", + child1Id: "", + child1ShortName: "", + child2: "", + child2DnaId: "", + child2Id: "", + child2ShortName: "", + child3: "", + child3DnaId: "", + child3Id: "", + child3ShortName: "", + child4: "", + child4DnaId: "", + child4Id: "", + child4ShortName: "", citizenId: "", - position: "", - posMaster: null, - posLevelName: null, - posLevelRank: null, - posLevelId: null, - posTypeName: null, - posTypeRank: null, - posTypeId: null, - posExecutiveName: "", - posExecutivePriority: null, + dateRetireLaw: "", + dateStart: "", + firstName: "", + isDirector: false, + isProbation: false, + keycloak: "", + lastName: "", + leaveDate: null, + node: 0, + nodeDnaId: "", + nodeId: "", + nodeShortName: "", posExecutiveId: null, - rootId: null, + posExecutiveName: null, + posExecutivePriority: null, + posLevelId: "", + posLevelName: "", + posLevelRank: 0, + posMaster: 0, + posMasterNo: 0, + posNo: "", + posTypeId: "", + posTypeName: "", + posTypeRank: 0, + position: "", + positionArea: null, + positionExecutiveField: null, + prefix: "", + profileId: "", + profileType: "", + rank: null, root: "", - child1Id: null, - child1: null, - child2Id: null, - child2: null, - child3Id: null, - child3: null, - child4Id: null, - child4: null, - node: null, - nodeId: null, + rootDnaId: "", + rootId: "", + rootShortName: "", + salary: 0, }); const dataEvaluation = ref({ diff --git a/src/modules/08_KPI/views/form.vue b/src/modules/08_KPI/views/form.vue index 5ee322d..9bfd689 100644 --- a/src/modules/08_KPI/views/form.vue +++ b/src/modules/08_KPI/views/form.vue @@ -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((res) => { + const data = res.data.result; + store.dataProfile = data; + }) + .catch((e) => { + messageError($q, e); + }); + } } async function downloadReport() { diff --git a/src/modules/08_KPI/views/main.vue b/src/modules/08_KPI/views/main.vue index 5712266..6a62d27 100644 --- a/src/modules/08_KPI/views/main.vue +++ b/src/modules/08_KPI/views/main.vue @@ -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, @@ -179,8 +180,13 @@ async function fetchRoundOption(type: string) { })); if (type === "main") { roundMainOp.value = list; - round.value = ""; - await fetchList(); + if (data.length === 0) { + round.value = ""; + rows.value = []; + } else { + round.value = roundMainOp.value[0].id; + await fetchList(); + } } else { roundDialgOp.value = list; formRound.kpiPeriodId = { id: "", name: "", isClosed: false }; @@ -205,6 +211,7 @@ async function fetchList() { kpiPeriodId: round.value, status: formQuery.status === "" ? undefined : formQuery.status, results: formQuery.results === "" ? undefined : formQuery.results, + year: year.value, }; await http .get(config.API.kpiEvaluation, { @@ -285,26 +292,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 + : ""; } /** เช็ครอบการประเมิน ปิด */ diff --git a/src/modules/08_KPI/views/mainEvaluator.vue b/src/modules/08_KPI/views/mainEvaluator.vue index 7b76576..f74d535 100644 --- a/src/modules/08_KPI/views/mainEvaluator.vue +++ b/src/modules/08_KPI/views/mainEvaluator.vue @@ -93,7 +93,7 @@ const maxPage = ref(1); * ดึงข้อมูลรายการขอรับประเมินผลการปฏิบัติราชการระดับบุคคล * @param type */ -async function fetchRoundOption(type: boolean = false) { +async function fetchRoundOption() { showLoader(); await http .get( @@ -101,21 +101,25 @@ async function fetchRoundOption(type: boolean = false) { `?page=${1}&pageSize=${10}&keyword=${""}&year=${store.yearRound}` ) .then(async (res) => { - const data = await res.data.result.data; - const list = data.map((e: ResRound) => ({ - id: e.id, - name: - e.durationKPI === "OCT" - ? "รอบที่ 2 ตุลาคม" - : e.durationKPI === "APR" - ? "รอบที่ 1 เมษายน" - : "", - })); + const data = res.data.result.data; + const list = + data.map((e: ResRound) => ({ + id: e.id, + name: + e.durationKPI === "OCT" + ? "รอบที่ 2 ตุลาคม" + : e.durationKPI === "APR" + ? "รอบที่ 1 เมษายน" + : "", + })) ?? []; roundOp.value = list; - if (type) { + if (data.length === 0) { store.formQuery.round = ""; + dataListMain.value = []; + } else { + store.formQuery.round = roundOp.value[0].id; + await fetchList(); } - await fetchList(); }) .catch((err) => { messageError($q, err); @@ -131,8 +135,9 @@ async function fetchList() { const body = { page: store.formQuery.page, pageSize: store.formQuery.pageSize, - kpiPeriodId: store.formQuery.round, + kpiPeriodId: store.formQuery.round ?? "", keyword: store.formQuery.keyword, + year: store.yearRound, status: store.tabMainevaluator === "2" ? "NEW" @@ -225,7 +230,7 @@ onMounted(async () => { year-picker :enableTimePicker="false" @update:model-value=" - (store.formQuery.page = 1), fetchRoundOption(true) + (store.formQuery.page = 1), fetchRoundOption() " > {{ year + 543 }} diff --git a/src/modules/09_scholarship/views/main.vue b/src/modules/09_scholarship/views/main.vue index be093ef..ad8856d 100644 --- a/src/modules/09_scholarship/views/main.vue +++ b/src/modules/09_scholarship/views/main.vue @@ -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(""); const currentPage = ref(1); const page = ref(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) { diff --git a/src/modules/10_registry/components/DialogAddRequestEdit.vue b/src/modules/10_registry/components/DialogAddRequestEdit.vue index 81b06d0..7df4b27 100644 --- a/src/modules/10_registry/components/DialogAddRequestEdit.vue +++ b/src/modules/10_registry/components/DialogAddRequestEdit.vue @@ -16,7 +16,7 @@ import { useCounterMixin } from "@/stores/mixin"; * use */ const $q = useQuasar(); -const link = ref('') +const link = ref(""); 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(); } ); diff --git a/src/modules/11_probation/router.ts b/src/modules/11_probation/router.ts index 8284c0b..67c9b70 100644 --- a/src/modules/11_probation/router.ts +++ b/src/modules/11_probation/router.ts @@ -1,5 +1,4 @@ // registry -const probationPage = () => import("@/modules/11_probation/views/main.vue"); const probationDetail = () => import("@/modules/11_probation/views/mainDetail.vue"); @@ -34,15 +33,6 @@ const probationAddevaluascore = () => import("@/modules/11_probation/component/addPage/04_addevaluascore.vue"); export default [ - { - path: "/probation", - name: "probationMain", - component: probationPage, - meta: { - Auth: true, - Key: [11], - }, - }, { path: "/probation-detail/:id", name: "probationMainDetail", diff --git a/src/modules/11_probation/views/main.vue b/src/modules/11_probation/views/main.vue deleted file mode 100644 index 86245ea..0000000 --- a/src/modules/11_probation/views/main.vue +++ /dev/null @@ -1,430 +0,0 @@ - - - - - - รายละเอียดงานที่ได้รับมอบหมาย - - - - - - {{ - formData.firstName - ? `${formData.prefix}${formData.firstName} ${formData.lastName}` - : "-" - }} - - - - - - - - - - - - ตำแหน่งในสายงาน - ระดับ - สังกัด - - - - {{ formData.position ? formData.position : "-" }} - - - {{ formData.posLevelName ? formData.posLevelName : "-" }} - - - {{ formData.org ? formData.org : "-" }} - - - - - - - - - - - {{ - formData.firstName - ? `${formData.prefix}${formData.firstName} ${formData.lastName}` - : "-" - }} - - - - - - - - - - - - - - ตำแหน่งในสายงาน - {{ - formData.position ? formData.position : "-" - }} - - - - - ระดับ - {{ - formData.posLevelName ? formData.posLevelName : "-" - }} - - - - - สังกัด - {{ - formData.org ? formData.org : "-" - }} - - - - - - - - - - เพิ่มงานที่ได้รับมอบหมาย - - - - - - - - - - - - - - - {{ col.label }} - - - - - - - - - {{ props.rowIndex + 1 }} - - - {{ props.row.status ? props.row.status : "-" }} - - - {{ col.value ? col.value : "-" }} - - - - - - - - - - ประวัติแก้ไขตำแหน่ง/เงินเดือน - - - - {{ col.label }} - - - {{ col.value ? col.value : "-" }} - - - - - - - - - ไม่พบข้อมูล - - - - - - - - - - - diff --git a/src/modules/15_probationReport/components/01_SurveyPage.vue b/src/modules/15_probationReport/components/01_SurveyPage.vue index 57456f5..ffb598d 100644 --- a/src/modules/15_probationReport/components/01_SurveyPage.vue +++ b/src/modules/15_probationReport/components/01_SurveyPage.vue @@ -56,11 +56,11 @@ async function save() { showLoader(); await http .post(config.API.summarySurveyDetail(store.assignId), data) - .then((res: any) => { + .then(async () => { + await props.getSurveyData?.(); success($q, "บันทึกสำเร็จ"); - props.getSurveyData?.(); }) - .catch((e: any) => { + .catch((e) => { messageError($q, e); }) .finally(() => { @@ -93,17 +93,16 @@ watch( } ); - /** get ค่า เมื่อโหลดหน้า */ onMounted(() => { if (store.tabMain === "SURVEY") { - if (dataSurvey.value !== null) { - answer1.value = dataSurvey.value.answer1; - answer2.value = dataSurvey.value.answer2; - answer3.value = dataSurvey.value.answer3; - status.value = false; - } + if (dataSurvey.value !== null) { + answer1.value = dataSurvey.value.answer1; + answer2.value = dataSurvey.value.answer2; + answer3.value = dataSurvey.value.answer3; + status.value = false; } + } }); diff --git a/src/modules/15_probationReport/components/02_ResultPage.vue b/src/modules/15_probationReport/components/02_ResultPage.vue index 07617cd..7fadf29 100644 --- a/src/modules/15_probationReport/components/02_ResultPage.vue +++ b/src/modules/15_probationReport/components/02_ResultPage.vue @@ -67,7 +67,6 @@ const formData = ref({ * @param type type file */ async function clickdownloadFile() { - console.log(props.page); showLoader(); await http .get( @@ -80,13 +79,13 @@ async function clickdownloadFile() { .then(async (res) => { const data = res.data.downloadUrl; window.open(data); - hideLoader(); }) .catch(async (e) => { messageError($q, JSON.parse(await e.response.data.text())); - hideLoader(); }) - .finally(() => {}); + .finally(() => { + hideLoader(); + }); } async function getData() { diff --git a/src/modules/15_probationReport/components/03_AssignPage.vue b/src/modules/15_probationReport/components/03_AssignPage.vue index 0ff38b3..4be7990 100644 --- a/src/modules/15_probationReport/components/03_AssignPage.vue +++ b/src/modules/15_probationReport/components/03_AssignPage.vue @@ -185,11 +185,13 @@ async function dataEdit(id: string) { const data = putDataEdit(id); http .put(config.API.saveEditAssign(id), data) - .then(() => {}) + .then(async () => { + await getAssign(); + }) .catch(() => {}) .finally(async () => { isEdit.value = false; - getAssign(); + hideLoader(); }); // } else { diff --git a/src/stores/data.ts b/src/stores/data.ts index 29e9851..57eea19 100644 --- a/src/stores/data.ts +++ b/src/stores/data.ts @@ -6,7 +6,7 @@ import config from "@/app.config"; import { useQuasar } from "quasar"; import { useRegistryInFormationStore } from "@/modules/10_registry/store/registry"; import { useCounterMixin } from "./mixin"; -import type { ProfileData } from "@/interface/Main"; +import type { ProfileData, DataProfile } from "@/interface/Main"; export const useDataStore = defineStore("dataMain", () => { const dataProfile = ref(); @@ -16,6 +16,8 @@ export const useDataStore = defineStore("dataMain", () => { const { messageError, showLoader, hideLoader, findPosMasterNo, findOrgName } = mixin; // ref() คือการประกาศ state เหมือน vuex + const profileId = ref(""); + const dataprofilePosition = ref(undefined); const formData = reactive({ profileId: "", rank: "", @@ -101,6 +103,8 @@ export const useDataStore = defineStore("dataMain", () => { async function getData(dataPerson: any) { const data = await dataPerson; + dataprofilePosition.value = data; + profileId.value = data.profileId; isProbation.value = data.isProbation; formData.profileId = data.profileId; formData.rank = data.rank; @@ -166,6 +170,8 @@ export const useDataStore = defineStore("dataMain", () => { officerLink, getProFileType, dataProfile, + profileId, + dataprofilePosition, }; }); diff --git a/src/views/MainLayout.vue b/src/views/MainLayout.vue index 534beb3..fdbb1ef 100644 --- a/src/views/MainLayout.vue +++ b/src/views/MainLayout.vue @@ -16,6 +16,7 @@ import { } from "@/plugins/auth"; import { useDataStore } from "@/stores/data"; +import { useKpiDataStore } from "@/modules/08_KPI/store"; // landing page config url const configParam = { @@ -27,6 +28,7 @@ const router = useRouter(); const $q = useQuasar(); const dataStore = useDataStore(); +const kpiDataStore = useKpiDataStore(); const mixin = useCounterMixin(); const { @@ -44,15 +46,13 @@ const notiList = ref([]); const notiTrigger = ref(false); const currentRouteName = router.currentRoute.value.name; const tab = ref(currentRouteName); -const link = ref(""); const isSsoToken = ref(false); /** * เรียกฟังก์ชันทั้งหมดตอนเรียกใช้ไฟล์นี้ */ onMounted(async () => { - await checkUser(); - await fetchTotolNotificate(); + await Promise.all([checkUser(), fetchTotolNotificate()]); const user = await tokenParsed(); const SSO_TOKEN = await getCookie("SSO"); isSsoToken.value = SSO_TOKEN === "y" ? true : false; @@ -63,9 +63,10 @@ async function checkUser() { await http .get(config.API.profilePosition()) .then(async (res) => { - const data = await res.data.result; + const data = res.data.result; await dataStore.getData(data); await dataStore.getProFileType(); + kpiDataStore.dataProfile = data; // Set dataProfile in kpiDataStore if (data.avatarName) { await getImg(data.profileId, data.avatarName); } else { @@ -77,17 +78,19 @@ async function checkUser() { component: CustomComponent, componentProps: { title: "ข้อความแจ้งเตือน", - message: err.response.data.message, + message: + err.response?.data?.message || "เกิดข้อผิดพลาดที่ไม่ทราบสาเหตุ", icon: "warning", color: "red", onlycancel: true, }, - }).onCancel(async () => { + }).onCancel(() => { showLoader(); - await logout(); - setTimeout(() => { - hideLoader(); - }, 1000); + logout().then(() => { + setTimeout(() => { + hideLoader(); + }, 1000); + }); }); }); } @@ -97,11 +100,7 @@ function getImg(id: string, pathName: string) { .get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, pathName)) .then((res) => { dataStore.profileImg = res.data.downloadUrl; - }) - .catch((e) => { - // messageError($q, e); - }) - .finally(() => {}); + }); } const totalNoti = ref(0); @@ -160,7 +159,7 @@ const doLogout = () => { async () => { await http.post(config.API.keycloakLogSSO, { text: "ออกจากระบบ" }); // authen with client - await logoutSSO(); + logoutSSO(); }, "ยืนยันการออกจากระบบ", "ต้องการออกจากระบบใช่หรือไม่"