แก้ไขคะแนนเต็ม

This commit is contained in:
STW_TTTY\stwtt 2024-04-29 13:41:41 +07:00
parent 9f14fc9a7b
commit eb87dee240
2 changed files with 182 additions and 19 deletions

View file

@ -23,6 +23,9 @@ export default {
kpiAchievement: (type: string) => `${kpiAchievement}/${type}`,
kpiAchievementPoint: (type: string) => `${kpiAchievement}/${type}/point`,
kpiScoreTotal: () => `${kpiEvaluation}/point`,
/** ผลสัมฤทธิ์ของงาน*/
fileByFile: (name: string, group: string, id: string, fileName: string) =>
`${url}/file/${name}/${group}/${id}/${fileName}`,

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref, onMounted, reactive } from "vue";
import { ref, onMounted, reactive, computed, watch } from "vue";
import { useRoute, useRouter } from "vue-router";
import http from "@/plugins/http";
import config from "@/app.config";
@ -13,11 +13,26 @@ import DialogHeader from "@/components/DialogHeader.vue";
import type { FormProfile } from "@/modules/08_KPI/interface/request/index";
import type { DataOptions } from "@/modules/08_KPI/interface/index/Main";
const scoreTotal = ref<boolean>(false);
const modalScore = ref<boolean>(false);
const modalEdit = ref<boolean>(false);
const route = useRoute();
const id = ref<string>(route.params.id as string);
const isReadonly = <boolean>(route.name === "KPIEditEvaluator" ? true : false);
const totalScore = computed(
() =>
Number(plannedPoint.value) +
Number(rolePoint.value) +
Number(specialPoint.value) +
Number(capacityPoint.value)
);
const plannedPoint = ref<string>("");
const rolePoint = ref<string>("");
const specialPoint = ref<string>("");
const capacityPoint = ref<string>("");
const store = useKpiDataStore();
const $q = useQuasar();
const mixin = useCounterMixin();
@ -59,6 +74,12 @@ function fetchEvaluation() {
formProfile.result = store.convertResults(data.evaluationResults);
fetchProfile(data.profileId);
console.log(store.dataEvaluation);
plannedPoint.value = data.plannedPoint == null ? "" : data.plannedPoint;
rolePoint.value = data.rolePoint == null ? "" : data.rolePoint;
specialPoint.value = data.specialPoint == null ? "" : data.specialPoint;
capacityPoint.value =
data.capacityPoint == null ? "" : data.capacityPoint;
})
.catch((e) => {
messageError($q, e);
@ -127,26 +148,27 @@ async function clearDialog() {
function onSubmit() {
dialogConfirm($q, () => {
if(id.value){
if (id.value) {
showLoader();
http
.put(config.API.kpiEvaluationCheck + `/${id.value}`, {
evaluatorId: evaluatorId.value ? evaluatorId.value.id:null,
commanderId: commanderId.value ? commanderId.value.id:null,
commanderHighId: commanderHighId.value ? commanderHighId.value.id:null,
})
.then((res) => {
success($q, "บันทึกสำเร็จ");
clearDialog();
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
http
.put(config.API.kpiEvaluationCheck + `/${id.value}`, {
evaluatorId: evaluatorId.value ? evaluatorId.value.id : null,
commanderId: commanderId.value ? commanderId.value.id : null,
commanderHighId: commanderHighId.value
? commanderHighId.value.id
: null,
})
.then((res) => {
success($q, "บันทึกสำเร็จ");
clearDialog();
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
});
}
@ -221,6 +243,53 @@ function filterOption(val: any, update: Function, refData: string) {
}
}
watch(
[plannedPoint, rolePoint, specialPoint, capacityPoint],
(
[newPlannedPoint, newRolePoint, newSpecialPoint, newCapacityPoint],
[oldPlannedPoint, oldRolePoint, oldSpecialPoint, oldCapacityPoint]
) => {
if (
newPlannedPoint !== "" &&
newRolePoint !== "" &&
newSpecialPoint !== "" &&
newCapacityPoint !== ""
) {
if (totalScore.value == 100) {
scoreTotal.value = false;
} else {
scoreTotal.value = true;
}
} else {
console.log(2);
}
}
);
function onSubmitScore() {
showLoader();
http
.put(config.API.kpiScoreTotal() + `/${id.value}`, {
plannedPoint:plannedPoint.value,
rolePoint:rolePoint.value,
specialPoint:specialPoint.value,
capacityPoint:capacityPoint.value
})
.then(async (res) => {
await fetchEvaluation();
await getProfile();
await getOrgOp();
await success($q, "บันทึกสำเร็จ");
modalScore.value = false
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
onMounted(async () => {
await fetchEvaluation();
await getProfile();
@ -276,6 +345,18 @@ onMounted(async () => {
}}</span>
<q-space />
<div class="q-gutter-x-sm">
<q-btn
v-if="!isReadonly"
unelevated
round
icon="mdi-format-list-bulleted-square"
color="grey-2"
text-color="amber-10"
size="md"
@click="modalScore = true"
>
<q-tooltip>แกไขคะแนนเต</q-tooltip>
</q-btn>
<q-btn
v-if="!isReadonly"
unelevated
@ -462,6 +543,85 @@ onMounted(async () => {
</q-form>
</q-card>
</q-dialog>
<q-dialog v-model="modalScore" persistent>
<q-card bordered style="width: 50vh">
<q-form greedy @submit.prevent @validation-success="onSubmitScore">
<DialogHeader
tittle="แก้ไขคะแนนเต็ม"
:close="
() => {
modalScore = false;
}
"
/>
<q-separator />
<q-card-section>
<div class="column q-gutter-sm">
<q-input
v-model="plannedPoint"
label="งานตามแผนปฏิบัติราชการประจำปี"
dense
outlined
class="inputgreen"
mask="###"
:rules="[(val:string) => !!val || `${'กรุณากรอกคะเเนนงานตามแผนปฏิบัติราชการประจำปี หรือ 0'}`,]"
hide-bottom-space
lazy-rules
/>
<q-input
v-model="rolePoint"
label="งานตามหน้าที่ความรับผิดชอบหลัก"
dense
outlined
class="inputgreen"
mask="###"
:rules="[(val:string) => !!val || `${'กรุณากรอกคะเเนนงานตามหน้าที่ความรับผิดชอบหลัก หรือ 0'}`,]"
hide-bottom-space
lazy-rules
/>
<q-input
v-model="specialPoint"
label="งานที่ได้รับมอบหมายพิเศษ"
dense
outlined
class="inputgreen"
mask="###"
:rules="[(val:string) => !!val || `${'กรุณากรอกคะเเนนงานที่ได้รับมอบหมายพิเศษ หรือ 0'}`,]"
hide-bottom-space
lazy-rules
/>
<q-input
v-model="capacityPoint"
label="สมรรถนะ"
dense
outlined
class="inputgreen"
mask="###"
:rules="[(val:string) => !!val || `${'กรุณากรอกคะเเนนสมรรถนะ หรือ 0'}`,]"
hide-bottom-space
lazy-rules
/>
</div>
</q-card-section>
<q-separator />
<q-card-actions class="bg-white row justify-between">
<div class="col-8 text-center text-red text-bold">
<span v-if="scoreTotal == true"
>คะแนนเตมรวมกนตองเทาก 100 คะแนน</span
>
</div>
<q-btn
label="บันทึก"
color="secondary"
type="submit"
:disable="totalScore !== 100"
><q-tooltip>นทกขอม</q-tooltip></q-btn
>
</q-card-actions>
</q-form>
</q-card>
</q-dialog>
</template>
<style>
.bg-toolbar {