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