fix(测试跟踪): 功能用例编辑页跳转优化

--bug=1023154 --user=陈建星 【测试跟踪】功能用例-编辑页面-修改用例等级和版本后未更新 https://www.tapd.cn/55049933/s/1337368
This commit is contained in:
chenjianxing 2023-02-17 22:17:20 +08:00 committed by jianxing
parent 8cc1080453
commit 4f954a1f84
14 changed files with 64 additions and 254 deletions

View File

@ -174,6 +174,11 @@ public class TestCaseController {
return testCaseService.getTestCaseStep(testCaseId);
}
@GetMapping("/get/simple/{testCaseId}")
public TestCaseWithBLOBs getSimpleCase(@PathVariable String testCaseId) {
return testCaseService.getSimpleCase(testCaseId);
}
@GetMapping("/project/{testCaseId}")
public Project getProjectByTestCaseId(@PathVariable String testCaseId) {
trackCheckPermissionService.checkTestCaseOwner(testCaseId);

View File

@ -3150,4 +3150,8 @@ public class TestCaseService {
return new ArrayList<>(0);
}
}
public TestCaseWithBLOBs getSimpleCase(String testCaseId) {
return testCaseMapper.selectByPrimaryKey(testCaseId);
}
}

View File

@ -22,6 +22,10 @@ export function getTestCase(id) {
return get(BASE_URL + `get/${id}`);
}
export function getSimpleTestCase(id) {
return get(BASE_URL + `get/simple/${id}`);
}
export function getTestCaseByVersionId(refId, versionId) {
return get(BASE_URL + `get/version/${refId}/${versionId}`);
}

View File

