ทะเบียนประวัติ: ข้อมูลส่วนตัว (เพิ่ม ยศ แก้ q-select)
This commit is contained in:
parent
32136fd932
commit
ca4871ae4b
5 changed files with 190 additions and 187 deletions
|
|
@ -5,16 +5,11 @@ import { useQuasar } from "quasar";
|
|||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
import type { RequestObject } from "@/modules/04_registryNew/interface/request/Profile";
|
||||
import type {
|
||||
DataOption,
|
||||
InformationOps,
|
||||
} from "@/modules/04_registryNew/interface/index/Main";
|
||||
// import type {
|
||||
// Gender,
|
||||
// Religion,
|
||||
// Relationship,
|
||||
// BloodGroup,
|
||||
// } from "@/modules/04_registryNew/interface/response/Profile";
|
||||
|
||||
export const useProfileDataStore = defineStore("profile", () => {
|
||||
const $q = useQuasar();
|
||||
|
|
@ -27,10 +22,35 @@ export const useProfileDataStore = defineStore("profile", () => {
|
|||
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,
|
||||
dateRetire: null,
|
||||
isProbation: false,
|
||||
keycloak: "",
|
||||
phone: null,
|
||||
email: null,
|
||||
position: "",
|
||||
lastName: "",
|
||||
firstName: "",
|
||||
prefix: "",
|
||||
rank: null,
|
||||
};
|
||||
|
||||
const Ops = ref<InformationOps>({
|
||||
prefixOps: [],
|
||||
prefixOldOps: [],
|
||||
rankOps: [],
|
||||
genderOps: [],
|
||||
bloodOps: [],
|
||||
statusOps: [],
|
||||
|
|
@ -47,7 +67,7 @@ export const useProfileDataStore = defineStore("profile", () => {
|
|||
|
||||
const OpsFilter = ref<InformationOps>({
|
||||
prefixOps: [],
|
||||
prefixOldOps: [],
|
||||
rankOps: [],
|
||||
genderOps: [],
|
||||
bloodOps: [],
|
||||
statusOps: [],
|
||||
|
|
@ -62,13 +82,16 @@ export const useProfileDataStore = defineStore("profile", () => {
|
|||
],
|
||||
});
|
||||
|
||||
// const genderOp = ref<Gender[]>([]);
|
||||
// const religionOp = ref<Religion[]>([]);
|
||||
// const relationshipOp = ref<Relationship[]>([]);
|
||||
// const bloodGroupOp = ref<BloodGroup[]>([]);
|
||||
// const prefixOp = ref<string[]>(["นาย", "นาง", "นางสาว"]);
|
||||
const prefixOp = ref<string[]>([
|
||||
"นาย",
|
||||
"นาง",
|
||||
"นางสาว",
|
||||
"เด็กชาย",
|
||||
"เด็กหญิง",
|
||||
]);
|
||||
|
||||
function calculateAge(birthDate: Date): string {
|
||||
function calculateAge(birthDate: Date | null) {
|
||||
if (!birthDate) return null;
|
||||
const birthDateTimeStamp = new Date(birthDate).getTime();
|
||||
const now = new Date();
|
||||
const diff = now.getTime() - birthDateTimeStamp;
|
||||
|
|
@ -77,6 +100,9 @@ export const useProfileDataStore = defineStore("profile", () => {
|
|||
const years = ageDate.getUTCFullYear() - 1970;
|
||||
const months = ageDate.getUTCMonth();
|
||||
const days = ageDate.getUTCDate() - 1;
|
||||
const retire = new Date(birthDate);
|
||||
retire.setFullYear(retire.getFullYear() + 60);
|
||||
retireDate.value = retire
|
||||
|
||||
if (years > 60) {
|
||||
return "อายุเกิน 60 ปี";
|
||||
|
|
@ -118,9 +144,25 @@ export const useProfileDataStore = defineStore("profile", () => {
|
|||
name: r.name.toString(),
|
||||
});
|
||||
});
|
||||
optionprefixs = optionprefixs.filter((o) =>
|
||||
prefixOp.value.find((p) => o.name === p)
|
||||
);
|
||||
Ops.value.prefixOps = optionprefixs;
|
||||
OpsFilter.value.prefixOps = optionprefixs;
|
||||
|
||||
let optionrank: DataOption[] = [];
|
||||
data.prefixs.map((r: any) => {
|
||||
optionrank.push({
|
||||
id: r.id.toString(),
|
||||
name: r.name.toString(),
|
||||
});
|
||||
});
|
||||
optionrank = optionrank.filter(
|
||||
(o) => !prefixOp.value.find((p) => o.name === p)
|
||||
);
|
||||
Ops.value.rankOps = optionrank;
|
||||
OpsFilter.value.rankOps = optionrank;
|
||||
|
||||
let optionrelationships: DataOption[] = [];
|
||||
data.relationships.map((r: any) => {
|
||||
optionrelationships.push({
|
||||
|
|
@ -156,6 +198,13 @@ export const useProfileDataStore = defineStore("profile", () => {
|
|||
);
|
||||
});
|
||||
break;
|
||||
case "rankOps":
|
||||
update(() => {
|
||||
Ops.value.rankOps = OpsFilter.value.rankOps.filter(
|
||||
(v: DataOption) => v.name.indexOf(val) > -1
|
||||
);
|
||||
});
|
||||
break;
|
||||
case "genderOps":
|
||||
update(() => {
|
||||
Ops.value.genderOps = OpsFilter.value.genderOps.filter(
|
||||
|
|
@ -198,87 +247,20 @@ export const useProfileDataStore = defineStore("profile", () => {
|
|||
);
|
||||
});
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
// async function getGender() {
|
||||
// showLoader();
|
||||
// await http
|
||||
// .get(config.API.profileNewGender)
|
||||
// .then((res) => {
|
||||
// genderOp.value = res.data.result;
|
||||
// })
|
||||
// .catch((e) => {
|
||||
// messageError($q, e);
|
||||
// })
|
||||
// .finally(() => {
|
||||
// hideLoader();
|
||||
// });
|
||||
// }
|
||||
|
||||
// async function getRelationship() {
|
||||
// showLoader();
|
||||
// await http
|
||||
// .get(config.API.profileNewRelationship)
|
||||
// .then((res) => {
|
||||
// relationshipOp.value = res.data.result;
|
||||
// })
|
||||
// .catch((e) => {
|
||||
// messageError($q, e);
|
||||
// })
|
||||
// .finally(() => {
|
||||
// hideLoader();
|
||||
// });
|
||||
// }
|
||||
|
||||
// async function getReligion() {
|
||||
// showLoader();
|
||||
// await http
|
||||
// .get(config.API.profileNewReligion)
|
||||
// .then((res) => {
|
||||
// religionOp.value = res.data.result;
|
||||
// })
|
||||
// .catch((e) => {
|
||||
// messageError($q, e);
|
||||
// })
|
||||
// .finally(() => {
|
||||
// hideLoader();
|
||||
// });
|
||||
// }
|
||||
|
||||
// async function getBloodGroup() {
|
||||
// showLoader();
|
||||
// await http
|
||||
// .get(config.API.profileNewBloodGroup)
|
||||
// .then((res) => {
|
||||
// bloodGroupOp.value = res.data.result;
|
||||
// })
|
||||
// .catch((e) => {
|
||||
// messageError($q, e);
|
||||
// })
|
||||
// .finally(() => {
|
||||
// hideLoader();
|
||||
// });
|
||||
// }
|
||||
|
||||
return {
|
||||
defaultProfile,
|
||||
retireDate,
|
||||
Ops,
|
||||
OpsFilter,
|
||||
// prefixOp,
|
||||
// genderOp,
|
||||
// religionOp,
|
||||
// relationshipOp,
|
||||
// bloodGroupOp,
|
||||
|
||||
calculateAge,
|
||||
fetchPerson,
|
||||
filterSelector,
|
||||
// getGender,
|
||||
// getRelationship,
|
||||
// getReligion,
|
||||
// getBloodGroup,
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue