Refactoring code module 04_registryPerson
This commit is contained in:
parent
1164d79122
commit
eeb92dfb5d
46 changed files with 1935 additions and 2230 deletions
|
|
@ -13,18 +13,17 @@ import type {
|
|||
zipCodeOption,
|
||||
} from "@/modules/04_registryPerson/interface/index/Main";
|
||||
|
||||
const $q = useQuasar();
|
||||
const mixin = useCounterMixin();
|
||||
const {
|
||||
showLoader,
|
||||
hideLoader,
|
||||
|
||||
messageError,
|
||||
} = mixin;
|
||||
|
||||
export const useAddressDataStore = defineStore("addess", () => {
|
||||
const $q = useQuasar();
|
||||
const profileIdBefore = ref<string>("");
|
||||
const mixin = useCounterMixin();
|
||||
const {
|
||||
showLoader,
|
||||
hideLoader,
|
||||
date2Thai,
|
||||
messageError,
|
||||
convertDate,
|
||||
dateToISO,
|
||||
} = mixin;
|
||||
|
||||
const Ops = ref<AddressOps>({
|
||||
provinceOps: [],
|
||||
|
|
@ -73,6 +72,9 @@ export const useAddressDataStore = defineStore("addess", () => {
|
|||
return ops.find((r: { id: string }) => r.id === id) || {};
|
||||
}
|
||||
|
||||
/**
|
||||
* ฟังก์ชันดึงข้อมูลจังหวัด
|
||||
*/
|
||||
async function fetchProvince() {
|
||||
showLoader();
|
||||
await http
|
||||
|
|
@ -94,6 +96,11 @@ export const useAddressDataStore = defineStore("addess", () => {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* ฟังก์ชันดึงข้อมูล เขต / อำเภอ
|
||||
* @param id จังหวัด
|
||||
* @param position ที่อยู่ตามทะเบียนบ้าน, ที่อยู่ปัจจุบัน
|
||||
*/
|
||||
async function fetchDistrict(id: string | null, position: string) {
|
||||
if (!id) return;
|
||||
showLoader();
|
||||
|
|
@ -122,6 +129,11 @@ export const useAddressDataStore = defineStore("addess", () => {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* ฟังก์ชันดึงข้อมูล แขวง / ตำบล
|
||||
* @param id เขต / อำเภอ
|
||||
* @param position ที่อยู่ตามทะเบียนบ้าน, ที่อยู่ปัจจุบัน
|
||||
*/
|
||||
async function fetchSubDistrict(id: string | null, position: string) {
|
||||
if (!id) return;
|
||||
showLoader();
|
||||
|
|
@ -153,6 +165,12 @@ export const useAddressDataStore = defineStore("addess", () => {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* ฟังกชันค้นหาข้อมูลใน select
|
||||
* @param val คำที่ต้องการค้นหา
|
||||
* @param update function
|
||||
* @param refData ประเภทตัวเลือก
|
||||
*/
|
||||
function filterSelector(val: any, update: Function, refData: string) {
|
||||
switch (refData) {
|
||||
case "provinceOps":
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
import { ref } from "vue";
|
||||
import { defineStore } from "pinia";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useQuasar } from "quasar";
|
||||
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
import type { RequestObject } from "@/modules/04_registryPerson/interface/request/Profile";
|
||||
import type {
|
||||
|
|
@ -11,39 +12,53 @@ import type {
|
|||
InformationOps,
|
||||
} from "@/modules/04_registryPerson/interface/index/Main";
|
||||
|
||||
const $q = useQuasar();
|
||||
const mixin = useCounterMixin();
|
||||
const {
|
||||
showLoader,
|
||||
hideLoader,
|
||||
|
||||
messageError,
|
||||
} = mixin;
|
||||
|
||||
export const useProfileDataStore = defineStore("profile", () => {
|
||||
const $q = useQuasar();
|
||||
const mixin = useCounterMixin();
|
||||
const {
|
||||
showLoader,
|
||||
hideLoader,
|
||||
date2Thai,
|
||||
messageError,
|
||||
convertDate,
|
||||
dateToISO,
|
||||
} = mixin;
|
||||
const retireDate = ref<Date>();
|
||||
|
||||
//ข้อมูลส่วนตัว
|
||||
const defaultProfile: RequestObject = {
|
||||
bloodGroup: null,
|
||||
relationship: null,
|
||||
gender: null,
|
||||
// posTypeId: "",
|
||||
// posLevelId: "",
|
||||
religion: null,
|
||||
citizenId: "",
|
||||
// telephoneNumber: null,
|
||||
nationality: null,
|
||||
ethnicity: null,
|
||||
birthDate: null,
|
||||
phone: null,
|
||||
// email: null,
|
||||
lastName: "",
|
||||
firstName: "",
|
||||
prefix: "",
|
||||
rank: null,
|
||||
};
|
||||
|
||||
//ข้อมูลตัวเลือก
|
||||
const OpsFilter = ref<InformationOps>({
|
||||
prefixOps: [],
|
||||
rankOps: [],
|
||||
genderOps: [],
|
||||
bloodOps: [],
|
||||
statusOps: [],
|
||||
religionOps: [],
|
||||
employeeClassOps: [
|
||||
{ id: "perm", name: "ลูกจ้างประจำ" },
|
||||
{ id: "temp", name: "ลูกจ้างชั่วคราว" },
|
||||
],
|
||||
employeeTypeOps: [
|
||||
{ id: "gov", name: "งบประมาณเงินอุดหนุนรัฐบาล" },
|
||||
{ id: "bkk", name: "งบประมาณกรุงเทพมหานคร" },
|
||||
],
|
||||
});
|
||||
//รายการตัวเลือก
|
||||
const Ops = ref<InformationOps>({
|
||||
prefixOps: [],
|
||||
rankOps: [],
|
||||
|
|
@ -61,31 +76,11 @@ export const useProfileDataStore = defineStore("profile", () => {
|
|||
],
|
||||
});
|
||||
|
||||
const OpsFilter = ref<InformationOps>({
|
||||
prefixOps: [],
|
||||
rankOps: [],
|
||||
genderOps: [],
|
||||
bloodOps: [],
|
||||
statusOps: [],
|
||||
religionOps: [],
|
||||
employeeClassOps: [
|
||||
{ id: "perm", name: "ลูกจ้างประจำ" },
|
||||
{ id: "temp", name: "ลูกจ้างชั่วคราว" },
|
||||
],
|
||||
employeeTypeOps: [
|
||||
{ id: "gov", name: "งบประมาณเงินอุดหนุนรัฐบาล" },
|
||||
{ id: "bkk", name: "งบประมาณกรุงเทพมหานคร" },
|
||||
],
|
||||
});
|
||||
|
||||
const prefixOp = ref<string[]>([
|
||||
"นาย",
|
||||
"นาง",
|
||||
"นางสาว",
|
||||
"เด็กชาย",
|
||||
"เด็กหญิง",
|
||||
]);
|
||||
|
||||
/**
|
||||
* ฟังก์ชันคำนวนอายุด้วยวันเดิอนปีเกิด
|
||||
* @param birthDate วันเกิด
|
||||
* @returns อายุ
|
||||
*/
|
||||
function calculateAge(birthDate: Date | null) {
|
||||
if (!birthDate) return null;
|
||||
const birthDateTimeStamp = new Date(birthDate).getTime();
|
||||
|
|
@ -107,7 +102,10 @@ export const useProfileDataStore = defineStore("profile", () => {
|
|||
return `${years} ปี ${months} เดือน ${days} วัน`;
|
||||
}
|
||||
|
||||
const fetchPerson = async () => {
|
||||
/**
|
||||
* ฟังก์ชันดึงข้อมูลตัวเลือกข้อมูลหลัก
|
||||
*/
|
||||
async function fetchPerson() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.profileNewMetaMain)
|
||||
|
|
@ -181,9 +179,15 @@ export const useProfileDataStore = defineStore("profile", () => {
|
|||
hideLoader();
|
||||
}, 2500);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const filterSelector = (val: any, update: Function, refData: string) => {
|
||||
/**
|
||||
* ฟังกชันค้นหาข้อมูลใน select
|
||||
* @param val คำที่ต้องการค้นหา
|
||||
* @param update function
|
||||
* @param refData ประเภทตัวเลือก
|
||||
*/
|
||||
const filterSelector = (val: string, update: Function, refData: string) => {
|
||||
switch (refData) {
|
||||
case "prefixOps":
|
||||
update(() => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue