ประเมินบุคคล => permission ,รายการชื่อกรรมการ

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-08-09 14:05:38 +07:00
parent d2f52a2551
commit 3d3013277b
3 changed files with 109 additions and 132 deletions

View file

@ -12,12 +12,21 @@ import type { FormData } from "@/modules/11_discipline/interface/request/directo
import DialogHeader from "@/components/DialogHeader.vue"; import DialogHeader from "@/components/DialogHeader.vue";
import Form from "@/modules/12_evaluatePersonal/components/Director/Form.vue"; import Form from "@/modules/12_evaluatePersonal/components/Director/Form.vue";
/**
* importStore
*/
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
/**
* use
*/
const $q = useQuasar(); const $q = useQuasar();
const { messageError, showLoader, hideLoader, dialogConfirm, success } = const { messageError, showLoader, hideLoader, dialogConfirm, success } =
useCounterMixin(); useCounterMixin();
/**
* props
*/
const modal = defineModel<boolean>("modal", { required: true }); const modal = defineModel<boolean>("modal", { required: true });
const directorId = defineModel<string>("directorId", { required: true }); const directorId = defineModel<string>("directorId", { required: true });
const actionType = defineModel<string>("actionType", { required: true }); const actionType = defineModel<string>("actionType", { required: true });
@ -25,6 +34,7 @@ const props = defineProps({
fetchDataList: { type: Function, required: true }, fetchDataList: { type: Function, required: true },
}); });
// Dialog
const title = computed(() => const title = computed(() =>
actionType.value === "VIEW" ? "รายละเอียด" : "แก้ไขรายชื่อกรรมการ" actionType.value === "VIEW" ? "รายละเอียด" : "แก้ไขรายชื่อกรรมการ"
); );
@ -44,7 +54,7 @@ const dataDettail = reactive<FormData>({
}); });
/** /**
* งคาจาก api * function fetch อมลชอกรรมการ
*/ */
function fetchData() { function fetchData() {
showLoader(); showLoader();
@ -66,6 +76,10 @@ function fetchData() {
}); });
} }
/**
* function นยนการบนทกการแกไขขอม
* @param formData อมลชอกรรมการ
*/
function onSubmit(formData: FormData) { function onSubmit(formData: FormData) {
dialogConfirm($q, () => { dialogConfirm($q, () => {
showLoader(); showLoader();
@ -92,6 +106,9 @@ function onSubmit(formData: FormData) {
}); });
} }
/**
* dialog
*/
function onCloseDialog() { function onCloseDialog() {
modal.value = false; modal.value = false;
} }

View file

@ -1,39 +1,36 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive, watch, onMounted, computed } from "vue"; import { ref, reactive, watch, onMounted, computed } from "vue";
import { useCounterMixin } from "@/stores/mixin";
import { useQuasar } from "quasar"; import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
/**
* importTypr
*/
import type { QTableProps } from "quasar"; import type { QTableProps } from "quasar";
import type { import type {
FormData, FormData,
FormRef,
typeOp, typeOp,
ResponsePreson, ResponsePreson,
tableType, tableType,
} from "@/modules/11_discipline/interface/request/director"; } 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"; import PopupPersonal from "@/components/Dialogs/PopupPersonalNew.vue";
const total = ref<number>(0); /**
const totalList = ref<number>(1); * importStore
const pagination = ref({ */
sortBy: "createdAt", import { useCounterMixin } from "@/stores/mixin";
descending: true,
page: 1, /**
rowsPerPage: 10, * use
}); */
const modalPersonal = ref<boolean>(false);
const personId = ref<string>("");
const $q = useQuasar(); const $q = useQuasar();
const mixin = useCounterMixin(); const { showLoader, hideLoader, messageError } = useCounterMixin();
const {
messageError,
showLoader,
dialogMessageNotify,
dialogConfirm,
success,
hideLoader,
} = mixin;
/** /**
* props มาจาก page หล * props มาจาก page หล
*/ */
@ -48,16 +45,11 @@ const props = defineProps({
default: () => "", default: () => "",
}, },
}); });
// const isReadonly = ref<boolean>(false); //
const emit = defineEmits(["formDataReturn"]); const emit = defineEmits(["formDataReturn"]);
const isReadonly = computed(() => (actionType.value === "VIEW" ? true : false));
/** const isReadonly = computed(() => (actionType.value === "VIEW" ? true : false));
* อมลเลขประจำตวประชาชน const modalPersonal = ref<boolean>(false);
*/ const personId = ref<string>("");
//
const idCard = ref<string>("");
const idCardRef = ref<any>(null);
const type = ref<string>("citizenId"); const type = ref<string>("citizenId");
const search = ref<string>(""); const search = ref<string>("");
const typeOps = ref<typeOp[]>([ const typeOps = ref<typeOp[]>([
@ -80,19 +72,18 @@ const formData = reactive<FormData>({
qualification: "", qualification: "",
}); });
/** หัวข้อที่เเสดงในตารางผู้ถูกร้องเรียน */ /**
* ตารางผกรองเรยน
*/
const searchRef = ref<any>(null);
const rows = ref<tableType[]>([]);
const visibleColumnsRespondent = ref<string[]>([ const visibleColumnsRespondent = ref<string[]>([
"info", "info",
"no", "no",
// "idcard",
"name", "name",
// "posNo",
"position", "position",
// "positionLevel",
// "salary",
"organization", "organization",
]); ]);
const columnsRespondent = ref<QTableProps["columns"]>([ const columnsRespondent = ref<QTableProps["columns"]>([
{ {
name: "info", name: "info",
@ -140,72 +131,33 @@ const columnsRespondent = ref<QTableProps["columns"]>([
style: "font-size: 14px", 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 () => { function onSubmit() {
// // console.log("data==>", props.data) props.onSubmit(formData);
// 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;
// });
/** /**
* ตรวจสอบขอมลกอนสงไปย 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() { function updateSelect() {
search.value = ""; search.value = "";
} }
async function searchInput() { /**
* นหารายช
*/
function searchInput() {
searchRef.value.validate(); searchRef.value.validate();
if (!searchRef.value.hasError) { if (!searchRef.value.hasError) {
showLoader(); showLoader();
@ -213,7 +165,7 @@ async function searchInput() {
fieldName: type.value, fieldName: type.value,
keyword: search.value, keyword: search.value,
}; };
await http http
.post( .post(
config.API.orgSearchPersonal() + config.API.orgSearchPersonal() +
`?page=${pagination.value.page}&pageSize=${pagination.value.rowsPerPage}`, `?page=${pagination.value.page}&pageSize=${pagination.value.rowsPerPage}`,
@ -225,7 +177,6 @@ async function searchInput() {
res.data.result.total / pagination.value.rowsPerPage res.data.result.total / pagination.value.rowsPerPage
); );
total.value = res.data.result.total; total.value = res.data.result.total;
const list = data.map((e: ResponsePreson) => ({ const list = data.map((e: ResponsePreson) => ({
personId: e.id, personId: e.id,
idcard: e.citizenId, idcard: e.citizenId,
@ -244,13 +195,18 @@ async function searchInput() {
rows.value = list; rows.value = list;
}) })
.catch((err) => {}) .catch((err) => {
messageError($q, err);
})
.finally(() => { .finally(() => {
hideLoader(); hideLoader();
}); });
} }
} }
/**
* เลอกชอกรรมการ
*/
function returnDetail(data: any) { function returnDetail(data: any) {
formData.prefix = data.prefix; formData.prefix = data.prefix;
formData.firstname = data.firstName; formData.firstname = data.firstName;
@ -269,9 +225,13 @@ function onclickViewinfo(id: string) {
personId.value = id; personId.value = id;
} }
/**
* เป, popup ทะเบยนประว
*/
function updatemodalPersonal(modal: boolean) { function updatemodalPersonal(modal: boolean) {
modalPersonal.value = modal; modalPersonal.value = modal;
} }
function updatePagination(newPagination: any) { function updatePagination(newPagination: any) {
pagination.value.page = 1; pagination.value.page = 1;
pagination.value.rowsPerPage = newPagination.rowsPerPage; pagination.value.rowsPerPage = newPagination.rowsPerPage;
@ -279,8 +239,8 @@ function updatePagination(newPagination: any) {
watch( watch(
() => pagination.value.rowsPerPage, () => pagination.value.rowsPerPage,
async () => { () => {
await searchInput(); searchInput();
} }
); );
@ -293,6 +253,13 @@ function fetchForm(data: any) {
formData.email = data.email; formData.email = data.email;
} }
function inputEdit(val: boolean) {
return {
"full-width cursor-pointer ": val,
"full-width cursor-pointer inputgreen": !val,
};
}
onMounted(() => { onMounted(() => {
if (props.data) { if (props.data) {
showLoader(); showLoader();
@ -304,7 +271,7 @@ onMounted(() => {
}); });
</script> </script>
<template> <template>
<form @submit.prevent.stop="onValidate"> <q-form greedy @submit.prevent @validation-success="onSubmit">
<q-card bordered> <q-card bordered>
<div class="col-12 row q-pa-md"> <div class="col-12 row q-pa-md">
<div class="row col-12 q-col-gutter-md"> <div class="row col-12 q-col-gutter-md">
@ -331,10 +298,10 @@ onMounted(() => {
v-model="search" v-model="search"
outlined outlined
clearable clearable
@clear="search = ''"
hide-bottom-space hide-bottom-space
dense dense
label="คำค้น" label="คำค้น"
:rules="[(val) => !!val || `กรุณากรอกคำค้น`]"
/> />
</div> </div>
@ -408,10 +375,6 @@ onMounted(() => {
}} }}
</div> </div>
<div v-else-if="col.name == 'info'"> <div v-else-if="col.name == 'info'">
<!-- <router-link
target="_blank"
:to="`/registry/${props.row.personId}`"
> -->
<q-btn <q-btn
dense dense
flat flat
@ -531,12 +494,12 @@ onMounted(() => {
id="formSubmit" id="formSubmit"
color="secondary" color="secondary"
label="บันทึก" label="บันทึก"
@click.stop="onValidate" type="onSubmit"
><q-tooltip>บทกขอม</q-tooltip></q-btn ><q-tooltip>บทกขอม</q-tooltip></q-btn
> >
</div> </div>
</q-card> </q-card>
</form> </q-form>
<PopupPersonal <PopupPersonal
:modal="modalPersonal" :modal="modalPersonal"

View file

@ -38,6 +38,9 @@ const pagination = ref({
rowsPerPage: 10, rowsPerPage: 10,
}); });
/**
* function fetch อมลรายการชอกรรมการ
*/
function getList() { function getList() {
showLoader(); showLoader();
http http
@ -55,33 +58,32 @@ function getList() {
} }
/** /**
* ลบขอม * นย การลบขอมลรายการชอกรรมการ
* @param id ไอดของขอม * @param id ไอดของขอม
*/ */
function clickDelete(id: string) { 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();
});
});
} }
/** /**
* ลบขอม * function รายละเอยดของขอม
* @param id type * @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) { function onOpenDetail(id: string, type: string) {
directorId.value = id; directorId.value = id;
actionType.value = type; actionType.value = type;
@ -101,10 +103,6 @@ function resetFilter() {
} }
} }
function filterFn() {
getList();
}
onMounted(() => { onMounted(() => {
getList(); getList();
}); });
@ -137,7 +135,6 @@ onMounted(() => {
outlined outlined
debounce="300" debounce="300"
placeholder="ค้นหา" placeholder="ค้นหา"
@keydown.enter.prevent="filterFn"
> >
<template v-slot:append> <template v-slot:append>
<q-icon v-if="filterKeyword == ''" name="search" /> <q-icon v-if="filterKeyword == ''" name="search" />