ทะเบียนประวัติ: แก้ไข ฟอร์มเพิ่มข้อมูล
This commit is contained in:
parent
acdc6d19f7
commit
a3c10761fa
1 changed files with 51 additions and 91 deletions
|
|
@ -21,11 +21,9 @@ const profileStore = useProfileDataStore();
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
const store = useRegistryNewDataStore();
|
const store = useRegistryNewDataStore();
|
||||||
const {
|
const {
|
||||||
dialogRemove,
|
|
||||||
dialogConfirm,
|
dialogConfirm,
|
||||||
success,
|
success,
|
||||||
messageError,
|
messageError,
|
||||||
showLoader,
|
|
||||||
hideLoader,
|
hideLoader,
|
||||||
dialogMessageNotify,
|
dialogMessageNotify,
|
||||||
date2Thai,
|
date2Thai,
|
||||||
|
|
@ -54,24 +52,6 @@ const formData = reactive<FormAddPerson>({
|
||||||
birthDate: null,
|
birthDate: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
const prefixRef = ref<object | null>(null);
|
|
||||||
const firstNameRef = ref<object | null>(null);
|
|
||||||
const lastNameRef = ref<object | null>(null);
|
|
||||||
const citizenIdRef = ref<object | null>(null);
|
|
||||||
const positionRef = ref<object | null>(null);
|
|
||||||
const posTypeIdRef = ref<object | null>(null);
|
|
||||||
const posLevelIdRef = ref<object | null>(null);
|
|
||||||
|
|
||||||
const objectRef: MyObjectRef = {
|
|
||||||
prefix: prefixRef,
|
|
||||||
firstName: firstNameRef,
|
|
||||||
lastName: lastNameRef,
|
|
||||||
citizenId: citizenIdRef,
|
|
||||||
position: positionRef,
|
|
||||||
posTypeId: posTypeIdRef,
|
|
||||||
posLevelId: posLevelIdRef,
|
|
||||||
};
|
|
||||||
|
|
||||||
function fetchPrefix() {
|
function fetchPrefix() {
|
||||||
http
|
http
|
||||||
.get(config.API.orgPrefix)
|
.get(config.API.orgPrefix)
|
||||||
|
|
@ -152,22 +132,6 @@ function clearFormData() {
|
||||||
formData.birthDate = null;
|
formData.birthDate = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateForm() {
|
|
||||||
const hasError = [];
|
|
||||||
for (const key in objectRef) {
|
|
||||||
if (Object.prototype.hasOwnProperty.call(objectRef, key)) {
|
|
||||||
const property = objectRef[key];
|
|
||||||
if (property.value && typeof property.value.validate === "function") {
|
|
||||||
const isValid = property.value.validate();
|
|
||||||
hasError.push(isValid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hasError.every((result) => result === true)) {
|
|
||||||
onSubmit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function onSubmit() {
|
async function onSubmit() {
|
||||||
dialogConfirm($q, async () => {
|
dialogConfirm($q, async () => {
|
||||||
await http
|
await http
|
||||||
|
|
@ -209,35 +173,38 @@ watch(
|
||||||
<template>
|
<template>
|
||||||
<q-dialog v-model="modal" persistent>
|
<q-dialog v-model="modal" persistent>
|
||||||
<q-card style="min-width: 350px">
|
<q-card style="min-width: 350px">
|
||||||
<form @submit.prevent="validateForm">
|
<q-form @submit.prevent @validation-success="onSubmit()" greedy>
|
||||||
<q-card-section class="flex justify-between" style="padding: 0">
|
<q-card-section class="flex justify-between" style="padding: 0">
|
||||||
<DialogHeader tittle="เพิ่มข้อมูล" :close="closeDialog" />
|
<DialogHeader tittle="เพิ่มข้อมูล" :close="closeDialog" />
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
|
|
||||||
<q-separator />
|
<q-separator />
|
||||||
<q-card-section class="q-pa-md q-col-gutter-md">
|
<q-card-section class="q-pa-md q-col-gutter-md">
|
||||||
<div class="row q-gutter-sm">
|
<div class="row q-gutter-sm">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<q-select
|
<q-select
|
||||||
bg-color="white"
|
bg-color="white"
|
||||||
ref="prefixRef"
|
|
||||||
v-model="formData.prefix"
|
v-model="formData.prefix"
|
||||||
label="คำนำหน้าชื่อ"
|
label="คำนำหน้าชื่อ"
|
||||||
outlined
|
outlined
|
||||||
dense
|
dense
|
||||||
|
lazy-rules
|
||||||
:options="prefixOps"
|
:options="prefixOps"
|
||||||
option-label="name"
|
option-label="name"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
map-options
|
map-options
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
:rules="[(val) => !!val || 'กรุณาเลือกคำนำหน้าชื่อ']"
|
:rules="[
|
||||||
|
(val) => {
|
||||||
|
console.log(val);
|
||||||
|
return val.length > 0 || 'กรุณาเลือกคำนำหน้าชื่อ';
|
||||||
|
},
|
||||||
|
]"
|
||||||
emit-value
|
emit-value
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<q-select
|
<q-select
|
||||||
bg-color="white"
|
bg-color="white"
|
||||||
ref="prefixRef"
|
|
||||||
v-model="formData.rank"
|
v-model="formData.rank"
|
||||||
label="ยศ"
|
label="ยศ"
|
||||||
outlined
|
outlined
|
||||||
|
|
@ -253,7 +220,6 @@ watch(
|
||||||
</div>
|
</div>
|
||||||
<q-input
|
<q-input
|
||||||
bg-color="white"
|
bg-color="white"
|
||||||
ref="firstNameRef"
|
|
||||||
outlined
|
outlined
|
||||||
v-model="formData.firstName"
|
v-model="formData.firstName"
|
||||||
label="ชื่อ"
|
label="ชื่อ"
|
||||||
|
|
@ -265,7 +231,6 @@ watch(
|
||||||
/>
|
/>
|
||||||
<q-input
|
<q-input
|
||||||
bg-color="white"
|
bg-color="white"
|
||||||
ref="lastNameRef"
|
|
||||||
outlined
|
outlined
|
||||||
v-model="formData.lastName"
|
v-model="formData.lastName"
|
||||||
label="นามสกุล"
|
label="นามสกุล"
|
||||||
|
|
@ -277,7 +242,6 @@ watch(
|
||||||
/>
|
/>
|
||||||
<q-input
|
<q-input
|
||||||
bg-color="white"
|
bg-color="white"
|
||||||
ref="citizenIdRef"
|
|
||||||
outlined
|
outlined
|
||||||
v-model="formData.citizenId"
|
v-model="formData.citizenId"
|
||||||
label="เลขประจำตัวประชาชน"
|
label="เลขประจำตัวประชาชน"
|
||||||
|
|
@ -295,51 +259,6 @@ watch(
|
||||||
mask="#############"
|
mask="#############"
|
||||||
@update:model-value="changeCardID"
|
@update:model-value="changeCardID"
|
||||||
/>
|
/>
|
||||||
<q-input
|
|
||||||
bg-color="white"
|
|
||||||
ref="positionRef"
|
|
||||||
outlined
|
|
||||||
v-model="formData.position"
|
|
||||||
label="ตำแหน่ง"
|
|
||||||
dense
|
|
||||||
lazy-rules
|
|
||||||
borderless
|
|
||||||
:rules="[(val) => val.length > 0 || 'กรุณากรอกตำแหน่ง']"
|
|
||||||
hide-bottom-space
|
|
||||||
/>
|
|
||||||
<q-select
|
|
||||||
bg-color="white"
|
|
||||||
ref="posTypeIdRef"
|
|
||||||
v-model="formData.posTypeId"
|
|
||||||
label="ประเภทตำแหน่ง"
|
|
||||||
outlined
|
|
||||||
:options="store.posTypeOps"
|
|
||||||
dense
|
|
||||||
options-cover
|
|
||||||
map-options
|
|
||||||
emit-value
|
|
||||||
option-label="name"
|
|
||||||
option-value="id"
|
|
||||||
hide-bottom-space
|
|
||||||
:rules="[(val) => !!val || 'กรุณาเลือกประเภทตำแหน่ง']"
|
|
||||||
@update:model-value="fetchLevel"
|
|
||||||
/>
|
|
||||||
<q-select
|
|
||||||
bg-color="white"
|
|
||||||
ref="posLevelIdRef"
|
|
||||||
v-model="formData.posLevelId"
|
|
||||||
label="ระดับตำแหน่ง"
|
|
||||||
:options="levelOps"
|
|
||||||
outlined
|
|
||||||
dense
|
|
||||||
map-options
|
|
||||||
emit-value
|
|
||||||
option-label="posLevelName"
|
|
||||||
option-value="id"
|
|
||||||
options-cover
|
|
||||||
hide-bottom-space
|
|
||||||
:rules="[(val) => !!val || 'กรุณาเลือกระดับตำแหน่ง']"
|
|
||||||
/>
|
|
||||||
<div class="row q-col-gutter-sm">
|
<div class="row q-col-gutter-sm">
|
||||||
<div class="col-xs-6 col-sm-6 col-md-6">
|
<div class="col-xs-6 col-sm-6 col-md-6">
|
||||||
<datepicker
|
<datepicker
|
||||||
|
|
@ -359,7 +278,6 @@ watch(
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
<q-input
|
<q-input
|
||||||
for="inputDatereceive"
|
for="inputDatereceive"
|
||||||
ref="dateReceivedRef"
|
|
||||||
outlined
|
outlined
|
||||||
dense
|
dense
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
|
|
@ -399,6 +317,48 @@ watch(
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<q-input
|
||||||
|
bg-color="white"
|
||||||
|
outlined
|
||||||
|
v-model="formData.position"
|
||||||
|
label="ตำแหน่ง"
|
||||||
|
dense
|
||||||
|
lazy-rules
|
||||||
|
borderless
|
||||||
|
:rules="[(val) => val.length > 0 || 'กรุณากรอกตำแหน่ง']"
|
||||||
|
hide-bottom-space
|
||||||
|
/>
|
||||||
|
<q-select
|
||||||
|
bg-color="white"
|
||||||
|
v-model="formData.posTypeId"
|
||||||
|
label="ประเภทตำแหน่ง"
|
||||||
|
outlined
|
||||||
|
:options="store.posTypeOps"
|
||||||
|
dense
|
||||||
|
options-cover
|
||||||
|
map-options
|
||||||
|
emit-value
|
||||||
|
option-label="name"
|
||||||
|
option-value="id"
|
||||||
|
hide-bottom-space
|
||||||
|
:rules="[(val) => !!val || 'กรุณาเลือกประเภทตำแหน่ง']"
|
||||||
|
@update:model-value="fetchLevel"
|
||||||
|
/>
|
||||||
|
<q-select
|
||||||
|
bg-color="white"
|
||||||
|
v-model="formData.posLevelId"
|
||||||
|
label="ระดับตำแหน่ง"
|
||||||
|
:options="levelOps"
|
||||||
|
outlined
|
||||||
|
dense
|
||||||
|
map-options
|
||||||
|
emit-value
|
||||||
|
option-label="posLevelName"
|
||||||
|
option-value="id"
|
||||||
|
options-cover
|
||||||
|
hide-bottom-space
|
||||||
|
:rules="[(val) => !!val || 'กรุณาเลือกระดับตำแหน่ง']"
|
||||||
|
/>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
|
|
||||||
<q-separator />
|
<q-separator />
|
||||||
|
|
@ -415,7 +375,7 @@ watch(
|
||||||
<q-tooltip>บันทึกข้อมูล</q-tooltip>
|
<q-tooltip>บันทึกข้อมูล</q-tooltip>
|
||||||
</q-btn>
|
</q-btn>
|
||||||
</q-card-actions>
|
</q-card-actions>
|
||||||
</form>
|
</q-form>
|
||||||
</q-card>
|
</q-card>
|
||||||
</q-dialog>
|
</q-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue