Refactor Code รายการช่วยราชการ

This commit is contained in:
setthawutttty 2023-09-21 10:49:05 +07:00
parent 021fa97b61
commit b48765d0e3
5 changed files with 393 additions and 704 deletions

View file

@ -3,16 +3,9 @@ import { onMounted, ref } from "vue";
import { useQuasar } from "quasar";
import { useRoute, useRouter } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import type { QTableProps, QForm } from "quasar";
// import type {
// TypeFile,
// ResponseDataDetail,
// } from "@/modules/05_placement/interface/response/Transfer";
import type { QForm } from "quasar";
const $q = useQuasar();
const route = useRoute();
@ -29,11 +22,8 @@ const {
success,
} = mixin;
const roleAdmin = ref<boolean>(false);
const myForm = ref<QForm | null>(null);
const name = ref<string>("นายสมคิด ยอดใจ");
const level = ref<string>("ชำนาญการพิเศษ");
const institution = ref<string>("ฝ่ายบริหารงานทั่วไป");
const fullname = ref<string>("");
const id = ref<string>("");
const profileId = ref<string>("");
@ -88,7 +78,6 @@ const getData = async () => {
isActive.value = data.isActive;
})
.catch((e) => {
// messageError($q, e);
})
.finally(() => {
hideLoader();
@ -102,9 +91,6 @@ const getClass = (val: boolean) => {
};
//
const conditionSave = async () => {
// if (myForm.value !== null) {
// myForm.value.validate().then((success: any) => {
// if (success) {
dialogConfirm(
$q,
async () => await saveData(),
@ -112,9 +98,7 @@ const conditionSave = async () => {
"แก้ไขข้อมูลเพื่อลงบัญชีแนบท้าย"
);
};
// });
// }
// };
const cancelBtn = () => {
edit.value = !edit;
getData();
@ -135,8 +119,6 @@ const saveData = async () => {
await http
.put(config.API.officerMainEdit(dataId), body)
.then((res: any) => {
// const data = res.data.result;
// console.log(data);
success($q, "แก้ไขข้อมูลเพื่อลงบัญชีแนบท้ายสำเร็จ");
edit.value = false;
})
@ -156,31 +138,16 @@ onMounted(async () => {
<template>
<div class="toptitle text-dark col-12 row items-center">
<q-btn
icon="mdi-arrow-left"
unelevated
round
dense
flat
color="primary"
class="q-mr-sm"
@click="router.go(-1)"
/>
<q-btn icon="mdi-arrow-left" unelevated round dense flat color="primary"
class="q-mr-sm" @click="router.push(`/help-government`)" />
รายละเอยดการชวยราชการ {{ fullname }}
</div>
<q-card bordered class="row col-12 text-dark">
<div class="bg-grey-1 q-pa-sm col-12 row items-center text-primary">
<div class="q-pl-sm text-weight-bold text-subtitle2">{{ fullname }}</div>
<q-space />
<q-btn
outline
color="blue"
dense
icon-right="mdi-open-in-new"
class="q-px-sm"
label="ดูข้อมูลทะเบียนประวัติ"
@click="router.push(`/registry/${profileId}`)"
/>
<q-btn outline color="blue" dense icon-right="mdi-open-in-new" class="q-px-sm"
label="ดูข้อมูลทะเบียนประวัติ" @click="router.push(`/registry/${profileId}`)" />
</div>
<div class="col-12"><q-separator /></div>
<div class="row col-12 q-pa-md">
@ -224,37 +191,15 @@ onMounted(async () => {
</div>
<q-space />
<div class="q-gutter-sm" v-if="!edit">
<q-btn
outline
color="primary"
dense
icon-right="mdi-file-edit-outline"
class="q-px-sm"
label="แก้ไข"
style="width: 80px"
@click="edit = !edit"
v-if="!(status == 'REPORT' || status == 'DONE')"
/>
<q-btn outline color="primary" dense icon-right="mdi-file-edit-outline"
class="q-px-sm" label="แก้ไข" style="width: 80px" @click="edit = !edit"
v-if="!(status == 'REPORT' || status == 'DONE')" />
</div>
<div class="q-gutter-sm" v-else>
<q-btn
outline
color="public"
dense
class="q-px-sm"
label="บันทึก"
style="width: 80px"
@click="conditionSave"
/>
<q-btn
outline
color="red"
dense
class="q-px-sm"
label="ยกเลิก"
style="width: 80px"
@click="cancelBtn"
/>
<q-btn outline color="public" dense class="q-px-sm" label="บันทึก" style="width: 80px"
@click="conditionSave" />
<q-btn outline color="red" dense class="q-px-sm" label="ยกเลิก"
style="width: 80px" @click="cancelBtn" />
</div>
</div>
<div class="col-12"><q-separator /></div>
@ -268,143 +213,35 @@ onMounted(async () => {
</div>
</div>
<div class="col-12">
<q-input
:class="getClass(edit)"
:outlined="edit"
dense
lazy-rules
:readonly="!edit"
:borderless="!edit"
v-model="organizationPositionOld"
:rules="[(val) => !!val || `${'กรุณากรอกตำแหน่ง/สังกัด'}`]"
hide-bottom-space
:label="`${'ตำแหน่ง'}`"
type="textarea"
/>
<q-input :class="getClass(edit)" :outlined="edit" dense lazy-rules :readonly="!edit"
:borderless="!edit" v-model="organizationPositionOld" :rules="[(val) => !!val || `${'กรุณากรอกตำแหน่ง/สังกัด'}`]"
hide-bottom-space :label="`${'ตำแหน่ง'}`" type="textarea" />
</div>
</div>
<!-- <div class="col-xs-6 col-sm-3 row items-center">
<div class="col-12">
<q-input
:class="getClass(edit)"
:outlined="edit"
dense
lazy-rules
:readonly="!edit"
:borderless="!edit"
v-model="positionTypeOld"
:rules="[(val) => !!val || `${'กรุณากรอกตำแหน่งประเภท'}`]"
hide-bottom-space
:label="`${'ตำแหน่งประเภท'}`"
/>
</div>
</div>
<div class="col-xs-6 col-sm-3 row items-center">
<div class="col-12">
<q-input
:class="getClass(edit)"
:outlined="edit"
dense
lazy-rules
:readonly="!edit"
:borderless="!edit"
v-model="positionLevelOld"
:rules="[(val) => !!val || `${'กรุณากรอกระดับ'}`]"
hide-bottom-space
:label="`${'ระดับ'}`"
/>
</div>
</div>
<div class="col-xs-6 col-sm-3 row items-center">
<div class="col-12">
<q-input
:class="getClass(edit)"
:outlined="edit"
dense
lazy-rules
:readonly="!edit"
:borderless="!edit"
v-model="posNo"
:rules="[(val) => !!val || `${'กรุณากรอกเลขที่'}`]"
hide-bottom-space
:label="`${'เลขที่'}`"
/>
</div>
</div>
<div class="col-xs-6 col-sm-3 row items-center">
<div class="col-12">
<q-input
:class="getClass(edit)"
:outlined="edit"
dense
lazy-rules
:readonly="!edit"
:borderless="!edit"
v-model="salary"
:rules="[(val) => !!val || `${'กรุณากรอกเงินเดือน'}`]"
hide-bottom-space
:label="`${'เงินเดือน'}`"
type="number"
/>
</div>
</div> -->
<div class="col-12"><q-separator /></div>
<div class="col-xs-6 col-sm-4 row ">
<div class="col-12">
<q-input
:class="getClass(edit)"
:outlined="edit"
dense
lazy-rules
:readonly="!edit"
:borderless="!edit"
v-model="organization"
:rules="[(val) => !!val || `${'กรุณากรอกโอนไปสังกัด'}`]"
hide-bottom-space
:label="`${'หน่วยงานที่ให้ช่วยราชการ'}`"
/>
<q-input :class="getClass(edit)" :outlined="edit" dense lazy-rules :readonly="!edit"
:borderless="!edit" v-model="organization" :rules="[(val) => !!val || `${'กรุณากรอกโอนไปสังกัด'}`]" hide-bottom-space
:label="`${'หน่วยงานที่ให้ช่วยราชการ'}`" />
</div>
</div>
<div class="col-xs-6 col-sm-4 row ">
<div class="col-12">
<datepicker
menu-class-name="modalfix"
:readonly="!edit"
v-model="dateStart"
:locale="'th'"
autoApply
:enableTimePicker="false"
week-start="0"
>
<datepicker menu-class-name="modalfix" :readonly="!edit" v-model="dateStart" :locale="'th'"
autoApply :enableTimePicker="false" 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
:readonly="!edit"
lazy-rules
:borderless="!edit"
:model-value="
dateStart !== null ? date2Thai(dateStart) : null
"
:rules="[(val) => !!val || `${'กรุณาเลือกตั้งแต่วัน'}`]"
hide-bottom-space
:label="`${'ตั้งแต่วัน'}`"
>
<q-input :class="getClass(edit)" :outlined="edit" dense :readonly="!edit"
lazy-rules :borderless="!edit" :rules="[(val) => !!val || `${'กรุณาเลือกตั้งแต่วัน'}`]"
:model-value=" dateStart !== null ? date2Thai(dateStart) : null "
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 name="event" class="cursor-pointer"
:style=" edit ? 'color: var(--q-primary)' : 'color: var(--q-grey)' " >
</q-icon>
</template>
</q-input>
@ -414,41 +251,19 @@ onMounted(async () => {
</div>
<div class="col-xs-6 col-sm-4 row ">
<div class="col-12">
<datepicker
menu-class-name="modalfix"
:readonly="!edit"
v-model="dateEnd"
:locale="'th'"
autoApply
:enableTimePicker="false"
week-start="0"
>
<datepicker menu-class-name="modalfix" :readonly="!edit" v-model="dateEnd" :locale="'th'"
autoApply :enableTimePicker="false" week-start="0" >
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
:readonly="!edit"
:class="getClass(edit)"
:outlined="edit"
dense
lazy-rules
:borderless="!edit"
:model-value="dateEnd !== null ? date2Thai(dateEnd) : null"
:rules="[(val) => !!val || `${'กรุณาเลือกตั้งแต่วัน'}`]"
hide-bottom-space
:label="`${'ถึงวันที่'}`"
>
<q-input :readonly="!edit" :class="getClass(edit)" :outlined="edit" dense
lazy-rules :borderless="!edit" :model-value="dateEnd !== null ? date2Thai(dateEnd) : null"
: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 name="event" class="cursor-pointer"
:style=" edit ? 'color: var(--q-primary)' : 'color: var(--q-grey)' "
>
</q-icon>
</template>
@ -458,19 +273,9 @@ onMounted(async () => {
</div>
</div>
<div class="col-12">
<q-input
:class="getClass(edit)"
:outlined="edit"
dense
lazy-rules
:readonly="!edit"
:borderless="!edit"
v-model="reason"
:rules="[(val) => !!val || `${'กรุณากรอกหมายเหตุ '}`]"
hide-bottom-space
:label="`${'หมายเหตุ '}`"
type="textarea"
/>
<q-input :class="getClass(edit)" :outlined="edit" dense lazy-rules :readonly="!edit"
:borderless="!edit" v-model="reason" :rules="[(val) => !!val || `${'กรุณากรอกหมายเหตุ '}`]"
hide-bottom-space :label="`${'หมายเหตุ '}`" type="textarea" />
</div>
</div>
</div>