diff --git a/src/api/index.ts b/src/api/index.ts index e83c37800..7e3e8e494 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -14,31 +14,31 @@ export const dashboardPanelUrl = import.meta.env.VITE_DASHBOARD_PANEL; const config = ref({ development: { // API_URI: "http://localhost:13001/api/v1", - API_URI: "https://bma-ehr.frappet.synology.me/api/v1", + API_URI: "https://hrmsbkk.case-collection.com/api/v1", // API_URI_ORG_SERVICE: "https://localhost:7056/api/v1", //ใช้ชั่วคราว - API_URI_ORG_SERVICE: "https://bma-ehr.frappet.synology.me/api/v1", //ใช้ชั่วคราว + API_URI_ORG_SERVICE: "https://hrmsbkk.case-collection.com/api/v1", //ใช้ชั่วคราว // API_URI_ORG_EMPLOYEE_SERVICE: "https://localhost:7208/api/v1", //ใช้ชั่วคราว - API_URI_ORG_EMPLOYEE_SERVICE: "https://bma-ehr.frappet.synology.me/api/v1", //ใช้ชั่วคราว + API_URI_ORG_EMPLOYEE_SERVICE: "https://hrmsbkk.case-collection.com/api/v1", //ใช้ชั่วคราว // API_URI_PROFILE_SERVICE: "https://localhost:7159/api/v1", - API_URI_PROFILE_SERVICE: "https://bma-ehr.frappet.synology.me/api/v1", //ใช้ชั่วคราว + API_URI_PROFILE_SERVICE: "https://hrmsbkk.case-collection.com/api/v1", //ใช้ชั่วคราว // API_CANDIDATE_URI: "https://localhost:7007/api/v1", - API_CANDIDATE_URI: "https://bma-ehr.frappet.synology.me/api/v1", + API_CANDIDATE_URI: "https://hrmsbkk.case-collection.com/api/v1", // API_REPORT_URI: "https://localhost:7187/api/v1", - API_REPORT_URI: "https://bma-ehr.frappet.synology.me/api/v1", + API_REPORT_URI: "https://hrmsbkk.case-collection.com/api/v1", // API_PLACEMENT_URI: "https://localhost:7260/api", - API_PLACEMENT_URI: "https://bma-ehr.frappet.synology.me/api/v1", + API_PLACEMENT_URI: "https://hrmsbkk.case-collection.com/api/v1", API_URI_ORG_TREE: "https://s3cluster.frappet.com/bma-ehr-fpt/organization/strueture/tree_20230712_172702.json", MEET_URI: "meet.frappet.com", - API_RETIREMENT_URI: "https://bma-ehr.frappet.synology.me/api/v1", + API_RETIREMENT_URI: "https://hrmsbkk.case-collection.com/api/v1", // API_PROBATION_URI: "https://ehr.joolsoft.com/v1", - API_PROBATION_URI: "https://bma-ehr.frappet.synology.me/api/v1/probation", + API_PROBATION_URI: "https://hrmsbkk.case-collection.com/api/v1/probation", // API_PROBATION_URI: "http://192.168.1.151:7776/v1", - API_REPORT2_URI: "https://bma-ehr.frappet.synology.me/api/v2", + API_REPORT2_URI: "https://hrmsbkk.case-collection.com/api/v2", LINK_EVALUATE_PUBLISH: "https://bma-ehr-publish.frappet.synology.me", API_REPORT_TEMPLATE_URI: "https://report-server.frappet.synology.me/api/v1/report-template", - API_SUPPORT_URI: "https://bma-ehr.frappet.synology.me/api/v1/support", + API_SUPPORT_URI: "https://hrmsbkk.case-collection.com/api/v1/support", DASHBOARD_URL: dashboardPanelUrl, }, test: { diff --git a/src/modules/04_registryPerson/components/detail/Employee/01_DataEmployee.vue b/src/modules/04_registryPerson/components/detail/Employee/01_DataEmployee.vue index 7c6cc7c8f..b9cc75d5d 100644 --- a/src/modules/04_registryPerson/components/detail/Employee/01_DataEmployee.vue +++ b/src/modules/04_registryPerson/components/detail/Employee/01_DataEmployee.vue @@ -8,13 +8,11 @@ import config from "@/app.config"; import type { QTableColumn } from "quasar"; import type { FormEmployee } from "@/modules/04_registryPerson/interface/request/Employee"; -import type { - EmployeeHistory, - ResEmployee, -} from "@/modules/04_registryPerson/interface/response/Employee"; +import type { ResEmployee } from "@/modules/04_registryPerson/interface/response/Employee"; import DialogHeader from "@/components/DialogHeader.vue"; import DialogHistory from "@/modules/04_registryPerson/components/detail/DialogHistory.vue"; +import CurruncyInput from "@/components/CurruncyInput.vue"; import { useCounterMixin } from "@/stores/mixin"; @@ -27,7 +25,6 @@ const { date2Thai, messageError, dialogConfirm, - onSearchDataTable, } = useCounterMixin(); const profileId = ref( @@ -60,11 +57,11 @@ const formData = reactive({ positionEmployeePositionId: "", employeeOc: "", employeeTypeIndividual: "", - employeeWage: "", - employeeMoneyIncrease: "", - employeeMoneyAllowance: "", - employeeMoneyEmployee: "", - employeeMoneyEmployer: "", + employeeWage: undefined, + employeeMoneyIncrease: undefined, + employeeMoneyAllowance: undefined, + employeeMoneyEmployee: undefined, + employeeMoneyEmployer: undefined, }); /** function fetch ข้อมูลลูกจ้างชั่วคราว*/ @@ -101,11 +98,15 @@ function onClickEdit() { formData.positionEmployeePositionId = dataEmployee.positionEmployeePositionId; formData.employeeOc = dataEmployee.employeeOc; formData.employeeTypeIndividual = dataEmployee.employeeTypeIndividual; - formData.employeeWage = dataEmployee.employeeWage; - formData.employeeMoneyIncrease = dataEmployee.employeeMoneyIncrease; - formData.employeeMoneyAllowance = dataEmployee.employeeMoneyAllowance; - formData.employeeMoneyEmployee = dataEmployee.employeeMoneyEmployee; - formData.employeeMoneyEmployer = dataEmployee.employeeMoneyEmployer; + formData.employeeWage = Number(dataEmployee.employeeWage) || undefined; + formData.employeeMoneyIncrease = + Number(dataEmployee.employeeMoneyIncrease) || undefined; + formData.employeeMoneyAllowance = + Number(dataEmployee.employeeMoneyAllowance) || undefined; + formData.employeeMoneyEmployee = + Number(dataEmployee.employeeMoneyEmployee) || undefined; + formData.employeeMoneyEmployer = + Number(dataEmployee.employeeMoneyEmployer) || undefined; } /** function ปิด Dialog แก้ไขมูลลูกจ้างชั่วคราว*/ @@ -116,11 +117,11 @@ function onCloseDialog() { formData.positionEmployeePositionId = ""; formData.employeeOc = ""; formData.employeeTypeIndividual = ""; - formData.employeeWage = ""; - formData.employeeMoneyIncrease = ""; - formData.employeeMoneyAllowance = ""; - formData.employeeMoneyEmployee = ""; - formData.employeeMoneyEmployer = ""; + formData.employeeWage = undefined; + formData.employeeMoneyIncrease = undefined; + formData.employeeMoneyAllowance = undefined; + formData.employeeMoneyEmployee = undefined; + formData.employeeMoneyEmployer = undefined; } /** function บันทึกแก้ไขมูลลูกจ้างชั่วคราว*/ @@ -128,7 +129,15 @@ function onSubmit() { dialogConfirm($q, () => { showLoader(); http - .put(config.API.informationEmployee(profileId.value), formData) + .put(config.API.informationEmployee(profileId.value), { + ...formData, + employeeWage: formData.employeeWage?.toString() || "", + employeeMoneyIncrease: formData.employeeMoneyIncrease?.toString() || "", + employeeMoneyAllowance: + formData.employeeMoneyAllowance?.toString() || "", + employeeMoneyEmployee: formData.employeeMoneyEmployee?.toString() || "", + employeeMoneyEmployer: formData.employeeMoneyEmployer?.toString() || "", + }) .then(async () => { await fetchData(); await success($q, "บันทึกข้อมูลสำเร็จ"); @@ -533,7 +542,8 @@ onMounted(() => {
- { v-model="formData.employeeWage" class="inputgreen" label="ค่าจ้าง" - mask="###,###,###,###" - reverse-fill-mask + :rules="[(val:number) => { + if (!val) return true; + const numVal = typeof val === 'number' ? val : Number(String(val).replace(/,/g, '')); + return numVal <= 10000000 || 'ค่าจ้างต้องไม่เกิน 10,000,000 บาท'; + }]" />
- { v-model="formData.employeeMoneyIncrease" class="inputgreen" label="เงินเพิ่มการครองชีพชั่วคราว" - mask="###,###,###,###" - reverse-fill-mask + :rules="[(val:number) => { + if (!val) return true; + const numVal = typeof val === 'number' ? val : Number(String(val).replace(/,/g, '')); + return numVal <= 10000000 || 'เงินเพิ่มการครองชีพชั่วคราวต้องไม่เกิน 10,000,000 บาท'; + }]" />
- { v-model="formData.employeeMoneyAllowance" class="inputgreen" label="เงินช่วยเหลือการครองชีพชั่วคราว" - mask="###,###,###,###" - reverse-fill-mask + :rules="[(val:number) => { + if (!val) return true; + const numVal = typeof val === 'number' ? val : Number(String(val).replace(/,/g, '')); + return numVal <= 10000000 || 'เงินช่วยเหลือการครองชีพชั่วคราวต้องไม่เกิน 10,000,000 บาท'; + }]" />
- { v-model="formData.employeeMoneyEmployee" class="inputgreen" label="เงินสมทบประกันสังคม(ลูกจ้าง)" - mask="###,###,###,###" - reverse-fill-mask + :rules="[(val:number) => { + if (!val) return true; + const numVal = typeof val === 'number' ? val : Number(String(val).replace(/,/g, '')); + return numVal <= 10000000 || 'เงินสมทบประกันสังคม(ลูกจ้าง)ต้องไม่เกิน 10,000,000 บาท'; + }]" />
- { v-model="formData.employeeMoneyEmployer" class="inputgreen" label="เงินสมทบประกันสังคม(นายจ้าง)" - mask="###,###,###,###" - reverse-fill-mask + :rules="[(val:number) => { + if (!val) return true; + const numVal = typeof val === 'number' ? val : Number(String(val).replace(/,/g, '')); + return numVal <= 10000000 || 'เงินสมทบประกันสังคม(นายจ้าง)ต้องไม่เกิน 10,000,000 บาท'; + }]" />
diff --git a/src/modules/04_registryPerson/components/detail/GovernmentInformation/07_Position.vue b/src/modules/04_registryPerson/components/detail/GovernmentInformation/07_Position.vue index f7520694d..f2eed2106 100644 --- a/src/modules/04_registryPerson/components/detail/GovernmentInformation/07_Position.vue +++ b/src/modules/04_registryPerson/components/detail/GovernmentInformation/07_Position.vue @@ -27,6 +27,7 @@ import type { DataCardPos } from "@/modules/04_registryPerson/interface/index/go import DialogHeader from "@/components/DialogHeader.vue"; import DialogHistory from "@/modules/04_registryPerson/components/detail/DialogHistory.vue"; import DialogPreviewCommand from "@/modules/18_command/components/DialogPreviewCommand.vue"; +import CurruncyInput from "@/components/CurruncyInput.vue"; const $q = useQuasar(); const route = useRoute(); @@ -370,8 +371,8 @@ const formData = reactive({ positionExecutive: "", //ตำแหน่งทางการบริหาร positionExecutiveField: "", //ด้านทางการบริหาร positionArea: "", //ด้าน/สาขา - amount: null, //เงินเดือน - amountSpecial: null, //เงินค่าตอบแทนพิเศษ + amount: undefined, //เงินเดือน + amountSpecial: undefined, //เงินค่าตอบแทนพิเศษ orgRoot: "", //หน่วยงาน orgChild1: "", //ส่วนราชการระดับ 1 orgChild2: "", //ส่วนราชการระดับ 2 @@ -685,8 +686,8 @@ async function onClickOpenDialog( ? data.positionExecutiveField : ""; formData.positionArea = statusEdit ? data.positionArea : ""; - formData.amount = statusEdit ? data.amount : null; - formData.amountSpecial = statusEdit ? data.amountSpecial : null; + formData.amount = statusEdit ? data.amount : undefined; + formData.amountSpecial = statusEdit ? data.amountSpecial : undefined; formData.orgRoot = statusEdit ? data.orgRoot : ""; formData.orgChild1 = statusEdit ? data.orgChild1 : ""; formData.orgChild2 = statusEdit ? data.orgChild2 : ""; @@ -1468,31 +1469,43 @@ onMounted(async () => {
-
-
diff --git a/src/modules/04_registryPerson/components/detail/Salary/01_PositionSalary.vue b/src/modules/04_registryPerson/components/detail/Salary/01_PositionSalary.vue index a17157593..238f4dc55 100644 --- a/src/modules/04_registryPerson/components/detail/Salary/01_PositionSalary.vue +++ b/src/modules/04_registryPerson/components/detail/Salary/01_PositionSalary.vue @@ -26,6 +26,7 @@ import type { ResListSalary } from "@/modules/04_registryPerson/interface/respon import DialogHeader from "@/components/DialogHeader.vue"; import DialogHistory from "@/modules/04_registryPerson/components/detail/DialogHistory.vue"; import DialogPreviewCommand from "@/modules/18_command/components/DialogPreviewCommand.vue"; +import CurruncyInput from "@/components/CurruncyInput.vue"; const { findOrgName } = useCounterMixin(); const $q = useQuasar(); @@ -423,10 +424,10 @@ const formData = reactive({ positionExecutive: "", //ตำแหน่งทางการบริหาร positionExecutiveField: "", //ด้านทางการบริหาร positionArea: "", //ด้าน/สาขา - amount: null, //เงินเดือน - amountSpecial: null, //เงินค่าตอบแทนพิเศษ - positionSalaryAmount: null, //เงินประจำตำแหน่ง - mouthSalaryAmount: null, //เงินค่าตอบแทนรายเดือน + amount: undefined, //เงินเดือน + amountSpecial: undefined, //เงินค่าตอบแทนพิเศษ + positionSalaryAmount: undefined, //เงินประจำตำแหน่ง + mouthSalaryAmount: undefined, //เงินค่าตอบแทนรายเดือน orgRoot: "", //หน่วยงาน orgChild1: "", //ส่วนราชการระดับ 1 orgChild2: "", //ส่วนราชการระดับ 2 @@ -666,10 +667,12 @@ async function onClickOpenDialog( ? data.positionExecutiveField : ""; formData.positionArea = statusEdit ? data.positionArea : ""; - formData.amount = statusEdit ? data.amount : null; - formData.amountSpecial = statusEdit ? data.amountSpecial : null; - formData.positionSalaryAmount = statusEdit ? data.positionSalaryAmount : null; - formData.mouthSalaryAmount = statusEdit ? data.mouthSalaryAmount : null; + formData.amount = statusEdit ? data.amount : undefined; + formData.amountSpecial = statusEdit ? data.amountSpecial : undefined; + formData.positionSalaryAmount = statusEdit + ? data.positionSalaryAmount + : undefined; + formData.mouthSalaryAmount = statusEdit ? data.mouthSalaryAmount : undefined; formData.orgRoot = statusEdit ? data.orgRoot : ""; formData.orgChild1 = statusEdit ? data.orgChild1 : ""; formData.orgChild2 = statusEdit ? data.orgChild2 : ""; @@ -1433,60 +1436,75 @@ onMounted(async () => {
-
-
-
-
diff --git a/src/modules/04_registryPerson/interface/index/government.ts b/src/modules/04_registryPerson/interface/index/government.ts index bf46d84fa..ab594c210 100644 --- a/src/modules/04_registryPerson/interface/index/government.ts +++ b/src/modules/04_registryPerson/interface/index/government.ts @@ -75,8 +75,8 @@ interface FormPostition { positionExecutiveField?: string; //ด้านทางการบริหาร positionArea?: string; //ด้าน/สาขา positionCee: string; //ระดับซี - amount: number | null; //เงินเดือน - amountSpecial: number | null; //เงินค่าตอบแทนพิเศษ + amount: number | undefined; //เงินเดือน + amountSpecial: number | undefined; //เงินค่าตอบแทนพิเศษ orgRoot: string; //หน่วยงาน orgChild1: string; //ส่วนราชการระดับ 1 orgChild2: string; //ส่วนราชการระดับ 2 diff --git a/src/modules/04_registryPerson/interface/request/Edit.ts b/src/modules/04_registryPerson/interface/request/Edit.ts index 4f6f6f00a..794b1fd6b 100644 --- a/src/modules/04_registryPerson/interface/request/Edit.ts +++ b/src/modules/04_registryPerson/interface/request/Edit.ts @@ -22,10 +22,10 @@ interface FormDataSalary { positionPathSide: string; //ด้าน/สาขา positionExecutive: string; //ตำแหน่งทางการบริหาร positionExecutiveField: string; //ด้านทางการบริหาร - amount: number | null; //เงินเดือน - amountSpecial: number | null; //เงินค่าตอบแทนพิเศษ - positionSalaryAmount: number | null; //เงินประจำตำแหน่ง - mouthSalaryAmount: number | null; //เงินค่าตอบแทนรายเดือน + amount: number | undefined; //เงินเดือน + amountSpecial: number | undefined; //เงินค่าตอบแทนพิเศษ + positionSalaryAmount: number | undefined; //เงินประจำตำแหน่ง + mouthSalaryAmount: number | undefined; //เงินค่าตอบแทนรายเดือน orgRoot: string; //หน่วยงาน orgChild1: string; //ส่วนราชการระดับ 1 orgChild2: string; //ส่วนราชการระดับ 2 diff --git a/src/modules/04_registryPerson/interface/request/Employee.ts b/src/modules/04_registryPerson/interface/request/Employee.ts index 3d8c623bf..4decc9346 100644 --- a/src/modules/04_registryPerson/interface/request/Employee.ts +++ b/src/modules/04_registryPerson/interface/request/Employee.ts @@ -4,11 +4,11 @@ interface FormEmployee { positionEmployeePositionId: string; employeeOc: string; employeeTypeIndividual: string; - employeeWage: string; - employeeMoneyIncrease: string; - employeeMoneyAllowance: string; - employeeMoneyEmployee: string; - employeeMoneyEmployer: string; + employeeWage: number | undefined; + employeeMoneyIncrease: number | undefined; + employeeMoneyAllowance: number | undefined; + employeeMoneyEmployee: number | undefined; + employeeMoneyEmployer: number | undefined; } interface FormEmployment { diff --git a/src/modules/04_registryPerson/interface/request/Salary.ts b/src/modules/04_registryPerson/interface/request/Salary.ts index da895b49c..71991f592 100644 --- a/src/modules/04_registryPerson/interface/request/Salary.ts +++ b/src/modules/04_registryPerson/interface/request/Salary.ts @@ -15,10 +15,10 @@ interface FormSalary { positionExecutive: string; //ตำแหน่งทางการบริหาร positionExecutiveField?: string; //ด้านทางการบริหาร positionArea?: string; //ด้าน/สาขา - amount: number | null; //เงินเดือน - amountSpecial: number | null; //เงินค่าตอบแทนพิเศษ - positionSalaryAmount: number | null; //เงินประจำตำแหน่ง - mouthSalaryAmount: number | null; //เงินค่าตอบแทนรายเดือน + amount: number | undefined; //เงินเดือน + amountSpecial: number | undefined; //เงินค่าตอบแทนพิเศษ + positionSalaryAmount: number | undefined; //เงินประจำตำแหน่ง + mouthSalaryAmount: number | undefined; //เงินค่าตอบแทนรายเดือน orgRoot: string; //หน่วยงาน orgChild1: string; //ส่วนราชการระดับ 1 orgChild2: string; //ส่วนราชการระดับ 2 diff --git a/src/modules/04_registryPerson/views/edit/components/DialogForm.vue b/src/modules/04_registryPerson/views/edit/components/DialogForm.vue index ad12ede48..866ec62cd 100644 --- a/src/modules/04_registryPerson/views/edit/components/DialogForm.vue +++ b/src/modules/04_registryPerson/views/edit/components/DialogForm.vue @@ -62,10 +62,10 @@ const formData = reactive({ positionPathSide: "", //ด้าน/สาขา positionExecutive: "", //ตำแหน่งทางการบริหาร positionExecutiveField: "", //ด้านทางการบริหาร - amount: null, //เงินเดือน - amountSpecial: null, //เงินค่าตอบแทนพิเศษ - positionSalaryAmount: null, //เงินประจำตำแหน่ง - mouthSalaryAmount: null, //เงินค่าตอบแทนรายเดือน + amount: undefined, //เงินเดือน + amountSpecial: undefined, //เงินค่าตอบแทนพิเศษ + positionSalaryAmount: undefined, //เงินประจำตำแหน่ง + mouthSalaryAmount: undefined, //เงินค่าตอบแทนรายเดือน orgRoot: "", //หน่วยงาน orgChild1: "", //ส่วนราชการระดับ 1 orgChild2: "", //ส่วนราชการระดับ 2 @@ -91,10 +91,10 @@ const formReadonly = reactive({ positionPathSide: "", //ด้าน/สาขา positionExecutive: "", //ตำแหน่งทางการบริหาร positionExecutiveField: "", //ด้านทางการบริหาร - amount: null, //เงินเดือน - amountSpecial: null, //เงินค่าตอบแทนพิเศษ - positionSalaryAmount: null, //เงินประจำตำแหน่ง - mouthSalaryAmount: null, //เงินค่าตอบแทนรายเดือน + amount: undefined, //เงินเดือน + amountSpecial: undefined, //เงินค่าตอบแทนพิเศษ + positionSalaryAmount: undefined, //เงินประจำตำแหน่ง + mouthSalaryAmount: undefined, //เงินค่าตอบแทนรายเดือน orgRoot: "", //หน่วยงาน orgChild1: "", //ส่วนราชการระดับ 1 orgChild2: "", //ส่วนราชการระดับ 2 @@ -377,10 +377,10 @@ function onClickCloseDialog() { formData.positionPathSide = ""; formData.positionExecutive = ""; formData.positionExecutiveField = ""; - formData.amount = null; - formData.amountSpecial = null; - formData.positionSalaryAmount = null; - formData.mouthSalaryAmount = null; + formData.amount = undefined; + formData.amountSpecial = undefined; + formData.positionSalaryAmount = undefined; + formData.mouthSalaryAmount = undefined; formData.orgRoot = ""; formData.orgChild1 = ""; formData.orgChild2 = ""; @@ -405,9 +405,9 @@ function onClickCloseDialog() { formReadonly.positionPathSide = ""; formReadonly.positionExecutive = ""; formReadonly.positionExecutiveField = ""; - formReadonly.amount = null; - formReadonly.positionSalaryAmount = null; - formReadonly.mouthSalaryAmount = null; + formReadonly.amount = undefined; + formReadonly.positionSalaryAmount = undefined; + formReadonly.mouthSalaryAmount = undefined; formReadonly.orgRoot = ""; formReadonly.orgChild1 = ""; formReadonly.orgChild2 = ""; diff --git a/src/modules/04_registryPerson/views/edit/components/FormPosition.vue b/src/modules/04_registryPerson/views/edit/components/FormPosition.vue index 6a459c9ec..60a2cf9ff 100644 --- a/src/modules/04_registryPerson/views/edit/components/FormPosition.vue +++ b/src/modules/04_registryPerson/views/edit/components/FormPosition.vue @@ -5,6 +5,8 @@ import { useEditPosDataStore } from "@/modules/04_registryPerson/stores/Edit"; import type { DataOption } from "@/modules/04_registryPerson/interface/index/Main"; import type { FormDataSalary } from "@/modules/04_registryPerson/interface/request/Edit"; +import CurruncyInput from "@/components/CurruncyInput.vue"; + const { date2Thai } = useCounterMixin(); const store = useEditPosDataStore(); @@ -597,7 +599,7 @@ function classInput(val: boolean) {
-
-
-
-
diff --git a/src/modules/04_registryPerson/views/edit/components/Table.vue b/src/modules/04_registryPerson/views/edit/components/Table.vue index c93771d7e..2c025f97e 100644 --- a/src/modules/04_registryPerson/views/edit/components/Table.vue +++ b/src/modules/04_registryPerson/views/edit/components/Table.vue @@ -20,6 +20,7 @@ import type { import DialogForm from "@/modules/04_registryPerson/views/edit/components/DialogForm.vue"; import DialogSort from "@/modules/04_registryPerson/views/edit/components/DialogSort.vue"; +import CurruncyInput from "@/components/CurruncyInput.vue"; const $q = useQuasar(); const route = useRoute(); @@ -47,6 +48,10 @@ const statusCheckEdit = defineModel("statusCheckEdit", { required: true, }); +const amountRef = ref(null); +const amountSpecialRef = ref(null); +const currencyPopupRef = ref(null); + //Table const isLoad = ref(true); const rowIndex = ref(0); @@ -341,7 +346,6 @@ function onEditData(index: number) { rowIndex.value = index; modal.value = true; isAddPosition.value = index === -1; // ถ้า index เป็น -1 แสดงว่าเป็นการเพิ่มข้อมูลใหม่ - console.log(`isAddPosition: ${isAddPosition.value}`); } /** @@ -559,6 +563,14 @@ function onShow(data: DataPosition, colName: string) { * @param close */ async function onSave(val: any, id: string, close?: () => void) { + // ตรวจสอบ validation ถ้า amountRef มีค่าและมี validate method + if (amountRef.value && typeof amountRef.value.validate === "function") { + const isValid = amountRef.value.validate(); + if (isValid === false) { + return; // หยุดการบันทึกถ้า validation ไม่ผ่าน + } + } + if (isUpdateData.value) { showLoader(); const isCol = (key: string) => colNameMain.value === key; @@ -746,6 +758,97 @@ function onUpdateData() { isUpdateData.value = true; } +/** + * ฟังก์ชันตรวจสอบ validation และบันทึกข้อมูลสำหรับทุกประเภท + */ +async function validateAndSave( + val: any, + id: string, + close?: () => void, + fieldType: "amount" | "currency" | "normal" = "normal" +) { + let isValid = true; + + // ตรวจสอบ validation สำหรับ amount fields + if (fieldType === "amount") { + // Validate เงินเดือน + if (formData.amount !== null && formData.amount !== undefined) { + const amountNum = + typeof formData.amount === "number" + ? formData.amount + : Number(String(formData.amount).replace(/,/g, "")); + if (amountNum > 10000000) { + isValid = false; + } + } + + // Validate เงินค่าตอบแทนพิเศษ + if ( + isValid && + formData.amountSpecial !== null && + formData.amountSpecial !== undefined + ) { + const amountSpecialNum = + typeof formData.amountSpecial === "number" + ? formData.amountSpecial + : Number(String(formData.amountSpecial).replace(/,/g, "")); + if (amountSpecialNum > 10000000) { + isValid = false; + } + } + + // Force validate refs ถ้ามี + if ( + isValid && + amountRef.value && + typeof amountRef.value.validate === "function" + ) { + const amountValid = amountRef.value.validate(); + isValid = isValid && amountValid !== false; + } + + if ( + isValid && + amountSpecialRef.value && + typeof amountSpecialRef.value.validate === "function" + ) { + const amountSpecialValid = amountSpecialRef.value.validate(); + isValid = isValid && amountSpecialValid !== false; + } + } + + // ตรวจสอบ validation สำหรับ currency fields อื่นๆ + else if (fieldType === "currency") { + // Validate ค่าโดยตรงก่อน + if (val !== null && val !== undefined) { + const numVal = + typeof val === "number" ? val : Number(String(val).replace(/,/g, "")); + if (numVal > 10000000) { + isValid = false; + } + } + + // Force validate ref ถ้ามี + if ( + isValid && + currencyPopupRef.value && + typeof currencyPopupRef.value.validate === "function" + ) { + const currencyValid = currencyPopupRef.value.validate(); + isValid = isValid && currencyValid !== false; + } + } + + // บันทึกข้อมูลถ้า validation ผ่าน + if (isValid) { + await onSave(val, id, close); + return true; + } else { + // หยุดการบันทึกถ้า validation ไม่ผ่าน (rules จะแสดง error message เอง) + return false; + } +} + onMounted(async () => { await Promise.all([fetchData(), fetchType()]); }); @@ -946,7 +1049,11 @@ onMounted(async () => { label-set="บันทึก" label-cancel="ยกเลิก" @before-show="onShow(props.row, col.name)" - :persistent="col.name === 'commandNo'" + :persistent=" + col.name === 'commandNo' || col.name === 'amount' + " + :buttons="false" + @save="null" >
{{ `แก้ไข${col.label}` }} @@ -999,27 +1106,65 @@ onMounted(async () => {
- - + + +
+ + +
@@ -1165,7 +1310,11 @@ onMounted(async () => {
-
+ +
{ flat color="primary" label="บันทึก" - @click="onSave(formData, props.row.id, scope.cancel)" + @click=" + validateAndSave( + formData, + props.row.id, + scope.cancel, + 'normal' + ) + " + /> +
+ + +
+ +
@@ -1205,6 +1387,8 @@ onMounted(async () => { label-set="บันทึก" label-cancel="ยกเลิก" @before-show="onShow(props.row, col.name)" + :buttons="false" + @save="null" >
{{ `แก้ไข${col.label}` }} @@ -1276,7 +1460,14 @@ onMounted(async () => { flat color="primary" label="บันทึก" - @click="onSave(formData, props.row.id, scope.cancel)" + @click=" + validateAndSave( + formData, + props.row.id, + scope.cancel, + 'normal' + ) + " />
@@ -1293,13 +1484,37 @@ onMounted(async () => { v-slot="scope" :persistent=" col.name === 'commandDateAffect' || - col.name === 'commandDateSign' + col.name === 'commandDateSign' || + col.name === 'mouthSalaryAmount' || + col.name === 'positionSalaryAmount' " v-model="props.row[col.name]" - buttons + :buttons=" + col.name !== 'mouthSalaryAmount' && + col.name !== 'positionSalaryAmount' && + col.name !== 'commandDateAffect' && + col.name !== 'commandDateSign' && + col.name !== 'positionName' && + col.name !== 'positionExecutive' && + col.name !== 'positionExecutiveField' && + col.name !== 'remark' && + col.name !== 'positionType' + " label-set="บันทึก" label-cancel="ยกเลิก" - @save="onSave" + @save=" + col.name === 'mouthSalaryAmount' || + col.name === 'positionSalaryAmount' || + col.name === 'commandDateAffect' || + col.name === 'commandDateSign' || + col.name === 'positionName' || + col.name === 'positionExecutive' || + col.name === 'positionExecutiveField' || + col.name === 'remark' || + col.name === 'positionType' + ? null + : onSave + " @before-show="onShow(props.row, col.name)" >
@@ -1360,19 +1575,26 @@ onMounted(async () => { @update:model-value="onUpdateData" /> - { + + +
+ + +
+ + +
+ + +
diff --git a/src/modules/09_leave/components/05_Leave/DetailLeavePage.vue b/src/modules/09_leave/components/05_Leave/DetailLeavePage.vue index f0ac7daf3..7d71309a2 100644 --- a/src/modules/09_leave/components/05_Leave/DetailLeavePage.vue +++ b/src/modules/09_leave/components/05_Leave/DetailLeavePage.vue @@ -365,20 +365,24 @@ async function fetchDetailLeave(paramsId: string) { formData.coupleDayLevelCountry = data.coupleDayLevelCountry ? data.coupleDayLevelCountry : "-"; - formData.coupleDayCountryHistory = data.coupleDayCountryHistory - ? data.coupleDayCountryHistory - : "-"; - formData.coupleDayTotalHistory = data.coupleDayTotalHistory - ? data.coupleDayTotalHistory - : "-"; + formData.coupleDayCountryHistory = + data.coupleDayCountryHistory && data.coupleDayCountryHistory !== "null" + ? data.coupleDayCountryHistory + : "-"; + formData.coupleDayTotalHistory = + data.coupleDayTotalHistory && data.coupleDayTotalHistory !== "null" + ? data.coupleDayTotalHistory + : "-"; formData.coupleDayStartDateHistory = data.coupleDayStartDateHistory && date2Thai(data.coupleDayStartDateHistory); formData.coupleDayEndDateHistory = data.coupleDayEndDateHistory && date2Thai(data.coupleDayEndDateHistory); - formData.coupleDaySumTotalHistory = data.coupleDaySumTotalHistory - ? data.coupleDaySumTotalHistory - : ""; + formData.coupleDaySumTotalHistory = + data.coupleDaySumTotalHistory && + data.coupleDaySumTotalHistory !== "null" + ? data.coupleDaySumTotalHistory + : ""; formData.approveStep = data.approveStep ? data.approveStep : "-"; formData.dear = data.dear ? data.dear : "-"; formData.profileType = data.profileType; diff --git a/src/modules/09_leave/components/05_Leave/formDetail/formSpouse.vue b/src/modules/09_leave/components/05_Leave/formDetail/formSpouse.vue index bf7596e93..cfe967acc 100644 --- a/src/modules/09_leave/components/05_Leave/formDetail/formSpouse.vue +++ b/src/modules/09_leave/components/05_Leave/formDetail/formSpouse.vue @@ -1,10 +1,10 @@