หลักเกณฑ์(ยังไม่สมบูรณ์)

This commit is contained in:
setthawutttty 2024-03-14 17:50:02 +07:00
parent 3b76e636db
commit bae6df1f51
4 changed files with 247 additions and 83 deletions

View file

@ -3,6 +3,8 @@ const salary = `${env.API_URI}/salary`;
const salaryRate = `${env.API_URI}/salary/rate`;
const salaryPeriod = `${env.API_URI}/salary/period`;
const salaryOrg = `${env.API_URI}/org/employee`;
export default {
salaryChart: salary,
salaryChartCopy: `${salary}/copy`,
@ -41,4 +43,7 @@ export default {
salaryEmployeeRateList: `${salaryRate}/employee`,
salaryEmployeeRateListByid: (id: string) => `${salaryRate}/employee/${id}`,
salaryEmployeePosType:()=>`${salaryOrg}/pos/type`,
salaryEmployeePositionType:(key:string)=>`${salaryOrg}/pos/position?keyword=${key}&type=positionType`
};

View file

@ -5,8 +5,12 @@ import { useRoute } from "vue-router";
import http from "@/plugins/http";
import config from "@/app.config";
import type { ObjectReteRef } from "@/modules/13_salary/interface/index/EmployeeChart";
// import type { FormDataRate } from "@/modules/13_salary/interface/request/EmployeeChart";
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";
@ -26,11 +30,8 @@ const {
// const salaryEmployeeId = ref<string>(route.params.id.toString());
const modal = defineModel<boolean>("modal", { required: true });
const isEdit = defineModel<boolean>("isStatusEdit", { required: true });
const props = defineProps({
isStatusEdit: {
type: Boolean,
required: true,
},
data: {
type: Object,
defult: [],
@ -41,21 +42,42 @@ const props = defineProps({
// },
});
const posTypeOp = ref<DataOptions[]>([]);
const posNameOp = ref<DataOptions[]>([]);
const posLevelOp = ref<any[]>([]);
const posNameListOp = ref<DataListOptions[]>([]);
const formData = reactive<any>({
salaryNo: null,
salaryMonth: null,
salaryDay: null,
id: "",
posType: "", //
posName: "", //
posLevel: "", //
reson: "", //
rateOldMin: "", //
groupOld: "", //
rateMaxOld: "", //
groupRateHigh: "", //
rateHighMax: "", //
});
/** ตัวแปร ref สำหรับแสดง validate */
const salaryNoRef = ref<Object | null>(null);
const salaryMonthRef = ref<Object | null>(null);
const salaryDayRef = ref<Object | null>(null);
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 = {
salaryNo: salaryNoRef,
salaryMonth: salaryMonthRef,
salaryDay: salaryDayRef,
posType: posTypeRef,
posName: posNameRef,
posLevel: posLevelRef,
rateOldMin: rateOldMinRef,
groupOld: groupOldRef,
rateMaxOld: rateMaxOldRef,
groupRateHigh: groupRateHighRef,
rateHighMax: rateHighMaxRef,
};
function closeDialog() {
@ -64,9 +86,17 @@ function closeDialog() {
}
function clearFormData() {
formData.salaryNo = null;
formData.salaryMonth = null;
formData.salaryDay = null;
console.log(3);
isEdit.value = false;
formData.posType = "";
formData.posName = "";
formData.posLevel = "";
formData.reson = "";
formData.rateOldMin = "";
formData.groupOld = "";
formData.rateMaxOld = "";
formData.groupRateHigh = "";
formData.rateHighMax = "";
}
function onClickSubmit() {
@ -86,39 +116,43 @@ function onClickSubmit() {
}
function onSubmit() {
// dialogConfirm($q, async () => {
// showLoader();
// const body: FormDataRate = {
// salaryEmployeeId: !props.isStatusEdit
// ? salaryEmployeeId.value
// : undefined,
// step:
// typeof formData.salaryNo === "number"
// ? formData.salaryNo
// : Number(formData.salaryNo.replace(/,/g, "")),
// salaryMonth:
// typeof formData.salaryMonth === "number"
// ? formData.salaryMonth
// : Number(formData.salaryMonth.replace(/,/g, "")), //*
// salaryDay:
// typeof formData.salaryDay === "number"
// ? formData.salaryDay
// : Number(formData.salaryDay.replace(/,/g, "")), //0.5
// };
// try {
// const url = !props.isStatusEdit
// ? config.API.salaryEmployeeRateList
// : config.API.salaryEmployeeRateListByid(props?.data?.id);
// await http[!props.isStatusEdit ? "post" : "put"](url, body);
// success($q, "");
// props.fetchData?.();
// } catch (err) {
// messageError($q, err);
// hideLoader();
// } finally {
// closeDialog();
// }
// });
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();
});
});
}
// watch(
@ -135,13 +169,95 @@ function onSubmit() {
// }
// }
// );
/** ดึงข้อมูล กลุ่มงาน */
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;
}
}
}
);
</script>
<template>
<q-dialog v-model="modal" persistent>
<q-card class="col-12" style="width: 80%">
<Header
:tittle="props.isStatusEdit ? 'แก้ไขหลักเกณฑ์' : 'เพิ่มหลักเกณฑ์'"
:tittle="isEdit ? 'แก้ไขหลักเกณฑ์' : 'เพิ่มหลักเกณฑ์'"
:close="closeDialog"
/>
<q-separator />
@ -151,36 +267,52 @@ function onSubmit() {
<div class="row col-xs-12 col-md-12 q-col-gutter-sm">
<div class="col-4">
<q-select
ref="salaryNoRef"
ref="posTypeRef"
dense
outlined
v-model="formData.salaryNo"
v-model="formData.posType"
label="กลุ่มงาน"
:rules="[(val) => !!val || 'กรุณาเลือกกลุ่มงาน']"
:options="posTypeOp"
option-label="name"
option-value="name"
emit-value
lazy-rules
hide-bottom-space
@update:model-value="getPosName()"
/>
</div>
<div class="col-4">
<q-select
ref="salaryNoRef"
ref="posNameRef"
dense
:readonly="formData.posType"
outlined
v-model="formData.salaryNo"
v-model="formData.posName"
label="ตำแหน่ง"
:rules="[(val) => !!val || 'กรุณาเลือกตำแหน่ง']"
:options="posNameOp"
option-label="name"
option-value="name"
emit-value
lazy-rules
hide-bottom-space
@update:model-value="getPosLevel()"
/>
</div>
<div class="col-4">
<q-select
ref="salaryNoRef"
:readonly="formData.posName"
ref="posLevelRef"
dense
outlined
v-model="formData.salaryNo"
v-model="formData.posLevel"
:options="posLevelOp"
option-label="name"
option-value="name"
emit-value
label="ระดับชั้นงาน"
:rules="[(val) => !!val || 'กรุณาเลือกระดับชั้นงาน']"
lazy-rules
@ -190,24 +322,20 @@ function onSubmit() {
<div class="col-8">
<q-input
ref="salaryMonthRef"
dense
outlined
v-model="formData.salaryMonth"
v-model="formData.reson"
label="หมายเหตุ"
reverse-fill-mask
lazy-rules
hide-bottom-space
/>
</div>
<div class="col-12 text-bold">ตราคาจาง</div>
<div class="col-4">
<q-input
ref="salaryMonthRef"
ref="rateOldMinRef"
dense
outlined
v-model="formData.salaryMonth"
v-model="formData.rateOldMin"
label="ขั้นต่ำสุด"
mask="###,###,###,###"
reverse-fill-mask
@ -220,16 +348,17 @@ function onSubmit() {
</div>
<div class="col-4">
<q-select
ref="salaryMonthRef"
ref="groupOldRef"
dense
outlined
v-model="formData.salaryMonth"
label="กลุ่มบัญชีค่าจ้าง"
v-model="formData.groupOld"
label="กลุ่มของผังบัญชีอัตราค่าจ้าง"
mask="###,###,###,###"
reverse-fill-mask
:rules="[
(val) =>
!!val || `${'กรุณาเลือกอัตราค่าจ้าง กลุ่มบัญชีค่าจ้าง'}`,
!!val ||
`${'กรุณาเลือกอัตราค่าจ้าง กลุ่มของผังบัญชีอัตราค่าจ้าง'}`,
]"
lazy-rules
hide-bottom-space
@ -237,10 +366,10 @@ function onSubmit() {
</div>
<div class="col-4">
<q-input
ref="salaryMonthRef"
ref="rateMaxOldRef"
dense
outlined
v-model="formData.salaryMonth"
v-model="formData.rateMaxOld"
label="ขั้นสูงสุดเดิม"
mask="###,###,###,###"
reverse-fill-mask
@ -257,10 +386,10 @@ function onSubmit() {
</div>
<div class="col-4">
<q-select
ref="salaryMonthRef"
ref="groupRateHighRef"
dense
outlined
v-model="formData.salaryMonth"
v-model="formData.groupRateHigh"
label="กลุ่มบัญชีค่าจ้าง"
mask="###,###,###,###"
reverse-fill-mask
@ -273,10 +402,10 @@ function onSubmit() {
</div>
<div class="col-4">
<q-input
ref="salaryMonthRef"
ref="rateHighMaxRef"
dense
outlined
v-model="formData.salaryMonth"
v-model="formData.rateHighMax"
label="อัตราค่าจ้างขั้นสูงใหม่"
mask="###,###,###,###"
reverse-fill-mask

View file

@ -133,11 +133,11 @@ const rows = ref<any>([
posType: "ช่าง",
posName: "ผู้ช่วยช่างทั่วไป",
posLevel: "ช 1",
rateOldMin: (7690).toLocaleString(),
rateOldMin: 7690,
groupOld: "กลุ่มที่ 1",
rateMaxOld: (17880).toLocaleString(),
rateMaxOld: 17880,
groupRateHigh: "กลุ่มที่ 1",
rateHighMax: (20000).toLocaleString(),
rateHighMax: 20000,
reson: "",
isActive: true,
},
@ -165,6 +165,9 @@ const dataRow = ref<any>({});
function editPopup(params: any) {
modalForm.value = true;
isStatusEdit.value = true;
console.log(params);
dataRow.value = params
}
function onClickDelete(id: string) {
@ -254,6 +257,15 @@ function onClickDelete(id: string) {
size="24px"
></q-icon>
</div> -->
<div
v-else-if="
col.name == 'rateOldMin' ||
col.name == 'rateMaxOld' ||
col.name == 'rateHighMax'
"
>
{{ col.value ? col.value.toLocaleString() : "-" }}
</div>
<div v-else>{{ col.value != "" ? col.value : "-" }}</div>
</q-td>
<q-td>
@ -309,7 +321,7 @@ function onClickDelete(id: string) {
<DialogFormCriteria
v-model:modal="modalForm"
:isStatusEdit="isStatusEdit"
v-model:isStatusEdit="isStatusEdit"
:data="dataRow"
/>
</template>

View file

@ -6,10 +6,28 @@ interface ObjectCharRef {
}
interface ObjectReteRef {
salaryNo: object | null;
salaryMonth: object | null;
salaryDay: object | null;
posType: object|null
posName: object|null
posLevel: object|null
rateOldMin: object|null
groupOld: object|null
rateMaxOld: object|null
groupRateHigh: object|null
rateHighMax: object|null
[key: string]: any;
}
export type { ObjectCharRef, ObjectReteRef };
interface DataOptions {
id:string
name:string
}
interface DataListOptions {
id:string
posDictName:string
posTypeId:string
posTypeName:string
posLevelId:string
posLevelName:number
}
export type { ObjectCharRef, ObjectReteRef,DataOptions,DataListOptions };