fix(command): sort

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-09-30 14:12:12 +07:00
parent 6d3c26d0af
commit 00fc7eac26
8 changed files with 109 additions and 212 deletions

View file

@ -1,16 +1,16 @@
<script setup lang="ts">
import { onMounted, ref, watch } from "vue";
import { onMounted, ref } from "vue";
import { useQuasar } from "quasar";
import axios from "axios";
import { useRoute, useRouter } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
import { useCommandDetail } from "@/modules/18_command/store/DetailStore";
import { usePagination } from "@/composables/usePagination";
import http from "@/plugins/http";
import config from "@/app.config";
import type { QTableProps } from "quasar";
import type { Pagination } from "@/modules/18_command/interface/index/Main";
import type {
DataFileDownload,
DataDirector,
@ -31,6 +31,7 @@ const {
dialogConfirm,
dialogMessageNotify,
} = useCounterMixin();
const { pagination, params, onRequest } = usePagination("", fetchListDirector);
const commandId = ref<string>(route.params.id.toString()); //ID
@ -48,16 +49,13 @@ const fileUploadOrder = ref<any>(null); //ไฟล์คำสั่ง
const fileUploadTailer = ref<any>(null); //
const fileOrder = ref<any>(null); //
const fileTailer = ref<any>(null); //
const isDirector = ref<boolean>(true);
const isAct = ref<boolean>(false);
const isDirector = ref<boolean>(true); //
const isAct = ref<boolean>(false); //
const dataFile = ref<DataFileDownload>(); //
const modalSelect = ref<boolean>(false); //popup /
const search = ref<string>("");
const rows = ref<DataDirector[]>([]); ///
const page = ref<number>(1);
const pageSize = ref<number>(10);
const maxPaeg = ref<number>(1);
const total = ref<number>(0);
const selected = ref<DataDirector[]>([]); ///
const columns = ref<QTableProps["columns"]>([
{
@ -80,7 +78,7 @@ const columns = ref<QTableProps["columns"]>([
},
{
name: "fullName",
name: "firstName",
align: "left",
label: "ชื่อ-นามสกุล",
sortable: true,
@ -133,14 +131,11 @@ const modalComment = ref<boolean>(false); //popup แสดงความเห
const reason = ref<string>("");
//
const isCheckOrder = ref<boolean>(true); //
const isLoad = ref<boolean>(false); //
const isPersonSign = ref<boolean>(false); //
const modalPerView = ref<boolean>(false);
/**
* งกนยนยนการสงใหอำนาจลงนามอน
*/
/** ฟังก์ชันยืนยันการส่งให้ผู้มีอำนาจลงนามอนุมัติ*/
function onConfirmDraft() {
if (
store?.dataCommand?.commandNo !== "" &&
@ -156,21 +151,20 @@ function onConfirmDraft() {
}
}
function fetchListDirector() {
/** ฟังก์ชันดึงข้อมูลผู้บังคับบัญชา/ผู้มีอำนาจออกคำสั่ง */
async function fetchListDirector() {
showLoader();
http
await http
.post(config.API.commandDirector, {
isDirector: isDirector.value, // fix true
isAct: isAct.value,
keyword: search.value,
page: page.value,
pageSize: pageSize.value,
...params.value,
})
.then((res) => {
const data = res.data.result;
rows.value = data.data;
maxPaeg.value = Math.ceil(data.total / pageSize.value);
total.value = data.total;
const result = res.data.result;
pagination.value.rowsNumber = result.total;
rows.value = result.data;
})
.catch((err) => {
messageError($q, err);
@ -180,11 +174,13 @@ function fetchListDirector() {
});
}
/** ฟังก์ชันค้นหาข้อมูล */
function onSearchData() {
page.value = 1;
pagination.value.page = 1;
fetchListDirector();
}
/** ฟังก์ชันยืนยันการส่งไปยังผู้บังคับบัญชา/ผู้มีอำนาจ */
function onConfirmSendToCommander() {
dialogConfirm(
$q,
@ -212,12 +208,14 @@ function onConfirmSendToCommander() {
);
}
/** ฟังก์ชันแสดง popup แสดงความเห็น */
function onComment(id: string, isStatus: boolean) {
modalComment.value = true;
commandSignId.value = id;
isSignatory.value = isStatus;
}
/** ฟังก์ชันบันทึกความคิดเห็น */
function onSubmitComment() {
dialogConfirm($q, async () => {
showLoader();
@ -243,6 +241,7 @@ function onSubmitComment() {
});
}
/** ฟังก์ชันปิด dialog และ reset ค่า */
function onCloseDialog() {
isAct.value = false;
isDirector.value = true;
@ -252,17 +251,21 @@ function onCloseDialog() {
rows.value = [];
selected.value = [];
search.value = "";
page.value = 1;
pageSize.value = 10;
maxPaeg.value = 1;
total.value = 0;
pagination.value = {
page: 1,
rowsPerPage: 10,
rowsNumber: 0,
sortBy: "",
descending: false,
};
reason.value = "";
}
function updatePagination(newPagination: Pagination) {
pageSize.value = newPagination.rowsPerPage;
}
/**
* งกนดงขอมลเอกสารคำส
* @param group ประเภทคำส order=คำส, tailer=เอกสารแนบทาย
*/
async function fetchDoc(group: string) {
showLoader();
let type = group === "order" ? "คำสั่ง" : "แนบท้าย";
@ -284,6 +287,10 @@ async function fetchDoc(group: string) {
});
}
/**
* งกนอพโหลดไฟลคำส
* @param group ประเภทคำส order=คำส, tailer=เอกสารแนบทาย
*/
function onUploadFile(group: string) {
showLoader();
let type = group === "order" ? "คำสั่ง" : "แนบท้าย";
@ -312,7 +319,10 @@ function onUploadFile(group: string) {
}
/**
* งกนสำหรบอพโหลดไฟลเอกสารหลกฐาน
* งกนอพโหลดไฟลคำส
* @param uploadUrl งคพโหลดไฟล
* @param file ไฟลพโหลด
* @param group ประเภทคำส order=คำส, tailer=เอกสารแนบทาย
*/
async function uploadFileDoc(uploadUrl: string, file: any, group: string) {
const formData = new FormData();
@ -340,11 +350,11 @@ async function uploadFileDoc(uploadUrl: string, file: any, group: string) {
});
}
const dataFile = ref<DataFileDownload>();
/**
* ดาวนโหลดลงกไฟล
* @param fileName file name
* งกนดาวนโหลดไฟล
* @param file อมลไฟล
* @param group ประเภทคำส order=คำส, tailer=เอกสารแนบทาย
* @param isView ไฟลในหนาใหมไหม (default=false)
*/
function downloadFile(file: any, group: string, isView: boolean = false) {
let type = group === "order" ? "คำสั่ง" : "แนบท้าย";
@ -375,6 +385,7 @@ function downloadFile(file: any, group: string, isView: boolean = false) {
});
}
/** ฟังก์ชันดึงข้อมูลรายการผู้มีอำนาจ */
async function fetchListAuthority() {
await http
.get(config.API.command + `/step/${commandId.value}`)
@ -387,17 +398,11 @@ async function fetchListAuthority() {
});
}
/** ฟังก์ชันแสดงเฉพาะรักษาการแทน */
function onAct() {
isDirector.value = !isDirector.value;
}
watch(
() => pageSize.value,
() => {
onSearchData();
}
);
onMounted(async () => {
isLoad.value = false;
let promises = [fetchDoc("order")];
@ -742,7 +747,7 @@ onMounted(async () => {
</div>
<div class="col-12">
<d-table
<p-table
flat
:columns="columns"
:rows="rows"
@ -751,7 +756,8 @@ onMounted(async () => {
selection="single"
v-model:selected="selected"
:rows-per-page-options="[10, 25, 50, 100]"
@update:pagination="updatePagination"
v-model:pagination="pagination"
@request="onRequest"
>
<template v-slot:header-selection="scope">
<q-checkbox
@ -796,21 +802,7 @@ onMounted(async () => {
</q-td>
</q-tr>
</template>
<template v-slot:pagination="scope">
งหมด {{ total.toLocaleString() }} รายการ
<q-pagination
v-model="page"
active-color="primary"
color="dark"
:max="Number(maxPaeg)"
size="sm"
boundary-links
direction-links
:max-pages="5"
@update:model-value="fetchListDirector"
></q-pagination>
</template>
</d-table>
</p-table>
</div>
<div class="col-12">
@ -861,10 +853,7 @@ onMounted(async () => {
</q-card>
</q-dialog>
<PerviewPDF
v-model:modal="modalPerView"
v-model:data-file="dataFile as DataFileDownload"
/>
<PerviewPDF v-model:modal="modalPerView" v-model:data-file="dataFile" />
</template>
<style lang="scss" scoped>