fix: 优化环境编辑
This commit is contained in:
parent
cb3fa9dfa1
commit
04e27d27c8
|
@ -50,19 +50,34 @@
|
||||||
this.getEnvironments();
|
this.getEnvironments();
|
||||||
},
|
},
|
||||||
deleteEnvironment(environment) {
|
deleteEnvironment(environment) {
|
||||||
this.result = this.$get('/api/environment/delete/' + environment.id, response => {
|
if (environment.id) {
|
||||||
this.$success(this.$t('commons.delete_success'));
|
this.result = this.$get('/api/environment/delete/' + environment.id, () => {
|
||||||
this.getEnvironments();
|
this.$success(this.$t('commons.delete_success'));
|
||||||
});
|
this.getEnvironments();
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
copyEnvironment(environment) {
|
copyEnvironment(environment) {
|
||||||
let newEnvironment = {};
|
let newEnvironment = {};
|
||||||
Object.assign(newEnvironment, environment);
|
Object.assign(newEnvironment, environment);
|
||||||
newEnvironment.id = null;
|
newEnvironment.id = null;
|
||||||
|
newEnvironment.name = this.getNoRepeatName(newEnvironment.name);
|
||||||
|
this.$refs.environmentEdit._save(newEnvironment);
|
||||||
this.environments.push(newEnvironment);
|
this.environments.push(newEnvironment);
|
||||||
|
this.$refs.environmentItems.itemSelected(this.environments.length -1 , newEnvironment);
|
||||||
|
},
|
||||||
|
getNoRepeatName(name) {
|
||||||
|
for (let i in this.environments) {
|
||||||
|
if (this.environments[i].name === name) {
|
||||||
|
return this.getNoRepeatName(name + ' copy');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return name;
|
||||||
},
|
},
|
||||||
addEnvironment() {
|
addEnvironment() {
|
||||||
this.environments.push(this.getDefaultEnvironment());
|
let newEnvironment = this.getDefaultEnvironment();
|
||||||
|
this.environments.push(newEnvironment);
|
||||||
|
this.$refs.environmentItems.itemSelected(this.environments.length -1 , newEnvironment);
|
||||||
},
|
},
|
||||||
environmentSelected(environment) {
|
environmentSelected(environment) {
|
||||||
this.getEnvironment(environment);
|
this.getEnvironment(environment);
|
||||||
|
@ -97,6 +112,7 @@
|
||||||
close() {
|
close() {
|
||||||
this.$emit('close');
|
this.$emit('close');
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
|
this.$refs.environmentEdit.clearValidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,7 +132,4 @@
|
||||||
height: 100%;
|
height: 100%;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -78,30 +78,30 @@
|
||||||
save() {
|
save() {
|
||||||
this.$refs['from'].validate((valid) => {
|
this.$refs['from'].validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
this._save();
|
this._save(this.environment);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
_save() {
|
_save(environment) {
|
||||||
let param = this.buildParam();
|
let param = this.buildParam(environment);
|
||||||
let url = '/api/environment/add';
|
let url = '/api/environment/add';
|
||||||
if (param.id) {
|
if (param.id) {
|
||||||
url = '/api/environment/update';
|
url = '/api/environment/update';
|
||||||
}
|
}
|
||||||
this.result = this.$post(url, param, response => {
|
this.result = this.$post(url, param, response => {
|
||||||
if (!param.id) {
|
if (!param.id) {
|
||||||
this.environment.id = response.data;
|
environment.id = response.data;
|
||||||
}
|
}
|
||||||
this.$success(this.$t('commons.save_success'));
|
this.$success(this.$t('commons.save_success'));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
buildParam() {
|
buildParam(environment) {
|
||||||
let param = {};
|
let param = {};
|
||||||
Object.assign(param, this.environment);
|
Object.assign(param, environment);
|
||||||
param.variables = JSON.stringify(this.environment.variables);
|
param.variables = JSON.stringify(environment.variables);
|
||||||
param.headers = JSON.stringify(this.environment.headers);
|
param.headers = JSON.stringify(environment.headers);
|
||||||
return param;
|
return param;
|
||||||
},
|
},
|
||||||
validateSocket(socket) {
|
validateSocket(socket) {
|
||||||
|
@ -135,6 +135,9 @@
|
||||||
},
|
},
|
||||||
cancel() {
|
cancel() {
|
||||||
this.$emit('close');
|
this.$emit('close');
|
||||||
|
},
|
||||||
|
clearValidate() {
|
||||||
|
this.$refs["from"].clearValidate();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,14 +10,10 @@
|
||||||
</span>
|
</span>
|
||||||
</slot>
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div :style="{'height': itemBarHeight + 'px'}" v-for="(item, index) in data" :key="index" class="item-bar" @click="itemSelected(index, item)" :class="{'item-selected' : index == selectIndex}">
|
<div :style="{'height': itemBarHeight + 'px'}" v-for="(item, index) in data" :key="index" class="item-bar" @click="itemSelected(index, item)" :class="{'item-selected' : index == selectIndex}">
|
||||||
<!-- <span :style="{'line-height': itemBarHeight - 10 + 'px'}" class="item-left">-->
|
<input class="item-input" :style="{'height': itemBarHeight - 12 + 'px', 'line-height': itemBarHeight - 12 + 'px', 'width': width - 90 + 'px'}" v-model="item.name" :placeholder="$t('commons.input_content')"/>
|
||||||
<!--<!– {{item.name}}–>-->
|
|
||||||
<!-- </span>-->
|
|
||||||
<input class="item-input" :style="{'height': itemBarHeight - 12 + 'px', 'line-height': itemBarHeight - 12 + 'px', 'width': width - 90 + 'px'}" v-model="item.name" placeholder="请输入内容"/>
|
|
||||||
<span :style="{'line-height': itemBarHeight - 10 + 'px'}" class="item-right">
|
<span :style="{'line-height': itemBarHeight - 10 + 'px'}" class="item-right">
|
||||||
<i v-for="(operator, index) in itemOperators" :key="index" :class="operator.icon" @click="operator.func(item)"/>
|
<i v-for="(operator, index) in itemOperators" :key="index" :class="operator.icon" @click.stop="operator.func(item)"/>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</ms-aside-container>
|
</ms-aside-container>
|
||||||
|
|
Loading…
Reference in New Issue