2023-07-24 13:19:14 +07:00
|
|
|
<script setup lang="ts">
|
2023-08-08 16:50:50 +07:00
|
|
|
import { ref, onMounted } from "vue";
|
2023-07-24 13:19:14 +07:00
|
|
|
import type { QTableProps } from "quasar";
|
2023-08-08 16:50:50 +07:00
|
|
|
import { useQuasar } from "quasar";
|
|
|
|
|
import { useCounterMixin } from "@/stores/mixin";
|
2023-07-24 13:19:14 +07:00
|
|
|
import { useRouter } from "vue-router";
|
2023-08-08 16:50:50 +07:00
|
|
|
import http from "@/plugins/http";
|
|
|
|
|
import config from "@/app.config";
|
2023-11-17 14:21:53 +07:00
|
|
|
|
|
|
|
|
/** Use */
|
2023-08-08 16:50:50 +07:00
|
|
|
const router = useRouter();
|
|
|
|
|
const $q = useQuasar();
|
|
|
|
|
const mixin = useCounterMixin();
|
2024-05-03 13:24:48 +07:00
|
|
|
const {
|
|
|
|
|
showLoader,
|
|
|
|
|
hideLoader,
|
|
|
|
|
messageError,
|
|
|
|
|
success,
|
|
|
|
|
date2Thai,
|
|
|
|
|
findOrgName,
|
|
|
|
|
} = mixin;
|
2023-07-24 13:19:14 +07:00
|
|
|
|
2023-11-17 14:21:53 +07:00
|
|
|
/** คอลัมน์ */
|
2023-08-08 16:50:50 +07:00
|
|
|
const rows = ref<any>([]);
|
2023-07-24 13:19:14 +07:00
|
|
|
const columns = ref<QTableProps["columns"]>([
|
|
|
|
|
{
|
2023-09-19 17:42:17 +07:00
|
|
|
name: "no",
|
2023-07-24 13:19:14 +07:00
|
|
|
align: "left",
|
2023-09-19 17:42:17 +07:00
|
|
|
label: "ลำดับ",
|
2023-09-20 13:58:12 +07:00
|
|
|
sortable: false,
|
2023-09-19 17:42:17 +07:00
|
|
|
field: "no",
|
2023-07-24 13:19:14 +07:00
|
|
|
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",
|
2024-05-03 13:24:48 +07:00
|
|
|
format(val, row) {
|
|
|
|
|
return `${row.prefix}${row.firstName} ${row.lastName}`;
|
|
|
|
|
},
|
2023-07-24 13:19:14 +07:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "position",
|
|
|
|
|
align: "left",
|
|
|
|
|
label: "ตำแหน่งในสายงาน",
|
|
|
|
|
sortable: true,
|
|
|
|
|
field: "position",
|
|
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-05-03 13:24:48 +07:00
|
|
|
name: "positionType",
|
2023-07-24 13:19:14 +07:00
|
|
|
align: "left",
|
2024-05-03 13:24:48 +07:00
|
|
|
label: "ประเภทตำแหน่ง",
|
2023-07-24 13:19:14 +07:00
|
|
|
sortable: true,
|
2024-05-03 13:24:48 +07:00
|
|
|
field: "positionType",
|
2023-07-24 13:19:14 +07:00
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
2024-05-03 13:24:48 +07:00
|
|
|
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;
|
|
|
|
|
},
|
2023-07-24 13:19:14 +07:00
|
|
|
},
|
2024-05-03 13:24:48 +07:00
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
// name: "positionExecutive",
|
|
|
|
|
// align: "left",
|
|
|
|
|
// label: "ตำแหน่งทางการบริหาร",
|
|
|
|
|
// sortable: true,
|
|
|
|
|
// field: "positionExecutive",
|
|
|
|
|
// headerStyle: "font-size: 14px",
|
|
|
|
|
// style: "font-size: 14px",
|
|
|
|
|
// },
|
2023-07-24 13:19:14 +07:00
|
|
|
{
|
2024-05-03 13:24:48 +07:00
|
|
|
name: "org",
|
2023-07-24 13:19:14 +07:00
|
|
|
align: "left",
|
|
|
|
|
label: "สังกัด",
|
|
|
|
|
sortable: true,
|
2024-05-03 13:24:48 +07:00
|
|
|
field: "org",
|
2023-07-24 13:19:14 +07:00
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
2024-05-03 13:24:48 +07:00
|
|
|
format(val, row) {
|
|
|
|
|
return findOrgName(row);
|
|
|
|
|
},
|
2023-07-24 13:19:14 +07:00
|
|
|
},
|
2023-08-22 14:02:35 +07:00
|
|
|
{
|
|
|
|
|
name: "createdAt",
|
|
|
|
|
align: "left",
|
|
|
|
|
label: "วันที่ดำเนินการ",
|
|
|
|
|
sortable: true,
|
|
|
|
|
field: "createdAt",
|
|
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
2024-05-03 13:24:48 +07:00
|
|
|
format: (val) => date2Thai(val),
|
2023-08-22 14:02:35 +07:00
|
|
|
},
|
2023-07-24 13:19:14 +07:00
|
|
|
]);
|
2023-11-17 14:21:53 +07:00
|
|
|
|
|
|
|
|
/** คอลัมน์ที่แสดง */
|
2023-08-08 16:50:50 +07:00
|
|
|
const visibleColumns = ref<string[]>([
|
2023-09-19 17:42:17 +07:00
|
|
|
"no",
|
2023-08-08 16:50:50 +07:00
|
|
|
"fullname",
|
|
|
|
|
"positionType",
|
2023-08-08 18:11:39 +07:00
|
|
|
"position",
|
2023-08-08 16:50:50 +07:00
|
|
|
"positionLevel",
|
|
|
|
|
"positionExecutive",
|
2024-05-03 13:24:48 +07:00
|
|
|
"org",
|
2023-08-22 14:02:35 +07:00
|
|
|
"createdAt",
|
2023-08-08 16:50:50 +07:00
|
|
|
]);
|
2023-11-17 14:21:53 +07:00
|
|
|
|
|
|
|
|
/**Hook */
|
2023-08-08 16:50:50 +07:00
|
|
|
onMounted(() => {
|
|
|
|
|
fectListDecased();
|
|
|
|
|
});
|
2023-11-17 14:21:53 +07:00
|
|
|
|
|
|
|
|
/**เรียกข้อมูลจาก APi */
|
2023-08-08 16:50:50 +07:00
|
|
|
const fectListDecased = async () => {
|
|
|
|
|
showLoader();
|
|
|
|
|
await http
|
|
|
|
|
.get(config.API.listDeceased())
|
|
|
|
|
.then((res) => {
|
2024-05-03 13:24:48 +07:00
|
|
|
const data = res.data.result;
|
|
|
|
|
rows.value = data;
|
2023-08-08 16:50:50 +07:00
|
|
|
})
|
|
|
|
|
.catch((e) => {
|
|
|
|
|
messageError($q, e);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//ค้นหา คอลัมน์ คอลัมน์ที่แสดง
|
|
|
|
|
const filterKeyword = ref<string>("");
|
|
|
|
|
const filterRef = ref<any>(null);
|
|
|
|
|
const resetFilter = () => {
|
|
|
|
|
filterKeyword.value = "";
|
|
|
|
|
filterRef.value.focus();
|
|
|
|
|
};
|
2023-11-17 14:21:53 +07:00
|
|
|
|
|
|
|
|
/** Setting Pagination */
|
2023-08-08 16:50:50 +07:00
|
|
|
const nextPage = (id: string) => {
|
|
|
|
|
router.push("/deceased/" + id);
|
|
|
|
|
};
|
2023-08-22 17:06:53 +07:00
|
|
|
const pagination = ref({
|
|
|
|
|
sortBy: "createdAt",
|
|
|
|
|
descending: true,
|
|
|
|
|
page: 1,
|
|
|
|
|
rowsPerPage: 10,
|
|
|
|
|
});
|
2023-07-24 13:19:14 +07:00
|
|
|
</script>
|
|
|
|
|
<template>
|
2023-08-08 16:50:50 +07:00
|
|
|
<div class="toptitle text-dark col-12 row items-center">
|
|
|
|
|
รายการบันทึกเวียนแจ้งการถึงแก่กรรม
|
|
|
|
|
</div>
|
2023-07-24 13:19:14 +07:00
|
|
|
<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">
|
2023-08-22 17:06:53 +07:00
|
|
|
<d-table
|
2023-07-24 13:19:14 +07:00
|
|
|
ref="table"
|
|
|
|
|
:columns="columns"
|
|
|
|
|
:rows="rows"
|
|
|
|
|
:filter="filterKeyword"
|
|
|
|
|
row-key="fullname"
|
|
|
|
|
flat
|
|
|
|
|
bordered
|
|
|
|
|
:paging="true"
|
|
|
|
|
dense
|
|
|
|
|
class="custom-header-table"
|
|
|
|
|
:visible-columns="visibleColumns"
|
2023-08-08 16:50:50 +07:00
|
|
|
v-model:pagination="pagination"
|
2023-07-24 13:19:14 +07:00
|
|
|
>
|
|
|
|
|
<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-tr>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-slot:body="props">
|
2023-08-08 16:50:50 +07:00
|
|
|
<q-tr
|
|
|
|
|
:props="props"
|
|
|
|
|
class="cursor-pointer"
|
2024-05-03 13:24:48 +07:00
|
|
|
@click="nextPage(props.row.id)"
|
2023-08-08 16:50:50 +07:00
|
|
|
>
|
2023-08-22 14:02:35 +07:00
|
|
|
<q-td
|
2024-05-03 13:24:48 +07:00
|
|
|
v-for="col in props.cols"
|
|
|
|
|
:key="col.id"
|
|
|
|
|
@click.stop.prevent="nextPage(props.row.id)"
|
2023-08-22 14:02:35 +07:00
|
|
|
>
|
2024-05-03 13:24:48 +07:00
|
|
|
<div v-if="col.name === 'no'">
|
|
|
|
|
{{ props.rowIndex + 1 }}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
v-else
|
|
|
|
|
:class="col.name === 'org' ? 'table_ellipsis' : ''"
|
|
|
|
|
>
|
|
|
|
|
{{ col.value ? col.value : "-" }}
|
|
|
|
|
</div>
|
2023-08-22 14:02:35 +07:00
|
|
|
</q-td>
|
2023-07-24 13:19:14 +07:00
|
|
|
</q-tr>
|
|
|
|
|
</template>
|
2023-08-22 17:06:53 +07:00
|
|
|
</d-table>
|
2023-07-24 13:19:14 +07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</q-card>
|
|
|
|
|
</template>
|
|
|
|
|
<style scoped lang="scss">
|
2023-08-08 16:50:50 +07:00
|
|
|
.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;
|
2023-07-24 13:19:14 +07:00
|
|
|
}
|
2023-08-08 16:50:50 +07:00
|
|
|
}
|
|
|
|
|
</style>
|