Merge branch 'develop' into devTee

This commit is contained in:
STW_TTTY\stwtt 2024-03-27 11:47:12 +07:00
commit c2fee13ef9
6 changed files with 675 additions and 127 deletions

View file

@ -8,6 +8,7 @@ export default {
registryNewByProfileId: (profileId: string) => `${registryNew}${profileId}`, registryNewByProfileId: (profileId: string) => `${registryNew}${profileId}`,
// metadata // metadata
profileNewMetaMain: `${metadata}main/person`,
profileNewGender: `${metadata}gender`, profileNewGender: `${metadata}gender`,
profileNewReligion: `${metadata}religion`, profileNewReligion: `${metadata}religion`,
profileNewRelationship: `${metadata}relationship`, profileNewRelationship: `${metadata}relationship`,
@ -141,4 +142,13 @@ profileNewLeaveType:()=>`${env.API_URI}/leave/type`,
profileSalaryNew: `${env.API_URI}/org/profileSalary`, profileSalaryNew: `${env.API_URI}/org/profileSalary`,
profileSalaryNewById: (id: string) => profileSalaryNewById: (id: string) =>
`${env.API_URI}/org/profileSalary/${id}`, `${env.API_URI}/org/profileSalary/${id}`,
// ประวัติการเปลี่ยนชื่อ-นามสกุล
profileNewChangeName: `${registryNew}changeName`,
profileNewChangeNameByProfileId: (profileId: string) =>
`${registryNew}changeName/${profileId}`,
profileNewChangeNameByChangeNameId: (changeNameId: string) =>
`${registryNew}changeName/${changeNameId}`,
profileNewChangeNameHisByChangeNameId: (changeNameId: string) =>
`${registryNew}changeName/history/${changeNameId}`,
}; };

View file

