From bae6df1f51bbf497663c721a61d0e4454215d217 Mon Sep 17 00:00:00 2001 From: setthawutttty Date: Thu, 14 Mar 2024 17:50:02 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=AB=E0=B8=A5=E0=B8=B1=E0=B8=81=E0=B9=80?= =?UTF-8?q?=E0=B8=81=E0=B8=93=E0=B8=91=E0=B9=8C(=E0=B8=A2=E0=B8=B1?= =?UTF-8?q?=E0=B8=87=E0=B9=84=E0=B8=A1=E0=B9=88=E0=B8=AA=E0=B8=A1=E0=B8=9A?= =?UTF-8?q?=E0=B8=B9=E0=B8=A3=E0=B8=93=E0=B9=8C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/13_salary/api.salary.ts | 5 + .../DialogFormCriteria.vue | 279 +++++++++++++----- .../salaryEmployeeChart/TabCriteria.vue | 20 +- .../interface/index/EmployeeChart.ts | 26 +- 4 files changed, 247 insertions(+), 83 deletions(-) diff --git a/src/api/13_salary/api.salary.ts b/src/api/13_salary/api.salary.ts index ebde4a4bf..7b484cfe0 100644 --- a/src/api/13_salary/api.salary.ts +++ b/src/api/13_salary/api.salary.ts @@ -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` }; diff --git a/src/modules/13_salary/components/salaryEmployeeChart/DialogFormCriteria.vue b/src/modules/13_salary/components/salaryEmployeeChart/DialogFormCriteria.vue index db62795d3..c45d70b10 100644 --- a/src/modules/13_salary/components/salaryEmployeeChart/DialogFormCriteria.vue +++ b/src/modules/13_salary/components/salaryEmployeeChart/DialogFormCriteria.vue @@ -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(route.params.id.toString()); const modal = defineModel("modal", { required: true }); +const isEdit = defineModel("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([]); +const posNameOp = ref([]); +const posLevelOp = ref([]); +const posNameListOp = ref([]); const formData = reactive({ - salaryNo: null, - salaryMonth: null, - salaryDay: null, + id: "", + posType: "", //กลุ่มงาน + posName: "", //ตำแหน่ง + posLevel: "", //ระดับชั้นงาน + reson: "", //หมายเหตุ + rateOldMin: "", //อัตราค่าจ้าง ขั้นต่ำสุด + groupOld: "", //อัตราค่าจ้าง กลุ่มบัญชีค่าจ้าง + rateMaxOld: "", //อัตราค่าจ้าง ขั้นสูงสุดเดิม + groupRateHigh: "", //อัตราค่าจ้างสูงกว่าฯ กลุ่มบัญชีค่าจ่าง + rateHighMax: "", //อัตราค่าจ้างสูงกว่าฯ ขั้นสูงใหม่ }); /** ตัวแปร ref สำหรับแสดง validate */ -const salaryNoRef = ref(null); -const salaryMonthRef = ref(null); -const salaryDayRef = ref(null); +const posTypeRef = ref(null); +const posNameRef = ref(null); +const posLevelRef = ref(null); +const rateOldMinRef = ref(null); +const groupOldRef = ref(null); +const rateMaxOldRef = ref(null); +const groupRateHighRef = ref(null); +const rateHighMaxRef = ref(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; + } + } + } +); diff --git a/src/modules/13_salary/interface/index/EmployeeChart.ts b/src/modules/13_salary/interface/index/EmployeeChart.ts index 7755909e9..9c00df8f8 100644 --- a/src/modules/13_salary/interface/index/EmployeeChart.ts +++ b/src/modules/13_salary/interface/index/EmployeeChart.ts @@ -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 };