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

@ -1,14 +1,16 @@
<script setup lang="ts">
import { ref, computed, watchEffect } from "vue";
import { useQuasar } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import type { QTableProps } from "quasar";
import type { ResponseItems } from "@/modules/06_retirement/interface/response/Main";
import DialogHeader from "@/modules/06_retirement/components/DialogHeader.vue";
import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import { useTransferDataStore } from "@/modules/05_placement/store";
import type { ResponseItems } from "@/modules/06_retirement/interface/response/Main";
import DialogHeader from "@/modules/06_retirement/components/DialogHeader.vue";
/** use */
const $q = useQuasar();
const { statusText } = useTransferDataStore();
@ -126,17 +128,17 @@ const checkSelected = computed(() => {
});
//popup
const saveOrder = () => {
function saveOrder() {
dialogConfirm(
$q,
() => Ordersave(),
"ยืนยันส่งไปออกคำสั่ง",
"ต้องการยืนยันส่งไปออกคำสั่งใช่หรือไม่?"
);
};
}
//
const Ordersave = async () => {
async function Ordersave() {
const id = selected.value.map((r) => r.id);
const body = {
id,
@ -155,17 +157,18 @@ const Ordersave = async () => {
props.fecthlistRecevice?.();
hideLoader();
});
};
}
const emit = defineEmits(["update:filterKeyword2", "update:selected"]);
const updateInput = (value: any) => {
function updateInput(value: any) {
emit("update:filterKeyword2", value);
};
}
//
const Reset = () => {
function Reset() {
emit("update:filterKeyword2", "");
};
}
watchEffect(() => {
if (props.modal === true) {
selected.value = [];

View file

@ -3,13 +3,16 @@ import { ref, onMounted } from "vue";
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { useRouter } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
import { useTransferDataStore } from "@/modules/05_placement/store";
import http from "@/plugins/http";
import config from "@/app.config";
import DialogSendToCommand from "@/modules/06_retirement/components/DismissOrder/DialogSendToCommand.vue";
import type { ResponseData } from "@/modules/06_retirement/interface/response/out";
import { useCounterMixin } from "@/stores/mixin";
import { checkPermission } from "@/utils/permissions";
import { useTransferDataStore } from "@/modules/05_placement/store";
import type { ResponseData } from "@/modules/06_retirement/interface/response/out";
import DialogSendToCommand from "@/modules/06_retirement/components/DismissOrder/DialogSendToCommand.vue";
/** use */
const $q = useQuasar();
@ -23,7 +26,6 @@ const {
hideLoader,
success,
dialogMessage,
findOrgNameOld,
} = mixin;
const { statusText } = transferStore;
const modal = ref<boolean>(false);
@ -119,11 +121,15 @@ const columns = ref<QTableProps["columns"]>([
format: (val) => statusText(val),
},
]);
onMounted(async () => {
await getData();
const pagination = ref({
sortBy: "createdAt",
descending: true,
page: 1,
rowsPerPage: 10,
});
const openModalOrder = () => {
function openModalOrder() {
openModal();
const row = filters.value.filter(
(r: ResponseData) =>
@ -139,10 +145,10 @@ const openModalOrder = () => {
r.date
);
rows2.value = row;
};
}
//
const getData = async () => {
async function getData() {
showLoader();
await http
.get(config.API.retirementOut)
@ -157,9 +163,9 @@ const getData = async () => {
.finally(() => {
hideLoader();
});
};
}
const clickDelete = async (id: string) => {
async function clickDelete(id: string) {
dialogMessage(
$q,
`ลบข้อมูล`,
@ -170,9 +176,9 @@ const clickDelete = async (id: string) => {
async () => await deleteData(id),
async () => await getData()
);
};
}
const deleteData = async (id: string) => {
async function deleteData(id: string) {
await http
.delete(config.API.outByid(id))
.then(() => {
@ -184,21 +190,19 @@ const deleteData = async (id: string) => {
.finally(async () => {
await getData();
});
};
}
const openModal = () => (modal.value = true);
const closeModal = () => (modal.value = false);
const resetFilter = () => {
function resetFilter() {
filterKeyword.value = "";
filterKeyword2.value = "";
filterRef.value.focus();
};
const pagination = ref({
sortBy: "createdAt",
descending: true,
page: 1,
rowsPerPage: 10,
}
onMounted(async () => {
await getData();
});
</script>
<template>

View file

@ -2,9 +2,10 @@
import { onMounted, ref } from "vue";
import { useQuasar } from "quasar";
import { useRoute, useRouter } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import { tokenParsed } from "@/plugins/auth";
/**Import type */
@ -51,7 +52,7 @@ const fullName = ref<string>("");
const status = ref<string>("");
// API
const getData = async () => {
async function getData() {
showLoader();
await http
.get(config.API.outByid(dataId))
@ -81,21 +82,21 @@ const getData = async () => {
.finally(() => {
hideLoader();
});
};
}
/**
* งก Cancle
*/
const clickCancel = async () => {
async function clickCancel() {
await getData();
edit.value = false;
myForm.value?.resetValidation();
};
}
/**
* งก Saveจาก API
*/
const onSubmit = async () => {
async function onSubmit() {
dialogMessage(
$q,
"ต้องการแก้ไขข้อมูลหรือไม่?",
@ -131,18 +132,18 @@ const onSubmit = async () => {
},
undefined
);
};
}
/**
* Function เพ Class เวลา Edit
* @param val เมอเปนEdit จะเปลยน Class
*/
const getClass = (val: boolean) => {
function getClass(val: boolean) {
return {
"full-width inputgreen cursor-pointer": val,
"full-width cursor-pointer": !val,
};
};
}
/** Hook */
onMounted(async () => {