fix(接口测试): 修复环境配置复制环境,复制成功后页面关闭的缺陷

--bug=1015758 --user=王孝刚 【接口测试】github#16797,环境配置,点击复制环境,复制成功,但环境配置窗口关闭了
https://www.tapd.cn/55049933/s/1222041
This commit is contained in:
wxg0103 2022-08-11 13:47:15 +08:00 committed by 刘瑞斌
parent f5ab742d5e
commit 2297374a46
2 changed files with 333 additions and 323 deletions

View File

@ -7,7 +7,8 @@
:env-add-permission="['PROJECT_ENVIRONMENT:READ+CREATE']" :env-add-permission="['PROJECT_ENVIRONMENT:READ+CREATE']"
:data="environments" :item-operators="environmentOperators" :add-fuc="addEnvironment" :data="environments" :item-operators="environmentOperators" :add-fuc="addEnvironment"
:delete-fuc="deleteEnvironment" @itemSelected="environmentSelected" ref="environmentItems"/> :delete-fuc="deleteEnvironment" @itemSelected="environmentSelected" ref="environmentItems"/>
<environment-edit :if-create="ifCreate" :environment="currentEnvironment" ref="environmentEdit" @close="close" :is-read-only="isReadOnly"/> <environment-edit :if-create="ifCreate" :environment="currentEnvironment" ref="environmentEdit" @close="close"
:is-read-only="isReadOnly"/>
</el-container> </el-container>
</el-dialog> </el-dialog>
</template> </template>
@ -21,7 +22,7 @@
import MsMainContainer from "../../../../common/components/MsMainContainer"; import MsMainContainer from "../../../../common/components/MsMainContainer";
import MsAsideItem from "../../../../common/components/MsAsideItem"; import MsAsideItem from "../../../../common/components/MsAsideItem";
import EnvironmentEdit from "./EnvironmentEdit"; import EnvironmentEdit from "./EnvironmentEdit";
import {deepClone, hasPermission, listenGoBack, removeGoBackListener} from "@/common/js/utils"; import {hasPermission, listenGoBack, removeGoBackListener} from "@/common/js/utils";
import {Environment, parseEnvironment} from "../../model/EnvironmentModel"; import {Environment, parseEnvironment} from "../../model/EnvironmentModel";
export default { export default {
@ -52,6 +53,7 @@
], ],
selectEnvironmentId: '', selectEnvironmentId: '',
ifCreate: false, // ifCreate: false, //
isCopy: false
} }
}, },
computed: { computed: {
@ -74,13 +76,13 @@
this.$success(this.$t('commons.delete_success')); this.$success(this.$t('commons.delete_success'));
this.getEnvironments(); this.getEnvironments();
}); });
} } else {
else {
this.environments.splice(index, 1); this.environments.splice(index, 1);
} }
}, },
copyEnvironment(environment) { copyEnvironment(environment) {
this.ifCreate = false; this.ifCreate = false;
this.isCopy = true;
this.currentEnvironment = environment; this.currentEnvironment = environment;
if (!environment.id) { if (!environment.id) {
this.$warning(this.$t('commons.please_save')); this.$warning(this.$t('commons.please_save'));
@ -94,7 +96,7 @@
return; return;
} }
this.$refs.environmentEdit._save(newEnvironment); this.$refs.environmentEdit._save(newEnvironment);
this.environments.push(newEnvironment); this.environments.unshift(newEnvironment);
this.$refs.environmentItems.itemSelected(this.environments.length - 1, newEnvironment); this.$refs.environmentItems.itemSelected(this.environments.length - 1, newEnvironment);
}, },
validateEnvironment(environment) { validateEnvironment(environment) {
@ -157,9 +159,12 @@
}, },
close() { close() {
this.$emit('close'); this.$emit('close');
if (!this.isCopy) {
this.visible = false; this.visible = false;
}
this.$refs.environmentEdit.clearValidate(); this.$refs.environmentEdit.clearValidate();
removeGoBackListener(this.close); removeGoBackListener(this.close);
this.isCopy = false;
} }
} }
} }

View File

@ -7,7 +7,8 @@
:data="environments" :item-operators="environmentOperators" :add-fuc="addEnvironment" :data="environments" :item-operators="environmentOperators" :add-fuc="addEnvironment"
:env-add-permission="ENV_CREATE" :env-add-permission="ENV_CREATE"
:delete-fuc="deleteEnvironment" @itemSelected="environmentSelected" ref="environmentItems"/> :delete-fuc="deleteEnvironment" @itemSelected="environmentSelected" ref="environmentItems"/>
<environment-edit :if-create="ifCreate" :project-id="projectId" :environment="currentEnvironment" ref="environmentEdit" :is-read-only="isReadOnly" <environment-edit :if-create="ifCreate" :project-id="projectId" :environment="currentEnvironment"
ref="environmentEdit" :is-read-only="isReadOnly"
@confirm="save" @confirm="save"
@close="close"/> @close="close"/>
</el-container> </el-container>
@ -23,7 +24,7 @@
import MsMainContainer from "../../../common/components/MsMainContainer"; import MsMainContainer from "../../../common/components/MsMainContainer";
import MsAsideItem from "../../../common/components/MsAsideItem"; import MsAsideItem from "../../../common/components/MsAsideItem";
import EnvironmentEdit from "./environment/EnvironmentEdit"; import EnvironmentEdit from "./environment/EnvironmentEdit";
import {deepClone, hasPermission, listenGoBack, removeGoBackListener} from "../../../../../common/js/utils"; import {hasPermission, listenGoBack, removeGoBackListener} from "../../../../../common/js/utils";
import {Environment, parseEnvironment} from "../model/EnvironmentModel"; import {Environment, parseEnvironment} from "../model/EnvironmentModel";
import MsDialogHeader from "@/business/components/common/components/MsDialogHeader"; import MsDialogHeader from "@/business/components/common/components/MsDialogHeader";
@ -57,6 +58,7 @@
], ],
selectEnvironmentId: '', selectEnvironmentId: '',
ifCreate: false, // ifCreate: false, //
isCopy: false
} }
}, },
props: { props: {
@ -97,13 +99,13 @@
this.$success(this.$t('commons.delete_success')); this.$success(this.$t('commons.delete_success'));
this.getEnvironments(); this.getEnvironments();
}); });
} } else {
else {
this.environments.splice(index, 1); this.environments.splice(index, 1);
} }
}, },
copyEnvironment(environment) { copyEnvironment(environment) {
this.ifCreate = false; this.ifCreate = false;
this.isCopy = true;
// //
this.environmentSelected(environment); this.environmentSelected(environment);
this.currentEnvironment = environment; this.currentEnvironment = environment;
@ -119,7 +121,7 @@
return; return;
} }
this.$refs.environmentEdit._save(newEnvironment); this.$refs.environmentEdit._save(newEnvironment);
this.environments.push(newEnvironment); this.environments.unshift(newEnvironment);
this.$refs.environmentItems.itemSelected(this.environments.length - 1, newEnvironment); this.$refs.environmentItems.itemSelected(this.environments.length - 1, newEnvironment);
}, },
validateEnvironment(environment) { validateEnvironment(environment) {
@ -185,9 +187,12 @@
}, },
close() { close() {
this.$emit('close'); this.$emit('close');
if (!this.isCopy) {
this.visible = false; this.visible = false;
}
this.$refs.environmentEdit.clearValidate(); this.$refs.environmentEdit.clearValidate();
removeGoBackListener(this.close); removeGoBackListener(this.close);
this.isCopy = false;
} }
} }
} }