优化树形表格

This commit is contained in:
julyp
2020-05-06 11:08:37 +08:00
parent 06fbfac3d8
commit e326621f44
8 changed files with 28 additions and 8 deletions

View File

@@ -1,5 +1,13 @@
# Changelog
## [1.2.3](https://github.com/peng92055/smart-table/tree/1.2.3) (2020-05-06)
[Full Changelog](https://github.com/peng92055/smart-table/compare/1.2.2...1.2.3)
- 优化树形表格含有非法expand-parent
- 优化树形表格支持自定义高度控制
- 修复expand中多标签bug
## [1.2.2](https://github.com/peng92055/smart-table/tree/1.2.2) (2020-02-19)
[Full Changelog](https://github.com/peng92055/smart-table/compare/1.2.1...1.2.2)

View File

@@ -10,7 +10,7 @@ module.exports = merge(common, {
inject: 'head'
})
],
devtool: 'inline-source-map',
devtool: 'cheap-module-eval-source-map',
devServer: {
contentBase: './examples'
}

View File

@@ -23,6 +23,7 @@ module.exports = merge(common, {
}
}],
},
devtool: 'cheap-module-source-map',
plugins: [
new CleanWebpackPlugin(),
new webpack.BannerPlugin(`smartTable v${pkg.version} | (c) pengyajun 2020 | Released under the MIT License.`),

View File

@@ -21,6 +21,7 @@ module.exports = merge(common, {
}
}],
},
devtool: 'cheap-module-source-map',
plugins: [
new CleanWebpackPlugin(),
new webpack.BannerPlugin(`smartTable v${pkg.version} | (c) pengyajun 2020 | Released under the MIT License.`)

File diff suppressed because one or more lines are too long

1
dist/smartTable.min.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"smartTable.min.js","sources":["webpack:///smartTable.min.js"],"mappings":"AACA","sourceRoot":""}

View File

@@ -174,6 +174,7 @@ function layout(vm, table) {
height: tbodyWrapperHeight + "px"
})
vm.size.tbodyWrapperHeight = tbodyWrapperHeight;
//垂直方向是否有滚动条
@@ -667,25 +668,28 @@ function initExpand(vm, tbody) {
const expandAll = vm.options.defaultExpandAll;
let data = [];
let parents = [];
let parentIds = [];
querySelectorAll(tbody, "tr").forEach(row => {
let paddingLength = parents.length;
let expand = hasAttribute(row, "expand");
let hasParent = hasAttribute(row, "expand-parent");
let expandParentId = getAttribute(row, "expand-parent");
if (parentIds.indexOf(expandParentId) === -1) {
hasParent = false;
}
let node = {
$el: row,
id: getAttribute(row, "expand"),
expand: expand
};
if (expand) {
if (expandAll) {
setAttribute(row, 'expanded')
} else {
removeAttribute(row, 'expanded')
}
expandAll ? setAttribute(row, 'expanded') : removeAttribute(row, 'expanded');
}
if (expand && !hasParent) {
node.children = [];
parents = [node];
parentIds.push(node.id)
data.push(node);
} else if (hasParent) {
let parentId = getAttribute(row, "expand-parent");
@@ -702,6 +706,7 @@ function initExpand(vm, tbody) {
parent && parent.children.push(node);
if (expand) {
parents.push(node)
parentIds.push(node.id)
node.children = [];
}
} else {
@@ -720,6 +725,9 @@ function initExpand(vm, tbody) {
styled(vm.$tbodyWrapper, {
height: ''
})
styled(vm.$tbodyWrapper, {
maxHeight: vm.size.tbodyWrapperHeight + 'px'
})
}
function initData(vm, tbody) {

View File

@@ -1,6 +1,6 @@
{
"name": "smart-table",
"version": "1.2.2",
"version": "1.2.3",
"description": "smart table for static html",
"main": "index.js",
"scripts": {