ปรับรายการลา

This commit is contained in:
setthawutttty 2025-03-27 10:47:56 +07:00
parent 72483b2d6d
commit 9e3ee0030d
6 changed files with 55 additions and 51 deletions

View file

@ -17,7 +17,7 @@ import CalendarView from "@/modules/09_leave/components/05_Leave/Calendar.vue";
const $q = useQuasar(); // noti quasar
const mixin = useCounterMixin();
const leaveStore = useLeavelistDataStore();
const dataToobar = ref<any[]>([]);
const { showLoader, hideLoader, messageError } = mixin;
const total = ref<number>(0);
@ -29,14 +29,16 @@ const querySting = reactive<QuerySting>({
status: leaveStore.filter.status, //*
page: 1, //*
pageSize: 10, //*
sortBy: "dateSendLeave",
descending: true,
keyword: leaveStore.filter.keyword, //keyword
profileType: 'ALL', //profileType
profileType: "ALL", //profileType
});
//** API*/
async function fecthLeaveList() {
leaveStore.rows = [];
querySting.keyword = querySting.keyword.trim()
querySting.keyword = querySting.keyword.trim();
querySting.status = await (querySting.status == null
? "ALL"
: querySting.status);
@ -67,14 +69,16 @@ async function fecthLeaveList() {
/** function เรียกข้อมูลสถานะ*/
async function fetchOption() {
await http
.get(config.API.leaveType())
.then((res) => {
dataToobar.value = res.data.result;
})
.catch((err) => {
messageError($q, err);
});
if (leaveStore.dataToobar.length == 0) {
await http
.get(config.API.leaveType())
.then((res) => {
leaveStore.leaveTypeOption(res.data.result);
})
.catch((err) => {
messageError($q, err);
});
}
}
function getSearch() {
@ -142,7 +146,7 @@ onMounted(async () => {
</q-toolbar>
<div v-if="leaveStore.tabView === 'list'">
<ToolBar
:dataToobar="dataToobar"
:dataToobar="leaveStore.dataToobar"
v-model:query-sting="querySting"
:get-list="fecthLeaveList"
:get-search="getSearch"
@ -151,7 +155,7 @@ onMounted(async () => {
v-model:total="total"
v-model:total-list="totalList"
v-model:pagination="querySting"
:dataToobar="dataToobar"
:dataToobar="leaveStore.dataToobar"
:getList="fecthLeaveList"
/>
</div>

View file

@ -20,7 +20,6 @@ const mixin = useCounterMixin();
const leaveStore = useLeavelistDataStore();
const { showLoader, hideLoader, messageError } = mixin;
const { fetchListLeaveReject } = leaveStore;
const dataToobar = ref<any[]>([]);
const $q = useQuasar(); // noti quasar
const total = ref<number>(0);
@ -32,13 +31,15 @@ const querySting = reactive<QuerySting>({
status: leaveStore.filter.status, //*
page: 1, //*
pageSize: 10, //*
sortBy: "dateSendLeave",
descending: true,
keyword: leaveStore.filter.keyword, //keyword
profileType: 'ALL', //profileType
profileType: "ALL", //profileType
});
//** API*/
async function fecthLeaveList() {
leaveStore.rows = [];
querySting.keyword = querySting.keyword.trim()
querySting.keyword = querySting.keyword.trim();
querySting.status = await (querySting.status == null
? "ALL"
: querySting.status);
@ -69,14 +70,16 @@ async function fecthLeaveList() {
/** function เรียกข้อมูลสถานะ*/
async function fetchOption() {
await http
.get(config.API.leaveType())
.then((res) => {
dataToobar.value = res.data.result;
})
.catch((err) => {
messageError($q, err);
});
if (leaveStore.dataToobar.length == 0) {
await http
.get(config.API.leaveType())
.then((res) => {
leaveStore.leaveTypeOption(res.data.result);
})
.catch((err) => {
messageError($q, err);
});
}
}
function getSearch() {
@ -97,7 +100,7 @@ onMounted(async () => {
</script>
<template>
<ToolBar
:dataToobar="dataToobar"
:dataToobar="leaveStore.dataToobar"
v-model:query-sting="querySting"
:get-list="fecthLeaveList"
:get-search="getSearch"
@ -106,7 +109,7 @@ onMounted(async () => {
v-model:total="total"
v-model:total-list="totalList"
v-model:pagination="querySting"
:dataToobar="dataToobar"
:dataToobar="leaveStore.dataToobar"
:getList="fecthLeaveList"
/>
</template>

View file

@ -280,6 +280,7 @@ onMounted(() => {
:paging="true"
dense
class="custom-header-table"
v-model:pagination="pagination"
:visible-columns="leaveStore.visibleColumns"
:rows-per-page-options="[10, 25, 50, 100]"
@update:pagination="updatePagination"

View file

@ -86,7 +86,8 @@ function filterOption(val: string, update: any, name: string) {
update(() => {
const needle = val.toLowerCase();
if (name === "type") {
optionType.value = optionTypeMain.value.filter(
const dataOp = leaveStore.dataToobar;
optionType.value = dataOp.filter(
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
);
} else if (name === "status") {
@ -108,27 +109,6 @@ function filterOptionFn(val: string, update: Function) {
roleOp.value = data.filter((e: any) => e.name.search(val) !== -1);
});
}
watch(
async () => props.dataToobar,
() => {
if (props.dataToobar) {
const data = props.dataToobar;
leaveStore.leaveType = data;
optionTypeMain.value = [
{ id: "00000000-0000-0000-0000-000000000000", name: "ทั้งหมด" },
];
const option = data.map((e: any) => ({
id: e.id,
name: e.name,
}));
optionTypeMain.value.push(...option);
optionType.value = optionTypeMain.value;
}
}
);
</script>
<template>
@ -212,12 +192,16 @@ watch(
hide-selected
fill-input
dense
v-model="querySting.type"
:model-value="
querySting.type == '00000000-0000-0000-0000-000000000000'
? 'ทั้งหมด'
: querySting.type
"
:options="optionType"
option-value="id"
option-label="name"
label="ประเภทการลา"
@update:model-value="props.getSearch?.()"
@update:model-value="(value:any)=>(querySting.type = value,props.getSearch?.())"
use-input
@filter="
(inputValue:any, doneFn:Function) =>

View file

@ -13,6 +13,8 @@ interface QuerySting {
pageSize: number; //*จำนวนแถวต่อหน้า
keyword: string; //keyword ค้นหา
profileType: string;
sortBy?: string;
descending?: boolean;
}
interface DateFilter {

View file

@ -15,6 +15,7 @@ const mixin = useCounterMixin();
const { date2Thai } = mixin;
export const useLeavelistDataStore = defineStore("leave", () => {
const dataToobar = ref<any[]>([]);
/** ข้อมูล Main*/
const tabMenu = ref<string>("1");
@ -79,7 +80,7 @@ export const useLeavelistDataStore = defineStore("leave", () => {
async function fetchListLeaveReject(data: any[]) {
let datalist = data.map((e: FremData) => ({
id: e.id,
profileType: e.profileType ?? '-',
profileType: e.profileType ?? "-",
leaveTypeName: e.leaveTypeName,
leaveTypeId: e.leaveTypeId,
fullName: e.fullName,
@ -168,7 +169,15 @@ export const useLeavelistDataStore = defineStore("leave", () => {
}
}
function leaveTypeOption(val: any) {
dataToobar.value = val.map((e: any) => ({
id: e.id,
name: e.name,
}));
}
return {
dataToobar,
tabMenu,
filter,
tabView,
@ -181,5 +190,6 @@ export const useLeavelistDataStore = defineStore("leave", () => {
convertLeaveDaytype,
leaveType,
colorType,
leaveTypeOption,
};
});