hrms-mgt/src/modules/11_discipline/components/1_Complaint/MainPage.vue

248 lines
8.5 KiB
Vue
Raw Normal View History

<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useRouter } from "vue-router";
import type { QTableProps } from "quasar";
2023-10-19 15:39:18 +07:00
import type { DataList } from "@/modules/11_discipline/interface/response/complaint";
// importStroe
2023-10-19 15:39:18 +07:00
import { useComplainstDataStore } from "@/modules/11_discipline/store/ComplaintsStore";
const router = useRouter();
const complainstStore = useComplainstDataStore();
2023-10-19 15:39:18 +07:00
const { fetchComplainst } = complainstStore; // function จาก stores
//ข้อมูล Table
const filterTable = ref<string>("");
const columns = ref<QTableProps["columns"]>([
{
name: "no",
align: "left",
label: "ลำดับ",
sortable: false,
field: "no",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "subject",
align: "left",
label: "เรื่อง",
sortable: true,
field: "subject",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "detail",
align: "left",
label: "รายละเอียด",
sortable: true,
field: "detail",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "complainant",
align: "left",
label: "ผู้ถูกร้องเรียน",
sortable: true,
field: "complainant",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "offenseDescription",
align: "left",
label: "ลักษณะความผิด",
sortable: true,
field: "offenseDescription",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "creationDate",
align: "left",
label: "วันที่สร้างเรื่องร้องเรียน",
sortable: true,
field: "creationDate",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "considerationLevel",
align: "left",
label: "ระดับการพิจารณา",
sortable: true,
field: "considerationLevel",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "considerationDeadlineDate",
align: "left",
label: "วันที่กำหนดพิจารณา",
sortable: true,
field: "considerationDeadlineDate",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
]);
const visibleColumns = ref<string[]>([
"no",
"subject",
"detail",
"complainant",
"offenseDescription",
"creationDate",
"considerationLevel",
"considerationDeadlineDate",
]);
onMounted(async () => {
2023-10-19 15:39:18 +07:00
await fetchListComplaints();
});
// เรีนกรายการเรื่องร้องเรียน
2023-10-19 15:39:18 +07:00
async function fetchListComplaints() {
const listData: DataList[] = [
{
subject: "ทุจริตในหน้าที่",
detail: "มีข้อร้องเรียนเรื่องการทุจริตทางการเงิน",
complainant: "นางศิรินภา คงน้อย",
offenseDescription: "ร้ายแรง",
creationDate: "2023-10-16",
considerationLevel: "ด่วนมาก",
considerationDeadlineDate: "2023-11-01",
},
{
subject: "ทุจริตในหน้าที่",
detail: "มีข้อร้องเรียนเรื่องการทุจริตทางการเงิน",
complainant: "นายแก้ว คำ",
offenseDescription: "ร้ายแรง",
creationDate: "2023-10-16",
considerationLevel: "ด่วนมาก",
considerationDeadlineDate: "2023-11-01",
},
{
subject: "ทุจริตในหน้าที่",
detail:
"มีข้อร้องเรียนเรื่องการทุจริตทางการเงิน มีข้อร้องเรียนเรื่องการทุจริตทางการเงิน มีข้อร้องเรียนเรื่องการทุจริตทางการเงิน มีข้อร้องเรียนเรื่องการทุจริตทางการเงิน มีข้อร้องเรียนเรื่องการทุจริตทางการเงิน มีข้อร้องเรียนเรื่องการทุจริตทางการเงิน มีข้อร้องเรียนเรื่องการทุจริตทางการเงิน มีข้อร้องเรียนเรื่องการทุจริตทางการเงิน มีข้อร้องเรียนเรื่องการทุจริตทางการเงิน มีข้อร้องเรียนเรื่องการทุจริตทางการเงิน มีข้อร้องเรียนเรื่องการทุจริตทางการเงิน",
complainant: "นายภัทรานุย คงนอย",
offenseDescription: "ร้ายแรง",
creationDate: "2023-10-16",
considerationLevel: "ด่วนมาก",
considerationDeadlineDate: "2023-11-01",
},
];
2023-10-19 15:39:18 +07:00
await fetchComplainst(listData);
}
function redirectToPageadd() {
router.push(`/discipline/complaints/add`);
}
//pagination
const pagination = ref({
descending: true,
page: 1,
rowsPerPage: 10,
});
const paging = ref<boolean>(true);
const paginationLabel = (start: string, end: string, total: string) => {
if (paging.value == true) return " " + start + "-" + end + " ใน " + total;
else return start + "-" + end + " ใน " + total;
};
</script>
<template>
<div class="toptitle text-dark col-12 row items-center">เรองรองเรยน</div>
<div class="col-12 q-mt-sm">
<q-card flat bordered>
<div class="q-pa-md">
<q-toolbar style="padding: 0" class="q-gutter-sm q-mb-md">
<q-btn
2023-10-19 15:39:18 +07:00
id="addComplaints"
flat
dense
round
color="primary"
icon="mdi-plus"
@click="redirectToPageadd()"
><q-tooltip>เพมเรองรองเรยน </q-tooltip></q-btn
>
<q-space />
<div class="col-2">
2023-10-19 15:39:18 +07:00
<q-input
id="filterTable"
for="filterTable"
dense
outlined
v-model="filterTable"
label="ค้นหา"
/>
</div>
<div class="col-2">
<q-select
2023-10-19 15:39:18 +07:00
id="visibleColumns"
for="visibleColumns"
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
/>
</div>
</q-toolbar>
<d-table
2023-10-19 15:39:18 +07:00
id="table"
ref="table"
:columns="columns"
:rows="complainstStore.rows"
:filter="filterTable"
row-key="subject"
flat
bordered
:paging="true"
dense
class="custom-header-table"
: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-tr>
</template>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer" style="height: 40px">
2023-10-19 15:39:18 +07:00
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'no'">
{{ props.rowIndex + 1 }}
</div>
<div v-if="col.name == 'detail'">
<div class="table_ellipsis">
{{ props.row.detail }}
</div>
</div>
<div v-else>
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</d-table>
</div>
</q-card>
</div>
</template>
<style scoped></style>