ปรับ table ลงเวลา

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2023-10-20 16:57:32 +07:00
parent 9e3fb8bff7
commit 7d23bdc945
11 changed files with 309 additions and 267 deletions

View file

@ -13,7 +13,6 @@ const workStore = useWorklistDataStore();
const { date2Thai } = mixin;
const { searchDataFn, filterFn } = workStore;
onMounted(() => {});
// Table
const columns = ref<QTableProps["columns"]>([
@ -90,6 +89,12 @@ const visibleColumns = ref<string[]>([
"coordinatesOut",
"status",
]);
onMounted(() => {
workStore.columns = columns.value;
workStore.visibleColumns = visibleColumns.value;
});
//DialogDetail
const modal = ref<boolean>(false);
const dataDetail = ref<any>([]);
@ -108,96 +113,9 @@ const pagination = ref({
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>
<q-toolbar style="padding: 0" class="q-gutter-sm q-mb-md">
<div class="col-2">
<datepicker
menu-class-name="modalfix"
v-model="workStore.selectDate"
:locale="'th'"
autoApply
:enableTimePicker="false"
week-start="0"
@update:model-value="
searchDataFn(workStore.selectDate, workStore.selectStatus)
"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
dense
outlined
lazy-rules
:model-value="
workStore.selectDate !== null
? date2Thai(workStore.selectDate)
: null
"
hide-bottom-space
:label="`${'วันที่'}`"
>
<template v-slot:prepend>
<q-icon name="event" class="cursor-pointer text-primary">
</q-icon>
</template>
</q-input>
</template>
</datepicker>
</div>
<div class="col-3">
<q-select
emit-value
map-options
outlined
dense
v-model="workStore.selectStatus"
:options="workStore.optionStatus"
option-value="id"
option-label="name"
label="สถานะ"
@update:model-value="
searchDataFn(workStore.selectDate, workStore.selectStatus)
"
use-input
@filter="filterFn"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey"> ไมอม </q-item-section>
</q-item>
</template></q-select
>
</div>
<q-space />
<div class="col-2">
<q-input dense outlined v-model="workStore.filterTable" label="ค้นหา" />
</div>
<div class="col-2">
<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
/>
</div>
</q-toolbar>
<d-table
ref="table"
:columns="columns"
@ -209,8 +127,7 @@ const paginationLabel = (start: string, end: string, total: string) => {
:paging="true"
dense
class="custom-header-table"
:visible-columns="visibleColumns"
:pagination-label="paginationLabel"
:visible-columns="workStore.visibleColumns"
v-model:pagination="pagination"
>
<template v-slot:header="props">
@ -222,64 +139,38 @@ const paginationLabel = (start: string, end: string, total: string) => {
</template>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td key="no" :props="props" @click.prevent="clickDetail(props.row)">
{{ props.rowIndex + 1 }}
</q-td>
<q-td
key="fullName"
v-for="col in props.cols"
:key="col.name"
:props="props"
@click.prevent="clickDetail(props.row)"
>
{{ props.row.fullName }}
</q-td>
<q-td
key="timeIn"
:props="props"
@click.prevent="clickDetail(props.row)"
>
{{ props.row.timeIn }}
</q-td>
<q-td
key="coordinatesIn"
:props="props"
@click.prevent="clickDetail(props.row)"
>
<q-item style="padding: 0">
<q-item-section>
<q-item-label> {{ props.row.coordinatesIn }}</q-item-label>
<q-item-label caption lines="2">{{
props.row.latIn + " " + props.row.longIn
}}</q-item-label>
</q-item-section>
</q-item>
</q-td>
<q-td
key="timeOut"
:props="props"
@click.prevent="clickDetail(props.row)"
>
{{ props.row.timeOut }}
</q-td>
<q-td
key="coordinatesOut"
:props="props"
@click.prevent="clickDetail(props.row)"
>
<q-item style="padding: 0">
<q-item-section>
<q-item-label> {{ props.row.coordinatesOut }}</q-item-label>
<q-item-label caption lines="2">{{
props.row.latOut + " " + props.row.longOut
}}</q-item-label>
</q-item-section>
</q-item>
</q-td>
<q-td
key="status"
:props="props"
@click.prevent="clickDetail(props.row)"
>
{{ props.row.status }}
<div v-if="col.name == 'no'">
{{ props.rowIndex + 1 }}
</div>
<div v-else-if="col.name == 'coordinatesIn'">
<q-item style="padding: 0">
<q-item-section>
<q-item-label> {{ props.row.coordinatesIn }}</q-item-label>
<q-item-label caption lines="2">{{
props.row.latIn + " " + props.row.longIn
}}</q-item-label>
</q-item-section>
</q-item>
</div>
<div v-else-if="col.name == 'coordinatesOut'">
<q-item style="padding: 0">
<q-item-section>
<q-item-label> {{ props.row.coordinatesOut }}</q-item-label>
<q-item-label caption lines="2">{{
props.row.latOut + " " + props.row.longOut
}}</q-item-label>
</q-item-section>
</q-item>
</div>
<div v-else>
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>

View file

@ -0,0 +1,98 @@
<script setup lang="ts">
//import Stores
import { useCounterMixin } from "@/stores/mixin";
import { useWorklistDataStore } from "@/modules/09_leave/stores/WorkStore";
const workStore = useWorklistDataStore();
const mixin = useCounterMixin();
const { date2Thai } = mixin;
const { filterFn, searchDataFn } = workStore;
</script>
<template>
<q-toolbar style="padding: 0" class="q-gutter-sm q-mb-md">
<div class="col-2">
<datepicker
menu-class-name="modalfix"
v-model="workStore.selectDate"
:locale="'th'"
autoApply
:enableTimePicker="false"
week-start="0"
@update:model-value="
searchDataFn(workStore.selectDate, workStore.selectStatus)
"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
dense
outlined
lazy-rules
:model-value="
workStore.selectDate !== null
? date2Thai(workStore.selectDate)
: null
"
hide-bottom-space
:label="`${'วันที่'}`"
>
<template v-slot:prepend>
<q-icon name="event" class="cursor-pointer text-primary">
</q-icon>
</template>
</q-input>
</template>
</datepicker>
</div>
<div class="col-3">
<q-select
emit-value
map-options
outlined
dense
v-model="workStore.selectStatus"
:options="workStore.optionStatus"
option-value="id"
option-label="name"
label="สถานะ"
@update:model-value="
searchDataFn(workStore.selectDate, workStore.selectStatus)
"
use-input
@filter="filterFn"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey"> ไมอม </q-item-section>
</q-item>
</template></q-select
>
</div>
<q-space />
<div class="col-2">
<q-input dense outlined v-model="workStore.filterTable" label="ค้นหา" />
</div>
<div class="col-2">
<q-select
v-model="workStore.visibleColumns"
multiple
outlined
dense
options-dense
:display-value="$q.lang.table.columns"
emit-value
map-options
:options="workStore.columns"
option-value="name"
options-cover
/>
</div>
</q-toolbar>
</template>
<style scoped></style>

View file

@ -1,9 +1,8 @@
q
<script setup lang="ts">
import { ref } from "vue";
import { ref, onMounted } from "vue";
import type { QTableProps } from "quasar";
import { useRouter } from "vue-router";
//import Stores
import { useCounterMixin } from "@/stores/mixin";
import { useLeavelistDataStore } from "@/modules/09_leave/stores/LeaveStore";
@ -71,6 +70,11 @@ const visibleColumns = ref<string[]>([
"status",
]);
onMounted(() => {
leaveStore.columns = columns.value;
leaveStore.visibleColumns = visibleColumns.value;
});
const pagination = ref({
descending: true,
page: 1,
@ -85,89 +89,6 @@ const paginationLabel = (start: string, end: string, total: string) => {
</script>
<template>
<q-toolbar style="padding: 0" class="q-gutter-sm q-mb-md">
<div class="col-2">
<q-select
emit-value
map-options
outlined
dense
v-model="leaveStore.selectYear"
:options="optionYear"
option-value="id"
option-label="name"
label="ปีงบประมาณ"
/>
</div>
<div class="col-3">
<q-select
emit-value
map-options
outlined
dense
v-model="leaveStore.selectType"
:options="leaveStore.optionType"
option-value="id"
option-label="name"
label="ประเภทการลา"
@update:model-value="
searchDataFn(leaveStore.selectType, leaveStore.selectStatus)
"
use-input
@filter="
(inputValue:any, doneFn:Function) =>
filterOption(inputValue, doneFn, 'type')
"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey"> ไมอม </q-item-section>
</q-item>
</template></q-select
>
</div>
<div class="col-2">
<q-select
v-if="leaveStore.tab == '2'"
emit-value
map-options
outlined
dense
v-model="leaveStore.selectStatus"
:options="leaveStore.optionStatus"
option-value="id"
option-label="name"
label="สถานะ"
@update:model-value="
searchDataFn(leaveStore.selectType, leaveStore.selectStatus)
"
use-input
@filter="
(inputValue:any, doneFn:Function) =>
filterOption(inputValue, doneFn, 'status')
"
/>
</div>
<q-space />
<div class="col-2">
<q-input dense outlined v-model="leaveStore.filterTable" label="ค้นหา" />
</div>
<div class="col-2">
<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
/>
</div>
</q-toolbar>
<d-table
ref="table"
:columns="columns"
@ -179,7 +100,7 @@ const paginationLabel = (start: string, end: string, total: string) => {
:paging="true"
dense
class="custom-header-table"
:visible-columns="visibleColumns"
:visible-columns="leaveStore.visibleColumns"
:pagination-label="paginationLabel"
v-model:pagination="pagination"
:loading="leaveStore.loadTable"
@ -192,26 +113,20 @@ const paginationLabel = (start: string, end: string, total: string) => {
</q-tr>
</template>
<template v-slot:body="props">
<q-tr
:props="props"
class="cursor-pointer"
@click.prevent="router.push(`/leave/detail/${props.row.name}`)"
>
<q-td key="no" :props="props"> {{ props.rowIndex + 1 }} </q-td>
<q-td key="leaveType" :props="props">
{{ props.row.leaveType }}
</q-td>
<q-td key="name" :props="props">
{{ props.row.name }}
</q-td>
<q-td key="Date" :props="props">
{{ props.row.Date }}
</q-td>
<q-td key="timeOut" :props="props">
{{ props.row.timeOut }}
</q-td>
<q-td key="status" :props="props">
{{ props.row.status }}
<q-tr :props="props" class="cursor-pointer">
<q-td
v-for="col in props.cols"
:key="col.name"
:props="props"
@click.prevent="router.push(`/leave/detail/${props.row.name}`)"
>
<div v-if="col.name == 'no'">
{{ props.rowIndex + 1 }}
</div>
<div v-else>
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>

View file

@ -0,0 +1,95 @@
<script setup lang="ts">
//import Stores
import { useLeavelistDataStore } from "@/modules/09_leave/stores/LeaveStore";
const leaveStore = useLeavelistDataStore();
const { searchDataFn, filterOption } = leaveStore;
</script>
<template>
<q-toolbar style="padding: 0" class="q-gutter-sm q-mb-md">
<div class="col-2">
<q-select
emit-value
map-options
outlined
dense
v-model="leaveStore.selectYear"
:options="leaveStore.optionYear"
option-value="id"
option-label="name"
label="ปีงบประมาณ"
/>
</div>
<div class="col-3">
<q-select
emit-value
map-options
outlined
dense
v-model="leaveStore.selectType"
:options="leaveStore.optionType"
option-value="id"
option-label="name"
label="ประเภทการลา"
@update:model-value="
searchDataFn(leaveStore.selectType, leaveStore.selectStatus)
"
use-input
@filter="
(inputValue:any, doneFn:Function) =>
filterOption(inputValue, doneFn, 'type')
"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey"> ไมอม </q-item-section>
</q-item>
</template></q-select
>
</div>
<div class="col-2">
<q-select
v-if="leaveStore.tab == '2'"
emit-value
map-options
outlined
dense
v-model="leaveStore.selectStatus"
:options="leaveStore.optionStatus"
option-value="id"
option-label="name"
label="สถานะ"
@update:model-value="
searchDataFn(leaveStore.selectType, leaveStore.selectStatus)
"
use-input
@filter="
(inputValue:any, doneFn:Function) =>
filterOption(inputValue, doneFn, 'status')
"
/>
</div>
<q-space />
<div class="col-2">
<q-input dense outlined v-model="leaveStore.filterTable" label="ค้นหา" />
</div>
<div class="col-2">
<q-select
v-model="leaveStore.visibleColumns"
multiple
outlined
dense
options-dense
:display-value="$q.lang.table.columns"
emit-value
map-options
:options="leaveStore.columns"
option-value="name"
options-cover
/>
</div>
</q-toolbar>
</template>
<style scoped></style>