@nokecy/qc-ui 0.0.11 → 0.0.12
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.
|
@@ -13,8 +13,6 @@ var _antd = require("antd");
|
|
|
13
13
|
|
|
14
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
15
|
|
|
16
|
-
var _gridManager = _interopRequireDefault(require("./gridManager"));
|
|
17
|
-
|
|
18
16
|
require("ag-grid-enterprise");
|
|
19
17
|
|
|
20
18
|
require("./global.scss");
|
|
@@ -33,7 +31,7 @@ var _icons = require("@ant-design/icons");
|
|
|
33
31
|
|
|
34
32
|
var _utils = require("./utils");
|
|
35
33
|
|
|
36
|
-
var _excluded = ["style", "params", "request", "dataSource", "headerTitle", "toolBarRender", "search", "hideRedo", "onGridReady", "gridKey", "gridColumnState", "children"];
|
|
34
|
+
var _excluded = ["style", "params", "request", "dataSource", "gridRef", "headerTitle", "toolBarRender", "search", "hideRedo", "onGridReady", "gridKey", "gridColumnState", "children"];
|
|
37
35
|
|
|
38
36
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
39
37
|
|
|
@@ -74,6 +72,7 @@ function AgGridPlus(props) {
|
|
|
74
72
|
gridParams = props.params,
|
|
75
73
|
request = props.request,
|
|
76
74
|
dataSource = props.dataSource,
|
|
75
|
+
propsGridRef = props.gridRef,
|
|
77
76
|
headerTitle = props.headerTitle,
|
|
78
77
|
toolBarRender = props.toolBarRender,
|
|
79
78
|
search = props.search,
|
|
@@ -84,9 +83,9 @@ function AgGridPlus(props) {
|
|
|
84
83
|
children = props.children,
|
|
85
84
|
rest = _objectWithoutProperties(props, _excluded);
|
|
86
85
|
|
|
86
|
+
var gridRef = (0, _react.useRef)();
|
|
87
87
|
var apiRef = (0, _react.useRef)();
|
|
88
88
|
var columnsRef = (0, _react.useRef)();
|
|
89
|
-
var gridManager = new _gridManager.default();
|
|
90
89
|
|
|
91
90
|
var _useState = (0, _react.useState)(false),
|
|
92
91
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -125,8 +124,11 @@ function AgGridPlus(props) {
|
|
|
125
124
|
}),
|
|
126
125
|
_useState14 = _slicedToArray(_useState13, 2),
|
|
127
126
|
pagination = _useState14[0],
|
|
128
|
-
setPagination = _useState14[1];
|
|
127
|
+
setPagination = _useState14[1];
|
|
129
128
|
|
|
129
|
+
(0, _react.useImperativeHandle)(propsGridRef, function () {
|
|
130
|
+
return gridRef.current;
|
|
131
|
+
}); //默认列属性
|
|
130
132
|
|
|
131
133
|
var defaultColDef = {
|
|
132
134
|
resizable: true,
|
|
@@ -154,9 +156,6 @@ function AgGridPlus(props) {
|
|
|
154
156
|
var onGridReady = (0, _react.useCallback)(function (params) {
|
|
155
157
|
apiRef.current = params.api;
|
|
156
158
|
columnsRef.current = params.columnApi;
|
|
157
|
-
gridManager.agGridApi = params.api;
|
|
158
|
-
gridManager.agGridColumnApi = params.columnApi; // gridManager.rowkey = rowkey;
|
|
159
|
-
|
|
160
159
|
onReady && onReady(params); ///@ts-ignore
|
|
161
160
|
|
|
162
161
|
dataSource && setRowData(dataSource);
|
|
@@ -202,10 +201,15 @@ function AgGridPlus(props) {
|
|
|
202
201
|
setSortColumn(sortedColumn);
|
|
203
202
|
};
|
|
204
203
|
|
|
205
|
-
var
|
|
204
|
+
var onRefresh = function onRefresh() {
|
|
206
205
|
request && onRequest(queryFilter);
|
|
207
206
|
};
|
|
208
207
|
|
|
208
|
+
(0, _react.useEffect)(function () {
|
|
209
|
+
gridRef.current = {
|
|
210
|
+
onRefresh: onRefresh
|
|
211
|
+
};
|
|
212
|
+
}, [queryFilter]);
|
|
209
213
|
return /*#__PURE__*/_react.default.createElement(_antd.Spin, {
|
|
210
214
|
spinning: loading,
|
|
211
215
|
wrapperClassName: "grid-spin"
|
|
@@ -250,10 +254,10 @@ function AgGridPlus(props) {
|
|
|
250
254
|
title: headerTitle,
|
|
251
255
|
actions: actionDom,
|
|
252
256
|
settings: [/*#__PURE__*/_react.default.createElement(_settingItem.default, {
|
|
253
|
-
onClick:
|
|
257
|
+
onClick: onRefresh,
|
|
254
258
|
icon: /*#__PURE__*/_react.default.createElement(_icons.RedoOutlined, null)
|
|
255
259
|
}), /*#__PURE__*/_react.default.createElement(_settingItem.default, {
|
|
256
|
-
onClick:
|
|
260
|
+
onClick: onRefresh,
|
|
257
261
|
icon: /*#__PURE__*/_react.default.createElement(_icons.SettingOutlined, null)
|
|
258
262
|
})]
|
|
259
263
|
}), /*#__PURE__*/_react.default.createElement(_agGridReact.AgGridReact, _extends({
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { GridApi } from 'ag-grid-community';
|
|
2
2
|
import { AgGridReactProps, AgGridColumnProps, AgGridColumnGroupProps } from 'ag-grid-react';
|
|
3
3
|
import React, { CSSProperties, ReactNode } from 'react';
|
|
4
|
+
interface GridRef {
|
|
5
|
+
onRefresh: () => void;
|
|
6
|
+
}
|
|
4
7
|
interface GridProps extends AgGridReactProps {
|
|
5
8
|
hideRedo?: boolean;
|
|
6
9
|
style?: CSSProperties;
|
|
@@ -20,6 +23,7 @@ interface GridProps extends AgGridReactProps {
|
|
|
20
23
|
* 列方案
|
|
21
24
|
*/
|
|
22
25
|
gridColumnState?: any[];
|
|
26
|
+
gridRef?: React.Ref<GridRef | undefined>;
|
|
23
27
|
}
|
|
24
28
|
interface AgGridColumnPropsClone extends AgGridColumnProps {
|
|
25
29
|
hideInTable?: boolean;
|
|
@@ -30,4 +34,4 @@ interface AgGridColumnPropsClone extends AgGridColumnProps {
|
|
|
30
34
|
searchSort?: number;
|
|
31
35
|
}
|
|
32
36
|
declare function AgGridColumn(props: AgGridColumnPropsClone | AgGridColumnGroupProps): JSX.Element;
|
|
33
|
-
export { GridProps, AgGridColumn };
|
|
37
|
+
export { GridProps, AgGridColumn, GridRef };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["style", "params", "request", "dataSource", "headerTitle", "toolBarRender", "search", "hideRedo", "onGridReady", "gridKey", "gridColumnState", "children"];
|
|
1
|
+
var _excluded = ["style", "params", "request", "dataSource", "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
|
|
|
@@ -26,8 +26,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
26
26
|
|
|
27
27
|
import { AgGridReact } from 'ag-grid-react';
|
|
28
28
|
import { Spin, Pagination, Card, Tag } from 'antd';
|
|
29
|
-
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
30
|
-
import GridManage from "./gridManager";
|
|
29
|
+
import React, { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
31
30
|
import "ag-grid-enterprise";
|
|
32
31
|
import "./global.scss";
|
|
33
32
|
import "./index.less";
|
|
@@ -47,6 +46,7 @@ function AgGridPlus(props) {
|
|
|
47
46
|
gridParams = props.params,
|
|
48
47
|
request = props.request,
|
|
49
48
|
dataSource = props.dataSource,
|
|
49
|
+
propsGridRef = props.gridRef,
|
|
50
50
|
headerTitle = props.headerTitle,
|
|
51
51
|
toolBarRender = props.toolBarRender,
|
|
52
52
|
search = props.search,
|
|
@@ -57,9 +57,9 @@ function AgGridPlus(props) {
|
|
|
57
57
|
children = props.children,
|
|
58
58
|
rest = _objectWithoutProperties(props, _excluded);
|
|
59
59
|
|
|
60
|
+
var gridRef = useRef();
|
|
60
61
|
var apiRef = useRef();
|
|
61
62
|
var columnsRef = useRef();
|
|
62
|
-
var gridManager = new GridManage();
|
|
63
63
|
|
|
64
64
|
var _useState = useState(false),
|
|
65
65
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -98,8 +98,11 @@ function AgGridPlus(props) {
|
|
|
98
98
|
}),
|
|
99
99
|
_useState14 = _slicedToArray(_useState13, 2),
|
|
100
100
|
pagination = _useState14[0],
|
|
101
|
-
setPagination = _useState14[1];
|
|
101
|
+
setPagination = _useState14[1];
|
|
102
102
|
|
|
103
|
+
useImperativeHandle(propsGridRef, function () {
|
|
104
|
+
return gridRef.current;
|
|
105
|
+
}); //默认列属性
|
|
103
106
|
|
|
104
107
|
var defaultColDef = {
|
|
105
108
|
resizable: true,
|
|
@@ -127,9 +130,6 @@ function AgGridPlus(props) {
|
|
|
127
130
|
var onGridReady = useCallback(function (params) {
|
|
128
131
|
apiRef.current = params.api;
|
|
129
132
|
columnsRef.current = params.columnApi;
|
|
130
|
-
gridManager.agGridApi = params.api;
|
|
131
|
-
gridManager.agGridColumnApi = params.columnApi; // gridManager.rowkey = rowkey;
|
|
132
|
-
|
|
133
133
|
onReady && onReady(params); ///@ts-ignore
|
|
134
134
|
|
|
135
135
|
dataSource && setRowData(dataSource);
|
|
@@ -175,10 +175,15 @@ function AgGridPlus(props) {
|
|
|
175
175
|
setSortColumn(sortedColumn);
|
|
176
176
|
};
|
|
177
177
|
|
|
178
|
-
var
|
|
178
|
+
var onRefresh = function onRefresh() {
|
|
179
179
|
request && onRequest(queryFilter);
|
|
180
180
|
};
|
|
181
181
|
|
|
182
|
+
useEffect(function () {
|
|
183
|
+
gridRef.current = {
|
|
184
|
+
onRefresh: onRefresh
|
|
185
|
+
};
|
|
186
|
+
}, [queryFilter]);
|
|
182
187
|
return /*#__PURE__*/React.createElement(Spin, {
|
|
183
188
|
spinning: loading,
|
|
184
189
|
wrapperClassName: "grid-spin"
|
|
@@ -223,10 +228,10 @@ function AgGridPlus(props) {
|
|
|
223
228
|
title: headerTitle,
|
|
224
229
|
actions: actionDom,
|
|
225
230
|
settings: [/*#__PURE__*/React.createElement(SettingItem, {
|
|
226
|
-
onClick:
|
|
231
|
+
onClick: onRefresh,
|
|
227
232
|
icon: /*#__PURE__*/React.createElement(RedoOutlined, null)
|
|
228
233
|
}), /*#__PURE__*/React.createElement(SettingItem, {
|
|
229
|
-
onClick:
|
|
234
|
+
onClick: onRefresh,
|
|
230
235
|
icon: /*#__PURE__*/React.createElement(SettingOutlined, null)
|
|
231
236
|
})]
|
|
232
237
|
}), /*#__PURE__*/React.createElement(AgGridReact, _extends({
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { GridApi } from 'ag-grid-community';
|
|
2
2
|
import { AgGridReactProps, AgGridColumnProps, AgGridColumnGroupProps } from 'ag-grid-react';
|
|
3
3
|
import React, { CSSProperties, ReactNode } from 'react';
|
|
4
|
+
interface GridRef {
|
|
5
|
+
onRefresh: () => void;
|
|
6
|
+
}
|
|
4
7
|
interface GridProps extends AgGridReactProps {
|
|
5
8
|
hideRedo?: boolean;
|
|
6
9
|
style?: CSSProperties;
|
|
@@ -20,6 +23,7 @@ interface GridProps extends AgGridReactProps {
|
|
|
20
23
|
* 列方案
|
|
21
24
|
*/
|
|
22
25
|
gridColumnState?: any[];
|
|
26
|
+
gridRef?: React.Ref<GridRef | undefined>;
|
|
23
27
|
}
|
|
24
28
|
interface AgGridColumnPropsClone extends AgGridColumnProps {
|
|
25
29
|
hideInTable?: boolean;
|
|
@@ -30,4 +34,4 @@ interface AgGridColumnPropsClone extends AgGridColumnProps {
|
|
|
30
34
|
searchSort?: number;
|
|
31
35
|
}
|
|
32
36
|
declare function AgGridColumn(props: AgGridColumnPropsClone | AgGridColumnGroupProps): JSX.Element;
|
|
33
|
-
export { GridProps, AgGridColumn };
|
|
37
|
+
export { GridProps, AgGridColumn, GridRef };
|