UNPKG

react-antd-table-rowspan

Version:

react+antd表格指定的列,连续的,行合并

30 lines (29 loc) 1.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** 通用的treeData递归查找某一项 * @origin 原始数据默认[] * @childrenName children字段名称默认children * @fieldName 对比的字段名称默认id * @value 需要对比的值默认为空字符串 */ function TreeDataFindItem(_a) { var _b = _a.origin, origin = _b === void 0 ? [] : _b, _c = _a.childrenName, childrenName = _c === void 0 ? 'children' : _c, _d = _a.fieldName, fieldName = _d === void 0 ? 'id' : _d, _e = _a.value, value = _e === void 0 ? '' : _e; var item = null; function loop(arr) { for (var i = 0; i < arr.length; i++) { var x = arr[i]; if (x[fieldName] === value) { item = x; break; } if (Array.isArray(x[childrenName]) && x[childrenName].length) { loop(x[childrenName]); } } } loop(origin); if (item) return item; return null; } exports.default = TreeDataFindItem;