Refactoring code module 04_registryPerson

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-09-18 17:24:21 +07:00
parent 1164d79122
commit eeb92dfb5d
46 changed files with 1935 additions and 2230 deletions

View file

@ -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":

View file

@ -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(() => {