2024-02-15 11:46:25 +07:00
|
|
|
<script setup lang="ts">
|
2024-02-16 11:12:16 +07:00
|
|
|
import { ref, onMounted, reactive, watch } from "vue";
|
2024-02-15 11:46:25 +07:00
|
|
|
import { useQuasar } from "quasar";
|
|
|
|
|
import { useRouter } from "vue-router";
|
2024-02-16 15:57:30 +07:00
|
|
|
import http from "@/plugins/http";
|
|
|
|
|
import config from "@/app.config";
|
2024-02-15 11:46:25 +07:00
|
|
|
|
2024-02-15 18:01:15 +07:00
|
|
|
/** importType*/
|
|
|
|
|
import type { QTableProps } from "quasar";
|
|
|
|
|
import type {
|
|
|
|
|
NewPagination,
|
|
|
|
|
ItemsMenu,
|
|
|
|
|
} from "@/modules/13_salary/interface/index/Main";
|
|
|
|
|
import type { Salary } from "@/modules/13_salary/interface/response/Main";
|
|
|
|
|
import type { FormQuerySalary } from "@/modules/13_salary/interface/request/Main";
|
|
|
|
|
|
|
|
|
|
import DialogFormMain from "@/modules/13_salary/components/SalaryChart/DialogFormMain.vue";
|
|
|
|
|
|
|
|
|
|
/** importStore*/
|
|
|
|
|
import { useCounterMixin } from "@/stores/mixin";
|
|
|
|
|
|
2024-02-15 11:46:25 +07:00
|
|
|
/** use*/
|
|
|
|
|
const $q = useQuasar();
|
|
|
|
|
const router = useRouter();
|
2024-02-16 15:57:30 +07:00
|
|
|
const {
|
|
|
|
|
date2Thai,
|
|
|
|
|
dialogRemove,
|
|
|
|
|
messageError,
|
|
|
|
|
showLoader,
|
|
|
|
|
hideLoader,
|
|
|
|
|
success,
|
|
|
|
|
} = useCounterMixin();
|
2024-02-15 18:01:15 +07:00
|
|
|
|
|
|
|
|
/** modalDialog*/
|
|
|
|
|
const modalDialogFormMain = ref<boolean>(false);
|
|
|
|
|
|
|
|
|
|
/** Table*/
|
|
|
|
|
const rows = ref<Salary[]>([]);
|
|
|
|
|
const columns = ref<QTableProps["columns"]>([
|
|
|
|
|
{
|
|
|
|
|
name: "salaryType",
|
|
|
|
|
align: "left",
|
|
|
|
|
label: "ประเภทผัง",
|
2024-02-19 10:53:52 +07:00
|
|
|
sortable: true,
|
2024-02-15 18:01:15 +07:00
|
|
|
field: "salaryType",
|
|
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "posType",
|
|
|
|
|
align: "left",
|
2024-02-19 10:53:52 +07:00
|
|
|
label: "ประเภทตำแหน่ง",
|
2024-02-15 18:01:15 +07:00
|
|
|
sortable: true,
|
|
|
|
|
field: "posType",
|
|
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "posLevel",
|
|
|
|
|
align: "left",
|
|
|
|
|
label: "ระดับ",
|
|
|
|
|
field: "posLevel",
|
2024-02-19 10:53:52 +07:00
|
|
|
sortable: true,
|
2024-02-15 18:01:15 +07:00
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "startDate",
|
|
|
|
|
align: "left",
|
|
|
|
|
label: "วันที่มีผลบังคับใช้",
|
|
|
|
|
sortable: true,
|
|
|
|
|
field: "startDate",
|
|
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "isActive",
|
2024-02-20 10:55:31 +07:00
|
|
|
align: "center",
|
2024-02-15 18:01:15 +07:00
|
|
|
label: "สถานะการใช้งาน",
|
|
|
|
|
sortable: true,
|
|
|
|
|
field: "isActive",
|
|
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
]);
|
|
|
|
|
const visibleColumns = ref<string[]>([
|
|
|
|
|
"salaryType",
|
|
|
|
|
"posType",
|
|
|
|
|
"posLevel",
|
|
|
|
|
"startDate",
|
|
|
|
|
"isActive",
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
/** List Mune*/
|
|
|
|
|
const itemMenu = ref<ItemsMenu[]>([
|
|
|
|
|
{
|
|
|
|
|
label: "แก้ไข",
|
|
|
|
|
icon: "edit",
|
|
|
|
|
color: "edit",
|
|
|
|
|
type: "edit",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "อัตราเงินเดือน",
|
|
|
|
|
icon: "mdi-format-list-bulleted-triangle",
|
|
|
|
|
color: "secondary",
|
|
|
|
|
type: "salaryRate",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "คัดลอก",
|
|
|
|
|
icon: "content_copy",
|
|
|
|
|
color: "blue-6",
|
2024-02-16 15:57:30 +07:00
|
|
|
type: "copy",
|
2024-02-15 18:01:15 +07:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "ลบ",
|
|
|
|
|
icon: "delete",
|
|
|
|
|
color: "red",
|
|
|
|
|
type: "delete",
|
|
|
|
|
},
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
/** queryString*/
|
|
|
|
|
const formQuery = reactive<FormQuerySalary>({
|
|
|
|
|
page: 1, //*หน้า
|
2024-02-19 10:53:52 +07:00
|
|
|
pageSize: 10, //*จำนวนแถวต่อหน้า
|
2024-02-15 18:01:15 +07:00
|
|
|
keyword: "", //keyword ค้นหา
|
|
|
|
|
});
|
2024-02-16 15:57:30 +07:00
|
|
|
const maxPage = ref<number>(1);
|
2024-02-15 18:01:15 +07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* function updatePagination
|
|
|
|
|
* @param newPagination ข้อมูล Pagination ใหม่
|
|
|
|
|
*/
|
|
|
|
|
function updatePagination(newPagination: NewPagination) {
|
2024-02-16 11:12:16 +07:00
|
|
|
formQuery.page = 1;
|
|
|
|
|
formQuery.pageSize = newPagination.rowsPerPage;
|
2024-02-15 18:01:15 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function fetchListSalaly() {
|
2024-02-16 15:57:30 +07:00
|
|
|
showLoader();
|
|
|
|
|
const page = await formQuery.page.toString();
|
|
|
|
|
const pageSize = await formQuery.pageSize.toString();
|
|
|
|
|
const keyword = await formQuery.keyword.toString();
|
|
|
|
|
await http
|
|
|
|
|
.get(
|
|
|
|
|
config.API.salaryChart +
|
|
|
|
|
`?page=${page}&pageSize=${pageSize}&keyword=${keyword}`
|
|
|
|
|
)
|
|
|
|
|
.then((res) => {
|
|
|
|
|
maxPage.value = Math.ceil(res.data.result.total / formQuery.pageSize);
|
|
|
|
|
const data = res.data.result.data;
|
|
|
|
|
rows.value = data;
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
messageError($q, err);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
|
|
|
|
});
|
2024-02-15 18:01:15 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const typeAction = ref<string>("");
|
|
|
|
|
const dataRow = ref<Salary>();
|
|
|
|
|
async function onClickSalary(type: string, data: Salary | null) {
|
|
|
|
|
modalDialogFormMain.value = !modalDialogFormMain.value;
|
|
|
|
|
typeAction.value = type;
|
|
|
|
|
if (data) {
|
|
|
|
|
dataRow.value = data;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function onClickSalaryRate(id: string) {
|
|
|
|
|
router.push(`/salary/rate/${id}`);
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-16 15:57:30 +07:00
|
|
|
async function onClickCoppy(id: string) {
|
|
|
|
|
await http
|
|
|
|
|
.post(config.API.salaryChartCopy, { id: id })
|
|
|
|
|
.then(() => {
|
|
|
|
|
success($q, "คัดลอกข้อมูลสำเร็จ");
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
messageError($q, err);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
fetchListSalaly();
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-02-15 18:01:15 +07:00
|
|
|
|
2024-02-16 15:57:30 +07:00
|
|
|
async function onClickDelete(id: string) {
|
|
|
|
|
dialogRemove($q, async () => {
|
|
|
|
|
await http
|
|
|
|
|
.delete(config.API.salaryChartByid(id))
|
|
|
|
|
.then(() => {
|
|
|
|
|
success($q, "ลบข้อมูลสำเร็จ");
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
messageError($q, err);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
fetchListSalaly();
|
|
|
|
|
});
|
|
|
|
|
});
|
2024-02-15 18:01:15 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
await fetchListSalaly();
|
|
|
|
|
});
|
2024-02-16 11:12:16 +07:00
|
|
|
|
2024-02-16 15:57:30 +07:00
|
|
|
watch([() => formQuery.page, () => formQuery.pageSize], async () => {
|
|
|
|
|
await fetchListSalaly();
|
2024-02-16 11:12:16 +07:00
|
|
|
});
|
2024-02-16 15:57:30 +07:00
|
|
|
|
|
|
|
|
async function filterFn(page: number) {
|
|
|
|
|
page !== 1 ? (formQuery.page = 1) : await fetchListSalaly();
|
|
|
|
|
}
|
2024-02-15 11:46:25 +07:00
|
|
|
</script>
|
|
|
|
|
|
2024-02-15 18:01:15 +07:00
|
|
|
<template>
|
|
|
|
|
<div class="row items-center">
|
|
|
|
|
<div class="toptitle text-dark row items-center q-py-xs">
|
|
|
|
|
รายการผังบัญชีเงินเดือน
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<q-card flat bordered class="q-pa-md">
|
2024-02-20 10:55:31 +07:00
|
|
|
<div class="col-12 row text-primary">
|
2024-02-15 18:01:15 +07:00
|
|
|
<q-btn flat round dense icon="add" @click="onClickSalary('add', null)">
|
|
|
|
|
<q-tooltip>เพิ่มผังบัญชีเงินเดือน </q-tooltip>
|
|
|
|
|
</q-btn>
|
|
|
|
|
<q-space />
|
|
|
|
|
|
|
|
|
|
<q-input
|
|
|
|
|
borderless
|
|
|
|
|
dense
|
|
|
|
|
debounce="300"
|
|
|
|
|
outlined
|
|
|
|
|
v-model="formQuery.keyword"
|
|
|
|
|
placeholder="ค้นหา"
|
2024-02-16 15:57:30 +07:00
|
|
|
@keydown.enter.prevent="filterFn(formQuery.page)"
|
2024-02-15 18:01:15 +07:00
|
|
|
>
|
|
|
|
|
<template v-slot:append>
|
|
|
|
|
<q-icon name="search" />
|
|
|
|
|
</template>
|
|
|
|
|
</q-input>
|
|
|
|
|
<q-select
|
|
|
|
|
for="#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"
|
2024-02-20 10:55:31 +07:00
|
|
|
class="col-xs-12 col-sm-3 col-md-2 q-ml-sm"
|
2024-02-15 18:01:15 +07:00
|
|
|
/>
|
2024-02-20 10:55:31 +07:00
|
|
|
</div>
|
2024-02-15 18:01:15 +07:00
|
|
|
|
2024-02-20 10:55:31 +07:00
|
|
|
<div class="col-12 q-pt-sm">
|
2024-02-15 18:01:15 +07:00
|
|
|
<d-table
|
|
|
|
|
ref="table"
|
|
|
|
|
:columns="columns"
|
|
|
|
|
:rows="rows"
|
|
|
|
|
row-key="id"
|
|
|
|
|
flat
|
|
|
|
|
bordered
|
|
|
|
|
:paging="true"
|
|
|
|
|
dense
|
2024-02-16 15:57:30 +07:00
|
|
|
:rows-per-page-options="[2, 10, 25, 50, 100]"
|
2024-02-15 18:01:15 +07:00
|
|
|
@update:pagination="updatePagination"
|
|
|
|
|
:visible-columns="visibleColumns"
|
|
|
|
|
>
|
|
|
|
|
<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">
|
|
|
|
|
<q-tr :props="props" class="cursor-pointer">
|
|
|
|
|
<q-td v-for="col in props.cols" :key="col.name" :props="props">
|
|
|
|
|
<div v-if="col.name === 'isActive'">
|
|
|
|
|
<q-icon
|
|
|
|
|
:name="col.value ? 'done' : 'close'"
|
|
|
|
|
:color="col.value ? 'primary' : 'grey'"
|
|
|
|
|
size="24px"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else-if="col.name === 'salaryType'">
|
|
|
|
|
{{
|
|
|
|
|
col.value === "OFFICER"
|
|
|
|
|
? "ข้าราชการกรุงเทพมหานครสามัญ"
|
|
|
|
|
: "ลูกจ้างประจำกรุงเทพมหานคร"
|
|
|
|
|
}}
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else-if="col.name === 'startDate'">
|
|
|
|
|
{{ col.value ? date2Thai(col.value) : "-" }}
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else>
|
|
|
|
|
{{ col.value ? col.value : "-" }}
|
|
|
|
|
</div>
|
|
|
|
|
</q-td>
|
|
|
|
|
<q-td>
|
|
|
|
|
<q-btn
|
|
|
|
|
flat
|
|
|
|
|
dense
|
|
|
|
|
icon="mdi-dots-vertical"
|
|
|
|
|
class="q-pa-none q-ml-xs"
|
|
|
|
|
color="grey-13"
|
|
|
|
|
size="12px"
|
|
|
|
|
>
|
|
|
|
|
<q-menu>
|
|
|
|
|
<q-list dense style="min-width: 150px">
|
|
|
|
|
<q-item
|
|
|
|
|
v-for="(item, index) in itemMenu"
|
|
|
|
|
:key="index"
|
|
|
|
|
clickable
|
|
|
|
|
v-close-popup
|
|
|
|
|
@click.stop="
|
|
|
|
|
item.type === 'edit'
|
|
|
|
|
? onClickSalary('edit', props.row)
|
|
|
|
|
: item.type === 'salaryRate'
|
|
|
|
|
? onClickSalaryRate(props.row.id)
|
2024-02-16 15:57:30 +07:00
|
|
|
: item.type === 'copy'
|
|
|
|
|
? onClickCoppy(props.row.id)
|
2024-02-15 18:01:15 +07:00
|
|
|
: item.type === 'delete'
|
2024-02-16 15:57:30 +07:00
|
|
|
? onClickDelete(props.row.id)
|
2024-02-15 18:01:15 +07:00
|
|
|
: null
|
|
|
|
|
"
|
|
|
|
|
>
|
|
|
|
|
<q-item-section>
|
|
|
|
|
<div class="row items-center">
|
|
|
|
|
<q-icon
|
|
|
|
|
:color="item.color"
|
|
|
|
|
size="17px"
|
|
|
|
|
:name="item.icon"
|
|
|
|
|
/>
|
|
|
|
|
<div class="q-pl-md">{{ item.label }}</div>
|
|
|
|
|
</div>
|
|
|
|
|
</q-item-section>
|
|
|
|
|
</q-item>
|
|
|
|
|
</q-list>
|
|
|
|
|
</q-menu>
|
|
|
|
|
</q-btn>
|
|
|
|
|
</q-td>
|
|
|
|
|
</q-tr>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-slot:pagination="scope">
|
|
|
|
|
<q-pagination
|
|
|
|
|
v-model="formQuery.page"
|
|
|
|
|
active-color="primary"
|
|
|
|
|
color="dark"
|
2024-02-16 15:57:30 +07:00
|
|
|
:max="maxPage"
|
2024-02-15 18:01:15 +07:00
|
|
|
size="sm"
|
|
|
|
|
boundary-links
|
|
|
|
|
direction-links
|
|
|
|
|
></q-pagination>
|
|
|
|
|
</template>
|
|
|
|
|
</d-table>
|
|
|
|
|
</div>
|
|
|
|
|
</q-card>
|
|
|
|
|
|
|
|
|
|
<DialogFormMain
|
|
|
|
|
v-model:modal="modalDialogFormMain"
|
|
|
|
|
:typeAction="typeAction"
|
|
|
|
|
:data="dataRow"
|
2024-02-16 15:57:30 +07:00
|
|
|
:fetchData="fetchListSalaly"
|
2024-02-15 18:01:15 +07:00
|
|
|
/>
|
|
|
|
|
</template>
|
2024-02-15 11:46:25 +07:00
|
|
|
|
|
|
|
|
<style scoped></style>
|