diff --git a/src/api/registry/api.registry.ts b/src/api/registry/api.registry.ts index d353d710a..525f343b5 100644 --- a/src/api/registry/api.registry.ts +++ b/src/api/registry/api.registry.ts @@ -176,4 +176,6 @@ export default { //ข้อมูลครอบครับ profileFamily: (empType: string, type: string) => `${registryNew}${empType}/family/${type}`, + profileFamilyHistory: (id: string, empType: string, type: string) => + `${registryNew}${empType}/family/${type}/history/${id}`, }; diff --git a/src/modules/04_registryNew/components/detail/GovernmentInformation/01_Info.vue b/src/modules/04_registryNew/components/detail/GovernmentInformation/01_Info.vue index 78dedc239..e9cdc17a9 100644 --- a/src/modules/04_registryNew/components/detail/GovernmentInformation/01_Info.vue +++ b/src/modules/04_registryNew/components/detail/GovernmentInformation/01_Info.vue @@ -2,7 +2,6 @@ import { ref, reactive, watch, onMounted } from "vue"; import { useCounterMixin } from "@/stores/mixin"; import type { - MyObjectRef, RequestItemsHistoryObject, FormMain, } from "@/modules/04_registryNew/interface/index/government"; @@ -25,6 +24,7 @@ const { messageError, showLoader, hideLoader, + success, } = mixin; const profileId = ref(route.params.id.toString()); @@ -70,24 +70,6 @@ const containDateRef = ref(null); const workDateRef = ref(null); const reasonSameDateRef = ref(null); -const objectRef: MyObjectRef = { - containDate: containDateRef, - workDate: workDateRef, - reasonSameDate: reasonSameDateRef, -}; - -const fieldLabels = { - ocId: "สังกัด", - positionId: "ตำแหน่ง", - numberId: "เลขที่ตำแหน่ง", - positionExecutive: "ตำแหน่งทางการบริหาร", - positionExecutiveSide: "ด้านทางการบริหาร", - positionLine: "สายงาน", - positionLevel: "ระดับ", - positionType: "ประเภท", - positionPathSide: "ด้าน/สาขา", -}; - const visibleColumnsHistory = ref([ "oc", "position", @@ -317,7 +299,6 @@ const columnsHistory = ref([ /** เปิด dialog */ function openDialogEdit() { modalEdit.value = true; - containDate.value = formMain.containDate ? formMain.containDate : null; workDate.value = formMain.workDate ? formMain.workDate : null; reasonSameDate.value = formMain.reasonSameDate @@ -338,23 +319,6 @@ function closeDialog() { reasonSameDate.value = null; } -/** validate check*/ -function validateForm() { - 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)) { - onSubmit(); - } -} - function onSubmit() { dialogConfirm($q, () => { showLoader(); @@ -371,9 +335,10 @@ function onSubmit() { : reasonSameDate.value, } ) - .then((res) => { - closeDialog(); + .then(() => { getData(); + success($q, "บันทึกข้อมูลสำเร็จ"); + closeDialog(); }) .catch((e) => { messageError($q, e); @@ -381,8 +346,6 @@ function onSubmit() { .finally(() => { hideLoader(); }); - - closeDialog(); }); } @@ -393,15 +356,15 @@ function getData() { .get(config.API.profileNewGovernmentById(profileId.value, empType.value)) .then((res) => { const data = res.data.result; - formMain.ocId = data.org; //สังกัด - formMain.positionId = data.position; //ตำแหน่ง - formMain.positionLine = data.positionField; //สายงาน - formMain.positionLevel = data.posLevel; //ระดับ - formMain.numberId = data.posMasterNo; //เลขที่ตำแหน่ง - formMain.positionType = data.posType; //ประเภท - formMain.positionExecutive = data.posExecutive; //ตำแหน่งทางการ บริหาร - formMain.positionPathSide = data.positionArea; //ด้านสาขา - formMain.positionExecutiveSide = data.positionExecutiveField; //ด้านทางการบริหาร + formMain.ocId = data.org ?? "-"; //สังกัด + formMain.positionId = data.position ?? "-"; //ตำแหน่ง + formMain.positionLine = data.positionField ?? "-"; //สายงาน + formMain.positionLevel = data.posLevel ?? "-"; //ระดับ + formMain.numberId = data.posMasterNo ?? "-"; //เลขที่ตำแหน่ง + formMain.positionType = data.posType ?? "-"; //ประเภท + formMain.positionExecutive = data.posExecutive ?? "-"; //ตำแหน่งทางการ บริหาร + formMain.positionPathSide = data.positionArea ?? "-"; //ด้านสาขา + formMain.positionExecutiveSide = data.positionExecutiveField ?? "-"; //ด้านทางการบริหาร formMain.containDate = data.dateAppoint; formMain.workDate = data.dateStart; @@ -463,16 +426,6 @@ function getDataHistory() { }); } -// watch( -// () => modalHistory.value, -// (isOpen) => { -// if (isOpen === true) { -// filterKeyword.value = ""; -// getDataHistory(); -// } -// } -// ); - onMounted(() => { getData(); }); @@ -505,34 +458,72 @@ onMounted(() => {
-
-
- {{ - fieldLabels[field as keyof typeof fieldLabels] - }} +
+
+
สังกัด
+
+
{{ formMain.ocId }}
+
+
+
+
ตำแหน่ง
+
+
{{ formMain.positionId }}
+
+
+
+
เลขที่ตำแหน่ง
+
+
{{ formMain.numberId }}
+
+
+
+
ตำแหน่งทางการบริหาร
- {{ formMain[field] ? formMain[field] : "-" }} + {{ formMain.positionExecutive }} +
+
+
+
+
ด้านทางการบริหาร
+
+
+ {{ formMain.positionExecutiveSide }}
-
-
- {{ - fieldLabels[field as keyof typeof fieldLabels] - }} +
+
+
สายงาน
- {{ formMain[field] ? formMain[field] : "-" }} + {{ formMain.positionLine }} +
+
+
+
+
{{ empType === "" ? "ประเภทตำแหน่ง" : "กลุ่มงาน" }}
+
+
+ {{ formMain.positionType }} +
+
+
+
+
{{ empType === "" ? "ระดับตำแหน่ง" : "ระดับชั้นงาน" }}
+
+
+ {{ formMain.positionLevel }} +
+
+
+
+
ด้าน/สาขา
+
+
+ {{ formMain.positionPathSide }}
@@ -665,7 +656,7 @@ onMounted(() => { -
+ @@ -785,7 +776,7 @@ onMounted(() => { บันทึกข้อมูล - +
diff --git a/src/modules/04_registryNew/components/detail/PersonalInformation/04_FamilyNew.vue b/src/modules/04_registryNew/components/detail/PersonalInformation/04_FamilyNew.vue index 53c2b06d2..6d8d6c5b1 100644 --- a/src/modules/04_registryNew/components/detail/PersonalInformation/04_FamilyNew.vue +++ b/src/modules/04_registryNew/components/detail/PersonalInformation/04_FamilyNew.vue @@ -37,6 +37,7 @@ const visibleColumns = ref([ "lastName", "job", "isLive", + "lastNameOld", ]); const columns = ref([ { @@ -76,6 +77,15 @@ const columns = ref([ headerStyle: "font-size: 14px", style: "font-size: 14px", }, + { + name: "lastNameOld", + align: "left", + label: "นามสกุลเดิม", + sortable: true, + field: "lastNameOld", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, { name: "job", align: "left", @@ -93,37 +103,37 @@ const columns = ref([ field: "isLive", headerStyle: "font-size: 14px", style: "font-size: 14px", - format: (val) => convertisLive(val), + format: (val) => (val ? "มีชีวิต" : "ถึงแก่กรรม"), }, ]); const rows = ref([]); /** ข้อมูล*/ -const fatherData = ref({ - isLive: 1, - citizenId: "1231231231231", - prefix: "นาย", - firstName: "ตรีชาไทย", - lastName: "หวังดี", - job: "จอมพล", +const fatherData = reactive({ + isLive: null, + citizenId: "", + prefix: "", + firstName: "", + lastName: "", + job: "", }); -const motherData = ref({ - isLive: 0, - citizenId: "1572476458930", - prefix: "นาง", - firstName: "บุษดี", - lastName: "มาดี", - job: "พยาบาล", +const motherData = reactive({ + isLive: null, + citizenId: "", + prefix: "", + firstName: "", + lastName: "", + job: "", }); -const coupleData = ref({ - isLive: 1, - citizenId: "1231231231231", - prefix: "นาย", - firstName: "ตรีชาไทย", - lastName: "หวังดี", - job: "จอมพล", - lastNameOld: "หวังดี", - statusMarital: "แต่งงานแล้ว", +const coupleData = reactive({ + isLive: null, + citizenId: "", + prefix: "", + firstName: "", + lastName: "", + job: "", + lastNameOld: "", + statusMarital: "", }); const childData = ref([{}]); @@ -134,6 +144,7 @@ const filterHistory = ref(""); const titleForm = ref(""); const typeForm = ref(""); const isEdit = ref(false); +const childernId = ref(""); const optionRelationshipMain = ref([]); const optionRelationship = ref([]); @@ -152,9 +163,20 @@ const fromData = reactive({ function fetchDataFather() { showLoader(); http - .get(config.API.profileFamily(empType.value, "father")) + .get( + config.API.profileFamily(empType.value, "father") + `/${profileId.value}` + ) .then((res) => { - console.log(res); + const data = res.data.result; + + if (data) { + fatherData.isLive = data.fatherLive; + fatherData.citizenId = data.fatherCitizenId; + fatherData.prefix = data.fatherPrefix; + fatherData.firstName = data.fatherFirstName; + fatherData.lastName = data.fatherLastName; + fatherData.job = data.fatherCareer; + } }) .catch((err) => { messageError($q, err); @@ -166,9 +188,19 @@ function fetchDataFather() { function fetchDataMother() { showLoader(); http - .get(config.API.profileFamily(empType.value, "mother ")) + .get( + config.API.profileFamily(empType.value, "mother") + `/${profileId.value}` + ) .then((res) => { - console.log(res); + const data = res.data.result; + if (data) { + motherData.isLive = data.motherLive; + motherData.citizenId = data.motherCitizenId; + motherData.prefix = data.motherPrefix; + motherData.firstName = data.motherFirstName; + motherData.lastName = data.motherLastName; + motherData.job = data.motherCareer; + } }) .catch((err) => { messageError($q, err); @@ -180,9 +212,21 @@ function fetchDataMother() { function fetchDataCouple() { showLoader(); http - .get(config.API.profileFamily(empType.value, "couple")) + .get( + config.API.profileFamily(empType.value, "couple") + `/${profileId.value}` + ) .then((res) => { - console.log(res); + const data = res.data.result; + if (data) { + coupleData.isLive = data.coupleLive; + coupleData.citizenId = data.coupleCitizenId; + coupleData.prefix = data.couplePrefix; + coupleData.firstName = data.coupleFirstName; + coupleData.lastName = data.coupleLastName; + coupleData.job = data.coupleCareer; + coupleData.lastNameOld = data.coupleLastNameOld; + coupleData.statusMarital = data.relationship; + } }) .catch((err) => { messageError($q, err); @@ -194,9 +238,13 @@ function fetchDataCouple() { function fetchDataChildren() { showLoader(); http - .get(config.API.profileFamily(empType.value, "children")) + .get( + config.API.profileFamily(empType.value, "children") + + `/${profileId.value}` + ) .then((res) => { - console.log(res); + const data = res.data.result; + childData.value = data; }) .catch((err) => { messageError($q, err); @@ -207,14 +255,45 @@ function fetchDataChildren() { } function onSubmit(type: string) { - dialogConfirm($q, () => { - if (type === "father") { - } else if (type === "mother") { - } else if (type === "couple") { - } else if (type === "child") { - submitChildren(); + dialogConfirm($q, async () => { + showLoader(); + + const formBody = { + profileId: + !isEdit.value && empType.value === "" ? profileId.value : undefined, + profileEmployeeId: + !isEdit.value && empType.value !== "" ? profileId.value : undefined, + [`${type}CitizenId`]: fromData.citizenId, + [`${type}Prefix`]: fromData.prefix, + [`${type}FirstName`]: fromData.firstName, + [`${type}LastName`]: fromData.lastName, + [`${type}Career`]: fromData.job, + [`${type}Live`]: fromData.isLive === 1 ? true : false, + relationship: type === "couple" ? fromData.statusMarital : undefined, + coupleLastNameOld: type === "couple" ? fromData.lastNameOld : undefined, + }; + + const url = + isEdit.value && type === "children" + ? config.API.profileFamily(empType.value, type) + `/${childernId.value}` + : config.API.profileFamily(empType.value, type); + const method = isEdit.value && type === "children" ? "patch" : "post"; + try { + await http[method](url, formBody); + success($q, "บันทึกข้อมูลสำเร็จ"); + type === "father" + ? fetchDataFather() + : type === "mother" + ? fetchDataMother() + : type === "couple" + ? fetchDataCouple() + : fetchDataChildren(); + closeDialog(); + } catch (e) { + messageError($q, e); + } finally { + hideLoader(); } - closeDialog(); }); } @@ -239,43 +318,47 @@ function onOpenDialogForm( modal.value = true; typeForm.value = type; isEdit.value = isStatusEdit; + console.log(data); if (type === "father") { titleForm.value = "บิดา"; - if (isStatusEdit) { - fromData.isLive = fatherData.value.isLive; - fromData.citizenId = fatherData.value.citizenId; - fromData.prefix = fatherData.value.prefix; - fromData.firstName = fatherData.value.firstName; - fromData.lastName = fatherData.value.lastName; - fromData.job = fatherData.value.job; - } + + fromData.isLive = fatherData.isLive ? 1 : 0; + fromData.citizenId = fatherData.citizenId; + fromData.prefix = fatherData.prefix; + fromData.firstName = fatherData.firstName; + fromData.lastName = fatherData.lastName; + fromData.job = fatherData.job; } else if (type === "mother") { titleForm.value = "มารดา"; - if (isStatusEdit) { - fromData.isLive = motherData.value.isLive; - fromData.citizenId = motherData.value.citizenId; - fromData.prefix = motherData.value.prefix; - fromData.firstName = motherData.value.firstName; - fromData.lastName = motherData.value.lastName; - fromData.job = motherData.value.job; - } + + fromData.isLive = motherData.isLive ? 1 : 0; + fromData.citizenId = motherData.citizenId; + fromData.prefix = motherData.prefix; + fromData.firstName = motherData.firstName; + fromData.lastName = motherData.lastName; + fromData.job = motherData.job; } else if (type === "couple") { titleForm.value = "คู่สมรส"; - } else if (type === "child") { + } else if (type === "children") { titleForm.value = "บุตร"; - fromData.isLive = data.isLive; - fromData.citizenId = data.citizenId; - fromData.prefix = data.prefix; - fromData.firstName = data.firstName; - fromData.lastName = data.lastName; - fromData.job = data.job; + if (isStatusEdit) { + childernId.value = data.id; + fromData.isLive = data.childrenLive ? 1 : 0; + fromData.citizenId = data.childrenCitizenId; + fromData.prefix = data.childrenPrefix; + fromData.firstName = data.childrenFirstName; + fromData.lastName = data.childrenLastName; + fromData.job = data.childrenCareer; + } } } -function onOpenDialogHistory(type: string) { +function onOpenDialogHistory(type: string, id: string = "") { modalHistory.value = true; - console.log(type); + typeForm.value = type; + const historyId = type === "children" ? id : profileId.value; + fetchHistory(historyId, type); } function fetchDataRelationship() { @@ -305,42 +388,30 @@ const filterSelectorRelation = (val: any, update: Function) => { }); }; -function convertisLive(status: number) { - switch (status) { - case 1: - return "ถึงแก่กรรม"; - case 2: - return "มีชีวิต"; - - default: - break; - } -} - -function submitChildren() { - const body = { - profileId: empType.value === "" ? profileId.value : undefined, - profileEmployeeId: empType.value !== "" ? profileId.value : undefined, - childrenCareer: fromData.job, - childrenFirstName: fromData.firstName, - childrenLastName: fromData.lastName, - childrenPrefix: fromData.prefix, - childrenLive: fromData.isLive === 1 ? true : false, - childrenCitizenId: fromData.citizenId, - }; - +function fetchHistory(id: string, type: string) { + hideLoader(); http - .post(config.API.profileFamily(empType.value, "children"), body) - .then(() => { - success($q, "บันทึกข้อมูลสำเร็จ"); + .get(config.API.profileFamilyHistory(id, empType.value, type)) + .then((res) => { + const data = res.data.result; + rows.value = data.map((e: any) => ({ + citizenId: e[`${type}CitizenId`], + prefix: e[`${type}Prefix`], + firstName: e[`${type}FirstName`], + lastName: e[`${type}LastName`], + job: e[`${type}Career`], + isLive: e[`${type}Live`], + lastNameOld: type === "couple" ? e.coupleLastNameOld : undefined, + })); }) .catch((err) => { messageError($q, err); + }) + .finally(() => { + hideLoader(); }); } -function fetchHistory() {} - onMounted(() => { fetchDataFather(); fetchDataMother(); @@ -366,7 +437,7 @@ onMounted(() => { icon="mdi-pencil-outline" size="14px" dense - @click="onOpenDialogForm('father', true)" + @click="onOpenDialogForm('father')" > แก้ไขข้อมูล @@ -415,8 +486,13 @@ onMounted(() => { สถานภาพการมีชีวิต
-
มีชีวิตอยู่
-
ถึงแก่กรรม
+ {{ + fatherData.isLive === true + ? "มีชีวิตอยู่" + : fatherData.isLive === false + ? "ถึงแก่กรรม" + : "-" + }}
@@ -436,7 +512,7 @@ onMounted(() => { icon="mdi-pencil-outline" size="14px" dense - @click="onOpenDialogForm('mother', true)" + @click="onOpenDialogForm('mother')" > แก้ไขข้อมูล @@ -468,7 +544,10 @@ onMounted(() => {
{{ motherData.prefix - ? motherData.prefix + motherData.firstName + " " + motherData.lastName + ? motherData.prefix + + motherData.firstName + + " " + + motherData.lastName : "-" }}
@@ -482,8 +561,13 @@ onMounted(() => { สถานภาพการมีชีวิต
-
มีชีวิตอยู่
-
ถึงแก่กรรม
+ {{ + motherData.isLive === true + ? "มีชีวิตอยู่" + : motherData.isLive === false + ? "ถึงแก่กรรม" + : "-" + }}
@@ -524,7 +608,11 @@ onMounted(() => {
- +
คู่สมรส
@@ -535,7 +623,7 @@ onMounted(() => {
สถานภาพการสมรส
- {{ coupleData.statusMarital }} + {{ coupleData.statusMarital ?? "-" }}
@@ -543,7 +631,7 @@ onMounted(() => {
เลขบัตรประจำตัวประชาชน
- {{ coupleData.citizenId }} + {{ coupleData.citizenId ?? "-" }}
@@ -560,7 +648,7 @@ onMounted(() => {
อาชีพ
- {{ coupleData.job }} + {{ coupleData.job ?? "-" }}
@@ -568,8 +656,13 @@ onMounted(() => { สถานภาพการมีชีวิต
-
มีชีวิตอยู่
-
ถึงแก่กรรม
+ {{ + coupleData.isLive === true + ? "มีชีวิตอยู่" + : coupleData.isLive === false + ? "ถึงแก่กรรม" + : "-" + }}
@@ -588,7 +681,7 @@ onMounted(() => { color="primary" icon="add" size="14px" - @click="onOpenDialogForm('child')" + @click="onOpenDialogForm('children')" > เพิ่มบุตร @@ -597,7 +690,7 @@ onMounted(() => {
- +
บุตรคนที่ : {{ index + 1 }} @@ -611,7 +704,7 @@ onMounted(() => { icon="mdi-pencil-outline" size="14px" dense - @click="onOpenDialogForm('child', true, item)" + @click="onOpenDialogForm('children', true, item)" > แก้ไขข้อมูล @@ -622,7 +715,7 @@ onMounted(() => { color="info" icon="mdi-history" size="14px" - @click="onOpenDialogHistory('child')" + @click="onOpenDialogHistory('children', item.id)" > ประวัติการแก้ไขข้อมูลครอบครัว @@ -635,7 +728,7 @@ onMounted(() => {
เลขบัตรประจำตัวประชาชน
- {{ item.citizenId }} + {{ item.childrenCitizenId }}
@@ -644,14 +737,17 @@ onMounted(() => {
{{ - item.prefix - ? item.prefix + item.firstName + " " + item.lastName + item.childrenPrefix + ? item.childrenPrefix + + item.childrenFirstName + + " " + + item.childrenLastName : "-" }}
อาชีพ
- {{ item.job }} + {{ item.childrenCareer }}
@@ -659,8 +755,13 @@ onMounted(() => { สถานภาพการมีชีวิต
-
มีชีวิตอยู่
-
ถึงแก่กรรม
+ {{ + item.childrenLive === true + ? "มีชีวิตอยู่" + : item.childrenLive === false + ? "ถึงแก่กรรม" + : "-" + }}
@@ -680,13 +781,6 @@ onMounted(() => { /> -
{ - +
@@ -899,7 +1004,11 @@ onMounted(() => { :display-value="$q.lang.table.columns" emit-value map-options - :options="columns" + :options=" + typeForm === 'couple' + ? columns + : columns?.filter((e) => e.name !== 'lastNameOld') + " option-value="name" options-cover style="min-width: 150px" @@ -910,7 +1019,11 @@ onMounted(() => { flat bordered dense - :columns="columns" + :columns=" + typeForm === 'couple' + ? columns + : columns?.filter((e) => e.name !== 'lastNameOld') + " :rows="rows" :paging="true" :rows-per-page-options="[10, 25, 50, 100]" diff --git a/src/modules/04_registryNew/components/detail/PersonalInformation/05_Education.vue b/src/modules/04_registryNew/components/detail/PersonalInformation/05_Education.vue index c6ee665ff..c8ece79b7 100644 --- a/src/modules/04_registryNew/components/detail/PersonalInformation/05_Education.vue +++ b/src/modules/04_registryNew/components/detail/PersonalInformation/05_Education.vue @@ -653,6 +653,8 @@ async function addData() { } function editData(idData: string) { + console.log(educationData); + http .patch(config.API.profileNewEducationByEducationId(idData, empType.value), { ...educationData, @@ -660,6 +662,8 @@ function editData(idData: string) { startYear: undefined, endYear: undefined, isDate: isDate.value === "false" ? false : true, + durationYear: + educationData.durationYear === "" ? null : educationData.durationYear, }) .then(() => { fetchData(id.value); @@ -797,7 +801,7 @@ onMounted(async () => {
- {{ col.value === "" ? "-" : col.value }} + {{ col.value === ""|| col.value === null ? "-" : col.value }}
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 4e653cc85..67eb614d5 100644 --- a/src/modules/04_registryNew/components/detail/Salary/01_PositionSalary.vue +++ b/src/modules/04_registryNew/components/detail/Salary/01_PositionSalary.vue @@ -143,7 +143,6 @@ const formFilter = reactive({ pageSize: 10, keyword: "", }); -const maxPage = ref(1); const pagination = ref({ page: 1, @@ -176,11 +175,17 @@ const salaryId = ref(""); const dataLevel = ref([]); const posNoOptions = ref(store.optionTemplatePos); -const positionLineOptions = 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); @@ -219,18 +224,26 @@ 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: e.posLevelName, + name: e.posLevelName.toString(), })); - posLevelOption.value = posLevelOptionMain.value; + formDataSalary.positionLevel = !status ? "" : formDataSalary.positionLevel; } } async function onClickOpenDialog(statusEdit: boolean = false, data: any = []) { - dataLevel.value.length === 0 && (await fetchType()); + if (empType.value === "") { + dataLevel.value.length === 0 && fetchType(); + fetchDataOption(); + fetchDataOptionExecutive(); + } else { + fetchOptionGroup(); + } + setTimeout(async () => { statusEdit && (await updateSelectType(data.positionType, true)); isStatusEdit.value = statusEdit; @@ -270,8 +283,8 @@ function filterSelector(val: any, update: Function, filtername: string) { break; case "positionLine": update(() => { - positionLineOptions.value = store.optionTemplatePos.filter( - (v: DataOption2) => v.name.indexOf(val) > -1 + positionFielOptiond.value = positionFielOptiondMain.value.filter( + (v: DataOption) => v.name.indexOf(val) > -1 ); }); break; @@ -296,6 +309,21 @@ function filterSelector(val: any, update: Function, filtername: string) { ); }); 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; @@ -318,14 +346,19 @@ function onSubmit() { async function submit() { const formData = { - profileId: isStatusEdit.value || empType.value !== ''? undefined : profileId.value, - profileEmployeeId: empType.value !== "" ? profileId.value : undefined, + 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: formDataSalary.positionLine, //สายงาน - positionPathSide: formDataSalary.positionPathSide, // ด้าน/สาขา - positionExecutive: formDataSalary.positionExecutive, //ตำแหน่งทางการบริหาร + 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: @@ -395,6 +428,95 @@ function onClikcHistory(id: string) { modalHistory.value = true; } +async function fetchDataOption() { + showLoader(); + await http + .get(config.API.orgPosPosition + `?keyword=&type=ALL`) + .then((res) => { + const data = res.data.result; + console.log(res); + + const seen = new Set(); + const seen2 = new Set(); + + const listPositionField = data.filter((item: any) => { + if (seen.has(item.positionField)) { + return false; + } else { + seen.add(item.positionField); + return true; + } + }); + positionFielOptiondMain.value = listPositionField.map((e: any) => ({ + id: e.positionField, + name: e.positionField, + })); + + const listPositionArea = data.filter((item: any) => { + if ( + item.positionArea === null || + item.positionArea === "" || + item.positionArea === "-" || + seen2.has(item.positionArea) + ) { + return false; + } else { + seen2.add(item.positionArea); + return true; + } + }); + positionAreaOptiondMain.value = listPositionArea.map((e: any) => ({ + id: e.positionArea, + name: e.positionArea, + })); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); +} + +function fetchDataOptionExecutive() { + showLoader(); + http + .get(config.API.orgPosExecutive) + .then((res) => { + const data = res.data.result; + posExecutiveOptionMain.value = data.map((e: any) => ({ + id: e.posExecutiveName, + name: e.posExecutiveName, + })); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); +} + +async function fetchOptionGroup() { + showLoader(); + await http + .get(config.API.orgEmployeeType) + .then(async (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(() => { + hideLoader(); + }); +} + onMounted(() => { fetchListSalary(); }); @@ -535,7 +657,7 @@ onMounted(() => { - + - - -
- -
- -
-
- - -
-
{ lazy-rules borderless v-model="formDataSalary.positionType" - :label="`${'ตำแหน่งประเภท'}`" + :label="empType == '' ? 'ตำแหน่งประเภท' : 'กลุ่มงาน'" emit-value map-options option-label="name" @@ -711,7 +780,7 @@ onMounted(() => { use-input input-debounce="0" @update:model-value="updateSelectType" - :rules="[(val: string) => !!val || `${'กรุณาเลือกตำแหน่งประเภท'}`]" + :rules="empType == '' ? [(val: string) => !!val || 'กรุณาเลือกตำแหน่งประเภท' ]:[(val: string) => !!val || 'กรุณาเลือกกลุ่มงาน' ]" @filter="(inputValue: any, doneFn: Function) => filterSelector(inputValue, doneFn, 'posType' )" @@ -726,8 +795,8 @@ onMounted(() => { lazy-rules borderless v-model="formDataSalary.positionLevel" - :rules="[(val: string) => !!val || `${'กรุณาเลือกระดับตำแหน่ง'}`]" - :label="`${'ระดับตำแหน่ง'}`" + :rules="empType == '' ? [(val: string) => !!val || 'กรุณาเลือกระดับตำแหน่ง' ] : [(val: string) => !!val || 'กรุณาเลือกระดับชั้นงาน']" + :label="empType == '' ? 'ระดับตำแหน่ง' : 'ระดับชั้นงาน'" emit-value map-options option-label="name" @@ -742,6 +811,76 @@ onMounted(() => { />
+ +
+ +
+ +
+ +
+ +
+ +
+
{ hide-bottom-space />
+