@nokecy/qc-ui 1.0.47 → 1.0.49
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/utils.js +3 -2
- package/dist/cjs/array-table/index.js +10 -63
- package/dist/cjs/array-table/utils.d.ts +2 -1
- package/dist/cjs/array-table/utils.js +36 -1
- package/dist/esm/ag-grid-plus/utils.js +3 -2
- package/dist/esm/array-table/index.js +11 -64
- package/dist/esm/array-table/utils.d.ts +2 -1
- package/dist/esm/array-table/utils.js +36 -1
- package/dist/umd/qc-ui.min.js +1 -1
- package/package.json +1 -1
|
@@ -33,15 +33,16 @@ var getFilter = function getFilter(objectKey, value, colDef) {
|
|
|
33
33
|
return "".concat(objectKey, " = ").concat(value);
|
|
34
34
|
}
|
|
35
35
|
if (value instanceof Array) {
|
|
36
|
-
var _colDef$searchCompone;
|
|
36
|
+
var _colDef$searchCompone, _colDef$searchCompone2;
|
|
37
37
|
var format = (colDef === null || colDef === void 0 || (_colDef$searchCompone = colDef.searchComponentProps) === null || _colDef$searchCompone === void 0 ? void 0 : _colDef$searchCompone.format) || 'YYYY-MM-DD';
|
|
38
|
+
var showTime = colDef === null || colDef === void 0 || (_colDef$searchCompone2 = colDef.searchComponentProps) === null || _colDef$searchCompone2 === void 0 ? void 0 : _colDef$searchCompone2.showTime;
|
|
38
39
|
// 处理时间数组
|
|
39
40
|
if (value.length === 2 && (value.every(function (v) {
|
|
40
41
|
return (0, _dayjs.default)(v, 'YYYY-MM-DD').isValid();
|
|
41
42
|
}) || value.every(function (v) {
|
|
42
43
|
return (0, _dayjs.default)(v, 'YYYY-MM-DD HH:mm:ss').isValid();
|
|
43
44
|
}))) {
|
|
44
|
-
return "".concat(objectKey, " >= ").concat((0, _dayjs.default)(value[0]).format(format), " ,") + "".concat(objectKey, " <= ").concat((0, _dayjs.default)(value[1]).add(1, 'days').format(format));
|
|
45
|
+
return "".concat(objectKey, " >= ").concat((0, _dayjs.default)(value[0]).format(format), " ,") + "".concat(objectKey, " <= ").concat(showTime ? (0, _dayjs.default)(value[1]).format(format) : (0, _dayjs.default)(value[1]).add(1, 'days').format(format));
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
// 处理非时间数组(如数字数组),转为 "asnStatus=10|asnStatus=20"
|
|
@@ -24,6 +24,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
24
24
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
25
25
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
26
26
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
27
|
+
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); }
|
|
27
28
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
28
29
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
29
30
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -47,6 +48,7 @@ var ArrayTable = (0, _react2.observer)(function (props) {
|
|
|
47
48
|
var dataSource = Array.isArray(field.value) ? field.value.slice() : [];
|
|
48
49
|
var dataSourceCopy = dataSource.slice();
|
|
49
50
|
var sources = (0, _utils.useArrayTableSources)();
|
|
51
|
+
var actions = (0, _utils.useArrayTableActions)();
|
|
50
52
|
var columns = (0, _utils.useArrayTableColumns)(dataSource, field, sources);
|
|
51
53
|
var schema = (0, _react2.useFieldSchema)();
|
|
52
54
|
//@ts-ignore
|
|
@@ -60,67 +62,6 @@ var ArrayTable = (0, _react2.observer)(function (props) {
|
|
|
60
62
|
onSaveColumnState = _useGridPlusColumnSta.onSaveColumnState,
|
|
61
63
|
gridPlusColumnState = _useGridPlusColumnSta.columnState,
|
|
62
64
|
extensibleColumns = _useGridPlusColumnSta.extensibleColumns;
|
|
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
|
-
// ]
|
|
123
|
-
|
|
124
65
|
(0, _react.useEffect)(function () {
|
|
125
66
|
if (props.gridKey && gridPlusColumnState && gridPlusColumnState[props.gridKey] && apiRef.current) {
|
|
126
67
|
setTimeout(function () {
|
|
@@ -167,7 +108,7 @@ var ArrayTable = (0, _react2.observer)(function (props) {
|
|
|
167
108
|
style: {
|
|
168
109
|
marginBottom: 5
|
|
169
110
|
}
|
|
170
|
-
}, addition ? /*#__PURE__*/_react.default.createElement(_arrayAddBtn.default, {
|
|
111
|
+
}, addition ? /*#__PURE__*/_react.default.createElement(_arrayAddBtn.default, _extends({
|
|
171
112
|
arrayField: field,
|
|
172
113
|
schema: schema,
|
|
173
114
|
defaultValue: {
|
|
@@ -178,7 +119,13 @@ var ArrayTable = (0, _react2.observer)(function (props) {
|
|
|
178
119
|
onAdd: function onAdd() {
|
|
179
120
|
setIsAdd(true);
|
|
180
121
|
}
|
|
181
|
-
}) : null
|
|
122
|
+
}, addition.props)) : null, actions.map(function (column, key) {
|
|
123
|
+
return /*#__PURE__*/_react.default.createElement(_react2.RecursionField, {
|
|
124
|
+
schema: column.schema,
|
|
125
|
+
name: key,
|
|
126
|
+
onlyRenderProperties: true
|
|
127
|
+
});
|
|
128
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
182
129
|
ref: ref,
|
|
183
130
|
style: {
|
|
184
131
|
height: height ? height : 400
|
|
@@ -5,6 +5,7 @@ import { Schema } from '@formily/json-schema';
|
|
|
5
5
|
import { ObservableColumnSource } from './interface';
|
|
6
6
|
declare const isColumnComponent: (schema: Schema) => boolean;
|
|
7
7
|
declare const useArrayTableSources: () => ObservableColumnSource[];
|
|
8
|
+
declare const useArrayTableActions: () => ObservableColumnSource[];
|
|
8
9
|
declare const useArrayTableColumns: (dataSource: any[], field: ArrayField, sources: ObservableColumnSource[]) => AgGridReactProps['columnDefs'];
|
|
9
10
|
declare const useAddition: () => React.JSX.Element | null;
|
|
10
|
-
export { isColumnComponent, useArrayTableSources, useArrayTableColumns, useAddition };
|
|
11
|
+
export { isColumnComponent, useArrayTableSources, useArrayTableActions, useArrayTableColumns, useAddition };
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useArrayTableSources = exports.useArrayTableColumns = exports.useAddition = exports.isColumnComponent = void 0;
|
|
6
|
+
exports.useArrayTableSources = exports.useArrayTableColumns = exports.useArrayTableActions = exports.useAddition = exports.isColumnComponent = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _react2 = require("@formily/react");
|
|
9
9
|
var _shared = require("@formily/shared");
|
|
@@ -27,6 +27,10 @@ var isAdditionComponent = function isAdditionComponent(schema) {
|
|
|
27
27
|
var _schema$xComponent3;
|
|
28
28
|
return ((_schema$xComponent3 = schema['x-component']) === null || _schema$xComponent3 === void 0 ? void 0 : _schema$xComponent3.indexOf('Addition')) > -1;
|
|
29
29
|
};
|
|
30
|
+
var isActionComponent = function isActionComponent(schema) {
|
|
31
|
+
var _schema$xComponent4;
|
|
32
|
+
return ((_schema$xComponent4 = schema['x-component']) === null || _schema$xComponent4 === void 0 ? void 0 : _schema$xComponent4.indexOf('Action')) > -1;
|
|
33
|
+
};
|
|
30
34
|
var useArrayTableSources = exports.useArrayTableSources = function useArrayTableSources() {
|
|
31
35
|
var arrayField = (0, _react2.useField)();
|
|
32
36
|
var schema = (0, _react2.useFieldSchema)();
|
|
@@ -70,6 +74,37 @@ var useArrayTableSources = exports.useArrayTableSources = function useArrayTable
|
|
|
70
74
|
if (!schema) throw new Error('can not found schema object');
|
|
71
75
|
return parseArrayItems(schema.items);
|
|
72
76
|
};
|
|
77
|
+
var useArrayTableActions = exports.useArrayTableActions = function useArrayTableActions() {
|
|
78
|
+
var arrayField = (0, _react2.useField)();
|
|
79
|
+
var schema = (0, _react2.useFieldSchema)();
|
|
80
|
+
var parseSources = function parseSources(schema) {
|
|
81
|
+
if (isActionComponent(schema)) {
|
|
82
|
+
var _schema$xComponentP3, _schema$xComponentP4, _field$component2;
|
|
83
|
+
if (!((_schema$xComponentP3 = schema['x-component-props']) !== null && _schema$xComponentP3 !== void 0 && _schema$xComponentP3['dataIndex']) && !schema['name']) return [];
|
|
84
|
+
var name = ((_schema$xComponentP4 = schema['x-component-props']) === null || _schema$xComponentP4 === void 0 ? void 0 : _schema$xComponentP4['dataIndex']) || schema['name'];
|
|
85
|
+
var field = arrayField.query(arrayField.address.concat(name)).take();
|
|
86
|
+
//@ts-ignore
|
|
87
|
+
var columnProps = (field === null || field === void 0 || (_field$component2 = field.component) === null || _field$component2 === void 0 ? void 0 : _field$component2[1]) || schema['x-component-props'] || {};
|
|
88
|
+
var display = (field === null || field === void 0 ? void 0 : field.display) || schema['x-display'];
|
|
89
|
+
return [{
|
|
90
|
+
name: name,
|
|
91
|
+
display: display,
|
|
92
|
+
//@ts-ignore
|
|
93
|
+
field: field,
|
|
94
|
+
schema: schema,
|
|
95
|
+
columnProps: columnProps
|
|
96
|
+
}];
|
|
97
|
+
} else if (schema.properties) {
|
|
98
|
+
return schema.reduceProperties(function (buf, schema) {
|
|
99
|
+
//@ts-ignore
|
|
100
|
+
return buf.concat(parseSources(schema));
|
|
101
|
+
}, []);
|
|
102
|
+
}
|
|
103
|
+
return [];
|
|
104
|
+
};
|
|
105
|
+
if (!schema) throw new Error('can not found schema object');
|
|
106
|
+
return schema.properties ? parseSources(schema.properties['actions']) : [];
|
|
107
|
+
};
|
|
73
108
|
var AgField = function AgField(_ref) {
|
|
74
109
|
var value = _ref.value,
|
|
75
110
|
record = _ref.data,
|
|
@@ -26,15 +26,16 @@ var getFilter = function getFilter(objectKey, value, colDef) {
|
|
|
26
26
|
return "".concat(objectKey, " = ").concat(value);
|
|
27
27
|
}
|
|
28
28
|
if (value instanceof Array) {
|
|
29
|
-
var _colDef$searchCompone;
|
|
29
|
+
var _colDef$searchCompone, _colDef$searchCompone2;
|
|
30
30
|
var format = (colDef === null || colDef === void 0 || (_colDef$searchCompone = colDef.searchComponentProps) === null || _colDef$searchCompone === void 0 ? void 0 : _colDef$searchCompone.format) || 'YYYY-MM-DD';
|
|
31
|
+
var showTime = colDef === null || colDef === void 0 || (_colDef$searchCompone2 = colDef.searchComponentProps) === null || _colDef$searchCompone2 === void 0 ? void 0 : _colDef$searchCompone2.showTime;
|
|
31
32
|
// 处理时间数组
|
|
32
33
|
if (value.length === 2 && (value.every(function (v) {
|
|
33
34
|
return dayjs(v, 'YYYY-MM-DD').isValid();
|
|
34
35
|
}) || value.every(function (v) {
|
|
35
36
|
return dayjs(v, 'YYYY-MM-DD HH:mm:ss').isValid();
|
|
36
37
|
}))) {
|
|
37
|
-
return "".concat(objectKey, " >= ").concat(dayjs(value[0]).format(format), " ,") + "".concat(objectKey, " <= ").concat(dayjs(value[1]).add(1, 'days').format(format));
|
|
38
|
+
return "".concat(objectKey, " >= ").concat(dayjs(value[0]).format(format), " ,") + "".concat(objectKey, " <= ").concat(showTime ? dayjs(value[1]).format(format) : dayjs(value[1]).add(1, 'days').format(format));
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
// 处理非时间数组(如数字数组),转为 "asnStatus=10|asnStatus=20"
|
|
@@ -4,6 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
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); }
|
|
7
8
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
9
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
10
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -16,7 +17,7 @@ import { useField, observer, RecursionField } from "@formily/react";
|
|
|
16
17
|
import { useFieldSchema } from "@formily/react";
|
|
17
18
|
import { connect, mapProps, mapReadPretty } from "@formily/react";
|
|
18
19
|
import uniqueId from "lodash/uniqueId";
|
|
19
|
-
import { useAddition, useArrayTableColumns, useArrayTableSources, isColumnComponent } from "./utils";
|
|
20
|
+
import { useAddition, useArrayTableColumns, useArrayTableSources, useArrayTableActions, isColumnComponent } from "./utils";
|
|
20
21
|
import ArrayBase from "./arrayBase";
|
|
21
22
|
import ArrayAddBtn from "./arrayAddBtn";
|
|
22
23
|
import PreviewArrayTable from "./preview";
|
|
@@ -41,6 +42,7 @@ var ArrayTable = observer(function (props) {
|
|
|
41
42
|
var dataSource = Array.isArray(field.value) ? field.value.slice() : [];
|
|
42
43
|
var dataSourceCopy = dataSource.slice();
|
|
43
44
|
var sources = useArrayTableSources();
|
|
45
|
+
var actions = useArrayTableActions();
|
|
44
46
|
var columns = useArrayTableColumns(dataSource, field, sources);
|
|
45
47
|
var schema = useFieldSchema();
|
|
46
48
|
//@ts-ignore
|
|
@@ -54,67 +56,6 @@ var ArrayTable = observer(function (props) {
|
|
|
54
56
|
onSaveColumnState = _useGridPlusColumnSta.onSaveColumnState,
|
|
55
57
|
gridPlusColumnState = _useGridPlusColumnSta.columnState,
|
|
56
58
|
extensibleColumns = _useGridPlusColumnSta.extensibleColumns;
|
|
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
|
-
// ]
|
|
117
|
-
|
|
118
59
|
useEffect(function () {
|
|
119
60
|
if (props.gridKey && gridPlusColumnState && gridPlusColumnState[props.gridKey] && apiRef.current) {
|
|
120
61
|
setTimeout(function () {
|
|
@@ -161,7 +102,7 @@ var ArrayTable = observer(function (props) {
|
|
|
161
102
|
style: {
|
|
162
103
|
marginBottom: 5
|
|
163
104
|
}
|
|
164
|
-
}, addition ? /*#__PURE__*/React.createElement(ArrayAddBtn, {
|
|
105
|
+
}, addition ? /*#__PURE__*/React.createElement(ArrayAddBtn, _extends({
|
|
165
106
|
arrayField: field,
|
|
166
107
|
schema: schema,
|
|
167
108
|
defaultValue: {
|
|
@@ -172,7 +113,13 @@ var ArrayTable = observer(function (props) {
|
|
|
172
113
|
onAdd: function onAdd() {
|
|
173
114
|
setIsAdd(true);
|
|
174
115
|
}
|
|
175
|
-
}) : null
|
|
116
|
+
}, addition.props)) : null, actions.map(function (column, key) {
|
|
117
|
+
return /*#__PURE__*/React.createElement(RecursionField, {
|
|
118
|
+
schema: column.schema,
|
|
119
|
+
name: key,
|
|
120
|
+
onlyRenderProperties: true
|
|
121
|
+
});
|
|
122
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
176
123
|
ref: ref,
|
|
177
124
|
style: {
|
|
178
125
|
height: height ? height : 400
|
|
@@ -5,6 +5,7 @@ import { Schema } from '@formily/json-schema';
|
|
|
5
5
|
import { ObservableColumnSource } from './interface';
|
|
6
6
|
declare const isColumnComponent: (schema: Schema) => boolean;
|
|
7
7
|
declare const useArrayTableSources: () => ObservableColumnSource[];
|
|
8
|
+
declare const useArrayTableActions: () => ObservableColumnSource[];
|
|
8
9
|
declare const useArrayTableColumns: (dataSource: any[], field: ArrayField, sources: ObservableColumnSource[]) => AgGridReactProps['columnDefs'];
|
|
9
10
|
declare const useAddition: () => React.JSX.Element | null;
|
|
10
|
-
export { isColumnComponent, useArrayTableSources, useArrayTableColumns, useAddition };
|
|
11
|
+
export { isColumnComponent, useArrayTableSources, useArrayTableActions, useArrayTableColumns, useAddition };
|
|
@@ -20,6 +20,10 @@ var isAdditionComponent = function isAdditionComponent(schema) {
|
|
|
20
20
|
var _schema$xComponent3;
|
|
21
21
|
return ((_schema$xComponent3 = schema['x-component']) === null || _schema$xComponent3 === void 0 ? void 0 : _schema$xComponent3.indexOf('Addition')) > -1;
|
|
22
22
|
};
|
|
23
|
+
var isActionComponent = function isActionComponent(schema) {
|
|
24
|
+
var _schema$xComponent4;
|
|
25
|
+
return ((_schema$xComponent4 = schema['x-component']) === null || _schema$xComponent4 === void 0 ? void 0 : _schema$xComponent4.indexOf('Action')) > -1;
|
|
26
|
+
};
|
|
23
27
|
var useArrayTableSources = function useArrayTableSources() {
|
|
24
28
|
var arrayField = useField();
|
|
25
29
|
var schema = useFieldSchema();
|
|
@@ -63,6 +67,37 @@ var useArrayTableSources = function useArrayTableSources() {
|
|
|
63
67
|
if (!schema) throw new Error('can not found schema object');
|
|
64
68
|
return parseArrayItems(schema.items);
|
|
65
69
|
};
|
|
70
|
+
var useArrayTableActions = function useArrayTableActions() {
|
|
71
|
+
var arrayField = useField();
|
|
72
|
+
var schema = useFieldSchema();
|
|
73
|
+
var parseSources = function parseSources(schema) {
|
|
74
|
+
if (isActionComponent(schema)) {
|
|
75
|
+
var _schema$xComponentP3, _schema$xComponentP4, _field$component2;
|
|
76
|
+
if (!((_schema$xComponentP3 = schema['x-component-props']) !== null && _schema$xComponentP3 !== void 0 && _schema$xComponentP3['dataIndex']) && !schema['name']) return [];
|
|
77
|
+
var name = ((_schema$xComponentP4 = schema['x-component-props']) === null || _schema$xComponentP4 === void 0 ? void 0 : _schema$xComponentP4['dataIndex']) || schema['name'];
|
|
78
|
+
var field = arrayField.query(arrayField.address.concat(name)).take();
|
|
79
|
+
//@ts-ignore
|
|
80
|
+
var columnProps = (field === null || field === void 0 || (_field$component2 = field.component) === null || _field$component2 === void 0 ? void 0 : _field$component2[1]) || schema['x-component-props'] || {};
|
|
81
|
+
var display = (field === null || field === void 0 ? void 0 : field.display) || schema['x-display'];
|
|
82
|
+
return [{
|
|
83
|
+
name: name,
|
|
84
|
+
display: display,
|
|
85
|
+
//@ts-ignore
|
|
86
|
+
field: field,
|
|
87
|
+
schema: schema,
|
|
88
|
+
columnProps: columnProps
|
|
89
|
+
}];
|
|
90
|
+
} else if (schema.properties) {
|
|
91
|
+
return schema.reduceProperties(function (buf, schema) {
|
|
92
|
+
//@ts-ignore
|
|
93
|
+
return buf.concat(parseSources(schema));
|
|
94
|
+
}, []);
|
|
95
|
+
}
|
|
96
|
+
return [];
|
|
97
|
+
};
|
|
98
|
+
if (!schema) throw new Error('can not found schema object');
|
|
99
|
+
return schema.properties ? parseSources(schema.properties['actions']) : [];
|
|
100
|
+
};
|
|
66
101
|
var AgField = function AgField(_ref) {
|
|
67
102
|
var value = _ref.value,
|
|
68
103
|
record = _ref.data,
|
|
@@ -121,4 +156,4 @@ var useAddition = function useAddition() {
|
|
|
121
156
|
return addition;
|
|
122
157
|
}, null);
|
|
123
158
|
};
|
|
124
|
-
export { isColumnComponent, useArrayTableSources, useArrayTableColumns, useAddition };
|
|
159
|
+
export { isColumnComponent, useArrayTableSources, useArrayTableActions, useArrayTableColumns, useAddition };
|