ประกาศผล

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-07-09 15:52:41 +07:00
parent 855a514d52
commit 7af273ad08
3 changed files with 330 additions and 14 deletions

View file

@ -1,12 +1,271 @@
<script setup lang="ts">
import { ref, watch } from "vue";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
/**
* importType
*/
import type { QTableProps } from "quasar";
import type { ResResults } from "@/modules/14_KPI/interface/response/Main";
/**
* importStore
*/
import { useCounterMixin } from "@/stores/mixin";
import { useKpiDataStore } from "@/modules/14_KPI/store";
/**
* use
*/
const $q = useQuasar();
const {
showLoader,
success,
messageError,
dialogConfirm,
hideLoader,
date2Thai,
} = useCounterMixin();
const { convertResults, convertStatus } = useKpiDataStore();
/**
* props
*/
const tab = defineModel<string>("tab", { required: true });
const rows = defineModel<ResResults[]>("row", { required: true });
const page = defineModel<number>("page", { required: true });
const pageSize = defineModel<number>("pageSize", { required: true });
const maxPage = defineModel<number>("maxPage", { required: true });
const total = defineModel<number>("total", { required: true });
const keyword = defineModel<string>("keyword", { required: true });
const porps = defineProps({
fetchData: { type: Function, required: true },
});
/**
* Table
*/
const columns = ref<QTableProps["columns"]>([
{
name: "no",
align: "left",
label: "ลำดับ",
sortable: false,
field: "no",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "fullName",
align: "left",
label: "ผู้รับการประเมิน",
sortable: true,
field: "fullName",
format: (val, row) => {
return `${row.prefix ?? ""}${row.firstname ?? ""} ${row.lastname ?? ""}`;
},
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "createdAt",
align: "left",
label: "วันที่สร้างแบบประเมิน",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
format(val, row) {
return date2Thai(val);
},
style: "font-size: 14px",
},
{
name: "evaluationStatus",
align: "left",
label: "สถานะการประเมิน",
sortable: true,
field: "evaluationStatus",
format(val, row) {
return val === "KP7" ? "ประการผลแล้ว" : convertStatus(val);
},
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "evaluationResults",
align: "left",
label: "ผลการประเมิน",
sortable: true,
field: "evaluationResults",
format(val, row) {
return convertResults(val);
},
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
]);
const visibleColumns = ref<string[]>([
"no",
"fullName",
"createdAt",
"evaluationStatus",
"evaluationResults",
]);
const pagination = ref({
page: page.value,
rowsPerPage: pageSize.value,
});
const selected = ref<ResResults[]>([]);
/**
* function นทกการประกาศผล
*/
function onAnnounce() {
const ids = selected.value.map((item) => item.id);
dialogConfirm(
$q,
() => {
showLoader();
http
.post(config.API.evaluationUserDone, {
id: ids,
})
.then(() => {
setTimeout(async () => {
await porps.fetchData();
await success($q, "ประกาศผลสำเร็จ");
selected.value = [];
}, 1000);
})
.catch((err) => {
messageError($q, err);
hideLoader();
});
},
"ยืนยันการประกาศผล",
"ต้องการยืนยันการประกาศผลใช่หรือไม่?"
);
}
/**
* นหาขอม
*/
function onSearchData() {
page.value = 1;
porps.fetchData();
}
/**
* ทำงานเมอมการเปลยนแถวตอหน
*/
watch(pagination, () => {
page.value = 1;
pageSize.value = pagination.value.rowsPerPage;
});
</script>
<template>
{{ tab }}
<q-card-section>
<div class="items-center col-12 row q-gutter-x-sm q-mb-sm">
<q-space />
<q-input
borderless
dense
outlined
v-model="keyword"
placeholder="ค้นหา"
@keydown.enter="onSearchData"
>
<template v-slot:append>
<q-icon v-if="keyword === ''" name="search" />
<q-icon
v-else
name="clear"
class="cursor-pointer"
@click="(keyword = ''), onSearchData()"
/>
</template>
</q-input>
<q-select
v-model="visibleColumns"
multiple
outlined
dense
options-dense
:display-value="$q.lang.table.columns"
emit-value
map-options
:options="columns"
option-value="name"
options-cover
/>
</div>
<d-table
:columns="columns"
:rows="rows"
row-key="id"
:selection="tab === 'COMPLETE' ? 'multiple' : null"
v-model:selected="selected"
:rows-per-page-options="[10, 25, 50, 100]"
v-model:pagination="pagination"
:paging="true"
>
<template v-slot:header-selection="scope" v-if="tab === 'COMPLETE'">
<q-checkbox keep-color color="primary" dense v-model="scope.selected" />
</template>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td v-if="tab === 'COMPLETE'">
<q-checkbox
keep-color
color="primary"
dense
v-model="props.selected"
/>
</q-td>
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'no'">
{{ (page - 1) * pageSize + props.rowIndex + 1 }}
</div>
<div v-else>
{{ col.value ?? "-" }}
</div>
</q-td>
</q-tr>
</template>
<template v-slot:pagination="scope">
งหมด {{ total }} รายการ
<q-pagination
v-model="page"
active-color="primary"
color="dark"
:max="Number(maxPage)"
size="sm"
boundary-links
direction-links
:max-pages="5"
@update:model-value="porps.fetchData()"
></q-pagination>
</template>
</d-table>
</q-card-section>
<q-separator v-if="tab === 'COMPLETE'" />
<q-card-actions
align="right"
class="bg-white text-teal"
v-if="tab === 'COMPLETE'"
>
<q-btn
label="ประกาศผล"
color="public"
@click="onAnnounce"
:disable="selected.length === 0"
/>
</q-card-actions>
</template>
<style scoped></style>

View file

@ -39,5 +39,19 @@ interface ResEvaluator {
topic: string;
type: string;
}
interface ResResults {
commanderHighId: string | null;
commanderId: string | null;
createdAt: string;
evaluationResults: string;
evaluationStatus: string;
evaluatorId: string;
firstname: string;
id: string;
kpiPeriodId: string;
lastname: string;
prefix: string;
profileId: string;
}
export type { ResRound, ResDataCapacity, ResEvaluator };
export type { ResRound, ResDataCapacity, ResEvaluator, ResResults };

View file

@ -8,6 +8,7 @@ import config from "@/app.config";
* import type
*/
import type { ItemsTab } from "@/modules/14_KPI/interface/index/Main";
import type { ResResults } from "@/modules/14_KPI/interface/response/Main";
/**
* import components
@ -23,8 +24,7 @@ import { useCounterMixin } from "@/stores/mixin";
* use
*/
const $q = useQuasar();
const { dialogRemove, messageError, showLoader, hideLoader, success } =
useCounterMixin();
const { messageError, showLoader, hideLoader } = useCounterMixin();
/**
* วแปร
@ -34,19 +34,31 @@ const tabItems = ref<ItemsTab[]>([
{ name: "COMPLETE", label: " รอประกาศผล" },
{ name: "KP7", label: "ประกาศผลแล้ว" },
]);
const dataList = ref<ResResults[]>([]); //
const page = ref<number>(1);
const pageSize = ref<number>(10);
const maxPage = ref<number>(1);
const total = ref<number>(1);
const keyword = ref<string>("");
function fetcDatahList() {
/**
* function fetch รายการประกาศผล
*/
function fetcDataList() {
showLoader();
http
.post(config.API.evaluationUser, {
status: tab.value,
page: page.value,
pageSize: pageSize.value,
keyword: keyword.value,
})
.then((res) => {
const data = res.data.result;
dataList.value = data.data;
total.value = data.total;
maxPage.value = Math.ceil(total.value / pageSize.value);
})
.then((res) => {})
.catch((err) => {
messageError($q, err);
})
@ -55,14 +67,27 @@ function fetcDatahList() {
});
}
/**
* ทำงานเมอมการเปลยน Tab
*/
watch(tab, () => {
page.value = 1;
pageSize.value = 10;
fetcDatahList();
keyword.value = "";
fetcDataList();
});
/**
* ทำงานเมอมการเปลยนแถวตอหน
*/
watch(pageSize, () => {
fetcDataList();
});
/**
* HooK
*/
onMounted(() => {
fetcDatahList();
fetcDataList();
});
</script>
@ -85,12 +110,30 @@ onMounted(() => {
</q-tabs>
<q-separator />
<q-tab-panels v-model="tab" animated class="shadow-2 rounded-borders">
<q-tab-panel name="COMPLETE">
<TableResults :tab="tab" />
<q-tab-panel name="COMPLETE" style="padding: 0px">
<TableResults
:tab="tab"
:row="dataList"
v-model:page="page"
v-model:pageSize="pageSize"
v-model:maxPage="maxPage"
v-model:total="total"
v-model:keyword="keyword"
:fetchData="fetcDataList"
/>
</q-tab-panel>
<q-tab-panel name="KP7">
<TableResults :tab="tab" />
<q-tab-panel name="KP7" style="padding: 0px">
<TableResults
:tab="tab"
:row="dataList"
v-model:page="page"
v-model:pageSize="pageSize"
v-model:maxPage="maxPage"
v-model:total="total"
v-model:keyword="keyword"
:fetchData="fetcDataList"
/>
</q-tab-panel>
</q-tab-panels>
</q-card>