983 lines
30 KiB
Vue
983 lines
30 KiB
Vue
<!-- card ผลการประเมินการปฏิบัติราชการ -->
|
||
<template>
|
||
<q-card flat bordered class="col-12 q-px-lg q-pa-md">
|
||
<q-form ref="myForm">
|
||
<ProfileTable
|
||
:rows="rows"
|
||
:columns="columns"
|
||
:filter="filter"
|
||
:visible-columns="visibleColumns"
|
||
v-model:inputfilter="filter"
|
||
v-model:inputvisible="visibleColumns"
|
||
:add="clickAdd"
|
||
name="ผลการประเมินการปฏิบัติราชการ"
|
||
icon="mdi-clipboard-text"
|
||
:statusEdit="statusEdit"
|
||
>
|
||
<template #columns="props">
|
||
<q-tr :props="props">
|
||
<q-td
|
||
v-for="col in props.cols"
|
||
:key="col.name"
|
||
:props="props"
|
||
@click="selectData(props)"
|
||
class="cursor-pointer"
|
||
>
|
||
<div v-if="col.name == 'date'" class="table_ellipsis">
|
||
{{ date2Thai(col.value) }}
|
||
</div>
|
||
<div v-else-if="col.name == 'name'" class="table_ellipsis">
|
||
{{ textPoint(props.row.pointSum) }}
|
||
{{ textRangePoint(props.row.pointSum) }}
|
||
</div>
|
||
<div v-else class="table_ellipsis">
|
||
{{ col.value }}
|
||
</div>
|
||
</q-td>
|
||
<q-td auto-width>
|
||
<q-btn
|
||
color="info"
|
||
flat
|
||
dense
|
||
round
|
||
size="14px"
|
||
icon="mdi-history"
|
||
@click="clickHistory(props.row)"
|
||
>
|
||
<q-tooltip>ประวัติแก้ไขผลการประเมินการปฏิบัติราชการ</q-tooltip>
|
||
</q-btn>
|
||
</q-td>
|
||
</q-tr>
|
||
</template>
|
||
</ProfileTable>
|
||
</q-form>
|
||
</q-card>
|
||
<!-- popup Edit window-->
|
||
<q-dialog v-model="modal" persistent>
|
||
<q-card style="width: 600px">
|
||
<q-form ref="myForm">
|
||
<DialogHeader
|
||
tittle="ผลการประเมินการปฏิบัติราชการ"
|
||
:close="clickClose"
|
||
/>
|
||
<q-separator />
|
||
<q-card-section class="q-p-sm">
|
||
<div
|
||
class="row col-12 q-col-gutter-x-xs q-col-gutter-y-xs"
|
||
>
|
||
<div class="col-xs-12 col-sm-12 col-md-12">
|
||
<datepicker
|
||
menu-class-name="modalfix"
|
||
:readonly="!edit"
|
||
v-model="date"
|
||
:locale="'th'"
|
||
autoApply
|
||
:enableTimePicker="false"
|
||
@update:modelValue="clickEditRow"
|
||
week-start="0"
|
||
>
|
||
<template #year="{ year }">{{ year + 543 }}</template>
|
||
<template #year-overlay-value="{ value }">{{
|
||
parseInt(value + 543)
|
||
}}</template>
|
||
<template #trigger>
|
||
<q-input
|
||
:class="getClass(edit)"
|
||
:outlined="edit"
|
||
dense
|
||
lazy-rules
|
||
:borderless="!edit"
|
||
:model-value="date2Thai(date)"
|
||
:rules="[(val) => !!val || `${'กรุณาเลือกวันที่ได้รับ'}`]"
|
||
hide-bottom-space
|
||
:label="`${'วันที่ได้รับ'}`"
|
||
>
|
||
<template v-slot:prepend>
|
||
<q-icon
|
||
name="event"
|
||
class="cursor-pointer"
|
||
:style="
|
||
edit
|
||
? 'color: var(--q-primary)'
|
||
: 'color: var(--q-grey)'
|
||
"
|
||
>
|
||
</q-icon>
|
||
</template>
|
||
</q-input>
|
||
</template>
|
||
</datepicker>
|
||
</div>
|
||
<!-- <div class="col-6">
|
||
<q-input
|
||
:class="getClass(edit)"
|
||
:outlined="edit"
|
||
dense
|
||
lazy-rules
|
||
:readonly="!edit"
|
||
:borderless="!edit"
|
||
v-model="point"
|
||
:rules="[(val) => !!val || `${'กรุณากรอกคะแนน'}`]"
|
||
hide-bottom-space
|
||
:label="`${'คะแนน'}`"
|
||
@update:modelValue="clickEditRow"
|
||
type="number"
|
||
/>
|
||
</div> -->
|
||
<div class="col-6">
|
||
<q-input
|
||
input-class="text-right"
|
||
:class="getClass(edit)"
|
||
:outlined="edit"
|
||
dense
|
||
lazy-rules
|
||
:readonly="!edit"
|
||
:borderless="!edit"
|
||
v-model="point1Total"
|
||
:rules="[(val) => !!val || `${'กรุณากรอกส่วนที่1 (คะแนน)'}`]"
|
||
hide-bottom-space
|
||
:label="`${'ส่วนที่1 (คะแนน)'}`"
|
||
@update:modelValue="clickEditRow"
|
||
type="number"
|
||
/>
|
||
</div>
|
||
<div class="col-6">
|
||
<q-input
|
||
input-class="text-right"
|
||
:class="getClass(edit)"
|
||
:outlined="edit"
|
||
dense
|
||
lazy-rules
|
||
:readonly="!edit"
|
||
:borderless="!edit"
|
||
v-model="point1"
|
||
:rules="[
|
||
(val) => !!val || `${'กรุณากรอกผลประเมินส่วนที่1 (คะแนน)'}`,
|
||
]"
|
||
hide-bottom-space
|
||
:label="`${'ผลประเมินส่วนที่1 (คะแนน)'}`"
|
||
@update:modelValue="clickEditRow"
|
||
type="number"
|
||
/>
|
||
</div>
|
||
<div class="col-6">
|
||
<q-input
|
||
input-class="text-right"
|
||
:class="getClass(edit)"
|
||
:outlined="edit"
|
||
dense
|
||
lazy-rules
|
||
:readonly="!edit"
|
||
:borderless="!edit"
|
||
v-model="point2Total"
|
||
:rules="[(val) => !!val || `${'กรุณากรอกส่วนที่2 (คะแนน)'}`]"
|
||
hide-bottom-space
|
||
:label="`${'ส่วนที่2 (คะแนน)'}`"
|
||
@update:modelValue="clickEditRow"
|
||
type="number"
|
||
/>
|
||
</div>
|
||
<div class="col-6">
|
||
<q-input
|
||
input-class="text-right"
|
||
:class="getClass(edit)"
|
||
:outlined="edit"
|
||
dense
|
||
lazy-rules
|
||
:readonly="!edit"
|
||
:borderless="!edit"
|
||
v-model="point2"
|
||
:rules="[
|
||
(val) => !!val || `${'กรุณากรอกผลประเมินส่วนที่2 (คะแนน)'}`,
|
||
]"
|
||
hide-bottom-space
|
||
:label="`${'ผลประเมินส่วนที่2 (คะแนน)'}`"
|
||
@update:modelValue="clickEditRow"
|
||
type="number"
|
||
/>
|
||
</div>
|
||
<div class="col-6">
|
||
<q-input
|
||
input-class="text-right"
|
||
:class="getClass(edit)"
|
||
:outlined="edit"
|
||
dense
|
||
lazy-rules
|
||
:readonly="!edit"
|
||
:borderless="!edit"
|
||
v-model="pointSumTotal"
|
||
:rules="[(val) => !!val || `${'กรุณากรอกผลรวม (คะแนน)'}`]"
|
||
hide-bottom-space
|
||
:label="`${'ผลรวม (คะแนน)'}`"
|
||
@update:modelValue="clickEditRow"
|
||
type="number"
|
||
/>
|
||
</div>
|
||
<div class="col-6">
|
||
<q-input
|
||
input-class="text-right"
|
||
:class="getClass(edit)"
|
||
:outlined="edit"
|
||
dense
|
||
lazy-rules
|
||
:readonly="!edit"
|
||
:borderless="!edit"
|
||
v-model="pointSum"
|
||
:rules="[
|
||
(val) => !!val || `${'กรุณากรอกผลประเมินรวม (คะแนน)'}`,
|
||
]"
|
||
hide-bottom-space
|
||
:label="`${'ผลประเมินรวม (คะแนน)'}`"
|
||
@update:modelValue="clickEditRow"
|
||
type="number"
|
||
/>
|
||
</div>
|
||
<div class="text-subtitle2 col-12 row items-center">
|
||
<q-space></q-space>
|
||
ผลการประเมิน:
|
||
<div class="text-bold items-center q-px-sm">
|
||
{{ textPoint(pointSum) }}
|
||
</div>
|
||
{{ textRangePoint(pointSum) }}
|
||
</div>
|
||
<!-- <div class="col-12">
|
||
<q-input
|
||
:class="getClass(edit)"
|
||
:outlined="edit"
|
||
dense
|
||
lazy-rules
|
||
:readonly="!edit"
|
||
:borderless="!edit"
|
||
v-model="name"
|
||
:rules="[(val) => !!val || `${'กรุณากรอกชื่อแบบประเมิน'}`]"
|
||
hide-bottom-space
|
||
:label="`${'ชื่อแบบประเมิน'}`"
|
||
@update:modelValue="clickEditRow"
|
||
/>
|
||
</div> -->
|
||
</div>
|
||
</q-card-section>
|
||
<q-separator />
|
||
<DialogFooter
|
||
:cancel="clickCancel"
|
||
:edit="clickEdit"
|
||
:save="clickSave"
|
||
:validate="validateData"
|
||
:clickNext="clickNext"
|
||
:clickPrevious="clickPrevious"
|
||
:clickDelete="clickDelete"
|
||
v-model:editvisible="edit"
|
||
v-model:next="next"
|
||
v-model:previous="previous"
|
||
v-model:modalEdit="modalEdit"
|
||
/>
|
||
</q-form>
|
||
</q-card>
|
||
</q-dialog>
|
||
<HistoryTable
|
||
:rows="rowsHistory"
|
||
:columns="columnsHistory"
|
||
:filter="filterHistory"
|
||
:visible-columns="visibleColumnsHistory"
|
||
v-model:modal="modalHistory"
|
||
v-model:inputfilter="filterHistory"
|
||
v-model:inputvisible="visibleColumnsHistory"
|
||
v-model:tittle="tittleHistory"
|
||
>
|
||
<template #columns="props">
|
||
<q-tr :props="props">
|
||
<q-td v-for="col in props.cols" :key="col.name" :props="props">
|
||
<div
|
||
v-if="col.name == 'date' || col.name == 'createdAt'"
|
||
class="table_ellipsis"
|
||
>
|
||
{{ date2Thai(col.value) }}
|
||
</div>
|
||
<div v-else-if="col.name == 'name'" class="table_ellipsis">
|
||
{{ textPoint(props.row.pointSum) }}
|
||
{{ textRangePoint(props.row.pointSum) }}
|
||
</div>
|
||
<div v-else class="table_ellipsis">
|
||
{{ col.value }}
|
||
</div>
|
||
</q-td>
|
||
</q-tr>
|
||
</template>
|
||
</HistoryTable>
|
||
</template>
|
||
<script setup lang="ts">
|
||
import { onMounted, ref, watch } from "vue";
|
||
import { useRoute } from "vue-router";
|
||
import { useCounterMixin } from "@/stores/mixin";
|
||
import { useProfileDataStore } from "@/modules/04_registry/store";
|
||
|
||
import ProfileTable from "@/modules/04_registry/components/Table.vue";
|
||
import DialogHeader from "@/modules/04_registry/components/DialogHeader.vue";
|
||
import DialogFooter from "@/modules/04_registry/components/DialogFooter.vue";
|
||
import { useQuasar } from "quasar";
|
||
import type {
|
||
RequestItemsObject,
|
||
DataProps,
|
||
} from "@/modules/04_registry/interface/request/Assessment";
|
||
import type { ResponseObject } from "@/modules/04_registry/interface/response/Assessment";
|
||
import type { DataOption } from "@/modules/04_registry/interface/index/Main";
|
||
import HistoryTable from "@/components/TableHistory.vue";
|
||
import http from "@/plugins/http";
|
||
import config from "@/app.config";
|
||
import type { QTableProps } from "quasar";
|
||
|
||
const props = defineProps({
|
||
statusEdit: {
|
||
type: Boolean,
|
||
required: true,
|
||
},
|
||
profileType: {
|
||
type: String,
|
||
required: true,
|
||
},
|
||
});
|
||
|
||
const $q = useQuasar();
|
||
const store = useProfileDataStore();
|
||
const { profileData, changeProfileColumns } = store;
|
||
|
||
const mixin = useCounterMixin();
|
||
const { date2Thai, success, dateToISO, messageError, showLoader, hideLoader } =
|
||
mixin;
|
||
const route = useRoute();
|
||
const id = ref<string>("");
|
||
const name = ref<string>();
|
||
const point1Total = ref<number>();
|
||
const point1 = ref<number>();
|
||
const point2Total = ref<number>();
|
||
const point2 = ref<number>();
|
||
const pointSumTotal = ref<number>();
|
||
const pointSum = ref<number>();
|
||
const date = ref<Date>(new Date());
|
||
const myForm = ref<any>(); //form data input
|
||
const edit = ref<boolean>(false); //เช็คการกดปุ่มแก้ไขใน dialog
|
||
const modal = ref<boolean>(false); //modal add detail
|
||
const modalEdit = ref<boolean>(false); //modal ที่แสดงใช้สำหรับแก้ไขหรือไม่
|
||
const rawItem = ref<RequestItemsObject>(); //ข้อมูลเดิมที่เลือกใน row นั้น
|
||
const rowIndex = ref<number>(0); //indexข้อมูลเดิมที่เลือกใน row นั้น
|
||
const previous = ref<boolean>(); //แสดงปุ่มดูข้อมูลก่อนหน้า
|
||
const next = ref<boolean>(); //แสดงปุ่มดูข้อมูลต่อไป
|
||
const editRow = ref<boolean>(false); //เช็คมีการแก้ไขข้อมูล
|
||
const rowsHistory = ref<RequestItemsObject[]>([]); //select data history
|
||
const tittleHistory = ref<string>("ประวัติแก้ไขผลการประเมินการปฏิบัติราชการ"); //
|
||
const filterHistory = ref<string>(""); //search data table history
|
||
const modalHistory = ref<boolean>(false); //modal ประวัติการแก้ไขข้อมูล
|
||
const checkValidate = ref<boolean>(false); //validate data ผ่านหรือไม่
|
||
const profileId = ref<string>(
|
||
route.params.id ? route.params.id.toString() : ""
|
||
);
|
||
const rows = ref<RequestItemsObject[]>([]);
|
||
const filter = ref<string>(""); //search data table
|
||
const visibleColumns = ref<String[]>([]);
|
||
profileData.assessment.columns.length == 0
|
||
? (visibleColumns.value = [
|
||
"point1Total",
|
||
"point1",
|
||
"point2Total",
|
||
"point2",
|
||
"pointSumTotal",
|
||
"pointSum",
|
||
"name",
|
||
"date",
|
||
])
|
||
: (visibleColumns.value = profileData.assessment.columns);
|
||
const columns = ref<QTableProps["columns"]>([
|
||
{
|
||
name: "date",
|
||
align: "left",
|
||
label: "วันที่ได้รับ",
|
||
sortable: true,
|
||
field: "date",
|
||
headerStyle: "font-size: 14px",
|
||
style: "font-size: 14px",
|
||
sort: (a: string, b: string) =>
|
||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||
},
|
||
{
|
||
name: "point1Total",
|
||
align: "left",
|
||
label: "ส่วนที่1 (คะแนน)",
|
||
sortable: true,
|
||
field: "point1Total",
|
||
headerStyle: "font-size: 14px",
|
||
style: "font-size: 14px",
|
||
sort: (a: string, b: string) =>
|
||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||
},
|
||
{
|
||
name: "point1",
|
||
align: "left",
|
||
label: "ผลประเมินส่วนที่1 (คะแนน)",
|
||
sortable: true,
|
||
field: "point1",
|
||
headerStyle: "font-size: 14px",
|
||
style: "font-size: 14px",
|
||
sort: (a: string, b: string) =>
|
||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||
},
|
||
{
|
||
name: "point2Total",
|
||
align: "left",
|
||
label: "ส่วนที่2 (คะแนน)",
|
||
sortable: true,
|
||
field: "point2Total",
|
||
headerStyle: "font-size: 14px",
|
||
style: "font-size: 14px",
|
||
sort: (a: string, b: string) =>
|
||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||
},
|
||
{
|
||
name: "point2",
|
||
align: "left",
|
||
label: "ผลประเมินส่วนที่2 (คะแนน)",
|
||
sortable: true,
|
||
field: "point2",
|
||
headerStyle: "font-size: 14px",
|
||
style: "font-size: 14px",
|
||
sort: (a: string, b: string) =>
|
||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||
},
|
||
{
|
||
name: "pointSumTotal",
|
||
align: "left",
|
||
label: "ผลรวม (คะแนน)",
|
||
sortable: true,
|
||
field: "pointSumTotal",
|
||
headerStyle: "font-size: 14px",
|
||
style: "font-size: 14px",
|
||
sort: (a: string, b: string) =>
|
||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||
},
|
||
{
|
||
name: "pointSum",
|
||
align: "left",
|
||
label: "ผลประเมินรวม (คะแนน)",
|
||
sortable: true,
|
||
field: "pointSum",
|
||
headerStyle: "font-size: 14px",
|
||
style: "font-size: 14px",
|
||
sort: (a: string, b: string) =>
|
||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||
},
|
||
{
|
||
name: "name",
|
||
align: "left",
|
||
label: "ผลประเมิน",
|
||
sortable: true,
|
||
field: "name",
|
||
headerStyle: "font-size: 14px",
|
||
style: "font-size: 14px",
|
||
sort: (a: string, b: string) =>
|
||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||
},
|
||
]);
|
||
const columnsHistory = ref<QTableProps["columns"]>([
|
||
{
|
||
name: "point1Total",
|
||
align: "left",
|
||
label: "ส่วนที่1 (คะแนน)",
|
||
sortable: true,
|
||
field: "point1Total",
|
||
headerStyle: "font-size: 14px",
|
||
style: "font-size: 14px",
|
||
sort: (a: string, b: string) =>
|
||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||
},
|
||
{
|
||
name: "point1",
|
||
align: "left",
|
||
label: "ผลประเมินส่วนที่1 (คะแนน)",
|
||
sortable: true,
|
||
field: "point1",
|
||
headerStyle: "font-size: 14px",
|
||
style: "font-size: 14px",
|
||
sort: (a: string, b: string) =>
|
||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||
},
|
||
{
|
||
name: "point2Total",
|
||
align: "left",
|
||
label: "ส่วนที่2 (คะแนน)",
|
||
sortable: true,
|
||
field: "point2Total",
|
||
headerStyle: "font-size: 14px",
|
||
style: "font-size: 14px",
|
||
sort: (a: string, b: string) =>
|
||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||
},
|
||
{
|
||
name: "point2",
|
||
align: "left",
|
||
label: "ผลประเมินส่วนที่2 (คะแนน)",
|
||
sortable: true,
|
||
field: "point2",
|
||
headerStyle: "font-size: 14px",
|
||
style: "font-size: 14px",
|
||
sort: (a: string, b: string) =>
|
||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||
},
|
||
{
|
||
name: "pointSumTotal",
|
||
align: "left",
|
||
label: "ผลรวม (คะแนน)",
|
||
sortable: true,
|
||
field: "pointSumTotal",
|
||
headerStyle: "font-size: 14px",
|
||
style: "font-size: 14px",
|
||
sort: (a: string, b: string) =>
|
||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||
},
|
||
{
|
||
name: "pointSum",
|
||
align: "left",
|
||
label: "ผลประเมินรวม (คะแนน)",
|
||
sortable: true,
|
||
field: "pointSum",
|
||
headerStyle: "font-size: 14px",
|
||
style: "font-size: 14px",
|
||
sort: (a: string, b: string) =>
|
||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||
},
|
||
{
|
||
name: "name",
|
||
align: "left",
|
||
label: "ผลประเมิน",
|
||
sortable: true,
|
||
field: "name",
|
||
headerStyle: "font-size: 14px",
|
||
style: "font-size: 14px",
|
||
sort: (a: string, b: string) =>
|
||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||
},
|
||
{
|
||
name: "createdFullName",
|
||
align: "left",
|
||
label: "ผู้ดำเนินการ",
|
||
sortable: true,
|
||
field: "createdFullName",
|
||
headerStyle: "font-size: 14px",
|
||
style: "font-size: 14px",
|
||
sort: (a: string, b: string) =>
|
||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||
},
|
||
{
|
||
name: "createdAt",
|
||
align: "left",
|
||
label: "วันที่แก้ไข",
|
||
sortable: true,
|
||
field: "createdAt",
|
||
headerStyle: "font-size: 14px",
|
||
style: "font-size: 14px",
|
||
sort: (a: string, b: string) =>
|
||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||
},
|
||
]);
|
||
const visibleColumnsHistory = ref<String[]>([
|
||
"point1Total",
|
||
"point1",
|
||
"point2Total",
|
||
"point2",
|
||
"pointSumTotal",
|
||
"pointSum",
|
||
"name",
|
||
"date",
|
||
"createdFullName",
|
||
"createdAt",
|
||
]);
|
||
|
||
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
|
||
await changeProfileColumns("assessment", count);
|
||
});
|
||
|
||
onMounted(async () => {
|
||
await fetchData();
|
||
});
|
||
|
||
const fetchData = async () => {
|
||
if (profileId.value) {
|
||
showLoader();
|
||
await http
|
||
.get(config.API.profileAssessmentId(profileId.value))
|
||
.then((res) => {
|
||
let data = res.data.result;
|
||
rows.value = [];
|
||
data.map((e: ResponseObject) => {
|
||
rows.value.push({
|
||
id: e.id,
|
||
name: e.name,
|
||
point1Total: e.point1Total,
|
||
point1: e.point1,
|
||
point2Total: e.point2Total,
|
||
point2: e.point2,
|
||
pointSumTotal: e.pointSumTotal,
|
||
pointSum: e.pointSum,
|
||
date: new Date(e.date),
|
||
createdAt: new Date(e.createdAt),
|
||
createdFullName: e.createdFullName,
|
||
});
|
||
});
|
||
})
|
||
.catch((e) => {
|
||
messageError($q, e);
|
||
})
|
||
.finally(() => {
|
||
hideLoader();
|
||
});
|
||
}
|
||
};
|
||
|
||
/**
|
||
* กดดูข้อมูลก่อนหน้า
|
||
*/
|
||
const clickPrevious = async () => {
|
||
edit.value = false;
|
||
rowIndex.value -= 1;
|
||
await getData();
|
||
await checkRowPage();
|
||
};
|
||
|
||
/**
|
||
* กดดูข้อมูลต่อไป
|
||
*/
|
||
const clickNext = async () => {
|
||
edit.value = false;
|
||
rowIndex.value += 1;
|
||
await getData();
|
||
await checkRowPage();
|
||
};
|
||
|
||
/**
|
||
* กดดูข้อมูลต่อไป
|
||
*/
|
||
const getData = () => {
|
||
const row = rows.value[rowIndex.value];
|
||
name.value = row.name;
|
||
point1Total.value = row.point1Total;
|
||
point1.value = row.point1;
|
||
point2Total.value = row.point2Total;
|
||
point2.value = row.point2;
|
||
pointSumTotal.value = row.pointSumTotal;
|
||
pointSum.value = row.pointSum;
|
||
date.value = row.date;
|
||
id.value = row.id;
|
||
};
|
||
|
||
/**
|
||
* เช็คปุ่มดูข้อมูล ย้อน กับ ต่อไป ว่าต้องแสดงไหม
|
||
*/
|
||
const checkRowPage = () => {
|
||
editRow.value = false;
|
||
next.value = true;
|
||
previous.value = true;
|
||
if (rowIndex.value + 1 >= rows.value.length) {
|
||
next.value = false;
|
||
}
|
||
if (rowIndex.value - 1 < 0) {
|
||
previous.value = false;
|
||
}
|
||
};
|
||
|
||
/**
|
||
* กดปุ่มแก้ไขใน dialog
|
||
*/
|
||
const clickEdit = () => {
|
||
editRow.value = false;
|
||
next.value = false;
|
||
previous.value = false;
|
||
};
|
||
|
||
/**
|
||
* กดปุ่มเพิ่มด้านบน table
|
||
*/
|
||
const clickAdd = async () => {
|
||
editRow.value = false;
|
||
await addData();
|
||
};
|
||
|
||
/**
|
||
* กดบันทึกใน dialog
|
||
*/
|
||
const clickSave = async () => {
|
||
myForm.value.validate().then(async (result: boolean) => {
|
||
if (result) {
|
||
if (modalEdit.value) {
|
||
await editData();
|
||
} else {
|
||
await saveData();
|
||
}
|
||
}
|
||
});
|
||
};
|
||
|
||
/**
|
||
* บันทึกเพิ่มข้อมูล
|
||
*/
|
||
const saveData = async () => {
|
||
if (profileId.value) {
|
||
showLoader();
|
||
await http
|
||
.post(config.API.profileAssessmentId(profileId.value), {
|
||
id: id.value,
|
||
name: name.value,
|
||
point1Total: point1Total.value,
|
||
point1: point1.value,
|
||
point2Total: point2Total.value,
|
||
point2: point2.value,
|
||
pointSumTotal: pointSumTotal.value,
|
||
pointSum: pointSum.value,
|
||
date: dateToISO(date.value),
|
||
})
|
||
.then((res) => {
|
||
success($q, "บันทึกข้อมูลสำเร็จ");
|
||
modal.value = false;
|
||
})
|
||
.catch((e) => {
|
||
messageError($q, e);
|
||
})
|
||
.finally(async () => {
|
||
await fetchData();
|
||
});
|
||
}
|
||
};
|
||
|
||
/**
|
||
* บันทึกแก้ไขข้อมูล
|
||
*/
|
||
const editData = async () => {
|
||
showLoader();
|
||
await http
|
||
.put(config.API.profileAssessmentId(id.value), {
|
||
id: id.value,
|
||
name: name.value,
|
||
point1Total: point1Total.value,
|
||
point1: point1.value,
|
||
point2Total: point2Total.value,
|
||
point2: point2.value,
|
||
pointSumTotal: pointSumTotal.value,
|
||
pointSum: pointSum.value,
|
||
date: dateToISO(date.value),
|
||
})
|
||
.then((res) => {
|
||
success($q, "บันทึกข้อมูลสำเร็จ");
|
||
modal.value = false;
|
||
})
|
||
.catch((e) => {
|
||
messageError($q, e);
|
||
})
|
||
.finally(async () => {
|
||
await fetchData();
|
||
});
|
||
};
|
||
|
||
/**
|
||
* ลบลบข้อมูล
|
||
*/
|
||
const clickDelete = async () => {
|
||
$q.dialog({
|
||
title: `ลบข้อมูล`,
|
||
message: `ต้องการทำการลบข้อมูลนี้ใช่หรือไม่?`,
|
||
cancel: "ยกเลิก",
|
||
ok: "ยืนยัน",
|
||
persistent: true,
|
||
})
|
||
.onOk(async () => {
|
||
showLoader();
|
||
await http
|
||
.delete(config.API.profileAssessmentId(id.value))
|
||
.then((res) => {
|
||
success($q, "ลบข้อมูลสำเร็จ");
|
||
modal.value = false;
|
||
})
|
||
.catch((e) => {
|
||
messageError($q, e);
|
||
})
|
||
.finally(async () => {
|
||
await fetchData();
|
||
});
|
||
})
|
||
.onCancel(async () => {
|
||
await fetchData();
|
||
});
|
||
};
|
||
|
||
/**
|
||
* กดปิด dialog
|
||
*/
|
||
const clickClose = async () => {
|
||
if (editRow.value == true) {
|
||
$q.dialog({
|
||
title: `ข้อมูลมีการแก้ไข`,
|
||
message: `ยืนยันที่จะปิดโดยไม่บันทึกใช่หรือไม่?`,
|
||
cancel: "ยกเลิก",
|
||
ok: "ยืนยัน",
|
||
persistent: true,
|
||
}).onOk(async () => {
|
||
modal.value = false;
|
||
next.value = false;
|
||
previous.value = false;
|
||
});
|
||
} else {
|
||
modal.value = false;
|
||
next.value = false;
|
||
previous.value = false;
|
||
}
|
||
};
|
||
|
||
/**
|
||
* กดเลือกข้อมูลที่จะแก้ไข
|
||
* @param props ค่า props ใน row ที่เลือก
|
||
*/
|
||
const selectData = async (props: DataProps) => {
|
||
modalEdit.value = true;
|
||
modal.value = true;
|
||
edit.value = false;
|
||
rawItem.value = props.row;
|
||
rowIndex.value = props.rowIndex;
|
||
name.value = props.row.name;
|
||
point1Total.value = props.row.point1Total;
|
||
point1.value = props.row.point1;
|
||
point2Total.value = props.row.point2Total;
|
||
point2.value = props.row.point2;
|
||
pointSumTotal.value = props.row.pointSumTotal;
|
||
pointSum.value = props.row.pointSum;
|
||
date.value = props.row.date;
|
||
id.value = props.row.id;
|
||
await checkRowPage();
|
||
};
|
||
|
||
/**
|
||
* กดปุ่มเพิ่มบน table
|
||
*/
|
||
const addData = () => {
|
||
modalEdit.value = false;
|
||
modal.value = true;
|
||
edit.value = true;
|
||
name.value = "";
|
||
point1Total.value = 0;
|
||
point1.value = 0;
|
||
point2Total.value = 0;
|
||
point2.value = 0;
|
||
pointSumTotal.value = 0;
|
||
pointSum.value = 0;
|
||
date.value = new Date();
|
||
};
|
||
|
||
/**
|
||
* ฟังก์ชันปุ่มยกเลิกการแก้ไขข้อมูล
|
||
*/
|
||
const clickCancel = async () => {
|
||
if (editRow.value == true) {
|
||
$q.dialog({
|
||
title: `ข้อมูลมีการแก้ไข`,
|
||
message: `ยืนยันยกเลิกการแก้ไขใช่หรือไม่?`,
|
||
cancel: "ยกเลิก",
|
||
ok: "ยืนยัน",
|
||
persistent: true,
|
||
}).onOk(async () => {
|
||
edit.value = false;
|
||
await checkRowPage();
|
||
await getData();
|
||
});
|
||
} else {
|
||
edit.value = false;
|
||
await checkRowPage();
|
||
}
|
||
};
|
||
|
||
/**
|
||
* เช็คว่ามีการแก้ไขข้อมูล
|
||
*/
|
||
const clickEditRow = () => {
|
||
editRow.value = true;
|
||
};
|
||
|
||
/**
|
||
* ฟังชั้นดูข้อมูลประวัติแก้ไขข้อมูลที่เลือก
|
||
* @param row ข้อมูล row ที่ดูประวัติการแก้ไข
|
||
*/
|
||
const clickHistory = async (row: RequestItemsObject) => {
|
||
tittleHistory.value = "ประวัติแก้ไขผลการประเมินการปฏิบัติราชการ";
|
||
modalHistory.value = true;
|
||
showLoader();
|
||
await http
|
||
.get(config.API.profileAssessmentHisId(row.id))
|
||
.then((res) => {
|
||
let data = res.data.result;
|
||
rowsHistory.value = [];
|
||
data.map((e: ResponseObject) => {
|
||
rowsHistory.value.push({
|
||
id: e.id,
|
||
name: e.name,
|
||
point1Total: e.point1Total,
|
||
point1: e.point1,
|
||
point2Total: e.point2Total,
|
||
point2: e.point2,
|
||
pointSumTotal: e.pointSumTotal,
|
||
pointSum: e.pointSum,
|
||
date: new Date(e.date),
|
||
createdAt: new Date(e.createdAt),
|
||
createdFullName: e.createdFullName,
|
||
});
|
||
});
|
||
})
|
||
.catch((e) => {
|
||
messageError($q, e);
|
||
})
|
||
.finally(() => {
|
||
hideLoader();
|
||
});
|
||
};
|
||
|
||
/**
|
||
* validate input ใน dialog
|
||
*/
|
||
const validateData = async () => {
|
||
checkValidate.value = true;
|
||
await myForm.value.validate().then((result: boolean) => {
|
||
if (result == false) {
|
||
checkValidate.value = false;
|
||
}
|
||
});
|
||
};
|
||
|
||
/**
|
||
* class จัดรูปแบบแสดงระหว่างข้อมูลที่แก้ไขหรือแสดงเฉยๆ
|
||
* @param val ข้อมูล input สำหรับแก้ไขหรือไม่
|
||
*/
|
||
const getClass = (val: boolean) => {
|
||
return {
|
||
"full-width inputgreen cursor-pointer": val,
|
||
"full-width cursor-pointer": !val,
|
||
};
|
||
};
|
||
|
||
const textRangePoint = (val: number | undefined) => {
|
||
if (val == undefined) val = -1;
|
||
if (val >= 0 && val <= 60) return "(ต่ำกว่าร้อยละ 60)";
|
||
if (val >= 60 && val <= 69) return "(ร้อยละ 60 – 69)";
|
||
if (val >= 70 && val <= 79) return "(ร้อยละ 70 – 79)";
|
||
if (val >= 80 && val <= 89) return "(ร้อยละ 80 – 89)";
|
||
if (val >= 90 && val <= 100) return "(ร้อยละ 90 - 100)";
|
||
else return "";
|
||
};
|
||
|
||
const textPoint = (val: number | undefined) => {
|
||
if (val == undefined) val = -1;
|
||
if (val >= 0 && val <= 60) return "ต้องปรับปรุง";
|
||
if (val >= 60 && val <= 69) return "พอใช้";
|
||
if (val >= 70 && val <= 79) return "ดี";
|
||
if (val >= 80 && val <= 89) return "ดีมาก";
|
||
if (val >= 90 && val <= 100) return "ดีเด่น";
|
||
else return "-";
|
||
};
|
||
</script>
|
||
<style lang="scss">
|
||
.modalfix {
|
||
position: fixed !important;
|
||
}
|
||
</style>
|