เงินเดือน => permission ผังบัญชีค่าจ้างลูกจ้างประจำ

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-08-09 16:59:57 +07:00
parent 864b67fbe5
commit 38d5697a7c
9 changed files with 323 additions and 252 deletions

View file

@ -1,5 +1,6 @@
<script setup lang="ts">
import { ref, reactive, onMounted, watch } from "vue";
import { checkPermission } from "@/utils/permissions";
import { useQuasar } from "quasar";
import { useRouter } from "vue-router";
import http from "@/plugins/http";
@ -7,10 +8,7 @@ import config from "@/app.config";
/** importType*/
import type { QTableProps } from "quasar";
import type {
ItemsMenu,
NewPagination,
} from "@/modules/13_salary/interface/index/Main";
import type { NewPagination } from "@/modules/13_salary/interface/index/Main";
import type { FormFilter } from "@/modules/13_salary/interface/request/EmployeeChart";
import type { EmployeeSalary } from "@/modules/13_salary/interface/response/salaryEmployeeChart";
@ -43,6 +41,7 @@ const totalList = ref<number>(0);
const modalDialogEmployeeChart = ref<boolean>(false);
const isStatusEdit = ref<boolean>(false);
const activeType = ref<string>("");
const dataRow = ref<EmployeeSalary>();
/** ข้อมูล Table*/
@ -92,34 +91,6 @@ const visibleColumns = ref<string[]>([
"isActive",
]);
/** List Mune*/
const itemMenu = ref<ItemsMenu[]>([
{
label: "แก้ไข",
icon: "edit",
color: "edit",
type: "edit",
},
{
label: "เอกสารอ้างอิง",
icon: "mdi-file-document-outline",
color: "teal",
type: "upload",
},
{
label: "อัตราค่าจ้าง",
icon: "mdi-format-list-bulleted-triangle",
color: "secondary",
type: "salaryRate",
},
{
label: "คัดลอก",
icon: "content_copy",
color: "blue-6",
type: "copy",
},
]);
/** function fetch ข้แมูลรายาการผังบัญชีค่าจ้างลูกจ้างประจำ */
function fetchListChart() {
showLoader();
@ -141,38 +112,39 @@ function fetchListChart() {
});
}
/**
* function เลอกเม
* @param type ประเทภเม
* @param data อมลผงบญชาจางลกจางประจ
*/
function onClickAction(type: string, data: EmployeeSalary) {
switch (type) {
case "edit":
onEdit(data);
break;
case "upload":
onUpload(data.id, data.isActive);
break;
case "salaryRate":
onSalaryRate(data.id);
break;
case "copy":
onCoppy(data.id);
break;
default:
break;
}
}
// /**
// * function
// * @param type
// * @param data
// */
// function onClickAction(type: string, data: EmployeeSalary) {
// switch (type) {
// case "edit":
// onEdit(data);
// break;
// case "upload":
// onUpload(data.id, data.isActive);
// break;
// case "salaryRate":
// onSalaryRate(data.id);
// break;
// case "copy":
// onCoppy(data.id);
// break;
// default:
// break;
// }
// }
/**
* function openDialog แกไขผงบญชาจางลกจางประจำ
* @param data อมลผงบญชาจางลกจางประจำ
*/
function onEdit(data: EmployeeSalary) {
modalDialogEmployeeChart.value = true;
function onEdit(data: EmployeeSalary, type: string) {
activeType.value = type;
isStatusEdit.value = true;
dataRow.value = data;
modalDialogEmployeeChart.value = true;
}
const modalDialogUpload = ref<boolean>(false);
@ -205,9 +177,9 @@ function onSalaryRate(id: string) {
function onCoppy(id: string) {
http
.post(config.API.salaryEmployeeChartCopy, { id: id })
.then(() => {
fetchListChart();
success($q, "คัดลอกข้อมูลสำเร็จ");
.then(async () => {
await fetchListChart();
await success($q, "คัดลอกข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
@ -222,9 +194,9 @@ function onClickDelete(id: string) {
dialogRemove($q, () => {
http
.delete(config.API.salaryEmployeeChartByid(id))
.then(() => {
fetchListChart();
success($q, "ลบข้อมูลสำเร็จ");
.then(async () => {
await fetchListChart();
await success($q, "ลบข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
@ -273,7 +245,14 @@ onMounted(() => {
</script>
<template>
<q-toolbar class="text-primary" style="padding: 0px">
<q-btn flat round dense icon="add" @click="onClickAdd()">
<q-btn
v-if="checkPermission($route)?.attrIsCreate"
flat
round
dense
icon="add"
@click="onClickAdd()"
>
<q-tooltip>เพ </q-tooltip>
</q-btn>
<q-space />
@ -330,43 +309,121 @@ onMounted(() => {
<q-tr :props="props" class="cursor-pointer">
<q-td>
<q-btn
v-if="
checkPermission($route)?.attrIsGet ||
checkPermission($route)?.attrIsCreate ||
(checkPermission($route)?.attrIsDelete &&
props.row.isActive == false)
"
flat
dense
icon="mdi-dots-vertical"
class="q-pa-none q-ml-xs"
color="grey-13"
size="12px"
color="secondary"
icon="mdi-dots-horizontal-circle-outline"
round
>
<q-menu>
<q-list dense style="min-width: 200px">
<!-- ตราเงนเดอน -->
<q-item
v-for="(item, index) in itemMenu"
:key="index"
v-if="checkPermission($route)?.attrIsGet"
clickable
v-close-popup
@click.stop="onClickAction(item.type, props.row)"
@click.stop="onSalaryRate(props.row.id)"
>
<q-item-section>
<div class="row items-center">
<q-icon
:color="item.color"
size="17px"
:name="item.icon"
color="secondary"
size="xs"
name="mdi-format-list-bulleted-triangle"
/>
<div class="q-pl-md">{{ item.label }}</div>
<div class="q-pl-md">ตราเงนเดอน</div>
</div>
</q-item-section>
</q-item>
<!-- เอกสารอางอ -->
<q-item
v-if="props.row.isActive == false"
v-if="checkPermission($route)?.attrIsGet"
clickable
v-close-popup
@click.stop="onUpload(props.row.id, props.row.isActive)"
>
<q-item-section>
<div class="row items-center">
<q-icon
color="teal"
size="xs"
name="mdi-file-document-outline"
/>
<div class="q-pl-md">เอกสารอางอ</div>
</div>
</q-item-section>
</q-item>
<!-- รายละเอยด -->
<q-item
v-if="checkPermission($route)?.attrIsGet"
clickable
v-close-popup
@click.stop="onEdit(props.row, 'view')"
>
<q-item-section>
<div class="row items-center">
<q-icon color="info" size="xs" name="mdi-eye" />
<div class="q-pl-md">รายละเอยด</div>
</div>
</q-item-section>
</q-item>
<!-- แกไข -->
<q-item
v-if="
checkPermission($route)?.attrIsUpdate &&
checkPermission($route)?.attrIsGet &&
!props.row.isActive
"
clickable
v-close-popup
@click.stop="onEdit(props.row, 'edit')"
>
<q-item-section>
<div class="row items-center">
<q-icon color="edit" size="xs" name="edit" />
<div class="q-pl-md">แกไข</div>
</div>
</q-item-section>
</q-item>
<!-- ดลอก -->
<q-item
v-if="checkPermission($route)?.attrIsCreate"
clickable
v-close-popup
@click.stop="onCoppy(props.row.id)"
>
<q-item-section>
<div class="row items-center">
<q-icon color="blue-6" size="xs" name="content_copy" />
<div class="q-pl-md">ดลอก</div>
</div>
</q-item-section>
</q-item>
<!-- ลบขอม -->
<q-item
v-if="
props.row.isActive == false &&
checkPermission($route)?.attrIsDelete
"
clickable
v-close-popup
@click.stop="onClickDelete(props.row.id)"
>
<q-item-section>
<div class="row items-center">
<q-icon color="red" size="17px" name="delete" />
<div class="q-pl-md">ลบ</div>
<q-icon color="red" size="xs" name="delete" />
<div class="q-pl-md">ลบอม</div>
</div>
</q-item-section>
</q-item>
@ -390,7 +447,6 @@ onMounted(() => {
</div>
<div v-else>{{ col.value ? col.value : "-" }}</div>
</q-td>
</q-tr>
</template>
<template v-slot:pagination="scope">
@ -414,6 +470,7 @@ onMounted(() => {
:isStatusEdit="isStatusEdit"
:data="dataRow as EmployeeSalary"
:fetchData="fetchListChart"
:activeType="activeType"
/>
<DialogEmployeeUpload