hrms-mgt/src/modules/13_salary/components/InfoDiscipline.vue

199 lines
4.5 KiB
Vue
Raw Normal View History

<script setup lang="ts">
import { ref, onMounted } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import { useQuasar } from "quasar";
/**
* importType
*/
import type { QTableProps } from "quasar";
import type { DataDiscipline } from "@/modules/13_salary/interface/response/Main";
/**
* importStore
*/
import { useCounterMixin } from "@/stores/mixin";
const $q = useQuasar();
2024-12-10 11:44:02 +07:00
const { date2Thai, showLoader, hideLoader, messageError,onSearchDataTable } = useCounterMixin();
/**
* props
*/
const profileId = defineModel<string>("profileId", { required: true });
const employeeClass = defineModel<string>("employeeClass", { required: true });
/**
* Table
*/
const keyword = ref<string>("");
const rows = ref<DataDiscipline[]>([]);
2024-12-10 11:44:02 +07:00
const rowsData = ref<DataDiscipline[]>([]);
const columns = ref<QTableProps["columns"]>([
{
name: "date",
align: "left",
label: "วัน เดือน ปี",
sortable: true,
field: "date",
format: (v) => date2Thai(v),
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "detail",
align: "left",
label: "รายละเอียด",
sortable: true,
field: "detail",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "level",
align: "left",
label: "ระดับการลงโทษทางวินัย",
sortable: true,
field: "level",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "unStigma",
align: "left",
label: "ประเภทคำสั่ง",
sortable: true,
field: "unStigma",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "refCommandNo",
align: "left",
label: "เลขที่คำสั่ง",
sortable: true,
field: "refCommandNo",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "refCommandDate",
align: "left",
label: "เอกสารอ้างอิง (ลงวันที่)",
sortable: true,
field: "refCommandDate",
format: (v) => date2Thai(v),
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
]);
const visibleColumns = ref<string[]>([
"level",
"detail",
"unStigma",
"refCommandNo",
"refCommandDate",
"date",
]);
/**
* function fetch อมลว
*/
function fetchListDiscipline() {
showLoader();
http
2024-08-29 10:25:35 +07:00
.get(config.API.disciplineListCard(profileId.value, employeeClass.value))
.then((res) => {
rows.value = res.data.result;
2024-12-10 11:44:02 +07:00
rowsData.value = res.data.result;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
2024-12-10 11:44:02 +07:00
function onSearch() {
rows.value = onSearchDataTable(
keyword.value,
rowsData.value,
columns.value ? columns.value : []
);
}
onMounted(() => {
fetchListDiscipline();
});
</script>
<template>
2024-07-19 11:50:08 +07:00
<q-card-section class="q-pt-none">
<div class="row items-center q-gutter-x-sm q-pb-sm">
<q-space />
2024-12-10 11:44:02 +07:00
<q-input
dense
outlined
v-model="keyword"
label="ค้นหา"
class="q-mr-sm"
@keydown.enter="onSearch"
>
<template v-slot:append>
2024-12-10 11:44:02 +07:00
<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"
2024-11-05 16:33:46 +07:00
style="min-width: 140px"
/>
</div>
<div class="col-12">
<d-table
ref="table"
row-key="id"
flat
bordered
dense
:paging="true"
:rows-per-page-options="[20, 50, 100]"
:visible-columns="visibleColumns"
:rows="rows"
:columns="columns"
>
<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">
<q-td v-for="col in props.cols" :key="col.id">
<div class="table_ellipsis">
{{ col.value ? col.value : "-" }}
</div>
</q-td>
</q-tr>
</template>
</d-table>
</div>
</q-card-section>
</template>
<style scoped></style>