diff --git a/src/modules/07_insignia/components/1_Proposals/addProposals.vue b/src/modules/07_insignia/components/1_Proposals/addProposals.vue index 447a32b7c..d6de134f3 100644 --- a/src/modules/07_insignia/components/1_Proposals/addProposals.vue +++ b/src/modules/07_insignia/components/1_Proposals/addProposals.vue @@ -225,8 +225,8 @@ const fileDocDataUpload = ref([]); const roundInsig = ref(); const datelast = ref(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)) diff --git a/src/modules/07_insignia/components/2_Manage/Tab1.vue b/src/modules/07_insignia/components/2_Manage/Tab1.vue index 4d190c950..e56c89a1b 100644 --- a/src/modules/07_insignia/components/2_Manage/Tab1.vue +++ b/src/modules/07_insignia/components/2_Manage/Tab1.vue @@ -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) => {
("1"); @@ -136,7 +139,9 @@ const columns = ref([ 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) => {
("1"); @@ -131,7 +134,9 @@ const columns = ref([ ]); 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) => {
("admin"); const DataStore = useInsigniaDataStore(); const mixin = useCounterMixin(); @@ -29,16 +32,33 @@ const optiontypeOc = ref([]); const tab = ref("pending"); const stat = ref({ - 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 ( />
-
+
- +
@@ -224,6 +257,7 @@ const fecthInsigniaByOc = async ( :tab="tab" :roundId="round" :fecthInsigniaByOc="fecthInsigniaByOc" + :role-user="roleUser" /> @@ -231,6 +265,7 @@ const fecthInsigniaByOc = async ( :tab="tab" :roundId="round" :fecthInsigniaByOc="fecthInsigniaByOc" + :role-user="roleUser" /> @@ -238,10 +273,15 @@ const fecthInsigniaByOc = async ( :tab="tab" :roundId="round" :fecthInsigniaByOc="fecthInsigniaByOc" + :role-user="roleUser" /> - - + +