466 lines
18 KiB
Vue
466 lines
18 KiB
Vue
<script setup lang="ts">
|
|
import router from "@/router";
|
|
import { onMounted, ref, watch, reactive } from "vue";
|
|
import { useQuasar } from "quasar";
|
|
import { useCounterMixin } from "@/stores/mixin";
|
|
import { useInvestigateFactStore } from "@/modules/11_discipline/store/InvestigateFactStore";
|
|
import type {
|
|
FormData,
|
|
MyObjectInvestigateRef,
|
|
} from "@/modules/11_discipline/interface/request/investigate";
|
|
const investigateFactStore = useInvestigateFactStore();
|
|
const { filterFnOptionsType } = investigateFactStore;
|
|
|
|
const mixin = useCounterMixin();
|
|
const {
|
|
messageError,
|
|
showLoader,
|
|
hideLoader,
|
|
date2Thai,
|
|
dialogConfirm,
|
|
success,
|
|
} = mixin;
|
|
const $q = useQuasar();
|
|
const complaintRef = ref<Object | null>(null);
|
|
const complaintdetailRef = ref<Object | null>(null);
|
|
const detailRef = ref<Object | null>(null);
|
|
const faultRef = ref<Object | null>(null);
|
|
const resultsRef = ref<Object | null>(null);
|
|
const otherRef = ref<Object | null>(null);
|
|
const evidenceFilesRef = ref<Object | null>(null);
|
|
const fileComplaintRef = ref<Object | null>(null);
|
|
const clickTimeRef = ref<Object | null>(null);
|
|
const dateRef = ref<Object | null>(null);
|
|
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,
|
|
};
|
|
|
|
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>
|
|
<template>
|
|
<div class="toptitle text-dark col-12 row items-center">
|
|
<q-btn
|
|
icon="mdi-arrow-left"
|
|
unelevated
|
|
round
|
|
dense
|
|
flat
|
|
color="primary"
|
|
class="q-mr-sm"
|
|
@click="router.go(-1)"
|
|
/>
|
|
เพิ่มรายการสืบสวนข้อเท็จจริง
|
|
</div>
|
|
<q-card flat bordered class="col-12 q-mt-sm">
|
|
<div class="q-pa-md">
|
|
<form @submit.prevent="validateForm">
|
|
<div class="row col-12">
|
|
<div class="col-12 row bg-white q-col-gutter-md">
|
|
<div class="col-xs-12 row items-center">
|
|
<div class="col-12">
|
|
<q-input
|
|
for="#complaint"
|
|
class="full-width inputgreen cursor-pointer"
|
|
ref="complaintRef"
|
|
outlined
|
|
dense
|
|
lazy-rules
|
|
borderless
|
|
v-model="formData.complaint"
|
|
:rules="[(val) => !!val || `${'กรุณากรอกเรื่องร้องเรียน'}`]"
|
|
hide-bottom-space
|
|
:label="`${'เรื่องร้องเรียน'}`"
|
|
type="textarea"
|
|
/>
|
|
</div>
|
|
<div class="row no-wrap col-12">
|
|
<div class="col-4 q-my-md q-mr-xs">
|
|
<q-select
|
|
for="#fault"
|
|
outlined
|
|
dense
|
|
ref="faultRef"
|
|
v-model="formData.fault"
|
|
:rules="[(val) => !!val || `${'กรุณาเลือกลักษณะความผิด'}`]"
|
|
:options="investigateFactStore.faultOp"
|
|
label="ลักษณะความผิด"
|
|
emit-value
|
|
map-options
|
|
option-label="name"
|
|
option-value="id"
|
|
use-input
|
|
@filter="(inputValue: any,
|
|
doneFn: Function) => filterFnOptionsType(inputValue, doneFn, 'faultOp'
|
|
)"
|
|
><template v-slot:no-option>
|
|
<q-item>
|
|
<q-item-section class="text-grey">
|
|
ไม่มีข้อมูล
|
|
</q-item-section>
|
|
</q-item>
|
|
</template>
|
|
</q-select>
|
|
</div>
|
|
<div class="col-4 q-my-md q-mr-xs">
|
|
<q-select
|
|
for="#investigation"
|
|
outlined
|
|
dense
|
|
ref="investigationRef"
|
|
:rules="[
|
|
(val) => !!val || `${'กรุณาเลือกลักษณะการสืบสวน'}`,
|
|
]"
|
|
v-model="formData.investigation"
|
|
:options="investigateFactStore.investigationOp"
|
|
label="ลักษณะการสืบสวน"
|
|
emit-value
|
|
map-options
|
|
option-label="name"
|
|
option-value="id"
|
|
use-input
|
|
@filter="(inputValue: any,
|
|
doneFn: Function) => filterFnOptionsType(inputValue, doneFn, 'investigationOp'
|
|
)"
|
|
><template v-slot:no-option>
|
|
<q-item>
|
|
<q-item-section class="text-grey">
|
|
ไม่มีข้อมูล
|
|
</q-item-section>
|
|
</q-item>
|
|
</template>
|
|
</q-select>
|
|
</div>
|
|
</div>
|
|
<div
|
|
v-if="formData.investigation === '003'"
|
|
class="col-12 q-mb-md"
|
|
>
|
|
<q-input
|
|
for="#other"
|
|
class="full-width inputgreen cursor-pointer"
|
|
outlined
|
|
ref="otherRef"
|
|
dense
|
|
borderless
|
|
v-model="formData.other"
|
|
hide-bottom-space
|
|
:label="`${'รายการอื่นๆ(โปรดระบุ)'}`"
|
|
type="textarea"
|
|
:rules="[
|
|
(val) =>
|
|
formData.investigation === '003'
|
|
? !!val || 'กรุณาเลือกจำนวนวันที่ต้องการขยาย'
|
|
: true,
|
|
]"
|
|
/>
|
|
</div>
|
|
|
|
<div class="row items-start col-12">
|
|
<p
|
|
class="text-weight-medium q-ma-none text-center align-top q-pt-sm"
|
|
>
|
|
วันที่สืบสวน
|
|
</p>
|
|
<q-checkbox
|
|
for="#clickTime"
|
|
size="md"
|
|
v-model="formData.clickTime"
|
|
label="ขยายเวลา"
|
|
color="primary"
|
|
class="text-weight-medium q-ml-sm"
|
|
keep-color
|
|
/>
|
|
<div v-if="formData.clickTime !== true" class="self-start row">
|
|
<div class="q-mx-xs">
|
|
<datepicker
|
|
menu-class-name="modalfix"
|
|
v-model="formData.date"
|
|
:locale="'th'"
|
|
autoApply
|
|
:enableTimePicker="false"
|
|
week-start="0"
|
|
>
|
|
<template #year="{ year }">{{ year + 543 }}</template>
|
|
<template #year-overlay-value="{ value }">{{
|
|
parseInt(value + 543)
|
|
}}</template>
|
|
<template #trigger>
|
|
<q-input
|
|
for="#date"
|
|
class="full-width inputgreen cursor-pointer"
|
|
ref="dateRef"
|
|
outlined
|
|
dense
|
|
lazy-rules
|
|
borderless
|
|
:model-value="
|
|
formData.date ? date2Thai(formData.date) : null
|
|
"
|
|
:rules="[
|
|
(val) =>
|
|
!!val || `${'กรุณาเลือกวันที่เริ่มการสอบสวน'}`,
|
|
]"
|
|
:label="`${'วันที่เริ่มการสอบสวน'}`"
|
|
>
|
|
<template v-slot:prepend>
|
|
<q-icon
|
|
name="event"
|
|
class="cursor-pointer"
|
|
color="primary"
|
|
>
|
|
</q-icon>
|
|
</template>
|
|
</q-input>
|
|
</template>
|
|
</datepicker>
|
|
</div>
|
|
<div class="q-mx-xs q-">
|
|
<datepicker
|
|
menu-class-name="modalfix"
|
|
v-model="formData.dateEnd"
|
|
:locale="'th'"
|
|
autoApply
|
|
:enableTimePicker="false"
|
|
week-start="0"
|
|
>
|
|
<template #year="{ year }">{{ year + 543 }}</template>
|
|
<template #year-overlay-value="{ value }">{{
|
|
parseInt(value + 543)
|
|
}}</template>
|
|
<template #trigger>
|
|
<q-input
|
|
for="#dateEnd"
|
|
ref="dateEndRef"
|
|
class="full-width inputgreen cursor-pointer"
|
|
outlined
|
|
dense
|
|
lazy-rules
|
|
borderless
|
|
:model-value="
|
|
formData.dateEnd
|
|
? date2Thai(formData.dateEnd)
|
|
: null
|
|
"
|
|
:rules="[
|
|
(val) =>
|
|
!!val || `${'กรุณาเลือกวันที่สิ้นสุดการสอบสวน'}`,
|
|
]"
|
|
:label="`${'วันที่สิ้นสุดการสอบสวน'}`"
|
|
>
|
|
<template v-slot:prepend>
|
|
<q-icon
|
|
name="event"
|
|
class="cursor-pointer"
|
|
color="primary"
|
|
>
|
|
</q-icon>
|
|
</template>
|
|
</q-input>
|
|
</template>
|
|
</datepicker>
|
|
</div>
|
|
</div>
|
|
<div v-else class="q-mx-xs">
|
|
<q-select
|
|
for="#daysExtend"
|
|
outlined
|
|
dense
|
|
lazy-rules
|
|
ref="daysExtendRef"
|
|
v-model="formData.daysExtend"
|
|
:options="investigateFactStore.daysExtendOp"
|
|
label="จำนวนวันที่ต้องการขยาย"
|
|
emit-value
|
|
map-options
|
|
:rules="[
|
|
(val) =>
|
|
formData.clickTime === true
|
|
? !!val || 'กรุณาเลือกจำนวนวันที่ต้องการขยาย'
|
|
: true,
|
|
]"
|
|
option-label="name"
|
|
option-value="id"
|
|
use-input
|
|
@filter="(inputValue: any,
|
|
doneFn: Function) => filterFnOptionsType(inputValue, doneFn, 'daysExtendOp'
|
|
)"
|
|
><template v-slot:no-option>
|
|
<q-item>
|
|
<q-item-section class="text-grey">
|
|
ไม่มีข้อมูล
|
|
</q-item-section>
|
|
</q-item>
|
|
</template>
|
|
</q-select>
|
|
</div>
|
|
</div>
|
|
<div class="col-12 q-my-xs">
|
|
<q-input
|
|
for="#complaintdetail"
|
|
class="full-width inputgreen cursor-pointer"
|
|
outlined
|
|
ref="complaintdetailRef"
|
|
dense
|
|
lazy-rules
|
|
borderless
|
|
v-model="formData.complaintdetail"
|
|
:rules="[
|
|
(val) => !!val || `${'กรุณากรอกรายละเอียดเรื่องร้องเรียน'}`,
|
|
]"
|
|
hide-bottom-space
|
|
:label="`${'รายละเอียดเรื่องร้องเรียน'}`"
|
|
type="textarea"
|
|
/>
|
|
</div>
|
|
<div class="col-12 q-my-sm">
|
|
<q-file
|
|
for="#fileComplaint"
|
|
outlined
|
|
ref="fileComplaintRef"
|
|
dense
|
|
v-model="formData.fileComplaint"
|
|
label="ไฟล์เอกสารหลักฐานเรื่องร้องเรียน"
|
|
lazy-rules
|
|
:rules="[(val) => !!val || 'กรุณาเลือกไฟล์หลักฐานการรับ']"
|
|
hide-bottom-space
|
|
>
|
|
<template v-slot:prepend>
|
|
<q-icon name="attach_file" color="primary" />
|
|
</template>
|
|
</q-file>
|
|
</div>
|
|
<div class="col-12 q-my-sm">
|
|
<q-input
|
|
for="#detail"
|
|
class="full-width inputgreen cursor-pointer"
|
|
outlined
|
|
ref="detailRef"
|
|
dense
|
|
lazy-rules
|
|
borderless
|
|
v-model="formData.detail"
|
|
:rules="[(val) => !!val || `${'กรุณากรอกรายละเอียด'}`]"
|
|
hide-bottom-space
|
|
:label="`${'รายละเอียด'}`"
|
|
type="textarea"
|
|
/>
|
|
</div>
|
|
<div class="col-12 q-my-xs">
|
|
<q-file
|
|
for="#evidenceFiles"
|
|
outlined
|
|
dense
|
|
ref="evidenceFilesRef"
|
|
v-model="formData.evidenceFiles"
|
|
label="ไฟล์หลักฐานการรับ"
|
|
lazy-rules
|
|
:rules="[(val) => !!val || 'กรุณาเลือกไฟล์หลักฐานการรับ']"
|
|
hide-bottom-space
|
|
>
|
|
<template v-slot:prepend>
|
|
<q-icon name="attach_file" color="primary" />
|
|
</template>
|
|
</q-file>
|
|
</div>
|
|
<div class="row col-12 items-start q-mt-sm">
|
|
<div class="col-4">
|
|
<q-input
|
|
for="#results"
|
|
standout
|
|
dense
|
|
ref="resultsRef"
|
|
:rules="[(val) => !!val || `${'กรุณากรอกผลการสืบสวน'}`]"
|
|
v-model="formData.results"
|
|
outlined
|
|
debounce="300"
|
|
placeholder="ผลการสืบสวน"
|
|
>
|
|
</q-input>
|
|
</div>
|
|
<div class="col-4">
|
|
<q-btn
|
|
id="#confirm"
|
|
label="ยืนยันผลการสืบสวน"
|
|
color="public"
|
|
class="q-py-sm q-ml-sm"
|
|
>
|
|
<q-tooltip>ยืนยันผลการสืบสวน</q-tooltip>
|
|
</q-btn>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<q-separator />
|
|
<div class="row col-12 q-pa-sm">
|
|
<q-space />
|
|
<q-btn
|
|
id="onSubmit"
|
|
type="submit"
|
|
flat
|
|
round
|
|
color="secondary"
|
|
icon="mdi-content-save-outline"
|
|
><q-tooltip>บับทึกข้อมูล</q-tooltip></q-btn
|
|
>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</q-card>
|
|
</template>
|