Refactoring code module 07_appealComplain

This commit is contained in:
STW_TTTY\stwtt 2024-09-09 11:39:54 +07:00
parent d03e3b9e98
commit 3636f380fb
4 changed files with 88 additions and 172 deletions

View file

@ -4,12 +4,11 @@ import type { QTableProps } from "quasar";
import { ref, onMounted, reactive, watch } from "vue";
import { useQuasar } from "quasar";
import { useRouter } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
import { useTransferDataStore } from "@/modules/02_transfer/store";
import { useAppealComplainStore } from "@/modules/07_appealComplain/store";
import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import { useAppealComplainStore } from "@/modules/07_appealComplain/store";
import type { FormType } from "@/modules/07_appealComplain/interface/response/mainType";
import type { DataOption } from "@/modules/07_appealComplain/interface/index/main";
@ -20,18 +19,18 @@ const maxPage = ref<number>(1);
const page = ref<number>(1);
const rowsPerPage = ref<number>(10);
const filterKeyword = ref<string>("");
const dataStore = useAppealComplainStore();
const transferData = useTransferDataStore();
const { statusText } = transferData;
const router = useRouter();
const $q = useQuasar();
const router = useRouter();
const mixin = useCounterMixin();
const { date2Thai, messageError, showLoader, hideLoader } = mixin;
const dataStore = useAppealComplainStore();
const { messageError, showLoader, hideLoader } = mixin;
const filterKeyword = ref<string>("");
const type = ref<DataOption[]>([
{ id: "ALL", name: "ทั้งหมด" },
...dataStore.typeOptions,
]);
/**
* งค pagination
*/
@ -45,7 +44,6 @@ const pagination = ref({
/**
* เพมหวขอตาราง
*/
const filter = ref<string>("");
const formData = reactive<FormType>({
type: "ALL",
@ -65,6 +63,7 @@ const visibleColumns = ref<string[]>([
"lastUpdatedAt",
"status",
]);
const columns = ref<QTableProps["columns"]>([
{
name: "no",
@ -161,7 +160,7 @@ const columns = ref<QTableProps["columns"]>([
]);
//
const getData = async () => {
async function getData() {
showLoader();
await http
.get(
@ -186,14 +185,14 @@ const getData = async () => {
.finally(() => {
hideLoader();
});
};
}
/**
* กดเพอยอนกล
*/
const clickBack = () => {
function clickBack() {
router.push(`/`);
};
}
/** ดึงข้อมูลเมื่อมีการปรับฟิลเตอร์ */
function dataUpdate() {
@ -205,6 +204,18 @@ function filterFn() {
getData();
}
/**
* เปดหนาแกไข
* @param id id ของ คคล
*/
function editPage(id: string) {
router.push(`/appeal-complain/${id}`);
}
function redirectToPageadd() {
router.push(`/appeal-complain/add`);
}
watch(
() => currentPage.value,
() => {
@ -222,19 +233,6 @@ watch(
}
);
/**
* เปดหนาแกไข
* @param id id ของ คคล
*/
function editPage(id: string) {
router.push(`/appeal-complain/${id}`);
}
function redirectToPageadd() {
// dataStore.rowsAdd = []
router.push(`/appeal-complain/add`);
}
/**
* เรยกฟงกนทงหมดตอนเรยกใชไฟล
*/