- แก้รอบเครื่องราช

- ผูก flow จัดการคำขอ
This commit is contained in:
Warunee Tamkoo 2023-08-23 22:23:09 +07:00
parent 8d45efa921
commit 7894e7a715
5 changed files with 82 additions and 26 deletions

View file

@ -225,8 +225,8 @@ const fileDocDataUpload = ref<File[]>([]);
const roundInsig = ref<any>();
const datelast = ref<number>(1);
const options = ref([
{ label: "รอบที่ 1", value: 1 },
{ label: "รอบที่ 2", value: 2 },
{ label: "รอบการเสนอขอพระราชทานเครื่องราชรอบที่ 1", value: 1 },
{ label: "รอบการเสนอขอพระราชทานเครื่องราชรอบที่ 2", value: 2 },
]);
onMounted(async () => {
await fetchData();
@ -236,7 +236,7 @@ const fetchData = async () => {
if (route.params.id) {
edit.value = true;
showLoader();
console.log(id.value);
// console.log(id.value);
await http
.get(config.API.getRoundInsignia(id.value))

View file

@ -190,6 +190,9 @@ const props = defineProps({
fecthInsigniaByOc: {
type: Function,
},
roleUser: {
type: String,
},
});
onMounted(async () => {
@ -197,8 +200,8 @@ onMounted(async () => {
// // organization.value = DataStore.optionsTypeOc[2].id;
// DataStore.typeOc = organization.value;
// } else organization.value = DataStore.typeOc;
organization.value = DataStore.typeOc;
organizationOptions.value = DataStore.optionsTypeOc;
organization.value = await (DataStore.agency != null ? DataStore.agency : DataStore.typeOc);
organizationOptions.value = await DataStore.optionsTypeOc;
if (organization.value !== "" || organization.value !== undefined) {
if (props.fecthInsigniaByOc) {
props.fecthInsigniaByOc(
@ -492,6 +495,7 @@ const paginationLabel2 = (start: string, end: string, total: string) => {
<div class="row col-12 q-col-gutter-sm">
<!-- {{ DataStore.typeinsigniaOptions }} -->
<q-select
v-if="props.roleUser=='admin'"
v-model="organization"
label="หน่วยงาน"
dense

View file

@ -23,6 +23,9 @@ const props = defineProps({
fecthInsigniaByOc: {
type: Function,
},
roleUser: {
type: String,
},
});
const organization = ref<string>("1");
@ -136,7 +139,9 @@ const columns = ref<QTableProps["columns"]>([
onMounted(async () => {
organizationOptions.value = DataStore.optionsTypeOc;
organization.value = DataStore.typeOc;
organization.value = await (DataStore.agency != null
? DataStore.agency
: DataStore.typeOc);
// if (props.fecthInsigniaAll) {
// await props.fecthInsigniaAll(props.roundId, props.tab);
// }
@ -190,6 +195,7 @@ const paginationLabel = (start: string, end: string, total: string) => {
<!-- {{ DataStore.typeinsigniaOptions }} -->
<div class="row col-12 q-col-gutter-sm">
<q-select
v-if="props.roleUser == 'admin'"
v-model="organization"
label="หน่วยงาน"
dense

View file

@ -21,6 +21,9 @@ const props = defineProps({
fecthInsigniaByOc: {
type: Function,
},
roleUser: {
type: String,
},
});
const organization = ref<string>("1");
@ -131,7 +134,9 @@ const columns = ref<QTableProps["columns"]>([
]);
onMounted(async () => {
organizationOptions.value = DataStore.optionsTypeOc;
organization.value = DataStore.typeOc;
organization.value = await (DataStore.agency != null
? DataStore.agency
: DataStore.typeOc);
// if (props.fecthInsigniaAll) {
// await props.fecthInsigniaAll(props.roundId, props.tab);
// }
@ -184,6 +189,7 @@ const paginationLabel = (start: string, end: string, total: string) => {
<div class="row col-12">
<div class="row col-12 q-col-gutter-sm">
<q-select
v-if="props.roleUser == 'admin'"
v-model="organization"
label="หน่วยงาน"
dense

View file

@ -13,6 +13,9 @@ import tab1 from "@/modules/07_insignia/components/2_Manage/Tab1.vue";
import tab2 from "@/modules/07_insignia/components/2_Manage/Tab2.vue";
import tab3 from "@/modules/07_insignia/components/2_Manage/Tab3.vue";
import tab4 from "@/modules/07_insignia/components/2_Manage/Tab4.vue";
import keycloak from "@/plugins/keycloak";
const roleUser = ref<string>("admin");
const DataStore = useInsigniaDataStore();
const mixin = useCounterMixin();
@ -29,16 +32,33 @@ const optiontypeOc = ref<any>([]);
const tab = ref<any>("pending");
const stat = ref<any>({
total: 0,
sendName: 0,
nonSend: 0,
personSend: 0,
disclaim: 0,
allUserUser: 0,
orgAllCount: 0,
orgNoSendCount: 0,
orgSendCount: 0,
});
onMounted(async () => {
await checkRole();
await fecthlistRound();
await fecthAgency();
});
const checkRole = async () => {
if (keycloak.tokenParsed != null) {
const insignia1 = await keycloak.tokenParsed.role.includes("insignia1");
const insignia2 = await keycloak.tokenParsed.role.includes("insignia2");
if (insignia1) {
roleUser.value = "insignia1";
} else if (insignia2) {
roleUser.value = "insignia2";
} else {
roleUser.value = "admin";
}
// console.log("roleUser ===> ", roleUser.value);
}
};
const fecthlistRound = async () => {
await http
.get(config.API.listRoundInsignia())
@ -46,9 +66,7 @@ const fecthlistRound = async () => {
optionRound.value = res.data.result.map((e: any) => ({
id: e.period_id,
year: e.period_year,
name: `รอบการเสนอพระราชทานเครื่องราชรอบที่ ${e.period_round} ปี ${
e.period_year + 543
} `,
name: e.period_name,
}));
// console.log(optionRound.value);
// const lastIndex = optionRound.value.length;
@ -61,6 +79,7 @@ const fecthlistRound = async () => {
messageError($q, err);
});
};
const fecthStat = async (id: string) => {
showLoader();
await http
@ -75,21 +94,26 @@ const fecthStat = async (id: string) => {
hideLoader();
});
};
const fecthAgency = async () => {
showLoader();
await http
.get(config.API.insigniaAgency())
.then(async (res) => {
DataStore.agency = res.data.result;
await fecthType();
if (roleUser.value == "admin") {
await fecthType();
}
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
loading.value = true;
hideLoader();
});
};
const fecthType = async () => {
await http
.get(config.API.typeOc())
@ -109,9 +133,13 @@ const fecthType = async () => {
loading.value = true;
});
};
const changround = () => {
const changround = async () => {
fecthStat(round.value);
fecthInsigniaByOc(round.value, DataStore.typeOc, "officer", tab.value);
var organization = await (DataStore.agency != null
? DataStore.agency
: DataStore.typeOc);
fecthInsigniaByOc(round.value, organization, "officer", tab.value);
};
// const fecthInsigniaAll = async (periodId: string, tab: string) => {
// // let data: any = [];
@ -135,18 +163,19 @@ const fecthInsigniaByOc = async (
status: string
) => {
showLoader();
console.log("ocId===>", ocId);
await http
.get(config.API.insigniaList(roundId, ocId, role, status))
.then(async (res) => {
console.log(res);
// console.log(res);
await DataStore.fetchData(res.data.result.items);
})
.catch((err) => {
console.log(err);
// messageError($q);
// console.log(err);
messageError($q);
})
.finally(() => {
loading.value = true;
hideLoader();
});
};
@ -172,7 +201,7 @@ const fecthInsigniaByOc = async (
/>
</div>
<div class="col-12"><q-separator /></div>
<div class="col-12 row bg-white">
<div v-if="roleUser == 'admin'" 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">
<cardTop
@ -214,7 +243,11 @@ const fecthInsigniaByOc = async (
<q-tab name="pending" label="ผู้ที่ได้รับพระราชทานเครื่องราชฯ" />
<q-tab name="reject" label="คนที่ไม่ยื่นขอ" />
<q-tab name="delete" label="คนที่ถูกลบออก" />
<q-tab name="organization" label="หน่วยงานที่ยังไม่ได้ส่งรายชื่อ" />
<q-tab
v-if="roleUser == 'admin'"
name="organization"
label="หน่วยงานที่ยังไม่ได้ส่งรายชื่อ"
/>
</q-tabs>
</div>
<q-separator />
@ -224,6 +257,7 @@ const fecthInsigniaByOc = async (
:tab="tab"
:roundId="round"
:fecthInsigniaByOc="fecthInsigniaByOc"
:role-user="roleUser"
/>
</q-tab-panel>
<q-tab-panel name="reject" class="q-pa-none">
@ -231,6 +265,7 @@ const fecthInsigniaByOc = async (
:tab="tab"
:roundId="round"
:fecthInsigniaByOc="fecthInsigniaByOc"
:role-user="roleUser"
/>
</q-tab-panel>
<q-tab-panel name="delete" class="q-pa-none">
@ -238,10 +273,15 @@ const fecthInsigniaByOc = async (
:tab="tab"
:roundId="round"
:fecthInsigniaByOc="fecthInsigniaByOc"
:role-user="roleUser"
/>
</q-tab-panel>
<q-tab-panel name="organization" class="q-pa-none">
<tab4 :tab="tab" :roundId="round" />
<q-tab-panel
v-if="roleUser == 'admin'"
name="organization"
class="q-pa-none"
>
<tab4 :tab="tab" :roundId="round" :role-user="roleUser" />
</q-tab-panel>
</q-tab-panels>
</q-card>