API ฟอร์มบันทึกหลักเกณฑ์
This commit is contained in:
parent
838ae1ae3c
commit
eedb90d155
3 changed files with 46 additions and 26 deletions
|
|
@ -1,10 +1,12 @@
|
||||||
import env from "../index";
|
import env from "../index";
|
||||||
const KPI = `${env.API_URI}/kpi`;
|
const KPI = `${env.API_URI}/kpi`;
|
||||||
const kpiPeriod = `${env.API_URI}/kpi/period`;
|
const kpiPeriod = `${env.API_URI}/kpi/period`;
|
||||||
|
const kpiEvaluation = `${env.API_URI}/kpi/evaluation`;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
KPI,
|
KPI,
|
||||||
/** รอบการประเมินผล*/
|
/** รอบการประเมินผล*/
|
||||||
kpiPeriod: `${kpiPeriod}`,
|
kpiPeriod: `${kpiPeriod}`,
|
||||||
kpiPeriodById: (id: string) => `${kpiPeriod}/${id}`,
|
kpiPeriodById: (id: string) => `${kpiPeriod}/${id}`,
|
||||||
|
kpiEvaluation
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,14 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, onMounted, watch } from "vue";
|
import { ref, reactive, onMounted, watch } from "vue";
|
||||||
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
|
|
||||||
|
import http from "@/plugins/http";
|
||||||
|
import config from "@/app.config";
|
||||||
|
import { useQuasar } from "quasar";
|
||||||
|
|
||||||
|
const $q = useQuasar();
|
||||||
|
const dataLevel = ref<any>();
|
||||||
|
const { showLoader, hideLoader, success } = useCounterMixin();
|
||||||
const fieldLabels = {
|
const fieldLabels = {
|
||||||
score5: "5",
|
score5: "5",
|
||||||
score4: "4",
|
score4: "4",
|
||||||
|
|
@ -23,26 +31,39 @@ interface FormScore {
|
||||||
score3: string;
|
score3: string;
|
||||||
score2: string;
|
score2: string;
|
||||||
score1: string;
|
score1: string;
|
||||||
[key:string]:any
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSubmit() {
|
function onSubmit() {
|
||||||
const array = ref<any>([])
|
|
||||||
|
|
||||||
for (const key in formScore) {
|
|
||||||
if (formScore.hasOwnProperty(key)) {
|
|
||||||
if (key in formScore) {
|
|
||||||
const scoreObj: Partial<FormScore> = {}; // กำหนด scoreObj ให้เป็น Partial<FormScore>
|
|
||||||
scoreObj[key] = formScore[key];
|
|
||||||
array.value.push(scoreObj)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const body = {
|
const body = {
|
||||||
formScore: array.value ,
|
formScore: dataLevel.value.map((item: any) => {
|
||||||
|
const { level, ...rest } = item;
|
||||||
|
return rest;
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
console.log(body);
|
|
||||||
|
http
|
||||||
|
.put(config.API.kpiEvaluation, body.formScore)
|
||||||
|
.then((res) => {
|
||||||
|
success($q, "บันทึกสำเร็จ");
|
||||||
|
})
|
||||||
|
.finally(() => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getData() {
|
||||||
|
showLoader();
|
||||||
|
http
|
||||||
|
.get(config.API.kpiEvaluation)
|
||||||
|
.then((res) => {
|
||||||
|
dataLevel.value = res.data.result;
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
hideLoader();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
onMounted(() => {
|
||||||
|
getData();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -55,16 +76,13 @@ const array = ref<any>([])
|
||||||
</div>
|
</div>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
<q-card-section class="q-pa-none">
|
<q-card-section class="q-pa-none">
|
||||||
<div
|
<div v-for="(field, index) in dataLevel" :key="field.id">
|
||||||
v-for="(field, index) in Object.keys(fieldLabels)"
|
|
||||||
:key="index + 1"
|
|
||||||
>
|
|
||||||
<div class="row q-pa-sm">
|
<div class="row q-pa-sm">
|
||||||
<div class="col-8 text-left">
|
<div class="col-8 text-left">
|
||||||
<q-field
|
<q-field
|
||||||
class="q_field_p_none"
|
class="q_field_p_none"
|
||||||
ref="fieldRef"
|
ref="fieldRef"
|
||||||
v-model="formScore[field]"
|
v-model="field.description"
|
||||||
label-slot
|
label-slot
|
||||||
borderless
|
borderless
|
||||||
:rules="[(val) => !!val || 'กรุณากรอกมาตรฐานพฤติกรรม']"
|
:rules="[(val) => !!val || 'กรุณากรอกมาตรฐานพฤติกรรม']"
|
||||||
|
|
@ -73,7 +91,7 @@ const array = ref<any>([])
|
||||||
<template #control>
|
<template #control>
|
||||||
<q-editor
|
<q-editor
|
||||||
class="full-width"
|
class="full-width"
|
||||||
v-model="formScore[field]"
|
v-model="field.description"
|
||||||
:dense="$q.screen.lt.md"
|
:dense="$q.screen.lt.md"
|
||||||
min-height="5rem"
|
min-height="5rem"
|
||||||
:toolbar="[
|
:toolbar="[
|
||||||
|
|
@ -114,7 +132,7 @@ const array = ref<any>([])
|
||||||
<div
|
<div
|
||||||
class="col-4 text-center text-body1 text-weight-bold self-center"
|
class="col-4 text-center text-body1 text-weight-bold self-center"
|
||||||
>
|
>
|
||||||
{{ fieldLabels[field as keyof typeof fieldLabels] }}
|
{{ field.level }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
|
|
|
||||||
|
|
@ -371,7 +371,7 @@ onMounted(() => {
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-8" style="height: 340px">
|
<div class="col-4" style="height: 340px">
|
||||||
<q-card flat bordered>
|
<q-card flat bordered>
|
||||||
<q-card-section class="bg-grey-3 q-pa-sm">
|
<q-card-section class="bg-grey-3 q-pa-sm">
|
||||||
<div class="text-dark text-body2 text-weight-medium">
|
<div class="text-dark text-body2 text-weight-medium">
|
||||||
|
|
@ -439,12 +439,12 @@ onMounted(() => {
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-4" style="height: 340px">
|
<div class="col-8" style="height: 340px">
|
||||||
<q-card flat bordered>
|
<q-card flat bordered>
|
||||||
<q-card-section class="bg-grey-3 q-pa-sm">
|
<q-card-section class="bg-grey-3 q-pa-sm">
|
||||||
<div class="row text-dark text-body2 text-weight-medium">
|
<div class="row text-dark text-body2 text-weight-medium">
|
||||||
<div class="text-center col-4">ระดับคะแนน</div>
|
<div class="text-center col-4">ระดับคะแนน</div>
|
||||||
<div class="col-8">อ้างอิง</div>
|
<div class="col-8">ผลสำเร็จของงาน</div>
|
||||||
</div>
|
</div>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
<q-card-section class="q-pa-none">
|
<q-card-section class="q-pa-none">
|
||||||
|
|
@ -504,8 +504,8 @@ onMounted(() => {
|
||||||
dense
|
dense
|
||||||
outlined
|
outlined
|
||||||
class="inputgreen"
|
class="inputgreen"
|
||||||
label="กรอกข้อความเพื่อไว้ใช้อ้างอิงเท่านั้น"
|
label="กรอกผลสำเร็จของงาน"
|
||||||
:rules="[(val:string) => !!val || `${'กรุณากรอกข้อความเพื่อไว้ใช้อ้างอิงเท่านั้น'}`,]"
|
:rules="[(val:string) => !!val || `${'กรุณากรอกผลสำเร็จของงาน'}`,]"
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue