fix bug list log
This commit is contained in:
parent
97d1323437
commit
70524922e2
3 changed files with 63 additions and 39 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { cloneVNode, onMounted, ref, reactive } from "vue";
|
import { cloneVNode, onMounted, ref, reactive, onBeforeMount } from "vue";
|
||||||
import { useQuasar, type QTableProps } from "quasar";
|
import { useQuasar, type QTableProps } from "quasar";
|
||||||
import { useRoute } from "vue-router";
|
import { useRoute } from "vue-router";
|
||||||
|
|
||||||
|
|
@ -25,7 +25,7 @@ import type { ResLog } from "@/modules/03_logs/interface/response/Main";
|
||||||
/** use*/
|
/** use*/
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
const storeData = useDataStore();
|
const storeData = useDataStore();
|
||||||
const { logData, size, searchAfter, systemName } = storeToRefs(storeData);
|
const { logData, size, searchAfter, systemName, date } = storeToRefs(storeData);
|
||||||
const { date2Thai, messageError, hideLoader } = useCounterMixin();
|
const { date2Thai, messageError, hideLoader } = useCounterMixin();
|
||||||
|
|
||||||
const startTime = ref<Date | null>(null); // เวลาเริ่มต้น
|
const startTime = ref<Date | null>(null); // เวลาเริ่มต้น
|
||||||
|
|
@ -192,31 +192,27 @@ const statusOpt = ref<string[]>(["info", "warning", "error"]);
|
||||||
const filter = ref<string>(""); // ค้นหาข้อมูลรายการโครงสร้าง
|
const filter = ref<string>(""); // ค้นหาข้อมูลรายการโครงสร้าง
|
||||||
const nodeTree = ref<DataTree[]>([]); // ข้อมูลรายการโครงสร้าง
|
const nodeTree = ref<DataTree[]>([]); // ข้อมูลรายการโครงสร้าง
|
||||||
const expanded = ref<Array<string>>([]); // เปิดรายการโครงสร้าง
|
const expanded = ref<Array<string>>([]); // เปิดรายการโครงสร้าง
|
||||||
const orgId = ref<string>(""); // id หน่วยงานที่เลือก
|
|
||||||
|
|
||||||
const qureyBody = reactive<QueryProfile>({
|
const qureyBody = reactive<QueryProfile>({
|
||||||
searchKeyword: "", // คำค้นหา
|
searchKeyword: "", // คำค้นหา
|
||||||
searchField: "fullName", // field ที่ต้องการค้นหา
|
searchField: "fullName", // field ที่ต้องการค้นหา
|
||||||
page: 1, // หน้า
|
page: 1, // หน้า
|
||||||
pageSize: 10, // จำนวนที่ต้องการ
|
pageSize: 10, // จำนวนที่ต้องการ
|
||||||
id: null, // หน่วยงานที่เลือก
|
rootId: undefined, // หน่วยงานที่เลือก
|
||||||
});
|
});
|
||||||
/**
|
/**
|
||||||
* ฟังก์ชันเลือกหน่วยงาน
|
* ฟังก์ชันเลือกหน่วยงาน
|
||||||
* @param id หน่วยงานที่เลือก
|
* @param id หน่วยงานที่เลือก
|
||||||
*
|
*
|
||||||
* กำหนดค่าของ qureyBody ให้เป็นค่า defult และกำหนดค่าของ qureyBody.id เป็นหน่วยงานที่เลือก
|
* กำหนดค่าของ qureyBody ให้เป็นค่า defult และกำหนดค่าของ qureyBody.rootId เป็นหน่วยงานที่เลือก
|
||||||
* และดึงข้อมูลรายชื่อคนที่มีสิทธิ์จัดการโครงสร้างในหน่วยงานที่เลือก
|
* และดึงข้อมูลรายชื่อคนที่มีสิทธิ์จัดการโครงสร้างในหน่วยงานที่เลือก
|
||||||
*/
|
*/
|
||||||
async function selectedOrg(id: string) {
|
async function selectedOrg(id: string) {
|
||||||
orgId.value = id;
|
qureyBody.rootId = id;
|
||||||
qureyBody.id = id;
|
|
||||||
qureyBody.searchKeyword = "";
|
|
||||||
qureyBody.searchField = "fullName";
|
|
||||||
qureyBody.page = 1;
|
qureyBody.page = 1;
|
||||||
await storeData.fetchLog(
|
await storeData.fetchLog(
|
||||||
{
|
{
|
||||||
rootId: qureyBody.id ?? undefined,
|
rootId: qureyBody.rootId ?? undefined,
|
||||||
size: size.value ?? undefined,
|
size: size.value ?? undefined,
|
||||||
search: inputSearch.value ?? undefined,
|
search: inputSearch.value ?? undefined,
|
||||||
systemName: systemName.value ?? undefined,
|
systemName: systemName.value ?? undefined,
|
||||||
|
|
@ -230,28 +226,51 @@ async function selectedOrg(id: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ฟังก์ชันดึงข้อมูลโครงสร้าง
|
* ฟังชั่นสำหรับดึงไอดีโครงสร้างปัจจุบัน
|
||||||
*
|
|
||||||
* เก็บข้อมูลโครงสร้างไว้ใน nodeTree
|
|
||||||
*/
|
*/
|
||||||
async function fatchOrg() {
|
async function fetchOrganizationActive() {
|
||||||
await http
|
await http
|
||||||
.get(config.API.permissionOrg)
|
.get(config.API.activeOrganization)
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
const data = await res.data.result;
|
const data = res.data.result;
|
||||||
nodeTree.value = data;
|
if (data) {
|
||||||
|
await fatchOrg(data.activeId);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
messageError($q, err);
|
messageError($q, err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ฟังก์ชันดึงข้อมูลโครงสร้างเก็บข้อมูลโครงสร้างไว้ใน nodeTree
|
||||||
|
* revision id ของโครงสร้าง
|
||||||
|
*/
|
||||||
|
async function fatchOrg(id: string) {
|
||||||
|
await http
|
||||||
|
.get(config.API.orgByid(id))
|
||||||
|
.then(async (res) => {
|
||||||
|
const data = await res.data.result;
|
||||||
|
nodeTree.value = data;
|
||||||
|
searchAfter.value = undefined;
|
||||||
|
if (data.length === 1) {
|
||||||
|
selectedOrg(data[0].orgTreeId);
|
||||||
|
} else {
|
||||||
|
await storeData.fetchLog({
|
||||||
|
size: size.value,
|
||||||
|
systemName: systemName.value ?? undefined,
|
||||||
|
date: date.value[0],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
messageError($q, err);
|
||||||
hideLoader();
|
hideLoader();
|
||||||
})
|
})
|
||||||
.finally(() => {});
|
.finally(() => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*** scroll และโหลดข้อมูลรายการ Logs เพิ่ม */
|
||||||
* scroll และโหลดข้อมูลรายการ Logs เพิ่ม
|
|
||||||
*/
|
|
||||||
const infiniteScroll = handleScroll();
|
const infiniteScroll = handleScroll();
|
||||||
function handleScroll() {
|
function handleScroll() {
|
||||||
let scrollFlag = false;
|
let scrollFlag = false;
|
||||||
|
|
@ -269,6 +288,7 @@ function handleScroll() {
|
||||||
scrollFlag = true;
|
scrollFlag = true;
|
||||||
await storeData.fetchLog(
|
await storeData.fetchLog(
|
||||||
{
|
{
|
||||||
|
rootId: qureyBody.rootId ?? undefined,
|
||||||
size: size.value ?? undefined,
|
size: size.value ?? undefined,
|
||||||
search: inputSearch.value ?? undefined,
|
search: inputSearch.value ?? undefined,
|
||||||
systemName: systemName.value ?? undefined,
|
systemName: systemName.value ?? undefined,
|
||||||
|
|
@ -285,9 +305,7 @@ function handleScroll() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** ฟังก์ชั่นดึงข้อมูลรายการ Logs ตามเงื่อนไข */
|
||||||
* ค้นหาข้อมูลรายการ Logs
|
|
||||||
*/
|
|
||||||
function selectedDate() {
|
function selectedDate() {
|
||||||
if (!startDate.value) {
|
if (!startDate.value) {
|
||||||
const startDateToday = new Date();
|
const startDateToday = new Date();
|
||||||
|
|
@ -305,6 +323,7 @@ function selectedDate() {
|
||||||
searchAfter.value = undefined;
|
searchAfter.value = undefined;
|
||||||
storeData.fetchLog(
|
storeData.fetchLog(
|
||||||
{
|
{
|
||||||
|
rootId: qureyBody.rootId ?? undefined,
|
||||||
size: size.value ?? undefined,
|
size: size.value ?? undefined,
|
||||||
search: inputSearch.value ?? undefined,
|
search: inputSearch.value ?? undefined,
|
||||||
systemName: systemName.value ?? undefined,
|
systemName: systemName.value ?? undefined,
|
||||||
|
|
@ -406,8 +425,11 @@ function updateDate() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onBeforeMount(async () => {
|
||||||
fatchOrg();
|
await fetchOrganizationActive(); // ดึงข้อมูลโครงสร้างปัจจุบัน
|
||||||
|
});
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
systemName.value = route.query.system as string;
|
systemName.value = route.query.system as string;
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
date.setHours(0, 0, 0, 0); // ตั้งเวลาเป็น 00:00:00.000
|
date.setHours(0, 0, 0, 0); // ตั้งเวลาเป็น 00:00:00.000
|
||||||
|
|
@ -420,7 +442,7 @@ onMounted(() => {
|
||||||
<template>
|
<template>
|
||||||
<div class="bg-white q-pa-md">
|
<div class="bg-white q-pa-md">
|
||||||
<div class="row q-col-gutter-sm">
|
<div class="row q-col-gutter-sm">
|
||||||
<div class="col-4">
|
<div class="col-md-3">
|
||||||
<div class="q-mb-sm">
|
<div class="q-mb-sm">
|
||||||
<q-input dense outlined v-model="filter" label="ค้นหา">
|
<q-input dense outlined v-model="filter" label="ค้นหา">
|
||||||
<template v-slot:append>
|
<template v-slot:append>
|
||||||
|
|
@ -450,9 +472,9 @@ onMounted(() => {
|
||||||
<q-item
|
<q-item
|
||||||
clickable
|
clickable
|
||||||
class="row col-12 items-center text-dark q-py-xs q-pl-sm rounded-borders my-list"
|
class="row col-12 items-center text-dark q-py-xs q-pl-sm rounded-borders my-list"
|
||||||
:active="orgId == prop.node.id"
|
:active="qureyBody.rootId == prop.node.orgTreeId"
|
||||||
active-class="my-list-link text-primary text-weight-medium"
|
active-class="my-list-link text-primary text-weight-medium"
|
||||||
@click.stop="selectedOrg(prop.node.id)"
|
@click.stop="selectedOrg(prop.node.orgTreeId)"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
<div class="text-weight-medium">
|
<div class="text-weight-medium">
|
||||||
|
|
@ -476,9 +498,10 @@ onMounted(() => {
|
||||||
</q-tree>
|
</q-tree>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-8">
|
|
||||||
<div class="row no-wrap">
|
<div class="col-md-9">
|
||||||
<div class="row col-7 q-col-gutter-md">
|
<div class="row">
|
||||||
|
<div class="q-col-gutter-xs">
|
||||||
<div>
|
<div>
|
||||||
<q-btn-dropdown outline color="grey-5">
|
<q-btn-dropdown outline color="grey-5">
|
||||||
<template v-slot:label>
|
<template v-slot:label>
|
||||||
|
|
@ -505,7 +528,7 @@ onMounted(() => {
|
||||||
|
|
||||||
<q-space />
|
<q-space />
|
||||||
<div
|
<div
|
||||||
class="items-center justify-end q-gutter-md col-5"
|
class="items-center justify-end q-gutter-xs"
|
||||||
style="display: flex"
|
style="display: flex"
|
||||||
>
|
>
|
||||||
<!-- ค้นหาข้อความใน table -->
|
<!-- ค้นหาข้อความใน table -->
|
||||||
|
|
@ -517,6 +540,7 @@ onMounted(() => {
|
||||||
ref="filterRef"
|
ref="filterRef"
|
||||||
@update:model-value="
|
@update:model-value="
|
||||||
storeData.fetchLog({
|
storeData.fetchLog({
|
||||||
|
rootId: qureyBody.rootId ?? undefined,
|
||||||
size: size ?? undefined,
|
size: size ?? undefined,
|
||||||
search: inputSearch ?? undefined,
|
search: inputSearch ?? undefined,
|
||||||
systemName: systemName ?? undefined,
|
systemName: systemName ?? undefined,
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,6 @@ interface QueryProfile {
|
||||||
searchField: string;
|
searchField: string;
|
||||||
page: number;
|
page: number;
|
||||||
pageSize: number;
|
pageSize: number;
|
||||||
id: string | null;
|
rootId: string | undefined;
|
||||||
}
|
}
|
||||||
export type { Pagination, ItemsDropdown,DataTree,QueryProfile };
|
export type { Pagination, ItemsDropdown, DataTree, QueryProfile };
|
||||||
|
|
|
||||||
|
|
@ -100,11 +100,11 @@ const menuList = ref<{ icon: string; label: string; path: string }[]>([
|
||||||
]);
|
]);
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await storeData.fetchLog({
|
// await storeData.fetchLog({
|
||||||
size: size.value,
|
// size: size.value,
|
||||||
systemName: systemName.value ?? undefined,
|
// systemName: systemName.value ?? undefined,
|
||||||
date: date.value[0],
|
// date: date.value[0],
|
||||||
});
|
// });
|
||||||
if (route.query.system) {
|
if (route.query.system) {
|
||||||
const a = menuList.value.find((v) => {
|
const a = menuList.value.find((v) => {
|
||||||
if (v.path.includes(route.fullPath)) {
|
if (v.path.includes(route.fullPath)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue