ทะเบียนใหม่(วินัย//ปรับหน้าราชการ)

This commit is contained in:
setthawutttty 2024-03-12 10:51:08 +07:00
parent a62ebce427
commit ab39c2d2f2
4 changed files with 1414 additions and 121 deletions

View file

@ -52,7 +52,7 @@ const modalEdit = ref<boolean>(false);
const modalHistory = ref<boolean>(false);
const rowsHistory = ref<RequestItemsHistoryObject[]>([]);
const filterKeyword = ref<string>('');
const filterKeyword = ref<string>("");
const containDate = ref<Date | null>(null);
const workDate = ref<Date | null>(null);
@ -379,12 +379,15 @@ function getDataHistory() {
// });
}
watch(() => modalHistory.value, (isOpen) => {
if(isOpen === true) {
getDataHistory()
watch(
() => modalHistory.value,
(isOpen) => {
if (isOpen === true) {
filterKeyword.value = ''
getDataHistory();
}
}
});
);
</script>
<template>
<div class="row">
@ -410,132 +413,212 @@ watch(() => modalHistory.value, (isOpen) => {
</div>
</div>
<q-card bordered class="bg-grey-2 q-pa-md">
<q-card bordered class="q-pa-md">
<div class="row q-col-gutter-md">
<div class="col-12 col-sm-12 col-md-6">
<div class="column">
<span class="text-grey-7">งก</span>
<span>{{ formMain.ocId !== "" ? formMain.ocId : "-" }}</span>
<div class="col-12 col-sm-6 col-md-6 q-gutter-y-sm">
<div class="col-12 col-sm-6 col-md-6">
<div class="row">
<div class="col-12 col-sm-12 col-md-4">
<span class="text-grey-7">งก</span>
</div>
<div class="col-12 col-sm-12 col-md-8">
<span>{{ formMain.ocId !== "" ? formMain.ocId : "-" }}</span>
</div>
</div>
</div>
<div class="col-12 col-sm-6 col-md-6">
<div class="row">
<div class="col-12 col-sm-12 col-md-4">
<span class="text-grey-7">ตำแหน</span>
</div>
<div class="col-12 col-sm-12 col-md-8">
<span>{{
formMain.positionId !== "" ? formMain.positionId : "-"
}}</span>
</div>
</div>
</div>
<div class="col-12 col-sm-6 col-md-6">
<div class="row">
<div class="col-12 col-sm-12 col-md-4">
<span class="text-grey-7">เลขทตำแหน</span>
</div>
<div class="col-12 col-sm-12 col-md-8">
<span>{{
formMain.numberId !== "" ? formMain.numberId : "-"
}}</span>
</div>
</div>
</div>
<div class="col-12 col-sm-6 col-md-6">
<div class="row">
<div class="col-12 col-sm-12 col-md-4">
<span class="text-grey-7">ตำแหนงทางการบรหาร</span>
</div>
<div class="col-12 col-sm-12 col-md-8">
<span>{{
formMain.positionExecutive !== ""
? formMain.positionExecutive
: "-"
}}</span>
</div>
</div>
</div>
<div class="col-12 col-sm-6 col-md-6">
<div class="row">
<div class="col-12 col-sm-12 col-md-4">
<span class="text-grey-7">านตำแหนงทางการบรหาร</span>
</div>
<div class="col-12 col-sm-12 col-md-8">
<span>{{
formMain.positionExecutiveSide !== ""
? formMain.positionExecutiveSide
: "-"
}}</span>
</div>
</div>
</div>
</div>
<div class="col-12 col-sm-6 col-md-3">
<div class="column">
<span class="text-grey-7">ตำแหน</span>
<span>{{
formMain.positionId !== "" ? formMain.positionId : "-"
}}</span>
<div class="col-12 col-sm-6 col-md-6 q-gutter-y-sm">
<div class="col-12 col-sm-6 col-md-6">
<div class="row">
<div class="col-12 col-sm-12 col-md-4">
<span class="text-grey-7">สายงาน</span>
</div>
<div class="col-12 col-sm-12 col-md-8">
<span>{{
formMain.positionLine !== "" ? formMain.positionLine : "-"
}}</span>
</div>
</div>
</div>
</div>
<div class="col-12 col-sm-6 col-md-3">
<div class="column">
<span class="text-grey-7">สายงาน</span>
<span>{{
formMain.positionLine !== "" ? formMain.positionLine : "-"
}}</span>
<div class="col-12 col-sm-6 col-md-6">
<div class="row">
<div class="col-12 col-sm-12 col-md-4">
<span class="text-grey-7">ระด</span>
</div>
<div class="col-12 col-sm-12 col-md-8">
<span>{{
formMain.positionLevel !== "" ? formMain.positionLevel : "-"
}}</span>
</div>
</div>
</div>
</div>
<div class="col-12 col-sm-6 col-md-3">
<div class="column">
<span class="text-grey-7">ระด</span>
<span>{{
formMain.positionLevel !== "" ? formMain.positionLevel : "-"
}}</span>
<div class="col-12 col-sm-6 col-md-6">
<div class="row">
<div class="col-12 col-sm-12 col-md-4">
<span class="text-grey-7">ประเภท</span>
</div>
<div class="col-12 col-sm-12 col-md-8">
<span>{{
formMain.positionType !== "" ? formMain.positionType : "-"
}}</span>
</div>
</div>
</div>
</div>
<div class="col-12 col-sm-6 col-md-3">
<div class="column">
<span class="text-grey-7">เลขทตำแหน</span>
<span>{{ formMain.numberId !== "" ? formMain.numberId : "-" }}</span>
</div>
</div>
<div class="col-12 col-sm-6 col-md-3">
<div class="column">
<span class="text-grey-7">ตำแหนงทางการบรหาร</span>
<span>{{
formMain.positionExecutive !== "" ? formMain.positionExecutive : "-"
}}</span>
</div>
</div>
<div class="col-12 col-sm-6 col-md-3">
<div class="column">
<span class="text-grey-7">านตำแหนงทางการบรหาร</span>
<span>{{
formMain.positionExecutiveSide !== ""
? formMain.positionExecutiveSide
: "-"
}}</span>
</div>
</div>
<div class="col-12 col-sm-6 col-md-3">
<div class="column">
<span class="text-grey-7">ประเภท</span>
<span>{{
formMain.positionType !== "" ? formMain.positionType : "-"
}}</span>
</div>
</div>
<div class="col-12 col-sm-6 col-md-3">
<div class="column">
<span class="text-grey-7">าน/สาขา</span>
<span>{{
formMain.positionPathSide !== "" ? formMain.positionPathSide : "-"
}}</span>
<div class="col-12 col-sm-6 col-md-6">
<div class="row">
<div class="col-12 col-sm-12 col-md-4">
<span class="text-grey-7">าน/สาขา</span>
</div>
<div class="col-12 col-sm-12 col-md-8">
<span>{{
formMain.positionPathSide !== ""
? formMain.positionPathSide
: "-"
}}</span>
</div>
</div>
</div>
</div>
</div>
<q-separator inset color="grey-5" class="q-my-md" />
<div class="row q-col-gutter-md">
<div class="col-12 col-sm-6 col-md-3">
<div class="column">
<span class="text-grey-7">นทงบรรจ</span>
<span>{{
formMain.containDate ? date2Thai(formMain.containDate) : "-"
}}</span>
<div class="col-12 col-sm-6 col-md-6 q-gutter-y-sm">
<div class="col-12 col-sm-6 col-md-6">
<div class="row">
<div class="col-12 col-sm-12 col-md-4">
<span class="text-grey-7">นทงบรรจ</span>
</div>
<div class="col-12 col-sm-12 col-md-8">
<span>{{
formMain.containDate ? date2Thai(formMain.containDate) : "-"
}}</span>
</div>
</div>
</div>
<div class="col-12 col-sm-6 col-md-6">
<div class="row">
<div class="col-12 col-sm-12 col-md-4">
<span class="text-grey-7">นทเรมปฏราชการ</span>
</div>
<div class="col-12 col-sm-12 col-md-8">
<span>{{
formMain.workDate !== "" ? date2Thai(formMain.workDate) : "-"
}}</span>
</div>
</div>
</div>
<div
v-if="dateToISO(formMain.containDate as Date) !== dateToISO(formMain.workDate as Date)"
class="col-12 col-sm-6 col-md-6"
>
<div class="row">
<div class="col-12 col-sm-12 col-md-4">
<span class="text-grey-7">เหตผลทนทไมตรงก</span>
</div>
<div class="col-12 col-sm-12 col-md-8">
<span>{{
formMain.reasonSameDate !== "" ? formMain.reasonSameDate : "-"
}}</span>
</div>
</div>
</div>
<div class="col-12 col-sm-6 col-md-6">
<div class="row">
<div class="col-12 col-sm-12 col-md-4">
<span class="text-grey-7">นเกษยณอาย</span>
</div>
<div class="col-12 col-sm-12 col-md-8">
<span>{{
formMain.retireDate !== ""
? date2Thai(formMain.retireDate)
: "-"
}}</span>
</div>
</div>
</div>
</div>
<div class="col-12 col-sm-6 col-md-3">
<div class="column">
<span class="text-grey-7">นทเรมปฏราชการ</span>
<span>{{
formMain.workDate !== "" ? date2Thai(formMain.workDate) : "-"
}}</span>
<div class="col-12 col-sm-6 col-md-6 q-gutter-y-sm">
<div class="col-12 col-sm-6 col-md-6">
<div class="row">
<div class="col-12 col-sm-12 col-md-4">
<span class="text-grey-7">อายราชการ</span>
</div>
<div class="col-12 col-sm-12 col-md-8">
<span>{{ formMain.ageAll !== "" ? formMain.ageAll : "-" }}</span>
</div>
</div>
</div>
</div>
<div
v-if="dateToISO(formMain.containDate as Date) !== dateToISO(formMain.workDate as Date)"
class="col-12 col-sm-12 col-md-6"
>
<div class="column">
<span class="text-grey-7">เหตผลทนทไมตรงก</span>
<span>{{
formMain.reasonSameDate !== "" ? formMain.reasonSameDate : "-"
}}</span>
<div class="col-12 col-sm-6 col-md-6">
<div class="row">
<div class="col-12 col-sm-12 col-md-4">
<span class="text-grey-7">ขาดราชการ</span>
</div>
<div class="col-12 col-sm-12 col-md-8">
<span>{{ formMain.absent ? formMain.absent : 0 }}</span>
</div>
</div>
</div>
</div>
<div class="col-12 col-sm-6 col-md-3">
<div class="column">
<span class="text-grey-7">นเกษยณอาย</span>
<span>{{
formMain.retireDate !== "" ? date2Thai(formMain.retireDate) : "-"
}}</span>
</div>
</div>
<div class="col-12 col-sm-6 col-md-3">
<div class="column">
<span class="text-grey-7">อายราชการ</span>
<span>{{ formMain.ageAll !== "" ? formMain.ageAll : "-" }}</span>
</div>
</div>
<div class="col-12 col-sm-6 col-md-3">
<div class="column">
<span class="text-grey-7">ขาดราชการ</span>
<span>{{ formMain.absent ? formMain.absent : 0 }}</span>
</div>
</div>
<div class="col-12 col-sm-6 col-md-3">
<div class="column">
<span class="text-grey-7">อายราชการเกอก</span>
<span>{{ formMain.age ? formMain.age : 0 }}</span>
<div class="col-12 col-sm-6 col-md-6">
<div class="row">
<div class="col-12 col-sm-12 col-md-4">
<span class="text-grey-7">อายราชการเกอก</span>
</div>
<div class="col-12 col-sm-12 col-md-8">
<span>{{ formMain.age ? formMain.age : 0 }}</span>
</div>
</div>
</div>
</div>
</div>
@ -698,8 +781,18 @@ watch(() => modalHistory.value, (isOpen) => {
debounce="300"
>
<template v-slot:append>
<q-icon v-if="filterKeyword == ''" name="search" @click.stop.prevent="filterKeyword = ''" class="cursor-pointer" />
<q-icon v-if="filterKeyword" name="cancel" @click.stop.prevent="filterKeyword = ''" class="cursor-pointer" />
<q-icon
v-if="filterKeyword == ''"
name="search"
@click.stop.prevent="filterKeyword = ''"
class="cursor-pointer"
/>
<q-icon
v-if="filterKeyword"
name="cancel"
@click.stop.prevent="filterKeyword = ''"
class="cursor-pointer"
/>
</template>
</q-input>
<q-select

View file

@ -1,6 +1,852 @@
<script setup lang="ts"></script>
<script setup lang="ts">
import { ref, onMounted, reactive } from "vue";
import type { QTableProps } from "quasar";
import type {
RequestItemsObject,
FormFilter,
DataOption,
DisciplineOps,
MyObjectRef,
} from "@/modules/04_registryNew/interface/index/discipline";
import { useCounterMixin } from "@/stores/mixin";
import { useQuasar } from "quasar";
import DialogHeader from "@/components/DialogHeader.vue";
import http from "@/plugins/http";
import config from "@/app.config";
import DialogHistory from "@/modules/04_registryNew/components/detail/GovernmentInformation/02_DisciplineHistory.vue";
import { useRoute } from "vue-router";
const route = useRoute();
const profileId = ref<string>(
route.params.id ? route.params.id.toString() : ""
);
const $q = useQuasar();
const mixin = useCounterMixin();
const {
date2Thai,
dialogConfirm,
showLoader,
hideLoader,
messageError,
success,
dateToISO,
} = mixin;
const rows = ref<RequestItemsObject[]>([]);
const mode = ref<string>("card");
const filterKeyword = ref<string>("");
const formFilter = reactive<FormFilter>({
page: 1,
pageSize: 12,
keyword: "",
type: "",
posType: "",
posLevel: "",
retireYear: "",
rangeYear: { min: 0, max: 60 },
isShowRetire: false,
isProbation: false,
});
const currentPage = ref<number>(1);
const maxPage = ref<number>(1);
const visibleColumns = ref<String[]>([
"level",
"detail",
"unStigma",
"refCommandNo",
"refCommandDate",
"date",
]);
const columns = ref<QTableProps["columns"]>([
{
name: "date",
align: "left",
label: "วัน เดือน ปี",
sortable: true,
field: "date",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "detail",
align: "left",
label: "รายละเอียด",
sortable: true,
field: "detail",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "level",
align: "left",
label: "ระดับการลงโทษทางวินัย",
sortable: true,
field: "level",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "unStigma",
align: "left",
label: "ล้างมลทิน",
sortable: true,
field: "unStigma",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "refCommandNo",
align: "left",
label: "เลขที่คำสั่ง",
sortable: true,
field: "refCommandNo",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "refCommandDate",
align: "left",
label: "เอกสารอ้างอิง (ลงวันที่)",
sortable: true,
field: "refCommandDate",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const dateRef = ref<object | null>(null);
const detailRef = ref<object | null>(null);
const refCommandNoRef = ref<object | null>(null);
const objectRef: MyObjectRef = {
date: dateRef,
detail: detailRef,
refCommandNo: refCommandNoRef,
};
/** dialog */
const edit = ref<boolean>(false);
const modal = ref<boolean>(false);
const modalHistory = ref<boolean>(false);
const id = ref<string>("");
const date = ref<Date | null>(null);
const detail = ref<string>();
const level = ref<string>();
const unStigma = ref<string>();
const refCommandNo = ref<string>();
const refCommandDate = ref<Date | null>(null);
const Ops = ref<DisciplineOps>({
levelOptions: [
{
name: "ภาคทัณฑ์",
id: "ภาคทัณฑ์",
},
{
name: "ตัดเงินเดือน",
id: "ตัดเงินเดือน",
},
{
name: "ลดขั้นเงินเดือน",
id: "ลดขั้นเงินเดือน",
},
{
name: "ปลดออก",
id: "ปลดออก",
},
{
name: "ไล่ออก",
id: "ไล่ออก",
},
],
});
const OpsFilter = ref<DisciplineOps>({
levelOptions: [
{
name: "ภาคทัณฑ์",
id: "ภาคทัณฑ์",
},
{
name: "ตัดเงินเดือน",
id: "ตัดเงินเดือน",
},
{
name: "ลดขั้นเงินเดือน",
id: "ลดขั้นเงินเดือน",
},
{
name: "ปลดออก",
id: "ปลดออก",
},
{
name: "ไล่ออก",
id: "ไล่ออก",
},
],
});
function filterSelector(val: string, update: Function, refData: string) {
switch (refData) {
case "levelOptions":
update(() => {
Ops.value.levelOptions = OpsFilter.value.levelOptions.filter(
(v: DataOption) => v.name.indexOf(val) > -1
);
});
break;
default:
break;
}
}
/** ปิด dialog */
function closeDialog() {
modal.value = false;
edit.value = false;
date.value = null;
detail.value = "";
level.value = "";
unStigma.value = "";
refCommandNo.value = "";
refCommandDate.value = null;
}
function openDialogAdd() {
modal.value = true;
}
/**
* กดเลอกขอมลทจะแกไข
* @param props props ใน row เลอก
*/
function openDialogEdit(props: RequestItemsObject) {
modal.value = true;
edit.value = true;
console.log(props);
id.value = props.id;
date.value = props.date;
detail.value = props.detail;
level.value = props.level;
unStigma.value = props.unStigma;
refCommandNo.value = props.refCommandNo;
refCommandDate.value = props.refCommandDate;
}
/** validate check*/
function validateForm() {
const hasError = [];
for (const key in objectRef) {
if (Object.prototype.hasOwnProperty.call(objectRef, key)) {
const property = objectRef[key];
if (property.value && typeof property.value.validate === "function") {
const isValid = property.value.validate();
hasError.push(isValid);
}
}
}
if (hasError.every((result) => result === true)) {
if ((edit.value = false)) {
saveData();
} else {
editData();
}
}
}
/**
* นทกเพมขอม
*/
function saveData() {
// showLoader();
// await http
// .post(config.API.profileDisId(profileId.value), {
// id: id.value,
// level: level.value,
// detail: detail.value,
// unStigma: unStigma.value,
// refCommandNo: refCommandNo.value,
// refCommandDate:
// refCommandDate.value == null
// ? null
// : dateToISO(refCommandDate.value as Date),
// date: dateToISO(date.value),
// })
// .then((res) => {
// success($q, "");
// closeDialog()
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(async () => {
// await fetchData();
// });
closeDialog();
}
/**
* นทกแกไขขอม
*/
const editData = async () => {
// showLoader();
// await http
// .put(config.API.profileDisId(id.value), {
// id: id.value,
// level: level.value,
// detail: detail.value,
// unStigma: unStigma.value,
// refCommandNo: refCommandNo.value,
// refCommandDate:
// refCommandDate.value == null
// ? null
// : dateToISO(refCommandDate.value as Date),
// date: dateToISO(date.value as Date),
// })
// .then((res) => {
// success($q, "");
// modal.value = false;
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(async () => {
// await fetchData();
// });
closeDialog();
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const openDialogHistory = async (idOrder: string) => {
modalHistory.value = true;
id.value = idOrder;
};
function getData() {
// showLoader();
// http
// .get(config.API.profileDisId(profileId.value))
// .then((res) => {
// let data = res.data.result;
// console.log(data);
// rows.value = [];
// data.map((e: RequestItemsObject) => {
// rows.value.push({
// id: e.id,
// level: e.level,
// detail: e.detail,
// unStigma: e.unStigma,
// refCommandNo: e.refCommandNo,
// refCommandDate: e.refCommandDate ? new Date(e.refCommandDate) : null,
// date: e.date,
// createdFullName: e.createdFullName,
// createdAt: e.createdAt,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {});
const data: RequestItemsObject[] = [
{
level: "ภาคทัณฑ์",
detail: "1",
refCommandNo: "1",
refCommandDate: null,
date: new Date("2024-03-19T00:00:00"),
unStigma: "1",
id: "08dc2e0f-5631-4a7c-8ac4-0f7c99156c2e",
createdAt: new Date("2024-02-15T17:17:38.524861"),
createdFullName: "สาวิตรี ศรีสมัย",
},
{
level: "ภาคทัณฑ์",
detail: "11",
refCommandNo: "11",
refCommandDate: new Date("2024-03-11T00:00:00"),
date: new Date("2024-02-20T00:00:00"),
unStigma: "",
id: "08dc2e11-3588-44ea-8c1a-99109a4c4fe0",
createdAt: new Date("2024-02-20T12:59:47.193103"),
createdFullName: "สาวิตรี ศรีสมัย",
},
{
level: "ตัดเงินเดือน",
detail: "115",
refCommandNo: "1",
refCommandDate: new Date("2024-03-11T00:00:00"),
date: new Date("2024-02-20T00:00:00"),
unStigma: "11",
id: "08dc2e11-8054-416c-8299-81005d739a25",
createdAt: new Date("2024-02-20T12:59:47.193103"),
createdFullName: "สาวิตรี ศรีสมัย",
},
{
level: "",
detail: "test",
refCommandNo: "12",
refCommandDate: new Date("2024-03-11T00:00:00"),
date: new Date("2024-02-20T00:00:00"),
unStigma: "",
id: "08dc31d9-24a0-4870-896c-4c4ea8f7b104",
createdAt: new Date("2024-02-20T12:59:47.193103"),
createdFullName: "สาวิตรี ศรีสมัย",
},
];
rows.value = data;
}
onMounted(() => {
getData();
});
</script>
<template>
<div></div>
<div class="row items-center q-gutter-x-sm q-py-sm">
<div class="text-weight-bold text-subtitle1"></div>
<q-btn color="teal-5" icon="add" flat round @click="openDialogAdd()"
><q-tooltip>เพมขอม</q-tooltip></q-btn
>
<q-space />
<q-input
standout
dense
v-model="filterKeyword"
ref="filterRef"
outlined
placeholder="ค้นหา"
debounce="300"
>
<template v-slot:append>
<q-icon
v-if="filterKeyword == ''"
name="search"
@click.stop.prevent="filterKeyword = ''"
class="cursor-pointer"
/>
<q-icon
v-if="filterKeyword"
name="cancel"
@click.stop.prevent="filterKeyword = ''"
class="cursor-pointer"
/>
</template>
</q-input>
<q-select
v-if="mode == 'table'"
v-model="visibleColumns"
multiple
outlined
dense
options-dense
:display-value="$q.lang.table.columns"
emit-value
map-options
:options="columns"
option-value="name"
options-cover
style="min-width: 150px"
/>
<q-btn-toggle
v-model="mode"
dense
class="no-shadow"
toggle-color="grey-4"
:options="[
{ value: 'table', slot: 'table' },
{ value: 'card', slot: 'card' },
]"
>
<template v-slot:table>
<q-icon
name="format_list_bulleted"
size="24px"
:style="{
color: mode === 'table' ? '#787B7C' : '#C9D3DB',
}"
/>
</template>
<template v-slot:card>
<q-icon
name="mdi-view-grid-outline"
size="24px"
:style="{
color: mode === 'card' ? '#787B7C' : '#C9D3DB',
}"
/>
</template>
</q-btn-toggle>
</div>
<d-table
ref="table"
flat
bordered
dense
:card-container-class="mode === 'card' ? 'q-col-gutter-md' : ''"
:columns="columns"
:rows="rows"
:grid="mode === 'card'"
:paging="true"
:rows-per-page-options="[10, 25, 50, 100]"
:visible-columns="visibleColumns"
:filter="filterKeyword"
>
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th v-for="col in props.cols" :key="col.name" :props="props">
<span class="text-weight-medium">{{ col.label }}</span>
</q-th>
<q-th auto-width></q-th>
</q-tr>
</template>
<template v-slot:body="props" v-if="mode === 'table'">
<q-tr :props="props" class="cursor-pointer">
<q-td
v-for="col in props.cols"
:key="col.id"
@click="openDialogEdit(props.row)"
>
<div v-if="col.name === 'no'">
{{
(formFilter.page - 1) * formFilter.pageSize + props.rowIndex + 1
}}
</div>
<div
v-else-if="col.name == 'refCommandDate' || col.name == 'date'"
class="table_ellipsis"
>
{{ col.value == null ? null : date2Thai(col.value) }}
</div>
<div v-else>
{{ col.value ? col.value : "-" }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="openDialogHistory(props.row.id)"
>
<q-tooltip>ประวแกไขว</q-tooltip>
</q-btn>
</q-td>
</q-tr>
</template>
<template v-slot:item="props" v-else>
<div class="col-xs-12 col-sm-4 col-md-4 q-pa-lg">
<q-card flat bordered>
<q-card-section class="text-center">
<div class="text-weight-medium q-mt-md">
{{ props.row.level !== "" ? props.row.level : "-" }}
</div>
<div class="text-weight-light full-width text-center">
{{ date2Thai(props.row.date) }}
</div>
</q-card-section>
<q-card-section class="q-pa-lg">
<q-card bordered class="bg-grey-12">
<q-list>
<q-item>
<q-item-section>
<q-item-label caption>รายละเอยด</q-item-label>
<q-item-label>{{
props.row.detail !== "" ? props.row.detail : "-"
}}</q-item-label>
</q-item-section>
</q-item>
<q-item>
<q-item-section>
<q-item-label caption>างมลท</q-item-label>
<q-item-label>
{{
props.row.unStigma !== "" ? props.row.unStigma : "-"
}}</q-item-label
>
</q-item-section>
</q-item>
<q-item>
<q-item-section>
<q-item-label caption>เลขทคำส</q-item-label>
<q-item-label>
{{
props.row.refCommandNo !== ""
? props.row.refCommandNo
: "-"
}}</q-item-label
>
</q-item-section>
</q-item>
<q-item>
<q-item-section>
<q-item-label caption
>เอกสารอางอ (ลงวนท)</q-item-label
>
<q-item-label>
{{
props.row.refCommandDate
? date2Thai(props.row.refCommandDate)
: "-"
}}</q-item-label
>
</q-item-section>
</q-item>
</q-list>
</q-card>
</q-card-section>
<q-separator inset />
<q-btn
flat
color="black"
label="แก้ไขข้อมูล"
class="hover-button full-width q-pa-md"
@click="openDialogEdit(props.row)"
/>
</q-card>
</div>
</template>
<template v-slot:pagination="scope">
<q-pagination
v-model="currentPage"
active-color="primary"
color="dark"
:max="Number(maxPage)"
size="sm"
boundary-links
direction-links
></q-pagination>
</template>
<template v-slot:no-data="{ icon, message, filter }">
<div class="full-width row flex-center text-accent q-gutter-sm">
<span
><div
style="
height: 50vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
"
class="text-grey-5"
>
<q-icon name="search" size="4rem" />
<span>ไมพบขอม</span>
</div>
</span>
</div>
</template>
</d-table>
<!-- dialog add edit -->
<q-dialog v-model="modal" persistent>
<q-card style="min-width: 600px">
<form @submit.prevent="validateForm">
<q-card-section class="flex justify-between" style="padding: 0">
<DialogHeader tittle="วินัย" :close="closeDialog" />
</q-card-section>
<q-separator />
<q-card-section class="q-p-sm">
<div class="row col-12 q-col-gutter-x-xs q-col-gutter-y-xs">
<div class="col-xs-6 col-sm-6 col-md-6">
<datepicker
menu-class-name="modalfix"
v-model="date"
:locale="'th'"
autoApply
:enableTimePicker="false"
week-start="0"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
ref="dateRef"
class="full-width inputgreen cursor-pointer"
outlined
dense
:model-value="date2Thai(date)"
:rules="[(val:string) => !!val || `${'กรุณาเลือก วัน/เดือน/ปี'}`]"
hide-bottom-space
:label="`${'วัน/เดือน/ปี'}`"
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
:style="
edit
? 'color: var(--q-primary)'
: 'color: var(--q-grey)'
"
>
</q-icon>
</template>
</q-input>
</template>
</datepicker>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<q-input
ref="detailRef"
class="full-width inputgreen cursor-pointer"
outlined
dense
lazy-rules
v-model="detail"
:rules="[(val:string) => !!val || `${'กรุณากรอกรายละเอียด'}`]"
hide-bottom-space
:label="`${'รายละเอียด'}`"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<selector
class="full-width inputgreen cursor-pointer"
outlined
dense
lazy-rules
v-model="level"
:label="`${'ระดับการลงโทษทางวินัย'}`"
emit-value
map-options
option-label="name"
:options="Ops.levelOptions"
option-value="id"
use-input
input-debounce="0"
@filter="(inputValue:string,
doneFn:Function) => filterSelector(inputValue, doneFn,'levelOptions'
) "
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<q-input
class="full-width inputgreen cursor-pointer"
outlined
dense
v-model="unStigma"
hide-bottom-space
:label="`${'ล้างมลทิน'}`"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<q-input
ref="refCommandNoRef"
class="full-width inputgreen cursor-pointer"
outlined
dense
lazy-rules
v-model="refCommandNo"
hide-bottom-space
:label="`${'เลขที่คำสั่ง'}`"
:rules="[(val:string) => !!val || `${'กรุณากรอกเลขที่คำสั่ง'}`]"
>
<template v-slot:append>
<q-icon name="mdi-file" class="cursor-pointer" />
</template>
</q-input>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<datepicker
menu-class-name="modalfix"
v-model="refCommandDate"
:locale="'th'"
autoApply
:enableTimePicker="false"
week-start="0"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
class="full-width inputgreen cursor-pointer"
outlined
dense
:model-value="
(refCommandDate && date2Thai(refCommandDate as Date)) || null
"
:label="`${'เอกสารอ้างอิง (ลงวันที่)'}`"
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
:style="
edit
? 'color: var(--q-primary)'
: 'color: var(--q-grey)'
"
>
</q-icon>
</template>
<template v-if="refCommandDate && edit" v-slot:append>
<q-icon
name="cancel"
@click.stop.prevent="refCommandDate = null"
class="cursor-pointer"
/>
</template>
</q-input>
</template>
</datepicker>
</div>
</div>
</q-card-section>
<q-separator />
<q-card-actions align="right">
<q-btn
id="onSubmit"
type="submit"
dense
unelevated
label="บันทึก"
color="public"
class="q-px-md"
>
<q-tooltip>นทกขอม</q-tooltip>
</q-btn>
</q-card-actions>
</form>
</q-card>
</q-dialog>
<DialogHistory v-model:modal="modalHistory" v-model:id="id" />
</template>
<style scoped></style>

View file

@ -0,0 +1,313 @@
<script setup lang="ts">
import { ref, watch, reactive } from "vue";
import DialogHeader from "@/components/DialogHeader.vue";
import { useCounterMixin } from "@/stores/mixin";
import { useQuasar, type QTableProps } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
import type {
RequestItemsObject,
FormFilter,
} from "@/modules/04_registryNew/interface/index/discipline";
const modal = defineModel<boolean>("modal", { required: true });
const id = defineModel<string>("id", { required: true });
const $q = useQuasar();
const mixin = useCounterMixin();
const { showLoader, hideLoader, messageError, date2Thai } = mixin;
const currentPage = ref<number>(1);
const maxPage = ref<number>(1);
const filterKeyword = ref<string>("");
const rows = ref<RequestItemsObject[]>([]); //select data history
const formFilter = reactive<FormFilter>({
page: 1,
pageSize: 12,
keyword: "",
type: "",
posType: "",
posLevel: "",
retireYear: "",
rangeYear: { min: 0, max: 60 },
isShowRetire: false,
isProbation: false,
});
const visibleColumns = ref<String[]>([
"level",
"detail",
"unStigma",
"refCommandNo",
"refCommandDate",
"date",
"createdFullName",
"createdAt",
]);
const columns = ref<QTableProps["columns"]>([
{
name: "date",
align: "left",
label: "วัน เดือน ปี",
sortable: true,
field: "date",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "detail",
align: "left",
label: "รายละเอียด",
sortable: true,
field: "detail",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "level",
align: "left",
label: "ระดับการลงโทษทางวินัย",
sortable: true,
field: "level",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "unStigma",
align: "left",
label: "ล้างมลทิน",
sortable: true,
field: "unStigma",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "refCommandNo",
align: "left",
label: "เลขที่คำสั่ง",
sortable: true,
field: "refCommandNo",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "refCommandDate",
align: "left",
label: "เอกสารอ้างอิง (ลงวันที่)",
sortable: true,
field: "refCommandDate",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "createdFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "left",
label: "วันที่แก้ไข",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
function getHistory() {
showLoader();
http
.get(config.API.profileDisHisId(id.value))
.then((res) => {
let data = res.data.result;
rows.value = [];
data.map((e: RequestItemsObject) => {
rows.value.push({
id: e.id,
level: e.level,
detail: e.detail,
unStigma: e.unStigma,
refCommandNo: e.refCommandNo,
refCommandDate:
e.refCommandDate == null ? null : new Date(e.refCommandDate),
date: new Date(e.date),
createdFullName: e.createdFullName,
createdAt: new Date(e.createdAt),
});
});
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
watch(modal, (status) => {
if (status == true) {
getHistory();
filterKeyword.value = "";
} else {
filterKeyword.value = "";
}
});
</script>
<template>
<q-dialog v-model="modal" persistent>
<q-card style="min-width: 80%">
<q-card-section class="flex justify-between" style="padding: 0">
<DialogHeader
tittle="ประวัติแก้ไขวินัย"
:close="() => (modal = false)"
/>
</q-card-section>
<q-separator />
<q-card-section class="q-p-sm">
<div class="row q-gutter-sm q-mb-sm">
<q-space />
<q-input
standout
dense
v-model="filterKeyword"
ref="filterRef"
outlined
placeholder="ค้นหา"
debounce="300"
>
<template v-slot:append>
<q-icon
v-if="filterKeyword == ''"
name="search"
@click.stop.prevent="filterKeyword = ''"
class="cursor-pointer"
/>
<q-icon
v-if="filterKeyword"
name="cancel"
@click.stop.prevent="filterKeyword = ''"
class="cursor-pointer"
/>
</template>
</q-input>
<q-select
v-model="visibleColumns"
multiple
outlined
dense
options-dense
:display-value="$q.lang.table.columns"
emit-value
map-options
:options="columns"
option-value="name"
options-cover
style="min-width: 150px"
/>
</div>
<d-table
ref="table"
flat
bordered
dense
:columns="columns"
:rows="rows"
:paging="true"
:rows-per-page-options="[10, 25, 50, 100]"
:visible-columns="visibleColumns"
:filter="filterKeyword"
>
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th v-for="col in props.cols" :key="col.name" :props="props">
<span class="text-weight-medium">{{ col.label }}</span>
</q-th>
</q-tr>
</template>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td v-for="col in props.cols" :key="col.id">
<div v-if="col.name === 'no'">
{{
(formFilter.page - 1) * formFilter.pageSize +
props.rowIndex +
1
}}
</div>
<div
v-else-if="
col.name == 'refCommandDate' ||
col.name == 'date' ||
col.name == 'createdAt'
"
>
{{ col.value == null ? null : date2Thai(col.value) }}
</div>
<div v-else>
{{ col.value ? col.value : "-" }}
</div>
</q-td>
</q-tr>
</template>
<template v-slot:pagination="scope">
<q-pagination
v-model="currentPage"
active-color="primary"
color="dark"
:max="Number(maxPage)"
size="sm"
boundary-links
direction-links
></q-pagination>
</template>
<template v-slot:no-data="{ icon, message, filter }">
<div class="full-width row flex-center text-accent q-gutter-sm">
<span
><div
style="
height: 50vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
"
class="text-grey-5"
>
<q-icon name="search" size="4rem" />
<span>ไมพบขอม</span>
</div>
</span>
</div>
</template>
</d-table>
</q-card-section>
</q-card>
</q-dialog>
</template>

View file

@ -0,0 +1,41 @@
interface RequestItemsObject {
id: string;
level: string;
detail: string;
unStigma: string;
refCommandNo: string;
refCommandDate: Date | null;
date: Date;
createdFullName: string;
createdAt: Date;
}
interface FormFilter {
page: number;
pageSize: number;
keyword: string;
type: string;
posType: string;
posLevel: string;
retireYear: string | null;
rangeYear: { min: number; max: number };
isShowRetire: boolean;
isProbation: boolean;
}
interface DataOption {
id: string;
name: string;
}
interface DisciplineOps {
levelOptions: DataOption[];
}
interface MyObjectRef {
date: object | null;
detail: object | null;
refCommandNo: object | null;
[key: string]: any;
}
export type { RequestItemsObject,FormFilter,DataOption,DisciplineOps,MyObjectRef };