From 7c62840eebc3c0b3b476a3ddbed533231dc7a296 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Mon, 29 Apr 2024 18:02:00 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=87=E0=B8=B4=E0=B8=99=E0=B9=80?= =?UTF-8?q?=E0=B8=94=E0=B8=B7=E0=B8=99=20=3D>=20=E0=B8=9B=E0=B8=A3?= =?UTF-8?q?=E0=B8=B1=E0=B8=9A=20code=20=20=E0=B8=9C=E0=B8=B1=E0=B8=87?= =?UTF-8?q?=E0=B8=9A=E0=B8=B1=E0=B8=8D=E0=B8=8A=E0=B8=B5=E0=B8=84=E0=B9=88?= =?UTF-8?q?=E0=B8=B2=E0=B8=88=E0=B9=89=E0=B8=B2=E0=B8=87=E0=B8=A5=E0=B8=B9?= =?UTF-8?q?=E0=B8=81=E0=B8=88=E0=B9=89=E0=B8=B2=E0=B8=87=E0=B8=9B=E0=B8=A3?= =?UTF-8?q?=E0=B8=B0=E0=B8=88=E0=B8=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DialogEmployeeChart.vue | 78 ++- .../DialogEmployeeRate.vue | 203 ++++---- .../DialogFormCriteria.vue | 453 ++++++++---------- .../salaryEmployeeChart/TabCriteria.vue | 128 ++--- .../salaryEmployeeChart/TabStructure.vue | 45 +- .../interface/index/EmployeeChart.ts | 78 ++- .../interface/request/EmployeeChart.ts | 8 +- .../interface/response/salaryEmployeeChart.ts | 17 +- 8 files changed, 484 insertions(+), 526 deletions(-) diff --git a/src/modules/13_salary/components/salaryEmployeeChart/DialogEmployeeChart.vue b/src/modules/13_salary/components/salaryEmployeeChart/DialogEmployeeChart.vue index 75fee022d..d41188c3d 100644 --- a/src/modules/13_salary/components/salaryEmployeeChart/DialogEmployeeChart.vue +++ b/src/modules/13_salary/components/salaryEmployeeChart/DialogEmployeeChart.vue @@ -4,13 +4,16 @@ import { useQuasar } from "quasar"; import http from "@/plugins/http"; import config from "@/app.config"; -import type { ObjectCharRef } from "@/modules/13_salary/interface/index/EmployeeChart"; +/** importType*/ import type { FormDataChar } from "@/modules/13_salary/interface/request/EmployeeChart"; +/** importComponentes*/ import Header from "@/components/DialogHeader.vue"; +/** importStore*/ import { useCounterMixin } from "@/stores/mixin"; +/** use*/ const $q = useQuasar(); const { date2Thai, @@ -19,9 +22,9 @@ const { hideLoader, messageError, success, - dialogRemove, } = useCounterMixin(); +/** props*/ const modal = defineModel("modal", { required: true }); const props = defineProps({ isStatusEdit: { type: Boolean, required: true }, @@ -31,6 +34,8 @@ const props = defineProps({ required: true, }, }); + +/** form บัญชีค่าจ้างลูกจ้างประจำ */ const formData = reactive({ name: "", //ชื่อผังบัญชีอัตราค่าจ้าง group: "", //*กลุ่มของผังบัญชีอัตราค่าจ้าง @@ -41,14 +46,12 @@ const formData = reactive({ details: "", //คำอธิบาย }); -const nameRef = ref(null); -const groupRef = ref(null); - -const ObjectRef: ObjectCharRef = { - name: nameRef, - group: groupRef, -}; +const isReadonly = ref(false); +/** + * function fetch ข้อมูล ผังบัญชีค่าจ้างลูกจ้างประจำ + * @param id ผังบัญชีค่าจ้างลูกจ้างประจำ + */ function fetchSalaryDetail(id: string) { showLoader(); http @@ -72,47 +75,33 @@ function fetchSalaryDetail(id: string) { }); } -const isReadonly = ref(false); -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); - } +/** function บันทึกข้อมูลผังบัญชีค่าจ้างลูกจ้างประจำ*/ +function onSubmit() { + dialogConfirm($q, async () => { + showLoader(); + try { + const url = !props.isStatusEdit + ? config.API.salaryEmployeeChart + : config.API.salaryEmployeeChartByid(props.data.id); + await http[!props.isStatusEdit ? "post" : "put"](url, formData); + success($q, "บันทีกข้อมูลสำเร็จ"); + props.fetchData?.(); + closeDialog(); + } catch (err) { + messageError($q, err); + } finally { + hideLoader(); } - } - if (hasError.every((result) => result === true)) { - dialogConfirm($q, () => { - onSubmit(); - }); - } -} - -async function onSubmit() { - showLoader(); - try { - const url = !props.isStatusEdit - ? config.API.salaryEmployeeChart - : config.API.salaryEmployeeChartByid(props.data.id); - await http[!props.isStatusEdit ? "post" : "put"](url, formData); - success($q, "บันทีกข้อมูลสำเร็จ"); - props.fetchData?.(); - } catch (err) { - messageError($q, err); - } finally { - hideLoader(); - closeDialog(); - } + }); } +/** function ปืด Dialog*/ function closeDialog() { modal.value = false; clearFormData(); } +/** function เคลียข้อมูล form*/ function clearFormData() { formData.name = ""; formData.group = ""; @@ -132,6 +121,7 @@ function checkEndDate() { } } +/** callbaclFunction fetch ช้อมูลเมื่อแก้ไข*/ watch( () => modal.value, () => { @@ -144,7 +134,7 @@ watch(