2024-04-04 15:37:46 +07:00
|
|
|
<script setup lang="ts">
|
2024-04-19 14:15:08 +07:00
|
|
|
import { ref, reactive, onMounted, watch } from "vue";
|
2024-04-04 15:37:46 +07:00
|
|
|
import { useQuasar, type QTableProps } from "quasar";
|
|
|
|
|
import { useRouter } from "vue-router";
|
|
|
|
|
|
|
|
|
|
/** importStore*/
|
|
|
|
|
import { useCounterMixin } from "@/stores/mixin";
|
2024-04-19 14:15:08 +07:00
|
|
|
import http from "@/plugins/http";
|
|
|
|
|
import config from "@/app.config";
|
|
|
|
|
import type { NewPagination } from "@/modules/14_KPI/interface/request/Main";
|
2024-04-04 15:37:46 +07:00
|
|
|
/** use*/
|
|
|
|
|
const $q = useQuasar();
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
const { showLoader, hideLoader, dialogRemove, success } = useCounterMixin();
|
|
|
|
|
|
2024-04-19 14:15:08 +07:00
|
|
|
const maxPage = ref<number>(1);
|
|
|
|
|
const totalList = ref<number>(1); //จำนวนข้อมูลรายการ
|
|
|
|
|
|
2024-04-04 15:37:46 +07:00
|
|
|
/** หัวตาราง */
|
|
|
|
|
const rows = ref<any>([]);
|
|
|
|
|
const columns = ref<QTableProps["columns"]>([
|
|
|
|
|
{
|
2024-04-19 14:15:08 +07:00
|
|
|
name: "no",
|
2024-04-04 15:37:46 +07:00
|
|
|
align: "left",
|
|
|
|
|
label: "ลำดับตัวชี้วัด ",
|
|
|
|
|
sortable: true,
|
2024-04-19 14:15:08 +07:00
|
|
|
field: "no",
|
2024-04-04 15:37:46 +07:00
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-04-19 14:15:08 +07:00
|
|
|
name: "including",
|
2024-04-04 15:37:46 +07:00
|
|
|
align: "left",
|
|
|
|
|
label: "รหัสตัวชี้วัด",
|
|
|
|
|
sortable: true,
|
2024-04-19 14:15:08 +07:00
|
|
|
field: "including",
|
2024-04-04 15:37:46 +07:00
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-04-19 14:15:08 +07:00
|
|
|
name: "includingName",
|
2024-04-04 15:37:46 +07:00
|
|
|
align: "left",
|
|
|
|
|
label: "ชื่อตัวชี้วัด",
|
|
|
|
|
sortable: true,
|
2024-04-19 14:15:08 +07:00
|
|
|
field: "includingName",
|
2024-04-04 15:37:46 +07:00
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
]);
|
2024-04-19 14:15:08 +07:00
|
|
|
const visibleColumns = ref<string[]>(["no", "including", "includingName"]);
|
2024-04-04 15:37:46 +07:00
|
|
|
|
|
|
|
|
const positionOp = ref<any[]>([
|
|
|
|
|
{ id: "1", name: "นักจัดการทั่วไป 1" },
|
|
|
|
|
{ id: "2", name: "นักจัดการทั่วไป 2" },
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
const roundOp = ref<any[]>([
|
|
|
|
|
{ id: "1", name: "รอบเมษายน" },
|
|
|
|
|
{ id: "2", name: "รอบตุลาคม" },
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
const formFilter = reactive({
|
|
|
|
|
page: 1,
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
position: "1",
|
|
|
|
|
round: "1",
|
|
|
|
|
keyword: "",
|
|
|
|
|
});
|
2024-04-19 14:15:08 +07:00
|
|
|
const pagination = ref({
|
|
|
|
|
page: formFilter.page,
|
|
|
|
|
rowsPerPage: formFilter.pageSize,
|
|
|
|
|
});
|
2024-04-04 15:37:46 +07:00
|
|
|
|
|
|
|
|
function fetchList() {
|
|
|
|
|
showLoader();
|
2024-04-19 14:15:08 +07:00
|
|
|
http
|
|
|
|
|
.get(
|
|
|
|
|
config.API.kpiRoleMainList +
|
|
|
|
|
`?page=${formFilter.page}&pageSize=${formFilter.pageSize}`
|
|
|
|
|
)
|
|
|
|
|
.then((res) => {
|
|
|
|
|
console.log(res);
|
|
|
|
|
const data = res.data.result.data;
|
|
|
|
|
maxPage.value = Math.ceil(res.data.result.total / formFilter.pageSize);
|
|
|
|
|
rows.value = data;
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
|
|
|
|
});
|
2024-04-04 15:37:46 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onClickAddOrView(status: boolean = false, id: string = "") {
|
2024-04-09 10:31:22 +07:00
|
|
|
status
|
|
|
|
|
? router.push(`/KPI-indicator-role/${id}`)
|
|
|
|
|
: router.push("/KPI-indicator-role/add");
|
2024-04-04 15:37:46 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onClickDelete(id: number) {
|
|
|
|
|
dialogRemove($q, () => {
|
2024-04-19 14:15:08 +07:00
|
|
|
http
|
|
|
|
|
.delete(config.API.kpiRoleMainList+`/${id}`)
|
|
|
|
|
.then((res)=>{
|
|
|
|
|
success($q, "ลบข้อมูลสำเร็จ");
|
|
|
|
|
fetchList()
|
|
|
|
|
}).finally(()=>{
|
|
|
|
|
|
|
|
|
|
})
|
2024-04-04 15:37:46 +07:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-19 14:15:08 +07:00
|
|
|
function updatePage(val: number) {
|
|
|
|
|
formFilter.page = val;
|
|
|
|
|
fetchList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updatePageSize(newPagination: NewPagination) {
|
|
|
|
|
formFilter.page = 1;
|
|
|
|
|
formFilter.pageSize = newPagination.rowsPerPage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
() => formFilter.pageSize,
|
|
|
|
|
() => {
|
|
|
|
|
fetchList();
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2024-04-04 15:37:46 +07:00
|
|
|
onMounted(() => {
|
|
|
|
|
fetchList();
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
2024-04-04 10:26:13 +07:00
|
|
|
<template>
|
2024-04-04 15:37:46 +07:00
|
|
|
<div class="toptitle text-dark col-12 row items-center">
|
2024-04-17 17:17:05 +07:00
|
|
|
รายการตัวชี้วัดตามตำแหน่ง
|
2024-04-04 15:37:46 +07:00
|
|
|
</div>
|
|
|
|
|
<q-card flat bordered class="q-pa-md">
|
2024-04-04 16:27:17 +07:00
|
|
|
<q-toolbar class="q-pa-none">
|
2024-04-04 15:37:46 +07:00
|
|
|
<div class="row q-gutter-sm">
|
|
|
|
|
<q-select
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
|
|
|
|
v-model="formFilter.position"
|
|
|
|
|
:options="positionOp"
|
|
|
|
|
label="ตำแหน่ง"
|
|
|
|
|
option-label="name"
|
|
|
|
|
option-value="id"
|
|
|
|
|
emit-value
|
|
|
|
|
map-options
|
|
|
|
|
/>
|
|
|
|
|
<q-select
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
|
|
|
|
v-model="formFilter.round"
|
|
|
|
|
:options="positionOp"
|
2024-04-04 17:58:08 +07:00
|
|
|
label="รอบการประเมิน"
|
2024-04-04 15:37:46 +07:00
|
|
|
option-label="name"
|
|
|
|
|
option-value="id"
|
|
|
|
|
emit-value
|
|
|
|
|
map-options
|
|
|
|
|
/>
|
2024-04-04 16:27:17 +07:00
|
|
|
</div>
|
|
|
|
|
<q-toolbar-title>
|
2024-04-04 15:37:46 +07:00
|
|
|
<q-btn
|
|
|
|
|
flat
|
|
|
|
|
round
|
|
|
|
|
dense
|
|
|
|
|
icon="add"
|
|
|
|
|
color="primary"
|
|
|
|
|
@click="onClickAddOrView()"
|
|
|
|
|
>
|
|
|
|
|
<q-tooltip>เพิ่ม</q-tooltip>
|
|
|
|
|
</q-btn>
|
2024-04-04 16:27:17 +07:00
|
|
|
</q-toolbar-title>
|
2024-04-04 15:37:46 +07:00
|
|
|
|
|
|
|
|
<q-space />
|
|
|
|
|
<div class="row q-gutter-sm">
|
|
|
|
|
<q-input
|
|
|
|
|
standout
|
|
|
|
|
dense
|
|
|
|
|
v-model="formFilter.keyword"
|
|
|
|
|
ref="filterRef"
|
|
|
|
|
outlined
|
|
|
|
|
debounce="300"
|
|
|
|
|
placeholder="ค้นหา"
|
|
|
|
|
>
|
|
|
|
|
<template v-slot:append>
|
|
|
|
|
<q-icon v-if="formFilter.keyword == ''" name="search" />
|
|
|
|
|
<q-icon
|
|
|
|
|
v-if="formFilter.keyword !== ''"
|
|
|
|
|
name="clear"
|
|
|
|
|
class="cursor-pointer"
|
|
|
|
|
@click="formFilter.keyword = ''"
|
|
|
|
|
/>
|
|
|
|
|
</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
|
|
|
|
|
style="min-width: 150px"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</q-toolbar>
|
|
|
|
|
|
|
|
|
|
<div class="col-12">
|
|
|
|
|
<d-table
|
|
|
|
|
for="table"
|
|
|
|
|
ref="table"
|
|
|
|
|
:columns="columns"
|
|
|
|
|
:rows="rows"
|
|
|
|
|
row-key="subject"
|
|
|
|
|
flat
|
|
|
|
|
bordered
|
|
|
|
|
dense
|
|
|
|
|
class="custom-header-table"
|
|
|
|
|
:visible-columns="visibleColumns"
|
2024-04-19 14:15:08 +07:00
|
|
|
:rows-per-page-options="[10, 20, 50, 100]"
|
|
|
|
|
@update:pagination="updatePageSize"
|
2024-04-04 15:37:46 +07:00
|
|
|
>
|
2024-04-19 14:15:08 +07:00
|
|
|
<template v-slot:pagination="scope">
|
|
|
|
|
<q-pagination
|
|
|
|
|
v-model="formFilter.page"
|
|
|
|
|
active-color="primary"
|
|
|
|
|
color="dark"
|
|
|
|
|
:max="maxPage"
|
|
|
|
|
:max-pages="5"
|
|
|
|
|
size="sm"
|
|
|
|
|
boundary-links
|
|
|
|
|
direction-links
|
|
|
|
|
@update:model-value="updatePage"
|
|
|
|
|
></q-pagination>
|
|
|
|
|
</template>
|
2024-04-04 15:37:46 +07:00
|
|
|
<template v-slot:header="props">
|
|
|
|
|
<q-tr :props="props">
|
|
|
|
|
<q-th v-for="col in props.cols" :key="col.name" :props="props">
|
|
|
|
|
<span class="text-weight-medium">{{ col.label }}</span>
|
|
|
|
|
</q-th>
|
|
|
|
|
<q-th auto-width />
|
|
|
|
|
</q-tr>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-slot:body="props">
|
|
|
|
|
<q-tr :props="props" class="cursor-pointer">
|
|
|
|
|
<q-td
|
|
|
|
|
v-for="col in props.cols"
|
|
|
|
|
:key="col.name"
|
|
|
|
|
:props="props"
|
|
|
|
|
@click="onClickAddOrView(true, props.row.id)"
|
|
|
|
|
>
|
2024-04-19 14:15:08 +07:00
|
|
|
<div v-if="col.name === 'no'">
|
|
|
|
|
{{
|
|
|
|
|
(formFilter.page - 1) * Number(pagination.rowsPerPage) + props.rowIndex + 1
|
|
|
|
|
}}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div v-else class="table_ellipsis">
|
2024-04-04 15:37:46 +07:00
|
|
|
{{ col.value ? col.value : "-" }}
|
|
|
|
|
</div>
|
|
|
|
|
</q-td>
|
|
|
|
|
<q-td>
|
|
|
|
|
<q-btn
|
|
|
|
|
flat
|
|
|
|
|
round
|
|
|
|
|
icon="delete"
|
|
|
|
|
color="red"
|
2024-04-19 14:15:08 +07:00
|
|
|
@click.stop.pervent="onClickDelete(props.row.id)"
|
2024-04-04 15:37:46 +07:00
|
|
|
>
|
|
|
|
|
<q-tooltip>ลบข้อมูล </q-tooltip>
|
|
|
|
|
</q-btn>
|
|
|
|
|
</q-td>
|
|
|
|
|
</q-tr>
|
|
|
|
|
</template>
|
|
|
|
|
</d-table>
|
2024-04-04 10:26:13 +07:00
|
|
|
</div>
|
2024-04-04 15:37:46 +07:00
|
|
|
</q-card>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped></style>
|