2023-07-21 16:34:06 +07:00
|
|
|
<template>
|
2023-08-21 15:05:05 +07:00
|
|
|
<div class="col-12 row justify-center">
|
|
|
|
|
<div class="col-xs-12 col-sm-12 col-md-11">
|
|
|
|
|
<div class="toptitle text-white 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)" />
|
|
|
|
|
<div v-if="routeName == 'AddLeave'">เพิ่มเรื่องลาออก</div>
|
|
|
|
|
<div v-else>รายละเอียดเรื่องลาออก</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-12">
|
|
|
|
|
<q-card bordered>
|
|
|
|
|
<div class="col-12 row q-col-gutter-md q-pa-md">
|
|
|
|
|
<div class="col-xs-12 col-sm-12">
|
2023-08-21 15:56:12 +07:00
|
|
|
<div class="col-12 row q-pa-sm q-col-gutter-sm">
|
2023-08-21 16:03:36 +07:00
|
|
|
<q-input class="col-8" dense outlined v-model="tranferOrg" label="สถานที่ยื่นขอลาออกจากราชการ" :readonly="routeName != 'AddLeave'" />
|
|
|
|
|
<datepicker class="col-2" menu-class-name="modalfix" v-model="dateCommand" :locale="'th'" autoApply readonly borderless :enableTimePicker="false" week-start="0">
|
2023-08-21 15:56:12 +07:00
|
|
|
<template #year="{ year }">
|
|
|
|
|
{{ year + 543 }}
|
|
|
|
|
</template>
|
|
|
|
|
<template #year-overlay-value="{ value }">
|
|
|
|
|
{{ parseInt(value + 543) }}
|
|
|
|
|
</template>
|
|
|
|
|
<template #trigger>
|
|
|
|
|
<q-input
|
|
|
|
|
outlined
|
|
|
|
|
readonly
|
|
|
|
|
dense
|
2023-08-21 16:03:36 +07:00
|
|
|
hide-bottom-space
|
2023-08-21 15:56:12 +07:00
|
|
|
class="full-width datepicker"
|
2023-08-21 16:03:36 +07:00
|
|
|
:model-value="dateCommand != null ? date2Thai(dateCommand) : null"
|
2023-08-21 15:56:12 +07:00
|
|
|
:label="`${'วันที่ยื่นขอลาออกจากราชการ'}`"
|
2023-08-21 16:03:36 +07:00
|
|
|
:rules="[val => !!val || `${'กรุณาเลือกวันที่ยื่นขอลาออกจากราชการ'}`]"
|
2023-08-21 15:56:12 +07:00
|
|
|
>
|
|
|
|
|
<template v-slot:prepend>
|
2023-08-21 16:03:36 +07:00
|
|
|
<q-icon name="event" class="cursor-pointer" style="color: var(--q-primary)"> </q-icon>
|
2023-08-21 15:56:12 +07:00
|
|
|
</template>
|
|
|
|
|
</q-input>
|
|
|
|
|
</template>
|
|
|
|
|
</datepicker>
|
|
|
|
|
<datepicker
|
|
|
|
|
class="col-2"
|
|
|
|
|
menu-class-name="modalfix"
|
|
|
|
|
v-model="dateLeave"
|
|
|
|
|
:locale="'th'"
|
|
|
|
|
autoApply
|
|
|
|
|
borderless
|
|
|
|
|
:enableTimePicker="false"
|
|
|
|
|
week-start="0"
|
|
|
|
|
:readonly="routeName != 'AddLeave'"
|
|
|
|
|
>
|
|
|
|
|
<template #year="{ year }">
|
|
|
|
|
{{ year + 543 }}
|
|
|
|
|
</template>
|
|
|
|
|
<template #year-overlay-value="{ value }">
|
|
|
|
|
{{ parseInt(value + 543) }}
|
|
|
|
|
</template>
|
|
|
|
|
<template #trigger>
|
|
|
|
|
<q-input
|
|
|
|
|
outlined
|
|
|
|
|
dense
|
2023-08-21 16:03:36 +07:00
|
|
|
hide-bottom-space
|
2023-08-21 15:56:12 +07:00
|
|
|
:readonly="routeName != 'AddLeave'"
|
|
|
|
|
class="full-width datepicker"
|
2023-08-21 16:03:36 +07:00
|
|
|
:model-value="dateLeave != null ? date2Thai(dateLeave) : null"
|
2023-08-21 15:56:12 +07:00
|
|
|
:label="`${'วันที่ขอลาออกจากราชการ'}`"
|
2023-08-21 16:03:36 +07:00
|
|
|
:rules="[val => !!val || `${'กรุณาเลือกวันที่ขอลาออกจากราชการ'}`]"
|
2023-08-21 15:56:12 +07:00
|
|
|
>
|
|
|
|
|
<template v-slot:prepend>
|
2023-08-21 16:03:36 +07:00
|
|
|
<q-icon name="event" class="cursor-pointer" style="color: var(--q-primary)"> </q-icon>
|
2023-08-21 15:56:12 +07:00
|
|
|
</template>
|
|
|
|
|
</q-input>
|
|
|
|
|
</template>
|
|
|
|
|
</datepicker>
|
2023-08-21 16:03:36 +07:00
|
|
|
<q-input class="col-12" dense outlined v-model="noteReason" label="เหตุผลที่ลาออกจากราชการ" type="textarea" :readonly="routeName != 'AddLeave'" />
|
2023-07-21 16:34:06 +07:00
|
|
|
|
2023-08-21 16:03:36 +07:00
|
|
|
<div class="col-12 row">
|
|
|
|
|
<q-uploader
|
|
|
|
|
flat
|
|
|
|
|
bordered
|
|
|
|
|
class="col-xs-12 col-sm-12"
|
|
|
|
|
accept=".jpg,.png,.pdf,.csv,.doc"
|
|
|
|
|
url="http://localhost:4444/upload"
|
|
|
|
|
label="เอกสารเพิ่มเติม"
|
|
|
|
|
type="file"
|
|
|
|
|
@added="fileUploadDoc"
|
|
|
|
|
style="max-width: px"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2023-08-21 15:56:12 +07:00
|
|
|
</div>
|
2023-08-21 15:05:05 +07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2023-08-21 15:56:12 +07:00
|
|
|
<q-separator v-if="routeName == 'AddLeave'"/>
|
2023-08-21 16:03:36 +07:00
|
|
|
<div class="row col-12 q-pa-md" v-if="routeName == 'AddLeave'">
|
2023-08-21 15:05:05 +07:00
|
|
|
<q-space />
|
|
|
|
|
<q-btn unelevated dense class="q-px-md items-center" color="primary" label="ยื่นเรื่องขอลาออก" @click="saveResing" :disable="tranferOrg == '' && noteReason == ''" />
|
|
|
|
|
</div>
|
|
|
|
|
</q-card>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2023-07-21 16:34:06 +07:00
|
|
|
</template>
|
|
|
|
|
<script setup lang="ts">
|
2023-08-21 15:05:05 +07:00
|
|
|
import type { QTableProps } from "quasar"
|
|
|
|
|
import { ref, onMounted } from "vue"
|
|
|
|
|
import { useQuasar } from "quasar"
|
|
|
|
|
import { useRouter, useRoute } from "vue-router"
|
|
|
|
|
import { useCounterMixin } from "@/stores/mixin"
|
|
|
|
|
import http from "@/plugins/http"
|
|
|
|
|
import config from "@/app.config"
|
2023-07-21 16:34:06 +07:00
|
|
|
|
2023-08-21 15:05:05 +07:00
|
|
|
const mixin = useCounterMixin()
|
|
|
|
|
const { date2Thai, dateToISO, success, messageError, showLoader, hideLoader } = mixin
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
const route = useRoute()
|
|
|
|
|
const $q = useQuasar()
|
|
|
|
|
const routeName = router.currentRoute.value.name
|
|
|
|
|
const id = ref<string>("")
|
|
|
|
|
const fileDocDataUpload = ref<File[]>([])
|
|
|
|
|
const files = ref<any>()
|
|
|
|
|
const tranferOrg = ref("")
|
|
|
|
|
const dateCommand = ref<Date>(new Date())
|
|
|
|
|
const dateLeave = ref<Date>(new Date())
|
|
|
|
|
const noteReason = ref("")
|
2023-08-09 12:04:57 +07:00
|
|
|
|
|
|
|
|
onMounted(() => {
|
2023-08-21 15:05:05 +07:00
|
|
|
if (route.params.id !== undefined) {
|
|
|
|
|
id.value = route.params.id.toString()
|
|
|
|
|
fectDataresign(id.value)
|
|
|
|
|
}
|
|
|
|
|
})
|
2023-08-09 12:04:57 +07:00
|
|
|
const saveResing = () => {
|
2023-08-21 15:05:05 +07:00
|
|
|
$q.dialog({
|
|
|
|
|
title: "ยืนยันการยื่นข้อมูลลาออก",
|
|
|
|
|
message: "ต้องการยื่นข้อมูลลาออกนี้ใช่หรือไม่?",
|
|
|
|
|
cancel: {
|
|
|
|
|
flat: true,
|
|
|
|
|
color: "negative",
|
|
|
|
|
},
|
|
|
|
|
persistent: true,
|
|
|
|
|
})
|
|
|
|
|
.onOk(async () => {
|
|
|
|
|
createFormresign()
|
|
|
|
|
})
|
|
|
|
|
.onCancel(() => {})
|
|
|
|
|
.onDismiss(() => {})
|
|
|
|
|
}
|
2023-08-09 12:04:57 +07:00
|
|
|
const createFormresign = async () => {
|
2023-08-21 15:05:05 +07:00
|
|
|
const formData = new FormData()
|
|
|
|
|
formData.append("Location", tranferOrg.value)
|
|
|
|
|
formData.append("SendDate", dateToISO(dateCommand.value))
|
|
|
|
|
formData.append("ActiveDate", dateToISO(dateLeave.value))
|
|
|
|
|
formData.append("Reason", noteReason.value)
|
|
|
|
|
formData.append("file", files.value)
|
|
|
|
|
await http
|
|
|
|
|
.post(config.API.listResign(), formData)
|
|
|
|
|
.then((res: any) => {
|
|
|
|
|
// console.log(res);
|
|
|
|
|
success($q, "บันทึกข้อมูลสำเร็จ")
|
|
|
|
|
router.push(`/leave/result`)
|
|
|
|
|
})
|
|
|
|
|
.catch((e: any) => {
|
|
|
|
|
messageError($q, e)
|
|
|
|
|
console.log(e)
|
|
|
|
|
})
|
|
|
|
|
}
|
2023-08-09 12:04:57 +07:00
|
|
|
const fectDataresign = async (id: string) => {
|
2023-08-21 15:05:05 +07:00
|
|
|
showLoader()
|
|
|
|
|
await http
|
|
|
|
|
.get(config.API.resingByid(id))
|
|
|
|
|
.then((res: any) => {
|
|
|
|
|
let data = res.data.result
|
|
|
|
|
// console.log(data);
|
|
|
|
|
;(tranferOrg.value = data.location), (dateCommand.value = data.sendDate), (dateLeave.value = data.activeDate), (noteReason.value = data.reason), (files.value = data.file)
|
|
|
|
|
})
|
|
|
|
|
.catch((e: any) => {
|
|
|
|
|
console.log(e)
|
|
|
|
|
messageError($q, e)
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader()
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const fileUploadDoc = async (file: any) => {
|
|
|
|
|
fileDocDataUpload.value.push(file)
|
|
|
|
|
files.value = file
|
|
|
|
|
}
|
2023-07-21 16:34:06 +07:00
|
|
|
</script>
|