367 lines
11 KiB
Vue
367 lines
11 KiB
Vue
<script setup lang="ts">
|
|
import { ref, onMounted } from "vue";
|
|
import { useQuasar } from "quasar";
|
|
|
|
import { checkPermission } from "@/utils/permissions";
|
|
import { useCounterMixin } from "@/stores/mixin";
|
|
import { useInsigniaDataStore } from "@/modules/07_insignia/store";
|
|
import config from "@/app.config";
|
|
import http from "@/plugins/http";
|
|
|
|
/** import Type*/
|
|
import type { QTableProps } from "quasar";
|
|
import type { FormProprsalsRound2 } from "@/modules/07_insignia/interface/request/Main";
|
|
|
|
import DialogDetail from "@/modules/07_insignia/components/1_Round/DialogDetail.vue";
|
|
|
|
/** use */
|
|
const $q = useQuasar(); //ใช้ noti quasar
|
|
const storeInsignia = useInsigniaDataStore();
|
|
const mixin = useCounterMixin();
|
|
const {
|
|
date2Thai,
|
|
success,
|
|
messageError,
|
|
showLoader,
|
|
hideLoader,
|
|
dialogRemove,
|
|
onSearchDataTable,
|
|
} = mixin;
|
|
|
|
/** Table */
|
|
const rows = ref<FormProprsalsRound2[]>([]); //รายการรอบการเสนอขอพระราชทานเครื่องราชอิสริยาภรณ์
|
|
const rowsData = ref<FormProprsalsRound2[]>([]); //รายการรอบการเสนอขอพระราชทานเครื่องราชอิสริยาภรณ์
|
|
const filterKeyword = ref<string>(""); //คำค้นหาข้อมูลในตาราง
|
|
const filterRef = ref<HTMLInputElement | null>(null);
|
|
const columns = ref<QTableProps["columns"]>([
|
|
{
|
|
name: "period_name",
|
|
align: "left",
|
|
label: "รอบการเสนอขอพระราชทานเครื่องราชฯ",
|
|
sortable: true,
|
|
field: "period_name",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "period_year",
|
|
align: "left",
|
|
label: "ปีที่เสนอ",
|
|
sortable: true,
|
|
field: "period_year",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "period_start",
|
|
align: "left",
|
|
label: "วันที่เริ่มต้น",
|
|
sortable: true,
|
|
field: "period_start",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "period_end",
|
|
align: "left",
|
|
label: "วันที่สิ้นสุด",
|
|
sortable: true,
|
|
field: "period_end",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "statusRoyal",
|
|
align: "left",
|
|
label: "สถานะ",
|
|
sortable: false,
|
|
field: "statusRoyal",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
]);
|
|
const visibleColumns = ref<string[]>([
|
|
"period_name",
|
|
"period_year",
|
|
"period_start",
|
|
"period_end",
|
|
"statusRoyal",
|
|
]);
|
|
const pagination = ref({
|
|
descending: false,
|
|
page: 1,
|
|
rowsPerPage: 10,
|
|
});
|
|
|
|
const modalForm = ref<boolean>(false); //แสดงรายละเอียด
|
|
const actionType = ref<string>(""); // ประเภท ดูรายละเอียด,แก้ไข
|
|
const roundId = ref<string>(""); //id ที่ต้องการ ดูรายละเอียด,แก้ไข
|
|
|
|
/**
|
|
* Function เรียกรายการรอบการเสนอขอพระราชทานเครื่องราชอิสริยาภรณ์
|
|
*/
|
|
async function fetchData() {
|
|
showLoader();
|
|
await http
|
|
.get(config.API.listRoundInsignia(), { params: { path: "ROUND" } })
|
|
.then(async (res) => {
|
|
const data = res.data.result;
|
|
const listData = await data.map((e: FormProprsalsRound2) => ({
|
|
period_id: e.period_id,
|
|
period_name: e.period_name,
|
|
period_year: e.period_year + 543,
|
|
period_amount: e.period_amount,
|
|
period_start:
|
|
e.period_start == null ? null : date2Thai(new Date(e.period_start)),
|
|
period_end:
|
|
e.period_end == null ? null : date2Thai(new Date(e.period_end)),
|
|
period_isActive: e.period_isActive,
|
|
period_doc: e.period_doc,
|
|
period_status: e.period_status,
|
|
statusRoyal: storeInsignia.convertStatus(e.period_status),
|
|
}));
|
|
|
|
rows.value = listData;
|
|
rowsData.value = listData;
|
|
})
|
|
.catch((e) => {
|
|
messageError($q, e);
|
|
})
|
|
.finally(() => {
|
|
hideLoader();
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Function ยืนยันการลบรอบการเสนอขอ
|
|
* @param id รอบการเสนขอ
|
|
*/
|
|
function clickDelete(id: string) {
|
|
dialogRemove($q, async () => {
|
|
showLoader();
|
|
await http
|
|
.delete(config.API.RoundInsignia(id))
|
|
.then(async () => {
|
|
await fetchData();
|
|
await success($q, "ลบข้อมูลสำเร็จ");
|
|
})
|
|
.catch((e) => {
|
|
messageError($q, e);
|
|
})
|
|
.finally(() => {
|
|
hideLoader();
|
|
});
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Function กำหนดค่า filterKeyword เป็นค่าว่าง
|
|
*/
|
|
function resetFilter() {
|
|
filterKeyword.value = "";
|
|
if (filterRef.value) {
|
|
filterRef.value.focus();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* function ดูข้อมูลรายละเอียดรอบการเสนอขอพระราชทานเครื่องราชอิสริยาภรณ์
|
|
* @param action ประเภท ดูรายละเอียด,แก้ไข
|
|
* @param id id ที่ต้องการ ดูรายละเอียด,แก้ไข
|
|
*/
|
|
function onOpenFormDetail(action: string = "", id: string = "") {
|
|
modalForm.value = true;
|
|
actionType.value = action;
|
|
roundId.value = id;
|
|
}
|
|
|
|
function onSearch() {
|
|
rows.value = onSearchDataTable(
|
|
filterKeyword.value,
|
|
rowsData.value,
|
|
columns.value ? columns.value : []
|
|
);
|
|
}
|
|
|
|
/**
|
|
* ทำงานเมื่อ Componenets ถูกเรียกใช้งาน
|
|
*/
|
|
onMounted(async () => {
|
|
await fetchData();
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<div class="toptitle text-dark col-12 row items-center">
|
|
รายการรอบการเสนอขอพระราชทานเครื่องราชอิสริยาภรณ์
|
|
</div>
|
|
<q-card flat bordered class="col-12 q-mt-sm q-pa-md">
|
|
<div class="row q-col-gutter-sm">
|
|
<div class="row col-12 q-col-gutter-sm">
|
|
<div>
|
|
<q-btn
|
|
v-if="checkPermission($route)?.attrIsCreate"
|
|
@click="onOpenFormDetail()"
|
|
flat
|
|
round
|
|
color="add"
|
|
icon="mdi-plus"
|
|
>
|
|
<q-tooltip>เพิ่มรายการรอบการเสนอขอ</q-tooltip>
|
|
</q-btn>
|
|
</div>
|
|
<q-space />
|
|
|
|
<q-input
|
|
standout
|
|
dense
|
|
v-model="filterKeyword"
|
|
ref="filterRef"
|
|
outlined
|
|
debounce="300"
|
|
placeholder="ค้นหา"
|
|
@keydown.enter="onSearch"
|
|
>
|
|
<template v-slot:append>
|
|
<q-icon name="search" />
|
|
</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"
|
|
style="min-width: 140px"
|
|
/>
|
|
</div>
|
|
<div class="col-12">
|
|
<d-table
|
|
ref="table"
|
|
:columns="columns"
|
|
:rows="rows"
|
|
row-key="Order"
|
|
flat
|
|
bordered
|
|
:paging="true"
|
|
dense
|
|
:visible-columns="visibleColumns"
|
|
v-model:pagination="pagination"
|
|
>
|
|
<template v-slot:header="props">
|
|
<q-tr :props="props">
|
|
<q-th auto-width />
|
|
<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">
|
|
<q-tr :props="props">
|
|
<q-td auto-width>
|
|
<!-- <q-btn
|
|
dense
|
|
flat
|
|
round
|
|
color="primary"
|
|
@click="clickListInsignia(props.row.period_id)"
|
|
icon="mdi-account-check"
|
|
>
|
|
<q-tooltip>ผู้ได้รับเครื่องราชฯ</q-tooltip>
|
|
</q-btn> -->
|
|
|
|
<q-btn
|
|
v-if="checkPermission($route)?.attrIsGet"
|
|
dense
|
|
flat
|
|
round
|
|
color="info"
|
|
@click="onOpenFormDetail('view', props.row.period_id)"
|
|
icon="mdi-eye"
|
|
>
|
|
<q-tooltip>รายละเอียด</q-tooltip>
|
|
</q-btn>
|
|
|
|
<q-btn
|
|
v-if="
|
|
checkPermission($route)?.attrIsGet &&
|
|
checkPermission($route)?.attrIsUpdate &&
|
|
props.row.period_status !== 'DONE'
|
|
"
|
|
dense
|
|
flat
|
|
round
|
|
color="edit"
|
|
@click="onOpenFormDetail('edit', props.row.period_id)"
|
|
icon="edit"
|
|
>
|
|
<q-tooltip>แก้ไขข้อมูล</q-tooltip>
|
|
</q-btn>
|
|
<q-btn
|
|
v-if="
|
|
checkPermission($route)?.attrIsDelete &&
|
|
props.row.period_status !== 'DONE'
|
|
"
|
|
dense
|
|
flat
|
|
round
|
|
color="red"
|
|
@click="clickDelete(props.row.period_id)"
|
|
icon="mdi-delete"
|
|
>
|
|
<q-tooltip>ลบข้อมูล</q-tooltip>
|
|
</q-btn>
|
|
</q-td>
|
|
|
|
<q-td v-for="col in props.cols" :key="col.id">
|
|
<div>
|
|
{{ col.value ?? "-" }}
|
|
</div>
|
|
</q-td>
|
|
<q-td auto-width>
|
|
<q-btn
|
|
v-if="
|
|
props.row.period_doc !== null &&
|
|
checkPermission($route)?.attrIsGet
|
|
"
|
|
dense
|
|
type="a"
|
|
flat
|
|
target="_blank"
|
|
round
|
|
color="light-blue-8"
|
|
icon="mdi-file-download"
|
|
:href="props.row.period_doc"
|
|
>
|
|
<q-tooltip>ดาวน์โหลดเอกสารประกอบ </q-tooltip>
|
|
</q-btn>
|
|
</q-td>
|
|
</q-tr>
|
|
</template>
|
|
</d-table>
|
|
</div>
|
|
</div>
|
|
</q-card>
|
|
|
|
<DialogDetail
|
|
v-model:modal="modalForm"
|
|
:actionType="actionType"
|
|
:round-id="roundId"
|
|
:fetch-list="fetchData"
|
|
/>
|
|
</template>
|
|
|
|
<style lang="scss" scope></style>
|