@nokecy/qc-ui 1.0.40 → 1.0.42

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.
@@ -23,6 +23,7 @@ var _ = require(".");
23
23
  var _customGroupCellRenderer = _interopRequireDefault(require("./_utils/customGroupCellRenderer"));
24
24
  var _processColumnGroups = _interopRequireDefault(require("./_utils/processColumnGroups"));
25
25
  var _processFormColumnState = _interopRequireDefault(require("./_utils/processFormColumnState"));
26
+ var _antdV = require("@formily/antd-v5");
26
27
  var _excluded = ["style", "loading", "params", "request", "dataSource", "treeKeyName", "treeParentName", "rowData", "gridRef", "headerTitle", "toolBarRender", "search", "hideTool", "onGridReady", "gridKey", "children", "defaultSearchExpand", "overlayNoRowsTemplateText", "queryDefaultRows"];
27
28
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
28
29
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -384,6 +385,50 @@ function AgGridPlus(props) {
384
385
  var columnDefs = !columnProps ? props.columnDefs ? props.columnDefs : [] : columnProps;
385
386
  columnDefs = columnDefs.map(function (col) {
386
387
  var dataType = getDataType(data, col.field);
388
+ if (col.valueEnum && Array.isArray(col.valueEnum)) {
389
+ var _defaultItems$0$value, _defaultItems$;
390
+ // 统计默认值
391
+ var defaultItems = col.valueEnum.filter(function (item) {
392
+ return item.default;
393
+ });
394
+ var isMultiple = defaultItems.length > 1;
395
+ var defaultValue = isMultiple ? defaultItems.map(function (item) {
396
+ return item.value;
397
+ }) : (_defaultItems$0$value = (_defaultItems$ = defaultItems[0]) === null || _defaultItems$ === void 0 ? void 0 : _defaultItems$.value) !== null && _defaultItems$0$value !== void 0 ? _defaultItems$0$value : undefined;
398
+ var valueFormatter = function valueFormatter(params) {
399
+ var match = col.valueEnum.find(function (item) {
400
+ return item.value == params.value;
401
+ });
402
+ return match ? match.label : params.value;
403
+ };
404
+ return _objectSpread(_objectSpread(_objectSpread({}, dataType), col), {}, {
405
+ cellRenderer: function cellRenderer(params) {
406
+ var match = col.valueEnum.find(function (item) {
407
+ return item.value == params.value;
408
+ });
409
+ if (match) {
410
+ return /*#__PURE__*/_react.default.createElement(_antd.Tag, {
411
+ color: match.color || "default"
412
+ }, match.label);
413
+ }
414
+ return params.value;
415
+ },
416
+ filterParams: _objectSpread(_objectSpread({}, col.filterParams || {}), {}, {
417
+ valueFormatter: valueFormatter
418
+ }),
419
+ searchComponent: _antdV.Select,
420
+ searchComponentProps: {
421
+ options: col.valueEnum.map(function (item) {
422
+ return {
423
+ label: item.label,
424
+ value: item.value
425
+ };
426
+ }),
427
+ mode: isMultiple ? "multiple" : undefined,
428
+ defaultValue: defaultValue
429
+ }
430
+ });
431
+ }
387
432
  if (col.type || typeof col.cellRenderer == "string") {
388
433
  return _objectSpread({}, col);
389
434
  }
@@ -519,6 +564,9 @@ function AgGridPlus(props) {
519
564
  onRequest && onRequest(formValues);
520
565
  return prev;
521
566
  });
567
+ },
568
+ onInit: function onInit(defaultValues) {
569
+ setQueryFilter(defaultValues);
522
570
  }
523
571
  }), /*#__PURE__*/_react.default.createElement(_antd.Card, {
524
572
  bordered: false,
@@ -9,5 +9,6 @@ declare const FormRender: (props: {
9
9
  defaultExpand?: Boolean | undefined;
10
10
  defaultRows?: number | undefined;
11
11
  onQuery: (formValue: any) => void;
12
+ onInit?: ((defaultValues: any) => void) | undefined;
12
13
  }) => React.JSX.Element;
13
14
  export default FormRender;
@@ -57,6 +57,9 @@ var FormRender = function FormRender(props) {
57
57
  }
58
58
  });