@ -1,37 +1,73 @@
<script setup lang="ts"> <script setup lang="ts">
import { onMounted, ref, useAttrs } from "vue"; import { onMounted, ref, useAttrs, reactive } from "vue";
import { useRoute } from "vue-router"; import { useRoute } from "vue-router";
import { useQuasar } from "quasar"; import { useQuasar } from "quasar";
import axios from "axios";
import type { QTableProps } from "quasar"; import type { QTableProps } from "quasar";
import http from "@/plugins/http"; import http from "@/plugins/http";
import config from "@/app.config"; import config from "@/app.config";
import dialogHeader from "@/components/DialogHeader.vue";
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
import HistoryTable from "@/components/TableHistory.vue"; import HistoryTable from "@/components/TableHistory.vue";
import type { ResponseObject } from "@/components/information/interface/response/OldName"; import type { ResponseObject } from "@/components/information/interface/response/OldName";
import type { Pagination } from "@/modules/04_registryNew/interface/index/Main"; import type { Pagination } from "@/modules/04_registryNew/interface/index/Main";
import type { RequestItemsObject } from "@/components/information/interface/request/OldName"; import type { RequestItemsObject } from "@/components/information/interface/request/OldName";
import { useProfileDataStore } from "@/modules/04_registryNew/stores/profile";
const $q = useQuasar(); const $q = useQuasar();
const route = useRoute(); const route = useRoute();
const mixin = useCounterMixin(); const mixin = useCounterMixin();
const store = useProfileDataStore();
const attrs = ref<any>(useAttrs()); const attrs = ref<any>(useAttrs());
const { const {
date2Thai, date2Thai,
success, success,
dateToISO, dialogConfirm,
messageError, messageError,
typeChangeName, typeChangeName,
dialogMessage,
showLoader, showLoader,
hideLoader, hideLoader,
dialogRemove,
} = mixin; } = mixin;
const profileId = ref<string>(route.params.id.toString());
const { calculateAge, fetchPerson } = store;
const profileId = ref<string>(route.params.id.toString());
const editId = ref<string>("");
const dialog = ref<boolean>(false);
const dialogStatus = ref<string>("create");
const filterSearch = ref(""); const filterSearch = ref("");
const filterHistory = ref<string>(""); const filterHistory = ref<string>("");
const fileName = ref<string>("");
const modalHistory = ref<boolean>(false); const modalHistory = ref<boolean>(false);
const rowsHistory = ref<RequestItemsObject[]>([]); const rowsHistory = ref<RequestItemsObject[]>([]);
const changeNameData = reactive<any>({
profileId: profileId.value,
prefixId: "",
prefix: "",
firstName: "",
lastName: "",
status: "",
documentId: "",
});
const statusOption = ref([
"เปลี่ยนคำนำหน้าชื่อ",
"เปลี่ยนชื่อ",
"เปลี่ยนนามสกุล",
"เปลี่ยนชื่อ-นามสกุล",
"เปลี่ยนคำนำหน้าชื่อ และนามสกุล",
"เปลี่ยนคำนำหน้าชื่อ และชื่อ-นามสกุล",
]);
const prefixFilter = ref([]);
const statusOptionFilter = ref([
"เปลี่ยนคำนำหน้าชื่อ",
"เปลี่ยนชื่อ",
"เปลี่ยนนามสกุล",
"เปลี่ยนชื่อ-นามสกุล",
"เปลี่ยนคำนำหน้าชื่อ และนามสกุล",
"เปลี่ยนคำนำหน้าชื่อ และชื่อ-นามสกุล",
]);
const alertUpload = ref<boolean>(false);
const tittleHistory = ref<string>("ประวัติการเปลี่ยนชื่อ-นามสกุล"); const tittleHistory = ref<string>("ประวัติการเปลี่ยนชื่อ-นามสกุล");
const visibleColumns = ref<string[]>([ const visibleColumns = ref<string[]>([
"prefix", "prefix",
@ -47,43 +83,44 @@ const visibleColumnsHistory = ref<String[]>([
"createdFullName", "createdFullName",
"createdAt", "createdAt",
]); ]);
const rows = ref<ResponseObject[]>([]);
const historyRows = ref<ResponseObject[]>([]);
// mock data // mock data
const rows = ref<RequestItemsObject[]>([ // const rows = ref<RequestItemsObject[]>([
{ // {
id: "08dc2c65-c0e9-4692-8494-ab39e09aec24", // id: "08dc2c65-c0e9-4692-8494-ab39e09aec24",
prefix: "นางสาว", // prefix: "",
prefixId: "71ed89df-8257-43e8-8fba-0b42fb2c55e0", // prefixId: "71ed89df-8257-43e8-8fba-0b42fb2c55e0",
firstName: "อรัญญาวินัย", // firstName: "",
lastName: "พรไชยะสาร", // lastName: "",
status: "all", // status: "all",
file: null, // file: null,
createdFullName: "", // createdFullName: "",
createdAt: new Date("2024-02-13T14:31:11.959404"), // createdAt: new Date("2024-02-13T14:31:11.959404"),
}, // },
{ // {
id: "08dc2c65-c0e9-4692-8494-ab39e09aec24", // id: "08dc2c65-c0e9-4692-8494-ab39e09aec24",
prefix: "นางสาว", // prefix: "",
prefixId: "71ed89df-8257-43e8-8fba-0b42fb2c55e0", // prefixId: "71ed89df-8257-43e8-8fba-0b42fb2c55e0",
firstName: "อรัญญาวินัย", // firstName: "",
lastName: "พรไชยะสาร", // lastName: "",
status: "lastName", // status: "lastName",
file: null, // file: null,
createdFullName: "", // createdFullName: "",
createdAt: new Date("2024-02-13T14:30:34.660735"), // createdAt: new Date("2024-02-13T14:30:34.660735"),
}, // },
{ // {
id: "08dc2c65-c0e9-4692-8494-ab39e09aec24", // id: "08dc2c65-c0e9-4692-8494-ab39e09aec24",
prefix: "นางสาว", // prefix: "",
prefixId: "71ed89df-8257-43e8-8fba-0b42fb2c55e0", // prefixId: "71ed89df-8257-43e8-8fba-0b42fb2c55e0",
firstName: "อรัญญาวินัย", // firstName: "",
lastName: "พรไชยะสาร", // lastName: "",
status: "lastName", // status: "lastName",
file: null, // file: null,
createdFullName: "", // createdFullName: "",
createdAt: new Date("2024-02-13T14:30:14.562741"), // createdAt: new Date("2024-02-13T14:30:14.562741"),
}, // },
]); // ]);
const columns = ref<QTableProps["columns"]>([ const columns = ref<QTableProps["columns"]>([
{ {
name: "prefix", name: "prefix",
@ -192,16 +229,226 @@ const columnsHistory = ref<QTableProps["columns"]>([
label: "วันที่แก้ไข", label: "วันที่แก้ไข",
sortable: true, sortable: true,
field: "createdAt", field: "createdAt",
format: (v) => date2Thai(v),
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) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
}, },
]); ]);
const uploadUrl = ref<string>("");
const initialPagination = ref<Pagination>({ const initialPagination = ref<Pagination>({
rowsPerPage: 0, rowsPerPage: 0,
}); });
const subId = ref<string>("");
const fileUpload = ref<File>();
function editForm(row: any) {
dialogStatus.value = "edit";
editId.value = row.id;
changeNameData.prefix = row.prefix;
changeNameData.firstName = row.firstName;
changeNameData.lastName = row.lastName;
changeNameData.status = row.status;
dialog.value = true;
}
function closeDialog() {
alertUpload.value = false;
dialog.value = false;
}
function clearForm() {
changeNameData.status = "";
changeNameData.prefix = "";
changeNameData.firstName = "";
changeNameData.lastName = "";
alertUpload.value = false;
}
async function onSubmit() {
if (!!fileUpload.value) {
await dialogConfirm(
$q,
async () => {
showLoader();
dialogStatus.value === "create"
? await addData()
: await editData(editId.value);
closeDialog();
await uploadProfile(fileUpload.value);
},
"ยืนยันการบันทึกข้อมูล",
"ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?"
);
}
}
async function uploadProfile(file: File | undefined) {
await http
.post(
config.API.subFile(
"ทะเบียนประวัติ",
"ประวัติการเปลี่ยนชื่อ-นามสกุล",
profileId.value,
subId.value
),
{
replace: true,
fileList: [
{
fileName: "เอกสารหลักฐาน",
},
],
}
)
.then(async (res) => {
uploadUrl.value = res.data["เอกสารหลักฐาน"].uploadUrl;
uploadFileURL(uploadUrl.value, file);
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
async function uploadFileURL(uploadUrl: string, file: any) {
showLoader();
await axios
.put(uploadUrl, file, {
headers: {
"Content-Type": file.type,
},
})
.then(() => {
// fetchProfile(profileId.value);
// success($q, "");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
async function fetchProfile(id: string) {
showLoader();
await http
.get(
config.API.subFileByFileName(
"ทะเบียนประวัติ",
"ประวัติการเปลี่ยนชื่อ-นามสกุล",
profileId.value,
id,
"เอกสารหลักฐาน"
)
)
.then(async (res) => {
const data = res.data.downloadUrl;
window.open(data, "_blank");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
async function addData() {
await http
.post(config.API.profileNewChangeName, {
...changeNameData,
})
.then((res) => {
subId.value = res.data.result;
fetchData(profileId.value);
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
function editData(idData: string) {
http
.patch(config.API.profileNewChangeNameByChangeNameId(idData), {
...changeNameData,
profileId: undefined,
})
.then(() => {
fetchData(profileId.value);
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
function deleteData(idData: string) {
// dialogRemove($q, () =>
http
.delete(config.API.profileNewChangeNameByChangeNameId(idData))
.then(() => {
fetchData(profileId.value);
success($q, "ลบข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
// );
}
function deleteFileData(idData: string) {
// dialogRemove($q, () =>
http
.delete(
config.API.subFile(
"ทะเบียนประวัติ",
"ประวัติการเปลี่ยนชื่อ-นามสกุล",
profileId.value,
idData
)
)
.then(() => {
fetchData(profileId.value);
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
// );
}
async function fetchHistoryData(id: string) {
showLoader();
await http
.get(config.API.profileNewChangeNameHisByChangeNameId(id))
.then(async (res) => {
historyRows.value = res.data.result;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
const paginationLabel = (start: string, end: string, total: string) => { const paginationLabel = (start: string, end: string, total: string) => {
return start + "-" + end + " ใน " + total; return start + "-" + end + " ใน " + total;
@ -213,57 +460,17 @@ async function openFile(val: string | null) {
async function clickHistory(row: RequestItemsObject) { async function clickHistory(row: RequestItemsObject) {
modalHistory.value = true; modalHistory.value = true;
// showLoader();
// await http
// .get(config.API.profileChangeNameHisId(row.id))
// .then((res) => {
// let data = res.data.result;
// rowsHistory.value = [];
// data.map((e: ResponseObject) => {
// rowsHistory.value.push({
// id: e.id,
// prefix: e.prefix,
// prefixId: e.prefixId,
// firstName: e.firstName,
// lastName: e.lastName,
// status: e.status,
// file: e.file,
// createdFullName: e.createdFullName,
// createdAt: new Date(e.createdAt),
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// hideLoader();
// });
} }
async function fetchData() { async function fetchData(id: string) {
showLoader(); showLoader();
await http await http
.get(config.API.profileChangeNameId(profileId.value)) .get(config.API.profileNewChangeNameByProfileId(id))
.then((res) => { .then(async (res) => {
let data = res.data.result; rows.value = res.data.result;
rows.value = [];
data.map((e: ResponseObject) => {
rows.value.push({
id: e.id,
prefix: e.prefix,
prefixId: e.prefixId,
firstName: e.firstName,
lastName: e.lastName,
status: e.status,
file: e.file,
createdFullName: e.createdFullName,
createdAt: new Date(e.createdAt),
});
});
}) })
.catch((e) => { .catch((err) => {
messageError($q, e); messageError($q, err);
}) })
.finally(() => { .finally(() => {
hideLoader(); hideLoader();
@ -271,11 +478,61 @@ async function fetchData() {
} }
onMounted(async () => { onMounted(async () => {
// await fetchData(); if (
store.Ops.prefixOps.length === 0 ||
store.Ops.genderOps.length === 0 ||
store.Ops.bloodOps.length === 0 ||
store.Ops.statusOps.length === 0 ||
store.Ops.religionOps.length === 0
) {
await fetchPerson();
}
prefixFilter.value = store.Ops.prefixOps;
fetchData(profileId.value);
}); });
function filterSelector(val: string, update: Function, refData: string) {
switch (refData) {
case "statusOptions":
update(() => {
statusOption.value = statusOptionFilter.value.filter(
(v: any) => v.indexOf(val) > -1
);
});
break;
case "prefixOps":
update(() => {
store.Ops.prefixOps = prefixFilter.value.filter(
(v: any) => v.name.indexOf(val) > -1
);
});
break;
default:
break;
}
}
</script> </script>
<template> <template>
<q-toolbar style="padding: 0px" class="text-primary row justify-end"> <q-toolbar style="padding: 0px" class="text-primary row justify-end">
<q-btn
round
flat
color="primary"
icon="add"
size="16px"
@click="
() => {
dialogStatus = 'create';
dialog = true;
clearForm();
}
"
>
<q-tooltip>เพมขอม</q-tooltip></q-btn
>
<q-space />
<q-input <q-input
dense dense
outlined outlined
@ -332,24 +589,37 @@ onMounted(async () => {
<template v-slot:body="props"> <template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer"> <q-tr :props="props" class="cursor-pointer">
<q-td v-for="(col, index) in props.cols" :key="col.name"> <q-td v-for="(col, index) in props.cols" :key="col.name">
<div v-if="col.name == 'status'" class="table_ellipsis"> <div class="table_ellipsis">
{{ typeChangeName(col.value) }}
</div>
<div v-else class="table_ellipsis">
{{ col.value }} {{ col.value }}
</div> </div>
</q-td> </q-td>
<q-td auto-width> <q-td auto-width>
<q-btn <q-btn
v-if="props.row.file != null"
color="green" color="green"
flat flat
dense dense
round round
size="14px" size="14px"
icon="mdi-file-document-outline" icon="mdi-file-document-outline"
@click="openFile(props.row.file)" @click="fetchProfile(props.row.id)"
/> />
<q-btn
color="primary"
flat
dense
round
class="q-mr-xs"
size="14px"
icon="mdi-pencil-outline"
clickable
@click="
() => {
editForm(props.row);
}
"
>
<q-tooltip>แกไขขอม</q-tooltip>
</q-btn>
<q-btn <q-btn
color="info" color="info"
flat flat
@ -357,15 +627,30 @@ onMounted(async () => {
round round
size="14px" size="14px"
icon="mdi-history" icon="mdi-history"
@click="clickHistory(props.row)" @click="
() => (fetchHistoryData(props.row.id), clickHistory(props.row))
"
/> />
<q-btn
color="red"
flat
dense
round
size="14px"
icon="mdi-delete"
clickable
@click.stop="deleteData(props.row.id), deleteFileData(props.row.id)"
v-close-popup
>
<q-tooltip>ลบขอม</q-tooltip>
</q-btn>
</q-td> </q-td>
</q-tr> </q-tr>
</template> </template>
</d-table> </d-table>
<history-table <history-table
:rows="rowsHistory" :rows="historyRows"
:columns="columnsHistory" :columns="columnsHistory"
:filter="filterHistory" :filter="filterHistory"
:visible-columns="visibleColumnsHistory" :visible-columns="visibleColumnsHistory"
@ -378,13 +663,7 @@ onMounted(async () => {
<template #columns="props"> <template #columns="props">
<q-tr :props="props"> <q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props"> <q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'createdAt'" class="table_ellipsis"> <div class="table_ellipsis">
{{ date2Thai(col.value) }}
</div>
<div v-else-if="col.name == 'status'" class="table_ellipsis">
{{ typeChangeName(col.value) }}
</div>
<div v-else class="table_ellipsis">
{{ col.value }} {{ col.value }}
</div> </div>
</q-td> </q-td>
@ -403,6 +682,192 @@ onMounted(async () => {
</q-tr> </q-tr>
</template> </template>
</history-table> </history-table>
<q-dialog v-model="dialog" class="dialog" persistent>
<q-card style="min-width: 50%" class="bg-white">
<q-form @submit.prevent greedy @validation-success="onSubmit()">
<q-card-section class="flex justify-between" style="padding: 0">
<dialog-header
:tittle="dialogStatus == 'edit' ? 'แก้ไขข้อมูล' : 'เพิ่มข้อมูล'"
:close="closeDialog"
/>
</q-card-section>
<q-separator color="grey-4" />
<div class="q-pa-md">
<div class="row q-mb-md">
<div class="col-5">
<q-select
outlined
v-model="changeNameData.status"
:options="statusOption"
label="สถานะการเปลี่ยนชื่อ"
clearable
use-input
input-debounce="0"
:rules="[
(val) => !!val || `${'กรุณาเลือกสถานะการเปลี่ยนชื่อ'}`,
]"
@filter="(inputValue:string,
doneFn:Function) => filterSelector(inputValue, doneFn,'statusOptions'
) "
dense
/>
</div>
</div>
<div class="row q-gutter-md q-mb-md">
<div class="col">
<q-select
v-model="changeNameData.prefix"
:options="store.Ops.prefixOps"
label="คำนำหน้าชื่อ"
dense
outlined
use-input
lazy-rules
clearable
emit-value
map-options
:rules="[(val) => !!val || `${'กรุณาเลือกคำนำหน้าชื่อ'}`]"
hide-bottom-space
input-debounce="0"
option-label="name"
option-value="name"
@filter="(inputValue:string,
doneFn:Function) => filterSelector(inputValue, doneFn,'prefixOps'
) "
/>
</div>
<div class="col">
<q-input
outlined
v-model="changeNameData.firstName"
label="ชื่อ"
bg-color="white"
dense
:rules="[(val) => !!val || `${'กรุณากรอกชื่อ'}`]"
hide-bottom-space
/>
</div>
<div class="col">
<q-input
outlined
v-model="changeNameData.lastName"
label="นามสกุล"
bg-color="white"
dense
:rules="[(val) => !!val || `${'กรุณากรอกนามสกุล'}`]"
hide-bottom-space
/>
</div>
</div>
<div class="row">
<q-uploader
color="gray"
type="file"
flat
ref="uploader"
class="full-width"
text-color="white"
:max-size="10000000"
accept=".jpg,.png,.pdf,.csv,.doc,.docx"
bordered
label="[ไฟล์ jpg,png,pdf,csv,doc,docx ขนาดไม่เกิน 10MB]"
@added="(v) => (fileUpload = v[0])"
>
<template v-slot:header="scope">
<div class="row no-wrap items-center q-pa-sm q-gutter-xs">
<q-btn
v-if="scope.queuedFiles.length > 0"
icon="clear_all"
@click="scope.removeQueuedFiles"
round
dense
flat
>
<q-tooltip>ลบทงหมด</q-tooltip>
</q-btn>
<q-btn
v-if="scope.uploadedFiles.length > 0"
icon="done_all"
@click="scope.removeUploadedFiles"
round
dense
flat
>
<q-tooltip>ลบไฟลปโหลด</q-tooltip>
</q-btn>
<q-spinner
v-if="scope.isUploading"
class="q-uploader__spinner"
/>
<div class="col">
<div class="q-uploader__title">
{{ "[ไฟล์ jpg,png,pdf,csv,doc,docx ขนาดไม่เกิน 10MB]" }}
</div>
<div class="q-uploader__subtitle">
{{ scope.uploadSizeLabel }} /
{{ scope.uploadProgressLabel }}
</div>
</div>
<q-btn
v-if="scope.canAddFiles"
type="a"
icon="add_box"
@click="scope.pickFiles"
round
dense
flat
>
<q-uploader-add-trigger />
<q-tooltip>เลอกไฟล</q-tooltip>
</q-btn>
<q-btn
v-if="scope.isUploading"
icon="clear"
@click="scope.abort"
round
dense
flat
>
<q-tooltip>ยกเลกการอปโหลด</q-tooltip>
</q-btn>
</div>
</template>
</q-uploader>
<div
v-if="alertUpload"
class="row text-negative items-center q-mt-sm"
>
กรณาอพโหลดเอกสาร
<q-icon name="mdi-alert-circle q-ml-sm" size="24px" />
</div>
</div>
</div>
<q-card-actions align="right">
<q-btn
id="onSubmit"
type="submit"
dense
unelevated
label="บันทึก"
color="public"
class="q-px-md"
@click="
() => {
if (!!fileUpload) {
alertUpload = false;
} else {
alertUpload = true;
}
}
"
>
<q-tooltip>นทกขอม</q-tooltip>
</q-btn>
</q-card-actions>
</q-form>
</q-card>
</q-dialog>
</template> </template>
<style scoped></style> <style scoped></style>

View file

@ -7,7 +7,7 @@ import http from "@/plugins/http";
import config from "@/app.config"; import config from "@/app.config";
import { useRoute } from "vue-router"; import { useRoute } from "vue-router";
import DialogHistory from "@/modules/04_registryNew/components/detail/PersonalInformation/04_FamilyHistory.vue"; import DialogHistory from "@/modules/04_registryNew/components/detail/PersonalInformation/04_FamilyHistory.vue";
import { useProfileDataStore } from "@/modules/04_registryNew/stores/profile";
const mixin = useCounterMixin(); const mixin = useCounterMixin();
const $q = useQuasar(); const $q = useQuasar();
const { const {
@ -20,6 +20,7 @@ const {
date2Thai, date2Thai,
} = mixin; } = mixin;
const store = useProfileDataStore();
const route = useRoute(); const route = useRoute();
const id = ref<string>(route.params.id.toString()); const id = ref<string>(route.params.id.toString());
const dialog = ref<boolean>(false); const dialog = ref<boolean>(false);
@ -64,7 +65,7 @@ const spouseData = reactive({
const rows = ref<any>([]); const rows = ref<any>([]);
const historyRows = ref<any>([]); const historyRows = ref<any>([]);
const prefixFilter = ref([]);
const childrenData: any = reactive({ const childrenData: any = reactive({
childrens: [], childrens: [],
}); });
@ -233,8 +234,32 @@ function deleteChildren(items: any) {
} }
onMounted(async () => { onMounted(async () => {
if (
store.Ops.prefixOps.length === 0 ||
store.Ops.genderOps.length === 0 ||
store.Ops.bloodOps.length === 0 ||
store.Ops.statusOps.length === 0 ||
store.Ops.religionOps.length === 0
) {
await fetchPerson();
}
prefixFilter.value = store.Ops.prefixOps;
await fetchData(id.value); await fetchData(id.value);
}); });
function filterSelector(val: string, update: Function, refData: string) {
switch (refData) {
case "prefixOps":
update(() => {
store.Ops.prefixOps = prefixFilter.value.filter(
(v: any) => v.name.indexOf(val) > -1
);
});
break;
default:
break;
}
}
</script> </script>
<template> <template>
@ -504,12 +529,22 @@ onMounted(async () => {
outlined outlined
bg-color="white" bg-color="white"
lazy-rules lazy-rules
hidden-space
dense dense
v-model="fatherData.prefix"
:options="fatherData.optionPrefix"
:rules="[(val) => !!val || 'กรุณาเลือกคำนำหน้าชื่อ']" :rules="[(val) => !!val || 'กรุณาเลือกคำนำหน้าชื่อ']"
label="คำนำหน้าชื่อ" label="คำนำหน้าชื่อ"
hidden-space v-model="fatherData.prefix"
use-input
clearable
input-debounce="0"
emit-value
map-options
:options="store.Ops.prefixOps"
option-label="name"
option-value="name"
@filter="(inputValue:string,
doneFn:Function) => filterSelector(inputValue, doneFn,'prefixOps'
) "
/> />
</div> </div>
<div class="col"> <div class="col">
@ -625,10 +660,20 @@ onMounted(async () => {
lazy-rules lazy-rules
dense dense
v-model="motherData.prefix" v-model="motherData.prefix"
:options="motherData.optionPrefix"
:rules="[(val) => !!val || 'กรุณาเลือกคำนำหน้าชื่อ']" :rules="[(val) => !!val || 'กรุณาเลือกคำนำหน้าชื่อ']"
label="คำนำหน้าชื่อ" label="คำนำหน้าชื่อ"
hidden-space hidden-space
use-input
clearable
input-debounce="0"
emit-value
map-options
:options="store.Ops.prefixOps"
option-label="name"
option-value="name"
@filter="(inputValue:string,
doneFn:Function) => filterSelector(inputValue, doneFn,'prefixOps'
) "
/> />
</div> </div>
<div class="col"> <div class="col">
@ -744,10 +789,20 @@ onMounted(async () => {
lazy-rules lazy-rules
dense dense
v-model="spouseData.prefix" v-model="spouseData.prefix"
:options="spouseData.optionPrefix"
:rules="[(val) => !!val || 'กรุณาเลือกคำนำหน้าชื่อ']" :rules="[(val) => !!val || 'กรุณาเลือกคำนำหน้าชื่อ']"
label="คำนำหน้าชื่อ" label="คำนำหน้าชื่อ"
hidden-space hidden-space
use-input
clearable
input-debounce="0"
emit-value
map-options
:options="store.Ops.prefixOps"
option-label="name"
option-value="name"
@filter="(inputValue:string,
doneFn:Function) => filterSelector(inputValue, doneFn,'prefixOps'
) "
/> />
</div> </div>
<div class="col"> <div class="col">
@ -857,8 +912,18 @@ onMounted(async () => {
bg-color="white" bg-color="white"
v-model="items.childrenPrefix" v-model="items.childrenPrefix"
:rules="[(val) => !!val || 'กรุณาเลือกคำนำหน้าชื่อ']" :rules="[(val) => !!val || 'กรุณาเลือกคำนำหน้าชื่อ']"
:options="childrenOptionPrefix"
label="คำนำหน้าชื่อ" label="คำนำหน้าชื่อ"
use-input
clearable
input-debounce="0"
emit-value
map-options
:options="store.Ops.prefixOps"
option-label="name"
option-value="name"
@filter="(inputValue:string,
doneFn:Function) => filterSelector(inputValue, doneFn,'prefixOps'
) "
/> />
</div> </div>
<div class="col"> <div class="col">

View file

@ -215,7 +215,8 @@ const educationOptionFilter = ref([
{ label: "ไม่ใช่", value: false }, { label: "ไม่ใช่", value: false },
]); ]);
let educationLevelOption: any = []; const educationLevelOption = ref([]);
const educationLevelOptionFilter = ref([]);
const historyDialog = ref<boolean>(false); const historyDialog = ref<boolean>(false);
const educationData = reactive<RequestItemsObject>({ const educationData = reactive<RequestItemsObject>({
@ -300,13 +301,20 @@ async function onSubmit() {
function filterSelector(val: string, update: Function, refData: string) { function filterSelector(val: string, update: Function, refData: string) {
switch (refData) { switch (refData) {
case "options": case "educationOption":
update(() => { update(() => {
educationOption.value = educationOptionFilter.value.filter( educationOption.value = educationOptionFilter.value.filter(
(v: any) => v.label.indexOf(val) > -1 (v: any) => v.label.indexOf(val) > -1
); );
}); });
break; break;
case "educationLevelOption":
update(() => {
educationLevelOption.value = educationLevelOptionFilter.value.filter(
(v: any) => v.label.indexOf(val) > -1
);
});
break;
default: default:
break; break;
} }
@ -386,8 +394,12 @@ async function fetchEducationLevel() {
.get(config.API.orgEducationLevel) .get(config.API.orgEducationLevel)
.then(async (res) => { .then(async (res) => {
res.data.result.map((r: any) => { res.data.result.map((r: any) => {
educationLevelOption.push(r.name); educationLevelOption.value.push({
value: r.id,
label: r.name,
});
}); });
educationLevelOptionFilter.value = educationLevelOption.value;
}) })
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
@ -755,6 +767,8 @@ onMounted(async () => {
outlined outlined
dense dense
emit-value emit-value
option-value="label"
option-label="label"
map-options map-options
bg-color="white" bg-color="white"
v-model="educationData.educationLevel" v-model="educationData.educationLevel"
@ -762,7 +776,7 @@ onMounted(async () => {
input-debounce="0" input-debounce="0"
use-input use-input
@filter="(inputValue:string, @filter="(inputValue:string,
doneFn:Function) => filterSelector(inputValue, doneFn,'options' doneFn:Function) => filterSelector(inputValue, doneFn,'educationLevelOption'
) " ) "
:rules="[(val) => !!val || `${'กรุณาเลือกระดับการศึกษา'}`]" :rules="[(val) => !!val || `${'กรุณาเลือกระดับการศึกษา'}`]"
label="ระดับการศึกษา" label="ระดับการศึกษา"
@ -1030,12 +1044,12 @@ onMounted(async () => {
bg-color="white" bg-color="white"
v-model="educationData.isEducation" v-model="educationData.isEducation"
:options="educationOption" :options="educationOption"
option-value="value" option-value="label"
option-label="label" option-label="label"
input-debounce="0" input-debounce="0"
use-input use-input
@filter="(inputValue:string, @filter="(inputValue:string,
doneFn:Function) => filterSelector(inputValue, doneFn,'options' doneFn:Function) => filterSelector(inputValue, doneFn,'educationOption'
) " ) "
:rules="[ :rules="[
(val) => (val) =>

View file

@ -114,7 +114,7 @@ export const useProfileDataStore = defineStore("profile", () => {
const fetchPerson = async () => { const fetchPerson = async () => {
showLoader(); showLoader();
await http await http
.get(config.API.person) .get(config.API.profileNewMetaMain)
.then((res) => { .then((res) => {
const data = res.data.result; const data = res.data.result;
let optionbloodGroups: DataOption[] = []; let optionbloodGroups: DataOption[] = [];
@ -144,22 +144,16 @@ export const useProfileDataStore = defineStore("profile", () => {
name: r.name.toString(), name: r.name.toString(),
}); });
}); });
optionprefixs = optionprefixs.filter((o) =>
prefixOp.value.find((p) => o.name === p)
);
Ops.value.prefixOps = optionprefixs; Ops.value.prefixOps = optionprefixs;
OpsFilter.value.prefixOps = optionprefixs; OpsFilter.value.prefixOps = optionprefixs;
let optionrank: DataOption[] = []; let optionrank: DataOption[] = [];
data.prefixs.map((r: any) => { data.rank.map((r: any) => {
optionrank.push({ optionrank.push({
id: r.id.toString(), id: r.id.toString(),
name: r.name.toString(), name: r.name.toString(),
}); });
}); });
optionrank = optionrank.filter(
(o) => !prefixOp.value.find((p) => o.name === p)
);
Ops.value.rankOps = optionrank; Ops.value.rankOps = optionrank;
OpsFilter.value.rankOps = optionrank; OpsFilter.value.rankOps = optionrank;

View file

@ -608,7 +608,7 @@ onMounted(async () => {
</q-card> </q-card>
</template> </template>
<style> <style scoped>
.card-img { .card-img {
background: url("@/assets/registry-banner.png"); background: url("@/assets/registry-banner.png");
background-size: cover; background-size: cover;