@nokecy/qc-ui 1.1.66 → 1.1.68
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.
- package/dist/cjs/ag-grid-plus/queryForm/index.js +5 -1
- package/dist/cjs/array-table/index.js +15 -1
- package/dist/cjs/array-table/indexColumn.d.ts +17 -0
- package/dist/cjs/array-table/indexColumn.js +58 -0
- package/dist/esm/ag-grid-plus/queryForm/index.js +5 -1
- package/dist/esm/array-table/index.js +15 -1
- package/dist/esm/array-table/indexColumn.d.ts +17 -0
- package/dist/esm/array-table/indexColumn.js +52 -0
- package/dist/umd/qc-ui.min.js +1 -1
- package/package.json +1 -1
|
@@ -140,11 +140,15 @@ var FormRender = function FormRender(props) {
|
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
142
|
var columns = colDefs === null || colDefs === void 0 ? void 0 : colDefs.map(function (colDef) {
|
|
143
|
+
var _searchComponentProps;
|
|
143
144
|
var state = columnStates.find(function (x) {
|
|
144
145
|
return x.colId == colDef.field;
|
|
145
146
|
});
|
|
146
147
|
var columnDefs = gridApi === null || gridApi === void 0 ? void 0 : gridApi.getColumnDef(colDef.field);
|
|
147
|
-
|
|
148
|
+
// 查询组件属性(下拉选项)以本次传入的列为准:AG Grid 在本副作用之后才应用新 columnDefs,此刻取到的还是上一版。@author nokecy
|
|
149
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, colDef), columnDefs), state), {}, {
|
|
150
|
+
searchComponentProps: (_searchComponentProps = colDef.searchComponentProps) !== null && _searchComponentProps !== void 0 ? _searchComponentProps : columnDefs === null || columnDefs === void 0 ? void 0 : columnDefs.searchComponentProps
|
|
151
|
+
});
|
|
148
152
|
});
|
|
149
153
|
columns = columns ? (_columns = columns) === null || _columns === void 0 ? void 0 : _columns.filter(function (i) {
|
|
150
154
|
return (i === null || i === void 0 ? void 0 : i.visible) != false && !(i !== null && i !== void 0 && i.hide) && !(i !== null && i !== void 0 && i.hideInSearch) || (i === null || i === void 0 ? void 0 : i.hideInTable);
|
|
@@ -11,6 +11,7 @@ var _react2 = require("@formily/react");
|
|
|
11
11
|
var _uniqueId = _interopRequireDefault(require("lodash/uniqueId"));
|
|
12
12
|
var _utils = require("./utils");
|
|
13
13
|
var _columnGroup = require("./columnGroup");
|
|
14
|
+
var _indexColumn = require("./indexColumn");
|
|
14
15
|
var _hooks = require("./hooks");
|
|
15
16
|
var _arrayBase = _interopRequireDefault(require("./arrayBase"));
|
|
16
17
|
var _arrayAddBtn = _interopRequireDefault(require("./arrayAddBtn"));
|
|
@@ -134,8 +135,13 @@ var ArrayTableInner = (0, _react2.observer)(function (props) {
|
|
|
134
135
|
* 列的状态(宽度、顺序、隐藏等)由方案通过 applyColumnState 控制,不需要通过 columnDefs 传递
|
|
135
136
|
*/
|
|
136
137
|
var stableColumnDefs = (0, _react.useMemo)(function () {
|
|
138
|
+
var _buildArrayTableColum;
|
|
137
139
|
// 只依赖 sources,不依赖 dataSource 和 field.value
|
|
138
|
-
var cols = (0, _utils.buildArrayTableColumns)([], field, sources);
|
|
140
|
+
var cols = (_buildArrayTableColum = (0, _utils.buildArrayTableColumns)([], field, sources)) !== null && _buildArrayTableColum !== void 0 ? _buildArrayTableColum : [];
|
|
141
|
+
// 默认在最左加序号列;schema 里已经放了 ArrayTable.Index 的不再加。@author nokecy
|
|
142
|
+
if (cols.length > 0 && !(0, _indexColumn.hasOwnIndexColumn)(sources)) {
|
|
143
|
+
cols.unshift((0, _indexColumn.makeIndexColumn)());
|
|
144
|
+
}
|
|
139
145
|
//@ts-ignore
|
|
140
146
|
if (cols.length > 0 && props.onRowDrag) {
|
|
141
147
|
//@ts-ignore
|
|
@@ -369,6 +375,14 @@ var ArrayTableInner = (0, _react2.observer)(function (props) {
|
|
|
369
375
|
},
|
|
370
376
|
onRowDragMove: handleRowDragMove,
|
|
371
377
|
onRowDataUpdated: function onRowDataUpdated(e) {
|
|
378
|
+
// 增删行、拖动换行后行位置变了,未改动的行不会自己重算序号,统一刷新序号列 @author nokecy
|
|
379
|
+
if (stableColumnDefs.some(function (c) {
|
|
380
|
+
return (c === null || c === void 0 ? void 0 : c.field) === _indexColumn.ARRAY_TABLE_INDEX_FIELD;
|
|
381
|
+
})) {
|
|
382
|
+
e.api.refreshCells({
|
|
383
|
+
columns: [_indexColumn.ARRAY_TABLE_INDEX_FIELD]
|
|
384
|
+
});
|
|
385
|
+
}
|
|
372
386
|
if (isAdd) {
|
|
373
387
|
var _apiRef$current;
|
|
374
388
|
(_apiRef$current = apiRef.current) === null || _apiRef$current === void 0 || _apiRef$current.ensureIndexVisible(dataSource.length - 1, "bottom");
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ColDef } from 'ag-grid-community';
|
|
2
|
+
/** 默认序号列的字段名;不对应任何数据字段,值由 valueGetter 按行位置生成 */
|
|
3
|
+
export declare const ARRAY_TABLE_INDEX_FIELD = "__arrayTableIndex";
|
|
4
|
+
/**
|
|
5
|
+
* 表格是否已经自己写了序号列(某个可见列里放了 ArrayTable.Index)。
|
|
6
|
+
* 写了就不再加默认序号列,免得出现两列序号;「行号」等业务数据列不算序号列。@author nokecy
|
|
7
|
+
*/
|
|
8
|
+
export declare const hasOwnIndexColumn: (sources: Array<{
|
|
9
|
+
schema: any;
|
|
10
|
+
display?: string;
|
|
11
|
+
}>) => boolean;
|
|
12
|
+
/**
|
|
13
|
+
* 默认序号列:按行在表格里的位置编号(1 起),不依赖业务行号或主键,与列表页的序号一致。
|
|
14
|
+
* 固定在最左、不可隐藏/拖动/排序;合计等固定行不编号。
|
|
15
|
+
* 增删行、拖动换行后由 ArrayTable 在 onRowDataUpdated 里刷新本列,见 index.tsx。@author nokecy
|
|
16
|
+
*/
|
|
17
|
+
export declare const makeIndexColumn: () => ColDef;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.makeIndexColumn = exports.hasOwnIndexColumn = exports.ARRAY_TABLE_INDEX_FIELD = void 0;
|
|
7
|
+
/** 默认序号列的字段名;不对应任何数据字段,值由 valueGetter 按行位置生成 */
|
|
8
|
+
var ARRAY_TABLE_INDEX_FIELD = exports.ARRAY_TABLE_INDEX_FIELD = '__arrayTableIndex';
|
|
9
|
+
|
|
10
|
+
/** schema 里含 ArrayTable.Index / ArrayBase.Index 之类的序号组件 */
|
|
11
|
+
var containsIndexComponent = function containsIndexComponent(schema) {
|
|
12
|
+
var _schema$properties;
|
|
13
|
+
if (!schema) return false;
|
|
14
|
+
var component = schema['x-component'];
|
|
15
|
+
if (typeof component === 'string' && /(?:^|\.)Index$/.test(component)) return true;
|
|
16
|
+
return Object.values((_schema$properties = schema.properties) !== null && _schema$properties !== void 0 ? _schema$properties : {}).some(containsIndexComponent);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 表格是否已经自己写了序号列(某个可见列里放了 ArrayTable.Index)。
|
|
21
|
+
* 写了就不再加默认序号列,免得出现两列序号;「行号」等业务数据列不算序号列。@author nokecy
|
|
22
|
+
*/
|
|
23
|
+
var hasOwnIndexColumn = exports.hasOwnIndexColumn = function hasOwnIndexColumn(sources) {
|
|
24
|
+
return sources.some(function (_ref) {
|
|
25
|
+
var schema = _ref.schema,
|
|
26
|
+
display = _ref.display;
|
|
27
|
+
return (!display || display === 'visible') && containsIndexComponent(schema);
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 默认序号列:按行在表格里的位置编号(1 起),不依赖业务行号或主键,与列表页的序号一致。
|
|
33
|
+
* 固定在最左、不可隐藏/拖动/排序;合计等固定行不编号。
|
|
34
|
+
* 增删行、拖动换行后由 ArrayTable 在 onRowDataUpdated 里刷新本列,见 index.tsx。@author nokecy
|
|
35
|
+
*/
|
|
36
|
+
var makeIndexColumn = exports.makeIndexColumn = function makeIndexColumn() {
|
|
37
|
+
return {
|
|
38
|
+
field: ARRAY_TABLE_INDEX_FIELD,
|
|
39
|
+
headerName: '序号',
|
|
40
|
+
width: 60,
|
|
41
|
+
pinned: 'left',
|
|
42
|
+
lockPosition: 'left',
|
|
43
|
+
lockPinned: true,
|
|
44
|
+
lockVisible: true,
|
|
45
|
+
suppressMovable: true,
|
|
46
|
+
suppressColumnsToolPanel: true,
|
|
47
|
+
sortable: false,
|
|
48
|
+
filter: false,
|
|
49
|
+
resizable: false,
|
|
50
|
+
editable: false,
|
|
51
|
+
valueGetter: function valueGetter(params) {
|
|
52
|
+
var _params$node, _params$node2;
|
|
53
|
+
if ((_params$node = params.node) !== null && _params$node !== void 0 && _params$node.rowPinned) return '';
|
|
54
|
+
var rowIndex = (_params$node2 = params.node) === null || _params$node2 === void 0 ? void 0 : _params$node2.rowIndex;
|
|
55
|
+
return rowIndex == null ? '' : rowIndex + 1;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
};
|
|
@@ -132,11 +132,15 @@ var FormRender = function FormRender(props) {
|
|
|
132
132
|
}
|
|
133
133
|
};
|
|
134
134
|
var columns = colDefs === null || colDefs === void 0 ? void 0 : colDefs.map(function (colDef) {
|
|
135
|
+
var _searchComponentProps;
|
|
135
136
|
var state = columnStates.find(function (x) {
|
|
136
137
|
return x.colId == colDef.field;
|
|
137
138
|
});
|
|
138
139
|
var columnDefs = gridApi === null || gridApi === void 0 ? void 0 : gridApi.getColumnDef(colDef.field);
|
|
139
|
-
|
|
140
|
+
// 查询组件属性(下拉选项)以本次传入的列为准:AG Grid 在本副作用之后才应用新 columnDefs,此刻取到的还是上一版。@author nokecy
|
|
141
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, colDef), columnDefs), state), {}, {
|
|
142
|
+
searchComponentProps: (_searchComponentProps = colDef.searchComponentProps) !== null && _searchComponentProps !== void 0 ? _searchComponentProps : columnDefs === null || columnDefs === void 0 ? void 0 : columnDefs.searchComponentProps
|
|
143
|
+
});
|
|
140
144
|
});
|
|
141
145
|
columns = columns ? (_columns = columns) === null || _columns === void 0 ? void 0 : _columns.filter(function (i) {
|
|
142
146
|
return (i === null || i === void 0 ? void 0 : i.visible) != false && !(i !== null && i !== void 0 && i.hide) && !(i !== null && i !== void 0 && i.hideInSearch) || (i === null || i === void 0 ? void 0 : i.hideInTable);
|
|
@@ -19,6 +19,7 @@ import { connect, mapProps, mapReadPretty } from "@formily/react";
|
|
|
19
19
|
import uniqueId from "lodash/uniqueId";
|
|
20
20
|
import { useAddition, buildArrayTableColumns, useArrayTableSources, useArrayTableActions, isColumnComponent } from "./utils";
|
|
21
21
|
import { groupColumnDefs } from "./columnGroup";
|
|
22
|
+
import { ARRAY_TABLE_INDEX_FIELD, hasOwnIndexColumn, makeIndexColumn } from "./indexColumn";
|
|
22
23
|
import { useCellFocus, useKeyboardNavigation, useRowDrag, suppressNativeInputKeys } from "./hooks";
|
|
23
24
|
import ArrayBase from "./arrayBase";
|
|
24
25
|
import ArrayAddBtn from "./arrayAddBtn";
|
|
@@ -130,8 +131,13 @@ var ArrayTableInner = observer(function (props) {
|
|
|
130
131
|
* 列的状态(宽度、顺序、隐藏等)由方案通过 applyColumnState 控制,不需要通过 columnDefs 传递
|
|
131
132
|
*/
|
|
132
133
|
var stableColumnDefs = useMemo(function () {
|
|
134
|
+
var _buildArrayTableColum;
|
|
133
135
|
// 只依赖 sources,不依赖 dataSource 和 field.value
|
|
134
|
-
var cols = buildArrayTableColumns([], field, sources);
|
|
136
|
+
var cols = (_buildArrayTableColum = buildArrayTableColumns([], field, sources)) !== null && _buildArrayTableColum !== void 0 ? _buildArrayTableColum : [];
|
|
137
|
+
// 默认在最左加序号列;schema 里已经放了 ArrayTable.Index 的不再加。@author nokecy
|
|
138
|
+
if (cols.length > 0 && !hasOwnIndexColumn(sources)) {
|
|
139
|
+
cols.unshift(makeIndexColumn());
|
|
140
|
+
}
|
|
135
141
|
//@ts-ignore
|
|
136
142
|
if (cols.length > 0 && props.onRowDrag) {
|
|
137
143
|
//@ts-ignore
|
|
@@ -365,6 +371,14 @@ var ArrayTableInner = observer(function (props) {
|
|
|
365
371
|
},
|
|
366
372
|
onRowDragMove: handleRowDragMove,
|
|
367
373
|
onRowDataUpdated: function onRowDataUpdated(e) {
|
|
374
|
+
// 增删行、拖动换行后行位置变了,未改动的行不会自己重算序号,统一刷新序号列 @author nokecy
|
|
375
|
+
if (stableColumnDefs.some(function (c) {
|
|
376
|
+
return (c === null || c === void 0 ? void 0 : c.field) === ARRAY_TABLE_INDEX_FIELD;
|
|
377
|
+
})) {
|
|
378
|
+
e.api.refreshCells({
|
|
379
|
+
columns: [ARRAY_TABLE_INDEX_FIELD]
|
|
380
|
+
});
|
|
381
|
+
}
|
|
368
382
|
if (isAdd) {
|
|
369
383
|
var _apiRef$current;
|
|
370
384
|
(_apiRef$current = apiRef.current) === null || _apiRef$current === void 0 || _apiRef$current.ensureIndexVisible(dataSource.length - 1, "bottom");
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ColDef } from 'ag-grid-community';
|
|
2
|
+
/** 默认序号列的字段名;不对应任何数据字段,值由 valueGetter 按行位置生成 */
|
|
3
|
+
export declare const ARRAY_TABLE_INDEX_FIELD = "__arrayTableIndex";
|
|
4
|
+
/**
|
|
5
|
+
* 表格是否已经自己写了序号列(某个可见列里放了 ArrayTable.Index)。
|
|
6
|
+
* 写了就不再加默认序号列,免得出现两列序号;「行号」等业务数据列不算序号列。@author nokecy
|
|
7
|
+
*/
|
|
8
|
+
export declare const hasOwnIndexColumn: (sources: Array<{
|
|
9
|
+
schema: any;
|
|
10
|
+
display?: string;
|
|
11
|
+
}>) => boolean;
|
|
12
|
+
/**
|
|
13
|
+
* 默认序号列:按行在表格里的位置编号(1 起),不依赖业务行号或主键,与列表页的序号一致。
|
|
14
|
+
* 固定在最左、不可隐藏/拖动/排序;合计等固定行不编号。
|
|
15
|
+
* 增删行、拖动换行后由 ArrayTable 在 onRowDataUpdated 里刷新本列,见 index.tsx。@author nokecy
|
|
16
|
+
*/
|
|
17
|
+
export declare const makeIndexColumn: () => ColDef;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** 默认序号列的字段名;不对应任何数据字段,值由 valueGetter 按行位置生成 */
|
|
2
|
+
export var ARRAY_TABLE_INDEX_FIELD = '__arrayTableIndex';
|
|
3
|
+
|
|
4
|
+
/** schema 里含 ArrayTable.Index / ArrayBase.Index 之类的序号组件 */
|
|
5
|
+
var containsIndexComponent = function containsIndexComponent(schema) {
|
|
6
|
+
var _schema$properties;
|
|
7
|
+
if (!schema) return false;
|
|
8
|
+
var component = schema['x-component'];
|
|
9
|
+
if (typeof component === 'string' && /(?:^|\.)Index$/.test(component)) return true;
|
|
10
|
+
return Object.values((_schema$properties = schema.properties) !== null && _schema$properties !== void 0 ? _schema$properties : {}).some(containsIndexComponent);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 表格是否已经自己写了序号列(某个可见列里放了 ArrayTable.Index)。
|
|
15
|
+
* 写了就不再加默认序号列,免得出现两列序号;「行号」等业务数据列不算序号列。@author nokecy
|
|
16
|
+
*/
|
|
17
|
+
export var hasOwnIndexColumn = function hasOwnIndexColumn(sources) {
|
|
18
|
+
return sources.some(function (_ref) {
|
|
19
|
+
var schema = _ref.schema,
|
|
20
|
+
display = _ref.display;
|
|
21
|
+
return (!display || display === 'visible') && containsIndexComponent(schema);
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 默认序号列:按行在表格里的位置编号(1 起),不依赖业务行号或主键,与列表页的序号一致。
|
|
27
|
+
* 固定在最左、不可隐藏/拖动/排序;合计等固定行不编号。
|
|
28
|
+
* 增删行、拖动换行后由 ArrayTable 在 onRowDataUpdated 里刷新本列,见 index.tsx。@author nokecy
|
|
29
|
+
*/
|
|
30
|
+
export var makeIndexColumn = function makeIndexColumn() {
|
|
31
|
+
return {
|
|
32
|
+
field: ARRAY_TABLE_INDEX_FIELD,
|
|
33
|
+
headerName: '序号',
|
|
34
|
+
width: 60,
|
|
35
|
+
pinned: 'left',
|
|
36
|
+
lockPosition: 'left',
|
|
37
|
+
lockPinned: true,
|
|
38
|
+
lockVisible: true,
|
|
39
|
+
suppressMovable: true,
|
|
40
|
+
suppressColumnsToolPanel: true,
|
|
41
|
+
sortable: false,
|
|
42
|
+
filter: false,
|
|
43
|
+
resizable: false,
|
|
44
|
+
editable: false,
|
|
45
|
+
valueGetter: function valueGetter(params) {
|
|
46
|
+
var _params$node, _params$node2;
|
|
47
|
+
if ((_params$node = params.node) !== null && _params$node !== void 0 && _params$node.rowPinned) return '';
|
|
48
|
+
var rowIndex = (_params$node2 = params.node) === null || _params$node2 === void 0 ? void 0 : _params$node2.rowIndex;
|
|
49
|
+
return rowIndex == null ? '' : rowIndex + 1;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
};
|