diff --git a/src/api/02_organizational/api.organization.ts b/src/api/02_organizational/api.organization.ts index 34030c278..da0d26cc9 100644 --- a/src/api/02_organizational/api.organization.ts +++ b/src/api/02_organizational/api.organization.ts @@ -52,6 +52,7 @@ export default { orgPosExecutiveById: (id: string) => `${orgPos}/executive/${id}`, orgPosHistory: (id: string) => `${orgPos}/history/${id}`, + orgPosHistoryUpdate: (id: string) => `${orgPos}/history-update/${id}`, orgSalaryPosition: `${orgPos}/position?keyword=&type=ALL`, diff --git a/src/interface/response/dashboard/dashboard.ts b/src/interface/response/dashboard/dashboard.ts index e62164b33..142898843 100644 --- a/src/interface/response/dashboard/dashboard.ts +++ b/src/interface/response/dashboard/dashboard.ts @@ -2,6 +2,7 @@ interface attachments { name: string; url: string; isReport: boolean; + isTemplate: boolean; } interface ResponseInbox { body: string; @@ -30,4 +31,4 @@ interface DataInbox { isOpen: boolean; } -export type { ResponseInbox, DataInbox }; +export type { ResponseInbox, DataInbox, attachments }; diff --git a/src/modules/02_organization/components/DialogHistoryPos.vue b/src/modules/02_organization/components/DialogHistoryPos.vue index 26f053d4c..6e6b1de07 100644 --- a/src/modules/02_organization/components/DialogHistoryPos.vue +++ b/src/modules/02_organization/components/DialogHistoryPos.vue @@ -1,5 +1,5 @@ @@ -198,7 +227,7 @@ watch(
(false); //ดูรายละเอียดประวัติตำแหน่ง -const dataDetailPos = ref([]); //รายละเอียดตำแหน่ง +const dataDetailPos = ref(); //รายละเอียดตำแหน่ง /** * function ดูรายละเอียดประวัติตำแหน่ง * @param data ข้อมูล ประวัติตำแหน่ง */ -function onClickViewDetail(data: DataPosition[]) { +function onClickViewDetail(data: PosMaster2) { dialogDetail.value = !dialogDetail.value; dataDetailPos.value = data; } @@ -432,13 +438,15 @@ function onClickMovePos(id: string, type: string) { } const modalDialogHistoryPos = ref(false); +const historyType = ref("HISTORY"); /** * function ดูประวัติตำแหน่ง * @param id ID ตำแหน่ง */ -function onClickHistoryPos(id: string) { +function onClickHistoryPos(id: string, type: string = "HISTORY") { modalDialogHistoryPos.value = !modalDialogHistoryPos.value; rowId.value = id; + historyType.value = type; } /** @@ -454,7 +462,7 @@ function updatePagination(newPagination: NewPagination) { * function เปิด pop เลือกตนครอง * @param data ข้อมูลตำแหน่งที่ต้องการเพิ่มคนครอง */ -function openSelectPerson(data: DataPosition[]) { +function openSelectPerson(data: PosMaster2) { modalSelectPerson.value = true; dataDetailPos.value = data; } @@ -591,6 +599,39 @@ async function fetchDataCondition() { ); } +function onClickAction(type: string, data: PosMaster2) { + console.log(data); + switch (type) { + case "EDIT": + onClickPosition(type, data.id, data); + break; + case "COPY": + onClickCopyPosition(type, data.id, data); + break; + case "DEL": + onClickDelete(data.id || ""); + break; + case "MOVE": + onClickMovePos(data.id || "", "SINGER"); + break; + case "INHERIT": + onClickInherit(data.id || ""); + break; + case "CONDITION": + onClickCodition(data); + break; + case "OWNER_HISTORY": + onClickHistoryPos(data.ancestorDNA || "", type); + break; + case "HISTORY": + onClickHistoryPos(data.id || ""); + break; + case "VIEW": + onClickViewDetail(data); + break; + } +} + const pagination = ref({ page: reqMaster.value.page, rowsPerPage: reqMaster.value.pageSize, @@ -789,25 +830,7 @@ watch( :key="index" clickable v-close-popup - @click=" - item.type === 'EDIT' - ? onClickPosition('EDIT', props.row.id, props.row) - : item.type === 'DEL' - ? onClickDelete(props.row.id) - : item.type === 'MOVE' - ? onClickMovePos(props.row.id, 'SINGER') - : item.type === 'HISTORY' - ? onClickHistoryPos(props.row.id) - : item.type === 'INHERIT' - ? onClickInherit(props.row.id) - : item.type === 'COPY' - ? onClickCopyPosition('COPY', props.row.id, props.row) - : item.type === 'CONDITION' - ? onClickCodition(props.row) - : item.type === 'VIEW' - ? onClickViewDetail(props.row) - : null - " + @click="onClickAction(item.type, props.row)" >
@@ -836,6 +859,40 @@ watch( + + + + + +
+ +
{{ item.label }}
+
+
+
+
+
+
+ - + ([ ? "เลื่อน" : val === "MOVE" ? "ย้าย" + : val === "ROYAL" + ? "โปรดเกล้าฯ" : "-"; }, }, @@ -274,26 +276,19 @@ async function sendToCommand() { // }); } -/** ฟังก์ชันเลือกประเภทคำสั่ง */ -function filterSelectOrder() { - const data = rowsData.value; - - selected.value = []; - rows.value = data.filter((v: PersonData) => { +function filterSelectOrder(data: PersonData[]) { + return data.filter((v: PersonData) => { switch (commandType.value) { case "C-PM-05": return v.typeCommand === "APPOINT"; - case "C-PM-39": return v.typeCommand === "SLIP"; - case "C-PM-07": return v.typeCommand === "MOVE"; - case "C-PM-47": - return v.posTypeName === "บริหาร" || v.posTypeName === "อำนวยการ"; + return v.typeCommand === "ROYAL"; default: - return []; + return []; // ไม่กรอง ถ้าไม่มีประเภท } }); } @@ -312,9 +307,11 @@ function filterSelector(val: string, update: Function) { } function onSearch() { + selected.value = []; + const filteredByType = filterSelectOrder(rowsData.value); rows.value = onSearchDataTable( filterKeyword2.value, - rowsData.value, + filteredByType, columns2.value ? columns2.value : [] ); } @@ -328,6 +325,7 @@ watch( async () => { if (props.Modal === true) { selected.value = []; + rows.value = rowsData.value; commandType.value = ""; const data = await storeCommand.getCommandTypes(); commandMainOp.value = data.filter( @@ -364,7 +362,7 @@ watch( use-input hide-selected fill-input - @update:model-value="filterSelectOrder" + @update:model-value="onSearch" @filter="(inputValue:string, doneFn:Function) => filterSelector(inputValue, doneFn ) " @@ -411,7 +409,7 @@ watch( {{ props.row.organizationPositionOld !== null @@ -462,7 +461,10 @@ watch( }}
-
+
{{ props.row.position !== null ? props.row.position : "" }}{{ diff --git a/src/modules/05_placement/components/Other/DialogOrders.vue b/src/modules/05_placement/components/Other/DialogOrders.vue index 2a29b94de..9b94bd467 100644 --- a/src/modules/05_placement/components/Other/DialogOrders.vue +++ b/src/modules/05_placement/components/Other/DialogOrders.vue @@ -313,7 +313,7 @@ watch( -import { ref, onMounted } from "vue"; +import { ref, onMounted, computed } from "vue"; import { useQuasar } from "quasar"; -import { useRouter } from "vue-router"; +import { useRouter, useRoute } from "vue-router"; import { checkPermission, checkPermissionList, @@ -26,6 +26,7 @@ import DialogOrgSelect from "@/components/Dialogs/DialogOrgSelect.vue"; // เ const $q = useQuasar(); const router = useRouter(); +const route = useRoute(); const store = useTransferDataStore(); const { statusText, filterOption } = useTransferDataStore(); const { @@ -194,6 +195,8 @@ const columns = ref([ ? "เลื่อน" : val === "MOVE" ? "ย้าย" + : val === "ROYAL" + ? "โปรดเกล้าฯ" : "-"; }, }, @@ -242,6 +245,121 @@ const pagination = ref({ rowsPerPage: 10, }); +const getMenuItems = computed(() => { + return (row: PersonData) => { + const baseCondition = { + canUpdate: + checkPermission(route)?.attrIsUpdate && + checkPermission(route)?.attrIsGet, + canDelete: checkPermission(route)?.attrIsDelete, + canView: checkPermission(route)?.attrIsGet, + isNotDone: row.status !== "REPORT" && row.status !== "DONE", + }; + + const allMenuItems = [ + { + id: "appoint", + label: "เลือกหน่วยงานที่รับแต่งตั้ง", + icon: "mdi-bookmark-outline", + color: "primary", + type: "APPOINT", + condition: false, + }, + { + id: "slip", + label: "เลือกหน่วยงานที่รับเลื่อน", + icon: "mdi-bookmark-outline", + color: "primary", + type: "SLIP", + condition: false, + }, + { + id: "move", + label: "เลือกหน่วยงานที่รับย้าย", + icon: "mdi-bookmark-outline", + color: "primary", + type: "MOVE", + condition: false, + }, + { + id: "royal", + label: "เลือกหน่วยงานที่โปรดเกล้าฯ", + icon: "mdi-bookmark-outline", + color: "primary", + type: "ROYAL", + condition: false, + }, + { + id: "detail", + label: "รายละเอียด", + icon: "mdi-eye", + color: "info", + type: "DETAIL", + condition: baseCondition.canView, + }, + { + id: "delete", + label: "ลบ", + icon: "mdi-delete", + color: "red", + type: "DELETE", + condition: baseCondition.canDelete && baseCondition.isNotDone, + }, + ]; + + // กำหนดเงื่อนไขตามประเภทและระดับตำแหน่ง + const posType = row.posTypeNameOld?.toLowerCase() || ""; + const posLevel = row.posLevelNameOld?.toLowerCase() || ""; + + // หาเมนูแต่ละประเภท + const appointItem = allMenuItems.find((item) => item.id === "appoint"); + const slipItem = allMenuItems.find((item) => item.id === "slip"); + const moveItem = allMenuItems.find((item) => item.id === "move"); + const royalItem = allMenuItems.find((item) => item.id === "royal"); + + // ประเภทวิชาการ ระดับเชี่ยวชาญ - แสดง "ย้าย" และ "โปรดเกล้าฯ" + if (posType === "วิชาการ" && posLevel === "เชี่ยวชาญ") { + if (moveItem) + moveItem.condition = baseCondition.canUpdate && baseCondition.isNotDone; + if (royalItem) + royalItem.condition = + baseCondition.canUpdate && baseCondition.isNotDone; + } + // ประเภทบริหาร ระดับต้น - แสดง "ย้าย" และ "โปรดเกล้าฯ" + else if (posType === "บริหาร" && posLevel === "ต้น") { + if (moveItem) + moveItem.condition = baseCondition.canUpdate && baseCondition.isNotDone; + if (royalItem) + royalItem.condition = + baseCondition.canUpdate && baseCondition.isNotDone; + } + // ประเภทวิชาการ ทรงคุณวุฒิ - แสดงเฉพาะ "โปรดเกล้าฯ" + else if (posType === "วิชาการ" && posLevel === "ทรงคุณวุฒิ") { + if (royalItem) + royalItem.condition = + baseCondition.canUpdate && baseCondition.isNotDone; + } + // ประเภทบริหาร ระดับสูง - แสดงเฉพาะ "โปรดเกล้าฯ" + else if (posType === "บริหาร" && posLevel === "สูง") { + if (royalItem) + royalItem.condition = + baseCondition.canUpdate && baseCondition.isNotDone; + } + // อื่นๆ - แสดง "แต่งตั้ง", "เลื่อน", "ย้าย" + else { + if (appointItem) + appointItem.condition = + baseCondition.canUpdate && baseCondition.isNotDone; + if (slipItem) + slipItem.condition = baseCondition.canUpdate && baseCondition.isNotDone; + if (moveItem) + moveItem.condition = baseCondition.canUpdate && baseCondition.isNotDone; + } + + return allMenuItems.filter((item) => item.condition); + }; +}); + /** fetch รายการแต่งตั้ง-เลื่อน-ย้าย*/ async function fecthlistappointment() { showLoader(); @@ -376,6 +494,24 @@ async function onSearch() { ); } +// ฟังก์ชันจัดการการคลิกเมนู +function handleMenuClick(row: PersonData, type: string) { + switch (type) { + case "APPOINT": + case "SLIP": + case "MOVE": + case "ROYAL": + openModalTree(row, type); + break; + case "DETAIL": + nextPage(row.id); + break; + case "DELETE": + clickDelete(row.id); + break; + } +} + /** ทำงานเมื่อมีการเรียกใช้ Components*/ onMounted(async () => { await fecthlistappointment(); @@ -491,7 +627,7 @@ onMounted(async () => {