UNPKG

react-antd-table-rowspan

Version:

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

24 lines (23 loc) 1.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** TreeData查找所有父级 */ function TreeDataFindParent(_a) { var _b = _a.origin, origin = _b === void 0 ? [] : _b, _c = _a.fieldName, fieldName = _c === void 0 ? 'id' : _c, _d = _a.childrenName, childrenName = _d === void 0 ? 'children' : _d, _e = _a.value, value = _e === void 0 ? '' : _e, _f = _a.needFieldName, needFieldName = _f === void 0 ? fieldName : _f; var temp = []; function loop(arr, value) { arr.forEach(function (x) { if (Array.isArray(x[childrenName]) && x[childrenName].length) { if (x[childrenName].map(function (y) { return y[fieldName]; }).includes(value)) { temp.push(x[needFieldName]); loop(origin, x[fieldName]); } else { loop(x[childrenName], value); } } }); } loop(origin, value); return temp; } exports.default = TreeDataFindParent;