Refactoring code 09_leave

This commit is contained in:
STW_TTTY\stwtt 2024-09-18 17:26:53 +07:00
parent d20fdb0190
commit 94eb31fc26
27 changed files with 289 additions and 577 deletions

View file

@ -1,21 +1,20 @@
<script setup lang="ts">
import { ref, reactive, watch, onMounted } from "vue";
import { date, useQuasar } from "quasar";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import { useChangeRoundDataStore } from "@/modules/09_leave/stores/ChangeRoundStore";
/** importType */
import type {
changeRoundEdit,
MyObjectRoundChangeRef,
DataOption,
} from "@/modules/09_leave/interface/request/changeRound";
/** importStore */
import { useCounterMixin } from "@/stores/mixin";
import { useChangeRoundDataStore } from "@/modules/09_leave/stores/ChangeRoundStore";
/** useStore */
const $q = useQuasar();
const dataStore = useChangeRoundDataStore();
const mixin = useCounterMixin();
const {
@ -27,11 +26,15 @@ const {
success,
} = mixin;
const $q = useQuasar();
const emit = defineEmits(["update:change-page"]);
/**Hook */
onMounted(async () => {
// await fetchDataOption();
/**Props */
const props = defineProps({
modal: Boolean,
closeDialog: Function,
editCheck: String,
DataRow: Object,
personId: String,
});
/**FormData */
@ -52,6 +55,31 @@ const objectRoundChange: MyObjectRoundChangeRef = {
reson: resonRef,
};
const dataToday = ref<Date>(new Date());
const pageSize = ref<number>(10);
/**
* งก 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);
const roundOp = ref<any>([]);
async function updatePagination(newPagination: any) {
initialPagination.value = newPagination;
currentPage.value = 1; // set current page 1 per row
}
/** Function validateForm */
function validateForm() {
const hasError = [];
@ -68,7 +96,6 @@ function validateForm() {
onSubmit();
}
}
const dataToday = ref<Date>(new Date());
/** Function ยืนยันการบันทึกข้อมูล */
function onSubmit() {
@ -103,7 +130,6 @@ async function changeRound() {
});
}
const roundOp = ref<any>([]);
/**
*ประวการเปลยนรอบการปฏงาน"
*
@ -134,25 +160,13 @@ async function fetchDataOption() {
});
}
// paging
const pageSize = ref<number>(10);
/**ฟังก์ชั่น ปิดไดอาล็อก */
function close() {
if (props.closeDialog) {
props.closeDialog();
}
}
/**
* งก 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],
() => {
@ -164,27 +178,7 @@ watch(
);
}
);
const emit = defineEmits(["update:change-page"]);
async function updatePagination(newPagination: any) {
initialPagination.value = newPagination;
currentPage.value = 1; // set current page 1 per row
}
/**Props */
const props = defineProps({
modal: Boolean,
closeDialog: Function,
editCheck: String,
DataRow: Object,
personId: String,
});
/**ฟังก์ชั่น ปิดไดอาล็อก */
function close() {
if (props.closeDialog) {
props.closeDialog();
}
}
watch(
() => props.modal,
async () => {