เพิ่ม API รายการลา และ รายการขอยกเลิกการลา
This commit is contained in:
parent
b78b1c99c0
commit
f79335d5b9
5 changed files with 89 additions and 53 deletions
|
|
@ -20,5 +20,6 @@ export default {
|
||||||
/** รายการลา*/
|
/** รายการลา*/
|
||||||
leaveType: () => `${leave}/type`,
|
leaveType: () => `${leave}/type`,
|
||||||
leaveList: () => `${leave}/admin`,
|
leaveList: () => `${leave}/admin`,
|
||||||
|
leaveListDelete: () => `${leave}/admin/delete`,
|
||||||
leaveListById: (id: string) => `${leave}/admin/${id}`,
|
leaveListById: (id: string) => `${leave}/admin/${id}`,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, onMounted } from "vue";
|
import { ref, reactive, onMounted } from "vue";
|
||||||
|
import { useQuasar } from "quasar";
|
||||||
|
import http from "@/plugins/http";
|
||||||
|
import config from "@/app.config";
|
||||||
|
|
||||||
/**importType*/
|
/**importType*/
|
||||||
import type {
|
import type {
|
||||||
|
|
@ -12,19 +15,17 @@ import ToolBar from "@/modules/09_leave/components/2_Leave/ToolBarLeave.vue";
|
||||||
import CalendarView from "@/modules/09_leave/components/2_Leave/Calendar.vue";
|
import CalendarView from "@/modules/09_leave/components/2_Leave/Calendar.vue";
|
||||||
|
|
||||||
/**importStroe*/
|
/**importStroe*/
|
||||||
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
import { useLeavelistDataStore } from "@/modules/09_leave/stores/LeaveStore";
|
import { useLeavelistDataStore } from "@/modules/09_leave/stores/LeaveStore";
|
||||||
import { useLeavelistDataStoreTest } from "@/modules/09_leave/stores/ListLeave";
|
import { useLeavelistDataStoreTest } from "@/modules/09_leave/stores/ListLeave";
|
||||||
|
|
||||||
|
const mixin = useCounterMixin();
|
||||||
const leaveStore = useLeavelistDataStore();
|
const leaveStore = useLeavelistDataStore();
|
||||||
const APIDATA = useLeavelistDataStoreTest();
|
const APIDATA = useLeavelistDataStoreTest();
|
||||||
|
const { date2Thai, dateToISO, showLoader, hideLoader, messageError } = mixin;
|
||||||
const { fetchListLeave } = leaveStore;
|
const { fetchListLeave } = leaveStore;
|
||||||
|
|
||||||
//** เรียกข้อมูลจาก API*/
|
const $q = useQuasar(); //ใช้ noti quasar
|
||||||
function fecthLeaveList() {
|
|
||||||
const data = APIDATA.data;
|
|
||||||
maxPage.value = Math.ceil(data.length / querySting.pageSize);
|
|
||||||
fetchListLeave(data); /** ส่งข้อมูลไป stores*/
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
const querySting = reactive<QuerySting>({
|
const querySting = reactive<QuerySting>({
|
||||||
|
|
@ -37,13 +38,34 @@ const querySting = reactive<QuerySting>({
|
||||||
});
|
});
|
||||||
const maxPage = ref<number>(1);
|
const maxPage = ref<number>(1);
|
||||||
|
|
||||||
|
//** เรียกข้อมูลจาก API*/
|
||||||
|
async function fecthLeaveList() {
|
||||||
|
// showLoader();
|
||||||
|
// await http
|
||||||
|
// .post(config.API.leaveList(), querySting)
|
||||||
|
// .then((res) => {
|
||||||
|
// console.log(res);
|
||||||
|
|
||||||
|
// maxPage.value = Math.ceil(data.length / querySting.pageSize);
|
||||||
|
// })
|
||||||
|
// .catch((err) => {
|
||||||
|
// messageError($q, err);
|
||||||
|
// })
|
||||||
|
// .finally(() => {
|
||||||
|
// hideLoader();
|
||||||
|
// });
|
||||||
|
const data = APIDATA.data;
|
||||||
|
maxPage.value = Math.ceil(data.length / querySting.pageSize);
|
||||||
|
fetchListLeave(data); /** ส่งข้อมูลไป stores*/
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param newPage หน้า
|
* @param newPage หน้า
|
||||||
* @param pageSize จำนวนต่อแถว
|
* @param pageSize จำนวนต่อแถว
|
||||||
* @param dateFilter ข้อมูลค้นหา
|
* @param dateFilter ข้อมูลค้นหา
|
||||||
*/
|
*/
|
||||||
function updatePaging(
|
async function updatePaging(
|
||||||
newPage: number,
|
newPage: number,
|
||||||
pageSize: number,
|
pageSize: number,
|
||||||
dateFilter: DateFilter
|
dateFilter: DateFilter
|
||||||
|
|
@ -52,9 +74,10 @@ function updatePaging(
|
||||||
querySting.type = dateFilter ? dateFilter.type : querySting.type;
|
querySting.type = dateFilter ? dateFilter.type : querySting.type;
|
||||||
querySting.status = dateFilter ? dateFilter.status : querySting.status;
|
querySting.status = dateFilter ? dateFilter.status : querySting.status;
|
||||||
querySting.page = newPage;
|
querySting.page = newPage;
|
||||||
querySting.pageSize = pageSize;
|
querySting.pageSize = pageSize ? pageSize : querySting.pageSize;
|
||||||
querySting.keyword = dateFilter ? dateFilter.keyword : querySting.keyword;
|
querySting.keyword = dateFilter ? dateFilter.keyword : querySting.keyword;
|
||||||
console.log(querySting);
|
console.log(querySting);
|
||||||
|
await fecthLeaveList();
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, onMounted } from "vue";
|
import { ref, reactive, onMounted } from "vue";
|
||||||
|
import { useQuasar } from "quasar";
|
||||||
|
import http from "@/plugins/http";
|
||||||
|
import config from "@/app.config";
|
||||||
|
|
||||||
/**importType*/
|
/**importType*/
|
||||||
import type {
|
import type {
|
||||||
|
|
@ -11,15 +14,20 @@ import TableList from "@/modules/09_leave/components/2_Leave/TableList.vue";
|
||||||
import ToolBar from "@/modules/09_leave/components/2_Leave/ToolBarLeave.vue";
|
import ToolBar from "@/modules/09_leave/components/2_Leave/ToolBarLeave.vue";
|
||||||
|
|
||||||
/**importStroe*/
|
/**importStroe*/
|
||||||
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
import { useLeavelistDataStore } from "@/modules/09_leave/stores/LeaveStore";
|
import { useLeavelistDataStore } from "@/modules/09_leave/stores/LeaveStore";
|
||||||
import { useLeavelistDataStoreTest } from "@/modules/09_leave/stores/ListLeave";
|
import { useLeavelistDataStoreTest } from "@/modules/09_leave/stores/ListLeave";
|
||||||
|
|
||||||
|
const mixin = useCounterMixin();
|
||||||
const leaveStore = useLeavelistDataStore();
|
const leaveStore = useLeavelistDataStore();
|
||||||
const APIDATA = useLeavelistDataStoreTest();
|
const APIDATA = useLeavelistDataStoreTest();
|
||||||
|
const { date2Thai, dateToISO, showLoader, hideLoader, messageError } = mixin;
|
||||||
const { fetchListLeaveReject } = leaveStore;
|
const { fetchListLeaveReject } = leaveStore;
|
||||||
|
|
||||||
|
const $q = useQuasar(); //ใช้ noti quasar
|
||||||
|
|
||||||
const querySting = reactive<QuerySting>({
|
const querySting = reactive<QuerySting>({
|
||||||
year: 0, //*ปีในการยื่นขอใบลา(ใช้เป็น คศ.)
|
year: new Date().getFullYear(), //*ปีในการยื่นขอใบลา(ใช้เป็น คศ.)
|
||||||
type: "00000000-0000-0000-0000-000000000000", //*Id ประเภทการลา
|
type: "00000000-0000-0000-0000-000000000000", //*Id ประเภทการลา
|
||||||
status: "ALL", //*สถานะการของลา
|
status: "ALL", //*สถานะการของลา
|
||||||
page: 1, //*หน้า
|
page: 1, //*หน้า
|
||||||
|
|
@ -29,9 +37,23 @@ const querySting = reactive<QuerySting>({
|
||||||
const maxPage = ref<number>(1);
|
const maxPage = ref<number>(1);
|
||||||
|
|
||||||
//** เรียกข้อมูลจาก API*/
|
//** เรียกข้อมูลจาก API*/
|
||||||
function fecthLeaveList() {
|
async function fecthLeaveList() {
|
||||||
|
// showLoader();
|
||||||
|
// await http
|
||||||
|
// .post(config.API.leaveListDelete(), querySting)
|
||||||
|
// .then((res) => {
|
||||||
|
// console.log(res);
|
||||||
|
|
||||||
|
// maxPage.value = Math.ceil(data.length / querySting.pageSize);
|
||||||
|
// })
|
||||||
|
// .catch((err) => {
|
||||||
|
// messageError($q, err);
|
||||||
|
// })
|
||||||
|
// .finally(() => {
|
||||||
|
// hideLoader();
|
||||||
|
// });
|
||||||
const data = APIDATA.data;
|
const data = APIDATA.data;
|
||||||
maxPage.value = Math.ceil(data.length / querySting.pageSize);
|
|
||||||
fetchListLeaveReject(data); /** ส่งข้อมูลไป stores*/
|
fetchListLeaveReject(data); /** ส่งข้อมูลไป stores*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -41,7 +63,7 @@ function fecthLeaveList() {
|
||||||
* @param pageSize จำนวนต่อแถว
|
* @param pageSize จำนวนต่อแถว
|
||||||
* @param dateFilter ข้อมูลค้นหา
|
* @param dateFilter ข้อมูลค้นหา
|
||||||
*/
|
*/
|
||||||
function updatePaging(
|
async function updatePaging(
|
||||||
newPage: number,
|
newPage: number,
|
||||||
pageSize: number,
|
pageSize: number,
|
||||||
dateFilter: DateFilter
|
dateFilter: DateFilter
|
||||||
|
|
@ -54,6 +76,7 @@ function updatePaging(
|
||||||
querySting.keyword = dateFilter ? dateFilter.keyword : querySting.keyword;
|
querySting.keyword = dateFilter ? dateFilter.keyword : querySting.keyword;
|
||||||
|
|
||||||
console.log(querySting);
|
console.log(querySting);
|
||||||
|
await fecthLeaveList();
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
|
|
||||||
|
|
@ -163,8 +163,12 @@ function redirectToDetail(id: string) {
|
||||||
router.push(`${routePrefix}/detail/${id}`);
|
router.push(`${routePrefix}/detail/${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updatedPagination(newPageZize: any) {
|
||||||
|
currentPage.value = 1;
|
||||||
|
pagination.value.rowsPerPage = newPageZize.rowsPerPage;
|
||||||
|
}
|
||||||
|
|
||||||
watch([() => currentPage.value, () => pagination.value.rowsPerPage], () => {
|
watch([() => currentPage.value, () => pagination.value.rowsPerPage], () => {
|
||||||
// updateProp(pagination.value, currentPage.value);
|
|
||||||
currentPage.value &&
|
currentPage.value &&
|
||||||
pagination.value.rowsPerPage &&
|
pagination.value.rowsPerPage &&
|
||||||
updateQuerySting(currentPage.value, pagination.value.rowsPerPage);
|
updateQuerySting(currentPage.value, pagination.value.rowsPerPage);
|
||||||
|
|
@ -172,7 +176,6 @@ watch([() => currentPage.value, () => pagination.value.rowsPerPage], () => {
|
||||||
|
|
||||||
/** Hook*/
|
/** Hook*/
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
console.log(leaveStore.tabMenu);
|
|
||||||
if (leaveStore.tabMenu === "1") {
|
if (leaveStore.tabMenu === "1") {
|
||||||
leaveStore.visibleColumns = visibleColumnsLeave.value;
|
leaveStore.visibleColumns = visibleColumnsLeave.value;
|
||||||
leaveStore.columns = columnsLeave.value;
|
leaveStore.columns = columnsLeave.value;
|
||||||
|
|
@ -195,7 +198,8 @@ onMounted(() => {
|
||||||
dense
|
dense
|
||||||
class="custom-header-table"
|
class="custom-header-table"
|
||||||
:visible-columns="leaveStore.visibleColumns"
|
:visible-columns="leaveStore.visibleColumns"
|
||||||
v-model:pagination="pagination"
|
:pagination="pagination"
|
||||||
|
@update:pagination="updatedPagination"
|
||||||
>
|
>
|
||||||
<template v-slot:header="props">
|
<template v-slot:header="props">
|
||||||
<q-tr :props="props">
|
<q-tr :props="props">
|
||||||
|
|
|
||||||
|
|
@ -47,20 +47,12 @@ function updateQuerySting(
|
||||||
|
|
||||||
/** function ค้นหาข้อมูลใน Table*/
|
/** function ค้นหาข้อมูลใน Table*/
|
||||||
async function filterListLeave() {
|
async function filterListLeave() {
|
||||||
console.log("test");
|
updateQuerySting(1, 0, filter);
|
||||||
|
|
||||||
// filter.status &&
|
|
||||||
// filter.type &&
|
|
||||||
// (await updateQuerySting(1, Number(props.rowsPerPage), filter));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Option*/
|
/** Option*/
|
||||||
const optionType = ref<DataOption[]>([
|
const optionTypeMain = ref<DataOption[]>([]);
|
||||||
{
|
const optionType = ref<DataOption[]>([]);
|
||||||
id: "00000000-0000-0000-0000-000000000000",
|
|
||||||
name: "ทั้งหมด",
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
const optionStatus = ref<DataOption[]>([
|
const optionStatus = ref<DataOption[]>([
|
||||||
{
|
{
|
||||||
id: "ALL",
|
id: "ALL",
|
||||||
|
|
@ -93,29 +85,37 @@ const optionStatus2 = ref<DataOption[]>([
|
||||||
name: "ขอยกเลิก",
|
name: "ขอยกเลิก",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "PENDING ",
|
id: "APPROVE ",
|
||||||
name: "อนุมัติ",
|
name: "อนุมัติ",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "APPROVE ",
|
id: "REJECT ",
|
||||||
name: "ไม่อนุมัติ",
|
name: "ไม่อนุมัติ",
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
const optionTypeMain = ref<DataOption[]>(optionType.value);
|
|
||||||
const optionStatusMain = ref<DataOption[]>(
|
const optionStatusMain = ref<DataOption[]>(
|
||||||
leaveStore.tabMenu == "1" ? optionStatus.value : optionStatus2.value
|
leaveStore.tabMenu == "1" ? optionStatus.value : optionStatus2.value
|
||||||
);
|
);
|
||||||
|
|
||||||
async function fetchOption() {
|
async function fetchOption() {
|
||||||
console.log("loadOption รอ API");
|
await http
|
||||||
// await http
|
.get(config.API.leaveType())
|
||||||
// .get(config.API.leaveType())
|
.then((res) => {
|
||||||
// .then((res) => {
|
const data = res.data.result;
|
||||||
// console.log(res);
|
optionTypeMain.value = [
|
||||||
// })
|
{ id: "00000000-0000-0000-0000-000000000000", name: "ทั้งหมด" },
|
||||||
// .catch((err) => {
|
];
|
||||||
// console.log(err);
|
const option = data.map((e: DataOption) => ({
|
||||||
// });
|
id: e.id,
|
||||||
|
name: e.name,
|
||||||
|
}));
|
||||||
|
optionTypeMain.value.push(...option);
|
||||||
|
optionType.value = optionTypeMain.value;
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -141,8 +141,6 @@ function filterOption(val: string, update: any, name: string) {
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await fetchOption();
|
await fetchOption();
|
||||||
// optionTypeMain.value =
|
|
||||||
// leaveStore.tabMenu == "1" ? optionStatus.value : optionStatus2.value;
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
@ -182,19 +180,6 @@ onMounted(async () => {
|
||||||
</q-input>
|
</q-input>
|
||||||
</template>
|
</template>
|
||||||
</datepicker>
|
</datepicker>
|
||||||
<!-- <q-select
|
|
||||||
for="selectYear"
|
|
||||||
emit-value
|
|
||||||
map-options
|
|
||||||
outlined
|
|
||||||
dense
|
|
||||||
v-model="filter.year"
|
|
||||||
:options="optionStatus"
|
|
||||||
option-value="id"
|
|
||||||
option-label="name"
|
|
||||||
label="ปีงบประมาณ"
|
|
||||||
@update:model-value="filterListLeave"
|
|
||||||
/> -->
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-12 col-sm-3 col-md-2">
|
<div class="col-xs-12 col-sm-3 col-md-2">
|
||||||
<q-select
|
<q-select
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue