เครื่องราช

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-11-14 13:42:31 +07:00
parent 6642e3f25b
commit a94bebd6d0
6 changed files with 136 additions and 77 deletions

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { onMounted, onUnmounted, ref } from "vue";
import { useQuasar } from "quasar";
import { useRoute } from "vue-router";
@ -77,25 +77,25 @@ async function fecthlistRound() {
// UI
if (optionRound.value.length !== 0) {
DataStore.optionRound = optionRound.value;
const lastValue = optionRound.value[0];
await fetchListOrg(lastValue.period_revision);
await fecthAgency(lastValue.period_revision);
if (DataStore.roundId) {
round.value = DataStore.roundId; //
} else {
round.value = lastValue.id.toString(); //
}
await fecthStat(round.value);
DataStore.roundId = round.value;
roundName.value = lastValue.name;
// DataStore.optionRound = optionRound.value;
// const lastValue = optionRound.value[0];
// await fetchListOrg(lastValue.period_revision);
// await fecthAgency(lastValue.period_revision);
// if (DataStore.roundId) {
// round.value = DataStore.roundId; //
// } else {
// round.value = lastValue.id.toString(); //
// }
// // await fecthStat(round.value);
// DataStore.roundId = round.value;
// roundName.value = lastValue.name;
loadview.value = true;
} else {
hideLoader();
}
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
@ -104,14 +104,16 @@ async function fecthlistRound() {
* function เรยกด Stat ของรอบการเสนอขอพระราชทานเครอง
*/
async function fecthStat(id: string) {
await http
.get(config.API.insigniaDashboard(id))
.then((res) => {
stat.value = res.data.result;
})
.catch((err) => {
messageError($q, err);
});
if (DataStore.isOfficer) {
await http
.get(config.API.insigniaDashboard(id))
.then((res) => {
stat.value = res.data.result;
})
.catch((err) => {
messageError($q, err);
});
}
}
/**
@ -119,24 +121,26 @@ async function fecthStat(id: string) {
* @param id โครงสรางปจจ
*/
async function fetchListOrg(id: string) {
await http
.get(config.API.orgByIdSystemRoot(id, route.meta.Key as string))
.then(async (res) => {
const data = res.data.result;
if (data.length !== 0) {
optiontypeOc.value = await res.data.result.map(
(item: DataStructureTree) => ({
id: item.orgTreeId,
name: item.orgName,
})
);
if (DataStore.isOfficer) {
await http
.get(config.API.orgByIdSystemRoot(id, route.meta.Key as string))
.then(async (res) => {
const data = res.data.result;
if (data.length !== 0) {
optiontypeOc.value = await res.data.result.map(
(item: DataStructureTree) => ({
id: item.orgTreeId,
name: item.orgName,
})
);
await DataStore.fetchOption(optiontypeOc.value); // DataStore
}
})
.catch((err) => {
messageError($q, err);
});
await DataStore.fetchOption(optiontypeOc.value); // DataStore
}
})
.catch((err) => {
messageError($q, err);
});
}
}
/**
@ -175,6 +179,20 @@ async function fecthInsignia() {
}
}
async function fetchCheckIsofficer() {
http
.get(config.API.checkIsofficer + `SYS_INSIGNIA_MANAGE`)
.then((res) => {
const data = res.data.result;
DataStore.isStaff = data.isStaff;
DataStore.isOfficer = data.isOfficer;
DataStore.isDirector = data.isDirector;
})
.catch((err) => {
messageError($q, err);
});
}
/**
* function เปลยนรอบการแสดง
*/
@ -433,7 +451,11 @@ async function uploadFile(event: any) {
*/
onMounted(async () => {
tab.value = DataStore.mainTab ?? "";
await Promise.all([fecthlistRound(), fecthInsignia(), fecthInsignia()]);
await Promise.all([fecthlistRound(), fecthInsignia(), fetchCheckIsofficer()]);
});
onUnmounted(() => {
DataStore.typeOc = "";
});
</script>
@ -441,7 +463,14 @@ onMounted(async () => {
<div class="toptitle text-dark col-12 row items-center">
รายชอขาราชการสามญฯ ทธนขอพระราชทานเครองราชอสรยาภรณ
</div>
<q-card bordered class="row col-12 q-mt-sm" v-if="loadview">
<q-card
bordered
class="row col-12 q-mt-sm"
v-if="
loadview &&
(DataStore.isDirector || DataStore.isOfficer || DataStore.isStaff)
"
>
<div class="row col-12 items-center bg-grey-1">
<div class="q-pl-md q-pr-sm text-weight-medium text-grey-7">รอบ</div>
<q-select
@ -458,10 +487,9 @@ onMounted(async () => {
<q-space />
<!-- สกจ. Freez อม -->
<q-btn
v-if="
roleDataStore.adminRole &&
DataStore.isOfficer &&
DataStore.isLock !== true &&
hideBottom &&
checkPermission($route)?.attrIsUpdate
@ -477,7 +505,7 @@ onMounted(async () => {
</q-btn>
</div>
<div class="col-12"><q-separator /></div>
<div v-if="roleDataStore.adminRole" class="col-12 row bg-white">
<div v-if="DataStore.isOfficer" class="col-12 row bg-white">
<div class="fit q-px-md q-py-sm">
<div class="row col-12 q-col-gutter-sm fit">
<!-- stat -->
@ -514,11 +542,19 @@ onMounted(async () => {
</div>
</q-card>
<q-card flat bordered class="col-12 q-mt-sm" v-if="loadview">
<q-card
flat
bordered
class="col-12 q-mt-sm"
v-if="
loadview &&
(DataStore.isDirector || DataStore.isOfficer || DataStore.isStaff)
"
>
<div
v-if="
(roleDataStore.insignia1Role && requestStatus == 'st4') ||
(roleDataStore.insignia2Role && requestStatus == 'st5')
(DataStore.isStaff && requestStatus == 'st4') ||
(DataStore.isDirector && requestStatus == 'st5')
"
class="q-pa-md q-gutter-sm"
>
@ -545,7 +581,7 @@ onMounted(async () => {
<q-tab name="reject" label="คนที่ไม่ยื่นขอ" />
<q-tab name="delete" label="คนที่ถูกลบออก" />
<q-tab
v-if="roleDataStore.adminRole"
v-if="DataStore.isOfficer"
name="organization"
label="หน่วยงานที่ยังไม่ได้ส่งรายชื่อ"
/>
@ -585,7 +621,7 @@ onMounted(async () => {
<!-- แทบหนวยงานทงไมไดงรายช -->
<q-tab-panel
v-if="roleDataStore.adminRole"
v-if="DataStore.isOfficer"
name="organization"
class="q-pa-none"
>
@ -595,9 +631,7 @@ onMounted(async () => {
<q-toolbar class="q-py-md text-right">
<q-file
v-if="
roleDataStore.insignia1Role && checkPermission($route)?.attrIsUpdate
"
v-if="DataStore.isStaff && checkPermission($route)?.attrIsUpdate"
bg-color="white"
clearable
outlined
@ -628,9 +662,7 @@ onMounted(async () => {
flat
round
color="primary"
v-if="
roleDataStore.insignia1Role && checkPermission($route)?.attrIsGet
"
v-if="DataStore.isStaff && checkPermission($route)?.attrIsGet"
:href="document"
target="_blank"
>
@ -651,7 +683,7 @@ onMounted(async () => {
<q-space />
<q-btn
v-if="
roleDataStore.insignia1Role &&
DataStore.isStaff &&
(requestStatus == 'st1' || requestStatus == 'st4') &&
checkPermission($route)?.attrIsUpdate
"
@ -664,7 +696,7 @@ onMounted(async () => {
/>
<q-btn
v-if="
roleDataStore.insignia2Role &&
DataStore.isDirector &&
(requestStatus == 'st3' || requestStatus == 'st5') &&
checkPermission($route)?.attrIsUpdate
"
@ -677,7 +709,7 @@ onMounted(async () => {
/>
<q-btn
v-if="
roleDataStore.insignia2Role &&
DataStore.isDirector &&
requestStatus == 'st3' &&
checkPermission($route)?.attrIsUpdate
"
@ -691,7 +723,7 @@ onMounted(async () => {
<q-btn
v-if="
requestStatus == 'st6' &&
roleDataStore.adminRole &&
DataStore.isOfficer &&
!DataStore.isLock &&
checkPermission($route)?.attrIsUpdate
"