From 8626d1f4e3295ffa6eb315fc8d47d99fb6fe8356 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Mon, 10 Mar 2025 18:30:28 +0700 Subject: [PATCH 1/5] =?UTF-8?q?=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=87?= =?UTF-8?q?=E0=B8=B2=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../04_registryPerson/stores/Position.ts | 4 +- .../21_report/views/02_reportRegistry.vue | 181 +++++++++++++----- 2 files changed, 136 insertions(+), 49 deletions(-) diff --git a/src/modules/04_registryPerson/stores/Position.ts b/src/modules/04_registryPerson/stores/Position.ts index 583f8d659..ee7c6d0ea 100644 --- a/src/modules/04_registryPerson/stores/Position.ts +++ b/src/modules/04_registryPerson/stores/Position.ts @@ -24,7 +24,9 @@ export const useGovernmentPosDataStore = defineStore("GovernmentPos", () => { const posExecutiveData = ref([]); //รายการตำแหน่งทางการบริหาร function convertCommandCodeName(val: string) { - return commandCodeData.value.find((e: DataOption) => e.id === val)?.name; + return ( + commandCodeData.value.find((e: DataOption) => e.id === val)?.name ?? "-" + ); } return { diff --git a/src/modules/21_report/views/02_reportRegistry.vue b/src/modules/21_report/views/02_reportRegistry.vue index 3738266fd..3e9850572 100644 --- a/src/modules/21_report/views/02_reportRegistry.vue +++ b/src/modules/21_report/views/02_reportRegistry.vue @@ -94,6 +94,9 @@ const statusOps = ref([]); //ตัวเลือก สถาน const education = ref(""); const educationOp = ref([]); const educationOpMain = ref([]); +const educationLevel = ref(""); +const field = ref(""); +const positionArea = ref(""); /** ตัวแปรสังกัด */ const modalOrg = ref(false); @@ -128,6 +131,8 @@ const visibleColumnsBase = ref([ "gender", "status", "education", + "educationLevel", + "field", "dateAppoint", "dateRetireLaw", "age", @@ -247,6 +252,17 @@ const columns = computed(() => { sort: (a: string, b: string) => a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, + { + name: "educationLevel", + align: "left", + label: "ระดับการศึกษา", + sortable: true, + field: "educationLevel", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + sort: (a: string, b: string) => + a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), + }, { name: "education", align: "left", @@ -258,6 +274,18 @@ const columns = computed(() => { sort: (a: string, b: string) => a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, + + { + name: "field", + align: "left", + label: "สาขา", + sortable: true, + field: "field", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + sort: (a: string, b: string) => + a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), + }, { name: "dateAppoint", align: "left", @@ -336,10 +364,6 @@ const rangeTerm = ref({ }); const isLoadStructureTree = ref(true); -function onOpenOrg() { - modalOrg.value = true; -} - /** * ฟังก์ชั่นค้นหาข้อมูลของ Option Filter * @param val คำที่ค้นหา @@ -491,29 +515,12 @@ function getDataPerson() { }); } -/** function ดึง ข้อมูลระดับการศึกษา*/ -function getEducationLevel() { - http - .get(config.API.orgEducationLevel) - .then(async (res) => { - const list = res.data.result.map((r: DataEducationLevel) => ({ - id: r.id, - name: r.name, - })); - educationOpMain.value = list; - }) - .catch((err) => { - messageError($q, err); - }); -} - async function onSearch() { loadingBtn.value = true; pagination.value.page = 1; const queryParams = { node: storeReport.formFilter.node ?? null, nodeId: storeReport.formFilter.nodeId ?? "", - posType: posType.value, posLevel: posLevel.value, position: position.value, @@ -521,11 +528,13 @@ async function onSearch() { gender: gender.value, status: status.value, education: education.value.trim(), + educationLevel: educationLevel.value.trim(), + field: field.value.trim(), + positionArea: education.value.trim(), ageMin: rangeAge.value.min, ageMax: rangeAge.value.max, dateStart: dateStart.value ?? null, dateEnd: dateEnd.value ?? null, - isProbation: isProbation.value, isRetire: isRetire.value, retireType: retireType.value, @@ -546,6 +555,22 @@ async function onSearch() { ) .then(async (res) => { const data = res.data.result.data; + const Educations = [ + { + field: "", + degree: "วิทยาศาสตร์บัณฑิต", + isHigh: null, + isEducation: 1, + educationLevel: "", + }, + { + field: "", + degree: "วิทยาศาสตร์บัณฑิต2", + isHigh: null, + isEducation: 1, + educationLevel: "ปริญญาตรี", + }, + ]; total.value = res.data.result.total; rows.value = data.map((item: any, index: number) => ({ profileId: item.profileId, @@ -561,7 +586,12 @@ async function onSearch() { positionExecutive: item.posExecutiveName ?? "-", gender: item.gender ?? "-", status: item.relationship ?? "-", - education: item.degree ?? "-", + education: + Educations.length > 0 ? Educations.map((e) => e.degree) : "-", + educationLevel: + Educations.length > 0 ? Educations.map((e) => e.educationLevel) : "-", + field: Educations.length > 0 ? Educations.map((e) => e.field) : "-", + dateAppoint: item.dateAppoint ?? "-", age: item.age ?? "-", positionDate: @@ -599,6 +629,9 @@ function exportToExcel() { ...rest, dateAppoint: date2Thai(e.dateAppoint), dateRetireLaw: date2Thai(e.dateRetireLaw), + education: e.education.map((e: string) => `${e}`).join(", "), + educationLevel: e.education.map((e: string) => `${e}`).join(", "), + feild: e.education.map((e: string) => `${e}`).join(", "), }; }); @@ -635,6 +668,10 @@ function clearFilter() { gender.value = ""; //เพศ status.value = ""; //สถานภาพ education.value = ""; //วุฒิการศึกษา + field.value = ""; + educationLevel.value = ""; + positionArea.value = ""; + //ช่วงเวลาบรรจุ dateStart.value = null; //ตั้งแต่วันที่ dateEnd.value = null; //ถึงวันที่ @@ -743,6 +780,14 @@ onMounted(async () => { }); }); +function formatEducation(value: any) { + return Array.isArray(value) && value.length > 0 + ? value + .map((e, index) => (e ? `- ${e}` : index > 0 ? "
" : "")) + .join("
") + : "-"; +} + watch( () => storeMenu.permissions, () => { @@ -774,7 +819,7 @@ watch( map-options option-label="name" option-value="id" - @update:model-value="clearFilter(), getType()" + @update:model-value="clearFilter(), getType(), (rows = [])" > @@ -1238,6 +1283,25 @@ watch(
+
+ + + +
+
- + +
+
+ +
+
+ + +
@@ -1677,6 +1752,16 @@ watch( > {{ col.value ? col.value : "-" }}
+
+
+
+
{{ col.value ? col.value : "-" }}
From 139437d793b37dd3ce525283108d76a2d06cba7b Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Tue, 11 Mar 2025 09:44:13 +0700 Subject: [PATCH 2/5] =?UTF-8?q?fix=20=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=87?= =?UTF-8?q?=E0=B8=B2=E0=B8=99=E0=B8=97=E0=B8=B0=E0=B9=80=E0=B8=9A=E0=B8=B5?= =?UTF-8?q?=E0=B8=A2=E0=B8=99=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=A7=E0=B8=B1?= =?UTF-8?q?=E0=B8=95=E0=B8=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../21_report/views/02_reportRegistry.vue | 63 ++++++++++--------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/src/modules/21_report/views/02_reportRegistry.vue b/src/modules/21_report/views/02_reportRegistry.vue index 3e9850572..400374095 100644 --- a/src/modules/21_report/views/02_reportRegistry.vue +++ b/src/modules/21_report/views/02_reportRegistry.vue @@ -21,7 +21,6 @@ import type { DataOption, OptionExecutive, ResOptionPerson, - DataEducationLevel, } from "@/modules/21_report/interface/Main"; import type { DataRoles } from "@/interface/response/main"; import type { DataStructureTree } from "@/interface/main"; @@ -44,6 +43,7 @@ const { hideLoader, date2Thai, formatDatePositionReport, + convertDateToAPI, } = useCounterMixin(); const loadingBtn = ref(false); @@ -530,11 +530,11 @@ async function onSearch() { education: education.value.trim(), educationLevel: educationLevel.value.trim(), field: field.value.trim(), - positionArea: education.value.trim(), + positionArea: positionArea.value.trim(), ageMin: rangeAge.value.min, ageMax: rangeAge.value.max, - dateStart: dateStart.value ?? null, - dateEnd: dateEnd.value ?? null, + dateStart: convertDateToAPI(dateStart.value) ?? null, + dateEnd: convertDateToAPI(dateEnd.value) ?? null, isProbation: isProbation.value, isRetire: isRetire.value, retireType: retireType.value, @@ -555,22 +555,7 @@ async function onSearch() { ) .then(async (res) => { const data = res.data.result.data; - const Educations = [ - { - field: "", - degree: "วิทยาศาสตร์บัณฑิต", - isHigh: null, - isEducation: 1, - educationLevel: "", - }, - { - field: "", - degree: "วิทยาศาสตร์บัณฑิต2", - isHigh: null, - isEducation: 1, - educationLevel: "ปริญญาตรี", - }, - ]; + total.value = res.data.result.total; rows.value = data.map((item: any, index: number) => ({ profileId: item.profileId, @@ -587,10 +572,17 @@ async function onSearch() { gender: item.gender ?? "-", status: item.relationship ?? "-", education: - Educations.length > 0 ? Educations.map((e) => e.degree) : "-", + item.Educations.length > 0 + ? item.Educations.map((e: any) => e.degree) + : [], educationLevel: - Educations.length > 0 ? Educations.map((e) => e.educationLevel) : "-", - field: Educations.length > 0 ? Educations.map((e) => e.field) : "-", + item.Educations.length > 0 + ? item.Educations.map((e: any) => e.educationLevel) + : [], + field: + item.Educations.length > 0 + ? item.Educations.map((e: any) => e.field) + : [], dateAppoint: item.dateAppoint ?? "-", age: item.age ?? "-", @@ -630,8 +622,8 @@ function exportToExcel() { dateAppoint: date2Thai(e.dateAppoint), dateRetireLaw: date2Thai(e.dateRetireLaw), education: e.education.map((e: string) => `${e}`).join(", "), - educationLevel: e.education.map((e: string) => `${e}`).join(", "), - feild: e.education.map((e: string) => `${e}`).join(", "), + educationLevel: e.educationLevel.map((e: string) => `${e}`).join(", "), + field: e.field.map((e: string) => `${e}`).join(", "), }; }); @@ -781,11 +773,22 @@ onMounted(async () => { }); function formatEducation(value: any) { - return Array.isArray(value) && value.length > 0 - ? value - .map((e, index) => (e ? `- ${e}` : index > 0 ? "
" : "")) - .join("
") - : "-"; + if (!Array.isArray(value) || value.length === 0) { + return "-"; + } + + // ตรวจสอบว่าทุกค่าว่างทั้งหมดหรือไม่ + const allEmpty = value.every((e) => !e?.toString().trim()); + + if (allEmpty) { + return "-"; + } + + return value + .map((e, index) => + e?.toString().trim() ? `- ${e}` : index > 0 ? "
" : "" + ) + .join("
"); } watch( From e5b9299ee9be095c7abe3bdb4bff86c14744dde9 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Tue, 11 Mar 2025 11:11:31 +0700 Subject: [PATCH 3/5] =?UTF-8?q?fix=20=E0=B8=95=E0=B8=B3=E0=B9=81=E0=B8=AB?= =?UTF-8?q?=E0=B8=99=E0=B9=88=E0=B8=87=E0=B9=80=E0=B8=87=E0=B8=B4=E0=B8=99?= =?UTF-8?q?=E0=B9=80=E0=B8=94=E0=B8=B7=E0=B8=AD=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GovernmentInformation/07_Position.vue | 38 +- .../detail/Salary/01_PositionSalary.vue | 1318 +++++++++-------- .../Salary/01_PositionSalaryHistory.vue | 206 ++- .../components/detail/Salary/Main.vue | 2 +- .../interface/request/Salary.ts | 43 +- .../04_registryPerson/stores/salary.ts | 201 +-- 6 files changed, 842 insertions(+), 966 deletions(-) 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 9c6343bdb..6187ac38a 100644 --- a/src/modules/04_registryPerson/components/detail/GovernmentInformation/07_Position.vue +++ b/src/modules/04_registryPerson/components/detail/GovernmentInformation/07_Position.vue @@ -51,6 +51,7 @@ const { onSearchDataTable, formatDatePosition, findOrgName, + convertDateToAPI } = useCounterMixin(); const empType = ref(pathRegistryEmp(route.name?.toString() ?? "")); @@ -419,8 +420,6 @@ async function fetchDataOption() { .then((res) => { const data = res.data.result; - console.log(data); - const seen = new Set(); const seen2 = new Set(); @@ -566,7 +565,12 @@ async function onClickOpenDialog( } else { await fetchOptionGroup(); } - + commandCodeOptions.value = store.commandCodeData; + posTypeOptions.value = store.posTypeData; + posLevelOptions.value = store.posLevelData; + posLineOptions.value = store.posLineData; + posPathSideOptions.value = store.posPathSideData; + posExecutiveOptions.value = store.posExecutiveData; // หาระดับตำแหน่ง statusEdit && (await updateSelectType(data.positionType, true)); isStatusEdit.value = statusEdit; @@ -601,27 +605,6 @@ async function onClickOpenDialog( /** function ปิด dialog ตำแหน่งเงินเดือน*/ function onClickCloseDialog() { modalDialogSalary.value = false; - formData.commandCode = ""; - formData.commandNo = ""; - formData.commandYear = null; - formData.commandDateAffect = null; - formData.commandDateSign = null; - formData.posNoAbb = ""; - formData.posNo = ""; - formData.positionName = ""; - formData.positionType = ""; - formData.positionLevel = ""; - formData.positionLine = ""; - formData.positionPathSide = ""; - formData.positionExecutive = ""; - formData.amount = null; - formData.amountSpecial = null; - formData.orgRoot = ""; - formData.orgChild1 = ""; - formData.orgChild2 = ""; - formData.orgChild3 = ""; - formData.orgChild4 = ""; - formData.remark = ""; } /** @@ -704,6 +687,8 @@ function onSubmit() { ? profileId.value : undefined, ...formData, + commandDateAffect: convertDateToAPI(formData.commandDateAffect), + commandDateSign: convertDateToAPI(formData.commandDateSign), amount: Number(String(formData.amount)?.replace(/,/g, "")), amountSpecial: Number( String(formData.amountSpecial)?.replace(/,/g, "") @@ -921,9 +906,7 @@ onMounted(async () => { @@ -1417,6 +1400,7 @@ onMounted(async () => { +
(pathRegistryEmp(route.name?.toString() ?? "")); @@ -84,7 +86,7 @@ const baseColumns = ref([ style: "font-size: 14px", format(val, row) { return row.posNoAbb && row.posNo - ? `${row.posNoAbb}${row.posNo}` + ? `${row.posNoAbb}.${row.posNo}` : row.posNo ? row.posNo : "-"; @@ -159,7 +161,15 @@ const baseColumns = ref([ field: "amount", headerStyle: "font-size: 14px", style: "font-size: 14px", - format: (v) => Number(v).toLocaleString(), + format(v, row) { + return row.amount + ? `${row.amount.toLocaleString()}${ + row.amountSpecial !== 0 && row.amountSpecial + ? ` (${row.amountSpecial.toLocaleString()})` + : "" + }` + : "-"; + }, sort: (a: string, b: string) => a .toString() @@ -194,11 +204,11 @@ const baseColumns = ref([ .localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, { - name: "refCommandNo", + name: "commandNo", align: "left", label: "เลขที่คำสั่ง", sortable: true, - field: "refCommandNo", + field: "commandNo", format(val, row) { return row.commandNo && row.commandYear ? `${row.commandNo}/${row.commandYear}` @@ -210,13 +220,17 @@ const baseColumns = ref([ a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, { - name: "commandName", + name: "commandCode", align: "left", label: "ประเภทคำสั่ง", sortable: true, - field: "commandName", + field: "commandCode", headerStyle: "font-size: 14px", style: "font-size: 14px", + format(val, row) { + return store.convertCommandCodeName(val); + }, + sort: (a: string, b: string) => a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, @@ -282,62 +296,61 @@ const columns = computed(() => { }); const visibleColumns = ref([ "commandDateAffect", - "amount", - "positionSalaryAmount", - "mouthSalaryAmount", "posNo", "positionName", "positionType", "positionLevel", "positionExecutive", + "amount", + "positionSalaryAmount", + "mouthSalaryAmount", + "commandNo", + "commandCode", "commandDateSign", - "commandName", - "refCommandNo", - "remark", "organization", + "remark", ]); const pagination = ref({ sortBy: "", }); -const formDataSalary = reactive({ - date: null, //วัน/เดือน/ปี - posNo: "", //ตำแหน่งเลขที่ - templatePos: "", //ต้นแบบ (template) ตำแหน่ง - position: "", //ตำแหน่ง - positionType: "", //ประเภทตำแหน่ง, กลุ่มงาน - positionLevel: "", //ระดับตำแหน่ง, ระดับชั้นงาน +const formData = reactive({ + commandCode: "", //ประเภทคำสั่ง + commandNo: "", //เลขที่คำสั่ง + commandYear: null, //ปี + commandDateAffect: null, //วันที่มีผล + commandDateSign: null, //วันที่ลงนาม + posNoAbb: "", //ตัวย่อเลขที่ตำแหน่ง + posNo: "", //เลขที่ตำแหน่ง + positionName: "", //ตำแหน่ง + positionType: "", //ประเภทตำแหน่ง | กลุ่มงาน + positionLevel: "", //ระดับตำแหน่ง | ระดับชั้นงาน positionLine: "", // สายงาน positionPathSide: "", //ด้าน/สาขา positionExecutive: "", //ตำแหน่งทางการบริหาร - salary: null, //เงินเดือน - salaryPos: null, //เงินประจำตำแหน่ง - salaryCompensation: null, //เงินค่าตอบแทนรายเดือน - refCommandNo: "", //เลขที่คำสั่ง - templateDoc: "", //ต้นแบบ (template) เอกสารอ้างอิง - doc: "", //เอกสารอ้างอิง + amount: null, //เงินเดือน amountSpecial: null, //เงินค่าตอบแทนพิเศษ + positionSalaryAmount: null, //เงินประจำตำแหน่ง + mouthSalaryAmount: null, //เงินค่าตอบแทนรายเดือน + orgRoot: "", //หน่วยงาน + orgChild1: "", //ส่วนราชการระดับ 1 + orgChild2: "", //ส่วนราชการระดับ 2 + orgChild3: "", //ส่วนราชการระดับ 3 + orgChild4: "", //ส่วนราชการระดับ 4 + remark: "", //หมายเหตุ }); const modalDialogSalary = ref(false); //แสดง popup ตำแหน่งเงินเดือน const isStatusEdit = ref(false); //สถานะแก้ไขข้อมูลตำแหน่งเงินเดือน const salaryId = ref(""); //id ที่ต้องการแก้ไข -const dataLevel = ref([]); //รายการ ตำแหน่งเงินเดือน +const dataLevel = ref([]); //รายการ ตำแหน่งเงินเดือน -const posNoOptions = ref(store.optionTemplatePos); - -const posTypeOptions = ref([]); -const posTypeOptionsMain = ref([]); -const posLevelOption = ref([]); -const posLevelOptionMain = ref([]); -const positionFielOptiond = ref([]); -const positionFielOptiondMain = ref([]); -const positionAreaOptiond = ref([]); -const positionAreaOptiondMain = ref([]); -const posExecutiveOption = ref([]); -const posExecutiveOptionMain = ref([]); - -const docOption = ref(store.optionTemplateDoc); +const commandCodeOptions = ref(store.commandCodeData); //รายการปรเภทคำสั่ง +const posTypeOptions = ref(store.posTypeData); //รายการประเภทตำแหน่ง | กลุ่มงาน +const posLevelOptions = ref(store.posLevelData); //รายการระดับตำแหน่ง | ระดับชั้นงาน +const posLineOptions = ref(store.posLineData); //รายการสายงาน +const posPathSideOptions = ref(store.posPathSideData); //รายการด้าน/สาขา +const posExecutiveOptions = ref(store.posExecutiveData); //รายการตำแหน่งทางการบริหาร /** function fetch รายการ ตำแหน่งเงินเดือน*/ async function fetchListSalary() { @@ -356,299 +369,70 @@ async function fetchListSalary() { }); } -/** function fetch รายการ ตำแหน่งเงินเดือน*/ -function fetchType() { - http +/** function fetch ข้อมูลประเภทคำสั่ง*/ +async function fetchDataCommandCode() { + if (store.commandCodeData.length > 0) return false; + await http + .get(config.API.orgCommandCode) + .then((res) => { + const data = res.data.result; + const DataCommandCode = data.filter((e: DataCommandCode) => + store.salaryCode.includes(e.code) + ); + + const options = DataCommandCode.map((e: DataCommandCode) => ({ + id: e.code.toString(), + name: e.name, + })); + + store.commandCodeData = options; + commandCodeOptions.value = options; + }) + .catch((err) => { + messageError($q, err); + }); +} + +/** function fetch ข้อมูลปรเภทตำแหน่งข้าราชการ */ +async function fetchType() { + await http .get(config.API.orgPosType) .then((res) => { dataLevel.value = res.data.result; - posTypeOptionsMain.value = res.data.result.map((e: any) => ({ + store.posTypeData = res.data.result.map((e: DataPosType) => ({ id: e.id, name: e.posTypeName, })); - posTypeOptions.value = posTypeOptionsMain.value; + posTypeOptions.value = store.posTypeData; }) .catch((err) => { messageError($q, err); }); } -/** - * function เลือกประเภทตำแหน่ง - * @param val - * @param status - */ -async function updateSelectType(val: string, status: boolean = false) { - const listLevel = await dataLevel.value.find( - (e: any) => e.posTypeName === val - ); - - if (listLevel) { - posLevelOptionMain.value = listLevel.posLevels.map((e: any) => ({ - id: e.id, - name: - empType.value === "" - ? e.posLevelName - : `${listLevel.posTypeShortName} ${e.posLevelName}`, - })); - - formDataSalary.positionLevel = !status ? "" : formDataSalary.positionLevel; - } -} - -/** - * function เปิด dialog ตำแหน่งเงินเดือน - * @param statusEdit แก้ไข,เพิ่ม - * @param data - */ -function onClickOpenDialog(statusEdit: boolean = false, data: any = []) { - if (empType.value === "") { - dataLevel.value.length === 0 && fetchType(); - fetchDataOption(); - fetchDataOptionExecutive(); - } else { - fetchOptionGroup(); - } - - // หาระดับตำแหน่ง - setTimeout(async () => { - statusEdit && (await updateSelectType(data.positionType, true)); - isStatusEdit.value = statusEdit; - }, 500); - - posLevelOptionMain.value = !statusEdit ? [] : posLevelOptionMain.value; - modalDialogSalary.value = true; - salaryId.value = data.id; - formDataSalary.date = statusEdit ? data.date : null; - formDataSalary.posNo = statusEdit ? data.posNo : ""; - formDataSalary.templatePos = ""; - formDataSalary.position = statusEdit ? data.position : ""; - formDataSalary.positionLine = statusEdit ? data.positionLine : ""; - formDataSalary.positionType = statusEdit ? data.positionType : ""; - formDataSalary.positionLevel = statusEdit ? data.positionLevel : ""; - formDataSalary.positionPathSide = statusEdit ? data.positionPathSide : ""; - formDataSalary.positionExecutive = statusEdit ? data.positionExecutive : ""; - formDataSalary.salaryCompensation = statusEdit ? data.mouthSalaryAmount : ""; - formDataSalary.salary = statusEdit - ? data.amount - ? data.amount.toLocaleString() - : "" - : ""; - formDataSalary.salaryPos = statusEdit - ? data.positionSalaryAmount - ? data.positionSalaryAmount.toLocaleString() - : "" - : ""; - formDataSalary.refCommandNo = statusEdit ? data.refCommandNo : ""; - formDataSalary.templateDoc = ""; - formDataSalary.doc = statusEdit ? data.templateDoc : ""; - - formDataSalary.amountSpecial = statusEdit - ? data.amountSpecial === 0 - ? "" - : data.amountSpecial - : ""; -} - -/** function ปิด dialog ตำแหน่งเงินเดือน*/ -function onClickCloseDialog() { - modalDialogSalary.value = false; -} - -/** - * ฟิลเตอร์ข้อมูลจาก input - * @param val ค่าที่ป้อนให้ input - * @param update function จาก quasar - * @param filtername type ที่กำหนด ของ input นั้นๆ - */ -function filterSelector(val: string, update: Function, filtername: string) { - switch (filtername) { - case "pos": - update(() => { - posNoOptions.value = store.optionTemplatePos.filter( - (v: DataOption2) => v.name.indexOf(val) > -1 - ); - }); - break; - case "positionLine": - update(() => { - positionFielOptiond.value = positionFielOptiondMain.value.filter( - (v: DataOption) => v.name.indexOf(val) > -1 - ); - }); - break; - case "posType": - update(() => { - posTypeOptions.value = posTypeOptionsMain.value.filter( - (v: DataOption) => v.name.indexOf(val) > -1 - ); - }); - break; - case "posLevel": - update(() => { - posLevelOption.value = posLevelOptionMain.value.filter( - (v: DataOption) => v.name.indexOf(val) > -1 - ); - }); - break; - case "doc": - update(() => { - docOption.value = store.optionTemplateDoc.filter( - (v: DataOption2) => v.name.indexOf(val) > -1 - ); - }); - break; - case "positionPathSide": - update(() => { - positionAreaOptiond.value = positionAreaOptiondMain.value.filter( - (v: DataOption) => v.name.indexOf(val) > -1 - ); - }); - break; - - case "positionExecutive": - update(() => { - posExecutiveOption.value = posExecutiveOptionMain.value.filter( - (v: DataOption) => v.name.indexOf(val) > -1 - ); - }); - break; - - default: - break; - } -} - -/** - * function เลือกต้นแบบ tamplate ตำแหน่ง - * @param val - */ -function updatePos(val: string) { - formDataSalary.position = val; -} - -/** - * function เลือกต้นแบบ tamplate เอกสาร - * @param val - */ -function updateDoc(val: string) { - formDataSalary.doc = val; -} - -/** function ยืนยันการบันทึกข้อมูล */ -function onSubmit() { - dialogConfirm($q, async () => { - showLoader(); - const formData = { - profileEmployeeId: - !isStatusEdit.value && empType.value !== "" - ? profileId.value - : undefined, - profileId: - !isStatusEdit.value && empType.value === "" - ? profileId.value - : undefined, - date: formDataSalary.date, // วันที่ - posNo: formDataSalary.posNo, //ตำแหน่งเลขที่ - position: formDataSalary.position, //ตำแหน่ง - positionLine: - empType.value === "" ? formDataSalary.positionLine : undefined, //สายงาน - positionPathSide: - empType.value === "" ? formDataSalary.positionPathSide : undefined, // ด้าน/สาขา - positionExecutive: - empType.value === "" ? formDataSalary.positionExecutive : undefined, //ตำแหน่งทางการบริหาร - positionType: formDataSalary.positionType, // ประเภทตำแหน่ง - positionLevel: formDataSalary.positionLevel, // ระดับตำแหน่ง - amount: - typeof formDataSalary.salary === "number" - ? formDataSalary.salary - : Number(formDataSalary?.salary?.replace(/,/g, "")), //เงินเดือนฐาน - positionSalaryAmount: - typeof formDataSalary.salaryPos === "number" - ? formDataSalary.salaryPos - : Number(formDataSalary?.salaryPos?.replace(/,/g, "")), // เงินประจำตำแหน่ง - mouthSalaryAmount: - typeof formDataSalary.salaryCompensation === "number" - ? formDataSalary.salaryCompensation - : Number(formDataSalary?.salaryCompensation?.replace(/,/g, "")), //เงินค่าตอบแทนรายเดือน - amountSpecial: - typeof formDataSalary.amountSpecial === "number" - ? formDataSalary.amountSpecial - : Number(formDataSalary?.amountSpecial?.replace(/,/g, "")), //เงินค่าตอบแทนพิเศษ - refCommandNo: formDataSalary.refCommandNo, // เลขที่คำสั่ง - templateDoc: formDataSalary.doc, // เอกสารอ้างอิง - }; - - try { - const url = isStatusEdit.value - ? config.API.profileListSalaryNew(salaryId.value, empType.value) - : config.API.profileSalaryNew(empType.value); - const method = isStatusEdit.value ? "patch" : "post"; - await http[method](url, formData); - await onClickCloseDialog(); - await fetchListSalary(); - success($q, "บันทึกข้อมูลสำเร็จ"); - } catch (e) { - messageError($q, e); - hideLoader(); - } finally { - } - }); -} - -/** - * function เลื่อนรายการเงินเดือนขึ้น - * @param id รายการเงินเดือน - */ -function onSwapUp(id: string) { - showLoader(); - http - .get(config.API.profileSalarySwapNew("up", id, empType.value)) - .then(async () => { - await fetchListSalary(); +/** function fetch ข้อมูลปรเภทตำแหน่งลูกจ้าง*/ +async function fetchOptionGroup() { + await http + .get(config.API.orgEmployeeType) + .then((res) => { + dataLevel.value = res.data.result; + store.posTypeData = res.data.result.map((e: DataPosType) => ({ + id: e.id, + name: e.posTypeName, + })); + posTypeOptions.value = store.posTypeData; }) .catch((err) => { messageError($q, err); - }) - .finally(() => { - hideLoader(); }); } -/** - * function เลื่อนรายการเงินเดือนลง - * @param id รายการเงินเดือน - */ -function onSwapDown(id: string) { - showLoader(); - http - .get(config.API.profileSalarySwapNew("down", id, empType.value)) - .then(async () => { - await fetchListSalary(); - }) - .catch((err) => { - messageError($q, err); - }) - .finally(() => { - hideLoader(); - }); -} - -const modalHistory = ref(false); - -/** - * function ดูข้อมูลประวัติการแก้ไขรายการเงินเดือน - * @param id รายการเงินเดือน - */ -function onClikcHistory(id: string) { - salaryId.value = id; - modalHistory.value = true; -} - /** function fetch ข้อมูลสายงาน*/ -function fetchDataOption() { - showLoader(); - http +async function fetchDataOption() { + if (store.posLineData.length > 0 && store.posPathSideData.length > 0) + return false; + + await http .get(config.API.orgPosPosition + `?keyword=&type=ALL`) .then((res) => { const data = res.data.result; @@ -656,7 +440,7 @@ function fetchDataOption() { const seen = new Set(); const seen2 = new Set(); - const listPositionField = data.filter((item: any) => { + const listPositionField = data.filter((item: DataPosPosition) => { if (seen.has(item.positionField)) { return false; } else { @@ -664,12 +448,12 @@ function fetchDataOption() { return true; } }); - positionFielOptiondMain.value = listPositionField.map((e: any) => ({ + store.posLineData = listPositionField.map((e: DataPosPosition) => ({ id: e.positionField, name: e.positionField, })); - const listPositionArea = data.filter((item: any) => { + const listPositionArea = data.filter((item: DataPosPosition) => { if ( item.positionArea === null || item.positionArea === "" || @@ -682,58 +466,231 @@ function fetchDataOption() { return true; } }); - positionAreaOptiondMain.value = listPositionArea.map((e: any) => ({ + store.posPathSideData = listPositionArea.map((e: DataPosPosition) => ({ id: e.positionArea, name: e.positionArea, })); }) .catch((err) => { messageError($q, err); - }) - .finally(() => { - hideLoader(); }); } /** function fetch ข้อมูลตำแหน่งข้อมูลทางการบริหาร*/ -function fetchDataOptionExecutive() { - showLoader(); - http +async function fetchDataOptionExecutive() { + await http .get(config.API.orgPosExecutive) .then((res) => { const data = res.data.result; - posExecutiveOptionMain.value = data.map((e: any) => ({ + store.posExecutiveData = data.map((e: DataPosExecutive) => ({ id: e.posExecutiveName, name: e.posExecutiveName, })); }) .catch((e) => { messageError($q, e); - }) - .finally(() => { - hideLoader(); }); } -/** function fetch ข้อมูลปรเภทตำแหน่ง*/ -function fetchOptionGroup() { +/** + * function เลือกประเภทตำแหน่ง + * @param val id ประเภทตำแหน่ง + * @param status แก่ไข , เพิ่ม + */ +async function updateSelectType(val: string, status: boolean = false) { + const listLevel = dataLevel.value.find( + (e: DataPosType) => e.posTypeName === val + ); + + if (listLevel) { + store.posLevelData = listLevel.posLevels.map((e: DataPosLevel) => ({ + id: e.id, + name: + empType.value === "" + ? e.posLevelName + : `${listLevel.posTypeShortName} ${e.posLevelName}`, + })); + + formData.positionLevel = !status ? "" : formData.positionLevel; + } +} + +/** + * function เปิด dialog ตำแหน่งเงินเดือน + * @param statusEdit แก้ไข,เพิ่ม + * @param data + */ +async function onClickOpenDialog( + statusEdit: boolean = false, + data: DataPositions = {} as DataPositions +) { showLoader(); - http - .get(config.API.orgEmployeeType) - .then((res) => { - dataLevel.value = res.data.result; - posTypeOptionsMain.value = res.data.result.map((e: any) => ({ - id: e.id, - name: e.posTypeName, - })); - posTypeOptions.value = posTypeOptionsMain.value; - }) - .catch((err) => { - messageError($q, err); - }) - .finally(() => { + if (empType.value === "") { + await Promise.all([ + fetchType(), + fetchDataOption(), + fetchDataOptionExecutive(), + ]); + } else { + await fetchOptionGroup(); + } + commandCodeOptions.value = store.commandCodeData; + posTypeOptions.value = store.posTypeData; + posLevelOptions.value = store.posLevelData; + posLineOptions.value = store.posLineData; + posPathSideOptions.value = store.posPathSideData; + posExecutiveOptions.value = store.posExecutiveData; + + // หาระดับตำแหน่ง + statusEdit && (await updateSelectType(data.positionType, true)); + isStatusEdit.value = statusEdit; + + store.posLevelData = !statusEdit ? [] : store.posLevelData; + modalDialogSalary.value = true; + salaryId.value = data.id; + formData.commandCode = statusEdit ? data.commandCode : ""; + formData.commandNo = statusEdit ? data.commandNo : ""; + formData.commandYear = statusEdit ? data.commandYear : null; + formData.commandDateAffect = statusEdit ? data.commandDateAffect : null; + formData.commandDateSign = statusEdit ? data.commandDateSign : null; + formData.posNoAbb = statusEdit ? data.posNoAbb : ""; + formData.posNo = statusEdit ? data.posNo : ""; + formData.positionName = statusEdit ? data.positionName : ""; + formData.positionType = statusEdit ? data.positionType : ""; + formData.positionLevel = statusEdit ? data.positionLevel : ""; + formData.positionLine = statusEdit ? data.positionLine : ""; + formData.positionPathSide = statusEdit ? data.positionPathSide : ""; + formData.positionExecutive = statusEdit ? data.positionExecutive : ""; + 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.orgRoot = statusEdit ? data.orgRoot : ""; + formData.orgChild1 = statusEdit ? data.orgChild1 : ""; + formData.orgChild2 = statusEdit ? data.orgChild2 : ""; + formData.orgChild3 = statusEdit ? data.orgChild3 : ""; + formData.orgChild4 = statusEdit ? data.orgChild4 : ""; + formData.remark = statusEdit ? data.remark : ""; + hideLoader(); +} + +/** function ปิด dialog ตำแหน่งเงินเดือน*/ +function onClickCloseDialog() { + modalDialogSalary.value = false; +} + +/** function ยืนยันการบันทึกข้อมูล */ +function onSubmit() { + dialogConfirm($q, async () => { + showLoader(); + try { + const url = isStatusEdit.value + ? config.API.profileListSalaryNew(salaryId.value, empType.value) + : config.API.profileSalaryNew(empType.value); + const method = isStatusEdit.value ? "patch" : "post"; + await http[method](url, { + profileEmployeeId: + !isStatusEdit.value && empType.value !== "" + ? profileId.value + : undefined, + profileId: + !isStatusEdit.value && empType.value === "" + ? profileId.value + : undefined, + ...formData, + commandDateAffect: convertDateToAPI(formData.commandDateAffect), + commandDateSign: convertDateToAPI(formData.commandDateSign), + amount: Number(String(formData.amount)?.replace(/,/g, "")), + amountSpecial: Number( + String(formData.amountSpecial)?.replace(/,/g, "") + ), + positionSalaryAmount: Number( + String(formData.positionSalaryAmount)?.replace(/,/g, "") + ), + mouthSalaryAmount: Number( + String(formData.mouthSalaryAmount)?.replace(/,/g, "") + ), + }); + await fetchListSalary(); + onClickCloseDialog(); + success($q, "บันทึกข้อมูลสำเร็จ"); + } catch (e) { + messageError($q, e); + } finally { hideLoader(); - }); + } + }); +} + +const modalHistory = ref(false); + +/** + * ฟิลเตอร์ข้อมูลจาก input + * @param val ค่าที่ป้อนให้ input + * @param update function จาก quasar + * @param filtername type ที่กำหนด ของ input นั้นๆ + */ +function filterSelector(val: string, update: Function, filtername: string) { + switch (filtername) { + case "commandCode": + update(() => { + commandCodeOptions.value = store.commandCodeData.filter( + (v: DataOption) => v.name.indexOf(val) > -1 + ); + }); + break; + + case "posType": + update(() => { + posTypeOptions.value = store.posTypeData.filter( + (v: DataOption) => v.name.indexOf(val) > -1 + ); + }); + break; + + case "posLevel": + update(() => { + posLevelOptions.value = store.posLevelData.filter( + (v: DataOption) => v.name.indexOf(val) > -1 + ); + }); + break; + + case "posLine": + update(() => { + posLineOptions.value = store.posLineData.filter( + (v: DataOption) => v.name.indexOf(val) > -1 + ); + }); + break; + + case "posPathSide": + update(() => { + posPathSideOptions.value = store.posPathSideData.filter( + (v: DataOption) => v.name.indexOf(val) > -1 + ); + }); + break; + + case "posExecutive": + update(() => { + posExecutiveOptions.value = store.posExecutiveData.filter( + (v: DataOption) => v.name.indexOf(val) > -1 + ); + }); + break; + + default: + break; + } +} +/** + * function ดูข้อมูลประวัติการแก้ไขรายการเงินเดือน + * @param id รายการเงินเดือน + */ +function onClikcHistory(id: string) { + salaryId.value = id; + modalHistory.value = true; } const classInput = (val: boolean) => { @@ -747,7 +704,6 @@ function onRefCommand(data: ResListSalary) { modalCommand.value = true; command.value = data.refCommandNo; commandId.value = data.commandId; - // commandId.value = 'bdf9da91-ba45-497a-a2b7-cc49e2446d97'; //จำลอง } function serchDataTable() { @@ -759,8 +715,13 @@ function serchDataTable() { } /** ทำงานเมื่อ Components ถูกเรียกใช้งาน*/ -onMounted(() => { - fetchListSalary(); +onMounted(async () => { + showLoader(); + try { + await Promise.all([fetchListSalary(), fetchDataCommandCode()]); + } finally { + hideLoader(); + } }); + +
- +
-
+
+ + + +
+ +
+
+
+ +
+ +
+ + + + + +
+
+
+ +
{ outlined dense borderless - :model-value="date2Thai(formDataSalary.date)" + :model-value="date2Thai(formData.commandDateAffect)" :rules="[ (val: string) => !!val || - `${'กรุณาเลือก วัน/เดือน/ปี'}`, + `${'กรุณาเลือกวันที่คำสั่งมีผล'}`, ]" - :label="`${'วัน/เดือน/ปี'}`" + :label="`${'วันที่คำสั่งมีผล'}`" hide-bottom-space >
-
{ dense lazy-rules borderless - v-model="formDataSalary.positionLine" + v-model="formData.positionLine" :label="`${'สายงาน'}`" emit-value map-options option-label="name" - :options="positionFielOptiond" + :options="posLineOptions" option-value="id" hide-bottom-space use-input @@ -1128,7 +1168,7 @@ onMounted(() => { clearable input-debounce="0" @filter="(inputValue: string, - doneFn: Function) => filterSelector(inputValue, doneFn, 'positionLine' + doneFn: Function) => filterSelector(inputValue, doneFn, 'posLine' )" >