ข้อมูลทะเบียนประวัติ => เช็คเลขประชาชน

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-02-13 11:01:11 +07:00
parent e6538a3e4f
commit fd14b1b364

View file

@ -18,6 +18,7 @@ const {
messageError, messageError,
showLoader, showLoader,
hideLoader, hideLoader,
dialogMessageNotify,
} = mixin; } = mixin;
const columns = ref<QTableProps["columns"]>([ const columns = ref<QTableProps["columns"]>([
{ {
@ -170,34 +171,66 @@ async function fetchPrefix() {
} }
async function addData() { async function addData() {
await http.post(config.API.registryNew, { showLoader();
prefix: prefix.value, await http
firstName: firstName.value, .post(config.API.registryNew, {
lastName: lastName.value, prefix: prefix.value,
citizenId: citizenId.value, firstName: firstName.value,
position: position.value, lastName: lastName.value,
posTypeId: posTypeId.value, citizenId: citizenId.value,
posLevelId: posLevelId.value, position: position.value,
}); posTypeId: posTypeId.value,
fetchData(); posLevelId: posLevelId.value,
})
.then(() => {
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
fetchData();
hideLoader();
});
} }
async function editData(id: string) { async function editData(id: string) {
await http.put(config.API.registryNewId(id), { showLoader();
prefix: prefix.value, await http
firstName: firstName.value, .put(config.API.registryNewId(id), {
lastName: lastName.value, prefix: prefix.value,
citizenId: citizenId.value, firstName: firstName.value,
position: position.value, lastName: lastName.value,
posTypeId: posTypeId.value, citizenId: citizenId.value,
posLevelId: posLevelId.value, position: position.value,
}); posTypeId: posTypeId.value,
fetchData(); posLevelId: posLevelId.value,
})
.then(() => {
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
fetchData();
hideLoader();
});
} }
async function deleteData(id: string) { async function deleteData(id: string) {
await http.delete(config.API.registryNewId(id)); await http
fetchData(); .delete(config.API.registryNewId(id))
.then(() => {
success($q, "ลบข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
fetchData();
hideLoader();
});
} }
function updateSelectType(val: string) { function updateSelectType(val: string) {
@ -250,6 +283,28 @@ watch(posTypeId, () => {
updateSelectType(posTypeId.value); updateSelectType(posTypeId.value);
}, 200); }, 200);
}); });
/**
* function ตรวจสอบเลขประจำตวประชาชน
* @param citizenId เลขประจำตวประชาชน
*/
async function changeCardID(citizenId: string | number | null) {
if (citizenId != null && typeof citizenId == "string") {
if (citizenId.length == 13 && citizenId) {
await http
.get(config.API.profileCitizenId(citizenId))
.then((res) => {
console.log(res);
const statusId = res.data.result.citizen;
!statusId &&
dialogMessageNotify($q, "เลขประจำตัวประชาชนนี้มีการใช้งานแล้ว");
})
.catch((err) => {
messageError($q, err);
});
}
}
}
</script> </script>
<template> <template>
@ -294,103 +349,104 @@ watch(posTypeId, () => {
/> />
</div> </div>
</q-toolbar> </q-toolbar>
<div class="col-12">
<d-table
ref="table"
:columns="columns"
:rows="store.row"
:filter="filterKeyword"
row-key="name"
flat
bordered
:paging="true"
dense
class="custom-header-table"
:visible-columns="visibleColumns"
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th v-for="col in props.cols" :key="col.name" :props="props">
<span class="text-weight-medium">{{ col.label }}</span>
</q-th>
<q-th auto-width />
</q-tr>
</template>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td v-for="col in props.cols" :key="col.id">
<div v-if="col.name == 'no'">
{{ props.rowIndex + 1 }}
</div>
<div v-else-if="col.name == 'fullName'">
{{ props.row.prefix }}{{ props.row.firstName }}
{{ props.row.lastName }}
</div>
<d-table <div v-else>
ref="table" {{ col.value }}
:columns="columns" </div>
:rows="store.row" </q-td>
:filter="filterKeyword" <q-td auto-width>
row-key="name" <q-btn
flat color="grey"
bordered flat
:paging="true" dense
dense round
class="custom-header-table" size="14px"
:visible-columns="visibleColumns" icon="more_vert"
> @click.stop
<template v-slot:header="props"> >
<q-tr :props="props"> <q-menu>
<q-th v-for="col in props.cols" :key="col.name" :props="props"> <q-list dense>
<span class="text-weight-medium">{{ col.label }}</span> <q-item
</q-th>
<q-th auto-width />
</q-tr>
</template>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td v-for="col in props.cols" :key="col.id">
<div v-if="col.name == 'no'">
{{ props.rowIndex + 1 }}
</div>
<div v-else-if="col.name == 'fullName'">
{{ props.row.prefix }}{{ props.row.firstName }}
{{ props.row.lastName }}
</div>
<div v-else>
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="grey"
flat
dense
round
size="14px"
icon="more_vert"
@click.stop
>
<q-menu>
<q-list dense>
<q-item
v-close-popup
clickable
@click.stop="
() => {
dialogStatus = 'edit';
dialog = true;
editId = props.row.id;
prefix = props.row.prefix;
firstName = props.row.firstName;
lastName = props.row.lastName;
citizenId = props.row.citizenId;
position = props.row.position;
posTypeId = props.row.posTypeId;
posLevelId = props.row.posLevelId;
}
"
>
<q-item-section>
<div class="row items-center white">
<q-icon name="o_edit" color="positive" />
<span class="q-ml-sm">แกไข</span>
</div>
</q-item-section>
</q-item>
<q-item clickable>
<q-item-section
@click="
dialogRemove(
$q,
async () => await deleteData(props.row.id)
)
"
v-close-popup v-close-popup
clickable
@click.stop="
() => {
dialogStatus = 'edit';
dialog = true;
editId = props.row.id;
prefix = props.row.prefix;
firstName = props.row.firstName;
lastName = props.row.lastName;
citizenId = props.row.citizenId;
position = props.row.position;
posTypeId = props.row.posTypeId;
posLevelId = props.row.posLevelId;
}
"
> >
<div class="row items-center white"> <q-item-section>
<q-icon name="mdi-trash-can-outline" color="negative" /> <div class="row items-center white">
<span class="q-ml-sm">ลบ</span> <q-icon name="o_edit" color="positive" />
</div> <span class="q-ml-sm">แกไข</span>
</q-item-section> </div>
</q-item> </q-item-section>
</q-list> </q-item>
</q-menu> <q-item clickable>
</q-btn> <q-item-section
</q-td> @click="
</q-tr> dialogRemove(
</template> $q,
</d-table> async () => await deleteData(props.row.id)
)
"
v-close-popup
>
<div class="row items-center white">
<q-icon name="mdi-trash-can-outline" color="negative" />
<span class="q-ml-sm">ลบ</span>
</div>
</q-item-section>
</q-item>
</q-list>
</q-menu>
</q-btn>
</q-td>
</q-tr>
</template>
</d-table>
</div>
<q-dialog v-model="dialog" class="dialog" persistent> <q-dialog v-model="dialog" class="dialog" persistent>
<q-card style="min-width: 350px" class="bg-grey-11"> <q-card style="min-width: 350px" class="bg-grey-11">
@ -461,6 +517,7 @@ watch(posTypeId, () => {
maxlength="13" maxlength="13"
hide-bottom-space hide-bottom-space
mask="#############" mask="#############"
@update:model-value="changeCardID"
/> />
<q-input <q-input
ref="positionRef" ref="positionRef"