2025-05-14 19:57:11 +08:00
|
|
|
|
<script lang="tsx">
|
2025-05-15 18:54:14 +08:00
|
|
|
|
import { defineComponent, Teleport } from "vue"
|
2025-05-14 19:57:11 +08:00
|
|
|
|
import { useRoute } from "vue-router"
|
|
|
|
|
|
import { Popover } from "@arco-design/web-vue"
|
|
|
|
|
|
// 请求的API
|
|
|
|
|
|
import dutApi from "@/api/project/dut"
|
|
|
|
|
|
import designApi from "@/api/project/designDemand"
|
|
|
|
|
|
import demandApi from "@/api/project/testDemand"
|
2025-05-15 18:54:14 +08:00
|
|
|
|
// hooks
|
|
|
|
|
|
import useHoverText from "./useHoverText"
|
|
|
|
|
|
import useKeyToMaInfo from "./useKeyToMaInfo"
|
2025-05-14 19:57:11 +08:00
|
|
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
|
|
name: "ParentPreview",
|
|
|
|
|
|
props: {
|
|
|
|
|
|
parentKey: { type: String, default: "" } // 在ma-form已经判断所以必然有值,索引上级key
|
|
|
|
|
|
},
|
|
|
|
|
|
setup(props) {
|
2025-05-15 18:54:14 +08:00
|
|
|
|
// 1.获取路由上的-项目id
|
2025-05-14 19:57:11 +08:00
|
|
|
|
const route = useRoute()
|
|
|
|
|
|
const project_id = route.query.id // 项目id
|
2025-05-15 18:54:14 +08:00
|
|
|
|
// 2.获取传入的key信息,给上级节点
|
2025-05-14 19:57:11 +08:00
|
|
|
|
const keyLength = props.parentKey.split("-").length
|
2025-05-15 18:54:14 +08:00
|
|
|
|
// 3.hover变化按钮hook
|
|
|
|
|
|
const { hoverText, buttonLikeRef, onMouseenter, onMouseleave } = useHoverText()
|
|
|
|
|
|
// 4.里面处理不同columns,返回的函数可以对ma-info的DOM进行构建
|
|
|
|
|
|
const { maInfoDom, fetchNodeDataAndSetMaInfo } = useKeyToMaInfo()
|
|
|
|
|
|
// 5.根据不同长度
|
2025-05-14 19:57:11 +08:00
|
|
|
|
switch (keyLength) {
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
// 请求设计需求节点
|
2025-05-15 18:54:14 +08:00
|
|
|
|
fetchNodeDataAndSetMaInfo(dutApi.getDutOne({ project_id, key: props.parentKey }), "dut")
|
2025-05-14 19:57:11 +08:00
|
|
|
|
break
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
// 请求测试项节点
|
2025-05-15 18:54:14 +08:00
|
|
|
|
fetchNodeDataAndSetMaInfo(designApi.getDesignDemandOne({ project_id, key: props.parentKey }), "design")
|
2025-05-14 19:57:11 +08:00
|
|
|
|
break
|
|
|
|
|
|
case 4:
|
|
|
|
|
|
// 请求用例节点
|
2025-05-15 18:54:14 +08:00
|
|
|
|
fetchNodeDataAndSetMaInfo(demandApi.getTestDemandOne({ project_id, key: props.parentKey }), "demand")
|
2025-05-14 19:57:11 +08:00
|
|
|
|
break
|
|
|
|
|
|
default:
|
|
|
|
|
|
break
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return () => (
|
|
|
|
|
|
<Teleport to="body">
|
|
|
|
|
|
<Popover trigger="click" position="left">
|
|
|
|
|
|
{{
|
|
|
|
|
|
default: () => (
|
|
|
|
|
|
<div class="preview-container">
|
|
|
|
|
|
<div
|
|
|
|
|
|
class="button-like"
|
|
|
|
|
|
ref={buttonLikeRef}
|
|
|
|
|
|
onMouseenter={onMouseenter}
|
|
|
|
|
|
onMouseleave={onMouseleave}
|
|
|
|
|
|
>
|
|
|
|
|
|
<icon-find-replace />
|
|
|
|
|
|
{hoverText.value && <span class="ml-2">{hoverText.value}</span>}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
),
|
|
|
|
|
|
content: () => (
|
2025-05-15 18:54:14 +08:00
|
|
|
|
// 内容插槽
|
2025-05-14 19:57:11 +08:00
|
|
|
|
<div
|
|
|
|
|
|
style={{
|
|
|
|
|
|
width: "600px"
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
2025-05-15 18:54:14 +08:00
|
|
|
|
{maInfoDom.value}
|
2025-05-14 19:57:11 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
)
|
|
|
|
|
|
}}
|
|
|
|
|
|
</Popover>
|
|
|
|
|
|
</Teleport>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped lang="less">
|
|
|
|
|
|
.preview-container {
|
|
|
|
|
|
position: fixed;
|
|
|
|
|
|
right: 80px;
|
|
|
|
|
|
top: 45%;
|
|
|
|
|
|
z-index: 10000;
|
|
|
|
|
|
}
|
|
|
|
|
|
.button-like {
|
|
|
|
|
|
width: 40px;
|
|
|
|
|
|
height: 40px;
|
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
user-select: none;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.8);
|
|
|
|
|
|
transition: all 0.1s;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
span {
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
.button-like:hover {
|
|
|
|
|
|
width: 120px;
|
|
|
|
|
|
border-radius: 22px;
|
2025-05-15 18:54:14 +08:00
|
|
|
|
transition: all 0.1s;
|
|
|
|
|
|
border: 1px solid rgb(64, 128, 255);
|
|
|
|
|
|
color: rgb(64, 128, 255);
|
2025-05-14 19:57:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
.click-content {
|
|
|
|
|
|
min-width: 500px;
|
|
|
|
|
|
min-height: 300px;
|
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|