validate เพิ่มรายการสืบสวนข้อเท็จจริง
This commit is contained in:
parent
41cdbc7992
commit
8a61666c0b
2 changed files with 186 additions and 48 deletions
|
|
@ -1,10 +1,16 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import router from "@/router";
|
import router from "@/router";
|
||||||
import { onMounted, ref, watch } from "vue";
|
import { onMounted, ref, watch, reactive } from "vue";
|
||||||
|
import { useQuasar } from "quasar";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
import { useInvestigateFactStore } from "@/modules/11_discipline/store/InvestigateFactStore";
|
import { useInvestigateFactStore } from "@/modules/11_discipline/store/InvestigateFactStore";
|
||||||
|
import type {
|
||||||
|
FormData,
|
||||||
|
MyObjectInvestigateRef,
|
||||||
|
} from "@/modules/11_discipline/interface/request/investigate";
|
||||||
const investigateFactStore = useInvestigateFactStore();
|
const investigateFactStore = useInvestigateFactStore();
|
||||||
const { filterFnOptionsType } = investigateFactStore;
|
const { filterFnOptionsType } = investigateFactStore;
|
||||||
|
|
||||||
const mixin = useCounterMixin();
|
const mixin = useCounterMixin();
|
||||||
const {
|
const {
|
||||||
messageError,
|
messageError,
|
||||||
|
|
@ -14,20 +20,78 @@ const {
|
||||||
dialogConfirm,
|
dialogConfirm,
|
||||||
success,
|
success,
|
||||||
} = mixin;
|
} = mixin;
|
||||||
const complaint = ref<string>("");
|
const $q = useQuasar();
|
||||||
const complaintdetail = ref<string>("");
|
const complaintRef = ref<Object | null>(null);
|
||||||
const detail = ref<string>("");
|
const complaintdetailRef = ref<Object | null>(null);
|
||||||
const fault = ref<string>("");
|
const detailRef = ref<Object | null>(null);
|
||||||
const results = ref<string>("");
|
const faultRef = ref<Object | null>(null);
|
||||||
const other = ref<string>("");
|
const resultsRef = ref<Object | null>(null);
|
||||||
const evidenceFiles = ref<File | null>(null);
|
const otherRef = ref<Object | null>(null);
|
||||||
const fileComplaint = ref<File | null>(null);
|
const evidenceFilesRef = ref<Object | null>(null);
|
||||||
const clickTime = ref<boolean>(false);
|
const fileComplaintRef = ref<Object | null>(null);
|
||||||
const date = ref<Date>();
|
const clickTimeRef = ref<Object | null>(null);
|
||||||
const dateEnd = ref<Date>();
|
const dateRef = ref<Object | null>(null);
|
||||||
const investigation = ref<string>("");
|
const dateEndRef = ref<Object | null>(null);
|
||||||
|
const investigationRef = ref<Object | null>(null);
|
||||||
|
const daysExtendRef = ref<Object | null>(null);
|
||||||
|
const formData = reactive<FormData>({
|
||||||
|
complaint: "",
|
||||||
|
complaintdetail: "",
|
||||||
|
detail: "",
|
||||||
|
fault: "",
|
||||||
|
results: "",
|
||||||
|
other: "",
|
||||||
|
evidenceFiles: null,
|
||||||
|
fileComplaint: null,
|
||||||
|
clickTime: false,
|
||||||
|
date: null,
|
||||||
|
dateEnd: null,
|
||||||
|
investigation: "",
|
||||||
|
daysExtend: "",
|
||||||
|
});
|
||||||
|
const objectInvestigate: MyObjectInvestigateRef = {
|
||||||
|
complaint: complaintRef,
|
||||||
|
complaintdetail: complaintdetailRef,
|
||||||
|
detail: detailRef,
|
||||||
|
fault: faultRef,
|
||||||
|
results: resultsRef,
|
||||||
|
other: otherRef,
|
||||||
|
evidenceFiles: evidenceFilesRef,
|
||||||
|
fileComplaint: fileComplaintRef,
|
||||||
|
date: dateRef,
|
||||||
|
dateEnd: dateEndRef,
|
||||||
|
investigation: investigationRef,
|
||||||
|
daysExtend: daysExtendRef,
|
||||||
|
};
|
||||||
|
|
||||||
const daysExtend = ref<string>("");
|
function validateForm() {
|
||||||
|
const hasError = [];
|
||||||
|
for (const key in objectInvestigate) {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(objectInvestigate, key)) {
|
||||||
|
const property = objectInvestigate[key];
|
||||||
|
if (property.value && typeof property.value.validate === "function") {
|
||||||
|
const isValid = property.value.validate();
|
||||||
|
hasError.push(isValid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hasError.every((result) => result === true)) {
|
||||||
|
onSubmit();
|
||||||
|
} else {
|
||||||
|
console.log("ไม่ผ่าน ");
|
||||||
|
console.log(hasError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function onSubmit() {
|
||||||
|
dialogConfirm(
|
||||||
|
$q,
|
||||||
|
async () => {
|
||||||
|
console.log(formData);
|
||||||
|
},
|
||||||
|
"ยืนยันการบันทึกข้อมูล",
|
||||||
|
"ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?"
|
||||||
|
);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="toptitle text-dark col-12 row items-center">
|
<div class="toptitle text-dark col-12 row items-center">
|
||||||
|
|
@ -45,18 +109,19 @@ const daysExtend = ref<string>("");
|
||||||
</div>
|
</div>
|
||||||
<q-card flat bordered class="col-12 q-mt-sm">
|
<q-card flat bordered class="col-12 q-mt-sm">
|
||||||
<div class="q-pa-md">
|
<div class="q-pa-md">
|
||||||
<q-form ref="myForm">
|
<form @submit.prevent="validateForm">
|
||||||
<div class="row col-12">
|
<div class="row col-12">
|
||||||
<div class="col-12 row bg-white q-col-gutter-md">
|
<div class="col-12 row bg-white q-col-gutter-md">
|
||||||
<div class="col-xs-12 row items-center">
|
<div class="col-xs-12 row items-center">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<q-input
|
<q-input
|
||||||
class="full-width inputgreen cursor-pointer"
|
class="full-width inputgreen cursor-pointer"
|
||||||
|
ref="complaintRef"
|
||||||
outlined
|
outlined
|
||||||
dense
|
dense
|
||||||
lazy-rules
|
lazy-rules
|
||||||
borderless
|
borderless
|
||||||
v-model="complaint"
|
v-model="formData.complaint"
|
||||||
:rules="[(val) => !!val || `${'กรุณากรอกเรื่องร้องเรียน'}`]"
|
:rules="[(val) => !!val || `${'กรุณากรอกเรื่องร้องเรียน'}`]"
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
:label="`${'เรื่องร้องเรียน'}`"
|
:label="`${'เรื่องร้องเรียน'}`"
|
||||||
|
|
@ -68,7 +133,9 @@ const daysExtend = ref<string>("");
|
||||||
<q-select
|
<q-select
|
||||||
outlined
|
outlined
|
||||||
dense
|
dense
|
||||||
v-model="fault"
|
ref="faultRef"
|
||||||
|
v-model="formData.fault"
|
||||||
|
:rules="[(val) => !!val || `${'กรุณาเลือกลักษณะความผิด'}`]"
|
||||||
:options="investigateFactStore.faultOp"
|
:options="investigateFactStore.faultOp"
|
||||||
label="ลักษณะความผิด"
|
label="ลักษณะความผิด"
|
||||||
emit-value
|
emit-value
|
||||||
|
|
@ -92,7 +159,11 @@ const daysExtend = ref<string>("");
|
||||||
<q-select
|
<q-select
|
||||||
outlined
|
outlined
|
||||||
dense
|
dense
|
||||||
v-model="investigation"
|
ref="investigationRef"
|
||||||
|
:rules="[
|
||||||
|
(val) => !!val || `${'กรุณาเลือกลักษณะการสืบสวน'}`,
|
||||||
|
]"
|
||||||
|
v-model="formData.investigation"
|
||||||
:options="investigateFactStore.investigationOp"
|
:options="investigateFactStore.investigationOp"
|
||||||
label="ลักษณะการสืบสวน"
|
label="ลักษณะการสืบสวน"
|
||||||
emit-value
|
emit-value
|
||||||
|
|
@ -113,16 +184,26 @@ const daysExtend = ref<string>("");
|
||||||
</q-select>
|
</q-select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="investigation === '003'" class="col-12 q-mb-md">
|
<div
|
||||||
|
v-if="formData.investigation === '003'"
|
||||||
|
class="col-12 q-mb-md"
|
||||||
|
>
|
||||||
<q-input
|
<q-input
|
||||||
class="full-width inputgreen cursor-pointer"
|
class="full-width inputgreen cursor-pointer"
|
||||||
outlined
|
outlined
|
||||||
|
ref="otherRef"
|
||||||
dense
|
dense
|
||||||
borderless
|
borderless
|
||||||
v-model="other"
|
v-model="formData.other"
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
:label="`${'รายการอื่นๆ(โปรดระบุ)'}`"
|
:label="`${'รายการอื่นๆ(โปรดระบุ)'}`"
|
||||||
type="textarea"
|
type="textarea"
|
||||||
|
:rules="[
|
||||||
|
(val) =>
|
||||||
|
formData.investigation === '003'
|
||||||
|
? !!val || 'กรุณาเลือกจำนวนวันที่ต้องการขยาย'
|
||||||
|
: true,
|
||||||
|
]"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -134,17 +215,17 @@ const daysExtend = ref<string>("");
|
||||||
</p>
|
</p>
|
||||||
<q-checkbox
|
<q-checkbox
|
||||||
size="md"
|
size="md"
|
||||||
v-model="clickTime"
|
v-model="formData.clickTime"
|
||||||
label="ขยายเวลา"
|
label="ขยายเวลา"
|
||||||
color="primary"
|
color="primary"
|
||||||
class="text-weight-medium q-ml-sm"
|
class="text-weight-medium q-ml-sm"
|
||||||
keep-color
|
keep-color
|
||||||
/>
|
/>
|
||||||
<div v-if="clickTime !== true" class="self-start row">
|
<div v-if="formData.clickTime !== true" class="self-start row">
|
||||||
<div class="q-mx-xs">
|
<div class="q-mx-xs">
|
||||||
<datepicker
|
<datepicker
|
||||||
menu-class-name="modalfix"
|
menu-class-name="modalfix"
|
||||||
v-model="date"
|
v-model="formData.date"
|
||||||
:locale="'th'"
|
:locale="'th'"
|
||||||
autoApply
|
autoApply
|
||||||
:enableTimePicker="false"
|
:enableTimePicker="false"
|
||||||
|
|
@ -157,11 +238,14 @@ const daysExtend = ref<string>("");
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
<q-input
|
<q-input
|
||||||
class="full-width inputgreen cursor-pointer"
|
class="full-width inputgreen cursor-pointer"
|
||||||
|
ref="dateRef"
|
||||||
outlined
|
outlined
|
||||||
dense
|
dense
|
||||||
lazy-rules
|
lazy-rules
|
||||||
borderless
|
borderless
|
||||||
:model-value="date ? date2Thai(date) : null"
|
:model-value="
|
||||||
|
formData.date ? date2Thai(formData.date) : null
|
||||||
|
"
|
||||||
:rules="[
|
:rules="[
|
||||||
(val) =>
|
(val) =>
|
||||||
!!val || `${'กรุณาเลือกวันที่เริ่มการสอบสวน'}`,
|
!!val || `${'กรุณาเลือกวันที่เริ่มการสอบสวน'}`,
|
||||||
|
|
@ -183,7 +267,7 @@ const daysExtend = ref<string>("");
|
||||||
<div class="q-mx-xs q-">
|
<div class="q-mx-xs q-">
|
||||||
<datepicker
|
<datepicker
|
||||||
menu-class-name="modalfix"
|
menu-class-name="modalfix"
|
||||||
v-model="dateEnd"
|
v-model="formData.dateEnd"
|
||||||
:locale="'th'"
|
:locale="'th'"
|
||||||
autoApply
|
autoApply
|
||||||
:enableTimePicker="false"
|
:enableTimePicker="false"
|
||||||
|
|
@ -195,12 +279,17 @@ const daysExtend = ref<string>("");
|
||||||
}}</template>
|
}}</template>
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
<q-input
|
<q-input
|
||||||
|
ref="dateEndRef"
|
||||||
class="full-width inputgreen cursor-pointer"
|
class="full-width inputgreen cursor-pointer"
|
||||||
outlined
|
outlined
|
||||||
dense
|
dense
|
||||||
lazy-rules
|
lazy-rules
|
||||||
borderless
|
borderless
|
||||||
:model-value="dateEnd ? date2Thai(dateEnd) : null"
|
:model-value="
|
||||||
|
formData.dateEnd
|
||||||
|
? date2Thai(formData.dateEnd)
|
||||||
|
: null
|
||||||
|
"
|
||||||
:rules="[
|
:rules="[
|
||||||
(val) =>
|
(val) =>
|
||||||
!!val || `${'กรุณาเลือกวันที่สิ้นสุดการสอบสวน'}`,
|
!!val || `${'กรุณาเลือกวันที่สิ้นสุดการสอบสวน'}`,
|
||||||
|
|
@ -225,14 +314,15 @@ const daysExtend = ref<string>("");
|
||||||
outlined
|
outlined
|
||||||
dense
|
dense
|
||||||
lazy-rules
|
lazy-rules
|
||||||
v-model="daysExtend"
|
ref="daysExtendRef"
|
||||||
|
v-model="formData.daysExtend"
|
||||||
:options="investigateFactStore.daysExtendOp"
|
:options="investigateFactStore.daysExtendOp"
|
||||||
label="จำนวนวันที่ต้องการขยาย"
|
label="จำนวนวันที่ต้องการขยาย"
|
||||||
emit-value
|
emit-value
|
||||||
map-options
|
map-options
|
||||||
:rules="[
|
:rules="[
|
||||||
(val) =>
|
(val) =>
|
||||||
clickTime === true
|
formData.clickTime === true
|
||||||
? !!val || 'กรุณาเลือกจำนวนวันที่ต้องการขยาย'
|
? !!val || 'กรุณาเลือกจำนวนวันที่ต้องการขยาย'
|
||||||
: true,
|
: true,
|
||||||
]"
|
]"
|
||||||
|
|
@ -256,10 +346,11 @@ const daysExtend = ref<string>("");
|
||||||
<q-input
|
<q-input
|
||||||
class="full-width inputgreen cursor-pointer"
|
class="full-width inputgreen cursor-pointer"
|
||||||
outlined
|
outlined
|
||||||
|
ref="complaintdetailRef"
|
||||||
dense
|
dense
|
||||||
lazy-rules
|
lazy-rules
|
||||||
borderless
|
borderless
|
||||||
v-model="complaintdetail"
|
v-model="formData.complaintdetail"
|
||||||
:rules="[
|
:rules="[
|
||||||
(val) => !!val || `${'กรุณากรอกรายละเอียดเรื่องร้องเรียน'}`,
|
(val) => !!val || `${'กรุณากรอกรายละเอียดเรื่องร้องเรียน'}`,
|
||||||
]"
|
]"
|
||||||
|
|
@ -271,11 +362,12 @@ const daysExtend = ref<string>("");
|
||||||
<div class="col-12 q-my-sm">
|
<div class="col-12 q-my-sm">
|
||||||
<q-file
|
<q-file
|
||||||
outlined
|
outlined
|
||||||
|
ref="fileComplaintRef"
|
||||||
dense
|
dense
|
||||||
v-model="fileComplaint"
|
v-model="formData.fileComplaint"
|
||||||
label="ไฟล์เอกสารหลักฐานเรื่องร้องเรียน"
|
label="ไฟล์เอกสารหลักฐานเรื่องร้องเรียน"
|
||||||
lazy-rules
|
lazy-rules
|
||||||
:rules="[(val) => val || 'กรุณาเลือกไฟล์หลักฐานการรับ']"
|
:rules="[(val) => !!val || 'กรุณาเลือกไฟล์หลักฐานการรับ']"
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
>
|
>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
|
|
@ -287,10 +379,11 @@ const daysExtend = ref<string>("");
|
||||||
<q-input
|
<q-input
|
||||||
class="full-width inputgreen cursor-pointer"
|
class="full-width inputgreen cursor-pointer"
|
||||||
outlined
|
outlined
|
||||||
|
ref="detailRef"
|
||||||
dense
|
dense
|
||||||
lazy-rules
|
lazy-rules
|
||||||
borderless
|
borderless
|
||||||
v-model="detail"
|
v-model="formData.detail"
|
||||||
:rules="[(val) => !!val || `${'กรุณากรอกรายละเอียด'}`]"
|
:rules="[(val) => !!val || `${'กรุณากรอกรายละเอียด'}`]"
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
:label="`${'รายละเอียด'}`"
|
:label="`${'รายละเอียด'}`"
|
||||||
|
|
@ -301,10 +394,11 @@ const daysExtend = ref<string>("");
|
||||||
<q-file
|
<q-file
|
||||||
outlined
|
outlined
|
||||||
dense
|
dense
|
||||||
v-model="evidenceFiles"
|
ref="evidenceFilesRef"
|
||||||
|
v-model="formData.evidenceFiles"
|
||||||
label="ไฟล์หลักฐานการรับ"
|
label="ไฟล์หลักฐานการรับ"
|
||||||
lazy-rules
|
lazy-rules
|
||||||
:rules="[(val) => val || 'กรุณาเลือกไฟล์หลักฐานการรับ']"
|
:rules="[(val) => !!val || 'กรุณาเลือกไฟล์หลักฐานการรับ']"
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
>
|
>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
|
|
@ -312,33 +406,43 @@ const daysExtend = ref<string>("");
|
||||||
</template>
|
</template>
|
||||||
</q-file>
|
</q-file>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-4 q-mr-sm">
|
<div class="row col-12 items-start q-mt-sm">
|
||||||
|
<div class="col-4">
|
||||||
<q-input
|
<q-input
|
||||||
standout
|
standout
|
||||||
dense
|
dense
|
||||||
v-model="results"
|
ref="resultsRef"
|
||||||
|
:rules="[(val) => !!val || `${'กรุณากรอกผลการสืบสวน'}`]"
|
||||||
|
v-model="formData.results"
|
||||||
outlined
|
outlined
|
||||||
debounce="300"
|
debounce="300"
|
||||||
placeholder="ผลการสืบสวน"
|
placeholder="ผลการสืบสวน"
|
||||||
>
|
>
|
||||||
</q-input>
|
</q-input>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
<q-btn label="ยืนยันผลการสืบสวน" color="public">
|
<q-btn label="ยืนยันผลการสืบสวน" color="public" class="q-py-sm q-ml-sm">
|
||||||
<q-tooltip>ยืนยันผลการสืบสวน</q-tooltip>
|
<q-tooltip>ยืนยันผลการสืบสวน</q-tooltip>
|
||||||
</q-btn>
|
</q-btn>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</q-form>
|
<q-separator />
|
||||||
</div>
|
<div class="row col-12 q-pa-sm">
|
||||||
<q-separator />
|
<q-space />
|
||||||
<div class="row col-12 q-pa-sm">
|
<q-btn
|
||||||
<q-space />
|
id="onSubmit"
|
||||||
<q-btn flat round color="secondary" icon="mdi-content-save-outline"
|
type="submit"
|
||||||
><q-tooltip>บับทึกข้อมูล</q-tooltip></q-btn
|
flat
|
||||||
>
|
round
|
||||||
|
color="secondary"
|
||||||
|
icon="mdi-content-save-outline"
|
||||||
|
><q-tooltip>บับทึกข้อมูล</q-tooltip></q-btn
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</q-card>
|
</q-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
34
src/modules/11_discipline/interface/request/investigate.ts
Normal file
34
src/modules/11_discipline/interface/request/investigate.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
|
||||||
|
interface FormData {
|
||||||
|
complaint: string
|
||||||
|
complaintdetail: string
|
||||||
|
detail: string
|
||||||
|
fault: string
|
||||||
|
results: string
|
||||||
|
other: string
|
||||||
|
evidenceFiles: File | null
|
||||||
|
fileComplaint: File | null
|
||||||
|
clickTime: boolean
|
||||||
|
date: Date | null
|
||||||
|
dateEnd: Date | null
|
||||||
|
daysExtend: string
|
||||||
|
investigation: string
|
||||||
|
}
|
||||||
|
interface MyObjectInvestigateRef {
|
||||||
|
complaint: object | null;
|
||||||
|
complaintdetail: object | null;
|
||||||
|
detail: object | null;
|
||||||
|
fault: object | null;
|
||||||
|
results: object | null;
|
||||||
|
evidenceFiles: object | null;
|
||||||
|
fileComplaint: object | null;
|
||||||
|
date: object | null;
|
||||||
|
dateEnd: object | null;
|
||||||
|
investigation: object | null;
|
||||||
|
daysExtend: object | null;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
export type {
|
||||||
|
FormData,
|
||||||
|
MyObjectInvestigateRef
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue