fixing ระบบวินัย
This commit is contained in:
parent
e9ee7e7f40
commit
ba728ea000
16 changed files with 391 additions and 442 deletions
|
|
@ -18,46 +18,7 @@ async function onSubmit(data: any) {
|
|||
/** post */
|
||||
showLoader();
|
||||
http
|
||||
.post(config.API.complaintAdd(), {
|
||||
id: data.id,
|
||||
respondentType: data.respondentType,
|
||||
organizationId: data.organizationId,
|
||||
consideredAgency: data.consideredAgency,
|
||||
title: data.title,
|
||||
description: data.description,
|
||||
dateReceived: data.dateReceived,
|
||||
dateConsideration: data.dateConsideration,
|
||||
offenseDetails: data.offenseDetails,
|
||||
levelConsideration: data.levelConsideration,
|
||||
dateNotification: data.dateNotification,
|
||||
complaintFrom: data.complaintFrom,
|
||||
appellant: data.appellant,
|
||||
documentFile: data.documentFile,
|
||||
status: data.status,
|
||||
result: data.result,
|
||||
persons: data.persons.map((item: any) => ({
|
||||
personId: item.personId,
|
||||
idcard: item.idcard,
|
||||
prefix: item.prefix,
|
||||
firstName: item.firstName,
|
||||
lastName: item.lastName,
|
||||
name: item.name,
|
||||
posNo: item.posNo === "-" ? null : item.posNo,
|
||||
position: item.position,
|
||||
positionLevel: item.positionLevel,
|
||||
salary: item.salary === "-" ? null : item.salary,
|
||||
organization: item.organization,
|
||||
phone: item.phone === "-" ? null : item.phone,
|
||||
email: item.email,
|
||||
})),
|
||||
disciplineComplaintDocs: data.disciplineComplaintDocs.map(
|
||||
(file: any) => ({
|
||||
id: file.id,
|
||||
fileName: file.fileName,
|
||||
pathName: file.pathName,
|
||||
})
|
||||
),
|
||||
})
|
||||
.post(config.API.complaintAdd(), data)
|
||||
.then((res) => {
|
||||
success($q, "บันทึกข้อมูลสำเร็จ");
|
||||
router.push(`/discipline/complaints/${res.data.result}`);
|
||||
|
|
@ -70,6 +31,7 @@ async function onSubmit(data: any) {
|
|||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="col-xs-12 col-sm-12 col-md-11">
|
||||
<div class="toptitle text-dark col-12 row items-center">
|
||||
|
|
|
|||
|
|
@ -168,7 +168,9 @@ async function getData() {
|
|||
data.id = dataList.id;
|
||||
data.respondentType = dataList.respondentType;
|
||||
data.organizationId = dataList.organizationId;
|
||||
data.organization = dataList.organization;
|
||||
data.consideredAgency = dataList.consideredAgency;
|
||||
data.consideredAgencyId = dataList.consideredAgencyId;
|
||||
data.title = dataList.title;
|
||||
data.description = dataList.description;
|
||||
data.dateReceived = dataList.dateReceived;
|
||||
|
|
@ -182,6 +184,7 @@ async function getData() {
|
|||
data.persons = dataList.persons;
|
||||
data.result = dataList.result;
|
||||
data.disciplineComplaintDocs = dataList.disciplineComplaintDocs;
|
||||
data.activeId = dataList.activeId;
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
|
|
@ -197,47 +200,9 @@ async function getData() {
|
|||
*/
|
||||
async function onSubmit(data: any) {
|
||||
showLoader();
|
||||
|
||||
http
|
||||
.put(config.API.complaintbyId(id.value), {
|
||||
id: data.id,
|
||||
respondentType: data.respondentType,
|
||||
organizationId: data.organizationId,
|
||||
consideredAgency: data.consideredAgency,
|
||||
title: data.title,
|
||||
description: data.description,
|
||||
dateReceived: data.dateReceived,
|
||||
dateConsideration: data.dateConsideration,
|
||||
offenseDetails: data.offenseDetails,
|
||||
levelConsideration: data.levelConsideration,
|
||||
dateNotification: data.dateNotification,
|
||||
complaintFrom: data.complaintFrom,
|
||||
appellant: data.appellant,
|
||||
documentFile: data.documentFile,
|
||||
status: data.status,
|
||||
result: data.result,
|
||||
persons: data.persons.map((item: any) => ({
|
||||
personId: item.personId,
|
||||
idcard: item.idcard,
|
||||
prefix: item.prefix,
|
||||
firstName: item.firstName,
|
||||
lastName: item.lastName,
|
||||
name: item.name,
|
||||
posNo: item.posNo === "-" ? null : item.posNo,
|
||||
position: item.position,
|
||||
positionLevel: item.positionLevel,
|
||||
salary: item.salary === "-" ? null : item.salary,
|
||||
organization: item.organization,
|
||||
phone: item.phone === "-" ? null : item.phone,
|
||||
email: item.email,
|
||||
})),
|
||||
disciplineComplaintDocs: data.disciplineComplaintDocs.map(
|
||||
(file: any) => ({
|
||||
id: file.id,
|
||||
fileName: file.fileName,
|
||||
pathName: file.pathName,
|
||||
})
|
||||
),
|
||||
})
|
||||
.put(config.API.complaintbyId(id.value), data)
|
||||
.then((res) => {
|
||||
getData();
|
||||
success($q, "บันทึกข้อมูลสำเร็จ");
|
||||
|
|
@ -406,7 +371,9 @@ onMounted(() => {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<q-card bordered><Form :on-submit="onSubmit" :data="data" :get-data="getData" /></q-card>
|
||||
<q-card bordered
|
||||
><Form :on-submit="onSubmit" :data="data" :get-data="getData"
|
||||
/></q-card>
|
||||
<PopupSendToNext
|
||||
:modal="modalPopup"
|
||||
:close="closePopup"
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import { useQuasar } from "quasar";
|
|||
import type { DataOption } from "@/modules/11_discipline/interface/index/Main";
|
||||
import type {
|
||||
FormData,
|
||||
MyObjectComplaintsRef,
|
||||
ArrayFileList,
|
||||
} from "@/modules/11_discipline/interface/request/complaint";
|
||||
|
||||
|
|
@ -17,6 +16,7 @@ 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[]>([]);
|
||||
|
|
@ -28,6 +28,8 @@ const mainStore = useDisciplineMainStore();
|
|||
const complainstStore = useComplainstDataStore();
|
||||
const modalPersonal = ref<boolean>(false);
|
||||
const personId = ref<string>("");
|
||||
const organization = ref<OptionData>();
|
||||
const consideredAgency = ref<OptionData>();
|
||||
|
||||
/**ชั่งฟังเพิ่มข้อมูล ลง ตาราง */
|
||||
const modal = ref<boolean>(false);
|
||||
|
|
@ -43,21 +45,6 @@ const {
|
|||
} = mixin;
|
||||
const { filterSelector } = complainstStore; // function จาก store complainstStore
|
||||
|
||||
/** validateForm */
|
||||
const respondentTypeRef = ref<Object | null>(null);
|
||||
const organizationIdRef = ref<Object | null>(null);
|
||||
const consideredAgencyRef = ref<Object | null>(null);
|
||||
const titleRef = ref<Object | null>(null);
|
||||
const descriptionRef = ref<Object | null>(null);
|
||||
const dateReceivedRef = ref<Object | null>();
|
||||
const dateConsiderationRef = ref<Object | null>(null);
|
||||
const offenseDetailsRef = ref<Object | null>(null);
|
||||
const levelConsiderationRef = ref<Object | null>(null);
|
||||
const dateNotificationRef = ref<Object | null>(null);
|
||||
const complaintFromRef = ref<Object | null>(null);
|
||||
const appellantRef = ref<Object | null>(null);
|
||||
const resultRef = ref<Object | null>(null);
|
||||
|
||||
const isSave = ref<boolean>(false); // มีการแก้ไขรอบันทึก
|
||||
const isReadonly = ref<boolean>(false); // อ่านได้อย่างเดียว
|
||||
const fileList = ref<ArrayFileList[]>([]);
|
||||
|
|
@ -98,18 +85,11 @@ const formData = reactive<FormData>({
|
|||
result: "",
|
||||
persons: [],
|
||||
disciplineComplaintDocs: fileList.value ?? null,
|
||||
activeId: null,
|
||||
organization: "",
|
||||
consideredAgencyId: null,
|
||||
});
|
||||
|
||||
/** maping ref เข้าตัวแปรเพื่อเตรียมตรวจสอบ */
|
||||
const objectComplaintsRef: MyObjectComplaintsRef = {
|
||||
respondentType: respondentTypeRef,
|
||||
organizationId: organizationIdRef,
|
||||
consideredAgency: consideredAgencyRef,
|
||||
title: titleRef,
|
||||
dateReceived: dateReceivedRef,
|
||||
offenseDetails: offenseDetailsRef,
|
||||
};
|
||||
|
||||
/**
|
||||
* ฟังชั่นอัปโหลดไฟล์
|
||||
* @param documentFile ไฟล์ที่รับมา
|
||||
|
|
@ -143,31 +123,14 @@ function selectLevel(val: string) {
|
|||
}
|
||||
}
|
||||
|
||||
/** ฟังก์ชั่นตรวจสอบความถูกต้องของข้อมูลในฟอร์ม */
|
||||
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)) {
|
||||
countNum.value = 1;
|
||||
onSubmit();
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
/** ฟังชั่น บันทึก */
|
||||
function onSubmit() {
|
||||
dialogConfirm($q, async () => {
|
||||
if (mainStore.rowsAdd) {
|
||||
formData.persons = await mainStore.rowsAdd;
|
||||
}
|
||||
console.log("formData===>", formData);
|
||||
|
||||
await props.onSubmit(formData);
|
||||
isSave.value = false;
|
||||
});
|
||||
|
|
@ -224,7 +187,17 @@ watch(props.data, async () => {
|
|||
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;
|
||||
|
|
@ -237,6 +210,7 @@ watch(props.data, async () => {
|
|||
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;
|
||||
}
|
||||
|
|
@ -285,12 +259,52 @@ async function addPerson(data: any) {
|
|||
await mainStore.fetchData(data);
|
||||
}
|
||||
|
||||
/** ดึงข้อมูล active */
|
||||
async function getActive() {
|
||||
if (!formData.activeId) {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.activeOrganization)
|
||||
.then(async (res) => {
|
||||
const data = await res.data.result;
|
||||
formData.activeId = data.activeId;
|
||||
getOc(data.activeId);
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
} else {
|
||||
getOc(formData.activeId);
|
||||
}
|
||||
}
|
||||
|
||||
/** ดึงข้อมูลหน่วยงานจาก api */
|
||||
function getOc() {
|
||||
http.get(config.API.typeOc()).then((res) => {
|
||||
const data = res.data.result;
|
||||
complainstStore.ocListFn(data);
|
||||
});
|
||||
async function getOc(activeId: string) {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.orgByid(activeId))
|
||||
.then(async (res) => {
|
||||
const data = await res.data.result.map((item: any) => ({
|
||||
organizationId: item.orgTreeId,
|
||||
organizationName: item.orgName,
|
||||
}));
|
||||
complainstStore.ocListFn(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
|
||||
// http.get(config.API.typeOc()).then((res) => {
|
||||
// const data = res.data.result;
|
||||
// complainstStore.ocListFn(data);
|
||||
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -317,6 +331,14 @@ function getListChannel() {
|
|||
/** ฟังก์ชั่นเช็คการแก้ไขฟอร์มแล้วไม่ได้กดบันทึก */
|
||||
function changeFormData() {
|
||||
isSave.value = props.data != null ?? true;
|
||||
if (organization.value) {
|
||||
formData.organizationId = organization.value.id;
|
||||
formData.organization = organization.value.name;
|
||||
}
|
||||
if (consideredAgency.value) {
|
||||
formData.consideredAgencyId = consideredAgency.value.id;
|
||||
formData.consideredAgency = consideredAgency.value.name;
|
||||
}
|
||||
}
|
||||
|
||||
/** เปลี่ยนสี เมื่อ readonly
|
||||
|
|
@ -350,7 +372,8 @@ function updatemodalPersonal(modal: boolean) {
|
|||
onMounted(() => {
|
||||
mainStore.rowsAdd = [];
|
||||
getListChannel();
|
||||
getOc();
|
||||
|
||||
getActive();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
@ -369,7 +392,12 @@ onMounted(() => {
|
|||
<q-separator />
|
||||
</div>
|
||||
|
||||
<form @submit.prevent="validateForm" class="col-12 row">
|
||||
<q-form
|
||||
greedy
|
||||
@submit.prevent
|
||||
@validation-success="onSubmit"
|
||||
class="col-12 row"
|
||||
>
|
||||
<div class="col-12 row">
|
||||
<div class="col-sm-12 col-md-9 row no-wrap">
|
||||
<div class="col-12 row q-pl-md q-py-md">
|
||||
|
|
@ -423,12 +451,13 @@ onMounted(() => {
|
|||
outlined
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
emit-value
|
||||
map-options
|
||||
v-model="formData.organizationId"
|
||||
v-model="organization"
|
||||
:options="complainstStore.organizationIdOp"
|
||||
label="เลือกสำนักงาน"
|
||||
:rules="[(val) => !!val || `${'กรุณาเลือกสำนักงาน'}`]"
|
||||
label="หน่วยงานที่ถูกร้องเรียน"
|
||||
:rules="[
|
||||
(val) => !!val || `${'กรุณาเลือกหน่วยงานที่ถูกร้องเรียน'}`,
|
||||
]"
|
||||
@update:model-value="changeFormData()"
|
||||
/>
|
||||
</div>
|
||||
|
|
@ -440,14 +469,13 @@ onMounted(() => {
|
|||
for="selectAgency"
|
||||
dense
|
||||
outlined
|
||||
v-model="formData.consideredAgency"
|
||||
v-model="consideredAgency"
|
||||
:options="complainstStore.consideredAgencytoptions"
|
||||
label="หน่วยงานที่พิจารณา"
|
||||
option-value="id"
|
||||
option-label="name"
|
||||
:readonly="isReadonly"
|
||||
hide-bottom-space
|
||||
emit-value
|
||||
map-options
|
||||
:rules="[(val) => !!val || `${'กรุณาเลือกหน่วยงาน'}`]"
|
||||
use-input
|
||||
|
|
@ -456,13 +484,6 @@ onMounted(() => {
|
|||
)"
|
||||
@update:model-value="changeFormData()"
|
||||
>
|
||||
<template v-slot:no-option>
|
||||
<q-item>
|
||||
<q-item-section class="text-grey">
|
||||
ไม่มีข้อมูล
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</template>
|
||||
</q-select>
|
||||
</div>
|
||||
|
||||
|
|
@ -1010,7 +1031,7 @@ onMounted(() => {
|
|||
>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</q-form>
|
||||
</div>
|
||||
|
||||
<!-- Popup ผู้ถูกร้องเรียน -->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue