easy3wui 1.5.64-beta.8 → 1.5.64-beta1

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,13 +2,13 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
 
5
- var _modal = require('antd/lib/modal');
5
+ var _extends2 = require('babel-runtime/helpers/extends');
6
6
 
7
- var _modal2 = _interopRequireDefault(_modal);
7
+ var _extends3 = _interopRequireDefault(_extends2);
8
8
 
9
- var _extends4 = require('babel-runtime/helpers/extends');
9
+ var _modal = require('antd/lib/modal');
10
10
 
11
- var _extends5 = _interopRequireDefault(_extends4);
11
+ var _modal2 = _interopRequireDefault(_modal);
12
12
 
13
13
  var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
14
14
 
@@ -34,12 +34,16 @@ var _reactDataGrid = require('react-data-grid');
34
34
 
35
35
  var _reactDataGrid2 = _interopRequireDefault(_reactDataGrid);
36
36
 
37
- require('react-data-grid/lib/styles.css');
37
+ var _reactDataGridAddons = require('react-data-grid-addons');
38
38
 
39
39
  var _xlsx = require('xlsx');
40
40
 
41
41
  var _xlsx2 = _interopRequireDefault(_xlsx);
42
42
 
43
+ var _numeral = require('numeral');
44
+
45
+ var _numeral2 = _interopRequireDefault(_numeral);
46
+
43
47
  var _classnames = require('classnames');
44
48
 
45
49
  var _classnames2 = _interopRequireDefault(_classnames);
@@ -50,6 +54,9 @@ var _Easy3wEditBigTableForm2 = _interopRequireDefault(_Easy3wEditBigTableForm);
50
54
 
51
55
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
52
56
 
