diff --git a/src/app.config.ts b/src/app.config.ts index 31e50f1..9dde560 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -15,20 +15,48 @@ import probation from "./api/probation/api.probation"; import development from "./api/api.development"; const API = { - ...testtest, - ...retirementResign, - ...placementTransfer, - ...message, - ...evaluate, - ...appeal, - ...support, - ...org, - ...scholarship, - ...kpi, - ...probation, - ...development, + ...testtest, + ...retirementResign, + ...placementTransfer, + ...message, + ...evaluate, + ...appeal, + ...support, + ...org, + ...scholarship, + ...kpi, + ...probation, + ...development, +}; + +const path = "http://localhost:3008"; + +const generatePopupPath = (routeName: any) => { + if (routeName.includes("metadata")) { + return `${path}/manual/chapter-2-admin-metadata`; + } + if (routeName.includes("leave")) { + return `${path}/manual/chapter-3-user-leave`; + } + // if (routeName.includes("compete")) { + // return `${path}/manual/chapter-10-admin-recruit`; + // } + // if (routeName.includes("registryNew")) { + // return `${path}/manual/chapter-7-admin-registry`; + // } + // if (routeName.includes("registry")) { + // return `${path}/manual/chapter-7-admin-registry`; + // } + else { + return manualConfig[routeName as keyof typeof manualConfig]; + } +}; + +const manualConfig = { + dashboard: `${path}/manual/chapter-1-user-organization-chart`, }; export default { - API: API, + API: API, + generatePopupPath, }; diff --git a/src/views/MainLayout.vue b/src/views/MainLayout.vue index 9d6b110..e51aff5 100644 --- a/src/views/MainLayout.vue +++ b/src/views/MainLayout.vue @@ -14,13 +14,13 @@ const $q = useQuasar(); const mixin = useCounterMixin(); const { - date2Thai, - dialogRemove, - showLoader, - hideLoader, - messageError, - success, - dialogConfirm, + date2Thai, + dialogRemove, + showLoader, + hideLoader, + messageError, + success, + dialogConfirm, } = mixin; const fullname = ref(""); @@ -34,54 +34,54 @@ const link = ref(""); * เรียกฟังก์ชันทั้งหมดตอนเรียกใช้ไฟล์นี้ */ onMounted(async () => { - await fetchTotolNotificate(); - if (keycloak.tokenParsed != null) { - fullname.value = keycloak.tokenParsed.name; - } + await fetchTotolNotificate(); + if (keycloak.tokenParsed != null) { + fullname.value = keycloak.tokenParsed.name; + } }); const totalNoti = ref(0); async function fetchTotolNotificate() { - await http - .get(config.API.msgNotificateTotal) - .then((res) => { - totalNoti.value = res.data.result; - }) - .catch((err) => { - messageError($q, err); - }); + await http + .get(config.API.msgNotificateTotal) + .then((res) => { + totalNoti.value = res.data.result; + }) + .catch((err) => { + messageError($q, err); + }); } const statusLoad = ref(false); const fetchlistNotification = async (index: number, type: string) => { - await http - .get(config.API.msgNotificate + `?page=${index}&pageSize=${15}`) - .then((res: any) => { - const data = res.data.result.data; - totalInbox.value = res.data.result.total; - let list: any[] = []; - if (type === "DEL") { - notiList.value = []; - } - data.map((e: any) => { - list.push({ - id: e.id, - sender: - e.createdFullName == "" || e.createdFullName == null - ? "เจ้าหน้าที่"[0] - : e.createdFullName[0], - body: e.body ?? "", - timereceive: date2Thai(e.createdAt), - isOpen: e.isOpen, - receiveDate: e.receiveDate, - }); - }); - notiList.value.push(...list); - statusLoad.value = totalInbox.value === 0 ? true : false; - }) - .catch((err) => { - console.log(err); - }); + await http + .get(config.API.msgNotificate + `?page=${index}&pageSize=${15}`) + .then((res: any) => { + const data = res.data.result.data; + totalInbox.value = res.data.result.total; + let list: any[] = []; + if (type === "DEL") { + notiList.value = []; + } + data.map((e: any) => { + list.push({ + id: e.id, + sender: + e.createdFullName == "" || e.createdFullName == null + ? "เจ้าหน้าที่"[0] + : e.createdFullName[0], + body: e.body ?? "", + timereceive: date2Thai(e.createdAt), + isOpen: e.isOpen, + receiveDate: e.receiveDate, + }); + }); + notiList.value.push(...list); + statusLoad.value = totalInbox.value === 0 ? true : false; + }) + .catch((err) => { + console.log(err); + }); }; /** @@ -89,280 +89,311 @@ const fetchlistNotification = async (index: number, type: string) => { * confirm ก่อนออกจากระบบ */ const doLogout = () => { - dialogConfirm( - $q, - () => { - keycloak.logout(); - }, - "ยืนยันการออกจากระบบ", - "ต้องการออกจากระบบใช่หรือไม่" - ); + dialogConfirm( + $q, + () => { + keycloak.logout(); + }, + "ยืนยันการออกจากระบบ", + "ต้องการออกจากระบบใช่หรือไม่" + ); }; const clickDelete = async (id: string, index: number) => { - dialogRemove($q, async () => { - // showLoader(); - await http - .delete(config.API.msgId(id)) - .then(() => { - notiList.value.splice(index, 1); - totalInbox.value--; - success($q, "ลบข้อมูลสำเร็จ"); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(async () => { - notiList.value.length === 12 && fetchlistNotification(1, "DEL"); - // hideLoader(); - }); - }); + dialogRemove($q, async () => { + // showLoader(); + await http + .delete(config.API.msgId(id)) + .then(() => { + notiList.value.splice(index, 1); + totalInbox.value--; + success($q, "ลบข้อมูลสำเร็จ"); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(async () => { + notiList.value.length === 12 && fetchlistNotification(1, "DEL"); + // hideLoader(); + }); + }); }; const totalInbox = ref(0); const page = ref(0); async function onLoad(index: any, done: any) { - if ( - notiList.value.length < totalInbox.value || - (notiList.value.length === 0 && totalInbox.value === 0) - ) { - page.value++; - setTimeout(async () => { - await fetchlistNotification(page.value, "NOMAL"); - done(); - }, 1500); - } + if ( + notiList.value.length < totalInbox.value || + (notiList.value.length === 0 && totalInbox.value === 0) + ) { + page.value++; + setTimeout(async () => { + await fetchlistNotification(page.value, "NOMAL"); + done(); + }, 1500); + } } watch( - () => notiTrigger.value, - () => { - if (!notiTrigger.value) { - const updatedNotifications = notiList.value.map((item: any) => ({ - ...item, - isOpen: true, - })); - notiList.value = updatedNotifications; - fetchTotolNotificate(); - } - } + () => notiTrigger.value, + () => { + if (!notiTrigger.value) { + const updatedNotifications = notiList.value.map((item: any) => ({ + ...item, + isOpen: true, + })); + notiList.value = updatedNotifications; + fetchTotolNotificate(); + } + } ); const thaiOptions: Intl.DateTimeFormatOptions = { - hour: "2-digit", - minute: "2-digit", + hour: "2-digit", + minute: "2-digit", +}; + +const handleButtonClick = () => { + const currentPath = route.name; + const queryParams = { role: "user" }; // Replace with your query parameters + const queryString = new URLSearchParams(queryParams).toString(); + + // Assuming config.generatePopupPath() returns a base URL + const popupBasePath = config.generatePopupPath(currentPath); + + if (popupBasePath) { + const popupPath = `${popupBasePath}?${queryString}`; + window.open(popupPath, "_blank"); // Opens in a new tab/window + } else { + console.log("No manual available for this page:", currentPath); + } }; function onInfo() { - router.push(`/retire`); + router.push(`/retire`); }