fix (接口定义): 列表根据协议筛选问题修复 #1006144

--bug=1006144 --user=赵勇 【接口测试】接口定义... https://www.tapd.cn/55049933/s/1038801
This commit is contained in:
fit2-zhao 2021-08-24 18:05:54 +08:00 committed by fit2-zhao
parent ed657bf914
commit 989c96ef02
1 changed files with 37 additions and 34 deletions

View File

@ -37,12 +37,12 @@
min-width="120"/>
<span v-for="(item) in fields" :key="item.key">
<ms-table-column
prop="num"
label="ID"
:field="item"
min-width="100px"
:fields-width="fieldsWidth"
sortable>
prop="num"
label="ID"
:field="item"
min-width="100px"
:fields-width="fieldsWidth"
sortable>
<template slot-scope="scope">
<el-tooltip content="编辑">
@ -140,7 +140,7 @@
<template v-slot:default="scope">
<span>{{ scope.row.createTime | timestampFormatDate }}</span>
</template>
</ms-table-column >
</ms-table-column>
<ms-table-column
prop="caseTotal"
@ -205,7 +205,7 @@ import CaseBatchMove from "@/business/components/api/definition/components/basis
import {
initCondition,
getCustomTableHeader, getCustomTableWidth, buildBatchParam, checkTableRowIsSelected,
saveLastTableSortField,getLastTableSortField
saveLastTableSortField, getLastTableSortField
} from "@/common/js/tableUtils";
import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOperate";
import {Body} from "@/business/components/api/definition/model/ApiTestModel";
@ -237,7 +237,7 @@ export default {
data() {
return {
type: API_LIST,
tableHeaderKey:"API_DEFINITION",
tableHeaderKey: "API_DEFINITION",
fields: getCustomTableHeader('API_DEFINITION'),
fieldsWidth: getCustomTableWidth('API_DEFINITION'),
condition: {
@ -408,16 +408,16 @@ export default {
projectId() {
return getCurrentProjectID();
},
getApiRequestTypeName(){
if(this.currentProtocol === 'TCP'){
getApiRequestTypeName() {
if (this.currentProtocol === 'TCP') {
return this.$t('api_test.definition.api_agreement');
}else{
} else {
return this.$t('api_test.definition.api_type');
}
}
},
created: function () {
if(!this.projectName || this.projectName === ""){
if (!this.projectName || this.projectName === "") {
this.getProjectName();
}
if (this.trashEnable) {
@ -428,7 +428,7 @@ export default {
this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
}
let orderArr = this.getSortField();
if(orderArr){
if (orderArr) {
this.condition.orders = orderArr;
}
this.initTable();
@ -436,7 +436,7 @@ export default {
},
watch: {
selectNodeIds() {
if(!this.trashEnable){
if (!this.trashEnable) {
initCondition(this.condition, false);
this.currentPage = 1;
this.condition.moduleIds = [];
@ -449,7 +449,7 @@ export default {
this.currentPage = 1;
initCondition(this.condition, false);
this.closeCaseModel();
this.initTable();
this.initTable(true);
},
trashEnable() {
if (this.trashEnable) {
@ -466,10 +466,10 @@ export default {
}
},
methods: {
getProjectName (){
getProjectName() {
this.$get('project/get/' + this.projectId, response => {
let project = response.data;
if(project){
if (project) {
this.projectName = project.name;
}
});
@ -477,20 +477,20 @@ export default {
handleBatchMove() {
this.$refs.testCaseBatchMove.open(this.moduleTree, [], this.moduleOptions);
},
closeCaseModel(){
closeCaseModel() {
//
if(this.$refs.caseList){
if (this.$refs.caseList) {
this.$refs.caseList.handleClose();
}
},
initTable() {
initTable(currentProtocol) {
if (this.$refs.table) {
this.$refs.table.clear();
}
initCondition(this.condition, this.condition.selectAll);
this.selectDataCounts = 0;
if(!this.trashEnable){
if (!this.trashEnable) {
this.condition.moduleIds = this.selectNodeIds;
}
this.condition.projectId = this.projectId;
@ -522,6 +522,9 @@ export default {
this.condition.filters.status = [this.selectDataRange];
break;
}
if (currentProtocol) {
this.condition.moduleIds = [];
}
if (this.condition.projectId) {
this.result = this.$post("/api/definition/list/" + this.currentPage + "/" + this.pageSize, this.condition, response => {
this.genProtocalFilter(this.condition.protocol);
@ -536,7 +539,7 @@ export default {
checkTableRowIsSelected(this, this.$refs.table);
});
}
if(this.needRefreshModule()){
if (this.needRefreshModule()) {
this.$emit("refreshTree");
}
},
@ -590,7 +593,7 @@ export default {
});
});
},
enterSearch(){
enterSearch() {
this.$refs.inputVal.blur();
this.search();
},
@ -806,7 +809,7 @@ export default {
obj.nodeTree = nodeTree;
downloadFile("Metersphere_Api_" + this.projectName + ".json", JSON.stringify(obj));
} else {
downloadFile("Swagger_Api_" + this.projectName+ ".json", JSON.stringify(obj));
downloadFile("Swagger_Api_" + this.projectName + ".json", JSON.stringify(obj));
}
});
},
@ -821,24 +824,24 @@ export default {
open() {
this.$refs.searchBar.open();
},
needRefreshModule(){
if(this.initApiTableOpretion === '0'){
needRefreshModule() {
if (this.initApiTableOpretion === '0') {
return true;
}else {
this.$emit('updateInitApiTableOpretion','0');
} else {
this.$emit('updateInitApiTableOpretion', '0');
return false;
}
},
saveSortField(key,orders){
saveLastTableSortField(key,JSON.stringify(orders));
saveSortField(key, orders) {
saveLastTableSortField(key, JSON.stringify(orders));
},
getSortField(){
getSortField() {
let orderJsonStr = getLastTableSortField(this.tableHeaderKey);
let returnObj = null;
if(orderJsonStr){
if (orderJsonStr) {
try {
returnObj = JSON.parse(orderJsonStr);
}catch (e){
} catch (e) {
return null;
}
}