filter ตำแหน่งว่าง
This commit is contained in:
parent
5bfdd3cc2a
commit
6fab70b99b
2 changed files with 37 additions and 4 deletions
|
|
@ -17,6 +17,7 @@ const noData = ref<string>("ไม่พบข้อมูลผังโคร
|
|||
const checkValidate = ref<boolean>(false);
|
||||
const myFormPosition = ref<any>();
|
||||
const selected = ref<string>("");
|
||||
const selectedFile = ref<string>("");
|
||||
|
||||
// Set form field
|
||||
let dataForm = reactive({
|
||||
|
|
@ -33,18 +34,37 @@ let dataForm = reactive({
|
|||
positionSalaryAmount: null,
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
loadTreeData();
|
||||
fetchplacementPosition();
|
||||
onMounted(async () => {
|
||||
await fetchPublishFile();
|
||||
await loadTreeData();
|
||||
await fetchplacementPosition();
|
||||
});
|
||||
const fetchPublishFile = async () => {
|
||||
await http
|
||||
.get(config.API.getPublishFileHistory)
|
||||
.then((res) => {
|
||||
let data = res.data.result;
|
||||
selectedFile.value = data[0].fileName;
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {
|
||||
hideLoader();
|
||||
});
|
||||
};
|
||||
|
||||
// โหลดข้อมูลโครงสร้างจาก json
|
||||
const treeData = ref<Array<any>>([]);
|
||||
const loadTreeData = async () => {
|
||||
await http
|
||||
.get(config.API.orgTree)
|
||||
.get(`${config.s3ClusterUrl}${selectedFile.value}`)
|
||||
.then((res: any) => {
|
||||
treeData.value = res.data;
|
||||
|
||||
// Filter objects with "name" null
|
||||
const filteredData = res.data.filter(filterByPersonIdNull);
|
||||
treeData.value = filteredData;
|
||||
})
|
||||
.catch((e: any) => {
|
||||
messageError($q, e);
|
||||
|
|
@ -53,6 +73,18 @@ const loadTreeData = async () => {
|
|||
hideLoader();
|
||||
});
|
||||
};
|
||||
|
||||
function filterByPersonIdNull(obj: any) {
|
||||
if (obj.name === null) {
|
||||
return true;
|
||||
}
|
||||
if (obj.children && obj.children.length > 0) {
|
||||
obj.children = obj.children.filter(filterByPersonIdNull);
|
||||
return obj.children.length > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// โหลด position
|
||||
const placementPosition = ref<any>([]);
|
||||
const fetchplacementPosition = async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue