Merge branch 'develop'

This commit is contained in:
Warunee Tamkoo 2025-06-26 10:42:16 +07:00
commit 19e13e3296
14 changed files with 104 additions and 25 deletions

View file

@ -307,7 +307,10 @@ watch(
:options="typeOps"
emit-value
dense
@update:model-value="updateSelectType"
@update:model-value="
updateSelectType(formPositionSelect.positionType),
(formPositionSelect.positionLevel = '')
"
map-options
outlined
option-label="name"

View file

@ -48,6 +48,7 @@ export default [
name: "masterPersonal",
component: personalPage,
meta: {
Auth: true,
Role: ["SUPER_ADMIN"],
},
},
@ -56,6 +57,7 @@ export default [
name: "masterPersonalDistrict",
component: personalDistrict,
meta: {
Auth: true,
Role: ["SUPER_ADMIN"],
},
},
@ -64,6 +66,7 @@ export default [
name: "masterPersonalSubDistrict",
component: personalSubDistrict,
meta: {
Auth: true,
Role: ["SUPER_ADMIN"],
},
},
@ -74,6 +77,7 @@ export default [
name: "masterPosition",
component: positionPage,
meta: {
Auth: true,
Role: ["SUPER_ADMIN"],
},
},
@ -82,6 +86,7 @@ export default [
name: "masterPositionLevel",
component: positionLevelPage,
meta: {
Auth: true,
Role: ["SUPER_ADMIN"],
},
},
@ -92,6 +97,7 @@ export default [
name: "masterPositionEmployee",
component: positionEmployeePage,
meta: {
Auth: true,
Role: ["SUPER_ADMIN"],
},
},
@ -100,6 +106,7 @@ export default [
name: "masterPositionEmployeeLevel",
component: positionEmployeeLevelPage,
meta: {
Auth: true,
Role: ["SUPER_ADMIN"],
},
},
@ -110,6 +117,7 @@ export default [
name: "masterCalendarWork",
component: calendarWorkPage,
meta: {
Auth: true,
Role: ["SUPER_ADMIN"],
},
},
@ -120,6 +128,7 @@ export default [
name: "masterInsigniaPage",
component: masterInsignia,
meta: {
Auth: true,
Role: ["SUPER_ADMIN"],
},
},
@ -128,6 +137,7 @@ export default [
name: "masterInsigniadetail",
component: detailInsignia,
meta: {
Auth: true,
Role: ["SUPER_ADMIN"],
},
},

View file

@ -365,6 +365,7 @@ watch(
hide-bottom-space
dense
label="คำค้น"
@keydown.enter.prevent="(query.page = 1), fetchListUser()"
>
<template v-slot:after>
<q-btn

View file

@ -1,3 +1,5 @@
import Auth from "@/views/auth.vue";
/** user*/
const ListsPageUser = () => import("@/modules/02_users/views/01_user.vue");
const PageManagementRole = () =>
@ -31,6 +33,7 @@ export default [
name: "manageUsers",
component: ListsPageUser,
meta: {
Auth: true,
Role: ["SUPER_ADMIN", "ADMIN"],
},
},
@ -39,6 +42,7 @@ export default [
name: "manageUsersRolesId",
component: PageManagementRole,
meta: {
Auth: true,
Role: ["SUPER_ADMIN", "ADMIN"],
},
},
@ -47,6 +51,7 @@ export default [
name: "manageRoles",
component: ListsPageRole,
meta: {
Auth: true,
Role: ["SUPER_ADMIN", "ADMIN"],
},
},
@ -56,6 +61,7 @@ export default [
name: "manageRolesId",
component: ListsPage2Role,
meta: {
Auth: true,
Role: ["SUPER_ADMIN", "ADMIN"],
},
},
@ -65,6 +71,7 @@ export default [
name: "managePermission",
component: PermissionPage,
meta: {
Auth: true,
Role: ["SUPER_ADMIN", "ADMIN"],
},
},
@ -74,6 +81,7 @@ export default [
name: "roleOrganization",
component: roleOrgview,
meta: {
Auth: true,
Role: ["SUPER_ADMIN", "ADMIN"],
},
},
@ -82,6 +90,7 @@ export default [
name: "rolePositionSalary",
component: rolePositionSalary,
meta: {
Auth: true,
Role: ["SUPER_ADMIN", "ADMIN"],
},
},
@ -91,6 +100,7 @@ export default [
name: "responsibilities",
component: responsIbilitiesView,
meta: {
Auth: true,
Role: ["SUPER_ADMIN", "ADMIN"],
},
},

View file

@ -243,6 +243,7 @@ async function selectedOrg(id: string) {
* งชนสำหรบดงไอดโครงสรางปจจ
*/
async function fetchOrganizationActive() {
showLoader();
await http
.get(config.API.activeOrganization)
.then(async (res) => {
@ -253,6 +254,9 @@ async function fetchOrganizationActive() {
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
@ -279,9 +283,7 @@ async function fatchOrg(id: string) {
})
.catch((err) => {
messageError($q, err);
hideLoader();
})
.finally(() => {});
});
}
/*** scroll และโหลดข้อมูลรายการ Logs เพิ่ม */
@ -441,6 +443,7 @@ function updateDate() {
}
function onSendCSV() {
showLoader();
const queryString = {
rootId: qureyBody.rootId ?? undefined,
// size: size.value ?? undefined,
@ -455,14 +458,16 @@ function onSendCSV() {
.get(config.API.reportLog, {
params: queryString,
})
.then((res) => {
.then(async (res) => {
const data = res.data;
genReportXLSX(data, `LOG_${date2Thai(new Date(startDate.value))}`);
await genReportXLSX(data, `LOG_${date2Thai(new Date(startDate.value))}`);
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {});
.finally(() => {
hideLoader();
});
}
async function downloadTxt() {

View file

@ -6,6 +6,7 @@ export default [
name: "viewLogs",
component: ListsPage,
meta: {
Auth: true,
Role: ["SUPER_ADMIN", "ADMIN"],
},
},

View file

@ -6,6 +6,7 @@ export default [
name: "viewSystem",
component: MainView,
meta: {
Auth: true,
Role: ["SUPER_ADMIN"],
},
},

View file

@ -8,6 +8,7 @@ export default [
name: "commandTemplate",
component: ListsPage,
meta: {
Auth: true,
Role: ["SUPER_ADMIN"],
},
},
@ -16,6 +17,7 @@ export default [
name: "salaryTemplate",
component: SalaryTemplate,
meta: {
Auth: true,
Role: ["SUPER_ADMIN"],
},
},

View file

@ -6,6 +6,7 @@ export default [
name: "manageWebservices",
component: mainView,
meta: {
Auth: true,
Role: ["SUPER_ADMIN"],
},
},

View file

@ -1,6 +1,7 @@
const ACCESS_TOKEN = "BMAHRISADM_KEYCLOAK_IDENTITY";
const key_C_Config = {
url_Logout: import.meta.env.VITE_URL_SSO,
landing_PageUrl: import.meta.env.VITE_URL_LANDING,
};
interface AuthResponse {
access_token: string;
@ -10,22 +11,32 @@ interface AuthResponse {
const authenticated = async () => ((await getToken()) ? true : false);
async function setAuthen(r: AuthResponse, val: string) {
await setCookie(ACCESS_TOKEN, r.access_token, r.expires_in);
setCookie("SSO", val, r.expires_in);
window.location.href = "/";
async function setAuthen(r: AuthResponse, val: string, url?: string) {
if (r && r.access_token) {
await setCookie(ACCESS_TOKEN, r.access_token, r.expires_in);
setCookie("SSO", val, r.expires_in);
window.location.href = url ? encodeURI(url) : "/";
}
}
async function logout() {
await deleteCookie(ACCESS_TOKEN);
window.location.href = key_C_Config.url_Logout;
async function logout(force: boolean = false) {
if (!force) {
await deleteCookie(ACCESS_TOKEN);
window.location.href = key_C_Config.url_Logout;
} else {
const currentUrl = window.location.href;
const loginUrl = `${
key_C_Config.landing_PageUrl
}?system=admin&redirectUrl=${encodeURIComponent(currentUrl)}`;
window.location.href = loginUrl;
}
}
async function getToken() {
return getCookie(ACCESS_TOKEN);
}
// 2024-08-29T02:55:13.000Z
function setCookie(name: string, value: any, time: number) {
async function setCookie(name: string, value: any, time: number) {
let expires = "";
if (time) {
const date = new Date();
@ -47,7 +58,7 @@ function getCookie(name: string) {
return null;
}
function deleteCookie(name: string) {
async function deleteCookie(name: string) {
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;
}
@ -71,4 +82,23 @@ async function tokenParsed() {
return JSON.parse(jsonPayload);
}
export { getToken, authenticated, logout, setAuthen, tokenParsed, getCookie };
async function redirectToLandingPage() {
await deleteCookie(ACCESS_TOKEN);
window.location.href = key_C_Config.landing_PageUrl;
}
async function logoutSSO() {
await deleteCookie(ACCESS_TOKEN);
window.location.href = key_C_Config.landing_PageUrl + `/logout`;
}
export {
getToken,
authenticated,
logout,
setAuthen,
tokenParsed,
getCookie,
redirectToLandingPage,
logoutSSO,
};

View file

@ -33,9 +33,11 @@ http.interceptors.response.use(
function (error: any) {
if (typeof error !== undefined) {
// eslint-disable-next-line no-prototype-builtins
if (error.hasOwnProperty("response")) {
if (error.response.status === 401 || error.response.status === 403) {
logout();
if (error.response.status === 403) {
window.location.href = "/error";
// logout(true);
// Store.commit("SET_ERROR_MESSAGE", error.response.data.message);
// Store.commit("REMOVE_ACCESS_TOKEN")
}

View file

@ -95,7 +95,7 @@ router.beforeEach(async (to, from, next) => {
if (to.meta.Auth) {
const checkAuthen = await authenticated();
if (!checkAuthen && to.meta.Auth) {
logout();
logout(true);
return;
}
}

View file

@ -6,7 +6,13 @@ import { useQuasar } from "quasar";
import { useRoute } from "vue-router";
import config from "@/app.config";
import http from "@/plugins/http";
import { logout, tokenParsed, getCookie } from "@/plugins/auth";
import {
logout,
tokenParsed,
getCookie,
redirectToLandingPage,
logoutSSO,
} from "@/plugins/auth";
import checkPermission from "@/plugins/checkPermission";
import { useCounterMixin } from "@/stores/mixin";
import { useDataStore } from "@/stores/data";
@ -244,7 +250,7 @@ function doLogout() {
$q,
async () => {
await http.post(config.API.keycloakLogSSO, { text: "ออกจากระบบ" });
await logout();
await logoutSSO();
},
"ยืนยันการออกจากระบบ",
"ต้องการออกจากระบบใช่หรือไม่?"
@ -627,7 +633,11 @@ onUnmounted(() => {
</div> -->
<!-- <q-option-group v-model="group" :options="options" color="primary"/> -->
<q-list dense>
<q-item clickable :href="landingPageUrl" v-if="isSsoToken">
<q-item
clickable
@click="redirectToLandingPage"
v-if="isSsoToken"
>
<q-item-section avatar>
<q-avatar
color="blue"

View file

@ -1,7 +1,6 @@
<script setup lang="ts">
import { onMounted } from "vue";
import { useRoute } from "vue-router";
import { setAuthen } from "@/plugins/auth";
const route = useRoute();
@ -13,7 +12,11 @@ onMounted(async () => {
expires_in: route.query.expires ? route.query.expires : 36000,
refresh_token: route.query.accessToken,
};
setAuthen(params, "y");
setAuthen(
params,
"y",
route.query.redirectUrl ? (route.query.redirectUrl as string) : "/"
);
}
});
</script>