@nokecy/qc-ui 0.1.11 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -33,7 +33,7 @@ var _utils = require("./utils");
33
33
 
34
34
  var _setting = _interopRequireDefault(require("./setting"));
35
35
 
36
- var _excluded = ["style", "params", "request", "dataSource", "rowData", "gridRef", "headerTitle", "toolBarRender", "search", "hideRedo", "onGridReady", "gridKey", "gridColumnState", "children"];
36
+ var _excluded = ["style", "params", "request", "dataSource", "treeParentName", "rowData", "gridRef", "headerTitle", "toolBarRender", "search", "hideRedo", "onGridReady", "gridKey", "gridColumnState", "children"];
37
37
 
38
38
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39
39
 
@@ -74,6 +74,7 @@ function AgGridPlus(props) {
74
74
  gridParams = props.params,
75
75
  request = props.request,
76
76
  dataSource = props.dataSource,
77
+ treeParentName = props.treeParentName,
77
78
  propRowData = props.rowData,
78
79
  propsGridRef = props.gridRef,
79
80
  headerTitle = props.headerTitle,
@@ -282,7 +283,7 @@ function AgGridPlus(props) {
282
283
  }, rest, {
283
284
  //指定客户端模式
284
285
  rowModelType: "clientSide",
285
- rowData: props.treeData ? (0, _utils.flatten)((0, _utils.toTree)(rowData)) : rowData,
286
+ rowData: props.treeData ? (0, _utils.flatten)((0, _utils.toTree)(rowData), treeParentName) : rowData,
286
287
  onGridReady: onGridReady,
287
288
  defaultColDef: defaultColDef,
288
289
  onSortChanged: function onSortChanged(event) {
@@ -11,6 +11,7 @@ interface GridProps extends AgGridReactProps {
11
11
  initParams?: any;
12
12
  request?: (params: any, sort: any, filter: any) => Promise<any>;
13
13
  dataSource?: any[];
14
+ treeParentName?: string;
14
15
  search?: boolean;
15
16
  headerTitle?: React.ReactNode;
16
17
  toolBarRender?: (gridApi?: GridApi, filter?: string, queryFilter?: any) => React.ReactNode[];
@@ -3,7 +3,7 @@ declare const convertFilterModel: (filterModel: any) => string;
3
3
  declare const convertSortModel: (sortModel: any[]) => string;
4
4
  declare const dateValueFormatter: (params: ValueFormatterParams) => string;
5
5
  declare const dateTimeValueFormatter: (params: ValueFormatterParams) => string;
6
- declare const flatten: (arr: any[], parentref?: any[]) => any;
6
+ declare const flatten: (arr: any[], parentPropName: any, parentref?: any[]) => any;
7
7
  declare const toTree: (data: any[]) => any[];
8
- declare const flattenTreeDeep: (treeData: any[]) => any[];
8
+ declare const flattenTreeDeep: (treeData: any[], childrenName?: string) => any[];
9
9
  export { dateValueFormatter, dateTimeValueFormatter, convertFilterModel, convertSortModel, flattenTreeDeep, toTree, flatten };
@@ -111,11 +111,11 @@ var dateTimeValueFormatter = function dateTimeValueFormatter(params) {
111
111
 
112
112
  exports.dateTimeValueFormatter = dateTimeValueFormatter;
113
113
 
114
- var flatten = function flatten(arr, parentref) {
114
+ var flatten = function flatten(arr, parentPropName, parentref) {
115
115
  return arr ? arr.reduce(function (result, item) {
116
116
  return [].concat(_toConsumableArray(result), [_objectSpread(_objectSpread({}, item), {}, {
117
- hierarchy: parentref ? [].concat(_toConsumableArray(parentref), [item.name]) : [item.name]
118
- })], _toConsumableArray(flatten(item.children, parentref ? [].concat(_toConsumableArray(parentref), [item.name]) : [item.name])));
117
+ hierarchya: parentref ? [].concat(_toConsumableArray(parentref), [item[parentPropName]]) : [item[parentPropName]]
118
+ })], _toConsumableArray(flatten(item.children, parentref ? [].concat(_toConsumableArray(parentref), [item[parentPropName]]) : [item[parentPropName]])));
119
119
  }, []) : [];
120
120
  };
121
121
 
@@ -149,8 +149,10 @@ var toTree = function toTree(data) {
149
149
  exports.toTree = toTree;
150
150
 
151
151
  var flattenTreeDeep = function flattenTreeDeep(treeData) {
152
+ var childrenName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'childrens';
153
+
152
154
  var getTail = function getTail(item) {
153
- return item.children && item.children.length > 0 ? item.children.map(function (m) {
155
+ return item[childrenName] && item[childrenName].length > 0 ? item[childrenName].map(function (m) {
154
156
  return getTail(m);
155
157
  }) : [item];
156
158
  };
@@ -1,4 +1,4 @@
1
- var _excluded = ["style", "params", "request", "dataSource", "rowData", "gridRef", "headerTitle", "toolBarRender", "search", "hideRedo", "onGridReady", "gridKey", "gridColumnState", "children"];
1
+ var _excluded = ["style", "params", "request", "dataSource", "treeParentName", "rowData", "gridRef", "headerTitle", "toolBarRender", "search", "hideRedo", "onGridReady", "gridKey", "gridColumnState", "children"];
2
2
 
3
3
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
4
 
@@ -47,6 +47,7 @@ function AgGridPlus(props) {
47
47
  gridParams = props.params,
48
48
  request = props.request,
49
49
  dataSource = props.dataSource,
50
+ treeParentName = props.treeParentName,
50
51
  propRowData = props.rowData,
51
52
  propsGridRef = props.gridRef,
52
53
  headerTitle = props.headerTitle,
@@ -255,7 +256,7 @@ function AgGridPlus(props) {
255
256
  }, rest, {
256
257
  //指定客户端模式
257
258
  rowModelType: "clientSide",
258
- rowData: props.treeData ? flatten(toTree(rowData)) : rowData,
259
+ rowData: props.treeData ? flatten(toTree(rowData), treeParentName) : rowData,
259
260
  onGridReady: onGridReady,
260
261
  defaultColDef: defaultColDef,
261
262
  onSortChanged: function onSortChanged(event) {
@@ -11,6 +11,7 @@ interface GridProps extends AgGridReactProps {
11
11
  initParams?: any;
12
12
  request?: (params: any, sort: any, filter: any) => Promise<any>;
13
13
  dataSource?: any[];
14
+ treeParentName?: string;
14
15
  search?: boolean;
15
16
  headerTitle?: React.ReactNode;
16
17
  toolBarRender?: (gridApi?: GridApi, filter?: string, queryFilter?: any) => React.ReactNode[];
@@ -3,7 +3,7 @@ declare const convertFilterModel: (filterModel: any) => string;
3
3
  declare const convertSortModel: (sortModel: any[]) => string;
4
4
  declare const dateValueFormatter: (params: ValueFormatterParams) => string;
5
5
  declare const dateTimeValueFormatter: (params: ValueFormatterParams) => string;
6
- declare const flatten: (arr: any[], parentref?: any[]) => any;
6
+ declare const flatten: (arr: any[], parentPropName: any, parentref?: any[]) => any;
7
7
  declare const toTree: (data: any[]) => any[];
8
- declare const flattenTreeDeep: (treeData: any[]) => any[];
8
+ declare const flattenTreeDeep: (treeData: any[], childrenName?: string) => any[];
9
9
  export { dateValueFormatter, dateTimeValueFormatter, convertFilterModel, convertSortModel, flattenTreeDeep, toTree, flatten };
@@ -94,11 +94,11 @@ var dateTimeValueFormatter = function dateTimeValueFormatter(params) {
94
94
  }; //@ts-ignore
95
95
 
96
96
 
97
- var flatten = function flatten(arr, parentref) {
97
+ var flatten = function flatten(arr, parentPropName, parentref) {
98
98
  return arr ? arr.reduce(function (result, item) {
99
99
  return [].concat(_toConsumableArray(result), [_objectSpread(_objectSpread({}, item), {}, {
100
- hierarchy: parentref ? [].concat(_toConsumableArray(parentref), [item.name]) : [item.name]
101
- })], _toConsumableArray(flatten(item.children, parentref ? [].concat(_toConsumableArray(parentref), [item.name]) : [item.name])));
100
+ hierarchya: parentref ? [].concat(_toConsumableArray(parentref), [item[parentPropName]]) : [item[parentPropName]]
101
+ })], _toConsumableArray(flatten(item.children, parentref ? [].concat(_toConsumableArray(parentref), [item[parentPropName]]) : [item[parentPropName]])));
102
102
  }, []) : [];
103
103
  };
104
104
 
@@ -128,8 +128,10 @@ var toTree = function toTree(data) {
128
128
  };
129
129
 
130
130
  var flattenTreeDeep = function flattenTreeDeep(treeData) {
131
+ var childrenName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'childrens';
132
+
131
133
  var getTail = function getTail(item) {
132
- return item.children && item.children.length > 0 ? item.children.map(function (m) {
134
+ return item[childrenName] && item[childrenName].length > 0 ? item[childrenName].map(function (m) {
133
135
  return getTail(m);
134
136
  }) : [item];
135
137
  };