ฟิลเตอร์การลา
This commit is contained in:
parent
94a8733746
commit
1b23eed1d1
3 changed files with 72 additions and 14 deletions
|
|
@ -67,13 +67,18 @@ function updateVisible(value: []) {
|
||||||
|
|
||||||
/** filter */
|
/** filter */
|
||||||
const year = ref<number>(new Date().getFullYear());
|
const year = ref<number>(new Date().getFullYear());
|
||||||
const type = ref<string>("00000000-0000-0000-0000-000000000000");
|
|
||||||
const status = ref<string>("ALL");
|
|
||||||
const filter = ref<string>("");
|
const filter = ref<string>("");
|
||||||
|
|
||||||
/** function updateFilter*/
|
/** function updateFilter*/
|
||||||
function filterTable() {
|
function filterTable() {
|
||||||
emit("update:filter", year.value, type.value, status.value, filter.value);
|
emit(
|
||||||
|
"update:filter",
|
||||||
|
year.value,
|
||||||
|
leaveStore.type,
|
||||||
|
leaveStore.status,
|
||||||
|
filter.value
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** function updatePagination*/
|
/** function updatePagination*/
|
||||||
|
|
@ -134,7 +139,7 @@ watch([() => currentPage.value, () => pagination.value.rowsPerPage], () => {
|
||||||
<q-select
|
<q-select
|
||||||
outlined
|
outlined
|
||||||
dense
|
dense
|
||||||
v-model="type"
|
v-model="leaveStore.type"
|
||||||
:label="`${'ประเภทใบลา'}`"
|
:label="`${'ประเภทใบลา'}`"
|
||||||
emit-value
|
emit-value
|
||||||
map-options
|
map-options
|
||||||
|
|
@ -149,17 +154,31 @@ watch([() => currentPage.value, () => pagination.value.rowsPerPage], () => {
|
||||||
@filter="(inputValue:any,
|
@filter="(inputValue:any,
|
||||||
doneFn:Function) => filterOption(inputValue, doneFn,'LeaveTypeOption'
|
doneFn:Function) => filterOption(inputValue, doneFn,'LeaveTypeOption'
|
||||||
) "
|
) "
|
||||||
|
typeOptionsMain
|
||||||
>
|
>
|
||||||
<template v-slot:no-option>
|
<template v-slot:no-option>
|
||||||
<q-item>
|
<q-item>
|
||||||
<q-item-section class="text-grey"> ไม่มีข้อมูล </q-item-section>
|
<q-item-section class="text-grey"> ไม่มีข้อมูล </q-item-section>
|
||||||
</q-item>
|
</q-item>
|
||||||
</template></q-select
|
</template>
|
||||||
>
|
<template
|
||||||
|
v-if="leaveStore.type !== '00000000-0000-0000-0000-000000000000'"
|
||||||
|
v-slot:append
|
||||||
|
>
|
||||||
|
<q-icon
|
||||||
|
name="cancel"
|
||||||
|
@click.stop.prevent="
|
||||||
|
(leaveStore.typeOptions = leaveStore.typeOptionsMain),
|
||||||
|
(leaveStore.type = '00000000-0000-0000-0000-000000000000'),
|
||||||
|
filterTable()
|
||||||
|
"
|
||||||
|
class="cursor-pointer"
|
||||||
|
/> </template
|
||||||
|
></q-select>
|
||||||
<q-select
|
<q-select
|
||||||
outlined
|
outlined
|
||||||
dense
|
dense
|
||||||
v-model="status"
|
v-model="leaveStore.status"
|
||||||
:label="`${'สถานะ'}`"
|
:label="`${'สถานะ'}`"
|
||||||
emit-value
|
emit-value
|
||||||
map-options
|
map-options
|
||||||
|
|
@ -179,8 +198,18 @@ watch([() => currentPage.value, () => pagination.value.rowsPerPage], () => {
|
||||||
<q-item>
|
<q-item>
|
||||||
<q-item-section class="text-grey"> ไม่มีข้อมูล </q-item-section>
|
<q-item-section class="text-grey"> ไม่มีข้อมูล </q-item-section>
|
||||||
</q-item>
|
</q-item>
|
||||||
</template></q-select
|
</template>
|
||||||
>
|
<template v-if="leaveStore.status !== 'ALL'" v-slot:append>
|
||||||
|
<q-icon
|
||||||
|
name="cancel"
|
||||||
|
@click.stop.prevent="
|
||||||
|
(leaveStore.statusOptions = leaveStore.statusOptionsMain),
|
||||||
|
(leaveStore.status = 'ALL'),
|
||||||
|
filterTable()
|
||||||
|
"
|
||||||
|
class="cursor-pointer"
|
||||||
|
/> </template
|
||||||
|
></q-select>
|
||||||
<q-space />
|
<q-space />
|
||||||
|
|
||||||
<!-- แสดงคอลัมน์ใน table -->
|
<!-- แสดงคอลัมน์ใน table -->
|
||||||
|
|
@ -209,7 +238,6 @@ watch([() => currentPage.value, () => pagination.value.rowsPerPage], () => {
|
||||||
ref="table"
|
ref="table"
|
||||||
flat
|
flat
|
||||||
bordered
|
bordered
|
||||||
|
|
||||||
v-bind="attrs"
|
v-bind="attrs"
|
||||||
virtual-scroll
|
virtual-scroll
|
||||||
:virtual-scroll-sticky-size-start="48"
|
:virtual-scroll-sticky-size-start="48"
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,8 @@ import { useCounterMixin } from "@/stores/mixin"
|
||||||
const mixin = useCounterMixin()
|
const mixin = useCounterMixin()
|
||||||
const { date2Thai, messageError } = mixin
|
const { date2Thai, messageError } = mixin
|
||||||
const $q = useQuasar()
|
const $q = useQuasar()
|
||||||
|
const type = ref<string>("00000000-0000-0000-0000-000000000000");
|
||||||
|
const status = ref<string>("ALL");
|
||||||
export const useLeaveStore = defineStore("Leave", () => {
|
export const useLeaveStore = defineStore("Leave", () => {
|
||||||
const tabValue = ref<string>("calendar")
|
const tabValue = ref<string>("calendar")
|
||||||
const typeLeave = ref<string | undefined>("")
|
const typeLeave = ref<string | undefined>("")
|
||||||
|
|
@ -113,11 +114,13 @@ export const useLeaveStore = defineStore("Leave", () => {
|
||||||
function filterOption(val: any, update: Function, refData: string) {
|
function filterOption(val: any, update: Function, refData: string) {
|
||||||
switch (refData) {
|
switch (refData) {
|
||||||
case "LeaveTypeOption":
|
case "LeaveTypeOption":
|
||||||
|
type.value = ''
|
||||||
update(() => {
|
update(() => {
|
||||||
typeOptions.value = typeOptionsMain.value.filter((v: any) => v.name.indexOf(val) > -1)
|
typeOptions.value = typeOptionsMain.value.filter((v: any) => v.name.indexOf(val) > -1)
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
case "LeaveStatusOption":
|
case "LeaveStatusOption":
|
||||||
|
status.value = ''
|
||||||
update(() => {
|
update(() => {
|
||||||
statusOptions.value = statusOptionsMain.value.filter((v: any) => v.name.indexOf(val) > -1)
|
statusOptions.value = statusOptionsMain.value.filter((v: any) => v.name.indexOf(val) > -1)
|
||||||
})
|
})
|
||||||
|
|
@ -389,5 +392,9 @@ export const useLeaveStore = defineStore("Leave", () => {
|
||||||
convertStatud,
|
convertStatud,
|
||||||
resetForm2,
|
resetForm2,
|
||||||
fetchProfileOld,
|
fetchProfileOld,
|
||||||
|
type,
|
||||||
|
typeOptionsMain,
|
||||||
|
status,
|
||||||
|
statusOptionsMain
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,20 @@ function onSubmit(postData: FormData, isLeave: boolean = true) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const option = ref<any[]>(dataStore.options);
|
||||||
|
/**
|
||||||
|
* function ค้นหาข้อมูลใน option
|
||||||
|
* @param val คำค้นหา
|
||||||
|
* @param update function
|
||||||
|
*/
|
||||||
|
function filterOptionFn(val: string, update: Function) {
|
||||||
|
update(() => {
|
||||||
|
option.value = dataStore.options.filter(
|
||||||
|
(e: any) => e.name.search(val) !== -1
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (dataStore.options.length == 0) {
|
if (dataStore.options.length == 0) {
|
||||||
await fectOptionType();
|
await fectOptionType();
|
||||||
|
|
@ -103,7 +117,7 @@ onMounted(async () => {
|
||||||
<div>สร้างใบลา</div>
|
<div>สร้างใบลา</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<q-form ref="myform" >
|
<q-form ref="myform">
|
||||||
<q-card bordered>
|
<q-card bordered>
|
||||||
<div class="row q-col-gutter-md q-pa-md">
|
<div class="row q-col-gutter-md q-pa-md">
|
||||||
<div class="col-xs-12 col-sm-12">
|
<div class="col-xs-12 col-sm-12">
|
||||||
|
|
@ -124,7 +138,7 @@ onMounted(async () => {
|
||||||
class="col-12 col-sm-6 col-md-4 inputgreen"
|
class="col-12 col-sm-6 col-md-4 inputgreen"
|
||||||
outlined
|
outlined
|
||||||
v-model="model"
|
v-model="model"
|
||||||
:options="dataStore.options"
|
:options="option"
|
||||||
option-value="code"
|
option-value="code"
|
||||||
option-label="name"
|
option-label="name"
|
||||||
emit-value
|
emit-value
|
||||||
|
|
@ -135,7 +149,16 @@ onMounted(async () => {
|
||||||
(modelSpecific = ''),
|
(modelSpecific = ''),
|
||||||
dataStore.fetchProfile()
|
dataStore.fetchProfile()
|
||||||
"
|
"
|
||||||
/>
|
use-input
|
||||||
|
@filter="filterOptionFn"
|
||||||
|
>
|
||||||
|
<template v-slot:no-option>
|
||||||
|
<q-item>
|
||||||
|
<q-item-section class="text-grey">
|
||||||
|
ไม่มีข้อมูล
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</template></q-select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row q-mt-sm">
|
<div class="row q-mt-sm">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue