ปรับเเก้

This commit is contained in:
setthawutttty 2023-12-19 15:05:48 +07:00
parent d2c6837a86
commit 46f82b78fc
18 changed files with 446 additions and 190 deletions

View file

@ -4,12 +4,12 @@ import type { QTableProps } from "quasar";
import router from "@/router";
import { useCounterMixin } from "@/stores/mixin";
import { useQuasar } from "quasar";
import { useDisciplineDirectorDataStore } from "@/modules/11_discipline/store/DirectorStore";
import { useEvaluateDirectorDataStore } from "@/modules/12_evaluatePersonal/store/DirectorStore";
import http from "@/plugins/http";
import config from "@/app.config";
const $q = useQuasar();
const dataStore = useDisciplineDirectorDataStore();
const dataStore = useEvaluateDirectorDataStore();
const mixin = useCounterMixin();
const {
messageError,
@ -34,37 +34,126 @@ const pagination = ref({
rowsPerPage: rowsPerPage.value,
});
watch(() => currentPage.value,() => {
rowsPerPage.value = pagination.value.rowsPerPage;
getList();
});
watch(
() => currentPage.value,
() => {
rowsPerPage.value = pagination.value.rowsPerPage;
getList();
}
);
watch(()=>pagination.value.rowsPerPage,()=>{
rowsPerPage.value = pagination.value.rowsPerPage;
currentPage.value = 1
getList();
})
async function getList() {
showLoader();
await http
.get(
config.API.directorList(
currentPage.value,
rowsPerPage.value,
filterKeyword.value
)
)
.then((res) => {
maxPage.value = Math.ceil(res.data.result.total / rowsPerPage.value);
const data = res.data.result.data
dataStore.fetchData(data);
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
watch(
() => pagination.value.rowsPerPage,
() => {
rowsPerPage.value = pagination.value.rowsPerPage;
currentPage.value = 1;
getList();
}
);
function getList() {
// showLoader();
// http
// .get(
// config.API.evaluateDirectorMain(
// currentPage.value,
// rowsPerPage.value,
// filterKeyword.value
// )
// )
// .then((res) => {
// maxPage.value = Math.ceil(res.data.result.total / rowsPerPage.value);
// const data = res.data.result.data
// dataStore.fetchData(data);
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// hideLoader();
// });
// {
// "Id": "0a185476-c764-42d7-a6f9-2c3824a401ed",
// "CreatedAt": "2023-12-19T02:40:59.898Z",
// "CreatedUserId": "59134ef9-9e62-41d0-aac5-339be727f2b0",
// "LastUpdatedAt": "2023-12-19T02:40:59.898Z",
// "LastUpdateUserId": "59134ef9-9e62-41d0-aac5-339be727f2b0",
// "CreatedFullName": " ",
// "LastUpdateFullName": " ",
// "Prefix": "",
// "FirstName": "",
// "LastName": "",
// "Phone": "0999998767",
// "Email": "email@gmail.com",
// "Position": "frontEnd"
// }
const data = [
{
Id: "xx1",
CreatedAt: "2023-12-19T02:40:59.898Z",
CreatedUserId: "cc1",
LastUpdatedAt: "2023-12-19T02:40:59.898Z",
LastUpdateUserId: "ll1",
CreatedFullName: "สาวิตรี ศรีสมัย",
LastUpdateFullName: "สาวิตรี ศรีสมัย",
Prefix: "นาย",
FirstName: "เทสดี",
LastName: "ลองแอด",
Phone: "0999998767",
Email: "email@gmail.com",
Position: "frontEnd",
},
{
Id: "xx2",
CreatedAt: "2023-12-19T02:40:59.898Z",
CreatedUserId: "cc2",
LastUpdatedAt: "2023-12-19T02:40:59.898Z",
LastUpdateUserId: "ll2",
CreatedFullName: "สาวิตรี ศรีสมัย",
LastUpdateFullName: "สาวิตรี ศรีสมัย",
Prefix: "นาย",
FirstName: "เทสดี",
LastName: "ลองแอด",
Phone: "0999998767",
Email: "email@gmail.com",
Position: "frontEnd",
},
{
Id: "xx3",
CreatedAt: "2023-12-19T02:40:59.898Z",
CreatedUserId: "cc3",
LastUpdatedAt: "2023-12-19T02:40:59.898Z",
LastUpdateUserId: "ll3",
CreatedFullName: "สาวิตรี ศรีสมัย",
LastUpdateFullName: "สาวิตรี ศรีสมัย",
Prefix: "นาย",
FirstName: "เทสดี",
LastName: "ลองแอด",
Phone: "0999998767",
Email: "email@gmail.com",
Position: "frontEnd",
},
{
Id: "xx4",
CreatedAt: "2023-12-19T02:40:59.898Z",
CreatedUserId: "cc5",
LastUpdatedAt: "2023-12-19T02:40:59.898Z",
LastUpdateUserId: "ll5",
CreatedFullName: "สาวิตรี ศรีสมัย",
LastUpdateFullName: "สาวิตรี ศรีสมัย",
Prefix: "นาย",
FirstName: "เทสดี",
LastName: "ลองแอด",
Phone: "0999998767",
Email: "email@gmail.com",
Position: "frontEnd",
},
];
dataStore.fetchData(data);
}
/**
@ -82,7 +171,7 @@ function clickDelete(id: string) {
async function deleteData(id: string) {
showLoader();
await http
.delete(config.API.directorbyId(id))
.delete(config.API.evaluateDirectorById(id))
.then((res) => {
success($q, "ลบข้อมูลสำเร็จ");
})
@ -94,19 +183,12 @@ async function deleteData(id: string) {
});
}
/**
* งขอมลจำลองไปย store
*/
onMounted(() => {
getList();
// get store
});
/**
* นหาในตาราง
*/
const filterKeyword = ref<string>("");
const filterRef = ref<HTMLInputElement | null>(null);
function resetFilter() {
filterKeyword.value = "";
if (filterRef.value) {
@ -114,10 +196,14 @@ function resetFilter() {
}
}
function filterFn(){
getList()
console.log('enter',filterKeyword.value)
function filterFn() {
getList();
console.log("enter", filterKeyword.value);
}
onMounted(() => {
getList();
});
</script>
<template>
<div class="toptitle text-dark col-12 row items-center">