ปรับ table

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2023-10-20 10:31:07 +07:00
parent dd43268931
commit 9e3fb8bff7
10 changed files with 319 additions and 285 deletions

View file

@ -1,11 +1,13 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useRouter } from "vue-router";
import type { QTableProps } from "quasar";
// import type
import type { DataList } from "@/modules/11_discipline/interface/response/complaint";
// importStroe
import { useComplainstDataStore } from "@/modules/11_discipline/store/ComplaintsStore";
// impoet Components
import TableComplaint from "@/modules/11_discipline/components/1_Complaint/TableComplaint.vue";
const router = useRouter();
@ -14,90 +16,7 @@ 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 () => {
await fetchListComplaints();
});
@ -139,18 +58,6 @@ async function fetchListComplaints() {
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>
@ -184,7 +91,7 @@ const paginationLabel = (start: string, end: string, total: string) => {
<q-select
id="visibleColumns"
for="visibleColumns"
v-model="visibleColumns"
v-model="complainstStore.visibleColumns"
multiple
outlined
dense
@ -192,53 +99,13 @@ const paginationLabel = (start: string, end: string, total: string) => {
:display-value="$q.lang.table.columns"
emit-value
map-options
:options="columns"
:options="complainstStore.columns"
option-value="name"
options-cover
/>
</div>
</q-toolbar>
<d-table
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">
<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>
<TableComplaint :filterTable="filterTable" />
</div>
</q-card>
</div>

View file

@ -0,0 +1,157 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
// import type
import type { QTableProps } from "quasar";
// importStroe
import { useComplainstDataStore } from "@/modules/11_discipline/store/ComplaintsStore";
const complainstStore = useComplainstDataStore();
const props = defineProps({
filterTable: {
type: String,
default: "",
},
});
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(() => {
complainstStore.columns = columns.value;
complainstStore.visibleColumns = visibleColumns.value;
});
//pagination
const pagination = ref({
descending: true,
page: 1,
rowsPerPage: 10,
});
</script>
<template>
<d-table
id="table"
ref="table"
:columns="columns"
:rows="complainstStore.rows"
:filter="props.filterTable"
row-key="subject"
flat
bordered
:paging="true"
dense
class="custom-header-table"
:visible-columns="complainstStore.visibleColumns"
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">
<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>
</template>
<style scoped></style>