เลือกหน่วยงานที่รับบรรจุ

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-02-20 16:07:12 +07:00
parent 6fa7bb94e1
commit a2ff9264ee
5 changed files with 119 additions and 38 deletions

View file

@ -25,6 +25,7 @@ import { useSelectOrgStore } from "@/modules/05_placement/stores/storeSelect";
const $q = useQuasar();
const store = useSelectOrgStore();
const {
success,
showLoader,
hideLoader,
messageError,
@ -41,6 +42,11 @@ const props = defineProps({
type: Object,
require: true,
},
fetchTable: {
type: Function,
require: true,
},
fetchStatCard: { type: Function, require: true },
});
/** Tree*/
@ -53,6 +59,7 @@ const expanded = ref<string[]>([]);
const positionNo = ref<DataPositionNo[]>();
const positionId = ref<string>("");
const seletcId = ref<string>("");
const selectedPos = ref<any[]>([]);
const datePos = ref<Date>(new Date());
@ -107,9 +114,18 @@ async function fetchDataTree(id: string) {
* @param data อม Tree
*/
function updateSelected(data: TreeMain) {
console.log(props?.dataRow?.nodeId === data.orgTreeId);
if (props?.dataRow?.nodeId === data.orgTreeId) {
positionId.value = props?.dataRow?.posmasterId;
seletcId.value = props?.dataRow?.positionId;
} else {
positionId.value = "";
seletcId.value = "";
selectedPos.value = [];
}
nodeId.value = data.orgTreeId ? data.orgTreeId : "";
nodeLevel.value = data.orgLevel;
selectedPos.value = [];
datePos.value = new Date();
fetchDataTable(data.orgTreeId, data.orgLevel);
}
@ -146,19 +162,59 @@ async function fetchDataTable(id: string, level: number = 0) {
.finally(() => {});
}
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;
console.log(data);
expanded.value = data;
nodeId.value = id;
positionId.value = props?.dataRow?.posmasterId;
seletcId.value = props?.dataRow?.positionId;
fetchDataTable(nodeId.value, level);
})
.catch((e) => {
messageError($q, e);
hideLoader();
});
}
function onClickSubmit() {
if (selectedPos.value.length === 0) {
dialogMessageNotify($q, "กรุณาเลือกตำแหน่ง");
} else {
dialogConfirm($q, () => {
dialogConfirm($q, async () => {
showLoader();
const body = {
PersonalId: props?.dataRow?.personalId,
node: nodeLevel.value,
nodeId: nodeId.value,
posmasterId: positionId.value,
positionId: selectedPos.value[0].id,
reportingDate: datePos.value,
};
console.log(body);
await http
.post(config.API.placementPass(), body)
.then(() => {
success($q, "บันทึกข้อมูลสำเร็จ");
props.fetchStatCard?.();
props.fetchTable?.();
closePopup();
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
});
}
}
@ -174,15 +230,13 @@ watch(
if (modal.value) {
showLoader();
await fetchOrganizationActive();
// console.log(props.dataRow);
console.log(props.dataRow);
expanded.value = [];
// expanded.value = [
// "c6164a42-539d-401a-b289-653282c08e37",
// "277e5221-9c47-43ca-a7a5-0ba6e30039c4",
// ];
// nodeId.value = "c6164a42-539d-401a-b289-653282c08e37";
// fetchDataTable(nodeId.value);
if (props?.dataRow?.node !== null && props?.dataRow?.nodeId !== null) {
await fetchPosFind(props?.dataRow?.node, props?.dataRow?.nodeId);
} else {
expanded.value = [];
}
} else {
clearData();
}
@ -288,10 +342,11 @@ function filterItemsTaps(data: TreeMain[]) {
:name="item"
>
<CardPosition
:position="positionNo"
v-model:position="positionNo"
v-model:selectedPos="selectedPos"
v-model:datePos="datePos"
v-model:positionId="positionId"
v-model:seletcId="seletcId"
/>
</q-tab-panel>
</q-tab-panels>