validateForm เพิ่มเรื่องร้องเรียน

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2023-10-18 14:41:11 +07:00
parent dd89933261
commit b00a946c64
8 changed files with 302 additions and 62 deletions

View file

@ -1,23 +1,27 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted } from "vue"; import { ref, onMounted } from "vue";
import { useQuasar } from "quasar"; import { useQuasar } from "quasar";
import { useRoute, useRouter } from "vue-router"; import { useRouter } from "vue-router";
import type { DataOption } from "../../interface/index/Main"; // import Type
import type {
DataOption,
MyObjectComplaintsRef,
} from "../../interface/index/Main";
// importStroe // importStroe
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
import { useComplainstDataStore } from "../../stroes/ComplaintsStore"; import { useComplainstDataStore } from "../../stroes/ComplaintsStore";
const route = useRoute();
const $q = useQuasar(); const $q = useQuasar();
const router = useRouter(); const router = useRouter();
const mixin = useCounterMixin(); const mixin = useCounterMixin();
const { date2Thai, dialogConfirm } = mixin; const { date2Thai, dialogConfirm } = mixin; //function stores
const complainstStore = useComplainstDataStore(); const complainstStore = useComplainstDataStore();
const { selectComplainantTpye, filterSelector, fectOptioin } = complainstStore; const { selectComplainantTpye, filterSelector, fectOptioin } = complainstStore; // function store complainstStore
// options
const complainantoptions = ref<DataOption[]>([ const complainantoptions = ref<DataOption[]>([
{ id: "0", name: "บุคคล" }, { id: "0", name: "บุคคล" },
{ id: "1", name: "หน่ายงาน" }, { id: "1", name: "หน่ายงาน" },
@ -67,15 +71,15 @@ const fileDocDataUpload = ref<File[]>([]);
onMounted(() => { onMounted(() => {
fectOptioin(complainantoptions.value, agencytoptions.value); fectOptioin(complainantoptions.value, agencytoptions.value);
}); });
//
async function selectComplainant(val: string) { async function selectComplainant(val: string) {
complainant.value = ""; complainant.value = "";
office.value = ""; office.value = "";
agency.value = ""; agency.value = "";
if (val === "0") { if (val === "0") {
await fectListname(); await fectListname(); // function fectListname
} else if (val === "1") { } else if (val === "1") {
await fectOffice(); await fectOffice(); // function fectOffice
} }
} }
// //
@ -96,6 +100,7 @@ async function fectListname() {
]; ];
selectComplainantTpye(listName); selectComplainantTpye(listName);
} }
//
async function fectOffice() { async function fectOffice() {
// const listOffice = [ // const listOffice = [
// { // {
@ -112,22 +117,23 @@ async function fectOffice() {
// }, // },
// ]; // ];
} }
//
const fileUploadDoc = async (files: any) => { const fileUploadDoc = async (files: any) => {
files.forEach((file: any) => { files.forEach((file: any) => {
fileDocDataUpload.value.push(file); fileDocDataUpload.value.push(file);
}); });
}; };
//
function selectLevel(val: string) { function selectLevel(val: string) {
let dayNum = 0; let dayNum = 0;
if (val == "0") { if (val == "0") {
dayNum = 45; dayNum = 45; //
} else if (val == "1") { } else if (val == "1") {
dayNum = 30; dayNum = 30; //
} else { } else {
dayNum = 15; dayNum = 15; //
} }
//
if (dateconsideration.value) { if (dateconsideration.value) {
const currentDate = new Date(dateconsideration.value); const currentDate = new Date(dateconsideration.value);
const newDate = new Date( const newDate = new Date(
@ -136,7 +142,56 @@ function selectLevel(val: string) {
datewarn.value = newDate; datewarn.value = newDate;
} }
} }
// validateForm
const complainantTypeRef = ref<any>(null);
const complainantRef = ref<any>(null);
const officeRef = ref<any>(null);
const agencyRef = ref<any>(null);
const topicComplaintRef = ref<any>(null);
const detailRef = ref<any>(null);
const datereceiveRef = ref<any>();
const dateconsiderationRef = ref<any>(null);
const offenseDescriptionRef = ref<any>(null);
const considerationLevelRef = ref<any>(null);
const datewarnRef = ref<any>(null);
const receivecomplaintsRef = ref<any>(null);
const petitionerRef = ref<any>(null);
const filesRef = ref<any>(null);
const objectComplaintsRef: MyObjectComplaintsRef = {
complainantType: complainantTypeRef,
complainant: complainantRef,
office: officeRef,
agency: agencyRef,
topicComplaint: topicComplaintRef,
detail: detailRef,
datereceive: datereceiveRef,
dateconsideration: dateconsiderationRef,
offenseDescription: offenseDescriptionRef,
considerationLevel: considerationLevelRef,
datewarn: datewarnRef,
receivecomplaints: receivecomplaintsRef,
petitioner: petitionerRef,
files: filesRef,
};
function validateForm() {
const hasError = [];
for (const key in objectComplaintsRef) {
if (Object.prototype.hasOwnProperty.call(objectComplaintsRef, key)) {
const property = objectComplaintsRef[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("ไม่ผ่าน ");
}
}
//
function onSubmit() { function onSubmit() {
dialogConfirm( dialogConfirm(
$q, $q,
@ -162,13 +217,14 @@ function onSubmit() {
</div> </div>
<div class="col-12 q-mt-sm"> <div class="col-12 q-mt-sm">
<q-card flat bordered> <q-card flat bordered>
<q-form @submit.prevent="onSubmit"> <form @submit.prevent="validateForm">
<div class="col-12 row q-pa-md"> <div class="col-12 row q-pa-md">
<div <div
class="col-xs-12 col-sm-12 row q-col-gutter-x-md q-col-gutter-y-xs" class="col-xs-12 col-sm-12 row q-col-gutter-x-md q-col-gutter-y-xs"
> >
<div class="col-xs-12 col-sm-2"> <div class="col-xs-12 col-sm-2">
<q-select <q-select
ref="complainantTypeRef"
dense dense
outlined outlined
v-model="complainantType" v-model="complainantType"
@ -185,26 +241,58 @@ function onSubmit() {
@filter="(inputValue: any, @filter="(inputValue: any,
doneFn: Function) => filterSelector(inputValue, doneFn, 'filtercomplainantType' doneFn: Function) => filterSelector(inputValue, doneFn, 'filtercomplainantType'
)" )"
/> >
<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-xs-12 col-sm-2" v-if="complainantType === '0'"> <div class="col-xs-12 col-sm-2" v-if="complainantType === '0'">
<q-select <q-select
ref="complainantRef"
dense dense
outlined outlined
v-model="complainant" v-model="complainant"
:options="complainstStore.optionListName" :options="complainstStore.optionListName"
label="ราชชื่อจากทะเบียรประวัติ" label="ราชื่อจากทะเบียรประวัติ"
option-value="id" option-value="id"
option-label="name" option-label="name"
emit-value emit-value
map-options map-options
/> :rules="[(val) => !!val || `${'กรุณาเลือกรายชื่อ'}`]"
lazy-rules
use-input
@filter="(inputValue: any,
doneFn: Function) => filterSelector(inputValue, doneFn, 'filtercomplainantOP'
)"
><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-xs-12 col-sm-2" v-if="complainantType === '1'"> <div class="col-xs-12 col-sm-2" v-if="complainantType === '1'">
<q-input dense outlined v-model="office" label="เลือกสำนักงาน" /> <q-input
ref="officeRef"
dense
outlined
v-model="office"
label="เลือกสำนักงาน"
:rules="[(val) => !!val || `${'กรุณาเลือกสำนักงาน'}`]"
lazy-rules
/>
</div> </div>
<div class="col-xs-12 col-sm-2"> <div class="col-xs-12 col-sm-2">
<q-select <q-select
ref="agencyRef"
dense dense
outlined outlined
v-model="agency" v-model="agency"
@ -220,10 +308,19 @@ function onSubmit() {
@filter="(inputValue: any, @filter="(inputValue: any,
doneFn: Function) => filterSelector(inputValue, doneFn, 'filteragencytoptions' doneFn: Function) => filterSelector(inputValue, doneFn, 'filteragencytoptions'
)" )"
/> >
<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-xs-12 col-sm-12"> <div class="col-xs-12 col-sm-12">
<q-input <q-input
ref="topicComplaintRef"
dense dense
outlined outlined
v-model="topicComplaint" v-model="topicComplaint"
@ -236,6 +333,7 @@ function onSubmit() {
</div> </div>
<div class="col-xs-12 col-sm-12"> <div class="col-xs-12 col-sm-12">
<q-input <q-input
ref="detailRef"
dense dense
outlined outlined
v-model="detail" v-model="detail"
@ -264,6 +362,7 @@ function onSubmit() {
</template> </template>
<template #trigger> <template #trigger>
<q-input <q-input
ref="datereceiveRef"
outlined outlined
dense dense
class="full-width datepicker" class="full-width datepicker"
@ -306,6 +405,7 @@ function onSubmit() {
</template> </template>
<template #trigger> <template #trigger>
<q-input <q-input
ref="dateconsiderationRef"
outlined outlined
dense dense
class="full-width datepicker" class="full-width datepicker"
@ -334,6 +434,7 @@ function onSubmit() {
</div> </div>
<div class="col-xs-12 col-sm-2"> <div class="col-xs-12 col-sm-2">
<q-select <q-select
ref="offenseDescriptionRef"
dense dense
outlined outlined
v-model="offenseDescription" v-model="offenseDescription"
@ -349,6 +450,7 @@ function onSubmit() {
</div> </div>
<div class="col-xs-12 col-sm-2"> <div class="col-xs-12 col-sm-2">
<q-select <q-select
ref="considerationLevelRef"
dense dense
outlined outlined
v-model="considerationLevel" v-model="considerationLevel"
@ -382,6 +484,7 @@ function onSubmit() {
</template> </template>
<template #trigger> <template #trigger>
<q-input <q-input
ref="datewarnRef"
outlined outlined
dense dense
class="full-width datepicker" class="full-width datepicker"
@ -407,6 +510,7 @@ function onSubmit() {
</div> </div>
<div class="col-xs-12 col-sm-2"> <div class="col-xs-12 col-sm-2">
<q-select <q-select
ref="receivecomplaintsRef"
dense dense
outlined outlined
v-model="receivecomplaints" v-model="receivecomplaints"
@ -423,6 +527,7 @@ function onSubmit() {
<div class="col-xs-12 col-sm-6"></div> <div class="col-xs-12 col-sm-6"></div>
<div class="col-xs-12 col-sm-4"> <div class="col-xs-12 col-sm-4">
<q-input <q-input
ref="petitionerRef"
dense dense
outlined outlined
v-model="petitioner" v-model="petitioner"
@ -433,6 +538,7 @@ function onSubmit() {
</div> </div>
<div class="col-xs-12 col-sm-4"> <div class="col-xs-12 col-sm-4">
<q-file <q-file
ref="filesRef"
class="col-xs-12 col-sm-10" class="col-xs-12 col-sm-10"
outlined outlined
dense dense
@ -443,6 +549,7 @@ function onSubmit() {
lazy-rules lazy-rules
accept=".pdf,.xlsx,.doc" accept=".pdf,.xlsx,.doc"
clearable clearable
:rules="[(val) => !!val || `${'กรุณาเพิ่มไฟล์เอกสารหลักฐาน'}`]"
> >
<template v-slot:prepend> <template v-slot:prepend>
<q-icon name="attach_file" /> <q-icon name="attach_file" />
@ -463,7 +570,7 @@ function onSubmit() {
><q-tooltip>บทกขอม</q-tooltip></q-btn ><q-tooltip>บทกขอม</q-tooltip></q-btn
> >
</div> </div>
</q-form> </form>
</q-card> </q-card>
</div> </div>
</template> </template>

View file

@ -7,7 +7,7 @@ import { useComplainstDataStore } from "../../stroes/ComplaintsStore";
const router = useRouter(); const router = useRouter();
const complainstStore = useComplainstDataStore(); const complainstStore = useComplainstDataStore();
const { fectComplainst } = complainstStore; const { fectComplainst } = complainstStore; // function stores
// Table // Table
const filterTable = ref<string>(""); const filterTable = ref<string>("");
@ -99,6 +99,7 @@ onMounted(async () => {
await fecthListComplaints(); await fecthListComplaints();
}); });
//
async function fecthListComplaints() { async function fecthListComplaints() {
const listData = [ const listData = [
{ {

View file

@ -8,8 +8,9 @@ import { useOrderStore } from "../../stroes/OrderStore";
const router = useRouter(); const router = useRouter();
const OrderStore = useOrderStore(); const OrderStore = useOrderStore();
const { fecthOrder } = OrderStore; const { fecthOrder } = OrderStore; // function stores
// table
const columns = ref<QTableProps["columns"]>([ const columns = ref<QTableProps["columns"]>([
{ {
name: "subject", name: "subject",
@ -74,13 +75,13 @@ const visibleColumns = ref<string[]>([
"signer", "signer",
"statusorder", "statusorder",
]); ]);
const filterTable = ref<string>(""); const filterTable = ref<string>("");
onMounted(async () => { onMounted(async () => {
await fecthListOrder(); await fecthListOrder();
}); });
// API
async function fecthListOrder() { async function fecthListOrder() {
const listData = [ const listData = [
{ {
@ -108,9 +109,10 @@ async function fecthListOrder() {
statusorder: "เสร็จสิ้นแล้ว", statusorder: "เสร็จสิ้นแล้ว",
}, },
]; ];
await fecthOrder(listData); await fecthOrder(listData); // stores
} }
// redirect
function redirectToPageadd() { function redirectToPageadd() {
router.push(`/discipline-order/add`); router.push(`/discipline-order/add`);
} }

View file

@ -2,6 +2,7 @@
import { ref } from "vue"; import { ref } from "vue";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
// import step
import step01 from "./Step01.vue"; import step01 from "./Step01.vue";
import step02 from "./Step02.vue"; import step02 from "./Step02.vue";
import step03 from "./Step03.vue"; import step03 from "./Step03.vue";
@ -9,11 +10,12 @@ import step03 from "./Step03.vue";
const router = useRouter(); const router = useRouter();
const step = ref<number>(1); const step = ref<number>(1);
// nextStep
const nextStep = async () => { const nextStep = async () => {
localStorage.setItem("currentStep", step.value.toString()); localStorage.setItem("currentStep", step.value.toString());
step.value++; step.value++;
}; };
// previousStep
const previousStep = async () => { const previousStep = async () => {
localStorage.setItem("currentStep", step.value.toString()); localStorage.setItem("currentStep", step.value.toString());
step.value--; step.value--;

View file

@ -2,7 +2,7 @@
import { ref } from "vue"; import { ref } from "vue";
import { useQuasar } from "quasar"; import { useQuasar } from "quasar";
import type { DataOption } from "../../interface/index/Main"; import type { DataOption, MyObjectRef } from "../../interface/index/Main";
// importStroe // importStroe
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
@ -21,7 +21,7 @@ const props = defineProps({
}, },
}); });
const next = () => props.next(); const next = () => props.next();
// Options
const orderTypeOptions = ref<DataOption[]>([ const orderTypeOptions = ref<DataOption[]>([
{ id: "0", name: "ประเภทคำสั่ง 1" }, { id: "0", name: "ประเภทคำสั่ง 1" },
{ id: "1", name: "ประเภทคำสั่ง 2" }, { id: "1", name: "ประเภทคำสั่ง 2" },
@ -37,7 +37,7 @@ const listInvestigationOptions = ref<DataOption[]>([
{ id: "1", name: "รายการสอบสวนความผิดทางวินัย 2" }, { id: "1", name: "รายการสอบสวนความผิดทางวินัย 2" },
{ id: "2", name: "รายการสอบสวนความผิดทางวินัย 3" }, { id: "2", name: "รายการสอบสวนความผิดทางวินัย 3" },
]); ]);
//
const orderType = ref<string>(""); const orderType = ref<string>("");
const orderBy = ref<string>(""); const orderBy = ref<string>("");
const listInvestigation = ref<string>(""); const listInvestigation = ref<string>("");
@ -49,6 +49,47 @@ const authorityPosition = ref<string>("");
const subject = ref<string>(""); const subject = ref<string>("");
const mistakeDetail = ref<string>(""); const mistakeDetail = ref<string>("");
// validateForm
const orderTypeRef = ref<any>(null);
const orderByRef = ref<any>(null);
const listInvestigationRef = ref<any>(null);
const authorityRef = ref<any>(null);
const orderNumberRef = ref<any>(null);
const dateYearRef = ref<any>(null);
const dateRef = ref<any>(null);
const authorityPositionRef = ref<any>(null);
const subjectRef = ref<any>(null);
const mistakeDetailRef = ref<any>(null);
const myObjectRef: MyObjectRef = {
orderType: orderTypeRef,
orderBy: orderByRef,
listInvestigation: listInvestigationRef,
authority: authorityRef,
orderNumber: orderNumberRef,
dateYear: dateYearRef,
date: dateRef,
authorityPosition: authorityPositionRef,
subject: subjectRef,
mistakeDetail: mistakeDetailRef,
};
function validateForm() {
const hasError = [];
for (const key in myObjectRef) {
if (Object.prototype.hasOwnProperty.call(myObjectRef, key)) {
const property = myObjectRef[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("ไม่ผ่าน ");
}
}
function onSubmit() { function onSubmit() {
dialogConfirm( dialogConfirm(
$q, $q,
@ -62,12 +103,13 @@ function onSubmit() {
</script> </script>
<template> <template>
<q-form @submit.prevent="onSubmit"> <form @submit.prevent.stop="validateForm">
<div class="col-12 row q-pa-lg"> <div class="col-12 row q-pa-lg">
<div class="col-xs-12 col-sm-12 q-col-gutter-x-lg row q-col-gutter-y-xs"> <div class="col-xs-12 col-sm-12 q-col-gutter-x-lg row q-col-gutter-y-xs">
<div class="col-xs-12 col-sm-6"> <div class="col-xs-12 col-sm-6">
ประเภทคำส ประเภทคำส
<q-select <q-select
ref="orderTypeRef"
dense dense
outlined outlined
v-model="orderType" v-model="orderType"
@ -84,6 +126,7 @@ function onSubmit() {
<div class="col-xs-12 col-sm-6"> <div class="col-xs-12 col-sm-6">
คำสงโดย คำสงโดย
<q-select <q-select
ref="orderByRef"
dense dense
outlined outlined
v-model="orderBy" v-model="orderBy"
@ -100,6 +143,7 @@ function onSubmit() {
<div class="col-xs-12 col-sm-6"> <div class="col-xs-12 col-sm-6">
เลอกรายการสอบสวนความผดทางว เลอกรายการสอบสวนความผดทางว
<q-select <q-select
ref="listInvestigationRef"
dense dense
outlined outlined
v-model="listInvestigation" v-model="listInvestigation"
@ -118,6 +162,7 @@ function onSubmit() {
<div class="col-xs-12 col-sm-6"> <div class="col-xs-12 col-sm-6">
อำนาจลงนาม อำนาจลงนาม
<q-input <q-input
ref="authorityRef"
dense dense
outlined outlined
v-model="authority" v-model="authority"
@ -130,6 +175,7 @@ function onSubmit() {
<div class="col-6"> <div class="col-6">
คำสงท คำสงท
<q-input <q-input
ref="orderNumberRef"
outlined outlined
dense dense
v-model="orderNumber" v-model="orderNumber"
@ -157,6 +203,7 @@ function onSubmit() {
}}</template> }}</template>
<template #trigger> <template #trigger>
<q-input <q-input
ref="dateYearRef"
:model-value="dateYear + 543" :model-value="dateYear + 543"
:rules="[(val) => !!val || `${'กรุณากรอก พ.ศ.'}`]" :rules="[(val) => !!val || `${'กรุณากรอก พ.ศ.'}`]"
:label="`${'พ.ศ.'}`" :label="`${'พ.ศ.'}`"
@ -187,6 +234,7 @@ function onSubmit() {
</template> </template>
<template #trigger> <template #trigger>
<q-input <q-input
ref="dateRef"
outlined outlined
dense dense
class="full-width datepicker" class="full-width datepicker"
@ -208,6 +256,7 @@ function onSubmit() {
<div class="col-xs-12 col-sm-6"> <div class="col-xs-12 col-sm-6">
ตำแหนงผอำนาจลงนาม ตำแหนงผอำนาจลงนาม
<q-input <q-input
ref="authorityPositionRef"
dense dense
outlined outlined
v-model="authorityPosition" v-model="authorityPosition"
@ -219,6 +268,7 @@ function onSubmit() {
<div class="col-xs-12 col-sm-6"> <div class="col-xs-12 col-sm-6">
คำสงเรอง คำสงเรอง
<q-input <q-input
ref="subjectRef"
dense dense
outlined outlined
v-model="subject" v-model="subject"
@ -230,6 +280,7 @@ function onSubmit() {
<div class="col-xs-12 col-sm-12"> <div class="col-xs-12 col-sm-12">
รายละเอยดการกระทำความผ รายละเอยดการกระทำความผ
<q-input <q-input
ref="mistakeDetailRef"
dense dense
outlined outlined
v-model="mistakeDetail" v-model="mistakeDetail"
@ -252,7 +303,7 @@ function onSubmit() {
type="submit" type="submit"
/> />
</q-card-actions> </q-card-actions>
</q-form> </form>
</template> </template>
<style scoped></style> <style scoped></style>

View file

@ -1,4 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from "vue";
const props = defineProps({ const props = defineProps({
next: { next: {
type: Function, type: Function,
@ -11,10 +12,79 @@ const props = defineProps({
}); });
const next = () => props.next(); const next = () => props.next();
const previous = () => props.previous(); const previous = () => props.previous();
const name = ref<string>("");
const lastname = ref<string>("");
const age = ref<string>("");
const nameRef = ref<any>(null);
const ageRef = ref<any>(null);
const lastnameRef = ref<any>(null);
const myObject: MyObject = {
name: nameRef,
lastname: lastnameRef,
age: ageRef,
};
interface MyObject {
name: any;
lastname: any;
age: any;
[key: string]: any;
}
function onSubmit() {
const hasError = [];
for (const key in myObject) {
if (Object.prototype.hasOwnProperty.call(myObject, key)) {
const property = myObject[key];
if (property.value && typeof property.value.validate === "function") {
const isValid = property.value.validate();
hasError.push(isValid);
}
}
}
if (hasError.every((result) => result === true)) {
console.log("ผ่าน สำเร็จ!");
} else {
console.log("ไม่ผ่าน ");
}
}
</script> </script>
<template> <template>
<div><h1>step02</h1></div> <div><h1>step02</h1></div>
<form @submit.prevent.stop="onSubmit" class="q-gutter-md">
<q-input
ref="nameRef"
filled
v-model="name"
label="Your name *"
hint="Name and surname"
lazy-rules
:rules="[(val) => !!val || `${'Name and surname'}`]"
/>
<q-input
ref="lastnameRef"
filled
v-model="lastname"
label="lastname *"
lazy-rules
:rules="[(val) => !!val || `${'lastname'}`]"
/>
<q-input
ref="ageRef"
filled
type="number"
v-model="age"
label="Your age *"
lazy-rules
:rules="[(val) => !!val || `${'Your age'}`]"
/>
<div>
<q-btn label="Submit" type="submit" color="primary" />
</div>
</form>
<q-card-actions align="right"> <q-card-actions align="right">
<q-btn <q-btn
dense dense

View file

@ -22,11 +22,28 @@ interface MyObjectRef {
mistakeDetail: any, mistakeDetail: any,
[key: string]: any; [key: string]: any;
} }
interface MyObjectComplaintsRef {
complainantType: any
complainant: any
office: any
agency: any
topicComplaint: any
datereceive: any
dateconsideration: any
offenseDescription: any
considerationLevel: any
datewarn: any
receivecomplaints: any
petitioner: any
files: any
[key: string]: any;
}
export type { export type {
DataOption, DataOption,
investigatefactsDataRowType, investigatefactsDataRowType,
MyObjectRef, MyObjectRef,
MyObjectComplaintsRef,
}; };

View file

@ -5,7 +5,7 @@ import type { DataOption } from "../interface/index/Main";
export const useComplainstDataStore = defineStore("DisciplineComplainst", () => { export const useComplainstDataStore = defineStore("DisciplineComplainst", () => {
const rows = ref<any>([]) const rows = ref<any>([])
const optionListName = ref<any>([{}])
function fectComplainst(data: any) { function fectComplainst(data: any) {
@ -21,49 +21,39 @@ export const useComplainstDataStore = defineStore("DisciplineComplainst", () =>
rows.value = datalist rows.value = datalist
} }
function selectComplainantTpye(list: any) {
optionListName.value = list
}
const complainantoptionsMain = ref<DataOption[]>() const complainantoptionsMain = ref<DataOption[]>()
const complainantoptions = ref<DataOption[]>() const complainantoptions = ref<DataOption[]>()
const agencytoptionsMain = ref<DataOption[]>() const agencytoptionsMain = ref<DataOption[]>()
const agencytoptions = ref<DataOption[]>() const agencytoptions = ref<DataOption[]>()
const optionListNameMain = ref<DataOption[]>([])
const optionListName = ref<DataOption[]>([])
function fectOptioin(complainantoptions: any, agencytoptions: any) { function fectOptioin(complainantoptions: any, agencytoptions: any) {
complainantoptionsMain.value = complainantoptions complainantoptionsMain.value = complainantoptions
agencytoptionsMain.value = agencytoptions agencytoptionsMain.value = agencytoptions
}
function selectComplainantTpye(list: any) {
optionListNameMain.value = list
optionListName.value = list
} }
function filterSelector(val: any, update: Function, type: string) { function filterSelector(val: any, update: Function, type: string) {
console.log(val, type); update(() => {
let data: DataOption[] | undefined = undefined; if (type === "filtercomplainantType" && complainantoptionsMain.value) {
let filter: DataOption[] | undefined = undefined; complainantoptions.value = complainantoptionsMain.value.filter(
if (type == "filtercomplainantType") { (e) => e.name.search(val) !== -1
data = complainantoptionsMain.value );
} else if (type == "filteragencytoptions") { } else if (type === "filteragencytoptions" && agencytoptionsMain.value) {
data = agencytoptionsMain.value agencytoptions.value = agencytoptionsMain.value.filter(
} (e) => e.name.search(val) !== -1
if (val == "") { );
update(() => { } else if (type === "filtercomplainantOP" && optionListNameMain.value) {
filter = data; optionListName.value = optionListNameMain.value.filter(
}); (e) => e.name.search(val) !== -1
} else { );
update(() => {
if (data) {
filter = data.filter(
(e) => e.name.search(val) !== -1
);
}
});
}
if (filter) {
if (type == "filtercomplainantType") {
complainantoptions.value = filter
} else if (type = "filteragencytoptions") {
agencytoptions.value = filter
} }
}
})
} }
return { return {
rows, rows,