easy3wui 1.5.55-beta15 → 1.5.55-beta16

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.
@@ -2,14 +2,6 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
 
5
- var _modal = require('antd/lib/modal');
6
-
7
- var _modal2 = _interopRequireDefault(_modal);
8
-
9
- var _extends2 = require('babel-runtime/helpers/extends');
10
-
11
- var _extends3 = _interopRequireDefault(_extends2);
12
-
13
5
  var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
14
6
 
15
7
  var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
@@ -22,8 +14,6 @@ var _inherits2 = require('babel-runtime/helpers/inherits');
22
14
 
23
15
  var _inherits3 = _interopRequireDefault(_inherits2);
24
16
 
25
- require('antd/lib/modal/style');
26
-
27
17
  var _react = require('react');
28
18
 
29
19
  var _react2 = _interopRequireDefault(_react);
@@ -54,839 +44,668 @@ var Selectors = _reactDataGridAddons.Data.Selectors;
54
44
  var Easy3wEditBigTable = function (_Component) {
55
45
  (0, _inherits3['default'])(Easy3wEditBigTable, _Component);
56
46
 
57
- function Easy3wEditBigTable(props) {
47
+ function Easy3wEditBigTable() {
58
48
  (0, _classCallCheck3['default'])(this, Easy3wEditBigTable);
59
-
60
- var _this = (0, _possibleConstructorReturn3['default'])(this, _Component.call(this, props));
61
-
62
- _this.bidPureComponent = function (pureComponentName, that) {
63
- _this[pureComponentName] = that;
64
- };
65
-
66
- _this.ReactDataGridRef = function (ref) {
67
- if (ref) {
68
- _this.ReactDataGridRef = ref;
69
- }
70
- };
71
-
72
- _this.onGridRowsUpdated = function (objUpdated) {
73
- var fromRowData = objUpdated.fromRowData;
74
- var updated = objUpdated.updated;
75
- var _this$props = _this.props,
76
- touchAutoCompute = _this$props.touchAutoCompute,
77
- onGridRowsUpdated = _this$props.onGridRowsUpdated,
78
- dataList = _this$props.dataList;
79
-
80
- if (touchAutoCompute && typeof touchAutoCompute === 'function') {
81
- // 数据变更-自动计算行数据
82
- updated = touchAutoCompute(objUpdated);
83
- }
84
- var autoAddNumberIdxEdit = fromRowData.autoAddNumber_idx_edit;
85
-
86
- dataList[autoAddNumberIdxEdit] = (0, _extends3['default'])({}, fromRowData, updated);
87
- if (onGridRowsUpdated && typeof onGridRowsUpdated === 'function') {
88
- // 数据变更-回调函数
89
- onGridRowsUpdated('onGridRowsUpdated', dataList);
90
- }
91
- };
92
-
93
- _this.onGridSort = function (sortColumn, sortDirection) {
94
- _this.setState({ sortColumn: sortColumn, sortDirection: sortDirection });
95
- };
96
-
97
- _this.onRowsSelected = function (rows) {
98
- var _this$state = _this.state,
99
- arrValues = _this$state.arrValues,
100
- arrValuesInfo = _this$state.arrValuesInfo;
101
- var _this$props2 = _this.props,
102
- rowKey = _this$props2.rowKey,
103
- onRowsSelectedCb = _this$props2.onRowsSelectedCb;
104
-
105
- var arrValuesNew = []; // 表格选择行索引
106
- var arrValuesInfoNew = []; // 表格选择行数据
107
- rows.map(function (r) {
108
- arrValuesNew.push(r.row[rowKey]);
109
- arrValuesInfoNew.push(r.row);
110
- return r;
111
- });
112
- arrValues = arrValues.concat(arrValuesNew); // 表格选择行索引
113
- arrValuesInfo = arrValuesInfo.concat(arrValuesInfoNew); // 表格选择行数据
114
- if (onRowsSelectedCb && typeof onRowsSelectedCb === 'function') {
115
- // 表格选择回调函数
116
- onRowsSelectedCb('onRowsSelected', arrValues, arrValuesInfo, arrValuesNew, arrValuesInfoNew);
117
- }
118
- _this.onSelectedRowsChange(arrValues, arrValuesInfo);
119
- };
120
-
121
- _this.onRowsDeselected = function (rows) {
122
- var arrValuesInfo = _this.state.arrValuesInfo;
123
- var _this$props3 = _this.props,
124
- rowKey = _this$props3.rowKey,
125
- onRowsSelectedCb = _this$props3.onRowsSelectedCb;
126
-
127
- var arrValuesNew = []; // 表格选择行索引
128
- var arrValuesInfoNew = []; // 表格选择行数据
129
- var arrSelected = []; // 已选择的行索引
130
- var arrSelectedInfo = []; // 已选择的行数据
131
- arrValuesInfo.filter(function (item) {
132
- var flag = true;
133
- rows.map(function (r) {
134
- var row = r.row;
135
-
136
- if (item[rowKey] === row[rowKey]) {
137
- // 删除已取消选择的行
138
- flag = false;
139
- arrSelected.push(item[rowKey]);
140
- arrSelectedInfo.push(item);
141
- }
142
- return r;
143
- });
144
- if (flag) {
145
- arrValuesNew.push(item[rowKey]);
146
- arrValuesInfoNew.push(item);
147
- }
148
- return flag;
149
- });
150
- if (onRowsSelectedCb && typeof onRowsSelectedCb === 'function') {
151
- // 表格选择回调函数
152
- onRowsSelectedCb('onRowsDeselected', arrValuesNew, arrValuesInfoNew, arrSelected, arrSelectedInfo);
153
- }
154
- _this.onSelectedRowsChange(arrValuesNew, arrValuesInfoNew);
155
- };
156
-
157
- _this.onSelectedRowsChange = function (arrValues, arrValuesInfo) {
158
- _this.setState({ arrValues: arrValues, arrValuesInfo: arrValuesInfo });
159
- };
160
-
161
- _this.touchAddRow = function () {
162
- var _this$props4 = _this.props,
163
- onGridRowsUpdated = _this$props4.onGridRowsUpdated,
164
- dataList = _this$props4.dataList;
165
-
166
- var dataListNew = [].concat(dataList, [{}]);
167
- if (onGridRowsUpdated && typeof onGridRowsUpdated === 'function') {
168
- // 数据变更-回调函数
169
- onGridRowsUpdated('touchAddRow', dataListNew);
170
- }
171
- };
172
-
173
- _this.touchCopyRow = function () {
174
- var _this$props5 = _this.props,
175
- onGridRowsUpdated = _this$props5.onGridRowsUpdated,
176
- dataList = _this$props5.dataList;
177
- var arrValues = _this.state.arrValues;
178
-
179
- if (arrValues.length) {
180
- var newArr = []; // 复制的新数组
181
- arrValues.forEach(function (key) {
182
- var newRow = (0, _extends3['default'])({}, dataList[key]);
183
- newArr.push(newRow);
184
- return key;
185
- });
186
- var dataListNew = [].concat(dataList, newArr);
187
- if (onGridRowsUpdated && typeof onGridRowsUpdated === 'function') {
188
- // 数据变更-回调函数
189
- onGridRowsUpdated('touchCopyRow', dataListNew);
190
- }
191
- } else {
192
- _modal2['default'].error({
193
- title: '错误',
194
- content: '请选择要复制的行'
195
- });
196
- }
197
- };
198
-
199
- _this.deleteRow = function () {
200
- var _this$props6 = _this.props,
201
- dataList = _this$props6.dataList,
202
- onGridRowsUpdated = _this$props6.onGridRowsUpdated,
203
- objToolbarProps = _this$props6.objToolbarProps,
204
- rowKey = _this$props6.rowKey;
205
- var deleteRowInterface = objToolbarProps.deleteRowInterface;
206
- var arrValues = _this.state.arrValues;
207
-
208
- if (arrValues.length) {
209
- // const dataListNew = []; // 删除选择行后的新数组
210
- var dataListDel = []; // 要删除的行数组
211
- var dataListNew = dataList.filter(function (row) {
212
- var flag = true;
213
- arrValues.map(function (key) {
214
- if (key === row[rowKey]) {
215
- dataListDel.push(row);
216
- // 删除选择的行
217
- flag = false;
218
- }
219
- return key;
220
- });
221
- return flag;
222
- });
223
- if (deleteRowInterface && typeof deleteRowInterface === 'function') {
224
- // 删除行接口
225
- deleteRowInterface(dataListDel, arrValues);
226
- }
227
- if (onGridRowsUpdated && typeof onGridRowsUpdated === 'function') {
228
- // 数据变更-回调函数
229
- onGridRowsUpdated('deleteRow', dataListNew);
230
- }
231
- _this.onSelectedRowsChange([], []); // 选择行清空
232
- } else {
233
- _modal2['default'].error({
234
- title: '错误',
235
- content: '请选择要删除的行'
236
- });
237
- }
238
- };
239
-
240
- _this.touchImport = function () {
241
- var input = document.getElementById('touchImportExcel');
242
- // input.type = 'file';
243
- input.onchange = function (e) {
244
- var file = e.target.files[0];
245
- var reader = new FileReader();
246
- reader.onload = function (event) {
247
- var onGridRowsUpdated = _this.props.onGridRowsUpdated;
248
-
249
- var _this$getHearder = _this.getHearder(),
250
- arrColumnsKey = _this$getHearder.arrColumnsKey;
251
-
252
- var data = event.target.result;
253
- var workbook = _xlsx2['default'].read(data, { type: 'binary' });
254
- var firstSheetName = workbook.SheetNames[0];
255
- var worksheet = workbook.Sheets[firstSheetName];
256
- var rows = _xlsx2['default'].utils.sheet_to_json(worksheet, { header: arrColumnsKey });
257
- rows.shift();
258
- if (onGridRowsUpdated && typeof onGridRowsUpdated === 'function') {
259
- // 数据变更-回调函数
260
- onGridRowsUpdated('touchImport', rows);
261
- }
262
- };
263
- reader.readAsBinaryString(file);
264
- };
265
- input.click();
266
- };
267
-
268
- _this.touchExport = function () {
269
- var _this$getHearder2 = _this.getHearder(),
270
- objSheet = _this$getHearder2.objSheet,
271
- arrColInfo = _this$getHearder2.arrColInfo;
272
-
273
- var filterDataList = _this.getRows();
274
- // 计算 filterDataList 中所有对象字段最多的长度
275
- var maxFieldsLength = 0;
276
- filterDataList.forEach(function (item) {
277
- var fieldsLength = Object.keys(item).length;
278
- if (fieldsLength > maxFieldsLength) {
279
- maxFieldsLength = fieldsLength;
280
- }
281
- return item;
282
- });
283
- if (maxFieldsLength > arrColInfo.length) {
284
- for (var i = arrColInfo.length; i < maxFieldsLength;) {
285
- arrColInfo.push({ hidden: true });
286
- i += 1;
287
- }
288
- }
289
- // 创建工作簿和工作表
290
- var worksheet = _xlsx2['default'].utils.json_to_sheet([objSheet].concat(filterDataList), { skipHeader: true });
291
- worksheet['!cols'] = arrColInfo;
292
- var workbook = _xlsx2['default'].utils.book_new();
293
- _xlsx2['default'].utils.book_append_sheet(workbook, worksheet, 'Sheet1');
294
-
295
- // 生成Excel文件并触发下载
296
- _xlsx2['default'].writeFile(workbook, 'exported_data.xlsx');
297
- };
298
-
299
- _this.showModalBatchEditBigTable = function () {
300
- _this.setState({
301
- visible: true // 显示批量录入Modal
302
- });
303
- };
304
-
305
- _this.hideModalBatchEditBigTable = function () {
306
- _this.setState({
307
- visible: false // 隐藏批量录入Modal
308
- });
309
- };
310
-
311
- _this.confirmCallbackBatchEditBigTable = function (objFormData, objColumn) {
312
- var _this$props7 = _this.props,
313
- touchAutoCompute = _this$props7.touchAutoCompute,
314
- onGridRowsUpdated = _this$props7.onGridRowsUpdated,
315
- dataList = _this$props7.dataList,
316
- rowKey = _this$props7.rowKey;
317
- // if (touchAutoCompute && typeof touchAutoCompute === 'function') { // 数据变更-自动计算行数据
318
- // updated = touchAutoCompute(objUpdated);
319
- // }
320
-
321
- var rows = _this.getRows();
322
- rows.map(function (row) {
323
- var autoAddNumberIdxEdit = row.autoAddNumber_idx_edit,
324
- autoAddNumberIdxView = row.autoAddNumber_idx_view;
325
-
326
- var updated = (0, _extends3['default'])({}, objFormData);
327
- if (touchAutoCompute && typeof touchAutoCompute === 'function') {
328
- // 数据变更-自动计算行数据
329
- // action 改变的动作类型,'CELL_UPDATE' 单元格更新,'CELL_BATCH_CHANGE' 单元格批量更新
330
- // cellKey 改变的单元格的key
331
- // fromRow 改变的单元格的原来行序号
332
- // fromRowData 改变的单元格的原来行数据
333
- // fromRowId 改变的单元格的原来行id(行唯一标识)
334
- // rowIds 所有被选中的行id
335
- // toRow 改变的单元格的新行序号
336
- // toRowId 改变的单元格的新行id
337
- // updated 改变的单元格的新值
338
- updated = touchAutoCompute({ cellKey: objColumn.key, fromRow: autoAddNumberIdxView, toRow: autoAddNumberIdxView, fromRowId: row[rowKey], toRowId: row[rowKey], rowIds: [row[rowKey]], updated: updated, action: 'CELL_BATCH_CHANGE', fromRowData: row });
339
- }
340
- dataList[autoAddNumberIdxEdit] = (0, _extends3['default'])({}, row, updated);
341
- return row;
342
- });
343
- if (onGridRowsUpdated && typeof onGridRowsUpdated === 'function') {
344
- // 数据变更-回调函数
345
- onGridRowsUpdated('confirmCallbackBatchEditBigTable', dataList);
346
- }
347
- };
348
-
349
- _this.getRows = function () {
350
- var _this$state2 = _this.state,
351
- filters = _this$state2.filters,
352
- sortColumn = _this$state2.sortColumn,
353
- sortDirection = _this$state2.sortDirection;
354
- var _this$props8 = _this.props,
355
- dataList = _this$props8.dataList,
356
- enableCellSelect = _this$props8.enableCellSelect,
357
- rowSelection = _this$props8.rowSelection;
358
-
359
- var rows = dataList;
360
- if (enableCellSelect || rowSelection) {
361
- rows = _this.touchLoopDataBefore();
362
- }
363
- return Selectors.getRows({ rows: rows, filters: filters, sortColumn: sortColumn, sortDirection: sortDirection });
364
- };
365
-
366
- _this.getSize = function () {
367
- return _this.getRows().length;
368
- };
369
-
370
- _this.rowGetter = function (rowIdx) {
371
- var rows = _this.getRows();
372
- // autoAddNumber_idx_view 自动添加序号 序号列使用
373
- return (0, _extends3['default'])({}, rows[rowIdx], { autoAddNumber_idx_view: rowIdx + 1 });
374
- };
375
-
376
- _this.touchLoopDataBefore = function () {
377
- var dataList = _this.props.dataList;
378
-
379
- dataList.map(function (row, index) {
380
- // autoAddNumber_idx_edit 自动添加序号 数据更新时使用确定当前更新的行
381
- dataList[index] = (0, _extends3['default'])({}, row, { autoAddNumber_idx_edit: index });
382
- return row;
383
- });
384
- return dataList;
385
- };
386
-
387
- _this.touchLoopData = function () {
388
- var rows = _this.getRows();
389
- var objTotal = {}; // 总计对象
390
- rows.map(function (row, index) {
391
- _this.columns.map(function (item, idx) {
392
- var name = item.name,
393
- key = item.key,
394
- totalFlag = item.totalFlag,
395
- numberFormat = item.numberFormat;
396
-
397
- if (totalFlag && typeof totalFlag === 'boolean') {
398
- if (index === 0) {
399
- objTotal[key] = {}; // 初始值
400
- objTotal[key].name = name; // 初始值
401
- objTotal[key].value = 0; // 初始值
402
- objTotal[key].numberFormat = numberFormat; // 格式化
403
- }
404
- var intData = Number(row[key]) || 0;
405
- objTotal[key].value = (objTotal[key].value || 0) + intData;
406
- }
407
- return idx;
408
- });
409
- return index;
410
- });
411
- return objTotal;
412
- };
413
-
414
- _this.getHearder = function () {
415
- var columns = _this.props.columns;
416
- var _this$props9 = _this.props,
417
- arrColumnsKey = _this$props9.arrColumnsKey,
418
- objSheet = _this$props9.objSheet,
419
- arrColInfo = _this$props9.arrColInfo;
420
-
421
-
422
- var arrColumnsKeyNew = ['id'];
423
- var objSheetNew = { id: 'id' };
424
- // 定义列信息,隐藏第一列(A列)
425
- var arrColInfoNew = [{ hidden: true }];
426
- columns.forEach(function (column) {
427
- var key = column.key,
428
- name = column.name,
429
- hiddeKeys = column.hiddeKeys;
430
-
431
- objSheetNew[key] = name;
432
- arrColumnsKeyNew.push(key);
433
- arrColInfoNew.push({});
434
- if (hiddeKeys) {
435
- var arrHiddenKeys = hiddeKeys.split(',');
436
- arrHiddenKeys.map(function (item) {
437
- if (item === key) {
438
- // 隐藏列与显示列相同,则不添加入表头
439
- } else {
440
- objSheetNew[item] = item;
441
- arrColumnsKeyNew.push(item);
442
- arrColInfoNew.push({
443
- hidden: true
444
- });
445
- }
446
- return item;
447
- });
448
- }
449
- });
450
-
451
- return { arrColumnsKey: arrColumnsKey || arrColumnsKeyNew, objSheet: objSheet || objSheetNew, arrColInfo: arrColInfo || arrColInfoNew };
452
- };
453
-
454
- _this.handleFilterChange = function (filter) {
455
- var newFilters = (0, _extends3['default'])({}, _this.state.filters);
456
- if (filter.filterTerm) {
457
- newFilters[filter.column.key] = filter;
458
- } else {
459
- delete newFilters[filter.column.key];
460
- }
461
- _this.setState({ filters: newFilters });
462
- };
463
-
464
- _this.onClearFilters = function () {
465
- // all filters removed
466
- _this.setState({ filters: {} });
467
- };
468
-
469
- _this.getToolbar = function () {
470
- var objToolbarProps = _this.props.objToolbarProps;
471
- var addRowFlag = objToolbarProps.addRowFlag,
472
- addRowButtonText = objToolbarProps.addRowButtonText,
473
- touchAddRow = objToolbarProps.touchAddRow,
474
- enableFilter = objToolbarProps.enableFilter,
475
- filterRowsButtonText = objToolbarProps.filterRowsButtonText,
476
- arrBtn = objToolbarProps.arrBtn,
477
- batchFlag = objToolbarProps.batchFlag,
478
- batchButtonText = objToolbarProps.batchButtonText,
479
- showModalBatchEditBigTable = objToolbarProps.showModalBatchEditBigTable,
480
- saveFlag = objToolbarProps.saveFlag,
481
- saveButtonText = objToolbarProps.saveButtonText,
482
- saveEditBigTable = objToolbarProps.saveEditBigTable,
483
- deleteFlag = objToolbarProps.deleteFlag,
484
- deleteButtonText = objToolbarProps.deleteButtonText,
485
- deleteRow = objToolbarProps.deleteRow,
486
- importFlag = objToolbarProps.importFlag,
487
- importButtonText = objToolbarProps.importButtonText,
488
- touchImport = objToolbarProps.touchImport,
489
- exportFlag = objToolbarProps.exportFlag,
490
- exportButtonText = objToolbarProps.exportButtonText,
491
- touchExport = objToolbarProps.touchExport;
492
-
493
- var toolbarProps = {};
494
- if (addRowFlag) {
495
- // 新增按钮
496
- toolbarProps.onAddRow = touchAddRow || _this.touchAddRow;
497
- toolbarProps.addRowButtonText = addRowButtonText || '新增';
498
- } else if (enableFilter) {
499
- // 筛选按钮
500
- toolbarProps.enableFilter = enableFilter;
501
- toolbarProps.filterRowsButtonText = filterRowsButtonText || '筛选';
502
- }
503
- var toolbar = _react2['default'].createElement(
504
- _reactDataGridAddons.Toolbar,
505
- (0, _extends3['default'])({}, toolbarProps, {
506
- // 行数
507
- numberOfRows: _this.getSize()
508
- }),
509
- arrBtn && arrBtn.map(function (btn) {
510
- return _react2['default'].createElement(
511
- 'button',
512
- { type: 'button', className: 'btn', onClick: btn.onClick },
513
- btn.text
514
- );
515
- }),
516
- batchFlag ? _react2['default'].createElement(
517
- 'button',
518
- { type: 'button', className: 'btn', onClick: showModalBatchEditBigTable || _this.showModalBatchEditBigTable },
519
- batchButtonText || '批量录入'
520
- ) : '',
521
- saveFlag ? _react2['default'].createElement(
522
- 'button',
523
- { type: 'button', className: 'btn', onClick: saveEditBigTable },
524
- saveButtonText || '保存'
525
- ) : '',
526
- deleteFlag ? _react2['default'].createElement(
527
- 'button',
528
- { type: 'button', className: 'btn', onClick: deleteRow || _this.deleteRow },
529
- deleteButtonText || '删除'
530
- ) : '',
531
- importFlag ? _react2['default'].createElement(
532
- 'button',
533
- { type: 'button', className: 'btn', onClick: touchImport || _this.touchImport },
534
- _react2['default'].createElement('input', { type: 'file', id: 'touchImportExcel', accept: '.xlsx, .xls', style: { display: 'none' } }),
535
- importButtonText || '导入'
536
- ) : '',
537
- exportFlag ? _react2['default'].createElement(
538
- 'button',
539
- { type: 'button', className: 'btn', onClick: touchExport || _this.touchExport },
540
- exportButtonText || '导出'
541
- ) : ''
542
- );
543
- return toolbar;
544
- };
545
-
546
- _this.onCheckCellIsEditable = function (obj) {
547
- var column = obj.column;
548
- // column:当前列的信息。
549
- // idx:当前单元格的索引。
550
- // row:当前行的数据。
551
- // rowIdx:当前行的索引
552
-
553
- var editable = column.editable,
554
- editor = column.editor,
555
- onCheckCellIsEditable = column.onCheckCellIsEditable;
556
-
557
- var editableFlag = false; // 单元格是否可编辑 true 允许编辑 false 禁止编辑
558
- if (editable || editor) {
559
- // 单元格可编辑
560
- editableFlag = true;
561
- if (onCheckCellIsEditable && typeof onCheckCellIsEditable === 'function') {
562
- editableFlag = onCheckCellIsEditable(obj); // 自定义单元格是否可编辑
563
- }
564
- } else {
565
- editableFlag = false;
566
- }
567
- return editableFlag;
568
- };
569
-
570
- _this.touchRowRenderer = function (obj) {
571
- var onCheckCellIsEditable = _this.props.onCheckCellIsEditable;
572
- var renderBaseRow = obj.renderBaseRow,
573
- columns = obj.columns,
574
- row = obj.row,
575
- idx = obj.idx;
576
-
577
- var onCheckCellIsEditableNew = onCheckCellIsEditable || _this.onCheckCellIsEditable;
578
- var columnsNew = [].concat(columns);
579
- columns.map(function (column, index) {
580
- if (onCheckCellIsEditableNew({ column: column, idx: idx, row: row })) {
581
- columnsNew[index] = (0, _extends3['default'])({}, column, { cellClass: (column.cellClass || '') + ' custom-edit-cell' });
582
- }
583
- return column;
584
- });
585
- return _react2['default'].createElement(
586
- 'span',
587
- null,
588
- renderBaseRow((0, _extends3['default'])({}, obj, {
589
- columns: [].concat(columnsNew)
590
- }))
591
- );
592
- };
593
-
594
- _this.getReactDataGridProps = function () {
595
- var arrValues = _this.state.arrValues;
596
- var _this$props10 = _this.props,
597
- enableCellSelect = _this$props10.enableCellSelect,
598
- rowKey = _this$props10.rowKey,
599
- objToolbarProps = _this$props10.objToolbarProps,
600
- rowSelection = _this$props10.rowSelection,
601
- onCheckCellIsEditable = _this$props10.onCheckCellIsEditable,
602
- touchRowRenderer = _this$props10.touchRowRenderer;
603
-
604
- var objReactDataGridProps = {}; // ReactDataGrid属性对象
605
- // toolbar属性
606
- if (objToolbarProps) {
607
- var enableFilter = objToolbarProps.enableFilter;
608
-
609
- objReactDataGridProps.toolbar = _this.getToolbar();
610
- if (enableFilter) {
611
- objReactDataGridProps.onAddFilter = _this.handleFilterChange;
612
- objReactDataGridProps.onClearFilters = _this.onClearFilters;
613
- }
614
- }
615
- // 单元格选择
616
- if (enableCellSelect && typeof enableCellSelect === 'boolean') {
617
- objReactDataGridProps.enableCellSelect = enableCellSelect;
618
- objReactDataGridProps.onGridRowsUpdated = _this.onGridRowsUpdated; // 表格编辑
619
- objReactDataGridProps.onCheckCellIsEditable = onCheckCellIsEditable || _this.onCheckCellIsEditable; // 单元格是否可编辑
620
- // if (onCheckCellIsEditable) {
621
- // }
622
- objReactDataGridProps.rowRenderer = touchRowRenderer || _this.touchRowRenderer; // 表格行渲染
623
- }
624
- // 表格行选择
625
- if (rowSelection && typeof rowSelection === 'boolean') {
626
- objReactDataGridProps.rowSelection = { // 表格选择
627
- showCheckbox: true,
628
- enableShiftSelect: true,
629
- onRowsSelected: _this.onRowsSelected,
630
- onRowsDeselected: _this.onRowsDeselected,
631
- selectBy: {
632
- keys: {
633
- rowKey: rowKey || 'id',
634
- values: arrValues
635
- }
636
- // indexes: this.state.arrValues,
637
- }
638
- };
639
- } else if (rowSelection) {
640
- objReactDataGridProps.rowSelection = rowSelection;
641
- }
642
-
643
- return objReactDataGridProps;
644
- };
645
-
646
- _this.createColumns = function () {
647
- var _this$props11 = _this.props,
648
- autoAddNumber = _this$props11.autoAddNumber,
649
- columns = _this$props11.columns;
650
- // 自动添加序号
651
-
652
- var columnsNew = [].concat(columns);
653
- if (autoAddNumber && typeof autoAddNumber === 'boolean') {
654
- var objColumns = columns && columns.length > 0 ? columns[0] : {};
655
- var _objColumns$frozen = objColumns.frozen,
656
- frozen = _objColumns$frozen === undefined ? false : _objColumns$frozen;
657
-
658
- columnsNew = [{ name: '序号', key: 'autoAddNumber_idx_view', resizable: true, width: 50, frozen: frozen }].concat(columnsNew);
659
- }
660
- _this.columns = columnsNew;
661
- return columnsNew;
662
- };
663
-
664
- _this.checkReactDataGridData = function () {
665
- var clearFiltersFlag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
666
-
667
- if (clearFiltersFlag) {
668
- _this.onClearFilters(); // 清空筛选条件
669
- }
670
- _this.checkData(); // 校验数据
671
- };
672
-
673
- _this.checkData = function () {
674
- var _this$props12 = _this.props,
675
- columns = _this$props12.columns,
676
- dataList = _this$props12.dataList;
677
-
678
- var strCheckFailRows = ''; // 校验失败的行号
679
- var arrRequiredMessage = []; // 必填提示信息
680
- dataList.forEach(function (row, index) {
681
- var boolcheckFailFlag = false; // 校验失败标识
682
- columns.forEach(function (item) {
683
- var key = item.key,
684
- required = item.required,
685
- strName = item.strName,
686
- name = item.name;
687
- // key 字段
688
- // required 必填
689
- // strName 字串名称
690
- // name 字段名称
691
-
692
- if (required && !row[key]) {
693
- boolcheckFailFlag = true;
694
- var strRequiredMessage = '\u8BF7\u5F55\u5165\u7B2C' + (index + 1) + '\u884C\u7684' + (strName || name) + ';';
695
- arrRequiredMessage.push(strRequiredMessage);
696
- }
697
- });
698
- if (boolcheckFailFlag) {
699
- if (strCheckFailRows) {
700
- strCheckFailRows += ',' + (index + 1);
701
- } else {
702
- strCheckFailRows = '' + (index + 1);
703
- }
704
- }
705
- });
706
- _modal2['default'].error({
707
- title: '校验失败',
708
- content: _react2['default'].createElement(
709
- 'div',
710
- null,
711
- arrRequiredMessage.map(function (item, index) {
712
- return index === 0 ? _react2['default'].createElement(
713
- 'span',
714
- null,
715
- item
716
- ) : _react2['default'].createElement(
717
- 'span',
718
- null,
719
- _react2['default'].createElement('br', null),
720
- item
721
- );
722
- })
723
- )
724
- });
725
- console.error(arrRequiredMessage, strCheckFailRows);
726
- return { arrRequiredMessage: arrRequiredMessage, strCheckFailRows: strCheckFailRows };
727
- };
728
-
729
- _this.touchFormatNum = function (num) {
730
- return !isNaN(num) && isFinite(num) ? (0, _numeral2['default'])(num).format('0,0.00') : num || '';
731
- };
732
-
733
- var bidPureComponent = _this.props.bidPureComponent;
734
-
735
- if (bidPureComponent && typeof bidPureComponent === 'function') {
736
- bidPureComponent(_this);
737
- }
738
- _this.state = {
739
- // 表格选择
740
- arrValues: [], // 表格选择行索引
741
- arrValuesInfo: [], // 表格选择行数据
742
- // 查询条件
743
- filters: {},
744
- // 排序--sort
745
- sortColumn: null, // 排序列
746
- sortDirection: null, // 排序方向
747
- // 批量录入
748
- visible: false // 隐藏批量录入Modal
749
- };
750
- return _this;
49
+ return (0, _possibleConstructorReturn3['default'])(this, _Component.apply(this, arguments));
751
50
  }
752
51
 
753
- Easy3wEditBigTable.prototype.componentDidMount = function componentDidMount() {};
754
-
755
- Easy3wEditBigTable.prototype.componentWillUnmount = function componentWillUnmount() {};
756
- // 绑定组件
757
-
758
- // 获取列表
759
-
760
- // 表格编辑
761
-
762
- // 表头排序
763
-
764
- // #region 表格选择
765
- // 表格选择---选择
766
-
767
- // 表格选择---取消选择
768
-
769
- // 改变选择状态
770
-
771
- // #endregion 表格选择
772
- // #region 右上角按钮处理--toolbar
773
- // 新增
774
-
775
- // 复制
776
-
777
- // 删除
778
-
779
- // 导入
780
-
781
- // 导出--数据
782
-
783
- // 批量录入--显示批量录入Modal
784
-
785
- // 批量录入--隐藏批量录入Modal
786
-
787
- // 批量录入--确认回调
788
-
789
- // #endregion 右上角按钮处理--toolbar
790
- // #region 数据处理
791
-
792
- // 数据长度
793
-
794
- // 表格数据函数
795
-
796
- // 数据循环--处理前的数据
797
-
798
- // 数据循环--处理后的数据
799
-
800
- // 导入导出表头
801
-
802
- // #endregion 数据处理
803
- // #region 查询条件
804
- // 筛选条件变更
805
-
806
- // 清空筛选条件
807
-
808
- // #endregion 查询条件
809
-
810
- // #region toolbar处理
811
-
812
- // #endregion toolbar处理
813
- // #region 设置ReactDataGrid属性
814
- // 在单元格设置为活动状态之前调用,返回一个布尔值以确定单元格是否可编辑
815
-
816
- // 表格行渲染
817
-
818
- // 创建columns
819
-
820
- // #endregion 设置ReactDataGrid属性
821
- // #region 校验数据
822
- // 校验处理
823
-
824
- // 校验数据
825
-
826
- // #endregion 校验数据
827
- // 转换数字
828
-
829
-
52
+ // static defaultProps = {
53
+ // rowKey: 'autoAddNumber_idx_edit',
54
+ // };
55
+ // constructor(props) {
56
+ // super(props);
57
+ // const { bidPureComponent } = this.props;
58
+ // if (bidPureComponent && typeof bidPureComponent === 'function') {
59
+ // bidPureComponent(this);
60
+ // }
61
+ // this.state = {
62
+ // // 表格选择
63
+ // arrValues: [], // 表格选择行索引
64
+ // arrValuesInfo: [], // 表格选择行数据
65
+ // // 查询条件
66
+ // filters: {},
67
+ // // 排序--sort
68
+ // sortColumn: null, // 排序列
69
+ // sortDirection: null, // 排序方向
70
+ // // 批量录入
71
+ // visible: false, // 隐藏批量录入Modal
72
+ // };
73
+ // }
74
+ // componentDidMount() {
75
+ // }
76
+ // componentWillUnmount() {
77
+ // }
78
+ // // 绑定组件
79
+ // bidPureComponent = (pureComponentName, that) => {
80
+ // this[pureComponentName] = that;
81
+ // }
82
+ // // 获取列表
83
+ // ReactDataGridRef = (ref) => {
84
+ // if (ref) {
85
+ // this.ReactDataGridRef = ref;
86
+ // }
87
+ // }
88
+ // // 表格编辑
89
+ // onGridRowsUpdated = (objUpdated) => {
90
+ // const { fromRowData } = objUpdated;
91
+ // let { updated } = objUpdated;
92
+ // const { touchAutoCompute, onGridRowsUpdated, dataList } = this.props;
93
+ // if (touchAutoCompute && typeof touchAutoCompute === 'function') { // 数据变更-自动计算行数据
94
+ // updated = touchAutoCompute(objUpdated);
95
+ // }
96
+ // const { autoAddNumber_idx_edit: autoAddNumberIdxEdit } = fromRowData;
97
+ // dataList[autoAddNumberIdxEdit] = { ...fromRowData, ...updated };
98
+ // if (onGridRowsUpdated && typeof onGridRowsUpdated === 'function') { // 数据变更-回调函数
99
+ // onGridRowsUpdated('onGridRowsUpdated', dataList);
100
+ // }
101
+ // }
102
+ // // 表头排序
103
+ // onGridSort = (sortColumn, sortDirection) => {
104
+ // this.setState({ sortColumn, sortDirection });
105
+ // };
106
+ // // #region 表格选择
107
+ // // 表格选择---选择
108
+ // onRowsSelected = (rows) => {
109
+ // let { arrValues, arrValuesInfo } = this.state;
110
+ // const { rowKey, onRowsSelectedCb } = this.props;
111
+ // const arrValuesNew = []; // 表格选择行索引
112
+ // const arrValuesInfoNew = []; // 表格选择行数据
113
+ // rows.map((r) => {
114
+ // arrValuesNew.push(r.row[rowKey]);
115
+ // arrValuesInfoNew.push(r.row);
116
+ // return r;
117
+ // });
118
+ // arrValues = arrValues.concat(arrValuesNew); // 表格选择行索引
119
+ // arrValuesInfo = arrValuesInfo.concat(arrValuesInfoNew); // 表格选择行数据
120
+ // if (onRowsSelectedCb && typeof onRowsSelectedCb === 'function') { // 表格选择回调函数
121
+ // onRowsSelectedCb('onRowsSelected', arrValues, arrValuesInfo, arrValuesNew, arrValuesInfoNew);
122
+ // }
123
+ // this.onSelectedRowsChange(arrValues, arrValuesInfo);
124
+ // }
125
+ // // 表格选择---取消选择
126
+ // onRowsDeselected = (rows) => {
127
+ // const { arrValuesInfo } = this.state;
128
+ // const { rowKey, onRowsSelectedCb } = this.props;
129
+ // const arrValuesNew = []; // 表格选择行索引
130
+ // const arrValuesInfoNew = []; // 表格选择行数据
131
+ // const arrSelected = []; // 已选择的行索引
132
+ // const arrSelectedInfo = []; // 已选择的行数据
133
+ // arrValuesInfo.filter((item) => {
134
+ // let flag = true;
135
+ // rows.map((r) => {
136
+ // const { row } = r;
137
+ // if (item[rowKey] === row[rowKey]) {
138
+ // // 删除已取消选择的行
139
+ // flag = false;
140
+ // arrSelected.push(item[rowKey]);
141
+ // arrSelectedInfo.push(item);
142
+ // }
143
+ // return r;
144
+ // });
145
+ // if (flag) {
146
+ // arrValuesNew.push(item[rowKey]);
147
+ // arrValuesInfoNew.push(item);
148
+ // }
149
+ // return flag;
150
+ // });
151
+ // if (onRowsSelectedCb && typeof onRowsSelectedCb === 'function') { // 表格选择回调函数
152
+ // onRowsSelectedCb('onRowsDeselected', arrValuesNew, arrValuesInfoNew, arrSelected, arrSelectedInfo);
153
+ // }
154
+ // this.onSelectedRowsChange(arrValuesNew, arrValuesInfoNew);
155
+ // }
156
+ // // 改变选择状态
157
+ // onSelectedRowsChange = (arrValues, arrValuesInfo) => {
158
+ // this.setState({ arrValues, arrValuesInfo });
159
+ // }
160
+ // // #endregion 表格选择
161
+ // // #region 右上角按钮处理--toolbar
162
+ // // 新增
163
+ // touchAddRow = () => {
164
+ // const { onGridRowsUpdated, dataList } = this.props;
165
+ // const dataListNew = [...dataList, {}];
166
+ // if (onGridRowsUpdated && typeof onGridRowsUpdated === 'function') { // 数据变更-回调函数
167
+ // onGridRowsUpdated('touchAddRow', dataListNew);
168
+ // }
169
+ // }
170
+ // // 复制
171
+ // touchCopyRow = () => {
172
+ // const { onGridRowsUpdated, dataList } = this.props;
173
+ // const { arrValues } = this.state;
174
+ // if (arrValues.length) {
175
+ // const newArr = []; // 复制的新数组
176
+ // arrValues.forEach((key) => {
177
+ // const newRow = { ...dataList[key] };
178
+ // newArr.push(newRow);
179
+ // return key;
180
+ // });
181
+ // const dataListNew = [...dataList, ...newArr];
182
+ // if (onGridRowsUpdated && typeof onGridRowsUpdated === 'function') { // 数据变更-回调函数
183
+ // onGridRowsUpdated('touchCopyRow', dataListNew);
184
+ // }
185
+ // } else {
186
+ // Modal.error({
187
+ // title: '错误',
188
+ // content: '请选择要复制的行',
189
+ // });
190
+ // }
191
+ // }
192
+ // // 删除
193
+ // deleteRow = () => {
194
+ // const { dataList, onGridRowsUpdated, objToolbarProps, rowKey } = this.props;
195
+ // const { deleteRowInterface } = objToolbarProps;
196
+ // const { arrValues } = this.state;
197
+ // if (arrValues.length) {
198
+ // // const dataListNew = []; // 删除选择行后的新数组
199
+ // const dataListDel = []; // 要删除的行数组
200
+ // const dataListNew = dataList.filter((row) => {
201
+ // let flag = true;
202
+ // arrValues.map((key) => {
203
+ // if (key === row[rowKey]) {
204
+ // dataListDel.push(row);
205
+ // // 删除选择的行
206
+ // flag = false;
207
+ // }
208
+ // return key;
209
+ // });
210
+ // return flag;
211
+ // });
212
+ // if (deleteRowInterface && typeof deleteRowInterface === 'function') { // 删除行接口
213
+ // deleteRowInterface(dataListDel, arrValues);
214
+ // }
215
+ // if (onGridRowsUpdated && typeof onGridRowsUpdated === 'function') { // 数据变更-回调函数
216
+ // onGridRowsUpdated('deleteRow', dataListNew);
217
+ // }
218
+ // this.onSelectedRowsChange([], []); // 选择行清空
219
+ // } else {
220
+ // Modal.error({
221
+ // title: '错误',
222
+ // content: '请选择要删除的行',
223
+ // });
224
+ // }
225
+ // }
226
+ // // 导入
227
+ // touchImport = () => {
228
+ // const input = document.getElementById('touchImportExcel');
229
+ // // input.type = 'file';
230
+ // input.onchange = (e) => {
231
+ // const file = e.target.files[0];
232
+ // const reader = new FileReader();
233
+ // reader.onload = (event) => {
234
+ // const { onGridRowsUpdated } = this.props;
235
+ // const { arrColumnsKey } = this.getHearder();
236
+ // const data = event.target.result;
237
+ // const workbook = XLSX.read(data, { type: 'binary' });
238
+ // const firstSheetName = workbook.SheetNames[0];
239
+ // const worksheet = workbook.Sheets[firstSheetName];
240
+ // const rows = XLSX.utils.sheet_to_json(worksheet, { header: arrColumnsKey });
241
+ // rows.shift();
242
+ // if (onGridRowsUpdated && typeof onGridRowsUpdated === 'function') { // 数据变更-回调函数
243
+ // onGridRowsUpdated('touchImport', rows);
244
+ // }
245
+ // };
246
+ // reader.readAsBinaryString(file);
247
+ // };
248
+ // input.click();
249
+ // }
250
+ // // 导出--数据
251
+ // touchExport = () => {
252
+ // const { objSheet, arrColInfo } = this.getHearder();
253
+ // const filterDataList = this.getRows();
254
+ // // 计算 filterDataList 中所有对象字段最多的长度
255
+ // let maxFieldsLength = 0;
256
+ // filterDataList.forEach((item) => {
257
+ // const fieldsLength = Object.keys(item).length;
258
+ // if (fieldsLength > maxFieldsLength) {
259
+ // maxFieldsLength = fieldsLength;
260
+ // }
261
+ // return item;
262
+ // });
263
+ // if (maxFieldsLength > arrColInfo.length) {
264
+ // for (let i = arrColInfo.length; i < maxFieldsLength;) {
265
+ // arrColInfo.push({ hidden: true });
266
+ // i += 1;
267
+ // }
268
+ // }
269
+ // // 创建工作簿和工作表
270
+ // const worksheet = XLSX.utils.json_to_sheet([objSheet, ...filterDataList], { skipHeader: true });
271
+ // worksheet['!cols'] = arrColInfo;
272
+ // const workbook = XLSX.utils.book_new();
273
+ // XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
274
+
275
+ // // 生成Excel文件并触发下载
276
+ // XLSX.writeFile(workbook, 'exported_data.xlsx');
277
+ // }
278
+ // // 批量录入--显示批量录入Modal
279
+ // showModalBatchEditBigTable = () => {
280
+ // this.setState({
281
+ // visible: true, // 显示批量录入Modal
282
+ // });
283
+ // }
284
+ // // 批量录入--隐藏批量录入Modal
285
+ // hideModalBatchEditBigTable = () => {
286
+ // this.setState({
287
+ // visible: false, // 隐藏批量录入Modal
288
+ // });
289
+ // }
290
+ // // 批量录入--确认回调
291
+ // confirmCallbackBatchEditBigTable = (objFormData, objColumn) => {
292
+ // const { touchAutoCompute, onGridRowsUpdated, dataList, rowKey } = this.props;
293
+ // // if (touchAutoCompute && typeof touchAutoCompute === 'function') { // 数据变更-自动计算行数据
294
+ // // updated = touchAutoCompute(objUpdated);
295
+ // // }
296
+ // const rows = this.getRows();
297
+ // rows.map((row) => {
298
+ // const { autoAddNumber_idx_edit: autoAddNumberIdxEdit, autoAddNumber_idx_view: autoAddNumberIdxView } = row;
299
+ // let updated = { ...objFormData };
300
+ // if (touchAutoCompute && typeof touchAutoCompute === 'function') { // 数据变更-自动计算行数据
301
+ // // action 改变的动作类型,'CELL_UPDATE' 单元格更新,'CELL_BATCH_CHANGE' 单元格批量更新
302
+ // // cellKey 改变的单元格的key
303
+ // // fromRow 改变的单元格的原来行序号
304
+ // // fromRowData 改变的单元格的原来行数据
305
+ // // fromRowId 改变的单元格的原来行id(行唯一标识)
306
+ // // rowIds 所有被选中的行id
307
+ // // toRow 改变的单元格的新行序号
308
+ // // toRowId 改变的单元格的新行id
309
+ // // updated 改变的单元格的新值
310
+ // updated = touchAutoCompute({ cellKey: objColumn.key, fromRow: autoAddNumberIdxView, toRow: autoAddNumberIdxView, fromRowId: row[rowKey], toRowId: row[rowKey], rowIds: [row[rowKey]], updated, action: 'CELL_BATCH_CHANGE', fromRowData: row });
311
+ // }
312
+ // dataList[autoAddNumberIdxEdit] = { ...row, ...updated };
313
+ // return row;
314
+ // });
315
+ // if (onGridRowsUpdated && typeof onGridRowsUpdated === 'function') { // 数据变更-回调函数
316
+ // onGridRowsUpdated('confirmCallbackBatchEditBigTable', dataList);
317
+ // }
318
+ // }
319
+ // // #endregion 右上角按钮处理--toolbar
320
+ // // #region 数据处理
321
+ // getRows = () => {
322
+ // const { filters, sortColumn, sortDirection } = this.state;
323
+ // const { dataList, enableCellSelect, rowSelection } = this.props;
324
+ // let rows = dataList;
325
+ // if (enableCellSelect || rowSelection) {
326
+ // rows = this.touchLoopDataBefore();
327
+ // }
328
+ // return Selectors.getRows({ rows, filters, sortColumn, sortDirection });
329
+ // }
330
+ // // 数据长度
331
+ // getSize = () => {
332
+ // return this.getRows().length;
333
+ // }
334
+ // // 表格数据函数
335
+ // rowGetter = (rowIdx) => {
336
+ // const rows = this.getRows();
337
+ // // autoAddNumber_idx_view 自动添加序号 序号列使用
338
+ // return { ...rows[rowIdx], autoAddNumber_idx_view: rowIdx + 1 };
339
+ // }
340
+ // // 数据循环--处理前的数据
341
+ // touchLoopDataBefore = () => {
342
+ // const { dataList } = this.props;
343
+ // dataList.map((row, index) => {
344
+ // // autoAddNumber_idx_edit 自动添加序号 数据更新时使用确定当前更新的行
345
+ // dataList[index] = { ...row, autoAddNumber_idx_edit: index };
346
+ // return row;
347
+ // });
348
+ // return dataList;
349
+ // }
350
+ // // 数据循环--处理后的数据
351
+ // touchLoopData = () => {
352
+ // const rows = this.getRows();
353
+ // const objTotal = {}; // 总计对象
354
+ // rows.map((row, index) => {
355
+ // this.columns.map((item, idx) => {
356
+ // const { name, key, totalFlag, numberFormat } = item;
357
+ // if (totalFlag && typeof totalFlag === 'boolean') {
358
+ // if (index === 0) {
359
+ // objTotal[key] = {}; // 初始值
360
+ // objTotal[key].name = name; // 初始值
361
+ // objTotal[key].value = 0; // 初始值
362
+ // objTotal[key].numberFormat = numberFormat; // 格式化
363
+ // }
364
+ // const intData = Number(row[key]) || 0;
365
+ // objTotal[key].value = (objTotal[key].value || 0) + intData;
366
+ // }
367
+ // return idx;
368
+ // });
369
+ // return index;
370
+ // });
371
+ // return objTotal;
372
+ // }
373
+ // // 导入导出表头
374
+ // getHearder = () => {
375
+ // const { columns } = this.props;
376
+ // const { arrColumnsKey, objSheet, arrColInfo } = this.props;
377
+
378
+ // const arrColumnsKeyNew = ['id'];
379
+ // const objSheetNew = { id: 'id' };
380
+ // // 定义列信息,隐藏第一列(A列)
381
+ // const arrColInfoNew = [
382
+ // { hidden: true }, // A列
383
+ // ];
384
+ // columns.forEach((column) => {
385
+ // const { key, name, hiddeKeys } = column;
386
+ // objSheetNew[key] = name;
387
+ // arrColumnsKeyNew.push(key);
388
+ // arrColInfoNew.push({});
389
+ // if (hiddeKeys) {
390
+ // const arrHiddenKeys = hiddeKeys.split(',');
391
+ // arrHiddenKeys.map((item) => {
392
+ // if (item === key) {
393
+ // // 隐藏列与显示列相同,则不添加入表头
394
+ // } else {
395
+ // objSheetNew[item] = item;
396
+ // arrColumnsKeyNew.push(item);
397
+ // arrColInfoNew.push({
398
+ // hidden: true,
399
+ // });
400
+ // }
401
+ // return item;
402
+ // });
403
+ // }
404
+ // });
405
+
406
+ // return { arrColumnsKey: arrColumnsKey || arrColumnsKeyNew, objSheet: objSheet || objSheetNew, arrColInfo: arrColInfo || arrColInfoNew };
407
+ // }
408
+ // // #endregion 数据处理
409
+ // // #region 查询条件
410
+ // // 筛选条件变更
411
+ // handleFilterChange = (filter) => {
412
+ // const newFilters = Object.assign({}, this.state.filters);
413
+ // if (filter.filterTerm) {
414
+ // newFilters[filter.column.key] = filter;
415
+ // } else {
416
+ // delete newFilters[filter.column.key];
417
+ // }
418
+ // this.setState({ filters: newFilters });
419
+ // }
420
+ // // 清空筛选条件
421
+ // onClearFilters = () => {
422
+ // // all filters removed
423
+ // this.setState({ filters: {} });
424
+ // }
425
+ // // #endregion 查询条件
426
+
427
+ // // #region toolbar处理
428
+ // getToolbar = () => {
429
+ // const { objToolbarProps } = this.props;
430
+ // const {
431
+ // // 新增
432
+ // addRowFlag, // 新增按钮标识 非必须
433
+ // addRowButtonText, // 新增按钮文字 非必须
434
+ // touchAddRow, // 新增按钮点击事件 非必须
435
+ // // 筛选
436
+ // enableFilter, // 筛选按钮标识 非必须
437
+ // filterRowsButtonText, // 筛选按钮文字 非必须
438
+ // // 自定义按钮
439
+ // arrBtn, // 自定义按钮数组 非必须
440
+ // // 按钮标识 保存 删除 导入 导出
441
+ // batchFlag, // 批量录入按钮标识 非必须
442
+ // batchButtonText, // 批量录入按钮文字 非必须
443
+ // showModalBatchEditBigTable, // 批量录入按钮点击事件 非必须
444
+ // saveFlag, // 保存按钮标识 非必须
445
+ // saveButtonText, // 保存按钮文字 非必须
446
+ // saveEditBigTable, // 保存按钮点击事件 必须
447
+ // deleteFlag, // 删除按钮标识 非必须
448
+ // deleteButtonText, // 删除按钮文字 非必须
449
+ // deleteRow, // 删除按钮点击事件 非必须
450
+ // importFlag, // 导入按钮标识 非必须
451
+ // importButtonText, // 导入按钮文字 非必须
452
+ // touchImport, // 导入按钮点击事件 非必须
453
+ // exportFlag, // 导出按钮标识 非必须
454
+ // exportButtonText, // 导出按钮文字 非必须
455
+ // touchExport, // 导出按钮点击事件 非必须
456
+ // } = objToolbarProps;
457
+ // const toolbarProps = {};
458
+ // if (addRowFlag) { // 新增按钮
459
+ // toolbarProps.onAddRow = touchAddRow || this.touchAddRow;
460
+ // toolbarProps.addRowButtonText = addRowButtonText || '新增';
461
+ // } else if (enableFilter) { // 筛选按钮
462
+ // toolbarProps.enableFilter = enableFilter;
463
+ // toolbarProps.filterRowsButtonText = filterRowsButtonText || '筛选';
464
+ // }
465
+ // const toolbar = (
466
+ // <Toolbar
467
+ // {...toolbarProps}
468
+ // // 行数
469
+ // numberOfRows={this.getSize()}
470
+ // >
471
+ // {/* 自定义按钮 */}
472
+ // {
473
+ // arrBtn && arrBtn.map(btn => (
474
+ // <button type="button" className="btn" onClick={btn.onClick}>
475
+ // {btn.text}
476
+ // </button>
477
+ // ))
478
+ // }
479
+ // {/* 批量录入 删除 保存 导入 导出 */}
480
+ // {
481
+ // batchFlag ? (
482
+ // <button type="button" className="btn" onClick={showModalBatchEditBigTable || this.showModalBatchEditBigTable}>
483
+ // {batchButtonText || '批量录入'}
484
+ // </button>
485
+ // ) : ''
486
+ // }
487
+ // {
488
+ // saveFlag ? (
489
+ // <button type="button" className="btn" onClick={saveEditBigTable}>
490
+ // {saveButtonText || '保存'}
491
+ // </button>
492
+ // ) : ''
493
+ // }
494
+ // {
495
+ // deleteFlag ? (
496
+ // <button type="button" className="btn" onClick={deleteRow || this.deleteRow}>
497
+ // {deleteButtonText || '删除'}
498
+ // </button>
499
+ // ) : ''
500
+ // }
501
+ // {
502
+ // importFlag ? (
503
+ // <button type="button" className="btn" onClick={touchImport || this.touchImport}>
504
+ // <input type="file" id="touchImportExcel" accept=".xlsx, .xls" style={{ display: 'none' }} />
505
+ // {importButtonText || '导入'}
506
+ // </button>
507
+ // ) : ''
508
+ // }
509
+ // {
510
+ // exportFlag ? (
511
+ // <button type="button" className="btn" onClick={touchExport || this.touchExport}>
512
+ // {exportButtonText || '导出'}
513
+ // </button>
514
+ // ) : ''
515
+ // }
516
+ // </Toolbar>
517
+ // );
518
+ // return toolbar;
519
+ // }
520
+ // // #endregion toolbar处理
521
+ // // #region 设置ReactDataGrid属性
522
+ // // 在单元格设置为活动状态之前调用,返回一个布尔值以确定单元格是否可编辑
523
+ // onCheckCellIsEditable = (obj) => {
524
+ // const { column } = obj;
525
+ // // column:当前列的信息。
526
+ // // idx:当前单元格的索引。
527
+ // // row:当前行的数据。
528
+ // // rowIdx:当前行的索引
529
+ // const { editable, editor, onCheckCellIsEditable } = column;
530
+ // let editableFlag = false; // 单元格是否可编辑 true 允许编辑 false 禁止编辑
531
+ // if (editable || editor) { // 单元格可编辑
532
+ // editableFlag = true;
533
+ // if (onCheckCellIsEditable && typeof onCheckCellIsEditable === 'function') {
534
+ // editableFlag = onCheckCellIsEditable(obj); // 自定义单元格是否可编辑
535
+ // }
536
+ // } else {
537
+ // editableFlag = false;
538
+ // }
539
+ // return editableFlag;
540
+ // }
541
+ // // 表格行渲染
542
+ // touchRowRenderer = (obj) => {
543
+ // const { onCheckCellIsEditable } = this.props;
544
+ // const { renderBaseRow, columns, row, idx } = obj;
545
+ // const onCheckCellIsEditableNew = onCheckCellIsEditable || this.onCheckCellIsEditable;
546
+ // const columnsNew = [...columns];
547
+ // columns.map((column, index) => {
548
+ // if (onCheckCellIsEditableNew({ column, idx, row })) {
549
+ // columnsNew[index] = { ...column, cellClass: `${column.cellClass || ''} custom-edit-cell` };
550
+ // }
551
+ // return column;
552
+ // });
553
+ // return (
554
+ // <span>
555
+ // {renderBaseRow({
556
+ // ...obj,
557
+ // columns: [...columnsNew],
558
+ // })}
559
+ // </span>
560
+ // );
561
+ // }
562
+ // getReactDataGridProps = () => {
563
+ // const { arrValues } = this.state;
564
+ // const { enableCellSelect, rowKey, objToolbarProps, rowSelection, onCheckCellIsEditable, touchRowRenderer } = this.props;
565
+ // const objReactDataGridProps = { }; // ReactDataGrid属性对象
566
+ // // toolbar属性
567
+ // if (objToolbarProps) {
568
+ // const { enableFilter } = objToolbarProps;
569
+ // objReactDataGridProps.toolbar = this.getToolbar();
570
+ // if (enableFilter) {
571
+ // objReactDataGridProps.onAddFilter = this.handleFilterChange;
572
+ // objReactDataGridProps.onClearFilters = this.onClearFilters;
573
+ // }
574
+ // }
575
+ // // 单元格选择
576
+ // if (enableCellSelect && typeof enableCellSelect === 'boolean') {
577
+ // objReactDataGridProps.enableCellSelect = enableCellSelect;
578
+ // objReactDataGridProps.onGridRowsUpdated = this.onGridRowsUpdated; // 表格编辑
579
+ // objReactDataGridProps.onCheckCellIsEditable = onCheckCellIsEditable || this.onCheckCellIsEditable; // 单元格是否可编辑
580
+ // // if (onCheckCellIsEditable) {
581
+ // // }
582
+ // objReactDataGridProps.rowRenderer = touchRowRenderer || this.touchRowRenderer; // 表格行渲染
583
+ // }
584
+ // // 表格行选择
585
+ // if (rowSelection && typeof rowSelection === 'boolean') {
586
+ // objReactDataGridProps.rowSelection = { // 表格选择
587
+ // showCheckbox: true,
588
+ // enableShiftSelect: true,
589
+ // onRowsSelected: this.onRowsSelected,
590
+ // onRowsDeselected: this.onRowsDeselected,
591
+ // selectBy: {
592
+ // keys: {
593
+ // rowKey: rowKey || 'id',
594
+ // values: arrValues,
595
+ // },
596
+ // // indexes: this.state.arrValues,
597
+ // },
598
+ // };
599
+ // } else if (rowSelection) {
600
+ // objReactDataGridProps.rowSelection = rowSelection;
601
+ // }
602
+
603
+ // return objReactDataGridProps;
604
+ // }
605
+ // // 创建columns
606
+ // createColumns = () => {
607
+ // const { autoAddNumber, columns } = this.props;
608
+ // // 自动添加序号
609
+ // let columnsNew = [...columns];
610
+ // if (autoAddNumber && typeof autoAddNumber === 'boolean') {
611
+ // const objColumns = columns && columns.length > 0 ? columns[0] : {};
612
+ // const { frozen = false } = objColumns;
613
+ // columnsNew = [
614
+ // { name: '序号', key: 'autoAddNumber_idx_view', resizable: true, width: 50, frozen },
615
+ // ...columnsNew,
616
+ // ];
617
+ // }
618
+ // this.columns = columnsNew;
619
+ // return columnsNew;
620
+ // }
621
+ // // #endregion 设置ReactDataGrid属性
622
+ // // #region 校验数据
623
+ // // 校验处理
624
+ // checkReactDataGridData = (clearFiltersFlag = true) => {
625
+ // if (clearFiltersFlag) {
626
+ // this.onClearFilters(); // 清空筛选条件
627
+ // }
628
+ // this.checkData(); // 校验数据
629
+ // }
630
+ // // 校验数据
631
+ // checkData = () => {
632
+ // const { columns, dataList } = this.props;
633
+ // let strCheckFailRows = ''; // 校验失败的行号
634
+ // const arrRequiredMessage = []; // 必填提示信息
635
+ // dataList.forEach((row, index) => {
636
+ // let boolcheckFailFlag = false; // 校验失败标识
637
+ // columns.forEach((item) => {
638
+ // const { key, required, strName, name } = item;
639
+ // // key 字段
640
+ // // required 必填
641
+ // // strName 字串名称
642
+ // // name 字段名称
643
+ // if (required && !row[key]) {
644
+ // boolcheckFailFlag = true;
645
+ // const strRequiredMessage = `请录入第${index + 1}行的${strName || name};`;
646
+ // arrRequiredMessage.push(strRequiredMessage);
647
+ // }
648
+ // });
649
+ // if (boolcheckFailFlag) {
650
+ // if (strCheckFailRows) {
651
+ // strCheckFailRows += `,${index + 1}`;
652
+ // } else {
653
+ // strCheckFailRows = `${index + 1}`;
654
+ // }
655
+ // }
656
+ // });
657
+ // Modal.error({
658
+ // title: '校验失败',
659
+ // content: (
660
+ // <div>
661
+ // {arrRequiredMessage.map((item, index) => (index === 0 ? <span>{item}</span> : <span><br />{item}</span>))}
662
+ // </div>
663
+ // ),
664
+ // });
665
+ // console.error(arrRequiredMessage, strCheckFailRows);
666
+ // return { arrRequiredMessage, strCheckFailRows };
667
+ // }
668
+ // // #endregion 校验数据
669
+ // // 转换数字
670
+ // touchFormatNum = (num) => {
671
+ // return !isNaN(num) && isFinite(num) ? numeral(num).format('0,0.00') : num || '';
672
+ // }
830
673
  Easy3wEditBigTable.prototype.render = function render() {
831
- var _this2 = this;
832
-
833
- var visible = this.state.visible;
834
- var _props = this.props,
835
- totalFlag = _props.totalFlag,
836
- objOtherProps = _props.objOtherProps,
837
- objToolbarProps = _props.objToolbarProps,
838
- strReactDataGridStyle = _props.strReactDataGridStyle,
839
- strAddReactDataGridStyle = _props.strAddReactDataGridStyle;
840
-
841
- var objReactDataGridProps = this.getReactDataGridProps();
842
- var columns = this.createColumns(); // 表头
843
- var objTotal = totalFlag ? this.touchLoopData() : {}; // 循环数据获取
674
+ // const { visible } = this.state;
675
+ // const { totalFlag, objOtherProps, objToolbarProps, strReactDataGridStyle, strAddReactDataGridStyle } = this.props;
676
+ // const objReactDataGridProps = this.getReactDataGridProps();
677
+ // const columns = this.createColumns(); // 表头
678
+ // const objTotal = totalFlag ? this.touchLoopData() : {}; // 循环数据获取
844
679
  return _react2['default'].createElement(
845
680
  'div',
846
681
  { style: { backgroundColor: '#fff' } },
847
- _react2['default'].createElement(
848
- 'style',
849
- null,
850
- strReactDataGridStyle || (strAddReactDataGridStyle || '') + '\n .custom-edit-cell { \n background-color: #f6ffed;\n }\n '
851
- ),
852
- _react2['default'].createElement(_reactDataGrid2['default'], (0, _extends3['default'])({}, this.props, {
853
- ref: this.ReactDataGridRef,
854
- columns: columns // 表头
855
- // rows={rows}
856
- , rowGetter: this.rowGetter // 获取行数据
857
- , rowsCount: this.getSize() // 行数
858
- , onGridSort: this.onGridSort
859
- }, objReactDataGridProps, objOtherProps)),
860
- totalFlag ? _react2['default'].createElement(
861
- 'div',
862
- null,
863
- objTotal && Object.keys(objTotal).map(function (key, index) {
864
- return _react2['default'].createElement(
865
- 'span',
866
- { key: key },
867
- index === 0 ? '' : ';',
868
- _react2['default'].createElement(
869
- 'span',
870
- null,
871
- objTotal[key].name,
872
- '\uFF1A'
873
- ),
874
- _react2['default'].createElement(
875
- 'span',
876
- null,
877
- objTotal[key].numberFormat ? _this2.touchFormatNum(objTotal[key].value) : objTotal[key].value
878
- )
879
- );
880
- })
881
- ) : ''
682
+ 'Easy3wEditBigTable',
683
+ _react2['default'].createElement('br', null),
684
+ 'Easy3wEditBigTable',
685
+ _react2['default'].createElement('br', null),
686
+ 'Easy3wEditBigTable',
687
+ _react2['default'].createElement('br', null),
688
+ 'Easy3wEditBigTable',
689
+ _react2['default'].createElement('br', null),
690
+ 'Easy3wEditBigTable',
691
+ _react2['default'].createElement('br', null),
692
+ 'Easy3wEditBigTable',
693
+ _react2['default'].createElement('br', null),
694
+ 'Easy3wEditBigTable',
695
+ _react2['default'].createElement('br', null),
696
+ 'Easy3wEditBigTable',
697
+ _react2['default'].createElement('br', null),
698
+ 'Easy3wEditBigTable',
699
+ _react2['default'].createElement('br', null),
700
+ 'Easy3wEditBigTable',
701
+ _react2['default'].createElement('br', null),
702
+ 'Easy3wEditBigTable',
703
+ _react2['default'].createElement('br', null)
882
704
  );
883
705
  };
884
706
 
885
707
  return Easy3wEditBigTable;
886
708
  }(_react.Component);
887
709
 
888
- Easy3wEditBigTable.defaultProps = {
889
- rowKey: 'autoAddNumber_idx_edit'
890
- };
891
710
  exports['default'] = Easy3wEditBigTable;
892
711
  module.exports = exports['default'];