This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-10-25 11:17:13 +07:00
parent 75b0e08d2c
commit 44c5f56ab0
5 changed files with 3 additions and 685 deletions

View file

@ -1,284 +0,0 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { useRouter } from "vue-router";
import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import { checkPermission } from "@/utils/permissions";
/** Use */
const $q = useQuasar();
const router = useRouter();
const mixin = useCounterMixin();
const { showLoader, hideLoader, messageError, date2Thai, findOrgName } = mixin;
/** คอลัมน์ */
const rows = ref<any[]>([]);
const pagination = ref({
sortBy: "createdAt",
descending: true,
page: 1,
rowsPerPage: 10,
});
const columns = ref<QTableProps["columns"]>([
{
name: "no",
align: "left",
label: "ลำดับ",
sortable: false,
field: "no",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "fullname",
align: "left",
label: "ชื่อ-นามสกุล",
sortable: true,
field: "fullname",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format(val, row) {
return `${row.prefix ?? ""}${row.firstName} ${row.lastName}`;
},
},
{
name: "position",
align: "left",
label: "ตำแหน่งในสายงาน",
sortable: true,
field: "position",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "positionType",
align: "left",
label: "ประเภทตำแหน่ง",
sortable: true,
field: "positionType",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format(val, row) {
let name = "";
if (row.posTypeName && row.posLevelName) {
name = `${row.posTypeName} (${row.posLevelName})`;
} else if (row.posTypeName) {
name = `${row.posTypeName}`;
} else if (row.posLevelName) {
name = `(${row.posLevelName})`;
} else name = "-";
return name;
},
},
{
name: "org",
align: "left",
label: "สังกัด",
sortable: true,
field: "org",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format(val, row) {
return findOrgName(row);
},
},
{
name: "createdAt",
align: "left",
label: "วันที่ดำเนินการ",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (val) => date2Thai(val),
},
]);
/** คอลัมน์ที่แสดง */
const visibleColumns = ref<string[]>([
"no",
"fullname",
"positionType",
"position",
"positionLevel",
"positionExecutive",
"org",
"createdAt",
]);
/**เรียกข้อมูลจาก APi */
async function fectListDecased() {
showLoader();
await http
.get(config.API.listDeceased())
.then((res) => {
const data = res.data.result;
rows.value = data;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
//
const filterKeyword = ref<string>("");
const filterRef = ref<any>(null);
function resetFilter() {
filterKeyword.value = "";
filterRef.value.focus();
}
/** Setting Pagination */
function nextPage(id: string) {
router.push("/retirement/deceased/" + id);
}
/**Hook */
onMounted(() => {
fectListDecased();
});
</script>
<template>
<div class="toptitle text-dark col-12 row items-center">
รายการบนทกเวยนแจงการถงแกกรรม
</div>
<q-card flat bordered class="col-12 q-mt-sm">
<q-separator />
<div class="col-12 row q-pa-md">
<div class="row col-12">
<div class="row col-12 q-col-gutter-sm">
<q-space />
<q-input
class="col-xs-12 col-sm-3 col-md-2"
standout
dense
v-model="filterKeyword"
ref="filterRef"
outlined
debounce="300"
placeholder="ค้นหา"
>
<template v-slot:append>
<q-icon v-if="filterKeyword == ''" name="search" />
<q-icon
v-if="filterKeyword !== ''"
name="clear"
class="cursor-pointer"
@click="resetFilter"
/>
</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="col-xs-12 col-sm-3 col-md-2"
/>
</div>
<div class="col-12 q-pt-sm">
<d-table
ref="table"
:columns="columns"
:rows="rows"
:filter="filterKeyword"
row-key="fullname"
flat
bordered
:paging="true"
dense
class="custom-header-table"
:visible-columns="visibleColumns"
v-model:pagination="pagination"
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th auto-width></q-th>
<q-th v-for="col in props.cols" :key="col.name" :props="props">
<span class="text-weight-medium">{{ col.label }}</span>
</q-th>
</q-tr>
</template>
<template v-slot:body="props">
<q-tr :props="props">
<q-td auto-width>
<q-btn
v-if="checkPermission($route)?.attrIsGet"
flat
dense
round
color="info"
icon="mdi-eye"
@click.stop.prevent="nextPage(props.row.id)"
>
<q-tooltip>รายละเอยด</q-tooltip>
</q-btn>
</q-td>
<q-td v-for="col in props.cols" :key="col.id">
<div v-if="col.name === 'no'">
{{ props.rowIndex + 1 }}
</div>
<div
v-else
:class="col.name === 'org' ? 'table_ellipsis' : ''"
>
{{ col.value ? col.value : "-" }}
</div>
</q-td>
</q-tr>
</template>
</d-table>
</div>
</div>
</div>
</q-card>
</template>
<style scoped lang="scss">
.custom-header-table {
max-height: 64vh;
.q-table tr:nth-child(odd) td {
background: white;
}
.q-table tr:nth-child(even) td {
background: #f8f8f8;
}
.q-table thead tr {
background: #ecebeb;
}
.q-table thead tr th {
position: sticky;
z-index: 1;
}
/* this will be the loading indicator */
.q-table thead tr:last-child th {
/* height of all previous header rows */
top: 48px;
}
.q-table thead tr:first-child th {
top: 0;
}
}
</style>

View file

@ -1,456 +0,0 @@
<script setup lang="ts">
import { ref, onMounted, reactive } from "vue";
import { useQuasar } from "quasar";
import { useRouter, useRoute } from "vue-router";
import type { QInput, QForm } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import type { QTableProps } from "quasar";
import type {
requestSendNoti,
DataCopyOrder,
} from "@/modules/06_retirement/interface/response/Deceased";
import DialogOrgSelectOneStep from "@/components/Dialogs/DialogOrgSelectOneStep.vue";
/** Use */
const router = useRouter();
const route = useRoute();
const $q = useQuasar();
const mixin = useCounterMixin(); //
const {
dialogRemove,
messageError,
showLoader,
hideLoader,
success,
dialogConfirm,
} = mixin;
/** props*/
const props = defineProps({
next: {
type: Function,
default: () => console.log("not function"),
},
previous: {
type: Function,
default: () => console.log("not function"),
},
});
const profileId = ref<string>(route.params.id.toString());
const next = () => props.next();
/**ตัวแปร */
const myForm = ref<QForm | null>(null);
const filterRef = ref<QInput>();
const filter = ref<string>("");
const modalSelectOrg = ref<boolean>(false);
const selectedModal = ref<any[]>([]);
const rows = ref<DataCopyOrder[]>([]);
const editRows = ref<DataCopyOrder[]>([]);
/** selcet OPtion */
const optionSelect = ref<any>([
{ id: 1, name: "อีเมล" },
{ id: 2, name: "กล่องข้อความ" },
]);
/** คอลัมน์ที่แสดง */
const visibleColumns = ref<String[]>([
"no",
"idCard",
"name",
"position",
"unit",
"send",
]);
/** คอลัมน์ */
const columns = ref<QTableProps["columns"]>([
{ name: "no", align: "left", label: "ลำดับ", field: "no", sortable: true },
{
name: "idCard",
align: "left",
label: "เลขประจำตัวประชาชน",
field: "idCard",
sortable: true,
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "name",
align: "left",
label: "ชื่อ-นามสกุล",
field: "name",
sortable: true,
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "position",
align: "left",
label: "ตำแหน่ง",
field: "position",
sortable: true,
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "unit",
align: "left",
label: "หน่วยงาน",
field: "unit",
sortable: true,
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "send",
align: "left",
label: "ช่องทางการส่งสำเนา",
field: "send",
sortable: true,
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
/** เรียกข้อมูลจาก api */
async function getData() {
showLoader();
await http
.get(config.API.detailByidDeceased(profileId.value))
.then((res) => {
const data = res.data.result;
let list: DataCopyOrder[] = [];
data.map((r: any) => {
let selectCopyOrder = [];
if (r.isSendMail) {
selectCopyOrder.push(1);
}
if (r.isSendInbox) {
selectCopyOrder.push(2);
}
list.push({
id: r.id,
personalId: r.profileId ?? "",
name: `${r.prefix}${r.firstName} ${r.lastName}`,
idCard: r.citizenId ?? "",
position: r.positionName ?? "",
unit: r.organizationName ?? "-",
send: "",
mutiselect: selectCopyOrder,
});
});
if (editRows.value.length > 0) {
list.map((r: DataCopyOrder) => {
editRows.value.map((e: DataCopyOrder) => {
if (r.personalId == e.personalId) {
r.mutiselect = e.mutiselect;
}
});
});
}
rows.value = list;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
}
/**
*งก Save
*/
async function saveData() {
showLoader();
const persons = selectedModal.value.map((item) => ({
profileId: item.profileId,
}));
const dataToSend = { Persons: persons };
await http
.put(config.API.detailByidDeceased(profileId.value), dataToSend)
.then((res) => {
getData();
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
}
function resetFilter() {
// reset X
filter.value = "";
filterRef.value!.focus();
}
/**
* class ดรปแบบแสดงระหวางขอมลทแกไขหรอแสดงเฉยๆ
* @param val อม input สำหรบแกไขหรอไม
*/
function getClass(val: boolean) {
return {
"full-width inputgreen cursor-pointer": val,
"full-width cursor-pointer": !val,
};
}
/**
* กดปมเพมดานบน table
*/
function clickAdd() {
modalSelectOrg.value = true;
if (myForm.value !== null) {
myForm.value.reset();
}
}
/**
* ลบขอม
*/
function clickDelete(id: string) {
dialogRemove($q, () => deleteData(id));
}
/**ลบข้อมูล */
async function deleteData(id: string) {
await http
.delete(config.API.detailByidDeceased(id))
.then((res) => {
success($q, "ลบข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await getData();
});
}
/**
* Save อม
*/
async function saveDataCopyOrder() {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
dialogConfirm(
$q,
() => fetchSaveCopyOrder(),
"ยืนยันการส่งหนังสือเวียน",
"ต้องการยืนยันการส่งหนังสือเวียนหรือไม่"
);
}
});
}
}
// Save
async function fetchSaveCopyOrder() {
let list: requestSendNoti[] = [];
rows.value.map((r: DataCopyOrder) => {
list.push({
profileId: r.personalId,
isSendMail: r.mutiselect.includes(1),
isSendInbox: r.mutiselect.includes(2),
isSendNotification: true,
});
});
showLoader();
await http
.put(config.API.notiDeceased(profileId.value), { Persons: list })
.then((res: any) => {
success($q, "บันทึกข้อมูลสำเร็จ");
next();
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
getData();
});
}
function updateData(row: DataCopyOrder) {
editRows.value.push(row);
}
/** Hook */
onMounted(async () => {
await getData();
});
</script>
<template>
<div class="toptitle text-dark col-12 row items-center">
<q-btn
icon="mdi-arrow-left"
unelevated
round
dense
flat
color="primary"
class="q-mr-sm"
@click="router.push(`/retirement/deceased/${profileId}`)"
/>
งหนงสอเวยน
</div>
<div class="bg-white">
<div class="q-py-md q-pl-md" style="height: 68vh; overflow-y: scroll">
<div class="col-12 row q-py-sm items-center">
<q-btn flat round color="primary" @click="clickAdd" icon="mdi-plus">
<q-tooltip>เพมขอม</q-tooltip>
</q-btn>
<q-space />
<div class="items-center" style="display: flex">
<!-- นหาขอความใน table -->
<q-input
standout
dense
v-model="filter"
ref="filterRef"
outlined
debounce="300"
placeholder="ค้นหา"
style="max-width: 200px"
class="q-ml-sm"
>
<template v-slot:append>
<q-icon v-if="filter == ''" name="search" />
<q-icon
v-if="filter !== ''"
name="clear"
class="cursor-pointer"
@click="resetFilter"
/>
</template>
</q-input>
<!-- แสดงคอลมนใน table -->
<q-select
v-model="visibleColumns"
:display-value="$q.lang.table.columns"
multiple
outlined
dense
:options="columns"
options-dense
option-value="name"
map-options
emit-value
style="min-width: 150px"
class="gt-xs q-ml-sm"
/>
</div>
</div>
<q-form ref="myForm">
<d-table
:rows="rows"
:columns="columns"
:visible-columns="visibleColumns"
:filter="filter"
row-key="idCard"
>
<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-tr>
</template>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td key="no" :props="props">
{{ props.rowIndex + 1 }}
</q-td>
<q-td key="idCard" :props="props">
{{ props.row.idCard }}
</q-td>
<q-td key="name" :props="props">
{{ props.row.name }}
</q-td>
<q-td key="position" :props="props">
{{ props.row.position }}
</q-td>
<q-td key="unit" :props="props">
{{ props.row.unit }}
</q-td>
<q-td key="send" :props="props">
<q-select
:class="getClass(true)"
hide-bottom-space
multiple
:outlined="true"
dense
lazy-rules
v-model="props.row.mutiselect"
:rules="[(val:any) => !!val || `${'กรุณาเลือกช่องทางการส่งสำเนา'}`,(val:any) => val.length > 0 || `${'กรุณาเลือกช่องทางการส่งสำเนา'}`]"
:label="`${'เลือกช่องทางการส่งสำเนา'}`"
emit-value
map-options
option-label="name"
:options="optionSelect"
option-value="id"
input-debounce="0"
color="primary"
@update:model-value="() => updateData(props.row)"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-black">
ไมพบขอมลทนหา
</q-item-section>
</q-item>
</template>
</q-select>
</q-td>
<q-td auto-width>
<q-btn
dense
size="12px"
flat
round
color="red"
@click="clickDelete(props.row.id)"
icon="mdi-delete"
>
<q-tooltip>ลบขอม</q-tooltip>
</q-btn>
</q-td>
</q-tr>
</template>
</d-table>
</q-form>
</div>
<q-separator />
<div class="flex justify-end q-pa-sm q-gutter-sm">
<q-btn
dense
unelevated
label="ส่งหนังสือเวียน"
color="public"
@click="saveDataCopyOrder"
class="q-px-md"
>
</q-btn>
</div>
</div>
<DialogOrgSelectOneStep
v-model:modal="modalSelectOrg"
:title="'เลือกรายชื่อตามหน่วยงาน'"
v-model:selectedModal="selectedModal"
:saveData="saveData"
/>
</template>

View file

@ -1,235 +0,0 @@
<script setup lang="ts">
import { useRouter, useRoute } from "vue-router";
import { useQuasar } from "quasar";
import { ref, onMounted } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import genReport from "@/plugins/genreport";
import { useCounterMixin } from "@/stores/mixin";
import { checkPermission } from "@/utils/permissions";
import type { DataProfile } from "@/modules/05_placement/interface/index/Main";
import type { ResDetailDeceased } from "@/modules/06_retirement/interface/response/Deceased";
import CardProfile from "@/components/CardProfile.vue";
/**use*/
const $q = useQuasar();
const router = useRouter();
const route = useRoute();
const mixin = useCounterMixin();
const { showLoader, hideLoader, messageError, date2Thai } = mixin;
const fullName = ref<string>("");
const profileId = ref<string>(route.params.id.toString());
const detail = ref<ResDetailDeceased>();
const dataProfile = ref<DataProfile>();
/** นำข้อมูลจาก API มาแสดง */
async function fetchData() {
showLoader();
await http
.get(config.API.detailDeceased(profileId.value))
.then((res) => {
const data = res.data.result;
dataProfile.value = data as DataProfile;
detail.value = data;
fullName.value = `${data.prefix}${data.firstName} ${data.lastName}`;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
/** เปิดdetail ของ deceased */
function openDeceased(id: string) {
router.push(`/retirement/deceased/detail/${id}`);
}
/** ไปหน้าถัดไป */
function nextPage(page: string) {
window.open(page, "_blank");
}
/**
* งก ดาวโหลด
* @param type typeของรายละเอยด
*/
async function fileDownload(type: string) {
showLoader();
await http
.get(config.API.DeceasedReport(type, profileId.value))
.then(async (res) => {
const data = res.data.result;
await genReport(
data,
`รายละเอียดบันทึกเวียนแจ้งการถึงแก่กรรม-${fullName.value}`,
type
);
hideLoader();
})
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
hideLoader();
})
.finally(() => {});
}
/** Hook */
onMounted(() => {
fetchData();
});
</script>
<template>
<div class="toptitle text-dark col-12 row items-center">
<q-btn
icon="mdi-arrow-left"
unelevated
round
dense
flat
color="primary"
class="q-mr-sm"
@click="router.push(`/retirement/deceased`)"
/>
รายละเอยดบนทกเวยนแจงการถงแกกรรม{{ fullName }}
</div>
<CardProfile :data="dataProfile as DataProfile" />
<q-card bordered class="q-mt-sm">
<div class="bg-grey-1 q-pa-sm col-12 row items-center">
<div class="q-pl-sm text-weight-bold text-dark">อมลการถงแกกรรม</div>
<q-space />
<div class="q-gutter-x-sm">
<q-btn
flat
outline
color="red"
dense
icon-right="mdi-file-pdf"
class="q-px-sm"
@click="fileDownload('pdf')"
/>
<q-btn
flat
outline
color="blue"
dense
icon-right="mdi-file-word"
class="q-px-sm"
@click="fileDownload('docx')"
/>
</div>
</div>
<div class="col-12"><q-separator /></div>
<q-card-section>
<div class="col-12 row q-col-gutter-md">
<div class="col-xs-6 col-sm-3 row items-center">
<div class="col-12">
<div class="col-12 text-top">เลขทใบมรณบตร</div>
<div class="col-12 text-detail">
{{ detail?.number }}
</div>
</div>
</div>
<div class="col-xs-6 col-sm-3 row items-center">
<div class="col-12">
<div class="col-12 text-top">สถานทออกใบมรณบตร</div>
<div class="col-12 text-detail">{{ detail?.location }}</div>
</div>
</div>
<div class="col-xs-6 col-sm-3 row items-center">
<div class="col-12">
<div class="col-12 text-top">เหตผลการเสยช</div>
<div class="col-12 text-detail">{{ detail?.reason }}</div>
</div>
</div>
<div class="col-xs-6 col-sm-3 row items-center">
<div class="col-12">
<div class="col-12 text-top">นทเสยช</div>
<div class="col-12 text-detail">
{{ detail?.date ? date2Thai(detail?.date) : "-" }}
</div>
</div>
</div>
<div class="col-xs-6 col-sm-3 row items-center">
<div class="col-12">
<div class="col-12 text-top">ใบมรณบตร</div>
<div class="col-12 text-detail">
<q-btn
flat
round
color="red"
icon="mdi-file-pdf"
@click="detail?.pathName ? nextPage(detail?.pathName) : null"
>
<q-tooltip>ใบมรณบตร</q-tooltip></q-btn
>
</div>
</div>
</div>
</div>
</q-card-section>
<q-separator />
<q-card-actions align="right">
<q-btn
v-if="checkPermission($route)?.attrIsUpdate"
color="public"
label="ส่งหนังสือเวียน"
@click="openDeceased(profileId)"
/>
</q-card-actions>
</q-card>
</template>
<style lang="scss" scope>
.q-img {
border-radius: 5px;
height: 70px;
}
.text-top {
color: gray;
font-weight: 400;
padding-bottom: 3px;
}
.text-detail {
font-weight: 500;
}
.custom-header-table {
max-height: 64vh;
.q-table tr:nth-child(odd) td {
background: white;
}
.q-table tr:nth-child(even) td {
background: #f8f8f8;
}
.q-table thead tr {
background: #ecebeb;
}
.q-table thead tr th {
position: sticky;
z-index: 1;
}
/* this will be the loading indicator */
.q-table thead tr:last-child th {
/* height of all previous header rows */
top: 48px;
}
.q-table thead tr:first-child th {
top: 0;
}
}
</style>

View file

@ -1,682 +0,0 @@
<script setup lang="ts">
import { onMounted, reactive, ref, useAttrs, computed } from "vue";
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import router from "@/router";
import { useCounterMixin } from "@/stores/mixin";
import type { FormOrderPlacementMainData } from "@/modules/05_placement/interface/request/Main";
import type { DataOption } from "@/modules/05_placement/interface/index/Main";
import { useOrderPlacementDataStore } from "@/modules/05_placement/store";
/** Use */
const $q = useQuasar(); // noti quasar
const DataStore = useOrderPlacementDataStore();
const pagination = ref({
sortBy: "desc",
descending: false,
page: 1,
rowsPerPage: 10,
});
const mixin = useCounterMixin();
const { dateText } = mixin;
// . .
const textDate = (value: Date) => {
return dateText(value);
};
/** คอลัมน์ที่แสดง */
const visibleColumns = ref<string[]>([
"Order",
"OrderType",
"OrderNum",
"OrderDate",
"OrderBy",
"Signer",
"OrderStatus",
]); //
//
const columns = ref<QTableProps["columns"]>([
{
name: "Order",
align: "left",
label: "คำสั่ง",
sortable: true,
field: "Order",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "OrderNum",
align: "left",
label: "เลขที่คำสั่ง",
sortable: true,
field: "OrderNum",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "OrderType",
align: "left",
label: "ประเภท",
sortable: false,
field: "OrderType",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "OrderDate",
align: "left",
label: "สั่ง ณ วันที่/วันที่คำสั่งมีผล",
sortable: true,
field: "OrderDate",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "OrderBy",
align: "left",
label: "คำสั่งโดย",
sortable: true,
field: "OrderBy",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "Signer",
align: "left",
label: "ผู้ลงนาม",
sortable: false,
field: "Signer",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "OrderStatus",
align: "center",
label: "สถานะคำสั่ง",
sortable: false,
field: "OrderStatus",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "fiscalYear",
align: "left",
label: "ปีงบประมาณ",
sortable: true,
field: "fiscalYear",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
]);
// ()
const rows = ref<FormOrderPlacementMainData[]>([
{
Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้",
OrderNum: "1/2565",
fiscalYear: 2565,
OrderDate: "30 พ.ค. 2565",
OrderBy: "สำนักงาน กทม.",
Signer: "นาม สมคิด ยอดใจ ",
OrderStatus: "จัดทำร่างคำสั่ง",
OrderType: "คำสั่งย้าย",
},
{
Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้",
OrderNum: "1/2565",
fiscalYear: 2565,
OrderDate: "30 พ.ค. 2565",
OrderBy: "สำนักงาน กทม.",
Signer: "นาม สมคิด ยอดใจ ",
OrderStatus: "จัดทำร่างคำสั่ง",
OrderType: "คำสั่งบรรจุและแต่งตั้ง",
},
{
Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้",
OrderNum: "1/2564",
fiscalYear: 2564,
OrderDate: "30 พ.ค. 2564",
OrderBy: "สำนักงาน กทม.",
Signer: "นาม สมคิด ยอดใจ ",
OrderStatus: "บัญชีแนบท้าย",
OrderType: "คำสั่งบรรจุและแต่งตั้ง",
},
{
Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้",
OrderNum: "1/2564",
fiscalYear: 2564,
OrderDate: "30 พ.ค. 2564",
OrderBy: "สำนักงาน กทม.",
Signer: "นาม สมคิด ยอดใจ ",
OrderStatus: "บัญชีแนบท้าย",
OrderType: "คำสั่งย้าย",
},
{
Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้",
OrderNum: "1/2564",
fiscalYear: 2564,
OrderDate: "30 พ.ค. 2564",
OrderBy: "สำนักงาน กทม.",
Signer: "นาม สมคิด ยอดใจ ",
OrderStatus: "ส่งสำเนาคำสั่ง",
OrderType: "คำสั่งย้าย",
},
{
Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้",
OrderNum: "1/2564",
fiscalYear: 2564,
OrderDate: "30 พ.ค. 2564",
OrderBy: "สำนักงาน กทม.",
Signer: "นาม สมคิด ยอดใจ ",
OrderStatus: "ส่งสำเนาคำสั่ง",
OrderType: "คำสั่งบรรจุและแต่งตั้ง",
},
{
Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้",
OrderNum: "1/2566",
fiscalYear: 2566,
OrderDate: "30 พ.ค. 2566",
OrderBy: "สำนักงาน กทม.",
Signer: "นาม สมคิด ยอดใจ ",
OrderStatus: "รอลงนาม",
OrderType: "คำสั่งบรรจุและแต่งตั้ง",
},
{
Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้",
OrderNum: "1/2566",
fiscalYear: 2566,
OrderDate: "30 พ.ค. 2566",
OrderBy: "สำนักงาน กทม.",
Signer: "นาม สมคิด ยอดใจ ",
OrderStatus: "ออกคำสั่งแล้ว",
OrderType: "คำสั่งแต่งตั้ง",
},
{
Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้",
OrderNum: "1/2565",
fiscalYear: 2565,
OrderDate: "30 พ.ค. 2565",
OrderBy: "สำนักงาน กทม.",
Signer: "นาม สมคิด ยอดใจ ",
OrderStatus: "ออกคำสั่งแล้ว",
OrderType: "คำสั่งบรรจุและแต่งตั้ง",
},
{
Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้",
OrderNum: "1/2566",
fiscalYear: 2566,
OrderDate: "30 พ.ค. 2566",
OrderBy: "สำนักงาน กทม.",
Signer: "นาม สมคิด ยอดใจ ",
OrderStatus: "ออกคำสั่งแล้ว",
OrderType: "คำสั่งแต่งตั้ง",
},
{
Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้",
OrderNum: "1/2566",
fiscalYear: 2566,
OrderDate: "30 พ.ค. 2566",
OrderBy: "สำนักงาน กทม.",
Signer: "นาม สมคิด ยอดใจ ",
OrderStatus: "ออกคำสั่งแล้ว",
OrderType: "คำสั่งย้าย",
},
{
Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้",
OrderNum: "1/2564",
fiscalYear: 2564,
OrderDate: "30 พ.ค. 2564",
OrderBy: "สำนักงาน กทม.",
Signer: "นาม สมคิด ยอดใจ ",
OrderStatus: "ออกคำสั่งแล้ว",
OrderType: "คำสั่งแต่งตั้ง",
},
{
Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้",
OrderNum: "1/2566",
fiscalYear: 2566,
OrderDate: "30 พ.ค. 2566",
OrderBy: "สำนักงาน กทม.",
Signer: "นาม สมคิด ยอดใจ ",
OrderStatus: "ออกคำสั่งแล้ว",
OrderType: "คำสั่งแต่งตั้ง",
},
]);
let OriginalData = ref<FormOrderPlacementMainData[]>([]);
let UpdataData = ref<FormOrderPlacementMainData[]>([]);
/**
* งคาขอมลจาก store
*/
async function OriginalDataFetch() {
await DataStore.DataMainOrder(rows.value);
OriginalData.value = await DataStore.DataMainOrigOrder;
UpdataData.value = OriginalData.value;
}
//
function redirectToPage(id?: number) {
router.push(`/placement/order/detail`);
}
/**
* function delete
* @param id id delete
*/
function clickDelete(id: string) {
$q.dialog({
title: "ยืนยันการลบข้อมูล",
message: "ต้องการลบข้อมูลนี้ใช่หรือไม่?",
cancel: {
flat: true,
color: "negative",
},
persistent: true,
})
.onOk(async () => {})
.onCancel(() => {})
.onDismiss(() => {});
}
//route OrderplacementDetail
function clickAdd() {
router.push({ name: "OrderplacementDetail" });
}
//
const fiscalyear = ref<number | null>(0);
const fiscalyearOP = reactive<DataOption[]>([{ id: 0, name: "ทั้งหมด" }]);
const addedfiscalYearValues: number[] = [];
async function fiscalYearFilter() {
for (let data of OriginalData.value) {
const year = data.fiscalYear;
if (fiscalyear.value === null || year > fiscalyear.value) {
fiscalyear.value = year;
}
if (!addedfiscalYearValues.includes(year)) {
fiscalyearOP.push({ id: year, name: year.toString() });
addedfiscalYearValues.push(year);
}
}
}
/**
* เลอกประเภทคำส
*/
const OrderType = ref<string>("");
const OrderTypeOption = reactive<DataOption[]>([{ id: 0, name: "ทั้งหมด" }]);
const addedOrderTypeValues: string[] = [];
async function OrderTypeFilter() {
for (let data of OriginalData.value) {
const OrderTypeValue = data.OrderType;
if (!addedOrderTypeValues.includes(OrderTypeValue)) {
OrderTypeOption.push({
id: OrderTypeOption.length,
name: OrderTypeValue,
});
addedOrderTypeValues.push(OrderTypeValue);
}
}
}
/**
* เลอกStatus คำส
*/
const OrderStatus = ref<string>("");
const OrderStatusOption = reactive<DataOption[]>([{ id: 1, name: "ทั้งหมด" }]);
const addedOrderStatusValues: string[] = [];
async function OrderStatusFilter() {
for (let data of OriginalData.value) {
const OrderStatusValue = data.OrderStatus;
if (
OrderStatusValue === null ||
parseInt(OrderStatusValue) > parseInt(OrderStatusValue)
) {
OrderStatus.value = OrderStatusValue;
}
if (!addedOrderStatusValues.includes(OrderStatusValue)) {
OrderStatusOption.push({
id: OrderStatusOption.length,
name: OrderStatusValue,
});
addedOrderStatusValues.push(OrderStatusValue);
}
}
}
//
const filterKeyword = ref<string>("");
const filterRef = ref<any>(null);
/** ล้างค่าในฟิลเตอร์ */
function resetFilter() {
filterKeyword.value = "";
filterRef.value.focus();
}
const attrs = ref<any>(useAttrs());
async function searchFilterTable() {
await DataStore.DataUpdateOrder(
OrderType.value,
OrderStatus.value,
fiscalyear.value
);
UpdataData.value = DataStore.DataMainUpdateOrder;
}
/**Setting pagination */
const paging = ref<boolean>(true);
function paginationLabel(start: string, end: string, total: string) {
if (paging.value == true) return " " + start + "-" + end + " ใน " + total;
else return start + "-" + end + " ใน " + total;
}
/**Hook */
onMounted(async () => {
await OriginalDataFetch();
fiscalYearFilter();
searchFilterTable();
OrderStatusFilter();
OrderTypeFilter();
});
</script>
<template>
<div class="toptitle text-dark col-12 row items-center">คำสงลาออก</div>
<div>
<q-card flat bordered class="col-12 q-mt-sm q-pa-md">
<div class="row q-col-gutter-sm">
<div class="row col-12 q-col-gutter-sm">
<q-select
class="col-xs-12 col-sm-3 col-md-2"
v-model="fiscalyear"
label="ปีงบประมาณ"
dense
emit-value
map-options
:options="fiscalyearOP"
option-value="id"
option-label="name"
lazy-rules
hide-bottom-space
:readonly="false"
:borderless="false"
:outlined="true"
:hide-dropdown-icon="false"
@update:model-value="searchFilterTable"
/>
<div>
<q-btn
size="12px"
flat
round
color="add"
icon="mdi-plus"
@click="clickAdd"
>
<q-tooltip>เพมขอม</q-tooltip>
</q-btn>
</div>
<q-space />
<q-input
class="col-xs-12 col-sm-3 col-md-2"
standout
dense
v-model="filterKeyword"
ref="filterRef"
outlined
debounce="300"
placeholder="ค้นหา"
>
<template v-slot:append>
<q-icon v-if="filterKeyword == ''" name="search" />
<q-icon
v-if="filterKeyword !== ''"
name="clear"
class="cursor-pointer"
@click="resetFilter"
/>
</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="col-xs-12 col-sm-3 col-md-2"
/>
</div>
<div class="col-12">
<q-card bordered class="col-12 filter-card q-pa-sm">
<div class="row col-12 q-col-gutter-sm">
<q-select
class="col-xs-12 col-sm-3 col-md-2"
v-model="OrderType"
label="ประเภท"
dense
emit-value
map-options
option-label="name"
:options="OrderTypeOption"
option-value="id"
lazy-rules
hide-bottom-space
:readonly="false"
:borderless="false"
:outlined="true"
:hide-dropdown-icon="false"
@update:model-value="searchFilterTable"
/>
<q-select
class="col-xs-12 col-sm-3 col-md-2"
v-model="OrderStatus"
label="สถานะ"
dense
emit-value
map-options
option-label="name"
:options="OrderStatusOption"
option-value="id"
lazy-rules
hide-bottom-space
:readonly="false"
:borderless="false"
:outlined="true"
:hide-dropdown-icon="false"
@update:model-value="searchFilterTable"
/>
</div>
</q-card>
</div>
<div class="col-12">
<q-table
ref="table"
:columns="columns"
:rows="UpdataData"
:filter="filterKeyword"
row-key="Order"
flat
bordered
:paging="true"
dense
class="custom-header-table"
v-bind="attrs"
:visible-columns="visibleColumns"
:pagination-label="paginationLabel"
v-model:pagination="pagination"
>
<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-tr>
</template>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td
key="Order"
:props="props"
@click="redirectToPage(props.row.Order)"
>
{{ props.row.Order }}
</q-td>
<q-td
key="OrderNum"
:props="props"
@click="redirectToPage(props.row.Order)"
>
{{ props.row.OrderNum }}
</q-td>
<q-td
key="OrderType"
:props="props"
@click="redirectToPage(props.row.OrderType)"
>
{{ props.row.OrderType }}
</q-td>
<q-td
key="OrderDate"
:props="props"
@click="redirectToPage(props.row.Order)"
>
{{ props.row.OrderDate }}
</q-td>
<q-td
key="OrderBy"
:props="props"
@click="redirectToPage(props.row.Order)"
>
{{ props.row.OrderBy }}
</q-td>
<q-td
key="Signer"
:props="props"
@click="redirectToPage(props.row.Order)"
>
{{ props.row.Signer }}
</q-td>
<q-td
key="OrderStatus"
:props="props"
@click="redirectToPage(props.row.Order)"
>
{{ props.row.OrderStatus }}
</q-td>
<q-td auto-width>
<q-btn
dense
size="12px"
flat
round
color="red"
@click="clickDelete(props.row.id)"
icon="mdi-delete"
>
<q-tooltip>ลบขอม</q-tooltip>
</q-btn>
</q-td>
</q-tr>
</template>
<template v-slot:pagination="scope">
<q-pagination
v-model="pagination.page"
active-color="primary"
color="dark"
:max="scope.pagesNumber"
:max-pages="5"
size="sm"
boundary-links
direction-links
></q-pagination>
</template>
</q-table>
</div>
</div>
</q-card>
</div>
</template>
<style lang="scss" scope>
.filter-card {
background-color: #f1f1f1b0;
}
.toggle-expired-account {
font-size: 12px;
font-weight: 400;
font-size: 15px;
line-height: 150%;
color: #35373c;
}
.icon-color {
color: #4154b3;
}
.custom-header-table {
max-height: 64vh;
.q-table tr:nth-child(odd) td {
background: white;
}
.q-table tr:nth-child(even) td {
background: #f8f8f8;
}
.q-table thead tr {
background: #ecebeb;
}
.q-table thead tr th {
position: sticky;
z-index: 1;
}
/* this will be the loading indicator */
.q-table thead tr:last-child th {
/* height of all previous header rows */
top: 48px;
}
.q-table thead tr:first-child th {
top: 0;
}
}
</style>