Refactoring code module 07_insignia
This commit is contained in:
parent
208d867dfd
commit
6fb6024f53
31 changed files with 1158 additions and 2444 deletions
|
|
@ -1,6 +1,9 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, watch, onMounted } from "vue";
|
||||
import { QForm, useQuasar } from "quasar";
|
||||
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useBrrowDataStore } from "@/modules/07_insignia/storeBrrow";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
|
|
@ -10,15 +13,7 @@ import type { DataOption } from "@/modules/04_registry/components/profileType";
|
|||
/** impotrComponents */
|
||||
import DialogHeader from "@/components/DialogHeader.vue";
|
||||
|
||||
/** impotrStores */
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useBrrowDataStore } from "@/modules/07_insignia/storeBrrow";
|
||||
import { useRoute } from "vue-router";
|
||||
|
||||
const $q = useQuasar();
|
||||
const myForm = ref<QForm>();
|
||||
const route = useRoute();
|
||||
|
||||
const DataStore = useBrrowDataStore();
|
||||
const mixin = useCounterMixin();
|
||||
const {
|
||||
|
|
@ -31,22 +26,9 @@ const {
|
|||
notifyError,
|
||||
} = mixin;
|
||||
|
||||
const brand = ref<string>("");
|
||||
const roundNo = ref<string | undefined>("");
|
||||
const cardid = ref<string>("");
|
||||
const OrganazationId = ref<string>("");
|
||||
const fullName = ref<string>("");
|
||||
const receivedate = ref<Date | null>();
|
||||
const returndate = ref<Date | null>();
|
||||
const reason = ref<string>("");
|
||||
const listPerson = ref<any>([]);
|
||||
const OrgList = ref<DataOption[]>([]);
|
||||
const filterOrgList = ref<DataOption[]>([]);
|
||||
const insigniaNoteProfileId = ref<string>("");
|
||||
const filterSelectRound = ref<any>();
|
||||
const selectRound = ref<any>();
|
||||
const type = ref<any>(DataStore.type);
|
||||
|
||||
/**
|
||||
* props
|
||||
*/
|
||||
const props = defineProps({
|
||||
modal: Boolean,
|
||||
save: {
|
||||
|
|
@ -85,7 +67,25 @@ const props = defineProps({
|
|||
},
|
||||
});
|
||||
|
||||
/** function เคลียร์ข้อมูลในฟอร์ม*/
|
||||
const brand = ref<string>(""); //เครื่องราชฯ
|
||||
const roundNo = ref<string | undefined>(""); //รอบการขอเครื่องราชฯ
|
||||
const cardid = ref<string>(""); //เลขประจำตัวประชาชน
|
||||
const OrganazationId = ref<string>(""); //
|
||||
const receivedate = ref<Date | null>(); //วันที่ยืม
|
||||
const returndate = ref<Date | null>(); //วันที่คืน
|
||||
const fullName = ref<string>(""); //ชื่อ-นามสกุล
|
||||
const reason = ref<string>("");
|
||||
const listPerson = ref<any>([]);
|
||||
const OrgList = ref<DataOption[]>([]);
|
||||
const filterOrgList = ref<DataOption[]>([]);
|
||||
const insigniaNoteProfileId = ref<string>("");
|
||||
const filterSelectRound = ref<any>();
|
||||
const selectRound = ref<any>();
|
||||
const type = ref<any>(DataStore.type);
|
||||
|
||||
/**
|
||||
* function เคลียร์ข้อมูลในฟอร์ม
|
||||
*/
|
||||
function clearData() {
|
||||
receivedate.value = null;
|
||||
returndate.value = null;
|
||||
|
|
@ -97,7 +97,9 @@ function clearData() {
|
|||
reason.value = "";
|
||||
}
|
||||
|
||||
/** function เรียกข้อมูลรายการเครื่องราช */
|
||||
/**
|
||||
* function เรียกข้อมูลรายการเครื่องราช
|
||||
*/
|
||||
async function fecthlistInsignia() {
|
||||
if (roundNo.value !== "" && roundNo.value !== null) {
|
||||
showLoader();
|
||||
|
|
@ -125,48 +127,9 @@ async function fecthlistInsignia() {
|
|||
}
|
||||
}
|
||||
|
||||
/** funcion เรียกข้อมูลหน่วยงานจัดสรรเครื่องราชอิสริยาภรณ์ */
|
||||
async function fetchOrgList() {
|
||||
http
|
||||
.get(config.API.activeOrganization)
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
|
||||
http
|
||||
.get(config.API.orgByIdSystem(data.activeId, route.meta.Key as string))
|
||||
.then(async (res) => {
|
||||
const data = await res.data.result.map((item: any) => ({
|
||||
id: item.orgTreeId,
|
||||
name: item.orgName,
|
||||
}));
|
||||
OrgList.value = data;
|
||||
filterOrgList.value = data;
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
});
|
||||
}
|
||||
|
||||
// ดึงข้อมูลการยืม-คืนมาแสดงเก็บไว้ก่อนเผื่อต้องเอาข้อมูลมาแสดงเพิ่ม
|
||||
// const fetchData = async () => {
|
||||
// showLoader();
|
||||
// await http
|
||||
// .get(config.API.insigniaManageBorrowById(props.profileId))
|
||||
// .catch((err) => {
|
||||
// messageError($q, err);
|
||||
// })
|
||||
// .finally(() => {
|
||||
// hideLoader();
|
||||
// });
|
||||
// };
|
||||
|
||||
// บันทึกข้อมูลการยืม-คืน
|
||||
|
||||
/** function บันทึกการเพิ่มข้อมูล*/
|
||||
/**
|
||||
* function บันทึกการเพิ่มข้อมูล
|
||||
*/
|
||||
async function onSubmit() {
|
||||
dialogConfirm($q, async () => {
|
||||
showLoader();
|
||||
|
|
@ -205,7 +168,9 @@ async function onSubmit() {
|
|||
});
|
||||
}
|
||||
|
||||
/** function ค้นหาคนจากเลขประจำตัวประชาชน*/
|
||||
/**
|
||||
* function ค้นหาคนจากเลขประจำตัวประชาชน
|
||||
*/
|
||||
async function searchcardid() {
|
||||
if (cardid.value.length === 13) {
|
||||
showLoader();
|
||||
|
|
@ -236,13 +201,17 @@ async function searchcardid() {
|
|||
}
|
||||
}
|
||||
|
||||
/** function closePopup*/
|
||||
/**
|
||||
* function closePopup
|
||||
*/
|
||||
function closeDialog() {
|
||||
clearData();
|
||||
props.close();
|
||||
}
|
||||
|
||||
/** function reset วันที่คืน*/
|
||||
/**
|
||||
* function reset วันที่คืน
|
||||
*/
|
||||
function clearReturnDate() {
|
||||
returndate.value = null;
|
||||
}
|
||||
|
|
@ -253,17 +222,17 @@ function clearReturnDate() {
|
|||
* @param update function
|
||||
* @param name ชื่อ Selec
|
||||
*/
|
||||
function filterSelector(val: any, update: Function, name: any) {
|
||||
function filterSelector(val: string, update: Function, name: string) {
|
||||
update(() => {
|
||||
const needle = val.toLowerCase();
|
||||
if (name === "filterOrgList") {
|
||||
OrganazationId.value = "";
|
||||
OrganazationId.value = val ? "" : OrganazationId.value;
|
||||
filterOrgList.value = OrgList.value.filter(
|
||||
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
|
||||
);
|
||||
}
|
||||
if (name === "filterSelectRoundOption") {
|
||||
roundNo.value = "";
|
||||
roundNo.value = val ? "" : roundNo.value;
|
||||
filterSelectRound.value = selectRound.value.filter(
|
||||
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
|
||||
);
|
||||
|
|
@ -271,29 +240,32 @@ function filterSelector(val: any, update: Function, name: any) {
|
|||
});
|
||||
}
|
||||
|
||||
/** function setValue*/
|
||||
const setValue = () => {
|
||||
/**
|
||||
* function setValue
|
||||
*/
|
||||
function setValue() {
|
||||
filterSelectRound.value = props.filterSelectRoundOption;
|
||||
selectRound.value = props.selectRoundOption;
|
||||
};
|
||||
}
|
||||
|
||||
/** Hook*/
|
||||
onMounted(() => {
|
||||
setValue();
|
||||
});
|
||||
|
||||
/** function callback เช็ค props ถ้าเปิด dialog ให้ดึงรายการข้อมูล */
|
||||
/**
|
||||
* function callback เช็ค props ถ้าเปิด dialog ให้ดึงรายการข้อมูล
|
||||
*/
|
||||
watch(props, () => {
|
||||
if (props.modal == true && props.roundId != "all") {
|
||||
roundNo.value = props.roundId;
|
||||
if (props.action === "editData") {
|
||||
// fetchOrgList();
|
||||
} else {
|
||||
fecthlistInsignia();
|
||||
setValue();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/** Hook*/
|
||||
onMounted(() => {
|
||||
setValue();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
@ -333,9 +305,9 @@ watch(props, () => {
|
|||
:readonly="false"
|
||||
:borderless="false"
|
||||
style="min-width: 150px"
|
||||
:rules="[(val) => !!val || 'กรุณาเลือกรอบการขอเครื่องราชฯ']"
|
||||
:rules="[(val:string) => !!val || 'กรุณาเลือกรอบการขอเครื่องราชฯ']"
|
||||
@update:model-value="fecthlistInsignia()"
|
||||
@filter="(inputValue:any,
|
||||
@filter="(inputValue:string,
|
||||
doneFn:Function) => filterSelector(inputValue, doneFn,'filterSelectRoundOption'
|
||||
) "
|
||||
/>
|
||||
|
|
@ -376,7 +348,7 @@ watch(props, () => {
|
|||
v-model="fullName"
|
||||
:label="`${'ชื่อ-นามสกุล'}`"
|
||||
:rules="[
|
||||
(val) =>
|
||||
(val:string) =>
|
||||
!!val ||
|
||||
'ชื่อ-นามสกุลต้องไม่ว่าง กรุณากรอกเลขประจำตัวประชาชนให้ถูกต้อง',
|
||||
]"
|
||||
|
|
@ -388,7 +360,7 @@ watch(props, () => {
|
|||
</div>
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
<q-input
|
||||
:rules="[(val) => !!val || 'กรุณาเลือกเครื่องราชฯ']"
|
||||
:rules="[(val:string) => !!val || 'กรุณาเลือกเครื่องราชฯ']"
|
||||
v-model="brand"
|
||||
disable
|
||||
dense
|
||||
|
|
@ -420,7 +392,7 @@ watch(props, () => {
|
|||
dense
|
||||
borderless
|
||||
outlined
|
||||
:rules="[(val) => !!val || 'กรุณาเลือกวันที่']"
|
||||
:rules="[(val:string) => !!val || 'กรุณาเลือกวันที่']"
|
||||
hide-bottom-space
|
||||
:model-value="
|
||||
receivedate != null ? date2Thai(receivedate) : undefined
|
||||
|
|
@ -468,7 +440,7 @@ watch(props, () => {
|
|||
dense
|
||||
borderless
|
||||
outlined
|
||||
:rules="[(val) => !!val || 'กรุณาเลือกวันที่คืน']"
|
||||
:rules="[(val:string) => !!val || 'กรุณาเลือกวันที่คืน']"
|
||||
hide-bottom-space
|
||||
:model-value="
|
||||
returndate != null ? date2Thai(returndate) : undefined
|
||||
|
|
@ -491,28 +463,6 @@ watch(props, () => {
|
|||
</datepicker>
|
||||
</div>
|
||||
|
||||
<!-- <div class="col-xs-12 col-sm-6">
|
||||
<q-select
|
||||
hide-bottom-space
|
||||
:options="filterOrgList"
|
||||
dense
|
||||
lazy-rules
|
||||
borderless
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
emit-value
|
||||
map-options
|
||||
outlined
|
||||
use-input
|
||||
v-model="OrganazationId"
|
||||
:label="`เลือกหน่วยงานที่ส่งคืน`"
|
||||
:rules="[(val) => !!val || 'กรุณาเลือกหน่วยงานที่คืน']"
|
||||
@filter="(inputValue:any,
|
||||
doneFn:Function) => filterSelector(inputValue, doneFn,'filterOrgList'
|
||||
) "
|
||||
/>
|
||||
</div> -->
|
||||
|
||||
<div class="col-12">
|
||||
<q-input
|
||||
class="inputgreen"
|
||||
|
|
|
|||
|
|
@ -1,740 +0,0 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, onMounted, watch } from "vue";
|
||||
import { useQuasar } from "quasar";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
import { checkPermission } from "@/utils/permissions";
|
||||
|
||||
/** impotrType */
|
||||
import type { OptionDataYear } from "@/modules/07_insignia/interface/index/Main";
|
||||
import type { QTableProps, QInput } from "quasar";
|
||||
|
||||
/** impotrComponents */
|
||||
import DialogForm from "@/modules/07_insignia/components/5_Borrow/DialogForm.vue";
|
||||
|
||||
/** impotrStores */
|
||||
import { useBrrowDataStore } from "@/modules/07_insignia/storeBrrow";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
const DataStore = useBrrowDataStore();
|
||||
const mixin = useCounterMixin();
|
||||
const { showLoader, hideLoader, messageError } = mixin;
|
||||
|
||||
const $q = useQuasar();
|
||||
const tab = ref<string>("");
|
||||
|
||||
/** ข้อมูล Table*/
|
||||
const visibleColumns = ref<String[]>([
|
||||
"action",
|
||||
"no",
|
||||
"status",
|
||||
"citizenId",
|
||||
"name",
|
||||
"type",
|
||||
"employeeType",
|
||||
"date",
|
||||
"volumeNo",
|
||||
"section",
|
||||
"dateReceive",
|
||||
"page",
|
||||
"number",
|
||||
"vatnumber",
|
||||
"datepay",
|
||||
"typepay",
|
||||
"address",
|
||||
"borrowOrganization",
|
||||
"borrowDate",
|
||||
"returnOrganization",
|
||||
"returnDate",
|
||||
"returnReason",
|
||||
]);
|
||||
const columns = ref<QTableProps["columns"]>([
|
||||
{
|
||||
name: "action",
|
||||
align: "left",
|
||||
label: "",
|
||||
field: "",
|
||||
},
|
||||
{
|
||||
name: "no",
|
||||
align: "left",
|
||||
label: "ลำดับ",
|
||||
field: "no",
|
||||
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: "name",
|
||||
align: "left",
|
||||
label: "ชื่อ - นามสกุล",
|
||||
field: "name",
|
||||
sortable: true,
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "employeeType",
|
||||
align: "left",
|
||||
label: "สถานภาพ",
|
||||
field: "employeeType",
|
||||
sortable: true,
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "type",
|
||||
align: "left",
|
||||
label: "ประเภทเครื่องราชฯ",
|
||||
field: "type",
|
||||
sortable: true,
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "dateReceive",
|
||||
align: "left",
|
||||
label: "วันที่ได้รับพระราชทาน",
|
||||
field: "dateReceive",
|
||||
sortable: true,
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
|
||||
{
|
||||
name: "date",
|
||||
align: "left",
|
||||
label: "วันที่ในราชกิจนุเบกษา",
|
||||
field: "date",
|
||||
sortable: true,
|
||||
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: "number",
|
||||
align: "left",
|
||||
label: "ลำดับที่ในราชกิจจานุเบกษา",
|
||||
field: "number",
|
||||
sortable: true,
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "vatnumber",
|
||||
align: "left",
|
||||
label: "หมายเลขใบกำกับ",
|
||||
field: "vatnumber",
|
||||
sortable: true,
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "datepay",
|
||||
align: "left",
|
||||
label: "วันที่จ่ายใบกำกับฯ",
|
||||
field: "datepay",
|
||||
sortable: true,
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "typepay",
|
||||
align: "left",
|
||||
label: "รูปแบบการจ่าย",
|
||||
field: "typepay",
|
||||
sortable: true,
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "address",
|
||||
align: "left",
|
||||
label: "ที่อยู่ที่จ่าย",
|
||||
field: "address",
|
||||
sortable: true,
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "borrowOrganization",
|
||||
align: "left",
|
||||
label: "หน่วยงานที่ยืม",
|
||||
field: "borrowOrganization",
|
||||
sortable: true,
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "borrowDate",
|
||||
align: "left",
|
||||
label: "วันที่ยืม",
|
||||
field: "borrowDate",
|
||||
sortable: true,
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "returnOrganization",
|
||||
align: "left",
|
||||
label: "หน่วยงานที่คืน",
|
||||
field: "returnOrganization",
|
||||
sortable: true,
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "returnDate",
|
||||
align: "left",
|
||||
label: "วันที่คืน",
|
||||
field: "returnDate",
|
||||
sortable: true,
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "returnReason",
|
||||
align: "left",
|
||||
label: "เหตุผลการคืน",
|
||||
field: "returnReason",
|
||||
sortable: true,
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
]);
|
||||
const filterRef = ref<QInput>();
|
||||
const filter = ref<string>("");
|
||||
const pagination = ref({
|
||||
sortBy: "name",
|
||||
descending: false,
|
||||
page: 1,
|
||||
rowsPerPage: 10,
|
||||
});
|
||||
|
||||
const selectRound = ref<string>();
|
||||
const selectRoundOption = ref<OptionDataYear[]>([]);
|
||||
const filterSelectRoundOption = ref<any>([]);
|
||||
const selectRoundAllOption = ref<OptionDataYear[]>([]);
|
||||
const filterSelectRoundAllOption = ref<OptionDataYear[]>([]);
|
||||
const type = ref<any[]>(DataStore.type);
|
||||
const modal = ref<boolean>(false);
|
||||
const action = ref<string>("");
|
||||
const profileId = ref<string>("");
|
||||
const roundYear = ref<any>();
|
||||
const insigniaList = ref<any>([]);
|
||||
const fileterInsigniaList = ref<any>([]);
|
||||
const loadView = ref<boolean>(false);
|
||||
const employeeClassOps = ref<any>(DataStore.employeeClassOps);
|
||||
|
||||
/** function เรียกรอบการเสนอขอพระราชทานเครื่องราชฯ*/
|
||||
async function fecthRound() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.noteround())
|
||||
.then(async (res) => {
|
||||
let data = res.data.result;
|
||||
if (data.length !== 0) {
|
||||
selectRoundAllOption.value = [
|
||||
{
|
||||
name: "ทั้งหมด",
|
||||
id: "0",
|
||||
year: 0,
|
||||
},
|
||||
];
|
||||
data.map((e: any) => {
|
||||
selectRoundOption.value.push({
|
||||
name: "รอบการเสนอขอพระราชทานเครื่องราชฯ ปี" + " " + (e.year + 543),
|
||||
id: e.id,
|
||||
year: e.year,
|
||||
});
|
||||
selectRoundAllOption.value.push({
|
||||
name: "รอบการเสนอขอพระราชทานเครื่องราชฯ ปี" + " " + (e.year + 543),
|
||||
id: e.id,
|
||||
year: e.year,
|
||||
});
|
||||
});
|
||||
filterSelectRoundAllOption.value = selectRoundAllOption.value;
|
||||
selectRound.value = data[0].id;
|
||||
filterSelectRoundOption.value = selectRoundOption.value;
|
||||
yearRound.value = data[0].year;
|
||||
roundYear.value = data[0].year;
|
||||
if (roundYear.value) {
|
||||
await fecthInsigniaType();
|
||||
} else {
|
||||
hideLoader();
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
/** function เรียกประเภทเครื่องราชฯ*/
|
||||
async function fecthInsignia() {
|
||||
await http
|
||||
.get(config.API.insigniaOrg)
|
||||
.then((res) => {
|
||||
let data = res.data.result;
|
||||
DataStore.fetchDataInsignia(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(async () => {
|
||||
insigniaList.value = await DataStore.insigniaOp.filter(
|
||||
(x: any) => x.type == tab.value || x.type == ""
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/** function เรียกระดับเครื่องราชฯ Tab*/
|
||||
async function fecthInsigniaType() {
|
||||
await http(config.API.insigniaTypeOrg)
|
||||
.then(async (res) => {
|
||||
let data = res.data.result;
|
||||
DataStore.fetchDatainsigniaType(data);
|
||||
tab.value = DataStore.insigniaType ? DataStore.insigniaType[0].name : "";
|
||||
loadView.value = true;
|
||||
await fecthInsignia();
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {});
|
||||
}
|
||||
|
||||
/** รอบการเสนอขอ*/
|
||||
const yearRound = ref<number>();
|
||||
/**
|
||||
* function เลือกรอบการเสนอขอ
|
||||
* @param round ปีการเสนอขอ
|
||||
*/
|
||||
async function selectorRound(round: number) {
|
||||
roundYear.value = round;
|
||||
await fecthlistInsignia();
|
||||
}
|
||||
|
||||
/** function เรียกรายชื่อการเสนอขอเครื่องราชฯ */
|
||||
async function fecthlistInsignia() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(
|
||||
config.API.insigniaManageBorrowList(Number(roundYear.value), tab.value)
|
||||
)
|
||||
.then(async (res) => {
|
||||
await DataStore.fetchlistinsignia(res.data.result);
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
/** function closePopup */
|
||||
function close() {
|
||||
modal.value = false;
|
||||
}
|
||||
|
||||
/** function closePopup และเเรียกข้อมูลรายชื่อการเสนอขอเครื่องราชฯ */
|
||||
async function closeAndFecth() {
|
||||
await fecthlistInsignia();
|
||||
modal.value = false;
|
||||
}
|
||||
|
||||
/** function openPopup เพิ่มรายการ ยืม-คืนเครื่องราชฯ*/
|
||||
function addData() {
|
||||
modal.value = true;
|
||||
action.value = "addData";
|
||||
}
|
||||
|
||||
/**
|
||||
* function openPopup แก้ไขรายการ ยืม-คืนเครื่องราชฯ
|
||||
* @param id profileId
|
||||
*/
|
||||
function editData(id: any) {
|
||||
profileId.value = id;
|
||||
action.value = "editData";
|
||||
modal.value = true;
|
||||
}
|
||||
|
||||
function resetFilter() {
|
||||
// reset ค่าที่ค้นหาเมื่อกดปุ่ม X ในกล่องค้นหา
|
||||
filter.value = "";
|
||||
filterRef.value!.focus();
|
||||
}
|
||||
|
||||
/**
|
||||
* function ค้นหาข้อมูลใน option
|
||||
* @param val คำค้นหา
|
||||
* @param update function
|
||||
* @param name ชื่อ Selec
|
||||
*/
|
||||
function filterSelector(val: any, update: Function, name: any) {
|
||||
update(() => {
|
||||
const needle = val.toLowerCase();
|
||||
if (name === "employeeClassOps") {
|
||||
// DataStore.employeeClass = "";
|
||||
employeeClassOps.value = DataStore.employeeClassOps.filter(
|
||||
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
|
||||
);
|
||||
} else if (name === "fileterInsigniaList") {
|
||||
// DataStore.insignia = null as any;
|
||||
fileterInsigniaList.value = insigniaList.value.filter(
|
||||
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
|
||||
);
|
||||
} else if (name === "filterSelectRoundAllOption") {
|
||||
// yearRound.value = null as any;
|
||||
filterSelectRoundAllOption.value = selectRoundAllOption.value.filter(
|
||||
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** Hook*/
|
||||
onMounted(async () => {
|
||||
await fecthRound();
|
||||
});
|
||||
|
||||
/** function callblack ทำงานเมือมีการเปลี่ยน Tab*/
|
||||
watch(tab, async () => {
|
||||
insigniaList.value = await DataStore.insigniaOp.filter(
|
||||
(x: any) => x.type == tab.value || x.type == ""
|
||||
);
|
||||
DataStore.insignia = "";
|
||||
fileterInsigniaList.value = insigniaList.value;
|
||||
fecthlistInsignia();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="toptitle text-dark col-12 row items-center">
|
||||
ยืม-คืนเครื่องราชฯ
|
||||
</div>
|
||||
<q-card
|
||||
flat
|
||||
bordered
|
||||
class="col-12 q-my-md q-mt-sm rounded-borders"
|
||||
v-if="loadView == true"
|
||||
>
|
||||
<q-tabs
|
||||
dense
|
||||
v-model="tab"
|
||||
align="left"
|
||||
class="bg-white text-grey"
|
||||
active-color="primary"
|
||||
indicator-color="primary"
|
||||
>
|
||||
<div v-for="item in DataStore.insigniaType">
|
||||
<q-tab :name="item.name" :label="item.label" />
|
||||
</div>
|
||||
</q-tabs>
|
||||
<q-separator />
|
||||
<q-tab-panels v-model="tab" animated>
|
||||
<q-tab-panel
|
||||
v-for="item in DataStore.insigniaType"
|
||||
:key="item.name"
|
||||
:name="item.name"
|
||||
class="q-pa-md"
|
||||
>
|
||||
<div class="row col-12">
|
||||
<div class="row col-12 q-col-gutter-sm">
|
||||
<q-select
|
||||
v-model="yearRound"
|
||||
dense
|
||||
outlined
|
||||
lazy-rules
|
||||
hide-bottom-space
|
||||
:label="`${'รอบการเสนอขอเครื่องราชฯ'}`"
|
||||
emit-value
|
||||
map-options
|
||||
use-input
|
||||
option-label="name"
|
||||
:options="filterSelectRoundAllOption"
|
||||
option-value="year"
|
||||
:borderless="false"
|
||||
style="min-width: 150px"
|
||||
@update:model-value="selectorRound"
|
||||
@filter="(inputValue: any,
|
||||
doneFn: Function) => filterSelector(inputValue, doneFn, 'filterSelectRoundAllOption'
|
||||
)"
|
||||
>
|
||||
<template v-slot:no-option>
|
||||
<q-item>
|
||||
<q-item-section class="text-grey">
|
||||
ไม่มีข้อมูล
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</template>
|
||||
</q-select>
|
||||
<q-space />
|
||||
|
||||
<q-input
|
||||
class="col-xs-12 col-sm-3 col-md-2"
|
||||
standout
|
||||
dense
|
||||
v-model="filter"
|
||||
ref="filterRef"
|
||||
outlined
|
||||
debounce="300"
|
||||
placeholder="ค้นหา"
|
||||
>
|
||||
<template v-slot:append>
|
||||
<q-icon v-if="filter == ''" name="search" />
|
||||
<q-icon
|
||||
v-if="filter !== ''"
|
||||
name="clear"
|
||||
class="cursor-pointer"
|
||||
@click="resetFilter"
|
||||
/>
|
||||
</template>
|
||||
</q-input>
|
||||
|
||||
<q-select
|
||||
v-model="visibleColumns"
|
||||
multiple
|
||||
outlined
|
||||
dense
|
||||
options-dense
|
||||
:display-value="$q.lang.table.columns"
|
||||
emit-value
|
||||
map-options
|
||||
:options="columns"
|
||||
option-value="name"
|
||||
options-cover
|
||||
style="min-width: 150px"
|
||||
class="col-xs-12 col-sm-3 col-md-2"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<q-card bordered class="q-pa-sm col-12 bg-grey-1 q-mt-sm">
|
||||
<div class="row col-12 q-col-gutter-sm">
|
||||
<q-select
|
||||
v-model="DataStore.insignia"
|
||||
dense
|
||||
outlined
|
||||
use-input
|
||||
lazy-rules
|
||||
hide-bottom-space
|
||||
:label="`${'เครื่องราชฯ'}`"
|
||||
emit-value
|
||||
map-options
|
||||
option-label="name"
|
||||
:options="fileterInsigniaList"
|
||||
option-value="id"
|
||||
:readonly="false"
|
||||
:borderless="false"
|
||||
style="min-width: 230px"
|
||||
@update:model-value="
|
||||
DataStore.searchDatatable(
|
||||
DataStore.insignia,
|
||||
DataStore.employeeClass
|
||||
)
|
||||
"
|
||||
@filter="(inputValue: any,
|
||||
doneFn: Function) => filterSelector(inputValue, doneFn, 'fileterInsigniaList'
|
||||
)"
|
||||
>
|
||||
<template v-if="DataStore.insignia !== ''" v-slot:append>
|
||||
</template>
|
||||
<template v-slot:no-option>
|
||||
<q-item>
|
||||
<q-item-section class="text-grey">
|
||||
ไม่มีข้อมูล
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</template>
|
||||
</q-select>
|
||||
|
||||
<q-select
|
||||
class="col-2"
|
||||
v-model="DataStore.employeeClass"
|
||||
dense
|
||||
outlined
|
||||
lazy-rules
|
||||
hide-bottom-space
|
||||
:label="`${'สถานภาพ'}`"
|
||||
emit-value
|
||||
use-input
|
||||
map-options
|
||||
option-label="name"
|
||||
:options="employeeClassOps"
|
||||
option-value="id"
|
||||
:readonly="false"
|
||||
:borderless="false"
|
||||
style="min-width: 240px"
|
||||
@update:model-value="
|
||||
DataStore.searchDatatable(
|
||||
DataStore.insignia,
|
||||
DataStore.employeeClass
|
||||
)
|
||||
"
|
||||
@filter="(inputValue: any,
|
||||
doneFn: Function) => filterSelector(inputValue, doneFn, 'employeeClassOps'
|
||||
)"
|
||||
>
|
||||
<template
|
||||
v-if="DataStore.employeeClass !== 'all'"
|
||||
v-slot:append
|
||||
>
|
||||
</template>
|
||||
<template v-slot:no-option>
|
||||
<q-item>
|
||||
<q-item-section class="text-grey">
|
||||
ไม่มีข้อมูล
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</template>
|
||||
</q-select>
|
||||
|
||||
<div>
|
||||
<q-btn
|
||||
v-if="checkPermission($route)?.attrIsCreate"
|
||||
@click="addData()"
|
||||
flat
|
||||
round
|
||||
color="add"
|
||||
icon="mdi-plus"
|
||||
>
|
||||
<q-tooltip>เพิ่ม</q-tooltip>
|
||||
</q-btn>
|
||||
</div>
|
||||
</div>
|
||||
</q-card>
|
||||
</div>
|
||||
|
||||
<div class="col-12 q-pt-sm">
|
||||
<d-table
|
||||
:rows="DataStore.rows"
|
||||
:columns="columns"
|
||||
:visible-columns="visibleColumns"
|
||||
:filter="filter"
|
||||
row-key="id"
|
||||
v-model:pagination="pagination"
|
||||
:paging="true"
|
||||
>
|
||||
<template v-slot:body-cell="props">
|
||||
<q-td :props="props">
|
||||
<div v-if="props.col.name == 'no'">
|
||||
{{ props.rowIndex + 1 }}
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-else-if="
|
||||
props.col.name == 'action' && props.row.returnDate == '-'
|
||||
"
|
||||
>
|
||||
<q-td>
|
||||
<q-btn
|
||||
v-if="checkPermission($route)?.attrIsUpdate"
|
||||
label="คืนเครื่องราชฯ"
|
||||
@click="editData(props.row.id)"
|
||||
color="blue"
|
||||
/>
|
||||
</q-td>
|
||||
</div>
|
||||
<div v-else-if="props.col.name == 'returnOrganization'">
|
||||
{{
|
||||
props.row.returnOrganization == null
|
||||
? "-"
|
||||
: props.row.returnOrganization
|
||||
}}
|
||||
</div>
|
||||
<div v-else>
|
||||
{{ props.value }}
|
||||
</div>
|
||||
</q-td>
|
||||
</template>
|
||||
</d-table>
|
||||
</div>
|
||||
</q-tab-panel>
|
||||
</q-tab-panels>
|
||||
</q-card>
|
||||
<q-card v-else>
|
||||
<div class="q-pa-md q-gutter-sm">
|
||||
<q-banner inline-actions rounded class="bg-grey-1 text-center">
|
||||
ไม่มีข้อมูลรอบการเสนอขอพระราชทานเครื่องราชอิสริยาภรณ์
|
||||
</q-banner>
|
||||
</div>
|
||||
</q-card>
|
||||
|
||||
<DialogForm
|
||||
:modal="modal"
|
||||
:close="close"
|
||||
:close-and-fecth="closeAndFecth"
|
||||
:type="type"
|
||||
:round-id="selectRound == '0' ? 'all' : selectRound"
|
||||
:action="action"
|
||||
:profile-id="profileId"
|
||||
v-model:selectRoundOption="selectRoundOption"
|
||||
v-model:filterSelectRoundOption="filterSelectRoundOption"
|
||||
:type-id="tab"
|
||||
/>
|
||||
</template>
|
||||
<style lang="scss" scoped>
|
||||
.arrow {
|
||||
transition: transform 0.5s;
|
||||
}
|
||||
|
||||
.arrow-active {
|
||||
transition: transform 0.5s;
|
||||
transform: rotate(-90deg);
|
||||
}
|
||||
|
||||
.bg-base {
|
||||
background-color: #f3f3f398;
|
||||
}
|
||||
|
||||
.v-enter-active,
|
||||
.v-leave-active {
|
||||
transition: opacity 0.5s ease;
|
||||
}
|
||||
|
||||
.v-enter-from,
|
||||
.v-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.flexsave {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
</style>
|
||||
Loading…
Add table
Add a link
Reference in a new issue