refactor(接口自动化): 环境变量增加批量添加
This commit is contained in:
parent
e1e98a8a24
commit
bc133e8fd0
|
@ -3,6 +3,13 @@
|
|||
<span class="kv-description" v-if="description">
|
||||
{{ description }}
|
||||
</span>
|
||||
<div style="padding-bottom: 10px;">
|
||||
<el-link style="float: right;" @click="batchAdd" type="primary" :disabled="isReadOnly">
|
||||
{{ $t("commons.batch_add") }}
|
||||
</el-link>
|
||||
</div>
|
||||
<div style="display: none;">nothing</div>
|
||||
<div>
|
||||
<div class="kv-row" v-for="(item, index) in items" :key="index">
|
||||
<el-row type="flex" :gutter="20" justify="space-between" align="middle">
|
||||
<el-col class="kv-checkbox">
|
||||
|
@ -30,15 +37,18 @@
|
|||
</el-row>
|
||||
</div>
|
||||
</div>
|
||||
<batch-add-parameter @batchSave="batchSave" ref="batchAdd"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {KeyValue} from "../model/ScenarioModel";
|
||||
import MsApiVariableInput from "./ApiVariableInput";
|
||||
import BatchAddParameter from "@/business/components/api/definition/components/basis/BatchAddParameter";
|
||||
|
||||
export default {
|
||||
name: "MsApiScenarioVariables",
|
||||
components: {MsApiVariableInput},
|
||||
components: {BatchAddParameter, MsApiVariableInput},
|
||||
props: {
|
||||
description: String,
|
||||
items: Array,
|
||||
|
@ -56,8 +66,7 @@
|
|||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
}
|
||||
return {};
|
||||
},
|
||||
methods: {
|
||||
remove: function (index) {
|
||||
|
@ -86,14 +95,48 @@
|
|||
isDisable: function (index) {
|
||||
return this.items.length - 1 === index;
|
||||
},
|
||||
_handleBatchVars(data) {
|
||||
let params = data.split("\n");
|
||||
let keyValues = [];
|
||||
params.forEach(item => {
|
||||
let line = item.split(/,|,/);
|
||||
let required = false;
|
||||
if (line[1] === '必填' || line[1] === 'true') {
|
||||
required = true;
|
||||
}
|
||||
keyValues.push(new KeyValue({
|
||||
name: line[0],
|
||||
required: required,
|
||||
value: line[2],
|
||||
description: line[3],
|
||||
type: "text",
|
||||
valid: false,
|
||||
file: false,
|
||||
encode: true,
|
||||
enable: true,
|
||||
contentType: "text/plain"
|
||||
}));
|
||||
});
|
||||
return keyValues;
|
||||
},
|
||||
batchAdd() {
|
||||
this.$refs.batchAdd.open();
|
||||
},
|
||||
batchSave(data) {
|
||||
if (data) {
|
||||
let keyValues = this._handleBatchVars(data);
|
||||
keyValues.forEach(item => {
|
||||
this.items.unshift(item);
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
created() {
|
||||
if (this.items.length === 0) {
|
||||
this.items.push(new KeyValue({enable: true}));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
|
Loading…
Reference in New Issue