655 lines
23 KiB
Vue
655 lines
23 KiB
Vue
<script setup lang="ts">
|
|
import { useRouter, useRoute } from "vue-router";
|
|
import { onMounted, ref, watch, reactive, computed } 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";
|
|
import { diffDates } from "@fullcalendar/core/internal";
|
|
|
|
const $q = useQuasar();
|
|
const route = useRoute();
|
|
|
|
/**เรียกใช้ store */
|
|
const investigateFactStore = useInvestigateFactStore();
|
|
const mixin = useCounterMixin();
|
|
const { filterFnOptionsType } = investigateFactStore;
|
|
const { date2Thai, dialogConfirm } = mixin;
|
|
|
|
const complaintsOptions = ref<any>([]);
|
|
const isUpdate = ref<boolean>(false);
|
|
|
|
/** ตัวแปร ref สำหรับแสดง validate */
|
|
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 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 statusResultRef = ref<Object | null>(null);
|
|
const causeTextRef = ref<Object | null>(null);
|
|
|
|
/** รับ props มาจากหน้าหลัก */
|
|
const props = defineProps({
|
|
data: {
|
|
type: Object,
|
|
default: null,
|
|
},
|
|
onSubmit: {
|
|
type: Function,
|
|
default: () => "",
|
|
},
|
|
});
|
|
|
|
/** ข้อมูล v-model ของฟอร์ม */
|
|
const formData = reactive<FormData>({
|
|
complaint: "",
|
|
complaintdetail: "",
|
|
detail: "",
|
|
fault: "",
|
|
other: "",
|
|
evidenceFiles: null,
|
|
fileComplaint: null,
|
|
clickTime: false,
|
|
date: null,
|
|
dateEnd: new Date(),
|
|
investigation: "",
|
|
daysExtend: null,
|
|
statusResult: "ยังไม่ระบุ",
|
|
causeText: "",
|
|
complaintStatus: "",
|
|
});
|
|
const evidenceFiles = ref<any>([{ name: "ชื่อไฟล" }, { name: "ชื่อไฟล" }]);
|
|
|
|
/** maping ref เข้าตัวแปรเพื่อเตรียมตรวจสอบ */
|
|
const objectInvestigate: MyObjectInvestigateRef = {
|
|
complaint: complaintRef,
|
|
complaintdetail: complaintdetailRef,
|
|
detail: detailRef,
|
|
fault: faultRef,
|
|
other: otherRef,
|
|
evidenceFiles: evidenceFilesRef,
|
|
fileComplaint: fileComplaintRef,
|
|
date: dateRef,
|
|
dateEnd: dateEndRef,
|
|
investigation: investigationRef,
|
|
daysExtend: daysExtendRef,
|
|
statusResult: statusResultRef,
|
|
causeText: causeTextRef,
|
|
};
|
|
|
|
const statusStep = computed(() => {
|
|
return route.name === "/discipline-disciplinaryEdit" ? true : false;
|
|
});
|
|
|
|
/*** ฟังก์ชั่นสำหรับ validate ฟอร์ม */
|
|
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);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* ฟังก์ชั่นสำหรับบันทึกข้อมูล ระบบจะแสดง dialog ให้ยืนยันการบันทึก
|
|
* หากยืนยันจะส่งข้อมูลไปบันทึกที่ api
|
|
* หากยกเลิกจะกลับไปหน้าฟอร์ม
|
|
*/
|
|
function onSubmit() {
|
|
dialogConfirm(
|
|
$q,
|
|
async () => {
|
|
props.onSubmit(formData);
|
|
},
|
|
"ยืนยันการบันทึกข้อมูล",
|
|
"ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?"
|
|
);
|
|
}
|
|
|
|
/**
|
|
* ฟังชั้นคำนวณเวลาวันที่สิ้นสุดจาก วันที่เริ่ม
|
|
* @param val วันที่เริ่ม
|
|
*/
|
|
function calEndDate(val: string) {
|
|
const date = new Date(props.data.dateEnd);
|
|
const dateNew = new Date();
|
|
formData.dateEnd = new Date(dateNew.setDate(date.getDate() + Number(val)));
|
|
}
|
|
|
|
async function fetchDataDetail() {
|
|
if (props.data !== null) {
|
|
// isUpdate.value = true;
|
|
formData.complaint = props.data.complaint;
|
|
formData.complaintdetail = props.data.complaintdetail;
|
|
formData.detail = props.data.detail;
|
|
formData.fault = props.data.fault;
|
|
formData.other = props.data.other;
|
|
formData.evidenceFiles = props.data.evidenceFiles;
|
|
formData.fileComplaint = props.data.fileComplaint;
|
|
formData.clickTime = props.data.clickTime;
|
|
formData.date = props.data.date;
|
|
formData.dateEnd = props.data.dateEnd;
|
|
formData.investigation = props.data.investigation;
|
|
formData.daysExtend = props.data.daysExtend;
|
|
formData.statusResult = props.data.results;
|
|
formData.causeText = props.data.results;
|
|
}
|
|
}
|
|
onMounted(async () => {
|
|
await fetchDataDetail();
|
|
console.log(route.name);
|
|
});
|
|
|
|
/**
|
|
* เช็คข้อมูลจาก props
|
|
* เมื่อมีข้อมูล
|
|
* เก็บข้อมูลลง formData
|
|
*/
|
|
watch(props.data, async () => {
|
|
if (props.data !== null) {
|
|
isUpdate.value = true;
|
|
formData.complaint = props.data.complaint;
|
|
formData.complaintdetail = props.data.complaintdetail;
|
|
formData.detail = props.data.detail;
|
|
formData.fault = props.data.fault;
|
|
formData.other = props.data.other;
|
|
formData.evidenceFiles = props.data.evidenceFiles;
|
|
formData.fileComplaint = props.data.fileComplaint;
|
|
formData.clickTime = props.data.clickTime;
|
|
formData.date = props.data.date;
|
|
formData.dateEnd = props.data.dateEnd;
|
|
formData.investigation = props.data.investigation;
|
|
formData.daysExtend = props.data.daysExtend;
|
|
formData.statusResult = props.data.results;
|
|
formData.causeText = props.data.results;
|
|
}
|
|
});
|
|
</script>
|
|
<template>
|
|
<q-card flat class="q-mt-sm">
|
|
<form @submit.prevent="validateForm">
|
|
<div class="q-pa-md q-col-gutter-md">
|
|
<div class="col-xs-12 row items-center q-col-gutter-md">
|
|
<!-- <div class="col-6">
|
|
<q-select
|
|
for="#fault"
|
|
outlined
|
|
dense
|
|
ref="complaintRef"
|
|
v-model="formData.complaint"
|
|
:rules="[(val) => !!val || `${'กรุณาเลือกเรื่องร้องเรียน'}`]"
|
|
:options="complaintsOptions"
|
|
label="เรื่องร้องเรียน"
|
|
emit-value
|
|
map-options
|
|
hide-bottom-space
|
|
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-3">
|
|
<q-select
|
|
for="#fault"
|
|
outlined
|
|
dense
|
|
ref="faultRef"
|
|
v-model="formData.fault"
|
|
:rules="[(val) => !!val || `${'กรุณาเลือกลักษณะความผิด'}`]"
|
|
:options="investigateFactStore.faultOp"
|
|
label="ลักษณะความผิด"
|
|
emit-value
|
|
hide-bottom-space
|
|
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-3">
|
|
<q-select
|
|
:readonly="statusStep"
|
|
:disable="statusStep"
|
|
for="#investigation"
|
|
outlined
|
|
hide-bottom-space
|
|
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-input
|
|
for="#other"
|
|
class="full-width 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">
|
|
<q-card bordered class="col-12" style="border: 1px solid #d6dee1">
|
|
<div
|
|
class="col-xs-12 col-sm-12 text-weight-medium bg-grey-1 q-py-sm q-px-md"
|
|
>
|
|
วันที่สืบสวน
|
|
<q-checkbox
|
|
v-if="data != null && statusStep === false"
|
|
for="#clickTime"
|
|
size="md"
|
|
v-model="formData.clickTime"
|
|
label="ขยายเวลา"
|
|
color="primary"
|
|
dense
|
|
class="text-weight-medium q-ml-sm"
|
|
keep-color
|
|
/>
|
|
</div>
|
|
<div class="col-12"><q-separator /></div>
|
|
<div class="q-pa-sm">
|
|
<div class="q-col-gutter-sm row">
|
|
<div class="col-3" v-if="!formData.clickTime">
|
|
<datepicker
|
|
menu-class-name="modalfix"
|
|
:readonly="isUpdate && statusStep"
|
|
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 cursor-pointer"
|
|
ref="dateRef"
|
|
:readonly="statusStep && isUpdate"
|
|
outlined
|
|
dense
|
|
lazy-rules
|
|
borderless
|
|
hide-bottom-space
|
|
: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="col-3" v-if="formData.clickTime">
|
|
<q-select
|
|
for="#daysExtend"
|
|
outlined
|
|
dense
|
|
lazy-rules
|
|
ref="daysExtendRef"
|
|
v-model="formData.daysExtend"
|
|
:options="investigateFactStore.daysExtendOp"
|
|
label="จำนวนวันที่ต้องการขยาย"
|
|
emit-value
|
|
hide-bottom-space
|
|
map-options
|
|
:rules="[
|
|
(val) =>
|
|
formData.clickTime
|
|
? !!val || 'กรุณาเลือกจำนวนวันที่ต้องการขยาย'
|
|
: true,
|
|
]"
|
|
option-label="name"
|
|
option-value="id"
|
|
use-input
|
|
@update:model-value="calEndDate"
|
|
><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-3">
|
|
<datepicker
|
|
menu-class-name="modalfix"
|
|
v-model="formData.dateEnd"
|
|
:readonly="statusStep && isUpdate"
|
|
: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 cursor-pointer"
|
|
:readonly="statusStep && isUpdate"
|
|
outlined
|
|
dense
|
|
lazy-rules
|
|
hide-bottom-space
|
|
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>
|
|
</q-card>
|
|
</div>
|
|
|
|
<!-- <div class="col-12">
|
|
<q-input
|
|
for="#complaintdetail"
|
|
class="full-width 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-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-input
|
|
for="#detail"
|
|
class="full-width 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="row col-12 q-col-gutter-md">
|
|
<div class="col-3">
|
|
<q-select
|
|
for="#fault"
|
|
outlined
|
|
dense
|
|
:readonly="statusStep"
|
|
lazy-rules
|
|
ref="statusResultRef"
|
|
v-model="formData.statusResult"
|
|
:rules="[(val) => !!val || `${'กรุณาเลือกผลการสืบสวน'}`]"
|
|
:options="investigateFactStore.statusResultOptions"
|
|
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 v-if="formData.statusResult == 'have_cause'" class="col-3">
|
|
<q-select
|
|
for="#fault"
|
|
outlined
|
|
dense
|
|
ref="causeTextRef"
|
|
v-model="formData.causeText"
|
|
:rules="[(val) => !!val || `${'กรุณาเลือกร้ายแรง/ไม่ร้ายแรง'}`]"
|
|
:options="investigateFactStore.causeTextOptions"
|
|
label="ร้ายแรง/ไม่ร้ายแรง"
|
|
emit-value
|
|
map-options
|
|
option-label="name"
|
|
option-value="id"
|
|
use-input
|
|
><template v-slot:no-option>
|
|
<q-item>
|
|
<q-item-section class="text-grey">
|
|
ไม่มีข้อมูล
|
|
</q-item-section>
|
|
</q-item>
|
|
</template>
|
|
</q-select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<q-separator />
|
|
<div class="row col-12 q-pa-sm">
|
|
<q-space />
|
|
<q-btn
|
|
id="onSubmit"
|
|
type="submit"
|
|
label="ยืนยันผลการสืบสวน"
|
|
color="secondary"
|
|
><q-tooltip>ยืนยันผลการสืบสวน</q-tooltip></q-btn
|
|
>
|
|
</div>
|
|
</form>
|
|
</q-card>
|
|
<div class="col-12 row q-col-gutter-md q-mt-sm">
|
|
<div class="row col-12">
|
|
<q-card bordered class="row col-12" style="border: 1px solid #d6dee1">
|
|
<div
|
|
class="col-xs-12 col-sm-12 text-weight-medium bg-grey-1 q-py-xs q-px-md"
|
|
>
|
|
อัปโหลดหลักฐานสนับสนุนข้อกล่าวหา
|
|
</div>
|
|
<div class="col-12"><q-separator /></div>
|
|
<div class="col-xs-12 q-pa-sm row">
|
|
<q-file
|
|
class="col-11 q-mt-sm"
|
|
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>
|
|
<q-btn class="col q-mt-sm" flat round color="primary" icon="upload">
|
|
<q-tooltip>อัปโหลดเอกสารหลักฐาน</q-tooltip></q-btn
|
|
>
|
|
</div>
|
|
<div class="col-xs-12 q-pa-sm row">
|
|
<q-list bordered separator class="full-width">
|
|
<q-item
|
|
clickable
|
|
v-ripple
|
|
v-for="(file, index) in evidenceFiles"
|
|
:key="index"
|
|
>
|
|
<q-item-section>{{ file.name + (index + 1) }}</q-item-section>
|
|
<q-item-section avatar>
|
|
<div class="row">
|
|
<div>
|
|
<q-btn
|
|
dense
|
|
flat
|
|
round
|
|
size="12px"
|
|
color="blue"
|
|
icon="mdi-download-outline"
|
|
>
|
|
<q-tooltip>ดาวน์โหลดเอกสารหลักฐาน</q-tooltip>
|
|
</q-btn>
|
|
</div>
|
|
<div>
|
|
<q-btn
|
|
dense
|
|
flat
|
|
round
|
|
size="12px"
|
|
color="red"
|
|
icon="mdi-delete-outline"
|
|
><q-tooltip>ลบเอกสารหลักฐาน</q-tooltip></q-btn
|
|
>
|
|
</div>
|
|
</div>
|
|
</q-item-section>
|
|
</q-item>
|
|
</q-list>
|
|
</div>
|
|
</q-card>
|
|
</div>
|
|
</div>
|
|
</template>
|