ปรับ Code ประเมืน
This commit is contained in:
parent
f9c4bb3b80
commit
5b2be2af2b
24 changed files with 603 additions and 1398 deletions
|
|
@ -2,33 +2,47 @@
|
|||
import { ref, onMounted } 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";
|
||||
|
||||
/** impolerType*/
|
||||
import type { PersonInformation } from "@/modules/12_evaluatePersonal/interface/response/evalute";
|
||||
|
||||
/** importComponents*/
|
||||
import Tab1 from "@/modules/12_evaluatePersonal/components/Detail/Tab1.vue"; // ชำนาญการ
|
||||
import Tab2 from "@/modules/12_evaluatePersonal/components/Detail/Tab2.vue"; // ชำนาญการพิเศษ
|
||||
|
||||
/** importStore*/
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useEvaluateDetailStore } from "@/modules/12_evaluatePersonal/store/EvaluateDetail";
|
||||
|
||||
/** use*/
|
||||
const mixin = useCounterMixin();
|
||||
const { showLoader, hideLoader, messageError } = mixin;
|
||||
|
||||
const store = useEvaluateDetailStore();
|
||||
const router = useRouter();
|
||||
const $q = useQuasar();
|
||||
const route = useRoute();
|
||||
|
||||
const id = ref<string>(route.params.id as string);
|
||||
const { showLoader, hideLoader, messageError } = mixin;
|
||||
|
||||
const data = ref<any>({});
|
||||
function getData() {
|
||||
const id = ref<string>(route.params.id as string); // id รายการประเมิน
|
||||
|
||||
const data = ref<PersonInformation[]>([]);
|
||||
const prefix = ref<string>("");
|
||||
const fullName = ref<string>("");
|
||||
|
||||
/** funmction เรียกขอ้มูลคุณสมบัติ*/
|
||||
async function fetchFeature() {
|
||||
showLoader();
|
||||
http
|
||||
await http
|
||||
.get(config.API.evaluateGetDetail(id.value))
|
||||
.then((res: any) => {
|
||||
.then((res) => {
|
||||
data.value = res.data.result;
|
||||
const person = data.value[0];
|
||||
if (person) {
|
||||
prefix.value = person.prefix;
|
||||
fullName.value = person.fullName;
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
|
|
@ -38,8 +52,9 @@ function getData() {
|
|||
});
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getData();
|
||||
/** HookLifecycle*/
|
||||
onMounted(async () => {
|
||||
await fetchFeature();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
@ -56,9 +71,7 @@ onMounted(() => {
|
|||
class="q-mr-sm"
|
||||
@click="router.go(-1)"
|
||||
/>
|
||||
<div>
|
||||
รายละเอียดการประเมินบุคคลของ {{ `${data.prefix}${data.fullName}` }}
|
||||
</div>
|
||||
<div>รายละเอียดการประเมินบุคคลของ {{ `${prefix}${fullName}` }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<q-card flat bordered class="col-12 q-mt-sm q-pt-sm q-pa-md">
|
||||
|
|
|
|||
|
|
@ -1,26 +1,20 @@
|
|||
<script setup lang="ts">
|
||||
import { onMounted, ref, watch, useAttrs } from "vue";
|
||||
import { onMounted, ref, watch } from "vue";
|
||||
import { useQuasar } from "quasar";
|
||||
import { useRouter } from "vue-router";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
import Table from "@/modules/12_evaluatePersonal/components/Table.vue";
|
||||
/** importStore*/
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useEvalutuonStore } from "@/modules/12_evaluatePersonal/store/Evaluate";
|
||||
import type { Pagination } from "@/modules/03_recruiting/interface/index/Main";
|
||||
|
||||
const $q = useQuasar(); // show dialog
|
||||
/** use*/
|
||||
const $q = useQuasar();
|
||||
const router = useRouter();
|
||||
//search data table
|
||||
const mixin = useCounterMixin();
|
||||
const store = useEvalutuonStore();
|
||||
const { showLoader, hideLoader, messageError } = mixin;
|
||||
const attrs = ref<any>(useAttrs());
|
||||
|
||||
function Detailpage(id: string) {
|
||||
router.push(`/evaluate/detail/${id}`);
|
||||
}
|
||||
|
||||
const currentPage = ref<number>(1);
|
||||
const maxPage = ref<number>(0);
|
||||
|
|
@ -29,9 +23,7 @@ const total = ref<number>(0);
|
|||
const filter = ref<string>("");
|
||||
const pageSize = ref<number>(10);
|
||||
|
||||
/**
|
||||
*pagination ของตาราง
|
||||
*/
|
||||
/** pagination ของตาราง*/
|
||||
const initialPagination = ref<any>({
|
||||
sortBy: null,
|
||||
descending: false,
|
||||
|
|
@ -39,72 +31,75 @@ const initialPagination = ref<any>({
|
|||
rowsPerPage: pageSize,
|
||||
});
|
||||
|
||||
// Pagination - update rowsPerPage
|
||||
/**
|
||||
* function อัปเดท paging
|
||||
* @param initialPagination ข้อมูล pagination
|
||||
*/
|
||||
async function updatePagination(initialPagination: any) {
|
||||
currentPage.value = 1;
|
||||
pageSize.value = initialPagination.rowsPerPage;
|
||||
page.value = 1; // set current page เป็น 1 เสมอเมื่อเปลี่ยน per row
|
||||
}
|
||||
// Pagination - page & change page & get new data
|
||||
|
||||
/** function callback เมื่อมีการเปลี่ยนหน้า*/
|
||||
watch(
|
||||
[
|
||||
() => currentPage.value,
|
||||
() => (pageSize.value = initialPagination.value.rowsPerPage),
|
||||
],
|
||||
async () => {
|
||||
getList();
|
||||
fetchEvaluteList();
|
||||
}
|
||||
);
|
||||
// Pagination - page & change page & get new data
|
||||
|
||||
/** function callback เมื่อมีการเปลี่ยนหน้า*/
|
||||
watch(
|
||||
[() => currentPage.value, () => initialPagination.value.rowsPerPage],
|
||||
async () => {
|
||||
page.value = currentPage.value;
|
||||
await getList();
|
||||
await fetchEvaluteList();
|
||||
}
|
||||
);
|
||||
|
||||
/** function callback เมื่อมีการเปลี่ยนจำนวนแถว*/
|
||||
watch(
|
||||
() => initialPagination.value.rowsPerPage,
|
||||
() => {
|
||||
pageSize.value = initialPagination.value.rowsPerPage;
|
||||
currentPage.value = 1;
|
||||
getList();
|
||||
fetchEvaluteList();
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* filter function
|
||||
*/
|
||||
const filterRef = ref<HTMLInputElement | null>(null);
|
||||
/** function ค้นหาตาม keyword*/
|
||||
function filterFn() {
|
||||
updatePagination(filter.value);
|
||||
pageSize.value = initialPagination.value.rowsPerPage;
|
||||
getList();
|
||||
fetchEvaluteList();
|
||||
}
|
||||
const resetFilter = () => {
|
||||
|
||||
/** functrion ล้างค้นหา*/
|
||||
function resetFilter() {
|
||||
filter.value = "";
|
||||
getList();
|
||||
fetchEvaluteList();
|
||||
if (filterRef.value) {
|
||||
filterRef.value.focus();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function getList() {
|
||||
/** function เรียกรายการคำขอประเมิน*/
|
||||
async function fetchEvaluteList() {
|
||||
showLoader();
|
||||
http
|
||||
await http
|
||||
.get(
|
||||
config.API.evaluationMain(currentPage.value, pageSize.value, filter.value)
|
||||
)
|
||||
.then(async (res) => {
|
||||
const data = res.data.result.data;
|
||||
total.value = res.data.result.total;
|
||||
console.log(res.data.result.total);
|
||||
maxPage.value = await Math.ceil(total.value / pageSize.value);
|
||||
maxPage.value = maxPage.value < 1 ? 1 : maxPage.value;
|
||||
console.log(total.value);
|
||||
console.log(pageSize.value);
|
||||
console.log(maxPage.value);
|
||||
|
||||
store.fetchData(data);
|
||||
})
|
||||
.catch((e) => {
|
||||
|
|
@ -115,11 +110,17 @@ function getList() {
|
|||
});
|
||||
}
|
||||
|
||||
/**เมื่อเริ่มโหลดหน้า
|
||||
* ส่งข้อมูลจำลองไปยัง store
|
||||
/**
|
||||
* funcition redirectToDetail
|
||||
* @param id รายการคำขอประเมิน
|
||||
*/
|
||||
function Detailpage(id: string) {
|
||||
router.push(`/evaluate/detail/${id}`);
|
||||
}
|
||||
|
||||
/** HookLifecycle */
|
||||
onMounted(async () => {
|
||||
getList();
|
||||
await fetchEvaluteList(); // เรียกข้อมูลรายการปรัเมิน
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue