@nokecy/qc-ui 1.0.19 → 1.0.21

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.
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _sumBy2 = _interopRequireDefault(require("lodash/sumBy"));
9
9
  var _uniqueId2 = _interopRequireDefault(require("lodash/uniqueId"));
10
+ var _isArray2 = _interopRequireDefault(require("lodash/isArray"));
10
11
  var _agGridReact = require("ag-grid-react");
11
12
  var _antd = require("antd");
12
13
  var _react = _interopRequireWildcard(require("react"));
@@ -79,30 +80,34 @@ function AgGridPlus(props) {
79
80
  _useState6 = _slicedToArray(_useState5, 2),
80
81
  columnState = _useState6[0],
81
82
  setColumnState = _useState6[1];
82
- var _useState7 = (0, _react.useState)([]),
83
+ var _useState7 = (0, _react.useState)({}),
83
84
  _useState8 = _slicedToArray(_useState7, 2),
84
- rowData = _useState8[0],
85
- setRowData = _useState8[1];
86
- var _useState9 = (0, _react.useState)({}),
85
+ columnCellClass = _useState8[0],
86
+ setColumnCellClass = _useState8[1];
87
+ var _useState9 = (0, _react.useState)([]),
87
88
  _useState10 = _slicedToArray(_useState9, 2),
88
- selectRow = _useState10[0],
89
- setSelectRow = _useState10[1];
89
+ rowData = _useState10[0],
90
+ setRowData = _useState10[1];
90
91
  var _useState11 = (0, _react.useState)({}),
91
92
  _useState12 = _slicedToArray(_useState11, 2),
92
- queryFilter = _useState12[0],
93
- setQueryFilter = _useState12[1];
94
- var _useState13 = (0, _react.useState)(),
93
+ selectRow = _useState12[0],
94
+ setSelectRow = _useState12[1];
95
+ var _useState13 = (0, _react.useState)({}),
95
96
  _useState14 = _slicedToArray(_useState13, 2),
96
- sortColumn = _useState14[0],
97
- setSortColumn = _useState14[1];
98
- var _useState15 = (0, _react.useState)({
97
+ queryFilter = _useState14[0],
98
+ setQueryFilter = _useState14[1];
99
+ var _useState15 = (0, _react.useState)(),
100
+ _useState16 = _slicedToArray(_useState15, 2),
101
+ sortColumn = _useState16[0],
102
+ setSortColumn = _useState16[1];
103
+ var _useState17 = (0, _react.useState)({
99
104
  pageSize: 200,
100
105
  current: 1,
101
106
  total: dataSource ? dataSource.length : 0
102
107
  }),
103
- _useState16 = _slicedToArray(_useState15, 2),
104
- pagination = _useState16[0],
105
- setPagination = _useState16[1];
108
+ _useState18 = _slicedToArray(_useState17, 2),
109
+ pagination = _useState18[0],
110
+ setPagination = _useState18[1];
106
111
  (0, _react.useImperativeHandle)(propsGridRef, function () {
107
112
  return gridRef.current;
108
113
  });
@@ -167,6 +172,7 @@ function AgGridPlus(props) {
167
172
  // 加载列方案
168
173
  (0, _react.useEffect)(function () {
169
174
  if (gridPlusColumnState && gridKey && gridPlusColumnState[gridKey] && apiRef.current) {
175
+ setColumnCellClass(handelgridPlusColumnState(gridPlusColumnState[gridKey]));
170
176
  apiRef.current.applyColumnState({
171
177
  state: gridPlusColumnState[gridKey],
172
178
  applyOrder: true
@@ -214,6 +220,17 @@ function AgGridPlus(props) {
214
220
  setLoading(false);
215
221
  });
216
222
  };
223
+ var handelgridPlusColumnState = function handelgridPlusColumnState(columnState) {
224
+ var cellMap = {};
225
+ if ((0, _isArray2.default)(columnState)) {
226
+ columnState.map(function (item) {
227
+ if (item.cellClass) {
228
+ cellMap[item.field] = item.cellClass;
229
+ }
230
+ });
231
+ }
232
+ return cellMap;
233
+ };
217
234
  var sortChanged = function sortChanged(columnApi) {
218
235
  var sortedColumn = columnApi.getColumnState().find(function (col) {
219
236
  return Boolean(col.sort);
@@ -233,6 +250,7 @@ function AgGridPlus(props) {
233
250
  var onColumnStateChanged = function onColumnStateChanged(columnState) {
234
251
  if (gridKey) {
235
252
  onSaveColumnState && onSaveColumnState(gridKey, columnState);
253
+ setColumnCellClass(handelgridPlusColumnState(columnState));
236
254
  }
237
255
  };
238
256
  (0, _react.useEffect)(function () {
@@ -409,11 +427,16 @@ function AgGridPlus(props) {
409
427
  };
410
428
  var colDefs = (0, _react.useMemo)(function () {
411
429
  var columnDefs = getTableColumns(rowData);
412
- columnDefs = columnDefs.filter(function (x) {
430
+ columnDefs = columnDefs.map(function (i) {
431
+ if (columnCellClass[i.field]) {
432
+ i.cellClass = columnCellClass[i.field];
433
+ }
434
+ return i;
435
+ }).filter(function (x) {
413
436
  return !x.hideInTable;
414
437
  });
415
438
  return columnDefs;
416
- }, [children === null || children === void 0 ? void 0 : children.length, props.columnDefs, extensibleColumns]);
439
+ }, [children === null || children === void 0 ? void 0 : children.length, props.columnDefs, extensibleColumns, columnCellClass]);
417
440
  var allColDefs = (0, _react.useMemo)(function () {
418
441
  return getTableColumns(rowData);
419
442
  }, [children === null || children === void 0 ? void 0 : children.length, props.columnDefs, extensibleColumns]);
@@ -53,14 +53,17 @@ var Setting = function Setting(props) {
53
53
  var getColumnData = function getColumnData() {
54
54
  var columnStates = gridApi.getColumnState();
55
55
  var columnRowData = [];
56
- var columns = columnStates.map(function (columnState) {
56
+ columnStates.forEach(function (columnState) {
57
57
  var colDef = gridApi === null || gridApi === void 0 ? void 0 : gridApi.getColumnDef(columnState.colId);
58
+
59
+ // 将列信息和 cellClass 一并加入到 columnRowData 中
58
60
  columnRowData.push(_objectSpread({
59
61
  id: (0, _uniqueId2.default)(),
60
62
  field: colDef.field,
61
63
  headerName: colDef.headerName,
62
64
  width: columnState.width,
63
- hide: columnState.hide
65
+ hide: columnState.hide,
66
+ cellClass: colDef.cellClass
64
67
  }, columnState));
65
68
  });
66
69
  return columnRowData;
@@ -129,6 +132,27 @@ var Setting = function Setting(props) {
129
132
  "x-decorator": "FormItem",
130
133
  "x-component": "Input",
131
134
  "x-read-pretty": true
135
+ })), /*#__PURE__*/_react2.default.createElement(SchemaField.Void, {
136
+ "x-component": "ArrayTable.Column",
137
+ "x-component-props": {
138
+ width: 120,
139
+ title: '内容布局'
140
+ }
141
+ }, /*#__PURE__*/_react2.default.createElement(SchemaField.String, {
142
+ name: "cellClass",
143
+ "x-decorator": "FormItem",
144
+ "x-component": "Select",
145
+ default: "custom-cell-left",
146
+ enum: [{
147
+ value: "custom-cell-left",
148
+ label: "左对齐"
149
+ }, {
150
+ value: "custom-cell-right",
151
+ label: "右对齐"
152
+ }, {
153
+ value: 'custom-cell-centered',
154
+ label: "居中对齐"
155
+ }]
132
156
  })), /*#__PURE__*/_react2.default.createElement(SchemaField.Void, {
133
157
  "x-component": "ArrayTable.Column",
134
158
  "x-component-props": {
@@ -189,11 +213,13 @@ var Setting = function Setting(props) {
189
213
  });
190
214
  formDialog.forConfirm(function (payload, next) {
191
215
  var values = payload.values;
192
- var falg = gridApi.applyColumnState({
193
- state: values.items,
194
- applyOrder: true
195
- });
196
216
  onSaveColumnState && onSaveColumnState(values.items);
217
+ setTimeout(function () {
218
+ var falg = gridApi.applyColumnState({
219
+ state: values.items,
220
+ applyOrder: true
221
+ });
222
+ }, 100);
197
223
  next(payload);
198
224
  }).open(formProps);
199
225
  case 2:
@@ -1,6 +1,7 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
2
  import _sumBy from "lodash/sumBy";
3
3
  import _uniqueId from "lodash/uniqueId";
4
+ import _isArray from "lodash/isArray";
4
5
  var _excluded = ["style", "loading", "params", "request", "dataSource", "treeKeyName", "treeParentName", "rowData", "gridRef", "headerTitle", "toolBarRender", "search", "hideTool", "onGridReady", "gridKey", "children", "defaultSearchExpand"];
5
6
  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); }
6
7
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -70,30 +71,34 @@ function AgGridPlus(props) {
70
71
  _useState6 = _slicedToArray(_useState5, 2),
71
72
  columnState = _useState6[0],
72
73
  setColumnState = _useState6[1];
73
- var _useState7 = useState([]),
74
+ var _useState7 = useState({}),
74
75
  _useState8 = _slicedToArray(_useState7, 2),
75
- rowData = _useState8[0],
76
- setRowData = _useState8[1];
77
- var _useState9 = useState({}),
76
+ columnCellClass = _useState8[0],
77
+ setColumnCellClass = _useState8[1];
78
+ var _useState9 = useState([]),
78
79
  _useState10 = _slicedToArray(_useState9, 2),
79
- selectRow = _useState10[0],
80
- setSelectRow = _useState10[1];
80
+ rowData = _useState10[0],
81
+ setRowData = _useState10[1];
81
82
  var _useState11 = useState({}),
82
83
  _useState12 = _slicedToArray(_useState11, 2),
83
- queryFilter = _useState12[0],
84
- setQueryFilter = _useState12[1];
85
- var _useState13 = useState(),
84
+ selectRow = _useState12[0],
85
+ setSelectRow = _useState12[1];
86
+ var _useState13 = useState({}),
86
87
  _useState14 = _slicedToArray(_useState13, 2),
87
- sortColumn = _useState14[0],
88
- setSortColumn = _useState14[1];
89
- var _useState15 = useState({
88
+ queryFilter = _useState14[0],
89
+ setQueryFilter = _useState14[1];
90
+ var _useState15 = useState(),
91
+ _useState16 = _slicedToArray(_useState15, 2),
92
+ sortColumn = _useState16[0],
93
+ setSortColumn = _useState16[1];
94
+ var _useState17 = useState({
90
95
  pageSize: 200,
91
96
  current: 1,
92
97
  total: dataSource ? dataSource.length : 0
93
98
  }),
94
- _useState16 = _slicedToArray(_useState15, 2),
95
- pagination = _useState16[0],
96
- setPagination = _useState16[1];
99
+ _useState18 = _slicedToArray(_useState17, 2),
100
+ pagination = _useState18[0],
101
+ setPagination = _useState18[1];
97
102
  useImperativeHandle(propsGridRef, function () {
98
103
  return gridRef.current;
99
104
  });
@@ -158,6 +163,7 @@ function AgGridPlus(props) {
158
163
  // 加载列方案
159
164
  useEffect(function () {
160
165
  if (gridPlusColumnState && gridKey && gridPlusColumnState[gridKey] && apiRef.current) {
166
+ setColumnCellClass(handelgridPlusColumnState(gridPlusColumnState[gridKey]));
161
167
  apiRef.current.applyColumnState({
162
168
  state: gridPlusColumnState[gridKey],
163
169
  applyOrder: true
@@ -205,6 +211,17 @@ function AgGridPlus(props) {
205
211
  setLoading(false);
206
212
  });
207
213
  };
214
+ var handelgridPlusColumnState = function handelgridPlusColumnState(columnState) {
215
+ var cellMap = {};
216
+ if (_isArray(columnState)) {
217
+ columnState.map(function (item) {
218
+ if (item.cellClass) {
219
+ cellMap[item.field] = item.cellClass;
220
+ }
221
+ });
222
+ }
223
+ return cellMap;
224
+ };
208
225
  var sortChanged = function sortChanged(columnApi) {
209
226
  var sortedColumn = columnApi.getColumnState().find(function (col) {
210
227
  return Boolean(col.sort);
@@ -224,6 +241,7 @@ function AgGridPlus(props) {
224
241
  var onColumnStateChanged = function onColumnStateChanged(columnState) {
225
242
  if (gridKey) {
226
243
  onSaveColumnState && onSaveColumnState(gridKey, columnState);
244
+ setColumnCellClass(handelgridPlusColumnState(columnState));
227
245
  }
228
246
  };
229
247
  useEffect(function () {
@@ -400,11 +418,16 @@ function AgGridPlus(props) {
400
418
  };
401
419
  var colDefs = useMemo(function () {
402
420
  var columnDefs = getTableColumns(rowData);
403
- columnDefs = columnDefs.filter(function (x) {
421
+ columnDefs = columnDefs.map(function (i) {
422
+ if (columnCellClass[i.field]) {
423
+ i.cellClass = columnCellClass[i.field];
424
+ }
425
+ return i;
426
+ }).filter(function (x) {
404
427
  return !x.hideInTable;
405
428
  });
406
429
  return columnDefs;
407
- }, [children === null || children === void 0 ? void 0 : children.length, props.columnDefs, extensibleColumns]);
430
+ }, [children === null || children === void 0 ? void 0 : children.length, props.columnDefs, extensibleColumns, columnCellClass]);
408
431
  var allColDefs = useMemo(function () {
409
432
  return getTableColumns(rowData);
410
433
  }, [children === null || children === void 0 ? void 0 : children.length, props.columnDefs, extensibleColumns]);
@@ -44,14 +44,17 @@ var Setting = function Setting(props) {
44
44
  var getColumnData = function getColumnData() {
45
45
  var columnStates = gridApi.getColumnState();
46
46
  var columnRowData = [];
47
- var columns = columnStates.map(function (columnState) {
47
+ columnStates.forEach(function (columnState) {
48
48
  var colDef = gridApi === null || gridApi === void 0 ? void 0 : gridApi.getColumnDef(columnState.colId);
49
+
50
+ // 将列信息和 cellClass 一并加入到 columnRowData 中
49
51
  columnRowData.push(_objectSpread({
50
52
  id: _uniqueId(),
51
53
  field: colDef.field,
52
54
  headerName: colDef.headerName,
53
55
  width: columnState.width,
54
- hide: columnState.hide
56
+ hide: columnState.hide,
57
+ cellClass: colDef.cellClass
55
58
  }, columnState));
56
59
  });
57
60
  return columnRowData;
@@ -120,6 +123,27 @@ var Setting = function Setting(props) {
120
123
  "x-decorator": "FormItem",
121
124
  "x-component": "Input",
122
125
  "x-read-pretty": true
126
+ })), /*#__PURE__*/React.createElement(SchemaField.Void, {
127
+ "x-component": "ArrayTable.Column",
128
+ "x-component-props": {
129
+ width: 120,
130
+ title: '内容布局'
131
+ }
132
+ }, /*#__PURE__*/React.createElement(SchemaField.String, {
133
+ name: "cellClass",
134
+ "x-decorator": "FormItem",
135
+ "x-component": "Select",
136
+ default: "custom-cell-left",
137
+ enum: [{
138
+ value: "custom-cell-left",
139
+ label: "左对齐"
140
+ }, {
141
+ value: "custom-cell-right",
142
+ label: "右对齐"
143
+ }, {
144
+ value: 'custom-cell-centered',
145
+ label: "居中对齐"
146
+ }]
123
147
  })), /*#__PURE__*/React.createElement(SchemaField.Void, {
124
148
  "x-component": "ArrayTable.Column",
125
149
  "x-component-props": {
@@ -180,11 +204,13 @@ var Setting = function Setting(props) {
180
204
  });
181
205
  formDialog.forConfirm(function (payload, next) {
182
206
  var values = payload.values;
183
- var falg = gridApi.applyColumnState({
184
- state: values.items,
185
- applyOrder: true
186
- });
187
207
  onSaveColumnState && onSaveColumnState(values.items);
208
+ setTimeout(function () {
209
+ var falg = gridApi.applyColumnState({
210
+ state: values.items,
211
+ applyOrder: true
212
+ });
213
+ }, 100);
188
214
  next(payload);
189
215
  }).open(formProps);
190
216
  case 2: