fix(command): sort
This commit is contained in:
parent
6d3c26d0af
commit
00fc7eac26
8 changed files with 109 additions and 212 deletions
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue