อุทธรณ์ร้องทุกข์

This commit is contained in:
setthawutttty 2023-12-14 16:29:29 +07:00
parent 7777b27cda
commit c1f26bc764
12 changed files with 1139 additions and 308 deletions

View file

@ -1,42 +1,69 @@
useA
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { ref, onMounted } from "vue";
import { ref, onMounted, reactive, watch } from "vue";
import { useQuasar } from "quasar";
import { useRouter } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
import { useTransferDataStore } from "@/modules/02_transfer/store";
import { useAppealComplainStore } from "@/modules/07_appealComplain/store";
import http from "@/plugins/http";
import config from "@/app.config";
import Table from "@/components/Table.vue";
import type { FormType } from "@/modules/07_appealComplain/interface/response/mainType";
import type { DataOption } from "@/modules/07_appealComplain/interface/index/main";
const currentPage = ref<number>(1);
const maxPage = ref<number>(1);
const page = ref<number>(1);
const rowsPerPage = ref<number>(10);
const filterKeyword = ref<string>("");
const dataStore = useAppealComplainStore();
const transferData = useTransferDataStore();
const { statusText } = transferData;
const router = useRouter();
const $q = useQuasar();
const mixin = useCounterMixin();
const { date2Thai, messageError, showLoader, hideLoader } = mixin;
const type = ref<DataOption[]>([
{ id: "ALL", name: "ทั้งหมด" },
...dataStore.typeOptions,
]);
/**
* งค pagination
*/
const initialPagination = ref({
rowsPerPage: 0,
const pagination = ref({
sortBy: "lastUpdatedAt",
descending: true,
page: page.value,
rowsPerPage: rowsPerPage.value,
});
/**
* เพมหวขอตาราง
*/
const filter = ref<string>("");
const rows = ref<any>([]);
const visibleColumns = ref<String[]>([
const formData = reactive<FormType>({
type: "ALL",
status: "ALL",
year: new Date().getFullYear(),
});
const visibleColumns = ref<string[]>([
"no",
"date",
"position",
"noPos",
"level",
"salary",
"transfer",
"statustext",
"title",
"type",
"year",
"caseType",
"caseNumber",
"fullname",
"citizenId",
"lastUpdatedAt",
"status",
]);
const columns = ref<QTableProps["columns"]>([
{
@ -49,102 +76,116 @@ const columns = ref<QTableProps["columns"]>([
style: "font-size: 14px; width:5px;",
},
{
name: "date",
name: "title",
align: "left",
label: "วันที่",
label: "เรื่องที่อุทธรณ์/ร้องทุกข์",
sortable: true,
field: "date",
field: "title",
headerStyle: "font-size: 14px",
style: "font-size: 14px; width:15%;",
},
{
name: "position",
name: "type",
align: "left",
label: "ตำแหน่ง",
label: "ประเภท",
sortable: true,
field: "position",
field: "type",
headerStyle: "font-size: 14px",
style: "font-size: 14px; width:15%;",
},
{
name: "noPos",
name: "year",
align: "left",
label: "ตำแหน่งเลขที่",
label: "ปีงบประมาณ",
sortable: true,
field: "noPos",
field: "year",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "level",
name: "caseType",
align: "left",
label: "อันดับ/ระดับ",
label: "ประเภทคดี",
sortable: true,
field: "level",
field: "caseType",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "salary",
name: "caseNumber",
align: "left",
label: "เงินเดือน",
label: "คดีเลขที่",
sortable: true,
field: "salary",
field: "caseNumber",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "transfer",
name: "fullname",
align: "left",
label: "หน่วยงานที่ขอโอนไป",
label: "ชื่อ-นามสกุลผู้อุทธรณ์/ร้องทุกข์",
sortable: true,
field: "transfer",
field: "fullname",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "statustext",
name: "citizenId",
align: "left",
label: "สถานะ",
label: "รหัสบัตรประชาชน",
sortable: true,
field: "statustext",
field: "citizenId",
headerStyle: "font-size: 14px",
style: "font-size: 14px; width:10%;",
},
{
name: "lastUpdatedAt",
align: "left",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "status",
align: "left",
label: "สถานะของคำร้อง",
sortable: false,
field: "status",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
]);
/**
* เรยกฟงกนทงหมดตอนเรยกใชไฟล
*/
onMounted(async () => {
await fecthListTransfer();
});
//
const fecthListTransfer = async () => {
// showLoader();
// await http
// .get(config.API.listUserTransfer())
// .then((res: any) => {
// let data = res.data.result;
// rows.value = data.map((e: any) => ({
// id: e.id,
// date: date2Thai(e.createdAt),
// status: e.status,
// statustext: statusText(e.status),
// position: e.organizationPositionOld,
// noPos: e.posNo,
// level: e.positionLevel,
// salary: e.salary,
// transfer: e.organization,
// }));
// })
// .catch((e: any) => {
// messageError($q, e);
// })
// .finally(() => {
// hideLoader();
// });
const getData = async () => {
showLoader();
await http
.get(
config.API.appealMainList(
formData.status,
formData.type,
formData.year,
currentPage.value,
rowsPerPage.value,
filterKeyword.value
)
)
.then((res: any) => {
maxPage.value = Math.ceil(res.data.result.total / rowsPerPage.value);
let data = res.data.result.data;
dataStore.fetchAppealComplain(data);
console.log(data);
})
.catch((e: any) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
};
/**
@ -160,6 +201,49 @@ const clickAdd = async () => {
const clickBack = () => {
router.push(`/`);
};
function dataUpdate() {
getData();
}
function filterFn() {
getData();
}
watch(
() => currentPage.value,
() => {
rowsPerPage.value = pagination.value.rowsPerPage;
getData();
}
);
watch(
() => pagination.value.rowsPerPage,
() => {
rowsPerPage.value = pagination.value.rowsPerPage;
currentPage.value = 1;
getData();
}
);
function editPage(id:string){
router.push(`/appeal-complain/${id}`);
}
function redirectToPageadd() {
// dataStore.rowsAdd = []
router.push(`/appeal-complain/add`);
}
/**
* เรยกฟงกนทงหมดตอนเรยกใชไฟล
*/
onMounted(async () => {
dataStore.visibleColumns = visibleColumns.value;
dataStore.columns = columns.value;
await getData();
});
</script>
<template>
<div class="col-12 row justify-center">
@ -179,55 +263,217 @@ const clickBack = () => {
</div>
<div class="col-12">
<q-card bordered class="q-pa-md">
<Table
style="max-height: 80vh"
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
:pagination="initialPagination"
:inputShow="false"
:add="clickAdd"
:titleText="''"
>
<template #columns="props">
<q-tr
:props="props"
class="cursor-pointer"
@click="router.push(`/transfer/` + props.row.id)"
<div class="row 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
>
<q-td key="no" :props="props">
{{ props.rowIndex + 1 }}
</q-td>
<q-td key="date" :props="props">
{{ props.row.date }}
</q-td>
<q-td key="position" :props="props">
{{ props.row.position }}
</q-td>
<q-td key="noPos" :props="props">
{{ props.row.noPos }}
</q-td>
<q-td key="level" :props="props">
{{ props.row.level }}
</q-td>
<q-td key="salary" :props="props">
{{ props.row.salary }}
</q-td>
<q-td key="transfer" :props="props">
{{ props.row.transfer }}
</q-td>
<q-td key="statustext" :props="props">
{{ props.row.statustext }}
</div>
</div>
<div class="row col-12 q-col-gutter-sm q-mb-sm">
<div class="col-2">
<datepicker
menu-class-name="modalfix"
v-model="formData.year"
class="col-2"
:locale="'th'"
autoApply
year-picker
:enableTimePicker="false"
@update:model-value="dataUpdate"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
dense
lazy-rules
outlined
:model-value="Number(formData.year) + 543"
:label="`${'ปีงบประมาณ'}`"
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
style="color: var(--q-primary)"
>
</q-icon>
</template>
</q-input>
</template>
</datepicker>
</div>
<div class="col-2">
<q-select
v-model="formData.type"
label="ประเภท"
dense
outlined
emit-value
map-options
option-label="name"
option-value="id"
:options="type"
@update:model-value="dataUpdate"
/>
</div>
<div class="col-2">
<q-select
v-model="formData.status"
label="สถานะ"
dense
outlined
emit-value
map-options
option-label="name"
option-value="id"
:options="dataStore.statusOptions"
@update:model-value="dataUpdate"
/>
</div>
<q-space />
<q-input
class="col-xs-12 col-sm-3 col-md-2"
id="filterTable"
for="filterTable"
dense
outlined
v-model="filterKeyword"
label="ค้นหา"
debounce="300"
@keydown.enter.prevent="filterFn"
>
<template v-slot:append>
<q-icon name="search" />
</template>
</q-input>
<q-select
id="visibleColumns"
for="visibleColumns"
v-model="dataStore.visibleColumns"
multiple
outlined
dense
options-dense
:display-value="$q.lang.table.columns"
emit-value
map-options
:options="dataStore.columns"
option-value="name"
options-cover
class="col-xs-12 col-sm-3 col-md-2"
/>
</div>
<q-table
flat
bordered
dense
class="custom-table2"
style="max-height: 80vh"
:rows="dataStore.rows"
:columns="dataStore.columns"
:visible-columns="dataStore.visibleColumns"
v-model:pagination="pagination"
:rows-per-page-options="[10, 25, 50, 100]"
>
<template v-slot:pagination="scope">
<q-pagination
v-model="currentPage"
active-color="primary"
color="dark"
:max="Number(maxPage)"
size="sm"
boundary-links
direction-links
></q-pagination>
</template>
<template v-slot:header="props">
<q-tr :props="props">
<q-th
v-for="col in props.cols"
:key="col.name"
:props="props"
style="color: #000000; font-weight: 500"
>
<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">
<q-td v-for="col in props.cols" :key="col.name" :props="props" @click="editPage(props.row.id)">
<div v-if="col.name == 'no'">
{{ props.rowIndex + 1 }}
</div>
<div>
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</Table>
</q-table>
</q-card>
</div>
</div>
</div>
</template>
<style></style>
<style lang="scss">
.icon-color {
color: #4154b3;
}
.custom-table2 {
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;
}
.q-table td:nth-of-type(2) {
z-index: 3 !important;
}
.q-table th:nth-of-type(2),
.q-table td:nth-of-type(2) {
position: sticky;
left: 0;
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>