fix(接口测试): 修复环境变量批量删除失效的缺陷

--bug=1019659 --user=王孝刚 【接口测试】环境变量批量删除,没有变量名称的删不掉
https://www.tapd.cn/55049933/s/1296980
This commit is contained in:
wxg0103 2022-11-16 17:56:47 +08:00 committed by wxg0103
parent 1f5e0bf2f0
commit f703667a67
1 changed files with 9 additions and 6 deletions

View File

@ -76,7 +76,7 @@
<el-switch v-model="scope.row.enable" size="mini"/> <el-switch v-model="scope.row.enable" size="mini"/>
<el-tooltip effect="dark" :content="$t('commons.remove')" placement="top-start"> <el-tooltip effect="dark" :content="$t('commons.remove')" placement="top-start">
<el-button icon="el-icon-delete" type="danger" circle size="mini" style="margin-left: 10px" <el-button icon="el-icon-delete" type="danger" circle size="mini" style="margin-left: 10px"
@click="remove(scope.row)" v-if="scope.row.name"/> @click="remove(scope.row)" v-if="isDisable(scope.row)"/>
</el-tooltip> </el-tooltip>
<el-tooltip effect="dark" :content="$t('schema.adv_setting')" placement="top-start"> <el-tooltip effect="dark" :content="$t('schema.adv_setting')" placement="top-start">
<el-button icon="el-icon-setting" circle size="mini" style="margin-left: 10px" <el-button icon="el-icon-setting" circle size="mini" style="margin-left: 10px"
@ -247,9 +247,11 @@ export default {
operationConfirm(this, this.$t('api_test.environment.variables_delete_info') + " ", () => { operationConfirm(this, this.$t('api_test.environment.variables_delete_info') + " ", () => {
let ids = this.$refs.variableTable.selectRows; let ids = this.$refs.variableTable.selectRows;
ids.forEach(row => { ids.forEach(row => {
if (row.name) { if (row.id) {
const index = this.variables.findIndex(d => d.name === row.name); const index = this.variables.findIndex(d => d.id === row.id);
this.variables.splice(index, 1); if (index !== this.variables.length - 1) {
this.variables.splice(index, 1);
}
} }
}); });
this.sortParameters(); this.sortParameters();
@ -276,8 +278,9 @@ export default {
openSetting(data) { openSetting(data) {
this.$refs.apiVariableSetting.open(data); this.$refs.apiVariableSetting.open(data);
}, },
isDisable: function (index) { isDisable: function (row) {
return this.items.length - 1 === index; const index = this.variables.findIndex(d => d.name === row.name);
return this.variables.length - 1 !== index;
}, },
_handleBatchVars(data) { _handleBatchVars(data) {
let params = data.split("\n"); let params = data.split("\n");