2023-06-12 20:47:54 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<a-layout class="layout">
|
|
|
|
|
|
<div class="navbar layout-navbar">
|
2023-06-15 20:13:46 +08:00
|
|
|
|
<NavBar :title="projectInfo.name" />
|
2023-06-12 20:47:54 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<a-layout class="layout">
|
|
|
|
|
|
<a-layout class="layout layout-demo">
|
|
|
|
|
|
<a-layout-sider class="layout-sider">
|
|
|
|
|
|
<div class="p-2">
|
|
|
|
|
|
<a-input-group class="mb-2 w-full flex items-center" size="mini">
|
2023-06-19 19:51:12 +08:00
|
|
|
|
<a-input style="height: 32px" v-model="searchKey" allow-clear></a-input>
|
|
|
|
|
|
<a-button @click="handleSearchTreeDataClick">搜索</a-button>
|
2023-06-12 20:47:54 +08:00
|
|
|
|
</a-input-group>
|
2023-06-15 20:13:46 +08:00
|
|
|
|
<a-input-group class="mb-2 w-full flex items-center justify-between" size="mini">
|
|
|
|
|
|
<a-button class="w-1/2" type="primary">增加轮次</a-button>
|
|
|
|
|
|
<a-button class="w-1/2" type="primary" status="danger">删除轮次</a-button>
|
|
|
|
|
|
</a-input-group>
|
2023-06-12 20:47:54 +08:00
|
|
|
|
<a-tree
|
|
|
|
|
|
:data="treeData"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
block-node
|
|
|
|
|
|
animation
|
|
|
|
|
|
@select="pointNode"
|
|
|
|
|
|
:load-more="loadMore"
|
|
|
|
|
|
showLine
|
|
|
|
|
|
ref="treeRef"
|
2023-06-16 19:30:36 +08:00
|
|
|
|
border
|
2023-06-19 19:51:12 +08:00
|
|
|
|
:default-selected-keys="[currentNode ? currentNode : route.query.key]"
|
2023-06-12 20:47:54 +08:00
|
|
|
|
></a-tree>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</a-layout-sider>
|
2023-06-15 20:13:46 +08:00
|
|
|
|
<a-layout class="layout-content">
|
|
|
|
|
|
<a-layout-content class="work-area project-layout">
|
|
|
|
|
|
<PageLayout />
|
|
|
|
|
|
</a-layout-content>
|
|
|
|
|
|
</a-layout>
|
2023-06-12 20:47:54 +08:00
|
|
|
|
</a-layout>
|
|
|
|
|
|
</a-layout>
|
|
|
|
|
|
</a-layout>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
|
import { provide, ref, onMounted } from "vue"
|
|
|
|
|
|
import NavBar from "@/layout/components/navbar.vue"
|
|
|
|
|
|
import PageLayout from "@/layout/page-layout.vue"
|
|
|
|
|
|
import projectApi from "@/api/project/project"
|
|
|
|
|
|
import { useRoute } from "vue-router"
|
2023-06-15 20:13:46 +08:00
|
|
|
|
import { useRouter } from "vue-router"
|
2023-06-19 19:51:12 +08:00
|
|
|
|
import { useTreeDataStore } from "@/store"
|
|
|
|
|
|
import { storeToRefs } from "pinia"
|
2023-06-12 20:47:54 +08:00
|
|
|
|
// 缩小后的menu菜单
|
|
|
|
|
|
const drawerVisible = ref(false)
|
|
|
|
|
|
provide("toggleDrawerMenu", () => {
|
|
|
|
|
|
drawerVisible.value = !drawerVisible.value
|
|
|
|
|
|
})
|
2023-06-19 19:51:12 +08:00
|
|
|
|
// 搜索绑定与搜索按钮点击
|
|
|
|
|
|
const searchKey = ref("")
|
|
|
|
|
|
const handleSearchTreeDataClick = () => {
|
|
|
|
|
|
const loop = (itemdata) => {
|
|
|
|
|
|
const result = []
|
|
|
|
|
|
itemdata.forEach((item) => {
|
|
|
|
|
|
if (item.title.indexOf(searchKey.value) > -1) {
|
|
|
|
|
|
result.push({ ...item })
|
|
|
|
|
|
} else if (item.children) {
|
|
|
|
|
|
const filterdata = loop(item.children)
|
|
|
|
|
|
if (filterdata.length) {
|
|
|
|
|
|
result.push({
|
|
|
|
|
|
...item,
|
|
|
|
|
|
children: filterdata
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
return result
|
|
|
|
|
|
}
|
|
|
|
|
|
// 返回过滤后的treeData
|
|
|
|
|
|
// treeDataStore.originTreeData
|
|
|
|
|
|
if (searchKey.value) {
|
|
|
|
|
|
treeData.value = loop(treeDataStore.treeData)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
treeData.value = treeDataStore.originTreeData
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-06-12 20:47:54 +08:00
|
|
|
|
// 树状
|
|
|
|
|
|
/// 初始化round轮次数据
|
2023-06-19 19:51:12 +08:00
|
|
|
|
const treeDataStore = useTreeDataStore()
|
2023-06-12 20:47:54 +08:00
|
|
|
|
const route = useRoute()
|
2023-06-15 20:13:46 +08:00
|
|
|
|
const router = useRouter()
|
2023-06-12 20:47:54 +08:00
|
|
|
|
const treeRef = ref()
|
2023-06-19 19:51:12 +08:00
|
|
|
|
const { treeData, currentNode } = storeToRefs(treeDataStore)
|
2023-06-15 20:13:46 +08:00
|
|
|
|
const projectInfo = ref({ ...route.query })
|
|
|
|
|
|
const projectId = ref(route.query.projectId)
|
2023-06-12 20:47:54 +08:00
|
|
|
|
onMounted(async () => {
|
2023-06-19 19:51:12 +08:00
|
|
|
|
treeDataStore.initTreeData(projectId)
|
2023-06-12 20:47:54 +08:00
|
|
|
|
})
|
2023-06-15 20:13:46 +08:00
|
|
|
|
/// 点击树状节点-参数1:节点数组,参数2:树node对象
|
2023-06-12 20:47:54 +08:00
|
|
|
|
const pointNode = (value, data) => {
|
2023-06-19 19:51:12 +08:00
|
|
|
|
console.log(data.node);
|
2023-06-15 20:13:46 +08:00
|
|
|
|
if (data.node.level === "0") {
|
|
|
|
|
|
router.push({ name: "round", query: { ...projectInfo.value, key: data.node.key } })
|
|
|
|
|
|
}
|
|
|
|
|
|
if (data.node.level === "1") {
|
2023-06-19 19:51:12 +08:00
|
|
|
|
router.push({ name: "dut", query: { ...projectInfo.value, key: data.node.key } })
|
2023-06-15 20:13:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (data.node.level === "2") {
|
2023-06-19 19:51:12 +08:00
|
|
|
|
router.push({ name: "designDemand", query: { ...projectInfo.value, key: data.node.key } })
|
2023-06-15 20:13:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (data.node.level === "3") {
|
2023-06-19 19:51:12 +08:00
|
|
|
|
router.push({ name: "testDemand", query: { ...projectInfo.value, key: data.node.key } })
|
2023-06-15 20:13:46 +08:00
|
|
|
|
}
|
2023-06-16 19:30:36 +08:00
|
|
|
|
if (data.node.level === "4") {
|
2023-06-19 19:51:12 +08:00
|
|
|
|
router.push({ name: "case", query: { ...projectInfo.value, key: data.node.key } })
|
|
|
|
|
|
}
|
|
|
|
|
|
if (data.node.level === "5") {
|
2023-06-16 19:30:36 +08:00
|
|
|
|
router.push({ name: "problem", query: { ...projectInfo.value, key: data.node.key } })
|
|
|
|
|
|
}
|
2023-06-19 19:51:12 +08:00
|
|
|
|
treeDataStore.setCurrentNode(data.node.key)
|
2023-06-12 20:47:54 +08:00
|
|
|
|
}
|
2023-06-15 20:13:46 +08:00
|
|
|
|
/// 动态加载函数-参数1:树node对象
|
2023-06-12 20:47:54 +08:00
|
|
|
|
const loadMore = (nodeData) => {
|
|
|
|
|
|
console.log("动态加载的节点为:", nodeData) // 输出点击节点的key,以及添加上去的level属性
|
2023-06-15 20:13:46 +08:00
|
|
|
|
if (nodeData.level == "0") {
|
|
|
|
|
|
return new Promise(async (resolve) => {
|
2023-06-19 19:51:12 +08:00
|
|
|
|
const res = await projectApi.getDutInfo(projectInfo.value.id, nodeData.key, nodeData.level)
|
2023-06-15 20:13:46 +08:00
|
|
|
|
nodeData.children = res
|
|
|
|
|
|
resolve()
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2023-06-16 19:30:36 +08:00
|
|
|
|
if (nodeData.level == "1") {
|
2023-06-15 20:13:46 +08:00
|
|
|
|
return new Promise(async (resolve) => {
|
2023-06-19 19:51:12 +08:00
|
|
|
|
const res = await projectApi.getDemandInfo(projectInfo.value.id, nodeData.key, nodeData.level)
|
2023-06-15 20:13:46 +08:00
|
|
|
|
nodeData.children = res
|
|
|
|
|
|
resolve()
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2023-06-16 19:30:36 +08:00
|
|
|
|
if (nodeData.level == "2") {
|
2023-06-15 20:13:46 +08:00
|
|
|
|
return new Promise(async (resolve) => {
|
2023-06-19 19:51:12 +08:00
|
|
|
|
const res = await projectApi.getTestInfo(projectInfo.value.id, nodeData.key, nodeData.level)
|
2023-06-15 20:13:46 +08:00
|
|
|
|
nodeData.children = res
|
|
|
|
|
|
resolve()
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2023-06-16 19:30:36 +08:00
|
|
|
|
if (nodeData.level == "3") {
|
2023-06-19 19:51:12 +08:00
|
|
|
|
return new Promise(async (resolve) => {
|
|
|
|
|
|
const res = await projectApi.getCaseInfo(projectInfo.value.id, nodeData.key, nodeData.level)
|
|
|
|
|
|
nodeData.children = res
|
|
|
|
|
|
resolve()
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
if (nodeData.level == "4") {
|
2023-06-15 20:13:46 +08:00
|
|
|
|
return new Promise(async (resolve) => {
|
|
|
|
|
|
const res = await projectApi.getProblemInfo(projectInfo.value.id, nodeData.key, nodeData.level)
|
|
|
|
|
|
nodeData.children = res
|
|
|
|
|
|
resolve()
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2023-06-12 20:47:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
|
|
|
.tree {
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
}
|
2023-06-15 20:13:46 +08:00
|
|
|
|
.layout {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
}
|
2023-06-12 20:47:54 +08:00
|
|
|
|
.layout-demo :deep(.arco-layout-sider) {
|
|
|
|
|
|
width: 300px !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
.layout {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.layout-navbar {
|
|
|
|
|
|
position: fixed;
|
|
|
|
|
|
top: 0;
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
z-index: 100;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 60px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.layout-sider {
|
|
|
|
|
|
position: fixed;
|
|
|
|
|
|
top: 60px;
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
z-index: 99;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
transition: all 0.2s cubic-bezier(0.34, 0.69, 0.1, 1);
|
|
|
|
|
|
&::after {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
top: 0;
|
|
|
|
|
|
right: -1px;
|
|
|
|
|
|
display: block;
|
|
|
|
|
|
width: 1px;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
background-color: var(--color-border);
|
|
|
|
|
|
content: "";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
> :deep(.arco-layout-sider-children) {
|
|
|
|
|
|
overflow-y: hidden;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-06-15 20:13:46 +08:00
|
|
|
|
.layout-demo {
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
}
|
2023-06-12 20:47:54 +08:00
|
|
|
|
.layout-content {
|
2023-06-15 20:13:46 +08:00
|
|
|
|
position: absolute;
|
|
|
|
|
|
top: 60px;
|
|
|
|
|
|
left: 300px;
|
2023-06-12 20:47:54 +08:00
|
|
|
|
min-height: 100vh;
|
2023-06-15 20:13:46 +08:00
|
|
|
|
width: 100% - 300px;
|
2023-06-12 20:47:54 +08:00
|
|
|
|
overflow-y: auto;
|
|
|
|
|
|
background-color: var(--color-fill-2);
|
|
|
|
|
|
transition: padding 0.2s cubic-bezier(0.34, 0.69, 0.1, 1);
|
2023-06-15 20:13:46 +08:00
|
|
|
|
position: absolute;
|
2023-06-12 20:47:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
</style>
|