1
This commit is contained in:
@@ -194,18 +194,24 @@ export default {
|
||||
.forEach((col) => {
|
||||
let defaultVal = row[col.key]
|
||||
|
||||
// 如果值是 undefined 或 null,不赋值,保持原状态
|
||||
if (defaultVal === undefined || defaultVal === null) {
|
||||
return
|
||||
}
|
||||
|
||||
// 传递过来什么值就保持什么值
|
||||
if (col.data_type === 'number') {
|
||||
defaultVal = parseFloat(defaultVal) || 0
|
||||
Vue.set(this.row, col.key, defaultVal)
|
||||
// 保持原始数值,包括 0
|
||||
const numVal = parseFloat(defaultVal)
|
||||
Vue.set(this.row, col.key, isNaN(numVal) ? defaultVal : numVal)
|
||||
} else if (col.data_type === 'date') {
|
||||
Vue.set(this.row, col.key, dayjs(defaultVal).toDate())
|
||||
} else if (col.data_type === 'boolean') {
|
||||
Vue.set(this.row, col.key, defaultVal === 1 || defaultVal === true)
|
||||
// 保持原始布尔值,包括 false
|
||||
Vue.set(this.row, col.key, defaultVal === 1 || defaultVal === true || defaultVal === '1')
|
||||
} else {
|
||||
// 如果值没有填写(undefined 或 null),不设置为空字符串
|
||||
if (defaultVal !== undefined && defaultVal !== null) {
|
||||
Vue.set(this.row, col.key, defaultVal)
|
||||
}
|
||||
// 保持原始值,包括空字符串 ''
|
||||
Vue.set(this.row, col.key, defaultVal)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user