fix loading Skeleton

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-08-05 15:15:49 +07:00
parent ff6101067e
commit 016132096e
63 changed files with 3468 additions and 3452 deletions

View file

@ -1,38 +1,36 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useQuasar, type QTableProps } from "quasar";
import { ref, reactive, onMounted } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import { useDataStore } from "@/stores/data";
import { useRegistryInFormationStore } from "@/modules/10_registry/store/registry";
import { useRegistryDataStore } from "@/modules/10_registry/store/Main";
import type { HonorFormData } from "@/modules/10_registry/interface/index/Main";
//history dialog
import DialogHistory from "@/modules/10_registry/Dialog/DialogHistory.vue";
import SkeletonTable from "@/components/SkeletonTable.vue";
const link = ref<string>("");
const dataPerson = useDataStore();
const idByRow = ref<string>("");
const store = useRegistryInFormationStore();
const rows = ref<HonorFormData[]>([]);
const rowsData = ref<HonorFormData[]>([]);
const filter = ref<string>("");
const rowsHistory = ref<HonorFormData[]>([]);
const rowsHistoryData = ref<HonorFormData[]>([]);
const $q = useQuasar();
const mode = ref<boolean>($q.screen.gt.xs);
const mixin = useCounterMixin();
const { showLoader, hideLoader, messageError, date2Thai, onSearchDataTable } =
mixin;
const dataPerson = useDataStore();
const { getPathUploadFlie } = useRegistryDataStore();
const { showLoader, hideLoader, messageError, date2Thai, onSearchDataTable } =
useCounterMixin();
const modalHistory = ref<boolean>(false);
/** ตัวแปรข้อมูล */
const mode = ref<boolean>($q.screen.gt.xs); //
const link = ref<string>(""); //
const isLoading = ref<boolean>(false); //
const isLoadingHistory = ref<boolean>(false); //
const rows = ref<HonorFormData[]>([]); //
const rowsData = ref<HonorFormData[]>([]); //
const filter = ref<string>(""); //
const idByRow = ref<string>(""); // id
const rowsHistory = ref<HonorFormData[]>([]); //
const rowsHistoryData = ref<HonorFormData[]>([]); //
const modalHistory = ref<boolean>(false); // / modal
const visibleColumns = ref<String[]>([
"issuer",
"detail",
@ -127,7 +125,6 @@ const columns = ref<QTableProps["columns"]>([
const pagination = ref({
sortBy: "lastUpdatedAt",
});
const visibleColumnsHistory = ref<string[]>([
"issuer",
"detail",
@ -219,18 +216,12 @@ const columnsHistory = ref<QTableProps["columns"]>([
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const fileGroup = ref<string>("ประกาศเกียรติคุณ"); //
const fileGroup = ref<string>("ประกาศเกียรติคุณ");
function onHistory(id: string) {
modalHistory.value = true;
idByRow.value = id;
}
/** get data */
function getData() {
showLoader();
http
/** ฟังก์ชันสำหรับดึงข้อมูลประกาศเกียรติคุณ */
async function getData() {
isLoading.value = true;
await http
.get(config.API.dataUserCertificateByType(link.value, "honor"))
.then((res) => {
const data = res.data.result;
@ -241,18 +232,30 @@ function getData() {
messageError($q, e);
})
.finally(() => {
hideLoader();
isLoading.value = false;
});
}
/**
* เป modal ประวการแกไข
* @param id ID ของแถวทเลอก
*/
function onHistory(id: string) {
modalHistory.value = true;
idByRow.value = id;
}
/** get history */
function getHistory() {
async function getHistory() {
isLoadingHistory.value = true;
rowsHistory.value = [];
rowsHistoryData.value = [];
const url =
dataPerson.officerType == "OFFICER"
? config.API.dataUserHonorHistory("honor", "", idByRow.value)
: config.API.dataUserHonorHistory("honor", "-employee", idByRow.value);
showLoader();
http
await http
.get(url)
.then((res) => {
const data = res.data.result;
@ -263,15 +266,28 @@ function getHistory() {
messageError($q, e);
})
.finally(() => {
hideLoader();
isLoadingHistory.value = false;
});
}
/**
* งกนสำหรบดาวนโหลดไฟล
* @param id ID ของไฟลองการดาวนโหลด
* @param profileId id ของโปรไฟล
*/
async function onDownloadFile(id: string, profileId: string) {
const data = await getPathUploadFlie(fileGroup.value, profileId, id);
window.open(data.downloadUrl, "_blank");
showLoader();
try {
const data = await getPathUploadFlie(fileGroup.value, profileId, id);
window.open(data.downloadUrl, "_blank");
} catch (error) {
messageError($q, error);
} finally {
hideLoader();
}
}
/** ฟังก์ชันสำหรับค้นหาข้อมูลในตาราง */
function onSearch() {
rows.value = onSearchDataTable(
filter.value,
@ -282,11 +298,10 @@ function onSearch() {
onMounted(async () => {
link.value = await dataPerson.getProFileType();
getData();
await getData();
});
</script>
<template>
<!-- v-if="mode" -->
<div class="col-12">
<q-toolbar class="q-px-none q-mt-md">
<span class="text-blue-6 text-weight-bold text-body1"
@ -323,7 +338,10 @@ onMounted(async () => {
:display-value="$q.lang.table.columns"
/>
</q-toolbar>
<SkeletonTable v-if="isLoading" :columns="columns" />
<d-table
v-else
flat
dense
bordered
@ -445,6 +463,7 @@ onMounted(async () => {
:rows-data="rowsHistoryData"
:visibleColumns="visibleColumnsHistory"
:columns="columnsHistory"
:is-loading="isLoadingHistory"
/>
</template>
<style scoped>