remove keycloak use cookie auth
This commit is contained in:
parent
035db71697
commit
5a5e37c12d
27 changed files with 501 additions and 440 deletions
30
src/main.ts
30
src/main.ts
|
|
@ -3,7 +3,6 @@ import App from "./App.vue";
|
||||||
import router from "./router";
|
import router from "./router";
|
||||||
import { Dialog, Notify, Quasar, Loading } from "quasar";
|
import { Dialog, Notify, Quasar, Loading } from "quasar";
|
||||||
import "./quasar-user-options";
|
import "./quasar-user-options";
|
||||||
import keycloak, { getToken } from "@/plugins/keycloak";
|
|
||||||
|
|
||||||
import qDraggableTable from "quasar-ui-q-draggable-table";
|
import qDraggableTable from "quasar-ui-q-draggable-table";
|
||||||
import "quasar-ui-q-draggable-table/dist/index.css";
|
import "quasar-ui-q-draggable-table/dist/index.css";
|
||||||
|
|
@ -14,15 +13,9 @@ import th from "quasar/lang/th";
|
||||||
import "@vuepic/vue-datepicker/dist/main.css";
|
import "@vuepic/vue-datepicker/dist/main.css";
|
||||||
import http from "./plugins/http";
|
import http from "./plugins/http";
|
||||||
import { createPinia } from "pinia";
|
import { createPinia } from "pinia";
|
||||||
// organization
|
|
||||||
// position
|
|
||||||
// positionEmployee
|
|
||||||
//calendar
|
|
||||||
// insignia
|
|
||||||
|
|
||||||
// import './assets/main.css'
|
// import './assets/main.css'
|
||||||
|
|
||||||
// Import GlobalFilters
|
|
||||||
import filters from "./plugins/filters";
|
import filters from "./plugins/filters";
|
||||||
|
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
|
|
@ -81,27 +74,4 @@ app.component(
|
||||||
);
|
);
|
||||||
|
|
||||||
app.config.globalProperties.$http = http;
|
app.config.globalProperties.$http = http;
|
||||||
|
|
||||||
// authen with keycloak client
|
|
||||||
const auth = await getToken();
|
|
||||||
|
|
||||||
if (auth.token && auth.refresh_token) {
|
|
||||||
keycloak.init({
|
|
||||||
checkLoginIframe: false,
|
|
||||||
token: auth.token,
|
|
||||||
refreshToken: auth.refresh_token,
|
|
||||||
});
|
|
||||||
// .then((authenticated) => {
|
|
||||||
// console.log("authenticated", authenticated);
|
|
||||||
// if (!authenticated) {
|
|
||||||
// window.location.reload();
|
|
||||||
// } else {
|
|
||||||
// console.log("Authenticated");
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// .catch((err) => {
|
|
||||||
// console.error("Keycloak initialization failed:", err);
|
|
||||||
// });
|
|
||||||
}
|
|
||||||
|
|
||||||
app.mount("#app");
|
app.mount("#app");
|
||||||
|
|
|
||||||
|
|
@ -12,13 +12,13 @@ import type {
|
||||||
SupportMessageStatus,
|
SupportMessageStatus,
|
||||||
SupportIssueCategoryResponse,
|
SupportIssueCategoryResponse,
|
||||||
} from "@/modules/00_support/interface/index/Main";
|
} from "@/modules/00_support/interface/index/Main";
|
||||||
import keycloak from "@/plugins/keycloak";
|
|
||||||
import { useQuasar } from "quasar";
|
import { useQuasar } from "quasar";
|
||||||
|
import { getToken, tokenParsed } from "@/plugins/auth";
|
||||||
|
|
||||||
export const useSupportStore = defineStore("supportServiceStore", () => {
|
export const useSupportStore = defineStore("supportServiceStore", async () => {
|
||||||
const { showLoader, hideLoader, messageError } = useCounterMixin();
|
const { showLoader, hideLoader, messageError } = useCounterMixin();
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
const userId = ref<string | undefined>(keycloak.subject);
|
const userId = ref<string | undefined>("");
|
||||||
const issue = ref<SupportIssueResponse>();
|
const issue = ref<SupportIssueResponse>();
|
||||||
const message = ref<SupportMessageResponse>();
|
const message = ref<SupportMessageResponse>();
|
||||||
const messageStatus = ref<SupportMessageStatus>();
|
const messageStatus = ref<SupportMessageStatus>();
|
||||||
|
|
@ -44,8 +44,9 @@ export const useSupportStore = defineStore("supportServiceStore", () => {
|
||||||
}, 150);
|
}, 150);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const token = await getToken();
|
||||||
const socket = io(config.API.supportSocket, {
|
const socket = io(config.API.supportSocket, {
|
||||||
auth: { token: keycloak.token },
|
auth: { token: token },
|
||||||
autoConnect: false,
|
autoConnect: false,
|
||||||
path: "/api/v1/support/socket/",
|
path: "/api/v1/support/socket/",
|
||||||
});
|
});
|
||||||
|
|
@ -54,7 +55,10 @@ export const useSupportStore = defineStore("supportServiceStore", () => {
|
||||||
userStatus.value = data;
|
userStatus.value = data;
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("online", (r) => {
|
socket.on("online", async (r) => {
|
||||||
|
const user = await tokenParsed();
|
||||||
|
userId.value = user.subject;
|
||||||
|
|
||||||
userStatus.value.push({
|
userStatus.value.push({
|
||||||
socketId: r.socketId,
|
socketId: r.socketId,
|
||||||
userId: r.userId,
|
userId: r.userId,
|
||||||
|
|
|
||||||
|
|
@ -397,6 +397,7 @@
|
||||||
</div> -->
|
</div> -->
|
||||||
</q-form>
|
</q-form>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, watch } from "vue";
|
import { ref, onMounted, watch } from "vue";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
|
|
@ -412,8 +413,8 @@ import {
|
||||||
changeData,
|
changeData,
|
||||||
} from "@/modules/03_recruiting/interface/index/Main";
|
} from "@/modules/03_recruiting/interface/index/Main";
|
||||||
import HeaderTop from "@/modules/03_recruiting/components/top.vue";
|
import HeaderTop from "@/modules/03_recruiting/components/top.vue";
|
||||||
|
import { tokenParsed } from "@/plugins/auth";
|
||||||
import { useRoute } from "vue-router";
|
import { useRoute } from "vue-router";
|
||||||
import keycloak from "@/plugins/keycloak";
|
|
||||||
import { useQuasar } from "quasar";
|
import { useQuasar } from "quasar";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
|
@ -499,12 +500,10 @@ const fetchData = async () => {
|
||||||
defaultInformation.value.knowledge = data.knowledge;
|
defaultInformation.value.knowledge = data.knowledge;
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
defaultInformation.value.email =
|
const user = await tokenParsed();
|
||||||
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.email;
|
defaultInformation.value.email = user ? user.email : "";
|
||||||
defaultInformation.value.firstname =
|
defaultInformation.value.firstname = user ? user.given_name : "";
|
||||||
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.given_name;
|
defaultInformation.value.lastname = user ? user.family_name : "";
|
||||||
defaultInformation.value.lastname =
|
|
||||||
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.family_name;
|
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
hideLoader();
|
hideLoader();
|
||||||
|
|
|
||||||
|
|
@ -833,7 +833,7 @@ import type { DataOption } from "@/modules/04_registry/interface/index/Main";
|
||||||
import http from "@/plugins/http";
|
import http from "@/plugins/http";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
import { useProfileDataStore } from "@/modules/04_registry/store";
|
import { useProfileDataStore } from "@/modules/04_registry/store";
|
||||||
import keycloak from "@/plugins/keycloak";
|
import { tokenParsed } from "@/plugins/auth";
|
||||||
|
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
const store = useDataStore();
|
const store = useDataStore();
|
||||||
|
|
@ -996,13 +996,10 @@ function onClickUnlock() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (keycloak.tokenParsed != null) {
|
const user = await tokenParsed();
|
||||||
roleKeyregistry.value = await keycloak.tokenParsed.role.includes(
|
if (user) {
|
||||||
"keyregistry"
|
roleKeyregistry.value = await user.role.includes("keyregistry");
|
||||||
);
|
roleRegistryverify.value = await user.role.includes("registryverify");
|
||||||
roleRegistryverify.value = await keycloak.tokenParsed.role.includes(
|
|
||||||
"registryverify"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await changeTab("information");
|
await changeTab("information");
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,7 @@ import { checkPermission } from "@/utils/permissions";
|
||||||
import { useRoute, useRouter } from "vue-router";
|
import { useRoute, useRouter } from "vue-router";
|
||||||
import http from "@/plugins/http";
|
import http from "@/plugins/http";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
import keycloak from "@/plugins/keycloak";
|
import { tokenParsed } from "@/plugins/auth";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* impotyType
|
* impotyType
|
||||||
*/
|
*/
|
||||||
|
|
@ -143,8 +142,9 @@ const getClass = (val: boolean) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (keycloak.tokenParsed != null) {
|
const user = await tokenParsed();
|
||||||
roleAdmin.value = await keycloak.tokenParsed.role.includes("placement1");
|
if (user) {
|
||||||
|
roleAdmin.value = await user.role.includes("placement1");
|
||||||
}
|
}
|
||||||
fetchData();
|
fetchData();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ import { onMounted, ref } from "vue";
|
||||||
import { defineAsyncComponent } from "@vue/runtime-core";
|
import { defineAsyncComponent } from "@vue/runtime-core";
|
||||||
import { useRouter, useRoute } from "vue-router";
|
import { useRouter, useRoute } from "vue-router";
|
||||||
import cardTop from "@/modules/05_placement/components/PersonalList/StatCard.vue";
|
import cardTop from "@/modules/05_placement/components/PersonalList/StatCard.vue";
|
||||||
|
import { tokenParsed } from "@/plugins/auth";
|
||||||
|
|
||||||
import keycloak from "@/plugins/keycloak";
|
|
||||||
import http from "@/plugins/http";
|
import http from "@/plugins/http";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
|
|
||||||
|
|
@ -81,8 +81,9 @@ onMounted(async () => {
|
||||||
await fetchPlacementData();
|
await fetchPlacementData();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keycloak.tokenParsed != null) {
|
const user = await tokenParsed();
|
||||||
roleAdmin.value = await keycloak.tokenParsed.role.includes("placement1");
|
if (user) {
|
||||||
|
roleAdmin.value = await user.role.includes("placement1");
|
||||||
}
|
}
|
||||||
|
|
||||||
await getStat();
|
await getStat();
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,9 @@ import DialogOrgTree from "@/modules/05_placement/components/PersonalList/OrgTre
|
||||||
import { useRoute } from "vue-router";
|
import { useRoute } from "vue-router";
|
||||||
import http from "@/plugins/http";
|
import http from "@/plugins/http";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
import keycloak from "@/plugins/keycloak";
|
|
||||||
import router from "@/router";
|
import router from "@/router";
|
||||||
import avatar from "@/assets/avatar_user.jpg";
|
import avatar from "@/assets/avatar_user.jpg";
|
||||||
|
import { tokenParsed } from "@/plugins/auth";
|
||||||
|
|
||||||
let roleAdmin = ref<boolean>(false);
|
let roleAdmin = ref<boolean>(false);
|
||||||
|
|
||||||
|
|
@ -714,8 +714,9 @@ function onSubmitDate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (keycloak.tokenParsed != null) {
|
const user = await tokenParsed();
|
||||||
roleAdmin.value = await keycloak.tokenParsed.role.includes("placement1");
|
if (user) {
|
||||||
|
roleAdmin.value = await user.role.includes("placement1");
|
||||||
if (roleAdmin.value === false) {
|
if (roleAdmin.value === false) {
|
||||||
displayAdd.value = false;
|
displayAdd.value = false;
|
||||||
visibleColumns.value = [
|
visibleColumns.value = [
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import { useCounterMixin } from "@/stores/mixin";
|
||||||
|
|
||||||
import http from "@/plugins/http";
|
import http from "@/plugins/http";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
import keycloak from "@/plugins/keycloak";
|
|
||||||
import CurrencyInput from "@/components/CurruncyInput.vue";
|
import CurrencyInput from "@/components/CurruncyInput.vue";
|
||||||
import type { QTableProps, QForm } from "quasar";
|
import type { QTableProps, QForm } from "quasar";
|
||||||
import PopupPersonal from "@/components/Dialogs/PopupPersonal.vue";
|
import PopupPersonal from "@/components/Dialogs/PopupPersonal.vue";
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import { checkPermission } from "@/utils/permissions";
|
||||||
// import CurrencyInput from "@/components/CurruncyInput.vue";
|
// import CurrencyInput from "@/components/CurruncyInput.vue";
|
||||||
import http from "@/plugins/http";
|
import http from "@/plugins/http";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
import keycloak from "@/plugins/keycloak";
|
|
||||||
|
|
||||||
import type { QTableProps, QForm } from "quasar";
|
import type { QTableProps, QForm } from "quasar";
|
||||||
import type { DataProfile } from "@/modules/05_placement/interface/index/Main";
|
import type { DataProfile } from "@/modules/05_placement/interface/index/Main";
|
||||||
|
|
@ -19,6 +18,7 @@ import type {
|
||||||
} from "@/modules/05_placement/interface/response/Transfer";
|
} from "@/modules/05_placement/interface/response/Transfer";
|
||||||
import PopupPersonal from "@/components/Dialogs/PopupPersonal.vue";
|
import PopupPersonal from "@/components/Dialogs/PopupPersonal.vue";
|
||||||
import CardProfile from "@/components/CardProfile.vue";
|
import CardProfile from "@/components/CardProfile.vue";
|
||||||
|
import { tokenParsed } from "@/plugins/auth";
|
||||||
|
|
||||||
const modalPersonal = ref<boolean>(false);
|
const modalPersonal = ref<boolean>(false);
|
||||||
const personId = ref<string>("");
|
const personId = ref<string>("");
|
||||||
|
|
@ -304,8 +304,9 @@ function updatemodalPersonal(modal: boolean) {
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (keycloak.tokenParsed != null) {
|
const user = await tokenParsed();
|
||||||
roleAdmin.value = await keycloak.tokenParsed.role.includes("placement1");
|
if (user) {
|
||||||
|
roleAdmin.value = await user.role.includes("placement1");
|
||||||
}
|
}
|
||||||
await getData();
|
await getData();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,11 @@ import { useCounterMixin } from "@/stores/mixin";
|
||||||
import CurrencyInput from "@/components/CurruncyInput.vue";
|
import CurrencyInput from "@/components/CurruncyInput.vue";
|
||||||
import http from "@/plugins/http";
|
import http from "@/plugins/http";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
import keycloak from "@/plugins/keycloak";
|
|
||||||
/**Import type */
|
/**Import type */
|
||||||
import type { QForm } from "quasar";
|
import type { QForm } from "quasar";
|
||||||
import type { ResponseDataDetail } from "@/modules/06_retirement/interface/response/discharged";
|
import type { ResponseDataDetail } from "@/modules/06_retirement/interface/response/discharged";
|
||||||
import PopupPersonal from "@/components/Dialogs/PopupPersonal.vue";
|
import PopupPersonal from "@/components/Dialogs/PopupPersonal.vue";
|
||||||
|
import { tokenParsed } from "@/plugins/auth";
|
||||||
|
|
||||||
const modalPersonal = ref<boolean>(false);
|
const modalPersonal = ref<boolean>(false);
|
||||||
const personId = ref<string>("");
|
const personId = ref<string>("");
|
||||||
|
|
@ -64,8 +64,9 @@ const responseData = ref<ResponseDataDetail>({
|
||||||
|
|
||||||
/** Hook */
|
/** Hook */
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (keycloak.tokenParsed != null) {
|
const user = await tokenParsed();
|
||||||
roleAdmin.value = await keycloak.tokenParsed.role.includes("placement1");
|
if (user) {
|
||||||
|
roleAdmin.value = await user.role.includes("placement1");
|
||||||
}
|
}
|
||||||
await getData();
|
await getData();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import { useRoute, useRouter } from "vue-router";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
import http from "@/plugins/http";
|
import http from "@/plugins/http";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
import keycloak from "@/plugins/keycloak";
|
import { tokenParsed } from "@/plugins/auth";
|
||||||
|
|
||||||
/**Import type */
|
/**Import type */
|
||||||
import type { QForm } from "quasar";
|
import type { QForm } from "quasar";
|
||||||
|
|
@ -146,8 +146,9 @@ const getClass = (val: boolean) => {
|
||||||
|
|
||||||
/** Hook */
|
/** Hook */
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (keycloak.tokenParsed != null) {
|
const user = await tokenParsed();
|
||||||
roleAdmin.value = await keycloak.tokenParsed.role.includes("placement1");
|
if (user) {
|
||||||
|
roleAdmin.value = await user.role.includes("placement1");
|
||||||
}
|
}
|
||||||
await getData();
|
await getData();
|
||||||
});
|
});
|
||||||
|
|
@ -182,7 +183,11 @@ onMounted(async () => {
|
||||||
แก้ไขข้อมูลเพื่อลงบัญชีแนบท้าย
|
แก้ไขข้อมูลเพื่อลงบัญชีแนบท้าย
|
||||||
</div>
|
</div>
|
||||||
<q-space />
|
<q-space />
|
||||||
<div v-if="status !== 'DONE' && status !== 'REPORT' && !checkRoutePermisson">
|
<div
|
||||||
|
v-if="
|
||||||
|
status !== 'DONE' && status !== 'REPORT' && !checkRoutePermisson
|
||||||
|
"
|
||||||
|
>
|
||||||
<div class="q-gutter-sm" v-if="!edit">
|
<div class="q-gutter-sm" v-if="!edit">
|
||||||
<q-btn
|
<q-btn
|
||||||
outline
|
outline
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import { useRouter } from "vue-router";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
import http from "@/plugins/http";
|
import http from "@/plugins/http";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
// import keycloak from "@/plugins/keycloak";
|
|
||||||
|
|
||||||
import type { QForm } from "quasar";
|
import type { QForm } from "quasar";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import { useRoute, useRouter } from "vue-router";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
import http from "@/plugins/http";
|
import http from "@/plugins/http";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
import keycloak from "@/plugins/keycloak";
|
import { tokenParsed } from "@/plugins/auth";
|
||||||
|
|
||||||
/**import type*/
|
/**import type*/
|
||||||
import type {
|
import type {
|
||||||
|
|
@ -23,7 +23,9 @@ import CardProfile from "@/components/CardProfile.vue";
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const checkRoutePermisson = ref<boolean>(route.name == "exit-Interview-detailsOnly");
|
const checkRoutePermisson = ref<boolean>(
|
||||||
|
route.name == "exit-Interview-detailsOnly"
|
||||||
|
);
|
||||||
const mixin = useCounterMixin();
|
const mixin = useCounterMixin();
|
||||||
const dataId = route.params.id.toString();
|
const dataId = route.params.id.toString();
|
||||||
const {
|
const {
|
||||||
|
|
@ -80,8 +82,9 @@ const adjustOther = ref("");
|
||||||
|
|
||||||
/** HOOK */
|
/** HOOK */
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (keycloak.tokenParsed != null) {
|
const user = await tokenParsed();
|
||||||
roleAdmin.value = await keycloak.tokenParsed.role.includes("placement1");
|
if (user) {
|
||||||
|
roleAdmin.value = await user.role.includes("placement1");
|
||||||
}
|
}
|
||||||
await getData();
|
await getData();
|
||||||
await fecthquestion();
|
await fecthquestion();
|
||||||
|
|
@ -1087,9 +1090,14 @@ const putData = () => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-12" v-if="!checkRoutePermisson"><q-separator /></div>
|
<div class="col-12" v-if="!checkRoutePermisson">
|
||||||
|
<q-separator />
|
||||||
|
</div>
|
||||||
|
|
||||||
<q-card-actions class="col-12 text-primary q-pa-md" v-if="!checkRoutePermisson">
|
<q-card-actions
|
||||||
|
class="col-12 text-primary q-pa-md"
|
||||||
|
v-if="!checkRoutePermisson"
|
||||||
|
>
|
||||||
<q-space />
|
<q-space />
|
||||||
<q-btn
|
<q-btn
|
||||||
unelevated
|
unelevated
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@ import { useCounterMixin } from "@/stores/mixin";
|
||||||
import CurrencyInput from "@/components/CurruncyInput.vue";
|
import CurrencyInput from "@/components/CurruncyInput.vue";
|
||||||
import http from "@/plugins/http";
|
import http from "@/plugins/http";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
import keycloak from "@/plugins/keycloak";
|
import { tokenParsed } from "@/plugins/auth";
|
||||||
|
|
||||||
/**Import Type */
|
/**Import Type */
|
||||||
import type { QForm } from "quasar";
|
import type { QForm } from "quasar";
|
||||||
import type { ResponseDataDetail } from "@/modules/06_retirement/interface/response/expulsion";
|
import type { ResponseDataDetail } from "@/modules/06_retirement/interface/response/expulsion";
|
||||||
|
|
@ -62,8 +63,9 @@ const responseData = ref<ResponseDataDetail>({
|
||||||
|
|
||||||
/**Hook */
|
/**Hook */
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (keycloak.tokenParsed != null) {
|
const user = await tokenParsed();
|
||||||
roleAdmin.value = await keycloak.tokenParsed.role.includes("placement1");
|
if (user) {
|
||||||
|
roleAdmin.value = await user.role.includes("placement1");
|
||||||
}
|
}
|
||||||
await getData();
|
await getData();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@ import { useRetirementDataStore } from "@/modules/06_retirement/store";
|
||||||
import http from "@/plugins/http";
|
import http from "@/plugins/http";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import { tokenParsed } from "@/plugins/auth";
|
||||||
|
|
||||||
import keycloak from "@/plugins/keycloak";
|
|
||||||
import type {
|
import type {
|
||||||
TypeFile,
|
TypeFile,
|
||||||
rowFile,
|
rowFile,
|
||||||
|
|
@ -144,10 +144,11 @@ const checkboxOp = ref<CheckBoxType[]>([
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
fetchData(id.value);
|
fetchData(id.value);
|
||||||
fetchFile();
|
fetchFile();
|
||||||
if (keycloak.tokenParsed !== undefined) {
|
const user = await tokenParsed();
|
||||||
const commander = await keycloak.tokenParsed.role.includes("commander");
|
if (user) {
|
||||||
const oligarch = await keycloak.tokenParsed.role.includes("oligarch");
|
const commander = await user.role.includes("commander");
|
||||||
const officer = await keycloak.tokenParsed.role.includes("officer");
|
const oligarch = await kuser.role.includes("oligarch");
|
||||||
|
const officer = await user.role.includes("officer");
|
||||||
if (commander) {
|
if (commander) {
|
||||||
roleUser.value = "commander";
|
roleUser.value = "commander";
|
||||||
} else if (oligarch) {
|
} else if (oligarch) {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ import allLocales from "@fullcalendar/core/locales-all";
|
||||||
import listPlugin from "@fullcalendar/list";
|
import listPlugin from "@fullcalendar/list";
|
||||||
import http from "@/plugins/http";
|
import http from "@/plugins/http";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
import keycloak from "@/plugins/keycloak";
|
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { checkPermission } from "@/utils/permissions";
|
import { checkPermission } from "@/utils/permissions";
|
||||||
/** importType*/
|
/** importType*/
|
||||||
|
|
@ -19,6 +18,7 @@ import type {
|
||||||
DataDateMonthObject,
|
DataDateMonthObject,
|
||||||
ResCalendar,
|
ResCalendar,
|
||||||
} from "@/modules/09_leave/interface/response/leave";
|
} from "@/modules/09_leave/interface/response/leave";
|
||||||
|
import { tokenParsed } from "@/plugins/auth";
|
||||||
|
|
||||||
/** importStore*/
|
/** importStore*/
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
|
|
@ -32,9 +32,7 @@ const router = useRouter();
|
||||||
|
|
||||||
const { showLoader, hideLoader, messageError, monthYear2Thai } = mixin;
|
const { showLoader, hideLoader, messageError, monthYear2Thai } = mixin;
|
||||||
|
|
||||||
const keycloakId = ref<string>(
|
const keycloakId = ref<string>("");
|
||||||
keycloak.tokenParsed ? keycloak.tokenParsed.sub!.toString() : ""
|
|
||||||
);
|
|
||||||
/**
|
/**
|
||||||
* Option ของปฏิทิน
|
* Option ของปฏิทิน
|
||||||
*/
|
*/
|
||||||
|
|
@ -209,6 +207,8 @@ function redirectToDetail(id: string) {
|
||||||
* เรียกฟังก์ชันทั้งหมดตอนเรียกใช้ไฟล์นี้
|
* เรียกฟังก์ชันทั้งหมดตอนเรียกใช้ไฟล์นี้
|
||||||
*/
|
*/
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
const user = await tokenParsed();
|
||||||
|
keycloakId.value = user?.sub;
|
||||||
await fetchDataCalendar("onMounted");
|
await fetchDataCalendar("onMounted");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -292,11 +292,19 @@ const monthYearThai = (val: DataDateMonthObject) => {
|
||||||
<template v-slot:eventContent="arg">
|
<template v-slot:eventContent="arg">
|
||||||
<div
|
<div
|
||||||
class="row col-12 items-center no-wrap"
|
class="row col-12 items-center no-wrap"
|
||||||
:style="checkPermission($route)?.attrIsGet ? `background: + ${arg.event.color}`:`background: + ${arg.event.color};pointer-events: none;cursor: auto;`"
|
:style="
|
||||||
|
checkPermission($route)?.attrIsGet
|
||||||
|
? `background: + ${arg.event.color}`
|
||||||
|
: `background: + ${arg.event.color};pointer-events: none;cursor: auto;`
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="textHover col-10"
|
class="textHover col-10"
|
||||||
@click="checkPermission($route)?.attrIsGet ? redirectToDetail(arg.event.id):''"
|
@click="
|
||||||
|
checkPermission($route)?.attrIsGet
|
||||||
|
? redirectToDetail(arg.event.id)
|
||||||
|
: ''
|
||||||
|
"
|
||||||
>
|
>
|
||||||
{{ arg.event.title }}
|
{{ arg.event.title }}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import { useRoute, useRouter } from "vue-router";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
import http from "@/plugins/http";
|
import http from "@/plugins/http";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
import keycloak from "@/plugins/keycloak";
|
import { tokenParsed } from "@/plugins/auth";
|
||||||
import { useDisciplineSuspendStore } from "@/modules/11_discipline/store/SuspendStore";
|
import { useDisciplineSuspendStore } from "@/modules/11_discipline/store/SuspendStore";
|
||||||
|
|
||||||
/**Import type */
|
/**Import type */
|
||||||
|
|
@ -16,7 +16,6 @@ import type { DataProfile } from "@/modules/05_placement/interface/index/Main";
|
||||||
import PopupPersonal from "@/components/Dialogs/PopupPersonalNew.vue";
|
import PopupPersonal from "@/components/Dialogs/PopupPersonalNew.vue";
|
||||||
import CardProfile from "@/components/CardProfile.vue";
|
import CardProfile from "@/components/CardProfile.vue";
|
||||||
|
|
||||||
|
|
||||||
const modalPersonal = ref<boolean>(false);
|
const modalPersonal = ref<boolean>(false);
|
||||||
const personId = ref<string>("");
|
const personId = ref<string>("");
|
||||||
/** use */
|
/** use */
|
||||||
|
|
@ -24,7 +23,9 @@ const dataStore = useDisciplineSuspendStore();
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const checkRoutePermission = ref<boolean>(route.name == 'disciplineDetailSuspend')
|
const checkRoutePermission = ref<boolean>(
|
||||||
|
route.name == "disciplineDetailSuspend"
|
||||||
|
);
|
||||||
const mixin = useCounterMixin();
|
const mixin = useCounterMixin();
|
||||||
const dataId = route.params.id.toString();
|
const dataId = route.params.id.toString();
|
||||||
const {
|
const {
|
||||||
|
|
@ -251,8 +252,9 @@ function changeFormDataDate() {
|
||||||
|
|
||||||
/** Hook */
|
/** Hook */
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (keycloak.tokenParsed != null) {
|
const user = await tokenParsed();
|
||||||
roleAdmin.value = await keycloak.tokenParsed.role.includes("placement1");
|
if (user) {
|
||||||
|
roleAdmin.value = await user.role.includes("placement1");
|
||||||
}
|
}
|
||||||
await getData();
|
await getData();
|
||||||
});
|
});
|
||||||
|
|
@ -332,10 +334,20 @@ onMounted(async () => {
|
||||||
<q-form greedy @submit.prevent @validation-success="saveData">
|
<q-form greedy @submit.prevent @validation-success="saveData">
|
||||||
<div class="bg-grey-1 q-pa-sm col-12 row items-center text-primary">
|
<div class="bg-grey-1 q-pa-sm col-12 row items-center text-primary">
|
||||||
<div class="q-pl-sm text-weight-bold text-dark">
|
<div class="q-pl-sm text-weight-bold text-dark">
|
||||||
{{ checkRoutePermission ? 'รายละเอียดข้อมูลบัญชีแนบท้าย':'แก้ไขข้อมูลเพื่อลงบัญชีแนบท้าย'}}
|
{{
|
||||||
|
checkRoutePermission
|
||||||
|
? "รายละเอียดข้อมูลบัญชีแนบท้าย"
|
||||||
|
: "แก้ไขข้อมูลเพื่อลงบัญชีแนบท้าย"
|
||||||
|
}}
|
||||||
</div>
|
</div>
|
||||||
<q-space />
|
<q-space />
|
||||||
<div v-if="data.status !== 'DONE' && data.status !== 'REPORT'&& !checkRoutePermission">
|
<div
|
||||||
|
v-if="
|
||||||
|
data.status !== 'DONE' &&
|
||||||
|
data.status !== 'REPORT' &&
|
||||||
|
!checkRoutePermission
|
||||||
|
"
|
||||||
|
>
|
||||||
<div class="q-gutter-sm" v-if="!edit">
|
<div class="q-gutter-sm" v-if="!edit">
|
||||||
<q-btn
|
<q-btn
|
||||||
outline
|
outline
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
import avatar from "@/assets/avatar_user.jpg";
|
import avatar from "@/assets/avatar_user.jpg";
|
||||||
import { ref, reactive, onMounted } from "vue";
|
import { ref, reactive, onMounted } from "vue";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
import keycloak from "@/plugins/keycloak";
|
|
||||||
|
|
||||||
import { useRoute, useRouter } from "vue-router";
|
import { useRoute, useRouter } from "vue-router";
|
||||||
|
|
||||||
|
|
@ -11,13 +10,13 @@ import config from "@/app.config";
|
||||||
import { useQuasar, type QTableProps } from "quasar";
|
import { useQuasar, type QTableProps } from "quasar";
|
||||||
|
|
||||||
interface ListMain {
|
interface ListMain {
|
||||||
id: string
|
id: string;
|
||||||
round_no: number;
|
round_no: number;
|
||||||
date_start: string
|
date_start: string;
|
||||||
date_finish: string
|
date_finish: string;
|
||||||
mentors: string
|
mentors: string;
|
||||||
commander: string
|
commander: string;
|
||||||
chairman: string
|
chairman: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const profileId = ref<string>("");
|
const profileId = ref<string>("");
|
||||||
|
|
@ -38,7 +37,7 @@ const mode = ref<any>($q.screen.gt.xs);
|
||||||
const profileImg = ref<string>("");
|
const profileImg = ref<string>("");
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const idEva = ref<string>(route.params.id as string)
|
const idEva = ref<string>(route.params.id as string);
|
||||||
const formData = reactive<any>({
|
const formData = reactive<any>({
|
||||||
prefix: "",
|
prefix: "",
|
||||||
firstName: "",
|
firstName: "",
|
||||||
|
|
@ -123,7 +122,7 @@ function onMobile(type: string) {
|
||||||
function getMain() {
|
function getMain() {
|
||||||
showLoader();
|
showLoader();
|
||||||
http
|
http
|
||||||
.get(config.API.profilePosition+`/${idEva.value}`)
|
.get(config.API.profilePosition + `/${idEva.value}`)
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
const data = res.data.result;
|
const data = res.data.result;
|
||||||
formData.prefix = data.prefix;
|
formData.prefix = data.prefix;
|
||||||
|
|
@ -182,7 +181,7 @@ onMounted(async () => {
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="toptitle col-12 row items-center">
|
<div class="toptitle col-12 row items-center">
|
||||||
<q-btn
|
<q-btn
|
||||||
icon="mdi-arrow-left"
|
icon="mdi-arrow-left"
|
||||||
unelevated
|
unelevated
|
||||||
|
|
@ -195,104 +194,102 @@ onMounted(async () => {
|
||||||
/>
|
/>
|
||||||
รายละเอียดงานที่ได้รับมอบหมาย
|
รายละเอียดงานที่ได้รับมอบหมาย
|
||||||
</div>
|
</div>
|
||||||
<div class="row q-col-gutter-md">
|
<div class="row q-col-gutter-md">
|
||||||
<div v-if="$q.screen.gt.xs" class="col-12">
|
<div v-if="$q.screen.gt.xs" class="col-12">
|
||||||
<q-card>
|
<q-card>
|
||||||
<div class="bg-grey-1 row q-pa-sm items-center">
|
<div class="bg-grey-1 row q-pa-sm items-center">
|
||||||
<span class="text-teal text-weight-bold text-body2">{{
|
<span class="text-teal text-weight-bold text-body2">{{
|
||||||
formData.firstName
|
formData.firstName
|
||||||
? `${formData.prefix}${formData.firstName} ${formData.lastName}`
|
? `${formData.prefix}${formData.firstName} ${formData.lastName}`
|
||||||
: "-"
|
: "-"
|
||||||
}}</span>
|
}}</span>
|
||||||
|
</div>
|
||||||
|
<q-resize-observer @resize="onResize" />
|
||||||
|
<q-card-section class="q-pa-md">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-2 text-center self-center">
|
||||||
|
<q-avatar :size="sizeImg" rounded>
|
||||||
|
<img
|
||||||
|
:src="profileImg"
|
||||||
|
style="border-radius: 10px; object-fit: cover"
|
||||||
|
/>
|
||||||
|
</q-avatar>
|
||||||
</div>
|
</div>
|
||||||
<q-resize-observer @resize="onResize" />
|
<div class="col-10 column justify-center no-wrap">
|
||||||
<q-card-section class="q-pa-md">
|
<div class="row text-grey-6">
|
||||||
|
<div class="col-4">ตำแหน่งในสายงาน</div>
|
||||||
|
<div class="col-4">ระดับ</div>
|
||||||
|
<div class="col-4">สังกัด</div>
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-2 text-center self-center">
|
<div class="col-4">
|
||||||
<q-avatar :size="sizeImg" rounded>
|
{{ formData.position ? formData.position : "-" }}
|
||||||
<img
|
|
||||||
:src="profileImg"
|
|
||||||
style="border-radius: 10px; object-fit: cover"
|
|
||||||
/>
|
|
||||||
</q-avatar>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-10 column justify-center no-wrap">
|
<div class="col-4">
|
||||||
<div class="row text-grey-6">
|
{{ formData.posLevelName ? formData.posLevelName : "-" }}
|
||||||
<div class="col-4">ตำแหน่งในสายงาน</div>
|
</div>
|
||||||
<div class="col-4">ระดับ</div>
|
<div class="col-4">
|
||||||
<div class="col-4">สังกัด</div>
|
{{ formData.org ? formData.org : "-" }}
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-4">
|
|
||||||
{{ formData.position ? formData.position : "-" }}
|
|
||||||
</div>
|
|
||||||
<div class="col-4">
|
|
||||||
{{ formData.posLevelName ? formData.posLevelName : "-" }}
|
|
||||||
</div>
|
|
||||||
<div class="col-4">
|
|
||||||
{{ formData.org ? formData.org : "-" }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</q-card-section>
|
|
||||||
</q-card>
|
|
||||||
</div>
|
|
||||||
<div v-else class="col-12">
|
|
||||||
<q-card bordered>
|
|
||||||
<div class="bg-grey-1 row q-pa-sm items-center">
|
|
||||||
<span class="text-teal text-weight-bold text-body2">{{
|
|
||||||
formData.firstName
|
|
||||||
? `${formData.prefix}${formData.firstName} ${formData.lastName}`
|
|
||||||
: "-"
|
|
||||||
}}</span>
|
|
||||||
</div>
|
</div>
|
||||||
<q-resize-observer @resize="onResize" />
|
</div>
|
||||||
<q-card-section>
|
</q-card-section>
|
||||||
<div class="text-center q-mt-md">
|
</q-card>
|
||||||
<q-avatar :size="sizeImg" rounded>
|
</div>
|
||||||
<img
|
<div v-else class="col-12">
|
||||||
:src="profileImg"
|
<q-card bordered>
|
||||||
style="border-radius: 10px; object-fit: cover"
|
<div class="bg-grey-1 row q-pa-sm items-center">
|
||||||
/>
|
<span class="text-teal text-weight-bold text-body2">{{
|
||||||
</q-avatar>
|
formData.firstName
|
||||||
</div>
|
? `${formData.prefix}${formData.firstName} ${formData.lastName}`
|
||||||
</q-card-section>
|
: "-"
|
||||||
|
}}</span>
|
||||||
<q-list class="q-mt-md">
|
|
||||||
<q-item>
|
|
||||||
<q-item-section>
|
|
||||||
<q-item-label class="text-grey-6"
|
|
||||||
>ตำแหน่งในสายงาน</q-item-label
|
|
||||||
>
|
|
||||||
<q-item-label>{{
|
|
||||||
formData.position ? formData.position : "-"
|
|
||||||
}}</q-item-label>
|
|
||||||
</q-item-section>
|
|
||||||
</q-item>
|
|
||||||
<q-item>
|
|
||||||
<q-item-section>
|
|
||||||
<q-item-label class="text-grey-6">ระดับ</q-item-label>
|
|
||||||
<q-item-label>{{
|
|
||||||
formData.posLevelName ? formData.posLevelName : "-"
|
|
||||||
}}</q-item-label>
|
|
||||||
</q-item-section>
|
|
||||||
</q-item>
|
|
||||||
<q-item>
|
|
||||||
<q-item-section>
|
|
||||||
<q-item-label class="text-grey-6">สังกัด</q-item-label>
|
|
||||||
<q-item-label>{{
|
|
||||||
formData.org ? formData.org : "-"
|
|
||||||
}}</q-item-label>
|
|
||||||
</q-item-section>
|
|
||||||
</q-item>
|
|
||||||
</q-list>
|
|
||||||
</q-card>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 row">
|
<q-resize-observer @resize="onResize" />
|
||||||
<q-card bordered class="col-12 q-pa-md">
|
<q-card-section>
|
||||||
<div class="row">
|
<div class="text-center q-mt-md">
|
||||||
<!-- <q-btn
|
<q-avatar :size="sizeImg" rounded>
|
||||||
|
<img
|
||||||
|
:src="profileImg"
|
||||||
|
style="border-radius: 10px; object-fit: cover"
|
||||||
|
/>
|
||||||
|
</q-avatar>
|
||||||
|
</div>
|
||||||
|
</q-card-section>
|
||||||
|
|
||||||
|
<q-list class="q-mt-md">
|
||||||
|
<q-item>
|
||||||
|
<q-item-section>
|
||||||
|
<q-item-label class="text-grey-6">ตำแหน่งในสายงาน</q-item-label>
|
||||||
|
<q-item-label>{{
|
||||||
|
formData.position ? formData.position : "-"
|
||||||
|
}}</q-item-label>
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
<q-item>
|
||||||
|
<q-item-section>
|
||||||
|
<q-item-label class="text-grey-6">ระดับ</q-item-label>
|
||||||
|
<q-item-label>{{
|
||||||
|
formData.posLevelName ? formData.posLevelName : "-"
|
||||||
|
}}</q-item-label>
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
<q-item>
|
||||||
|
<q-item-section>
|
||||||
|
<q-item-label class="text-grey-6">สังกัด</q-item-label>
|
||||||
|
<q-item-label>{{
|
||||||
|
formData.org ? formData.org : "-"
|
||||||
|
}}</q-item-label>
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</q-list>
|
||||||
|
</q-card>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 row">
|
||||||
|
<q-card bordered class="col-12 q-pa-md">
|
||||||
|
<div class="row">
|
||||||
|
<!-- <q-btn
|
||||||
@click="router.push(`/probation/add/${profileId}`)"
|
@click="router.push(`/probation/add/${profileId}`)"
|
||||||
size="12px"
|
size="12px"
|
||||||
flat
|
flat
|
||||||
|
|
@ -302,141 +299,133 @@ onMounted(async () => {
|
||||||
>
|
>
|
||||||
<q-tooltip>เพิ่มงานที่ได้รับมอบหมาย</q-tooltip>
|
<q-tooltip>เพิ่มงานที่ได้รับมอบหมาย</q-tooltip>
|
||||||
</q-btn> -->
|
</q-btn> -->
|
||||||
<q-space />
|
<q-space />
|
||||||
<q-input
|
<q-input
|
||||||
class="inputgreen"
|
class="inputgreen"
|
||||||
outlined
|
outlined
|
||||||
dense
|
dense
|
||||||
v-model="filter"
|
v-model="filter"
|
||||||
label="ค้นหา"
|
label="ค้นหา"
|
||||||
:style="mode ? `max-width: 200px` : `max-width: 150px`"
|
:style="mode ? `max-width: 200px` : `max-width: 150px`"
|
||||||
>
|
>
|
||||||
<template v-slot:append>
|
<template v-slot:append>
|
||||||
<q-icon
|
<q-icon
|
||||||
v-if="filter !== ''"
|
v-if="filter !== ''"
|
||||||
name="clear"
|
name="clear"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click="filter = ''"
|
@click="filter = ''"
|
||||||
/>
|
|
||||||
<q-icon
|
|
||||||
v-else
|
|
||||||
name="search"
|
|
||||||
class="cursor-pointer"
|
|
||||||
@click="filter = ''"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</q-input>
|
|
||||||
<q-select
|
|
||||||
v-if="$q.screen.gt.xs"
|
|
||||||
class="q-ml-sm"
|
|
||||||
dense
|
|
||||||
multiple
|
|
||||||
outlined
|
|
||||||
emit-value
|
|
||||||
map-options
|
|
||||||
options-cover
|
|
||||||
options-dense
|
|
||||||
option-value="name"
|
|
||||||
style="min-width: 150px"
|
|
||||||
v-model="visibleColumns"
|
|
||||||
:options="columns"
|
|
||||||
:display-value="$q.lang.table.columns"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
<q-icon
|
||||||
<div class="q-mt-sm">
|
v-else
|
||||||
<d-table
|
name="search"
|
||||||
flat
|
class="cursor-pointer"
|
||||||
dense
|
@click="filter = ''"
|
||||||
bordered
|
/>
|
||||||
ref="table"
|
</template>
|
||||||
virtual-scroll
|
</q-input>
|
||||||
:rows="rows"
|
<q-select
|
||||||
:columns="columns"
|
v-if="$q.screen.gt.xs"
|
||||||
:grid="!$q.screen.gt.xs"
|
class="q-ml-sm"
|
||||||
:filter="filter"
|
dense
|
||||||
:rows-per-page-options="[10, 25, 50, 100]"
|
multiple
|
||||||
:visible-columns="visibleColumns"
|
outlined
|
||||||
:virtual-scroll-sticky-size-start="48"
|
emit-value
|
||||||
>
|
map-options
|
||||||
<template v-slot:header="props">
|
options-cover
|
||||||
<q-tr :props="props">
|
options-dense
|
||||||
<q-th
|
option-value="name"
|
||||||
v-for="col in props.cols"
|
style="min-width: 150px"
|
||||||
:key="col.name"
|
v-model="visibleColumns"
|
||||||
:props="props"
|
:options="columns"
|
||||||
>
|
:display-value="$q.lang.table.columns"
|
||||||
<span class="text-weight-medium">{{ col.label }}</span>
|
/>
|
||||||
</q-th>
|
</div>
|
||||||
</q-tr>
|
<div class="q-mt-sm">
|
||||||
</template>
|
<d-table
|
||||||
|
flat
|
||||||
|
dense
|
||||||
|
bordered
|
||||||
|
ref="table"
|
||||||
|
virtual-scroll
|
||||||
|
:rows="rows"
|
||||||
|
:columns="columns"
|
||||||
|
:grid="!$q.screen.gt.xs"
|
||||||
|
:filter="filter"
|
||||||
|
:rows-per-page-options="[10, 25, 50, 100]"
|
||||||
|
:visible-columns="visibleColumns"
|
||||||
|
:virtual-scroll-sticky-size-start="48"
|
||||||
|
>
|
||||||
|
<template v-slot:header="props">
|
||||||
|
<q-tr :props="props">
|
||||||
|
<q-th v-for="col in props.cols" :key="col.name" :props="props">
|
||||||
|
<span class="text-weight-medium">{{ col.label }}</span>
|
||||||
|
</q-th>
|
||||||
|
</q-tr>
|
||||||
|
</template>
|
||||||
|
|
||||||
<template v-if="$q.screen.gt.xs" v-slot:body="props">
|
<template v-if="$q.screen.gt.xs" v-slot:body="props">
|
||||||
<q-tr :props="props" class="cursor-pointer">
|
<q-tr :props="props" class="cursor-pointer">
|
||||||
<q-td
|
<q-td
|
||||||
v-for="(col, index) in props.cols"
|
v-for="(col, index) in props.cols"
|
||||||
:key="col.name"
|
:key="col.name"
|
||||||
|
@click="onDetail(props.row.id)"
|
||||||
|
>
|
||||||
|
<div v-if="col.name == 'no'">
|
||||||
|
{{ props.rowIndex + 1 }}
|
||||||
|
</div>
|
||||||
|
<div v-else-if="col.name == 'status'">
|
||||||
|
{{ props.row.status ? props.row.status : "-" }}
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
{{ col.value ? col.value : "-" }}
|
||||||
|
</div>
|
||||||
|
</q-td>
|
||||||
|
</q-tr>
|
||||||
|
</template>
|
||||||
|
<template v-else v-slot:item="props">
|
||||||
|
<div class="q-mb-xs col-xs-12 col-sm-6 col-md-4 col-lg-3">
|
||||||
|
<q-card bordered flat>
|
||||||
|
<q-list dense class="q-mt-lg relative-position">
|
||||||
|
<q-btn
|
||||||
|
icon="info"
|
||||||
|
color="info"
|
||||||
|
flat
|
||||||
|
dense
|
||||||
|
round
|
||||||
|
size="14px"
|
||||||
|
class="absolute_button"
|
||||||
@click="onDetail(props.row.id)"
|
@click="onDetail(props.row.id)"
|
||||||
>
|
>
|
||||||
<div v-if="col.name == 'no'">
|
<q-tooltip>ประวัติแก้ไขตำแหน่ง/เงินเดือน</q-tooltip>
|
||||||
{{ props.rowIndex + 1 }}
|
</q-btn>
|
||||||
</div>
|
<q-item v-for="col in props.cols" :key="col.name">
|
||||||
<div v-else-if="col.name == 'status'">
|
<q-item-section class="fix_top">
|
||||||
{{ props.row.status ? props.row.status : "-" }}
|
<q-item-label class="text-grey-6 text-weight-medium">{{
|
||||||
</div>
|
col.label
|
||||||
<div v-else>
|
}}</q-item-label>
|
||||||
{{ col.value ? col.value : "-" }}
|
</q-item-section>
|
||||||
</div>
|
<q-item-section class="fix_top">
|
||||||
</q-td>
|
<q-item-label class="text-dark text-weight-medium">{{
|
||||||
</q-tr>
|
col.value ? col.value : "-"
|
||||||
</template>
|
}}</q-item-label>
|
||||||
<template v-else v-slot:item="props">
|
</q-item-section>
|
||||||
<div class="q-mb-xs col-xs-12 col-sm-6 col-md-4 col-lg-3">
|
</q-item>
|
||||||
<q-card bordered flat>
|
</q-list>
|
||||||
<q-list dense class="q-mt-lg relative-position">
|
</q-card>
|
||||||
<q-btn
|
</div>
|
||||||
icon="info"
|
</template>
|
||||||
color="info"
|
<template v-slot:no-data>
|
||||||
flat
|
<div
|
||||||
dense
|
class="full-width row flex-center q-pa-sm rounded-borders text-weight-medium"
|
||||||
round
|
>
|
||||||
size="14px"
|
<span> ไม่พบข้อมูล </span>
|
||||||
class="absolute_button"
|
</div>
|
||||||
@click="onDetail(props.row.id)"
|
</template>
|
||||||
>
|
</d-table>
|
||||||
<q-tooltip>ประวัติแก้ไขตำแหน่ง/เงินเดือน</q-tooltip>
|
|
||||||
</q-btn>
|
|
||||||
<q-item v-for="col in props.cols" :key="col.name">
|
|
||||||
<q-item-section class="fix_top">
|
|
||||||
<q-item-label
|
|
||||||
class="text-grey-6 text-weight-medium"
|
|
||||||
>{{ col.label }}</q-item-label
|
|
||||||
>
|
|
||||||
</q-item-section>
|
|
||||||
<q-item-section class="fix_top">
|
|
||||||
<q-item-label
|
|
||||||
class="text-dark text-weight-medium"
|
|
||||||
>{{ col.value ? col.value : "-" }}</q-item-label
|
|
||||||
>
|
|
||||||
</q-item-section>
|
|
||||||
</q-item>
|
|
||||||
</q-list>
|
|
||||||
</q-card>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<template v-slot:no-data>
|
|
||||||
<div
|
|
||||||
class="full-width row flex-center q-pa-sm rounded-borders text-weight-medium"
|
|
||||||
>
|
|
||||||
<span> ไม่พบข้อมูล </span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</d-table>
|
|
||||||
</div>
|
|
||||||
</q-card>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</q-card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.absolute_button {
|
.absolute_button {
|
||||||
|
|
|
||||||
71
src/plugins/auth.ts
Normal file
71
src/plugins/auth.ts
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
const ACCESS_TOKEN = "BMAHRIS_KEYCLOAK_IDENTITY";
|
||||||
|
|
||||||
|
interface AuthResponse {
|
||||||
|
access_token: string;
|
||||||
|
expires_in: number;
|
||||||
|
refresh_token: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const authenticated = async () => ((await getToken()) ? true : false);
|
||||||
|
|
||||||
|
async function setAuthen(r: AuthResponse) {
|
||||||
|
await setCookie(ACCESS_TOKEN, r.access_token, r.expires_in);
|
||||||
|
window.location.href = "/login";
|
||||||
|
}
|
||||||
|
|
||||||
|
async function logout() {
|
||||||
|
await deleteCookie(ACCESS_TOKEN);
|
||||||
|
window.location.href = "/login";
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getToken() {
|
||||||
|
return getCookie(ACCESS_TOKEN);
|
||||||
|
}
|
||||||
|
// 2024-08-29T02:55:13.000Z
|
||||||
|
function setCookie(name: string, value: any, time: number) {
|
||||||
|
let expires = "";
|
||||||
|
if (time) {
|
||||||
|
const date = new Date();
|
||||||
|
date.setTime(date.getTime() + time * 1000);
|
||||||
|
// date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
||||||
|
expires = "; expires=" + date.toUTCString();
|
||||||
|
}
|
||||||
|
document.cookie = name + "=" + (value || "") + expires + "; path=/";
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCookie(name: string) {
|
||||||
|
const nameEQ = name + "=";
|
||||||
|
const ca = document.cookie.split(";");
|
||||||
|
for (let i = 0; i < ca.length; i++) {
|
||||||
|
let c = ca[i];
|
||||||
|
while (c.charAt(0) == " ") c = c.substring(1, c.length);
|
||||||
|
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteCookie(name: string) {
|
||||||
|
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function tokenParsed() {
|
||||||
|
const token = await getCookie(ACCESS_TOKEN);
|
||||||
|
if (!token) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const base64Url = token.split(".")[1];
|
||||||
|
const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
|
||||||
|
const jsonPayload = decodeURIComponent(
|
||||||
|
window
|
||||||
|
.atob(base64)
|
||||||
|
.split("")
|
||||||
|
.map(function (c) {
|
||||||
|
return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
|
||||||
|
})
|
||||||
|
.join("")
|
||||||
|
);
|
||||||
|
|
||||||
|
return JSON.parse(jsonPayload);
|
||||||
|
}
|
||||||
|
|
||||||
|
export { getToken, authenticated, logout, setAuthen, tokenParsed };
|
||||||
|
|
@ -1,25 +1,24 @@
|
||||||
import axios from "axios"
|
import axios from "axios";
|
||||||
import config from "process"
|
|
||||||
// import { dotnetPath } from "../path/axiosPath";
|
// import { dotnetPath } from "../path/axiosPath";
|
||||||
// import { getToken } from "@baloise/vue-keycloak";
|
// import { getToken } from "@baloise/vue-keycloak";
|
||||||
import keycloak from "../plugins/keycloak"
|
import { getToken } from "../plugins/auth";
|
||||||
|
|
||||||
const axiosInstance = axios.create({
|
const axiosInstance = axios.create({
|
||||||
withCredentials: false,
|
withCredentials: false,
|
||||||
})
|
});
|
||||||
|
|
||||||
// axiosInstance.defaults.baseURL = dotnetPath;
|
// axiosInstance.defaults.baseURL = dotnetPath;
|
||||||
axiosInstance.interceptors.request.use(
|
axiosInstance.interceptors.request.use(
|
||||||
async (config) => {
|
async (config: any) => {
|
||||||
const token = await keycloak.token
|
const token = await getToken();
|
||||||
config.headers = {
|
config.headers = {
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
}
|
};
|
||||||
return config
|
return config;
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
Promise.reject(error)
|
Promise.reject(error);
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
|
|
||||||
export default axiosInstance
|
export default axiosInstance;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import Axios, { type AxiosRequestConfig, type AxiosResponse } from "axios";
|
import Axios, { type AxiosRequestConfig, type AxiosResponse } from "axios";
|
||||||
import keycloak from "./keycloak";
|
import { getToken } from "./auth";
|
||||||
|
|
||||||
const http = Axios.create({
|
const http = Axios.create({
|
||||||
timeout: 1000000000, // เพิ่มค่า timeout
|
timeout: 1000000000, // เพิ่มค่า timeout
|
||||||
|
|
@ -12,10 +12,7 @@ http.interceptors.request.use(
|
||||||
async function (config: AxiosRequestConfig<any>) {
|
async function (config: AxiosRequestConfig<any>) {
|
||||||
// await keycloak.updateToken(1);
|
// await keycloak.updateToken(1);
|
||||||
config.headers = config.headers ?? {};
|
config.headers = config.headers ?? {};
|
||||||
const token = keycloak.token;
|
const token = await getToken();
|
||||||
// const token = localStorage.getItem("access_token")
|
|
||||||
// const token =
|
|
||||||
// "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICIxU2VKV2dVRFVlNXZwNS13Q1ZHaG9lT2l4bDJTTkdKemthLU5ZN211NXZJIn0.eyJleHAiOjE2NzI0MTI1NDksImlhdCI6MTY3MjM3NjU0OSwiYXV0aF90aW1lIjoxNjcyMzc2NTQ5LCJqdGkiOiI1MTVhY2IwNC1jODQ3LTQzM2YtYjUxOC03ODUzMzJhY2ZjNWYiLCJpc3MiOiJodHRwczovL2tleWNsb2FrLmZyYXBwZXQuc3lub2xvZ3kubWUvYXV0aC9yZWFsbXMvYm1hLWVociIsImF1ZCI6ImFjY291bnQiLCJzdWIiOiJlZmM5YjRlMC1mZGU2LTQ1NDQtYmU1OS1lMTA0MjEwMjUzZjAiLCJ0eXAiOiJCZWFyZXIiLCJhenAiOiJibWEtZWhyIiwibm9uY2UiOiI3NjMyMGI3ZS0xZTMxLTQ5ODYtYWIzOC1iOTUyYjFlODY3OGYiLCJzZXNzaW9uX3N0YXRlIjoiMDZlNTBkZjktNzAyNi00ZGIwLTkxMjgtMWY3Y2FiYTRkNDEyIiwiYWNyIjoiMSIsImFsbG93ZWQtb3JpZ2lucyI6WyJodHRwczovL2xvY2FsaG9zdDo3MDA2Il0sInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJkZWZhdWx0LXJvbGVzLWJtYS1laHIiLCJvZmZsaW5lX2FjY2VzcyIsImFkbWluIiwidW1hX2F1dGhvcml6YXRpb24iXX0sInJlc291cmNlX2FjY2VzcyI6eyJhY2NvdW50Ijp7InJvbGVzIjpbIm1hbmFnZS1hY2NvdW50IiwibWFuYWdlLWFjY291bnQtbGlua3MiLCJ2aWV3LXByb2ZpbGUiXX19LCJzY29wZSI6Im9wZW5pZCBlbWFpbCBwcm9maWxlIiwic2lkIjoiMDZlNTBkZjktNzAyNi00ZGIwLTkxMjgtMWY3Y2FiYTRkNDEyIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsInJvbGUiOlsiZGVmYXVsdC1yb2xlcy1ibWEtZWhyIiwib2ZmbGluZV9hY2Nlc3MiLCJhZG1pbiIsInVtYV9hdXRob3JpemF0aW9uIl0sIm5hbWUiOiJTeXN0ZW0gQWRtaW5pc3RyYXRvciIsInByZWZlcnJlZF91c2VybmFtZSI6ImFkbWluIiwiZ2l2ZW5fbmFtZSI6IlN5c3RlbSIsImZhbWlseV9uYW1lIjoiQWRtaW5pc3RyYXRvciIsImVtYWlsIjoiYWRtaW5AbG9jYWxob3N0In0.xmfJ3pzI-jLYsaiFXyjTW7gfAEpvUmMVsp9BsB1CfRCVOKiGBbuZhnQY8W-1SWVAx1NjJ55L-zMHPK6hk1dRPLbEse3DlIBZw04W9j8m-Wz3eqdHf_UCjmrXb8qAwkeq0Iaxq9mVfJJeQWeKhFBi-Ff8ek4hCXTYDICXS8ny_BaC5WkyrefHQ2xBqQjwRyoxsg4IoVMjXYNb8L9A-4BNlRfs928SqgFYCRlF5h6zw_rC0XoLrGTmqeacBdpey-r3j2g_lTqWy8mQg2T9s65IDqW3kFPOsr0SVO88sjlFbN9Et0L57RmiqORk_RwzbWg-_Yb6dOuolXsnjBOhOoTzkA";
|
|
||||||
if (token) config.headers.Authorization = `Bearer ${token}`;
|
if (token) config.headers.Authorization = `Bearer ${token}`;
|
||||||
return config;
|
return config;
|
||||||
},
|
},
|
||||||
|
|
@ -34,7 +31,6 @@ http.interceptors.response.use(
|
||||||
if (error.hasOwnProperty("response")) {
|
if (error.hasOwnProperty("response")) {
|
||||||
if (error.response.status === 403) {
|
if (error.response.status === 403) {
|
||||||
window.location.href = "/error";
|
window.location.href = "/error";
|
||||||
// kcLogout();
|
|
||||||
// Store.commit("SET_ERROR_MESSAGE", error.response.data.message);
|
// Store.commit("SET_ERROR_MESSAGE", error.response.data.message);
|
||||||
// Store.commit("REMOVE_ACCESS_TOKEN")
|
// Store.commit("REMOVE_ACCESS_TOKEN")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ import ModuleSupport from "@/modules/00_support/router";
|
||||||
import ModuleActing from "@/modules/17_acting/router";
|
import ModuleActing from "@/modules/17_acting/router";
|
||||||
|
|
||||||
// TODO: ใช้หรือไม่?
|
// TODO: ใช้หรือไม่?
|
||||||
import keycloak, { kcLogout } from "@/plugins/keycloak";
|
import { authenticated } from "@/plugins/auth";
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
history: createWebHistory(import.meta.env.BASE_URL),
|
history: createWebHistory(import.meta.env.BASE_URL),
|
||||||
|
|
@ -86,7 +86,7 @@ const router = createRouter({
|
||||||
component: Error404NotFound,
|
component: Error404NotFound,
|
||||||
},
|
},
|
||||||
|
|
||||||
// authen with keycloak client
|
// authen with client
|
||||||
{
|
{
|
||||||
path: "/login",
|
path: "/login",
|
||||||
name: "loginMain",
|
name: "loginMain",
|
||||||
|
|
@ -114,11 +114,12 @@ const router = createRouter({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// authen with keycloak client
|
// authen with client
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach(async (to, from, next) => {
|
||||||
if (to.meta.Auth) {
|
if (to.meta.Auth) {
|
||||||
if (keycloak.authenticated === undefined) {
|
const checkAuthen = await authenticated();
|
||||||
kcLogout();
|
if (!checkAuthen && to.meta.Auth) {
|
||||||
|
router.push({ name: "loginMain" });
|
||||||
} else {
|
} else {
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import "moment/dist/locale/th";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import CustomComponent from "@/components/CustomDialog.vue";
|
import CustomComponent from "@/components/CustomDialog.vue";
|
||||||
import { Loading, QSpinnerCube } from "quasar";
|
import { Loading, QSpinnerCube } from "quasar";
|
||||||
import { kcLogout } from "@/plugins/keycloak";
|
import { logout } from "@/plugins/auth";
|
||||||
|
|
||||||
moment.locale("th");
|
moment.locale("th");
|
||||||
|
|
||||||
|
|
@ -362,7 +362,7 @@ export const useCounterMixin = defineStore("mixin", () => {
|
||||||
},
|
},
|
||||||
}).onCancel(async () => {
|
}).onCancel(async () => {
|
||||||
showLoader();
|
showLoader();
|
||||||
await kcLogout();
|
await logout();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
hideLoader();
|
hideLoader();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
@ -379,7 +379,7 @@ export const useCounterMixin = defineStore("mixin", () => {
|
||||||
onlycancel: true,
|
onlycancel: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else {
|
} else if (e.response.data.status != 403) {
|
||||||
const message = e.response.data.result ?? e.response.data.message;
|
const message = e.response.data.result ?? e.response.data.message;
|
||||||
q.dialog({
|
q.dialog({
|
||||||
component: CustomComponent,
|
component: CustomComponent,
|
||||||
|
|
@ -406,7 +406,7 @@ export const useCounterMixin = defineStore("mixin", () => {
|
||||||
},
|
},
|
||||||
}).onCancel(async () => {
|
}).onCancel(async () => {
|
||||||
showLoader();
|
showLoader();
|
||||||
await kcLogout();
|
await logout();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
hideLoader();
|
hideLoader();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
@ -424,7 +424,7 @@ export const useCounterMixin = defineStore("mixin", () => {
|
||||||
},
|
},
|
||||||
}).onCancel(async () => {
|
}).onCancel(async () => {
|
||||||
showLoader();
|
showLoader();
|
||||||
await kcLogout();
|
await logout();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
hideLoader();
|
hideLoader();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
|
||||||
|
|
@ -2,39 +2,36 @@ import { defineStore } from "pinia";
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
|
|
||||||
export const useroleUserDataStore = defineStore("roleusers", () => {
|
export const useroleUserDataStore = defineStore("roleusers", () => {
|
||||||
const insignia1Role = ref<boolean>(false)
|
const insignia1Role = ref<boolean>(false);
|
||||||
const insignia2Role = ref<boolean>(false)
|
const insignia2Role = ref<boolean>(false);
|
||||||
const caregiverRole = ref<boolean>(false)
|
const caregiverRole = ref<boolean>(false);
|
||||||
const chairmanRole = ref<boolean>(false)
|
const chairmanRole = ref<boolean>(false);
|
||||||
const commanderRole = ref<boolean>(false)
|
const commanderRole = ref<boolean>(false);
|
||||||
const admin2Role = ref<boolean>(false)
|
const admin2Role = ref<boolean>(false);
|
||||||
const adminRole = ref<boolean>(false)
|
const adminRole = ref<boolean>(false);
|
||||||
const oligarchRole = ref<boolean>(false)
|
const oligarchRole = ref<boolean>(false);
|
||||||
|
|
||||||
|
const fetchroleUser = async (roles: string[]) => {
|
||||||
|
if (roles) {
|
||||||
|
insignia1Role.value = await roles.includes("insignia1");
|
||||||
const fetchroleUser = async (keycloak: any) => {
|
insignia2Role.value = await roles.includes("insignia2");
|
||||||
if (keycloak != null) {
|
caregiverRole.value = await roles.includes("caregiver");
|
||||||
insignia1Role.value = await keycloak.includes("insignia1");
|
chairmanRole.value = await roles.includes("chairman");
|
||||||
insignia2Role.value = await keycloak.includes("insignia2");
|
commanderRole.value = await roles.includes("commander");
|
||||||
caregiverRole.value = await keycloak.includes("caregiver");
|
admin2Role.value = await roles.includes("admin2");
|
||||||
chairmanRole.value = await keycloak.includes("chairman");
|
adminRole.value = await roles.includes("admin");
|
||||||
commanderRole.value = await keycloak.includes("commander");
|
oligarchRole.value = await roles.includes("oligarch");
|
||||||
admin2Role.value = await keycloak.includes("admin2");
|
|
||||||
adminRole.value = await keycloak.includes("admin");
|
|
||||||
oligarchRole.value = await keycloak.includes("oligarch");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
fetchroleUser,
|
fetchroleUser,
|
||||||
insignia1Role,
|
insignia1Role,
|
||||||
insignia2Role,
|
insignia2Role,
|
||||||
caregiverRole,
|
caregiverRole,
|
||||||
chairmanRole,
|
chairmanRole,
|
||||||
commanderRole,
|
commanderRole,
|
||||||
admin2Role,
|
admin2Role,
|
||||||
adminRole,
|
adminRole,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, onUnmounted, watch } from "vue";
|
import { ref, onMounted, onUnmounted, watch } from "vue";
|
||||||
import keycloak, { kcLogout } from "@/plugins/keycloak";
|
|
||||||
import { useRoute, useRouter } from "vue-router";
|
import { useRoute, useRouter } from "vue-router";
|
||||||
import { useDataStore } from "@/stores/data";
|
import { useDataStore } from "@/stores/data";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
import { scroll, useQuasar } from "quasar";
|
import { scroll, useQuasar } from "quasar";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
import { useMenuDataStore } from "@/stores/menuList";
|
import { useMenuDataStore } from "@/stores/menuList";
|
||||||
|
import { tokenParsed, logout } from "@/plugins/auth";
|
||||||
|
|
||||||
import http from "@/plugins/http";
|
import http from "@/plugins/http";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
|
|
@ -231,8 +231,12 @@ onMounted(async () => {
|
||||||
await fetchSys();
|
await fetchSys();
|
||||||
await fetchPermissionsSys();
|
await fetchPermissionsSys();
|
||||||
|
|
||||||
if (keycloak.tokenParsed) {
|
const user = await tokenParsed();
|
||||||
await fetchroleUser(keycloak.tokenParsed.role);
|
if (user) {
|
||||||
|
fullname.value = user.name;
|
||||||
|
role.value = user.role;
|
||||||
|
|
||||||
|
await fetchroleUser(user.role);
|
||||||
}
|
}
|
||||||
await fetchmsgNoread();
|
await fetchmsgNoread();
|
||||||
|
|
||||||
|
|
@ -405,28 +409,20 @@ const tagClickPlacement = (tag: string) => {
|
||||||
//**** End Tab Right หน้าจอแก้ไขข้อมูลส่วนตัวของผู้สอบผ่าน ****\\
|
//**** End Tab Right หน้าจอแก้ไขข้อมูลส่วนตัวของผู้สอบผ่าน ****\\
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* logout keycloak
|
* logout
|
||||||
* confirm ก่อนออกจากระบบ
|
* confirm ก่อนออกจากระบบ
|
||||||
*/
|
*/
|
||||||
const doLogout = () => {
|
const doLogout = () => {
|
||||||
dialogConfirm(
|
dialogConfirm(
|
||||||
$q,
|
$q,
|
||||||
async () => {
|
async () => {
|
||||||
kcLogout();
|
logout();
|
||||||
},
|
},
|
||||||
"ยืนยันการออกจากระบบ",
|
"ยืนยันการออกจากระบบ",
|
||||||
"ต้องการออกจากระบบใช่หรือไม่?"
|
"ต้องการออกจากระบบใช่หรือไม่?"
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* ดิงชื่อผู้ใช้งานจาก keycloak
|
|
||||||
*/
|
|
||||||
if (keycloak.tokenParsed != null) {
|
|
||||||
fullname.value = keycloak.tokenParsed.name;
|
|
||||||
role.value = keycloak.tokenParsed.role;
|
|
||||||
}
|
|
||||||
|
|
||||||
const clickDelete = async (id: string, index: number) => {
|
const clickDelete = async (id: string, index: number) => {
|
||||||
dialogRemove($q, async () => {
|
dialogRemove($q, async () => {
|
||||||
showLoader();
|
showLoader();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { kcAuthen } from "@/plugins/keycloak";
|
import { setAuthen } from "@/plugins/auth";
|
||||||
import { onMounted } from "vue";
|
import { onMounted } from "vue";
|
||||||
import { useRoute } from "vue-router";
|
import { useRoute } from "vue-router";
|
||||||
|
|
||||||
|
|
@ -7,9 +7,12 @@ const route = useRoute();
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (route.query.token && route.query.accessToken) {
|
if (route.query.token && route.query.accessToken) {
|
||||||
// console.log('query', route.query.token)
|
const params = await {
|
||||||
// console.log('accessToken', route.query.accessToken)
|
access_token: route.query.token,
|
||||||
kcAuthen(route.query.token.toString(), route.query.accessToken.toString());
|
expires_in: route.query.expires ? route.query.expires : 36000,
|
||||||
|
refresh_token: route.query.accessToken,
|
||||||
|
};
|
||||||
|
setAuthen(params);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<!-- authen with keycloak client -->
|
<!-- authen with client -->
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from "vue";
|
import { ref, onMounted } from "vue";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import keycloak, { keycloakConfig, kcAuthen } from "@/plugins/keycloak";
|
import { authenticated, tokenParsed, setAuthen } from "@/plugins/auth";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
import { useQuasar } from "quasar";
|
import { useQuasar } from "quasar";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
import CustomComponent from "@/components/CustomDialog.vue";
|
import CustomComponent from "@/components/CustomDialog.vue";
|
||||||
|
import env from "@/api/index";
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const mixin = useCounterMixin();
|
const mixin = useCounterMixin();
|
||||||
|
|
@ -23,47 +24,47 @@ const isDisplay = ref<boolean>(true); // check display login page
|
||||||
async function onSubmit() {
|
async function onSubmit() {
|
||||||
showLoader();
|
showLoader();
|
||||||
const formdata = new URLSearchParams();
|
const formdata = new URLSearchParams();
|
||||||
formdata.append("client_id", keycloakConfig.clientId);
|
|
||||||
formdata.append("client_secret", keycloakConfig.clientSecret);
|
|
||||||
formdata.append("grant_type", "password");
|
|
||||||
formdata.append(
|
|
||||||
"requested_token_type",
|
|
||||||
"urn:ietf:params:oauth:token-type:refresh_token"
|
|
||||||
);
|
|
||||||
formdata.append("username", username.value);
|
formdata.append("username", username.value);
|
||||||
formdata.append("password", password.value);
|
formdata.append("password", password.value);
|
||||||
|
|
||||||
await axios
|
await axios
|
||||||
.post(
|
.post(`${env.API_URI}/org/login`, formdata, {
|
||||||
`${keycloakConfig.url}/realms/${keycloakConfig.realm}/protocol/openid-connect/token`,
|
headers: {
|
||||||
formdata,
|
"Content-Type": "application/x-www-form-urlencoded",
|
||||||
{
|
},
|
||||||
headers: {
|
})
|
||||||
"Content-Type": "application/x-www-form-urlencoded",
|
.then(async (res) => {
|
||||||
},
|
setAuthen(res.data.result);
|
||||||
}
|
|
||||||
)
|
|
||||||
.then((res) => {
|
|
||||||
kcAuthen(res.data.access_token, res.data.refresh_token);
|
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
messageError($q, err, "ชื่อผู้ใช้หรือรหัสผ่านไม่ถูกต้อง");
|
$q.dialog({
|
||||||
|
component: CustomComponent,
|
||||||
|
componentProps: {
|
||||||
|
title: `ข้อความแจ้งเตือน`,
|
||||||
|
message: `${err.response.data.message}`,
|
||||||
|
icon: "warning",
|
||||||
|
color: "red",
|
||||||
|
onlycancel: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
hideLoader();
|
hideLoader();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(async () => {
|
||||||
// check authen keycloak and role of system
|
// check authen and role of system
|
||||||
if (keycloak.authenticated) {
|
const checkAuthen = await authenticated();
|
||||||
|
if (checkAuthen) {
|
||||||
isDisplay.value = false;
|
isDisplay.value = false;
|
||||||
showLoader();
|
showLoader();
|
||||||
if (keycloak.tokenParsed) {
|
const user = await tokenParsed();
|
||||||
|
if (user) {
|
||||||
const checkRole = (element: string) => element === "STAFF";
|
const checkRole = (element: string) => element === "STAFF";
|
||||||
|
|
||||||
// ถ้าไม่มีสิทธิ์เข้าใช้งานระบบ แสดงข้อความแจ้งเตือน
|
// ถ้าไม่มีสิทธิ์เข้าใช้งานระบบ แสดงข้อความแจ้งเตือน
|
||||||
if (keycloak.tokenParsed.role.findIndex(checkRole) === -1) {
|
if (user.role.findIndex(checkRole) === -1) {
|
||||||
$q.dialog({
|
$q.dialog({
|
||||||
component: CustomComponent,
|
component: CustomComponent,
|
||||||
componentProps: {
|
componentProps: {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue