diff --git a/src/components/CardProfile.vue b/src/components/CardProfile.vue new file mode 100644 index 000000000..e73dbbab3 --- /dev/null +++ b/src/components/CardProfile.vue @@ -0,0 +1,140 @@ + + + + + + + {{ profile.fullName }} + + + + + + + + + + + + + + ตำแหน่งในสายงาน + + {{ profile.position }} + + + + + + ประเภทตำแหน่ง + + {{ profile.positionLevel }} + + + + + + สังกัด + + {{ profile.organization }} + + + + + + + + + + + diff --git a/src/components/Dialogs/PopupPersonalNew.vue b/src/components/Dialogs/PopupPersonalNew.vue index d9664e4cb..df0e8794a 100644 --- a/src/components/Dialogs/PopupPersonalNew.vue +++ b/src/components/Dialogs/PopupPersonalNew.vue @@ -142,7 +142,7 @@ async function fetchProfileGov(id: string) { goverment.positionType = data.posType !== "" ? data.posType : "-"; goverment.positionLevel = data.posLevel !== "" ? data.posLevel : "-"; goverment.positionExecutive = - data.posExecutive !== "" ? data.posExecutive : "-"; + data.posExecutive !== null ? data.posExecutive : "-"; goverment.positionExecutiveSide = data.positionExecutiveField !== "" ? data.positionExecutiveField : "-"; }) @@ -172,9 +172,12 @@ watch( async () => { modal.value = props.modal ? props.modal : false; if (modal.value) { - props.id && (fetchInformation(props.id), fetchProfileGov(props.id)); - (fileName.value = `profile-${props.id}`), + if (props.id) { + fetchInformation(props.id); + fetchProfileGov(props.id); + fileName.value = `profile-${props.id}`; fetchProfile(props.id as string); + } } } ); @@ -214,11 +217,6 @@ async function fetchProfile(id: string) { style="color: red; background-color: #ffdede" /> - diff --git a/src/interface/main.ts b/src/interface/main.ts index cb2e79ee5..21a88d9d6 100644 --- a/src/interface/main.ts +++ b/src/interface/main.ts @@ -2,5 +2,13 @@ interface DataOption { id: string; label: string; } +interface FormProfile { + id: string; + avatar: string; + fullName: string; + position: string; + positionLevel: string; + organization: string; +} -export type { DataOption }; +export type { DataOption, FormProfile }; diff --git a/src/modules/05_placement/components/Repatriate/Dialogbody.vue b/src/modules/05_placement/components/Repatriate/Dialogbody.vue index 4d00e0f81..79d59db47 100644 --- a/src/modules/05_placement/components/Repatriate/Dialogbody.vue +++ b/src/modules/05_placement/components/Repatriate/Dialogbody.vue @@ -2,6 +2,8 @@ import { ref, computed, watchEffect } from "vue"; import { useQuasar } from "quasar"; import { useCounterMixin } from "@/stores/mixin"; +import { useTransferDataStore } from "@/modules/05_placement/store"; + import type { QTableProps } from "quasar"; import type { officerType } from "@/modules/05_placement/interface/response/officer"; @@ -11,20 +13,21 @@ import config from "@/app.config"; const $q = useQuasar(); const selected = ref([]); -const mixin = useCounterMixin(); -const { showLoader, success, messageError, dialogConfirm,hideLoader } = mixin; +const transferStore = useTransferDataStore(); + +const { statusText } = transferStore; +const mixin = useCounterMixin(); +const { + showLoader, + success, + messageError, + dialogConfirm, + hideLoader, + findOrgName, + findPosMasterNo, + date2Thai, +} = mixin; -const visibleColumns2 = ref([ - "no", - "fullname", - "posNo", - "position", - "positionLevel", - "organizationPositionOld", - "organization", - "createdAt", - "statusText", -]); const columns2 = ref([ { name: "no", @@ -36,22 +39,28 @@ const columns2 = ref([ style: "font-size: 14px", }, { - name: "fullname", + name: "name", align: "left", label: "ชื่อ-นามสกุล", sortable: true, - field: "fullname", + field: "naem", headerStyle: "font-size: 14px", style: "font-size: 14px", + format(val, row) { + return `${row.prefix}${row.firstName} ${row.lastName}`; + }, }, { name: "posNo", align: "left", - label: "ตำแหน่งเลขที่", + label: "เลขที่ตำแหน่ง", sortable: true, field: "posNo", headerStyle: "font-size: 14px", style: "font-size: 14px", + format(val, row) { + return findPosMasterNo(row); + }, }, { name: "position", @@ -65,11 +74,14 @@ const columns2 = ref([ { name: "positionLevel", align: "left", - label: "ระดับ", + label: "ประเภทตำแหน่ง", sortable: true, field: "positionLevel", headerStyle: "font-size: 14px", style: "font-size: 14px", + format(val, row) { + return `${row.posTypeName} (${row.posLevelName})`; + }, }, { name: "organizationPositionOld", @@ -79,6 +91,9 @@ const columns2 = ref([ field: "organizationPositionOld", headerStyle: "font-size: 14px", style: "font-size: 14px", + format(val, row) { + return findOrgName(row); + }, }, { name: "organization", @@ -97,30 +112,39 @@ const columns2 = ref([ field: "createdAt", headerStyle: "font-size: 14px", style: "font-size: 14px", - sort: (a: string, b: string) => - a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), - sortOrder: "da", + format: (val) => date2Thai(val), }, { - name: "statusText", + name: "status", align: "left", label: "สถานะ", sortable: true, - field: "statusText", + field: "status", headerStyle: "font-size: 14px", style: "font-size: 14px", + format: (val) => statusText(val), }, ]); +const visibleColumns2 = ref([ + "no", + "name", + "posNo", + "position", + "positionLevel", + "organizationPositionOld", + "organization", + "createdAt", + "status", +]); const props = defineProps({ Modal: Boolean, closeModal: Function, getData: Function, rows2: Array, - filterKeyword2:String, + filterKeyword2: String, }); - const checkSelected = computed(() => { if (selected.value.length === 0) { return true; @@ -129,8 +153,13 @@ const checkSelected = computed(() => { //popup ยืนยันส่งัว const saveOrder = () => { - dialogConfirm($q,() => Ordersave(),"ยืนยันส่งไปออกคำสั่ง","ต้องการยืนยันส่งไปออกคำสั่งใช่หรือไม่?" ) -} + dialogConfirm( + $q, + () => Ordersave(), + "ยืนยันส่งไปออกคำสั่ง", + "ต้องการยืนยันส่งไปออกคำสั่งใช่หรือไม่?" + ); +}; //ส่งไปออกคำสั่ง const Ordersave = async () => { const id = selected.value.map((item) => item.id); @@ -149,22 +178,18 @@ const Ordersave = async () => { messageError($q, e); }) .finally(async () => { - props.getData?.(); + props.getData?.(); hideLoader(); }); }; -const emit = defineEmits([ - "update:filterKeyword2", - "update:selected", - -]); +const emit = defineEmits(["update:filterKeyword2", "update:selected"]); const updateInput = (value: any) => { emit("update:filterKeyword2", value); }; //รีเซ็ตค่าในช่องค้นหา const Reset = () => { - emit("update:filterKeyword2", ""); + emit("update:filterKeyword2", ""); }; watchEffect(() => { if (props.Modal === true) { @@ -173,79 +198,111 @@ watchEffect(() => { }); - + - - + - + - + - + - + - + - - {{ props.rowIndex + 1 }} - - - {{ props.row.fullname }} - - - {{ props.row.posNo }} - - - {{ props.row.position }} - - - {{ props.row.positionLevel }} - - - - {{ props.row.organizationPositionOld }} + + + {{ props.rowIndex + 1 }} - - - - {{ props.row.organization }} + + + {{ col.value ? col.value : "-" }} - - {{ props.row.createdAt }} - - - {{ props.row.statusText }} - - + - \ No newline at end of file + diff --git a/src/modules/05_placement/components/Repatriate/RepatriateMain.vue b/src/modules/05_placement/components/Repatriate/RepatriateMain.vue index b08374d15..5a85adc91 100644 --- a/src/modules/05_placement/components/Repatriate/RepatriateMain.vue +++ b/src/modules/05_placement/components/Repatriate/RepatriateMain.vue @@ -34,24 +34,6 @@ const { findPosMasterNo, } = mixin; -const visibleColumns = ref([ - "no", - "fullname", - "posNo", - "position", - "positionLevel", - "organizationPositionOld", - "organization", - "createdAt", - "statusText", -]); -// รีเซ้ตค่าในช่อง ฟิลเตอร์ -const resetFilter = () => { - filterKeyword.value = ""; - filterKeyword2.value = ""; - filterRef.value.focus(); -}; - // หัวตาราง const columns = ref([ { @@ -64,13 +46,16 @@ const columns = ref([ style: "font-size: 14px", }, { - name: "fullname", + name: "name", align: "left", label: "ชื่อ-นามสกุล", sortable: true, - field: "fullname", + field: "naem", headerStyle: "font-size: 14px", style: "font-size: 14px", + format(val, row) { + return `${row.prefix}${row.firstName} ${row.lastName}`; + }, }, { name: "posNo", @@ -80,6 +65,9 @@ const columns = ref([ field: "posNo", headerStyle: "font-size: 14px", style: "font-size: 14px", + format(val, row) { + return findPosMasterNo(row); + }, }, { name: "position", @@ -98,6 +86,9 @@ const columns = ref([ field: "positionLevel", headerStyle: "font-size: 14px", style: "font-size: 14px", + format(val, row) { + return `${row.posTypeName} (${row.posLevelName})`; + }, }, { name: "organizationPositionOld", @@ -107,6 +98,9 @@ const columns = ref([ field: "organizationPositionOld", headerStyle: "font-size: 14px", style: "font-size: 14px", + format(val, row) { + return findOrgName(row); + }, }, { name: "organization", @@ -125,20 +119,37 @@ const columns = ref([ field: "createdAt", headerStyle: "font-size: 14px", style: "font-size: 14px", - sort: (a: string, b: string) => - a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), - sortOrder: "da", + format: (val) => date2Thai(val), }, { - name: "statusText", + name: "status", align: "left", label: "สถานะ", sortable: true, - field: "statusText", + field: "status", headerStyle: "font-size: 14px", style: "font-size: 14px", + format: (val) => statusText(val), }, ]); +const visibleColumns = ref([ + "no", + "name", + "posNo", + "position", + "positionLevel", + "organizationPositionOld", + "organization", + "createdAt", + "status", +]); + +// รีเซ้ตค่าในช่อง ฟิลเตอร์ +const resetFilter = () => { + filterKeyword.value = ""; + filterKeyword2.value = ""; + filterRef.value.focus(); +}; //เปิดรายละเอียด const openDetail = (id: string) => { @@ -169,6 +180,7 @@ const openModalOrder = () => { item.date && item.dateRepatriation ); + rows2.value = row; }; @@ -179,33 +191,11 @@ const getData = async () => { .get(config.API.repatriationMain()) .then((res: any) => { const data = res.data.result; - rows.value = data.map((item: officerType) => ({ - id: item.id, - fullname: `${item.prefix}${item.firstName} ${item.lastName}`, - position: item.position, - posNo: findPosMasterNo(item), - positionLevel: - item.posTypeName == null && item.posLevelName == null - ? "-" - : (item.posTypeName != null ? item.posTypeName : "") + - " " + - (item.posLevelName != null ? ` (${item.posLevelName})` : ""), - createdAt: date2Thai(item.createdAt), - organization: item.organization, - reason: item.reason, - status: item.status, - statusText: statusText(item.status), - date: item.date, - salary: item.salary, - positionTypeOld: item.positionTypeOld, - positionLevelOld: item.positionLevelOld, - positionNumberOld: item.positionNumberOld, - organizationPositionOld: item.organizationPositionOld, - isActive: item.isActive, - dateRepatriation: item.dateRepatriation, - })); + rows.value = data; + }) + .catch((e) => { + messageError($q, e); }) - .catch((e) => {}) .finally(() => { hideLoader(); }); @@ -308,69 +298,27 @@ onMounted(async () => { - - {{ props.rowIndex + 1 }} - - {{ props.row.fullname }} - - - {{ props.row.posNo }} - - - {{ props.row.position ?? "-" }} - - - {{ props.row.positionLevel }} - - - - {{ props.row.organizationPositionOld }} + + {{ props.rowIndex + 1 }} - - - - {{ props.row.organization }} + + + {{ col.value ? col.value : "-" }} - - {{ props.row.createdAt }} - - - {{ props.row.statusText }} - import { onMounted, ref } from "vue"; import { useQuasar } from "quasar"; import { useRoute, useRouter } from "vue-router"; import { useCounterMixin } from "@/stores/mixin"; - import CurrencyInput from "@/components/CurruncyInput.vue"; - import http from "@/plugins/http"; import config from "@/app.config"; +/** importTypr*/ import type { QForm } from "quasar"; import type { ResponseData } from "@/modules/05_placement/interface/response/officer"; -import PopupPersonal from "@/components/Dialogs/PopupPersonalNew.vue"; +import type { DataProfile } from "@/modules/05_placement/interface/index/Main"; -const modalPersonal = ref(false); -const personalId = ref(""); +/** importComponents*/ +import CardProfile from "@/components/CardProfile.vue"; + +/** use*/ const $q = useQuasar(); const route = useRoute(); const router = useRouter(); @@ -33,56 +33,42 @@ const { const myForm = ref(null); -const personId = ref(""); +const dataProfile = ref(); + const fullname = ref(""); -const id = ref(""); -const prefix = ref(""); -const firstName = ref(""); -const lastName = ref(""); -const position = ref(""); -const posNo = ref(""); -const positionLevel = ref(""); -const createdAt = ref(""); -const organization = ref(""); -const reason = ref(""); -const status = ref(""); -const date = ref(null); -const salary = ref(0); + +/** form แก้ไขข้อมูลเพื่อลงบัญชีแนบท้าย*/ +const organizationPositionOld = ref(""); const positionTypeOld = ref(""); const positionLevelOld = ref(""); const positionNumberOld = ref(""); -const organizationPositionOld = ref(""); -const avatar = ref(""); +const salary = ref(0); +const organization = ref(""); +const date = ref(null); const dateRepatriation = ref(null); +const reason = ref(""); +const status = ref(""); -const getData = async () => { +/** fetch ข้อมูลรายละเอียด*/ +const getData = () => { showLoader(); - await http + http .get(config.API.repatriationDetail(dataId)) .then((res: ResponseData) => { const data = res.data.result; - (fullname.value = `${data.prefix}${data.firstName} ${data.lastName}`), - (id.value = data.id); - personId.value = data.profileId; - prefix.value = data.prefix; - firstName.value = data.firstName; - lastName.value = data.lastName; + dataProfile.value = res.data.result as unknown as DataProfile; + fullname.value = `${data.prefix}${data.firstName} ${data.lastName}`; - position.value = data.position ?? "-"; - posNo.value = data.posNo; - positionLevel.value = `${data.posTypeName}(${data.posLevelName})`; - createdAt.value = data.createdAt; - organization.value = data.organization; - reason.value = data.reason; - status.value = data.status; - date.value = data.date; - salary.value = data.salary; + organizationPositionOld.value = data.organizationPositionOld; positionTypeOld.value = data.positionTypeOld; positionLevelOld.value = data.positionLevelOld; positionNumberOld.value = data.positionNumberOld; - organizationPositionOld.value = data.organizationPositionOld; + salary.value = data.salary; + organization.value = data.organization; + reason.value = data.reason; + date.value = data.date; dateRepatriation.value = data.dateRepatriation; - fetchProfile(data.profileId); + status.value = data.status; }) .catch((e) => { messageError($q, e); @@ -92,26 +78,46 @@ const getData = async () => { }); }; -function fetchProfile(id: string) { - showLoader(); - http - .get( - config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, `profile-${id}`) - ) - .then(async (res) => { - avatar.value = res.data.downloadUrl; - }) - .catch((e) => { - if (e.response.data.message === "ไม่พบไฟล์ในระบบ") { - avatar.value = ""; - } else { - messageError($q, e); - } - }) - .finally(() => { - hideLoader(); - }); -} +const onSubmit = () => { + dialogConfirm( + $q, + () => { + const body = { + organizationPositionOld: organizationPositionOld.value, + positionTypeOld: positionTypeOld.value, + positionLevelOld: positionLevelOld.value, + positionNumberOld: positionNumberOld.value, + amountOld: salary.value, + organization: organization.value, + date: date.value, + dateRepatriation: dateRepatriation.value, + reason: reason.value, + }; + showLoader(); + http + .put(config.API.repatriationMainEdit(dataId), body) + .then(() => { + success($q, "แก้ไขข้อมูลเพื่อลงบัญชีแนบท้ายสำเร็จ"); + edit.value = false; + getData(); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); + }, + "ต้องการแก้ไขข้อมูลหรือไม่?", + "แก้ไขข้อมูลเพื่อลงบัญชีแนบท้าย" + ); +}; + +const cancelBtn = () => { + edit.value = !edit; + getData(); + myForm.value?.resetValidation(); +}; const getClass = (val: boolean) => { return { @@ -120,64 +126,8 @@ const getClass = (val: boolean) => { }; }; -const conditionSave = async () => { - if (myForm.value !== null) { - myForm.value.validate().then((success: any) => { - if (success) { - dialogConfirm( - $q, - async () => await saveData(), - "ต้องการแก้ไขข้อมูลหรือไม่?", - "แก้ไขข้อมูลเพื่อลงบัญชีแนบท้าย" - ); - } - }); - } -}; -const cancelBtn = () => { - edit.value = !edit; +onMounted(() => { getData(); - myForm.value?.resetValidation(); -}; -const saveData = async () => { - const body = { - organization: organization.value, - reason: reason.value, - organizationPositionOld: organizationPositionOld.value, - date: date.value, - positionTypeOld: positionTypeOld.value, - positionLevelOld: positionLevelOld.value, - positionNumberOld: posNo.value, - amountOld: salary.value, - dateRepatriation: dateRepatriation.value, - }; - showLoader(); - await http - .put(config.API.repatriationMainEdit(dataId), body) - .then(() => { - success($q, "แก้ไขข้อมูลเพื่อลงบัญชีแนบท้ายสำเร็จ"); - edit.value = false; - }) - .catch((e) => { - messageError($q, e); - }) - .finally(async () => { - await getData(); - hideLoader(); - }); -}; - -function onclickViewinfo(id: string) { - modalPersonal.value = true; - personalId.value = id; -} - -function updatemodalPersonal(modal: boolean) { - modalPersonal.value = modal; -} - -onMounted(async () => { - await getData(); }); @@ -195,99 +145,58 @@ onMounted(async () => { /> รายละเอียดการส่งตัวกลับ {{ fullname }} - - - - {{ fullname }} - - - - - - - - - - - - - - ตำแหน่งในสายงาน - - {{ position }} - - - - - - ประเภทตำแหน่ง - - {{ positionLevel }} - - - - - - สังกัด - - {{ organization }} - - - - - - + + - - - แก้ไขข้อมูลเพื่อลงบัญชีแนบท้าย + + + + แก้ไขข้อมูลเพื่อลงบัญชีแนบท้าย + + + + + + + + + - - - - - - - - - - - + + @@ -351,7 +260,7 @@ onMounted(async () => { lazy-rules :readonly="!edit" :borderless="!edit" - v-model="posNo" + v-model="positionNumberOld" :rules="[(val) => !!val || `${'กรุณากรอกเลขที่'}`]" hide-bottom-space :label="`${'เลขที่'}`" @@ -366,6 +275,7 @@ onMounted(async () => { :options="{ currency: 'THB' }" :label="`${'เงินเดือน'}`" :rules="[(val:number) => !!val || `${'กรุณากรอกเงินเดือน'}`]" + lazy-rules /> @@ -500,12 +410,6 @@ onMounted(async () => { - -