2023-09-25 11:22:13 +07:00
|
|
|
<script setup lang="ts">
|
2023-10-02 13:58:56 +07:00
|
|
|
import { onMounted, ref,watch } from "vue";
|
2023-09-25 11:22:13 +07:00
|
|
|
import { QForm, useQuasar } from "quasar";
|
|
|
|
|
import { useCounterMixin } from "@/stores/mixin";
|
|
|
|
|
|
|
|
|
|
import http from "@/plugins/http";
|
|
|
|
|
import config from "@/app.config";
|
|
|
|
|
|
|
|
|
|
import type { DataOption } from "@/modules/04_registry/components/profileType";
|
|
|
|
|
|
|
|
|
|
const $q = useQuasar();
|
2023-09-27 15:39:39 +07:00
|
|
|
const myForm = ref<any>();
|
2023-09-25 11:22:13 +07:00
|
|
|
const mixin = useCounterMixin();
|
2023-10-02 13:58:56 +07:00
|
|
|
const { date2Thai,showLoader,success,hideLoader,messageError,dialogConfirm ,dateToISO} = mixin;
|
2023-09-25 11:22:13 +07:00
|
|
|
const files = ref<any>();
|
|
|
|
|
const filesReturn = ref<any>();
|
|
|
|
|
const OrganazationId = ref<string>("");
|
2023-10-02 09:43:38 +07:00
|
|
|
const OrganazationId2 = ref<string>("");
|
2023-09-25 11:22:13 +07:00
|
|
|
const OrgList = ref<DataOption[]>([]);
|
2023-10-02 13:58:56 +07:00
|
|
|
const OrgList2 = ref<DataOption[]>([]);
|
|
|
|
|
const Datereceive = ref<Date | null>();
|
2023-09-25 11:22:13 +07:00
|
|
|
const Datereturn = ref<Date | null>();
|
2023-09-25 23:50:03 +07:00
|
|
|
const remark = ref<string>("")
|
2023-09-27 15:39:39 +07:00
|
|
|
const nullii = ref<any>(null)
|
2023-09-25 11:22:13 +07:00
|
|
|
const props = defineProps({
|
|
|
|
|
modal: Boolean,
|
2023-09-27 15:39:39 +07:00
|
|
|
personId: String,
|
2023-09-25 11:22:13 +07:00
|
|
|
close: Function,
|
2023-09-27 15:39:39 +07:00
|
|
|
fecthlistInsignia: Function,
|
2023-10-02 13:58:56 +07:00
|
|
|
dateCheckReceive:String,
|
|
|
|
|
dateCheckReturn:String,
|
|
|
|
|
dataModal:Object
|
|
|
|
|
})
|
2023-09-25 11:22:13 +07:00
|
|
|
// reset วันที่ประกาศราชกิจจานุเบกษา
|
|
|
|
|
const clearReceiveDate = () => {
|
|
|
|
|
Datereceive.value = null;
|
|
|
|
|
};
|
|
|
|
|
const clearReturnDate = () => {
|
|
|
|
|
Datereturn.value = null;
|
|
|
|
|
};
|
|
|
|
|
const close = () => {
|
|
|
|
|
props.close?.();
|
2023-09-27 15:39:39 +07:00
|
|
|
Datereceive.value = null
|
|
|
|
|
files.value = null
|
|
|
|
|
OrganazationId.value = ''
|
|
|
|
|
Datereturn.value = null
|
|
|
|
|
filesReturn.value = null
|
2023-10-02 09:43:38 +07:00
|
|
|
OrganazationId2.value = ''
|
2023-09-25 11:22:13 +07:00
|
|
|
};
|
2023-09-27 15:39:39 +07:00
|
|
|
|
|
|
|
|
const SaveData = async (type:string,id:string) => {
|
|
|
|
|
await myForm.value.validate().then((result: boolean) => {
|
|
|
|
|
if (result) {
|
|
|
|
|
dialogConfirm($q,() => dataSave(type,id))
|
|
|
|
|
}else{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
})};
|
|
|
|
|
const dataSave = (type:string,id:string) => {
|
|
|
|
|
const formData = new FormData();
|
2023-10-02 13:58:56 +07:00
|
|
|
if(props.dateCheckReceive === null){
|
|
|
|
|
formData.append("Date", dateToISO(Datereceive.value ?? nullii));
|
|
|
|
|
formData.append("File", files.value);
|
|
|
|
|
formData.append("OrgId", OrganazationId.value);
|
2023-09-27 15:39:39 +07:00
|
|
|
} else {
|
2023-10-02 13:58:56 +07:00
|
|
|
formData.append("Date", dateToISO(Datereturn.value ?? nullii));
|
|
|
|
|
formData.append("File", filesReturn.value);
|
|
|
|
|
formData.append("OrgId", OrganazationId2.value);
|
2023-09-27 15:39:39 +07:00
|
|
|
}
|
|
|
|
|
showLoader();
|
|
|
|
|
http
|
|
|
|
|
.put(config.API.requestinsignia(type,id), formData)
|
|
|
|
|
.then(() => {
|
|
|
|
|
success($q, "บันทึกข้อมูลสำเร็จ");
|
|
|
|
|
})
|
|
|
|
|
.catch((e) => {
|
|
|
|
|
messageError($q, e);
|
|
|
|
|
})
|
|
|
|
|
.finally(async () => {
|
|
|
|
|
Datereceive.value = null
|
|
|
|
|
files.value = null
|
|
|
|
|
OrganazationId.value = ''
|
|
|
|
|
Datereturn.value = null
|
|
|
|
|
filesReturn.value = null
|
2023-10-02 09:43:38 +07:00
|
|
|
OrganazationId2.value = ''
|
2023-09-27 15:39:39 +07:00
|
|
|
props.close?.();
|
|
|
|
|
hideLoader();
|
|
|
|
|
props.fecthlistInsignia?.()
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
const fetchOrgList = async () => {
|
|
|
|
|
showLoader();
|
|
|
|
|
await http
|
|
|
|
|
.get(config.API.typeOc())
|
|
|
|
|
.then(async (response: any) => {
|
|
|
|
|
const orgArr = response.data.result.map((e: any) => ({
|
|
|
|
|
id: e.organizationId,
|
|
|
|
|
name: e.organizationName,
|
|
|
|
|
}));
|
|
|
|
|
OrgList.value = orgArr;
|
2023-10-02 13:58:56 +07:00
|
|
|
OrgList2.value = [
|
|
|
|
|
{
|
|
|
|
|
id: "00000000-0000-0000-0000-000000000000",
|
|
|
|
|
name: "สำนักนายกรัฐมนตรี",
|
|
|
|
|
},
|
|
|
|
|
...orgArr,
|
|
|
|
|
];
|
2023-09-27 15:39:39 +07:00
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
messageError($q, err);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
|
|
|
|
});
|
|
|
|
|
};
|
2023-10-02 13:58:56 +07:00
|
|
|
watch(props,()=>{
|
|
|
|
|
if(props.dataModal){
|
|
|
|
|
Datereceive.value = props.dataModal.dateReceiveInsignia
|
|
|
|
|
Datereturn.value = props.dataModal.dateReturnInsignia
|
|
|
|
|
OrganazationId.value = props.dataModal.orgReceiveInsignia
|
|
|
|
|
OrganazationId2.value = props.dataModal.orgReturnInsignia
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
2023-09-27 15:39:39 +07:00
|
|
|
onMounted(()=>{
|
|
|
|
|
fetchOrgList()
|
|
|
|
|
})
|
2023-09-25 11:22:13 +07:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<q-dialog v-model="props.modal" persistent>
|
|
|
|
|
<q-card style="min-width: 900px">
|
|
|
|
|
<q-toolbar>
|
2023-09-29 13:54:17 +07:00
|
|
|
<q-toolbar-title class="text-subtitle2 text-bold">รับ-คืนเครื่องราชฯ</q-toolbar-title>
|
2023-09-25 23:50:03 +07:00
|
|
|
<q-btn icon="close" unelevated round dense @click="close" style="color: #ff8080; background-color: #ffdede" />
|
2023-09-25 11:22:13 +07:00
|
|
|
</q-toolbar>
|
|
|
|
|
<q-separator />
|
|
|
|
|
|
|
|
|
|
<q-form ref="myForm">
|
|
|
|
|
<div class="q-pa-md bg-grey-1">
|
2023-09-29 13:54:17 +07:00
|
|
|
<div class="row col-12 q-col-gutter-x-xs q-col-gutter-y-xs">
|
|
|
|
|
<div class="col-12 text-weight-bold text-grey-7">
|
|
|
|
|
รับเครื่องราชฯ
|
|
|
|
|
</div>
|
2023-09-25 11:22:13 +07:00
|
|
|
<div class="col-xs-12 col-sm-4">
|
2023-10-02 13:58:56 +07:00
|
|
|
|
2023-09-25 23:50:03 +07:00
|
|
|
<datepicker menu-class-name="modalfix" v-model="Datereceive" :locale="'th'" autoApply borderless
|
2023-10-02 13:58:56 +07:00
|
|
|
:enableTimePicker="false" week-start="0" :readonly="dateCheckReceive !== null">
|
2023-09-25 11:22:13 +07:00
|
|
|
<template #year="{ year }">
|
|
|
|
|
{{ year + 543 }}
|
|
|
|
|
</template>
|
|
|
|
|
<template #year-overlay-value="{ value }">
|
|
|
|
|
{{ parseInt(value + 543) }}
|
|
|
|
|
</template>
|
|
|
|
|
<template #trigger>
|
2023-09-25 23:50:03 +07:00
|
|
|
<q-input dense borderless outlined lazy-rules :rules="[(val) => !!val || 'กรุณาเลือกวันที่ได้รับ']"
|
2023-10-02 13:58:56 +07:00
|
|
|
hide-bottom-space :model-value="Datereceive != null ? date2Thai(Datereceive) : null
|
|
|
|
|
" :label="`${'วันที่ได้รับ'}`" clearable @clear="clearReceiveDate" :disable="dateCheckReceive !== null">
|
2023-09-25 11:22:13 +07:00
|
|
|
<template v-slot:prepend>
|
2023-09-25 23:50:03 +07:00
|
|
|
<q-icon name="event" class="cursor-pointer" color="primary">
|
2023-09-25 11:22:13 +07:00
|
|
|
</q-icon>
|
|
|
|
|
</template>
|
|
|
|
|
</q-input>
|
|
|
|
|
</template>
|
|
|
|
|
</datepicker>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="col-xs-12 col-sm-4">
|
2023-09-27 15:39:39 +07:00
|
|
|
|
|
|
|
|
<q-file outlined dense v-model="files" label="ไฟล์หลักฐานการรับ" lazy-rules
|
2023-10-02 13:58:56 +07:00
|
|
|
:rules="[(val) => val || 'กรุณาเลือกไฟล์หลักฐานการรับ']" hide-bottom-space :disable="dateCheckReceive !== null">
|
2023-09-25 11:22:13 +07:00
|
|
|
<template v-slot:prepend>
|
|
|
|
|
<q-icon name="attach_file" color="primary" />
|
|
|
|
|
</template>
|
|
|
|
|
</q-file>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-xs-12 col-sm-4">
|
2023-09-27 15:39:39 +07:00
|
|
|
<q-select hide-bottom-space :options="OrgList" dense borderless option-label="name" option-value="id"
|
2023-09-25 23:50:03 +07:00
|
|
|
emit-value map-options outlined v-model="OrganazationId" lazy-rules :label="`หน่วยงานที่รับ`"
|
2023-10-02 13:58:56 +07:00
|
|
|
:rules="[(val) => !!val || 'กรุณาเลือกหน่วยงานที่รับ']" :disable="dateCheckReceive !== null"/>
|
2023-09-25 11:22:13 +07:00
|
|
|
</div>
|
2023-09-27 15:39:39 +07:00
|
|
|
</div>
|
2023-10-02 09:43:38 +07:00
|
|
|
|
2023-10-02 13:58:56 +07:00
|
|
|
<div v-if="dateCheckReceive !== null" class="row col-12 q-col-gutter-x-xs q-col-gutter-y-xs">
|
2023-10-02 09:43:38 +07:00
|
|
|
<div class="col-12 q-mt-sm"><q-separator/></div>
|
2023-09-29 13:54:17 +07:00
|
|
|
<div class="col-12 text-weight-bold text-grey-7">
|
|
|
|
|
คืนเครื่องราชฯ
|
|
|
|
|
</div>
|
2023-09-25 11:22:13 +07:00
|
|
|
<div class="col-xs-12 col-sm-4">
|
2023-09-27 15:39:39 +07:00
|
|
|
|
2023-09-25 23:50:03 +07:00
|
|
|
<datepicker menu-class-name="modalfix" v-model="Datereturn" :locale="'th'" autoApply borderless
|
2023-10-02 13:58:56 +07:00
|
|
|
:enableTimePicker="false" week-start="0" :readonly="dateCheckReturn !== null">
|
2023-09-25 11:22:13 +07:00
|
|
|
<template #year="{ year }">
|
|
|
|
|
{{ year + 543 }}
|
|
|
|
|
</template>
|
|
|
|
|
<template #year-overlay-value="{ value }">
|
|
|
|
|
{{ parseInt(value + 543) }}
|
|
|
|
|
</template>
|
|
|
|
|
<template #trigger>
|
2023-09-25 23:50:03 +07:00
|
|
|
<q-input dense borderless outlined lazy-rules :rules="[(val) => !!val || 'กรุณาเลือกวันที่คืน']"
|
|
|
|
|
hide-bottom-space :model-value="Datereturn != null ? date2Thai(Datereturn) : undefined
|
2023-10-02 13:58:56 +07:00
|
|
|
" :label="`${'วันที่คืน'}`" clearable @clear="clearReturnDate" :disable="dateCheckReturn !== null">
|
2023-09-25 11:22:13 +07:00
|
|
|
<template v-slot:prepend>
|
2023-09-25 23:50:03 +07:00
|
|
|
<q-icon name="event" class="cursor-pointer" color="primary">
|
2023-09-25 11:22:13 +07:00
|
|
|
</q-icon>
|
|
|
|
|
</template>
|
|
|
|
|
</q-input>
|
|
|
|
|
</template>
|
|
|
|
|
</datepicker>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-xs-12 col-sm-4">
|
2023-09-27 15:39:39 +07:00
|
|
|
<q-file outlined dense v-model="filesReturn" label="ไฟล์หลักฐานการคืน" lazy-rules
|
2023-10-02 13:58:56 +07:00
|
|
|
:rules="[(val) => val || 'กรุณาเลือกไฟล์หลักฐานการคืน']" hide-bottom-space :disable="dateCheckReturn !== null">
|
2023-09-25 11:22:13 +07:00
|
|
|
<template v-slot:prepend>
|
|
|
|
|
<q-icon name="attach_file" color="primary" />
|
|
|
|
|
</template>
|
|
|
|
|
</q-file>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-xs-12 col-sm-4">
|
2023-10-02 13:58:56 +07:00
|
|
|
<q-select hide-bottom-space :options="OrgList2" dense borderless option-label="name" option-value="id"
|
2023-10-02 09:43:38 +07:00
|
|
|
emit-value map-options outlined v-model="OrganazationId2" lazy-rules :label="`หน่วยงานที่คืน` "
|
2023-10-02 13:58:56 +07:00
|
|
|
:rules="[(val) => !!val || 'กรุณาเลือกหน่วยงานที่คืน']" :disable="dateCheckReturn !== null"/>
|
2023-09-25 11:22:13 +07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2023-09-27 15:39:39 +07:00
|
|
|
|
2023-09-25 11:22:13 +07:00
|
|
|
</q-form>
|
|
|
|
|
|
|
|
|
|
<q-separator />
|
|
|
|
|
<div class="q-px-md q-py-sm">
|
|
|
|
|
<div class="row justify-end">
|
2023-10-02 13:58:56 +07:00
|
|
|
<q-btn v-if="dateCheckReturn === null" label="บันทึก" color="public" @click="SaveData(props.dateCheckReceive === null ? 'receive':'return',props.personId as string)">
|
2023-09-25 11:22:13 +07:00
|
|
|
<q-tooltip>บันทึก</q-tooltip>
|
|
|
|
|
</q-btn>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</q-card>
|
|
|
|
|
</q-dialog>
|
|
|
|
|
</template>
|