ปรับ ตัวชี้วัด ตามแผน รอ API

This commit is contained in:
STW_TTTY\stwtt 2024-05-07 15:18:52 +07:00
parent 789627a6a9
commit ad66cacc1e
6 changed files with 385 additions and 212 deletions

View file

@ -0,0 +1,65 @@
<script setup lang="ts">
import { ref } from "vue";
import DialogHeader from "@/components/DialogHeader.vue";
import type { QTableProps } from "quasar";
const modal = defineModel<boolean>("modal", { required: true });
const rows = ref<any[]>([]);
const visibleColumns = ref<string[]>(["fullName"]);
const columns = ref<QTableProps["columns"]>([
{
name: "fullName",
align: "left",
label: "ชื่อ",
sortable: true,
field: "fullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
]);
function close() {
modal.value = false;
}
</script>
<template>
<q-dialog persistent v-model="modal">
<q-card style="min-width: 50vw">
<DialogHeader tittle="ประวัติการแก้ไข" :close="close" />
<q-separator />
<q-card-section>
<d-table
for="table"
ref="table"
:columns="columns"
:rows="rows"
row-key="id"
flat
bordered
dense
class="custom-header-table"
:rows-per-page-options="[10, 25, 50, 100]"
:visible-columns="visibleColumns"
>
<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">
<div class="table_ellipsis">
{{ col.value ? col.value : "-" }}
</div>
</q-td>
</q-tr>
</template>
</d-table>
</q-card-section>
</q-card>
</q-dialog>
</template>

View file

@ -28,14 +28,15 @@ const {
} = mixin;
const id = ref<string>(route.params.id ? route.params.id.toLocaleString() : "");
const editCheck = ref<boolean>(route.params.id ? true : false);
/**form ตัวชี้วัดตามแผนฯ*/
const planData = reactive({
kpiPeriodId: "", //(->APR, ->OCT)
period: "", //(->APR, ->OCT)
including: "", //
includingName: "", //
target: "", //
unit: null, //
unit: "", //
weight: null, //
achievement1: "", // 1
achievement2: "", // 2
@ -49,10 +50,14 @@ const planData = reactive({
orgRevisionId: "", //RevisionId
strategy: null, //
strategyId: "", //id
documentInfoEvidence: "", //
});
const year = ref<number>(0); //
const roundOp = ref<DataOption[]>([]);
const year = ref<number | null>(0); //
const roundOp = ref<DataOption[]>([
{ id: "APR", name: "รอบเมษายน" },
{ id: "OCT", name: "รอบตุลาคม" },
]);
const nodeplan = ref<any>([]);
const nodeAgency = ref<any>([]);
@ -64,36 +69,6 @@ const expandedAgency = ref<string[]>([]);
const editStatus = ref<boolean>(false);
const inputRef = ref<any>(null);
/** functiopn fetch รอบการประเมิน*/
function fetchRoundOption(isId: number | null = null) {
http
.get(
config.API.kpiPeriod +
`?page=${1}&pageSize=${10}&keyword=${""}&year=${year.value}`
)
.then((res) => {
const data = res.data.result.data;
const list = data.map((e: any) => ({
id: e.id,
name:
e.durationKPI === "OCT"
? "รอบตุลาคม"
: e.durationKPI === "APR"
? "รอบเมษายน"
: "",
}));
roundOp.value = list;
if (isId) {
planData.kpiPeriodId = "";
inputRef.value.resetValidation();
}
})
.catch((err) => {
messageError($q, err);
});
}
/** function fetch หาโครงสร้างที่ใช้งาน*/
function fetchOrganizationActive() {
http
@ -147,7 +122,7 @@ function fetchDataById(id: string) {
.then((res) => {
const data = res.data.result;
year.value = data.year;
planData.kpiPeriodId = data.kpiPeriodId;
planData.period = data.round;
planData.including = data.including;
planData.includingName = data.includingName;
planData.target = data.target;
@ -189,8 +164,6 @@ function fetchDataById(id: string) {
expandedPlan.value = arrayexpandedPlan
.filter((e) => e !== null)
.slice(0, -1);
fetchRoundOption();
})
.catch((err) => {
messageError($q, err);
@ -235,6 +208,27 @@ function onSubmit() {
dialogConfirm(
$q,
async () => {
const body = {
year: year.value == 0 ? null : year.value,
period: planData.period,
includingName: planData.includingName,
target: planData.target,
unit: planData.unit,
weight: planData.weight,
achievement1: planData.achievement1,
achievement2: planData.achievement2,
achievement3: planData.achievement3,
achievement4: planData.achievement4,
achievement5: planData.achievement5,
meaning: planData.meaning,
formula: planData.formula,
node: planData.node,
nodeId: planData.nodeId,
orgRevisionId: planData.orgRevisionId,
strategy: planData.strategy,
strategyId: planData.strategyId,
documentInfoEvidence: planData.documentInfoEvidence,
};
showLoader();
// editStatus.value ? editData(id.value) : addData();
try {
@ -242,7 +236,7 @@ function onSubmit() {
? config.API.kpiPlanById(id.value)
: config.API.kpiPlan;
const method = editStatus.value ? "put" : "post";
const res = await http[method](url, planData);
const res = await http[method](url, body);
success($q, "บันทึกข้อมูลสำเร็จ");
editStatus.value
? fetchDataById(id.value)
@ -272,6 +266,29 @@ onMounted(() => {
<q-form @submit.prevent greedy @validation-success="onSubmit()">
<div>
<div class="row q-col-gutter-md q-pa-md">
<div class="col-2" v-if="editCheck">
<q-input
outlined
v-model="planData.including"
label="ลำดับ/รหัสตัวชี้วัด"
bg-color="white"
readonly
dense
class="inputgreen"
/>
</div>
<div :class="`${editCheck ? 'col-6' : 'col-8'}`">
<q-input
outlined
v-model="planData.includingName"
label="ชื่อตัวชี้วัด"
bg-color="white"
dense
class="inputgreen"
:rules="[(val) => !!val || `${'กรุณากรอกชิ่อตัวชี้วัด'}`]"
hide-bottom-space
/>
</div>
<div class="col-2">
<datepicker
menu-class-name="modalfix"
@ -280,7 +297,7 @@ onMounted(() => {
autoApply
year-picker
:enableTimePicker="false"
@update:modelValue="fetchRoundOption"
@update:modelValue="planData.period = ''"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
@ -303,6 +320,17 @@ onMounted(() => {
>
</q-icon>
</template>
<template v-slot:append>
<q-icon
v-if="year"
name="cancel"
class="cursor-pointer"
@click.stop.prevent="
year = 0;
planData.period = '';
"
/>
</template>
</q-input>
</template>
</datepicker>
@ -310,47 +338,17 @@ onMounted(() => {
<div class="col-2">
<q-select
ref="inputRef"
:readonly="roundOp.length === 0"
:readonly="year == 0"
dense
outlined
v-model="planData.kpiPeriodId"
v-model="planData.period"
:options="roundOp"
label="รอบการประเมิน"
hide-bottom-space
option-label="name"
option-value="id"
map-options
emit-value
lazy-rules
class="inputgreen"
:rules="[
(val:string) =>
!!val || `${'กรุณาเลือกรอบการประเมิน'}`,
]"
/>
</div>
<div class="col-2">
<q-input
outlined
v-model="planData.including"
label="รหัสตัวชี้วัด"
bg-color="white"
dense
class="inputgreen"
:rules="[(val) => !!val || `${'กรุณากรอกรหัสตัวชี้วัด'}`]"
hide-bottom-space
/>
</div>
<div class="col-6">
<q-input
outlined
v-model="planData.includingName"
label="ชื่อตัวชี้วัด"
bg-color="white"
dense
class="inputgreen"
:rules="[(val) => !!val || `${'กรุณากรอกชิ่อตัวชี้วัด'}`]"
hide-bottom-space
/>
</div>
<div class="col-4">
@ -371,8 +369,8 @@ onMounted(() => {
v-model="planData.unit"
label="หน่วยนับ"
bg-color="white"
type="number"
dense
lazy-rules
class="inputgreen"
:rules="[(val) => !!val || `${'กรุณากรอกหน่วยนับ'}`]"
hide-bottom-space
@ -644,6 +642,16 @@ onMounted(() => {
</q-card-section>
</q-card>
</div>
<div class="col-12">
<q-input
class="inputgreen"
v-model="planData.documentInfoEvidence"
label="ข้อมูลเอกสารหลักฐาน"
outlined
dense
type="textarea"
></q-input>
</div>
</div>
<q-separator color="grey-4" />
</div>

View file

@ -45,6 +45,7 @@ const form = reactive<FormDataRole>({
weight: "", //
meaning: "", //
formula: "", //
documentInfoEvidence: "", //
node: null,
nodeId: null,
@ -71,7 +72,10 @@ const positionOp = ref<DataOption[]>([]);
const positionMainOp = ref<DataOption[]>([]);
/** Option รอบการประเมิน*/
const roundOp = ref<DataOption[]>([]);
const roundOp = ref<DataOption[]>([
{ id: "APR", name: "รอบเมษายน" },
{ id: "OCT", name: "รอบตุลาคม" },
]);
/**
* function นหาขอมลของ Option
@ -121,9 +125,9 @@ function onSubmit() {
: config.API.kpiRoleMainList;
const body = {
year: form.year == 0 ? null:form.year,
position: form.position, //
kpiPeriodId: form.round, //(->APR, ->OCT)
including: form.including, //
period: form.round, //(->APR, ->OCT)
includingName: form.includingName, //
target: form.target, //
unit: form.unit, //
@ -135,6 +139,7 @@ function onSubmit() {
achievement5: formScore.score5, // 5
meaning: form.meaning, //
formula: form.formula, //
documentInfoEvidence: form.documentInfoEvidence, //
node: form.node, //
nodeId: form.nodeId, //id
@ -171,7 +176,7 @@ function getDetail() {
const data = res.data.result;
form.position = data.position;
form.year = data.year == null ? 0 : data.year;
form.round = data.kpiPeriodId;
form.round = data.round;
form.including = data.including;
form.includingName = data.includingName;
form.target = data.target;
@ -244,21 +249,6 @@ function updateSelected(data: any) {
form.orgRevisionId = data.orgRevisionId;
}
function getRound() {
showLoader();
http
.get(config.API.kpiPeriod + `?year=${form.year}`)
.then((res) => {
const data = res.data.result.data;
roundOp.value = data.map((item: any) => ({
id: item.id,
name: statusTothai(item.durationKPI),
}));
})
.finally(() => {
hideLoader();
});
}
function statusTothai(val: string) {
switch (val) {
@ -284,7 +274,6 @@ function setModel(val: string) {
onMounted(() => {
fetchActive();
getOptions();
getRound();
if (id.value !== "") {
getDetail();
}
@ -345,7 +334,7 @@ onMounted(() => {
autoApply
year-picker
:enableTimePicker="false"
@update:model-value="(form.round = ''), getRound()"
@update:model-value="form.round = ''"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
@ -355,8 +344,6 @@ onMounted(() => {
<q-input
dense
class="inputgreen"
:rules="[(val:string) => !!val || `${'กรุณาเลือกปีงบประมาณ'}`,]"
hide-bottom-space
outlined
:model-value="
form.year === 0 ? null : Number(form.year) + 543
@ -371,12 +358,24 @@ onMounted(() => {
>
</q-icon>
</template>
<template v-slot:append>
<q-icon
v-if="form.year"
name="cancel"
class="cursor-pointer"
@click.stop.prevent="
form.year = 0;
form.round = '';
"
/>
</template>
</q-input>
</template>
</datepicker>
</div>
<div class="col-2">
<q-select
:readonly="form.year == 0"
dense
outlined
v-model="form.round"
@ -388,21 +387,16 @@ onMounted(() => {
input-class="text-red"
label="รอบการประเมิน"
class="inputgreen"
lazy-rules
:rules="[(val:string) => !!val || `${'กรุณาเลือกรอบการประเมิน'}`,]"
hide-bottom-space
/>
</div>
<div class="col-2">
<div class="col-2" v-if="id">
<q-input
label="รหัสตัวชี้วัด"
label="ลำดับ/รหัสตัวชี้วัด"
v-model="form.including"
outlined
readonly
dense
class="inputgreen"
lazy-rules
:rules="[(val:string) => !!val || `${'กรุณากรอกรหัสตัวชี้วัด'}`,]"
hide-bottom-space
/>
</div>
<div class="col-4">
@ -632,6 +626,16 @@ onMounted(() => {
type="textarea"
/>
</div>
<div class="col-12">
<q-input
class="inputgreen"
v-model="form.documentInfoEvidence"
label="ข้อมูลเอกสารหลักฐาน"
outlined
dense
type="textarea"
></q-input>
</div>
</div>
</q-card-section>
<q-separator />