fix: 修复跳转到api_case_list 报错的问题

This commit is contained in:
Captain.B 2021-09-13 18:04:08 +08:00 committed by 刘瑞斌
parent d195499696
commit dadfff5598
1 changed files with 39 additions and 22 deletions

View File

@ -7,7 +7,9 @@
<el-input :placeholder="$t('commons.search_by_id_name_tag')" @blur="search" @keyup.enter.native="search" <el-input :placeholder="$t('commons.search_by_id_name_tag')" @blur="search" @keyup.enter.native="search"
class="search-input" size="small" class="search-input" size="small"
v-model="condition.name"/> v-model="condition.name"/>
<el-button type="primary" style="float: right;margin-right: 10px" icon="el-icon-plus" size="small" @click="addTestCase" v-if="apiDefinitionId">{{ $t('commons.add') }}</el-button> <el-button type="primary" style="float: right;margin-right: 10px" icon="el-icon-plus" size="small"
@click="addTestCase" v-if="apiDefinitionId">{{ $t('commons.add') }}
</el-button>
<ms-table <ms-table
:data="tableData" :data="tableData"
:select-node-ids="selectNodeIds" :select-node-ids="selectNodeIds"
@ -90,7 +92,8 @@
:label="$t('test_track.plan_view.execute_result')"> :label="$t('test_track.plan_view.execute_result')">
<template v-slot:default="scope"> <template v-slot:default="scope">
<i class="el-icon-loading ms-running" v-if="scope.row.status === 'Running'"/> <i class="el-icon-loading ms-running" v-if="scope.row.status === 'Running'"/>
<el-link @click="getExecResult(scope.row)" :class="getStatusClass(scope.row.status)">{{ getStatusTitle(scope.row.status) }}</el-link> <el-link @click="getExecResult(scope.row)"
:class="getStatusClass(scope.row.status)">{{ getStatusTitle(scope.row.status) }}</el-link>
</template> </template>
</ms-table-column> </ms-table-column>
@ -165,9 +168,11 @@
:total="total"/> :total="total"/>
</div> </div>
<api-case-list @showExecResult="showExecResult" @refreshCase="initTable" :currentApi="selectCase" ref="caseList" @stop="stop"/> <api-case-list @showExecResult="showExecResult" @refreshCase="initTable" :currentApi="selectCase" ref="caseList"
@stop="stop"/>
<!--批量编辑--> <!--批量编辑-->
<ms-batch-edit ref="batchEdit" :data-count="$refs.caseTable ? $refs.caseTable.selectDataCounts : 0" @batchEdit="batchEdit" :typeArr="typeArr" :value-arr="valueArr"/> <ms-batch-edit ref="batchEdit" :data-count="$refs.caseTable ? $refs.caseTable.selectDataCounts : 0"
@batchEdit="batchEdit" :typeArr="typeArr" :value-arr="valueArr"/>
<!--选择环境(当创建性能测试的时候)--> <!--选择环境(当创建性能测试的时候)-->
<ms-set-environment ref="setEnvironment" :testCase="clickRow" @createPerformance="createPerformance"/> <ms-set-environment ref="setEnvironment" :testCase="clickRow" @createPerformance="createPerformance"/>
<!--查看引用--> <!--查看引用-->
@ -216,7 +221,9 @@ import {
_filter, _filter,
_sort, _sort,
getCustomTableHeader, getCustomTableHeader,
getCustomTableWidth, getLastTableSortField, handleRowDrop getCustomTableWidth,
getLastTableSortField,
handleRowDrop
} from "@/common/js/tableUtils"; } from "@/common/js/tableUtils";
import {API_CASE_LIST} from "@/common/js/constants"; import {API_CASE_LIST} from "@/common/js/constants";
import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOperate"; import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOperate";
@ -346,7 +353,7 @@ export default {
environments: [], environments: [],
resVisible: false, resVisible: false,
response: {}, response: {},
} };
}, },
props: { props: {
currentProtocol: String, currentProtocol: String,
@ -373,7 +380,7 @@ export default {
model: { model: {
type: String, type: String,
default() { default() {
'api' 'api';
} }
}, },
planId: String planId: String
@ -531,7 +538,7 @@ export default {
} }
} }
if (this.condition.filters && !this.condition.filters.status) { if (this.condition.filters && !this.condition.filters.status) {
this.$delete(this.condition.filters, 'status') this.$delete(this.condition.filters, 'status');
} }
if (!this.selectAll) { if (!this.selectAll) {
this.selectAll = false; this.selectAll = false;
@ -575,7 +582,7 @@ export default {
if (item.status === 'Running') { if (item.status === 'Running') {
isNext = true; isNext = true;
} }
}) });
this.$nextTick(function () { this.$nextTick(function () {
handleRowDrop(this.tableData, (param) => { handleRowDrop(this.tableData, (param) => {
@ -587,7 +594,7 @@ export default {
this.$refs.caseTable.doLayout(); this.$refs.caseTable.doLayout();
this.$refs.caseTable.checkTableRowIsSelect(); this.$refs.caseTable.checkTableRowIsSelect();
} }
}) });
if (isNext) { if (isNext) {
setTimeout(() => { setTimeout(() => {
this.initTable(); this.initTable();
@ -653,7 +660,9 @@ export default {
request.hashTree = []; request.hashTree = [];
} }
selectApi.url = request.path; selectApi.url = request.path;
if (this.$refs.caseList) {
this.$refs.caseList.open(selectApi, testCase.id); this.$refs.caseList.open(selectApi, testCase.id);
}
}); });
}, },
addTestCase() { addTestCase() {
@ -679,7 +688,15 @@ export default {
let uuid = getUUID(); let uuid = getUUID();
let apiCaseRequest = JSON.parse(data.request); let apiCaseRequest = JSON.parse(data.request);
apiCaseRequest.id = uuid; apiCaseRequest.id = uuid;
let obj = {name: "copy_" + data.name, apiDefinitionId: row.apiDefinitionId, priority: data.priority, active: true, tags: data.tags, request: apiCaseRequest, uuid: uuid}; let obj = {
name: "copy_" + data.name,
apiDefinitionId: row.apiDefinitionId,
priority: data.priority,
active: true,
tags: data.tags,
request: apiCaseRequest,
uuid: uuid
};
this.$refs.caseList.copy(obj); this.$refs.caseList.copy(obj);
}); });
}, },
@ -788,7 +805,7 @@ export default {
let obj = {}; let obj = {};
obj.projectId = this.projectId; obj.projectId = this.projectId;
obj.selectAllDate = false; obj.selectAllDate = false;
obj.ids = [apiCase.id] obj.ids = [apiCase.id];
obj = Object.assign(obj, this.condition); obj = Object.assign(obj, this.condition);
this.$post('/api/testcase/checkDeleteDatas/', obj, response => { this.$post('/api/testcase/checkDeleteDatas/', obj, response => {
let checkResult = response.data; let checkResult = response.data;
@ -829,7 +846,7 @@ export default {
let apiNames = ""; let apiNames = "";
cannotReductionApiNameArr.forEach(item => { cannotReductionApiNameArr.forEach(item => {
if (apiNames === "") { if (apiNames === "") {
apiNames += item apiNames += item;
} else { } else {
apiNames += ";" + item; apiNames += ";" + item;
} }
@ -855,7 +872,7 @@ export default {
let apiNames = ""; let apiNames = "";
cannotReductionApiNameArr.forEach(item => { cannotReductionApiNameArr.forEach(item => {
if (apiNames === "") { if (apiNames === "") {
apiNames += item apiNames += item;
} else { } else {
apiNames += ";" + item; apiNames += ";" + item;
} }
@ -875,7 +892,7 @@ export default {
let selectedIDs = this.getIds(selection); let selectedIDs = this.getIds(selection);
let allIDs = this.tableData.map(s => s.id); let allIDs = this.tableData.map(s => s.id);
this.unSelection = allIDs.filter(function (val) { this.unSelection = allIDs.filter(function (val) {
return selectedIDs.indexOf(val) === -1 return selectedIDs.indexOf(val) === -1;
}); });
if (this.selectAll) { if (this.selectAll) {
this.selectDataCounts = this.total - this.unSelection.length; this.selectDataCounts = this.total - this.unSelection.length;
@ -896,7 +913,7 @@ export default {
this.$emit("changeSelectDataRangeAll", "testCase"); this.$emit("changeSelectDataRangeAll", "testCase");
}, },
getIds(rowSets) { getIds(rowSets) {
let rowArray = Array.from(rowSets) let rowArray = Array.from(rowSets);
let ids = rowArray.map(s => s.id); let ids = rowArray.map(s => s.id);
return ids; return ids;
}, },
@ -938,7 +955,7 @@ export default {
if (res) { if (res) {
item.status = res.data.status; item.status = res.data.status;
} }
}) });
break; break;
} }
} }
@ -971,7 +988,7 @@ export default {
testPlan.hashTree = [threadGroup]; testPlan.hashTree = [threadGroup];
runData.forEach(item => { runData.forEach(item => {
threadGroup.hashTree.push(item); threadGroup.hashTree.push(item);
}) });
let reqObj = { let reqObj = {
id: row.id, id: row.id,
testElement: testPlan, testElement: testPlan,
@ -995,10 +1012,10 @@ export default {
this.$store.commit('setTest', { this.$store.commit('setTest', {
name: row.name, name: row.name,
jmx: jmxObj jmx: jmxObj
}) });
this.$router.push({ this.$router.push({
path: "/performance/test/create" path: "/performance/test/create"
}) });
// let performanceId = response.data; // let performanceId = response.data;
// if(performanceId!=null){ // if(performanceId!=null){
// this.$router.push({ // this.$router.push({
@ -1010,7 +1027,7 @@ export default {
}); });
}, },
}, },
} };
</script> </script>
<style scoped> <style scoped>