2024-10-10 17:47:55 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="plan_tree">
|
2024-11-13 18:58:53 +08:00
|
|
|
<!-- <div class="search_view">
|
2024-10-10 17:47:55 +08:00
|
|
|
<el-input
|
|
|
|
|
placeholder="请输入计划名称"
|
|
|
|
|
v-model="searchForm.planName"
|
|
|
|
|
></el-input>
|
2024-11-13 18:58:53 +08:00
|
|
|
</div> -->
|
2024-10-10 17:47:55 +08:00
|
|
|
<div class="tree_container">
|
|
|
|
|
<el-tree
|
|
|
|
|
:data="data"
|
|
|
|
|
ref="treeRef"
|
|
|
|
|
:filter-node-method="filterNode"
|
|
|
|
|
:props="defaultProps"
|
|
|
|
|
node-key="id"
|
|
|
|
|
default-expand-all
|
|
|
|
|
:default-checked-keys="defaultChecked"
|
|
|
|
|
@node-click="handleNodeClick"
|
|
|
|
|
@check-change="changeSelect"
|
|
|
|
|
>
|
2024-11-13 18:58:53 +08:00
|
|
|
<!-- scriptIdx -->
|
2024-10-10 17:47:55 +08:00
|
|
|
<template #default="{ node, data }">
|
|
|
|
|
<span
|
|
|
|
|
class="custom-tree-node"
|
|
|
|
|
style="display: flex; align-items: center"
|
|
|
|
|
>
|
2025-03-17 15:55:30 +08:00
|
|
|
<CircleCheck v-if="data.isChildNode && data.scriptIdx < currentIndex" style="width:18px;height: 18px;margin-right:8px;color:#91cc75;"/>
|
2024-11-14 18:47:15 +08:00
|
|
|
|
|
|
|
|
<svg-icon v-if="data.isChildNode && data.scriptIdx === currentIndex" name="loading" spin ></svg-icon>
|
2024-10-10 17:47:55 +08:00
|
|
|
<span>{{ node.label }}</span>
|
|
|
|
|
</span>
|
|
|
|
|
</template>
|
|
|
|
|
</el-tree>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
import { ref, onMounted, defineExpose, watch } from "vue";
|
2024-11-13 18:58:53 +08:00
|
|
|
import { Menu, Platform, CircleCheck,Loading } from "@element-plus/icons-vue";
|
2024-10-10 17:47:55 +08:00
|
|
|
const emit = defineEmits(["jump"]);
|
|
|
|
|
const data: any = ref([]);
|
|
|
|
|
const defaultProps = {
|
|
|
|
|
children: "children",
|
|
|
|
|
label: "name",
|
|
|
|
|
pid: "pid",
|
|
|
|
|
};
|
|
|
|
|
const searchForm = ref({
|
|
|
|
|
planName: "",
|
|
|
|
|
});
|
|
|
|
|
const defaultChecked: any = ref([]);
|
|
|
|
|
const treeList: any = ref([]);
|
|
|
|
|
const getTreeData = (val: any) => {
|
|
|
|
|
defaultChecked.value = [];
|
|
|
|
|
data.value = val;
|
2024-11-14 18:40:58 +08:00
|
|
|
|
|
|
|
|
if(data.value[0].children[0].hasOwnProperty("children"))
|
|
|
|
|
{
|
|
|
|
|
defaultChecked.value.push(data.value[0].children[0].children[0].id);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
defaultChecked.value.push(data.value[0].children[0].id);
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-10 17:47:55 +08:00
|
|
|
treeRef.value.setCurrentKey(defaultChecked.value);
|
|
|
|
|
};
|
2024-11-15 09:34:43 +08:00
|
|
|
|
|
|
|
|
const getCurrentIndex = (val: number) => {
|
|
|
|
|
currentIndex.value = val;
|
|
|
|
|
};
|
2024-10-10 17:47:55 +08:00
|
|
|
const filterText = ref("");
|
|
|
|
|
const treeRef = ref();
|
2024-11-13 18:58:53 +08:00
|
|
|
const currentIndex = ref(0);
|
|
|
|
|
|
2024-11-15 09:34:43 +08:00
|
|
|
// const timer = setInterval(() => {
|
|
|
|
|
// currentIndex.value++;
|
|
|
|
|
// if (currentIndex.value > 14)
|
|
|
|
|
// currentIndex.value = 0;
|
|
|
|
|
// // console.log(currentIndex.value);
|
2024-11-13 18:58:53 +08:00
|
|
|
|
2024-11-15 09:34:43 +08:00
|
|
|
// }, 2000);
|
2024-11-13 18:58:53 +08:00
|
|
|
|
|
|
|
|
|
2024-10-10 17:47:55 +08:00
|
|
|
watch(
|
|
|
|
|
() => searchForm.value.planName,
|
|
|
|
|
(val) => {
|
|
|
|
|
treeRef.value!.filter(val);
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
deep: true,
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
const changeSelect=()=>{
|
2024-11-14 18:26:34 +08:00
|
|
|
//console.log(treeRef.value.getCheckedKeys());
|
2024-10-10 17:47:55 +08:00
|
|
|
}
|
|
|
|
|
const handleNodeClick = (data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
};
|
|
|
|
|
const filterNode = (value: string, data) => {
|
|
|
|
|
if (!value) return true;
|
|
|
|
|
return data.name.includes(value);
|
|
|
|
|
};
|
|
|
|
|
// 点击详情
|
|
|
|
|
const detail = (e: any) => {
|
|
|
|
|
emit("jump", e);
|
|
|
|
|
};
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
console.log();
|
|
|
|
|
});
|
2024-11-15 09:34:43 +08:00
|
|
|
defineExpose({ getTreeData,getCurrentIndex });
|
2024-10-10 17:47:55 +08:00
|
|
|
</script>
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.plan_tree {
|
|
|
|
|
// width: 200px;
|
|
|
|
|
height: 100%;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
padding: 5px;
|
|
|
|
|
// height: calc(100% - 70px);
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
.search_view {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: auto;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
padding: 0 5px;
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
align-items: center;
|
|
|
|
|
.el-input {
|
|
|
|
|
margin-top: 6px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.el-input {
|
|
|
|
|
width: 100%;
|
|
|
|
|
// margin: 0 10px 10px 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.tree_container {
|
|
|
|
|
flex: 1;
|
|
|
|
|
height: 100%;
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
|
|
|
|
|
.el-tree {
|
|
|
|
|
height: 100%;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|