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 5799a1b3c8
commit 23da6a5473
1 changed files with 37 additions and 34 deletions

View File

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