แก้ รายการรับโอน (ไม่เสร็จดี)

This commit is contained in:
STW_TTTY\stwtt 2024-05-01 18:11:11 +07:00
parent 77ae7e5bed
commit ce1622d4aa
3 changed files with 608 additions and 53 deletions

View file

@ -18,6 +18,7 @@ import type {
ResponseRow,
} from "@/modules/05_placement/interface/response/Receive";
const dataRows = ref<any[]>([]);
const $q = useQuasar();
const router = useRouter();
const rows2 = ref<ResponseRow[]>([]);
@ -203,6 +204,9 @@ const fecthlistRecevice = async () => {
organizationShortName: e.organizationShortName,
positionNumber: e.positionNumber,
positionPath: e.positionPath,
positionLevelId: e.positionLevelId,
positionTypeId: e.positionTypeId,
positionId: e.positionId,
birthday:
e.dateOfBirth == null
? "-"
@ -254,10 +258,11 @@ const clickCloseUpload = () => {
files.value = null;
};
//
const openModalTree = (id: string) => {
const openModalTree = (id: string,data:any) => {
personalId.value = id;
personal.value = listRecevice.value.filter((e: ResponseData) => e.id === id);
modalTree.value = true;
dataRows.value = data
};
//
const openUpload = (id: string) => {
@ -479,7 +484,7 @@ onMounted(() => {
<q-item
clickable
v-close-popup
@click="openModalTree(props.row.personalId)"
@click="openModalTree(props.row.personalId,props.row)"
:disable="
props.row.status == 'REPORT' ||
props.row.status == 'DONE'
@ -627,6 +632,8 @@ onMounted(() => {
:close="closeModalTree"
:personal="personal"
:personalId="personalId"
:dataRows="dataRows"
/>
</template>
<style scoped lang="scss"></style>

View file

@ -5,9 +5,22 @@ import { useCounterMixin } from "@/stores/mixin";
import DialogHeader from "@/modules/05_placement/components/PersonalList/DialogHeader.vue";
import DialogFooter from "@/modules/05_placement/components/PersonalList/DialogFooter.vue";
import CardPosition from "@/modules/05_placement/components/PersonalList/CardPosition.vue";
import http from "@/plugins/http";
import config from "@/app.config";
import type {
DataActive,
OrgTree,
DataTree,
SumPosition,
PositionMaim,
PositionNo,
Positions,
DataPositionNo,
TreeMain,
} from "@/modules/05_placement/interface/response/Receive";
const $q = useQuasar();
const mixin = useCounterMixin(); //
const {
@ -19,9 +32,15 @@ const {
dialogConfirm,
} = mixin; //
const nodeLevel = ref<number>(0);
const isAll = ref<boolean>(false);
const isBlank = ref<boolean>(false);
const positionNo = ref<DataPositionNo[]>();
const posMasterMain = ref<any>([]);
const notFound = ref<string>("ไม่พบข้อมูลที่ค้นหา");
const noData = ref<string>("ไม่พบข้อมูลผังโครงสร้าง");
const level = ref<number>();
const id = ref<string>("");
const search = ref<string>("");
const selected = ref<string>("");
@ -35,27 +54,51 @@ const checkValidate = ref<boolean>(false);
const myFormPosition = ref<any>();
const editDataStatus = ref<boolean>(false);
const placementPosition = ref<any>([]);
const filter = ref<string>("");
const shortName = ref<string>("");
const nodes = ref<Array<OrgTree>>([]);
const lazy = ref(nodes);
const treeId = ref<string>();
const nodeTree = ref<OrgTree[]>(); // Tree
const nodeId = ref<string>(""); // id Tree
const itemTaps = ref<string[]>();
const selectedPos = ref<any[]>([]);
const positionId = ref<string>("");
const datePos = ref<Date>(new Date());
const seletcId = ref<string>("");
const sumPosition = reactive({
total: 0,
use: 0,
vacant: 0,
totalRoot: 0,
useRoot: 0,
vacantRoot: 0,
});
//
const posNoOptions = ref<Object[]>([ { label: "", value: "" } ]);
const posNoOptions = ref<Object[]>([{ label: "", value: "" }]);
//
const positionOptions = ref<Object[]>([ { label: "", value: "" } ]);
const positionOptions = ref<Object[]>([{ label: "", value: "" }]);
// /
const positionPathSideOptions = ref<Object[]>([ { label: "", value: "" } ]);
const positionPathSideOptions = ref<Object[]>([{ label: "", value: "" }]);
//
const positionTypeOptions = ref<Object[]>([ { label: "", value: "" } ]);
const positionTypeOptions = ref<Object[]>([{ label: "", value: "" }]);
//
const positionLineOptions = ref<Object[]>([ { label: "", value: "" } ]);
const positionLineOptions = ref<Object[]>([{ label: "", value: "" }]);
//
const positionLevelOptions = ref<Object[]>([ { label: "", value: "" } ]);
const positionLevelOptions = ref<Object[]>([{ label: "", value: "" }]);
const props = defineProps({
personalId: String,
dataRows: {
type: Object,
require: true,
},
modal: Boolean,
close: {
type: Function,
@ -140,15 +183,18 @@ const myFilterMethod = (node: any, filter: string) => {
(node.organizationName && node.organizationName.indexOf(filt) > -1) ||
(node.positionNum && node.positionNum.indexOf(filt) > -1) ||
(node.positionName && node.positionName.indexOf(filt) > -1) ||
(node.governmentCode && node.governmentCode.toString().indexOf(filt) > -1) ||
(node.governmentCode &&
node.governmentCode.toString().indexOf(filt) > -1) ||
(node.agency && node.agency.indexOf(filt) > -1) ||
(node.government && node.government.indexOf(filt) > -1) ||
(node.department && node.department.indexOf(filt) > -1) ||
(node.pile && node.pile.indexOf(filt) > -1) ||
(node.organizationShortName && node.organizationShortName.indexOf(filt) > -1) ||
(node.organizationShortName &&
node.organizationShortName.indexOf(filt) > -1) ||
(node.positionSideName && node.positionSideName.indexOf(filt) > -1) ||
(node.executivePosition && node.executivePosition.indexOf(filt) > -1) ||
(node.executivePositionSide && node.executivePositionSide.indexOf(filt) > -1) ||
(node.executivePositionSide &&
node.executivePositionSide.indexOf(filt) > -1) ||
(node.positionLevel && node.positionLevel.indexOf(filt) > -1)
);
};
@ -197,21 +243,33 @@ const saveAppoint = async () => {
});
};
const closeModal = () => {
if (editDataStatus.value == true) {
dialogConfirm(
$q,
async () => {
editDataStatus.value = false;
await closeAndClear();
},
`ข้อมูลมีการแก้ไข`,
`ยืนยันที่จะปิดโดยไม่บันทึกใช่หรือไม่?`
);
} else {
closeAndClear();
}
};
// const closeModal = () => {
// if (editDataStatus.value == true) {
// dialogConfirm(
// $q,
// async () => {
// editDataStatus.value = false;
// await closeAndClear();
// },
// ``,
// `?`
// );
// } else {
// closeAndClear();
// }
// };
/** function closePopup*/
async function closeModal() {
await props.close();
clearData();
}
/** function clearData*/
function clearData() {
nodeId.value = "";
expanded.value = [];
}
const closeAndClear = async () => {
await props.close();
@ -227,7 +285,6 @@ const closeAndClear = async () => {
dataForm.positionTypeId = "";
};
const selectedPosition = async (data: any) => {
if (data.name == null && selected.value != data.keyId) {
editDataStatus.value = true;
@ -362,6 +419,220 @@ function findByPerson(element: any): any {
}
return null;
}
const activeId = ref<string>();
const draftId = ref<string>();
const dataActive = ref<DataActive>();
const isPublic = ref<boolean>(false);
const orgPublishDate = ref<Date | null>(null);
/** function เรียกข้อมูลโครงสร้าง แบบปัจุบันและ แบบร่าง*/
async function fetchOrganizationActive() {
showLoader();
await http
.get(config.API.activeOrganization)
.then((res) => {
const data = res.data.result;
activeId.value = data.activeId;
draftId.value = data.draftId;
dataActive.value = data;
isPublic.value = data.isPublic;
orgPublishDate.value = data.orgPublishDate;
fetchDataTree(data.activeId);
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
function getSumPosition(data: SumPosition) {
sumPosition.total = data.totalPosition;
sumPosition.totalRoot = data.totalRootPosition ? data.totalRootPosition : 0;
sumPosition.use = data.totalPositionCurrentUse;
sumPosition.useRoot = data.totalRootPositionCurrentUse
? data.totalRootPositionCurrentUse
: 0;
sumPosition.vacant = data.totalPositionCurrentVacant;
sumPosition.vacantRoot = data.totalRootPositionCurrentVacant
? data.totalRootPositionCurrentVacant
: 0;
}
/**
* function fetch อมลของ Tree
* @param id id โครงสราง
*/
async function fetchDataTree(id: string) {
showLoader();
await http
.get(config.API.orgByid(id.toString()))
.then((res) => {
const data = res.data.result;
nodes.value = data;
filterItemsTaps(data);
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/**
* funtion เลอกขอม Tree
* @param data อม Tree
*/
function updateSelected(data: DataTree) {
// positionId.value = "";
// seletcId.value = "";
// selectedPos.value = [];
// datePos.value = new Date();
nodeId.value = data.orgTreeId ? data.orgTreeId : "";
nodeLevel.value = data.orgLevel;
fetchDataTable(data.orgTreeId, data.orgLevel);
}
async function fetchDataTable(id: string, level: number = 0) {
console.log(props.dataRows);
showLoader();
const body = {
node: level,
nodeId: id,
position: props?.dataRows?.positionPath,
typeCommand: "MOVE",
posLevel: props.dataRows?.positionLevelId,
posType: props.dataRows?.positionTypeId,
isAll: isAll.value,
isBlank: isBlank.value,
};
await http
.post(config.API.orgPosPlacement, body)
.then((res) => {
const dataMain: PositionMaim[] = [];
posMasterMain.value = res.data.result.data;
res.data.result.data.forEach((e: PositionNo) => {
const p = e.positions;
if (p.length !== 0) {
const a = p.find((el: Positions) => el.positionIsSelected === true);
const { id, ...rest } = a ? a : p[0];
const data: any = { ...e, ...rest };
dataMain.push(data);
}
});
const listPosNo: DataPositionNo[] = dataMain.map((e: PositionMaim) => ({
id: e.id,
isPosition: e.isPosition,
posMasterNo:
e.orgShortname +
(e.posMasterNoPrefix != null ? e.posMasterNoPrefix : "") +
e.posMasterNo +
(e.posMasterNoSuffix != null ? e.posMasterNoSuffix : ""),
positionName: e.positionName,
posTypeName: e.posTypeName,
posLevelName: e.posLevelName,
positionIsSelected: e.positionIsSelected
? e.fullNameCurrentHolder
: "-",
isSit: e.isSit,
positions: e.positions,
node: e.node,
nodeId: e.nodeId,
}));
positionNo.value = listPosNo;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
setTimeout(() => {
hideLoader();
}, 1000);
});
}
function filterItemsTaps(data: TreeMain[]) {
let orgTreeIds: string[] = [];
for (const child of data) {
orgTreeIds.push(child.orgTreeId);
if (child.children) {
orgTreeIds = orgTreeIds.concat(filterItemsTaps(child.children));
}
}
itemTaps.value = orgTreeIds;
return orgTreeIds;
}
/**
* 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;
fetchDataTable(nodeId.value, level);
})
.catch((e) => {
messageError($q, e);
hideLoader();
});
}
watch(
() => props.modal,
async () => {
if (props.modal) {
await fetchOrganizationActive();
if (props?.dataRows?.node !== null && props?.dataRows?.nodeId !== null) {
await fetchPosFind(props?.dataRows?.node, props?.dataRows?.nodeId);
} else {
expanded.value = [];
}
}
}
);
watch(
() => isAll.value,
(value, oldVal) => {
if (value !== oldVal) {
fetchDataTable(nodeId.value, nodeLevel.value);
}
}
);
watch(
() => isBlank.value,
(value, oldVal) => {
if (value !== oldVal) {
fetchDataTable(nodeId.value, nodeLevel.value);
}
}
);
onMounted(async () => {
await fetchPublishFile();
await loadTreeData();
@ -370,12 +641,105 @@ onMounted(async () => {
</script>
<template>
<q-dialog v-model="props.modal" persistent>
<q-card style="width: 900px; max-width: 80vw">
<q-form ref="myFormPosition">
<DialogHeader title="เลือกหน่วยงานที่รับโอน" :close="closeModal" />
<q-separator />
<q-card-section class="q-pa-sm bg-grey-1">
<q-dialog v-model="props.modal" persistent full-width>
<q-card>
<DialogHeader title="เลือกหน่วยงานที่รับโอน" :close="closeModal" />
<q-separator />
<q-card-section class="q-pt-none q-pa-sm bg-grey-2">
<div class="row">
<q-card
bordered
class="col-12 col-sm-3 scroll q-pa-sm"
style="height: 75vh"
>
<q-toolbar style="padding: 0">
<q-toolbar-title class="text-subtitle2 text-bold"
>เลอกหนวยงาน/วนราชการ</q-toolbar-title
>
</q-toolbar>
<q-input
ref="filterRef"
dense
outlined
v-model="filter"
label="ค้นหา"
>
<template v-slot:append>
<q-icon
v-if="filter !== ''"
name="clear"
class="cursor-pointer"
@click="filter = ''"
/>
</template>
</q-input>
<q-tree
class="q-pa-sm q-gutter-sm"
dense
default-expand-all
:nodes="lazy"
node-key="orgTreeId"
label-key="orgTreeName"
:filter="filter"
no-results-label="ไม่พบข้อมูลที่ค้นหา"
no-nodes-label="ไม่มีข้อมูล"
v-model:expanded="expanded"
>
<template v-slot:default-header="prop">
<q-item
@click.stop="updateSelected(prop.node)"
clickable
:active="nodeId == prop.node.orgTreeId"
active-class="my-list-link text-primary text-weight-medium"
class="row col-12 items-center text-dark q-py-xs q-pl-sm rounded-borders my-list"
>
<div>
<div class="text-weight-medium">
{{ prop.node.orgTreeName }}
</div>
<div class="text-weight-light">
{{ prop.node.orgCode == null ? null : prop.node.orgCode }}
{{
prop.node.orgTreeShortName == null
? null
: prop.node.orgTreeShortName
}}
</div>
</div>
</q-item>
</template>
</q-tree>
</q-card>
<q-card bordered class="col-12 col-sm-9 q-pa-sm">
<q-tab-panels
v-model="nodeId"
animated
transition-prev="jump-up"
transition-next="jump-up"
>
<q-tab-panel
v-for="(item, index) in itemTaps"
:key="index"
:name="item"
>
<CardPosition
v-model:position="positionNo"
v-model:selectedPos="selectedPos"
v-model:datePos="datePos"
v-model:positionId="positionId"
v-model:seletcId="seletcId"
v-model:is-all="isAll"
v-model:is-blank="isBlank"
/>
</q-tab-panel>
</q-tab-panels>
</q-card>
</div>
</q-card-section>
<!-- <q-card-section class="q-pa-sm bg-grey-1">
<div class="row col-12 q-col-gutter-sm">
<div class="col-xs-12 col-sm-7 row">
<q-card flat bordered class="fit q-pa-sm">
@ -409,7 +773,6 @@ onMounted(async () => {
<div
class="row items-center q-px-xs q-pt-xs q-gutter-sm"
>
<!--แสดงชอแผนก มพวหนา คลกแลวกาง/ Tree-->
<div class="text-weight-medium">
{{ prop.node.organizationName }}
</div>
@ -468,14 +831,14 @@ onMounted(async () => {
border-radius: 50%;
"
/>
<!--=====ตำแหนงวาง แดง=====-->
<div
v-if="prop.node.name == null"
class="q-px-sm text-weight-medium text-red"
>
าง
</div>
<!--=====วหน เขยว=====-->
<div v-else-if="prop.node.positionLeaderFlag">
<div
class="q-px-sm text-weight-medium text-primary"
@ -483,13 +846,13 @@ onMounted(async () => {
{{ prop.node.name }}
</div>
</div>
<!--=====กนอง ปกต=====-->
<div v-else>
<div class="q-px-sm text-weight-medium">
{{ prop.node.name }}
</div>
</div>
<!--อทายชอคน แสดงสปกต-->
<div class="q-pr-sm">
{{ prop.node.positionName }}
</div>
@ -538,7 +901,6 @@ onMounted(async () => {
class="full-width inputgreen cursor-pointer"
outlined
dense
:model-value="
date2Thai(new Date(dataForm.containDate))
"
@ -652,16 +1014,21 @@ onMounted(async () => {
</q-card>
</div>
</div>
</q-card-section>
</q-card-section> -->
<q-separator />
<q-separator />
<q-card-actions align="right" class="bg-white text-teal">
<q-btn label="บันทึก" color="secondary" type="submit"
><q-tooltip>นทกขอม</q-tooltip></q-btn
>
</q-card-actions>
<!-- <q-separator />
<DialogFooter
:editvisible="true"
:validate="validateData"
:save="saveAppoint"
v-model:modalEdit="editDataStatus"
/>
</q-form>
/> -->
</q-card>
</q-dialog>
</template>

View file

@ -19,13 +19,15 @@ interface ResponseRow {
statusText: string;
createdAt: Date | null;
dateText: string | null;
educationOld: string
organizationPositionOld: string
positionTypeOld: string
positionLevelOld: string
positionNumberOld: string
amountOld: number
educationOld: string;
organizationPositionOld: string;
positionTypeOld: string;
positionLevelOld: string;
positionNumberOld: string;
positionId: string;
positionTypeId: string;
positionLevelId: string;
amountOld: number;
}
interface ResponseData {
@ -62,7 +64,186 @@ interface ResponseData {
recruitDate: Date;
salary: number;
status: string;
amountOld: number
amountOld: number;
}
export type { ResponseTitle, ResponseData, ResponseRow };
interface DataActive {
activeId: string;
activeName: string;
draftId: string;
draftName: string;
isPublic: boolean;
orgPublishDate: Date | null;
}
interface OrgTree {
orgTreeId: string;
orgRootId: string;
orgLevel: number;
orgTreeName: string;
orgTreeShortName: string;
orgTreeCode: string;
orgCode: string;
orgTreeRank: string;
orgTreeOrder: number | null;
orgRootCode: string;
orgTreePhoneEx: string;
orgTreePhoneIn: string;
orgTreeFax: string;
orgRevisionId: string;
children: OrgTree[];
}
interface DataTree {
orgTreeId: string;
orgRootId?: string;
orgLevel: number;
orgName: string;
orgTreeName: string;
orgTreeShortName: string;
orgTreeCode: string;
orgCode: string;
orgTreeRank: string;
orgTreeOrder: number;
orgRootCode?: string;
orgTreePhoneEx: string;
orgTreePhoneIn: string;
orgTreeFax: string;
orgRevisionId: string;
orgRootName: string;
totalPosition: number;
totalPositionCurrentUse: number;
totalPositionCurrentVacant: number;
totalPositionNextUse: number;
totalPositionNextVacant: number;
totalRootPosition: number;
totalRootPositionCurrentUse: number;
totalRootPositionCurrentVacant: number;
totalRootPositionNextUse: number;
totalRootPositionNextVacant: number;
children?: DataTree[];
}
interface SumPosition {
totalPosition: number;
totalPositionCurrentUse: number;
totalPositionCurrentVacant: number;
totalPositionNextUse: number;
totalPositionNextVacant: number;
totalRootPosition: number;
totalRootPositionCurrentUse: number;
totalRootPositionCurrentVacant: number;
totalRootPositionNextUse: number;
totalRootPositionNextVacant: number;
}
interface PositionMaim {
fullNameCurrentHolder: string | null;
fullNameNextHolder: string | null;
id: string;
isPosition: boolean;
isSit: boolean;
orgRootId: string;
orgShortname: string;
posMasterNo: number;
posMasterNoPrefix: string;
posMasterNoSuffix: string;
posExecutiveId: string;
posExecutiveName: string;
posLevelId: string;
posLevelName: string;
posTypeId: string;
posTypeName: string;
positionArea: string;
positionExecutiveField: string;
positionField: string;
positionIsSelected: boolean;
positionName: string;
positions: Positions[];
node: number;
nodeId: string;
}
interface PositionNo {
fullNameCurrentHolder: string | null;
fullNameNextHolder: string | null;
id: string;
isPosition: boolean;
isSit: boolean;
orgRootId: string;
orgShortname: string;
posMasterNo: number;
posMasterNoPrefix: string;
posMasterNoSuffix: string;
positions: Positions[];
}
interface Positions {
id: string;
posExecutiveId: string;
posExecutiveName: string;
posLevelId: string;
posLevelName: string;
posTypeId: string;
posTypeName: string;
positionArea: string;
positionExecutiveField: string;
positionField: string;
positionIsSelected: boolean;
positionName: string;
}
interface DataPositionNo {
id: string;
isPosition: boolean;
posMasterNo: string;
positionName: string;
posTypeName: string;
posLevelName: string;
positionIsSelected: string | null;
isSit: boolean;
positions: Positions[];
}
interface TreeMain {
children: TreeMain[]; // ปรับเป็นชนิดข้อมูลที่ถูกต้องตามโครงสร้างของ children ถ้าเป็นไปได้
orgCode: string;
orgLevel: number;
orgName: string;
orgRevisionId: string;
orgRootName: string;
orgTreeCode: string;
orgTreeFax: string;
orgTreeId: string;
orgTreeName: string;
orgTreeOrder: number;
orgTreePhoneEx: string;
orgTreePhoneIn: string;
orgTreeRank: string;
orgTreeShortName: string;
totalPosition: number;
totalPositionCurrentUse: number;
totalPositionCurrentVacant: number;
totalPositionNextUse: number;
totalPositionNextVacant: number;
totalRootPosition: number;
totalRootPositionCurrentUse: number;
totalRootPositionCurrentVacant: number;
totalRootPositionNextUse: number;
totalRootPositionNextVacant: number;
}
export type {
ResponseTitle,
ResponseData,
ResponseRow,
DataActive,
OrgTree,
DataTree,
SumPosition,
PositionMaim,
PositionNo,
Positions,
DataPositionNo,
TreeMain,
};