优化 `treeTable.addNodes()` 方法参数,采用 `options` 形式

pull/1226/head
贤心 2023-04-21 08:59:48 +08:00
parent 9dd893ebaf
commit 2ca56ae5ee
1 changed files with 10 additions and 1 deletions

View File

@ -993,12 +993,21 @@ layui.define(['table'], function (exports) {
* @param {Boolean} focus 新增的节点单个或者多个
* @return {Array} 新增的节点
* */
treeTable.addNodes = function (id, parentIndex, index, newNodes, focus) {
treeTable.addNodes = function (id, opts) {
var that = getThisTable(id);
if(!that) return;
var options = that.getOptions();
var treeOptions = options.tree;
var tableViewElem = options.elem.next();
opts = opts || {};
var parentIndex = opts.parentIndex;
var index = opts.index;
var newNodes = opts.newNodes;
var focus = opts.focus;
parentIndex = layui.type(parentIndex) === 'number' ? parentIndex.toString() : parentIndex;
var parentNode = parentIndex ? that.getNodeDataByIndex(parentIndex) : null;
index = layui.type(index) === 'number' ? index : -1;