refactor(项目设置): 优化页面交互,提示无可用端口号之后,状态开关变回关闭

--bug=1014028 --user=宋天阳 【接口测试】开启TCP Mock时,默认端口号为0未随机一个可用端口号
https://www.tapd.cn/55049933/s/1182215
This commit is contained in:
song-tianyang 2022-06-15 12:23:33 +08:00 committed by f2c-ci-robot[bot]
parent ba8b017ab9
commit 406610fd15
1 changed files with 12 additions and 4 deletions

View File

@ -224,12 +224,17 @@ export default {
methods: {
tcpMockSwitchChange(value, other) {
if (value && this.config.mockTcpPort === 0) {
this.result = this.$get('/project/genTcpMockPort/' + this.projectId, res => {
let port = res.data;
this.$get('/project/genTcpMockPort/' + this.projectId).then(res => {
let port = res.data.data;
this.config.mockTcpPort = port;
this.$nextTick(() => {
this.switchChange("MOCK_TCP_OPEN", value, ['MOCK_TCP_PORT', this.config.mockTcpPort]);
})
}).catch(resp => {
this.config.mockTcpOpen = false;
if (resp.response && resp.response.data && resp.response.data.message) {
this.$error(resp.response.data.message);
}
});
} else {
this.switchChange("MOCK_TCP_OPEN", value, other);
@ -245,11 +250,14 @@ export default {
// tcp
configs.push({projectId: this.projectId, typeValue: value, type});
let params = {configs};
this.$post("/project_application/update/batch", params, () => {
this.$post("/project_application/update/batch", params).then(() => {
this.$success(this.$t('commons.save_success'));
this.init();
}, () => {
}).catch(resp => {
this.init();
if (resp.response && resp.response.data && resp.response.data.message) {
this.$error(resp.response.data.message);
}
});
},
init() {