488 lines
16 KiB
Vue
488 lines
16 KiB
Vue
<script setup lang="ts">
|
|
import { ref, onMounted, computed } from "vue";
|
|
import { useQuasar, type QTableProps } from "quasar";
|
|
|
|
import http from "@/plugins/http";
|
|
import config from "@/app.config";
|
|
import { useCounterMixin } from "@/stores/mixin";
|
|
import { useDataStore } from "@/stores/data";
|
|
import { useRegistryDataStore } from "@/modules/10_registry/store/Main";
|
|
import { downloadBlobFile } from "@/modules/10_registry/utils/downloadFile";
|
|
|
|
import type { NopaidFormType } from "@/modules/10_registry/interface/index/Main";
|
|
|
|
import DialogHistory from "@/modules/10_registry/Dialog/DialogHistory.vue";
|
|
|
|
const $q = useQuasar();
|
|
const dataPerson = useDataStore();
|
|
const { getPathUploadFlie } = useRegistryDataStore();
|
|
const { showLoader, hideLoader, messageError, date2Thai, onSearchDataTable } =
|
|
useCounterMixin();
|
|
|
|
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<NopaidFormType[]>([]); //ข้อมูลที่แสดงในตาราง
|
|
const rowsData = ref<NopaidFormType[]>([]); //ข้อมูลที่ใช้สำหรับค้นหาในตาราง
|
|
const filter = ref<string>(""); //ตัวกรองสำหรับค้นหาในตาราง
|
|
const idByRow = ref<string>(""); // รหัสของแถวที่ถูกเลือกสำหรับประวัติ
|
|
const rowsHistory = ref<NopaidFormType[]>([]); // ข้อมูลประวัติที่แสดงในตาราง
|
|
const rowsHistoryData = ref<NopaidFormType[]>([]); // ข้อมูลประวัติที่ใช้สำหรับค้นหาในตาราง
|
|
const modalHistory = ref<boolean>(false); // สถานะการแสดงโมดัลประวัติ
|
|
// ข้อความสำหรับแสดงในหัวตาราง
|
|
const salaryText = computed(() => {
|
|
return link.value == "" ? "เงินเดือน" : "ค่าจ้าง";
|
|
});
|
|
const visibleColumns = ref<string[]>([
|
|
"date",
|
|
"detail",
|
|
"reference",
|
|
"refCommandNo",
|
|
"refCommandDate",
|
|
"lastUpdateFullName",
|
|
"lastUpdatedAt",
|
|
]);
|
|
const columns = ref<QTableProps["columns"]>([
|
|
{
|
|
name: "date",
|
|
align: "left",
|
|
label: "วัน เดือน ปี",
|
|
sortable: true,
|
|
field: "date",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
format: (v) => date2Thai(v),
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "reference",
|
|
align: "left",
|
|
label: "เอกสารอ้างอิง",
|
|
sortable: true,
|
|
field: "reference",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "detail",
|
|
align: "left",
|
|
label: "รายละเอียด",
|
|
sortable: true,
|
|
field: "detail",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "refCommandNo",
|
|
align: "left",
|
|
label: "เลขที่คำสั่ง",
|
|
sortable: true,
|
|
field: "refCommandNo",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
|
|
{
|
|
name: "refCommandDate",
|
|
align: "left",
|
|
label: "เอกสารอ้างอิง (ลงวันที่)",
|
|
sortable: true,
|
|
field: "refCommandDate",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
format: (v) => date2Thai(v),
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "lastUpdateFullName",
|
|
align: "left",
|
|
label: "ผู้ดำเนินการ",
|
|
sortable: true,
|
|
field: "lastUpdateFullName",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "lastUpdatedAt",
|
|
align: "left",
|
|
label: "วันที่แก้ไข",
|
|
sortable: true,
|
|
field: "lastUpdatedAt",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
format: (v) => date2Thai(v, false, true),
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
]);
|
|
const pagination = ref({
|
|
sortBy: "lastUpdatedAt",
|
|
});
|
|
const visibleColumnsHistory = ref<string[]>([
|
|
"date",
|
|
"reference",
|
|
"detail",
|
|
"refCommandNo",
|
|
"refCommandDate",
|
|
"lastUpdateFullName",
|
|
"lastUpdatedAt",
|
|
]);
|
|
const columnsHistory = ref<QTableProps["columns"]>([
|
|
{
|
|
name: "date",
|
|
align: "left",
|
|
label: "วัน เดือน ปี",
|
|
sortable: true,
|
|
field: "date",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
format: (v) => date2Thai(v),
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "reference",
|
|
align: "left",
|
|
label: "เอกสารอ้างอิง",
|
|
sortable: true,
|
|
field: "reference",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "detail",
|
|
align: "left",
|
|
label: "รายละเอียด",
|
|
sortable: true,
|
|
field: "detail",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "refCommandNo",
|
|
align: "left",
|
|
label: "เลขที่คำสั่ง",
|
|
sortable: true,
|
|
field: "refCommandNo",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "refCommandDate",
|
|
align: "left",
|
|
label: "เอกสารอ้างอิง (ลงวันที่)",
|
|
sortable: true,
|
|
field: "refCommandDate",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
format: (v) => date2Thai(v),
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "lastUpdateFullName",
|
|
align: "left",
|
|
label: "ผู้ดำเนินการ",
|
|
sortable: true,
|
|
field: "lastUpdateFullName",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "lastUpdatedAt",
|
|
align: "left",
|
|
label: "วันที่แก้ไข",
|
|
sortable: true,
|
|
field: "lastUpdatedAt",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
format: (v) => date2Thai(v, false, true),
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
]);
|
|
const fileGroup = ref<string>(`เอกสารบันทึกวันที่ไม่ได้รับ${salaryText.value}`); // กลุ่มไฟล์สำหรับเอกสารบันทึก
|
|
|
|
/** ฟังก์ชันสำหรับดึงข้อมูล */
|
|
async function getData() {
|
|
isLoading.value = true;
|
|
await http
|
|
.get(config.API.dataUserNopaidByType(link.value))
|
|
.then((res) => {
|
|
const data = res.data.result;
|
|
rows.value = data;
|
|
rowsData.value = data;
|
|
})
|
|
.catch((e) => {
|
|
messageError($q, e);
|
|
})
|
|
.finally(() => {
|
|
isLoading.value = false;
|
|
});
|
|
}
|
|
|
|
/**
|
|
* ฟังก์ชันสำหรับเปิดประวัติการแก้ไข
|
|
* @param 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.dataUserSalaryNopaidHistoryByType(link.value, idByRow.value),
|
|
)
|
|
.then((res) => {
|
|
const data = res.data.result;
|
|
rowsHistory.value = data;
|
|
rowsHistoryData.value = data;
|
|
})
|
|
.catch((e) => {
|
|
messageError($q, e);
|
|
})
|
|
.finally(() => {
|
|
isLoadingHistory.value = false;
|
|
});
|
|
}
|
|
|
|
/**
|
|
* ฟังก์ชันสำหรับดาวน์โหลดไฟล์
|
|
* @param id รหัสของแถวที่ถูกเลือกสำหรับดาวน์โหลด
|
|
* @param profileId รหัสโปรไฟล์ของผู้ใช้
|
|
*/
|
|
async function onDownloadFile(id: string, profileId: string) {
|
|
showLoader();
|
|
try {
|
|
const res = await getPathUploadFlie(fileGroup.value, profileId, id);
|
|
const downloadUrl = res.downloadUrl;
|
|
await downloadBlobFile({
|
|
downloadUrl: downloadUrl,
|
|
fileName: `บันทึกวันที่ไม่ได้รับ${salaryText.value}ฯ`,
|
|
});
|
|
} catch (e) {
|
|
messageError($q, e);
|
|
} finally {
|
|
hideLoader();
|
|
}
|
|
}
|
|
|
|
/** ฟังก์ชันสำหรับค้นหาข้อมูล */
|
|
function onSearch() {
|
|
rows.value = onSearchDataTable(
|
|
filter.value,
|
|
rowsData.value,
|
|
columns.value ? columns.value : [],
|
|
);
|
|
}
|
|
|
|
onMounted(async () => {
|
|
link.value = await dataPerson.getProFileType();
|
|
await getData();
|
|
});
|
|
</script>
|
|
<template>
|
|
<div class="col-12">
|
|
<q-toolbar class="q-px-none q-mt-md">
|
|
<span class="text-blue-6 text-weight-bold text-body1">{{
|
|
`บันทึกวันที่ไม่ได้รับ${salaryText}ฯ`
|
|
}}</span>
|
|
<q-space />
|
|
<q-input
|
|
v-if="mode"
|
|
class="inputgreen"
|
|
outlined
|
|
dense
|
|
v-model="filter"
|
|
label="ค้นหา"
|
|
style="max-width: 200px"
|
|
@keydown.enter.prevent="onSearch"
|
|
>
|
|
<template v-slot:append>
|
|
<q-icon name="search" />
|
|
</template>
|
|
</q-input>
|
|
<q-select
|
|
v-if="mode"
|
|
class="q-ml-sm"
|
|
dense
|
|
multiple
|
|
outlined
|
|
emit-value
|
|
map-options
|
|
options-dense
|
|
option-value="name"
|
|
style="min-width: 140px"
|
|
v-model="visibleColumns"
|
|
:options="columns"
|
|
:display-value="$q.lang.table.columns"
|
|
/>
|
|
</q-toolbar>
|
|
|
|
<d-table
|
|
flat
|
|
dense
|
|
bordered
|
|
virtual-scroll
|
|
:rows="rows.length !== 0 ? rows : []"
|
|
:columns="columns"
|
|
:grid="!mode"
|
|
:rows-per-page-options="[10, 25, 50, 100]"
|
|
:visible-columns="visibleColumns"
|
|
:virtual-scroll-sticky-size-start="48"
|
|
:pagination="pagination"
|
|
:loading="isLoading"
|
|
row-key="id"
|
|
>
|
|
<template v-slot:header="props">
|
|
<q-tr :props="props">
|
|
<q-th v-for="col in props.cols" :key="col.name" :props="props">
|
|
<span class="text-weight-medium">{{ col.label }}</span>
|
|
</q-th>
|
|
<q-th auto-width />
|
|
<q-th auto-width />
|
|
</q-tr>
|
|
</template>
|
|
|
|
<template v-if="mode" v-slot:body="props">
|
|
<q-tr :props="props" class="cursor-pointer">
|
|
<q-td v-for="(col, index) in props.cols" :key="col.name">
|
|
<div v-if="col.name == 'no'">
|
|
{{ props.rowIndex + 1 }}
|
|
</div>
|
|
<div v-else-if="col.name == 'status'">
|
|
{{ props.row.status ? props.row.status : "-" }}
|
|
</div>
|
|
<div v-else>
|
|
{{ col.value ? col.value : "-" }}
|
|
</div>
|
|
</q-td>
|
|
<q-td auto-width>
|
|
<q-btn
|
|
v-if="props.row.isUpload"
|
|
color="green"
|
|
flat
|
|
dense
|
|
round
|
|
size="14px"
|
|
icon="mdi-file-document-outline"
|
|
@click="onDownloadFile(props.row.id, props.row.profileId)"
|
|
>
|
|
<q-tooltip>ดาวน์โหลด</q-tooltip>
|
|
</q-btn>
|
|
</q-td>
|
|
<q-td auto-width>
|
|
<q-btn
|
|
color="info"
|
|
flat
|
|
dense
|
|
round
|
|
size="14px"
|
|
icon="mdi-history"
|
|
@click="onHistory(props.row.id)"
|
|
>
|
|
<q-tooltip>{{
|
|
`ประวัติแก้ไขบันทึกวันที่ไม่ได้รับ${salaryText}ฯ`
|
|
}}</q-tooltip>
|
|
</q-btn>
|
|
</q-td>
|
|
</q-tr>
|
|
</template>
|
|
<template v-else v-slot:item="props">
|
|
<div class="q-mb-xs col-xs-12 col-sm-6 col-md-4 col-lg-3">
|
|
<q-card bordered flat>
|
|
<q-list dense class="q-mt-lg relative-position">
|
|
<div class="row absolute_button">
|
|
<q-btn
|
|
v-if="props.row.isUpload"
|
|
color="green"
|
|
flat
|
|
dense
|
|
round
|
|
size="14px"
|
|
icon="mdi-file-document-outline"
|
|
@click="onDownloadFile(props.row.id, props.row.profileId)"
|
|
>
|
|
<q-tooltip>ดาวน์โหลด</q-tooltip>
|
|
</q-btn>
|
|
<q-btn
|
|
icon="mdi-history"
|
|
color="info"
|
|
flat
|
|
dense
|
|
round
|
|
size="14px"
|
|
@click="onHistory(props.row.id)"
|
|
>
|
|
<q-tooltip>{{
|
|
`ประวัติแก้ไขบันทึกวันที่ไม่ได้รับ${salaryText}ฯ`
|
|
}}</q-tooltip>
|
|
</q-btn>
|
|
</div>
|
|
<q-item v-for="col in props.cols" :key="col.name">
|
|
<q-item-section class="fix_top">
|
|
<q-item-label class="text-grey-6 text-weight-medium">{{
|
|
col.label
|
|
}}</q-item-label>
|
|
</q-item-section>
|
|
<q-item-section class="fix_top">
|
|
<q-item-label class="text-dark text-weight-medium">{{
|
|
col.value ? col.value : "-"
|
|
}}</q-item-label>
|
|
</q-item-section>
|
|
</q-item>
|
|
</q-list>
|
|
</q-card>
|
|
</div>
|
|
</template>
|
|
</d-table>
|
|
</div>
|
|
|
|
<DialogHistory
|
|
v-model:modal="modalHistory"
|
|
:title="`ประวัติแก้ไขบันทึกวันที่ไม่ได้รับ${salaryText}ฯ`"
|
|
:getData="getHistory"
|
|
:rows="rowsHistory"
|
|
:rows-data="rowsHistoryData"
|
|
:visibleColumns="visibleColumnsHistory"
|
|
:columns="columnsHistory"
|
|
:is-loading="isLoadingHistory"
|
|
/>
|
|
</template>
|
|
<style scoped>
|
|
.absolute_button {
|
|
position: absolute;
|
|
right: 5px;
|
|
top: -20px;
|
|
}
|
|
|
|
.fix_top {
|
|
justify-content: start !important;
|
|
margin-top: 10px;
|
|
}
|
|
</style>
|