Refactoring code module 06_retirement

This commit is contained in:
STW_TTTY\stwtt 2024-09-18 15:18:57 +07:00
parent 1225254062
commit ea921b39b0
29 changed files with 730 additions and 823 deletions

View file

@ -6,6 +6,7 @@ import { useCounterMixin } from "@/stores/mixin";
import { useQuasar } from "quasar";
import { useRoute } from "vue-router";
import type { PersonData } from "@/modules/06_retirement/interface/index/Main";
import DialogHeader from "@/components/DialogHeader.vue";
/** Use */
@ -36,7 +37,6 @@ const props = defineProps({
const modal = ref<boolean>(false);
const retireld = ref<any>();
const type = ref<any>();
const filter = ref<string>("");
/** คอลัมน์ */
const columns = ref<any["columns"]>([
@ -76,22 +76,7 @@ const columns = ref<any["columns"]>([
align: "left",
},
]);
const rows = ref<any[]>([]);
watch(modal, () => {
if (modal.value === true) {
retireld.value = props.retireld;
formPagePersonList.page = 1;
formPagePersonList.keyword = "";
if (props.dataProfile) {
if (props.dataProfile.type === "OFFICER") {
type.value = "officer";
} else type.value = "all";
}
fecthProfile();
}
});
const rows = ref<PersonData[]>([]);
function findOrgChildName(obj: any) {
if (obj) {
@ -134,7 +119,7 @@ const maxPage = ref<number>(1);
const totalList = ref<number>(0);
// fecth profile
const fecthProfile = async () => {
async function fecthProfile() {
showLoader();
if (props?.dataProfile?.type === "OFFICER") {
formPagePersonList.keyword =
@ -200,10 +185,10 @@ const fecthProfile = async () => {
hideLoader();
});
}
};
}
//
const clickAdd = (props: any) => {
function clickAdd(props: any) {
if (retireld.value == undefined) {
retireld.value = retireld_params;
}
@ -227,17 +212,22 @@ const clickAdd = (props: any) => {
"ยืนยันการเพิ่มข้อมูล",
"ต้องการเพิ่มข้อมูลนี้ใช่หรือไม่ ?"
);
};
}
// update retireld
const updateListData = (retireld: string, pId: string) => {
function updateListData(retireld: string, pId: string) {
props.UpdateListId(retireld, pId);
};
}
function updatePageSize(newPagination: any) {
formPagePersonList.page = 1;
formPagePersonList.pageSize = newPagination.rowsPerPage;
}
function closeDialog() {
modal.value = false;
}
watch(
() => formPagePersonList.pageSize,
() => {
@ -245,9 +235,20 @@ watch(
}
);
function closeDialog() {
modal.value = false;
}
watch(modal, () => {
if (modal.value === true) {
retireld.value = props.retireld;
formPagePersonList.page = 1;
formPagePersonList.keyword = "";
if (props.dataProfile) {
if (props.dataProfile.type === "OFFICER") {
type.value = "officer";
} else type.value = "all";
}
fecthProfile();
}
});
</script>
<template>
@ -357,18 +358,6 @@ function closeDialog() {
</div>
</div>
</q-card-section>
<!-- <q-toolbar class="q-py-md">
<q-toolbar-title class="text-h6">เพมรายช </q-toolbar-title>
<q-btn
icon="close"
unelevated
round
dense
@click="modal = false"
style="color: #ff8080; background-color: #ffdede"
/>
</q-toolbar>
-->
</q-card>
</q-dialog>
</template>

View file

@ -9,6 +9,8 @@ import config from "@/app.config";
import genReport from "@/plugins/genreport";
import { useCounterMixin } from "@/stores/mixin";
import type { RetirementList } from "@/modules/06_retirement/interface/index/Main";
import DialogHeader from "@/components/DialogHeader.vue";
import DialogPopupReason from "@/components/Dialogs/PopupReason.vue";
import PopupPersonal from "@/components/Dialogs/PopupPersonalNew.vue";
@ -55,7 +57,7 @@ const dataProfile = ref<Object>([]);
/** คอลัมน์ที่แสดง */
const columns = ref<any["columns"]>([]);
const rows = ref<any[]>([]);
const rows = ref<RetirementList[]>([]);
const visibleColumns = ref<string[]>([
"order",
"name",
@ -71,13 +73,13 @@ const visibleColumns = ref<string[]>([
/**
* งกนป Dialog
*/
const closeDialog = () => {
function closeDialog() {
modalNote.value = false;
modalUpload.value = false;
};
}
// fecthlist
const fecthlistprofile = async (id: string) => {
async function fecthlistprofile(id: string) {
showLoader();
await http
.get(config.API.listRetire(id))
@ -191,10 +193,10 @@ const fecthlistprofile = async (id: string) => {
hideLoader();
});
};
}
//
const fecthCheck = async (id: string) => {
async function fecthCheck(id: string) {
await http
.get(config.API.checkfileupload(id))
.then((res) => {
@ -203,10 +205,10 @@ const fecthCheck = async (id: string) => {
.catch((err) => {
messageError($q, err);
});
};
}
// DelProfile
const clickDelete = () => {
function clickDelete() {
dialogRemove(
$q,
async () => {
@ -230,10 +232,10 @@ const clickDelete = () => {
"ยืนยันการลบข้อมูล",
"ต้องการลบข้อมูลนี้ใช่หรือไม่ ?"
);
};
}
//
const saveNote = () => {
function saveNote() {
dialogConfirm(
$q,
async () => {
@ -257,18 +259,18 @@ const saveNote = () => {
"ยืนยันการบันทึกข้อมูล",
"ต้องการบันทึกข้อมูลนี้ใช่หรือไม่ ?"
);
};
}
// ListId
const UpdateListId = (retireld: string, pId: string) => {
function UpdateListId(retireld: string, pId: string) {
profileId.value = pId;
fecthlistprofile(retireld);
};
}
//
const backHistory = () => {
function backHistory() {
window.history.back();
};
}
const visibleNote = computed(() => {
if (note.value === "" || note.value === undefined) {
@ -279,7 +281,7 @@ const visibleNote = computed(() => {
//
const modalUpload = ref<boolean>(false);
const signDate = ref<Date | null>(null);
const uploadFile = async (event: any, signDate: any) => {
async function uploadFile(event: any, signDate: any) {
if (myForm.value !== null) {
myForm.value.validate().then((successmyForm) => {
if (successmyForm) {
@ -317,7 +319,7 @@ const uploadFile = async (event: any, signDate: any) => {
}
});
}
};
}
/**
* ดาวหโหลด ไฟล
@ -341,7 +343,7 @@ async function downloadAttachment(type: string, id: string) {
}
//
const saveEdiitReport = (reason: string) => {
function saveEdiitReport(reason: string) {
const formdata = new FormData();
formdata.append("Detail", reason);
dialogConfirm(
@ -363,12 +365,12 @@ const saveEdiitReport = (reason: string) => {
"ยืนยันการแก้ไขข้อมูล",
"ต้องการยืนยันการแก้ไขข้อมูลนี้หรือไม่ ?"
);
};
}
// popup
const openmodalEditReport = () => {
function openmodalEditReport() {
modalEdit.value = true;
};
}
/** Setting Pagination */
const paging = ref<boolean>(true);
@ -378,16 +380,21 @@ const pagination = ref({
page: 1,
rowsPerPage: 10,
});
const paginationLabel = (start: number, end: number, total: number) => {
function paginationLabel(start: number, end: number, total: number) {
if (paging.value == true) return " " + start + "-" + end + " ใน " + total;
else return start + "-" + end + " ใน " + total;
};
}
/**
* อมลในทะเบยนประว
* @param id คคล
*/
function onclickViewinfo(id: string) {
modalPersonal.value = true;
personId.value = id;
}
/** ทะเบียนประวัติ */
function updatemodalPersonal(modal: boolean) {
modalPersonal.value = modal;
}
@ -489,22 +496,6 @@ onMounted(() => {
</q-menu>
<q-tooltip>ดาวนโหลดไฟล</q-tooltip>
</q-btn>
<!-- <q-file
bg-color="white"
clearable
outlined
dense
v-model="fileUpload"
accept=".pdf"
:style="fileUpload === null ? 'width: 150px' : 'width: auto'"
label="อัปโหลดไฟล์"
v-if="statusUpload !== true"
>
<template v-slot:prepend>
<q-icon color="light-blue" name="attach_file" />
<q-tooltip>ปโหลดไฟล</q-tooltip>
</template>
</q-file> -->
</div>
<q-space />
<div class="row">

View file

@ -1,10 +1,13 @@
<script setup lang="ts">
import { ref } from "vue";
import { useQuasar } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import { useRouter } from "vue-router";
import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import type { RoundData } from "@/modules/06_retirement/interface/index/Main";
/** Use */
const $q = useQuasar();
@ -33,11 +36,11 @@ const props = defineProps({
const modal = ref<boolean>(false);
const radio = ref<string>("");
const actionOption = ref<any>([]);
const actionOption = ref<RoundData[]>([]);
const action = ref<string>("");
//
const clickAdd = () => {
function clickAdd() {
if (props.rows) {
//
if (props.rows.length == 0) {
@ -61,13 +64,14 @@ const clickAdd = () => {
round: `รอบ ${e.round} (ประกาศ ณ วันที่ ${e.signDate})`,
}));
actionOption.value = list;
console.log("🚀 ~ clickAdd ~ actionOption.value:", actionOption.value);
}
}
}
};
}
//
const clickSelect = async (action: string) => {
async function clickSelect(action: string) {
dialogConfirm(
$q,
async () => {
@ -83,10 +87,10 @@ const clickSelect = async (action: string) => {
"ยืนยันการแก้ไขข้อมูลประกาศเกษียณ",
"ต้องการแก้ไขข้อมูลประกาศเกษียณใช่หรือไม่ ?"
);
};
}
// API
const cerateRetirement = async (data: object) => {
async function cerateRetirement(data: object) {
await http
.post(config.API.createProfile(), data)
.then((res) => {
@ -97,7 +101,7 @@ const cerateRetirement = async (data: object) => {
.catch((e) => {
messageError($q, e);
});
};
}
</script>
<template>
<q-btn