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

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-04-29 18:02:00 +07:00
parent 4232c5d4e8
commit 7c62840eeb
8 changed files with 484 additions and 526 deletions

View file

@ -1,31 +1,21 @@
<script setup lang="ts">
import { ref, reactive, watch } from "vue";
import { useQuasar } from "quasar";
import { useRoute } from "vue-router";
import http from "@/plugins/http";
import config from "@/app.config";
import type {
ObjectReteRef,
DataOptions,
DataListOptions,
} from "@/modules/13_salary/interface/index/EmployeeChart";
import type { FormDataRate } from "@/modules/13_salary/interface/request/EmployeeChart";
import Header from "@/components/DialogHeader.vue";
import { useCounterMixin } from "@/stores/mixin";
const $q = useQuasar();
const route = useRoute();
const {
date2Thai,
dialogConfirm,
showLoader,
hideLoader,
messageError,
success,
} = useCounterMixin();
const { dialogConfirm, showLoader, hideLoader, messageError, success } =
useCounterMixin();
// const salaryEmployeeId = ref<string>(route.params.id.toString());
@ -37,10 +27,6 @@ const props = defineProps({
defult: [],
},
getDataMain: Function,
// fetchData: {
// type: Function,
// required: true,
// },
});
const posTypeOp = ref<DataOptions[]>([]);
@ -49,6 +35,7 @@ const posNameOpMain = ref<DataOptions[]>([]);
const groupOldOp = ref<DataOptions[]>([]);
const posLevelOp = ref<any[]>([]);
const posNameListOp = ref<DataListOptions[]>([]);
const formData = reactive<any>({
id: "",
posType: "", //
@ -62,32 +49,13 @@ const formData = reactive<any>({
rateHighMax: "", //
});
/** ตัวแปร ref สำหรับแสดง validate */
const posTypeRef = ref<object | null>(null);
const posNameRef = ref<object | null>(null);
const posLevelRef = ref<object | null>(null);
const rateOldMinRef = ref<object | null>(null);
const groupOldRef = ref<object | null>(null);
const rateMaxOldRef = ref<object | null>(null);
const groupRateHighRef = ref<object | null>(null);
const rateHighMaxRef = ref<object | null>(null);
const ObjectRef: ObjectReteRef = {
posType: posTypeRef,
posName: posNameRef,
posLevel: posLevelRef,
rateOldMin: rateOldMinRef,
groupOld: groupOldRef,
rateMaxOld: rateMaxOldRef,
groupRateHigh: groupRateHighRef,
rateHighMax: rateHighMaxRef,
};
/** function ปืด Dialog*/
function closeDialog() {
modal.value = !modal.value;
clearFormData();
}
/** function เคลียข้อมูล form*/
function clearFormData() {
isEdit.value = false;
formData.posType = "";
@ -101,25 +69,10 @@ function clearFormData() {
formData.rateHighMax = "";
}
function onClickSubmit() {
const hasError = [];
for (const key in ObjectRef) {
if (Object.prototype.hasOwnProperty.call(ObjectRef, key)) {
const property = ObjectRef[key];
if (property.value && typeof property.value.validate === "function") {
const isValid = property.value.validate();
hasError.push(isValid);
}
}
}
if (hasError.every((result) => result === true)) {
onSubmit();
}
}
/** function บันทึกข้อมูลหลักเกณฑ์*/
function onSubmit() {
dialogConfirm($q, async () => {
// showLoader();
showLoader();
const body = {
posTypeId: formData.posType.id,
position: formData.posName,
@ -147,7 +100,7 @@ function onSubmit() {
? config.API.salaryFormula()
: config.API.salaryFormulaById(formData.id);
await http[!isEdit.value ? "post" : "put"](url, body)
.then((res) => {
.then(() => {
success($q, "บันทึกข้อมูลสำเร็จ");
closeDialog();
props.getDataMain?.();
@ -161,21 +114,6 @@ function onSubmit() {
});
}
// watch(
// () => modal.value,
// () => {
// if (modal.value && props.isStatusEdit) {
// if (props.data) {
// const data = props.data;
// console.log(data);
// formData.salaryNo = data.step;
// formData.salaryMonth = data.salaryMonth;
// formData.salaryDay = data.salaryDay;
// }
// }
// }
// );
/** ดึงข้อมูล กลุ่มงาน */
function getPosType() {
showLoader();
@ -247,6 +185,7 @@ function getPosNameEdit() {
hideLoader();
});
}
/** ดึงข้อมูล ระดับชั้นงาน */
function getPosLevel() {
formData.posLevel = "";
@ -258,11 +197,9 @@ function getPosLevel() {
formData.posLevel = posLevelOp.value[0];
}
}
/** ดึงข้อมูล ระดับชั้นงาน */
function getPosLevelEdit() {
console.log(1);
console.log(posNameListOp.value);
posLevelOp.value = posNameListOp.value
.filter((item) => item.posDictName === formData.posName)
.map((i) => ({ id: i.posLevelId, name: i.posLevelName }))
@ -272,6 +209,7 @@ function getPosLevelEdit() {
}
}
/** ดึงข้อมูล กลุ่ม */
function getSalaryGroup() {
http
.get(config.API.salaryEmployeeActive())
@ -282,14 +220,13 @@ function getSalaryGroup() {
id: item.id,
name: `กลุ่มที่ ${item.group}`,
}));
console.log(groupOldOp.value);
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {});
});
}
/** function fetch ข้อมูลหลักเกณฑ์ */
function getDataEdit() {
http.get(config.API.salaryFormula() + `/${formData.id}`).then(async (res) => {
const data = res.data.result;
@ -314,10 +251,10 @@ function getDataEdit() {
}
watch(
() => modal.value,
async (check) => {
(check) => {
if (check) {
await getPosType();
await getSalaryGroup();
getPosType();
getSalaryGroup();
if (isEdit.value) {
formData.id = props.data?.id ? props.data.id : null;
@ -333,7 +270,7 @@ watch(
* @param update พเดทค
* @param refData ดาตาทองการฟลเตอร
*/
function filterOption(val: any, update: Function) {
function filterOption(val: any, update: Function) {
update(() => {
posNameOp.value = posNameOpMain.value.filter(
(v: any) => v.name.indexOf(val) > -1
@ -345,188 +282,192 @@ watch(
<template>
<q-dialog v-model="modal" persistent>
<q-card class="col-12" style="width: 80%">
<Header
:tittle="isEdit ? 'แก้ไขหลักเกณฑ์' : 'เพิ่มหลักเกณฑ์'"
:close="closeDialog"
/>
<q-separator />
<q-form greedy @submit.prevent @validation-success="onSubmit">
<Header
:tittle="isEdit ? 'แก้ไขหลักเกณฑ์' : 'เพิ่มหลักเกณฑ์'"
:close="closeDialog"
/>
<q-separator />
<q-card-section>
<div class="row q-gutter-sm q-pa-sm">
<div class="row col-xs-12 col-md-12 q-col-gutter-sm">
<div class="col-4">
<q-select
ref="posTypeRef"
dense
outlined
v-model="formData.posType"
label="กลุ่มงาน"
:rules="[(val) => !!val || 'กรุณาเลือกกลุ่มงาน']"
:options="posTypeOp"
option-label="name"
option-value="id"
map-options
lazy-rules
hide-bottom-space
@update:model-value="getPosName()"
/>
</div>
<div class="col-4">
<q-select
ref="posNameRef"
dense
:readonly="formData.posType"
outlined
v-model="formData.posName"
label="ตำแหน่ง"
:rules="[(val) => !!val || 'กรุณาเลือกตำแหน่ง']"
:options="posNameOp"
option-label="name"
option-value="name"
emit-value
lazy-rules
use-input
@filter="(inputValue:any,doneFn:Function) => filterOption(inputValue, doneFn) "
hide-bottom-space
@update:model-value="getPosLevel()"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
ไมอม
</q-item-section>
</q-item>
</template>
</q-select>
</div>
<div class="col-4">
<q-select
:readonly="formData.posName"
ref="posLevelRef"
dense
outlined
v-model="formData.posLevel"
:options="posLevelOp"
option-label="name"
option-value="id"
map-options
label="ระดับชั้นงาน"
:rules="[(val) => !!val || 'กรุณาเลือกระดับชั้นงาน']"
lazy-rules
hide-bottom-space
/>
</div>
<q-card-section>
<div class="row q-gutter-sm q-pa-sm">
<div class="row col-xs-12 col-md-12 q-col-gutter-sm">
<div class="col-4">
<q-select
ref="posTypeRef"
dense
outlined
v-model="formData.posType"
label="กลุ่มงาน"
:rules="[(val) => !!val || 'กรุณาเลือกกลุ่มงาน']"
:options="posTypeOp"
option-label="name"
option-value="id"
map-options
lazy-rules
hide-bottom-space
@update:model-value="getPosName()"
/>
</div>
<div class="col-4">
<q-select
ref="posNameRef"
dense
:readonly="formData.posType"
outlined
v-model="formData.posName"
label="ตำแหน่ง"
:rules="[(val) => !!val || 'กรุณาเลือกตำแหน่ง']"
:options="posNameOp"
option-label="name"
option-value="name"
emit-value
lazy-rules
use-input
@filter="(inputValue:any,doneFn:Function) => filterOption(inputValue, doneFn) "
hide-bottom-space
@update:model-value="getPosLevel()"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey"> ไมอม </q-item-section>
</q-item>
</template>
</q-select>
</div>
<div class="col-4">
<q-select
:readonly="formData.posName"
ref="posLevelRef"
dense
outlined
v-model="formData.posLevel"
:options="posLevelOp"
option-label="name"
option-value="id"
map-options
label="ระดับชั้นงาน"
:rules="[(val) => !!val || 'กรุณาเลือกระดับชั้นงาน']"
lazy-rules
hide-bottom-space
/>
</div>
<div class="col-8">
<q-input
dense
outlined
v-model="formData.reson"
label="หมายเหตุ"
/>
</div>
<div class="col-8">
<q-input
dense
outlined
v-model="formData.reson"
label="หมายเหตุ"
/>
</div>
<div class="col-12 text-bold">ตราคาจาง</div>
<div class="col-4">
<q-input
ref="rateOldMinRef"
dense
outlined
v-model="formData.rateOldMin"
label="ขั้นต่ำสุด"
mask="###,###,###,###"
reverse-fill-mask
:rules="[
(val) => !!val || `${'กรุณากรอกอัตราค่าจ้าง ขั้นต่ำสุด'}`,
]"
lazy-rules
hide-bottom-space
/>
</div>
<div class="col-4">
<q-select
ref="groupOldRef"
dense
outlined
multiple
v-model="formData.groupOld"
label="กลุ่มของผังบัญชีอัตราค่าจ้าง"
:rules="[
(val) =>
!!val ||
`${'กรุณาเลือกอัตราค่าจ้าง กลุ่มของผังบัญชีอัตราค่าจ้าง'}`,
]"
:options="groupOldOp"
map-options
option-label="name"
option-value="id"
lazy-rules
hide-bottom-space
/>
</div>
<div class="col-4">
<q-input
ref="rateMaxOldRef"
dense
outlined
v-model="formData.rateMaxOld"
label="ขั้นสูงสุดเดิม"
mask="###,###,###,###"
reverse-fill-mask
:rules="[
(val) =>
!!val || `${'กรุณากรอกอัตราค่าจ้าง ขั้นสูงสุดเดิม'}`,
]"
lazy-rules
hide-bottom-space
/>
</div>
<div class="col-12 text-bold">ตราคาจาง</div>
<div class="col-4">
<q-input
ref="rateOldMinRef"
dense
outlined
v-model="formData.rateOldMin"
label="ขั้นต่ำสุด"
mask="###,###,###,###"
reverse-fill-mask
:rules="[
(val) => !!val || `${'กรุณากรอกอัตราค่าจ้าง ขั้นต่ำสุด'}`,
]"
lazy-rules
hide-bottom-space
/>
</div>
<div class="col-4">
<q-select
ref="groupOldRef"
dense
outlined
multiple
v-model="formData.groupOld"
label="กลุ่มของผังบัญชีอัตราค่าจ้าง"
:rules="[
(val) =>
!!val ||
`${'กรุณาเลือกอัตราค่าจ้าง กลุ่มของผังบัญชีอัตราค่าจ้าง'}`,
]"
:options="groupOldOp"
map-options
option-label="name"
option-value="id"
lazy-rules
hide-bottom-space
/>
</div>
<div class="col-4">
<q-input
ref="rateMaxOldRef"
dense
outlined
v-model="formData.rateMaxOld"
label="ขั้นสูงสุดเดิม"
mask="###,###,###,###"
reverse-fill-mask
:rules="[
(val) => !!val || `${'กรุณากรอกอัตราค่าจ้าง ขั้นสูงสุดเดิม'}`,
]"
lazy-rules
hide-bottom-space
/>
</div>
<div class="col-12 text-bold">
ตราคาจางสงกวาอตราคาจางขนสงของตำแหนงทไดบแตงตงในแตละระด
</div>
<div class="col-4">
<q-select
ref="groupRateHighRef"
dense
outlined
v-model="formData.groupRateHigh"
label="กลุ่มบัญชีค่าจ้าง"
:rules="[
(val) => !!val || `${'กรุณากรอกเลือกกลุ่มบัญชีค่าจ้าง'}`,
]"
lazy-rules
:options="groupOldOp"
map-options
option-label="name"
option-value="id"
emit-value
hide-bottom-space
/>
</div>
<div class="col-4">
<q-input
ref="rateHighMaxRef"
dense
outlined
v-model="formData.rateHighMax"
label="อัตราค่าจ้างขั้นสูงใหม่"
mask="###,###,###,###"
reverse-fill-mask
:rules="[
(val) => !!val || `${'กรุณากรอกอัตราค่าจ้างขั้นสูงใหม่'}`,
]"
lazy-rules
hide-bottom-space
/>
<div class="col-12 text-bold">
ตราคาจางสงกวาอตราคาจางขนสงของตำแหนงทไดบแตงตงในแตละระด
</div>
<div class="col-4">
<q-select
ref="groupRateHighRef"
dense
outlined
v-model="formData.groupRateHigh"
label="กลุ่มบัญชีค่าจ้าง"
:rules="[
(val) => !!val || `${'กรุณากรอกเลือกกลุ่มบัญชีค่าจ้าง'}`,
]"
lazy-rules
:options="groupOldOp"
map-options
option-label="name"
option-value="id"
emit-value
hide-bottom-space
/>
</div>
<div class="col-4">
<q-input
ref="rateHighMaxRef"
dense
outlined
v-model="formData.rateHighMax"
label="อัตราค่าจ้างขั้นสูงใหม่"
mask="###,###,###,###"
reverse-fill-mask
:rules="[
(val) => !!val || `${'กรุณากรอกอัตราค่าจ้างขั้นสูงใหม่'}`,
]"
lazy-rules
hide-bottom-space
/>
</div>
</div>
</div>
</div>
</q-card-section>
<q-separator />
</q-card-section>
<q-separator />
<q-card-actions align="right" class="bg-white text-teal">
<q-btn label="บันทึก" color="secondary" @click="onClickSubmit"
><q-tooltip>นทกขอม</q-tooltip></q-btn
>
</q-card-actions>
<q-card-actions align="right" class="bg-white text-teal">
<q-btn label="บันทึก" color="secondary" type="submit"
><q-tooltip>นทกขอม</q-tooltip></q-btn
>
</q-card-actions>
</q-form>
</q-card>
</q-dialog>
</template>