ทะเบียนประวัติ: ประวัติส่วนตัว (GET, PUT)
This commit is contained in:
parent
93fc17cea0
commit
79f08f7569
5 changed files with 409 additions and 454 deletions
|
|
@ -1,11 +1,26 @@
|
||||||
import env from "../index";
|
import env from "../index";
|
||||||
|
|
||||||
const registryNew = `${env.API_URI}/org/profile/`;
|
const registryNew = `${env.API_URI}/org/profile/`;
|
||||||
|
const metadata = `${env.API_URI}/org/metadata/`;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
registryNew,
|
registryNew,
|
||||||
registryNewByProfileId: (profileId: string) => `${registryNew}${profileId}`,
|
registryNewByProfileId: (profileId: string) => `${registryNew}${profileId}`,
|
||||||
|
|
||||||
|
// metadata
|
||||||
|
profileNewGender: `${metadata}gender`,
|
||||||
|
profileNewReligion: `${metadata}religion`,
|
||||||
|
profileNewRelationship: `${metadata}relationship`,
|
||||||
|
profileNewBloodGroup: `${metadata}bloodGroup`,
|
||||||
|
|
||||||
|
// ประวัติส่วนตัว
|
||||||
|
profileNewProfileByProfileId: (profileId: string) =>
|
||||||
|
`${registryNew}${profileId}`,
|
||||||
|
profileNewProfileById: (dataId: string) =>
|
||||||
|
`${registryNew}${dataId}`,
|
||||||
|
profileNewProfileHisById: (dataId: string) =>
|
||||||
|
`${registryNew}history/${dataId}`,
|
||||||
|
|
||||||
// บันทึกวันที่ไม่ได้รับเงินเดือนฯ
|
// บันทึกวันที่ไม่ได้รับเงินเดือนฯ
|
||||||
profileNewNoPaid: `${registryNew}nopaid`,
|
profileNewNoPaid: `${registryNew}nopaid`,
|
||||||
profileNewNoPaidByProfileId: (profileId: string) =>
|
profileNewNoPaidByProfileId: (profileId: string) =>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, watch, ref } from "vue";
|
import { onMounted, watch, ref, reactive } from "vue";
|
||||||
|
import { useRoute } from "vue-router";
|
||||||
import { useQuasar } from "quasar";
|
import { useQuasar } from "quasar";
|
||||||
import type { QTableColumn, QForm } from "quasar";
|
import type { QTableColumn, QForm } from "quasar";
|
||||||
import http from "@/plugins/http";
|
import http from "@/plugins/http";
|
||||||
|
|
@ -9,18 +10,16 @@ import { useCounterMixin } from "@/stores/mixin";
|
||||||
import { useProfileDataStore } from "@/modules/04_registryNew/stores/profile";
|
import { useProfileDataStore } from "@/modules/04_registryNew/stores/profile";
|
||||||
import HistoryTable from "@/components/TableHistory.vue";
|
import HistoryTable from "@/components/TableHistory.vue";
|
||||||
import DialogHeader from "@/components/DialogHeader.vue";
|
import DialogHeader from "@/components/DialogHeader.vue";
|
||||||
import type {
|
import type { RequestObject } from "@/modules/04_registryNew/interface/request/Profile";
|
||||||
InformationOps,
|
import type { ResponseObject } from "@/modules/04_registryNew/interface/response/Profile";
|
||||||
Information,
|
|
||||||
DataOption,
|
|
||||||
} from "@/modules/04_registryNew/interface/index/Main";
|
|
||||||
import { defaultInformation } from "@/modules/04_registryNew/interface/index/Main";
|
|
||||||
import type { RequestItemsHistoryObject } from "@/modules/04_registryNew/interface/request/Information";
|
import type { RequestItemsHistoryObject } from "@/modules/04_registryNew/interface/request/Information";
|
||||||
|
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
|
const route = useRoute();
|
||||||
const mixin = useCounterMixin();
|
const mixin = useCounterMixin();
|
||||||
const profileStore = useProfileDataStore();
|
const store = useProfileDataStore();
|
||||||
const {
|
const {
|
||||||
|
success,
|
||||||
showLoader,
|
showLoader,
|
||||||
hideLoader,
|
hideLoader,
|
||||||
date2Thai,
|
date2Thai,
|
||||||
|
|
@ -28,73 +27,45 @@ const {
|
||||||
convertDate,
|
convertDate,
|
||||||
dateToISO,
|
dateToISO,
|
||||||
} = mixin;
|
} = mixin;
|
||||||
const { changeRetireText, changeBirth } = profileStore;
|
const { calculateAge, getGender, getRelationship, getReligion, getBloodGroup } =
|
||||||
|
store;
|
||||||
|
const profileId = ref<string>(
|
||||||
|
route.params.id ? route.params.id.toString() : ""
|
||||||
|
);
|
||||||
|
|
||||||
const informaData = ref<Information>(defaultInformation);
|
|
||||||
const modal = ref<boolean>(false);
|
const modal = ref<boolean>(false);
|
||||||
const myForm = ref<any>();
|
const myForm = ref<any>();
|
||||||
|
const informaData = ref<ResponseObject>();
|
||||||
const rowsHistory = ref<RequestItemsHistoryObject[]>([]);
|
const rowsHistory = ref<RequestItemsHistoryObject[]>([]);
|
||||||
const tittleHistory = ref<string>("ประวัติแก้ไขข้อมูลส่วนตัว");
|
const tittleHistory = ref<string>("ประวัติแก้ไขข้อมูลส่วนตัว");
|
||||||
const filterHistory = ref<string>("");
|
const filterHistory = ref<string>("");
|
||||||
const modalHistory = ref<boolean>(false);
|
const modalHistory = ref<boolean>(false);
|
||||||
|
|
||||||
const Ops = ref<InformationOps>({
|
const id = ref<string>("");
|
||||||
prefixOps: [],
|
const age = ref<string>("");
|
||||||
prefixOldOps: [],
|
// หลังบ้านไม่มีข้อมูล สัญชาติ
|
||||||
genderOps: [],
|
const nationality = ref<string>("")
|
||||||
bloodOps: [],
|
const formData = reactive<RequestObject>({
|
||||||
statusOps: [],
|
citizenId: "",
|
||||||
religionOps: [],
|
prefix: "",
|
||||||
employeeClassOps: [
|
firstName: "",
|
||||||
{ id: "perm", name: "ลูกจ้างประจำ" },
|
lastName: "",
|
||||||
{ id: "temp", name: "ลูกจ้างชั่วคราว" },
|
birthDate: null,
|
||||||
],
|
genderId: "",
|
||||||
employeeTypeOps: [
|
relationshipId: "",
|
||||||
{ id: "gov", name: "งบประมาณเงินอุดหนุนรัฐบาล" },
|
// nationality: "",
|
||||||
{ id: "bkk", name: "งบประมาณกรุงเทพมหานคร" },
|
ethnicity: "",
|
||||||
],
|
religionId: "",
|
||||||
});
|
bloodGroupId: "",
|
||||||
|
phone: "",
|
||||||
const OpsFilter = ref<InformationOps>({
|
posTypeId: "",
|
||||||
prefixOps: [],
|
posLevelId: "",
|
||||||
prefixOldOps: [],
|
|
||||||
genderOps: [],
|
|
||||||
bloodOps: [],
|
|
||||||
statusOps: [],
|
|
||||||
religionOps: [],
|
|
||||||
employeeClassOps: [
|
|
||||||
{ id: "perm", name: "ลูกจ้างประจำ" },
|
|
||||||
{ id: "temp", name: "ลูกจ้างชั่วคราว" },
|
|
||||||
],
|
|
||||||
employeeTypeOps: [
|
|
||||||
{ id: "gov", name: "งบประมาณเงินอุดหนุนรัฐบาล" },
|
|
||||||
{ id: "bkk", name: "งบประมาณกรุงเทพมหานคร" },
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
// mock data
|
|
||||||
const resultData = ref({
|
|
||||||
citizenId: "3101502080439",
|
|
||||||
prefixId: "71ed89df-8257-43e8-8fba-0b42fb2c55e0",
|
|
||||||
prefix: "นางสาว",
|
|
||||||
firstName: "อรัญญาสาร",
|
|
||||||
lastName: "พรไชยะสิทธฺ์",
|
|
||||||
birthDate: new Date("1968-11-24T00:00:00"),
|
|
||||||
age: "55 ปี 3 เดือน 16 วัน",
|
|
||||||
genderId: "e2693577-6633-499b-9f0a-fec0bff0be6b",
|
|
||||||
gender: "หญิง",
|
|
||||||
relationshipId: null,
|
|
||||||
bloodGroupId: null,
|
|
||||||
nationality: "ไทย",
|
|
||||||
race: "ไทย",
|
|
||||||
religionId: "ceaec498-71b4-4f82-b5a2-7d6ec988b753",
|
|
||||||
telephoneNumber: null,
|
telephoneNumber: null,
|
||||||
profileType: "officer",
|
dateRetire: null,
|
||||||
employeeType: null,
|
isProbation: false,
|
||||||
employeeClass: null,
|
keycloak: "",
|
||||||
changeName: true,
|
email: null,
|
||||||
isVerified: true,
|
position: "",
|
||||||
isSendVerified: false,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const dataLabel = {
|
const dataLabel = {
|
||||||
|
|
@ -105,10 +76,10 @@ const dataLabel = {
|
||||||
gender: "เพศ",
|
gender: "เพศ",
|
||||||
relationship: "สถานภาพ",
|
relationship: "สถานภาพ",
|
||||||
nationality: "สัญชาติ",
|
nationality: "สัญชาติ",
|
||||||
race: "เชื้อชาติ",
|
ethnicity: "เชื้อชาติ",
|
||||||
religion: "ศาสนา",
|
religion: "ศาสนา",
|
||||||
bloodGroup: "หมู่เลือด",
|
bloodGroup: "หมู่เลือด",
|
||||||
telephoneNumber: "เบอร์โทร",
|
phone: "เบอร์โทร",
|
||||||
|
|
||||||
prefix: "คำนำหน้าชื่อ",
|
prefix: "คำนำหน้าชื่อ",
|
||||||
firstName: "ชื่อ",
|
firstName: "ชื่อ",
|
||||||
|
|
@ -238,11 +209,11 @@ const columnsHistory = ref<QTableColumn[]>([
|
||||||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "telephoneNumber",
|
name: "phone",
|
||||||
align: "left",
|
align: "left",
|
||||||
label: "เบอร์โทร",
|
label: "เบอร์โทร",
|
||||||
sortable: true,
|
sortable: true,
|
||||||
field: "telephoneNumber",
|
field: "phone",
|
||||||
headerStyle: "font-size: 14px",
|
headerStyle: "font-size: 14px",
|
||||||
style: "font-size: 14px",
|
style: "font-size: 14px",
|
||||||
sort: (a: string, b: string) =>
|
sort: (a: string, b: string) =>
|
||||||
|
|
@ -306,253 +277,89 @@ const visibleColumnsHistory = ref<String[]>([
|
||||||
"nationality",
|
"nationality",
|
||||||
"race",
|
"race",
|
||||||
"religion",
|
"religion",
|
||||||
"telephoneNumber",
|
"phone",
|
||||||
"employeeType",
|
"employeeType",
|
||||||
"employeeClass",
|
"employeeClass",
|
||||||
"createdFullName",
|
"createdFullName",
|
||||||
"createdAt",
|
"createdAt",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
async function fetchData() {
|
async function getData() {
|
||||||
informaData.value.cardid = resultData.value.citizenId;
|
showLoader();
|
||||||
informaData.value.prefixId = resultData.value.prefixId;
|
|
||||||
informaData.value.prefix = resultData.value.prefix;
|
|
||||||
informaData.value.firstname = resultData.value.firstName;
|
|
||||||
informaData.value.lastname = resultData.value.lastName;
|
|
||||||
informaData.value.birthDate = resultData.value.birthDate;
|
|
||||||
informaData.value.age = resultData.value.age;
|
|
||||||
informaData.value.genderId = resultData.value.genderId;
|
|
||||||
informaData.value.bloodId = resultData.value.bloodGroupId;
|
|
||||||
informaData.value.nationality = resultData.value.nationality;
|
|
||||||
informaData.value.ethnicity = resultData.value.race;
|
|
||||||
informaData.value.statusId = resultData.value.relationshipId;
|
|
||||||
informaData.value.religionId = resultData.value.religionId;
|
|
||||||
informaData.value.tel = resultData.value.telephoneNumber;
|
|
||||||
informaData.value.employeeType = resultData.value.employeeType;
|
|
||||||
informaData.value.employeeClass = resultData.value.employeeClass;
|
|
||||||
informaData.value.profileType = resultData.value.profileType;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get person detail list
|
|
||||||
async function fetchPerson() {
|
|
||||||
// showLoader();
|
|
||||||
await http
|
await http
|
||||||
.get(config.API.person)
|
.get(config.API.profileNewProfileByProfileId(profileId.value))
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data.result;
|
informaData.value = res.data.result;
|
||||||
let optionbloodGroups: DataOption[] = [];
|
if (informaData.value) {
|
||||||
data.bloodGroups.map((r: any) => {
|
age.value = calculateAge(informaData.value.birthDate);
|
||||||
optionbloodGroups.push({
|
}
|
||||||
id: r.id.toString(),
|
})
|
||||||
name: r.name.toString(),
|
.catch((e) => {
|
||||||
});
|
messageError($q, e);
|
||||||
});
|
|
||||||
Ops.value.bloodOps = optionbloodGroups;
|
|
||||||
OpsFilter.value.bloodOps = optionbloodGroups;
|
|
||||||
|
|
||||||
let optiongenders: DataOption[] = [];
|
|
||||||
data.genders.map((r: any) => {
|
|
||||||
optiongenders.push({
|
|
||||||
id: r.id.toString(),
|
|
||||||
name: r.name.toString(),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
Ops.value.genderOps = optiongenders;
|
|
||||||
OpsFilter.value.genderOps = optiongenders;
|
|
||||||
|
|
||||||
let optionprefixs: DataOption[] = [];
|
|
||||||
data.prefixs.map((r: any) => {
|
|
||||||
optionprefixs.push({
|
|
||||||
id: r.id.toString(),
|
|
||||||
name: r.name.toString(),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
Ops.value.prefixOps = optionprefixs;
|
|
||||||
OpsFilter.value.prefixOps = optionprefixs;
|
|
||||||
|
|
||||||
let optionrelationships: DataOption[] = [];
|
|
||||||
data.relationships.map((r: any) => {
|
|
||||||
optionrelationships.push({
|
|
||||||
id: r.id.toString(),
|
|
||||||
name: r.name.toString(),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
Ops.value.statusOps = optionrelationships;
|
|
||||||
OpsFilter.value.statusOps = optionrelationships;
|
|
||||||
|
|
||||||
let optionreligions: DataOption[] = [];
|
|
||||||
data.religions.map((r: any) => {
|
|
||||||
optionreligions.push({
|
|
||||||
id: r.id.toString(),
|
|
||||||
name: r.name.toString(),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
Ops.value.religionOps = optionreligions;
|
|
||||||
OpsFilter.value.religionOps = optionreligions;
|
|
||||||
})
|
})
|
||||||
.catch((e: any) => {})
|
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
// hideLoader();
|
hideLoader();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterSelector(val: any, update: Function, refData: string) {
|
function onClickOpenDialog() {
|
||||||
switch (refData) {
|
if (!informaData.value) return;
|
||||||
case "prefixOps":
|
modal.value = true;
|
||||||
update(() => {
|
|
||||||
Ops.value.prefixOps = OpsFilter.value.prefixOps.filter(
|
|
||||||
(v: DataOption) => v.name.indexOf(val) > -1
|
|
||||||
);
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case "genderOps":
|
|
||||||
update(() => {
|
|
||||||
Ops.value.genderOps = OpsFilter.value.genderOps.filter(
|
|
||||||
(v: DataOption) => v.name.indexOf(val) > -1
|
|
||||||
);
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case "bloodOps":
|
|
||||||
update(() => {
|
|
||||||
Ops.value.bloodOps = OpsFilter.value.bloodOps.filter(
|
|
||||||
(v: DataOption) => v.name.indexOf(val) > -1
|
|
||||||
);
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case "statusOps":
|
|
||||||
update(() => {
|
|
||||||
Ops.value.statusOps = OpsFilter.value.statusOps.filter(
|
|
||||||
(v: DataOption) => v.name.indexOf(val) > -1
|
|
||||||
);
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case "religionOps":
|
|
||||||
update(() => {
|
|
||||||
Ops.value.religionOps = OpsFilter.value.religionOps.filter(
|
|
||||||
(v: DataOption) => v.name.indexOf(val) > -1
|
|
||||||
);
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case "employeeClassOps":
|
|
||||||
update(() => {
|
|
||||||
Ops.value.employeeClassOps = OpsFilter.value.employeeClassOps.filter(
|
|
||||||
(v: DataOption) => v.name.indexOf(val) > -1
|
|
||||||
);
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case "employeeTypeOps":
|
|
||||||
update(() => {
|
|
||||||
Ops.value.employeeTypeOps = OpsFilter.value.employeeTypeOps.filter(
|
|
||||||
(v: DataOption) => v.name.indexOf(val) > -1
|
|
||||||
);
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
id.value = informaData.value.id;
|
||||||
break;
|
age.value = calculateAge(informaData.value.birthDate);
|
||||||
}
|
formData.citizenId = informaData.value.citizenId;
|
||||||
|
formData.prefix = informaData.value.prefix;
|
||||||
|
formData.firstName = informaData.value.firstName;
|
||||||
|
formData.lastName = informaData.value.lastName;
|
||||||
|
formData.birthDate = informaData.value.birthDate;
|
||||||
|
formData.genderId = informaData.value.genderId;
|
||||||
|
formData.relationshipId = informaData.value.relationshipId;
|
||||||
|
// formData.nationality = informaData.value.nationality;
|
||||||
|
formData.ethnicity = informaData.value.ethnicity;
|
||||||
|
formData.religionId = informaData.value.religionId;
|
||||||
|
formData.bloodGroupId = informaData.value.bloodGroupId;
|
||||||
|
formData.phone = informaData.value.phone;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function clickHistory() {
|
async function editData() {
|
||||||
modalHistory.value = true;
|
showLoader();
|
||||||
// showLoader();
|
await http
|
||||||
// await http
|
.put(config.API.profileNewProfileById(id.value), {
|
||||||
// .get(config.API.profileInforHisId(route.params.id.toString()))
|
...formData,
|
||||||
// .then((res) => {
|
})
|
||||||
// let data = res.data.result;
|
.then((res) => {
|
||||||
// rowsHistory.value = [];
|
success($q, "บันทึกข้อมูลสำเร็จ");
|
||||||
// data.map((e: RequestItemsHistoryObject) => {
|
getData(), (modal.value = false);
|
||||||
// rowsHistory.value.push({
|
})
|
||||||
// citizenId: e.citizenId,
|
.catch((e) => {
|
||||||
// prefix: e.prefix,
|
messageError($q, e);
|
||||||
// firstName: e.firstName,
|
})
|
||||||
// lastName: e.lastName,
|
.finally(() => {
|
||||||
// birthDate: new Date(e.birthDate),
|
hideLoader();
|
||||||
// gender: e.gender,
|
});
|
||||||
// relationship: e.relationship,
|
|
||||||
// bloodGroup: e.bloodGroup,
|
|
||||||
// nationality: e.nationality,
|
|
||||||
// race: e.race,
|
|
||||||
// religion: e.religion,
|
|
||||||
// telephoneNumber: e.telephoneNumber,
|
|
||||||
// employeeType:
|
|
||||||
// e.employeeType == "gov"
|
|
||||||
// ? "งบประมาณเงินอุดหนุนรัฐบาล"
|
|
||||||
// : e.employeeType == "bkk"
|
|
||||||
// ? "งบประมาณกรุงเทพมหานคร"
|
|
||||||
// : "-",
|
|
||||||
// employeeClass:
|
|
||||||
// e.employeeClass == "perm"
|
|
||||||
// ? "ลูกจ้างประจำ"
|
|
||||||
// : e.employeeClass == "temp"
|
|
||||||
// ? "ลูกจ้างชั่วคราว"
|
|
||||||
// : "-",
|
|
||||||
// createdFullName: e.createdFullName,
|
|
||||||
// createdAt: new Date(e.createdAt),
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// })
|
|
||||||
// .catch((e) => {
|
|
||||||
// messageError($q, e);
|
|
||||||
// })
|
|
||||||
// .finally(() => {
|
|
||||||
// hideLoader();
|
|
||||||
// });
|
|
||||||
}
|
|
||||||
|
|
||||||
async function calRetire(birth: Date) {
|
|
||||||
const body = {
|
|
||||||
birthDate: dateToISO(birth),
|
|
||||||
};
|
|
||||||
const dateBefore = ref<Date>(new Date());
|
|
||||||
if (dateToISO(dateBefore.value) != dateToISO(birth)) {
|
|
||||||
showLoader();
|
|
||||||
await http
|
|
||||||
.post(config.API.profileCalRetire, body)
|
|
||||||
.then((res: any) => {
|
|
||||||
const data = res.data.result;
|
|
||||||
informaData.value.age = data.age;
|
|
||||||
informaData.value.birthDate = birth;
|
|
||||||
changeRetireText(data.retireDate);
|
|
||||||
dateBefore.value = birth;
|
|
||||||
})
|
|
||||||
.catch((e: any) => {
|
|
||||||
messageError($q, e);
|
|
||||||
const retire = new Date(`${birth.getFullYear() + 60}-09-30`);
|
|
||||||
informaData.value.birthDate = dateBefore.value;
|
|
||||||
// inputBirthDate.value = dateBefore.value;
|
|
||||||
changeRetireText(date2Thai(retire));
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
hideLoader();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onSubmit() {
|
|
||||||
myForm.value.validate().then(async (result: boolean) => {
|
|
||||||
if (result) {
|
|
||||||
// await saveData();
|
|
||||||
modal.value = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => informaData.value.birthDate,
|
() => formData.birthDate,
|
||||||
(value) => {
|
(v) => {
|
||||||
// const dateVal = convertDate(value);
|
if (v) {
|
||||||
if (value) {
|
age.value = calculateAge(v);
|
||||||
calRetire(value);
|
|
||||||
} else {
|
|
||||||
informaData.value.age = "";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function onSubmit() {
|
||||||
|
editData();
|
||||||
|
modal.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await fetchPerson();
|
await getData();
|
||||||
await fetchData();
|
store.genderOp.length === 0 ? await getGender() : "";
|
||||||
|
store.relationshipOp.length === 0 ? await getRelationship() : "";
|
||||||
|
store.religionOp.length === 0 ? await getReligion() : "";
|
||||||
|
store.bloodGroupOp.length === 0 ? await getBloodGroup() : "";
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -563,18 +370,18 @@ onMounted(async () => {
|
||||||
round
|
round
|
||||||
icon="mdi-pencil-outline"
|
icon="mdi-pencil-outline"
|
||||||
color="primary"
|
color="primary"
|
||||||
@click="modal = true"
|
@click="onClickOpenDialog"
|
||||||
>
|
>
|
||||||
<q-tooltip>แก้ไขข้อมูล</q-tooltip>
|
<q-tooltip>แก้ไขข้อมูล</q-tooltip>
|
||||||
</q-btn>
|
</q-btn>
|
||||||
<q-btn flat round icon="mdi-history" color="info" @click="clickHistory">
|
<q-btn flat round icon="mdi-history" color="info">
|
||||||
<q-tooltip>ประวัติข้อมูลส่วนตัว</q-tooltip>
|
<q-tooltip>ประวัติข้อมูลส่วนตัว</q-tooltip>
|
||||||
</q-btn>
|
</q-btn>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<q-card bordered class="my-card bg-grey-1 q-pa-md">
|
<q-card bordered class="my-card bg-grey-1 q-pa-md">
|
||||||
<div :class="$q.screen.gt.xs ? 'row' : 'column'">
|
<div v-if="informaData" :class="$q.screen.gt.xs ? 'row' : 'column'">
|
||||||
<!-- column 1 -->
|
<!-- column 1 -->
|
||||||
<div class="col-md-7 col-12 row">
|
<div class="col-md-7 col-12 row">
|
||||||
<div class="col-md-4 col-5 text-grey-6 text-weight-medium">
|
<div class="col-md-4 col-5 text-grey-6 text-weight-medium">
|
||||||
|
|
@ -588,38 +395,24 @@ onMounted(async () => {
|
||||||
<!-- data -->
|
<!-- data -->
|
||||||
<div class="col-md-8 col-7">
|
<div class="col-md-8 col-7">
|
||||||
<div class="q-py-xs">
|
<div class="q-py-xs">
|
||||||
{{ informaData.cardid }}
|
{{ informaData.citizenId }}
|
||||||
</div>
|
</div>
|
||||||
<div class="q-py-xs">
|
<div class="q-py-xs">
|
||||||
{{
|
{{
|
||||||
`${informaData.prefix} ${informaData.firstname} ${informaData.lastname}`
|
`${informaData.prefix} ${informaData.firstName} ${informaData.lastName}`
|
||||||
}}
|
}}
|
||||||
</div>
|
</div>
|
||||||
<div class="q-py-xs">
|
<div class="q-py-xs">
|
||||||
{{ date2Thai(informaData.birthDate) }}
|
{{ date2Thai(informaData.birthDate) }}
|
||||||
</div>
|
</div>
|
||||||
<div class="q-py-xs">
|
<div class="q-py-xs">
|
||||||
{{ informaData.age ? informaData.age : "-" }}
|
{{ age ? age : "-" }}
|
||||||
</div>
|
</div>
|
||||||
<div class="q-py-xs">
|
<div class="q-py-xs">
|
||||||
{{
|
{{ informaData.gender ? informaData.gender.name : "-" }}
|
||||||
informaData.genderId
|
|
||||||
? (
|
|
||||||
Ops.genderOps.find((r) => r.id === informaData.genderId) ||
|
|
||||||
{}
|
|
||||||
).name
|
|
||||||
: "-"
|
|
||||||
}}
|
|
||||||
</div>
|
</div>
|
||||||
<div class="q-py-xs">
|
<div class="q-py-xs">
|
||||||
{{
|
{{ informaData.relationship ? informaData.relationship.name : "-" }}
|
||||||
informaData.statusId
|
|
||||||
? (
|
|
||||||
Ops.statusOps.find((r) => r.id === informaData.statusId) ||
|
|
||||||
{}
|
|
||||||
).name
|
|
||||||
: "-"
|
|
||||||
}}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -643,26 +436,13 @@ onMounted(async () => {
|
||||||
{{ informaData.ethnicity ? informaData.ethnicity : "-" }}
|
{{ informaData.ethnicity ? informaData.ethnicity : "-" }}
|
||||||
</div>
|
</div>
|
||||||
<div class="q-py-xs">
|
<div class="q-py-xs">
|
||||||
{{
|
{{ informaData.religion ? informaData.religion.name : "-" }}
|
||||||
informaData.religionId
|
|
||||||
? (
|
|
||||||
Ops.religionOps.find(
|
|
||||||
(r) => r.id === informaData.religionId
|
|
||||||
) || {}
|
|
||||||
).name
|
|
||||||
: "-"
|
|
||||||
}}
|
|
||||||
</div>
|
</div>
|
||||||
<div class="q-py-xs">
|
<div class="q-py-xs">
|
||||||
{{
|
{{ informaData.bloodGroup ? informaData.bloodGroup.name : "-" }}
|
||||||
informaData.bloodId
|
|
||||||
? (Ops.bloodOps.find((b) => b.id === informaData.bloodId) || {})
|
|
||||||
.name
|
|
||||||
: "-"
|
|
||||||
}}
|
|
||||||
</div>
|
</div>
|
||||||
<div class="q-py-xs">
|
<div class="q-py-xs">
|
||||||
{{ informaData.tel ? informaData.tel : "-" }}
|
{{ informaData.phone ? informaData.phone : "-" }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -672,7 +452,7 @@ onMounted(async () => {
|
||||||
<!-- Edit Dialog -->
|
<!-- Edit Dialog -->
|
||||||
<q-dialog v-model="modal" persistent>
|
<q-dialog v-model="modal" persistent>
|
||||||
<q-card style="width: 600px">
|
<q-card style="width: 600px">
|
||||||
<q-form ref="myForm" @submit="onSubmit">
|
<q-form greedy @submit.prevent @validation-success="onSubmit">
|
||||||
<DialogHeader
|
<DialogHeader
|
||||||
tittle="แก้ไขประวัติส่วนตัว"
|
tittle="แก้ไขประวัติส่วนตัว"
|
||||||
:close="() => (modal = false)"
|
:close="() => (modal = false)"
|
||||||
|
|
@ -688,7 +468,8 @@ onMounted(async () => {
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
maxlength="13"
|
maxlength="13"
|
||||||
mask="#############"
|
mask="#############"
|
||||||
v-model="informaData.cardid"
|
v-model="formData.citizenId"
|
||||||
|
class="inputgreen"
|
||||||
:label="dataLabel.citizenId"
|
:label="dataLabel.citizenId"
|
||||||
:rules="[
|
:rules="[
|
||||||
(val: string) => !!val || `${'กรุณากรอก เลขประจำตัวประชาชน'}`,
|
(val: string) => !!val || `${'กรุณากรอก เลขประจำตัวประชาชน'}`,
|
||||||
|
|
@ -702,20 +483,17 @@ onMounted(async () => {
|
||||||
<q-select
|
<q-select
|
||||||
dense
|
dense
|
||||||
outlined
|
outlined
|
||||||
|
use-input
|
||||||
lazy-rules
|
lazy-rules
|
||||||
emit-value
|
emit-value
|
||||||
map-options
|
map-options
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
option-value="id"
|
|
||||||
option-label="name"
|
|
||||||
input-debounce="0"
|
input-debounce="0"
|
||||||
v-model="informaData.prefixId"
|
v-model="formData.prefix"
|
||||||
:options="Ops.prefixOps"
|
class="inputgreen"
|
||||||
|
:options="store.prefixOp"
|
||||||
:label="dataLabel.prefix"
|
:label="dataLabel.prefix"
|
||||||
:rules="[(val: string) => !!val || `${'กรุณาเลือก คำนำหน้าชื่อ'}`]"
|
:rules="[(val: string) => !!val || `${'กรุณาเลือก คำนำหน้าชื่อ'}`]"
|
||||||
@filter="(inputValue: any,
|
|
||||||
doneFn: Function) => filterSelector(inputValue, doneFn, 'prefixOps'
|
|
||||||
)"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-6 col-sm-6 col-md-6">
|
<div class="col-xs-6 col-sm-6 col-md-6">
|
||||||
|
|
@ -724,7 +502,8 @@ onMounted(async () => {
|
||||||
outlined
|
outlined
|
||||||
lazy-rules
|
lazy-rules
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
v-model="informaData.firstname"
|
v-model="formData.firstName"
|
||||||
|
class="inputgreen"
|
||||||
:label="dataLabel.firstName"
|
:label="dataLabel.firstName"
|
||||||
:rules="[(val: string) => !!val || `${'กรุณากรอก ชื่อ'}`]"
|
:rules="[(val: string) => !!val || `${'กรุณากรอก ชื่อ'}`]"
|
||||||
/>
|
/>
|
||||||
|
|
@ -735,7 +514,8 @@ onMounted(async () => {
|
||||||
outlined
|
outlined
|
||||||
lazy-rules
|
lazy-rules
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
v-model="informaData.lastname"
|
v-model="formData.lastName"
|
||||||
|
class="inputgreen"
|
||||||
:label="dataLabel.lastName"
|
:label="dataLabel.lastName"
|
||||||
:rules="[(val: string) => !!val || `${'กรุณากรอก นามสกุล'}`]"
|
:rules="[(val: string) => !!val || `${'กรุณากรอก นามสกุล'}`]"
|
||||||
/>
|
/>
|
||||||
|
|
@ -746,7 +526,7 @@ onMounted(async () => {
|
||||||
borderless
|
borderless
|
||||||
week-start="0"
|
week-start="0"
|
||||||
menu-class-name="modalfix"
|
menu-class-name="modalfix"
|
||||||
v-model="informaData.birthDate"
|
v-model="formData.birthDate"
|
||||||
:locale="'th'"
|
:locale="'th'"
|
||||||
>
|
>
|
||||||
<template #year="{ year }">
|
<template #year="{ year }">
|
||||||
|
|
@ -762,9 +542,10 @@ onMounted(async () => {
|
||||||
outlined
|
outlined
|
||||||
dense
|
dense
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
|
class="inputgreen"
|
||||||
:model-value="
|
:model-value="
|
||||||
informaData.birthDate != null
|
formData.birthDate != null
|
||||||
? date2Thai(informaData.birthDate)
|
? date2Thai(formData.birthDate)
|
||||||
: null
|
: null
|
||||||
"
|
"
|
||||||
:label="dataLabel.birthDate"
|
:label="dataLabel.birthDate"
|
||||||
|
|
@ -791,7 +572,8 @@ onMounted(async () => {
|
||||||
lazy-rules
|
lazy-rules
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
readonly
|
readonly
|
||||||
v-model="informaData.age"
|
class="inputgreen"
|
||||||
|
v-model="age"
|
||||||
:label="dataLabel.age"
|
:label="dataLabel.age"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -804,15 +586,13 @@ onMounted(async () => {
|
||||||
emit-value
|
emit-value
|
||||||
map-options
|
map-options
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
option-value="id"
|
|
||||||
option-label="name"
|
|
||||||
input-debounce="0"
|
input-debounce="0"
|
||||||
v-model="informaData.genderId"
|
option-label="name"
|
||||||
:options="Ops.genderOps"
|
option-value="id"
|
||||||
|
v-model="formData.genderId"
|
||||||
|
class="inputgreen"
|
||||||
|
:options="store.genderOp"
|
||||||
:label="dataLabel.gender"
|
:label="dataLabel.gender"
|
||||||
@filter="(inputValue: any,
|
|
||||||
doneFn: Function) => filterSelector(inputValue, doneFn, 'genderOps'
|
|
||||||
)"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-6 col-sm-6 col-md-6">
|
<div class="col-xs-6 col-sm-6 col-md-6">
|
||||||
|
|
@ -827,12 +607,10 @@ onMounted(async () => {
|
||||||
option-value="id"
|
option-value="id"
|
||||||
option-label="name"
|
option-label="name"
|
||||||
input-debounce="0"
|
input-debounce="0"
|
||||||
v-model="informaData.statusId"
|
class="inputgreen"
|
||||||
:options="Ops.statusOps"
|
v-model="formData.relationshipId"
|
||||||
|
:options="store.relationshipOp"
|
||||||
:label="dataLabel.relationship"
|
:label="dataLabel.relationship"
|
||||||
@filter="(inputValue: any,
|
|
||||||
doneFn: Function) => filterSelector(inputValue, doneFn, 'statusOps'
|
|
||||||
)"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-6 col-sm-6 col-md-6">
|
<div class="col-xs-6 col-sm-6 col-md-6">
|
||||||
|
|
@ -841,7 +619,8 @@ onMounted(async () => {
|
||||||
outlined
|
outlined
|
||||||
lazy-rules
|
lazy-rules
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
v-model="informaData.nationality"
|
class="inputgreen"
|
||||||
|
v-model="nationality"
|
||||||
:label="dataLabel.nationality"
|
:label="dataLabel.nationality"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -851,8 +630,9 @@ onMounted(async () => {
|
||||||
outlined
|
outlined
|
||||||
lazy-rules
|
lazy-rules
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
v-model="informaData.ethnicity"
|
class="inputgreen"
|
||||||
:label="dataLabel.race"
|
v-model="formData.ethnicity"
|
||||||
|
:label="dataLabel.ethnicity"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-6 col-sm-6 col-md-6">
|
<div class="col-xs-6 col-sm-6 col-md-6">
|
||||||
|
|
@ -867,12 +647,10 @@ onMounted(async () => {
|
||||||
option-value="id"
|
option-value="id"
|
||||||
option-label="name"
|
option-label="name"
|
||||||
input-debounce="0"
|
input-debounce="0"
|
||||||
v-model="informaData.religionId"
|
v-model="formData.religionId"
|
||||||
:options="Ops.religionOps"
|
class="inputgreen"
|
||||||
|
:options="store.religionOp"
|
||||||
:label="dataLabel.religion"
|
:label="dataLabel.religion"
|
||||||
@filter="(inputValue: any,
|
|
||||||
doneFn: Function) => filterSelector(inputValue, doneFn, 'religionOps'
|
|
||||||
)"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-6 col-sm-6 col-md-6">
|
<div class="col-xs-6 col-sm-6 col-md-6">
|
||||||
|
|
@ -887,12 +665,10 @@ onMounted(async () => {
|
||||||
option-value="id"
|
option-value="id"
|
||||||
option-label="name"
|
option-label="name"
|
||||||
input-debounce="0"
|
input-debounce="0"
|
||||||
v-model="informaData.bloodId"
|
v-model="formData.bloodGroupId"
|
||||||
:options="Ops.bloodOps"
|
class="inputgreen"
|
||||||
|
:options="store.bloodGroupOp"
|
||||||
:label="dataLabel.bloodGroup"
|
:label="dataLabel.bloodGroup"
|
||||||
@filter="(inputValue: any,
|
|
||||||
doneFn: Function) => filterSelector(inputValue, doneFn, 'bloodOps'
|
|
||||||
)"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-6 col-sm-6 col-md-6">
|
<div class="col-xs-6 col-sm-6 col-md-6">
|
||||||
|
|
@ -902,8 +678,9 @@ onMounted(async () => {
|
||||||
lazy-rules
|
lazy-rules
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
mask="##########"
|
mask="##########"
|
||||||
v-model="informaData.tel"
|
class="inputgreen"
|
||||||
:label="dataLabel.telephoneNumber"
|
v-model="formData.phone"
|
||||||
|
:label="dataLabel.phone"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
24
src/modules/04_registryNew/interface/request/Profile.ts
Normal file
24
src/modules/04_registryNew/interface/request/Profile.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
interface RequestObject {
|
||||||
|
bloodGroupId: string | null;
|
||||||
|
relationshipId: string | null;
|
||||||
|
genderId: string | null;
|
||||||
|
posTypeId: string;
|
||||||
|
posLevelId: string;
|
||||||
|
religionId: string | null;
|
||||||
|
citizenId: string;
|
||||||
|
telephoneNumber: string | null;
|
||||||
|
// nationality: string | null;
|
||||||
|
ethnicity: string | null;
|
||||||
|
birthDate: Date | null;
|
||||||
|
dateRetire: Date | null;
|
||||||
|
isProbation: boolean;
|
||||||
|
keycloak: string;
|
||||||
|
phone: string | null;
|
||||||
|
email: string | null;
|
||||||
|
position: string;
|
||||||
|
lastName: string;
|
||||||
|
firstName: string;
|
||||||
|
prefix: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type { RequestObject };
|
||||||
108
src/modules/04_registryNew/interface/response/Profile.ts
Normal file
108
src/modules/04_registryNew/interface/response/Profile.ts
Normal file
|
|
@ -0,0 +1,108 @@
|
||||||
|
interface ResponseObject {
|
||||||
|
id: string;
|
||||||
|
createdAt: Date;
|
||||||
|
createdUserId: string;
|
||||||
|
lastUpdatedAt: Date;
|
||||||
|
lastUpdateUserId: string;
|
||||||
|
createdFullName: string;
|
||||||
|
lastUpdateFullName: string;
|
||||||
|
prefix: string;
|
||||||
|
firstName: string;
|
||||||
|
lastName: string;
|
||||||
|
citizenId: string;
|
||||||
|
position: string;
|
||||||
|
posLevelId: string | null;
|
||||||
|
posTypeId: string | null;
|
||||||
|
email: string | null;
|
||||||
|
phone: string | null;
|
||||||
|
keycloak: string | null;
|
||||||
|
isProbation: boolean;
|
||||||
|
dateRetire: Date | null;
|
||||||
|
birthDate: Date;
|
||||||
|
ethnicity: string | null;
|
||||||
|
religionId: string | null;
|
||||||
|
religion: Religion | null;
|
||||||
|
telephoneNumber: null | null;
|
||||||
|
genderId: string | null;
|
||||||
|
gender: Gender | null;
|
||||||
|
relationshipId: string | null;
|
||||||
|
relationship: Relationship | null;
|
||||||
|
bloodGroupId: string | null;
|
||||||
|
bloodGroup: BloodGroup | null;
|
||||||
|
posLevel: PosLevel | null;
|
||||||
|
posType: PosType | null;
|
||||||
|
|
||||||
|
nationality?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Religion {
|
||||||
|
id: string;
|
||||||
|
createdAt: Date;
|
||||||
|
lastUpdatedAt: Date;
|
||||||
|
createdFullName: string;
|
||||||
|
lastUpdateFullName: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Gender {
|
||||||
|
id: string;
|
||||||
|
createdAt: Date;
|
||||||
|
lastUpdatedAt: Date;
|
||||||
|
createdFullName: string;
|
||||||
|
lastUpdateFullName: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Relationship {
|
||||||
|
id: string;
|
||||||
|
createdAt: Date;
|
||||||
|
lastUpdatedAt: Date;
|
||||||
|
createdFullName: string;
|
||||||
|
lastUpdateFullName: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface BloodGroup {
|
||||||
|
id: string;
|
||||||
|
createdAt: Date;
|
||||||
|
lastUpdatedAt: Date;
|
||||||
|
createdFullName: string;
|
||||||
|
lastUpdateFullName: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PosLevel {
|
||||||
|
id: string;
|
||||||
|
createdAt: Date;
|
||||||
|
createdUserId: string;
|
||||||
|
lastUpdatedAt: Date;
|
||||||
|
lastUpdateUserId: string;
|
||||||
|
createdFullName: string;
|
||||||
|
lastUpdateFullName: string;
|
||||||
|
posLevelName: string;
|
||||||
|
posLevelRank: number;
|
||||||
|
posLevelAuthority: null;
|
||||||
|
posTypeId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PosType {
|
||||||
|
id: string;
|
||||||
|
createdAt: Date;
|
||||||
|
createdUserId: string;
|
||||||
|
lastUpdatedAt: Date;
|
||||||
|
lastUpdateUserId: string;
|
||||||
|
createdFullName: string;
|
||||||
|
lastUpdateFullName: string;
|
||||||
|
posTypeName: string;
|
||||||
|
posTypeRank: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type {
|
||||||
|
ResponseObject,
|
||||||
|
Religion,
|
||||||
|
Gender,
|
||||||
|
Relationship,
|
||||||
|
BloodGroup,
|
||||||
|
PosLevel,
|
||||||
|
PosType,
|
||||||
|
};
|
||||||
|
|
@ -1,92 +1,123 @@
|
||||||
import { ref, computed } from "vue";
|
import { ref } from "vue";
|
||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
|
import { useQuasar } from "quasar";
|
||||||
|
import http from "@/plugins/http";
|
||||||
|
import config from "@/app.config";
|
||||||
|
|
||||||
|
import type {
|
||||||
|
Gender,
|
||||||
|
Religion,
|
||||||
|
Relationship,
|
||||||
|
BloodGroup,
|
||||||
|
} from "@/modules/04_registryNew/interface/response/Profile";
|
||||||
|
|
||||||
export const useProfileDataStore = defineStore("profile", () => {
|
export const useProfileDataStore = defineStore("profile", () => {
|
||||||
const isVerified = ref<boolean>(false);
|
const $q = useQuasar();
|
||||||
const isEdit = ref<boolean>(false);
|
const mixin = useCounterMixin();
|
||||||
const emplployeeClass = ref<string | null>("");
|
const {
|
||||||
interface profile {
|
showLoader,
|
||||||
main: { columns: String[] };
|
hideLoader,
|
||||||
education: { columns: String[] };
|
date2Thai,
|
||||||
oldName: { columns: String[] };
|
messageError,
|
||||||
certicate: { columns: String[] };
|
convertDate,
|
||||||
train: { columns: String[] };
|
dateToISO,
|
||||||
insignia: { columns: String[] };
|
} = mixin;
|
||||||
coined: { columns: String[] };
|
|
||||||
assessment: { columns: String[] };
|
const genderOp = ref<Gender[]>([]);
|
||||||
salary: { columns: String[] };
|
const religionOp = ref<Religion[]>([]);
|
||||||
discipline: { columns: String[] };
|
const relationshipOp = ref<Relationship[]>([]);
|
||||||
leave: { columns: String[] };
|
const bloodGroupOp = ref<BloodGroup[]>([]);
|
||||||
talent: { columns: String[] };
|
const prefixOp = ref<string[]>(["นาย", "นาง", "นางสาว"]);
|
||||||
work: { columns: String[] };
|
|
||||||
record: { columns: String[] };
|
function calculateAge(birthDate: Date): string {
|
||||||
other: { columns: String[] };
|
const birthDateTimeStamp = new Date(birthDate).getTime();
|
||||||
document: { columns: String[] };
|
const now = new Date();
|
||||||
|
const diff = now.getTime() - birthDateTimeStamp;
|
||||||
|
|
||||||
|
const ageDate = new Date(diff);
|
||||||
|
const years = ageDate.getUTCFullYear() - 1970;
|
||||||
|
const months = ageDate.getUTCMonth();
|
||||||
|
const days = ageDate.getUTCDate() - 1;
|
||||||
|
|
||||||
|
if (years > 60) {
|
||||||
|
return "อายุเกิน 60 ปี";
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${years} ปี ${months} เดือน ${days} วัน`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const birthDate = ref<Date>(new Date());
|
async function getGender() {
|
||||||
const retireText = ref<string | null>(null);
|
showLoader();
|
||||||
const changeRetireText = (val: string | null) => {
|
await http
|
||||||
retireText.value = val;
|
.get(config.API.profileNewGender)
|
||||||
};
|
.then((res) => {
|
||||||
const changeBirth = (val: Date) => {
|
genderOp.value = res.data.result;
|
||||||
birthDate.value = val;
|
})
|
||||||
};
|
.catch((e) => {
|
||||||
const profileData = ref<profile>({
|
messageError($q, e);
|
||||||
main: { columns: [] },
|
})
|
||||||
education: { columns: [] },
|
.finally(() => {
|
||||||
oldName: { columns: [] },
|
hideLoader();
|
||||||
certicate: { columns: [] },
|
});
|
||||||
train: { columns: [] },
|
|
||||||
insignia: { columns: [] },
|
|
||||||
coined: { columns: [] },
|
|
||||||
assessment: { columns: [] },
|
|
||||||
salary: { columns: [] },
|
|
||||||
discipline: { columns: [] },
|
|
||||||
leave: { columns: [] },
|
|
||||||
talent: { columns: [] },
|
|
||||||
work: { columns: [] },
|
|
||||||
record: { columns: [] },
|
|
||||||
other: { columns: [] },
|
|
||||||
document: { columns: [] },
|
|
||||||
});
|
|
||||||
|
|
||||||
const changeProfileColumns = (system: String, val: String[]) => {
|
|
||||||
if (system == "main") profileData.value.main.columns = val;
|
|
||||||
if (system == "education") profileData.value.education.columns = val;
|
|
||||||
if (system == "oldName") profileData.value.oldName.columns = val;
|
|
||||||
if (system == "certicate") profileData.value.certicate.columns = val;
|
|
||||||
if (system == "train") profileData.value.train.columns = val;
|
|
||||||
if (system == "insignia") profileData.value.insignia.columns = val;
|
|
||||||
if (system == "coined") profileData.value.coined.columns = val;
|
|
||||||
if (system == "assessment") profileData.value.assessment.columns = val;
|
|
||||||
if (system == "salary") profileData.value.salary.columns = val;
|
|
||||||
if (system == "discipline") profileData.value.discipline.columns = val;
|
|
||||||
if (system == "leave") profileData.value.leave.columns = val;
|
|
||||||
if (system == "talent") profileData.value.talent.columns = val;
|
|
||||||
if (system == "work") profileData.value.work.columns = val;
|
|
||||||
if (system == "record") profileData.value.record.columns = val;
|
|
||||||
if (system == "other") profileData.value.other.columns = val;
|
|
||||||
if (system == "document") profileData.value.document.columns = val;
|
|
||||||
localStorage.setItem("profile", JSON.stringify(profileData.value));
|
|
||||||
};
|
|
||||||
|
|
||||||
if (localStorage.getItem("profile") !== null) {
|
|
||||||
profileData.value = JSON.parse(localStorage.getItem("profile") || "{}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const isLoad = ref<number>(0);
|
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 {
|
return {
|
||||||
isLoad,
|
prefixOp,
|
||||||
isVerified,
|
genderOp,
|
||||||
isEdit,
|
religionOp,
|
||||||
profileData,
|
relationshipOp,
|
||||||
changeProfileColumns,
|
bloodGroupOp,
|
||||||
birthDate,
|
|
||||||
changeBirth,
|
calculateAge,
|
||||||
retireText,
|
getGender,
|
||||||
changeRetireText,
|
getRelationship,
|
||||||
emplployeeClass,
|
getReligion,
|
||||||
|
getBloodGroup,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue