เงินเดือน => ปรับ code รายการผังบัญชีเงินเดือน
This commit is contained in:
parent
3d784decdb
commit
ff13fb1345
5 changed files with 225 additions and 356 deletions
|
|
@ -5,25 +5,24 @@ import { useRoute } from "vue-router";
|
|||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
import type { ObjectSalaryRateRef } from "@/modules/13_salary/interface/index/Main";
|
||||
/** importType*/
|
||||
import type { FormSalaryRate } from "@/modules/13_salary/interface/index/Main";
|
||||
|
||||
/** importComponents*/
|
||||
import Header from "@/components/DialogHeader.vue";
|
||||
|
||||
/** importStore*/
|
||||
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
/** use*/
|
||||
|
||||
const $q = useQuasar();
|
||||
const route = useRoute();
|
||||
const {
|
||||
date2Thai,
|
||||
dialogConfirm,
|
||||
showLoader,
|
||||
hideLoader,
|
||||
messageError,
|
||||
success,
|
||||
} = useCounterMixin();
|
||||
|
||||
const salaryId = ref<string>(route.params.id.toString());
|
||||
const { dialogConfirm, showLoader, hideLoader, messageError, success } =
|
||||
useCounterMixin();
|
||||
|
||||
/** props*/
|
||||
const modal = defineModel<boolean>("modal", { required: true });
|
||||
const props = defineProps({
|
||||
typeAction: {
|
||||
|
|
@ -40,7 +39,8 @@ const props = defineProps({
|
|||
},
|
||||
});
|
||||
|
||||
const formData = reactive<any>({
|
||||
const salaryId = ref<string>(route.params.id.toString());
|
||||
const formData = reactive<FormSalaryRate>({
|
||||
salaryId: "",
|
||||
salary: null,
|
||||
salaryHalf: null,
|
||||
|
|
@ -52,25 +52,6 @@ const formData = reactive<any>({
|
|||
isNext: false,
|
||||
});
|
||||
|
||||
/** ตัวแปร ref สำหรับแสดง validate */
|
||||
const salaryRef = ref<Object | null>(null);
|
||||
const salaryHalfRef = ref<Object | null>(null);
|
||||
const salaryHalfSpecialRef = ref<Object | null>(null);
|
||||
const salaryFullRef = ref<Object | null>(null);
|
||||
const salaryFullSpecialRef = ref<Object | null>(null);
|
||||
const salaryFullHalfRef = ref<Object | null>(null);
|
||||
const salaryFullHalfSpecialRef = ref<Object | null>(null);
|
||||
|
||||
const ObjectRef: ObjectSalaryRateRef = {
|
||||
salary: salaryRef,
|
||||
salaryHalf: salaryHalfRef,
|
||||
salaryHalfSpecial: salaryHalfSpecialRef,
|
||||
salaryFull: salaryFullRef,
|
||||
salaryFullSpecial: salaryFullSpecialRef,
|
||||
salaryFullHalf: salaryFullHalfRef,
|
||||
salaryFullHalfSpecial: salaryFullHalfSpecialRef,
|
||||
};
|
||||
|
||||
const title = computed(() => {
|
||||
const name =
|
||||
props.typeAction === "add"
|
||||
|
|
@ -82,11 +63,13 @@ const title = computed(() => {
|
|||
return name;
|
||||
});
|
||||
|
||||
/** function ปืด Dialog*/
|
||||
function closeDialog() {
|
||||
modal.value = !modal.value;
|
||||
clearFormData();
|
||||
}
|
||||
|
||||
/** function เคลียข้อมูล form*/
|
||||
function clearFormData() {
|
||||
formData.salaryId = "";
|
||||
formData.salary = null;
|
||||
|
|
@ -99,36 +82,20 @@ function clearFormData() {
|
|||
formData.isNext = false;
|
||||
}
|
||||
|
||||
function onClickSubmit() {
|
||||
console.log(formData.salaryHalfSpecial);
|
||||
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)) {
|
||||
createSalaryRate();
|
||||
}
|
||||
}
|
||||
|
||||
function createSalaryRate() {
|
||||
/** function บันทึกข้อมูล*/
|
||||
function onSubmit() {
|
||||
dialogConfirm($q, async () => {
|
||||
showLoader();
|
||||
const body: any = {
|
||||
salary:
|
||||
typeof formData.salary === "number"
|
||||
? formData.salary
|
||||
: Number(formData.salary.replace(/,/g, "")), //*เงินเดือนฐาน
|
||||
: Number(formData.salary?.replace(/,/g, "")), //*เงินเดือนฐาน
|
||||
|
||||
salaryHalf:
|
||||
typeof formData.salaryHalf === "number"
|
||||
? formData.salaryHalf
|
||||
: Number(formData.salaryHalf.replace(/,/g, "")), //0.5 ขั้น
|
||||
: Number(formData.salaryHalf?.replace(/,/g, "")), //0.5 ขั้น
|
||||
|
||||
salaryHalfSpecial:
|
||||
formData.salaryHalfSpecial === "" || formData.salaryHalfSpecial === null
|
||||
|
|
@ -140,19 +107,19 @@ function createSalaryRate() {
|
|||
salaryFull:
|
||||
typeof formData.salaryFull === "number"
|
||||
? formData.salaryFull
|
||||
: Number(formData.salaryFull.replace(/,/g, "")), //1 ขั้น
|
||||
: Number(formData.salaryFull?.replace(/,/g, "")), //1 ขั้น
|
||||
|
||||
salaryFullSpecial:
|
||||
formData.salaryFullSpecial === "" || formData.salaryFullSpecial === null
|
||||
? null
|
||||
: typeof formData.salaryFullSpecial === "number"
|
||||
? formData.salaryFullSpecial
|
||||
: Number(formData.salaryFullSpecial.replace(/,/g, "")), //1 ขั้น(เงินพิเศษ)
|
||||
: Number(formData.salaryFullSpecial?.replace(/,/g, "")), //1 ขั้น(เงินพิเศษ)
|
||||
|
||||
salaryFullHalf:
|
||||
typeof formData.salaryFullHalf === "number"
|
||||
? formData.salaryFullHalf
|
||||
: Number(formData.salaryFullHalf.replace(/,/g, "")), //1.formData5 ขั้น
|
||||
: Number(formData.salaryFullHalf?.replace(/,/g, "")), //1.formData5 ขั้น
|
||||
|
||||
salaryFullHalfSpecial:
|
||||
formData.salaryFullHalfSpecial === "" ||
|
||||
|
|
@ -183,6 +150,7 @@ function createSalaryRate() {
|
|||
});
|
||||
}
|
||||
|
||||
/** callbackFunction ทำการ fetch ข้อมูลไฟล์เมื่อเปิด Dialog*/
|
||||
watch(
|
||||
() => modal.value,
|
||||
() => {
|
||||
|
|
@ -207,120 +175,122 @@ watch(
|
|||
<template>
|
||||
<q-dialog v-model="modal" persistent>
|
||||
<q-card style="width: 700px; max-width: 80vw">
|
||||
<Header :tittle="title" :close="closeDialog" />
|
||||
<q-separator />
|
||||
<q-form greedy @submit.prevent @validation-success="onSubmit">
|
||||
<Header :tittle="title" :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-6">
|
||||
<q-input
|
||||
ref="salaryRef"
|
||||
dense
|
||||
outlined
|
||||
v-model="formData.salary"
|
||||
label="เงินเดือนฐาน"
|
||||
mask="###,###,###,###"
|
||||
reverse-fill-mask
|
||||
:rules="[(val) => !!val || `${'กรุณากรอกเงินเดือนฐาน'}`]"
|
||||
lazy-rules
|
||||
hide-bottom-space
|
||||
/>
|
||||
</div>
|
||||
<div class="col-6 row items-center">
|
||||
<q-checkbox dense v-model="formData.isNext" label="ทะลุขั้น" />
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<q-input
|
||||
ref="salaryHalfRef"
|
||||
dense
|
||||
outlined
|
||||
v-model="formData.salaryHalf"
|
||||
label="เลื่อน 0.5 ขั้น"
|
||||
mask="###,###,###,###"
|
||||
reverse-fill-mask
|
||||
:rules="[(val) => !!val || `${'กรุณากรอกเลื่อน 0.5 ขั้น'}`]"
|
||||
lazy-rules
|
||||
hide-bottom-space
|
||||
/>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<q-input
|
||||
ref="salaryHalfSpecialRef"
|
||||
dense
|
||||
outlined
|
||||
v-model="formData.salaryHalfSpecial"
|
||||
label="เงินพิเศษ"
|
||||
mask="###,###,###,###"
|
||||
reverse-fill-mask
|
||||
lazy-rules
|
||||
hide-bottom-space
|
||||
/>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<q-input
|
||||
ref="salaryFullRef"
|
||||
dense
|
||||
outlined
|
||||
v-model="formData.salaryFull"
|
||||
label="เลื่อน 1 ขั้น"
|
||||
mask="###,###,###,###"
|
||||
reverse-fill-mask
|
||||
:rules="[(val) => !!val || `${'กรุณากรอกเลื่อน 1 ขั้น'}`]"
|
||||
lazy-rules
|
||||
hide-bottom-space
|
||||
/>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<q-input
|
||||
ref="salaryFullSpecialRef"
|
||||
dense
|
||||
outlined
|
||||
v-model="formData.salaryFullSpecial"
|
||||
label="เงินพิเศษ"
|
||||
mask="###,###,###,###"
|
||||
reverse-fill-mask
|
||||
lazy-rules
|
||||
hide-bottom-space
|
||||
/>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<q-input
|
||||
ref="salaryFullHalfRef"
|
||||
dense
|
||||
outlined
|
||||
v-model="formData.salaryFullHalf"
|
||||
label="เลื่อน 1.5 ขั้น"
|
||||
mask="###,###,###,###"
|
||||
reverse-fill-mask
|
||||
:rules="[(val) => !!val || `${'กรุณากรอกเลื่อน 1.5 ขั้น'}`]"
|
||||
lazy-rules
|
||||
hide-bottom-space
|
||||
/>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<q-input
|
||||
ref="salaryFullHalfSpecialRef"
|
||||
dense
|
||||
outlined
|
||||
v-model="formData.salaryFullHalfSpecial"
|
||||
label="เงินพิเศษ"
|
||||
mask="###,###,###,###"
|
||||
reverse-fill-mask
|
||||
lazy-rules
|
||||
hide-bottom-space
|
||||
/>
|
||||
<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-6">
|
||||
<q-input
|
||||
ref="salaryRef"
|
||||
dense
|
||||
outlined
|
||||
v-model="formData.salary"
|
||||
label="เงินเดือนฐาน"
|
||||
mask="###,###,###,###"
|
||||
reverse-fill-mask
|
||||
:rules="[(val) => !!val || `${'กรุณากรอกเงินเดือนฐาน'}`]"
|
||||
lazy-rules
|
||||
hide-bottom-space
|
||||
/>
|
||||
</div>
|
||||
<div class="col-6 row items-center">
|
||||
<q-checkbox dense v-model="formData.isNext" label="ทะลุขั้น" />
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<q-input
|
||||
ref="salaryHalfRef"
|
||||
dense
|
||||
outlined
|
||||
v-model="formData.salaryHalf"
|
||||
label="เลื่อน 0.5 ขั้น"
|
||||
mask="###,###,###,###"
|
||||
reverse-fill-mask
|
||||
:rules="[(val) => !!val || `${'กรุณากรอกเลื่อน 0.5 ขั้น'}`]"
|
||||
lazy-rules
|
||||
hide-bottom-space
|
||||
/>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<q-input
|
||||
ref="salaryHalfSpecialRef"
|
||||
dense
|
||||
outlined
|
||||
v-model="formData.salaryHalfSpecial"
|
||||
label="เงินพิเศษ"
|
||||
mask="###,###,###,###"
|
||||
reverse-fill-mask
|
||||
lazy-rules
|
||||
hide-bottom-space
|
||||
/>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<q-input
|
||||
ref="salaryFullRef"
|
||||
dense
|
||||
outlined
|
||||
v-model="formData.salaryFull"
|
||||
label="เลื่อน 1 ขั้น"
|
||||
mask="###,###,###,###"
|
||||
reverse-fill-mask
|
||||
:rules="[(val) => !!val || `${'กรุณากรอกเลื่อน 1 ขั้น'}`]"
|
||||
lazy-rules
|
||||
hide-bottom-space
|
||||
/>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<q-input
|
||||
ref="salaryFullSpecialRef"
|
||||
dense
|
||||
outlined
|
||||
v-model="formData.salaryFullSpecial"
|
||||
label="เงินพิเศษ"
|
||||
mask="###,###,###,###"
|
||||
reverse-fill-mask
|
||||
lazy-rules
|
||||
hide-bottom-space
|
||||
/>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<q-input
|
||||
ref="salaryFullHalfRef"
|
||||
dense
|
||||
outlined
|
||||
v-model="formData.salaryFullHalf"
|
||||
label="เลื่อน 1.5 ขั้น"
|
||||
mask="###,###,###,###"
|
||||
reverse-fill-mask
|
||||
:rules="[(val) => !!val || `${'กรุณากรอกเลื่อน 1.5 ขั้น'}`]"
|
||||
lazy-rules
|
||||
hide-bottom-space
|
||||
/>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<q-input
|
||||
ref="salaryFullHalfSpecialRef"
|
||||
dense
|
||||
outlined
|
||||
v-model="formData.salaryFullHalfSpecial"
|
||||
label="เงินพิเศษ"
|
||||
mask="###,###,###,###"
|
||||
reverse-fill-mask
|
||||
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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue