2024-09-24 11:19:41 +07:00
|
|
|
<script setup lang="ts">
|
2024-09-24 17:16:27 +07:00
|
|
|
import { ref, watch } from "vue";
|
2024-09-24 11:19:41 +07:00
|
|
|
import { useQuasar } from "quasar";
|
|
|
|
|
|
2024-09-24 17:16:27 +07:00
|
|
|
import http from "@/plugins/http";
|
|
|
|
|
import config from "@/app.config";
|
2024-09-24 11:19:41 +07:00
|
|
|
import { useRouter } from "vue-router";
|
|
|
|
|
import { useCounterMixin } from "@/stores/mixin";
|
|
|
|
|
import { useCommandMainStore } from "@/modules/18_command/store/Main";
|
|
|
|
|
|
|
|
|
|
import type { QTableProps } from "quasar";
|
2024-10-08 10:35:55 +07:00
|
|
|
import type {
|
|
|
|
|
ListCommand,
|
|
|
|
|
DataOrder,
|
|
|
|
|
Pagination,
|
|
|
|
|
} from "@/modules/18_command/interface/index/Main";
|
2024-09-27 09:09:48 +07:00
|
|
|
import type { DataListCommand } from "@/modules/18_command/interface/response/Main";
|
2024-09-24 11:19:41 +07:00
|
|
|
|
|
|
|
|
import DialogHeader from "@/components/DialogHeader.vue";
|
|
|
|
|
|
|
|
|
|
const storeCommand = useCommandMainStore();
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
const $q = useQuasar();
|
|
|
|
|
const mixin = useCounterMixin();
|
2024-10-08 10:35:55 +07:00
|
|
|
const { showLoader, messageError, dialogConfirm, hideLoader, date2Thai } =
|
|
|
|
|
mixin;
|
2024-09-24 11:19:41 +07:00
|
|
|
|
2024-10-08 10:35:55 +07:00
|
|
|
/** props*/
|
2024-09-24 11:19:41 +07:00
|
|
|
const modal = defineModel<boolean>("modal", { required: true });
|
|
|
|
|
const props = defineProps({
|
2024-09-25 10:22:03 +07:00
|
|
|
commandTypeCode: String, // ไอดีประเภทคำสั่ง
|
2024-10-02 14:59:45 +07:00
|
|
|
persons: Array, // ไอดีคนที่เลือกออกคำสั่งส่งมาเป็น array
|
2024-10-18 16:48:27 +07:00
|
|
|
notPerson: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: false,
|
|
|
|
|
},
|
2024-09-24 11:19:41 +07:00
|
|
|
});
|
|
|
|
|
|
2024-09-25 10:22:03 +07:00
|
|
|
const commandOp = ref<ListCommand[]>([]); // ประเภทคำสั่ง
|
2024-09-24 17:16:27 +07:00
|
|
|
const commandType = ref<string>(""); //ประเภทคำสั่ง
|
2024-10-08 10:35:55 +07:00
|
|
|
const commandNo = ref<string>(""); //คำสั่งเลขที่
|
|
|
|
|
const commandYear = ref<number>(new Date().getFullYear()); //ปี
|
2024-09-24 17:16:27 +07:00
|
|
|
|
|
|
|
|
const rows = ref<DataListCommand[]>([]); // รายการคำสั่ง
|
2024-10-08 10:35:55 +07:00
|
|
|
const selected = ref<DataOrder[]>([]); // id คำสั่งที่เลือก
|
2024-09-24 11:19:41 +07:00
|
|
|
const filter = ref<string>(""); // คำค้นหา
|
2024-10-08 10:35:55 +07:00
|
|
|
const total = ref<number>(0); //จำนวนรายการ
|
|
|
|
|
const totalList = ref<number>(1); //จำนวนหน้า
|
2024-09-24 17:16:27 +07:00
|
|
|
const visibleColumns = ref<string[]>([
|
|
|
|
|
"commandNo",
|
|
|
|
|
"issue",
|
|
|
|
|
"commandExcecuteDate",
|
|
|
|
|
"commandAffectDate",
|
|
|
|
|
"createdFullName",
|
|
|
|
|
"assignFullName",
|
2024-09-24 11:19:41 +07:00
|
|
|
]);
|
2024-09-24 17:16:27 +07:00
|
|
|
const columns = ref<QTableProps["columns"]>([
|
2024-09-24 11:19:41 +07:00
|
|
|
{
|
2024-09-24 17:16:27 +07:00
|
|
|
name: "commandNo",
|
2024-09-24 11:19:41 +07:00
|
|
|
align: "left",
|
2024-09-24 17:16:27 +07:00
|
|
|
label: "เลขที่คำสั่ง",
|
2024-09-24 11:19:41 +07:00
|
|
|
sortable: false,
|
2024-09-24 17:16:27 +07:00
|
|
|
field: "commandNo",
|
|
|
|
|
format(val, row) {
|
|
|
|
|
return val ? `${val} / ${row.commandYear + 543}` : "-";
|
|
|
|
|
},
|
2024-09-24 11:19:41 +07:00
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-09-24 17:16:27 +07:00
|
|
|
name: "issue",
|
2024-09-24 11:19:41 +07:00
|
|
|
align: "left",
|
2024-09-24 17:16:27 +07:00
|
|
|
label: "ชื่อคำสั่ง",
|
2024-09-24 11:19:41 +07:00
|
|
|
sortable: true,
|
2024-09-24 17:16:27 +07:00
|
|
|
field: "issue",
|
2024-09-24 11:19:41 +07:00
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-09-30 13:30:45 +07:00
|
|
|
name: "commandAffectDate",
|
2024-09-24 11:19:41 +07:00
|
|
|
align: "left",
|
2024-09-24 17:16:27 +07:00
|
|
|
label: "วันที่ลงนาม",
|
|
|
|
|
sortable: false,
|
2024-09-30 13:30:45 +07:00
|
|
|
field: "commandAffectDate",
|
2024-09-24 17:16:27 +07:00
|
|
|
format(val) {
|
|
|
|
|
return val ? date2Thai(val) : "-";
|
|
|
|
|
},
|
2024-09-24 11:19:41 +07:00
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-09-30 13:30:45 +07:00
|
|
|
name: "commandExcecuteDate",
|
2024-09-24 11:19:41 +07:00
|
|
|
align: "left",
|
2024-09-24 17:16:27 +07:00
|
|
|
label: "วันที่คำสั่งมีผล",
|
|
|
|
|
sortable: false,
|
2024-09-30 13:30:45 +07:00
|
|
|
field: "commandExcecuteDate",
|
2024-09-24 17:16:27 +07:00
|
|
|
format(val) {
|
|
|
|
|
return val ? date2Thai(val) : "-";
|
|
|
|
|
},
|
2024-09-24 11:19:41 +07:00
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-09-24 17:16:27 +07:00
|
|
|
name: "createdFullName",
|
2024-09-24 11:19:41 +07:00
|
|
|
align: "left",
|
2024-09-24 17:16:27 +07:00
|
|
|
label: "ผู้สร้าง",
|
|
|
|
|
sortable: false,
|
|
|
|
|
field: "createdFullName",
|
2024-09-24 11:19:41 +07:00
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-09-24 17:16:27 +07:00
|
|
|
name: "assignFullName",
|
2024-09-24 11:19:41 +07:00
|
|
|
align: "left",
|
2024-09-24 17:16:27 +07:00
|
|
|
label: "ผู้ลงนาม",
|
|
|
|
|
sortable: false,
|
|
|
|
|
field: "assignFullName",
|
2024-09-24 11:19:41 +07:00
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
]);
|
2024-10-08 10:35:55 +07:00
|
|
|
const pagination = ref({
|
|
|
|
|
sortBy: "createdAt",
|
|
|
|
|
descending: true,
|
|
|
|
|
page: 1,
|
|
|
|
|
rowsPerPage: 10,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const selectCreate = ref<string | null>("NEW"); //ประเภทการออกคำสั่ง สร้างใหม่/คำสั่งแบบร่าง
|
|
|
|
|
|
|
|
|
|
/** ฟังก์ชันเรียกข้อมูลรายการคำสั่ง*/
|
|
|
|
|
async function getListCommandDraf() {
|
|
|
|
|
showLoader();
|
|
|
|
|
await http
|
|
|
|
|
.get(
|
|
|
|
|
config.API.commandList +
|
|
|
|
|
`?page=${pagination.value.page}&pageSize=${pagination.value.rowsPerPage}&year=${commandYear.value}&keyword=${filter.value}&status=DRAFT&commandTypeId=${commandType.value}`
|
|
|
|
|
)
|
|
|
|
|
.then(async (res) => {
|
|
|
|
|
totalList.value = Math.ceil(
|
|
|
|
|
res.data.result.total / pagination.value.rowsPerPage
|
|
|
|
|
);
|
|
|
|
|
total.value = res.data.result.total;
|
|
|
|
|
rows.value = res.data.result.data;
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
messageError($q, err);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-09-24 11:19:41 +07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ฟังก์ชันสร้างคำสั่งใหม่
|
2024-10-08 10:35:55 +07:00
|
|
|
* @param isRedirect บันทึกและไปยังหน้าคำสั่ง เป็น true บันทึกและเลือกรายชื่อต่อ เป็น false
|
2024-09-24 11:19:41 +07:00
|
|
|
*/
|
2024-09-26 10:03:22 +07:00
|
|
|
function createCommand(isRedirect: boolean) {
|
2024-09-24 17:16:27 +07:00
|
|
|
dialogConfirm($q, async () => {
|
2024-10-07 11:45:27 +07:00
|
|
|
showLoader();
|
|
|
|
|
const data = await props?.persons?.map((e: any) => ({
|
2024-10-02 14:59:45 +07:00
|
|
|
refId: e.id,
|
|
|
|
|
prefix: e.prefix,
|
|
|
|
|
firstName: e.firstName,
|
|
|
|
|
lastName: e.lastName,
|
|
|
|
|
citizenId: e.citizenId,
|
2024-10-09 09:39:06 +07:00
|
|
|
profileId: e.profileId,
|
2024-10-02 14:59:45 +07:00
|
|
|
}));
|
2024-09-25 10:22:03 +07:00
|
|
|
const body = {
|
|
|
|
|
commandYear: commandYear.value,
|
|
|
|
|
commandNo: commandNo.value,
|
|
|
|
|
commandTypeId: commandType.value,
|
2024-10-18 16:48:27 +07:00
|
|
|
persons: !props.notPerson ? data : [],
|
2024-09-25 10:22:03 +07:00
|
|
|
};
|
2024-10-09 09:39:06 +07:00
|
|
|
|
2024-10-18 16:48:27 +07:00
|
|
|
console.log(body);
|
2024-09-25 10:22:03 +07:00
|
|
|
await http
|
2024-10-02 14:59:45 +07:00
|
|
|
.post(config.API.command + `/person`, body)
|
2024-09-25 10:22:03 +07:00
|
|
|
.then(async (res) => {
|
|
|
|
|
const id = await res.data.result;
|
2024-10-07 11:45:27 +07:00
|
|
|
modal.value = false;
|
2024-09-26 10:03:22 +07:00
|
|
|
if (isRedirect) {
|
|
|
|
|
router.push(`/command/edit/${id}`);
|
|
|
|
|
} else {
|
|
|
|
|
clearValue();
|
|
|
|
|
}
|
2024-09-25 10:22:03 +07:00
|
|
|
})
|
|
|
|
|
.catch((e) => {
|
|
|
|
|
messageError($q, e);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
|
|
|
|
});
|
2024-09-24 17:16:27 +07:00
|
|
|
});
|
2024-09-24 11:19:41 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ฟังก์ชันเพิ่มคนเข้าไปในคำสั่งที่เป็นแบบร่าง
|
2024-10-08 10:35:55 +07:00
|
|
|
* @param isRedirect บันทึกและไปยังหน้าคำสั่ง เป็น true บันทึกและเลือกรายชื่อต่อ เป็น false
|
2024-09-24 11:19:41 +07:00
|
|
|
*/
|
2024-09-26 10:03:22 +07:00
|
|
|
function addPersonalToCommand(isRedirect: boolean) {
|
2024-09-24 17:16:27 +07:00
|
|
|
dialogConfirm($q, async () => {
|
2024-10-02 14:59:45 +07:00
|
|
|
const data = props?.persons?.map((e: any) => ({
|
|
|
|
|
refId: e.id,
|
|
|
|
|
prefix: e.prefix,
|
|
|
|
|
firstName: e.firstName,
|
|
|
|
|
lastName: e.lastName,
|
|
|
|
|
citizenId: e.citizenId,
|
|
|
|
|
}));
|
2024-09-24 17:16:27 +07:00
|
|
|
const body = {
|
|
|
|
|
commandId: selected.value[0].id,
|
|
|
|
|
persons: data,
|
|
|
|
|
};
|
2024-10-02 14:59:45 +07:00
|
|
|
showLoader();
|
|
|
|
|
await http
|
|
|
|
|
.post(config.API.command + `/person`, body)
|
|
|
|
|
.then(async (res) => {
|
|
|
|
|
const id = await res.data.result;
|
|
|
|
|
modal.value = false;
|
|
|
|
|
if (isRedirect) {
|
|
|
|
|
router.push(`/command/edit/${id}`);
|
|
|
|
|
} else {
|
|
|
|
|
modal.value = false;
|
|
|
|
|
clearValue();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch((e) => {
|
|
|
|
|
messageError($q, e);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
|
|
|
|
});
|
2024-09-24 17:16:27 +07:00
|
|
|
});
|
2024-09-24 11:19:41 +07:00
|
|
|
}
|
|
|
|
|
|
2024-10-08 10:35:55 +07:00
|
|
|
/**
|
|
|
|
|
* ฟังก์ชันบันทึกข้อมูล
|
|
|
|
|
* @param isRedirect บันทึกและไปยังหน้าคำสั่ง เป็น true บันทึกและเลือกรายชื่อต่อ เป็น false
|
|
|
|
|
*/
|
2024-09-26 10:03:22 +07:00
|
|
|
function onSubmit(isRedirect: boolean) {
|
2024-09-24 17:16:27 +07:00
|
|
|
if (selectCreate.value === "NEW") {
|
2024-09-26 10:03:22 +07:00
|
|
|
createCommand(isRedirect);
|
2024-09-24 11:19:41 +07:00
|
|
|
} else {
|
2024-09-26 10:03:22 +07:00
|
|
|
addPersonalToCommand(isRedirect);
|
2024-09-24 17:16:27 +07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-08 10:35:55 +07:00
|
|
|
/** ฟังก์ชันปิด popup */
|
2024-09-24 11:19:41 +07:00
|
|
|
function closeModal() {
|
|
|
|
|
modal.value = false;
|
2024-09-24 17:16:27 +07:00
|
|
|
clearValue();
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-08 10:35:55 +07:00
|
|
|
/** ฟังก์ชันกำหน้ค่าเป็น Defult*/
|
2024-09-24 17:16:27 +07:00
|
|
|
function clearValue() {
|
|
|
|
|
commandNo.value = "";
|
|
|
|
|
commandYear.value = new Date().getFullYear();
|
|
|
|
|
selectCreate.value = "NEW";
|
2024-09-25 10:22:03 +07:00
|
|
|
selected.value = [];
|
|
|
|
|
filter.value = "";
|
2024-09-24 17:16:27 +07:00
|
|
|
}
|
|
|
|
|
|
2024-10-08 10:35:55 +07:00
|
|
|
/** ฟังก์ชันดึงข้อมูลคำสั่ง */
|
2024-09-24 17:16:27 +07:00
|
|
|
async function fetchCommandType() {
|
2024-09-25 10:22:03 +07:00
|
|
|
const data = await storeCommand.getCommandTypes(); // ยิงไป get ที่ store
|
|
|
|
|
// filter เฉพาะ code ของคำสั่งที่เลือก
|
|
|
|
|
commandOp.value = await data.filter(
|
2024-10-08 10:35:55 +07:00
|
|
|
(v: ListCommand) => v.code == props.commandTypeCode
|
2024-09-25 10:22:03 +07:00
|
|
|
);
|
|
|
|
|
commandType.value = commandOp.value[0].id;
|
2024-10-18 16:48:27 +07:00
|
|
|
console.log("🚀 ~ fetchCommandType ~ commandType.value:", commandType.value)
|
2024-09-24 11:19:41 +07:00
|
|
|
}
|
|
|
|
|
|
2024-10-08 10:35:55 +07:00
|
|
|
/**
|
|
|
|
|
* ฟังก์ชันอัปเดทจำนวนแถวต่อหน้า
|
|
|
|
|
* @param newPagination จำนวนแถวที่ต้องการ
|
|
|
|
|
*/
|
|
|
|
|
function updatePagination(newPagination: Pagination) {
|
2024-09-24 17:16:27 +07:00
|
|
|
pagination.value.page = 1;
|
|
|
|
|
pagination.value.rowsPerPage = newPagination.rowsPerPage;
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-08 10:35:55 +07:00
|
|
|
/** ดูการเปลี่ยนแปลงของจำนวนแถวต่อหน้า*/
|
2024-09-24 17:16:27 +07:00
|
|
|
watch(
|
|
|
|
|
() => pagination.value.rowsPerPage,
|
|
|
|
|
async () => {
|
|
|
|
|
await getListCommandDraf();
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2024-10-08 10:35:55 +07:00
|
|
|
/** ดูการเปลี่ยนแปลงของ modal*/
|
2024-09-24 17:16:27 +07:00
|
|
|
watch(modal, () => {
|
2024-10-02 14:59:45 +07:00
|
|
|
if (modal.value && props.persons?.length !== 0) {
|
2024-09-24 17:16:27 +07:00
|
|
|
fetchCommandType();
|
|
|
|
|
}
|
|
|
|
|
});
|
2024-09-27 15:59:13 +07:00
|
|
|
|
2024-10-08 10:35:55 +07:00
|
|
|
/** ดูการเปลี่ยนแปลงของประเภทการออกคำสั่ง*/
|
2024-09-27 15:59:13 +07:00
|
|
|
watch(
|
|
|
|
|
() => selectCreate.value,
|
|
|
|
|
async () => {
|
|
|
|
|
if (selectCreate.value == "DRAF") {
|
|
|
|
|
getListCommandDraf();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
2024-09-24 11:19:41 +07:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2024-09-25 10:22:03 +07:00
|
|
|
<q-dialog v-model="modal" persistent>
|
|
|
|
|
<q-card style="min-width: 50vw">
|
2024-09-24 11:19:41 +07:00
|
|
|
<DialogHeader :tittle="'สร้าง/เลือกคำสั่ง'" :close="closeModal" />
|
2024-09-25 10:22:03 +07:00
|
|
|
|
2024-09-24 11:19:41 +07:00
|
|
|
<q-separator />
|
2024-09-25 10:22:03 +07:00
|
|
|
<q-card-section style="max-height: 50vh" class="scroll">
|
2024-09-24 11:19:41 +07:00
|
|
|
<div class="row q-mb-md">
|
|
|
|
|
<div class="col-12 q-gutter-md">
|
2024-09-26 10:03:22 +07:00
|
|
|
<q-btn-toggle
|
|
|
|
|
v-model="selectCreate"
|
|
|
|
|
toggle-color="primary"
|
|
|
|
|
color="white"
|
|
|
|
|
text-color="black"
|
|
|
|
|
no-caps
|
|
|
|
|
:options="[
|
|
|
|
|
{ label: 'สร้างคำสั่งใหม่', value: 'NEW' },
|
|
|
|
|
{ label: 'เลือกคำสั่งที่เป็นแบบร่าง', value: 'DRAF' },
|
|
|
|
|
]"
|
2024-09-24 11:19:41 +07:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<q-separator />
|
2024-09-24 17:16:27 +07:00
|
|
|
<div v-if="selectCreate == 'NEW'" class="row q-mt-sm q-col-gutter-sm">
|
|
|
|
|
<div class="col-12">
|
|
|
|
|
<q-select
|
|
|
|
|
class="inputgreen"
|
|
|
|
|
v-model="commandType"
|
|
|
|
|
:label="`${'ประเภทคำสั่ง'}`"
|
|
|
|
|
option-label="name"
|
|
|
|
|
:options="commandOp"
|
|
|
|
|
option-value="id"
|
2024-09-25 10:22:03 +07:00
|
|
|
dense
|
|
|
|
|
emit-value
|
|
|
|
|
map-options
|
2024-09-24 17:16:27 +07:00
|
|
|
lazy-rules
|
|
|
|
|
use-input
|
|
|
|
|
hide-bottom-space
|
|
|
|
|
outlined
|
2024-09-25 10:22:03 +07:00
|
|
|
readonly
|
2024-09-24 17:16:27 +07:00
|
|
|
>
|
|
|
|
|
<template v-slot:no-option>
|
|
|
|
|
<q-item>
|
|
|
|
|
<q-item-section class="text-grey">
|
|
|
|
|
ไม่มีข้อมูล
|
|
|
|
|
</q-item-section>
|
|
|
|
|
</q-item>
|
|
|
|
|
</template>
|
|
|
|
|
</q-select>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-6">
|
|
|
|
|
<q-input
|
|
|
|
|
class="inputgreen"
|
|
|
|
|
outlined
|
|
|
|
|
dense
|
|
|
|
|
v-model="commandNo"
|
|
|
|
|
:label="`${'คำสั่งเลขที่'}`"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<label class="col-1 flex justify-center items-center text-bold"
|
|
|
|
|
>/</label
|
|
|
|
|
>
|
2024-09-24 11:19:41 +07:00
|
|
|
|
|
|
|
|
<div class="col-5">
|
2024-09-24 17:16:27 +07:00
|
|
|
<datepicker
|
|
|
|
|
menu-class-name="modalfix"
|
|
|
|
|
v-model="commandYear"
|
|
|
|
|
:locale="'th'"
|
|
|
|
|
autoApply
|
|
|
|
|
year-picker
|
|
|
|
|
:enableTimePicker="false"
|
|
|
|
|
class="inputgreen"
|
|
|
|
|
>
|
|
|
|
|
<template #year="{ year }">{{ year + 543 }}</template>
|
|
|
|
|
<template #year-overlay-value="{ value }">{{
|
|
|
|
|
parseInt(value + 543)
|
|
|
|
|
}}</template>
|
|
|
|
|
<template #trigger>
|
|
|
|
|
<q-input
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
|
|
|
|
hide-bottom-space
|
|
|
|
|
:model-value="commandYear == null ? null : commandYear + 543"
|
|
|
|
|
:label="`${'พ.ศ.'}`"
|
|
|
|
|
:rules="[(val:string) => !!val || `${'กรุณากรอก พ.ศ.'}`]"
|
|
|
|
|
>
|
|
|
|
|
<template v-slot:prepend>
|
|
|
|
|
<q-icon
|
|
|
|
|
name="event"
|
|
|
|
|
class="cursor-pointer"
|
|
|
|
|
style="color: var(--q-primary)"
|
|
|
|
|
>
|
|
|
|
|
</q-icon>
|
|
|
|
|
</template>
|
|
|
|
|
</q-input>
|
|
|
|
|
</template>
|
|
|
|
|
</datepicker>
|
2024-09-24 11:19:41 +07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2024-09-24 17:16:27 +07:00
|
|
|
<div v-else class="row q-mt-sm">
|
|
|
|
|
<q-toolbar style="padding: 0">
|
|
|
|
|
<datepicker
|
|
|
|
|
menu-class-name="modalfix"
|
|
|
|
|
v-model="commandYear"
|
|
|
|
|
:locale="'th'"
|
|
|
|
|
autoApply
|
|
|
|
|
year-picker
|
|
|
|
|
:enableTimePicker="false"
|
|
|
|
|
class="inputgreen"
|
|
|
|
|
@update:model-value="getListCommandDraf()"
|
|
|
|
|
>
|
|
|
|
|
<template #year="{ year }">{{ year + 543 }}</template>
|
|
|
|
|
<template #year-overlay-value="{ value }">{{
|
|
|
|
|
parseInt(value + 543)
|
|
|
|
|
}}</template>
|
|
|
|
|
<template #trigger>
|
|
|
|
|
<q-input
|
2024-09-24 11:19:41 +07:00
|
|
|
dense
|
2024-09-24 17:16:27 +07:00
|
|
|
outlined
|
|
|
|
|
hide-bottom-space
|
|
|
|
|
:model-value="commandYear == null ? null : commandYear + 543"
|
|
|
|
|
:label="`${'พ.ศ.'}`"
|
|
|
|
|
:rules="[(val:string) => !!val || `${'กรุณากรอก พ.ศ.'}`]"
|
2024-09-24 11:19:41 +07:00
|
|
|
>
|
2024-09-24 17:16:27 +07:00
|
|
|
<template v-slot:prepend>
|
|
|
|
|
<q-icon
|
|
|
|
|
name="event"
|
|
|
|
|
class="cursor-pointer"
|
|
|
|
|
style="color: var(--q-primary)"
|
|
|
|
|
>
|
|
|
|
|
</q-icon>
|
|
|
|
|
</template>
|
|
|
|
|
</q-input>
|
|
|
|
|
</template>
|
|
|
|
|
</datepicker>
|
|
|
|
|
<q-space />
|
|
|
|
|
<q-input
|
|
|
|
|
borderless
|
|
|
|
|
outlined
|
|
|
|
|
dense
|
|
|
|
|
debounce="300"
|
|
|
|
|
v-model="filter"
|
|
|
|
|
placeholder="ค้นหา"
|
|
|
|
|
style="width: 200px; max-width: auto"
|
|
|
|
|
@keydown.enter.prevent="getListCommandDraf()"
|
|
|
|
|
>
|
|
|
|
|
<template v-slot:append>
|
|
|
|
|
<q-icon v-if="filter == ''" name="search" />
|
|
|
|
|
<q-icon
|
|
|
|
|
v-if="filter !== ''"
|
|
|
|
|
name="clear"
|
|
|
|
|
class="cursor-pointer"
|
|
|
|
|
@click="filter = ''"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
</q-input>
|
|
|
|
|
<q-select
|
|
|
|
|
v-model="visibleColumns"
|
|
|
|
|
multiple
|
|
|
|
|
outlined
|
|
|
|
|
dense
|
|
|
|
|
options-dense
|
|
|
|
|
:display-value="$q.lang.table.columns"
|
|
|
|
|
emit-value
|
|
|
|
|
map-options
|
|
|
|
|
:options="columns"
|
|
|
|
|
option-value="name"
|
|
|
|
|
options-cover
|
|
|
|
|
style="min-width: 150px"
|
|
|
|
|
class="gt-xs q-ml-sm"
|
|
|
|
|
/>
|
|
|
|
|
</q-toolbar>
|
|
|
|
|
<div class="col-12">
|
|
|
|
|
<d-table
|
|
|
|
|
:columns="columns"
|
|
|
|
|
:rows="rows"
|
|
|
|
|
row-key="id"
|
|
|
|
|
:visible-columns="visibleColumns"
|
|
|
|
|
selection="single"
|
|
|
|
|
v-model:selected="selected"
|
|
|
|
|
:rows-per-page-options="[10, 25, 50, 100]"
|
|
|
|
|
@update:pagination="updatePagination"
|
|
|
|
|
>
|
|
|
|
|
<template v-slot:pagination="scope">
|
|
|
|
|
ทั้งหมด {{ total }} รายการ
|
|
|
|
|
<q-pagination
|
|
|
|
|
v-model="pagination.page"
|
|
|
|
|
active-color="primary"
|
|
|
|
|
color="dark"
|
|
|
|
|
:max="Number(totalList)"
|
|
|
|
|
size="sm"
|
|
|
|
|
boundary-links
|
|
|
|
|
direction-links
|
|
|
|
|
:max-pages="5"
|
|
|
|
|
@update:model-value="getListCommandDraf"
|
|
|
|
|
></q-pagination>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<template v-slot:body="props">
|
|
|
|
|
<q-tr :props="props" class="cursor-pointer">
|
|
|
|
|
<q-td>
|
|
|
|
|
<q-checkbox
|
|
|
|
|
keep-color
|
|
|
|
|
color="primary"
|
|
|
|
|
dense
|
|
|
|
|
v-model="props.selected"
|
|
|
|
|
/>
|
|
|
|
|
</q-td>
|
|
|
|
|
<q-td
|
|
|
|
|
v-for="col in props.cols"
|
|
|
|
|
:key="col.name"
|
|
|
|
|
:props="props"
|
|
|
|
|
>
|
|
|
|
|
<div>
|
|
|
|
|
{{ col.value ?? "-" }}
|
|
|
|
|
</div>
|
|
|
|
|
</q-td>
|
|
|
|
|
</q-tr>
|
|
|
|
|
</template>
|
|
|
|
|
</d-table>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-09-24 11:19:41 +07:00
|
|
|
</q-card-section>
|
2024-09-25 10:22:03 +07:00
|
|
|
|
2024-09-24 11:19:41 +07:00
|
|
|
<q-separator />
|
2024-09-25 10:22:03 +07:00
|
|
|
|
2024-09-24 11:19:41 +07:00
|
|
|
<q-card-actions align="right">
|
|
|
|
|
<q-btn
|
2024-09-26 10:03:22 +07:00
|
|
|
label="บันทึกและเลือกรายชื่อต่อ"
|
|
|
|
|
@click="() => onSubmit(false)"
|
2024-09-30 13:30:45 +07:00
|
|
|
:disable="
|
|
|
|
|
selectCreate == 'NEW' ? commandType == '' : selected.length == 0
|
|
|
|
|
"
|
2024-09-26 10:03:22 +07:00
|
|
|
color="blue"
|
|
|
|
|
>
|
|
|
|
|
<q-tooltip>บันทึกและเลือกรายชื่อต่อ</q-tooltip>
|
|
|
|
|
</q-btn>
|
|
|
|
|
<q-btn
|
|
|
|
|
label="บันทึกและไปยังหน้าคำสั่ง"
|
|
|
|
|
@click="() => onSubmit(true)"
|
2024-09-30 13:30:45 +07:00
|
|
|
:disable="
|
|
|
|
|
selectCreate == 'NEW' ? commandType == '' : selected.length == 0
|
|
|
|
|
"
|
2024-09-24 11:19:41 +07:00
|
|
|
color="public"
|
|
|
|
|
>
|
2024-09-26 10:03:22 +07:00
|
|
|
<q-tooltip>บันทึกและไปยังหน้าคำสั่ง</q-tooltip>
|
|
|
|
|
</q-btn>
|
2024-09-24 11:19:41 +07:00
|
|
|
</q-card-actions>
|
|
|
|
|
</q-card>
|
|
|
|
|
</q-dialog>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped></style>
|