Merge branch 'phatt_dev' into develop

This commit is contained in:
puriphatt 2024-03-28 15:49:55 +07:00
commit 50c37620ce
5 changed files with 129 additions and 229 deletions

View file

@ -10,10 +10,9 @@ export default {
// metadata
profileNewMetaMain: `${metadata}main/person`,
profileNewGender: `${metadata}gender`,
profileNewReligion: `${metadata}religion`,
profileNewRelationship: `${metadata}relationship`,
profileNewBloodGroup: `${metadata}bloodGroup`,
profileNewProvince: `${metadata}province`,
profileNewDistrictByPId: (id: string) => `${metadata}province/${id}`,
profileNewSubDistrictByDId: (id: string) => `${metadata}district/${id}`,
// ประวัติส่วนตัว
profileNewProfileByProfileId: (profileId: string) =>
@ -159,8 +158,4 @@ export default {
`${registryNew}changeName/${changeNameId}`,
profileNewChangeNameHisByChangeNameId: (changeNameId: string) =>
`${registryNew}changeName/history/${changeNameId}`,
profileSalaryNew: `${salaryNew}`,
profileListSalaryNew: (id: string) => `${salaryNew}/${id}`,
profileListSalaryHistoryNew: (profileId: string) =>
`${salaryNew}/history/${profileId}`,
};

View file

@ -37,14 +37,14 @@ const profileId = ref<string>(
route.params.id ? route.params.id.toString() : ""
);
const statusAdd = ref(false);
const modal = ref<boolean>(false);
const modalHistory = ref<boolean>(false);
const rowsHistory = ref<ResponseObject[]>([]);
const tittleHistory = ref<string>("ประวัติแก้ไขข้อมูลที่อยู่"); //
const tittleHistory = ref<string>("ประวัติแก้ไขข้อมูลที่อยู่");
const filterHistory = ref<string>("");
const id = ref<string>("");
const rawSameAddress = ref<string>("0");
const sameAddress = ref<string>("0");
const addressData = reactive<ResponseObject>(store.defaultAddress);
const formData = reactive<RequestObject>(store.defaultAddressForm);
@ -111,6 +111,7 @@ const columnsHistory = ref<QTableProps["columns"]>([
field: "registrationProvince",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => (v ? v.name : "-"),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
@ -122,6 +123,7 @@ const columnsHistory = ref<QTableProps["columns"]>([
field: "registrationDistrict",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => (v ? v.name : "-"),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
@ -133,6 +135,7 @@ const columnsHistory = ref<QTableProps["columns"]>([
field: "registrationSubDistrict",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => (v ? v.name : "-"),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
@ -152,7 +155,11 @@ const columnsHistory = ref<QTableProps["columns"]>([
align: "left",
label: "ที่อยู่ปัจจุบันตรงกับที่อยู่ตามทะเบียนบ้าน",
sortable: true,
field: "registrationSame",
field: (v) =>
v.registrationAddress === v.currentAddress &&
v.registrationZipCode === v.currentZipCode
? "ใช่"
: "ไม่",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
@ -177,6 +184,7 @@ const columnsHistory = ref<QTableProps["columns"]>([
field: "currentProvince",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => (v ? v.name : "-"),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
@ -188,6 +196,7 @@ const columnsHistory = ref<QTableProps["columns"]>([
field: "currentDistrict",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => (v ? v.name : "-"),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
@ -199,6 +208,7 @@ const columnsHistory = ref<QTableProps["columns"]>([
field: "currentSubDistrict",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => (v ? v.name : "-"),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
@ -232,6 +242,7 @@ const columnsHistory = ref<QTableProps["columns"]>([
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
@ -246,13 +257,16 @@ async function getData() {
if (addressData) {
id.value = addressData.id;
if (
addressData.currentAddress === addressData.registrationAddress &&
addressData.currentZipCode === addressData.registrationZipCode
) {
sameAddress.value = "1";
}
addressData.currentAddress === addressData.registrationAddress &&
addressData.currentZipCode === addressData.registrationZipCode &&
addressData.currentAddress &&
addressData.registrationAddress &&
addressData.currentZipCode &&
addressData.registrationZipCode
? (rawSameAddress.value = "1")
: (rawSameAddress.value = "0");
}
sameAddress.value = rawSameAddress.value;
})
.catch((e) => {
messageError($q, e);
@ -262,131 +276,64 @@ async function getData() {
});
}
async function getProvince() {
await fetchProvince();
const checkRegistProvinceId = await store.Ops.provinceOps.find(
(e: any) => e.id === addressData.registrationProvinceId
);
if (!checkRegistProvinceId) {
addressData.registrationProvinceId = "";
addressData.registrationDistrictId = "";
addressData.registrationSubDistrictId = "";
addressData.registrationZipCode = "";
}
const checkCurrentProvinceId = await store.Ops.provinceOps.find(
(e: any) => e.id === addressData.currentProvinceId
);
if (!checkCurrentProvinceId) {
addressData.currentProvinceId = "";
addressData.currentDistrictId = "";
addressData.currentSubDistrictId = "";
addressData.currentZipCode = "";
}
}
async function getDistrict(id: string | null, position: string) {
if (!id) return;
await fetchDistrict(id, position);
if (position == "1") {
const checkRegistDistrictId = await store.Ops.districtOps.find(
(e: any) => e.id === addressData.registrationDistrictId
);
if (!checkRegistDistrictId) {
addressData.registrationDistrictId = "";
addressData.registrationSubDistrictId = "";
addressData.registrationZipCode = "";
}
} else {
const checkCurrentDistrictIdC = await store.Ops.districtCOps.find(
(e: any) => e.id === addressData.currentDistrictId
);
if (!checkCurrentDistrictIdC) {
addressData.currentDistrictId = "";
addressData.currentSubDistrictId = "";
addressData.currentZipCode = "";
}
}
}
async function getSubDistrict(id: string | null, position: string) {
if (!id) return;
await fetchSubDistrict(id, position);
if (position == "1") {
const checkRegistSubdistrictId = await store.Ops.subdistrictOps.find(
(e: any) => e.id === addressData.registrationSubDistrictId
);
if (!checkRegistSubdistrictId) {
addressData.registrationSubDistrictId = "";
addressData.registrationZipCode = "";
}
} else {
const checkCurrentSubdistrictIdC = await store.Ops.subdistrictCOps.find(
(e: any) => e.id === addressData.currentSubDistrictId
);
if (!checkCurrentSubdistrictIdC) {
addressData.currentSubDistrictId = "";
addressData.currentZipCode = "";
}
}
}
async function selectProvince(e: string | null, name: string) {
if (e != null) {
if (name == "1") {
formData.registrationDistrictId = "";
formData.registrationSubDistrictId = "";
formData.registrationZipCode = "";
} else {
formData.currentDistrictId = "";
formData.currentSubDistrictId = "";
formData.currentZipCode = "";
}
await fetchDistrict(e, name);
if (!e) return;
if (name == "1") {
formData.registrationDistrictId = "";
formData.registrationSubDistrictId = "";
formData.registrationZipCode = "";
} else {
formData.currentDistrictId = "";
formData.currentSubDistrictId = "";
formData.currentZipCode = "";
}
await fetchDistrict(e, name);
}
async function selectDistrict(e: string | null, name: string) {
if (e != null) {
if (name == "1") {
formData.registrationSubDistrictId = "";
formData.registrationZipCode = "";
} else {
formData.currentSubDistrictId = "";
formData.currentZipCode = "";
}
await fetchSubDistrict(e, name);
if (!e) return;
if (name == "1") {
formData.registrationSubDistrictId = "";
formData.registrationZipCode = "";
} else {
formData.currentSubDistrictId = "";
formData.currentZipCode = "";
}
await fetchSubDistrict(e, name);
}
function selectSubDistrict(e: string | null, name: string) {
if (e != null) {
if (name == "1") {
const findcode = store.Ops.subdistrictOps.filter((r) => r.id == e);
const namecode = findcode.length > 0 ? findcode[0].zipCode : "";
formData.registrationZipCode = namecode;
} else {
const findcode = store.Ops.subdistrictCOps.filter((r) => r.id == e);
const namecode = findcode.length > 0 ? findcode[0].zipCode : "";
formData.currentZipCode = namecode;
}
if (!e) return;
if (name == "1") {
const findcode = store.Ops.subdistrictOps.filter((r) => r.id == e);
const namecode = findcode.length > 0 ? findcode[0].zipCode : "";
formData.registrationZipCode = namecode;
} else {
const findcode = store.Ops.subdistrictCOps.filter((r) => r.id == e);
const namecode = findcode.length > 0 ? findcode[0].zipCode : "";
formData.currentZipCode = namecode;
}
}
async function fetchAll() {
await getData();
if (!store.profileIdBefore) {
store.profileIdBefore = profileId.value;
}
if (
store.Ops.provinceOps.length === 0 ||
store.Ops.districtOps.length === 0 ||
store.Ops.districtCOps.length === 0 ||
store.Ops.subdistrictOps.length === 0 ||
store.Ops.subdistrictCOps.length === 0
store.Ops.subdistrictCOps.length === 0 ||
store.profileIdBefore !== profileId.value
) {
await getProvince();
await getDistrict(addressData.registrationProvinceId, "1");
await getDistrict(addressData.currentProvinceId, "2");
await getSubDistrict(addressData.registrationDistrictId, "1");
await getSubDistrict(addressData.currentDistrictId, "2");
await fetchProvince();
await fetchDistrict(addressData.registrationProvinceId, "1");
await fetchDistrict(addressData.currentProvinceId, "2");
await fetchSubDistrict(addressData.registrationDistrictId, "1");
await fetchSubDistrict(addressData.currentDistrictId, "2");
store.profileIdBefore = profileId.value;
}
adsName.regisP = findData(
@ -436,10 +383,38 @@ async function editData() {
});
}
function onClickOpenDialog() {
function clickClose() {
Object.assign(formData, store.defaultAddressForm);
modal.value = false;
}
async function onClickOpenDialog() {
if (!addressData) return;
await Object.assign(formData, addressData);
const checkDistrict = await store.Ops.districtOps.some(
(e: any) => e.id === addressData.registrationDistrictId
);
const checkSubDistrict = await store.Ops.subdistrictOps.some(
(e: any) => e.id === addressData.registrationSubDistrictId
);
const checkDistrictC = await store.Ops.districtCOps.some(
(e: any) => e.id === addressData.currentDistrictId
);
const checkSubDistrictC = await store.Ops.subdistrictCOps.some(
(e: any) => e.id === addressData.currentSubDistrictId
);
modal.value = true;
Object.assign(formData, addressData);
sameAddress.value = rawSameAddress.value;
if (!checkDistrict || !checkSubDistrict) {
await fetchDistrict(addressData.registrationProvinceId, "1");
await fetchSubDistrict(addressData.registrationDistrictId, "1");
}
if (!checkDistrictC || !checkSubDistrictC) {
await fetchDistrict(addressData.currentProvinceId, "2");
await fetchSubDistrict(addressData.currentDistrictId, "2");
}
}
async function clickHistory() {
@ -448,7 +423,6 @@ async function clickHistory() {
.get(config.API.profileNewAddressHisById(id.value))
.then((res) => {
rowsHistory.value = res.data.result;
console.log(rowsHistory.value);
})
.catch((e) => {
messageError($q, e);
@ -462,6 +436,15 @@ function onSubmit() {
dialogConfirm(
$q,
async () => {
if (sameAddress.value === "1") {
formData.currentAddress = formData.registrationAddress;
formData.currentProvinceId = formData.registrationProvinceId;
formData.currentDistrictId = formData.registrationDistrictId;
formData.currentSubDistrictId = formData.registrationSubDistrictId;
formData.currentZipCode = formData.registrationZipCode;
store.Ops.districtCOps = store.Ops.districtOps;
store.Ops.subdistrictCOps = store.Ops.subdistrictOps;
}
editData();
modal.value = false;
},
@ -470,18 +453,22 @@ function onSubmit() {
);
}
function sameAddressToggle(v: string) {
if (v === "0") {
formData.currentAddress = "";
formData.currentProvinceId = "";
formData.currentDistrictId = "";
formData.currentSubDistrictId = "";
formData.currentZipCode = "";
store.Ops.districtCOps = [];
store.Ops.subdistrictCOps = [];
}
}
watch(
() => sameAddress.value,
(v) => {
if (v === "1") {
formData.currentAddress = formData.registrationAddress;
formData.currentProvinceId = formData.registrationProvinceId;
formData.currentDistrictId = formData.registrationDistrictId;
formData.currentSubDistrictId = formData.registrationSubDistrictId;
formData.currentZipCode = formData.registrationZipCode;
store.Ops.districtCOps = store.Ops.districtOps
store.Ops.subdistrictCOps = store.Ops.subdistrictOps
}
sameAddressToggle(v);
}
);
@ -581,10 +568,7 @@ onMounted(async () => {
<q-dialog v-model="modal" persistent>
<q-card style="width: 600px">
<q-form greedy @submit.prevent @validation-success="onSubmit">
<DialogHeader
tittle="แก้ไขข้อมูลที่อยู่"
:close="() => (modal = false)"
/>
<DialogHeader tittle="แก้ไขข้อมูลที่อยู่" :close="clickClose" />
<q-separator />
<!-- regis address -->
<q-card-section class="q-p-sm">
@ -839,16 +823,7 @@ onMounted(async () => {
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'createdAt'" class="table_ellipsis">
{{ date2Thai(col.value) }}
</div>
<div
v-else-if="col.name == 'registrationSame'"
class="table_ellipsis"
>
{{ col.value ? "ใช่" : "ไม่" }}
</div>
<div v-else class="table_ellipsis">
<div class="table_ellipsis">
{{ col.value }}
</div>
</q-td>

View file

@ -46,75 +46,6 @@ interface InsigniaOps {
insigniaOptions: DataOptionInsignia[];
}
interface Information {
cardid: string | null;
prefix: string | null;
age: string | null;
prefixId: string | null;
firstname: string | null;
lastname: string | null;
birthDate: Date | null;
genderId: string | null;
bloodId: string | null;
nationality: string | null;
ethnicity: string | null;
statusId: string | null;
religionId: string | null;
tel: string | null;
employeeType: string | null;
employeeClass: string | null;
profileType: string | null;
}
interface Address {
address: string | null;
provinceId: string | null;
districtId: string | null;
subdistrictId: string | null;
addressC: string | null;
provinceIdC: string | null;
districtIdC: string | null;
subdistrictIdC: string | null;
same: string | null;
codec: string | null;
codep: string | null;
}
const defaultInformation: Information = {
cardid: null,
age: null,
prefix: null,
prefixId: null,
firstname: null,
lastname: null,
birthDate: null,
genderId: null,
bloodId: null,
nationality: null,
ethnicity: null,
statusId: null,
religionId: null,
tel: null,
employeeType: null,
employeeClass: null,
profileType: null,
};
const defaultAddress: Address = {
address: null,
provinceId: null,
districtId: null,
subdistrictId: null,
addressC: null,
provinceIdC: null,
districtIdC: null,
subdistrictIdC: null,
codec: null,
codep: null,
same: "0",
};
export { defaultAddress, defaultInformation };
export type {
Pagination,
DataOption,
@ -124,6 +55,4 @@ export type {
InformationOps,
AddressOps,
InsigniaOps,
Information,
Address,
};

View file

@ -1,5 +1,4 @@
interface ResponseObject {
id: string;
registrationAddress: string | null;
registrationProvinceId: string | null;
registrationDistrictId: string | null;
@ -10,6 +9,7 @@ interface ResponseObject {
currentDistrictId: string | null;
currentSubDistrictId: string | null;
currentZipCode: string | null;
id: string;
}
export type { ResponseObject };

View file

@ -11,11 +11,11 @@ import type {
DataOption,
AddressOps,
zipCodeOption,
Address,
} from "@/modules/04_registryNew/interface/index/Main";
export const useAddressDataStore = defineStore("addess", () => {
const $q = useQuasar();
const profileIdBefore = ref<string>("");
const mixin = useCounterMixin();
const {
showLoader,
@ -69,14 +69,14 @@ export const useAddressDataStore = defineStore("addess", () => {
};
function findData(ops: any, id: string | null) {
if(id === null) return "";
if (id === null) return "";
return ops.find((r: { id: string }) => r.id === id) || {};
}
async function fetchProvince() {
showLoader();
await http
.get(config.API.province)
.get(config.API.profileNewProvince)
.then(async (res) => {
const data = res.data.result;
let option: DataOption[] = [];
@ -94,16 +94,16 @@ export const useAddressDataStore = defineStore("addess", () => {
});
}
async function fetchDistrict(id: string, position: string) {
async function fetchDistrict(id: string | null, position: string) {
if (!id) return;
showLoader();
await http
.get(config.API.listDistrict(id))
.get(config.API.profileNewDistrictByPId(id))
.then(async (res) => {
const data = res.data.result;
let option: DataOption[] = [];
data.map((r: any) => {
option.push({ id: r.id.toString(), name: r.name.toString() });
data.districts.map((r: any) => {
option.push({ id: r.id, name: r.name });
});
if (position == "1") {
Ops.value.districtOps = option;
@ -126,11 +126,11 @@ export const useAddressDataStore = defineStore("addess", () => {
if (!id) return;
showLoader();
await http
.get(config.API.listSubDistrict(id))
.get(config.API.profileNewSubDistrictByDId(id))
.then(async (res) => {
const data = res.data.result;
let option: zipCodeOption[] = [];
data.map((r: any) => {
data.subDistricts.map((r: any) => {
option.push({
id: r.id.toString(),
name: r.name.toString(),
@ -197,6 +197,7 @@ export const useAddressDataStore = defineStore("addess", () => {
}
return {
profileIdBefore,
defaultAddress,
defaultAddressForm,
Ops,