@ -1,7 +1,7 @@
<template>
<ms-container v-if="renderComponent" v-loading="loading">
<!-- operate-button -->
<div class="top-btn-group-layout" v-if="!showPublicNode && !showTrashNode && !editable" style="margin-bottom: 16px">
<div class="top-btn-group-layout" v-if="!showPublicNode && !showTrashNode" style="margin-bottom: 16px">
<el-button size="small" v-permission="['PROJECT_TRACK_CASE:READ+BATCH_EDIT']" @click="handleCreateCase" type="primary">
<svg-icon icon-class="icon_add_outlined_white"/>
{{$t('test_track.case.create_case')}}
@ -46,7 +46,7 @@
<span class="back-content">{{showPublicNode? $t('project.case_public') : $t('commons.trash')}}</span>
</div>
<div style="display: flex; height: calc(100vh - 130px)" v-if="!editable" class = "test-case-aside-layout">
<div style="display: flex; height: calc(100vh - 130px)" class = "test-case-aside-layout">
<!-- case-aside-container -->
<ms-aside-container v-show="isAsideHidden" :min-width="'0'" :enable-aside-hidden.sync="enableAsideHidden">
<test-case-node-tree
@ -161,7 +161,6 @@
:trash-enable="true"
:current-version="currentTrashVersion"
:version-enable="versionEnable"
@testCaseCopy="copyTestCase"
@refresh="refreshTrashNode"
@refreshAll="refreshAll"
@setCondition="setTrashCondition"
@ -171,29 +170,6 @@
</el-card>
</ms-main-container>
</div>
<!-- since v2.6 创建用例流程变更 -->
<ms-container v-if="editable" class = "edit-layout">
<div v-for="item in tabs" :key="item.name">
<test-case-edit
:currentTestCaseInfo="item.testCaseInfo"
:version-enable="versionEnable"
@refresh="refreshAll"
@checkout="checkout($event, item)"
:is-public="item.isPublic"
:read-only="testCaseReadOnly"
:tree-nodes="treeNodes"
:select-node="selectNode"
:select-condition="item.isPublic ? publicCondition : condition"
:public-enable="item.isPublic"
:case-type="type"
@addTab="addTab"
@closeTab="closeTab"
:editable="item.edit"
ref="testCaseEdit"
>
</test-case-edit>
</div>
</ms-container>
<!-- dialog -->
<!-- export case -->
@ -206,7 +182,6 @@
<script>
import TestCaseExportToExcel from "@/business/case/components/export/TestCaseExportToExcel";
import TestCaseCommonImportNew from "@/business/case/components/import/TestCaseCommonImportNew";
import TestCaseEdit from "./components/TestCaseEdit";
import TestCaseList from "./components/TestCaseList";
import SelectMenu from "../common/SelectMenu";
import MsContainer from "metersphere-frontend/src/components/new-ui/MsContainer";
@ -215,7 +190,6 @@ import MsMainContainer from "metersphere-frontend/src/components/new-ui/MsMainCo
import MsMainButtonGroup from "metersphere-frontend/src/components/new-ui/MsMainButtonGroup";
import {getCurrentProjectID, getCurrentWorkspaceId} from "metersphere-frontend/src/utils/token";
import {hasLicense, hasPermission} from "metersphere-frontend/src/utils/permission";
import {getUUID} from "metersphere-frontend/src/utils";
import TestCaseNodeTree from "@/business/module/TestCaseNodeTree";
import MsTabButton from "metersphere-frontend/src/components/new-ui/MsTabButton";
import TestCaseMinder from "../common/minder/TestCaseMinder";
@ -226,20 +200,19 @@ import {PROJECT_ID} from "metersphere-frontend/src/utils/constants";
import MxVersionSelect from "metersphere-frontend/src/components/version/MxVersionSelect";
import {useStore} from "@/store";
import {testCaseNodePublicCount, testCaseNodeTrashCount} from "@/api/test-case-node";
import {getTestCase} from "@/api/testCase";
import {getProjectApplicationConfig} from "@/api/project-application";
import {versionEnableByProjectId} from "@/api/project";
import TestCasePublicNodeTree from "@/business/module/TestCasePublicNodeTree";
import TestCaseTrashNodeTree from "@/business/module/TestCaseTrashNodeTree";
import PublicTestCaseList from "@/business/case/components/public/PublicTestCaseList";
import {openCaseCreate, openCaseEdit} from "@/business/case/test-case";
import {openCaseCreate} from "@/business/case/test-case";
const store = useStore();
export default {
name: "TestCase",
components: {
PublicTestCaseList, TestCaseTrashNodeTree, TestCasePublicNodeTree, IsChangeConfirm, TestCaseMinder, MsTabButton, TestCaseNodeTree,
MsMainContainer, MsAsideContainer, MsContainer, TestCaseList, TestCaseEdit, SelectMenu, TestCaseEditShow, 'VersionSelect': MxVersionSelect,
MsMainContainer, MsAsideContainer, MsContainer, TestCaseList, SelectMenu, TestCaseEditShow, 'VersionSelect': MxVersionSelect,
MsMainButtonGroup, TestCaseExportToExcel, TestCaseCommonImportNew
},
comments: {},
@ -257,7 +230,6 @@ export default {
publicCondition: {},
activeName: 'default',
currentActiveName: '',
tabs: [],
renderComponent: true,
loading: false,
type: '',
@ -367,10 +339,7 @@ export default {
},
moduleOptions() {
return store.testCaseModuleOptions;
},
editable() {
return this.tabs.length > 0;
},
}
},
methods: {
hasPermission,
@ -379,46 +348,6 @@ export default {
projectId: this.projectId
}, this);
},
closeTab(){
this.handleTabClose();
},
handleCommand(e) {
switch (e) {
case "ADD":
this.addTab({name: 'add'});
break;
}
},
addTab(tab) {
this.showPublic = false
if (tab.name === 'edit' || tab.name === 'show') {
let label = this.$t('test_track.case.create');
let name = getUUID().substring(0, 8);
if (this.activeName === 'public') {
this.currentActiveName = 'public'
} else {
this.currentActiveName = 'default'
}
this.activeName = name;
label = tab.testCaseInfo.name;
this.tabs = [];
this.tabs.push({ edit: false, label: label, name: name, testCaseInfo: tab.testCaseInfo, isPublic: tab.isPublic});
}
if (tab.name === 'public') {
this.publicEnable = false;
this.$nextTick(() => {
this.publicEnable = true;
})
} else if (tab.name === 'trash') {
this.trashEnable = false;
this.$nextTick(() => {
this.trashEnable = true;
})
}
this.setCurTabId(tab, 'testCaseEdit');
},
handleImportCommand(e) {
switch (e) {
case "excel":
@ -454,16 +383,6 @@ export default {
this.publicTotal = response.data;
});
},
setCurTabId(tab, ref) {
this.$nextTick(() => {
if (this.$refs && this.$refs[ref]) {
let index = tab.index ? Number.parseInt(tab.index) : this.tabs.length;
let cutEditTab = this.$refs[ref][index - 1];
let curTabId = cutEditTab ? cutEditTab.tabId : null;
useStore().curTabId = curTabId;
}
});
},
updateActiveDom(activeDom) {
openMinderConfirm(this, activeDom);
},
@ -510,98 +429,6 @@ export default {
}
return true;
},
addTabShow(tab) {
if (!this.projectId) {
this.$warning(this.$t('commons.check_project_tip'));
return;
}
if (tab.name === 'show') {
this.showPublic = true
let label = this.$t('test_track.case.create');
let name = getUUID().substring(0, 8);
this.activeName = name;
this.currentActiveName = 'public'
label = tab.testCaseInfo.name;
this.tabs.push({ edit: false, label: label, name: name, testCaseInfo: tab.testCaseInfo});
}
this.setCurTabId(this, tab, 'testCaseEditShow');
},
handleTabClose() {
let message = "";
this.tabs.forEach(t => {
if (t && store.testCaseMap.has(t.testCaseInfo.id) && store.testCaseMap.get(t.testCaseInfo.id) > 1) {
message += t.testCaseInfo.name + "";
}
if (t.label === this.$t('test_track.case.create')) {
message += this.$t('test_track.case.create') + "";
}
if (t.testCaseInfo.isCopy) {
message += t.testCaseInfo.name + "";
}
})
if (message !== "") {
this.$alert(this.$t('commons.track') + " [ " + message.substr(0, message.length - 1) + " ] " + this.$t('commons.confirm_info'), '', {
confirmButtonText: this.$t('commons.confirm'),
cancelButtonText: this.$t('commons.cancel'),
callback: (action) => {
if (action === 'confirm') {
store.testCaseMap.clear();
this.tabs = [];
this.activeName = "default";
this.refresh();
}
}
});
} else {
this.tabs = [];
this.activeName = "default";
this.refresh();
}
},
closeConfirm(targetName) {
if (targetName === 'trash') {
this.activeName = 'default';
this.trashEnable = false;
} else {
this.closeTabWithSave(targetName);
}
},
closeTabWithSave(targetName) {
let t = this.tabs.filter(tab => tab.name === targetName);
let message = "";
if (t && store.testCaseMap.has(t[0].testCaseInfo.id) && store.testCaseMap.get(t[0].testCaseInfo.id) > 0) {
message += t[0].testCaseInfo.name;
}
if (t[0].label === this.$t('test_track.case.create')) {
message += this.$t('test_track.case.create');
}
if (t[0].testCaseInfo.isCopy) {
message += t[0].testCaseInfo.name;
}
if (message !== "") {
this.$alert(this.$t('commons.track') + " [ " + message + " ] " + this.$t('commons.confirm_info'), '', {
confirmButtonText: this.$t('commons.confirm'),
cancelButtonText: this.$t('commons.cancel'),
callback: (action) => {
if (action === 'confirm') {
store.testCaseMap.delete(t[0].testCaseInfo.id);
this.removeTab(targetName);
}
}
});
} else {
store.testCaseMap.delete(t[0].testCaseInfo.id);
this.removeTab(targetName);
}
},
removeTab(targetName) {
this.tabs = this.tabs.filter(tab => tab.name !== targetName);
if (this.tabs.length > 0) {
this.activeName = this.tabs[this.tabs.length - 1].name;
} else {
this.activeName = "default";
}
},
handleExportCheck() {
if (this.$refs.testCaseList.checkSelected()) {
this.$refs.nodeTree.openExport();
@ -673,25 +500,13 @@ export default {
this.$refs.nodeTree.list();
}
},
setTable(data) {
if (data) {
for (let index in this.tabs) {
let tab = this.tabs[index];
if (tab.name === this.activeName) {
tab.label = data.name;
break;
}
}
}
},
refreshAll(data) {
refreshAll() {
if (this.$refs.testCaseList) {
this.$refs.testCaseList.initTableData();
}
if(this.$refs.nodeTree){
this.$refs.nodeTree.list();
}
this.setTable(data);
},
importRefresh() {
this.refreshAll();
@ -762,23 +577,6 @@ export default {
changeVersion(currentVersion) {
this.currentVersion = currentVersion || null;
},
changeTrashVersion(currentVersion) {
this.currentTrashVersion = currentVersion || null;
},
checkout(testCase, item) {
Object.assign(item.testCaseInfo, testCase)
// copy
for (let i = 0; i < this.$refs.testCaseEdit.length; i++) {
this.$refs.testCaseEdit[i].initEdit(item.testCaseInfo, () => {
this.$nextTick(() => {
let vh = this.$refs.testCaseEdit[i].$refs.versionHistory;
vh.getVersionOptionList(vh.handleVersionOptions);
vh.show = false;
vh.loading = false;
});
});
}
},
checkoutPublic(testCase, item) {
Object.assign(item.testCaseInfo, testCase)
// copy

View File

@ -362,7 +362,7 @@ import {
hasTestCaseOtherInfo,
testCaseEditFollows,
testCaseGetByVersionId,
testCaseDeleteToGc, getTestCaseNodesByCaseFilter, getTestCaseByVersionId,
testCaseDeleteToGc, getTestCaseNodesByCaseFilter, getTestCaseByVersionId, getSimpleTestCase,
} from "@/api/testCase";
import {
@ -682,17 +682,11 @@ export default {
},
activated() {
if (localStorage.getItem('trackProjectChange')) {
//
this.$router.push('/track/case/all');
} else {
this.loadTestCase();
}
this.loadTestCase();
},
created(){
this.$EventBus.$on('projectChange', () => {
this.projectChange = true;
localStorage.setItem('trackProjectChange', 'true');
this.$router.push('/track/case/all');
});
this.$EventBus.$on("handleSaveCaseWithEvent", this.handleSaveCaseWithEvent);
},
@ -779,7 +773,7 @@ export default {
this.checkVersionEnable();
},
editPublicCase(type) {
openCaseEdit({caseId: this.caseId, projectId: this.projectId, type}, this)
openCaseEdit({caseId: this.caseId, type}, this)
},
copyPublicCase() {
this.editPublicCase('copy');
@ -805,10 +799,7 @@ export default {
if (this.editable || !this.form.id || this.isPublicShow) {
return;
}
let TestCaseData = this.$router.resolve({
path: "/track/case/edit/" + this.form.id
});
window.open(TestCaseData.href, "_blank");
openCaseEdit({caseId: this.form.id}, this);
},
handleSaveCaseWithEvent(formData) {
this.saveCase();
@ -948,10 +939,23 @@ export default {
}
},
checkCurrentProject() {
//
if (getCurrentProjectID() !== this.projectId) {
setCurrentProjectID(this.projectId);
location.reload();
if (this.projectId) {
// projectId
if (getCurrentProjectID() !== this.projectId) {
setCurrentProjectID(this.projectId);
location.reload();
}
} else {
if (this.caseId) {
getSimpleTestCase(this.caseId).then((response) => {
let testCase = response.data;
if (getCurrentProjectID() !== testCase.projectId) {
//
setCurrentProjectID(testCase.projectId);
location.reload();
}
})
}
}
},
getTestCase() {
@ -976,8 +980,6 @@ export default {
item.isEdit = false;
});
this.form.id = null;
} else {
this.checkCurrentProject(testCase.projectId);
}
this.currentTestCaseInfo = testCase;
this.setFormData(testCase);
@ -1108,7 +1110,7 @@ export default {
}
},
routerToEdit(id) {
this.$router.push({path: '/track/' + this.projectId + '/case/edit/' + id});
this.$router.push({path: '/track/case/edit/' + id});
setTimeout(() => {
window.location.reload();
}, 300);
@ -1488,7 +1490,7 @@ export default {
this.saveCase();
},
copyRow() {
openCaseEdit({caseId: this.testCase.id, projectId: this.testCase.projectId, type: 'copy'}, this);
openCaseEdit({caseId: this.testCase.id, type: 'copy'}, this);
},
deleteRow() {
getTestCaseVersions(this.testCase.id)

View File

@ -849,7 +849,7 @@ export default {
this.$refs.table.resetHeader();
},
handleEdit(testCase, type) {
openCaseEdit({caseId: testCase.id, projectId: testCase.projectId, type}, this);
openCaseEdit({caseId: testCase.id, type}, this);
},
getCase(id) {
this.$refs.testCasePreview.open();

View File

@ -328,14 +328,9 @@
</template>
<script>
import { getTestCaseVersions } from "@/api/testCase";
import {
getDefaultVersion,
getProjectMembers,
getProjectVersions,
isProjectVersionEnable,
} from "metersphere-frontend/src/api/version";
import { getVersionFilters } from "@/business/utils/sdk-utils";
import { hasLicense } from "metersphere-frontend/src/utils/permission";
import MsFormDivider from "metersphere-frontend/src/components/MsFormDivider";
import MsSelectTree from "metersphere-frontend/src/components/select-tree/SelectTree";
@ -346,7 +341,6 @@ import BaseEditItemComponent from "../BaseEditItemComponent";
import { issueDemandList } from "@/api/issue";
import {
getCurrentProjectID,
getCurrentUser,
} from "metersphere-frontend/src/utils/token";
export default {
name: "CaseBaseInfo",

View File

@ -449,7 +449,7 @@ export default {
this.selectCounts = this.$refs.table.selectDataCounts;
},
handleEdit(testCase, type) {
openCaseEdit({caseId: testCase.id, projectId: testCase.projectId, type}, this);
openCaseEdit({caseId: testCase.id, type}, this);
},
handleEditShow(testCase, column) {
this.$refs.publicTestCaseShow.open(testCase.id);

View File

@ -64,11 +64,8 @@ export function openCaseEdit(query, v) {
if (!query.type) {
delete query.type;
}
if (!query.projectId) {
query.projectId = getCurrentProjectID();
}
let path = '/track/' + query.projectId + '/case/edit/' + query.caseId;
delete query.projectId;
let path = '/track/case/edit/' + query.caseId;
delete query.caseId;
let TestCaseData = v.$router.resolve({
path,
@ -88,8 +85,7 @@ export function openCaseCreate(query, v) {
if (!query.projectId) {
query.projectId = getCurrentProjectID();
}
let path = '/track/' + query.projectId + '/case/create';
delete query.projectId;
let path = '/track/case/create';
let TestCaseData = v.$router.resolve({
path,
query,

View File

@ -95,6 +95,8 @@ export default {
this.pathName = '/track/review/all';
} else if (to.params && to.params.planId) {
this.pathName = '/track/plan/all';
} if (to.path.indexOf("/track/case") >= 0) {
this.pathName = '/track/case/all';
} else {
this.pathName = to.path;
}

View File

@ -78,7 +78,7 @@ export default {
}
},
openTestCase() {
openCaseEdit({caseId: this.testCase.caseId, projectId: this.testCase.projectId}, this);
openCaseEdit({caseId: this.testCase.caseId}, this);
},
close() {
this.$emit('close');

View File

@ -12,7 +12,7 @@ export default {
component: () => import('@/business/home/TrackHome'),
},
{
path: ':projectId/case/create',
path: 'case/create',
name: 'testCaseCreate',
component: () => import('@/business/case/components/TestCaseEdit'),
},
@ -27,7 +27,7 @@ export default {
component: () => import('@/business/case/TestCase'),
},
{
path: ':projectId/case/edit/:caseId',
path: 'case/edit/:caseId',
name: 'testCaseEdit',
component: () => import('@/business/case/components/TestCaseEdit'),
},

View File

@ -654,13 +654,18 @@ export default {
this.initTableData();
},
handleEdit(testCase, column) {
let caseResolve = this.$router.resolve({
path: '/track/case/edit',
query: {
caseId: testCase.id,
},
let query = {
caseId: testCase.id,
projectId: testCase.projectId
};
let path = '/track/' + query.projectId + '/case/edit/' + query.caseId;
delete query.projectId;
delete query.caseId;
let TestCaseData = this.$router.resolve({
path,
query,
});
window.open(caseResolve.href, '_blank');
window.open(TestCaseData.href, '_blank');
},
refresh() {
this.$refs.table.clear();

View File

@ -75,7 +75,7 @@ export default{
},
toCreatCase(){
let caseData = this.$router.resolve({
path: '/track/' + getCurrentProject() + '/case/create',
path: '/track/case/create',
});
window.open(caseData.href, '_blank');
},