@nokecy/qc-ui 1.0.39 → 1.0.41

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.
@@ -44,21 +44,35 @@ var DiySetting = function DiySetting(props) {
44
44
  var getColumnData = function getColumnData() {
45
45
  var columnStates = gridApi.getColumnState();
46
46
  var columnRowData = [];
47
- columnStates.forEach(function (columnState) {
48
- var colDef = gridApi === null || gridApi === void 0 ? void 0 : gridApi.getColumnDef(columnState.colId);
47
+ var columnDefs = (gridApi === null || gridApi === void 0 ? void 0 : gridApi.getColumnDefs()) || [];
49
48
 
50
- // 将列信息和 cellClass 一并加入到 columnRowData 中
51
- columnRowData.push(_objectSpread({
52
- id: _uniqueId(),
53
- field: colDef.field,
54
- headerName: colDef.headerName,
55
- width: columnState.width,
56
- hide: columnState.hide,
57
- cellClass: colDef.cellClass,
58
- // 添加 cellClass
59
- suppressHeaderFilterButton: !colDef.suppressHeaderFilterButton
60
- }, columnState));
61
- });
49
+ // 递归处理列定义
50
+ var processColumns = function processColumns(columns, parentGroup) {
51
+ columns.forEach(function (column) {
52
+ if (column.children && column.children.length > 0) {
53
+ // 处理子列,将当前headerName作为分组名传递下去
54
+ processColumns(column.children, column.headerName);
55
+ } else {
56
+ // 找到对应的columnState
57
+ var columnState = columnStates.find(function (state) {
58
+ return state.colId === column.field;
59
+ });
60
+ if (columnState) {
61
+ columnRowData.push(_objectSpread({
62
+ id: _uniqueId(),
63
+ field: column.field,
64
+ headerName: column.headerName,
65
+ width: columnState.width,
66
+ hide: columnState.hide,
67
+ cellClass: column.cellClass,
68
+ suppressHeaderFilterButton: !column.suppressHeaderFilterButton,
69
+ groupName: parentGroup
70
+ }, columnState));
71
+ }
72
+ }
73
+ });
74
+ };
75
+ processColumns(columnDefs);
62
76
  return columnRowData;
63
77
  };
64
78
  var portalId = "workProcedure".concat(_uniqueId());
@@ -111,7 +125,7 @@ var DiySetting = function DiySetting(props) {
111
125
  })), /*#__PURE__*/React.createElement(SchemaField.Void, {
112
126
  "x-component": "ArrayTable.Column",
113
127
  "x-component-props": {
114
- width: 280,
128
+ width: 180,
115
129
  title: "列名"
116
130
  }
117
131
  }, /*#__PURE__*/React.createElement(SchemaField.String, {
@@ -119,6 +133,16 @@ var DiySetting = function DiySetting(props) {
119
133
  "x-decorator": "FormItem",
120
134
  "x-component": "Input",
121
135
  "x-read-pretty": true
136
+ })), /*#__PURE__*/React.createElement(SchemaField.Void, {
137
+ "x-component": "ArrayTable.Column",
138
+ "x-component-props": {
139
+ width: 120,
140
+ title: "分组名称"
141
+ }
142
+ }, /*#__PURE__*/React.createElement(SchemaField.String, {
143
+ name: "groupName",
144
+ "x-decorator": "FormItem",
145
+ "x-component": "Input"
122
146
  })), /*#__PURE__*/React.createElement(SchemaField.Void, {
123
147
  "x-component": "ArrayTable.Column",
124
148
  "x-component-props": {
@@ -207,24 +231,15 @@ var DiySetting = function DiySetting(props) {
207
231
  name: "hide",
208
232
  "x-decorator": "FormItem",
209
233
  "x-component": "Switch"
210
- })), /*#__PURE__*/React.createElement(SchemaField.Void, {
211
- "x-component": "ArrayTable.Column",
212
- "x-component-props": {
213
- width: 180,
214
- title: "分组名称"
215
- }
216
- }, /*#__PURE__*/React.createElement(SchemaField.String, {
217
- name: "groupName",
218
- "x-decorator": "FormItem",
219
- "x-component": "Input"
220
234
  })))))));
221
235
  });
222
236
  formDialog.forConfirm(function (payload, next) {
223
237
  var values = payload.values;
224
238
  onSaveColumnState && onSaveColumnState(values.items);
225
239
  var processedColumns = processColumnGroups(values.items);
226
- console.log('record1', processedColumns);
227
- gridApi.setGridOption("columnDefs", processedColumns);
240
+ if (props.type !== 'formArrayTable') {
241
+ gridApi.setGridOption("columnDefs", processedColumns);
242
+ }
228
243
  setTimeout(function () {
229
244
  gridApi.applyColumnState({
230
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;
@@ -23,6 +23,7 @@ var Setting = function Setting(props) {
23
23
  gridApiState = props.gridApiState,
24
24
  onSaveColumnState = props.onSaveColumnState;
25
25
  var _useGridPlusColumnSta = useGridPlusColumnState(),
26
+ extensibleColumns = _useGridPlusColumnSta.extensibleColumns,
26
27
  applyToGlobal = _useGridPlusColumnSta.applyToGlobal,
27
28
  resetCurrent = _useGridPlusColumnSta.resetCurrent,
28
29
  resetAll = _useGridPlusColumnSta.resetAll;
@@ -80,7 +81,8 @@ var Setting = function Setting(props) {
80
81
  label: /*#__PURE__*/React.createElement(DiySetting, {
81
82
  gridKey: gridKey,
82
83
  gridApi: gridApi,
83
- onSaveColumnState: onSaveColumnState
84
+ onSaveColumnState: onSaveColumnState,
85
+ type: props.type
84
86
  })
85
87
  }, {
86
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) {