fix: 修复上传json文件上传问题

This commit is contained in:
Jiangjie.Bai
2022-08-19 11:36:34 +08:00
parent 04465a1da3
commit e2eac83615
2 changed files with 7 additions and 3 deletions

View File

@@ -50,7 +50,7 @@ export default {
const reader = new FileReader()
reader.onload = function() {
let result = this.result
if (vm.toFormat === 'object') {
if (vm.toFormat === 'object' && vm.fileName.endsWith('.json')) {
result = JSON.parse(result)
}
vm.$emit('input', result)

View File

@@ -91,13 +91,17 @@ export default {
const attrs = values.attrs
for (const item of encryptedFields) {
const value = attrs[item]
if (value) {
attrs[item] = encryptPassword(value)
if (!value) {
continue
}
attrs[item] = encryptPassword(value)
}
const toListFields = ['ip_group']
for (const item of toListFields) {
let value = attrs[item]
if (!value) {
continue
}
value = value?.split(',') || []
value = value.filter((value, index) => { if (value) return true })
attrs[item] = value