Merge branch 'oat_dev' into develop
This commit is contained in:
commit
3d13a2bc8c
2 changed files with 145 additions and 32 deletions
|
|
@ -10,13 +10,14 @@ import type {
|
||||||
FormAddPerson,
|
FormAddPerson,
|
||||||
MyObjectRef,
|
MyObjectRef,
|
||||||
} from "@/modules/04_registryNew/interface/request/Main";
|
} from "@/modules/04_registryNew/interface/request/Main";
|
||||||
|
import { useProfileDataStore } from "@/modules/04_registryNew/stores/profile";
|
||||||
import DialogHeader from "@/components/DialogHeader.vue";
|
import DialogHeader from "@/components/DialogHeader.vue";
|
||||||
|
|
||||||
/** importStore*/
|
/** importStore*/
|
||||||
import { useRegistryNewDataStore } from "@/modules/04_registryNew/store";
|
import { useRegistryNewDataStore } from "@/modules/04_registryNew/store";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
|
|
||||||
|
const profileStore = useProfileDataStore();
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
const store = useRegistryNewDataStore();
|
const store = useRegistryNewDataStore();
|
||||||
const {
|
const {
|
||||||
|
|
@ -27,8 +28,9 @@ const {
|
||||||
showLoader,
|
showLoader,
|
||||||
hideLoader,
|
hideLoader,
|
||||||
dialogMessageNotify,
|
dialogMessageNotify,
|
||||||
|
date2Thai,
|
||||||
} = useCounterMixin();
|
} = useCounterMixin();
|
||||||
|
const { calculateAge } = profileStore;
|
||||||
const modal = defineModel<boolean>("modal", { required: true });
|
const modal = defineModel<boolean>("modal", { required: true });
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
|
@ -37,8 +39,9 @@ const props = defineProps({
|
||||||
});
|
});
|
||||||
|
|
||||||
const prefixOps = ref<DataOption[]>([]);
|
const prefixOps = ref<DataOption[]>([]);
|
||||||
|
const rankOps = ref<DataOption[]>([]);
|
||||||
const levelOps = ref<DataType[]>([]);
|
const levelOps = ref<DataType[]>([]);
|
||||||
|
const age = ref<string | null>("");
|
||||||
const formData = reactive<FormAddPerson>({
|
const formData = reactive<FormAddPerson>({
|
||||||
prefix: "",
|
prefix: "",
|
||||||
firstName: "",
|
firstName: "",
|
||||||
|
|
@ -47,6 +50,8 @@ const formData = reactive<FormAddPerson>({
|
||||||
position: "",
|
position: "",
|
||||||
posTypeId: "",
|
posTypeId: "",
|
||||||
posLevelId: "",
|
posLevelId: "",
|
||||||
|
rank: "",
|
||||||
|
birthDate: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
const prefixRef = ref<object | null>(null);
|
const prefixRef = ref<object | null>(null);
|
||||||
|
|
@ -80,6 +85,19 @@ function fetchPrefix() {
|
||||||
messageError($q, err);
|
messageError($q, err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function fetchRank() {
|
||||||
|
http
|
||||||
|
.get(config.API.orgRank)
|
||||||
|
.then((res) => {
|
||||||
|
rankOps.value = res.data.result.map((v: any) => ({
|
||||||
|
id: v.name,
|
||||||
|
name: v.name,
|
||||||
|
}));
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
messageError($q, err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* function ตรวจสอบเลขประจำตัวประชาชน
|
* function ตรวจสอบเลขประจำตัวประชาชน
|
||||||
|
|
@ -129,6 +147,9 @@ function clearFormData() {
|
||||||
formData.position = "";
|
formData.position = "";
|
||||||
formData.posTypeId = "";
|
formData.posTypeId = "";
|
||||||
formData.posLevelId = "";
|
formData.posLevelId = "";
|
||||||
|
formData.rank = "";
|
||||||
|
age.value = "";
|
||||||
|
formData.birthDate = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateForm() {
|
function validateForm() {
|
||||||
|
|
@ -148,20 +169,21 @@ function validateForm() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onSubmit() {
|
async function onSubmit() {
|
||||||
showLoader();
|
dialogConfirm($q, async () => {
|
||||||
await http
|
await http
|
||||||
.post(config.API.registryNew, formData)
|
.post(config.API.registryNew, formData)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
success($q, "บันทึกข้อมูลสำเร็จ");
|
success($q, "บันทึกข้อมูลสำเร็จ");
|
||||||
props.fetchData?.();
|
props.fetchData?.();
|
||||||
closeDialog();
|
closeDialog();
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
messageError($q, err);
|
messageError($q, err);
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
hideLoader();
|
hideLoader();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
|
@ -169,10 +191,20 @@ watch(
|
||||||
() => {
|
() => {
|
||||||
if (modal.value) {
|
if (modal.value) {
|
||||||
fetchPrefix();
|
fetchPrefix();
|
||||||
|
fetchRank();
|
||||||
props.fetchType?.();
|
props.fetchType?.();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => formData.birthDate,
|
||||||
|
(v) => {
|
||||||
|
if (v) {
|
||||||
|
age.value = calculateAge(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<q-dialog v-model="modal" persistent>
|
<q-dialog v-model="modal" persistent>
|
||||||
|
|
@ -184,21 +216,41 @@ watch(
|
||||||
|
|
||||||
<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">
|
||||||
<q-select
|
<div class="row q-gutter-sm">
|
||||||
bg-color="white"
|
<div class="col">
|
||||||
ref="prefixRef"
|
<q-select
|
||||||
v-model="formData.prefix"
|
bg-color="white"
|
||||||
label="คำนำหน้าชื่อ"
|
ref="prefixRef"
|
||||||
outlined
|
v-model="formData.prefix"
|
||||||
dense
|
label="คำนำหน้าชื่อ"
|
||||||
:options="prefixOps"
|
outlined
|
||||||
option-label="name"
|
dense
|
||||||
option-value="id"
|
:options="prefixOps"
|
||||||
map-options
|
option-label="name"
|
||||||
hide-bottom-space
|
option-value="id"
|
||||||
:rules="[(val) => !!val || 'กรุณาเลือกคำนำหน้าชื่อ']"
|
map-options
|
||||||
emit-value
|
hide-bottom-space
|
||||||
/>
|
:rules="[(val) => !!val || 'กรุณาเลือกคำนำหน้าชื่อ']"
|
||||||
|
emit-value
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<q-select
|
||||||
|
bg-color="white"
|
||||||
|
ref="prefixRef"
|
||||||
|
v-model="formData.rank"
|
||||||
|
label="ยศ"
|
||||||
|
outlined
|
||||||
|
dense
|
||||||
|
:options="rankOps"
|
||||||
|
option-label="name"
|
||||||
|
option-value="id"
|
||||||
|
map-options
|
||||||
|
hide-bottom-space
|
||||||
|
emit-value
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<q-input
|
<q-input
|
||||||
bg-color="white"
|
bg-color="white"
|
||||||
ref="firstNameRef"
|
ref="firstNameRef"
|
||||||
|
|
@ -288,6 +340,65 @@ watch(
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
:rules="[(val) => !!val || 'กรุณาเลือกระดับตำแหน่ง']"
|
:rules="[(val) => !!val || 'กรุณาเลือกระดับตำแหน่ง']"
|
||||||
/>
|
/>
|
||||||
|
<div class="row q-col-gutter-sm">
|
||||||
|
<div class="col-xs-6 col-sm-6 col-md-6">
|
||||||
|
<datepicker
|
||||||
|
autoApply
|
||||||
|
borderless
|
||||||
|
week-start="0"
|
||||||
|
menu-class-name="modalfix"
|
||||||
|
v-model="formData.birthDate"
|
||||||
|
:locale="'th'"
|
||||||
|
>
|
||||||
|
<template #year="{ year }">
|
||||||
|
{{ year + 543 }}
|
||||||
|
</template>
|
||||||
|
<template #year-overlay-value="{ value }">
|
||||||
|
{{ parseInt(value + 543) }}
|
||||||
|
</template>
|
||||||
|
<template #trigger>
|
||||||
|
<q-input
|
||||||
|
for="inputDatereceive"
|
||||||
|
ref="dateReceivedRef"
|
||||||
|
outlined
|
||||||
|
dense
|
||||||
|
hide-bottom-space
|
||||||
|
class="inputgreen"
|
||||||
|
:model-value="
|
||||||
|
formData.birthDate != null
|
||||||
|
? date2Thai(formData.birthDate)
|
||||||
|
: null
|
||||||
|
"
|
||||||
|
label="วัน/เดือน/ปี เกิด"
|
||||||
|
:rules="[
|
||||||
|
(val) => !!val || `${'กรุณาเลือก วัน/เดือน/ปี เกิด'}`,
|
||||||
|
]"
|
||||||
|
>
|
||||||
|
<template v-slot:prepend>
|
||||||
|
<q-icon
|
||||||
|
name="event"
|
||||||
|
class="cursor-pointer"
|
||||||
|
color="primary"
|
||||||
|
>
|
||||||
|
</q-icon>
|
||||||
|
</template>
|
||||||
|
</q-input>
|
||||||
|
</template>
|
||||||
|
</datepicker>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-6 col-sm-6 col-md-6">
|
||||||
|
<q-input
|
||||||
|
dense
|
||||||
|
outlined
|
||||||
|
lazy-rules
|
||||||
|
hide-bottom-space
|
||||||
|
readonly
|
||||||
|
class="inputgreen"
|
||||||
|
v-model="age"
|
||||||
|
label="อายุ"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
|
|
||||||
<q-separator />
|
<q-separator />
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@ interface FormFilter {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface FormAddPerson {
|
interface FormAddPerson {
|
||||||
|
birthDate: Date | null,
|
||||||
|
rank: string,
|
||||||
prefix: string;
|
prefix: string;
|
||||||
firstName: string;
|
firstName: string;
|
||||||
lastName: string;
|
lastName: string;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue