แก้ bug เครื่องราช, เพิ่ม validate

This commit is contained in:
Warunee Tamkoo 2023-09-20 15:33:39 +07:00
parent fe672a5aff
commit 627df1a30a
16 changed files with 484 additions and 1167 deletions

View file

@ -32,6 +32,7 @@ const listPerson = ref<any>([]);
const OrgList = ref<DataOption[]>([]);
const insigniaNoteProfileId = ref<string>("");
//
const clearData = () => {
receivedate.value = null;
returndate.value = null;
@ -75,17 +76,21 @@ const props = defineProps({
},
});
// props dialog
watch(props, () => {
if (props.modal == true && props.roundId != "all") {
roundNo.value = props.roundId;
fecthlistInsignia();
fetchOrgList();
if (props.action == "editData") {
fetchData();
}
// -
// if (props.action == "editData") {
// fetchData();
// }
}
});
//
const fecthlistInsignia = async () => {
showLoader();
let data = {
@ -111,6 +116,7 @@ const fecthlistInsignia = async () => {
});
};
//
const fetchOrgList = async () => {
showLoader();
await http
@ -141,21 +147,21 @@ const fetchOrgList = async () => {
});
};
const fetchData = async () => {
showLoader();
await http
.get(config.API.insigniaManageBorrowById(props.profileId))
.then(async (response: any) => {
console.log(response);
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
};
// -
// const fetchData = async () => {
// showLoader();
// await http
// .get(config.API.insigniaManageBorrowById(props.profileId))
// .catch((err) => {
// messageError($q, err);
// })
// .finally(() => {
// hideLoader();
// });
// };
// -
const clickSave = async () => {
await myForm.value!.validate().then((result: boolean) => {
if (result) {
@ -200,6 +206,7 @@ const clickSave = async () => {
});
};
//
const searchcardid = async () => {
if (cardid.value.length === 13) {
const node = await listPerson.value.find(
@ -220,15 +227,26 @@ const searchcardid = async () => {
}
};
// dialog
const closeDialog = () => {
clearData();
props.close();
};
// reset
const clearReceiveDate = () => {
receivedate.value = null;
}
// reset
const clearReturnDate = () => {
returndate.value = null;
}
</script>
<template>
<q-dialog v-model="props.modal" persistent>
<q-card style="min-width: 900px" class="q-pb-md">
<q-card style="min-width: 900px">
<DialogHeader tittle="ยืม-คืนเครื่องราชฯ" :close="closeDialog" />
<q-separator />
@ -261,7 +279,7 @@ const closeDialog = () => {
@update:model-value="fecthlistInsignia()"
/>
</div>
<div class="col-12 text-weight-bold text-grey">อมลผ</div>
<div class="col-12 q-mt-md text-weight-bold text-grey-7">อมลผ</div>
<div class="col-xs-12 col-sm-6">
<q-input
:disable="roundNo == ''"
@ -272,7 +290,7 @@ const closeDialog = () => {
dense
lazy-rules
:rules="[
(val: string) => !!val || `${'กรุณากรอก เลขประจำตัวประชาชน'}`,
(val: string) => !!val || `${'กรุณากรอกเลขประจำตัวประชาชน'}`,
(val: string) =>
val.length >= 13 ||
`${'กรุณากรอกเลขประจำตัวประชาชนให้ครบ'}`,
@ -285,7 +303,7 @@ const closeDialog = () => {
</div>
<div class="col-xs-6 col-sm-6">
<q-input
disable
readonly
hide-bottom-space
outlined
dense
@ -294,15 +312,16 @@ const closeDialog = () => {
borderless
v-model="fullName"
:label="`${'ชื่อ-นามสกุล'}`"
:rules="[(val) => !!val || 'ชื่อ-นามสกุลต้องไม่ว่าง กรุณากรอกเลขประจำตัวประชาชนให้ถูกต้อง']"
/>
</div>
<div class="col-12 q-my-xs"><q-separator size="2px" /></div>
<div class="col-12 text-weight-bold text-grey">
<div class="col-12 q-mt-md text-weight-bold text-grey-7">
รายละเอยดการยมเครองราชฯ
</div>
<div class="col-xs-12 col-sm-6">
<q-input
:rules="[(val) => !!val || 'กรุณาเลือกเครื่องราชฯ']"
v-model="brand"
disable
dense
@ -341,6 +360,7 @@ const closeDialog = () => {
"
:label="`${'วันที่ยืม'}`"
clearable
@clear="clearReceiveDate"
>
<template v-slot:prepend>
<q-icon
@ -369,6 +389,7 @@ const closeDialog = () => {
v-model="OrganazationId"
lazy-rules
:label="`เลือกหน่วยงาน`"
:rules="[(val) => !!val || 'กรุณาเลือกหน่วยงาน']"
/>
</div>
</div>
@ -377,8 +398,8 @@ const closeDialog = () => {
class="row col-12 q-col-gutter-x-xs q-col-gutter-y-xs"
v-if="props.action === 'editData'"
>
<div class="col-12 q-my-xs"><q-separator size="2px" /></div>
<div class="col-12 text-weight-bold text-grey">
<div class="col-12 text-weight-bold text-grey-7">
รายละเอยดการคนเครองราชฯ
</div>
<div class="col-xs-12 col-sm-6">
@ -403,13 +424,14 @@ const closeDialog = () => {
borderless
outlined
lazy-rules
:rules="[(val) => !!val || 'กรุณาเลือกวันที่']"
:rules="[(val) => !!val || 'กรุณาเลือกวันที่คืน']"
hide-bottom-space
:model-value="
returndate != null ? date2Thai(returndate) : undefined
"
:label="`${'วันที่คืน'}`"
clearable
@clear="clearReturnDate"
>
<template v-slot:prepend>
<q-icon
@ -438,6 +460,7 @@ const closeDialog = () => {
outlined
v-model="OrganazationId"
:label="`เลือกหน่วยงานที่ส่งคืน`"
:rules="[(val) => !!val || 'กรุณาเลือกหน่วยงานที่คืน']"
/>
</div>

View file

@ -137,9 +137,7 @@ const columns = ref<QTableProps["columns"]>([
align: "left",
label: "ลำดับ",
field: "no",
sortable: true,
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
sortable: false,
},
{
name: "citizenId",