2023-10-16 18:07:42 +07:00
|
|
|
<script setup lang="ts">
|
2023-11-23 10:13:13 +07:00
|
|
|
import { ref, onMounted, watch } from "vue";
|
2023-10-16 18:07:42 +07:00
|
|
|
import { useRouter } from "vue-router";
|
2023-11-23 10:13:13 +07:00
|
|
|
import { useQuasar } from "quasar";
|
2023-12-08 14:26:16 +07:00
|
|
|
|
2023-10-16 18:07:42 +07:00
|
|
|
// importStroe
|
2023-12-08 14:26:16 +07:00
|
|
|
import { useCounterMixin } from "@/stores/mixin";
|
2023-10-19 15:39:18 +07:00
|
|
|
import { useComplainstDataStore } from "@/modules/11_discipline/store/ComplaintsStore";
|
2023-12-08 14:26:16 +07:00
|
|
|
|
2023-10-20 10:31:07 +07:00
|
|
|
// impoet Components
|
|
|
|
|
import TableComplaint from "@/modules/11_discipline/components/1_Complaint/TableComplaint.vue";
|
2023-12-08 14:26:16 +07:00
|
|
|
|
2023-11-23 10:13:13 +07:00
|
|
|
import config from "@/app.config";
|
|
|
|
|
import http from "@/plugins/http";
|
|
|
|
|
|
|
|
|
|
const $q = useQuasar();
|
|
|
|
|
const mixin = useCounterMixin();
|
2023-10-19 15:39:18 +07:00
|
|
|
|
2023-11-23 10:13:13 +07:00
|
|
|
const { showLoader, messageError, hideLoader } = mixin;
|
2023-10-16 18:07:42 +07:00
|
|
|
const router = useRouter();
|
|
|
|
|
|
2023-11-10 13:12:34 +07:00
|
|
|
/** stoer */
|
2023-10-16 18:07:42 +07:00
|
|
|
const complainstStore = useComplainstDataStore();
|
2023-11-10 13:12:34 +07:00
|
|
|
const { fetchComplainst } = complainstStore;
|
2023-10-16 18:07:42 +07:00
|
|
|
|
|
|
|
|
const filterTable = ref<string>("");
|
2023-11-23 10:13:13 +07:00
|
|
|
const filterKeyword = ref<string>("");
|
|
|
|
|
const maxPage = ref<number>(1);
|
|
|
|
|
const page = ref<number>(1);
|
|
|
|
|
const rowsPerPage = ref<number>(10);
|
|
|
|
|
|
2023-11-24 13:15:43 +07:00
|
|
|
async function updatePagingProp(rowPerpage: number, pageCurrent: number) {
|
|
|
|
|
rowsPerPage.value = rowPerpage;
|
|
|
|
|
page.value = pageCurrent;
|
|
|
|
|
await getList();
|
2023-11-23 10:13:13 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function getList() {
|
|
|
|
|
showLoader();
|
|
|
|
|
await http
|
|
|
|
|
.get(
|
|
|
|
|
config.API.complaintList(
|
|
|
|
|
page.value,
|
|
|
|
|
rowsPerPage.value,
|
|
|
|
|
filterKeyword.value
|
|
|
|
|
)
|
|
|
|
|
)
|
2023-11-24 13:15:43 +07:00
|
|
|
//
|
2023-11-23 10:13:13 +07:00
|
|
|
.then((res) => {
|
2023-11-24 13:15:43 +07:00
|
|
|
maxPage.value = Math.ceil(res.data.result.total / rowsPerPage.value);
|
2023-11-23 10:13:13 +07:00
|
|
|
const data = res.data.result.data;
|
|
|
|
|
fetchComplainst(data);
|
|
|
|
|
})
|
|
|
|
|
.catch((e) => {
|
|
|
|
|
messageError($q, e);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
|
|
|
|
});
|
2023-10-16 18:07:42 +07:00
|
|
|
}
|
2023-11-23 10:13:13 +07:00
|
|
|
|
2023-11-10 13:12:34 +07:00
|
|
|
/** ไปยังหน้าเพิ่มข้อมูล */
|
2023-10-16 18:07:42 +07:00
|
|
|
function redirectToPageadd() {
|
|
|
|
|
router.push(`/discipline/complaints/add`);
|
|
|
|
|
}
|
2023-11-10 13:12:34 +07:00
|
|
|
|
2023-11-23 10:13:13 +07:00
|
|
|
function filterFn() {
|
|
|
|
|
getList();
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-10 13:12:34 +07:00
|
|
|
/** เรียกใช้งาน ฟังชั่น ตอนเริ่มโหลดหน้า */
|
|
|
|
|
onMounted(async () => {
|
2023-11-23 10:13:13 +07:00
|
|
|
await getList();
|
2023-11-10 13:12:34 +07:00
|
|
|
});
|
2023-10-16 18:07:42 +07:00
|
|
|
</script>
|
2023-10-16 13:28:48 +07:00
|
|
|
|
|
|
|
|
<template>
|
2023-12-07 09:13:55 +07:00
|
|
|
<div class="toptitle text-dark col-12 row items-center">รายการเรื่องร้องเรียน</div>
|
2023-10-20 16:50:28 +07:00
|
|
|
<q-card flat bordered class="col-12 q-mt-sm q-pa-md">
|
2023-10-24 15:03:48 +07:00
|
|
|
<div class="row col-12 q-col-gutter-sm q-mb-sm">
|
|
|
|
|
<div>
|
|
|
|
|
<q-btn
|
|
|
|
|
id="addComplaints"
|
|
|
|
|
for="addComplaints"
|
|
|
|
|
size="12px"
|
|
|
|
|
flat
|
|
|
|
|
round
|
|
|
|
|
color="primary"
|
|
|
|
|
icon="mdi-plus"
|
|
|
|
|
@click="redirectToPageadd()"
|
|
|
|
|
><q-tooltip>เพิ่มเรื่องร้องเรียน </q-tooltip></q-btn
|
|
|
|
|
>
|
2023-10-16 18:07:42 +07:00
|
|
|
</div>
|
2023-10-24 15:03:48 +07:00
|
|
|
<q-space />
|
2023-11-23 10:13:13 +07:00
|
|
|
|
2023-10-24 15:03:48 +07:00
|
|
|
<q-input
|
|
|
|
|
class="col-xs-12 col-sm-3 col-md-2"
|
|
|
|
|
id="filterTable"
|
|
|
|
|
for="filterTable"
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
2023-11-23 10:13:13 +07:00
|
|
|
v-model="filterKeyword"
|
2023-10-24 15:03:48 +07:00
|
|
|
label="ค้นหา"
|
2023-10-31 14:55:55 +07:00
|
|
|
debounce="300"
|
2023-11-23 10:13:13 +07:00
|
|
|
@keydown.enter.prevent="filterFn"
|
2023-10-24 15:03:48 +07:00
|
|
|
>
|
|
|
|
|
<template v-slot:append>
|
|
|
|
|
<q-icon name="search" />
|
|
|
|
|
</template>
|
|
|
|
|
</q-input>
|
2023-11-23 10:13:13 +07:00
|
|
|
|
2023-10-24 15:03:48 +07:00
|
|
|
<q-select
|
|
|
|
|
id="visibleColumns"
|
|
|
|
|
for="visibleColumns"
|
|
|
|
|
v-model="complainstStore.visibleColumns"
|
|
|
|
|
multiple
|
|
|
|
|
outlined
|
|
|
|
|
dense
|
|
|
|
|
options-dense
|
|
|
|
|
:display-value="$q.lang.table.columns"
|
|
|
|
|
emit-value
|
|
|
|
|
map-options
|
|
|
|
|
:options="complainstStore.columns"
|
|
|
|
|
option-value="name"
|
|
|
|
|
options-cover
|
|
|
|
|
class="col-xs-12 col-sm-3 col-md-2"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2023-11-10 13:12:34 +07:00
|
|
|
|
2023-10-24 15:03:48 +07:00
|
|
|
<div class="col-12">
|
2023-11-23 10:13:13 +07:00
|
|
|
<TableComplaint
|
|
|
|
|
:filterTable="filterTable"
|
|
|
|
|
:rowsPerPage="rowsPerPage"
|
|
|
|
|
:page="page"
|
|
|
|
|
:maxPage="maxPage"
|
|
|
|
|
@update:pagination="updatePagingProp"
|
|
|
|
|
/>
|
2023-10-24 15:03:48 +07:00
|
|
|
</div>
|
2023-10-20 16:50:28 +07:00
|
|
|
</q-card>
|
2023-10-16 13:28:48 +07:00
|
|
|
</template>
|
|
|
|
|
|
2023-10-16 18:07:42 +07:00
|
|
|
<style scoped></style>
|