ปรับแก้ไข เปลี่ยนแปลงรอบ
This commit is contained in:
parent
9100062af6
commit
ea614b07c2
3 changed files with 106 additions and 39 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, watch, onMounted } from "vue";
|
import { ref, reactive, watch, onMounted } from "vue";
|
||||||
import { useQuasar } from "quasar";
|
import { date, useQuasar } from "quasar";
|
||||||
import http from "@/plugins/http";
|
import http from "@/plugins/http";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
import { useRoute } from "vue-router";
|
import { useRoute } from "vue-router";
|
||||||
|
|
@ -29,23 +29,31 @@ const {
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
const profileId = ref<string>(
|
|
||||||
route.params.id ? route.params.id.toString() : ""
|
|
||||||
);
|
|
||||||
const roundRef = ref<Object | null>(null);
|
|
||||||
const resonRef = ref<Object | null>(null);
|
|
||||||
const effectiveDateRef = ref<Object | null>(null);
|
|
||||||
|
|
||||||
const roundOp = ref<any>([]);
|
const roundOp = ref<any>([]);
|
||||||
const objectRoundChange: MyObjectRoundChangeRef = {
|
|
||||||
round: roundRef,
|
|
||||||
effectiveDate: effectiveDateRef,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
/**Hook */
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await fetchDataOption();
|
await fetchDataOption();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**FormData */
|
||||||
|
const formData = reactive<changeRoundEdit>({
|
||||||
|
round: "",
|
||||||
|
date: "",
|
||||||
|
reson: "",
|
||||||
|
effectiveDate: null,
|
||||||
|
});
|
||||||
|
|
||||||
|
/**Validate ข้อมูล */
|
||||||
|
const roundRef = ref<Object | null>(null);
|
||||||
|
const resonRef = ref<Object | null>(null);
|
||||||
|
const effectiveDateRef = ref<Object | null>(null);
|
||||||
|
const objectRoundChange: MyObjectRoundChangeRef = {
|
||||||
|
round: roundRef,
|
||||||
|
effectiveDate: effectiveDateRef,
|
||||||
|
reson: resonRef,
|
||||||
|
};
|
||||||
|
|
||||||
/** Function validateForm */
|
/** Function validateForm */
|
||||||
function validateForm() {
|
function validateForm() {
|
||||||
const hasError = [];
|
const hasError = [];
|
||||||
|
|
@ -64,13 +72,7 @@ function validateForm() {
|
||||||
console.log(hasError);
|
console.log(hasError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const dataToday = ref<Date>(new Date());
|
||||||
const formData = reactive<changeRoundEdit>({
|
|
||||||
round: "",
|
|
||||||
date: "",
|
|
||||||
reson: "",
|
|
||||||
effectiveDate: null,
|
|
||||||
});
|
|
||||||
|
|
||||||
/** Function ยืนยันการบันทึกข้อมูล */
|
/** Function ยืนยันการบันทึกข้อมูล */
|
||||||
function onSubmit() {
|
function onSubmit() {
|
||||||
|
|
@ -133,6 +135,45 @@ async function fetchDataOption() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// paging
|
||||||
|
const page = ref<number>(1);
|
||||||
|
const pageSize = ref<number>(10);
|
||||||
|
const filter = ref<string>(""); //search data table
|
||||||
|
/**
|
||||||
|
* ฟังก์ชั่น api เปลี่ยนหน้า
|
||||||
|
* @param pageVal page
|
||||||
|
* @param pageSizeVal pagesize
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Pagination - initial pagination
|
||||||
|
const initialPagination = ref<any>({
|
||||||
|
sortBy: null,
|
||||||
|
descending: false,
|
||||||
|
page: 1,
|
||||||
|
rowsPerPage: pageSize, // set ตาม page หลักส่งมา
|
||||||
|
});
|
||||||
|
|
||||||
|
// Pagination - page & change page & get new data
|
||||||
|
const currentPage = ref<number>(1);
|
||||||
|
watch(
|
||||||
|
[() => currentPage.value, () => initialPagination.value.rowsPerPage],
|
||||||
|
() => {
|
||||||
|
emit(
|
||||||
|
"update:change-page",
|
||||||
|
currentPage.value,
|
||||||
|
initialPagination.value.rowsPerPage,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const emit = defineEmits(["update:change-page"]);
|
||||||
|
// Pagination - update rowsPerPage
|
||||||
|
async function updatePagination(newPagination: any) {
|
||||||
|
initialPagination.value = newPagination;
|
||||||
|
currentPage.value = 1; // set current page เป็น 1 เสมอเมื่อเปลี่ยน per row
|
||||||
|
}
|
||||||
|
|
||||||
|
/**Props */
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modal: Boolean,
|
modal: Boolean,
|
||||||
closeDialog: Function,
|
closeDialog: Function,
|
||||||
|
|
@ -141,6 +182,7 @@ const props = defineProps({
|
||||||
personId: String,
|
personId: String,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**ฟังก์ชั่น ปิดไดอาล็อก */
|
||||||
function close() {
|
function close() {
|
||||||
if (props.closeDialog) {
|
if (props.closeDialog) {
|
||||||
props.closeDialog();
|
props.closeDialog();
|
||||||
|
|
@ -228,6 +270,11 @@ watch(
|
||||||
borderless
|
borderless
|
||||||
:enableTimePicker="false"
|
:enableTimePicker="false"
|
||||||
week-start="0"
|
week-start="0"
|
||||||
|
:min-date="
|
||||||
|
dataToday
|
||||||
|
? new Date(dataToday.getTime() + 24 * 60 * 60 * 1000)
|
||||||
|
: null
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<template #year="{ year }">
|
<template #year="{ year }">
|
||||||
{{ year + 543 }}
|
{{ year + 543 }}
|
||||||
|
|
@ -270,10 +317,12 @@ watch(
|
||||||
class="col-12 bg-white"
|
class="col-12 bg-white"
|
||||||
outlined
|
outlined
|
||||||
stack-label
|
stack-label
|
||||||
|
ref="resonRef"
|
||||||
v-model="formData.reson"
|
v-model="formData.reson"
|
||||||
label="เหตุผล"
|
label="เหตุผล"
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
type="textarea"
|
type="textarea"
|
||||||
|
:rules="[(val) => !!val || `กรุณากรอกเหตุผล`]"
|
||||||
></q-input>
|
></q-input>
|
||||||
</div>
|
</div>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
|
|
@ -306,8 +355,23 @@ watch(
|
||||||
dense
|
dense
|
||||||
class="custom-header-table"
|
class="custom-header-table"
|
||||||
:visible-columns="dataStore.visibleColumnsHistory"
|
:visible-columns="dataStore.visibleColumnsHistory"
|
||||||
:rows-per-page-options="[10, 25, 50, 100]"
|
:rows-per-page-options="[5, 10, 25, 50, 100]"
|
||||||
|
:pagination="initialPagination"
|
||||||
|
@update:pagination="updatePagination"
|
||||||
>
|
>
|
||||||
|
<template v-slot:pagination="scope">
|
||||||
|
ทั้งหมด {{ dataStore.total }} รายการ
|
||||||
|
<q-pagination
|
||||||
|
v-model="currentPage"
|
||||||
|
active-color="primary"
|
||||||
|
color="dark"
|
||||||
|
:max-pages="5"
|
||||||
|
size="sm"
|
||||||
|
boundary-links
|
||||||
|
direction-links
|
||||||
|
:max="Number(dataStore.maxPage)"
|
||||||
|
></q-pagination>
|
||||||
|
</template>
|
||||||
<template v-slot:header="props">
|
<template v-slot:header="props">
|
||||||
<q-tr :props="props">
|
<q-tr :props="props">
|
||||||
<q-th
|
<q-th
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ export const useChangeRoundDataStore = defineStore(
|
||||||
roundStart: e.startTimeMorning,
|
roundStart: e.startTimeMorning,
|
||||||
roundEnd: e.leaveTimeAfterNoon,
|
roundEnd: e.leaveTimeAfterNoon,
|
||||||
currentRound: `${e.startTimeMorning}-${e.leaveTimeAfterNoon}`,
|
currentRound: `${e.startTimeMorning}-${e.leaveTimeAfterNoon}`,
|
||||||
effectiveDate: date2Thai(e.effectiveDate),
|
effectiveDate: date2Thai(e.effectiveDate) ?? "-",
|
||||||
}));
|
}));
|
||||||
console.log(profileId.value);
|
console.log(profileId.value);
|
||||||
console.log(apiData.length);
|
console.log(apiData.length);
|
||||||
|
|
@ -171,7 +171,9 @@ export const useChangeRoundDataStore = defineStore(
|
||||||
const rowsHistory = ref<historyShow[]>([]);
|
const rowsHistory = ref<historyShow[]>([]);
|
||||||
// paging
|
// paging
|
||||||
const page = ref<number>(1);
|
const page = ref<number>(1);
|
||||||
|
const total = ref<number>(0);
|
||||||
const pageSize = ref<number>(10);
|
const pageSize = ref<number>(10);
|
||||||
|
const maxPage = ref<number>(0);
|
||||||
const filter = ref<string>(""); //search data table
|
const filter = ref<string>(""); //search data table
|
||||||
/**
|
/**
|
||||||
* ฟังก์ชั่น api เปลี่ยนหน้า
|
* ฟังก์ชั่น api เปลี่ยนหน้า
|
||||||
|
|
@ -183,19 +185,19 @@ export const useChangeRoundDataStore = defineStore(
|
||||||
pageSize.value = await pageSizeVal;
|
pageSize.value = await pageSizeVal;
|
||||||
fetchDatainHistory();
|
fetchDatainHistory();
|
||||||
}
|
}
|
||||||
|
/**ฟังก์ชั่นดึงดาต้าประวัติ */
|
||||||
async function fetchDatainHistory() {
|
async function fetchDatainHistory() {
|
||||||
console.log(profileId.value);
|
console.log(profileId.value);
|
||||||
showLoader();
|
showLoader();
|
||||||
await http
|
await http
|
||||||
.post(
|
.get(
|
||||||
config.API.leaveRoundById(profileId.value),
|
config.API.leaveRoundById(profileId.value) +
|
||||||
{
|
// {
|
||||||
page: page.value,
|
// page: page.value,
|
||||||
pageSize: pageSize.value,
|
// pageSize: pageSize.value,
|
||||||
keyword: filter.value,
|
// keyword: filter.value,
|
||||||
}
|
// }
|
||||||
// `?page=${page.value}&pageSize=${pageSize.value}&keyword=${filter.value}`
|
`?page=${page.value}&pageSize=${pageSize.value}&keyword=${filter.value}`
|
||||||
)
|
)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const dataHistory = res.data.result.data;
|
const dataHistory = res.data.result.data;
|
||||||
|
|
@ -209,7 +211,9 @@ export const useChangeRoundDataStore = defineStore(
|
||||||
effectiveDate: date2Thai(e.effectiveDate),
|
effectiveDate: date2Thai(e.effectiveDate),
|
||||||
reson: e.remark ?? "-",
|
reson: e.remark ?? "-",
|
||||||
});
|
});
|
||||||
console.log(rowsHistory.value);
|
total.value = res.data.result.total;
|
||||||
|
maxPage.value = Math.ceil(total.value / pageSize.value);
|
||||||
|
maxPage.value = maxPage.value < 1 ? 1 : maxPage.value;
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
|
@ -232,6 +236,8 @@ export const useChangeRoundDataStore = defineStore(
|
||||||
checkCilck,
|
checkCilck,
|
||||||
setProfileId,
|
setProfileId,
|
||||||
changePage,
|
changePage,
|
||||||
|
total,
|
||||||
|
maxPage,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -37,11 +37,13 @@ const formData = reactive<dataPost>({
|
||||||
function Openmodal(check: string, detail: any) {
|
function Openmodal(check: string, detail: any) {
|
||||||
DataRow.value = detail;
|
DataRow.value = detail;
|
||||||
modal.value = true;
|
modal.value = true;
|
||||||
console.log(DataRow.value.profileId);
|
|
||||||
dataStore.setProfileId(DataRow.value.profileId);
|
dataStore.setProfileId(DataRow.value.profileId);
|
||||||
console.log(DataRow.value.profileId);
|
|
||||||
editCheck.value = check;
|
editCheck.value = check;
|
||||||
dataStore.fetchDatainHistory();
|
if (check === "history") {
|
||||||
|
modal.value = true;
|
||||||
|
dataStore.fetchDatainHistory();
|
||||||
|
}
|
||||||
|
|
||||||
console.log(detail);
|
console.log(detail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -58,11 +60,6 @@ function searchData() {
|
||||||
dialogMessageNotify($q, "กรุณากรอกข้อมูลอย่างน้อย 1 ช่อง");
|
dialogMessageNotify($q, "กรุณากรอกข้อมูลอย่างน้อย 1 ช่อง");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Hook */
|
|
||||||
onMounted(() => {
|
|
||||||
// dataStore.fetchDatainHistory();
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="toptitle text-dark col-12 row items-center">
|
<div class="toptitle text-dark col-12 row items-center">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue