@nokecy/qc-ui 0.0.7 → 0.0.8

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 _icons = require("@ant-design/icons");
33
33
 
34
34
  var _utils = require("./utils");
35
35
 
36
- var _excluded = ["style", "params", "request", "dataSource", "headerTitle", "toolBarRender", "search", "onGridReady", "children"];
36
+ var _excluded = ["style", "params", "request", "dataSource", "headerTitle", "toolBarRender", "search", "onGridReady", "gridKey", "gridColumnState", "children"];
37
37
 
38
38
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39
39
 
@@ -78,6 +78,8 @@ function AgGridPlus(props) {
78
78
  toolBarRender = props.toolBarRender,
79
79
  search = props.search,
80
80
  onReady = props.onGridReady,
81
+ gridKey = props.gridKey,
82
+ gridColumnState = props.gridColumnState,
81
83
  children = props.children,
82
84
  rest = _objectWithoutProperties(props, _excluded);
83
85
 
@@ -128,12 +130,23 @@ function AgGridPlus(props) {
128
130
  var defaultColDef = {
129
131
  resizable: true,
130
132
  sortable: true
131
- };
133
+ }; //请求数据
134
+
132
135
  (0, _react.useEffect)(function () {
133
136
  if (ready && request) {
134
137
  onRequest(queryFilter);
135
138
  }
136
- }, [ready, JSON.stringify(gridParams), JSON.stringify(sortColumn), pagination.pageSize, pagination.current]);
139
+ }, [ready, JSON.stringify(gridParams), JSON.stringify(sortColumn), pagination.pageSize, pagination.current]); // 加载列方案
140
+
141
+ (0, _react.useEffect)(function () {
142
+ // let columnStates = columnsRef.current!.getColumnState();
143
+ if (gridColumnState && columnsRef.current) {
144
+ columnsRef.current.applyColumnState({
145
+ state: gridColumnState,
146
+ applyOrder: true
147
+ });
148
+ }
149
+ }, [gridColumnState, columnsRef.current]);
137
150
  var onGridReady = (0, _react.useCallback)(function (params) {
138
151
  apiRef.current = params.api;
139
152
  columnsRef.current = params.columnApi;
@@ -11,8 +11,8 @@
11
11
  --ag-font-family: ('microsoft yahei', 'Helvetica', 'Arial'),
12
12
 
13
13
  --ag-borders: solid 0px,
14
- --ag-borders-row: dashed 1px,
15
- --ag-row-border-color: rgb(150, 150, 200),
14
+ --ag-borders-row: solid 1px,
15
+ --ag-row-border-color:#f0f0f5,
16
16
  --ag-grid-size: 4px,
17
17
 
18
18
  --ag-header-background-color: #fafafa,
@@ -12,6 +12,14 @@ interface GridProps extends AgGridReactProps {
12
12
  headerTitle?: React.ReactNode;
13
13
  toolBarRender?: (gridApi?: GridApi, filter?: string, queryFilter?: any) => React.ReactNode[];
14
14
  columnDefs?: any;
15
+ /**
16
+ * 用于标识grid唯一标识,用于保存列方案
17
+ */
18
+ gridKey?: string;
19
+ /**
20
+ * 列方案
21
+ */
22
+ gridColumnState?: any[];
15
23
  }
16
24
  interface AgGridColumnPropsClone extends AgGridColumnProps {
17
25
  hideInTable?: boolean;
@@ -22,17 +22,39 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
22
22
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
23
23
 
24
24
  var getFilter = function getFilter(objectKey, value) {
25
- var type = "=*";
25
+ if (typeof value === 'string') {
26
+ return "".concat(objectKey, " =* ").concat(value);
27
+ }
26
28
 
27
29
  if (typeof value === 'number') {
28
- type = "=";
30
+ return "".concat(objectKey, " = ").concat(value);
31
+ }
32
+
33
+ if (value instanceof Array) {
34
+ return "".concat(objectKey, " >= ").concat((0, _dayjs.default)(value[0]).format("YYYY-MM-DD"), " ,") + "".concat(objectKey, " <= ").concat((0, _dayjs.default)(value[1]).add(1, 'days').format("YYYY-MM-DD"));
35
+ }
36
+
37
+ return getObjectFilter(value, objectKey);
38
+ };
39
+
40
+ var getObjectFilter = function getObjectFilter(obj, objKey) {
41
+ var key = Object.keys(obj)[0];
42
+ var value = obj[key];
43
+ var objectKey = "".concat(objKey, ".").concat(key);
44
+
45
+ if (typeof value === 'number') {
46
+ return "".concat(objectKey, " = ").concat(value);
47
+ }
48
+
49
+ if (typeof value === 'string') {
50
+ return "".concat(objectKey, " =* ").concat(value);
29
51
  }
30
52
 
31
53
  if (value instanceof Array) {
32
54
  return "".concat(objectKey, " >= ").concat((0, _dayjs.default)(value[0]).format("YYYY-MM-DD"), " ,") + "".concat(objectKey, " <= ").concat((0, _dayjs.default)(value[1]).add(1, 'days').format("YYYY-MM-DD"));
33
55
  }
34
56
 
35
- return "".concat(objectKey).concat(type).concat(value);
57
+ return getObjectFilter(value, "".concat(objKey, ".").concat(key));
36
58
  };
37
59
 
38
60
  var convertFilterModel = function convertFilterModel(filterModel) {
@@ -1,10 +1,14 @@
1
1
  import { GridProps } from '../ag-grid-plus/interface';
2
2
  interface ExtensibleColumnProps {
3
+ /** 字段名称 */
3
4
  field: string;
5
+ /** 字段类型 */
4
6
  type?: string;
7
+ /** 显示列名称 */
5
8
  headerName: string;
6
9
  }
7
10
  interface ExtensibleGridProps extends GridProps {
11
+ /** 动态扩展的列列表 */
8
12
  extensibleColumns: ExtensibleColumnProps[];
9
13
  }
10
14
  export { ExtensibleGridProps };
@@ -1,4 +1,4 @@
1
- var _excluded = ["style", "params", "request", "dataSource", "headerTitle", "toolBarRender", "search", "onGridReady", "children"];
1
+ var _excluded = ["style", "params", "request", "dataSource", "headerTitle", "toolBarRender", "search", "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
 
@@ -51,6 +51,8 @@ function AgGridPlus(props) {
51
51
  toolBarRender = props.toolBarRender,
52
52
  search = props.search,
53
53
  onReady = props.onGridReady,
54
+ gridKey = props.gridKey,
55
+ gridColumnState = props.gridColumnState,
54
56
  children = props.children,
55
57
  rest = _objectWithoutProperties(props, _excluded);
56
58
 
@@ -101,12 +103,23 @@ function AgGridPlus(props) {
101
103
  var defaultColDef = {
102
104
  resizable: true,
103
105
  sortable: true
104
- };
106
+ }; //请求数据
107
+
105
108
  useEffect(function () {
106
109
  if (ready && request) {
107
110
  onRequest(queryFilter);
108
111
  }
109
- }, [ready, JSON.stringify(gridParams), JSON.stringify(sortColumn), pagination.pageSize, pagination.current]);
112
+ }, [ready, JSON.stringify(gridParams), JSON.stringify(sortColumn), pagination.pageSize, pagination.current]); // 加载列方案
113
+
114
+ useEffect(function () {
115
+ // let columnStates = columnsRef.current!.getColumnState();
116
+ if (gridColumnState && columnsRef.current) {
117
+ columnsRef.current.applyColumnState({
118
+ state: gridColumnState,
119
+ applyOrder: true
120
+ });
121
+ }
122
+ }, [gridColumnState, columnsRef.current]);
110
123
  var onGridReady = useCallback(function (params) {
111
124
  apiRef.current = params.api;
112
125
  columnsRef.current = params.columnApi;
@@ -11,8 +11,8 @@
11
11
  --ag-font-family: ('microsoft yahei', 'Helvetica', 'Arial'),
12
12
 
13
13
  --ag-borders: solid 0px,
14
- --ag-borders-row: dashed 1px,
15
- --ag-row-border-color: rgb(150, 150, 200),
14
+ --ag-borders-row: solid 1px,
15
+ --ag-row-border-color:#f0f0f5,
16
16
  --ag-grid-size: 4px,
17
17
 
18
18
  --ag-header-background-color: #fafafa,
@@ -12,6 +12,14 @@ interface GridProps extends AgGridReactProps {
12
12
  headerTitle?: React.ReactNode;
13
13
  toolBarRender?: (gridApi?: GridApi, filter?: string, queryFilter?: any) => React.ReactNode[];
14
14
  columnDefs?: any;
15
+ /**
16
+ * 用于标识grid唯一标识,用于保存列方案
17
+ */
18
+ gridKey?: string;
19
+ /**
20
+ * 列方案
21
+ */
22
+ gridColumnState?: any[];
15
23
  }
16
24
  interface AgGridColumnPropsClone extends AgGridColumnProps {
17
25
  hideInTable?: boolean;
@@ -13,17 +13,39 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
13
13
  import dayjs from 'dayjs';
14
14
 
15
15
  var getFilter = function getFilter(objectKey, value) {
16
- var type = "=*";
16
+ if (typeof value === 'string') {
17
+ return "".concat(objectKey, " =* ").concat(value);
18
+ }
17
19
 
18
20
  if (typeof value === 'number') {
19
- type = "=";
21
+ return "".concat(objectKey, " = ").concat(value);
22
+ }
23
+
24
+ if (value instanceof Array) {
25
+ return "".concat(objectKey, " >= ").concat(dayjs(value[0]).format("YYYY-MM-DD"), " ,") + "".concat(objectKey, " <= ").concat(dayjs(value[1]).add(1, 'days').format("YYYY-MM-DD"));
26
+ }
27
+
28
+ return getObjectFilter(value, objectKey);
29
+ };
30
+
31
+ var getObjectFilter = function getObjectFilter(obj, objKey) {
32
+ var key = Object.keys(obj)[0];
33
+ var value = obj[key];
34
+ var objectKey = "".concat(objKey, ".").concat(key);
35
+
36
+ if (typeof value === 'number') {
37
+ return "".concat(objectKey, " = ").concat(value);
38
+ }
39
+
40
+ if (typeof value === 'string') {
41
+ return "".concat(objectKey, " =* ").concat(value);
20
42
  }
21
43
 
22
44
  if (value instanceof Array) {
23
45
  return "".concat(objectKey, " >= ").concat(dayjs(value[0]).format("YYYY-MM-DD"), " ,") + "".concat(objectKey, " <= ").concat(dayjs(value[1]).add(1, 'days').format("YYYY-MM-DD"));
24
46
  }
25
47
 
26
- return "".concat(objectKey).concat(type).concat(value);
48
+ return getObjectFilter(value, "".concat(objKey, ".").concat(key));
27
49
  };
28
50
 
29
51
  var convertFilterModel = function convertFilterModel(filterModel) {
@@ -1,10 +1,14 @@
1
1
  import { GridProps } from '../ag-grid-plus/interface';
2
2
  interface ExtensibleColumnProps {
3
+ /** 字段名称 */
3
4
  field: string;
5
+ /** 字段类型 */
4
6
  type?: string;
7
+ /** 显示列名称 */
5
8
  headerName: string;
6
9
  }
7
10
  interface ExtensibleGridProps extends GridProps {
11
+ /** 动态扩展的列列表 */
8
12
  extensibleColumns: ExtensibleColumnProps[];
9
13
  }
10
14
  export { ExtensibleGridProps };