Merge remote-tracking branch 'origin/master'

This commit is contained in:
wenyann 2020-08-05 18:23:24 +08:00
commit de6a585d17
23 changed files with 167 additions and 72 deletions

View File

@ -318,11 +318,13 @@ public class APITestService {
List<String> resourceIds = schedules.stream()
.map(Schedule::getResourceId)
.collect(Collectors.toList());
ApiTestExample example = new ApiTestExample();
example.createCriteria().andIdIn(resourceIds);
List<ApiTest> apiTests = apiTestMapper.selectByExample(example);
Map<String, String> apiTestMap = apiTests.stream().collect(Collectors.toMap(ApiTest::getId, ApiTest::getName));
scheduleService.build(apiTestMap, schedules);
if (!resourceIds.isEmpty()) {
ApiTestExample example = new ApiTestExample();
example.createCriteria().andIdIn(resourceIds);
List<ApiTest> apiTests = apiTestMapper.selectByExample(example);
Map<String, String> apiTestMap = apiTests.stream().collect(Collectors.toMap(ApiTest::getId, ApiTest::getName));
scheduleService.build(apiTestMap, schedules);
}
return schedules;
}
}

View File

@ -18,6 +18,7 @@
import MsMainContainer from "../../../common/components/MsMainContainer";
import MsAsideItem from "../../../common/components/MsAsideItem";
import EnvironmentEdit from "./environment/EnvironmentEdit";
import {listenGoBack, removeGoBackListener} from "../../../../../common/js/utils";
export default {
name: "ApiEnvironmentConfig",
@ -45,10 +46,11 @@
}
},
methods: {
open(projectId) {
open: function (projectId) {
this.visible = true;
this.projectId = projectId;
this.getEnvironments();
listenGoBack(this.close);
},
deleteEnvironment(environment, index) {
if (environment.id) {
@ -134,6 +136,7 @@
this.$emit('close');
this.visible = false;
this.$refs.environmentEdit.clearValidate();
removeGoBackListener(this.close);
}
}
}

View File

@ -95,6 +95,7 @@
<script>
import MsDialogFooter from "../../../../common/components/MsDialogFooter";
import ApiEnvironmentConfig from "../ApiEnvironmentConfig";
import {listenGoBack, removeGoBackListener} from "../../../../../../common/js/utils";
export default {
name: "ApiImport",
components: {ApiEnvironmentConfig, MsDialogFooter},
@ -174,6 +175,7 @@
methods: {
open() {
this.visible = true;
listenGoBack(this.close);
},
upload(file) {
this.formData.file = file.file;
@ -255,6 +257,8 @@
swaggerUrl: ''
};
this.fileList = [];
removeGoBackListener(this.close);
this.visible = false;
}
}
}

View File

@ -25,6 +25,7 @@
import Crontab from "../cron/Crontab";
import CrontabResult from "../cron/CrontabResult";
import {cronValidate} from "../../../../common/js/cron";
import {listenGoBack, removeGoBackListener} from "../../../../common/js/utils";
function defaultCustomValidate() {return {pass: true};}
@ -80,6 +81,7 @@
open() {
this.dialogVisible = true;
this.form.cronValue = this.schedule.value;
listenGoBack(this.close);
},
crontabFill(value, resultList) {
//
@ -108,6 +110,7 @@
if (!this.schedule.value) {
this.$refs.crontabResult.resultList = [];
}
removeGoBackListener(this.close);
},
intervalShortValidate() {
if (this.getIntervalTime() < 3*60*1000) {

View File

@ -48,7 +48,7 @@
</el-card>
</ms-main-container>
<el-dialog :title="title" :visible.sync="createVisible" destroy-on-close>
<el-dialog :title="title" :visible.sync="createVisible" destroy-on-close @close="handleClose">
<el-form :model="form" :rules="rules" ref="form" label-position="right" label-width="100px" size="small">
<el-form-item :label="$t('commons.name')" prop="name">
<el-input v-model="form.name" autocomplete="off"></el-input>
@ -80,7 +80,7 @@
import MsTableHeader from "../common/components/MsTableHeader";
import MsTableOperator from "../common/components/MsTableOperator";
import MsDialogFooter from "../common/components/MsDialogFooter";
import {_sort, getCurrentUser} from "../../../common/js/utils";
import {_sort, getCurrentUser, listenGoBack, removeGoBackListener} from "../../../common/js/utils";
import MsContainer from "../common/components/MsContainer";
import MsMainContainer from "../common/components/MsMainContainer";
import MsDeleteConfirm from "../common/components/MsDeleteConfirm";
@ -162,12 +162,14 @@
return false;
}
this.title = this.$t('project.create');
listenGoBack(this.handleClose);
this.createVisible = true;
this.form = {};
},
edit(row) {
this.title = this.$t('project.edit');
this.createVisible = true;
listenGoBack(this.handleClose);
this.form = Object.assign({}, row);
},
submit(formName) {
@ -207,6 +209,10 @@
});
});
},
handleClose() {
removeGoBackListener(this.handleClose);
this.createVisible = false;
},
search() {
this.list();
},

