ค้นหาคนในทะเบียนประวัติ กรณีผู้ถูกร้องเรียนเป็นบุคคล #34

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2023-11-23 15:32:41 +07:00
parent e9ac152cf7
commit 861cbf6eff
3 changed files with 127 additions and 74 deletions

View file

@ -188,10 +188,8 @@ export default {
//ระบบ ลูกจ้างชั่คราว //ระบบ ลูกจ้างชั่คราว
employmentId: (profileId: string) => `${profile}employment/${profileId}`, employmentId: (profileId: string) => `${profile}employment/${profileId}`,
employmentHistoryId: (employmentId: string) => `${profile}employment/history/${employmentId}` employmentHistoryId: (employmentId: string) =>
`${profile}employment/history/${employmentId}`,
searchPersonal: () => `${profile}search-personal`,
}; };

View file

@ -1,12 +1,16 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted, watch } from "vue"; import { ref, onMounted, watch } from "vue";
import { useQuasar } from "quasar"; import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
import type { QTableProps } from "quasar"; import type { QTableProps } from "quasar";
import type { ResponsePreson } from "@/interface/response/listPerson";
const $q = useQuasar(); const $q = useQuasar();
const mixin = useCounterMixin(); const mixin = useCounterMixin();
const { dialogConfirm, dialogMessageNotify } = mixin; const { dialogConfirm, dialogMessageNotify, showLoader, hideLoader } = mixin;
const data = [ const data = [
{ {
@ -172,7 +176,7 @@ const columns = ref<QTableProps["columns"]>([
const props = defineProps({ const props = defineProps({
checkId: { checkId: {
type: Array, type: Array,
default:[] default: [],
}, },
modal: { modal: {
type: Boolean, type: Boolean,
@ -215,7 +219,7 @@ async function close() {
/** เปิด dialog ยืนยัน */ /** เปิด dialog ยืนยัน */
function savePost() { function savePost() {
if (selected.value.length != 0) { if (selected.value.length != 0) {
dialogConfirm($q, () => saveData()); dialogConfirm($q, () => console.log(selected.value));
} else { } else {
dialogMessageNotify($q, "กรุณาเลือกอย่างน้อย 1 รายการ"); dialogMessageNotify($q, "กรุณาเลือกอย่างน้อย 1 รายการ");
} }
@ -227,15 +231,45 @@ function saveData() {
emit("returnData", selected.value); emit("returnData", selected.value);
} }
const searchRef = ref<any>(null);
/** input ค้นหา */ /** input ค้นหา */
function searchInput() { async function searchInput() {
const data = dataObject.value; searchRef.value.validate();
if (type.value === "idcard") { if (!searchRef.value.hasError) {
rows.value = data.filter((item: any) => item.idcard === search.value); showLoader();
} else if (type.value === "firstname") { const body = {
rows.value = data.filter((item: any) => item.firstName === search.value); fieldName: type.value,
} else if (type.value === "lastname") { keyword: search.value,
rows.value = data.filter((item: any) => item.lastName === search.value); };
await http
.post(config.API.searchPersonal(), body)
.then((res) => {
const data = res.data.result;
const list = data.map((e: ResponsePreson) => ({
personId: e.personId,
idcard: e.idcard,
prefix: e.prefix,
firstName: e.firstName,
lastName: e.lastName,
fullName: `${e.prefix}${e.firstName} ${e.lastName}`,
posNo: e.posNo ?? "-",
position: e.position ?? "-",
positionLevel: e.positionLevel ?? "-",
salary: e.salaries ?? "-",
organization: e.organization ?? "-",
phone: e.phone ?? "-",
email: e.email ?? "-",
}));
rows.value = list;
console.log(list);
})
.catch((err) => {
console.log(err);
})
.finally(() => {
hideLoader();
});
} }
} }
@ -248,23 +282,27 @@ function updateInput() {
/** update เมื่อเปลี่ยน option */ /** update เมื่อเปลี่ยน option */
function updateSelect() { function updateSelect() {
rows.value = dataObject.value;
search.value = ""; search.value = "";
} }
watch(() => props.modal, () => { // watch(
if (props.modal === true) { // () => props.modal,
console.log(props.checkId); // () => {
const dataProps = props.checkId.map((item: any) => item.idcard); // if (props.modal === true) {
const dataMapId = data.filter((item: any) => !dataProps.includes(item.idcard)); // console.log(props.checkId);
rows.value = dataMapId // const dataProps = props.checkId.map((item: any) => item.idcard);
} // const dataMapId = data.filter(
}); // (item: any) => !dataProps.includes(item.idcard)
// );
// rows.value = dataMapId;
// }
// }
// );
/** เรียกข้อมูลเมื่อเริ่มโหลด หน้า dialog mock */ /** เรียกข้อมูลเมื่อเริ่มโหลด หน้า dialog mock */
onMounted(() => { onMounted(() => {
dataObject.value = data; // dataObject.value = data;
rows.value = data; // rows.value = data;
}); });
</script> </script>
@ -304,12 +342,13 @@ onMounted(() => {
<div class="col-12 col-sm-6 col-md-6"> <div class="col-12 col-sm-6 col-md-6">
<q-input <q-input
ref="searchRef"
v-model="search" v-model="search"
outlined outlined
clearable clearable
@update:model-value="updateInput"
dense dense
label="คำค้น" label="คำค้น"
:rules="[(val) => !!val || `กรุณากรอกคำค้น`]"
/> />
</div> </div>
@ -330,7 +369,7 @@ onMounted(() => {
ref="table" ref="table"
:columns="columns" :columns="columns"
:rows="rows" :rows="rows"
row-key="id" row-key="personId"
flat flat
bordered bordered
:paging="true" :paging="true"

View file

@ -0,0 +1,16 @@
interface ResponsePreson {
personId: string; //id อ้างอิง profile
idcard: string; //รหัสบัตรประชาชน
prefix: string; //คำนำหน้า
firstName: string; //ชื่อ
lastName: string; //นามสกุล
posNo: string; //เลขที่ตำแหน่ง
position: string; //ตำแหน่ง
positionLevel: string; //ระดับ
salaries: number; //เงินเดือน
organization: string; //สังกัด
email: string; //อีเมล
phone: string; //เบอร์โทรศัพท์
}
export type { ResponsePreson };