@nokecy/qc-ui 0.2.10 → 0.3.0

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.
@@ -279,6 +279,11 @@ function AgGridPlus(props) {
279
279
  return !x.hideInTable;
280
280
  });
281
281
  }, []);
282
+ var allColDefs = (0, _react.useMemo)(function () {
283
+ return _react.default.Children.map(children, function (child, index) {
284
+ return child.props;
285
+ });
286
+ }, []);
282
287
  var rowDataMemo = (0, _react.useMemo)(function () {
283
288
  return props.treeData ? (0, _utils.flatten)((0, _utils.toTree)(rowData), treeParentName) : rowData;
284
289
  }, [rowData, props.treeData]);
@@ -294,6 +299,7 @@ function AgGridPlus(props) {
294
299
  height: "100%"
295
300
  }
296
301
  }, search == false ? null : /*#__PURE__*/_react.default.createElement(_queryForm.default, {
302
+ colDefs: allColDefs,
297
303
  columnStates: columnState || [],
298
304
  gridApi: apiRef.current,
299
305
  onQuery: function onQuery(formValues) {
@@ -348,6 +354,18 @@ function AgGridPlus(props) {
348
354
  },
349
355
  onSelectionChanged: onRowChanged,
350
356
  onRowSelected: onRowSelected,
357
+ onDragStopped: function onDragStopped(e) {
358
+ if (columnsRef.current) {
359
+ var _columnsRef$current2;
360
+
361
+ setColumnState((_columnsRef$current2 = columnsRef.current) === null || _columnsRef$current2 === void 0 ? void 0 : _columnsRef$current2.getColumnState());
362
+ }
363
+ } // onColumnMoved={() => {
364
+ // if (columnsRef.current) {
365
+ // setColumnState(columnsRef.current?.getColumnState());
366
+ // }
367
+ // }}
368
+ ,
351
369
  columnTypes: columnTypes,
352
370
  animateRows: true //停用默认分页组件
353
371
  ,
@@ -1,9 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { ColumnState, GridApi } from 'ag-grid-community';
2
+ import { ColDef, ColumnState, GridApi } from 'ag-grid-community';
3
3
  import './index.less';
4
4
  declare const FormRender: (props: {
5
5
  className?: any;
6
6
  gridApi?: GridApi<any> | undefined;
7
+ colDefs: ColDef[];
7
8
  columnStates: ColumnState[];
8
9
  onQuery: (formValue: any) => void;
9
10
  }) => JSX.Element;
@@ -58,6 +58,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
58
58
  var FormRender = function FormRender(props) {
59
59
  var className = props.className,
60
60
  gridApi = props.gridApi,
61
+ colDefs = props.colDefs,
61
62
  columnStates = props.columnStates,
62
63
  onQuery = props.onQuery;
63
64
 
@@ -166,13 +167,15 @@ var FormRender = function FormRender(props) {
166
167
  },
167
168
  properties: {}
168
169
  };
169
- var columns = columnStates.filter(function (x) {
170
- return !x.hide;
171
- }).map(function (columnState) {
172
- return gridApi === null || gridApi === void 0 ? void 0 : gridApi.getColumnDef(columnState.colId);
170
+ var columns = colDefs.map(function (colDef) {
171
+ var state = columnStates.find(function (x) {
172
+ return x.colId == colDef.field;
173
+ });
174
+ console.log("state", state);
175
+ return _objectSpread(_objectSpread({}, colDef), state);
173
176
  });
174
177
  columns = columns.filter(function (i) {
175
- return (i === null || i === void 0 ? void 0 : i.visible) != false && !i.hideInSearch || i.hideInTable;
178
+ return (i === null || i === void 0 ? void 0 : i.visible) != false && !(i !== null && i !== void 0 && i.hide) && !(i !== null && i !== void 0 && i.hideInSearch) || (i === null || i === void 0 ? void 0 : i.hideInTable);
176
179
  });
177
180
  columns.map(function (col) {
178
181
  var _colDef$queryField;
@@ -252,6 +252,11 @@ function AgGridPlus(props) {
252
252
  return !x.hideInTable;
253
253
  });
254
254
  }, []);
255
+ var allColDefs = useMemo(function () {
256
+ return React.Children.map(children, function (child, index) {
257
+ return child.props;
258
+ });
259
+ }, []);
255
260
  var rowDataMemo = useMemo(function () {
256
261
  return props.treeData ? flatten(toTree(rowData), treeParentName) : rowData;
257
262
  }, [rowData, props.treeData]);
@@ -267,6 +272,7 @@ function AgGridPlus(props) {
267
272
  height: "100%"
268
273
  }
269
274
  }, search == false ? null : /*#__PURE__*/React.createElement(FormRender, {
275
+ colDefs: allColDefs,
270
276
  columnStates: columnState || [],
271
277
  gridApi: apiRef.current,
272
278
  onQuery: function onQuery(formValues) {
@@ -321,6 +327,18 @@ function AgGridPlus(props) {
321
327
  },
322
328
  onSelectionChanged: onRowChanged,
323
329
  onRowSelected: onRowSelected,
330
+ onDragStopped: function onDragStopped(e) {
331
+ if (columnsRef.current) {
332
+ var _columnsRef$current2;
333
+
334
+ setColumnState((_columnsRef$current2 = columnsRef.current) === null || _columnsRef$current2 === void 0 ? void 0 : _columnsRef$current2.getColumnState());
335
+ }
336
+ } // onColumnMoved={() => {
337
+ // if (columnsRef.current) {
338
+ // setColumnState(columnsRef.current?.getColumnState());
339
+ // }
340
+ // }}
341
+ ,
324
342
  columnTypes: columnTypes,
325
343
  animateRows: true //停用默认分页组件
326
344
  ,
@@ -1,9 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { ColumnState, GridApi } from 'ag-grid-community';
2
+ import { ColDef, ColumnState, GridApi } from 'ag-grid-community';
3
3
  import './index.less';
4
4
  declare const FormRender: (props: {
5
5
  className?: any;
6
6
  gridApi?: GridApi<any> | undefined;
7
+ colDefs: ColDef[];
7
8
  columnStates: ColumnState[];
8
9
  onQuery: (formValue: any) => void;
9
10
  }) => JSX.Element;
@@ -37,6 +37,7 @@ import "./index.less";
37
37
  var FormRender = function FormRender(props) {
38
38
  var className = props.className,
39
39
  gridApi = props.gridApi,
40
+ colDefs = props.colDefs,
40
41
  columnStates = props.columnStates,
41
42
  onQuery = props.onQuery;
42
43
 
@@ -145,13 +146,15 @@ var FormRender = function FormRender(props) {
145
146
  },
146
147
  properties: {}
147
148
  };
148
- var columns = columnStates.filter(function (x) {
149
- return !x.hide;
150
- }).map(function (columnState) {
151
- return gridApi === null || gridApi === void 0 ? void 0 : gridApi.getColumnDef(columnState.colId);
149
+ var columns = colDefs.map(function (colDef) {
150
+ var state = columnStates.find(function (x) {
151
+ return x.colId == colDef.field;
152
+ });
153
+ console.log("state", state);
154
+ return _objectSpread(_objectSpread({}, colDef), state);
152
155
  });
153
156
  columns = columns.filter(function (i) {
154
- return (i === null || i === void 0 ? void 0 : i.visible) != false && !i.hideInSearch || i.hideInTable;
157
+ return (i === null || i === void 0 ? void 0 : i.visible) != false && !(i !== null && i !== void 0 && i.hide) && !(i !== null && i !== void 0 && i.hideInSearch) || (i === null || i === void 0 ? void 0 : i.hideInTable);
155
158
  });
156
159
  columns.map(function (col) {
157
160
  var _colDef$queryField;