fix load เครื่องราช

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-09-26 15:56:13 +07:00
parent 64a640cf6a
commit 5d33b1babb
2 changed files with 91 additions and 86 deletions

View file

@ -37,7 +37,6 @@ const { messageError, dialogConfirm, showLoader, hideLoader, success } = mixin;
/**
* วแปร
*/
const loading = ref<boolean>(false); //
const loadview = ref<boolean>(false); // View
const hideBottom = ref<boolean>(false);
const round = ref<string>(""); //
@ -64,10 +63,12 @@ const modalbackInsignia2Role = ref<boolean>(false); // popup หมายเห
* function เรยกรอบการเสนอขอพระราชทานเครอง
*/
async function fecthlistRound() {
showLoader();
loadview.value = false;
await http
.get(config.API.listRoundInsignia(), { params: { path: "MANAGE" } })
.then(async (res) => {
optionRound.value = res.data.result.map((e: ResponsePeriod) => ({
optionRound.value = await res.data.result.map((e: ResponsePeriod) => ({
id: e.period_id,
year: e.period_year,
name: e.period_name,
@ -84,14 +85,15 @@ async function fecthlistRound() {
}
DataStore.roundId = round.value;
roundName.value = lastValue.name;
loadview.value = true;
await fecthStat(round.value);
} else {
loadview.value = false;
loading.value = false;
hideLoader();
}
})
.catch((err) => {
messageError($q, err);
hideLoader();
});
}
@ -109,23 +111,6 @@ async function fecthStat(id: string) {
});
}
/**
* funcion เชคหนวยงาน
*/
async function fecthAgency() {
await http
.get(config.API.keycloakPosition())
.then((res) => {
loadview.value = true;
DataStore.agency = res.data.result.rootId;
DataStore.typeOc = DataStore.agency;
loading.value = true;
})
.catch((err) => {
messageError($q, err);
});
}
/**
* function fetch โครองสรางปจจ
*/
@ -145,9 +130,8 @@ function fetchActiveId() {
* function fetch อมลโครองสรางปจจ
* @param id โครงสรางปจจ
*/
function fetchListOrg(id: string) {
showLoader();
http
async function fetchListOrg(id: string) {
await http
.get(config.API.orgByIdSystem(id, route.meta.Key as string))
.then(async (res) => {
const data = await res.data.result.map((item: DataStructureTree) => ({
@ -156,11 +140,24 @@ function fetchListOrg(id: string) {
}));
optiontypeOc.value = data;
DataStore.fetchOption(optiontypeOc.value); // DataStore
await fecthAgency();
})
.catch((err) => {
messageError($q, err);
hideLoader();
});
}
/**
* funcion เชคหนวยงาน
*/
async function fecthAgency() {
await http
.get(config.API.keycloakPosition())
.then((res) => {
DataStore.agency = res.data.result.rootId;
DataStore.typeOc = DataStore.agency;
})
.catch((err) => {
messageError($q, err);
});
}
@ -191,7 +188,7 @@ async function changround() {
DataStore.agency != null // agency agency Oc
? DataStore.agency
: DataStore.typeOc;
fecthInsigniaByOc(round.value, organization, "officer", tab.value); //
await fecthInsigniaByOc(round.value, organization, "officer", tab.value); //
// get round name
const roundFilter = optionRound.value.find((x: any) => round.value === x.id);
if (roundFilter) {
@ -214,6 +211,7 @@ async function fecthInsigniaByOc(
role: string,
status: string
) {
DataStore.rows = [];
if (roundId && ocId && role && status) {
showLoader();
await http
@ -225,7 +223,6 @@ async function fecthInsigniaByOc(
document.value = res.data.result.document;
await DataStore.fetchData(res.data.result.items); //
await DataStore.fetchDataInsignia(res.data.result); //
loading.value = true;
//
if (res.data.result.items !== null) {
if (res.data.result.items.length !== 0) {
@ -434,7 +431,13 @@ async function uploadFile(event: any) {
*/
onMounted(async () => {
tab.value = DataStore.mainTab ?? "";
Promise.all([fecthInsignia(), fecthlistRound(), fetchActiveId()]);
await Promise.all([
fecthlistRound(),
fecthInsignia(),
fecthInsignia(),
fetchActiveId(),
fecthAgency(),
]);
});
</script>
@ -506,6 +509,7 @@ onMounted(async () => {
</div>
</div>
</q-card>
<q-card v-else>
<div class="q-pa-md q-gutter-sm">
<q-banner inline-actions rounded class="bg-grey-1 text-center">
@ -514,7 +518,7 @@ onMounted(async () => {
</div>
</q-card>
<q-card flat bordered class="col-12 q-mt-sm" v-if="loading">
<q-card flat bordered class="col-12 q-mt-sm" v-if="loadview">
<div
v-if="
(roleDataStore.insignia1Role && requestStatus == 'st4') ||
@ -531,6 +535,7 @@ onMounted(async () => {
{{ requestNote }}
</q-banner>
</div>
<div class="row col-12">
<q-tabs
v-model="tab"
@ -550,48 +555,49 @@ onMounted(async () => {
label="หน่วยงานที่ยังไม่ได้ส่งรายชื่อ"
/>
</q-tabs>
<div class="col-12"><q-separator /></div>
<q-tab-panels v-model="tab" animated>
<!-- แทบคนทนขอ -->
<q-tab-panel name="pending" class="q-pa-none">
<tab1
:tab="tab"
:round-id="round"
:round-name="roundName"
:fecth-insignia-by-oc="fecthInsigniaByOc"
:request-status="requestStatus"
:fecth-stat="fecthStat"
/>
</q-tab-panel>
<!-- แทบคนทไมนขอ -->
<q-tab-panel name="reject" class="q-pa-none">
<tab2
:tab="tab"
:round-id="round"
:fecth-insignia-by-oc="fecthInsigniaByOc"
/>
</q-tab-panel>
<!-- แทบคนทกลบออก -->
<q-tab-panel name="delete" class="q-pa-none">
<tab3
:tab="tab"
:round-id="round"
:fecth-insignia-by-oc="fecthInsigniaByOc"
/>
</q-tab-panel>
<!-- แทบหนวยงานทงไมไดงรายช -->
<q-tab-panel
v-if="roleDataStore.adminRole"
name="organization"
class="q-pa-none"
>
<tab4 :tab="tab" :round-id="round" />
</q-tab-panel>
</q-tab-panels>
</div>
<q-separator />
<q-tab-panels v-model="tab" animated>
<!-- แทบคนทนขอ -->
<q-tab-panel name="pending" class="q-pa-none">
<tab1
:tab="tab"
:round-id="round"
:round-name="roundName"
:fecth-insignia-by-oc="fecthInsigniaByOc"
:request-status="requestStatus"
:fecth-stat="fecthStat"
/>
</q-tab-panel>
<!-- แทบคนทไมนขอ -->
<q-tab-panel name="reject" class="q-pa-none">
<tab2
:tab="tab"
:round-id="round"
:fecth-insignia-by-oc="fecthInsigniaByOc"
/>
</q-tab-panel>
<!-- แทบคนทกลบออก -->
<q-tab-panel name="delete" class="q-pa-none">
<tab3
:tab="tab"
:round-id="round"
:fecth-insignia-by-oc="fecthInsigniaByOc"
/>
</q-tab-panel>
<!-- แทบหนวยงานทงไมไดงรายช -->
<q-tab-panel
v-if="roleDataStore.adminRole"
name="organization"
class="q-pa-none"
>
<tab4 :tab="tab" :round-id="round" />
</q-tab-panel>
</q-tab-panels>
<q-toolbar class="q-py-md text-right">
<q-file
@ -703,21 +709,21 @@ onMounted(async () => {
@click="popupBackToInsignia2Role"
/>
</q-toolbar>
<!-- popup หมายเหต -->
<DialogPopupReason
v-model:modal="modalPopupBackToEdit"
title="หมายเหตุการตีกลับ"
label="หมายเหตุ"
:savaForm="backToEdit"
/>
<DialogPopupReason
v-model:modal="modalbackInsignia2Role"
title="หมายเหตุการตีกลับ"
label="หมายเหตุ"
:savaForm="backToEditinsignia2Role"
/>
</q-card>
<!-- popup หมายเหต -->
<DialogPopupReason
v-model:modal="modalPopupBackToEdit"
title="หมายเหตุการตีกลับ"
label="หมายเหตุ"
:savaForm="backToEdit"
/>
<DialogPopupReason
v-model:modal="modalbackInsignia2Role"
title="หมายเหตุการตีกลับ"
label="หมายเหตุ"
:savaForm="backToEditinsignia2Role"
/>
</template>
<style lang="scss" scope>

View file

@ -254,7 +254,6 @@ async function fecthRound() {
id: e.id,
}));
selectRound.value = data[0].id;
await Promise.all([fecthInsignia(), fecthInsigniaType()]);
} else {
hideLoader();