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' )" >