Refactoring code module 11_discipline
This commit is contained in:
parent
202fbf27b6
commit
9653ae78cb
58 changed files with 1021 additions and 1305 deletions
|
|
@ -1,17 +1,17 @@
|
|||
<script setup lang="ts">
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import Form from "@/modules/11_discipline/components/1_Complaint/Form.vue";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useRouter } from "vue-router";
|
||||
import { useQuasar } from "quasar";
|
||||
|
||||
import config from "@/app.config";
|
||||
import http from "@/plugins/http";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
import Form from "@/modules/11_discipline/components/1_Complaint/Form.vue";
|
||||
|
||||
const $q = useQuasar();
|
||||
const mixin = useCounterMixin();
|
||||
|
||||
const { showLoader, hideLoader, success, messageError } = mixin;
|
||||
const router = useRouter();
|
||||
const mixin = useCounterMixin();
|
||||
const { showLoader, hideLoader, success, messageError } = mixin;
|
||||
|
||||
/** บันทึกข้อมูล */
|
||||
async function onSubmit(data: any) {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref } from "vue";
|
||||
import Form from "@/modules/11_discipline/components/1_Complaint/Form.vue";
|
||||
import PopupSendToNext from "@/modules/11_discipline/components/PopupSendToNext.vue";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import { useQuasar } from "quasar";
|
||||
|
||||
import config from "@/app.config";
|
||||
import http from "@/plugins/http";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useDisciplineMainStore } from "@/modules/11_discipline/store/main";
|
||||
|
||||
import type { QTableProps } from "quasar";
|
||||
import type {
|
||||
FormData,
|
||||
|
|
@ -11,11 +15,8 @@ import type {
|
|||
ArrayFileList,
|
||||
} from "@/modules/11_discipline/interface/request/complaint";
|
||||
|
||||
import config from "@/app.config";
|
||||
import http from "@/plugins/http";
|
||||
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useDisciplineMainStore } from "@/modules/11_discipline/store/main";
|
||||
import Form from "@/modules/11_discipline/components/1_Complaint/Form.vue";
|
||||
import PopupSendToNext from "@/modules/11_discipline/components/PopupSendToNext.vue";
|
||||
|
||||
const mainStore = useDisciplineMainStore();
|
||||
const $q = useQuasar();
|
||||
|
|
|
|||
|
|
@ -1,24 +1,23 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, onMounted, reactive, watch, watchEffect } from "vue";
|
||||
import { ref, onMounted, reactive, watch } from "vue";
|
||||
import { useQuasar } from "quasar";
|
||||
import { useRoute } from "vue-router";
|
||||
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useComplainstDataStore } from "@/modules/11_discipline/store/ComplaintsStore";
|
||||
import { useDisciplineMainStore } from "@/modules/11_discipline/store/main";
|
||||
|
||||
import type { OptionData } from "@/modules/07_insignia/interface/index/Main";
|
||||
import type { DataOption } from "@/modules/11_discipline/interface/index/Main";
|
||||
import type {
|
||||
FormData,
|
||||
ArrayFileList,
|
||||
} from "@/modules/11_discipline/interface/request/complaint";
|
||||
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useComplainstDataStore } from "@/modules/11_discipline/store/ComplaintsStore";
|
||||
import { useDisciplineMainStore } from "@/modules/11_discipline/store/main";
|
||||
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
|
||||
import config from "@/app.config";
|
||||
import http from "@/plugins/http";
|
||||
|
||||
import PopupPersonal from "@/components/Dialogs/PopupPersonalNew.vue";
|
||||
import DialogAddPersonal from "@/components/Dialogs/AddPersonal.vue";
|
||||
import type { OptionData } from "@/modules/07_insignia/interface/index/Main";
|
||||
|
||||
const $q = useQuasar();
|
||||
const fileDocDataUpload = ref<File[]>([]);
|
||||
|
|
@ -167,53 +166,6 @@ function confirmDelete(id: string) {
|
|||
.finally(() => {});
|
||||
}
|
||||
|
||||
/**
|
||||
* เช็คข้อมูลจาก props
|
||||
* เมื่อมีข้อมูล
|
||||
* เก็บข้อมูลลง formData
|
||||
*/
|
||||
watch(props.data, async () => {
|
||||
if (props.data !== null) {
|
||||
if (countNum.value === 1) {
|
||||
isReadonly.value = props.data.status != "NEW" ?? true;
|
||||
isSave.value = false;
|
||||
|
||||
fileList.value = props.data.disciplineComplaintDocs;
|
||||
mainStore.fetchData(props.data.persons);
|
||||
|
||||
formData.id = props.data.id;
|
||||
formData.respondentType = props.data.respondentType;
|
||||
formData.organizationId = props.data.organizationId;
|
||||
formData.organization = props.data.organization;
|
||||
organization.value = {
|
||||
id: props.data.organizationId,
|
||||
name: props.data.organization,
|
||||
};
|
||||
formData.consideredAgency = props.data.consideredAgency;
|
||||
formData.consideredAgencyId = props.data.consideredAgencyId;
|
||||
consideredAgency.value = {
|
||||
id: props.data.consideredAgencyId,
|
||||
name: props.data.consideredAgency,
|
||||
};
|
||||
formData.title = props.data.title;
|
||||
formData.description = props.data.description;
|
||||
formData.dateReceived = props.data.dateReceived;
|
||||
formData.dateConsideration = props.data.dateConsideration;
|
||||
formData.offenseDetails = props.data.offenseDetails;
|
||||
formData.levelConsideration = props.data.levelConsideration;
|
||||
formData.dateNotification = props.data.dateNotification;
|
||||
formData.complaintFrom = props.data.complaintFrom;
|
||||
formData.appellant = props.data.appellant;
|
||||
formData.status = props.data.status;
|
||||
formData.result = props.data.result;
|
||||
formData.persons = mainStore.rowsAdd;
|
||||
formData.activeId = props.data.activeId ? props.data.activeId : null;
|
||||
} else if (countNum.value === 2) {
|
||||
fileList.value = props.data.disciplineComplaintDocs;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* ฟังชั่น รับค่าจาก คอมโพเเนน
|
||||
* @param returnData ค่าที่ได้คืนมา
|
||||
|
|
@ -296,12 +248,6 @@ async function getOc(activeId: string) {
|
|||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
|
||||
// http.get(config.API.typeOc()).then((res) => {
|
||||
// const data = res.data.result;
|
||||
// complainstStore.ocListFn(data);
|
||||
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -309,12 +255,10 @@ async function getOc(activeId: string) {
|
|||
* @param id id ของผู้ถูกร้อง
|
||||
*/
|
||||
function deletePerson(id: string) {
|
||||
// dialogRemove($q, () => {
|
||||
const dataRow = mainStore.rowsAdd;
|
||||
const updatedRows = dataRow.filter((item: any) => item.personId !== id);
|
||||
mainStore.rowsAdd = updatedRows;
|
||||
changeFormData();
|
||||
// });
|
||||
}
|
||||
|
||||
/** ช่องทางการร้องเรียน และฟังก์ชั่นการดึงข้อมูลช่องทางการร้องเรียนมาจาก api*/
|
||||
|
|
@ -365,16 +309,7 @@ function updatemodalPersonal(modal: boolean) {
|
|||
modalPersonal.value = modal;
|
||||
}
|
||||
|
||||
/** โหลดข้อมูลเมื่อเข้าหน้านี้ */
|
||||
onMounted(() => {
|
||||
mainStore.rowsAdd = [];
|
||||
getListChannel();
|
||||
|
||||
getActive();
|
||||
});
|
||||
|
||||
const optionOrganization = ref<any[]>(complainstStore.organizationIdOp);
|
||||
|
||||
function filterOptionFnOrganization(val: string, update: Function) {
|
||||
update(() => {
|
||||
optionOrganization.value = complainstStore.organizationIdOp.filter(
|
||||
|
|
@ -383,7 +318,6 @@ function filterOptionFnOrganization(val: string, update: Function) {
|
|||
});
|
||||
}
|
||||
const optionAgency = ref<any[]>(complainstStore.consideredAgencytoptions);
|
||||
|
||||
function filterOptionFnAgency(val: string, update: Function) {
|
||||
update(() => {
|
||||
optionAgency.value = complainstStore.consideredAgencytoptions.filter(
|
||||
|
|
@ -391,6 +325,61 @@ function filterOptionFnAgency(val: string, update: Function) {
|
|||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* เช็คข้อมูลจาก props
|
||||
* เมื่อมีข้อมูล
|
||||
* เก็บข้อมูลลง formData
|
||||
*/
|
||||
watch(props.data, async () => {
|
||||
if (props.data !== null) {
|
||||
if (countNum.value === 1) {
|
||||
isReadonly.value = props.data.status != "NEW" ?? true;
|
||||
isSave.value = false;
|
||||
|
||||
fileList.value = props.data.disciplineComplaintDocs;
|
||||
mainStore.fetchData(props.data.persons);
|
||||
|
||||
formData.id = props.data.id;
|
||||
formData.respondentType = props.data.respondentType;
|
||||
formData.organizationId = props.data.organizationId;
|
||||
formData.organization = props.data.organization;
|
||||
organization.value = {
|
||||
id: props.data.organizationId,
|
||||
name: props.data.organization,
|
||||
};
|
||||
formData.consideredAgency = props.data.consideredAgency;
|
||||
formData.consideredAgencyId = props.data.consideredAgencyId;
|
||||
consideredAgency.value = {
|
||||
id: props.data.consideredAgencyId,
|
||||
name: props.data.consideredAgency,
|
||||
};
|
||||
formData.title = props.data.title;
|
||||
formData.description = props.data.description;
|
||||
formData.dateReceived = props.data.dateReceived;
|
||||
formData.dateConsideration = props.data.dateConsideration;
|
||||
formData.offenseDetails = props.data.offenseDetails;
|
||||
formData.levelConsideration = props.data.levelConsideration;
|
||||
formData.dateNotification = props.data.dateNotification;
|
||||
formData.complaintFrom = props.data.complaintFrom;
|
||||
formData.appellant = props.data.appellant;
|
||||
formData.status = props.data.status;
|
||||
formData.result = props.data.result;
|
||||
formData.persons = mainStore.rowsAdd;
|
||||
formData.activeId = props.data.activeId ? props.data.activeId : null;
|
||||
} else if (countNum.value === 2) {
|
||||
fileList.value = props.data.disciplineComplaintDocs;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/** โหลดข้อมูลเมื่อเข้าหน้านี้ */
|
||||
onMounted(() => {
|
||||
mainStore.rowsAdd = [];
|
||||
getListChannel();
|
||||
|
||||
getActive();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
|||
|
|
@ -32,12 +32,14 @@ const rowsPerPage = ref<number>(10);
|
|||
const toptitle = ref<number>(0);
|
||||
const statusFilter = ref<string>("NEW");
|
||||
const option = ref<any[]>(complainstStore.statusOptions);
|
||||
|
||||
async function updatePagingProp(rowPerpage: number, pageCurrent: number) {
|
||||
rowsPerPage.value = rowPerpage;
|
||||
page.value = pageCurrent;
|
||||
await getList();
|
||||
}
|
||||
|
||||
/** ดึงข้อมูล เรื่องร้องเรียน */
|
||||
async function getList() {
|
||||
showLoader();
|
||||
await http
|
||||
|
|
@ -69,10 +71,7 @@ function redirectToPageadd() {
|
|||
router.push(`/discipline/complaints/add`);
|
||||
}
|
||||
|
||||
function filterFn() {
|
||||
getList();
|
||||
}
|
||||
|
||||
/** ล้างค่าใน input */
|
||||
function resetFilter() {
|
||||
filterKeyword.value = "";
|
||||
if (filterRef.value) {
|
||||
|
|
@ -165,7 +164,7 @@ onMounted(async () => {
|
|||
ref="filterRef"
|
||||
outlined
|
||||
placeholder="ค้นหา"
|
||||
@keydown.enter.prevent="filterFn"
|
||||
@keydown.enter.prevent="getList()"
|
||||
>
|
||||
<template v-slot:append>
|
||||
<q-icon v-if="filterKeyword == ''" name="search" />
|
||||
|
|
|
|||
|
|
@ -145,6 +145,14 @@ function updateProp(newPagination: any, page: number) {
|
|||
emit("update:pagination", newPagination, page);
|
||||
}
|
||||
|
||||
/**
|
||||
* ฟังชั่นสำหรับ เปลี่ยน route ตาม id ที่รับมา
|
||||
* @param id ไอดีระบุ
|
||||
*/
|
||||
function onDetail(id: string) {
|
||||
router.push(`/discipline/complaints-detail/${id}`);
|
||||
}
|
||||
|
||||
watch(
|
||||
() => currentPage.value,
|
||||
() => {
|
||||
|
|
@ -160,14 +168,6 @@ watch(
|
|||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* ฟังชั่นสำหรับ เปลี่ยน route ตาม id ที่รับมา
|
||||
* @param id ไอดีระบุ
|
||||
*/
|
||||
function onDetail(id: string) {
|
||||
router.push(`/discipline/complaints-detail/${id}`);
|
||||
}
|
||||
|
||||
/** เริ่มโหลดหน้า page เอาข้อมูลไปเก็บ ใน store*/
|
||||
onMounted(() => {
|
||||
complainstStore.columns = columns.value;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue