From 4986a17e06aa1a09597efd2b86484c4475dffd93 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Wed, 26 Jun 2024 15:30:48 +0700 Subject: [PATCH] fix bug --- src/components/Dialogs/DialogOrgSelect.vue | 47 ++++++++++++++++--- .../Dialogs/DialogOrgSelectEmployee.vue | 30 ++++++++++-- .../08_registryEmployee/views/Main.vue | 2 +- 3 files changed, 68 insertions(+), 11 deletions(-) diff --git a/src/components/Dialogs/DialogOrgSelect.vue b/src/components/Dialogs/DialogOrgSelect.vue index 336409cfa..099e139ef 100644 --- a/src/components/Dialogs/DialogOrgSelect.vue +++ b/src/components/Dialogs/DialogOrgSelect.vue @@ -3,11 +3,11 @@ import DialogHeader from "@/components/DialogHeader.vue"; import { useCounterMixin } from "@/stores/mixin"; import { useQuasar } from "quasar"; import { ref, watch, reactive } from "vue"; -import type { QTableProps } from "quasar"; -import CardPosition from "@/modules/05_placement/components/PersonalList/CardPosition.vue"; +import { useRoute } from "vue-router"; import http from "@/plugins/http"; import config from "@/app.config"; +import type { QTableProps } from "quasar"; import type { OrgTree, DataTree, @@ -27,6 +27,7 @@ const props = defineProps({ onSubmit: Function, }); const $q = useQuasar(); +const route = useRoute(); const mixin = useCounterMixin(); const { dialogConfirm, @@ -37,14 +38,15 @@ const { dialogMessageNotify, } = mixin; +/** props*/ const modal = defineModel("modal", { required: true }); const title = defineModel("title", { required: true }); const type = defineModel("type", { required: true }); - const posType = defineModel("posType", { required: true }); const posLevel = defineModel("posLevel", { required: true }); const position = defineModel("position", { required: true }); +// const routeName = ref(route?.name); const orgRevisionId = ref(""); const filter = ref(""); const isAll = ref(false); @@ -292,7 +294,20 @@ async function getDataTable(id: string, level: number = 0) { })); positionNo.value = listPosNo; - positionData.value = listPosNo; + // positionData.value = listPosNo; + + if (props.dataRows?.posmasterId) { + const newUse = positionUse.value.filter( + (e) => e !== props.dataRows?.posmasterId + ); + positionData.value = listPosNo.filter( + (e: any) => !newUse.includes(e.id) + ); + } else { + positionData.value = listPosNo.filter( + (e: any) => !positionUse.value.includes(e.id) + ); + } }) .catch((err) => { messageError($q, err); @@ -435,7 +450,7 @@ watch( async (n) => { if (n == true) { getActive(); - console.log(props.dataRows); + fetchPositionUes(); if (props?.dataRows?.node !== null && props?.dataRows?.nodeId !== null) { await fetchPosFind(props?.dataRows?.node, props?.dataRows?.nodeId); @@ -451,6 +466,26 @@ watch( } ); +const positionUse = ref([]); +function fetchPositionUes() { + const URL = + route.name === "appoint-promote" + ? config.API.apppointmentPosition() + : route.name === "receive" + ? config.API.receiveDataPosition() + : null; + if (URL) { + http + .get(URL) + .then((res) => { + positionUse.value = res.data.result; + }) + .catch((err) => { + messageError($q, err); + }); + } +} + watch( () => isAll.value, (value, oldVal) => { @@ -481,8 +516,6 @@ function onSubmit() { const dataPosMaster = posMasterMain.value?.find( (e: any) => e.id === positionId.value ); - - console.log(dataPosMaster); if (selectedPos.value.length === 0) { dialogMessageNotify($q, "กรุณาเลือกตำแหน่ง"); } else { diff --git a/src/components/Dialogs/DialogOrgSelectEmployee.vue b/src/components/Dialogs/DialogOrgSelectEmployee.vue index c174ad165..f76702dee 100644 --- a/src/components/Dialogs/DialogOrgSelectEmployee.vue +++ b/src/components/Dialogs/DialogOrgSelectEmployee.vue @@ -271,7 +271,20 @@ async function getDataTable(id: string, level: number = 0) { })); positionNo.value = listPosNo; - positionData.value = listPosNo; + // positionData.value = listPosNo; + + if (props.dataRows?.posmasterId) { + const newUse = positionUse.value.filter( + (e) => e !== props.dataRows?.posmasterId + ); + positionData.value = listPosNo.filter( + (e: any) => !newUse.includes(e.id) + ); + } else { + positionData.value = listPosNo.filter( + (e: any) => !positionUse.value.includes(e.id) + ); + } }) .catch((err) => { messageError($q, err); @@ -323,8 +336,6 @@ async function getActive() { }) .catch((err) => { messageError($q, err); - }) - .finally(() => { hideLoader(); }); } @@ -416,6 +427,7 @@ watch( async (n) => { if (n == true) { getActive(); + fetchPositionUes(); if (props?.dataRows?.node !== null && props?.dataRows?.nodeId !== null) { await fetchPosFind(props?.dataRows?.node, props?.dataRows?.nodeId); if (positionId.value) { @@ -430,6 +442,18 @@ watch( } ); +const positionUse = ref([]); +function fetchPositionUes() { + http + .get(config.API.apppointmentPositionUse()) + .then((res) => { + positionUse.value = res.data.result; + }) + .catch((err) => { + messageError($q, err); + }); +} + watch( () => isAll.value, (value, oldVal) => { diff --git a/src/modules/08_registryEmployee/views/Main.vue b/src/modules/08_registryEmployee/views/Main.vue index 27f0d4f08..a50833edb 100644 --- a/src/modules/08_registryEmployee/views/Main.vue +++ b/src/modules/08_registryEmployee/views/Main.vue @@ -436,7 +436,7 @@ onMounted(() => { v-close-popup v-if=" props.row.draftOrgEmployeeStatus === null || - props.row.draftOrgEmployeeStatus === 'PENDING' + props.row.draftOrgEmployeeStatus === 'WAITTING' " @click.pervent="onClickSelectPos(props.row)" >