fix(接口测试): 修复接口复制问题

--bug=1007334 --user=赵勇 【github#6815 】 复制的接口在未保存的情况下编辑原接口,跳转的是另一个复制接口 https://www.tapd.cn/55049933/s/1060079
This commit is contained in:
fit2-zhao 2021-10-27 17:56:32 +08:00 committed by fit2-zhao
parent 681ea5a33e
commit bb8c95a962
2 changed files with 31 additions and 25 deletions

View File

@ -601,6 +601,8 @@ export default {
} }
}, },
editApi(row) { editApi(row) {
const index = this.apiTabs.find(p => p.api && p.api.id === row.id);
if (!index) {
let name = ""; let name = "";
if (row.isCopy) { if (row.isCopy) {
name = "copy" + "-" + row.name; name = "copy" + "-" + row.name;
@ -620,6 +622,9 @@ export default {
} }
} }
this.handleTabsEdit(name, "ADD", row); this.handleTabsEdit(name, "ADD", row);
} else {
this.apiDefaultTab = index.name;
}
}, },
handleCase(api) { handleCase(api) {
this.currentApi = api; this.currentApi = api;

View File

@ -203,7 +203,7 @@ import MsTableColumn from "@/business/components/common/components/table/MsTable
import MsBottomContainer from "../BottomContainer"; import MsBottomContainer from "../BottomContainer";
import MsBatchEdit from "../basis/BatchEdit"; import MsBatchEdit from "../basis/BatchEdit";
import {API_METHOD_COLOUR, API_STATUS, DUBBO_METHOD, REQ_METHOD, SQL_METHOD, TCP_METHOD} from "../../model/JsonData"; import {API_METHOD_COLOUR, API_STATUS, DUBBO_METHOD, REQ_METHOD, SQL_METHOD, TCP_METHOD} from "../../model/JsonData";
import {downloadFile, getCurrentProjectID} from "@/common/js/utils"; import {downloadFile, getCurrentProjectID, getUUID} from "@/common/js/utils";
import {API_LIST} from '@/common/js/constants'; import {API_LIST} from '@/common/js/constants';
import MsTableHeaderSelectPopover from "@/business/components/common/components/table/MsTableHeaderSelectPopover"; import MsTableHeaderSelectPopover from "@/business/components/common/components/table/MsTableHeaderSelectPopover";
import ApiStatus from "@/business/components/api/definition/components/list/ApiStatus"; import ApiStatus from "@/business/components/api/definition/components/list/ApiStatus";
@ -605,11 +605,12 @@ export default {
this.$emit('editApi', row); this.$emit('editApi', row);
}, },
handleCopy(row) { handleCopy(row) {
row.isCopy = true; let obj = JSON.parse(JSON.stringify(row));
this.$emit('editApi', JSON.parse(JSON.stringify(row))); obj.isCopy = true;
obj.id =getUUID();
this.$emit('editApi', obj);
}, },
runApi(row) { runApi(row) {
let request = row ? JSON.parse(row.request) : {}; let request = row ? JSON.parse(row.request) : {};
if (row.tags instanceof Array) { if (row.tags instanceof Array) {
row.tags = JSON.stringify(row.tags); row.tags = JSON.stringify(row.tags);