เพิ่ม filter
This commit is contained in:
parent
4a9fa574de
commit
84f82b9457
3 changed files with 80 additions and 41 deletions
|
|
@ -3,11 +3,13 @@
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<div class="q-gutter-sm" v-if="nornmalData == true">
|
<div class="q-gutter-sm" v-if="nornmalData == true">
|
||||||
<datepicker
|
<datepicker
|
||||||
v-model="selectedDate"
|
menu-class-name="modalfix"
|
||||||
|
v-model="SpecialTimeStore.selectDate"
|
||||||
:locale="'th'"
|
:locale="'th'"
|
||||||
autoApply
|
autoApply
|
||||||
month-picker
|
|
||||||
:enableTimePicker="false"
|
:enableTimePicker="false"
|
||||||
|
week-start="0"
|
||||||
|
@update:model-value="searchFilterTable(SpecialTimeStore.selectDate)"
|
||||||
>
|
>
|
||||||
<template #year="{ year }">{{ year + 543 }}</template>
|
<template #year="{ year }">{{ year + 543 }}</template>
|
||||||
<template #year-overlay-value="{ value }">{{
|
<template #year-overlay-value="{ value }">{{
|
||||||
|
|
@ -15,18 +17,20 @@
|
||||||
}}</template>
|
}}</template>
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
<q-input
|
<q-input
|
||||||
:model-value="monthYearThai(dateMonth)"
|
for="selectDate"
|
||||||
dense
|
dense
|
||||||
outlined
|
outlined
|
||||||
|
lazy-rules
|
||||||
|
:model-value="
|
||||||
|
SpecialTimeStore.selectDate !== null
|
||||||
|
? date2Thai(SpecialTimeStore.selectDate)
|
||||||
|
: null
|
||||||
|
"
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
style="width: 130px"
|
:label="`${'วันที่'}`"
|
||||||
>
|
>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<q-icon
|
<q-icon name="event" class="cursor-pointer text-primary">
|
||||||
name="event"
|
|
||||||
class="cursor-pointer"
|
|
||||||
style="color: var(--q-primary)"
|
|
||||||
>
|
|
||||||
</q-icon>
|
</q-icon>
|
||||||
</template>
|
</template>
|
||||||
</q-input>
|
</q-input>
|
||||||
|
|
@ -98,27 +102,18 @@
|
||||||
<template #body="props">
|
<template #body="props">
|
||||||
<slot v-bind="props" name="columns"></slot>
|
<slot v-bind="props" name="columns"></slot>
|
||||||
</template>
|
</template>
|
||||||
<!-- <template v-slot:pagination="scope">
|
|
||||||
<q-pagination
|
|
||||||
v-model="pagination.page"
|
|
||||||
active-color="primary"
|
|
||||||
color="dark"
|
|
||||||
:max="scope.pagesNumber"
|
|
||||||
:max-pages="5"
|
|
||||||
size="sm"
|
|
||||||
boundary-links
|
|
||||||
direction-links
|
|
||||||
></q-pagination>
|
|
||||||
</template> -->
|
|
||||||
</d-table>
|
</d-table>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, useAttrs } from "vue";
|
import { ref, useAttrs } from "vue";
|
||||||
import type { Pagination } from "@/modules/04_registry/interface/index/Main";
|
import type { Pagination } from "@/modules/04_registry/interface/index/Main";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
|
import { useSpecialTimeStore } from "@/modules/09_leave/stores/SpecialTimeStore";
|
||||||
|
|
||||||
|
const SpecialTimeStore = useSpecialTimeStore();
|
||||||
|
const { searchFilterTable } = SpecialTimeStore;
|
||||||
const mixin = useCounterMixin();
|
const mixin = useCounterMixin();
|
||||||
const { hideLoader, monthYear2Thai } = mixin;
|
const { hideLoader, monthYear2Thai, date2Thai } = mixin;
|
||||||
const attrs = ref<any>(useAttrs());
|
const attrs = ref<any>(useAttrs());
|
||||||
const paging = ref<boolean>(true);
|
const paging = ref<boolean>(true);
|
||||||
const pagination = ref({
|
const pagination = ref({
|
||||||
|
|
@ -164,7 +159,6 @@ const props = defineProps({
|
||||||
defualt: false,
|
defualt: false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits([
|
const emit = defineEmits([
|
||||||
"update:inputfilter",
|
"update:inputfilter",
|
||||||
"update:inputvisible",
|
"update:inputvisible",
|
||||||
|
|
@ -180,18 +174,7 @@ const updateVisible = (value: []) => {
|
||||||
const checkAdd = () => {
|
const checkAdd = () => {
|
||||||
props.add();
|
props.add();
|
||||||
};
|
};
|
||||||
const selectedDate = ref<string>("");
|
|
||||||
|
|
||||||
const dateMonth = ref<any>({
|
|
||||||
month: new Date().getMonth(),
|
|
||||||
year: new Date().getFullYear(),
|
|
||||||
});
|
|
||||||
console.log(dateMonth);
|
|
||||||
|
|
||||||
const monthYearThai = (val: any) => {
|
|
||||||
if (val == null) return "";
|
|
||||||
else return monthYear2Thai(val.month, val.year);
|
|
||||||
};
|
|
||||||
const resetFilter = () => {
|
const resetFilter = () => {
|
||||||
// reset ค่าที่ค้นหาเมื่อกดปุ่ม X ในกล่องค้นหา
|
// reset ค่าที่ค้นหาเมื่อกดปุ่ม X ในกล่องค้นหา
|
||||||
emit("update:inputfilter", "");
|
emit("update:inputfilter", "");
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,76 @@
|
||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import type { QTableProps } from "quasar";
|
import type { QTableProps } from "quasar";
|
||||||
import type {
|
import type { DataRows } from "@/modules/09_leave/interface/response/specialTime";
|
||||||
investigateDisDataRowType,
|
|
||||||
DataOption,
|
|
||||||
} from "@/modules/11_discipline/interface/index/Main";
|
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
const mixin = useCounterMixin();
|
const mixin = useCounterMixin();
|
||||||
const { date2Thai } = mixin;
|
const { date2Thai } = mixin;
|
||||||
|
|
||||||
export const useSpecialTimeStore = defineStore("LeaveSpecialTime", () => {
|
export const useSpecialTimeStore = defineStore("LeaveSpecialTime", () => {
|
||||||
const rows = ref<any[]>([]);
|
const rows = ref<any[]>([]);
|
||||||
async function fecthList(data: any[]) {
|
const selectDate = ref<Date | null>(new Date());
|
||||||
let datalist: any[] = data.map((e: any) => ({
|
const fiscalYear = ref<string | null>("0");
|
||||||
|
const DataMainOrig = ref<DataRows[]>([]); // ข้อมูลหลักดั้งเดิม
|
||||||
|
async function fecthList(data: DataRows[]) {
|
||||||
|
let datalist: DataRows[] = data.map((e: any) => ({
|
||||||
fullname: e.fullname,
|
fullname: e.fullname,
|
||||||
date: date2Thai(new Date(e.date)),
|
date: date2Thai(new Date(e.date)),
|
||||||
dateFix: date2Thai(new Date(e.dateFix)),
|
dateFix: date2Thai(new Date(e.dateFix)) + (e.timeStamp || ""),
|
||||||
type: e.type,
|
type: e.type,
|
||||||
reason: e.reason,
|
reason: e.reason,
|
||||||
|
timeStamp: e.timeStamp,
|
||||||
}));
|
}));
|
||||||
rows.value = datalist;
|
rows.value = datalist;
|
||||||
|
DataMainOrig.value = datalist;
|
||||||
}
|
}
|
||||||
|
const DataMainUpdate = ref<DataRows[]>([]); // ข้อมูลเปลี่ยนแปลง
|
||||||
|
const DataMain = (val: DataRows[]) => (DataMainOrig.value = val);
|
||||||
|
const DataUpdate = (filterYear: string) => {
|
||||||
|
DataMainUpdate.value = [];
|
||||||
|
if (filterYear === "") {
|
||||||
|
DataMainUpdate.value = DataMainOrig.value;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//--------------|ฟิลเตอร์|--------------------------------------//
|
||||||
|
const searchFilterTable = async (searchDate: any) => {
|
||||||
|
rows.value = [];
|
||||||
|
|
||||||
|
if (fiscalYear.value !== undefined && searchDate.value !== null) {
|
||||||
|
await DataUpdate(searchDate.value === "0" ? "all" : searchDate.value!);
|
||||||
|
let filteredData = DataMainOrig.value;
|
||||||
|
if (searchDate.value !== "0") {
|
||||||
|
filteredData = filteredData.filter(
|
||||||
|
(item: DataRows) => item.date === searchDate.value
|
||||||
|
);
|
||||||
|
console.log(searchDate.value);
|
||||||
|
}
|
||||||
|
const dataArr = filteredData.map((e: any) => ({
|
||||||
|
fullname: e.fullname,
|
||||||
|
date: date2Thai(new Date(e.date)),
|
||||||
|
dateFix: date2Thai(new Date(e.dateFix)) + (e.timeStamp || ""),
|
||||||
|
type: e.type,
|
||||||
|
reason: e.reason,
|
||||||
|
timeStamp: e.timeStamp,
|
||||||
|
}));
|
||||||
|
rows.value = dataArr;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// const filterSelector = (val: any, update: Function, refData: string) => {
|
||||||
|
// switch (refData) {
|
||||||
|
// case "":
|
||||||
|
// update(() => {
|
||||||
|
// selectDate.value = selectDate.value.filter(
|
||||||
|
// (v: any) => v.name.indexOf(val) > -1
|
||||||
|
// );
|
||||||
|
// });
|
||||||
|
// break;
|
||||||
|
|
||||||
|
// default:
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
const visibleColumns = ref<String[]>([
|
const visibleColumns = ref<String[]>([
|
||||||
"no",
|
"no",
|
||||||
|
|
@ -100,5 +150,8 @@ export const useSpecialTimeStore = defineStore("LeaveSpecialTime", () => {
|
||||||
rows,
|
rows,
|
||||||
visibleColumns,
|
visibleColumns,
|
||||||
columns,
|
columns,
|
||||||
|
DataMain,
|
||||||
|
searchFilterTable,
|
||||||
|
selectDate,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ onMounted(async () => {
|
||||||
reason: "ลืม",
|
reason: "ลืม",
|
||||||
unapprove: "1",
|
unapprove: "1",
|
||||||
approve: "0",
|
approve: "0",
|
||||||
|
timeStamp: " 08:00 น.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fullname: "นางสาวรัชภรณ์ ภักดี",
|
fullname: "นางสาวรัชภรณ์ ภักดี",
|
||||||
|
|
@ -69,6 +70,7 @@ onMounted(async () => {
|
||||||
reason: "ลืม",
|
reason: "ลืม",
|
||||||
unapprove: "1",
|
unapprove: "1",
|
||||||
approve: "0",
|
approve: "0",
|
||||||
|
timeStamp: " 08:00 น.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fullname: "นางสาวภาพรรณ ลออ",
|
fullname: "นางสาวภาพรรณ ลออ",
|
||||||
|
|
@ -78,6 +80,7 @@ onMounted(async () => {
|
||||||
reason: "ลืม",
|
reason: "ลืม",
|
||||||
unapprove: "1",
|
unapprove: "1",
|
||||||
approve: "0",
|
approve: "0",
|
||||||
|
timeStamp: " 08:00 น.",
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
await hideLoader();
|
await hideLoader();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue