From 17ff56c7cfad9627c1e7f13b00db449e79cab642 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Wed, 30 Apr 2025 17:34:20 +0700 Subject: [PATCH] insignia Reclaim --- .../components/5_Borrow/DialogForm.vue | 591 ++++++++++++------ .../components/7_Reclaim/DialogForm.vue | 483 ++++++++++++++ src/modules/07_insignia/router.ts | 14 + src/modules/07_insignia/storeReclaim.ts | 18 + .../07_insignia/views/07_ReclaimMain.vue | 494 +++++++++++++++ 5 files changed, 1421 insertions(+), 179 deletions(-) create mode 100644 src/modules/07_insignia/components/7_Reclaim/DialogForm.vue create mode 100644 src/modules/07_insignia/storeReclaim.ts create mode 100644 src/modules/07_insignia/views/07_ReclaimMain.vue diff --git a/src/modules/07_insignia/components/5_Borrow/DialogForm.vue b/src/modules/07_insignia/components/5_Borrow/DialogForm.vue index 14d87a9d3..011328b55 100644 --- a/src/modules/07_insignia/components/5_Borrow/DialogForm.vue +++ b/src/modules/07_insignia/components/5_Borrow/DialogForm.vue @@ -8,6 +8,7 @@ import http from "@/plugins/http"; import config from "@/app.config"; /** impotrType */ +import type { QTableColumn } from "quasar"; import type { DataOption } from "@/modules/07_insignia/interface/index/Main"; /** impotrComponents */ @@ -23,13 +24,11 @@ const { messageError, showLoader, hideLoader, - notifyError, + onSearchDataTable, convertDateToAPI, } = mixin; -/** - * props - */ +/** props*/ const props = defineProps({ modal: Boolean, save: { @@ -76,17 +75,168 @@ const receivedate = ref(); //วันที่ยืม const returndate = ref(); //วันที่คืน const fullName = ref(""); //ชื่อ-นามสกุล const reason = ref(""); -const listPerson = ref([]); const OrgList = ref([]); const filterOrgList = ref([]); const insigniaNoteProfileId = ref(""); const filterSelectRound = ref(); const selectRound = ref(); -const type = ref(DataStore.type); -/** - * function เคลียร์ข้อมูลในฟอร์ม - */ +const rows = ref([]); +const rowsMain = ref([]); +const keyword = ref(""); +const selected = ref([]); +const columns = ref([ + { + name: "noNumber", + align: "left", + label: "ลำดับ", + field: "noNumber", + sortable: false, + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, + { + name: "citizenId", + align: "left", + label: "เลขประจำตัวประชาชน", + field: "citizenId", + sortable: true, + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, + { + name: "fullName", + align: "left", + label: "ชื่อ-นามสกุล", + field: "fullName", + sortable: true, + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, + { + name: "profileType", + align: "left", + label: "ประเภทตำแหน่ง", + field: "profileType", + sortable: true, + format(val, row) { + return DataStore.profileType(val); + }, + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, + { + name: "position", + align: "left", + label: "ตำแหน่งประเภท", + field: "position", + sortable: true, + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, + { + name: "requestInsignia", + align: "left", + label: "เครื่องราชๆ", + field: "requestInsignia", + format(val, row) { + return `${row.requestInsignia ?? ""} + ${ + row.requestInsigniaShortName ? `(${row.requestInsigniaShortName})` : "" + } `; + }, + sortable: true, + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, + { + name: "dateReceive", + align: "left", + label: "วันที่ได้รับพระราชทาน", + field: "dateReceive", + sortable: true, + format(val, row) { + return date2Thai(val); + }, + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, + + // { + // name: "date", + // align: "left", + // label: "วันที่ในราชกิจนุเบกษา", + // field: "date", + // sortable: true, + // format(val, row) { + // return date2Thai(val); + // }, + // headerStyle: "font-size: 14px", + // style: "font-size: 14px", + // }, + // { + // name: "volumeNo", + // align: "left", + // label: "เล่มที่ในราชกิจนุเบกษา", + // field: "volumeNo", + // sortable: true, + // headerStyle: "font-size: 14px", + // style: "font-size: 14px", + // }, + // { + // name: "section", + // align: "left", + // label: "ตอนที่ในราชกิจนุเบกษา", + // field: "section", + // sortable: true, + // headerStyle: "font-size: 14px", + // style: "font-size: 14px", + // }, + // { + // name: "page", + // align: "left", + // label: "หน้าในราชกิจนุเบกษา", + // field: "page", + // sortable: true, + // headerStyle: "font-size: 14px", + // style: "font-size: 14px", + // }, + // { + // name: "no", + // align: "left", + // label: "ลำดับที่ในราชกิจจานุเบกษา", + // field: "no", + // sortable: true, + // headerStyle: "font-size: 14px", + // style: "font-size: 14px", + // }, + // { + // name: "number", + // align: "left", + // label: "หมายเลขใบกำกับ", + // field: "number", + // sortable: true, + // headerStyle: "font-size: 14px", + // style: "font-size: 14px", + // }, +]); +const visibleColumns = ref([ + "noNumber", + "citizenId", + "fullName", + "profileType", + "position", + "requestInsignia", + "dateReceive", + // "date", + // "volumeNo", + // "section", + // "page", + // "no", + // "number", +]); + +/** function เคลียร์ข้อมูลในฟอร์ม*/ function clearData() { receivedate.value = null; returndate.value = null; @@ -96,11 +246,13 @@ function clearData() { fullName.value = ""; brand.value = ""; reason.value = ""; + selected.value = []; + keyword.value = ""; + rows.value = []; + rowsMain.value = []; } -/** - * function เรียกข้อมูลรายการเครื่องราช - */ +/** function เรียกข้อมูลรายการเครื่องราช*/ async function fecthlistInsignia() { if (roundNo.value !== "" && roundNo.value !== null) { showLoader(); @@ -112,25 +264,20 @@ async function fecthlistInsignia() { await http .post(config.API.noteSearchList(), data) .then((res) => { - listPerson.value = res.data.result; + rowsMain.value = res.data.result; + rows.value = res.data.result; + serchDataTable(); }) .catch((err) => { messageError($q, err); }) .finally(() => { - cardid.value = ""; - fullName.value = ""; - brand.value = ""; - OrganazationId.value = ""; - reason.value = ""; hideLoader(); }); } } -/** - * function บันทึกการเพิ่มข้อมูล - */ +/** function บันทึกการเพิ่มข้อมูล*/ async function onSubmit() { dialogConfirm($q, async () => { showLoader(); @@ -145,10 +292,12 @@ async function onSubmit() { .then(async () => { await props.closeAndFecth(); await success($q, "บันทึกข้อมูลสำเร็จ"); - clearData(); + closeDialog(); }) .catch((err) => { messageError($q, err); + }) + .finally(() => { hideLoader(); }); } else { @@ -163,60 +312,25 @@ async function onSubmit() { .then(async () => { await props.closeAndFecth(); await success($q, "บันทึกข้อมูลสำเร็จ"); - clearData(); + closeDialog(); }) .catch((err) => { messageError($q, err); + }) + .finally(() => { hideLoader(); }); } }); } -/** - * function ค้นหาคนจากเลขประจำตัวประชาชน - */ -async function searchcardid() { - if (cardid.value.length === 13) { - showLoader(); - const node = await listPerson.value.find( - (e: any) => e.citizenId === cardid.value - ); - - if (node) { - fullName.value = ` ${node.fullName}`; - brand.value = `${node.requestInsignia} (${ - type.value.find((item: any) => item.name === node.requestInsignia) - ?.shortName || "" - })`; - insigniaNoteProfileId.value = node.id; - hideLoader(); - } else { - notifyError($q, "ไม่พบข้อมูลการได้รับในรอบนี้"); - fullName.value = ""; - brand.value = ""; - OrganazationId.value = ""; - reason.value = ""; - hideLoader(); - } - } else { - fullName.value = ""; - brand.value = ""; - receivedate.value = null; - } -} - -/** - * function closePopup - */ +/** function closePopup*/ function closeDialog() { clearData(); props.close(); } -/** - * function reset วันที่คืน - */ +/** function reset วันที่คืน*/ function clearReturnDate() { returndate.value = null; } @@ -245,17 +359,21 @@ function filterSelector(val: string, update: Function, name: string) { }); } -/** - * function setValue - */ +function serchDataTable() { + rows.value = onSearchDataTable( + keyword.value, + rowsMain.value, + columns.value ? columns.value : [] + ); +} + +/** function setValue*/ function setValue() { filterSelectRound.value = props.filterSelectRoundOption; selectRound.value = props.selectRoundOption; } -/** - * function callback เช็ค props ถ้าเปิด dialog ให้ดึงรายการข้อมูล - */ +/** function callback เช็ค props ถ้าเปิด dialog ให้ดึงรายการข้อมูล*/ watch(props, () => { if (props.modal == true && props.roundId != "all") { roundNo.value = props.roundId; @@ -267,6 +385,18 @@ watch(props, () => { } }); +watch(selected, () => { + if (props.modal) { + const data = selected.value[0]; + insigniaNoteProfileId.value = data ? data.id : ""; + fullName.value = data ? data.fullName : ""; + cardid.value = data ? data.citizenId : ""; + brand.value = data + ? `${data.requestInsignia} (${data.requestInsigniaShortName})` + : ""; + } +}); + /** Hook*/ onMounted(() => { setValue(); @@ -275,7 +405,11 @@ onMounted(() => {