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