diff --git a/src/api/registry/api.registry.ts b/src/api/registry/api.registry.ts index cb5fc4a92..9a82231f3 100644 --- a/src/api/registry/api.registry.ts +++ b/src/api/registry/api.registry.ts @@ -2,6 +2,7 @@ import env from "../index"; const registryNew = `${env.API_URI}/org/profile/`; const metadata = `${env.API_URI}/org/metadata/`; +const salaryNew = `${env.API_URI}/org/profile/salary`; export default { registryNew, @@ -116,39 +117,43 @@ export default { profileNewDisciplineHisByDisciplineId: (disciplineId: string) => `${registryNew}discipline/history/${disciplineId}`, - // ปฏิบัติราชการพิเศษ -profileNewDuty: `${registryNew}duty`, -profileNewDutyByProfileId: (profileId: string) => -`${registryNew}duty/${profileId}`, -profileNewDutyByDutyId: (dutyId: string) => -`${registryNew}duty/${dutyId}`, -profileNewDutyHisByDutyId: (dutyId: string) => -`${registryNew}duty/history/${dutyId}`, + // ปฏิบัติราชการพิเศษ + profileNewDuty: `${registryNew}duty`, + profileNewDutyByProfileId: (profileId: string) => + `${registryNew}duty/${profileId}`, + profileNewDutyByDutyId: (dutyId: string) => `${registryNew}duty/${dutyId}`, + profileNewDutyHisByDutyId: (dutyId: string) => + `${registryNew}duty/history/${dutyId}`, + //ข้อมูลราชการ + profileNewGovernment: () => `${registryNew}government`, + profileNewGovernmentById: (id: string) => `${registryNew}government/${id}`, + profileNewGovernmentHistory: (id: string) => + `${registryNew}government/history/${id}`, -//ข้อมูลราชการ -profileNewGovernment:()=>`${registryNew}government`, -profileNewGovernmentById:(id:string)=>`${registryNew}government/${id}`, -profileNewGovernmentHistory:(id:string)=>`${registryNew}government/history/${id}`, - -//การลา -profileNewLeave:()=>`${registryNew}leave`, -profileNewLeaveById:(id:string)=>`${registryNew}leave/${id}`, -profileNewLeaveHistory:(id:string)=>`${registryNew}leave/history/${id}`, -profileCheckDate:()=>`${env.API_URI}/leave/user/check`, -profileNewLeaveType:()=>`${env.API_URI}/leave/type`, + //การลา + profileNewLeave: () => `${registryNew}leave`, + profileNewLeaveById: (id: string) => `${registryNew}leave/${id}`, + profileNewLeaveHistory: (id: string) => `${registryNew}leave/history/${id}`, + profileCheckDate: () => `${env.API_URI}/leave/user/check`, + profileNewLeaveType: () => `${env.API_URI}/leave/type`, /** ตำแหน่งเงินเดือน*/ - profileSalaryNew: `${env.API_URI}/org/profileSalary`, - profileSalaryNewById: (id: string) => - `${env.API_URI}/org/profileSalary/${id}`, + profileSalaryNew: `${salaryNew}`, + profileListSalaryNew: (id: string) => `${salaryNew}/${id}`, + profileListSalaryHistoryNew: (profileId: string) => + `${salaryNew}/history/${profileId}`, - // ประวัติการเปลี่ยนชื่อ-นามสกุล -profileNewChangeName: `${registryNew}changeName`, -profileNewChangeNameByProfileId: (profileId: string) => - `${registryNew}changeName/${profileId}`, -profileNewChangeNameByChangeNameId: (changeNameId: string) => - `${registryNew}changeName/${changeNameId}`, -profileNewChangeNameHisByChangeNameId: (changeNameId: string) => - `${registryNew}changeName/history/${changeNameId}`, + // ประวัติการเปลี่ยนชื่อ-นามสกุล + profileNewChangeName: `${registryNew}changeName`, + profileNewChangeNameByProfileId: (profileId: string) => + `${registryNew}changeName/${profileId}`, + profileNewChangeNameByChangeNameId: (changeNameId: string) => + `${registryNew}changeName/${changeNameId}`, + profileNewChangeNameHisByChangeNameId: (changeNameId: string) => + `${registryNew}changeName/history/${changeNameId}`, + profileSalaryNew: `${salaryNew}`, + profileListSalaryNew: (id: string) => `${salaryNew}/${id}`, + profileListSalaryHistoryNew: (profileId: string) => + `${salaryNew}/history/${profileId}`, }; diff --git a/src/modules/04_registryNew/components/detail/Salary/01_PositionSalary.vue b/src/modules/04_registryNew/components/detail/Salary/01_PositionSalary.vue index c456aa56a..879a5b8c9 100644 --- a/src/modules/04_registryNew/components/detail/Salary/01_PositionSalary.vue +++ b/src/modules/04_registryNew/components/detail/Salary/01_PositionSalary.vue @@ -6,7 +6,10 @@ import http from "@/plugins/http"; import config from "@/app.config"; import type { QTableProps } from "quasar"; -import type { DataOption2 } from "@/modules/04_registryNew/interface/index/Main"; +import type { + DataOption2, + DataOption, +} from "@/modules/04_registryNew/interface/index/Main"; import type { ObjectSalaryRef } from "@/modules/04_registryNew/interface/index/salary"; import type { FormSalaryNew } from "@/modules/04_registryNew/interface/request/Salary"; @@ -40,8 +43,7 @@ const columns = ref([ field: "date", headerStyle: "font-size: 14px", style: "font-size: 14px", - sort: (a: string, b: string) => - a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), + format: (v) => date2Thai(v), }, { name: "amount", @@ -51,8 +53,7 @@ const columns = ref([ field: "amount", headerStyle: "font-size: 14px", style: "font-size: 14px", - sort: (a: string, b: string) => - a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), + format: (v) => Number(v).toLocaleString(), }, { name: "positionSalaryAmount", @@ -62,8 +63,7 @@ const columns = ref([ field: "positionSalaryAmount", headerStyle: "font-size: 14px", style: "font-size: 14px", - sort: (a: string, b: string) => - a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), + format: (v) => Number(v).toLocaleString(), }, { name: "mouthSalaryAmount", @@ -73,8 +73,7 @@ const columns = ref([ field: "mouthSalaryAmount", headerStyle: "font-size: 14px", style: "font-size: 14px", - sort: (a: string, b: string) => - a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), + format: (v) => Number(v).toLocaleString(), }, { @@ -85,8 +84,6 @@ const columns = ref([ field: "posNo", headerStyle: "font-size: 14px", style: "font-size: 14px", - sort: (a: string, b: string) => - a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, { @@ -97,8 +94,6 @@ const columns = ref([ field: "postionTypeName", headerStyle: "font-size: 14px", style: "font-size: 14px", - sort: (a: string, b: string) => - a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, { name: "positionLevelName", @@ -108,20 +103,16 @@ const columns = ref([ field: "positionLevelName", headerStyle: "font-size: 14px", style: "font-size: 14px", - sort: (a: string, b: string) => - a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, { - name: "salaryRef", + name: "templateDoc", align: "left", label: "เอกสารอ้างอิง", sortable: true, - field: "salaryRef", + field: "templateDoc", headerStyle: "font-size: 14px", style: "font-size: 14px", - sort: (a: string, b: string) => - a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, { name: "refCommandNo", @@ -131,8 +122,6 @@ const columns = ref([ field: "refCommandNo", headerStyle: "font-size: 14px", style: "font-size: 14px", - sort: (a: string, b: string) => - a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, ]); const visibleColumns = ref([ @@ -143,7 +132,7 @@ const visibleColumns = ref([ "posNo", "postionTypeName", "positionLevelName", - "salaryRef", + "templateDoc", "refCommandNo", ]); const formFilter = reactive({ @@ -159,39 +148,39 @@ const pagination = ref({ }); const rows = ref([ - { - date: new Date(), - amount: 20000, - positionSalaryAmount: 20000, - mouthSalaryAmount: 20000, - posNo: "1", - postionTypeName: "คำแหน่งประเภท", - positionLevelName: "ระดับ", - salaryRef: "เอกสารอ้างอิง", - refCommandNo: "เลขที่คำสั่ง", - }, - { - date: new Date(), - amount: 20000, - positionSalaryAmount: 20000, - mouthSalaryAmount: 20000, - posNo: "1", - postionTypeName: "คำแหน่งประเภท", - positionLevelName: "ระดับ", - salaryRef: "เอกสารอ้างอิง", - refCommandNo: "เลขที่คำสั่ง", - }, - { - date: new Date(), - amount: 20000, - positionSalaryAmount: 20000, - mouthSalaryAmount: 20000, - posNo: "1", - postionTypeName: "คำแหน่งประเภท", - positionLevelName: "ระดับ", - salaryRef: "เอกสารอ้างอิง", - refCommandNo: "เลขที่คำสั่ง", - }, + // { + // date: new Date(), + // amount: 20000, + // positionSalaryAmount: 20000, + // mouthSalaryAmount: 20000, + // posNo: "1", + // postionTypeName: "คำแหน่งประเภท", + // positionLevelName: "ระดับ", + // salaryRef: "เอกสารอ้างอิง", + // refCommandNo: "เลขที่คำสั่ง", + // }, + // { + // date: new Date(), + // amount: 20000, + // positionSalaryAmount: 20000, + // mouthSalaryAmount: 20000, + // posNo: "1", + // postionTypeName: "คำแหน่งประเภท", + // positionLevelName: "ระดับ", + // salaryRef: "เอกสารอ้างอิง", + // refCommandNo: "เลขที่คำสั่ง", + // }, + // { + // date: new Date(), + // amount: 20000, + // positionSalaryAmount: 20000, + // mouthSalaryAmount: 20000, + // posNo: "1", + // postionTypeName: "คำแหน่งประเภท", + // positionLevelName: "ระดับ", + // salaryRef: "เอกสารอ้างอิง", + // refCommandNo: "เลขที่คำสั่ง", + // }, ]); const formDataSalary = reactive({ @@ -199,11 +188,11 @@ const formDataSalary = reactive({ posNo: "", templatePos: "", position: "", - positionLineName: "", - typePosition: "", - levelPosition: "", - positionPathSideName: "", - positionExecutiveName: "", + positionLine: "", + positionPathSide: "", + positionType: "", + positionLevel: "", + positionExecutive: "", salaryCompensation: null, salary: null, salaryPos: null, @@ -212,42 +201,25 @@ const formDataSalary = reactive({ doc: "", }); -/** ตัวแปร ref สำหรับแสดง validate */ -const dateRef = ref(null); -const posNoRef = ref(null); -const positionRef = ref(null); -const typePositionRef = ref(null); -const levelPositionRef = ref(null); -const salaryRef = ref(null); -const docRef = ref(null); - -const ObjectRef: ObjectSalaryRef = { - date: dateRef, - posNo: posNoRef, - position: positionRef, - typePosition: typePositionRef, - levelPosition: levelPositionRef, - salary: salaryRef, - doc: docRef, -}; - const modalDialogSalary = ref(false); const isStatusEdit = ref(false); +const salaryId = ref(""); +const dataLevel = ref([]); const posNoOptions = ref(store.optionTemplatePos); const positionLineOptions = ref(store.optionTemplatePos); -const posTypeOptions = ref(store.optionTemplatePos); -const posLevelOption = ref(store.optionTemplatePos); +const posTypeOptions = ref([]); +const posTypeOptionsMain = ref([]); +const posLevelOption = ref([]); +const posLevelOptionMain = ref([]); + const docOption = ref(store.optionTemplateDoc); function fetchListSalary() { showLoader(); http - .get( - config.API.profileSalaryNewById("59134ef9-9e62-41d0-aac5-339be727f2b1") - ) + .get(config.API.profileListSalaryNew(profileId.value)) .then((res) => { - // console.log(res); rows.value = res.data.result; }) .catch((err) => { @@ -258,29 +230,58 @@ function fetchListSalary() { }); } -function onClickOpenDialog(statusEdit: boolean = false, data: any = []) { - isStatusEdit.value = statusEdit; - modalDialogSalary.value = true; +function fetchType() { + http + .get(config.API.orgPosType) + .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); + }); +} +async function updateSelectType(val: string, status: boolean = false) { + const listLevel = await dataLevel.value.find((e: any) => e.id === val); + if (listLevel) { + posLevelOptionMain.value = listLevel.posLevels.map((e: any) => ({ + id: e.id, + name: e.posLevelName, + })); + posLevelOption.value = posLevelOptionMain.value; + formDataSalary.positionLevel = !status ? "" : formDataSalary.positionLevel; + } +} + +async function onClickOpenDialog(statusEdit: boolean = false, data: any = []) { + dataLevel.value.length === 0 && (await fetchType()); + 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 = statusEdit ? data.templatePos : ""; - // formDataSalary.position = statusEdit ? data.position : ""; - // formDataSalary.positionLineName = statusEdit ? data.positionLineName : ""; - // formDataSalary.typePosition = statusEdit ? data.postionTypeName : ""; - // formDataSalary.levelPosition = statusEdit ? data.levelPosition : ""; - // formDataSalary.positionPathSideName = statusEdit - // ? data.positionPathSideName - // : ""; - // formDataSalary.positionExecutiveName = statusEdit - // ? data.positionExecutiveName - // : ""; + 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 : ""; formDataSalary.salaryPos = statusEdit ? data.positionSalaryAmount : ""; - // formDataSalary.refCommandNo = statusEdit ? data.refCommandNo : ""; - // formDataSalary.templateDoc = statusEdit ? data.templateDoc : ""; - formDataSalary.doc = statusEdit ? data.salaryRef : ""; + formDataSalary.refCommandNo = statusEdit ? data.refCommandNo : ""; + formDataSalary.templateDoc = ""; + formDataSalary.doc = statusEdit ? data.templateDoc : ""; } function onClickCloseDialog() { @@ -296,7 +297,7 @@ function filterSelector(val: any, update: Function, filtername: string) { ); }); break; - case "positionLineName": + case "positionLine": update(() => { positionLineOptions.value = store.optionTemplatePos.filter( (v: DataOption2) => v.name.indexOf(val) > -1 @@ -305,15 +306,15 @@ function filterSelector(val: any, update: Function, filtername: string) { break; case "posType": update(() => { - posTypeOptions.value = store.optionTemplatePos.filter( - (v: DataOption2) => v.name.indexOf(val) > -1 + posTypeOptions.value = posTypeOptionsMain.value.filter( + (v: DataOption) => v.name.indexOf(val) > -1 ); }); break; case "posLevel": update(() => { - posLevelOption.value = store.optionTemplatePos.filter( - (v: DataOption2) => v.name.indexOf(val) > -1 + posLevelOption.value = posLevelOptionMain.value.filter( + (v: DataOption) => v.name.indexOf(val) > -1 ); }); break; @@ -339,30 +340,46 @@ function updateDoc(val: string) { } function onSubmit() { - 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); - } - } - } - if (hasError.every((result) => result === true)) { - dialogConfirm($q, () => { - submit(); - }); - } + dialogConfirm($q, () => { + submit(); + }); } async function submit() { + console.log(formDataSalary); + const formData = { + profileId: isStatusEdit.value ? undefined : profileId.value, + date: formDataSalary.date, // วันที่ + posNo: formDataSalary.posNo, //เลขที่ตำแหน่ง + position: formDataSalary.position, //ตำแหน่ง + positionLine: formDataSalary.positionLine, //สายงาน + positionPathSide: formDataSalary.positionPathSide, // ด้าน/สาขา + positionExecutive: formDataSalary.positionExecutive, //ตำแหน่งทางการบริหาร + 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, "")), //เงินค่าตอบแทนรายเดือน + refCommandNo: formDataSalary.refCommandNo, // เลขที่คำสั่ง + templateDoc: formDataSalary.doc, // เอกสารอ้างอิง + }; + console.log(formData); + try { const url = isStatusEdit.value - ? config.API.profileSalaryNewById("12312") + ? config.API.profileListSalaryNew(salaryId.value) : config.API.profileSalaryNew; - const method = isStatusEdit.value ? "put" : "post"; - await http[method](url, formDataSalary); + const method = isStatusEdit.value ? "patch" : "post"; + await http[method](url, formData); fetchListSalary(); onClickCloseDialog(); success($q, "บันทึกข้อมูลสำเร็จ"); @@ -374,7 +391,8 @@ async function submit() { } const modalHistory = ref(false); -function ocClikcHistory() { +function onClikcHistory(id: string) { + salaryId.value = id; modalHistory.value = true; } @@ -396,7 +414,13 @@ onMounted(() => { class="q-mr-sm" > @@ -421,6 +445,7 @@ onMounted(() => { flat bordered dense + :filter="formFilter.keyword" :columns="columns" :rows="rows" :paging="true" @@ -471,20 +496,9 @@ onMounted(() => { :key="col.id" @click="onClickOpenDialog(true, props.row)" > -
- {{ col.value ? date2Thai(col.value) : "-" }} +
+ {{ col.value ? col.value : "-" }}
-
- {{ col.value ? col.value.toLocaleString() : "-" }} -
- -
- {{ col.value ? col.value.toLocaleString() : "-" }} -
-
- {{ col.value ? col.value.toLocaleString() : "-" }} -
-
{{ col.value ? col.value : "-" }}
{ round size="14px" icon="mdi-history" - @click="ocClikcHistory" + @click="onClikcHistory(props.row.id)" > ประวัติแก้ไขตำแหน่ง/เงินเดือน @@ -517,7 +531,7 @@ onMounted(() => { -
+ { dense lazy-rules borderless - v-model="formDataSalary.positionLineName" + v-model="formDataSalary.positionLine" :label="`${'สายงาน'}`" emit-value map-options @@ -633,7 +646,7 @@ onMounted(() => { use-input input-debounce="0" @filter="(inputValue: any, - doneFn: Function) => filterSelector(inputValue, doneFn, 'positionLineName' + doneFn: Function) => filterSelector(inputValue, doneFn, 'positionLine' )" />
@@ -643,7 +656,7 @@ onMounted(() => { outlined dense lazy-rules - v-model="formDataSalary.positionPathSideName" + v-model="formDataSalary.positionPathSide" hide-bottom-space :label="`${'ด้าน/สาขา'}`" /> @@ -654,7 +667,7 @@ onMounted(() => { dense lazy-rules borderless - v-model="formDataSalary.positionExecutiveName" + v-model="formDataSalary.positionExecutive" hide-bottom-space :label="`${'ตำแหน่งทางการบริหาร'}`" > @@ -663,12 +676,12 @@ onMounted(() => {
{ hide-bottom-space use-input input-debounce="0" + @update:model-value="updateSelectType" :rules="[(val: string) => !!val || `${'กรุณาเลือกตำแหน่งประเภท'}`]" @filter="(inputValue: any, doneFn: Function) => filterSelector(inputValue, doneFn, 'posType' @@ -687,19 +701,19 @@ onMounted(() => {
{ dense outlined v-model="formDataSalary.salaryPos" + :rules="[(val) => !!val || `${'กรุณากรอกเงินประจำตำแหน่ง'}`]" label="เงินประจำตำแหน่ง" mask="###,###,###,###" reverse-fill-mask @@ -812,11 +827,11 @@ onMounted(() => { บันทึกข้อมูล - + - + diff --git a/src/modules/04_registryNew/components/detail/Salary/01_PositionSalaryHistory.vue b/src/modules/04_registryNew/components/detail/Salary/01_PositionSalaryHistory.vue index 7f1c8f522..28f7b6530 100644 --- a/src/modules/04_registryNew/components/detail/Salary/01_PositionSalaryHistory.vue +++ b/src/modules/04_registryNew/components/detail/Salary/01_PositionSalaryHistory.vue @@ -1,12 +1,27 @@