View File

@ -116,7 +116,7 @@
import MsRolesTag from "../../common/components/MsRolesTag";
import MsTableOperator from "../../common/components/MsTableOperator";
import MsDialogFooter from "../../common/components/MsDialogFooter";
import {getCurrentUser} from "../../../../common/js/utils";
import {getCurrentUser, listenGoBack, removeGoBackListener} from "../../../../common/js/utils";
export default {
name: "MsOrganizationMember",
@ -177,6 +177,9 @@
handleClose() {
this.form = {};
this.options = [];
removeGoBackListener(this.handleClose);
this.updateVisible = false;
this.createVisible = false;
},
edit(row) {
this.updateVisible = true;
@ -187,6 +190,7 @@
});
// 使
this.$set(this.form, 'roleIds', roleIds);
listenGoBack(this.handleClose);
},
updateOrgMember(formName) {
let param = {
@ -231,7 +235,8 @@
this.createVisible = true;
this.result = this.$get('/role/list/org', response => {
this.$set(this.form, "roles", response.data);
})
});
listenGoBack(this.handleClose);
},
submitForm(formName) {
this.$refs[formName].validate((valid) => {

View File

@ -24,7 +24,7 @@
:total="total"/>
</el-card>
<el-dialog :title="$t('workspace.create')" :visible.sync="dialogWsAddVisible" width="30%">
<el-dialog :title="$t('workspace.create')" :visible.sync="dialogWsAddVisible" width="30%" @close="close">
<el-form :model="form" :rules="rules" ref="form" label-position="right" label-width="100px" size="small">
<el-form-item :label="$t('commons.name')" prop="name">
<el-input v-model="form.name" autocomplete="off"/>
@ -56,7 +56,7 @@
</el-dialog>
<!-- dialog of workspace member -->
<el-dialog :visible.sync="dialogWsMemberVisible" width="70%" :destroy-on-close="true" @close="closeMemberFunc"
<el-dialog :visible.sync="dialogWsMemberVisible" width="70%" :destroy-on-close="true" @close="close"
class="dialog-css">
<ms-table-header :condition.sync="dialogCondition" @create="addMember" @search="dialogSearch"
:create-tip="$t('member.create')" :title="$t('commons.member')"/>
@ -178,8 +178,8 @@
import {
getCurrentOrganizationId,
getCurrentUser,
getCurrentWorkspaceId,
refreshSessionAndCookies
getCurrentWorkspaceId, listenGoBack,
refreshSessionAndCookies, removeGoBackListener
} from "../../../../common/js/utils";
import MsDeleteConfirm from "../../common/components/MsDeleteConfirm";
@ -299,6 +299,7 @@
this.result = this.$get('/role/list/test', response => {
this.$set(this.memberForm, "roles", response.data);
})
listenGoBack(this.close);
},
cellClick(row) {
// currentRow
@ -346,10 +347,6 @@
closeFunc() {
this.form = {};
},
closeMemberFunc() {
this.memberLineData = [];
this.list();
},
submitForm(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
@ -388,6 +385,7 @@
})
//
this.$set(this.memberForm, 'roleIds', roleIds);
listenGoBack(this.close);
},
delMember(row) {
this.$confirm(this.$t('member.remove_member'), '', {
@ -422,6 +420,13 @@
}
})
},
close: function () {
removeGoBackListener(this.close);
this.dialogWsMemberUpdateVisible = false;
this.dialogWsMemberAddVisible = false;
this.memberLineData = [];
this.list();
},
buildPagePath(path) {
return path + "/" + this.dialogCurrentPage + "/" + this.dialogPageSize;
},

