解决面包屑key重复

This commit is contained in:
chenjianxing 2020-05-14 10:09:04 +08:00
parent 8c286795f7
commit d569ef8582
6 changed files with 26 additions and 26 deletions

View File

@ -23,8 +23,8 @@
<el-main class="test-case-list"> <el-main class="test-case-list">
<test-case-list <test-case-list
:current-project="currentProject" :current-project="currentProject"
:selectNodeIds="selectNodeIds" :select-node-ids="selectNodeIds"
:selectNodeNames="selectNodeNames" :select-parent-nodes="selectParentNodes"
@testCaseEdit="editTestCase" @testCaseEdit="editTestCase"
@testCaseCopy="copyTestCase" @testCaseCopy="copyTestCase"
@testCaseDetail="showTestCaseDetail" @testCaseDetail="showTestCaseDetail"
@ -71,7 +71,7 @@
currentProject: null, currentProject: null,
treeNodes: [], treeNodes: [],
selectNodeIds: [], selectNodeIds: [],
selectNodeNames: [], selectParentNodes: [],
testCaseReadOnly: true, testCaseReadOnly: true,
selectNode: {}, selectNode: {},
} }
@ -142,9 +142,9 @@
changeProject(project) { changeProject(project) {
this.setCurrentProject(project); this.setCurrentProject(project);
}, },
nodeChange(nodeIds, nodeNames) { nodeChange(nodeIds, pNodes) {
this.selectNodeIds = nodeIds; this.selectNodeIds = nodeIds;
this.selectNodeNames = nodeNames; this.selectParentNodes = pNodes;
}, },
refreshTable() { refreshTable() {
this.$refs.testCaseList.initTableData(); this.$refs.testCaseList.initTableData();
@ -171,7 +171,7 @@
}, },
refresh() { refresh() {
this.selectNodeIds = []; this.selectNodeIds = [];
this.selectNodeNames = []; this.selectParentNodes = [];
this.selectNode = {}; this.selectNode = {};
this.$refs.testCaseList.initTableData(); this.$refs.testCaseList.initTableData();
this.getNodeTree(); this.getNodeTree();

View File

@ -7,7 +7,7 @@
<ms-table-header :condition.sync="condition" @search="initTableData" <ms-table-header :condition.sync="condition" @search="initTableData"
:create-tip="$t('test_track.case.create')" @create="testCaseCreate"> :create-tip="$t('test_track.case.create')" @create="testCaseCreate">
<template v-slot:title> <template v-slot:title>
<node-breadcrumb class="table-title" :node-names="selectNodeNames" @refresh="refresh"/> <node-breadcrumb class="table-title" :nodes="selectParentNodes" @refresh="refresh"/>
</template> </template>
<template v-slot:button> <template v-slot:button>
<ms-table-button icon="el-icon-upload2" :content="$t('test_track.case.import.import')" @click="importTestCase"/> <ms-table-button icon="el-icon-upload2" :content="$t('test_track.case.import.import')" @click="importTestCase"/>
@ -160,7 +160,7 @@
selectNodeIds: { selectNodeIds: {
type: Array type: Array
}, },
selectNodeNames: { selectParentNodes: {
type: Array type: Array
} }
}, },

View File