59
59
  }, []);
60
+ (0, _react2.useEffect)(function () {
61
+ props.onInit && props.onInit(form.values);
62
+ }, []);
60
63
  var SchemaField = (0, _react2.useMemo)(function () {
61
64
  return (0, _react.createSchemaField)({
62
65
  components: {
@@ -144,12 +147,12 @@ var FormRender = function FormRender(props) {
144
147
  //表单自定义组件
145
148
  var component = getComponent(colDef);
146
149
  if (colDef.filter != false) {
147
- var _colDef$searchCompone, _colDef$searchCompone2;
150
+ var _colDef$searchCompone, _colDef$searchCompone2, _colDef$searchCompone3;
148
151
  var filedSchema = {
149
152
  type: 'string',
150
153
  title: headerName,
151
154
  required: (colDef === null || colDef === void 0 || (_colDef$searchCompone = colDef.searchComponentProps) === null || _colDef$searchCompone === void 0 ? void 0 : _colDef$searchCompone.required) || false,
152
- default: colDef === null || colDef === void 0 || (_colDef$searchCompone2 = colDef.searchComponentProps) === null || _colDef$searchCompone2 === void 0 ? void 0 : _colDef$searchCompone2.default,
155
+ default: (colDef === null || colDef === void 0 || (_colDef$searchCompone2 = colDef.searchComponentProps) === null || _colDef$searchCompone2 === void 0 ? void 0 : _colDef$searchCompone2.default) || (colDef === null || colDef === void 0 || (_colDef$searchCompone3 = colDef.searchComponentProps) === null || _colDef$searchCompone3 === void 0 ? void 0 : _colDef$searchCompone3.defaultValue),
153
156
  enum: colDef === null || colDef === void 0 ? void 0 : colDef.enum,
154
157
  "x-component": component,
155
158
  "x-component-props": _objectSpread({
@@ -3,6 +3,7 @@ import React from "react";
3
3
  declare const DiySetting: (props: {
4
4
  gridKey?: string | undefined;
5
5
  gridApi?: GridApi<any> | undefined;
6
+ type?: string | undefined;
6
7
  gridApiState?: GridApi<any> | undefined;
7
8
  onSaveColumnState: (state: any) => void;
8
9
  }) => React.JSX.Element | null;
@@ -246,7 +246,9 @@ var DiySetting = function DiySetting(props) {
246
246
  var values = payload.values;
247
247
  onSaveColumnState && onSaveColumnState(values.items);
248
248
  var processedColumns = (0, _processColumnGroups.default)(values.items);
249
- gridApi.setGridOption("columnDefs", processedColumns);
249
+ if (props.type !== 'formArrayTable') {
250
+ gridApi.setGridOption("columnDefs", processedColumns);
251
+ }
250
252
  setTimeout(function () {
251
253
  gridApi.applyColumnState({
252
254
  state: processedColumns,
@@ -4,6 +4,7 @@ declare const Setting: (props: {
4
4
  gridKey?: string | undefined;
5
5
  gridApi?: GridApi<any> | undefined;
6
6
  gridApiState?: GridApi<any> | undefined;
7
+ type?: string | undefined;
7
8
  onSaveColumnState: (state: any) => void;
8
9
  }) => React.JSX.Element | null;
9
10
  export default Setting;
@@ -90,7 +90,8 @@ var Setting = function Setting(props) {
90
90
  label: /*#__PURE__*/_react2.default.createElement(_diySetting.default, {
91
91
  gridKey: gridKey,
92
92
  gridApi: gridApi,
93
- onSaveColumnState: onSaveColumnState
93
+ onSaveColumnState: onSaveColumnState,
94
+ type: props.type
94
95
  })
95
96
  }, {
96
97
  key: '2',
@@ -61,13 +61,74 @@ var ArrayTable = (0, _react2.observer)(function (props) {
61
61
  gridPlusColumnState = _useGridPlusColumnSta.columnState,
62
62
  extensibleColumns = _useGridPlusColumnSta.extensibleColumns;
63
63
  // const teststyle = '[{\"id\":\"18\",\"field\":\"xdxcp47tycp\",\"headerName\":\"A1\",\"width\":800,\"hide\":false,\"colId\":\"a1\",\"pinned\":null,\"sort\":null,\"sortIndex\":null,\"aggFunc\":null,\"rowGroup\":false,\"rowGroupIndex\":null,\"pivot\":false,\"pivotIndex\":null,\"flex\":null},{\"id\":\"19\",\"field\":\"nvhezzkyak9\",\"headerName\":\"Operations\",\"width\":60,\"hide\":false,\"colId\":\"nvhezzkyak9\",\"pinned\":null,\"sort\":null,\"sortIndex\":null,\"aggFunc\":null,\"rowGroup\":false,\"rowGroupIndex\":null,\"pivot\":false,\"pivotIndex\":null,\"flex\":null}]'
64
+ // const teststyle = [
65
+ // {
66
+ // "id": "5",
67
+ // "field": "NO_NAME_FIELD_$1",
68
+ // "headerName": "Index",
69
+ // "width": 80,
70
+ // "hide": false,
71
+ // "cellClass": "custom-cell-left",
72
+ // "suppressHeaderFilterButton": true,
73
+ // "colId": "NO_NAME_FIELD_$1",
74
+ // "pinned": null,
75
+ // "sort": null,
76
+ // "sortIndex": null,
77
+ // "aggFunc": null,
78
+ // "rowGroup": false,
79
+ // "rowGroupIndex": null,
80
+ // "pivot": false,
81
+ // "pivotIndex": null,
82
+ // "flex": null
83
+ // },
84
+ // {
85
+ // "id": "6",
86
+ // "field": "a1",
87
+ // "headerName": "A1",
88
+ // "width": 1200,
89
+ // "hide": false,
90
+ // "cellClass": "custom-cell-left",
91
+ // "suppressHeaderFilterButton": true,
92
+ // "colId": "a1",
93
+ // "pinned": null,
94
+ // "sort": null,
95
+ // "sortIndex": null,
96
+ // "aggFunc": null,
97
+ // "rowGroup": false,
98
+ // "rowGroupIndex": null,
99
+ // "pivot": false,
100
+ // "pivotIndex": null,
101
+ // "flex": null
102
+ // },
103
+ // {
104
+ // "id": "7",
105
+ // "field": "operations",
106
+ // "headerName": "Operations",
107
+ // "width": 80,
108
+ // "hide": false,
109
+ // "cellClass": "custom-cell-left",
110
+ // "suppressHeaderFilterButton": true,
111
+ // "colId": "operations",
112
+ // "pinned": "right",
113
+ // "sort": null,
114
+ // "sortIndex": null,
115
+ // "aggFunc": null,
116
+ // "rowGroup": false,
117
+ // "rowGroupIndex": null,
118
+ // "pivot": false,
119
+ // "pivotIndex": null,
120
+ // "flex": null
121
+ // }
122
+ // ]
64
123
 
65
124
  (0, _react.useEffect)(function () {
66
125
  if (props.gridKey && gridPlusColumnState && gridPlusColumnState[props.gridKey] && apiRef.current) {
67
- apiRef.current.applyColumnState({
68
- state: gridPlusColumnState[props.gridKey],
69
- applyOrder: true
70
- });
126
+ setTimeout(function () {
127
+ apiRef.current.applyColumnState({
128
+ state: gridPlusColumnState[props.gridKey],
129
+ applyOrder: true
130
+ });
131
+ }, 10);
71
132
  }
72
133
  }, [gridPlusColumnState, apiRef.current, dataSource]);
73
134
 
@@ -138,6 +199,7 @@ var ArrayTable = (0, _react2.observer)(function (props) {
138
199
  gridKey: props.gridKey,
139
200
  gridApi: apiRef.current,
140
201
  gridApiState: gridApiState,
202
+ type: 'formArrayTable',
141
203
  onSaveColumnState: onColumnStateChanged
142
204
  })), /*#__PURE__*/_react.default.createElement(_agGridReact.AgGridReact, {
143
205
  onGridReady: function onGridReady(params) {
@@ -32,6 +32,7 @@ import { useGridPlusColumnState } from '.';
32
32
  import CustomGroupCellRenderer from "./_utils/customGroupCellRenderer";
33
33
  import processColumnGroups from "./_utils/processColumnGroups";
34
34
  import flattenColumnState from "./_utils/processFormColumnState";
35
+ import { Select } from '@formily/antd-v5';
35
36
  var Paragraph = Typography.Paragraph,
36
37
  Text = Typography.Text;
37
38
  var getSort = function getSort(columnState) {
@@ -375,6 +376,50 @@ function AgGridPlus(props) {
375
376
  var columnDefs = !columnProps ? props.columnDefs ? props.columnDefs : [] : columnProps;
376
377
  columnDefs = columnDefs.map(function (col) {
377
378
  var dataType = getDataType(data, col.field);
379
+ if (col.valueEnum && Array.isArray(col.valueEnum)) {
380
+ var _defaultItems$0$value, _defaultItems$;
381
+ // 统计默认值
382
+ var defaultItems = col.valueEnum.filter(function (item) {
383
+ return item.default;
384
+ });
385
+ var isMultiple = defaultItems.length > 1;
386
+ var defaultValue = isMultiple ? defaultItems.map(function (item) {
387
+ return item.value;
388
+ }) : (_defaultItems$0$value = (_defaultItems$ = defaultItems[0]) === null || _defaultItems$ === void 0 ? void 0 : _defaultItems$.value) !== null && _defaultItems$0$value !== void 0 ? _defaultItems$0$value : undefined;
389
+ var valueFormatter = function valueFormatter(params) {
390
+ var match = col.valueEnum.find(function (item) {
391
+ return item.value == params.value;
392
+ });
393
+ return match ? match.label : params.value;
394
+ };
395
+ return _objectSpread(_objectSpread(_objectSpread({}, dataType), col), {}, {
396
+ cellRenderer: function cellRenderer(params) {
397
+ var match = col.valueEnum.find(function (item) {
398
+ return item.value == params.value;
399
+ });
400
+ if (match) {
401
+ return /*#__PURE__*/React.createElement(Tag, {
402
+ color: match.color || "default"
403
+ }, match.label);
404
+ }
405
+ return params.value;
406
+ },
407
+ filterParams: _objectSpread(_objectSpread({}, col.filterParams || {}), {}, {
408
+ valueFormatter: valueFormatter
409
+ }),
410
+ searchComponent: Select,
411
+ searchComponentProps: {
412
+ options: col.valueEnum.map(function (item) {
413
+ return {
414
+ label: item.label,
415
+ value: item.value
416
+ };
417
+ }),
418
+ mode: isMultiple ? "multiple" : undefined,
419
+ defaultValue: defaultValue
420
+ }
421
+ });
422
+ }
378
423
  if (col.type || typeof col.cellRenderer == "string") {
379
424
  return _objectSpread({}, col);
380
425
  }
@@ -510,6 +555,9 @@ function AgGridPlus(props) {
510
555
  onRequest && onRequest(formValues);
511
556
  return prev;
512
557
  });
558
+ },
559
+ onInit: function onInit(defaultValues) {
560
+ setQueryFilter(defaultValues);
513
561
  }
514
562
  }), /*#__PURE__*/React.createElement(Card, {
515
563
  bordered: false,
@@ -9,5 +9,6 @@ declare const FormRender: (props: {
9
9
  defaultExpand?: Boolean | undefined;
10
10
  defaultRows?: number | undefined;
11
11
  onQuery: (formValue: any) => void;
12
+ onInit?: ((defaultValues: any) => void) | undefined;
12
13
  }) => React.JSX.Element;
13
14
  export default FormRender;
@@ -49,6 +49,9 @@ var FormRender = function FormRender(props) {
49
49
  }
50
50
  });
51
51
  }, []);
52
+ useEffect(function () {
53
+ props.onInit && props.onInit(form.values);
54
+ }, []);
52
55
  var SchemaField = useMemo(function () {
53
56
  return createSchemaField({
54
57
  components: {
@@ -136,12 +139,12 @@ var FormRender = function FormRender(props) {
136
139
  //表单自定义组件
137
140
  var component = getComponent(colDef);
138
141
  if (colDef.filter != false) {
139
- var _colDef$searchCompone, _colDef$searchCompone2;
142
+ var _colDef$searchCompone, _colDef$searchCompone2, _colDef$searchCompone3;
140
143
  var filedSchema = {
141
144
  type: 'string',
142
145
  title: headerName,
143
146
  required: (colDef === null || colDef === void 0 || (_colDef$searchCompone = colDef.searchComponentProps) === null || _colDef$searchCompone === void 0 ? void 0 : _colDef$searchCompone.required) || false,
144
- default: colDef === null || colDef === void 0 || (_colDef$searchCompone2 = colDef.searchComponentProps) === null || _colDef$searchCompone2 === void 0 ? void 0 : _colDef$searchCompone2.default,
147
+ default: (colDef === null || colDef === void 0 || (_colDef$searchCompone2 = colDef.searchComponentProps) === null || _colDef$searchCompone2 === void 0 ? void 0 : _colDef$searchCompone2.default) || (colDef === null || colDef === void 0 || (_colDef$searchCompone3 = colDef.searchComponentProps) === null || _colDef$searchCompone3 === void 0 ? void 0 : _colDef$searchCompone3.defaultValue),
145
148
  enum: colDef === null || colDef === void 0 ? void 0 : colDef.enum,
146
149
  "x-component": component,
147
150
  "x-component-props": _objectSpread({
@@ -3,6 +3,7 @@ import React from "react";
3
3
  declare const DiySetting: (props: {
4
4
  gridKey?: string | undefined;
5
5
  gridApi?: GridApi<any> | undefined;
6
+ type?: string | undefined;
6
7
  gridApiState?: GridApi<any> | undefined;
7
8
  onSaveColumnState: (state: any) => void;
8
9
  }) => React.JSX.Element | null;
@@ -237,7 +237,9 @@ var DiySetting = function DiySetting(props) {
237
237
  var values = payload.values;
238
238
  onSaveColumnState && onSaveColumnState(values.items);
239
239
  var processedColumns = processColumnGroups(values.items);
240
- gridApi.setGridOption("columnDefs", processedColumns);
240
+ if (props.type !== 'formArrayTable') {
241
+ gridApi.setGridOption("columnDefs", processedColumns);
242
+ }
241
243
  setTimeout(function () {
242
244
  gridApi.applyColumnState({
243
245
  state: processedColumns,
@@ -4,6 +4,7 @@ declare const Setting: (props: {
4
4
  gridKey?: string | undefined;
5
5
  gridApi?: GridApi<any> | undefined;
6
6
  gridApiState?: GridApi<any> | undefined;
7
+ type?: string | undefined;
7
8
  onSaveColumnState: (state: any) => void;
8
9
  }) => React.JSX.Element | null;
9
10
  export default Setting;
@@ -81,7 +81,8 @@ var Setting = function Setting(props) {
81
81
  label: /*#__PURE__*/React.createElement(DiySetting, {
82
82
  gridKey: gridKey,
83
83
  gridApi: gridApi,
84
- onSaveColumnState: onSaveColumnState
84
+ onSaveColumnState: onSaveColumnState,
85
+ type: props.type
85
86
  })
86
87
  }, {
87
88
  key: '2',
@@ -55,13 +55,74 @@ var ArrayTable = observer(function (props) {
55
55
  gridPlusColumnState = _useGridPlusColumnSta.columnState,
56
56
  extensibleColumns = _useGridPlusColumnSta.extensibleColumns;
57
57
  // const teststyle = '[{\"id\":\"18\",\"field\":\"xdxcp47tycp\",\"headerName\":\"A1\",\"width\":800,\"hide\":false,\"colId\":\"a1\",\"pinned\":null,\"sort\":null,\"sortIndex\":null,\"aggFunc\":null,\"rowGroup\":false,\"rowGroupIndex\":null,\"pivot\":false,\"pivotIndex\":null,\"flex\":null},{\"id\":\"19\",\"field\":\"nvhezzkyak9\",\"headerName\":\"Operations\",\"width\":60,\"hide\":false,\"colId\":\"nvhezzkyak9\",\"pinned\":null,\"sort\":null,\"sortIndex\":null,\"aggFunc\":null,\"rowGroup\":false,\"rowGroupIndex\":null,\"pivot\":false,\"pivotIndex\":null,\"flex\":null}]'
58
+ // const teststyle = [
59
+ // {
60
+ // "id": "5",
61
+ // "field": "NO_NAME_FIELD_$1",
62
+ // "headerName": "Index",
63
+ // "width": 80,
64
+ // "hide": false,
65
+ // "cellClass": "custom-cell-left",
66
+ // "suppressHeaderFilterButton": true,
67
+ // "colId": "NO_NAME_FIELD_$1",
68
+ // "pinned": null,
69
+ // "sort": null,
70
+ // "sortIndex": null,
71
+ // "aggFunc": null,
72
+ // "rowGroup": false,
73
+ // "rowGroupIndex": null,
74
+ // "pivot": false,
75
+ // "pivotIndex": null,
76
+ // "flex": null
77
+ // },
78
+ // {
79
+ // "id": "6",
80
+ // "field": "a1",
81
+ // "headerName": "A1",
82
+ // "width": 1200,
83
+ // "hide": false,
84
+ // "cellClass": "custom-cell-left",
85
+ // "suppressHeaderFilterButton": true,
86
+ // "colId": "a1",
87
+ // "pinned": null,
88
+ // "sort": null,
89
+ // "sortIndex": null,
90
+ // "aggFunc": null,
91
+ // "rowGroup": false,
92
+ // "rowGroupIndex": null,
93
+ // "pivot": false,
94
+ // "pivotIndex": null,
95
+ // "flex": null
96
+ // },
97
+ // {
98
+ // "id": "7",
99
+ // "field": "operations",
100
+ // "headerName": "Operations",
101
+ // "width": 80,
102
+ // "hide": false,
103
+ // "cellClass": "custom-cell-left",
104
+ // "suppressHeaderFilterButton": true,
105
+ // "colId": "operations",
106
+ // "pinned": "right",
107
+ // "sort": null,
108
+ // "sortIndex": null,
109
+ // "aggFunc": null,
110
+ // "rowGroup": false,
111
+ // "rowGroupIndex": null,
112
+ // "pivot": false,
113
+ // "pivotIndex": null,
114
+ // "flex": null
115
+ // }
116
+ // ]
58
117
 
59
118
  useEffect(function () {
60
119
  if (props.gridKey && gridPlusColumnState && gridPlusColumnState[props.gridKey] && apiRef.current) {
61
- apiRef.current.applyColumnState({
62
- state: gridPlusColumnState[props.gridKey],
63
- applyOrder: true
64
- });
120
+ setTimeout(function () {
121
+ apiRef.current.applyColumnState({
122
+ state: gridPlusColumnState[props.gridKey],
123
+ applyOrder: true
124
+ });
125
+ }, 10);
65
126
  }
66
127
  }, [gridPlusColumnState, apiRef.current, dataSource]);
67
128
 
@@ -132,6 +193,7 @@ var ArrayTable = observer(function (props) {
132
193
  gridKey: props.gridKey,
133
194
  gridApi: apiRef.current,
134
195
  gridApiState: gridApiState,
196
+ type: 'formArrayTable',
135
197
  onSaveColumnState: onColumnStateChanged
136
198
  })), /*#__PURE__*/React.createElement(AgGridReact, {
137
199
  onGridReady: function onGridReady(params) {