fix loading Skeleton
This commit is contained in:
parent
ff6101067e
commit
016132096e
63 changed files with 3468 additions and 3452 deletions
|
|
@ -1,6 +1,6 @@
|
|||
<script setup lang="ts">
|
||||
import { useQuasar, type QTableProps } from "quasar";
|
||||
import { ref, onMounted } from "vue";
|
||||
import { useQuasar, type QTableProps } from "quasar";
|
||||
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
|
@ -10,27 +10,26 @@ import { useRegistryDataStore } from "@/modules/10_registry/store/Main";
|
|||
|
||||
import type { InsigniaFormType } 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 rows = ref<InsigniaFormType[]>([]);
|
||||
const rowsData = ref<InsigniaFormType[]>([]);
|
||||
const filter = ref<string>("");
|
||||
const rowsHistory = ref<InsigniaFormType[]>([]);
|
||||
const rowsHistoryData = ref<InsigniaFormType[]>([]);
|
||||
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 idByRow = ref<string>(""); // ตัวแปรสำหรับเก็บ id ของแถวที่เลือก
|
||||
const rows = ref<InsigniaFormType[]>([]); // ตัวแปรสำหรับเก็บข้อมูลเครื่องราชฯ
|
||||
const rowsData = ref<InsigniaFormType[]>([]); // ตัวแปรสำหรับเก็บข้อมูลเครื่องราชฯ ที่ใช้ในการค้นหา
|
||||
const filter = ref<string>(""); // ตัวแปรสำหรับเก็บค่าค้นหา
|
||||
const rowsHistory = ref<InsigniaFormType[]>([]); // ตัวแปรสำหรับเก็บข้อมูลประวัติการแก้ไขเครื่องราชฯ
|
||||
const rowsHistoryData = ref<InsigniaFormType[]>([]); // ตัวแปรสำหรับเก็บข้อมูลประวัติการแก้ไขเครื่องราชฯ ที่ใช้ในการค้นหา
|
||||
const modalHistory = ref<boolean>(false); // ตัวแปรสำหรับเปิด/ปิด modal ประวัติการแก้ไขเครื่องราชฯ
|
||||
const visibleColumns = ref<String[]>([
|
||||
"insignia",
|
||||
"insigniaType",
|
||||
|
|
@ -239,7 +238,6 @@ const columns = ref<QTableProps["columns"]>([
|
|||
const pagination = ref({
|
||||
sortBy: "lastUpdatedAt",
|
||||
});
|
||||
|
||||
const visibleColumnsHistory = ref<string[]>([
|
||||
"insignia",
|
||||
"insigniaType",
|
||||
|
|
@ -433,18 +431,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, "insignia"))
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
|
|
@ -455,14 +447,25 @@ function getData() {
|
|||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
isLoading.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
/** get history */
|
||||
function getHistory() {
|
||||
showLoader();
|
||||
http
|
||||
/**
|
||||
* ฟังก์ชันสำหรับเปิด modal ประวัติการแก้ไขเครื่องราชฯ
|
||||
* @param id ID ของแถวที่เลือก
|
||||
*/
|
||||
function onHistory(id: string) {
|
||||
modalHistory.value = true;
|
||||
idByRow.value = id;
|
||||
}
|
||||
|
||||
/** ฟังก์ชันสำหรับดึงข้อมูลประวัติการแก้ไขเครื่องราชฯ */
|
||||
async function getHistory() {
|
||||
isLoadingHistory.value = true;
|
||||
rowsHistory.value = [];
|
||||
rowsHistoryData.value = [];
|
||||
await http
|
||||
.get(
|
||||
config.API.dataUserCertificateHistoryByType(
|
||||
link.value,
|
||||
|
|
@ -479,15 +482,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,
|
||||
|
|
@ -498,11 +514,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"
|
||||
|
|
@ -539,7 +554,10 @@ onMounted(async () => {
|
|||
:display-value="$q.lang.table.columns"
|
||||
/>
|
||||
</q-toolbar>
|
||||
|
||||
<SkeletonTable v-if="isLoading" :columns="columns" />
|
||||
<d-table
|
||||
v-else
|
||||
flat
|
||||
dense
|
||||
bordered
|
||||
|
|
@ -674,8 +692,10 @@ onMounted(async () => {
|
|||
:visibleColumns="visibleColumnsHistory"
|
||||
:columns="columnsHistory"
|
||||
:type="'insignia'"
|
||||
:is-loading="isLoadingHistory"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.absolute_button {
|
||||
position: absolute;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue