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() { confirm() {
this.dialogVisible = false; this.dialogVisible = false;
this.$emit("batchSave", this.parameters); this.$emit("batchSave", this.parameters);
this.parameters = "";
} }
} }
} }

View File

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

View File

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