Refactoring code module 07_appealComplain
This commit is contained in:
parent
d03e3b9e98
commit
3636f380fb
4 changed files with 88 additions and 172 deletions
|
|
@ -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`);
|
||||
}
|
||||
|
||||
/**
|
||||
* เรียกฟังก์ชันทั้งหมดตอนเรียกใช้ไฟล์นี้
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue