提交 8d282b9b 编写于 作者: 沐夕花开's avatar 沐夕花开

1. fix: 修复树形结构下三层以上结构,收起子级无法正确工作的bug。

2. 模式调整:
> columns[item].columnFmt = currency 时 现在会拼接单位(columnNumberCount),在后缀(suffix)的前面
> columns[item].columnUnit = '万' | '亿' 的时候会自动将数据除以对应的比例
上级 8900da89
## 1.3.2(2022-05-30)
1. fix: 修复树形结构下三层以上结构,收起子级无法正确工作的bug。
2. 模式调整:
> columns[item].columnFmt = currency 时 现在会拼接单位(columnNumberCount),在后缀(suffix)的前面
> columns[item].columnUnit = '万' | '亿' 的时候会自动将数据除以对应的比例
## 1.3.1(2022-05-27)
表格名称右侧的菜单按钮改了。
修复一些小bug
......
......@@ -293,22 +293,31 @@
this.openList.push(row[this.idKey]);
} else {
// 收起
this.closeChild(row[this.idKey])
this.closeItem(row)
}
// 判断更新是否已经全部关闭/打开了
this.checkIsAll()
},
// 收起所有子行
closeChild(id) {
let idx = this.openList.findIndex(item => item == id)
// 移除自身
this.openList.splice(idx, 1)
// 移除子项
this.canOpenObj[id] && this.canOpenObj[id].forEach(item => {
idx = this.openList.findIndex(key => key == item)
closeItem(row) {
let closeIds = this.getChildIds([], row)
let idx = -1
while (closeIds.length) {
let delItem = closeIds.pop()
idx = this.openList.findIndex(it => it === delItem)
if (idx >= 0) this.openList.splice(idx, 1)
})
}
},
// 获取所有子项 ID
getChildIds(result, item) {
if (item.children) {
result.push(String(item[this.idKey]))
item.children.forEach(it => {
this.getChildIds(result, it)
})
}
return result
},
// 格式化数字
......@@ -360,13 +369,13 @@
// 存在映射值则直接返回
if (tempHTML) return tempHTML.toString()
}
// 自动处理数字
if(formatNum){
if (formatNum) {
tempHTML = isNaN(celValue - 0) || !formatNum ? celValue : this.numTransform(celValue - 0)
return tempHTML.toString()
}
result = this.fmtValue({
value: celValue,
columnFmt,
......@@ -376,7 +385,7 @@
prefix,
suffix
})
return result.toString()
},
......@@ -395,7 +404,8 @@
if (columnFmt === 'number') {
// 数字类型
if (!isNumber) return value
if (this.isValidData(columnNumberCount)) tempResult = numValue.toFixed(Number(columnNumberCount))
if (columnUnit) tempResult = this.transformUnit(numValue, columnUnit)
if (this.isValidData(columnNumberCount)) tempResult = tempResult.toFixed(Number(columnNumberCount))
if (useThousandth) tempResult = this.setThousandth(tempResult)
return tempResult + (columnUnit ? columnUnit : '')
......@@ -408,7 +418,7 @@
} else if (columnFmt === 'scientific') {
// 科学计算型:
if(!isNumber) return value
if (!isNumber) return value
let p = Math.floor(Math.log(numValue) / Math.LN10);
let n = numValue * Math.pow(10, -p);
return n + 'e' + p
......@@ -419,16 +429,39 @@
// 前缀 后缀
return `${prefix || ''}${value}${suffix || ''}`
}
if (columnUnit) tempResult = this.transformUnit(numValue, columnUnit)
// 小数位
if (isNumber && this.isValidData(columnNumberCount)) {
tempResult = numValue.toFixed(Number(columnNumberCount))
tempResult = tempResult.toFixed(Number(columnNumberCount))
}
// 是否使用千分位
if (isNumber && useThousandth) {
tempResult = this.setThousandth(tempResult)
}
return `${prefix || ''}${tempResult}${suffix || ''}`
return `${prefix || ''}${tempResult}${columnUnit || ''}${suffix || ''}`
}
},
// 根据单位处理数据
transformUnit(val, unit) {
let fmtRes = Number(val)
switch (unit) {
case '':
fmtRes = val / 10000
break;
case '亿':
fmtRes = val / 100000000
break;
case 'K':
break;
case 'M':
break;
case 'G':
break
default:
break;
}
return fmtRes
},
// 千分位
......
{
"id": "n-table",
"displayName": "n-table 多级表头、树形结构,高度配置表格组件",
"version": "1.3.1",
"version": "1.3.2",
"description": "n-table 多级表头、树形结构,高度配置表格组件",
"keywords": [
"表格,多级表头,树形结构,可配置"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册