优化树形表格
This commit is contained in:
@@ -1,5 +1,13 @@
|
|||||||
# Changelog
|
# 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)
|
## [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)
|
[Full Changelog](https://github.com/peng92055/smart-table/compare/1.2.1...1.2.2)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ module.exports = merge(common, {
|
|||||||
inject: 'head'
|
inject: 'head'
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
devtool: 'inline-source-map',
|
devtool: 'cheap-module-eval-source-map',
|
||||||
devServer: {
|
devServer: {
|
||||||
contentBase: './examples'
|
contentBase: './examples'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ module.exports = merge(common, {
|
|||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
},
|
},
|
||||||
|
devtool: 'cheap-module-source-map',
|
||||||
plugins: [
|
plugins: [
|
||||||
new CleanWebpackPlugin(),
|
new CleanWebpackPlugin(),
|
||||||
new webpack.BannerPlugin(`smartTable v${pkg.version} | (c) pengyajun 2020 | Released under the MIT License.`),
|
new webpack.BannerPlugin(`smartTable v${pkg.version} | (c) pengyajun 2020 | Released under the MIT License.`),
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ module.exports = merge(common, {
|
|||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
},
|
},
|
||||||
|
devtool: 'cheap-module-source-map',
|
||||||
plugins: [
|
plugins: [
|
||||||
new CleanWebpackPlugin(),
|
new CleanWebpackPlugin(),
|
||||||
new webpack.BannerPlugin(`smartTable v${pkg.version} | (c) pengyajun 2020 | Released under the MIT License.`)
|
new webpack.BannerPlugin(`smartTable v${pkg.version} | (c) pengyajun 2020 | Released under the MIT License.`)
|
||||||
|
|||||||
3
dist/smartTable.min.js
vendored
3
dist/smartTable.min.js
vendored
File diff suppressed because one or more lines are too long
1
dist/smartTable.min.js.map
vendored
Normal file
1
dist/smartTable.min.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"smartTable.min.js","sources":["webpack:///smartTable.min.js"],"mappings":"AACA","sourceRoot":""}
|
||||||
@@ -174,6 +174,7 @@ function layout(vm, table) {
|
|||||||
height: tbodyWrapperHeight + "px"
|
height: tbodyWrapperHeight + "px"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
vm.size.tbodyWrapperHeight = tbodyWrapperHeight;
|
vm.size.tbodyWrapperHeight = tbodyWrapperHeight;
|
||||||
|
|
||||||
//垂直方向是否有滚动条
|
//垂直方向是否有滚动条
|
||||||
@@ -667,25 +668,28 @@ function initExpand(vm, tbody) {
|
|||||||
const expandAll = vm.options.defaultExpandAll;
|
const expandAll = vm.options.defaultExpandAll;
|
||||||
let data = [];
|
let data = [];
|
||||||
let parents = [];
|
let parents = [];
|
||||||
|
let parentIds = [];
|
||||||
querySelectorAll(tbody, "tr").forEach(row => {
|
querySelectorAll(tbody, "tr").forEach(row => {
|
||||||
let paddingLength = parents.length;
|
let paddingLength = parents.length;
|
||||||
let expand = hasAttribute(row, "expand");
|
let expand = hasAttribute(row, "expand");
|
||||||
let hasParent = hasAttribute(row, "expand-parent");
|
let hasParent = hasAttribute(row, "expand-parent");
|
||||||
|
let expandParentId = getAttribute(row, "expand-parent");
|
||||||
|
if (parentIds.indexOf(expandParentId) === -1) {
|
||||||
|
hasParent = false;
|
||||||
|
}
|
||||||
let node = {
|
let node = {
|
||||||
$el: row,
|
$el: row,
|
||||||
id: getAttribute(row, "expand"),
|
id: getAttribute(row, "expand"),
|
||||||
expand: expand
|
expand: expand
|
||||||
};
|
};
|
||||||
if (expand) {
|
if (expand) {
|
||||||
if (expandAll) {
|
expandAll ? setAttribute(row, 'expanded') : removeAttribute(row, 'expanded');
|
||||||
setAttribute(row, 'expanded')
|
|
||||||
} else {
|
|
||||||
removeAttribute(row, 'expanded')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expand && !hasParent) {
|
if (expand && !hasParent) {
|
||||||
node.children = [];
|
node.children = [];
|
||||||
parents = [node];
|
parents = [node];
|
||||||
|
parentIds.push(node.id)
|
||||||
data.push(node);
|
data.push(node);
|
||||||
} else if (hasParent) {
|
} else if (hasParent) {
|
||||||
let parentId = getAttribute(row, "expand-parent");
|
let parentId = getAttribute(row, "expand-parent");
|
||||||
@@ -702,6 +706,7 @@ function initExpand(vm, tbody) {
|
|||||||
parent && parent.children.push(node);
|
parent && parent.children.push(node);
|
||||||
if (expand) {
|
if (expand) {
|
||||||
parents.push(node)
|
parents.push(node)
|
||||||
|
parentIds.push(node.id)
|
||||||
node.children = [];
|
node.children = [];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -720,6 +725,9 @@ function initExpand(vm, tbody) {
|
|||||||
styled(vm.$tbodyWrapper, {
|
styled(vm.$tbodyWrapper, {
|
||||||
height: ''
|
height: ''
|
||||||
})
|
})
|
||||||
|
styled(vm.$tbodyWrapper, {
|
||||||
|
maxHeight: vm.size.tbodyWrapperHeight + 'px'
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function initData(vm, tbody) {
|
function initData(vm, tbody) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "smart-table",
|
"name": "smart-table",
|
||||||
"version": "1.2.2",
|
"version": "1.2.3",
|
||||||
"description": "smart table for static html",
|
"description": "smart table for static html",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user