57
+ /* eslint-disable no-alert */
58
+ var Selectors = _reactDataGridAddons.Data.Selectors;
59
+
53
60
  var Easy3wEditBigTable = function (_Component) {
54
61
  (0, _inherits3['default'])(Easy3wEditBigTable, _Component);
55
62
 
@@ -58,802 +65,1121 @@ var Easy3wEditBigTable = function (_Component) {
58
65
 
59
66
  var _this = (0, _possibleConstructorReturn3['default'])(this, _Component.call(this, props));
60
67
 
61
- _this.bidPureComponent = function (pureComponentName, that) {
62
- _this[pureComponentName] = that;
68
+ _initialiseProps.call(_this);
69
+
70
+ var bidPureComponent = _this.props.bidPureComponent;
71
+
72
+ if (bidPureComponent && typeof bidPureComponent === 'function') {
73
+ bidPureComponent(_this);
74
+ }
75
+ var dataList = _this.props.dataList;
76
+
77
+ var rows = _this.touchLoopDataNum(dataList); // 表格数据
78
+ // const rowsView = this.getRows(rows); // 表格显示数据
79
+ _this.state = {
80
+ // 表格选择
81
+ arrValues: [], // 表格选择行索引
82
+ arrValuesInfo: [], // 表格选择行数据
83
+ // 表格数据
84
+ rows: rows, // 表格数据 原始数据
85
+ rowsView: rows, // 表格数据 显示数据
86
+ // 表格列
87
+ // 查询条件
88
+ filters: {},
89
+ // 排序--sort
90
+ sortColumn: null, // 排序列
91
+ sortDirection: null, // 排序方向
92
+ // 批量录入
93
+ visible: false, // 隐藏批量录入Modal
94
+ // 保存标识
95
+ saveFlag: true // 保存标识 true 已保存 false 未保存
63
96
  };
97
+ return _this;
98
+ }
99
+
100
+ Easy3wEditBigTable.prototype.componentDidMount = function componentDidMount() {};
101
+
102
+ Easy3wEditBigTable.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
103
+ var dataUpdateTime = this.props.dataUpdateTime;
104
+
105
+ if (dataUpdateTime !== nextProps.dataUpdateTime) {
106
+ // const rows = this.getRows(); // 显示行数据
107
+ var rows = this.touchLoopDataNum(nextProps.dataList); // 表格数据
108
+ var rowsView = this.getRows(rows); // 表格显示数据
109
+ this.touchSetState({ rows: rows, rowsView: rowsView });
110
+ }
111
+ };
112
+
113
+ Easy3wEditBigTable.prototype.componentWillUnmount = function componentWillUnmount() {
114
+ var objToolbarProps = this.props.objToolbarProps;
115
+
116
+ var _ref = objToolbarProps || {},
117
+ _ref$unloadSaveFlag = _ref.unloadSaveFlag,
118
+ unloadSaveFlag = _ref$unloadSaveFlag === undefined ? true : _ref$unloadSaveFlag;
119
+ // unloadSaveFlag 是否在卸载后保存 true 需要保存 false 不需要保存
120
+
64
121
 
65
- _this.touchCreateColumns = function (columns) {
66
- var _this$props = _this.props,
67
- _this$props$autoAddNu = _this$props.autoAddNumber,
68
- autoAddNumber = _this$props$autoAddNu === undefined ? true : _this$props$autoAddNu,
69
- selectedFlag = _this$props.selectedFlag;
70
-
71
- if (autoAddNumber) {
72
- columns.unshift({
73
- name: '序号',
74
- key: 'index',
75
- renderCell: function renderCell(_ref) {
76
- var rowIdx = _ref.rowIdx;
77
- return rowIdx + 1;
122
+ var saveFlag = this.state.saveFlag;
123
+ // saveFlag 是否已保存 true 已保存 false 未保存
124
+
125
+ var saveEditBigTableZJ = this.saveEditBigTableZJ;
126
+
127
+ if (unloadSaveFlag) {
128
+ if (saveFlag) {
129
+ // 已保存
130
+ } else {
131
+ // 有变更-未保存
132
+ _modal2['default'].confirm({
133
+ title: '提示',
134
+ content: '表格数据未保存, 是否保存?',
135
+ okText: '保存',
136
+ cancelText: '取消',
137
+ onOk: function onOk() {
138
+ saveEditBigTableZJ();
78
139
  }
79
140
  });
80
141
  }
81
- if (selectedFlag) {
82
- columns.unshift(_reactDataGrid.SelectColumn);
83
- }
84
- return columns;
85
- };
142
+ }
143
+ };
144
+ // 绑定组件
86
145
 
87
- _this.touchDP = function () {
88
- var dataList = _this.props.dataList;
146
+ // 获取列表
89
147
 
90
- var arrOriginalRows = [].concat(dataList); // 原始数据
91
- var _this$state = _this.state,
92
- objFilters = _this$state.objFilters,
93
- sortColumns = _this$state.sortColumns;
148
+ // 表格编辑
94
149
 
95
- var arrRows = [].concat(arrOriginalRows);
96
- var numFlag = false;
97
- if (objFilters.enabled) {
98
- // 启用筛选条件
99
- arrRows = _this.touchFilter(objFilters, arrOriginalRows);
100
- numFlag = true;
101
- }
102
- if (!numFlag) {
103
- arrRows.map(function (item, index) {
104
- item.autoAddNumber_idx_edit = index;
105
- return item;
106
- });
107
- }
108
- if (sortColumns.length > 0) {
109
- // 有排序字段
110
- arrRows = _this.touchSort(sortColumns[0], arrOriginalRows);
111
- }
112
- return arrRows;
113
- };
150
+ // #region 表格选择
151
+ // 表格选择---选择
114
152
 
115
- _this.touchFilter = function (objFilters, arrRows) {
116
- var objFiltersNew = (0, _extends5['default'])({}, objFilters);
117
- delete objFiltersNew.enabled;
118
- var arrFilterKeys = Object.keys(objFiltersNew);
119
- return arrRows.filter(function (r, index) {
120
- r.autoAddNumber_idx_edit = index;
121
- var filterFlag = true;
122
- arrFilterKeys.map(function (key) {
123
- filterFlag = filterFlag && (objFilters[key] || objFilters[key] === 0 ? r[key] && r[key].includes(objFilters[key]) : true);
124
- return key;
125
- });
126
- return filterFlag;
127
- });
128
- };
153
+ // 表格选择---取消选择
129
154
 
130
- _this.touchSort = function (objSortColumns, arrRows) {
131
- var columnKey = objSortColumns.columnKey,
132
- direction = objSortColumns.direction;
155
+ // 改变选择状态
133
156
 
134
- var dataType = 'number'; // 默认数据类型
135
- _this.props.columns.map(function (column) {
136
- if (column.key === columnKey) {
137
- dataType = column.dataType || dataType; // 获取数据类型
138
- }
139
- return true;
140
- });
141
- var arr = arrRows.sort(function (a, b) {
142
- // const comparator = getComparator(objSortColumns.columnKey);
143
- var compResult = 0; // 比较结果
144
- switch (dataType) {
145
- case 'string':
146
- // 字符串排序
147
- // #region 特殊值处理
148
- if (a[columnKey] === null && b[columnKey] === null) {
149
- compResult = 0;
150
- } else if (a[columnKey] === null) {
151
- compResult = 1;
152
- } else if (b[columnKey] === null) {
153
- compResult = -1;
154
- } else if (a[columnKey] === undefined && b[columnKey] === undefined) {
155
- compResult = 0;
156
- } else if (a[columnKey] === undefined) {
157
- compResult = 1;
158
- } else if (b[columnKey] === undefined) {
159
- compResult = -1;
160
- // #endregion 特殊值处理
161
- } else {
162
- compResult = a[columnKey].localeCompare(b[columnKey]); // 字符串排序
163
- }
164
- break;
165
- case 'boolean':
166
- // 布尔值排序
167
- compResult = a[columnKey] === b[columnKey] ? 0 : a[columnKey] ? 1 : -1; // 布尔值排序
168
- break;
169
- case 'date':
170
- // 日期排序
171
- compResult = new Date(a[columnKey]).getTime() - new Date(b[columnKey]).getTime(); // 日期排序
172
- break;
173
- case 'number':
174
- // 数字排序
175
- compResult = a[columnKey] - b[columnKey]; // 数字排序
176
- break;
177
- default:
178
- // throw new Error(`unsupported sortColumn: "${columnKey}"`);
179
- // 没有找到对应字段,返回0,参数位置不变
180
- compResult = 0;
181
- break;
182
- }
183
- if (compResult !== 0) {
184
- return direction === 'ASC' ? compResult : -compResult;
185
- } else {
186
- return compResult;
187
- }
188
- });
189
- return arr;
190
- };
157
+ // #endregion 表格选择
158
+ // #region 右上角按钮处理--toolbar
159
+ // 新增
191
160
 
192
- _this.touchCountTotal = function (rowsView, columns) {
193
- rowsView.map(function (row, index) {
194
- columns.map(function (item, idx) {
195
- var key = item.key,
196
- totalFlag = item.totalFlag,
197
- children = item.children;
198
-
199
- if (children) {
200
- _this.touchCountTotal(rowsView, children);
201
- } else if (totalFlag && typeof totalFlag === 'boolean') {
202
- if (index === 0) {
203
- _this.objTotal[key] = 0;
204
- }
205
- var intData = Number(row[key]) || 0;
206
- _this.objTotal[key] += intData;
207
- }
208
- return idx;
209
- });
210
- return index;
211
- });
212
- return _this.objTotal;
213
- };
161
+ // 复制
214
162
 
215
- _this.touchSetState = function (objState, callback) {
216
- // objState 要设置的state对象
217
- // callback 回调函数 非必须
218
- if (callback && typeof callback === 'function') {
219
- _this.setState(objState, callback);
220
- } else {
221
- _this.setState(objState);
222
- }
223
- };
163
+ // 删除
224
164
 
225
- _this.touchFilters = function () {
226
- var objFilters = _this.state.objFilters;
165
+ // 导入
227
166
 
228
- _this.setState({
229
- objFilters: (0, _extends5['default'])({}, objFilters, {
230
- enabled: !objFilters.enabled
231
- })
232
- }, function () {
233
- var touchFiltersChangeState = _this.props.touchFiltersChangeState;
167
+ // 导出--数据
234
168
 
235
- if (touchFiltersChangeState && typeof touchFiltersChangeState === 'function') {
236
- touchFiltersChangeState((0, _extends5['default'])({}, _this.state.objFilters));
237
- }
238
- });
239
- };
169
+ // 批量录入--显示批量录入Modal
240
170
 
241
- _this.touchFiltersChange = function (fieldId, value) {
242
- var _extends2;
171
+ // 批量录入--隐藏批量录入Modal
243
172
 
244
- var objFilters = _this.state.objFilters;
173
+ // 批量录入--确认回调
245
174
 
246
- _this.setState({
247
- objFilters: (0, _extends5['default'])({}, objFilters, (_extends2 = {}, _extends2[fieldId] = value, _extends2))
248
- }, function () {
249
- var touchFiltersChangeState = _this.props.touchFiltersChangeState;
175
+ // #endregion 右上角按钮处理--toolbar
176
+ // #region 数据处理
177
+ // 表格视图数据
250
178
 
251
- if (touchFiltersChangeState && typeof touchFiltersChangeState === 'function') {
252
- touchFiltersChangeState((0, _extends5['default'])({}, _this.state.objFilters));
253
- }
254
- });
255
- };
179
+ // 数据长度
256
180
 
257
- _this.touchClearFilters = function () {
258
- var objFilters = _this.state.objFilters;
181
+ // 表格数据函数
259
182
 
260
- _this.setState({
261
- objFilters: {
262
- enabled: objFilters.enabled
263
- }
264
- }, function () {
265
- var touchFiltersChangeState = _this.props.touchFiltersChangeState;
183
+ // 数据循环--设置数据序号
266
184
 
267
- if (touchFiltersChangeState && typeof touchFiltersChangeState === 'function') {
268
- touchFiltersChangeState((0, _extends5['default'])({}, _this.state.objFilters));
269
- }
270
- });
271
- };
185
+ // 设置组件state
272
186
 
273
- _this.touchSortColumnsChange = function (sort) {
274
- _this.setState({
275
- sortColumns: sort
276
- });
277
- };
187
+ // 数据循环--处理后的数据
278
188
 
279
- _this.getToolbar = function () {
280
- var objToolbarProps = _this.props.objToolbarProps;
281
- var addRowFlag = objToolbarProps.addRowFlag,
282
- addRowButtonText = objToolbarProps.addRowButtonText,
283
- touchAddRow = objToolbarProps.touchAddRow,
284
- enableFilter = objToolbarProps.enableFilter,
285
- filterRowsButtonText = objToolbarProps.filterRowsButtonText,
286
- filterRowsClearButtonText = objToolbarProps.filterRowsClearButtonText,
287
- arrBtn = objToolbarProps.arrBtn,
288
- batchFlag = objToolbarProps.batchFlag,
289
- batchButtonText = objToolbarProps.batchButtonText,
290
- showModalBatchEditBigTable = objToolbarProps.showModalBatchEditBigTable,
291
- saveFlag = objToolbarProps.saveFlag,
292
- saveButtonText = objToolbarProps.saveButtonText,
293
- deleteFlag = objToolbarProps.deleteFlag,
294
- deleteButtonText = objToolbarProps.deleteButtonText,
295
- deleteRow = objToolbarProps.deleteRow,
296
- importFlag = objToolbarProps.importFlag,
297
- importButtonText = objToolbarProps.importButtonText,
298
- touchImport = objToolbarProps.touchImport,
299
- exportFlag = objToolbarProps.exportFlag,
300
- exportButtonText = objToolbarProps.exportButtonText,
301
- touchExport = objToolbarProps.touchExport;
302
-
303
- var toolbar = _react2['default'].createElement(
304
- 'div',
305
- { className: 'reactGridToolbar' },
306
- addRowFlag ? _react2['default'].createElement(
307
- 'button',
308
- { type: 'button', className: 'btn', onClick: touchAddRow || _this.touchAddRow },
309
- addRowButtonText || '新增'
310
- ) : '',
311
- enableFilter ? _react2['default'].createElement(
312
- 'span',
313
- null,
314
- _react2['default'].createElement(
315
- 'button',
316
- { type: 'button', className: 'btn', onClick: _this.touchFilters },
317
- filterRowsButtonText || '筛选'
318
- ),
319
- _react2['default'].createElement(
320
- 'button',
321
- { type: 'button', className: 'btn', onClick: _this.touchClearFilters },
322
- filterRowsClearButtonText || '清空筛选条件'
323
- )
324
- ) : '',
325
- arrBtn && arrBtn.map(function (btn) {
326
- return _react2['default'].createElement(
327
- 'button',
328
- { type: 'button', className: 'btn', onClick: btn.onClick },
329
- btn.text
330
- );
331
- }),
332
- batchFlag ? _react2['default'].createElement(
333
- 'button',
334
- { type: 'button', className: 'btn', onClick: showModalBatchEditBigTable || _this.showModalBatchEditBigTable },
335
- batchButtonText || '批量录入'
336
- ) : '',
337
- saveFlag ? _react2['default'].createElement(
338
- 'button',
339
- { type: 'button', className: 'btn', onClick: _this.saveEditBigTableZJ },
340
- saveButtonText || '保存'
341
- ) : '',
342
- deleteFlag ? _react2['default'].createElement(
343
- 'button',
344
- { type: 'button', className: 'btn', onClick: deleteRow || _this.deleteRow },
345
- deleteButtonText || '删除'
346
- ) : '',
347
- importFlag ? _react2['default'].createElement(
348
- 'button',
349
- { type: 'button', className: 'btn', onClick: touchImport || _this.touchImport },
350
- _react2['default'].createElement('input', { type: 'file', id: 'touchImportExcel', accept: '.xlsx, .xls', style: { display: 'none' } }),
351
- importButtonText || '导入'
352
- ) : '',
353
- exportFlag ? _react2['default'].createElement(
354
- 'button',
355
- { type: 'button', className: 'btn', onClick: touchExport || _this.touchExport },
356
- exportButtonText || '导出'
357
- ) : ''
358
- );
359
- return toolbar;
360
- };
189
+ // 导入导出表头
361
190
 
362
- _this.touchAddRow = function () {
363
- var _ref2;
191
+ // #endregion 数据处理
364
192
 
365
- var rowKey = _this.props.rowKey;
366
- var dataList = _this.props.dataList;
193
+ // #region 查询条件
194
+ // 表头排序
367
195
 
368
- _this.saveEditBigTableModelZJ('touchAddRow', [].concat(dataList, [(_ref2 = {}, _ref2[rowKey] = 'add_' + (dataList.length - 1) + '_' + new Date().getTime(), _ref2)]));
369
- };
196
+ // 获取查询内容
370
197
 
371
- _this.touchCopyRow = function () {
372
- var _this$props2 = _this.props,
373
- dataList = _this$props2.dataList,
374
- rowKey = _this$props2.rowKey;
375
- var arrValuesInfo = _this.state.arrValuesInfo;
198
+ // 筛选条件变更
376
199
 
377
- if (arrValuesInfo.length) {
378
- var arrNew = []; // 复制的新数组
379
- arrValuesInfo.forEach(function (item, index) {
380
- var _extends3;
200
+ // 清空筛选条件
381
201
 
382
- var newRow = (0, _extends5['default'])({}, item, (_extends3 = {}, _extends3[rowKey] = item[rowKey] + '_copy_' + index + '_' + new Date().getTime(), _extends3));
383
- arrNew.push(newRow);
384
- return item;
385
- });
386
- _this.saveEditBigTableModelZJ('touchCopyRow', [].concat(dataList, arrNew));
387
- } else {
388
- _modal2['default'].error({
389
- title: '错误',
390
- content: '请选择要复制的行'
391
- });
392
- }
393
- };
202
+ // #endregion 查询条件
394
203
 
395
- _this.deleteRow = function () {
396
- var dataList = _this.props.dataList;
397
- var _this$state2 = _this.state,
398
- arrValues = _this$state2.arrValues,
399
- arrValuesInfo = _this$state2.arrValuesInfo;
400
- var _this$props3 = _this.props,
401
- objToolbarProps = _this$props3.objToolbarProps,
402
- rowKey = _this$props3.rowKey;
403
- var deleteRowInterface = objToolbarProps.deleteRowInterface;
404
-
405
- if (arrValues.length) {
406
- var arrRows = []; // 删除数据后的新数组
407
- dataList.map(function (row) {
408
- var flag = true;
409
- arrValues.map(function (key) {
410
- if (key === row[rowKey]) {
411
- // 删除选择的行
412
- flag = false;
413
- }
414
- return key;
415
- });
416
- if (flag) {
417
- arrRows.push((0, _extends5['default'])({}, row));
418
- }
419
- return flag;
420
- });
421
- if (deleteRowInterface && typeof deleteRowInterface === 'function') {
422
- // 删除行接口
423
- deleteRowInterface(arrValuesInfo, arrValues);
424
- } else {
425
- _this.saveEditBigTableModelZJ('deleteRow', arrRows);
426
- }
427
- _this.onSelectedRowsChange([], []); // 选择行清空
428
- } else {
429
- _modal2['default'].error({
430
- title: '错误',
431
- content: '请选择要删除的行'
432
- });
433
- }
434
- };
204
+ // #region toolbar处理
435
205
 
436
- _this.touchGetHearder = function () {
437
- var _this$props4 = _this.props,
438
- columns = _this$props4.columns,
439
- arrColumnsKey = _this$props4.arrColumnsKey,
440
- objSheet = _this$props4.objSheet,
441
- arrColInfo = _this$props4.arrColInfo;
206
+ // #endregion toolbar处理
207
+ // #region 设置ReactDataGrid属性
208
+ // 在单元格设置为活动状态之前调用,返回一个布尔值以确定单元格是否可编辑
442
209
 
210
+ // 表格行渲染
443
211
 
444
- var arrColumnsKeyNew = ['id'];
445
- var objSheetNew = { id: 'id' };
446
- // 定义列信息,隐藏第一列(A列)
447
- var arrColInfoNew = [{ hidden: true }];
448
- columns.forEach(function (column) {
449
- var key = column.key,
450
- name = column.name,
451
- hiddeKeys = column.hiddeKeys;
452
-
453
- objSheetNew[key] = name;
454
- arrColumnsKeyNew.push(key);
455
- arrColInfoNew.push({});
456
- if (hiddeKeys) {
457
- var arrHiddenKeys = hiddeKeys.split(',');
458
- arrHiddenKeys.map(function (item) {
459
- if (item === key) {
460
- // 隐藏列与显示列相同,则不添加入表头
461
- } else {
462
- objSheetNew[item] = item;
463
- arrColumnsKeyNew.push(item);
464
- arrColInfoNew.push({
465
- hidden: true
466
- });
467
- }
468
- return item;
469
- });
470
- }
471
- });
212
+ // 创建columns
472
213
 
473
- return { arrColumnsKey: arrColumnsKey || arrColumnsKeyNew, objSheet: objSheet || objSheetNew, arrColInfo: arrColInfo || arrColInfoNew };
474
- };
214
+ // #endregion 设置ReactDataGrid属性
215
+ // #region 保存
216
+ // 保存表格数据
475
217
 
476
- _this.touchImport = function () {
477
- var input = document.getElementById('touchImportExcel');
478
- input.onchange = function (e) {
479
- var file = e.target.files[0];
480
- var reader = new FileReader();
481
- reader.onload = function (event) {
482
- var _this$touchGetHearder = _this.touchGetHearder(),
483
- arrColumnsKey = _this$touchGetHearder.arrColumnsKey;
484
-
485
- var data = event.target.result;
486
- var workbook = _xlsx2['default'].read(data, { type: 'binary' });
487
- var firstSheetName = workbook.SheetNames[0];
488
- var worksheet = workbook.Sheets[firstSheetName];
489
- var dataList = _xlsx2['default'].utils.sheet_to_json(worksheet, { header: arrColumnsKey });
490
- dataList.shift(); // 去掉表头
491
- // const rowsView = this.getRows(dataList); // 表格显示数据
492
- _this.saveEditBigTableModelZJ('touchImport', dataList);
493
- };
494
- reader.readAsBinaryString(file);
495
- };
496
- input.click();
497
- };
218
+ // 保存表格数据
498
219
 
499
- _this.touchExport = function () {
500
- var _this$touchGetHearder2 = _this.touchGetHearder(),
501
- objSheet = _this$touchGetHearder2.objSheet,
502
- arrColInfo = _this$touchGetHearder2.arrColInfo;
503
-
504
- var rowsView = [].concat(_this.arrRows);
505
- // 计算 rowsView 中所有对象字段最多的长度
506
- var maxFieldsLength = 0;
507
- rowsView.forEach(function (item) {
508
- var fieldsLength = Object.keys(item).length;
509
- if (fieldsLength > maxFieldsLength) {
510
- maxFieldsLength = fieldsLength;
511
- }
512
- return item;
513
- });
514
- if (maxFieldsLength > arrColInfo.length) {
515
- for (var i = arrColInfo.length; i < maxFieldsLength;) {
516
- arrColInfo.push({ hidden: true });
517
- i += 1;
518
- }
519
- }
520
- // 创建工作簿和工作表
521
- var worksheet = _xlsx2['default'].utils.json_to_sheet([objSheet].concat(rowsView), { skipHeader: true });
522
- worksheet['!cols'] = arrColInfo;
523
- var workbook = _xlsx2['default'].utils.book_new();
524
- _xlsx2['default'].utils.book_append_sheet(workbook, worksheet, 'Sheet1');
525
-
526
- // 生成Excel文件并触发下载
527
- _xlsx2['default'].writeFile(workbook, 'exported_data.xlsx');
528
- };
220
+ // 设置保存标识
529
221
 
530
- _this.showModalBatchEditBigTable = function () {
531
- _this.setState({
532
- visible: true // 显示批量录入Modal
533
- });
534
- };
222
+ // #endregion 保存
223
+ // #region 校验数据
224
+ // 校验处理
535
225
 
536
- _this.hideModalBatchEditBigTable = function () {
537
- _this.setState({
538
- visible: false // 隐藏批量录入Modal
539
- });
540
- };
226
+ // 校验数据
541
227
 
542
- _this.confirmCallbackBatchEditBigTable = function (objFormData, objColumn) {
543
- var _this$props5 = _this.props,
544
- dataList = _this$props5.dataList,
545
- touchAutoCompute = _this$props5.touchAutoCompute,
546
- rowKey = _this$props5.rowKey;
547
-
548
- var rowsView = [].concat(_this.arrRows);
549
- rowsView.map(function (row) {
550
- // const rowId = row[rowKey];
551
- var autoAddNumberIdxEdit = row.autoAddNumber_idx_edit;
552
- // const { [rowKey]: } = row;
553
-
554
- var updated = (0, _extends5['default'])({}, objFormData);
555
- if (touchAutoCompute && typeof touchAutoCompute === 'function') {
556
- // 数据变更-自动计算行数据
557
- updated = touchAutoCompute({
558
- cellKey: objColumn.key,
559
- updated: updated,
560
- toRowData: row
561
- });
562
- }
563
- dataList[autoAddNumberIdxEdit] = (0, _extends5['default'])({}, dataList[autoAddNumberIdxEdit], updated);
564
- return row;
565
- });
566
- _this.saveEditBigTableModelZJ('confirmCallbackBatchEditBigTable', dataList);
567
- };
228
+ // #endregion 校验数据
229
+ // 转换数字
230
+
231
+ // 变量 num 是一个有效的数字,即非空、不为 NaN 且是有限值
232
+
233
+
234
+ Easy3wEditBigTable.prototype.render = function render() {
235
+ var _this2 = this;
236
+
237
+ var visible = this.state.visible;
238
+ var _props = this.props,
239
+ totalFlag = _props.totalFlag,
240
+ objOtherProps = _props.objOtherProps,
241
+ objToolbarProps = _props.objToolbarProps,
242
+ strReactDataGridStyle = _props.strReactDataGridStyle,
243
+ strAddReactDataGridStyle = _props.strAddReactDataGridStyle;
244
+
245
+ var objReactDataGridProps = this.getReactDataGridProps();
246
+ var columns = this.createColumns(); // 表头
247
+ var objTotal = totalFlag ? this.touchLoopData() : {}; // 循环数据获取
248
+ return _react2['default'].createElement(
249
+ 'div',
250
+ { className: (0, _classnames2['default'])(['Easy3wEditBigTable']) },
251
+ _react2['default'].createElement(
252
+ 'style',
253
+ null,
254
+ strReactDataGridStyle || (strAddReactDataGridStyle || '') + '\n .custom-edit-cell { \n background-color: #f6ffed;\n }\n '
255
+ ),
256
+ _react2['default'].createElement(_reactDataGrid2['default'], (0, _extends3['default'])({}, this.props, {
257
+ ref: this.ReactDataGridRef,
258
+ columns: columns // 表头
259
+ // rows={rows}
260
+ , rowGetter: this.rowGetter // 获取行数据
261
+ , rowsCount: this.getSize() // 行数
262
+ , onGridSort: this.onGridSort
263
+ }, objReactDataGridProps, objOtherProps)),
264
+ totalFlag ? _react2['default'].createElement(
265
+ 'div',
266
+ null,
267
+ objTotal && Object.keys(objTotal).map(function (key, index) {
268
+ return _react2['default'].createElement(
269
+ 'span',
270
+ { key: key },
271
+ index === 0 ? '' : ';',
272
+ _react2['default'].createElement(
273
+ 'span',
274
+ null,
275
+ objTotal[key].name,
276
+ '\uFF1A'
277
+ ),
278
+ _react2['default'].createElement(
279
+ 'span',
280
+ null,
281
+ ' ',
282
+ objTotal[key].numberFormat ? _this2.touchFormatNum(objTotal[key].value) : objTotal[key].value,
283
+ ' ',
284
+ objTotal[key].unit || ''
285
+ )
286
+ );
287
+ })
288
+ ) : '',
289
+ visible ? _react2['default'].createElement(_Easy3wEditBigTableForm2['default'] // 批量录入Modal
290
+ , { visible: visible // 是否显示
291
+ , objOtherParameters: (0, _extends3['default'])({}, objToolbarProps, { // 工具栏属性
292
+ columns: columns // 表头
293
+ }) // 其他参数
294
+ , bidPureComponent: function bidPureComponent(that) {
295
+ return _this2.bidPureComponent('Easy3wEditBigTableForm', that);
296
+ } // 绑定组件
297
+ , confirmCallback: this.confirmCallbackBatchEditBigTable,
298
+ hideModal: this.hideModalBatchEditBigTable
299
+ }) : ''
300
+ );
301
+ };
302
+
303
+ return Easy3wEditBigTable;
304
+ }(_react.Component);
305
+
306
+ Easy3wEditBigTable.defaultProps = {
307
+ rowKey: 'autoAddNumber_idx_edit' // 表格主键 原始数据索引
308
+ };
309
+
310
+ var _initialiseProps = function _initialiseProps() {
311
+ var _this3 = this;
312
+
313
+ this.bidPureComponent = function (pureComponentName, that) {
314
+ _this3[pureComponentName] = that;
315
+ };
316
+
317
+ this.ReactDataGridRef = function (ref) {
318
+ if (ref) {
319
+ _this3.ReactDataGridRef = ref;
320
+ }
321
+ };
568
322
 
569
- _this.saveEditBigTableModelZJ = function (operationType, dataList) {
570
- var saveEditBigTableModel = _this.props.saveEditBigTableModel;
323
+ this.onGridRowsUpdated = function (objUpdated) {
324
+ var fromRow = objUpdated.fromRow,
325
+ toRow = objUpdated.toRow,
326
+ fromRowData = objUpdated.fromRowData,
327
+ action = objUpdated.action,
328
+ cellKey = objUpdated.cellKey;
329
+ var updated = objUpdated.updated;
571
330
 
572
- if (saveEditBigTableModel && typeof saveEditBigTableModel === 'function') {
573
- // 数据变更-回调函数
574
- saveEditBigTableModel(operationType, dataList);
331
+ if (action === 'COPY_PASTE') {
332
+ updated[cellKey] = fromRowData[cellKey];
333
+ }
334
+ var touchAutoCompute = _this3.props.touchAutoCompute;
335
+ var _state = _this3.state,
336
+ rows = _state.rows,
337
+ rowsView = _state.rowsView;
338
+
339
+
340
+ for (var i = fromRow; i <= toRow;) {
341
+ var objRowToUpdate = rowsView[i] || {};
342
+ // let rowToUpdate = rows[i];
343
+ // let updatedRow = update(rowToUpdate, {$merge: updated});
344
+ // rows[i] = updatedRow;
345
+
346
+ if (touchAutoCompute && typeof touchAutoCompute === 'function') {
347
+ // 数据变更-自动计算行数据
348
+ updated = touchAutoCompute((0, _extends3['default'])({}, objUpdated, { toRowData: (0, _extends3['default'])({}, objRowToUpdate) }));
575
349
  }
576
- };
350
+ var autoAddNumberIdxEdit = objRowToUpdate.autoAddNumber_idx_edit;
577
351
 
578
- _this.saveEditBigTableZJ = function () {
579
- var objToolbarProps = _this.props.objToolbarProps;
352
+ rows[autoAddNumberIdxEdit] = (0, _extends3['default'])({}, rows[autoAddNumberIdxEdit], updated);
353
+ rowsView[i] = (0, _extends3['default'])({}, objRowToUpdate, updated);
354
+ i += 1;
355
+ }
580
356
 
581
- var _ref3 = objToolbarProps || {},
582
- saveEditBigTable = _ref3.saveEditBigTable;
357
+ _this3.onGridRowsUpdatedZJ('onGridRowsUpdated', rows, rowsView);
358
+ };
583
359
 
584
- if (saveEditBigTable && typeof saveEditBigTable === 'function') {
585
- // 数据变更-回调函数
586
- saveEditBigTable('saveEditBigTableZJ', function () {
587
- return _this.touchSetState({ saveFlag: true });
588
- });
360
+ this.onRowsSelected = function (rows) {
361
+ var _state2 = _this3.state,
362
+ arrValues = _state2.arrValues,
363
+ arrValuesInfo = _state2.arrValuesInfo;
364
+ var _props2 = _this3.props,
365
+ rowKey = _props2.rowKey,
366
+ onRowsSelectedCb = _props2.onRowsSelectedCb;
367
+
368
+ var arrValuesNew = []; // 表格选择行索引
369
+ var arrValuesInfoNew = []; // 表格选择行数据
370
+ rows.map(function (r) {
371
+ arrValuesNew.push(r.row[rowKey]);
372
+ arrValuesInfoNew.push(r.row);
373
+ return r;
374
+ });
375
+ arrValues = arrValues.concat(arrValuesNew); // 表格选择行索引
376
+ arrValuesInfo = arrValuesInfo.concat(arrValuesInfoNew); // 表格选择行数据
377
+ if (onRowsSelectedCb && typeof onRowsSelectedCb === 'function') {
378
+ // 表格选择回调函数
379
+ onRowsSelectedCb('onRowsSelected', arrValues, arrValuesInfo, arrValuesNew, arrValuesInfoNew);
380
+ }
381
+ _this3.onSelectedRowsChange(arrValues, arrValuesInfo);
382
+ };
383
+
384
+ this.onRowsDeselected = function (rows) {
385
+ var arrValuesInfo = _this3.state.arrValuesInfo;
386
+ var _props3 = _this3.props,
387
+ rowKey = _props3.rowKey,
388
+ onRowsSelectedCb = _props3.onRowsSelectedCb;
389
+
390
+ var arrValuesNew = []; // 表格选择行索引
391
+ var arrValuesInfoNew = []; // 表格选择行数据
392
+ var arrSelected = []; // 已选择的行索引
393
+ var arrSelectedInfo = []; // 已选择的行数据
394
+ arrValuesInfo.filter(function (item) {
395
+ var flag = true;
396
+ rows.map(function (r) {
397
+ var row = r.row;
398
+
399
+ if (item[rowKey] === row[rowKey]) {
400
+ // 删除已取消选择的行
401
+ flag = false;
402
+ arrSelected.push(item[rowKey]);
403
+ arrSelectedInfo.push(item);
404
+ }
405
+ return r;
406
+ });
407
+ if (flag) {
408
+ arrValuesNew.push(item[rowKey]);
409
+ arrValuesInfoNew.push(item);
589
410
  }
411
+ return flag;
412
+ });
413
+ if (onRowsSelectedCb && typeof onRowsSelectedCb === 'function') {
414
+ // 表格选择回调函数
415
+ onRowsSelectedCb('onRowsDeselected', arrValuesNew, arrValuesInfoNew, arrSelected, arrSelectedInfo);
416
+ }
417
+ _this3.onSelectedRowsChange(arrValuesNew, arrValuesInfoNew);
418
+ };
419
+
420
+ this.onSelectedRowsChange = function (arrValues, arrValuesInfo) {
421
+ _this3.setState({ arrValues: arrValues, arrValuesInfo: arrValuesInfo });
422
+ };
423
+
424
+ this.touchAddRow = function () {
425
+ var _state3 = _this3.state,
426
+ rows = _state3.rows,
427
+ rowsView = _state3.rowsView;
428
+
429
+ var intRows = rows.length;
430
+ var objNewRow = {
431
+ autoAddNumber_idx_edit: intRows || 0, // 自动添加序号 原始数据的索引
432
+ autoAddNumber_idx_view: intRows + 1 // 自动添加序号 显示数据的索引
590
433
  };
434
+ var intRowsView = rowsView.length;
435
+ var objNewRowView = {
436
+ autoAddNumber_idx_edit: intRows || 0, // 自动添加序号 原始数据的索引
437
+ autoAddNumber_idx_view: intRowsView + 1 // 自动添加序号 显示数据的索引
438
+ };
439
+ // objNewRow[rowKey] = require('uuid/v1')(); // 自定义主键
440
+ _this3.onGridRowsUpdatedZJ('touchAddRow', [].concat(rows, [objNewRow]), [].concat(rowsView, [objNewRowView]));
441
+ };
591
442
 
592
- _this.touchSetSaveFlag = function (saveFlag) {
593
- _this.setState({
594
- saveFlag: saveFlag // 保存标识 true 已保存 false 未保存
443
+ this.touchCopyRow = function () {
444
+ var _state4 = _this3.state,
445
+ rows = _state4.rows,
446
+ rowsView = _state4.rowsView;
447
+ var arrValues = _this3.state.arrValues;
448
+
449
+ if (arrValues.length) {
450
+ var newArr = []; // 复制的新数组
451
+ arrValues.forEach(function (key) {
452
+ var newRow = (0, _extends3['default'])({}, rows[key]);
453
+ newArr.push(newRow);
454
+ return key;
595
455
  });
596
- };
456
+ rows = [].concat(rows, newArr);
457
+ rowsView = [].concat(rowsView, newArr);
458
+ _this3.onGridRowsUpdatedZJ('touchCopyRow', rows, rowsView);
459
+ } else {
460
+ _modal2['default'].error({
461
+ title: '错误',
462
+ content: '请选择要复制的行'
463
+ });
464
+ }
465
+ };
597
466
 
598
- _this.touchRowsChange = function (updatedRows, obj) {
599
- var indexes = obj.indexes,
600
- column = obj.column;
601
- var _this$props6 = _this.props,
602
- touchAutoCompute = _this$props6.touchAutoCompute,
603
- dataList = _this$props6.dataList;
604
- var key = column.key;
605
-
606
- if (indexes && indexes.length) {
607
- indexes.map(function (index) {
608
- var updated = updatedRows[index];
609
- var _updated = updated,
610
- autoAddNumberIdxEdit = _updated.autoAddNumber_idx_edit;
611
-
612
- if (touchAutoCompute && typeof touchAutoCompute === 'function') {
613
- var _updated2;
614
-
615
- updated = touchAutoCompute({
616
- cellKey: key,
617
- updated: (_updated2 = {}, _updated2[column.key] = updated[column.key], _updated2),
618
- toRowData: _this.arrRows[index]
619
- });
467
+ this.deleteRow = function () {
468
+ var rows = _this3.state.rows;
469
+ var _state5 = _this3.state,
470
+ arrValues = _state5.arrValues,
471
+ arrValuesInfo = _state5.arrValuesInfo;
472
+ var _props4 = _this3.props,
473
+ objToolbarProps = _props4.objToolbarProps,
474
+ rowKey = _props4.rowKey;
475
+ var deleteRowInterface = objToolbarProps.deleteRowInterface;
476
+
477
+ if (arrValues.length) {
478
+ var arrRows = []; // 删除数据后的新数组
479
+ // rows = rows.map((row, index) => {
480
+ rows.map(function (row, index) {
481
+ var flag = true;
482
+ arrValues.map(function (key) {
483
+ if (key === row[rowKey]) {
484
+ // 删除选择的行
485
+ flag = false;
620
486
  }
621
- dataList[autoAddNumberIdxEdit] = (0, _extends5['default'])({}, dataList[autoAddNumberIdxEdit], updated);
622
- return index;
487
+ return key;
623
488
  });
624
- _this.saveEditBigTableModelZJ('touchRowsChange', dataList);
625
- }
626
- };
627
-
628
- _this.touchSelectedRowsChange = function (selectedRows) {
629
- var _this$props7 = _this.props,
630
- rowKey = _this$props7.rowKey,
631
- touchSelectedRowsChangeCB = _this$props7.touchSelectedRowsChangeCB;
632
-
633
- var arrValuesInfo = Array.from(selectedRows);
634
- var arrValues = [];
635
- arrValuesInfo.map(function (item) {
636
- arrValues.push(item[rowKey]);
637
- return item;
489
+ if (flag) {
490
+ arrRows.push((0, _extends3['default'])({}, row, { autoAddNumber_idx_edit: index }));
491
+ }
492
+ return flag;
638
493
  });
639
- if (touchSelectedRowsChangeCB && typeof touchSelectedRowsChangeCB === 'function') {
640
- touchSelectedRowsChangeCB(arrValues, arrValuesInfo, selectedRows);
494
+ var rowsView = _this3.getRows(arrRows); // 表格显示数据
495
+ if (deleteRowInterface && typeof deleteRowInterface === 'function') {
496
+ // 删除行接口
497
+ deleteRowInterface(arrValuesInfo, arrValues);
641
498
  }
642
- _this.setState({
643
- // 表格选择
644
- selectedRows: selectedRows, // 选中的行
645
- arrValues: arrValues, // 表格选择行索引
646
- arrValuesInfo: arrValuesInfo // 表格选择行数据
499
+ _this3.onGridRowsUpdatedZJ('deleteRow', arrRows, rowsView);
500
+ _this3.onSelectedRowsChange([], []); // 选择行清空
501
+ } else {
502
+ _modal2['default'].error({
503
+ title: '错误',
504
+ content: '请选择要删除的行'
647
505
  });
648
- };
649
-
650
- var bidPureComponent = _this.props.bidPureComponent;
651
-
652
- if (bidPureComponent && typeof bidPureComponent === 'function') {
653
- bidPureComponent(_this);
654
506
  }
655
- _this.state = {
656
- sortColumns: [], // 排序字段
657
- objFilters: {
658
- enabled: false // 是否启用筛选条件
659
- }, // 筛选条件
660
- // 表格选择
661
- selectedRows: new Set(), // 选中的行
662
- arrValues: [], // 表格选择行索引
663
- arrValuesInfo: [] // 表格选择行数据
507
+ };
508
+
509
+ this.touchImport = function () {
510
+ var input = document.getElementById('touchImportExcel');
511
+ // input.type = 'file';
512
+ input.onchange = function (e) {
513
+ var file = e.target.files[0];
514
+ var reader = new FileReader();
515
+ reader.onload = function (event) {
516
+ var _getHearder = _this3.getHearder(),
517
+ arrColumnsKey = _getHearder.arrColumnsKey;
518
+
519
+ var data = event.target.result;
520
+ var workbook = _xlsx2['default'].read(data, { type: 'binary' });
521
+ var firstSheetName = workbook.SheetNames[0];
522
+ var worksheet = workbook.Sheets[firstSheetName];
523
+ var rows = _xlsx2['default'].utils.sheet_to_json(worksheet, { header: arrColumnsKey });
524
+ rows.shift(); // 去掉表头
525
+ var rowsView = _this3.getRows(rows); // 表格显示数据
526
+ _this3.onGridRowsUpdatedZJ('touchImport', rows, rowsView);
527
+ };
528
+ reader.readAsBinaryString(file);
664
529
  };
665
- return _this;
666
- }
530
+ input.click();
531
+ };
667
532
 
668
- Easy3wEditBigTable.prototype.componentDidMount = function componentDidMount() {};
533
+ this.touchExport = function () {
534
+ var _getHearder2 = _this3.getHearder(),
535
+ objSheet = _getHearder2.objSheet,
536
+ arrColInfo = _getHearder2.arrColInfo;
537
+ // const filterDataList = this.getRows();
669
538
 
670
- Easy3wEditBigTable.prototype.componentWillUnmount = function componentWillUnmount() {
671
- var objToolbarProps = this.props.objToolbarProps;
672
539
 
673
- var _ref4 = objToolbarProps || {},
674
- _ref4$unloadSaveFlag = _ref4.unloadSaveFlag,
675
- unloadSaveFlag = _ref4$unloadSaveFlag === undefined ? true : _ref4$unloadSaveFlag;
676
- // unloadSaveFlag 是否在卸载后保存 true 需要保存 false 不需要保存
540
+ var rowsView = _this3.state.rowsView;
541
+ // 计算 rowsView 中所有对象字段最多的长度
677
542
 
543
+ var maxFieldsLength = 0;
544
+ rowsView.forEach(function (item) {
545
+ var fieldsLength = Object.keys(item).length;
546
+ if (fieldsLength > maxFieldsLength) {
547
+ maxFieldsLength = fieldsLength;
548
+ }
549
+ return item;
550
+ });
551
+ if (maxFieldsLength > arrColInfo.length) {
552
+ for (var i = arrColInfo.length; i < maxFieldsLength;) {
553
+ arrColInfo.push({ hidden: true });
554
+ i += 1;
555
+ }
556
+ }
557
+ // 创建工作簿和工作表
558
+ var worksheet = _xlsx2['default'].utils.json_to_sheet([objSheet].concat(rowsView), { skipHeader: true });
559
+ worksheet['!cols'] = arrColInfo;
560
+ var workbook = _xlsx2['default'].utils.book_new();
561
+ _xlsx2['default'].utils.book_append_sheet(workbook, worksheet, 'Sheet1');
562
+
563
+ // 生成Excel文件并触发下载
564
+ _xlsx2['default'].writeFile(workbook, 'exported_data.xlsx');
565
+ };
678
566
 
679
- var saveFlag = this.state.saveFlag;
680
- // saveFlag 是否已保存 true 已保存 false 未保存
567
+ this.showModalBatchEditBigTable = function () {
568
+ _this3.setState({
569
+ visible: true // 显示批量录入Modal
570
+ });
571
+ };
681
572
 
682
- var saveEditBigTableZJ = this.saveEditBigTableZJ;
573
+ this.hideModalBatchEditBigTable = function () {
574
+ _this3.setState({
575
+ visible: false // 隐藏批量录入Modal
576
+ });
577
+ };
683
578
 
684
- if (unloadSaveFlag) {
685
- if (saveFlag) {
686
- // 已保存
687
- } else {
688
- // 有变更-未保存
689
- _modal2['default'].confirm({
690
- title: '提示',
691
- content: '表格数据未保存, 是否保存?',
692
- okText: '保存',
693
- cancelText: '取消',
694
- onOk: function onOk() {
695
- saveEditBigTableZJ();
696
- }
579
+ this.confirmCallbackBatchEditBigTable = function (objFormData, objColumn) {
580
+ var _state6 = _this3.state,
581
+ rows = _state6.rows,
582
+ rowsView = _state6.rowsView;
583
+ var _props5 = _this3.props,
584
+ touchAutoCompute = _props5.touchAutoCompute,
585
+ rowKey = _props5.rowKey;
586
+ // const rows = this.getRows();
587
+
588
+ rowsView.map(function (row, index) {
589
+ var autoAddNumberIdxEdit = row.autoAddNumber_idx_edit;
590
+
591
+ var updated = (0, _extends3['default'])({}, objFormData);
592
+ if (touchAutoCompute && typeof touchAutoCompute === 'function') {
593
+ // 数据变更-自动计算行数据
594
+ // action 改变的动作类型,'CELL_UPDATE' 单元格更新,'CELL_BATCH_CHANGE' 单元格批量更新 CELL_UPDATE, COLUMN_FILL, COPY_PASTE, CELL_DRAG
595
+ // cellKey 改变的单元格的key
596
+ // fromRow 改变的单元格的原来行序号
597
+ // fromRowData 改变的单元格的原来行数据
598
+ // fromRowId 改变的单元格的原来行id(行唯一标识)
599
+ // rowIds 所有被选中的行id
600
+ // toRow 改变的单元格的新行序号
601
+ // toRowId 改变的单元格的新行id
602
+ // updated 改变的单元格的新值
603
+ updated = touchAutoCompute({
604
+ cellKey: objColumn.key,
605
+ fromRow: index,
606
+ toRow: index,
607
+ fromRowId: row[rowKey],
608
+ toRowId: row[rowKey],
609
+ rowIds: [row[rowKey]],
610
+ updated: updated,
611
+ action: 'CELL_BATCH_CHANGE',
612
+ fromRowData: row,
613
+ toRowData: row
697
614
  });
698
615
  }
699
- }
616
+ rows[autoAddNumberIdxEdit] = (0, _extends3['default'])({}, rows[autoAddNumberIdxEdit], updated);
617
+ rowsView[index] = (0, _extends3['default'])({}, rowsView[index], updated);
618
+ return row;
619
+ });
620
+ _this3.onGridRowsUpdatedZJ('confirmCallbackBatchEditBigTable', rows, rowsView);
700
621
  };
701
- // 绑定组件
702
622
 
703
- // #region 表头列处理
704
-
705
- // #endregion 表头列处理
706
-
707
- // #region 数据处理
708
- // 数据处理
623
+ this.getRows = function (rows) {
624
+ var _state7 = _this3.state,
625
+ filters = _state7.filters,
626
+ sortColumn = _state7.sortColumn,
627
+ sortDirection = _state7.sortDirection;
628
+ // 预处理数据,替换 null或undefined 值, 避免查询时报错
629
+
630
+ var cleanedRows = (rows || _this3.state.rows).map(function (row) {
631
+ var cleanedRow = {};
632
+ Object.keys(row).forEach(function (key) {
633
+ if (row[key] === null || row[key] === undefined) {
634
+ cleanedRow[key] = '';
635
+ } else if (key === sortColumn) {
636
+ cleanedRow[key] = _this3.checkNum(row[key]) ? Number(row[key]) : row[key] || ''; // 排序字段类型转换
637
+ } else {
638
+ cleanedRow[key] = row[key];
639
+ }
640
+ });
641
+ return cleanedRow;
642
+ });
643
+ return Selectors.getRows({ rows: cleanedRows, filters: filters, sortColumn: sortColumn, sortDirection: sortDirection });
644
+ };
709
645
 
710
- // 筛选
646
+ this.getSize = function () {
647
+ var rowsView = _this3.state.rowsView;
711
648
 
712
- // 排序
649
+ return rowsView.length;
650
+ };
713
651
 
714
- // 计算总计数据
652
+ this.rowGetter = function (rowIdx) {
653
+ var rowsView = _this3.state.rowsView;
654
+ // autoAddNumber_idx_view 自动添加序号 显示数据的索引
715
655
 
716
- // #endregion 数据处理
656
+ if (rowsView[rowIdx]) {
657
+ rowsView[rowIdx].autoAddNumber_idx_view = rowIdx + 1;
658
+ }
659
+ return rowsView[rowIdx];
660
+ };
717
661
 
718
- // #region state变更
719
- // 设置组件state
662
+ this.touchLoopDataNum = function (dataList) {
663
+ var arrDataList = [];
664
+ dataList.map(function (row, index) {
665
+ // autoAddNumber_idx_edit 自动添加序号 原始数据的索引
666
+ arrDataList.push((0, _extends3['default'])({}, row, { autoAddNumber_idx_edit: index }));
667
+ return row;
668
+ });
669
+ return arrDataList;
670
+ };
720
671
 
721
- // #endregion state变更
672
+ this.touchSetState = function (objState, callback) {
673
+ // objState 要设置的state对象
674
+ // callback 回调函数 非必须
675
+ if (callback && typeof callback === 'function') {
676
+ _this3.setState(objState, callback);
677
+ } else {
678
+ _this3.setState(objState);
679
+ }
680
+ };
722
681
 
723
- // #region 筛选
724
- // 切换筛选
682
+ this.touchLoopData = function () {
683
+ var rowsView = _this3.state.rowsView;
684
+
685
+ var objTotal = {}; // 总计对象
686
+ rowsView.map(function (row, index) {
687
+ _this3.columns.map(function (item, idx) {
688
+ var name = item.name,
689
+ key = item.key,
690
+ totalFlag = item.totalFlag,
691
+ numberFormat = item.numberFormat,
692
+ unit = item.unit;
693
+
694
+ if (totalFlag && typeof totalFlag === 'boolean') {
695
+ if (index === 0) {
696
+ objTotal[key] = {}; // 初始值
697
+ objTotal[key].name = name; // 初始值
698
+ objTotal[key].value = 0; // 初始值
699
+ objTotal[key].numberFormat = numberFormat; // 格式化
700
+ objTotal[key].unit = unit; // 格式化
701
+ }
702
+ var intData = Number(row[key]) || 0;
703
+ objTotal[key].value = (objTotal[key].value || 0) + intData;
704
+ }
705
+ return idx;
706
+ });
707
+ return index;
708
+ });
709
+ return objTotal;
710
+ };
725
711
 
726
- // 筛选条件变更
712
+ this.getHearder = function () {
713
+ var columns = _this3.props.columns;
714
+ var _props6 = _this3.props,
715
+ arrColumnsKey = _props6.arrColumnsKey,
716
+ objSheet = _props6.objSheet,
717
+ arrColInfo = _props6.arrColInfo;
718
+
719
+
720
+ var arrColumnsKeyNew = ['id'];
721
+ var objSheetNew = { id: 'id' };
722
+ // 定义列信息,隐藏第一列(A列)
723
+ var arrColInfoNew = [{ hidden: true }];
724
+ columns.forEach(function (column) {
725
+ var key = column.key,
726
+ name = column.name,
727
+ hiddeKeys = column.hiddeKeys;
728
+
729
+ objSheetNew[key] = name;
730
+ arrColumnsKeyNew.push(key);
731
+ arrColInfoNew.push({});
732
+ if (hiddeKeys) {
733
+ var arrHiddenKeys = hiddeKeys.split(',');
734
+ arrHiddenKeys.map(function (item) {
735
+ if (item === key) {
736
+ // 隐藏列与显示列相同,则不添加入表头
737
+ } else {
738
+ objSheetNew[item] = item;
739
+ arrColumnsKeyNew.push(item);
740
+ arrColInfoNew.push({
741
+ hidden: true
742
+ });
743
+ }
744
+ return item;
745
+ });
746
+ }
747
+ });
727
748
 
728
- // 清空筛选条件
749
+ return { arrColumnsKey: arrColumnsKey || arrColumnsKeyNew, objSheet: objSheet || objSheetNew, arrColInfo: arrColInfo || arrColInfoNew };
750
+ };
729
751
 
730
- // #endregion 筛选
752
+ this.onGridSort = function (sortColumn, sortDirection) {
753
+ _this3.setState({ sortColumn: sortColumn, sortDirection: sortDirection }, function () {
754
+ var rowsView = _this3.getRows();
755
+ _this3.touchSetState({ rowsView: rowsView });
756
+ });
757
+ };
731
758
 
732
- // #region 排序字段变化时触发
759
+ this.getValidFilterValues = function (columnId) {
760
+ var rows = _this3.state.rows;
761
+ var columns = _this3.props.columns;
733
762
 
734
- // #endregion 排序字段变化时触发
763
+ var column = columns.find(function (item) {
764
+ return item.key === columnId;
765
+ });
766
+ var options = column.options,
767
+ isTransformFlag = column.isTransformFlag;
735
768
 
736
- // #region toolbar处理
769
+ var values = [];
770
+ rows.map(function (r) {
771
+ if (r[columnId] === '' || r[columnId] === null || r[columnId] === undefined) {
772
+ return r;
773
+ } else {
774
+ values.push(r[columnId]);
775
+ return r;
776
+ }
777
+ });
778
+ var arrOptionsLabel = [];
779
+ var arrValues = values.filter(function (item, i, a) {
780
+ var flag = i === a.indexOf(item);
781
+ if (flag && isTransformFlag) {
782
+ var strLabel = '';
783
+ var isLabel = false;
784
+ options.map(function (option) {
785
+ if (option.value === item) {
786
+ strLabel = option.label;
787
+ isLabel = true;
788
+ }
789
+ return option;
790
+ });
791
+ arrOptionsLabel.push(isLabel ? strLabel : item);
792
+ }
793
+ return flag;
794
+ });
795
+ // arrOptionsLabel label数组
796
+ // arrValues // value数组
797
+ return isTransformFlag ? arrOptionsLabel : arrValues;
798
+ };
737
799
 
738
- // #endregion toolbar处理
800
+ this.handleFilterChange = function (filter) {
801
+ var newFilters = (0, _extends3['default'])({}, _this3.state.filters);
802
+ if (filter.filterTerm) {
803
+ var filterTerm = filter.filterTerm,
804
+ column = filter.column;
805
+ var options = column.options,
806
+ isTransformFlag = column.isTransformFlag;
807
+
808
+ if (options instanceof Array && options.length > 0 && filterTerm instanceof Array && isTransformFlag) {
809
+ var arrFilterTerm = [];
810
+ filterTerm.map(function (item) {
811
+ var isFlag = false;
812
+ options.map(function (option) {
813
+ if (item.label === option.label) {
814
+ arrFilterTerm.push({ value: option.value, label: option.value });
815
+ isFlag = true;
816
+ }
817
+ return option;
818
+ });
819
+ if (!isFlag) {
820
+ arrFilterTerm.push((0, _extends3['default'])({}, item));
821
+ }
822
+ return item;
823
+ });
824
+ filter.filterTerm = arrFilterTerm;
825
+ filter.rawValue = arrFilterTerm;
826
+ }
827
+ newFilters[filter.column.key] = filter;
828
+ } else {
829
+ delete newFilters[filter.column.key];
830
+ }
831
+ _this3.setState({ filters: newFilters }, function () {
832
+ var rowsView = _this3.getRows();
833
+ _this3.touchSetState({ rowsView: rowsView });
834
+ });
835
+ };
739
836
 
740
- // #region 右上角按钮处理--toolbar
741
- // 新增
837
+ this.onClearFilters = function () {
838
+ // all filters removed
839
+ _this3.setState({ filters: {} }, function () {
840
+ var rowsView = _this3.getRows();
841
+ _this3.touchSetState({ rowsView: rowsView });
842
+ });
843
+ };
742
844
 
743
- // 复制
845
+ this.getToolbar = function () {
846
+ var objToolbarProps = _this3.props.objToolbarProps;
847
+ var addRowFlag = objToolbarProps.addRowFlag,
848
+ addRowButtonText = objToolbarProps.addRowButtonText,
849
+ touchAddRow = objToolbarProps.touchAddRow,
850
+ enableFilter = objToolbarProps.enableFilter,
851
+ filterRowsButtonText = objToolbarProps.filterRowsButtonText,
852
+ arrBtn = objToolbarProps.arrBtn,
853
+ batchFlag = objToolbarProps.batchFlag,
854
+ batchButtonText = objToolbarProps.batchButtonText,
855
+ showModalBatchEditBigTable = objToolbarProps.showModalBatchEditBigTable,
856
+ saveFlag = objToolbarProps.saveFlag,
857
+ saveButtonText = objToolbarProps.saveButtonText,
858
+ deleteFlag = objToolbarProps.deleteFlag,
859
+ deleteButtonText = objToolbarProps.deleteButtonText,
860
+ deleteRow = objToolbarProps.deleteRow,
861
+ importFlag = objToolbarProps.importFlag,
862
+ importButtonText = objToolbarProps.importButtonText,
863
+ touchImport = objToolbarProps.touchImport,
864
+ exportFlag = objToolbarProps.exportFlag,
865
+ exportButtonText = objToolbarProps.exportButtonText,
866
+ touchExport = objToolbarProps.touchExport;
867
+
868
+ var toolbarProps = {};
869
+ if (addRowFlag) {
870
+ // 新增按钮
871
+ toolbarProps.onAddRow = touchAddRow || _this3.touchAddRow;
872
+ toolbarProps.addRowButtonText = addRowButtonText || '新增';
873
+ } else if (enableFilter) {
874
+ // 筛选按钮
875
+ toolbarProps.enableFilter = enableFilter;
876
+ toolbarProps.filterRowsButtonText = filterRowsButtonText || '筛选';
877
+ }
878
+ var toolbar = _react2['default'].createElement(
879
+ _reactDataGridAddons.Toolbar,
880
+ (0, _extends3['default'])({}, toolbarProps, {
881
+ // 行数
882
+ numberOfRows: _this3.getSize()
883
+ }),
884
+ arrBtn && arrBtn.map(function (btn) {
885
+ return _react2['default'].createElement(
886
+ 'button',
887
+ { type: 'button', className: 'btn', onClick: btn.onClick },
888
+ btn.text
889
+ );
890
+ }),
891
+ batchFlag ? _react2['default'].createElement(
892
+ 'button',
893
+ { type: 'button', className: 'btn', onClick: showModalBatchEditBigTable || _this3.showModalBatchEditBigTable },
894
+ batchButtonText || '批量录入'
895
+ ) : '',
896
+ saveFlag ? _react2['default'].createElement(
897
+ 'button',
898
+ { type: 'button', className: 'btn', onClick: _this3.saveEditBigTableZJ },
899
+ saveButtonText || '保存'
900
+ ) : '',
901
+ deleteFlag ? _react2['default'].createElement(
902
+ 'button',
903
+ { type: 'button', className: 'btn', onClick: deleteRow || _this3.deleteRow },
904
+ deleteButtonText || '删除'
905
+ ) : '',
906
+ importFlag ? _react2['default'].createElement(
907
+ 'button',
908
+ { type: 'button', className: 'btn', onClick: touchImport || _this3.touchImport },
909
+ _react2['default'].createElement('input', { type: 'file', id: 'touchImportExcel', accept: '.xlsx, .xls', style: { display: 'none' } }),
910
+ importButtonText || '导入'
911
+ ) : '',
912
+ exportFlag ? _react2['default'].createElement(
913
+ 'button',
914
+ { type: 'button', className: 'btn', onClick: touchExport || _this3.touchExport },
915
+ exportButtonText || '导出'
916
+ ) : ''
917
+ );
918
+ return toolbar;
919
+ };
744
920
 
745
- // 删除
921
+ this.onCheckCellIsEditable = function (obj) {
922
+ var column = obj.column;
923
+ // column:当前列的信息。
924
+ // idx:当前单元格的索引。
925
+ // row:当前行的数据。
926
+ // rowIdx:当前行的索引
927
+
928
+ var editable = column.editable,
929
+ editor = column.editor,
930
+ onCheckCellIsEditable = column.onCheckCellIsEditable;
931
+
932
+ var editableFlag = false; // 单元格是否可编辑 true 允许编辑 false 禁止编辑
933
+ if (editable || editor) {
934
+ // 单元格可编辑
935
+ editableFlag = true;
936
+ if (onCheckCellIsEditable && typeof onCheckCellIsEditable === 'function') {
937
+ editableFlag = onCheckCellIsEditable(obj); // 自定义单元格是否可编辑
938
+ }
939
+ } else {
940
+ editableFlag = false;
941
+ }
942
+ return editableFlag;
943
+ };
746
944
 
747
- // 导入导出表头
945
+ this.touchRowRenderer = function (obj) {
946
+ var _props7 = _this3.props,
947
+ onCheckCellIsEditable = _props7.onCheckCellIsEditable,
948
+ touchSetRowClass = _props7.touchSetRowClass,
949
+ touchSetRowStyle = _props7.touchSetRowStyle;
950
+ var renderBaseRow = obj.renderBaseRow,
951
+ columns = obj.columns,
952
+ row = obj.row,
953
+ idx = obj.idx;
954
+
955
+ var onCheckCellIsEditableNew = onCheckCellIsEditable || _this3.onCheckCellIsEditable;
956
+ var columnsNew = [];
957
+ // 单元格样式
958
+ columns.map(function (column, index) {
959
+ var touchSetCellClass = column.touchSetCellClass;
960
+
961
+ var cellClass = column.cellClass || '';
962
+
963
+ // 单元格样式
964
+ if (touchSetCellClass && typeof touchSetCellClass === 'function') {
965
+ cellClass += touchSetCellClass({ column: column, idx: idx, row: row, columnIndex: index });
966
+ }
967
+ // 编辑单元格样式
968
+ if (onCheckCellIsEditableNew({ column: column, idx: idx, row: row })) {
969
+ cellClass += 'custom-edit-cell'; // 编辑单元格样式
970
+ }
971
+ columnsNew.push((0, _extends3['default'])({}, column, { cellClass: cellClass }));
972
+ return column;
973
+ });
974
+ // 行样式-行class
975
+ var rowClass = '';
976
+ if (touchSetRowClass && typeof touchSetRowClass === 'function') {
977
+ rowClass = touchSetRowClass({ row: row, idx: idx, obj: obj });
978
+ }
979
+ // 行样式-行style
980
+ var rowStyle = {};
981
+ if (touchSetRowStyle && typeof touchSetRowStyle === 'function') {
982
+ rowStyle = touchSetRowStyle({ row: row, idx: idx, obj: obj });
983
+ }
748
984
 
749
- // 导入--数据
985
+ return _react2['default'].createElement(
986
+ 'span',
987
+ { className: rowClass, style: rowStyle },
988
+ renderBaseRow((0, _extends3['default'])({}, obj, {
989
+ columns: [].concat(columnsNew)
990
+ }))
991
+ );
992
+ };
750
993
 
751
- // 导出--数据
994
+ this.getReactDataGridProps = function () {
995
+ var arrValues = _this3.state.arrValues;
996
+ var _props8 = _this3.props,
997
+ enableCellSelect = _props8.enableCellSelect,
998
+ rowKey = _props8.rowKey,
999
+ objToolbarProps = _props8.objToolbarProps,
1000
+ rowSelection = _props8.rowSelection,
1001
+ onCheckCellIsEditable = _props8.onCheckCellIsEditable,
1002
+ touchRowRenderer = _props8.touchRowRenderer;
1003
+
1004
+ var objReactDataGridProps = {}; // ReactDataGrid属性对象
1005
+ // toolbar属性
1006
+ if (objToolbarProps) {
1007
+ var enableFilter = objToolbarProps.enableFilter;
1008
+
1009
+ objReactDataGridProps.toolbar = _this3.getToolbar();
1010
+ if (enableFilter) {
1011
+ objReactDataGridProps.onAddFilter = _this3.handleFilterChange;
1012
+ objReactDataGridProps.getValidFilterValues = _this3.getValidFilterValues;
1013
+ objReactDataGridProps.onClearFilters = _this3.onClearFilters;
1014
+ }
1015
+ }
1016
+ // 单元格选择
1017
+ if (enableCellSelect && typeof enableCellSelect === 'boolean') {
1018
+ objReactDataGridProps.enableCellSelect = enableCellSelect;
1019
+ objReactDataGridProps.onGridRowsUpdated = _this3.onGridRowsUpdated; // 表格编辑
1020
+ objReactDataGridProps.onCheckCellIsEditable = onCheckCellIsEditable || _this3.onCheckCellIsEditable; // 单元格是否可编辑
1021
+ // if (onCheckCellIsEditable) {
1022
+ // }
1023
+ objReactDataGridProps.rowRenderer = touchRowRenderer || _this3.touchRowRenderer; // 表格行渲染
1024
+ }
1025
+ // 表格行选择
1026
+ if (rowSelection && typeof rowSelection === 'boolean') {
1027
+ objReactDataGridProps.rowSelection = { // 表格选择
1028
+ showCheckbox: true,
1029
+ enableShiftSelect: true,
1030
+ onRowsSelected: _this3.onRowsSelected,
1031
+ onRowsDeselected: _this3.onRowsDeselected,
1032
+ selectBy: {
1033
+ keys: {
1034
+ rowKey: rowKey,
1035
+ values: arrValues
1036
+ }
1037
+ // indexes: this.state.arrValues,
1038
+ }
1039
+ };
1040
+ } else if (rowSelection) {
1041
+ objReactDataGridProps.rowSelection = rowSelection;
1042
+ }
752
1043
 
753
- // 批量录入--显示批量录入Modal
1044
+ return objReactDataGridProps;
1045
+ };
754
1046
 
755
- // 批量录入--隐藏批量录入Modal
1047
+ this.createColumns = function () {
1048
+ var _props9 = _this3.props,
1049
+ autoAddNumber = _props9.autoAddNumber,
1050
+ columns = _props9.columns;
1051
+ // 自动添加序号
756
1052
 
757
- // 批量录入--确认回调 ---待完善
1053
+ var columnsNew = [].concat(columns);
1054
+ if (autoAddNumber && typeof autoAddNumber === 'boolean') {
1055
+ var objColumns = columns && columns.length > 0 ? columns[0] : {};
1056
+ var _objColumns$frozen = objColumns.frozen,
1057
+ frozen = _objColumns$frozen === undefined ? false : _objColumns$frozen;
758
1058
 
759
- // #endregion 右上角按钮处理--toolbar
1059
+ columnsNew = [{ name: '序号', key: 'autoAddNumber_idx_view', resizable: true, width: 50, frozen: frozen }].concat(columnsNew);
1060
+ }
1061
+ _this3.columns = columnsNew;
1062
+ return columnsNew;
1063
+ };
760
1064
 
761
- // #region 保存
762
- // 保存表格数据-存model onGridRowsUpdated --> saveEditBigTableModel
1065
+ this.onGridRowsUpdatedZJ = function (operationType, rows, rowsView) {
1066
+ var onGridRowsUpdated = _this3.props.onGridRowsUpdated;
763
1067
 
764
- // 保存表格数据-存后端
1068
+ if (onGridRowsUpdated && typeof onGridRowsUpdated === 'function') {
1069
+ // 数据变更-回调函数
1070
+ onGridRowsUpdated(operationType, rows);
1071
+ _this3.touchSetState({
1072
+ rows: rows, // 表格数据
1073
+ rowsView: rowsView, // 表格视图数据
1074
+ saveFlag: false // 保存标识 true 已保存 false 未保存
1075
+ });
1076
+ }
1077
+ };
765
1078
 
766
- // 设置保存标识
1079
+ this.saveEditBigTableZJ = function () {
1080
+ var objToolbarProps = _this3.props.objToolbarProps;
767
1081
 
768
- // #endregion 保存
1082
+ var _ref2 = objToolbarProps || {},
1083
+ saveEditBigTable = _ref2.saveEditBigTable;
769
1084
 
770
- // #region 表单数据编辑
1085
+ if (saveEditBigTable && typeof saveEditBigTable === 'function') {
1086
+ // 数据变更-回调函数
1087
+ saveEditBigTable('saveEditBigTableZJ', function () {
1088
+ return _this3.touchSetState({ saveFlag: true });
1089
+ });
1090
+ }
1091
+ };
771
1092
 
772
- // #endregion 表单数据编辑
1093
+ this.touchSetSaveFlag = function (saveFlag) {
1094
+ _this3.setState({
1095
+ saveFlag: saveFlag // 保存标识 true 已保存 false 未保存
1096
+ });
1097
+ };
773
1098
 
774
- // #region 行选择
1099
+ this.checkReactDataGridData = function () {
1100
+ var clearFiltersFlag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
775
1101
 
1102
+ if (clearFiltersFlag) {
1103
+ _this3.onClearFilters(); // 清空筛选条件
1104
+ }
1105
+ _this3.checkData(); // 校验数据
1106
+ };
776
1107
 
777
- // #endregion 行选择
1108
+ this.checkData = function () {
1109
+ var rows = _this3.state.rows;
1110
+ var columns = _this3.props.columns;
778
1111
 
779
- //
1112
+ var strCheckFailRows = ''; // 校验失败的行号
1113
+ var arrRequiredMessage = []; // 必填提示信息
1114
+ rows.forEach(function (row, rowIndex) {
1115
+ var boolcheckFailFlag = false; // 校验失败标识
1116
+ columns.forEach(function (column, columnIndex) {
1117
+ var key = column.key,
1118
+ strName = column.strName,
1119
+ name = column.name;
780
1120
 
781
- Easy3wEditBigTable.prototype.render = function render() {
782
- var _this2 = this;
1121
+ var editable = _this3.onCheckCellIsEditable({ column: column, idx: columnIndex, row: row, rowIdx: rowIndex });
1122
+ if (editable) {
1123
+ // 编辑的单元格
1124
+ var required = column.required;
783
1125
 
784
- var _state = this.state,
785
- visible = _state.visible,
786
- objFilters = _state.objFilters,
787
- sortColumns = _state.sortColumns,
788
- selectedRows = _state.selectedRows;
789
- var _props = this.props,
790
- columns = _props.columns,
791
- objToolbarProps = _props.objToolbarProps,
792
- rowKey = _props.rowKey,
793
- topTotalFlag = _props.topTotalFlag,
794
- bottomTotalFlag = _props.bottomTotalFlag,
795
- objOtherProps = _props.objOtherProps;
796
- // #region 表格数据处理,排序(sort)、筛选(filter)
797
-
798
- this.arrRows = this.touchDP();
799
- var objPrps = {};
800
- // #region 总计行
801
- if (topTotalFlag || bottomTotalFlag) {
802
- this.objTotal = {}; // 总计对象
803
- var arrTotalRows = [this.touchCountTotal(this.arrRows, columns)];
804
- if (topTotalFlag) {
805
- objPrps.topSummaryRows = arrTotalRows;
806
- }
807
- if (bottomTotalFlag) {
808
- objPrps.bottomSummaryRows = arrTotalRows;
1126
+ if (required && typeof required === 'function') {
1127
+ required = required({ row: row, rowIndex: rowIndex, column: column, columnIndex: columnIndex });
1128
+ }
1129
+ // key 字段
1130
+ // required 必填
1131
+ // strName 字串名称
1132
+ // name 字段名称
1133
+ if (required && !row[key]) {
1134
+ boolcheckFailFlag = true;
1135
+ var strRequiredMessage = '\u8BF7\u5F55\u5165\u7B2C' + (rowIndex + 1) + '\u884C\u7684' + (strName || name) + ';';
1136
+ arrRequiredMessage.push(strRequiredMessage);
1137
+ }
1138
+ }
1139
+ });
1140
+ if (boolcheckFailFlag) {
1141
+ if (strCheckFailRows) {
1142
+ strCheckFailRows += ',' + (rowIndex + 1);
1143
+ } else {
1144
+ strCheckFailRows = '' + (rowIndex + 1);
1145
+ }
809
1146
  }
1147
+ });
1148
+ if (strCheckFailRows) {
1149
+ // 校验失败
1150
+ _modal2['default'].error({
1151
+ title: '校验失败',
1152
+ content: _react2['default'].createElement(
1153
+ 'div',
1154
+ null,
1155
+ arrRequiredMessage.map(function (item, index) {
1156
+ return index === 0 ? _react2['default'].createElement(
1157
+ 'span',
1158
+ null,
1159
+ item
1160
+ ) : _react2['default'].createElement(
1161
+ 'span',
1162
+ null,
1163
+ _react2['default'].createElement('br', null),
1164
+ item
1165
+ );
1166
+ })
1167
+ )
1168
+ });
1169
+ console.error(arrRequiredMessage, strCheckFailRows);
810
1170
  }
811
- // #endregion 总计行
812
- return _react2['default'].createElement(
813
- 'div',
814
- { className: (0, _classnames2['default'])(['Easy3wEditBigTable']) },
815
- objToolbarProps ? this.getToolbar() : '',
816
- _react2['default'].createElement(_reactDataGrid2['default'], (0, _extends5['default'])({}, objPrps, {
817
- columns: this.touchCreateColumns(columns) // 表头
818
- , defaultColumnOptions: {
819
- resizable: true // 可调整列宽
820
- },
821
- rows: this.arrRows // 行数据
822
- , headerRowHeight: objFilters.enabled ? 70 : undefined // 表头高度
823
- // 排序
824
- , sortColumns: sortColumns // 排序字段
825
- , onSortColumnsChange: this.touchSortColumnsChange // 排序字段变化时触发
826
- // 行选择
827
- , rowKeyGetter: function rowKeyGetter(row) {
828
- return row[rowKey];
829
- },
830
- selectedRows: selectedRows,
831
- onSelectedRowsChange: this.touchSelectedRowsChange
832
- // 表格编辑时触发
833
- , onRowsChange: this.touchRowsChange
834
- // 其它属性
835
- }, objOtherProps)),
836
- visible ? _react2['default'].createElement(_Easy3wEditBigTableForm2['default'] // 批量录入Modal
837
- , { visible: visible // 是否显示
838
- , objOtherParameters: {
839
- columns: columns // 表头
840
- } // 其他参数
841
- , bidPureComponent: function bidPureComponent(that) {
842
- return _this2.bidPureComponent('Easy3wEditBigTableForm', that);
843
- } // 绑定组件
844
- , confirmCallback: this.confirmCallbackBatchEditBigTable,
845
- hideModal: this.hideModalBatchEditBigTable
846
- }) : ''
847
- );
1171
+ return { arrRequiredMessage: arrRequiredMessage, strCheckFailRows: strCheckFailRows };
848
1172
  };
849
1173
 
850
- return Easy3wEditBigTable;
851
- }(_react.Component); /* eslint-disable no-param-reassign */
852
- /* eslint-disable no-alert */
853
-
1174
+ this.touchFormatNum = function (num) {
1175
+ return _this3.checkNum(num) ? (0, _numeral2['default'])(num).format('0,0.00') : num || '';
1176
+ };
854
1177
 
855
- Easy3wEditBigTable.defaultProps = {
856
- rowKey: 'autoAddNumber_idx_edit' // 表格主键 原始数据索引
1178
+ this.checkNum = function (num) {
1179
+ return num !== '' && !isNaN(num) && isFinite(num);
1180
+ // return num !== '' && !isNaN(num) && isFinite(num) ? true : false;
1181
+ };
857
1182
  };
1183
+
858
1184
  exports['default'] = Easy3wEditBigTable;
859
1185
  module.exports = exports['default'];