2024-03-14 11:23:51 +07:00
|
|
|
<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";
|
|
|
|
|
|
2024-03-14 17:50:02 +07:00
|
|
|
import type {
|
|
|
|
|
ObjectReteRef,
|
|
|
|
|
DataOptions,
|
|
|
|
|
DataListOptions,
|
|
|
|
|
} from "@/modules/13_salary/interface/index/EmployeeChart";
|
|
|
|
|
import type { FormDataRate } from "@/modules/13_salary/interface/request/EmployeeChart";
|
2024-03-14 11:23:51 +07:00
|
|
|
|
|
|
|
|
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 salaryEmployeeId = ref<string>(route.params.id.toString());
|
|
|
|
|
|
|
|
|
|
const modal = defineModel<boolean>("modal", { required: true });
|
2024-03-14 17:50:02 +07:00
|
|
|
const isEdit = defineModel<boolean>("isStatusEdit", { required: true });
|
2024-03-14 11:23:51 +07:00
|
|
|
const props = defineProps({
|
|
|
|
|
data: {
|
|
|
|
|
type: Object,
|
|
|
|
|
defult: [],
|
|
|
|
|
},
|
|
|
|
|
// fetchData: {
|
|
|
|
|
// type: Function,
|
|
|
|
|
// required: true,
|
|
|
|
|
// },
|
|
|
|
|
});
|
|
|
|
|
|
2024-03-14 17:50:02 +07:00
|
|
|
const posTypeOp = ref<DataOptions[]>([]);
|
|
|
|
|
const posNameOp = ref<DataOptions[]>([]);
|
|
|
|
|
const posLevelOp = ref<any[]>([]);
|
|
|
|
|
const posNameListOp = ref<DataListOptions[]>([]);
|
2024-03-14 11:23:51 +07:00
|
|
|
const formData = reactive<any>({
|
2024-03-14 17:50:02 +07:00
|
|
|
id: "",
|
|
|
|
|
posType: "", //กลุ่มงาน
|
|
|
|
|
posName: "", //ตำแหน่ง
|
|
|
|
|
posLevel: "", //ระดับชั้นงาน
|
|
|
|
|
reson: "", //หมายเหตุ
|
|
|
|
|
rateOldMin: "", //อัตราค่าจ้าง ขั้นต่ำสุด
|
|
|
|
|
groupOld: "", //อัตราค่าจ้าง กลุ่มบัญชีค่าจ้าง
|
|
|
|
|
rateMaxOld: "", //อัตราค่าจ้าง ขั้นสูงสุดเดิม
|
|
|
|
|
groupRateHigh: "", //อัตราค่าจ้างสูงกว่าฯ กลุ่มบัญชีค่าจ่าง
|
|
|
|
|
rateHighMax: "", //อัตราค่าจ้างสูงกว่าฯ ขั้นสูงใหม่
|
2024-03-14 11:23:51 +07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/** ตัวแปร ref สำหรับแสดง validate */
|
2024-03-14 17:50:02 +07:00
|
|
|
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);
|
2024-03-14 11:23:51 +07:00
|
|
|
|
|
|
|
|
const ObjectRef: ObjectReteRef = {
|
2024-03-14 17:50:02 +07:00
|
|
|
posType: posTypeRef,
|
|
|
|
|
posName: posNameRef,
|
|
|
|
|
posLevel: posLevelRef,
|
|
|
|
|
rateOldMin: rateOldMinRef,
|
|
|
|
|
groupOld: groupOldRef,
|
|
|
|
|
rateMaxOld: rateMaxOldRef,
|
|
|
|
|
groupRateHigh: groupRateHighRef,
|
|
|
|
|
rateHighMax: rateHighMaxRef,
|
2024-03-14 11:23:51 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function closeDialog() {
|
|
|
|
|
modal.value = !modal.value;
|
|
|
|
|
clearFormData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function clearFormData() {
|
2024-03-14 17:50:02 +07:00
|
|
|
console.log(3);
|
|
|
|
|
isEdit.value = false;
|
|
|
|
|
formData.posType = "";
|
|
|
|
|
formData.posName = "";
|
|
|
|
|
formData.posLevel = "";
|
|
|
|
|
formData.reson = "";
|
|
|
|
|
formData.rateOldMin = "";
|
|
|
|
|
formData.groupOld = "";
|
|
|
|
|
formData.rateMaxOld = "";
|
|
|
|
|
formData.groupRateHigh = "";
|
|
|
|
|
formData.rateHighMax = "";
|
2024-03-14 11:23:51 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 onSubmit() {
|
2024-03-14 17:50:02 +07:00
|
|
|
dialogConfirm($q, () => {
|
|
|
|
|
showLoader();
|
|
|
|
|
const body = {
|
|
|
|
|
posType: formData.posType,
|
|
|
|
|
posName: formData.posName,
|
|
|
|
|
posLevel: formData.posLevel,
|
|
|
|
|
reson: formData.reson,
|
|
|
|
|
rateOldMin:
|
|
|
|
|
typeof formData.rateOldMin === "string"
|
|
|
|
|
? Number(formData.rateOldMin.replace(/,/g, ""))
|
|
|
|
|
: formData.rateOldMin,
|
|
|
|
|
groupOld: formData.groupOld,
|
|
|
|
|
rateMaxOld:
|
|
|
|
|
typeof formData.rateMaxOld === "string"
|
|
|
|
|
? Number(formData.rateMaxOld.replace(/,/g, ""))
|
|
|
|
|
: formData.rateMaxOld,
|
|
|
|
|
groupRateHigh: formData.groupRateHigh,
|
|
|
|
|
rateHighMax:
|
|
|
|
|
typeof formData.rateHighMax === "string"
|
|
|
|
|
? Number(formData.rateHighMax.replace(/,/g, ""))
|
|
|
|
|
: formData.rateHighMax,
|
|
|
|
|
};
|
|
|
|
|
const url = !isEdit
|
|
|
|
|
? config.API.salaryEmployeeRateList
|
|
|
|
|
: config.API.salaryEmployeeRateListByid(formData.id);
|
|
|
|
|
http[!isEdit ? "post" : "put"](url, body)
|
|
|
|
|
.then((res) => {
|
|
|
|
|
success($q, "บันทึกข้อมูลสำเร็จ");
|
|
|
|
|
closeDialog();
|
|
|
|
|
})
|
|
|
|
|
.catch((e) => {
|
|
|
|
|
messageError($q, e);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
|
|
|
|
});
|
|
|
|
|
});
|
2024-03-14 11:23:51 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// );
|
2024-03-14 17:50:02 +07:00
|
|
|
|
|
|
|
|
/** ดึงข้อมูล กลุ่มงาน */
|
|
|
|
|
function getPosType() {
|
|
|
|
|
showLoader();
|
|
|
|
|
http
|
|
|
|
|
.get(config.API.salaryEmployeePosType())
|
|
|
|
|
.then((res) => {
|
|
|
|
|
console.log(res.data.result);
|
|
|
|
|
const dataOp = res.data.result;
|
|
|
|
|
posTypeOp.value = dataOp.map((item: any) => ({
|
|
|
|
|
id: item.id,
|
|
|
|
|
name: item.posTypeName,
|
|
|
|
|
}));
|
|
|
|
|
})
|
|
|
|
|
.catch((e) => {
|
|
|
|
|
messageError($q, e);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** ดึงข้อมูล ตำแหน่ง */
|
|
|
|
|
function getPosName() {
|
|
|
|
|
formData.posName = "";
|
|
|
|
|
formData.posLevel = "";
|
|
|
|
|
showLoader();
|
|
|
|
|
http
|
|
|
|
|
.get(config.API.salaryEmployeePositionType(formData.posType))
|
|
|
|
|
.then((res) => {
|
|
|
|
|
const dataOp = res.data.result;
|
|
|
|
|
posNameListOp.value = res.data.result;
|
|
|
|
|
posNameOp.value = dataOp.filter((item: DataListOptions) => item.posDictName).map((i:DataListOptions)=>({
|
|
|
|
|
id:i.id,
|
|
|
|
|
name:i.posDictName
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
.catch((e) => {
|
|
|
|
|
messageError($q, e);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
/** ดึงข้อมูล ระดับชั้นงาน */
|
|
|
|
|
function getPosLevel() {
|
|
|
|
|
formData.posLevel = "";
|
|
|
|
|
posLevelOp.value = posNameListOp.value
|
|
|
|
|
.filter((item) => item.posDictName === formData.posName)
|
|
|
|
|
.map((i) => ({ id: i.id, name: i.posLevelName }));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
() => modal.value,
|
|
|
|
|
(check) => {
|
|
|
|
|
if (check) {
|
|
|
|
|
getPosType();
|
|
|
|
|
|
|
|
|
|
if (isEdit.value) {
|
|
|
|
|
formData.id = props.data?.id ? props.data.id : null;
|
|
|
|
|
formData.posType = props.data?.posType ? props.data.posType : null;
|
|
|
|
|
formData.posName = props.data?.posName ? props.data.posName : null;
|
|
|
|
|
formData.posLevel = props.data?.posLevel ? props.data.posLevel : null;
|
|
|
|
|
formData.reson = props.data?.reson ? props.data.reson : null;
|
|
|
|
|
formData.rateOldMin = props.data?.rateOldMin
|
|
|
|
|
? props.data.rateOldMin
|
|
|
|
|
: null;
|
|
|
|
|
formData.groupOld = props.data?.groupOld ? props.data.groupOld : null;
|
|
|
|
|
formData.rateMaxOld = props.data?.rateMaxOld
|
|
|
|
|
? props.data.rateMaxOld
|
|
|
|
|
: null;
|
|
|
|
|
formData.groupRateHigh = props.data?.groupRateHigh
|
|
|
|
|
? props.data.groupRateHigh
|
|
|
|
|
: null;
|
|
|
|
|
formData.rateHighMax = props.data?.rateHighMax
|
|
|
|
|
? props.data.rateHighMax
|
|
|
|
|
: null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
2024-03-14 11:23:51 +07:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<q-dialog v-model="modal" persistent>
|
|
|
|
|
<q-card class="col-12" style="width: 80%">
|
|
|
|
|
<Header
|
2024-03-14 17:50:02 +07:00
|
|
|
:tittle="isEdit ? 'แก้ไขหลักเกณฑ์' : 'เพิ่มหลักเกณฑ์'"
|
2024-03-14 11:23:51 +07:00
|
|
|
: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
|
2024-03-14 17:50:02 +07:00
|
|
|
ref="posTypeRef"
|
2024-03-14 11:23:51 +07:00
|
|
|
dense
|
|
|
|
|
outlined
|
2024-03-14 17:50:02 +07:00
|
|
|
v-model="formData.posType"
|
2024-03-14 11:23:51 +07:00
|
|
|
label="กลุ่มงาน"
|
|
|
|
|
:rules="[(val) => !!val || 'กรุณาเลือกกลุ่มงาน']"
|
2024-03-14 17:50:02 +07:00
|
|
|
:options="posTypeOp"
|
|
|
|
|
option-label="name"
|
|
|
|
|
option-value="name"
|
|
|
|
|
emit-value
|
2024-03-14 11:23:51 +07:00
|
|
|
lazy-rules
|
|
|
|
|
hide-bottom-space
|
2024-03-14 17:50:02 +07:00
|
|
|
@update:model-value="getPosName()"
|
2024-03-14 11:23:51 +07:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="col-4">
|
|
|
|
|
<q-select
|
2024-03-14 17:50:02 +07:00
|
|
|
ref="posNameRef"
|
2024-03-14 11:23:51 +07:00
|
|
|
dense
|
2024-03-14 17:50:02 +07:00
|
|
|
:readonly="formData.posType"
|
2024-03-14 11:23:51 +07:00
|
|
|
outlined
|
2024-03-14 17:50:02 +07:00
|
|
|
v-model="formData.posName"
|
2024-03-14 11:23:51 +07:00
|
|
|
label="ตำแหน่ง"
|
|
|
|
|
:rules="[(val) => !!val || 'กรุณาเลือกตำแหน่ง']"
|
2024-03-14 17:50:02 +07:00
|
|
|
:options="posNameOp"
|
|
|
|
|
option-label="name"
|
|
|
|
|
option-value="name"
|
|
|
|
|
emit-value
|
2024-03-14 11:23:51 +07:00
|
|
|
lazy-rules
|
|
|
|
|
hide-bottom-space
|
2024-03-14 17:50:02 +07:00
|
|
|
@update:model-value="getPosLevel()"
|
2024-03-14 11:23:51 +07:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="col-4">
|
|
|
|
|
<q-select
|
2024-03-14 17:50:02 +07:00
|
|
|
:readonly="formData.posName"
|
|
|
|
|
ref="posLevelRef"
|
2024-03-14 11:23:51 +07:00
|
|
|
dense
|
|
|
|
|
outlined
|
2024-03-14 17:50:02 +07:00
|
|
|
v-model="formData.posLevel"
|
|
|
|
|
:options="posLevelOp"
|
|
|
|
|
option-label="name"
|
|
|
|
|
option-value="name"
|
|
|
|
|
emit-value
|
2024-03-14 11:23:51 +07:00
|
|
|
label="ระดับชั้นงาน"
|
|
|
|
|
:rules="[(val) => !!val || 'กรุณาเลือกระดับชั้นงาน']"
|
|
|
|
|
lazy-rules
|
|
|
|
|
hide-bottom-space
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="col-8">
|
|
|
|
|
<q-input
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
2024-03-14 17:50:02 +07:00
|
|
|
v-model="formData.reson"
|
2024-03-14 11:23:51 +07:00
|
|
|
label="หมายเหตุ"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="col-12 text-bold">อัตราค่าจ้าง</div>
|
|
|
|
|
<div class="col-4">
|
|
|
|
|
<q-input
|
2024-03-14 17:50:02 +07:00
|
|
|
ref="rateOldMinRef"
|
2024-03-14 11:23:51 +07:00
|
|
|
dense
|
|
|
|
|
outlined
|
2024-03-14 17:50:02 +07:00
|
|
|
v-model="formData.rateOldMin"
|
2024-03-14 11:23:51 +07:00
|
|
|
label="ขั้นต่ำสุด"
|
|
|
|
|
mask="###,###,###,###"
|
|
|
|
|
reverse-fill-mask
|
|
|
|
|
:rules="[
|
|
|
|
|
(val) => !!val || `${'กรุณากรอกอัตราค่าจ้าง ขั้นต่ำสุด'}`,
|
|
|
|
|
]"
|
|
|
|
|
lazy-rules
|
|
|
|
|
hide-bottom-space
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-4">
|
|
|
|
|
<q-select
|
2024-03-14 17:50:02 +07:00
|
|
|
ref="groupOldRef"
|
2024-03-14 11:23:51 +07:00
|
|
|
dense
|
|
|
|
|
outlined
|
2024-03-14 17:50:02 +07:00
|
|
|
v-model="formData.groupOld"
|
|
|
|
|
label="กลุ่มของผังบัญชีอัตราค่าจ้าง"
|
2024-03-14 11:23:51 +07:00
|
|
|
mask="###,###,###,###"
|
|
|
|
|
reverse-fill-mask
|
|
|
|
|
:rules="[
|
|
|
|
|
(val) =>
|
2024-03-14 17:50:02 +07:00
|
|
|
!!val ||
|
|
|
|
|
`${'กรุณาเลือกอัตราค่าจ้าง กลุ่มของผังบัญชีอัตราค่าจ้าง'}`,
|
2024-03-14 11:23:51 +07:00
|
|
|
]"
|
|
|
|
|
lazy-rules
|
|
|
|
|
hide-bottom-space
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-4">
|
|
|
|
|
<q-input
|
2024-03-14 17:50:02 +07:00
|
|
|
ref="rateMaxOldRef"
|
2024-03-14 11:23:51 +07:00
|
|
|
dense
|
|
|
|
|
outlined
|
2024-03-14 17:50:02 +07:00
|
|
|
v-model="formData.rateMaxOld"
|
2024-03-14 11:23:51 +07:00
|
|
|
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
|
2024-03-14 17:50:02 +07:00
|
|
|
ref="groupRateHighRef"
|
2024-03-14 11:23:51 +07:00
|
|
|
dense
|
|
|
|
|
outlined
|
2024-03-14 17:50:02 +07:00
|
|
|
v-model="formData.groupRateHigh"
|
2024-03-14 11:23:51 +07:00
|
|
|
label="กลุ่มบัญชีค่าจ้าง"
|
|
|
|
|
mask="###,###,###,###"
|
|
|
|
|
reverse-fill-mask
|
|
|
|
|
:rules="[
|
|
|
|
|
(val) => !!val || `${'กรุณากรอกเลือกกลุ่มบัญชีค่าจ้าง'}`,
|
|
|
|
|
]"
|
|
|
|
|
lazy-rules
|
|
|
|
|
hide-bottom-space
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-4">
|
|
|
|
|
<q-input
|
2024-03-14 17:50:02 +07:00
|
|
|
ref="rateHighMaxRef"
|
2024-03-14 11:23:51 +07:00
|
|
|
dense
|
|
|
|
|
outlined
|
2024-03-14 17:50:02 +07:00
|
|
|
v-model="formData.rateHighMax"
|
2024-03-14 11:23:51 +07:00
|
|
|
label="อัตราค่าจ้างขั้นสูงใหม่"
|
|
|
|
|
mask="###,###,###,###"
|
|
|
|
|
reverse-fill-mask
|
|
|
|
|
:rules="[
|
|
|
|
|
(val) => !!val || `${'กรุณากรอกอัตราค่าจ้างขั้นสูงใหม่'}`,
|
|
|
|
|
]"
|
|
|
|
|
lazy-rules
|
|
|
|
|
hide-bottom-space
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</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>
|
|
|
|
|
</q-dialog>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped></style>
|