This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-06-26 15:30:48 +07:00
parent c1bb3651ab
commit 4986a17e06
3 changed files with 68 additions and 11 deletions

View file

@ -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<boolean>("modal", { required: true });
const title = defineModel<string>("title", { required: true });
const type = defineModel<any>("type", { required: true });
const posType = defineModel<any>("posType", { required: true });
const posLevel = defineModel<any>("posLevel", { required: true });
const position = defineModel<any>("position", { required: true });
// const routeName = ref<string>(route?.name);
const orgRevisionId = ref<string>("");
const filter = ref<string>("");
const isAll = ref<boolean>(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<string[]>([]);
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 {

View file

@ -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<string[]>([]);
function fetchPositionUes() {
http
.get(config.API.apppointmentPositionUse())
.then((res) => {
positionUse.value = res.data.result;
})
.catch((err) => {
messageError($q, err);
});
}
watch(
() => isAll.value,
(value, oldVal) => {