@ -6,7 +6,8 @@
{{$t('test_track.plan_view.all_case')}} {{$t('test_track.plan_view.all_case')}}
</a> </a>
</el-breadcrumb-item> </el-breadcrumb-item>
<el-breadcrumb-item v-for="nodeName in data" :key="nodeName">{{nodeName}}</el-breadcrumb-item>
<el-breadcrumb-item v-for="node in data" :key="node.id">{{node.name}}</el-breadcrumb-item>
</el-breadcrumb> </el-breadcrumb>
</template> </template>
@ -19,12 +20,12 @@
} }
}, },
props: { props: {
nodeNames: { nodes: {
type: Array type: Array
} }
}, },
watch: { watch: {
nodeNames() { nodes() {
this.filterData(); this.filterData();
} }
}, },
@ -33,7 +34,7 @@
this.$emit('refresh'); this.$emit('refresh');
}, },
filterData() { filterData() {
this.data = this.nodeNames; this.data = this.nodes;
if (this.data.length > 4) { if (this.data.length > 4) {
let lastData = this.data[this.data.length - 1]; let lastData = this.data[this.data.length - 1];
this.data.splice(1, this.data.length); this.data.splice(1, this.data.length);

View File

@ -52,7 +52,6 @@
</span> </span>
</template> </template>
</el-tree> </el-tree>
<node-edit ref="nodeEdit" :tree-nodes="treeNodes" @refresh="refreshNode" /> <node-edit ref="nodeEdit" :tree-nodes="treeNodes" @refresh="refreshNode" />
</div> </div>
</template> </template>
@ -168,10 +167,10 @@ export default {
}, },
handleNodeSelect(node) { handleNodeSelect(node) {
let nodeIds = []; let nodeIds = [];
let nodeNames = []; let pNodes = [];
this.getChildNodeId(node, nodeIds); this.getChildNodeId(node, nodeIds);
this.getParentNodeName(node, nodeNames); this.getParentNodes(node, pNodes);
this.$emit("nodeSelectEvent", nodeIds, nodeNames); this.$emit("nodeSelectEvent", nodeIds, pNodes);
this.$emit("update:selectNode", node); this.$emit("update:selectNode", node);
}, },
getChildNodeId(rootNode, nodeIds) { getChildNodeId(rootNode, nodeIds) {
@ -181,12 +180,12 @@ export default {
this.getChildNodeId(rootNode.childNodes[i], nodeIds); this.getChildNodeId(rootNode.childNodes[i], nodeIds);
} }
}, },
getParentNodeName(rootNode, nodeNames) { getParentNodes(rootNode, pNodes) {
if (rootNode.parent && rootNode.parent.id != 0) { if (rootNode.parent && rootNode.parent.id != 0) {
this.getParentNodeName(rootNode.parent, nodeNames); this.getParentNodes(rootNode.parent, pNodes);
} }
if (rootNode.data.name && rootNode.data.name != "") { if (rootNode.data.name && rootNode.data.name != "") {
nodeNames.push(rootNode.data.name); pNodes.push(rootNode.data);
} }
}, },
filterNode(value, data) { filterNode(value, data) {

View File

@ -23,7 +23,7 @@
@refresh="refresh" @refresh="refresh"
:plan-id="planId" :plan-id="planId"
:select-node-ids="selectNodeIds" :select-node-ids="selectNodeIds"
:select-node-names="selectNodeNames" :select-parent-nodes="selectParentNodes"
ref="testCasePlanList"/> ref="testCasePlanList"/>
</el-main> </el-main>
</el-container> </el-container>
@ -52,7 +52,7 @@
testPlans: [], testPlans: [],
currentPlan: {}, currentPlan: {},
selectNodeIds: [], selectNodeIds: [],
selectNodeNames: [], selectParentNodes: [],
treeNodes: [] treeNodes: []
} }
}, },
@ -72,7 +72,7 @@
methods: { methods: {
refresh() { refresh() {
this.selectNodeIds = []; this.selectNodeIds = [];
this.selectNodeNames = []; this.selectParentNodes = [];
this.getNodeTreeByPlanId(); this.getNodeTreeByPlanId();
}, },
initData() { initData() {
@ -92,9 +92,9 @@
}); });
}); });
}, },
nodeChange(nodeIds, nodeNames) { nodeChange(nodeIds, pNodes) {
this.selectNodeIds = nodeIds; this.selectNodeIds = nodeIds;
this.selectNodeNames = nodeNames; this.selectParentNodes = pNodes;
}, },
changePlan(plan) { changePlan(plan) {
this.currentPlan = plan; this.currentPlan = plan;

View File

@ -3,7 +3,7 @@
<template v-slot:header> <template v-slot:header>
<ms-table-header :condition.sync="condition" @search="initTableData" :show-create="false"> <ms-table-header :condition.sync="condition" @search="initTableData" :show-create="false">
<template v-slot:title> <template v-slot:title>
<node-breadcrumb class="table-title" :node-names="selectNodeNames" @refresh="refresh"/> <node-breadcrumb class="table-title" :nodes="selectParentNodes" @refresh="refresh"/>
</template> </template>
<template v-slot:button> <template v-slot:button>
<ms-table-button v-if="!showMyTestCase" icon="el-icon-s-custom" :content="$t('test_track.plan_view.my_case')" @click="searchMyTestCase"/> <ms-table-button v-if="!showMyTestCase" icon="el-icon-s-custom" :content="$t('test_track.plan_view.my_case')" @click="searchMyTestCase"/>
@ -191,7 +191,7 @@
selectNodeIds: { selectNodeIds: {
type: Array type: Array
}, },
selectNodeNames: { selectParentNodes: {
type: Array type: Array
} }
}, },