Merge branch 'develop' into devTee
This commit is contained in:
commit
1d8093f4e6
3 changed files with 113 additions and 134 deletions
|
|
@ -12,12 +12,21 @@ import type { FormData } from "@/modules/11_discipline/interface/request/directo
|
|||
import DialogHeader from "@/components/DialogHeader.vue";
|
||||
import Form from "@/modules/12_evaluatePersonal/components/Director/Form.vue";
|
||||
|
||||
/**
|
||||
* importStore
|
||||
*/
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
/**
|
||||
* use
|
||||
*/
|
||||
const $q = useQuasar();
|
||||
const { messageError, showLoader, hideLoader, dialogConfirm, success } =
|
||||
useCounterMixin();
|
||||
|
||||
/**
|
||||
* props
|
||||
*/
|
||||
const modal = defineModel<boolean>("modal", { required: true });
|
||||
const directorId = defineModel<string>("directorId", { required: true });
|
||||
const actionType = defineModel<string>("actionType", { required: true });
|
||||
|
|
@ -25,6 +34,7 @@ const props = defineProps({
|
|||
fetchDataList: { type: Function, required: true },
|
||||
});
|
||||
|
||||
// ชื่อ Dialog
|
||||
const title = computed(() =>
|
||||
actionType.value === "VIEW" ? "รายละเอียด" : "แก้ไขรายชื่อกรรมการ"
|
||||
);
|
||||
|
|
@ -44,7 +54,7 @@ const dataDettail = reactive<FormData>({
|
|||
});
|
||||
|
||||
/**
|
||||
* ดึงค่าจาก api
|
||||
* function fetch ช้อมูลชื่อกรรมการ
|
||||
*/
|
||||
function fetchData() {
|
||||
showLoader();
|
||||
|
|
@ -66,6 +76,10 @@ function fetchData() {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* function ยืนยันการบันทึกการแก้ไขข้อมุล
|
||||
* @param formData ข้อมุลชื่อกรรมการ
|
||||
*/
|
||||
function onSubmit(formData: FormData) {
|
||||
dialogConfirm($q, () => {
|
||||
showLoader();
|
||||
|
|
@ -92,6 +106,9 @@ function onSubmit(formData: FormData) {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* ปิด dialog
|
||||
*/
|
||||
function onCloseDialog() {
|
||||
modal.value = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,39 +1,36 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, reactive, watch, onMounted, computed } from "vue";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useQuasar } from "quasar";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
/**
|
||||
* importTypr
|
||||
*/
|
||||
import type { QTableProps } from "quasar";
|
||||
import type {
|
||||
FormData,
|
||||
FormRef,
|
||||
typeOp,
|
||||
ResponsePreson,
|
||||
tableType,
|
||||
} from "@/modules/11_discipline/interface/request/director";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
/**
|
||||
* importComponenst
|
||||
*/
|
||||
import PopupPersonal from "@/components/Dialogs/PopupPersonalNew.vue";
|
||||
|
||||
const total = ref<number>(0);
|
||||
const totalList = ref<number>(1);
|
||||
const pagination = ref({
|
||||
sortBy: "createdAt",
|
||||
descending: true,
|
||||
page: 1,
|
||||
rowsPerPage: 10,
|
||||
});
|
||||
const modalPersonal = ref<boolean>(false);
|
||||
const personId = ref<string>("");
|
||||
/**
|
||||
* importStore
|
||||
*/
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
/**
|
||||
* use
|
||||
*/
|
||||
const $q = useQuasar();
|
||||
const mixin = useCounterMixin();
|
||||
const {
|
||||
messageError,
|
||||
showLoader,
|
||||
dialogMessageNotify,
|
||||
dialogConfirm,
|
||||
success,
|
||||
hideLoader,
|
||||
} = mixin;
|
||||
const { showLoader, hideLoader, messageError } = useCounterMixin();
|
||||
|
||||
/**
|
||||
* รับ props มาจาก page หลัก
|
||||
*/
|
||||
|
|
@ -48,16 +45,11 @@ const props = defineProps({
|
|||
default: () => "",
|
||||
},
|
||||
});
|
||||
// const isReadonly = ref<boolean>(false); // อ่านได้อย่างเดียว
|
||||
const emit = defineEmits(["formDataReturn"]);
|
||||
const isReadonly = computed(() => (actionType.value === "VIEW" ? true : false));
|
||||
|
||||
/**
|
||||
* ข้อมูลเลขประจำตัวประชาชน
|
||||
*/
|
||||
//
|
||||
const idCard = ref<string>("");
|
||||
const idCardRef = ref<any>(null);
|
||||
const isReadonly = computed(() => (actionType.value === "VIEW" ? true : false));
|
||||
const modalPersonal = ref<boolean>(false);
|
||||
const personId = ref<string>("");
|
||||
const type = ref<string>("citizenId");
|
||||
const search = ref<string>("");
|
||||
const typeOps = ref<typeOp[]>([
|
||||
|
|
@ -80,19 +72,18 @@ const formData = reactive<FormData>({
|
|||
qualification: "",
|
||||
});
|
||||
|
||||
/** หัวข้อที่เเสดงในตารางผู้ถูกร้องเรียน */
|
||||
/**
|
||||
* ตารางผู้ถูกร้องเรียน
|
||||
*/
|
||||
const searchRef = ref<any>(null);
|
||||
const rows = ref<tableType[]>([]);
|
||||
const visibleColumnsRespondent = ref<string[]>([
|
||||
"info",
|
||||
"no",
|
||||
// "idcard",
|
||||
"name",
|
||||
// "posNo",
|
||||
"position",
|
||||
// "positionLevel",
|
||||
// "salary",
|
||||
"organization",
|
||||
]);
|
||||
|
||||
const columnsRespondent = ref<QTableProps["columns"]>([
|
||||
{
|
||||
name: "info",
|
||||
|
|
@ -140,72 +131,33 @@ const columnsRespondent = ref<QTableProps["columns"]>([
|
|||
style: "font-size: 14px",
|
||||
},
|
||||
]);
|
||||
const total = ref<number>(0);
|
||||
const totalList = ref<number>(1);
|
||||
const pagination = ref({
|
||||
sortBy: "createdAt",
|
||||
descending: true,
|
||||
page: 1,
|
||||
rowsPerPage: 10,
|
||||
});
|
||||
|
||||
/**
|
||||
* เช็คข้อมูลจาก props
|
||||
* เมื่อมีข้อมูล
|
||||
* เก็บข้อมูลลง formData
|
||||
* บันทึกข้อมูล
|
||||
*/
|
||||
// watch(props.data, async () => {
|
||||
// // console.log("data==>", props.data)
|
||||
// formData.prefix = props.data.prefix;
|
||||
// formData.firstname = props.data.firstname;
|
||||
// formData.lastname = props.data.lastname;
|
||||
// formData.position = props.data.position;
|
||||
// formData.phone = props.data.phone;
|
||||
// formData.email = props.data.email;
|
||||
// });
|
||||
function onSubmit() {
|
||||
props.onSubmit(formData);
|
||||
}
|
||||
|
||||
/**
|
||||
* ตรวจสอบข้อมูลก่อนส่งไปยัง api
|
||||
* update เมื่อเปลี่ยน option
|
||||
*/
|
||||
const rows = ref<tableType[]>([]);
|
||||
const searchRef = ref<any>(null);
|
||||
const prefixRef = ref<object | null>(null);
|
||||
const firstnameRef = ref<object | null>(null);
|
||||
const lastnameRef = ref<object | null>(null);
|
||||
const positionRef = ref<object | null>(null);
|
||||
const phoneRef = ref<object | null>(null);
|
||||
const emailRef = ref<object | null>(null);
|
||||
const formRef: FormRef = {
|
||||
prefix: prefixRef,
|
||||
firstname: firstnameRef,
|
||||
lastname: lastnameRef,
|
||||
position: positionRef,
|
||||
phone: phoneRef,
|
||||
email: emailRef,
|
||||
};
|
||||
|
||||
/** ฟังชั่นตรวจสอบความถูกต้องก่อน บันทึก */
|
||||
function onValidate() {
|
||||
const hasError = [];
|
||||
for (const key in formRef) {
|
||||
if (Object.prototype.hasOwnProperty.call(formRef, key)) {
|
||||
const property = formRef[key];
|
||||
if (property.value && typeof property.value.validate === "function") {
|
||||
const isValid = property.value.validate();
|
||||
hasError.push(isValid);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasError.every((result) => result === true)) {
|
||||
props.onSubmit(formData);
|
||||
}
|
||||
}
|
||||
|
||||
function inputEdit(val: boolean) {
|
||||
return {
|
||||
"full-width cursor-pointer ": val,
|
||||
"full-width cursor-pointer inputgreen": !val,
|
||||
};
|
||||
}
|
||||
|
||||
/** update เมื่อเปลี่ยน option */
|
||||
function updateSelect() {
|
||||
search.value = "";
|
||||
}
|
||||
|
||||
async function searchInput() {
|
||||
/**
|
||||
* ค้นหารายชื่อ
|
||||
*/
|
||||
function searchInput() {
|
||||
searchRef.value.validate();
|
||||
if (!searchRef.value.hasError) {
|
||||
showLoader();
|
||||
|
|
@ -213,7 +165,7 @@ async function searchInput() {
|
|||
fieldName: type.value,
|
||||
keyword: search.value,
|
||||
};
|
||||
await http
|
||||
http
|
||||
.post(
|
||||
config.API.orgSearchPersonal() +
|
||||
`?page=${pagination.value.page}&pageSize=${pagination.value.rowsPerPage}`,
|
||||
|
|
@ -225,7 +177,6 @@ async function searchInput() {
|
|||
res.data.result.total / pagination.value.rowsPerPage
|
||||
);
|
||||
total.value = res.data.result.total;
|
||||
|
||||
const list = data.map((e: ResponsePreson) => ({
|
||||
personId: e.id,
|
||||
idcard: e.citizenId,
|
||||
|
|
@ -244,13 +195,18 @@ async function searchInput() {
|
|||
|
||||
rows.value = list;
|
||||
})
|
||||
.catch((err) => {})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* เลืือกชื่อกรรมการ
|
||||
*/
|
||||
function returnDetail(data: any) {
|
||||
formData.prefix = data.prefix;
|
||||
formData.firstname = data.firstName;
|
||||
|
|
@ -269,9 +225,13 @@ function onclickViewinfo(id: string) {
|
|||
personId.value = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* เปิด,ปิด popup ทะเบียนประวัติ
|
||||
*/
|
||||
function updatemodalPersonal(modal: boolean) {
|
||||
modalPersonal.value = modal;
|
||||
}
|
||||
|
||||
function updatePagination(newPagination: any) {
|
||||
pagination.value.page = 1;
|
||||
pagination.value.rowsPerPage = newPagination.rowsPerPage;
|
||||
|
|
@ -279,8 +239,8 @@ function updatePagination(newPagination: any) {
|
|||
|
||||
watch(
|
||||
() => pagination.value.rowsPerPage,
|
||||
async () => {
|
||||
await searchInput();
|
||||
() => {
|
||||
searchInput();
|
||||
}
|
||||
);
|
||||
|
||||
|
|
@ -293,6 +253,13 @@ function fetchForm(data: any) {
|
|||
formData.email = data.email;
|
||||
}
|
||||
|
||||
function inputEdit(val: boolean) {
|
||||
return {
|
||||
"full-width cursor-pointer ": val,
|
||||
"full-width cursor-pointer inputgreen": !val,
|
||||
};
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (props.data) {
|
||||
showLoader();
|
||||
|
|
@ -304,7 +271,7 @@ onMounted(() => {
|
|||
});
|
||||
</script>
|
||||
<template>
|
||||
<form @submit.prevent.stop="onValidate">
|
||||
<q-form greedy @submit.prevent @validation-success="onSubmit">
|
||||
<q-card bordered>
|
||||
<div class="col-12 row q-pa-md">
|
||||
<div class="row col-12 q-col-gutter-md">
|
||||
|
|
@ -331,10 +298,10 @@ onMounted(() => {
|
|||
v-model="search"
|
||||
outlined
|
||||
clearable
|
||||
@clear="search = ''"
|
||||
hide-bottom-space
|
||||
dense
|
||||
label="คำค้น"
|
||||
:rules="[(val) => !!val || `กรุณากรอกคำค้น`]"
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
|
@ -398,7 +365,7 @@ onMounted(() => {
|
|||
v-for="col in props.cols"
|
||||
:key="col.name"
|
||||
:props="props"
|
||||
@click="returnDetail(props.row)"
|
||||
@click.stop.pervent="returnDetail(props.row)"
|
||||
>
|
||||
<div v-if="col.name == 'no'">
|
||||
{{
|
||||
|
|
@ -408,17 +375,15 @@ onMounted(() => {
|
|||
}}
|
||||
</div>
|
||||
<div v-else-if="col.name == 'info'">
|
||||
<!-- <router-link
|
||||
target="_blank"
|
||||
:to="`/registry/${props.row.personId}`"
|
||||
> -->
|
||||
<q-btn
|
||||
dense
|
||||
flat
|
||||
round
|
||||
color="info"
|
||||
icon="info"
|
||||
@click="onclickViewinfo(props.row.personId)"
|
||||
@click.stop.pervent="
|
||||
onclickViewinfo(props.row.personId)
|
||||
"
|
||||
>
|
||||
<q-tooltip>ดูข้อมูลในทะเบียนประวัติ</q-tooltip>
|
||||
</q-btn>
|
||||
|
|
@ -531,12 +496,12 @@ onMounted(() => {
|
|||
id="formSubmit"
|
||||
color="secondary"
|
||||
label="บันทึก"
|
||||
@click.stop="onValidate"
|
||||
type="onSubmit"
|
||||
><q-tooltip>บับทึกข้อมูล</q-tooltip></q-btn
|
||||
>
|
||||
</div>
|
||||
</q-card>
|
||||
</form>
|
||||
</q-form>
|
||||
|
||||
<PopupPersonal
|
||||
:modal="modalPersonal"
|
||||
|
|
|
|||
|
|
@ -38,6 +38,9 @@ const pagination = ref({
|
|||
rowsPerPage: 10,
|
||||
});
|
||||
|
||||
/**
|
||||
* function fetch ข้อมูลรายการชื่อกรรมการ
|
||||
*/
|
||||
function getList() {
|
||||
showLoader();
|
||||
http
|
||||
|
|
@ -55,33 +58,32 @@ function getList() {
|
|||
}
|
||||
|
||||
/**
|
||||
* ลบข้อมูล
|
||||
* ยืนยัน การลบข้อมูลรายการชื่อกรรมการ
|
||||
* @param id ไอดีของข้อมูล
|
||||
*/
|
||||
function clickDelete(id: string) {
|
||||
dialogRemove($q, async () => deleteData(id), `ลบข้อมูล`);
|
||||
dialogRemove($q, async () => {
|
||||
showLoader();
|
||||
http
|
||||
.delete(config.API.evaluateDirectorById(id))
|
||||
.then(async () => {
|
||||
getList();
|
||||
success($q, "ลบข้อมูลสำเร็จ");
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* ลบข้อมูล
|
||||
* @param id type
|
||||
* function ดูรายละเอียดของข้อมูล
|
||||
* @param id รายการชื่อกรรมการ
|
||||
* @param type ดูรายละเอียด,แก้ไขข้อมูล
|
||||
*/
|
||||
function deleteData(id: string) {
|
||||
showLoader();
|
||||
http
|
||||
.delete(config.API.evaluateDirectorById(id))
|
||||
.then(async () => {
|
||||
getList();
|
||||
success($q, "ลบข้อมูลสำเร็จ");
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
function onOpenDetail(id: string, type: string) {
|
||||
directorId.value = id;
|
||||
actionType.value = type;
|
||||
|
|
@ -101,10 +103,6 @@ function resetFilter() {
|
|||
}
|
||||
}
|
||||
|
||||
function filterFn() {
|
||||
getList();
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
|
|
@ -137,7 +135,6 @@ onMounted(() => {
|
|||
outlined
|
||||
debounce="300"
|
||||
placeholder="ค้นหา"
|
||||
@keydown.enter.prevent="filterFn"
|
||||
>
|
||||
<template v-slot:append>
|
||||
<q-icon v-if="filterKeyword == ''" name="search" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue