fix(系统设置): 批量添加全局变量错误

--bug=1008074 --user=王孝刚 【系统设置】批量添加全局变量错误 https://www.tapd.cn/55049933/s/1070140
This commit is contained in:
wxg0103 2021-11-18 19:34:49 +08:00 committed by 刘瑞斌
parent bb5646bdee
commit 521f8e9963
3 changed files with 19 additions and 11 deletions

View File

@ -54,6 +54,7 @@
confirm() {
this.dialogVisible = false;
this.$emit("batchSave", this.parameters);
this.parameters = "";
}
}
}

View File

@ -307,7 +307,7 @@ export default {
let required = false;
keyValues.unshift(new KeyValue({
name: line[0],
required: required,
required: !required,
value: line[1],
description: line[2],
type: "text",

View File

@ -109,16 +109,13 @@ export default {
let params = data.split("\n");
let keyValues = [];
params.forEach(item => {
let line = item.split(/|,/);
let line = item.split(/|:/);
let required = false;
if (line[1] === '必填' || line[1] === 'Required' || line[1] === 'true') {
required = true;
}
keyValues.push(new KeyValue({
keyValues.unshift(new KeyValue({
name: line[0],
required: required,
value: line[2],
description: line[3],
value: line[1],
description: line[2],
type: "text",
valid: false,
file: false,
@ -135,9 +132,19 @@ export default {
batchSave(data) {
if (data) {
let keyValues = this._handleBatchVars(data);
keyValues.forEach(item => {
this.items.unshift(item);
});
keyValues.forEach(keyValue => {
let isAdd = true;
for (let i in this.items) {
let item = this.items[i];
if (item.name === keyValue.name) {
item.value = keyValue.value;
isAdd = false;
}
}
if (isAdd) {
this.items.unshift(keyValue);
}
})
}
},
},