หน้ารายการผู้ประเมิน => เพิ่ม tab
This commit is contained in:
parent
a99119660b
commit
f28baeb158
7 changed files with 472 additions and 114 deletions
|
|
@ -8,23 +8,21 @@ import http from "@/plugins/http";
|
|||
import type { DataOptions } from "@/modules/08_KPI/interface/index/Main";
|
||||
import type { QTableProps } from "quasar";
|
||||
|
||||
import TabAll from "@/modules/08_KPI/components/Evaluator/01_TabAll.vue";
|
||||
import TabOther from "@/modules/08_KPI/components/Evaluator/02_TabOther.vue";
|
||||
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useKpiDataStore } from "@/modules/08_KPI/store";
|
||||
|
||||
const $q = useQuasar();
|
||||
const router = useRouter();
|
||||
const store = useKpiDataStore();
|
||||
const { showLoader, hideLoader, messageError, date2Thai } = useCounterMixin();
|
||||
|
||||
const { showLoader, hideLoader, messageError, date2Thai, dialogConfirm } =
|
||||
useCounterMixin();
|
||||
|
||||
const filterKeyword = ref<string>("");
|
||||
|
||||
const rows = ref<any>();
|
||||
const dataListMain = ref<any>();
|
||||
|
||||
const year = ref<number>(new Date().getFullYear());
|
||||
|
||||
const round = ref<string>("");
|
||||
const roundOp = ref<DataOptions[]>([]);
|
||||
|
||||
const visibleColumns = ref<string[]>([
|
||||
|
|
@ -83,18 +81,15 @@ const columns = ref<QTableProps["columns"]>([
|
|||
},
|
||||
]);
|
||||
|
||||
const formQuery = reactive({
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
});
|
||||
const totalList = ref<number>(1);
|
||||
const totalList = ref<number>(0);
|
||||
const maxPage = ref<number>(1);
|
||||
|
||||
function fetchRoundOption() {
|
||||
function fetchRoundOption(type: boolean = false) {
|
||||
showLoader();
|
||||
http
|
||||
.get(
|
||||
config.API.kpiPeriod +
|
||||
`?page=${1}&pageSize=${10}&keyword=${""}&year=${year.value}`
|
||||
`?page=${1}&pageSize=${10}&keyword=${""}&year=${store.yearRound}`
|
||||
)
|
||||
.then((res) => {
|
||||
const data = res.data.result.data;
|
||||
|
|
@ -108,7 +103,9 @@ function fetchRoundOption() {
|
|||
: "",
|
||||
}));
|
||||
roundOp.value = list;
|
||||
round.value = "";
|
||||
if (type) {
|
||||
store.formQuery.round = "";
|
||||
}
|
||||
fetchList();
|
||||
})
|
||||
.catch((err) => {
|
||||
|
|
@ -121,15 +118,44 @@ function fetchRoundOption() {
|
|||
|
||||
function fetchList() {
|
||||
showLoader();
|
||||
const formTab1 = {
|
||||
page: store.formQuery.page,
|
||||
pageSize: store.formQuery.pageSize,
|
||||
kpiPeriodId: store.formQuery.round,
|
||||
keyword: store.formQuery.keyword,
|
||||
};
|
||||
const formTab2 = {
|
||||
page: store.formQuery.page,
|
||||
pageSize: store.formQuery.pageSize,
|
||||
kpiPeriodId: store.formQuery.round,
|
||||
keyword: store.formQuery.keyword,
|
||||
status: "NEW_EVALUATOR",
|
||||
};
|
||||
|
||||
const formTab3 = {
|
||||
page: store.formQuery.page,
|
||||
pageSize: store.formQuery.pageSize,
|
||||
kpiPeriodId: store.formQuery.round,
|
||||
keyword: store.formQuery.keyword,
|
||||
reqedit: "EVALUATOR",
|
||||
};
|
||||
|
||||
const body =
|
||||
store.tabMainevaluator === "1"
|
||||
? formTab1
|
||||
: store.tabMainevaluator === "2"
|
||||
? formTab2
|
||||
: store.tabMainevaluator === "3"
|
||||
? formTab3
|
||||
: "";
|
||||
|
||||
http
|
||||
.get(
|
||||
config.API.kpiEvaluation +
|
||||
`/admin?page=${formQuery.page}&pageSize=${formQuery.pageSize}&kpiPeriodId=${round.value}&keyword=${filterKeyword.value}`
|
||||
)
|
||||
.post(config.API.kpiEvaluation + `/admin`, body)
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
totalList.value = Math.ceil(data.total / formQuery.pageSize);
|
||||
rows.value = data.data;
|
||||
maxPage.value = Math.ceil(data.total / store.formQuery.pageSize);
|
||||
totalList.value = data.total;
|
||||
dataListMain.value = data.data;
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
|
|
@ -140,37 +166,31 @@ function fetchList() {
|
|||
}
|
||||
|
||||
function changRound() {
|
||||
formQuery.page = 1;
|
||||
store.formQuery.page = 1;
|
||||
fetchList();
|
||||
}
|
||||
|
||||
function redirectViewDetail(id: string) {
|
||||
router.push(`/KPI-evaluator/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* function updatePagination
|
||||
* @param newPagination ข้อมูล Pagination ใหม่
|
||||
*/
|
||||
function updatePagination(newPagination: any) {
|
||||
formQuery.page = 1;
|
||||
formQuery.pageSize = newPagination.rowsPerPage;
|
||||
store.formQuery.page = 1;
|
||||
store.formQuery.pageSize = newPagination.rowsPerPage;
|
||||
}
|
||||
|
||||
const pagination = ref({
|
||||
sortBy: "desc",
|
||||
descending: false,
|
||||
page: 1,
|
||||
rowsPerPage: 10,
|
||||
});
|
||||
|
||||
watch(
|
||||
() => formQuery.pageSize,
|
||||
() => store.formQuery.pageSize,
|
||||
() => {
|
||||
fetchList();
|
||||
}
|
||||
);
|
||||
|
||||
function onChangTab() {
|
||||
store.formQuery.page = 1;
|
||||
fetchList();
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
fetchRoundOption();
|
||||
});
|
||||
|
|
@ -198,12 +218,12 @@ onMounted(async () => {
|
|||
<div class="row q-gutter-sm">
|
||||
<datepicker
|
||||
menu-class-name="modalfix"
|
||||
v-model="year"
|
||||
v-model="store.yearRound"
|
||||
:locale="'th'"
|
||||
autoApply
|
||||
year-picker
|
||||
:enableTimePicker="false"
|
||||
@update:model-value="fetchRoundOption()"
|
||||
@update:model-value="fetchRoundOption(true)"
|
||||
>
|
||||
<template #year="{ year }">{{ year + 543 }}</template>
|
||||
<template #year-overlay-value="{ value }">{{
|
||||
|
|
@ -214,9 +234,10 @@ onMounted(async () => {
|
|||
dense
|
||||
lazy-rules
|
||||
outlined
|
||||
class="inputgreen"
|
||||
hide-bottom-space
|
||||
:model-value="!!year ? year + 543 : null"
|
||||
:model-value="
|
||||
!!store.yearRound ? store.yearRound + 543 : null
|
||||
"
|
||||
:label="`${'ปีงบประมาณ'}`"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
|
|
@ -232,7 +253,7 @@ onMounted(async () => {
|
|||
</datepicker>
|
||||
|
||||
<q-select
|
||||
v-model="round"
|
||||
v-model="store.formQuery.round"
|
||||
outlined
|
||||
label="รอบการประเมิน"
|
||||
dense
|
||||
|
|
@ -251,16 +272,16 @@ onMounted(async () => {
|
|||
<q-input
|
||||
outlined
|
||||
dense
|
||||
v-model="filterKeyword"
|
||||
v-model="store.formQuery.keyword"
|
||||
label="ค้นหาผู้ขอรับการประเมิน"
|
||||
@keydown.enter.prevent="changRound"
|
||||
>
|
||||
<template v-slot:append>
|
||||
<q-icon
|
||||
v-if="filterKeyword !== ''"
|
||||
v-if="store.formQuery.keyword !== ''"
|
||||
name="clear"
|
||||
class="cursor-pointer"
|
||||
@click="(filterKeyword = ''), changRound()"
|
||||
@click="(store.formQuery.keyword = ''), changRound()"
|
||||
/>
|
||||
<q-icon v-else name="search" color="grey-5" />
|
||||
</template>
|
||||
|
|
@ -282,7 +303,75 @@ onMounted(async () => {
|
|||
</div>
|
||||
</q-toolbar>
|
||||
<div class="col-12">
|
||||
<q-table
|
||||
<q-card bordered class="q-mt-sm">
|
||||
<q-tabs
|
||||
v-model="store.tabMainevaluator"
|
||||
inline-label
|
||||
align="left"
|
||||
class="text-grey"
|
||||
active-color="primary"
|
||||
indicator-color="primary"
|
||||
narrow-indicator
|
||||
>
|
||||
<q-tab name="1" label="รายการทั้งหมด" @click="onChangTab" />
|
||||
<q-tab
|
||||
name="2"
|
||||
label="รออนุมัติการจัดทำข้อตกลง"
|
||||
@click="onChangTab"
|
||||
/>
|
||||
<q-tab
|
||||
name="3"
|
||||
label="รออนุมัติแก้ไขข้อตกลง"
|
||||
@click="onChangTab"
|
||||
/>
|
||||
</q-tabs>
|
||||
<q-separator />
|
||||
|
||||
<q-tab-panels v-model="store.tabMainevaluator" animated>
|
||||
<q-tab-panel name="1">
|
||||
<TabAll
|
||||
:columns="columns"
|
||||
:visibleColumns="visibleColumns"
|
||||
:rows="dataListMain"
|
||||
:formQuery="store.formQuery"
|
||||
:total="totalList"
|
||||
:maxPage="maxPage"
|
||||
:updatePagination="updatePagination"
|
||||
:fetchList="fetchList"
|
||||
/>
|
||||
</q-tab-panel>
|
||||
|
||||
<q-tab-panel name="2">
|
||||
<TabOther
|
||||
:columns="columns"
|
||||
:visibleColumns="visibleColumns"
|
||||
:rows="dataListMain"
|
||||
:formQuery="store.formQuery"
|
||||
:total="totalList"
|
||||
:maxPage="maxPage"
|
||||
:updatePagination="updatePagination"
|
||||
:fetchList="fetchList"
|
||||
/>
|
||||
</q-tab-panel>
|
||||
|
||||
<q-tab-panel name="3">
|
||||
<TabOther
|
||||
:columns="columns"
|
||||
:visibleColumns="visibleColumns"
|
||||
:rows="dataListMain"
|
||||
:formQuery="store.formQuery"
|
||||
:total="totalList"
|
||||
:maxPage="maxPage"
|
||||
:updatePagination="updatePagination"
|
||||
:fetchList="fetchList"
|
||||
/>
|
||||
</q-tab-panel>
|
||||
</q-tab-panels>
|
||||
</q-card>
|
||||
</div>
|
||||
|
||||
<!-- <div class="col-12"> -->
|
||||
<!-- <q-table
|
||||
ref="table"
|
||||
:columns="columns"
|
||||
:rows="rows"
|
||||
|
|
@ -340,8 +429,8 @@ onMounted(async () => {
|
|||
@update:model-value="fetchList"
|
||||
></q-pagination>
|
||||
</template>
|
||||
</q-table>
|
||||
</div>
|
||||
</q-table> -->
|
||||
<!-- </div> -->
|
||||
</q-card>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -351,45 +440,4 @@ onMounted(async () => {
|
|||
.icon-color {
|
||||
color: #4154b3;
|
||||
}
|
||||
|
||||
.custom-table2 {
|
||||
max-height: 64vh;
|
||||
|
||||
.q-table tr:nth-child(odd) td {
|
||||
background: white;
|
||||
}
|
||||
|
||||
.q-table tr:nth-child(even) td {
|
||||
background: #f8f8f8;
|
||||
}
|
||||
|
||||
.q-table thead tr {
|
||||
background: #ecebeb;
|
||||
}
|
||||
|
||||
.q-table thead tr th {
|
||||
position: sticky;
|
||||
}
|
||||
|
||||
.q-table td:nth-of-type(2) {
|
||||
z-index: 3 !important;
|
||||
}
|
||||
|
||||
.q-table th:nth-of-type(2),
|
||||
.q-table td:nth-of-type(2) {
|
||||
position: sticky;
|
||||
left: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
/* this will be the loading indicator */
|
||||
.q-table thead tr:last-child th {
|
||||
/* height of all previous header rows */
|
||||
top: 48px;
|
||||
}
|
||||
|
||||
.q-table thead tr:first-child th {
|
||||
top: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue