340 lines
10 KiB
Vue
340 lines
10 KiB
Vue
<script setup lang="ts">
|
|
import { ref, onMounted, reactive } from "vue";
|
|
import { useQuasar } from "quasar";
|
|
import { useRouter } from "vue-router";
|
|
|
|
/** 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";
|
|
|
|
/** use*/
|
|
const $q = useQuasar();
|
|
const router = useRouter();
|
|
const { date2Thai, dialogRemove } = useCounterMixin();
|
|
|
|
/** modalDialog*/
|
|
const modalDialogFormMain = ref<boolean>(false);
|
|
|
|
/** Table*/
|
|
const rows = ref<Salary[]>([]);
|
|
const columns = ref<QTableProps["columns"]>([
|
|
{
|
|
name: "salaryType",
|
|
align: "left",
|
|
label: "ประเภทผัง",
|
|
sortable: false,
|
|
field: "salaryType",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "posType",
|
|
align: "left",
|
|
label: "เลขที่ตำแหน่ง",
|
|
sortable: true,
|
|
field: "posType",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "posLevel",
|
|
align: "left",
|
|
label: "ระดับ",
|
|
field: "posLevel",
|
|
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",
|
|
align: "left",
|
|
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",
|
|
type: "coppy",
|
|
},
|
|
{
|
|
label: "ลบ",
|
|
icon: "delete",
|
|
color: "red",
|
|
type: "delete",
|
|
},
|
|
]);
|
|
|
|
/** queryString*/
|
|
const formQuery = reactive<FormQuerySalary>({
|
|
page: 1, //*หน้า
|
|
pageSize: 10, //*จำนวนแถวต่อหน้า
|
|
keyword: "", //keyword ค้นหา
|
|
});
|
|
const totalRow = ref<number>(1);
|
|
|
|
/**
|
|
* function updatePagination
|
|
* @param newPagination ข้อมูล Pagination ใหม่
|
|
*/
|
|
function updatePagination(newPagination: NewPagination) {
|
|
// reqMaster.value.pageSize = newPagination.rowsPerPage;
|
|
// reqMaster.value.page = 1;
|
|
}
|
|
|
|
async function fetchListSalaly() {
|
|
const data = [
|
|
{
|
|
id: "1",
|
|
salaryType: "OFFICER", //ประเภทผัง (OFFICER->"ข้าราชการกรุงเทพมหานครสามัญ",EMPLOYEE->"ลูกจ้างประจำกรุงเทพมหานคร")
|
|
posType: "ทั่วไป", //ระดับของตำแหน่ง
|
|
posLevel: "ชำนาญการ", //ประเภทของตำแหน่ง
|
|
isActive: true, //สถานะการใช้งาน
|
|
date: new Date(), //ให้ไว้ ณ วันที่
|
|
startDate: new Date(), //วันที่มีผลบังคับใช้
|
|
endDate: new Date(), //วันที่สิ้นสุดบังคับใช้
|
|
detail: "", //คำอธิบาย
|
|
},
|
|
{
|
|
id: "2",
|
|
salaryType: "EMPLOYEE", //ประเภทผัง (OFFICER->"ข้าราชการกรุงเทพมหานครสามัญ",EMPLOYEE->"ลูกจ้างประจำกรุงเทพมหานคร")
|
|
posType: "ทั่วไป", //ระดับของตำแหน่ง
|
|
posLevel: "ชำนาญการ", //ประเภทของตำแหน่ง
|
|
isActive: false, //สถานะการใช้งาน
|
|
date: new Date(), //ให้ไว้ ณ วันที่
|
|
startDate: new Date(), //วันที่มีผลบังคับใช้
|
|
endDate: new Date(), //วันที่สิ้นสุดบังคับใช้
|
|
detail: "", //คำอธิบาย
|
|
},
|
|
];
|
|
|
|
rows.value = data;
|
|
}
|
|
|
|
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}`);
|
|
}
|
|
|
|
async function onClickCoppy() {}
|
|
|
|
async function onClickDelete() {
|
|
dialogRemove($q, () => {});
|
|
}
|
|
|
|
onMounted(async () => {
|
|
await fetchListSalaly();
|
|
});
|
|
</script>
|
|
|
|
<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">
|
|
<q-toolbar class="text-primary q-gutter-sm" style="padding: 0px">
|
|
<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="ค้นหา"
|
|
>
|
|
<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"
|
|
class="col-xs-12 col-sm-3 col-md-2"
|
|
/>
|
|
</q-toolbar>
|
|
|
|
<div class="col-12 q-pa-sm">
|
|
<d-table
|
|
ref="table"
|
|
:columns="columns"
|
|
:rows="rows"
|
|
row-key="id"
|
|
flat
|
|
bordered
|
|
:paging="true"
|
|
dense
|
|
:rows-per-page-options="[10, 25, 50, 100]"
|
|
@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)
|
|
: item.type === 'coppy'
|
|
? onClickCoppy()
|
|
: item.type === 'delete'
|
|
? onClickDelete()
|
|
: 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"
|
|
:max="totalRow"
|
|
size="sm"
|
|
boundary-links
|
|
direction-links
|
|
></q-pagination>
|
|
</template>
|
|
</d-table>
|
|
</div>
|
|
</q-card>
|
|
|
|
<DialogFormMain
|
|
v-model:modal="modalDialogFormMain"
|
|
:typeAction="typeAction"
|
|
:data="dataRow"
|
|
/>
|
|
</template>
|
|
|
|
<style scoped></style>
|