262 lines
8.5 KiB
Vue
262 lines
8.5 KiB
Vue
<script setup lang="ts">
|
|
import { reactive,watch } from "vue";
|
|
import { useQuasar } from "quasar";
|
|
|
|
import http from "@/plugins/http";
|
|
import config from "@/app.config";
|
|
import { useCounterMixin } from "@/stores/mixin";
|
|
import { useDataLinkCenter } from "@/modules/04_registryPerson/stores/LinkCenter";
|
|
import { useProfileDataStore } from "@/modules/04_registryPerson/stores/profile";
|
|
|
|
import type { FormPerson } from "@/modules/04_registryPerson/interface/index/family";
|
|
|
|
import Header from "@/components/DialogHeader.vue"; //ส่วนหัว popup
|
|
|
|
const $q = useQuasar();
|
|
const mixin = useCounterMixin();
|
|
const storeLinkCenter = useDataLinkCenter();
|
|
const storeProfile = useProfileDataStore();
|
|
|
|
const {
|
|
showLoader,
|
|
hideLoader,
|
|
messageError,
|
|
dialogConfirm,
|
|
modalError,
|
|
success,
|
|
} = mixin;
|
|
|
|
const modal = defineModel<boolean>("modal", { required: true }); // ตัวแปร popup
|
|
const profileId = defineModel<string>("profileId", { required: true }); //id บุคคล
|
|
const idCard = defineModel<string>("idCard", { required: true }); //เลขบัตร ปชช
|
|
|
|
const props = defineProps({
|
|
fetchData: Function,
|
|
requestId: String,
|
|
});
|
|
|
|
const fatherData = reactive<FormPerson>({
|
|
isLive: 1,
|
|
citizenId: "",
|
|
prefix: "",
|
|
firstName: "",
|
|
lastName: "",
|
|
job: "",
|
|
});
|
|
|
|
/** ปิด popup */
|
|
async function closeDialog() {
|
|
modal.value = false;
|
|
|
|
fatherData.isLive = 1;
|
|
fatherData.citizenId = "";
|
|
fatherData.prefix = "";
|
|
fatherData.firstName = "";
|
|
fatherData.lastName = "";
|
|
fatherData.job = "";
|
|
}
|
|
|
|
async function onSubmit() {
|
|
dialogConfirm($q, async () => {
|
|
const body = {
|
|
profileId: profileId.value,
|
|
fatherCitizenId: fatherData.citizenId,
|
|
fatherPrefix: fatherData.prefix,
|
|
fatherFirstName: fatherData.firstName,
|
|
fatherLastName: fatherData.lastName,
|
|
fatherCareer: fatherData.job,
|
|
fatherLive: fatherData.isLive === 1 ? true : false,
|
|
};
|
|
http
|
|
.post(config.API.profileFamily("", "father"), body)
|
|
.then(async (res) => {
|
|
await upDateStatus();
|
|
success($q, "บันทึกข้อมูลสำเร็จ");
|
|
closeDialog();
|
|
await props.fetchData?.();
|
|
})
|
|
.catch((e) => {
|
|
messageError($q, e);
|
|
hideLoader();
|
|
})
|
|
.finally(() => {});
|
|
});
|
|
}
|
|
|
|
/** ส่ง สถานะ ดำเนินการเเล้ว */
|
|
async function upDateStatus() {
|
|
await http
|
|
.patch(config.API.requestEdit + `${props.requestId}`, {
|
|
status: "COMPLETE",
|
|
remark: "",
|
|
})
|
|
.then(async () => {
|
|
await props.fetchData?.();
|
|
await success($q, "บันทึกข้อมูลสำเร็จ");
|
|
closeDialog();
|
|
})
|
|
.catch((err) => {
|
|
messageError($q, err);
|
|
})
|
|
.finally(() => {
|
|
hideLoader();
|
|
});
|
|
}
|
|
watch(
|
|
() => modal.value,
|
|
() => {
|
|
if (modal.value) {
|
|
storeLinkCenter.fetchPerson();
|
|
fatherData.citizenId = idCard.value;
|
|
}
|
|
}
|
|
);
|
|
</script>
|
|
<template>
|
|
<q-dialog v-model="modal" persistent>
|
|
<q-card class="col-12" style="width: 80vw">
|
|
<q-form greedy @submit.prevent @validation-success="onSubmit">
|
|
<Header tittle="ขอปรับปรุงข้อมูลบิดา" :close="closeDialog" />
|
|
<q-separator />
|
|
|
|
<q-card-section class="scroll" style="max-height: 80vh">
|
|
<div class="row q-col-gutter-sm">
|
|
<div class="col-12">
|
|
<div class="row col-12 q-col-gutter-x-xs q-col-gutter-y-xs">
|
|
<div class="col-xs-6 col-sm-6 col-md-3">
|
|
<q-input
|
|
outlined
|
|
hide-bottom-space
|
|
readonly
|
|
bg-color="white"
|
|
dense
|
|
v-model="fatherData.citizenId"
|
|
:label="`${'เลขประจำตัวประชาชน'}`"
|
|
maxlength="13"
|
|
:rules="[
|
|
(val:string) => !!val || 'กรุณากรอกเลขบัตรประชาชน',
|
|
(val:string) =>
|
|
val.length === 13 ||
|
|
'กรุณากรอกเลขบัตรประชาชนให้ครบ 13 หลัก',
|
|
]
|
|
"
|
|
class="inputgreen"
|
|
mask="#############"
|
|
/>
|
|
</div>
|
|
<div class="col-xs-6 col-sm-6 col-md-2">
|
|
<q-select
|
|
outlined
|
|
bg-color="white"
|
|
lazy-rules
|
|
hidden-space
|
|
hide-bottom-space
|
|
dense
|
|
class="inputgreen"
|
|
:rules="
|
|
[(val:string) => !!val || 'กรุณาเลือกคำนำหน้าชื่อ']
|
|
|
|
"
|
|
label="คำนำหน้าชื่อ"
|
|
v-model="fatherData.prefix"
|
|
use-input
|
|
input-debounce="0"
|
|
emit-value
|
|
map-options
|
|
:options="storeLinkCenter.OpsPerson.prefixOps"
|
|
option-label="name"
|
|
option-value="name"
|
|
@filter="(inputValue:string,
|
|
doneFn:Function) => storeProfile.filterSelector(inputValue, doneFn,'prefixOps'
|
|
) "
|
|
/>
|
|
</div>
|
|
<div class="col-xs-6 col-sm-6 col-md-2">
|
|
<q-input
|
|
outlined
|
|
dense
|
|
hide-bottom-space
|
|
bg-color="white"
|
|
class="inputgreen"
|
|
lazy-rules
|
|
v-model="fatherData.firstName"
|
|
:rules="
|
|
[(val:string) => !!val || 'กรุณากรอกชื่อ']
|
|
|
|
"
|
|
label="ชื่อ"
|
|
hidden-space
|
|
/>
|
|
</div>
|
|
<div class="col-xs-6 col-sm-6 col-md-2">
|
|
<q-input
|
|
outlined
|
|
dense
|
|
class="inputgreen"
|
|
bg-color="white"
|
|
hide-bottom-space
|
|
lazy-rules
|
|
v-model="fatherData.lastName"
|
|
:rules="
|
|
[(val:string) => !!val || 'กรุณากรอกนามสกุล']
|
|
|
|
"
|
|
label="นามสกุล"
|
|
/>
|
|
</div>
|
|
<div class="col-xs-6 col-sm-6 col-md-3">
|
|
<q-input
|
|
outlined
|
|
dense
|
|
class="inputgreen"
|
|
bg-color="white"
|
|
v-model="fatherData.job"
|
|
label="อาชีพ"
|
|
/>
|
|
</div>
|
|
<div class="col-12">
|
|
<div class="row q-my-xs">
|
|
<div class="q-mr-sm">สถานภาพการมีชีวิต</div>
|
|
<div>
|
|
<q-radio
|
|
class="q-mr-sm"
|
|
v-model="fatherData.isLive"
|
|
checked-icon="task_alt"
|
|
unchecked-icon="panorama_fish_eye"
|
|
:val="1"
|
|
label="ยังมีชีวิตอยู่"
|
|
dense
|
|
:color="!fatherData.isLive ? 'grey' : 'primary'"
|
|
/>
|
|
<q-radio
|
|
v-model="fatherData.isLive"
|
|
checked-icon="task_alt"
|
|
unchecked-icon="panorama_fish_eye"
|
|
:val="0"
|
|
:color="!fatherData.isLive ? 'grey' : 'red'"
|
|
label="ถึงแก่กรรม"
|
|
dense
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</q-card-section>
|
|
<q-separator />
|
|
|
|
<q-card-actions align="right">
|
|
<q-btn
|
|
label="บันทึกลงทะเบียนประวัติ"
|
|
color="secondary"
|
|
type="submit"
|
|
/>
|
|
<q-btn label="ยกเลิก" color="orange" @click="modal = false"
|
|
><q-tooltip>ยกเลิก</q-tooltip></q-btn
|
|
>
|
|
</q-card-actions>
|
|
</q-form>
|
|
</q-card>
|
|
</q-dialog>
|
|
</template>
|