fix(权限设置): 修复接口定义,接口自动化,测试跟踪只读用户可以点击创建的权限
This commit is contained in:
parent
ae9fc29b31
commit
94741cfac8
|
@ -48,7 +48,7 @@
|
|||
</div>
|
||||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane name="add">
|
||||
<el-tab-pane name="add" v-if="hasPermission('PROJECT_API_SCENARIO:READ+CREATE')">
|
||||
<template v-slot:label>
|
||||
<el-dropdown @command="handleCommand">
|
||||
<el-button type="primary" plain icon="el-icon-plus" size="mini"/>
|
||||
|
@ -74,164 +74,165 @@ import MsContainer from "@/business/components/common/components/MsContainer";
|
|||
import MsAsideContainer from "@/business/components/common/components/MsAsideContainer";
|
||||
import MsMainContainer from "@/business/components/common/components/MsMainContainer";
|
||||
import MsApiScenarioList from "@/business/components/api/automation/scenario/ApiScenarioList";
|
||||
import {getCurrentUser, getUUID} from "@/common/js/utils";
|
||||
import {getCurrentUser, getUUID, hasPermission} from "@/common/js/utils";
|
||||
import MsApiScenarioModule from "@/business/components/api/automation/scenario/ApiScenarioModule";
|
||||
import MsEditApiScenario from "./scenario/EditApiScenario";
|
||||
|
||||
export default {
|
||||
name: "ApiAutomation",
|
||||
components: {
|
||||
MsApiScenarioModule,
|
||||
MsApiScenarioList,
|
||||
MsMainContainer,
|
||||
MsAsideContainer,
|
||||
MsContainer,
|
||||
MsEditApiScenario
|
||||
export default {
|
||||
name: "ApiAutomation",
|
||||
components: {
|
||||
MsApiScenarioModule,
|
||||
MsApiScenarioList,
|
||||
MsMainContainer,
|
||||
MsAsideContainer,
|
||||
MsContainer,
|
||||
MsEditApiScenario
|
||||
},
|
||||
comments: {},
|
||||
computed: {
|
||||
checkRedirectID: function () {
|
||||
let redirectIDParam = this.$route.params.redirectID;
|
||||
this.changeRedirectParam(redirectIDParam);
|
||||
return redirectIDParam;
|
||||
},
|
||||
comments: {},
|
||||
computed: {
|
||||
checkRedirectID: function () {
|
||||
let redirectIDParam = this.$route.params.redirectID;
|
||||
this.changeRedirectParam(redirectIDParam);
|
||||
return redirectIDParam;
|
||||
},
|
||||
isRedirectEdit: function () {
|
||||
let redirectParam = this.$route.params.dataSelectRange;
|
||||
this.checkRedirectEditPage(redirectParam);
|
||||
return redirectParam;
|
||||
},
|
||||
isReadOnly() {
|
||||
return false;
|
||||
},
|
||||
projectId() {
|
||||
return this.$store.state.projectId
|
||||
},
|
||||
isRedirectEdit: function () {
|
||||
let redirectParam = this.$route.params.dataSelectRange;
|
||||
this.checkRedirectEditPage(redirectParam);
|
||||
return redirectParam;
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
redirectID: '',
|
||||
renderComponent: true,
|
||||
isHide: true,
|
||||
activeName: 'default',
|
||||
redirectFlag: 'none',
|
||||
currentModule: null,
|
||||
moduleOptions: [],
|
||||
tabs: [],
|
||||
loading: false,
|
||||
trashEnable: false,
|
||||
selectNodeIds: [],
|
||||
nodeTree: [],
|
||||
currentModulePath: "",
|
||||
customNum: false
|
||||
}
|
||||
isReadOnly() {
|
||||
return false;
|
||||
},
|
||||
mounted() {
|
||||
this.getProject();
|
||||
projectId() {
|
||||
return this.$store.state.projectId;
|
||||
},
|
||||
watch: {
|
||||
redirectID() {
|
||||
this.renderComponent = false;
|
||||
this.$nextTick(() => {
|
||||
// 在 DOM 中添加 my-component 组件
|
||||
this.renderComponent = true;
|
||||
});
|
||||
},
|
||||
'$route'(to, from) { // 路由改变时,把接口定义界面中的 ctrl s 保存快捷键监听移除
|
||||
if (to.path.indexOf('/api/automation') == -1) {
|
||||
if (this.$refs && this.$refs.autoScenarioConfig) {
|
||||
this.$refs.autoScenarioConfig.forEach(item => {
|
||||
item.removeListener();
|
||||
});
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
redirectID: '',
|
||||
renderComponent: true,
|
||||
isHide: true,
|
||||
activeName: 'default',
|
||||
redirectFlag: 'none',
|
||||
currentModule: null,
|
||||
moduleOptions: [],
|
||||
tabs: [],
|
||||
loading: false,
|
||||
trashEnable: false,
|
||||
selectNodeIds: [],
|
||||
nodeTree: [],
|
||||
currentModulePath: "",
|
||||
customNum: false
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.getProject();
|
||||
},
|
||||
watch: {
|
||||
redirectID() {
|
||||
this.renderComponent = false;
|
||||
this.$nextTick(() => {
|
||||
// 在 DOM 中添加 my-component 组件
|
||||
this.renderComponent = true;
|
||||
});
|
||||
},
|
||||
'$route'(to, from) { // 路由改变时,把接口定义界面中的 ctrl s 保存快捷键监听移除
|
||||
if (to.path.indexOf('/api/automation') == -1) {
|
||||
if (this.$refs && this.$refs.autoScenarioConfig) {
|
||||
this.$refs.autoScenarioConfig.forEach(item => {
|
||||
item.removeListener();
|
||||
});
|
||||
}
|
||||
},
|
||||
selectNodeIds() {
|
||||
this.activeName = "default";
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
exportAPI() {
|
||||
this.$refs.apiScenarioList.exportApi();
|
||||
},
|
||||
exportJmx() {
|
||||
this.$refs.apiScenarioList.exportJmx();
|
||||
},
|
||||
checkRedirectEditPage(redirectParam) {
|
||||
if (redirectParam != null) {
|
||||
let selectParamArr = redirectParam.split("edit:");
|
||||
if (selectParamArr.length == 2) {
|
||||
let scenarioId = selectParamArr[1];
|
||||
let projectId = this.projectId;
|
||||
//查找单条数据,跳转修改页面
|
||||
let url = "/api/automation/list/" + 1 + "/" + 1;
|
||||
this.$post(url, {id: scenarioId, projectId: projectId}, response => {
|
||||
let data = response.data;
|
||||
if (data != null) {
|
||||
//如果树未加载
|
||||
if (JSON.stringify(this.moduleOptions) === '{}') {
|
||||
this.$refs.nodeTree.list();
|
||||
}
|
||||
let row = data.listObject[0];
|
||||
if (row.tags.length > 0) {
|
||||
row.tags = JSON.parse(row.tags);
|
||||
}
|
||||
|
||||
this.editScenario(row);
|
||||
selectNodeIds() {
|
||||
this.activeName = "default";
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
hasPermission,
|
||||
exportAPI() {
|
||||
this.$refs.apiScenarioList.exportApi();
|
||||
},
|
||||
exportJmx() {
|
||||
this.$refs.apiScenarioList.exportJmx();
|
||||
},
|
||||
checkRedirectEditPage(redirectParam) {
|
||||
if (redirectParam != null) {
|
||||
let selectParamArr = redirectParam.split("edit:");
|
||||
if (selectParamArr.length == 2) {
|
||||
let scenarioId = selectParamArr[1];
|
||||
let projectId = this.projectId;
|
||||
//查找单条数据,跳转修改页面
|
||||
let url = "/api/automation/list/" + 1 + "/" + 1;
|
||||
this.$post(url, {id: scenarioId, projectId: projectId}, response => {
|
||||
let data = response.data;
|
||||
if (data != null) {
|
||||
//如果树未加载
|
||||
if (JSON.stringify(this.moduleOptions) === '{}') {
|
||||
this.$refs.nodeTree.list();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
changeRedirectParam(redirectIDParam) {
|
||||
this.redirectID = redirectIDParam;
|
||||
if (redirectIDParam != null) {
|
||||
if (this.redirectFlag == "none") {
|
||||
this.activeName = "default";
|
||||
this.addListener();
|
||||
this.redirectFlag = "redirected";
|
||||
}
|
||||
} else {
|
||||
this.redirectFlag = "none";
|
||||
}
|
||||
},
|
||||
getPath(id, arr) {
|
||||
if (id === null) {
|
||||
return null;
|
||||
}
|
||||
if(arr) {
|
||||
arr.forEach(item => {
|
||||
if (item.id === id) {
|
||||
this.currentModulePath = item.path;
|
||||
}
|
||||
if (item.children && item.children.length > 0) {
|
||||
this.getPath(id, item.children);
|
||||
let row = data.listObject[0];
|
||||
if (row.tags.length > 0) {
|
||||
row.tags = JSON.parse(row.tags);
|
||||
}
|
||||
|
||||
this.editScenario(row);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
addTab(tab) {
|
||||
if (tab.name === 'default') {
|
||||
this.$refs.apiScenarioList.search();
|
||||
}
|
||||
},
|
||||
changeRedirectParam(redirectIDParam) {
|
||||
this.redirectID = redirectIDParam;
|
||||
if (redirectIDParam != null) {
|
||||
if (this.redirectFlag == "none") {
|
||||
this.activeName = "default";
|
||||
this.addListener();
|
||||
this.redirectFlag = "redirected";
|
||||
}
|
||||
if (!this.projectId) {
|
||||
this.$warning(this.$t('commons.check_project_tip'));
|
||||
return;
|
||||
}
|
||||
this.currentModulePath = "";
|
||||
if (tab.name === 'add') {
|
||||
let label = this.$t('api_test.automation.add_scenario');
|
||||
let name = getUUID().substring(0, 8);
|
||||
this.activeName = name;
|
||||
let currentScenario = {
|
||||
status: "Underway", principal: getCurrentUser().id,
|
||||
apiScenarioModuleId: "default-module", id: getUUID(),
|
||||
modulePath: "/" + this.$t("commons.module_title")
|
||||
};
|
||||
if (this.nodeTree && this.nodeTree.length > 0) {
|
||||
currentScenario.apiScenarioModuleId = this.nodeTree[0].id;
|
||||
this.getPath(this.nodeTree[0].id, this.moduleOptions);
|
||||
currentScenario.modulePath = this.currentModulePath;
|
||||
} else {
|
||||
this.redirectFlag = "none";
|
||||
}
|
||||
},
|
||||
getPath(id, arr) {
|
||||
if (id === null) {
|
||||
return null;
|
||||
}
|
||||
if (arr) {
|
||||
arr.forEach(item => {
|
||||
if (item.id === id) {
|
||||
this.currentModulePath = item.path;
|
||||
}
|
||||
if (item.children && item.children.length > 0) {
|
||||
this.getPath(id, item.children);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
addTab(tab) {
|
||||
if (tab.name === 'default') {
|
||||
this.$refs.apiScenarioList.search();
|
||||
}
|
||||
if (!this.projectId) {
|
||||
this.$warning(this.$t('commons.check_project_tip'));
|
||||
return;
|
||||
}
|
||||
this.currentModulePath = "";
|
||||
if (tab.name === 'add') {
|
||||
let label = this.$t('api_test.automation.add_scenario');
|
||||
let name = getUUID().substring(0, 8);
|
||||
this.activeName = name;
|
||||
let currentScenario = {
|
||||
status: "Underway", principal: getCurrentUser().id,
|
||||
apiScenarioModuleId: "default-module", id: getUUID(),
|
||||
modulePath: "/" + this.$t("commons.module_title")
|
||||
};
|
||||
if (this.nodeTree && this.nodeTree.length > 0) {
|
||||
currentScenario.apiScenarioModuleId = this.nodeTree[0].id;
|
||||
this.getPath(this.nodeTree[0].id, this.moduleOptions);
|
||||
currentScenario.modulePath = this.currentModulePath;
|
||||
}
|
||||
|
||||
if (this.selectNodeIds && this.selectNodeIds.length > 0) {
|
||||
currentScenario.apiScenarioModuleId = this.selectNodeIds[0];
|
||||
|
@ -309,28 +310,28 @@ import MsEditApiScenario from "./scenario/EditApiScenario";
|
|||
selectModule(data) {
|
||||
this.currentModule = data;
|
||||
},
|
||||
saveScenario(data) {
|
||||
this.setTabLabel(data);
|
||||
this.$refs.apiScenarioList.search(data);
|
||||
},
|
||||
refresh(data) {
|
||||
this.setTabTitle(data);
|
||||
this.$refs.apiScenarioList.search(data);
|
||||
this.$refs.nodeTree.list();
|
||||
},
|
||||
refreshTree() {
|
||||
this.$refs.nodeTree.list();
|
||||
},
|
||||
refreshAll() {
|
||||
this.$refs.nodeTree.list();
|
||||
this.$refs.apiScenarioList.search();
|
||||
},
|
||||
setTabTitle(data) {
|
||||
for (let index in this.tabs) {
|
||||
let tab = this.tabs[index];
|
||||
if (tab.name === this.activeName) {
|
||||
tab.label = data.name;
|
||||
break;
|
||||
saveScenario(data) {
|
||||
this.setTabLabel(data);
|
||||
this.$refs.apiScenarioList.search(data);
|
||||
},
|
||||
refresh(data) {
|
||||
this.setTabTitle(data);
|
||||
this.$refs.apiScenarioList.search(data);
|
||||
this.$refs.nodeTree.list();
|
||||
},
|
||||
refreshTree() {
|
||||
this.$refs.nodeTree.list();
|
||||
},
|
||||
refreshAll() {
|
||||
this.$refs.nodeTree.list();
|
||||
this.$refs.apiScenarioList.search();
|
||||
},
|
||||
setTabTitle(data) {
|
||||
for (let index in this.tabs) {
|
||||
let tab = this.tabs[index];
|
||||
if (tab.name === this.activeName) {
|
||||
tab.label = data.name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -120,7 +120,7 @@
|
|||
</div>
|
||||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane name="add">
|
||||
<el-tab-pane name="add" v-if="hasPermission('PROJECT_API_DEFINITION:READ+CREATE_API')">
|
||||
<template v-slot:label>
|
||||
<el-dropdown @command="handleCommand">
|
||||
<el-button type="primary" plain icon="el-icon-plus" size="mini"/>
|
||||
|
@ -160,7 +160,7 @@ import MsRunTestHttpPage from "./components/runtest/RunTestHTTPPage";
|
|||
import MsRunTestTcpPage from "./components/runtest/RunTestTCPPage";
|
||||
import MsRunTestSqlPage from "./components/runtest/RunTestSQLPage";
|
||||
import MsRunTestDubboPage from "./components/runtest/RunTestDubboPage";
|
||||
import {getCurrentUser, getUUID} from "@/common/js/utils";
|
||||
import {getCurrentUser, getUUID, hasPermission} from "@/common/js/utils";
|
||||
import MsApiModule from "./components/module/ApiModule";
|
||||
import ApiCaseSimpleList from "./components/list/ApiCaseSimpleList";
|
||||
|
||||
|
@ -281,6 +281,7 @@ export default {
|
|||
},
|
||||
|
||||
methods: {
|
||||
hasPermission,
|
||||
getPath(id, arr) {
|
||||
if (id === null) {
|
||||
return null;
|
||||
|
|
|
@ -72,10 +72,10 @@
|
|||
</test-case-edit>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane name="add">
|
||||
<el-tab-pane name="add" v-if="hasPermission('PROJECT_TRACK_CASE:READ+CREATE')">
|
||||
<template v-slot:label>
|
||||
<el-dropdown @command="handleCommand" v-permission="['PROJECT_TRACK_CASE:READ+CREATE']">
|
||||
<el-button type="primary" plain icon="el-icon-plus" size="mini" />
|
||||
<el-button type="primary" plain icon="el-icon-plus" size="mini"/>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item command="ADD" v-permission="['PROJECT_TRACK_CASE:READ+CREATE']">
|
||||
{{ $t('test_track.case.create') }}
|
||||
|
@ -105,7 +105,7 @@ import SelectMenu from "../common/SelectMenu";
|
|||
import MsContainer from "../../common/components/MsContainer";
|
||||
import MsAsideContainer from "../../common/components/MsAsideContainer";
|
||||
import MsMainContainer from "../../common/components/MsMainContainer";
|
||||
import {getUUID} from "../../../../common/js/utils";
|
||||
import {getUUID, hasPermission} from "@/common/js/utils";
|
||||
import TestCaseNodeTree from "../common/TestCaseNodeTree";
|
||||
|
||||
import MsTabButton from "@/business/components/common/components/MsTabButton";
|
||||
|
@ -190,6 +190,7 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
hasPermission,
|
||||
handleCommand(e) {
|
||||
switch (e) {
|
||||
case "ADD":
|
||||
|
|
Loading…
Reference in New Issue