View File

@ -81,7 +81,7 @@
<script>
import {TokenKey} from "../../../../common/js/constants";
import MsDialogFooter from "../../common/components/MsDialogFooter";
import {getCurrentUser} from "../../../../common/js/utils";
import {getCurrentUser, listenGoBack, removeGoBackListener} from "../../../../common/js/utils";
import MsTableOperatorButton from "../../common/components/MsTableOperatorButton";
export default {
@ -154,9 +154,11 @@
edit(row) {
this.updateVisible = true;
this.form = Object.assign({}, row);
listenGoBack(this.handleClose);
},
editPassword(row) {
this.editPasswordVisible = true;
listenGoBack(this.handleClose);
},
cancel(){
this.editPasswordVisible = false;
@ -209,6 +211,9 @@
handleClose() {
this.form = {};
this.ruleForm = {};
removeGoBackListener(this.handleClose);
this.editPasswordVisible = false;
this.updateVisible = false;
}
}
}

View File

@ -38,7 +38,7 @@
</div>
<el-dialog :title="$t('ldap.test_login')" :visible.sync="loginVisible" width="30%" destroy-on-close
v-loading="result.loading">
v-loading="result.loading" @close="close">
<el-form :model="loginForm" :rules="loginFormRules" ref="loginForm" label-width="90px">
<el-form-item :label="$t('commons.username')" prop="username">
<el-input v-model="loginForm.username" autocomplete="off" :placeholder="$t('ldap.input_username')"/>
@ -61,6 +61,7 @@
<script>
import MsDialogFooter from "../../common/components/MsDialogFooter";
import {listenGoBack, removeGoBackListener} from "../../../../common/js/utils";
export default {
name: "LdapSetting",
@ -118,6 +119,10 @@
this.show = true;
this.init();
},
close() {
removeGoBackListener(this.close);
this.loginVisible = false;
},
testConnection() {
if (!this.checkParam()) {
return false;
@ -151,6 +156,7 @@
this.loginForm = {};
this.loginVisible = true;
listenGoBack(this.close);
},
checkParam() {
if (!this.form.url) {

View File

@ -27,7 +27,7 @@
</el-card>
<!-- dialog of organization member -->
<el-dialog :visible.sync="dialogOrgMemberVisible" width="70%" :destroy-on-close="true" @close="closeMemberFunc" class="dialog-css">
<el-dialog :visible.sync="dialogOrgMemberVisible" width="70%" :destroy-on-close="true" @close="closeFunc" class="dialog-css">
<ms-table-header :condition.sync="dialogCondition" @create="addMember" @search="dialogSearch"
:create-tip="$t('member.create')" :title="$t('commons.member')"/>
<!-- organization member table -->
@ -178,7 +178,12 @@
import MsTableOperator from "../../common/components/MsTableOperator";
import MsTableOperatorButton from "../../common/components/MsTableOperatorButton";
import MsDialogFooter from "../../common/components/MsDialogFooter";
import {getCurrentOrganizationId, getCurrentUser, refreshSessionAndCookies} from "../../../../common/js/utils";
import {
getCurrentOrganizationId,
getCurrentUser, listenGoBack,
refreshSessionAndCookies,
removeGoBackListener
} from "../../../../common/js/utils";
import {DEFAULT, ORGANIZATION} from "../../../../common/js/constants";
import MsDeleteConfirm from "../../common/components/MsDeleteConfirm";
@ -251,6 +256,7 @@
methods: {
create() {
this.dialogOrgAddVisible = true;
listenGoBack(this.closeFunc);
},
addMember() {
this.dialogOrgMemberAddVisible = true;
@ -265,6 +271,7 @@
edit(row) {
this.dialogOrgUpdateVisible = true;
this.form = Object.assign({}, row);
listenGoBack(this.closeFunc);
},
editMember(row) {
this.dialogOrgMemberUpdateVisible = true;
@ -275,6 +282,7 @@
})
//
this.$set(this.memberForm, 'roleIds', roleIds);
listenGoBack(this.closeFunc);
},
cellClick(row) {
// currentRow
@ -297,6 +305,7 @@
}
this.dialogTotal = data.itemCount;
});
listenGoBack(this.closeFunc);
},
dialogSearch() {
let row = this.currentRow;
@ -409,11 +418,15 @@
})
},
closeFunc() {
this.form = {};
},
closeMemberFunc() {
this.memberLineData = [];
this.initTableData();
this.form = {};
removeGoBackListener(this.closeFunc);
this.dialogOrgAddVisible = false;
this.dialogOrgUpdateVisible = false;
this.dialogOrgMemberVisible = false;
this.dialogOrgMemberAddVisible = false;
this.dialogOrgMemberUpdateVisible = false;
},
handleSelectionChange(val) {
this.multipleSelection = val;

View File

@ -28,7 +28,7 @@
</el-card>
<!-- add workspace dialog -->
<el-dialog :title="$t('workspace.create')" :visible.sync="dialogWsAddVisible" width="30%">
<el-dialog :title="$t('workspace.create')" :visible.sync="dialogWsAddVisible" width="30%" @close="close">
<el-form :model="form" :rules="rules" ref="form" label-position="right" label-width="100px" size="small">
<el-form-item :label="$t('commons.name')" prop="name">
<el-input v-model="form.name" autocomplete="off"/>
@ -56,7 +56,7 @@
</el-dialog>
<!-- update workspace dialog -->
<el-dialog :title="$t('workspace.update')" :visible.sync="dialogWsUpdateVisible" width="30%">
<el-dialog :title="$t('workspace.update')" :visible.sync="dialogWsUpdateVisible" width="30%" @close="close">
<el-form :model="form" :rules="rules" ref="updateForm" label-position="right" label-width="100px" size="small">
<el-form-item :label="$t('commons.name')" prop="name">
<el-input v-model="form.name" autocomplete="off"/>
@ -202,8 +202,8 @@
import {
getCurrentOrganizationId,
getCurrentUser,
getCurrentWorkspaceId,
refreshSessionAndCookies
getCurrentWorkspaceId, listenGoBack,
refreshSessionAndCookies, removeGoBackListener
} from "../../../../common/js/utils";
import {DEFAULT, WORKSPACE} from "../../../../common/js/constants";
import MsDeleteConfirm from "../../common/components/MsDeleteConfirm";
@ -230,6 +230,7 @@
this.$get("/organization/list", response => {
this.$set(this.form, "orgList", response.data);
})
listenGoBack(this.close);
},
submit(formName) {
this.$refs[formName].validate((valid) => {
@ -255,7 +256,8 @@
});
this.result = this.$get('/role/list/test', response => {
this.$set(this.memberForm, "roles", response.data);
})
});
listenGoBack(this.handleClose);
},
cellClick(row) {
// currentRow
@ -279,6 +281,7 @@
}
this.dialogTotal = data.itemCount;
});
listenGoBack(this.closeWsMemberDialog);
},
dialogSearch() {
let row = this.currentWorkspaceRow;
@ -307,6 +310,12 @@
this.$get("/organization/list", response => {
this.$set(this.form, "orgList1", response.data);
})
listenGoBack(this.close);
},
close() {
this.dialogWsAddVisible = false;
this.dialogWsUpdateVisible = false;
removeGoBackListener(this.close);
},
updateWorkspace(updateForm) {
this.$refs[updateForm].validate(valid => {
@ -323,10 +332,15 @@
},
handleClose() {
this.memberForm = {};
this.dialogWsMemberAddVisible = false;
this.dialogWsMemberUpdateVisible = false;
removeGoBackListener(this.handleClose);
},
closeWsMemberDialog() {
this.memberLineData = [];
this.list();
removeGoBackListener(this.closeWsMemberDialog);
this.dialogWsMemberVisible = false;
},
list() {
let url = '/workspace/list/all/' + this.currentPage + '/' + this.pageSize;
@ -373,6 +387,7 @@
})
//
this.$set(this.memberForm, 'roleIds', roleIds);
listenGoBack(this.handleClose);
},
handleDelete(workspace) {
this.$refs.deleteConfirm.open(workspace);

View File

@ -178,6 +178,7 @@
import MsTableHeader from "../../common/components/MsTableHeader";
import MsTableOperator from "../../common/components/MsTableOperator";
import MsDialogFooter from "../../common/components/MsDialogFooter";
import {listenGoBack, removeGoBackListener} from "../../../../common/js/utils";
export default {
name: "MsTestResourcePool",
@ -272,11 +273,13 @@
},
create() {
this.createVisible = true;
listenGoBack(this.closeFunc);
},
edit(row) {
this.updateVisible = true;
this.form = JSON.parse(JSON.stringify(row));
this.convertResources();
listenGoBack(this.closeFunc);
},
convertResources() {
let resources = [];
@ -364,6 +367,9 @@
},
closeFunc() {
this.form = {};
this.updateVisible = false;
this.createVisible = false;
removeGoBackListener(this.closeFunc);
},
changeSwitch(row) {
this.result.loading = true;

View File

@ -296,7 +296,7 @@
import MsTableOperator from "../../common/components/MsTableOperator";
import MsDialogFooter from "../../common/components/MsDialogFooter";
import MsTableOperatorButton from "../../common/components/MsTableOperatorButton";
import {getCurrentUser} from "../../../../common/js/utils";
import {getCurrentUser, listenGoBack, removeGoBackListener} from "../../../../common/js/utils";
import MsRolesTag from "../../common/components/MsRolesTag";
export default {
@ -404,6 +404,7 @@
this.createVisible = true;
this.getOrgList();
this.getWsList();
listenGoBack(this.handleClose);
},
edit(row) {
this.updateVisible = true;
@ -418,10 +419,12 @@
let data = response.data;
this.$set(this.form, "roles", data);
});
listenGoBack(this.handleClose);
},
editPassword(row) {
this.editPasswordVisible = true;
this.ruleForm = Object.assign({}, row);
listenGoBack(this.handleClose);
},
del(row) {
this.$confirm(this.$t('user.delete_confirm'), '', {
@ -497,6 +500,10 @@
handleClose() {
this.form = {roles: [{id: ''}]};
this.btnAddRole = false;
removeGoBackListener(this.handleClose);
this.editPasswordVisible = false;
this.createVisible = false;
this.updateVisible = false;
},
changeSwitch(row) {
this.$post('/user/special/update_status', row, () => {

View File

@ -108,7 +108,7 @@
import MsRolesTag from "../../common/components/MsRolesTag";
import MsTableOperator from "../../common/components/MsTableOperator";
import MsDialogFooter from "../../common/components/MsDialogFooter";
import {getCurrentUser} from "../../../../common/js/utils";
import {getCurrentUser, listenGoBack, removeGoBackListener} from "../../../../common/js/utils";
export default {
name: "MsMember",
@ -173,6 +173,9 @@
},
handleClose() {
this.form = {};
this.createVisible = false;
this.updateVisible = false;
removeGoBackListener(this.handleClose);
},
del(row) {
this.$confirm(this.$t('member.remove_member'), '', {
@ -197,6 +200,7 @@
})
// 使
this.$set(this.form, 'roleIds', roleIds);
listenGoBack(this.handleClose);
},
updateWorkspaceMember(formName) {
let param = {
@ -239,6 +243,7 @@
this.result = this.$get('/role/list/test', response => {
this.$set(this.form, "roles", response.data);
})
listenGoBack(this.handleClose);
},
submitForm(formName) {
this.$refs[formName].validate((valid) => {

View File

@ -36,6 +36,7 @@
<script>
import MsDialogFooter from "../../../common/components/MsDialogFooter";
import {WORKSPACE_ID} from "../../../../../common/js/constants";
import {listenGoBack, removeGoBackListener} from "../../../../../common/js/utils";
export default {
name: "BatchEdit",
@ -88,9 +89,11 @@
open() {
this.dialogVisible = true;
this.size = this.$parent.selectRows.size;
listenGoBack(this.handleClose);
},
handleClose() {
this.form = {};
removeGoBackListener(this.handleClose);
},
changeType(val) {
this.$set(this.form, "value", "");

View File

@ -224,6 +224,7 @@
import {WORKSPACE_ID, TokenKey} from '../../../../../common/js/constants';
import MsDialogFooter from '../../../common/components/MsDialogFooter'
import {listenGoBack, removeGoBackListener, removeListenGoBack} from "../../../../../common/js/utils";
export default {
name: "TestCaseEdit",
@ -302,7 +303,12 @@
methods: {
open(testCase) {
this.resetForm();
this.listenGoBack();
if (window.history && window.history.pushState) {
history.pushState(null, null, document.URL);
window.addEventListener('popstate', this.close);
}
listenGoBack(this.close);
this.operationType = 'add';
if (testCase) {
//
@ -354,16 +360,9 @@
}
});
},
listenGoBack() {
//
if (window.history && window.history.pushState) {
history.pushState(null, null, document.URL);
window.addEventListener('popstate', this.close, false);
}
},
close() {
//
window.removeEventListener('popstate', this.goBack, false);
removeGoBackListener(this.close);
this.dialogFormVisible = false;
},
saveCase() {

View File

@ -1,6 +1,6 @@
<template>
<el-dialog class="testcase-import" :title="$t('test_track.case.import.case_import')" :visible.sync="dialogVisible"
@close="init">
@close="close">
<el-row>
<el-link type="primary" class="download-template"
@ -44,6 +44,7 @@
<script>
import ElUploadList from "element-ui/packages/upload/src/upload-list";
import MsTableButton from '../../../../components/common/components/MsTableButton';
import {listenGoBack, removeGoBackListener} from "../../../../../common/js/utils";
export default {
name: "TestCaseImport",
@ -85,13 +86,16 @@
this.isLoading = false;
this.$error(err.message);
},
init() {
open() {
listenGoBack(this.close);
this.dialogVisible = true;
},
close() {
removeGoBackListener(this.close);
this.dialogVisible = false;
this.fileList = [];
this.errList = [];
},
open() {
this.dialogVisible = true;
},
downloadTemplate() {
this.$fileDownload('/test/case/export/template');
},

View File

@ -172,7 +172,6 @@
currentPage: 1,
pageSize: 10,
total: 0,
// selectIds: new Set(),
selectRows: new Set(),
priorityFilters: [
{text: 'P0', value: 'P0'},
@ -274,14 +273,8 @@
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
// this.$post('/test/case/batch/delete', {ids: [...this.selectIds]}, () => {
// this.selectIds.clear();
// this.$emit("refresh");
// this.$success(this.$t('commons.delete_success'));
// });
let ids = Array.from(this.selectRows).map(row => row.id);
this.$post('/test/case/batch/delete', {ids: ids}, () => {
// this.selectIds.clear();
this.selectRows.clear();
this.$emit("refresh");
this.$success(this.$t('commons.delete_success'));
@ -375,17 +368,12 @@
});
},
handleBatch(type) {
// if (this.selectIds.size < 1) {
// this.$warning(this.$t('test_track.plan_view.select_manipulate'));
// return;
// }
if (this.selectRows.size < 1) {
this.$warning(this.$t('test_track.plan_view.select_manipulate'));
return;
}
if (type === 'move') {
let ids = Array.from(this.selectRows).map(row => row.id);
// this.$emit('moveToNode', this.selectIds);
this.$emit('moveToNode', ids);
} else if (type === 'delete') {
this.handleDeleteBatch();

View File

@ -25,6 +25,7 @@
<script>
import MsDialogFooter from '../../../common/components/MsDialogFooter';
import {listenGoBack, removeGoBackListener} from "../../../../../common/js/utils";
export default {
name: "TestCaseMove",
@ -62,11 +63,13 @@
this.moduleOptions = moduleOptions;
this.selectIds = selectIds;
this.dialogVisible = true;
listenGoBack(this.close);
},
close() {
this.module = '';
this.selectIds = [];
this.dialogVisible = false;
removeGoBackListener(this.close);
}
}
}

View File

@ -30,8 +30,8 @@
</template>
<script>
import {CURRENT_PROJECT} from '../../../../common/js/constants';
import MsDialogFooter from '../../common/components/MsDialogFooter';
import {listenGoBack, removeGoBackListener} from "../../../../common/js/utils";
export default {
components: {MsDialogFooter},
@ -70,6 +70,7 @@
this.form.name = this.node.name;
}
this.nodeIds = nodeIds;
listenGoBack(this.close);
this.dialogFormVisible = true;
},
saveNode() {
@ -118,6 +119,7 @@
},
close() {
this.form.name = '';
removeGoBackListener(this.close);
this.dialogFormVisible = false;
}
}

View File

@ -4,6 +4,7 @@
<el-dialog :title="operationType == 'edit' ? $t('test_track.plan.edit_plan') : $t('test_track.plan.create_plan')"
:visible.sync="dialogFormVisible"
@close="close"
width="65%">
<el-form :model="form" :rules="rules" ref="planFrom">
@ -111,6 +112,7 @@
import {WORKSPACE_ID} from '../../../../../common/js/constants';
import TestPlanStatusButton from "../common/TestPlanStatusButton";
import {listenGoBack, removeGoBackListener} from "../../../../../common/js/utils";
export default {
name: "TestPlanEdit",
@ -154,6 +156,7 @@
Object.assign(tmp, testPlan);
Object.assign(this.form, tmp);
}
listenGoBack(this.close);
this.dialogFormVisible = true;
},
savePlan(){
@ -196,6 +199,10 @@
this.form.status = status;
this.$forceUpdate();
},
close() {
removeGoBackListener(this.close);
this.dialogFormVisible = false;
},
resetForm() {
//
if (this.$refs['planFrom']) {

View File

@ -225,6 +225,7 @@
import ApiTestResult from "./test/ApiTestResult";
import PerformanceTestDetail from "./test/PerformanceTestDetail";
import PerformanceTestResult from "./test/PerformanceTestResult";
import {listenGoBack, removeGoBackListener} from "../../../../../../common/js/utils";
export default {
name: "TestPlanTestCaseEdit",
@ -265,19 +266,8 @@
}
},
methods: {
listenGoBack() {
//
if (window.history && window.history.pushState) {
history.pushState(null, null, document.URL);
window.addEventListener('popstate', this.goBack, false);
}
},
goBack() {
this.handleClose();
},
handleClose() {
//
window.removeEventListener('popstate', this.goBack, false);
removeGoBackListener(this.handleClose);
this.showDialog = false;
},
cancel() {
@ -359,7 +349,7 @@
openTestCaseEdit(testCase) {
this.showDialog = true;
this.activeTab = 'detail';
this.listenGoBack();
listenGoBack(this.handleClose);
this.initData(testCase);
},
initTest() {

View File

@ -174,3 +174,17 @@ export function downloadFile(name, content) {
navigator.msSaveBlob(blob, name)
}
}
export function listenGoBack( callback) {
//监听浏览器返回操作,关闭该对话框
if (window.history && window.history.pushState) {
history.pushState(null, null, document.URL);
window.addEventListener('popstate', callback);
}
}
export function removeGoBackListener(callback) {
window.removeEventListener('popstate', callback);
}