easy3wui 1.5.55-beta1 → 1.5.55-beta10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Easy3wEditBigTable/index.js +173 -52
- package/lib/index.js +9 -0
- package/package.json +1 -1
|
@@ -48,12 +48,9 @@ var _Easy3wEditBigTableForm = require('./Easy3wEditBigTableForm');
|
|
|
48
48
|
|
|
49
49
|
var _Easy3wEditBigTableForm2 = _interopRequireDefault(_Easy3wEditBigTableForm);
|
|
50
50
|
|
|
51
|
-
var _lodash = require('lodash');
|
|
52
|
-
|
|
53
51
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
54
52
|
|
|
55
|
-
/* eslint-disable no-alert */
|
|
56
|
-
var Selectors = _reactDataGridAddons.Data.Selectors;
|
|
53
|
+
var Selectors = _reactDataGridAddons.Data.Selectors; /* eslint-disable no-alert */
|
|
57
54
|
|
|
58
55
|
var Easy3wEditBigTable = function (_Component) {
|
|
59
56
|
(0, _inherits3['default'])(Easy3wEditBigTable, _Component);
|
|
@@ -74,8 +71,7 @@ var Easy3wEditBigTable = function (_Component) {
|
|
|
74
71
|
};
|
|
75
72
|
|
|
76
73
|
_this.onGridRowsUpdated = function (objUpdated) {
|
|
77
|
-
var
|
|
78
|
-
fromRowData = objUpdated.fromRowData;
|
|
74
|
+
var fromRowData = objUpdated.fromRowData;
|
|
79
75
|
var updated = objUpdated.updated;
|
|
80
76
|
var _this$props = _this.props,
|
|
81
77
|
touchAutoCompute = _this$props.touchAutoCompute,
|
|
@@ -86,7 +82,6 @@ var Easy3wEditBigTable = function (_Component) {
|
|
|
86
82
|
// 数据变更-自动计算行数据
|
|
87
83
|
updated = touchAutoCompute(objUpdated);
|
|
88
84
|
}
|
|
89
|
-
console.log('onGridRowsUpdated', objUpdated, updated);
|
|
90
85
|
var autoAddNumberIdxEdit = fromRowData.autoAddNumber_idx_edit;
|
|
91
86
|
|
|
92
87
|
dataList[autoAddNumberIdxEdit] = (0, _extends3['default'])({}, fromRowData, updated);
|
|
@@ -101,22 +96,53 @@ var Easy3wEditBigTable = function (_Component) {
|
|
|
101
96
|
};
|
|
102
97
|
|
|
103
98
|
_this.onRowsSelected = function (rows) {
|
|
104
|
-
_this.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
99
|
+
var _this$state = _this.state,
|
|
100
|
+
arrValues = _this$state.arrValues,
|
|
101
|
+
arrValuesInfo = _this$state.arrValuesInfo;
|
|
102
|
+
var rowKey = _this.props.rowKey;
|
|
103
|
+
|
|
104
|
+
var arrValuesNew = []; // 表格选择行索引
|
|
105
|
+
var arrValuesInfoNew = []; // 表格选择行数据
|
|
106
|
+
rows.map(function (r) {
|
|
107
|
+
arrValuesNew.push(r.row[rowKey]);
|
|
108
|
+
arrValuesInfoNew.push(r.row);
|
|
109
|
+
return r;
|
|
108
110
|
});
|
|
111
|
+
arrValues = arrValues.concat(arrValuesNew); // 表格选择行索引
|
|
112
|
+
arrValuesInfo = arrValuesInfo.concat(arrValuesInfoNew); // 表格选择行数据
|
|
113
|
+
_this.onSelectedRowsChange(arrValues, arrValuesInfo);
|
|
109
114
|
};
|
|
110
115
|
|
|
111
116
|
_this.onRowsDeselected = function (rows) {
|
|
112
|
-
var
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
_this.
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
var _this$state2 = _this.state,
|
|
118
|
+
arrValues = _this$state2.arrValues,
|
|
119
|
+
arrValuesInfo = _this$state2.arrValuesInfo;
|
|
120
|
+
var rowKey = _this.props.rowKey;
|
|
121
|
+
|
|
122
|
+
var arrValuesNew = []; // 表格选择行索引
|
|
123
|
+
var arrValuesInfoNew = []; // 表格选择行数据
|
|
124
|
+
arrValuesInfo.filter(function (item) {
|
|
125
|
+
var flag = true;
|
|
126
|
+
rows.map(function (r) {
|
|
127
|
+
var row = r.row;
|
|
128
|
+
|
|
129
|
+
if (item[rowKey] === row[rowKey]) {
|
|
130
|
+
// 删除已取消选择的行
|
|
131
|
+
flag = false;
|
|
132
|
+
}
|
|
133
|
+
return r;
|
|
134
|
+
});
|
|
135
|
+
if (flag) {
|
|
136
|
+
arrValuesNew.push(item[rowKey]);
|
|
137
|
+
arrValuesInfoNew.push(item);
|
|
138
|
+
}
|
|
139
|
+
return flag;
|
|
119
140
|
});
|
|
141
|
+
_this.onSelectedRowsChange(arrValues, arrValuesInfo);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
_this.onSelectedRowsChange = function (arrValues, arrValuesInfo) {
|
|
145
|
+
_this.setState({ arrValues: arrValues, arrValuesInfo: arrValuesInfo });
|
|
120
146
|
};
|
|
121
147
|
|
|
122
148
|
_this.touchAddRow = function () {
|
|
@@ -135,14 +161,14 @@ var Easy3wEditBigTable = function (_Component) {
|
|
|
135
161
|
var _this$props3 = _this.props,
|
|
136
162
|
onGridRowsUpdated = _this$props3.onGridRowsUpdated,
|
|
137
163
|
dataList = _this$props3.dataList;
|
|
138
|
-
var
|
|
164
|
+
var arrValues = _this.state.arrValues;
|
|
139
165
|
|
|
140
|
-
if (
|
|
166
|
+
if (arrValues.length) {
|
|
141
167
|
var newArr = []; // 复制的新数组
|
|
142
|
-
|
|
143
|
-
var newRow = (0, _extends3['default'])({}, dataList[
|
|
168
|
+
arrValues.forEach(function (key) {
|
|
169
|
+
var newRow = (0, _extends3['default'])({}, dataList[key]);
|
|
144
170
|
newArr.push(newRow);
|
|
145
|
-
return
|
|
171
|
+
return key;
|
|
146
172
|
});
|
|
147
173
|
var dataListNew = [].concat(dataList, newArr);
|
|
148
174
|
if (onGridRowsUpdated && typeof onGridRowsUpdated === 'function') {
|
|
@@ -160,21 +186,36 @@ var Easy3wEditBigTable = function (_Component) {
|
|
|
160
186
|
_this.deleteRow = function () {
|
|
161
187
|
var _this$props4 = _this.props,
|
|
162
188
|
dataList = _this$props4.dataList,
|
|
163
|
-
onGridRowsUpdated = _this$props4.onGridRowsUpdated
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
189
|
+
onGridRowsUpdated = _this$props4.onGridRowsUpdated,
|
|
190
|
+
objToolbarProps = _this$props4.objToolbarProps,
|
|
191
|
+
rowKey = _this$props4.rowKey;
|
|
192
|
+
var deleteRowInterface = objToolbarProps.deleteRowInterface;
|
|
193
|
+
var arrValues = _this.state.arrValues;
|
|
194
|
+
|
|
195
|
+
if (arrValues.length) {
|
|
196
|
+
// const dataListNew = []; // 删除选择行后的新数组
|
|
197
|
+
var dataListDel = []; // 要删除的行数组
|
|
198
|
+
var dataListNew = dataList.filter(function (row) {
|
|
199
|
+
var flag = true;
|
|
200
|
+
arrValues.map(function (key) {
|
|
201
|
+
if (key === row[rowKey]) {
|
|
202
|
+
dataListDel.push(row);
|
|
203
|
+
// 删除选择的行
|
|
204
|
+
flag = false;
|
|
205
|
+
}
|
|
206
|
+
return key;
|
|
207
|
+
});
|
|
208
|
+
return flag;
|
|
173
209
|
});
|
|
210
|
+
if (deleteRowInterface && typeof deleteRowInterface === 'function') {
|
|
211
|
+
// 删除行接口
|
|
212
|
+
deleteRowInterface(dataListDel, arrValues);
|
|
213
|
+
}
|
|
174
214
|
if (onGridRowsUpdated && typeof onGridRowsUpdated === 'function') {
|
|
175
215
|
// 数据变更-回调函数
|
|
176
216
|
onGridRowsUpdated('deleteRow', dataListNew);
|
|
177
217
|
}
|
|
218
|
+
_this.onSelectedRowsChange([], []); // 选择行清空
|
|
178
219
|
} else {
|
|
179
220
|
_modal2['default'].error({
|
|
180
221
|
title: '错误',
|
|
@@ -258,7 +299,8 @@ var Easy3wEditBigTable = function (_Component) {
|
|
|
258
299
|
var _this$props5 = _this.props,
|
|
259
300
|
touchAutoCompute = _this$props5.touchAutoCompute,
|
|
260
301
|
onGridRowsUpdated = _this$props5.onGridRowsUpdated,
|
|
261
|
-
dataList = _this$props5.dataList
|
|
302
|
+
dataList = _this$props5.dataList,
|
|
303
|
+
rowKey = _this$props5.rowKey;
|
|
262
304
|
// if (touchAutoCompute && typeof touchAutoCompute === 'function') { // 数据变更-自动计算行数据
|
|
263
305
|
// updated = touchAutoCompute(objUpdated);
|
|
264
306
|
// }
|
|
@@ -280,8 +322,6 @@ var Easy3wEditBigTable = function (_Component) {
|
|
|
280
322
|
// toRow 改变的单元格的新行序号
|
|
281
323
|
// toRowId 改变的单元格的新行id
|
|
282
324
|
// updated 改变的单元格的新值
|
|
283
|
-
var rowKey = _this.ReactDataGridRef.props.rowKey;
|
|
284
|
-
|
|
285
325
|
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 });
|
|
286
326
|
}
|
|
287
327
|
dataList[autoAddNumberIdxEdit] = (0, _extends3['default'])({}, row, updated);
|
|
@@ -294,16 +334,17 @@ var Easy3wEditBigTable = function (_Component) {
|
|
|
294
334
|
};
|
|
295
335
|
|
|
296
336
|
_this.getRows = function () {
|
|
297
|
-
var _this$
|
|
298
|
-
filters = _this$
|
|
299
|
-
sortColumn = _this$
|
|
300
|
-
sortDirection = _this$
|
|
337
|
+
var _this$state3 = _this.state,
|
|
338
|
+
filters = _this$state3.filters,
|
|
339
|
+
sortColumn = _this$state3.sortColumn,
|
|
340
|
+
sortDirection = _this$state3.sortDirection;
|
|
301
341
|
var _this$props6 = _this.props,
|
|
302
342
|
dataList = _this$props6.dataList,
|
|
303
|
-
enableCellSelect = _this$props6.enableCellSelect
|
|
343
|
+
enableCellSelect = _this$props6.enableCellSelect,
|
|
344
|
+
rowSelection = _this$props6.rowSelection;
|
|
304
345
|
|
|
305
346
|
var rows = dataList;
|
|
306
|
-
if (enableCellSelect) {
|
|
347
|
+
if (enableCellSelect || rowSelection) {
|
|
307
348
|
rows = _this.touchLoopDataBefore();
|
|
308
349
|
}
|
|
309
350
|
return Selectors.getRows({ rows: rows, filters: filters, sortColumn: sortColumn, sortDirection: sortDirection });
|
|
@@ -322,11 +363,12 @@ var Easy3wEditBigTable = function (_Component) {
|
|
|
322
363
|
_this.touchLoopDataBefore = function () {
|
|
323
364
|
var dataList = _this.props.dataList;
|
|
324
365
|
|
|
325
|
-
|
|
366
|
+
dataList.map(function (row, index) {
|
|
326
367
|
// autoAddNumber_idx_edit 自动添加序号 数据更新时使用确定当前更新的行
|
|
327
|
-
|
|
368
|
+
dataList[index] = (0, _extends3['default'])({}, row, { autoAddNumber_idx_edit: index });
|
|
369
|
+
return row;
|
|
328
370
|
});
|
|
329
|
-
return
|
|
371
|
+
return dataList;
|
|
330
372
|
};
|
|
331
373
|
|
|
332
374
|
_this.touchLoopData = function () {
|
|
@@ -488,11 +530,63 @@ var Easy3wEditBigTable = function (_Component) {
|
|
|
488
530
|
return toolbar;
|
|
489
531
|
};
|
|
490
532
|
|
|
533
|
+
_this.onCheckCellIsEditable = function (obj) {
|
|
534
|
+
var column = obj.column;
|
|
535
|
+
// column:当前列的信息。
|
|
536
|
+
// idx:当前单元格的索引。
|
|
537
|
+
// row:当前行的数据。
|
|
538
|
+
// rowIdx:当前行的索引
|
|
539
|
+
|
|
540
|
+
var editable = column.editable,
|
|
541
|
+
editor = column.editor,
|
|
542
|
+
onCheckCellIsEditable = column.onCheckCellIsEditable;
|
|
543
|
+
|
|
544
|
+
var editableFlag = false; // 单元格是否可编辑 true 允许编辑 false 禁止编辑
|
|
545
|
+
if (editable || editor) {
|
|
546
|
+
// 单元格可编辑
|
|
547
|
+
editableFlag = true;
|
|
548
|
+
if (onCheckCellIsEditable && typeof onCheckCellIsEditable === 'function') {
|
|
549
|
+
editableFlag = onCheckCellIsEditable(obj); // 自定义单元格是否可编辑
|
|
550
|
+
}
|
|
551
|
+
} else {
|
|
552
|
+
editableFlag = false;
|
|
553
|
+
}
|
|
554
|
+
return editableFlag;
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
_this.touchRowRenderer = function (obj) {
|
|
558
|
+
var onCheckCellIsEditable = _this.props.onCheckCellIsEditable;
|
|
559
|
+
var renderBaseRow = obj.renderBaseRow,
|
|
560
|
+
columns = obj.columns,
|
|
561
|
+
row = obj.row,
|
|
562
|
+
idx = obj.idx;
|
|
563
|
+
|
|
564
|
+
var onCheckCellIsEditableNew = onCheckCellIsEditable || _this.onCheckCellIsEditable;
|
|
565
|
+
var columnsNew = [].concat(columns);
|
|
566
|
+
columns.map(function (column, index) {
|
|
567
|
+
if (onCheckCellIsEditableNew({ column: column, idx: idx, row: row })) {
|
|
568
|
+
columnsNew[index] = (0, _extends3['default'])({}, column, { cellClass: (column.cellClass || '') + ' custom-edit-cell' });
|
|
569
|
+
}
|
|
570
|
+
return column;
|
|
571
|
+
});
|
|
572
|
+
return _react2['default'].createElement(
|
|
573
|
+
'span',
|
|
574
|
+
null,
|
|
575
|
+
renderBaseRow((0, _extends3['default'])({}, obj, {
|
|
576
|
+
columns: [].concat(columnsNew)
|
|
577
|
+
}))
|
|
578
|
+
);
|
|
579
|
+
};
|
|
580
|
+
|
|
491
581
|
_this.getReactDataGridProps = function () {
|
|
582
|
+
var arrValues = _this.state.arrValues;
|
|
492
583
|
var _this$props8 = _this.props,
|
|
493
584
|
enableCellSelect = _this$props8.enableCellSelect,
|
|
585
|
+
rowKey = _this$props8.rowKey,
|
|
494
586
|
objToolbarProps = _this$props8.objToolbarProps,
|
|
495
|
-
rowSelection = _this$props8.rowSelection
|
|
587
|
+
rowSelection = _this$props8.rowSelection,
|
|
588
|
+
onCheckCellIsEditable = _this$props8.onCheckCellIsEditable,
|
|
589
|
+
touchRowRenderer = _this$props8.touchRowRenderer;
|
|
496
590
|
|
|
497
591
|
var objReactDataGridProps = {}; // ReactDataGrid属性对象
|
|
498
592
|
// toolbar属性
|
|
@@ -509,6 +603,10 @@ var Easy3wEditBigTable = function (_Component) {
|
|
|
509
603
|
if (enableCellSelect && typeof enableCellSelect === 'boolean') {
|
|
510
604
|
objReactDataGridProps.enableCellSelect = enableCellSelect;
|
|
511
605
|
objReactDataGridProps.onGridRowsUpdated = _this.onGridRowsUpdated; // 表格编辑
|
|
606
|
+
objReactDataGridProps.onCheckCellIsEditable = onCheckCellIsEditable || _this.onCheckCellIsEditable; // 单元格是否可编辑
|
|
607
|
+
// if (onCheckCellIsEditable) {
|
|
608
|
+
// }
|
|
609
|
+
objReactDataGridProps.rowRenderer = touchRowRenderer || _this.touchRowRenderer; // 表格行渲染
|
|
512
610
|
}
|
|
513
611
|
// 表格行选择
|
|
514
612
|
if (rowSelection && typeof rowSelection === 'boolean') {
|
|
@@ -518,8 +616,11 @@ var Easy3wEditBigTable = function (_Component) {
|
|
|
518
616
|
onRowsSelected: _this.onRowsSelected,
|
|
519
617
|
onRowsDeselected: _this.onRowsDeselected,
|
|
520
618
|
selectBy: {
|
|
521
|
-
|
|
522
|
-
|
|
619
|
+
keys: {
|
|
620
|
+
rowKey: rowKey || 'id',
|
|
621
|
+
values: arrValues
|
|
622
|
+
}
|
|
623
|
+
// indexes: this.state.arrValues,
|
|
523
624
|
}
|
|
524
625
|
};
|
|
525
626
|
} else if (rowSelection) {
|
|
@@ -537,7 +638,11 @@ var Easy3wEditBigTable = function (_Component) {
|
|
|
537
638
|
|
|
538
639
|
var columnsNew = [].concat(columns);
|
|
539
640
|
if (autoAddNumber && typeof autoAddNumber === 'boolean') {
|
|
540
|
-
|
|
641
|
+
var objColumns = columns && columns.length > 0 ? columns[0] : {};
|
|
642
|
+
var _objColumns$frozen = objColumns.frozen,
|
|
643
|
+
frozen = _objColumns$frozen === undefined ? false : _objColumns$frozen;
|
|
644
|
+
|
|
645
|
+
columnsNew = [{ name: '序号', key: 'autoAddNumber_idx_view', resizable: true, width: 50, frozen: frozen }].concat(columnsNew);
|
|
541
646
|
}
|
|
542
647
|
_this.columns = columnsNew;
|
|
543
648
|
return columnsNew;
|
|
@@ -619,7 +724,8 @@ var Easy3wEditBigTable = function (_Component) {
|
|
|
619
724
|
}
|
|
620
725
|
_this.state = {
|
|
621
726
|
// 表格选择
|
|
622
|
-
|
|
727
|
+
arrValues: [], // 表格选择行索引
|
|
728
|
+
arrValuesInfo: [], // 表格选择行数据
|
|
623
729
|
// 查询条件
|
|
624
730
|
filters: {},
|
|
625
731
|
// 排序--sort
|
|
@@ -647,6 +753,8 @@ var Easy3wEditBigTable = function (_Component) {
|
|
|
647
753
|
|
|
648
754
|
// 表格选择---取消选择
|
|
649
755
|
|
|
756
|
+
// 改变选择状态
|
|
757
|
+
|
|
650
758
|
// #endregion 表格选择
|
|
651
759
|
// #region 右上角按钮处理--toolbar
|
|
652
760
|
// 新增
|
|
@@ -690,6 +798,9 @@ var Easy3wEditBigTable = function (_Component) {
|
|
|
690
798
|
|
|
691
799
|
// #endregion toolbar处理
|
|
692
800
|
// #region 设置ReactDataGrid属性
|
|
801
|
+
// 在单元格设置为活动状态之前调用,返回一个布尔值以确定单元格是否可编辑
|
|
802
|
+
|
|
803
|
+
// 表格行渲染
|
|
693
804
|
|
|
694
805
|
// 创建columns
|
|
695
806
|
|
|
@@ -710,7 +821,9 @@ var Easy3wEditBigTable = function (_Component) {
|
|
|
710
821
|
var _props = this.props,
|
|
711
822
|
totalFlag = _props.totalFlag,
|
|
712
823
|
objOtherProps = _props.objOtherProps,
|
|
713
|
-
objToolbarProps = _props.objToolbarProps
|
|
824
|
+
objToolbarProps = _props.objToolbarProps,
|
|
825
|
+
strReactDataGridStyle = _props.strReactDataGridStyle,
|
|
826
|
+
strAddReactDataGridStyle = _props.strAddReactDataGridStyle;
|
|
714
827
|
|
|
715
828
|
var objReactDataGridProps = this.getReactDataGridProps();
|
|
716
829
|
var columns = this.createColumns(); // 表头
|
|
@@ -718,7 +831,12 @@ var Easy3wEditBigTable = function (_Component) {
|
|
|
718
831
|
return _react2['default'].createElement(
|
|
719
832
|
'div',
|
|
720
833
|
{ style: { backgroundColor: '#fff' } },
|
|
721
|
-
_react2['default'].createElement(
|
|
834
|
+
_react2['default'].createElement(
|
|
835
|
+
'style',
|
|
836
|
+
null,
|
|
837
|
+
strReactDataGridStyle || (strAddReactDataGridStyle || '') + '\n .custom-edit-cell { \n background-color: #f6ffed;\n }\n '
|
|
838
|
+
),
|
|
839
|
+
_react2['default'].createElement(_reactDataGrid2['default'], (0, _extends3['default'])({}, this.props, {
|
|
722
840
|
ref: this.ReactDataGridRef,
|
|
723
841
|
columns: columns // 表头
|
|
724
842
|
// rows={rows}
|
|
@@ -765,5 +883,8 @@ var Easy3wEditBigTable = function (_Component) {
|
|
|
765
883
|
return Easy3wEditBigTable;
|
|
766
884
|
}(_react.Component);
|
|
767
885
|
|
|
886
|
+
Easy3wEditBigTable.defaultProps = {
|
|
887
|
+
rowKey: 'autoAddNumber_idx_edit'
|
|
888
|
+
};
|
|
768
889
|
exports['default'] = Easy3wEditBigTable;
|
|
769
890
|
module.exports = exports['default'];
|
package/lib/index.js
CHANGED
|
@@ -389,4 +389,13 @@ Object.defineProperty(exports, 'Easy3wGetDesensitization', {
|
|
|
389
389
|
}
|
|
390
390
|
});
|
|
391
391
|
|
|
392
|
+
var _Easy3wEditBigTable = require('./Easy3wEditBigTable');
|
|
393
|
+
|
|
394
|
+
Object.defineProperty(exports, 'Easy3wEditBigTable', {
|
|
395
|
+
enumerable: true,
|
|
396
|
+
get: function get() {
|
|
397
|
+
return _interopRequireDefault(_Easy3wEditBigTable)['default'];
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
|
|
392
401
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|