@lemon-fe/kits 1.0.3-3 → 1.0.3
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.
|
@@ -68,6 +68,7 @@ export default class DataGrid<TData extends Record<string, any>> extends Compone
|
|
|
68
68
|
constructor(props: DataGridProps<TData>);
|
|
69
69
|
setField(field: FieldCol): void;
|
|
70
70
|
getField(id: string): FieldCol | undefined;
|
|
71
|
+
getFields(): FieldCol[];
|
|
71
72
|
deleteField(id: string): void;
|
|
72
73
|
saveFields(): Promise<void>;
|
|
73
74
|
resetFields(): void;
|
|
@@ -100,20 +100,28 @@ import DetailCellRenderer from "./renderer/DetailCellRenderer";
|
|
|
100
100
|
import HeaderRenderer from "./renderer/HeaderRenderer";
|
|
101
101
|
import { prefix, getColField, isColumn, withSyncRender, Store, Selection, columnTypes } from "./utils";
|
|
102
102
|
|
|
103
|
+
function toNumber(a) {
|
|
104
|
+
if (typeof a === 'string') {
|
|
105
|
+
return a.replace(/,/g, '');
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return a;
|
|
109
|
+
}
|
|
110
|
+
|
|
103
111
|
var add = function add(a, b) {
|
|
104
|
-
return new BigNumber(a).plus(b);
|
|
112
|
+
return new BigNumber(toNumber(a)).plus(toNumber(b));
|
|
105
113
|
};
|
|
106
114
|
|
|
107
115
|
var subtract = function subtract(a, b) {
|
|
108
|
-
return new BigNumber(a).minus(b);
|
|
116
|
+
return new BigNumber(toNumber(a)).minus(toNumber(b));
|
|
109
117
|
};
|
|
110
118
|
|
|
111
119
|
var multiply = function multiply(a, b) {
|
|
112
|
-
return new BigNumber(a).times(b);
|
|
120
|
+
return new BigNumber(toNumber(a)).times(toNumber(b));
|
|
113
121
|
};
|
|
114
122
|
|
|
115
123
|
var divide = function divide(a, b) {
|
|
116
|
-
return new BigNumber(a).div(b);
|
|
124
|
+
return new BigNumber(toNumber(a)).div(toNumber(b));
|
|
117
125
|
};
|
|
118
126
|
|
|
119
127
|
var _create = create({
|
|
@@ -571,6 +579,11 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
571
579
|
return item.id === id;
|
|
572
580
|
});
|
|
573
581
|
}
|
|
582
|
+
}, {
|
|
583
|
+
key: "getFields",
|
|
584
|
+
value: function getFields() {
|
|
585
|
+
return this.fields;
|
|
586
|
+
}
|
|
574
587
|
}, {
|
|
575
588
|
key: "deleteField",
|
|
576
589
|
value: function deleteField(id) {
|
|
@@ -992,7 +1005,8 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
992
1005
|
}, {
|
|
993
1006
|
key: "getColumnDefs",
|
|
994
1007
|
value: function getColumnDefs() {
|
|
995
|
-
var _this6 = this
|
|
1008
|
+
var _this6 = this,
|
|
1009
|
+
_this$props$customCol;
|
|
996
1010
|
|
|
997
1011
|
var _this$props7 = this.props,
|
|
998
1012
|
_this$props7$columns = _this$props7.columns,
|
|
@@ -1189,6 +1203,7 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1189
1203
|
};
|
|
1190
1204
|
|
|
1191
1205
|
var result = map(columns);
|
|
1206
|
+
var suppressFieldsValueGetter = !!((_this$props$customCol = this.props.customColumnPanelStorage) !== null && _this$props$customCol !== void 0 && _this$props$customCol.suppressFieldValueGetter);
|
|
1192
1207
|
this.fields.forEach(function (field) {
|
|
1193
1208
|
var expression = field.expression.replace(/\$\{([^{}]+)\}/g, function (match, p1) {
|
|
1194
1209
|
if (p1) {
|
|
@@ -1199,13 +1214,18 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1199
1214
|
});
|
|
1200
1215
|
leafColIds.push(field.id);
|
|
1201
1216
|
var code = parse(expression).compile();
|
|
1202
|
-
|
|
1217
|
+
var fieldCol = {
|
|
1203
1218
|
colId: field.id,
|
|
1204
1219
|
headerName: field.name,
|
|
1205
1220
|
spanHeaderHeight: true,
|
|
1206
1221
|
sortable: false,
|
|
1207
|
-
type: 'rightAligned'
|
|
1208
|
-
|
|
1222
|
+
type: 'rightAligned'
|
|
1223
|
+
};
|
|
1224
|
+
|
|
1225
|
+
if (suppressFieldsValueGetter) {
|
|
1226
|
+
fieldCol.field = field.id;
|
|
1227
|
+
} else {
|
|
1228
|
+
fieldCol.valueGetter = function (params) {
|
|
1209
1229
|
var api = params.api,
|
|
1210
1230
|
node = params.node,
|
|
1211
1231
|
columnApi = params.columnApi;
|
|
@@ -1265,8 +1285,10 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1265
1285
|
}
|
|
1266
1286
|
|
|
1267
1287
|
return null;
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1288
|
+
};
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
result.push(fieldCol);
|
|
1270
1292
|
});
|
|
1271
1293
|
|
|
1272
1294
|
if (rowSelection !== undefined) {
|
|
@@ -1307,7 +1329,6 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1307
1329
|
colId: '$$actions',
|
|
1308
1330
|
pinned: 'right',
|
|
1309
1331
|
headerName: '操作',
|
|
1310
|
-
resizable: false,
|
|
1311
1332
|
sortable: false,
|
|
1312
1333
|
suppressAutoSize: true,
|
|
1313
1334
|
suppressMovable: true,
|
|
@@ -214,6 +214,7 @@ export interface DataGridProps<TData> extends Omit<AgGridReactProps<TData>, 'row
|
|
|
214
214
|
* @description 自定义列保存
|
|
215
215
|
*/
|
|
216
216
|
customColumnPanelStorage?: {
|
|
217
|
+
suppressFieldValueGetter?: boolean;
|
|
217
218
|
set: (data: CustomColumnData) => Promise<void> | void;
|
|
218
219
|
get: () => Promise<CustomColumnData | null | undefined> | CustomColumnData | null | undefined;
|
|
219
220
|
};
|
|
@@ -56,7 +56,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
56
56
|
|
|
57
57
|
import { ReloadOutlined } from '@ant-design/icons';
|
|
58
58
|
import { Subject } from '@lemon-fe/utils';
|
|
59
|
-
import { ConfigProvider, Modal, Row, Spin } from 'antd';
|
|
59
|
+
import { ConfigProvider, Modal, Row, Spin, Typography } from 'antd';
|
|
60
60
|
import { get } from 'lodash';
|
|
61
61
|
import React, { useContext, Component, createRef } from 'react';
|
|
62
62
|
import { unmountComponentAtNode, render } from 'react-dom';
|
|
@@ -65,6 +65,7 @@ import DataGrid from "../../components/DataGrid";
|
|
|
65
65
|
import Icons from "../../components/Icons";
|
|
66
66
|
import Layout from "../../components/Layout";
|
|
67
67
|
import Section from "../../components/Section";
|
|
68
|
+
var Text = Typography.Text;
|
|
68
69
|
|
|
69
70
|
var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
70
71
|
_inherits(BatchOperate, _Component);
|
|
@@ -298,7 +299,14 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
298
299
|
if (mode === 'warning') {
|
|
299
300
|
return /*#__PURE__*/React.createElement(Row, {
|
|
300
301
|
justify: 'space-between'
|
|
301
|
-
}, /*#__PURE__*/React.createElement(
|
|
302
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
303
|
+
ellipsis: {
|
|
304
|
+
tooltip: error.message
|
|
305
|
+
},
|
|
306
|
+
style: {
|
|
307
|
+
flex: 1
|
|
308
|
+
}
|
|
309
|
+
}, /*#__PURE__*/React.createElement(Icons.Tip, {
|
|
302
310
|
type: "warning"
|
|
303
311
|
}), /*#__PURE__*/React.createElement("span", null, " ", error.message, " ")), /*#__PURE__*/React.createElement("a", {
|
|
304
312
|
onClick: function onClick() {
|
|
@@ -307,18 +315,33 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
307
315
|
}, "\u7EE7\u7EED"));
|
|
308
316
|
}
|
|
309
317
|
|
|
310
|
-
return /*#__PURE__*/React.createElement(
|
|
318
|
+
return /*#__PURE__*/React.createElement(Row, {
|
|
319
|
+
align: 'middle',
|
|
320
|
+
wrap: false
|
|
321
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
322
|
+
style: {
|
|
323
|
+
marginRight: 2
|
|
324
|
+
},
|
|
325
|
+
ellipsis: {
|
|
326
|
+
tooltip: error.message
|
|
327
|
+
}
|
|
328
|
+
}, /*#__PURE__*/React.createElement(Icons.Tip, {
|
|
311
329
|
type: "error"
|
|
312
|
-
}), /*#__PURE__*/React.createElement("span", null, " ", error.message, " "), /*#__PURE__*/React.createElement(ReloadOutlined, {
|
|
330
|
+
}), /*#__PURE__*/React.createElement("span", null, " ", error.message, " ")), /*#__PURE__*/React.createElement(ReloadOutlined, {
|
|
313
331
|
onClick: function onClick() {
|
|
314
332
|
_this2.processNode(id, 0, _this2.props.params);
|
|
315
333
|
}
|
|
316
334
|
}));
|
|
317
335
|
}
|
|
318
336
|
|
|
319
|
-
|
|
337
|
+
var resultInfo = (typeof result === 'string' ? result : '操作成功').toString();
|
|
338
|
+
return /*#__PURE__*/React.createElement(Text, {
|
|
339
|
+
ellipsis: {
|
|
340
|
+
tooltip: resultInfo
|
|
341
|
+
}
|
|
342
|
+
}, /*#__PURE__*/React.createElement(Icons.Tip, {
|
|
320
343
|
type: "success"
|
|
321
|
-
}), /*#__PURE__*/React.createElement("span", null, " ",
|
|
344
|
+
}), /*#__PURE__*/React.createElement("span", null, " ", resultInfo));
|
|
322
345
|
}
|
|
323
346
|
});
|
|
324
347
|
} else {
|
|
@@ -465,9 +488,19 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
465
488
|
};
|
|
466
489
|
|
|
467
490
|
if (error) {
|
|
468
|
-
return /*#__PURE__*/React.createElement(
|
|
491
|
+
return /*#__PURE__*/React.createElement(Row, {
|
|
492
|
+
align: 'middle',
|
|
493
|
+
wrap: false
|
|
494
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
495
|
+
style: {
|
|
496
|
+
marginRight: 2
|
|
497
|
+
},
|
|
498
|
+
ellipsis: {
|
|
499
|
+
tooltip: error.message
|
|
500
|
+
}
|
|
501
|
+
}, /*#__PURE__*/React.createElement(Icons.Tip, {
|
|
469
502
|
type: "error"
|
|
470
|
-
}), /*#__PURE__*/React.createElement("span", null, " ", error.message, " "), /*#__PURE__*/React.createElement(ReloadOutlined, {
|
|
503
|
+
}), /*#__PURE__*/React.createElement("span", null, " ", error.message, " ")), /*#__PURE__*/React.createElement(ReloadOutlined, {
|
|
471
504
|
onClick: function onClick() {
|
|
472
505
|
return reload();
|
|
473
506
|
}
|
|
@@ -495,9 +528,14 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
495
528
|
});
|
|
496
529
|
}
|
|
497
530
|
|
|
498
|
-
|
|
531
|
+
var resultInfo = (typeof result === 'string' ? result : '操作成功').toString();
|
|
532
|
+
return /*#__PURE__*/React.createElement(Text, {
|
|
533
|
+
ellipsis: {
|
|
534
|
+
tooltip: resultInfo
|
|
535
|
+
}
|
|
536
|
+
}, /*#__PURE__*/React.createElement(Icons.Tip, {
|
|
499
537
|
type: "success"
|
|
500
|
-
}), /*#__PURE__*/React.createElement("span", null, " ",
|
|
538
|
+
}), /*#__PURE__*/React.createElement("span", null, " ", resultInfo));
|
|
501
539
|
}
|
|
502
540
|
}];
|
|
503
541
|
} else if (process) {
|