API รายการผังบัญชีเงินเดือน

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-02-16 15:57:30 +07:00
parent 3b0dea6b52
commit 7ca7518c23
7 changed files with 461 additions and 129 deletions

View file

@ -1,6 +1,9 @@
<script setup lang="ts">
import { computed, 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 { ObjectSalaryRateRef } from "@/modules/13_salary/interface/index/Main";
@ -9,6 +12,7 @@ import Header from "@/components/DialogHeader.vue";
import { useCounterMixin } from "@/stores/mixin";
const $q = useQuasar();
const route = useRoute();
const {
date2Thai,
dialogConfirm,
@ -18,6 +22,8 @@ const {
success,
} = useCounterMixin();
const salaryId = ref<string>(route.params.id.toString());
const modal = defineModel<boolean>("modal", { required: true });
const props = defineProps({
typeAction: {
@ -77,7 +83,6 @@ function closeDialog() {
}
function onClickSubmit() {
// console.log(Number(formData.salary.replace(/,/g, "")));
const hasError = [];
for (const key in ObjectRef) {
if (Object.prototype.hasOwnProperty.call(ObjectRef, key)) {
@ -94,22 +99,46 @@ function onClickSubmit() {
}
function createSalaryRate() {
dialogConfirm($q, () => {
dialogConfirm($q, async () => {
showLoader();
const body: any = {
salary: Number(formData.salary.replace(/,/g, "")), //*
salaryHalf: Number(formData.salaryHalf.replace(/,/g, "")), //0.5
salaryHalfSpecial: Number(formData.salaryHalfSpecial.replace(/,/g, "")), //0.5 ()
salaryFull: Number(formData.salaryFull.replace(/,/g, "")), //1
salaryFullSpecial: Number(formData.salaryFullSpecial.replace(/,/g, "")), //1 ()
salaryFullHalf: Number(formData.salaryFullHalf.replace(/,/g, "")), //1.formData5
salaryFullHalfSpecial: Number(
formData.salaryFullHalfSpecial.replace(/,/g, "")
), //1.5 ()
isNext: formData.isNext, //*
};
if (props.typeAction === "add") {
success($q, "add");
} else {
success($q, "edit");
body.salaryId = salaryId.value;
}
try {
const url =
props.typeAction === "add"
? config.API.salaryRateList
: config.API.salaryRateListByid(salaryId.value);
await http[props.typeAction === "add" ? "post" : "put"](url, body);
success($q, "บันทีกข้อมูลสำเร็จ");
// props.fetchData?.();
} catch (err) {
messageError($q, err);
} finally {
hideLoader();
closeDialog();
}
closeDialog();
});
}
watch(
() => modal.value,
() => {
console.log(salaryId.value);
if (modal.value && props.typeAction === "edit") {
if (props.data) {
console.log(props.data);
const data = props.data;
// formData.salaryId = data.id;
@ -151,7 +180,7 @@ watch(
/>
</div>
<div class="col-6 row items-center">
<q-checkbox dense v-model="formData.isNext" label="ทลุขั้น" />
<q-checkbox dense v-model="formData.isNext" label="ทลุขั้น" />
</div>
<div class="col-6">
<q-input