hrms-mgt/src/modules/04_registryNew/components/detail/Achievement/03_Insignia.vue

1378 lines
41 KiB
Vue
Raw Normal View History

<script setup lang="ts">
import { onMounted, ref, watch, reactive } from "vue";
import { useRoute } from "vue-router";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
import type { QTableProps } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import HistoryTable from "@/components/TableHistory.vue";
import DialogHeader from "@/components/DialogHeader.vue";
import type {
DataOption,
DataOptionInsignia,
InsigniaOps,
Pagination,
} from "@/modules/04_registryNew/interface/index/Main";
import type {
RequestItemsObject,
Columns,
DataProps,
} from "@/modules/04_registryNew/interface/request/Insignia";
const $q = useQuasar();
const route = useRoute();
const mixin = useCounterMixin();
const {
date2Thai,
success,
dateToISO,
messageError,
typeChangeName,
dialogMessage,
showLoader,
hideLoader,
} = mixin;
const profileId = ref<string>(
route.params.id ? route.params.id.toString() : ""
);
const insigniaData = reactive<{
id: string;
isActive: boolean;
year: number | null;
receiveDate: Date | string | null;
insigniaId: string;
insigniaType: string;
no: string;
issue: string;
volumeNo: string;
volume: string;
section: string;
page: string;
dateAnnounce: Date | null | string;
refCommandNo: string;
refCommandDate: Date | null | string;
note: string;
}>({
id: "",
isActive: true,
year: 0,
receiveDate: null,
insigniaId: "",
insigniaType: "",
no: "",
issue: "",
volumeNo: "",
volume: "",
section: "",
page: "",
dateAnnounce: null,
refCommandNo: "",
refCommandDate: null,
note: "",
});
const editRow = ref<boolean>(false);
const myForm = ref<any>();
const isEdit = ref<boolean>(false);
const modal = ref<boolean>(false);
const modeView = ref<string>("table");
const filterSearch = ref("");
const filterHistory = ref<string>("");
const modalHistory = ref<boolean>(false);
const rowsHistory = ref<RequestItemsObject[]>([]);
const tittleHistory = ref<string>("ประวัติแก้ไขเครื่องราชอิสริยาภรณ์");
const Ops = ref<InsigniaOps>({
insigniaOptions: [],
});
const OpsFilter = ref<InsigniaOps>({
insigniaOptions: [],
});
const rows = ref<any>([]);
const columns = ref<QTableProps["columns"]>([
{
name: "year",
align: "left",
label: "ปีที่ยื่นขอ",
sortable: true,
field: "year",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "receiveDate",
align: "left",
label: "วันที่ได้รับ",
sortable: true,
field: "receiveDate",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "insignia",
align: "left",
label: "ชื่อเครื่องราชฯ",
sortable: true,
field: "insigniaId",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "insigniaType",
align: "left",
label: "ลำดับชั้น",
sortable: true,
field: "insigniaType",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "no",
align: "left",
label: "ลำดับที่",
sortable: true,
field: "no",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "issue",
align: "left",
label: "ราชกิจจาฯ ฉบับที่",
sortable: true,
field: "issue",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "volumeNo",
align: "left",
label: "เล่มที่",
sortable: true,
field: "volumeNo",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "volume",
align: "left",
label: "เล่ม",
sortable: true,
field: "volume",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "section",
align: "left",
label: "ตอน",
sortable: true,
field: "section",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "page",
align: "left",
label: "หน้า",
sortable: true,
field: "page",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "dateAnnounce",
align: "left",
label: "วันที่ประกาศในราชกิจจาฯ",
sortable: true,
field: "dateAnnounce",
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: "note",
align: "left",
label: "หมายเหตุ",
sortable: true,
field: "note",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "year",
align: "left",
label: "ปีที่ยื่นขอ",
sortable: true,
field: "year",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "receiveDate",
align: "left",
label: "ลงวันที่",
sortable: true,
field: "receiveDate",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "insignia",
align: "left",
label: "ชื่อเครื่องราชฯ",
sortable: true,
field: "insignia",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "insigniaType",
align: "left",
label: "ลำดับชั้น",
sortable: true,
field: "insigniaType",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "no",
align: "left",
label: "ลำดับที่",
sortable: true,
field: "no",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "issue",
align: "left",
label: "ราชกิจจาฯ ฉบับที่",
sortable: true,
field: "issue",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "volumeNo",
align: "left",
label: "เล่มที่",
sortable: true,
field: "volumeNo",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "volume",
align: "left",
label: "เล่ม",
sortable: true,
field: "volume",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "section",
align: "left",
label: "ตอน",
sortable: true,
field: "section",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "page",
align: "left",
label: "หน้า",
sortable: true,
field: "page",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "dateAnnounce",
align: "left",
label: "วันที่ประกาศในราชกิจจาฯ",
sortable: true,
field: "dateAnnounce",
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" }),
},
]);
const visibleColumns = ref<String[]>([
"insignia",
"insigniaType",
"year",
"no",
"issue",
"volumeNo",
"volume",
"section",
"page",
"receiveDate",
"dateAnnounce",
"refCommandNo",
"refCommandDate",
"note",
"createdAt",
]);
const visibleColumnsHistory = ref<String[]>([
"insignia",
"insigniaType",
"year",
"no",
"issue",
"volumeNo",
"volume",
"section",
"page",
"receiveDate",
"dateAnnounce",
"refCommandNo",
"refCommandDate",
"createdFullName",
"createdAt",
]);
const formFilter = reactive({
page: 1,
pageSize: 10,
keyword: "",
});
const pagination = ref({
page: formFilter.page,
rowsPerPage: formFilter.pageSize,
});
async function fetchData() {
if (profileId.value) {
showLoader();
await http
.get(config.API.profileNewInsignByProfileId(profileId.value))
.then((res) => {
let data = res.data.result;
rows.value = [];
data.map((e: any) => {
rows.value.push({
id: e.id,
insigniaId: e.insigniaId,
insigniaType: e.insigniaType,
year: e.year,
no: e.no,
issue: e.issue,
volumeNo: e.volumeNo,
volume: e.volume,
section: e.section,
page: e.page,
receiveDate: e.receiveDate,
dateAnnounce: e.dateAnnounce,
refCommandNo: e.refCommandNo,
refCommandDate: e.refCommandDate,
createdFullName: e.createdFullName,
createdAt: e.createdAt,
note: e.note,
});
});
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
// store.isLoad++;
});
}
}
async function fetchInsignia() {
showLoader();
await http
.get(config.API.insignia)
.then((res) => {
const data = res.data.result;
let option: DataOptionInsignia[] = [];
data.map((r: any) => {
option.push({
id: r.id.toString(),
name: r.name.toString() + ` (${r.shortName})`,
typeName:
r.insigniaType == null ? null : r.insigniaType.name.toString(),
});
});
Ops.value.insigniaOptions = option;
OpsFilter.value.insigniaOptions = option;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
// store.isLoad++;
});
}
async function saveData() {
if (profileId.value) {
showLoader();
await http
.post(config.API.profileNewInsign, {
profileId: profileId.value,
isActive: insigniaData.isActive,
year: insigniaData.year,
no: insigniaData.no,
volume: insigniaData.volume,
section: insigniaData.section,
page: insigniaData.page,
receiveDate: dateToISO(insigniaData.receiveDate as Date),
insigniaId: insigniaData.insigniaId,
insigniaType: insigniaData.insigniaType,
dateAnnounce: insigniaData.dateAnnounce
? dateToISO(insigniaData.dateAnnounce as Date)
: null,
issue: insigniaData.issue,
volumeNo: insigniaData.volumeNo,
refCommandDate:
insigniaData.refCommandDate == null
? null
: dateToISO(insigniaData.refCommandDate as Date),
refCommandNo: insigniaData.refCommandNo,
// note: note.value,
})
.then((res) => {
success($q, "บันทึกข้อมูลสำเร็จ");
modal.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
});
}
}
async function editData() {
showLoader();
await http
.patch(config.API.profileNewInsignById(insigniaData.id), {
profileId: profileId.value,
isActive: insigniaData.isActive,
year: insigniaData.year,
no: insigniaData.no,
volume: insigniaData.volume,
section: insigniaData.section,
page: insigniaData.page,
receiveDate: dateToISO(insigniaData.receiveDate as Date),
insigniaId: insigniaData.insigniaId,
insigniaType: insigniaData.insigniaType,
dateAnnounce: insigniaData.dateAnnounce
? dateToISO(insigniaData.dateAnnounce as Date)
: null,
issue: insigniaData.issue,
volumeNo: insigniaData.volumeNo,
refCommandDate:
insigniaData.refCommandDate == null
? null
: dateToISO(insigniaData.refCommandDate as Date),
refCommandNo: insigniaData.refCommandNo,
// note: note.value,
})
.then((res) => {
success($q, "บันทึกข้อมูลสำเร็จ");
modal.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
});
}
async function clickDelete(dataId: string) {
$q.dialog({
title: `ลบข้อมูล`,
message: `ต้องการทำการลบข้อมูลนี้ใช่หรือไม่?`,
cancel: "ยกเลิก",
ok: "ยืนยัน",
persistent: true,
})
.onOk(async () => {
showLoader();
await http
.delete(config.API.profileNewInsignById(dataId))
.then((res) => {
success($q, "ลบข้อมูลสำเร็จ");
modal.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
});
})
.onCancel(async () => {
await fetchData();
});
}
function onClickOpenDialog(editStatus: boolean = false, props?: any) {
modal.value = true;
editRow.value = false;
if (editStatus && props) {
isEdit.value = editStatus;
insigniaData.id = props.row.id;
insigniaData.year = props.row.year == 0 ? 0 : props.row.year;
insigniaData.receiveDate = props.row.receiveDate;
insigniaData.insigniaId = props.row.insigniaId;
insigniaData.insigniaType = props.row.insigniaType;
insigniaData.no = props.row.no;
insigniaData.issue = props.row.issue;
insigniaData.volumeNo = props.row.volumeNo;
insigniaData.volume = props.row.volume;
insigniaData.section = props.row.section;
insigniaData.page = props.row.page;
insigniaData.dateAnnounce =
props.row.dateAnnounce == "-" ? "" : props.row.dateAnnounce;
insigniaData.refCommandNo = props.row.refCommandNo;
insigniaData.refCommandDate =
props.row.refCommandDate == "-" ? null : props.row.refCommandDate;
insigniaData.note = props.note;
} else {
isEdit.value = editStatus;
insigniaData.id = "";
insigniaData.year = 0;
insigniaData.receiveDate = "";
insigniaData.insigniaId = "";
insigniaData.insigniaType = "";
insigniaData.no = "";
insigniaData.issue = "";
insigniaData.volumeNo = "";
insigniaData.volume = "";
insigniaData.section = "";
insigniaData.page = "";
insigniaData.dateAnnounce = null;
insigniaData.refCommandNo = "";
insigniaData.refCommandDate = null;
insigniaData.note = "";
}
}
async function clickClose() {
if (editRow.value == true) {
$q.dialog({
title: `ข้อมูลมีการแก้ไข`,
message: `ยืนยันที่จะปิดโดยไม่บันทึกใช่หรือไม่?`,
cancel: "ยกเลิก",
ok: "ยืนยัน",
persistent: true,
}).onOk(async () => {
modal.value = false;
editRow.value = false;
// next.value = false;
// previous.value = false;
});
} else {
modal.value = false;
// next.value = false;
// previous.value = false;
}
}
async function clickHistory(row: RequestItemsObject) {
modalHistory.value = true;
// showLoader();
// await http
// .get(config.API.profileInsignHisId(row.id))
// .then((res) => {
// let data = res.data.result;
// rowsHistory.value = [];
// data.map((e: ResponseObject) => {
// rowsHistory.value.push({
// id: e.id,
// insignia: e.insignia,
// insigniaId: e.insigniaId,
// insigniaType: e.insigniaType,
// year: e.year,
// no: e.no,
// issue: e.issue,
// volumeNo: e.volumeNo,
// volume: e.volume,
// section: e.section,
// page: e.page,
// receiveDate: new Date(e.receiveDate),
// dateAnnounce: new Date(e.dateAnnounce),
// refCommandNo: e.refCommandNo,
// refCommandDate:
// e.refCommandDate == null ? null : new Date(e.refCommandDate),
// createdFullName: e.createdFullName,
// createdAt: new Date(e.createdAt),
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// hideLoader();
// });
}
function onSubmit() {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
isEdit.value ? await editData() : await saveData();
modal.value = false;
}
});
}
function filterSelector(val: any, update: Function, refData: string) {
switch (refData) {
case "insigniaOptions":
update(() => {
Ops.value.insigniaOptions = OpsFilter.value.insigniaOptions.filter(
(v: DataOption) => v.name.indexOf(val) > -1
);
});
break;
default:
break;
}
}
watch(
() => insigniaData.insigniaId,
(count: string, prevCount: string) => {
const insigniaTypeFilter = Ops.value.insigniaOptions.filter(
(r: DataOptionInsignia) => r.id === insigniaData.insigniaId
);
if (insigniaTypeFilter.length > 0) {
insigniaData.insigniaType = insigniaTypeFilter[0].typeName;
}
}
);
onMounted(async () => {
await fetchInsignia();
await fetchData();
});
</script>
<template>
<q-toolbar style="padding: 0px" class="text-primary">
<q-btn flat round dense icon="add" @click="onClickOpenDialog()">
<q-tooltip>เพ</q-tooltip>
</q-btn>
<q-space />
<q-input
dense
outlined
label="ค้นหา"
class="q-mr-sm"
v-model="filterSearch"
>
<template v-slot:append>
<q-icon name="search" />
</template>
</q-input>
<q-select
v-if="modeView === 'table'"
dense
multiple
outlined
emit-value
map-options
options-cover
options-dense
class="q-mr-sm"
option-value="name"
style="min-width: 150px"
v-model="visibleColumns"
:options="columns"
:display-value="$q.lang.table.columns"
/>
<q-btn-toggle
dense
v-model="modeView"
toggle-color="grey-4"
class="no-shadow toggle-borderd"
:options="[
{ value: 'table', slot: 'table' },
{ value: 'card', slot: 'card' },
]"
>
<template v-slot:table>
<q-icon
name="format_list_bulleted"
size="24px"
:style="{
color: modeView === 'table' ? '#787B7C' : '#C9D3DB',
}"
/>
</template>
<template v-slot:card>
<q-icon
name="mdi-view-grid-outline"
size="24px"
:style="{
color: modeView === 'card' ? '#787B7C' : '#C9D3DB',
}"
/>
</template>
</q-btn-toggle>
</q-toolbar>
<d-table
flat
dense
bordered
ref="table"
class="custom-header-table"
:rows="rows"
:paging="true"
:columns="columns"
:filter="filterSearch"
:grid="modeView === 'card'"
:visible-columns="visibleColumns"
:rows-per-page-options="[20, 50, 100]"
>
<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-tr>
</template>
<template v-slot:body="props" v-if="modeView === 'table'">
<q-tr :props="props" class="cursor-pointer">
<q-td
v-for="col in props.cols"
class="cursor-pointer"
:key="col.name"
:props="props"
@click="onClickOpenDialog(true, props)"
>
<div
v-if="
col.name == 'receiveDate' ||
col.name == 'dateAnnounce' ||
col.name == 'refCommandDate'
"
class="table_ellipsis"
>
{{ col.value == null ? "-" : date2Thai(col.value) }}
</div>
<div v-else-if="col.name == 'year'" class="table_ellipsis">
{{ col.value + 543 }}
</div>
<div v-else-if="col.name == 'insignia'" class="table_ellipsis">
{{
col.value
? (Ops.insigniaOptions.find((r) => r.id === col.value) || {})
.name
: "-"
}}
</div>
<div v-else class="table_ellipsis">
{{ col.value ? col.value : "-" }}
</div>
</q-td>
<q-td auto-width>
<q-btn
flat
dense
round
size="14px"
color="info"
icon="mdi-history"
@click="clickHistory(props.row)"
>
<q-tooltip>ประวแกไขเครองราชอสรยาภรณ</q-tooltip>
</q-btn>
<q-btn
flat
dense
round
size="14px"
color="red"
icon="mdi-delete"
@click="clickDelete(props.row.id)"
>
<q-tooltip>ลบขอม</q-tooltip>
</q-btn>
</q-td>
</q-tr>
</template>
<template v-slot:item="props" v-else>
<div
class="q-pa-xs col-xs-12 col-sm-6 col-md-6 col-lg-6 grid-style-transition"
>
<q-card bordered>
<q-card-actions class="bg-grey-3" align="right">
<q-btn
flat
round
color="primary"
icon="mdi-pencil-outline"
@click="onClickOpenDialog(true, props)"
>
<q-tooltip>แกไขขอม</q-tooltip>
</q-btn>
<q-btn
flat
round
color="info"
icon="mdi-history"
@click="clickHistory(props.row)"
>
<q-tooltip>ประวแกไขเครองราชอสรยาภรณ</q-tooltip>
</q-btn>
</q-card-actions>
<q-separator />
<div>
<q-item
v-for="(col, index) in props.cols.filter(
(col) => col.name !== 'desc'
)"
:key="col.name"
:class="index % 2 !== 0 ? 'bg-grey-1' : ''"
>
<q-item-section class="text-grey-6">
<q-item-label>{{ col.label }}</q-item-label>
</q-item-section>
<q-item-section class="text-dark">
<q-item-label
v-if="
col.name == 'receiveDate' ||
col.name == 'dateAnnounce' ||
col.name == 'refCommandDate'
"
>
{{ col.value ? date2Thai(col.value) : "-" }}
</q-item-label>
<q-item-label v-else-if="col.name == 'year'">
{{ col.value + 543 }}
</q-item-label>
<q-item-label
v-else-if="col.name == 'insignia'"
class="table_ellipsis"
>
{{
col.value
? (
Ops.insigniaOptions.find((r) => r.id === col.value) ||
{}
).name
: "-"
}}
</q-item-label>
<q-item-label v-else>
{{ col.value ? col.value : "-" }}
</q-item-label>
</q-item-section>
</q-item>
</div>
</q-card>
</div>
</template>
</d-table>
<q-dialog v-model="modal" persistent>
<q-card style="width: 600px">
<q-form greedy ref="myForm" @submit="onSubmit">
<DialogHeader tittle="เครื่องราชอิสริยาภรณ์" :close="clickClose" />
<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
autoApply
year-picker
v-model="insigniaData.year"
week-start="0"
menu-class-name="modalfix"
:locale="'th'"
:enableTimePicker="false"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
dense
outlined
lazy-rules
hide-bottom-space
class="inputgreen"
:model-value="insigniaData.year !== 0 ? (insigniaData.year as number) + 543 : null"
:rules="[
(val:string) =>
!!val ||
`${'กรุณาเลือกปีที่ยื่นขอพระราชทานเครื่องราชฯ'}`,
]"
:label="`${'ปีที่ยื่นขอพระราชทานเครื่องราชฯ'}`"
@update:modelValue="() => (editRow = true)"
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
color="primary"
/>
</template>
</q-input>
</template>
</datepicker>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<datepicker
autoApply
borderless
week-start="0"
menu-class-name="modalfix"
v-model="insigniaData.receiveDate"
:locale="'th'"
:enableTimePicker="false"
>
<template #year="{ year }">
{{ year + 543 }}
</template>
<template #year-overlay-value="{ value }">
{{ parseInt(value + 543) }}
</template>
<template #trigger>
<q-input
dense
outlined
hide-bottom-space
class="inputgreen"
for="inputDatereceive"
ref="dateReceivedRef"
:model-value="
insigniaData.receiveDate != null
? date2Thai(insigniaData.receiveDate as Date)
: null
"
:label="`${'วันที่ได้รับ'}`"
:rules="[(val) => !!val || `${'กรุณาเลือกวันที่ได้รับ'}`]"
@update:modelValue="() => (editRow = true)"
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
color="primary"
/>
</template>
</q-input>
</template>
</datepicker>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<selector
dense
outlined
use-input
emit-value
lazy-rules
map-options
hide-bottom-space
option-value="id"
input-debounce="0"
option-label="name"
v-model="insigniaData.insigniaId"
class="inputgreen"
:label="`${'ชื่อเครื่องราชฯ'}`"
:options="Ops.insigniaOptions"
:rules="[(val:string) => !!val || `${'กรุณาเลือกชื่อเครื่องราชฯ'}`]"
@filter="(inputValue:any,
doneFn:Function) => filterSelector(inputValue, doneFn,'insigniaOptions'
) "
@update:modelValue="() => (editRow = true)"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<q-input
dense
readonly
outlined
lazy-rules
hide-bottom-space
v-model="insigniaData.insigniaType"
:label="`${'ลำดับชั้น'}`"
@update:modelValue="() => (editRow = true)"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<q-input
dense
outlined
lazy-rules
hide-bottom-space
v-model="insigniaData.no"
class="inputgreen"
:label="`${'ลำดับที่'}`"
:rules="[(val:string) => !!val || `${'กรุณากรอกลำดับที่'}`]"
@update:modelValue="() => (editRow = true)"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<q-input
dense
outlined
lazy-rules
hide-bottom-space
v-model="insigniaData.issue"
class="inputgreen"
:label="`${'ราชกิจจาฯ ฉบับที่'}`"
:rules="[(val:string) => !!val || `${'กรุณากรอกราชกิจจาฯ ฉบับที่'}`]"
@update:modelValue="() => (editRow = true)"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<q-input
dense
outlined
lazy-rules
hide-bottom-space
v-model="insigniaData.volumeNo"
class="inputgreen"
:label="`${'เล่มที่'}`"
:rules="[(val:string) => !!val || `${'กรุณากรอกเล่มที่'}`]"
@update:modelValue="() => (editRow = true)"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<q-input
dense
outlined
lazy-rules
hide-bottom-space
v-model="insigniaData.volume"
class="inputgreen"
:label="`${'เล่ม'}`"
:rules="[(val:string) => !!val || `${'กรุณากรอกเล่ม'}`]"
@update:modelValue="() => (editRow = true)"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<q-input
dense
outlined
lazy-rules
hide-bottom-space
v-model="insigniaData.section"
class="inputgreen"
:label="`${'ตอน'}`"
:rules="[(val:string) => !!val || `${'กรุณากรอกตอน'}`]"
@update:modelValue="() => (editRow = true)"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<q-input
dense
lazy-rules
outlined
hide-bottom-space
v-model="insigniaData.page"
class="inputgreen"
:label="`${'หน้า'}`"
:rules="[(val:string) => !!val || `${'กรุณากรอกหน้า'}`]"
@update:modelValue="() => (editRow = true)"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<datepicker
autoApply
week-start="0"
v-model="insigniaData.dateAnnounce"
menu-class-name="modalfix"
:locale="'th'"
:enableTimePicker="false"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
dense
outlined
lazy-rules
hide-bottom-space
class="inputgreen"
:model-value="date2Thai(insigniaData.dateAnnounce as Date)"
:label="`${'วันที่ประกาศในราชกิจจาฯ'}`"
:rules="[
(val:string) =>
!!val || `${'กรุณาเลือกวันที่ประกาศในราชกิจจาฯ'}`,
]"
@update:modelValue="() => (editRow = true)"
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
color="primary"
/>
</template>
</q-input>
</template>
</datepicker>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<q-input
dense
outlined
lazy-rules
hide-bottom-space
v-model="insigniaData.refCommandNo"
class="inputgreen"
:label="`${'เลขที่คำสั่ง'}`"
@update:modelValue="() => (editRow = true)"
>
<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
autoApply
week-start="0"
v-model="insigniaData.refCommandDate"
menu-class-name="modalfix"
:locale="'th'"
:enableTimePicker="false"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
dense
outlined
clearable
lazy-rules
hide-bottom-space
class="inputgreen"
:label="`${'เอกสารอ้างอิง (ลง วัน/เดือน/ปี)'}`"
:model-value="
date2Thai(insigniaData.refCommandDate as Date)
"
@clear="insigniaData.refCommandDate = ''"
@update:modelValue="() => (editRow = true)"
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
color="primary"
/>
</template>
</q-input>
</template>
</datepicker>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<q-input
dense
outlined
hide-bottom-space
v-model="insigniaData.note"
class="inputgreen"
label="หมายเหตุ"
@update:modelValue="() => (editRow = true)"
/>
</div>
</div>
</q-card-section>
<q-separator />
<div class="text-right q-pa-sm">
<q-btn
dense
unelevated
label="บันทึก"
id="onSubmit"
type="submit"
color="public"
class="q-px-md"
>
<q-tooltip>นทกขอม</q-tooltip>
</q-btn>
</div>
</q-form>
</q-card>
</q-dialog>
<history-table
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div
v-if="
col.name == 'receiveDate' ||
col.name == 'dateAnnounce' ||
col.name == 'createdAt' ||
col.name == 'refCommandDate'
"
class="table_ellipsis"
>
{{ col.value ? date2Thai(col.value) : "-" }}
</div>
<div v-else-if="col.name == 'year'" class="table_ellipsis">
{{ col.value ? col.value + 543 : "-" }}
</div>
<div v-else class="table_ellipsis">
{{ col.value ? col.value : "-" }}
</div>
</q-td>
</q-tr>
</template>
</history-table>
</template>
<style lang="scss">
.modalfix {
position: fixed !important;
}
</style>