Files
cdTestPlant3/cdTMP/src/layout/project-layout.vue

472 lines
20 KiB
Vue
Raw Normal View History

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">
2023-07-21 16:08:08 +08:00
<div class="p-2 overflow-auto myhcalc">
2025-02-04 16:39:06 +08:00
<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>
2025-02-04 16:39:06 +08:00
<div class="flex justify-between mb-2">
<a-button type="primary" @click="toggleExpanded" class="w-5/12">
{{ expandedKeys?.length ? "全部收缩" : "全部展开" }}
2024-04-02 18:44:26 +08:00
</a-button>
2025-02-04 16:39:06 +08:00
<a-popconfirm type="warning" @ok="handleCopyNode" content="是否确定根据选中节点进行创建?">
<a-button type="outline" status="warning">
<template #icon> <icon-plus /></template>点击复制创建轮次
</a-button>
</a-popconfirm>
</div>
2023-06-12 20:47:54 +08:00
<a-tree
2024-05-31 18:29:29 +08:00
class="h-10/12 select-none my-arco-wrap-class"
2023-06-12 20:47:54 +08:00
:data="treeData"
2024-05-11 18:11:56 +08:00
size="mini"
2024-06-04 18:56:45 +08:00
showLine
2024-03-29 19:03:35 +08:00
checkable
2023-06-12 20:47:54 +08:00
block-node
2024-05-11 18:11:56 +08:00
draggable
2023-06-12 20:47:54 +08:00
animation
2024-05-11 18:11:56 +08:00
auto-expand-parent
2023-06-12 20:47:54 +08:00
@select="pointNode"
2024-05-11 18:11:56 +08:00
@drop="ondrop"
:allow-drop="allowdrop"
2023-06-12 20:47:54 +08:00
:load-more="loadMore"
2023-08-21 19:57:49 +08:00
v-model:expanded-keys="expandedKeys"
2023-08-25 13:28:24 +08:00
v-model:selected-keys="selectedKeys"
2024-03-29 19:03:35 +08:00
v-model:checked-keys="checkedKeys"
2023-06-12 20:47:54 +08:00
ref="treeRef"
2023-06-16 19:30:36 +08:00
border
2024-05-11 18:11:56 +08:00
@contextmenu="displayRightMenu"
2023-06-19 19:51:12 +08:00
:default-selected-keys="[currentNode ? currentNode : route.query.key]"
2023-06-20 18:09:30 +08:00
>
<!-- 在轮次节点可以新增编辑删除复制 -->
<template #extra="nodeData">
<template v-if="nodeData.level === '0'">
<a-tooltip content="点击新增轮次">
<IconPlus
style="position: absolute; right: 8px; font-size: 12px; top: 8px; color: #3370ff"
2023-06-20 18:09:30 +08:00
@click="() => handleRoundAddClick(nodeData)"
/>
</a-tooltip>
2023-06-28 21:02:31 +08:00
<a-tooltip content="点击删除轮次">
<a-popconfirm content="确定要删除该轮次吗?" position="bottom" @ok="handleRoundDelClick(nodeData)">
<icon-close style="position: absolute; right: 25px; font-size: 12px; top: 8px; color: #3370ff" />
2023-06-28 21:02:31 +08:00
</a-popconfirm>
</a-tooltip>
2023-06-20 18:09:30 +08:00
<a-tooltip content="点击编辑当前轮次"
><IconEdit
style="position: absolute; right: 42px; font-size: 12px; top: 8px; color: #3370ff"
2023-06-20 18:09:30 +08:00
@click="() => handleRoundEditClick(nodeData)"
/></a-tooltip>
2025-05-10 19:21:50 +08:00
<a-tooltip content="综合阅览该轮次下问题单"
><icon-bug
style="position: absolute; right: 60px; font-size: 12px; top: 8px; color: #3370ff"
2025-05-10 19:21:50 +08:00
@click="handleProblemShowClick"
/></a-tooltip>
<a-tooltip content="轮次数据管理视图"
><icon-storage
style="position: absolute; right: 77px; font-size: 12px; top: 8px; color: #3370ff"
2025-05-15 18:54:14 +08:00
:style="{
color: isOpeSetsRoute && nodeData.key === route.query.key ? 'red' : '#3370ff'
2025-05-15 18:54:14 +08:00
}"
2025-05-10 19:21:50 +08:00
@click="
() => {
router.push({
name: 'opeSets',
query: {
...route.query,
key: nodeData.key
}
})
}
"
/></a-tooltip>
2023-06-20 18:09:30 +08:00
</template>
</template>
2024-05-11 18:11:56 +08:00
<!-- 设计节点的图标 -->
<template #switcher-icon="_, { isLeaf }">
<div class="font-icon">
<IconDownCircle v-if="!isLeaf" />
<IconFile v-if="isLeaf" />
</div>
2024-05-11 18:11:56 +08:00
</template>
2023-08-09 16:30:05 +08:00
<!-- 节点图标插槽 -->
<template #icon="props">
<template v-if="props.node.level === '1'"> <span style="white-space: nowrap">[被测件]</span> </template>
2023-08-15 17:15:52 +08:00
<template v-if="props.node.level === '2'"> [] </template>
<template v-if="props.node.level === '3'"> [] </template>
2024-06-07 18:03:11 +08:00
<template v-if="props.node.level === '4'">
<template v-if="props.node.isRelatedProblem">
<a-tooltip content="有问题单关联">
<button>[@]</button>
</a-tooltip>
</template>
<template v-else>
<template v-if="props.node.isNotPassed">
<a-tooltip content="该用例未通过,但是未关联问题单,请关联">
<button :style="{ color: 'red' }">[×]</button>
</a-tooltip>
</template>
<template v-else>
<a-tooltip content="该用例未执行或已通过,未关联问题单">
<button>[>]</button>
</a-tooltip>
</template>
</template>
</template>
2023-08-09 16:30:05 +08:00
</template>
2025-12-19 18:08:59 +08:00
<!-- 节点title插槽 -->
<template #title="{ level, title }">
<template v-if="level === '0' || level === '3'">
{{ title }}
<span class="small-right-context-tip">
<i>右键</i>
</span>
</template>
<template v-else>{{ title }}</template>
</template>
2023-06-20 18:09:30 +08:00
</a-tree>
2023-06-12 20:47:54 +08:00
</div>
</a-layout-sider>
2024-06-21 17:30:55 +08:00
<a-layout class="layout-content myhcalc my-custom">
2025-05-10 19:21:50 +08:00
<!-- 右侧界面是该元素决定滚动条overflow-y:auto -->
<a-layout-content class="work-area project-layout" id="basic-scroll-container">
2024-05-11 18:11:56 +08:00
<PageLayout ref="routeViewRef" />
2023-06-15 20:13:46 +08:00
</a-layout-content>
</a-layout>
2023-06-12 20:47:54 +08:00
</a-layout>
</a-layout>
</a-layout>
2025-05-10 19:21:50 +08:00
<a-back-top target-container="#basic-scroll-container" :style="{ position: 'absolute' }">
<a-popover title="回到顶部">
<a-button type="primary" shape="circle">
<template #icon>
<icon-arrow-rise />
</template>
</a-button>
</a-popover>
</a-back-top>
<ma-form-modal ref="maFormModalRef" :title="title" :column="roundColumn" :options="roundOption" :width="800" :submit="handleRoundSubmit"> </ma-form-modal>
2024-03-29 19:03:35 +08:00
<!-- 如果没有第一轮的SO_dut则弹窗 -->
<ma-form-modal
ref="soDutFormRef"
2024-05-16 18:44:00 +08:00
:title="soDutModalTitle"
2024-03-29 19:03:35 +08:00
:column="soDutColumn"
2024-09-06 10:48:22 +08:00
:width="800"
2024-03-29 19:03:35 +08:00
:submit="handleSoDutSubmit"
2024-09-06 10:48:22 +08:00
@cancel="handleSoDutCancel"
2024-06-13 19:41:57 +08:00
cancelText="返回项目页面"
:cancel-button-props="{ status: 'warning' }"
:closable="false"
:mask-closable="false"
>
2024-09-06 10:48:22 +08:00
<!-- 添加input前缀 -->
<template #inputPrepend-version> V </template>
2024-06-13 19:41:57 +08:00
</ma-form-modal>
<Progress :visible="visible" :isComplete="isComplete" :text="ptext" @clickConfirm="handleModalConfirmClick"></Progress>
2024-05-11 18:11:56 +08:00
<!-- 右键菜单 -->
<a-dropdown v-model:popup-visible="popupVisible" :popup-container="popupContainer" position="bottom" alignPoint :style="{ display: 'block' }">
2024-05-11 18:11:56 +08:00
<template #content>
<a-dgroup title="执行操作">
<a-doption @click="handleDoptionClickGreateCases">
<template #icon>
<icon-plus-circle />
</template>
根据测试子项生成所属用例
</a-doption>
</a-dgroup>
<a-dgroup title="复制">
<a-doption @click="handleDoptionClickCopyDemand">
<template #icon>
<icon-copy />
</template>
复制到设计需求下...
</a-doption>
</a-dgroup>
</template>
</a-dropdown>
<!-- 复制modal组件 -->
<!-- 关联的modal组件 -->
2025-05-17 18:04:53 +08:00
<a-modal v-model:visible="modalVisible" unmount-on-close :width="700" draggable :on-before-ok="handleCopyDemand">
2024-05-11 18:11:56 +08:00
<template #title>复制到设计需求</template>
<div class="pb-3">选择复制到的节点<span class="point">支持搜索</span>:</div>
2024-05-11 18:11:56 +08:00
<a-cascader
:options="options"
allow-search
allow-clear
size="large"
placeholder="复制到选择的设计需求节点下"
:loading="cascaderLoading"
v-model:model-value="relatedCopyData"
/>
<div class="mt-3"><a-checkbox v-model="checkboxValue">是否复制用例</a-checkbox></div>
</a-modal>
<!-- 拖拽用例气泡提示 -->
<a-popconfirm
v-model:popup-visible="paoVisible"
ok-text="移动"
cancel-text="复制"
@ok="paoOk"
@cancel="paoCancel"
:popup-container="paoContainer"
content="选择移动/复制"
>
</a-popconfirm>
<a-popconfirm
v-model:popup-visible="pao2Visible"
ok-text="移动"
cancel-text="复制"
@ok="paoOk2"
@cancel="paoCancel2"
:popup-container="pao2Container"
content="选择移动/复制"
>
</a-popconfirm>
2024-05-14 20:02:19 +08:00
<!-- w1:外部下拉选项组件 -->
<roundRight
:fvisible="roundRightVisible"
@update:visible="roundRightVisible = false"
:container="roundRightContainer"
@click-problem-show="handleProblemShowClick"
@create-renji="handleCreateRenji"
2024-05-14 20:02:19 +08:00
></roundRight>
<!-- w2:轮次的问题单ma-crud这里要传参2个首先是请求另外一个接口然后取消是否关联字段 -->
<problem-choose ref="problemRoundRef" hasRelated="roundProblem" :title="problemTitle"></problem-choose>
2024-12-26 17:53:50 +08:00
<!-- 下面都是对应被测件设计需求测试项测试用例问题单的SubForm -->
2024-12-30 09:50:38 +08:00
<DutSubForm ref="dutSubFormRef" />
<DesignSubForm ref="designSubFormRef" />
<TestDemandSubForm ref="testDemandSubFormRef" />
<CaseSubForm ref="caseSubFormRef" />
2023-06-12 20:47:54 +08:00
</template>
<script setup>
2025-05-15 18:54:14 +08:00
import { provide, ref, watch } from "vue"
2023-06-12 20:47:54 +08:00
import NavBar from "@/layout/components/navbar.vue"
import PageLayout from "@/layout/page-layout.vue"
2023-06-20 18:09:30 +08:00
import MaFormModal from "@/components/ma-form-modal/index.vue"
2024-05-14 20:02:19 +08:00
// 轮次的右键菜单,单独一个组件 -> 在treeComponents里面
import roundRight from "./treeComponents/roundRight.vue"
// 问题单ma-crud
import ProblemChoose from "@/views/project/case/components/ProblemChoose.vue"
2025-05-10 19:21:50 +08:00
import { useRoute, useRouter } from "vue-router"
2023-06-19 19:51:12 +08:00
import { useTreeDataStore } from "@/store"
import { storeToRefs } from "pinia"
2024-03-29 19:03:35 +08:00
import Progress from "@/views/testmanage/projmanage/cpns/progress.vue"
2024-12-26 17:53:50 +08:00
// 导入单独节点类型单独对应的Modal组件
import DutSubForm from "@/views/project/round/DutSubForm"
2024-12-30 09:50:38 +08:00
import DesignSubForm from "@/views/project/dut/DesignSubForm"
import TestDemandSubForm from "@/views/project/design-demand/DemandSubForm"
import CaseSubForm from "@/views/project/testDemand/CaseSubForm"
2024-08-09 19:31:36 +08:00
// hooks模块化
import useTreeDrag from "@/layout/treeHooks/treeDrag.js"
import { useRightClick } from "./treeHooks/rightClick"
import useNodeCopy from "./treeHooks/nodeCopy"
import useSearchNodes from "./treeHooks/searchNodes"
import useMustSoDut from "./treeHooks/mustSoDut"
import useNodeExpand from "./treeHooks/useNodeExpand"
import useNodeClick from "./treeHooks/useNodeClick"
import useLoadTreeNode from "./treeHooks/useLoadTreeNodes"
import useRoundMaForm from "./treeHooks/useRoundMaForm"
// router-view里面组件的ref -> 多个hook使用
2024-05-11 18:11:56 +08:00
const routeViewRef = ref()
2024-12-26 17:53:50 +08:00
provide("rightViewRef", routeViewRef)
2024-03-29 19:03:35 +08:00
const treeDataStore = useTreeDataStore()
2024-08-09 19:31:36 +08:00
const { treeData, currentNode } = storeToRefs(treeDataStore)
2024-03-29 19:03:35 +08:00
const route = useRoute()
2025-05-10 19:21:50 +08:00
const router = useRouter()
2024-03-29 19:03:35 +08:00
const treeRef = ref()
const projectInfo = ref({ ...route.query })
const projectId = ref(route.query.id)
2024-08-09 19:31:36 +08:00
//~~~~~~大模块:选择同一节点新建复制到下一轮~~~~~~
const { checkedKeys, visible, isComplete, ptext, handleCopyNode, handleModalConfirmClick } = useNodeCopy(projectId)
//~~~~~~providemenu缩小菜单~~~~~~
2023-06-12 20:47:54 +08:00
const drawerVisible = ref(false)
provide("toggleDrawerMenu", () => {
drawerVisible.value = !drawerVisible.value
})
2023-08-21 19:57:49 +08:00
2024-08-09 19:31:36 +08:00
//~~~~~~小功能:节点搜索功能~~~~~~
const { searchKey, handleSearchTreeDataClick } = useSearchNodes()
2024-05-11 18:11:56 +08:00
2024-08-09 19:31:36 +08:00
//~~~~~~M功能强制必须有源代码被测件~~~~~~
const { soDutFormRef, soDutModalTitle, handleSoDutExistsForceModal, handleSoDutSubmit, handleSoDutCancel, soDutColumn } = useMustSoDut(projectId)
2024-05-11 18:11:56 +08:00
2024-08-09 19:31:36 +08:00
//~~~~~~小功能:展开和收缩~~~~~~
const { expandedKeys, toggleExpanded } = useNodeExpand()
2024-05-11 18:11:56 +08:00
2024-08-09 19:31:36 +08:00
//~~~~~~大功能:单击/双击节点逻辑~~~~~~
const { selectedKeys, pointNode, dutSubFormRef, designSubFormRef, testDemandSubFormRef, caseSubFormRef } = useNodeClick(expandedKeys)
2024-08-09 19:31:36 +08:00
2025-05-15 18:54:14 +08:00
//~~~~~~小功能路由中key绑定selectedKeys好像有点非性能~~~~~~
const isOpeSetsRoute = ref(false)
watch(
() => route,
(newRoute) => {
isOpeSetsRoute.value = newRoute.matched.some((it) => it.name === "opeSets")
if (isOpeSetsRoute.value) {
selectedKeys.value = []
} else {
selectedKeys.value = [newRoute.query.key]
}
},
{ immediate: true, deep: true }
)
2024-08-09 19:31:36 +08:00
//~~~~~~大功能动态加载a-tree节点函数~~~~~~
const { loadMore } = useLoadTreeNode()
//~~~~~~功能轮次的Ma-Form~~~~~~
const { maFormModalRef, title, roundColumn, roundOption, handleRoundAddClick, handleRoundEditClick, handleRoundDelClick, handleRoundSubmit } = useRoundMaForm(
projectId,
handleSoDutExistsForceModal
)
2024-08-09 19:31:36 +08:00
// 大功能:~~~~~~右键菜单实现~~~~~~
const {
popupVisible,
popupContainer,
roundRightVisible,
roundRightContainer,
problemRoundRef,
options,
modalVisible,
relatedCopyData,
cascaderLoading,
problemTitle,
checkboxValue,
displayRightMenu,
handleProblemShowClick,
handleDoptionClickGreateCases,
handleDoptionClickCopyDemand,
handleCopyDemand,
handleCreateRenji
2024-08-09 19:31:36 +08:00
} = useRightClick(projectId, routeViewRef)
// ~~~~~~~~大功能:拖拽~~~~~~~~
const { paoVisible, paoContainer, pao2Visible, pao2Container, ondrop, allowdrop, paoOk, paoCancel, paoOk2, paoCancel2 } = useTreeDrag(projectId, routeViewRef)
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
}
2023-07-21 16:08:08 +08:00
.myhcalc {
height: calc(100% - 60px);
}
2024-06-21 17:30:55 +08:00
// 这里容易出错注意
.my-custom {
width: calc(100% - 300px);
}
2024-05-31 18:29:29 +08:00
.my-arco-wrap-class :deep(.arco-tree-node-title-text) {
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
2024-06-04 18:56:45 +08:00
.chen-node-title {
cursor: help;
}
.point {
color: red;
}
2025-05-15 18:54:14 +08:00
// 自定义选中节点样式
:deep(.arco-tree-node-selected) {
.arco-tree-node-title {
2025-05-17 18:04:53 +08:00
color: #f53f3f !important;
2025-05-15 18:54:14 +08:00
}
}
.font-icon {
font-size: 20px;
2025-12-19 18:08:59 +08:00
margin-bottom: -2.8px;
}
.font-icon:hover {
color: #f53f3fed;
transition: all 0.3s;
}
2025-12-19 18:08:59 +08:00
// 有右键菜单节点显示图标
.small-right-context-tip {
align-items: center;
background: linear-gradient(54.58deg, rgba(74, 228, 255, 0.12) -14.12%, rgba(66, 130, 255, 0.12) 47.61%, rgba(215, 104, 255, 0.12) 105.84%);
border: 1px solid #d5d7f9;
border-radius: 10px;
color: transparent;
display: inline-flex;
height: 10px;
justify-content: center;
margin-left: 2px;
padding: 0 2.5px;
position: absolute;
top: 7px;
i {
-webkit-text-fill-color: transparent !important;
zoom: 0.7;
background: linear-gradient(85.2deg, #0062ff -3.15%, #cb50ff 98.89%) !important;
background-clip: text !important;
-webkit-background-clip: text !important;
font-size: 10px;
font-style: normal;
}
}
2023-06-12 20:47:54 +08:00
</style>