รายการแต่งตั้ง-เลื่อน-ย้าย

This commit is contained in:
STW_TTTY\stwtt 2024-05-03 17:35:17 +07:00
parent 7a2d0d2811
commit ad2e4ece16
4 changed files with 211 additions and 97 deletions

View file

@ -244,6 +244,7 @@ function close() {
async function getDataTable(id: string, level: number = 0) {
showLoader();
const body = {
node: level,
nodeId: id,
@ -308,10 +309,16 @@ async function getDataTable(id: string, level: number = 0) {
* @param data อม Tree
*/
function updateSelected(data: DataTree) {
positionId.value = "";
seletcId.value = "";
selectedPos.value = [];
datePos.value = new Date();
if (props?.dataRows?.nodeId === data.orgTreeId) {
positionId.value = props?.dataRows?.posmasterId;
seletcId.value = props?.dataRows?.positionId;
datePos.value = props?.dataRows?.reportingDateFullDate;
} else {
positionId.value = "";
seletcId.value = "";
selectedPos.value = [];
datePos.value = new Date();
}
nodeId.value = data.orgTreeId ? data.orgTreeId : "";
nodeLevel.value = data.orgLevel;
@ -396,11 +403,50 @@ async function onClickSelectPos(id: string) {
}
}
/**
* function fetch อม expanded tree
* @param level levelTree
* @param id treeId
*/
async function fetchPosFind(level: number, id: string) {
showLoader();
const body = {
node: level,
nodeId: id,
};
await http
.post(config.API.orgPosFind, body)
.then((res) => {
const data = res.data.result;
expanded.value = data;
nodeId.value = id;
positionId.value = props?.dataRows?.posmasterId;
seletcId.value = props?.dataRows?.positionId;
datePos.value = props?.dataRows?.reportingDateFullDate;
getDataTable(nodeId.value, level);
})
.catch((e) => {
messageError($q, e);
hideLoader();
});
}
watch(
() => modal.value,
(n) => {
async (n) => {
if (n == true) {
getActive();
if (props?.dataRows?.node !== null && props?.dataRows?.nodeId !== null) {
await fetchPosFind(props?.dataRows?.node, props?.dataRows?.nodeId);
if (positionId.value) {
setTimeout(async () => {
await onClickSelectPos(positionId.value);
}, 200);
}
} else {
expanded.value = [];
}
}
}
);
@ -436,7 +482,7 @@ function onSubmit() {
(e: any) => e.id === positionId.value
);
console.log(dataPosMaster)
console.log(dataPosMaster);
if (selectedPos.value.length === 0) {
dialogMessageNotify($q, "กรุณาเลือกตำแหน่ง");
} else {
@ -461,7 +507,6 @@ function onSubmit() {
props.onSubmit?.(body);
});
}
}
</script>
<template>
@ -496,7 +541,6 @@ function onSubmit() {
<q-tree
class="q-pa-sm q-gutter-sm"
dense
default-expand-all
:nodes="lazy"
node-key="orgTreeId"
label-key="orgTreeName"