diff --git a/src/api/02_organizational/api.organization.ts b/src/api/02_organizational/api.organization.ts index 39c453eb..c9c1c79f 100644 --- a/src/api/02_organizational/api.organization.ts +++ b/src/api/02_organizational/api.organization.ts @@ -103,5 +103,5 @@ export default { /** View Work Flow*/ viewWorkflow: `${organization}/view-workflow`, - + keycloakLogSSO: `${organization}/keycloak/log/sso`, }; diff --git a/src/api/05_command/api.command.ts b/src/api/05_command/api.command.ts index d9c4e897..9857f070 100644 --- a/src/api/05_command/api.command.ts +++ b/src/api/05_command/api.command.ts @@ -13,6 +13,6 @@ export default { commandSysId: string, search: string ) => - `${commandSalary}/admin?page=${page}&pageSize=${pageSize}&isActive=${isActive}&commandSysId=${commandSysId}&search=${search}`, + `${commandSalary}/admin?page=${page}&pageSize=${pageSize}&isActive=${isActive}&commandSysId=${commandSysId}&searchKeyword=${search}`, commandSalaryById: (id: string) => `${commandSalary}/${id}`, }; diff --git a/src/components/Dialogs/PopupReplyInbox.vue b/src/components/Dialogs/PopupReplyInbox.vue index 37600e2b..e8daf23c 100644 --- a/src/components/Dialogs/PopupReplyInbox.vue +++ b/src/components/Dialogs/PopupReplyInbox.vue @@ -41,29 +41,34 @@ const body = ref(""); //ข้อความ * ยืนยันการจตอบกลับการส่งข้อความ */ function onSubmit() { - dialogConfirm($q, async () => { - showLoader(); - const pathAPI = - props.type === "Administrator" - ? config.API.msgNotiAdmin - : config.API.replyMessage(props.idInbox); - const method = props.type === "Administrator" ? http.post : http.put; + dialogConfirm( + $q, + async () => { + showLoader(); + const pathAPI = + props.type === "Administrator" + ? config.API.msgNotiAdmin + : config.API.replyMessage(props.idInbox); + const method = props.type === "Administrator" ? http.post : http.put; - await method(pathAPI, { - subject: subject.value, - body: body.value, - }) - .then(() => { - success($q, "ส่งข้อความสำเร็จ"); - onClose(); + await method(pathAPI, { + subject: subject.value, + body: body.value, }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - hideLoader(); - }); - }); + .then(() => { + success($q, "ส่งข้อความสำเร็จ"); + onClose(); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); + }, + "ยืนยันการส่งข้อความ", + "คุณต้องการส่งข้อความใช่หรือไม่?" + ); } function onClose() { @@ -91,7 +96,7 @@ function onClose() {
diff --git a/src/modules/03_logs/components/DialogDataDiff.vue b/src/modules/03_logs/components/DialogDataDiff.vue index bf10dde1..4c1bbdeb 100644 --- a/src/modules/03_logs/components/DialogDataDiff.vue +++ b/src/modules/03_logs/components/DialogDataDiff.vue @@ -1,4 +1,6 @@ @@ -33,7 +35,7 @@ defineProps<{ color="blue" type="submit" icon="download" - @click="onSend" + @click="() => downloadTxt()" >ดาวน์โหลด (.TXT) diff --git a/src/modules/03_logs/components/LogTable.vue b/src/modules/03_logs/components/LogTable.vue index f2936ad7..9eec6833 100644 --- a/src/modules/03_logs/components/LogTable.vue +++ b/src/modules/03_logs/components/LogTable.vue @@ -22,12 +22,13 @@ import DialogDataDiff from "@/modules/03_logs/components/DialogDataDiff.vue"; const route = useRoute(); import type { ResLog } from "@/modules/03_logs/interface/response/Main"; +import generateTxt from "@/plugins/generateTxt"; /** use*/ const $q = useQuasar(); const storeData = useDataStore(); const { logData, size, searchAfter, systemName, date } = storeToRefs(storeData); -const { date2Thai, messageError, hideLoader,dateToISO } = useCounterMixin(); +const { date2Thai, messageError, hideLoader, dateToISO } = useCounterMixin(); const startTime = ref(null); // เวลาเริ่มต้น const endTime = ref(null); //เวลาสินสุด @@ -452,16 +453,31 @@ function onSendCSV() { params: queryString, }) .then((res) => { - const data = res.data - genReportXLSX(data,`LOG_${date2Thai(new Date(startDate.value))}`) + const data = res.data; + genReportXLSX(data, `LOG_${date2Thai(new Date(startDate.value))}`); }) .catch((e) => { messageError($q, e); }) .finally(() => {}); } -function onSend() { - console.log(1); + +function downloadTxt() { + const queryString = { + id: currentlogData.value?.id, + }; + http + .get(`${config.API.log}/report/logsDetail`, { + params: queryString, + }) + .then((res) => { + const data = res.data; + generateTxt(data, `LOG_${date2Thai(new Date(startDate.value))}`); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => {}); } onBeforeMount(async () => { @@ -872,6 +888,7 @@ onMounted(async () => { () => { currentDataDiff = col.value; currentlogData = { + id: props.row.id, startTimeStamp: props.row.startTimeStamp, username: props.row.userName, host: props.row.host, @@ -911,7 +928,7 @@ onMounted(async () => { ([ ]); onMounted(async () => { + storeData.logData = await []; // await storeData.fetchLog({ // size: size.value, // systemName: systemName.value ?? undefined, diff --git a/src/modules/05_command/views/salaryLists.vue b/src/modules/05_command/views/salaryLists.vue index 6d11fd44..26b1748e 100644 --- a/src/modules/05_command/views/salaryLists.vue +++ b/src/modules/05_command/views/salaryLists.vue @@ -174,6 +174,8 @@ function onSubmit() { function selectInbox(data: CommandSysType) { activeOrderId.value = data.id; pagination.value.page = 1; + filter.value = ""; + fetchSalaryList(); } diff --git a/src/plugins/generateTxt.ts b/src/plugins/generateTxt.ts new file mode 100644 index 00000000..733e8c59 --- /dev/null +++ b/src/plugins/generateTxt.ts @@ -0,0 +1,49 @@ +import axios from "axios"; +import config from "@/app.config"; + +import { useQuasar } from "quasar"; +import { useCounterMixin } from "@/stores/mixin"; + +const $q = useQuasar(); + +const mixin = useCounterMixin(); +const { showLoader, hideLoader, messageError } = mixin; + +async function generateTxt(data: any, fileName: string) { + showLoader(); + await axios + .post(`${config.API.reportTemplate}/txt`, data, { + headers: { + "Content-Type": "text/plain;charset=utf-8", + }, + responseType: "blob", + }) + .then((res) => { + const data = res.data; + if (data) { + // สร้าง Blob จาก array buffer + const blob = new Blob([data], { type: "text/plain;charset=utf-8" }); + + // สร้าง URL สำหรับไฟล์ Blob + const url = URL.createObjectURL(blob); + + // สร้างลิงก์เพื่อดาวน์โหลดไฟล์ + const link = document.createElement("a"); + link.href = url; + link.download = `${fileName}.txt`; // กำหนดชื่อไฟล์ที่จะดาวน์โหลด + document.body.appendChild(link); + link.click(); + + // ลบ URL ที่สร้างขึ้นหลังจากใช้งาน + URL.revokeObjectURL(url); + } + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); +} + +export default generateTxt; diff --git a/src/views/MainLayout.vue b/src/views/MainLayout.vue index f99f734a..980f8058 100644 --- a/src/views/MainLayout.vue +++ b/src/views/MainLayout.vue @@ -97,7 +97,7 @@ async function getDataNotification(index: number, type: string) { minute: "2-digit", }; await http - .get(config.API.msgNotificate + `?page=${index}&pageSize=${10}`) + .get(config.API.msgNotificate + `?page=${index}&pageSize=${15}`) .then((res) => { const response = res.data.result.data; totalInbox.value = res.data.result.total; @@ -237,7 +237,8 @@ function doLogout() { dialogConfirm( $q, async () => { - logout(); + await http.post(config.API.keycloakLogSSO, { text: "ออกจากระบบ" }); + await logout(); }, "ยืนยันการออกจากระบบ", "ต้องการออกจากระบบใช่หรือไม่?" @@ -286,9 +287,9 @@ function onLoad(index: any, done: Function) { (notiList.value.length === 0 && totalInbox.value === 0) ) { page.value++; - setTimeout(() => { + setTimeout(async () => { + await getDataNotification(page.value, "NOMAL"); done(); - getDataNotification(page.value, "NOMAL"); }, 1500); } } @@ -443,7 +444,11 @@ onUnmounted(() => { v-if="totalNoti !== 0" >{{ totalNoti }} - +
การแจ้งเตือน
diff --git a/tsconfig.config.json b/tsconfig.config.json index 92f9cb6e..48ba8afb 100644 --- a/tsconfig.config.json +++ b/tsconfig.config.json @@ -1,10 +1,16 @@ { "extends": "@vue/tsconfig/tsconfig.node.json", - "include": ["vite.config.*", "vitest.config.*", "cypress.config.*", "playwright.config.*"], + "include": [ + "vite.config.*", + "vitest.config.*", + "cypress.config.*", + "playwright.config.*" + ], "compilerOptions": { "composite": true, "types": ["node"], "ignoreDeprecations": "5.0", - "verbatimModuleSyntax": true + "verbatimModuleSyntax": true, + "module": "esnext" } }