dlt-for-react 2.0.16 → 2.1.1

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.
@@ -0,0 +1,784 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _toConsumableArray2 = require("babel-runtime/helpers/toConsumableArray");
8
+
9
+ var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
10
+
11
+ var _table = require("antd/lib/table");
12
+
13
+ var _table2 = _interopRequireDefault(_table);
14
+
15
+ var _button = require("antd/lib/button");
16
+
17
+ var _button2 = _interopRequireDefault(_button);
18
+
19
+ var _input = require("antd/lib/input");
20
+
21
+ var _input2 = _interopRequireDefault(_input);
22
+
23
+ var _select = require("antd/lib/select");
24
+
25
+ var _select2 = _interopRequireDefault(_select);
26
+
27
+ var _typeof2 = require("babel-runtime/helpers/typeof");
28
+
29
+ var _typeof3 = _interopRequireDefault(_typeof2);
30
+
31
+ var _getPrototypeOf = require("babel-runtime/core-js/object/get-prototype-of");
32
+
33
+ var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
34
+
35
+ var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
36
+
37
+ var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
38
+
39
+ var _createClass2 = require("babel-runtime/helpers/createClass");
40
+
41
+ var _createClass3 = _interopRequireDefault(_createClass2);
42
+
43
+ var _possibleConstructorReturn2 = require("babel-runtime/helpers/possibleConstructorReturn");
44
+
45
+ var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
46
+
47
+ var _inherits2 = require("babel-runtime/helpers/inherits");
48
+
49
+ var _inherits3 = _interopRequireDefault(_inherits2);
50
+
51
+ require("antd/lib/table/style");
52
+
53
+ require("antd/lib/button/style");
54
+
55
+ require("antd/lib/input/style");
56
+
57
+ require("antd/lib/select/style");
58
+
59
+ var _react = require("react");
60
+
61
+ var _react2 = _interopRequireDefault(_react);
62
+
63
+ var _reactCustomScrollbarsPatched = require("react-custom-scrollbars-patched");
64
+
65
+ var _index = require("../../../index");
66
+
67
+ require("../../../../assets/selector/table/index.less");
68
+
69
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
70
+
71
+ var loadCount = 0;
72
+
73
+ // 精确搜索时的字段
74
+ var fieldList = [{ value: "xm_EQ", label: "姓名" }, { value: "xh_EQ", label: "学号" }];
75
+ var initPreciseSearchField = fieldList[0].value;
76
+
77
+ var SelectorTable = function (_React$Component) {
78
+ (0, _inherits3.default)(SelectorTable, _React$Component);
79
+
80
+ function SelectorTable(props) {
81
+ (0, _classCallCheck3.default)(this, SelectorTable);
82
+
83
+ var _this = (0, _possibleConstructorReturn3.default)(this, (SelectorTable.__proto__ || (0, _getPrototypeOf2.default)(SelectorTable)).call(this, props));
84
+
85
+ _initialiseProps.call(_this);
86
+
87
+ _this.state = {
88
+ columns: _this.props.columns,
89
+ searchParams: {}, //自定义的搜索条件
90
+ searchValue: undefined, // 搜索框的值
91
+ sorter: {}, //排序字段
92
+ selectedRows: [], //选中的数据
93
+ selectedRowKeys: [], //选中的数据的主键loading
94
+ loading: false,
95
+ data: [], //数据
96
+ pageData: {
97
+ //分页设置的是三个参数
98
+ total: 0,
99
+ pageSize: _this.props.footerFlag === false ? 10000000 : 20, //当前页默认多少条数据
100
+ page: 1
101
+ },
102
+ height: _this.props.height, //列表的高度
103
+ width: undefined, //列表的宽度
104
+ className: (0, _index.createUuid)(),
105
+ preciseSearchField: initPreciseSearchField // 列表可以进行精确查询的字段
106
+ };
107
+ return _this;
108
+ }
109
+
110
+ //在组件挂载之后调用一次。
111
+
112
+ //设置可以传递参数的默认值
113
+
114
+
115
+ (0, _createClass3.default)(SelectorTable, [{
116
+ key: "componentDidMount",
117
+ value: function componentDidMount() {
118
+ this.refreshHeight();
119
+ }
120
+ }, {
121
+ key: "componentDidUpdate",
122
+ value: function componentDidUpdate() {
123
+ this.refreshHeight();
124
+ }
125
+
126
+ //固定通用方法
127
+ //搜索操作
128
+
129
+ //重置操作
130
+
131
+
132
+ //重新加载数据数据的方法(从第一页开始)
133
+
134
+ //在当前页刷新数据
135
+
136
+
137
+ //当Table有变动的时候会触发此方法
138
+
139
+
140
+ /**
141
+ * 绑定查询条件值改变事件
142
+ */
143
+
144
+ /**
145
+ * 绑定查询条件值改变事件
146
+ */
147
+
148
+
149
+ /**
150
+ * 对选中的值进行操作
151
+ */
152
+
153
+ }, {
154
+ key: "render",
155
+ value: function render() {
156
+ var _this2 = this;
157
+
158
+ var _props = this.props,
159
+ safeMode = _props.safeMode,
160
+ placeholder = _props.placeholder;
161
+ var preciseSearchField = this.state.preciseSearchField;
162
+
163
+ function deepCopy(obj) {
164
+ if ((typeof obj === "undefined" ? "undefined" : (0, _typeof3.default)(obj)) !== "object") {
165
+ return obj;
166
+ }
167
+ var newobj = {};
168
+ for (var attr in obj) {
169
+ newobj[attr] = deepCopy(obj[attr]);
170
+ }
171
+ return newobj;
172
+ }
173
+ /****************************以下操作是初始化列的数据*********************************/
174
+ var columns = [];
175
+ var minWidthCount = 0; //最小宽度列(只有最小宽度这个参数)
176
+ var minAllWidth = 0; //最小宽度列宽度之和
177
+ var fieldAllWidth = 0; //除开序号列和参数列的宽度之和
178
+ this.state.columns.map(function (item1) {
179
+ var item = deepCopy(item1);
180
+ if (item.hidden !== true) {
181
+ if (!item.dataIndex && item.key) {
182
+ item.dataIndex = item.key;
183
+ }
184
+ if (!item.dataIndex) {
185
+ alert("dataIndex不能为空");
186
+ }
187
+ //dataIndex必须大写
188
+ item.dataIndex = item.dataIndex;
189
+ //列width或者minWidth必须至少设置一个
190
+ if (!item.width && !item.minWidth) {
191
+ alert("参数设置有误,width和minWidth必须设置一个!");
192
+ return item1;
193
+ }
194
+ //如果列的最小宽度不存在,则设置width为最小宽度
195
+ if (!item.minWidth) {
196
+ item.minWidth = item.width;
197
+ }
198
+ //项缓存冻结列的数据,因为当列的宽度总和小于列表宽度的时候不需要是使用冻结列的
199
+ if (item.fixed && item.fixed === "left") {
200
+ item.cacheFixed = "left";
201
+ } else if (item.fixed && item.fixed === "right") {
202
+ item.cacheFixed = "right";
203
+ }
204
+ delete item.fixed;
205
+ //获取一些数据给下面使用
206
+ if (item.dataIndex.toUpperCase() !== "ROW_ID") {
207
+ fieldAllWidth += parseInt(item.minWidth, 10);
208
+ }
209
+ if (!item.width) {
210
+ minWidthCount++;
211
+ minAllWidth += parseInt(item.minWidth, 10);
212
+ }
213
+ if (item.render !== undefined && item.render !== "" && typeof item.render === "string") {
214
+ if (item.render.indexOf("function") != -1) {
215
+ if (item.render) {
216
+ item.render = eval("(true&&" + item.render.replace(/[\r\n]/g, "") + ")");
217
+ } else {
218
+ delete item.render;
219
+ }
220
+ } else {
221
+ if (_this2.props.funcParams && _this2.props.funcParams[item.render] !== undefined) {
222
+ item.render = _this2.props.funcParams[item.render];
223
+ } else {
224
+ delete item.render;
225
+ }
226
+ }
227
+ }
228
+ columns.push(item);
229
+ }
230
+ return item1;
231
+ });
232
+
233
+ /****************************以下操作是列的宽度,并做处理*********************************/
234
+ var width = 0;
235
+ if (document.getElementsByClassName(this.state.className)[0]) {
236
+ //存在二级列表时候的+号列50
237
+ var expandWidth = 0;
238
+ //滚动条宽度20
239
+ var scollWidth = 20;
240
+ //选择框列63
241
+ var selectFieldWidth = 40; //原来是63,现被强制设置成40
242
+ //列表的宽度
243
+ var tableWidth = document.getElementsByClassName(this.state.className)[0].offsetWidth;
244
+ // tableWidth = getWidth(tableWidth, document.getElementsByClassName(this.state.className)[0]);
245
+ tableWidth = parseInt(this.props.width, 10);
246
+ //列的实际宽度
247
+ var trueWidth = scollWidth + selectFieldWidth + expandWidth;
248
+ columns.map(function (item) {
249
+ trueWidth += parseInt(item.minWidth, 10);
250
+ return item;
251
+ });
252
+ //如果列的宽度大于列表的宽度的时候,需要冻结列,减少10px是为了减少误差
253
+ if (trueWidth > tableWidth - 10) {
254
+ columns.map(function (item, index) {
255
+ item.width = parseInt(item.minWidth, 10);
256
+ if (item.cacheFixed) {
257
+ item.fixed = item.cacheFixed;
258
+ }
259
+ return item;
260
+ });
261
+ width = trueWidth + 10;
262
+ } else if (trueWidth === tableWidth - 10) {
263
+ //如果列的宽度等于列表的宽度的时候,不需要做任何的处理
264
+ columns.map(function (item, index) {
265
+ item.width = parseInt(item.minWidth, 10);
266
+ return item;
267
+ });
268
+ } else {
269
+ //如果列的宽度小于列表的宽度的时候,存在最小宽度列,则把剩余宽度平分到最小宽度列,如果没有,则平分到除了序号和操作列的其他列
270
+ var elseWidth = tableWidth - 10 - trueWidth;
271
+ if (minWidthCount === 0) {
272
+ //没有扩展列
273
+ columns.map(function (item, index) {
274
+ if (item.dataIndex && item.dataIndex !== "ROW_ID") {
275
+ item.width = parseInt(item.minWidth, 10) + parseInt(elseWidth * parseInt(item.minWidth, 10) / fieldAllWidth, 10);
276
+ }
277
+ return item;
278
+ });
279
+ } else {
280
+ columns.map(function (item, index) {
281
+ if (!item.width) {
282
+ //最小宽度列
283
+ item.width = parseInt(item.minWidth, 10) + parseInt(elseWidth * parseInt(item.minWidth, 10) / minAllWidth, 10);
284
+ }
285
+ return item;
286
+ });
287
+ }
288
+ }
289
+ }
290
+
291
+ /****************************以下部分页的参数,如果不需要尾部则这些信息不需要进行设置*********************************/
292
+ var Pagination = undefined;
293
+ if (this.props.footerFlag !== false) {
294
+ Pagination = {
295
+ total: this.state.pageData.total, //数据总数
296
+ pageSize: this.state.pageData.pageSize, //每页的条数
297
+ current: this.state.pageData.page, //当前页数
298
+ showTotal: function showTotal(total, range) {
299
+ return "\u5F53\u524D" + range[0] + "-" + range[1] + "\u6761 \u603B\u6570" + total + "\u6761";
300
+ },
301
+ // showQuickJumper: true,
302
+ showSizeChanger: true,
303
+ pageSizeOptions: ["10", "20", "50", "100", "200", "500"]
304
+ };
305
+ } else {
306
+ Pagination = false;
307
+ }
308
+
309
+ /****************************以下是设置是否需要选择框*********************************/
310
+
311
+ var rowSelection = {
312
+ type: this.props.type === "checkbox" ? "checkbox" : "radio",
313
+ columnWidth: 40,
314
+ selectedRowKeys: this.state.selectedRowKeys,
315
+ onSelect: function onSelect(record, selected, selectedRows, nativeEvent) {
316
+ _this2.setSelectRows([record], selected);
317
+ },
318
+ onSelectAll: function onSelectAll(selected, selectedRows, changeRows) {
319
+ _this2.setSelectRows(changeRows, selected);
320
+ }
321
+ };
322
+ var onRow = function onRow(record) {
323
+ return {
324
+ onClick: function onClick() {
325
+ _this2.setSelectRows([record]);
326
+ }
327
+ };
328
+ };
329
+
330
+ /****************************以下是循环判断是否需要排序、搜索条件*********************************/
331
+ columns.map(function (item, index) {
332
+ if (!item.key) {
333
+ item.key = item.dataIndex;
334
+ }
335
+ //是否需要排序
336
+ if (item.sorted !== false && item.title !== "序号" && item.title !== "操作") {
337
+ item.sorter = true;
338
+ } else {
339
+ item.sorter = false;
340
+ }
341
+ return item;
342
+ });
343
+
344
+ var searchWidth = parseInt(this.props.searchWidth, 10);
345
+
346
+ // 搜索框placeholder
347
+ var searchPlaceholder = placeholder;
348
+ if (safeMode) {
349
+ var label = fieldList.filter(function (item) {
350
+ return item.value === preciseSearchField;
351
+ })[0].label;
352
+ searchPlaceholder = "\u8BF7\u8F93\u5165" + label + "\u67E5\u8BE2";
353
+ }
354
+ return _react2.default.createElement(
355
+ "div",
356
+ { style: { height: "100%", width: "100%" } },
357
+ _react2.default.createElement(
358
+ "div",
359
+ {
360
+ className: "dlt-selector-table-searchDiv",
361
+ style: { padding: "5px" }
362
+ },
363
+ this.props.searchRender ? this.props.searchRender() : _react2.default.createElement(
364
+ "div",
365
+ null,
366
+ safeMode && _react2.default.createElement(
367
+ _select2.default,
368
+ {
369
+ value: preciseSearchField,
370
+ onChange: this.preciseSearchFieldChange,
371
+ dropdownMatchSelectWidth: false,
372
+ dropdownStyle: { width: "auto" }
373
+ },
374
+ fieldList.map(function (item) {
375
+ return _react2.default.createElement(
376
+ _select2.default.Option,
377
+ { value: item.value, key: item.value },
378
+ item.label
379
+ );
380
+ })
381
+ ),
382
+ _react2.default.createElement(_input2.default, {
383
+ placeholder: searchPlaceholder,
384
+ value: this.state.searchValue,
385
+ onChange: function onChange(value) {
386
+ _this2.handlerSearchTextChange(value);
387
+ },
388
+ style: { width: searchWidth },
389
+ onPressEnter: this.onSearch
390
+ }),
391
+ _react2.default.createElement(
392
+ _button2.default,
393
+ {
394
+ type: "primary",
395
+ style: { marginLeft: "20px" },
396
+ onClick: this.onSearch
397
+ },
398
+ "\u67E5\u8BE2"
399
+ ),
400
+ _react2.default.createElement(
401
+ _button2.default,
402
+ {
403
+ type: "Default",
404
+ style: { paddingLeft: 5, marginLeft: "10px" },
405
+ icon: "reload",
406
+ onClick: this.onRest
407
+ },
408
+ "\u91CD\u7F6E"
409
+ )
410
+ )
411
+ ),
412
+ _react2.default.createElement(_table2.default, {
413
+ className: this.state.className,
414
+ size: "small",
415
+ rowKey: this.props.rowKey,
416
+ rowSelection: rowSelection,
417
+ onRow: onRow,
418
+ dataSource: this.state.data,
419
+ columns: columns,
420
+ showHeader: this.props.showHeader,
421
+ pagination: Pagination,
422
+ loading: this.state.loading,
423
+ onChange: this.handleTableChange,
424
+ bordered: false,
425
+ components: this.components,
426
+ scroll: { x: width, y: this.state.height }
427
+ })
428
+ );
429
+ }
430
+ }]);
431
+ return SelectorTable;
432
+ }(_react2.default.Component);
433
+
434
+ SelectorTable.defaultProps = {
435
+ sign: undefined,
436
+ rowKey: undefined, //【推荐存在】设置的rowKey,在selectedRowKeys中存放的数据就是这个字段的值
437
+ keyField: undefined, //主键字段
438
+ initParams: {}, //初始化过滤的参数,这个不会根据重置而改变
439
+ treeParams: {}, //树选中的时候的查询条件
440
+ type: "checkbox", //【根据需求判断】是否需要checkbox
441
+ footerFlag: true, //【根据需求判断】是否需要尾部,不需要尾部的时候,不会进行分页,
442
+ onSelect: undefined,
443
+ url: undefined, //后台访问地址,传了此路径就表示后台查询使用此路径而不是使用通用路径
444
+ columns: [],
445
+ searchField: "", //列表可以进行模糊查询的字段
446
+ searchWidth: "230", //查询框的宽度
447
+ placeholder: "请输入查询条件", //查询框的默认提示
448
+ width: 500, //列表的宽度
449
+ showHeader: true, //是否显示头部
450
+ searchRender: undefined, //自定义搜索框
451
+ rangeFilter: undefined, //是否开启职务范围过滤
452
+ rangeFilterList: undefined, // 自定义职务过滤列表
453
+ historyRangeFilter: undefined, // 历史职务过滤(目前只支持班级职务)。读取历史带班表【ZHXG_XGDW_LSDBXX】,开启后班级职务使用历史带班表,其他层级职务照旧
454
+ historyCycleList: undefined, // 历史数据周期(学年学期格式)。值为空时查询全表,historyRangeFilter为true时生效。
455
+ funcParams: {} //如果在columns内部写代码操作时,用键值对的形式存起来
456
+ };
457
+
458
+ var _initialiseProps = function _initialiseProps() {
459
+ var _this3 = this;
460
+
461
+ this.refreshHeight = function () {
462
+ //如果需要自适应高度
463
+ if (document.getElementsByClassName(_this3.state.className)) {
464
+ var lastHeight = _this3.state.height;
465
+ var height = (0, _index.getSuitHeight)(document.getElementsByClassName(_this3.state.className)[0]);
466
+ var titleHeight = 40;
467
+ if (_this3.props.showHeader !== true) {
468
+ titleHeight = 0;
469
+ }
470
+ var reduceHeight = 40 + titleHeight;
471
+ if (_this3.props.footerFlag === false) {
472
+ reduceHeight = 5 + titleHeight;
473
+ }
474
+ height = height - reduceHeight;
475
+ if (!lastHeight || lastHeight !== height) {
476
+ _this3.setState({
477
+ height: height
478
+ });
479
+ }
480
+ }
481
+ };
482
+
483
+ this.onSearch = function () {
484
+ _this3.filterTableData();
485
+ };
486
+
487
+ this.onRest = function () {
488
+ _this3.setState(function (prevState, props) {
489
+ return {
490
+ searchParams: {}, //自定义的搜索条件
491
+ searchValue: undefined,
492
+ preciseSearchField: initPreciseSearchField,
493
+ sorter: {}, //排序字段
494
+ pageData: {
495
+ total: _this3.state.pageData.total,
496
+ pageSize: _this3.state.pageData.pageSize,
497
+ page: 1
498
+ }
499
+ };
500
+ }, function () {
501
+ this.filterTableData();
502
+ });
503
+ };
504
+
505
+ this.filterTableData = function () {
506
+ var safeMode = _this3.props.safeMode;
507
+ var searchValue = _this3.state.searchValue;
508
+ // 安全模式下必须有搜索条件才能查询数据
509
+
510
+ if (safeMode && !searchValue) {
511
+ _this3.setState({
512
+ data: []
513
+ });
514
+ return;
515
+ }
516
+
517
+ _this3.setState(function (prevState, props) {
518
+ return {
519
+ pageData: {
520
+ total: _this3.state.pageData.total,
521
+ pageSize: _this3.state.pageData.pageSize,
522
+ page: 1
523
+ }
524
+ };
525
+ }, function () {
526
+ _this3.readTableData();
527
+ });
528
+ // 将此方法放进 setState的回调里,让设置pageData及时生效
529
+ // this.readTableData();
530
+ };
531
+
532
+ this.readTableData = function () {
533
+ var params = _this3.getFilterParams();
534
+ _this3.setState({ loading: true });
535
+ var url = _this3.props.url;
536
+ (0, _index.NHFetch)(url, "POST", params).then(function (res) {
537
+ if (res) {
538
+ _this3.setState({
539
+ data: res.data.list,
540
+ pageData: {
541
+ total: res.data.total,
542
+ pageSize: _this3.state.pageData.pageSize,
543
+ page: _this3.state.pageData.page
544
+ }
545
+ });
546
+ }
547
+ _this3.setState({ loading: false });
548
+ }).catch(function (res) {
549
+ _this3.setState({ loading: false });
550
+ return res;
551
+ });
552
+ };
553
+
554
+ this.getFilterParams = function () {
555
+ var pagination = _this3.state.pageData; //分页的参数
556
+ var sorter = _this3.state.sorter; //过滤的数据
557
+ var initParams = _this3.props.initParams; //初始化参数
558
+ var treeParams = _this3.props.treeParams; //树过滤条件
559
+ var rangeFilter = _this3.props.rangeFilter; //是否开启职务范围过滤
560
+ var rangeFilterList = _this3.props.rangeFilterList; // 自定义职务过滤列表
561
+ var historyRangeFilter = _this3.props.historyRangeFilter; // 历史职务过滤(目前只支持班级职务)。读取历史带班表【ZHXG_XGDW_LSDBXX】,开启后班级职务使用历史带班表,其他层级职务照旧
562
+ var historyCycleList = _this3.props.historyCycleList; // 历史数据周期(学年学期格式)。值为空时查询全表,historyRangeFilter为true时生效。
563
+ var params = _this3.mergeParams(initParams, treeParams);
564
+
565
+ var res = {
566
+ pagination: pagination,
567
+ sorter: sorter,
568
+ params: params,
569
+ sign: _this3.props.sign,
570
+ sqlParams: _this3.props.sqlParams,
571
+ keyField: _this3.props.keyField
572
+ };
573
+ //如果启用职位范围过滤
574
+ if (rangeFilter) {
575
+ var userId = (0, _index.getLoginUser)() ? (0, _index.getLoginUser)().userId : "";
576
+ res.rangeFilter = { id: userId };
577
+ }
578
+ if (rangeFilterList) {
579
+ res.rangeFilterList = rangeFilterList;
580
+ }
581
+ if (historyRangeFilter) {
582
+ res.historyRangeFilter = {
583
+ historyCycleList: historyCycleList || []
584
+ };
585
+ }
586
+ return res;
587
+ };
588
+
589
+ this.mergeParams = function (initParams, treeParams) {
590
+ var _props2 = _this3.props,
591
+ safeMode = _props2.safeMode,
592
+ searchField = _props2.searchField;
593
+ var _state = _this3.state,
594
+ searchValue = _state.searchValue,
595
+ preciseSearchField = _state.preciseSearchField;
596
+
597
+ var searchParams = {};
598
+
599
+ // 是否安全模式,即是否使用精确匹配
600
+ if (safeMode) {
601
+ searchParams[preciseSearchField] = searchValue;
602
+ } else {
603
+ searchParams[searchField] = searchValue;
604
+ }
605
+
606
+ var params = {};
607
+ for (var key in searchParams) {
608
+ params[key] = searchParams[key];
609
+ }
610
+ if (initParams) {
611
+ for (var _key in initParams) {
612
+ params[_key] = initParams[_key];
613
+ }
614
+ }
615
+ if (treeParams) {
616
+ for (var _key2 in treeParams) {
617
+ params[_key2] = treeParams[_key2];
618
+ }
619
+ }
620
+ return params;
621
+ };
622
+
623
+ this.handleTableChange = function (pagination, filters, sorter) {
624
+ _this3.setState(function (prevState, props) {
625
+ return {
626
+ sorter: {
627
+ columnKey: sorter.columnKey,
628
+ order: sorter.order
629
+ },
630
+ pageData: {
631
+ total: _this3.state.pageData.total,
632
+ pageSize: pagination.pageSize,
633
+ page: pagination.current
634
+ }
635
+ };
636
+ }, function () {
637
+ this.readTableData();
638
+ });
639
+ };
640
+
641
+ this.handlerSearchTextChange = function (e) {
642
+ _this3.setState({
643
+ searchValue: e.target.value
644
+ });
645
+ };
646
+
647
+ this.preciseSearchFieldChange = function (value) {
648
+ _this3.setState({
649
+ preciseSearchField: value
650
+ });
651
+ };
652
+
653
+ this.setSelectRows = function (changeRows, isSelect) {
654
+ var selectedRowKeys = [].concat((0, _toConsumableArray3.default)(_this3.state.selectedRowKeys));
655
+ var selectedRows = [].concat((0, _toConsumableArray3.default)(_this3.state.selectedRows));
656
+ var rowKey = _this3.props.rowKey;
657
+
658
+ //如果是多选
659
+ if (_this3.props.type === "checkbox") {
660
+ var rowsMap = {};
661
+ for (var i = 0; i < changeRows.length; i++) {
662
+ rowsMap[changeRows[i][rowKey]] = changeRows[i];
663
+ }
664
+ if (isSelect === true) {
665
+ //表示是选中
666
+ for (var _i = 0; _i < selectedRowKeys.length; _i++) {
667
+ if (rowsMap[selectedRowKeys[_i]]) {
668
+ rowsMap[selectedRowKeys[_i]] = undefined;
669
+ }
670
+ }
671
+ for (var key in rowsMap) {
672
+ if (rowsMap[key]) {
673
+ selectedRowKeys.push(key);
674
+ selectedRows.push(rowsMap[key]);
675
+ }
676
+ }
677
+ } else if (isSelect === false) {
678
+ //表示没有选中
679
+ for (var _i2 = 0; _i2 < selectedRowKeys.length; _i2++) {
680
+ if (rowsMap[selectedRowKeys[_i2]]) {
681
+ //表示这个值不能不能存在,需要删除
682
+ selectedRowKeys.splice(_i2, 1);
683
+ selectedRows.splice(_i2, 1);
684
+ _i2--;
685
+ }
686
+ }
687
+ } else {
688
+ //表示不知道是选中还是没有选中,这个时候只会有一个值
689
+ var _key3 = changeRows[0][rowKey];
690
+ var isAdd = true;
691
+ for (var _i3 = 0; _i3 < selectedRowKeys.length; _i3++) {
692
+ if (selectedRowKeys[_i3] === _key3) {
693
+ //存在说明是删除
694
+ selectedRowKeys.splice(_i3, 1);
695
+ selectedRows.splice(_i3, 1);
696
+ isAdd = false;
697
+ break;
698
+ }
699
+ }
700
+ if (isAdd) {
701
+ selectedRowKeys.push(_key3);
702
+ selectedRows.push(changeRows[0]);
703
+ }
704
+ }
705
+ } else {
706
+ //单选
707
+ selectedRows = [];
708
+ selectedRowKeys = [];
709
+ selectedRowKeys.push(changeRows[0][rowKey]);
710
+ selectedRows.push(changeRows[0]);
711
+ }
712
+ _this3.setState({
713
+ selectedRows: selectedRows,
714
+ selectedRowKeys: selectedRowKeys
715
+ });
716
+ if (_this3.props.onSelect) {
717
+ _this3.props.onSelect(selectedRowKeys, selectedRows);
718
+ }
719
+ };
720
+
721
+ this.setSelectedRowKeys = function (selectedRowKeys, selectedRows) {
722
+ _this3.setState({
723
+ selectedRows: selectedRows,
724
+ selectedRowKeys: selectedRowKeys
725
+ });
726
+ };
727
+
728
+ this.components = {
729
+ table: function table(props) {
730
+ return _react2.default.createElement(
731
+ _reactCustomScrollbarsPatched.Scrollbars,
732
+ {
733
+ onScroll: _this3.onScroll,
734
+ autoHide: true,
735
+ style: { width: "100%", height: _this3.state.height }
736
+ },
737
+ _react2.default.createElement("table", props)
738
+ );
739
+ }
740
+ };
741
+
742
+ this.onScroll = function (e1) {
743
+ if (loadCount === 0) {
744
+ var scrollLeft = e1.target.scrollLeft;
745
+ var scrollTop = e1.target.scrollTop;
746
+ var $parentObj = e1.target.parentNode.parentNode;
747
+ var obj = $parentObj.classList.contains("ant-table-body") ? "content" : "none";
748
+ if (obj === "none") {
749
+ obj = $parentObj.parentNode.parentNode.classList.contains("ant-table-fixed-left") ? "left" : "right";
750
+ }
751
+
752
+ //头部对象
753
+ var $table = document.getElementsByClassName(_this3.state.className)[0];
754
+ var $header = $table.getElementsByClassName("ant-table-scroll")[0].getElementsByClassName("ant-table-header")[0];
755
+ $header.scrollLeft = scrollLeft;
756
+ //中间内容区
757
+ var $content = $table.getElementsByClassName("ant-table-scroll")[0].getElementsByClassName("ant-table-body")[0].childNodes[0].childNodes[0];
758
+ if (obj !== "content" && $content.scrollTop !== scrollTop) {
759
+ loadCount++;
760
+ $content.scrollTop = scrollTop;
761
+ }
762
+ //左部固定内容区
763
+ if ($table.getElementsByClassName("ant-table-fixed-left")[0]) {
764
+ var $left = $table.getElementsByClassName("ant-table-fixed-left")[0].getElementsByClassName("ant-table-body-inner")[0].childNodes[0].childNodes[0];
765
+ if ($left && obj !== "left" && $left.scrollTop !== scrollTop) {
766
+ loadCount++;
767
+ $left.scrollTop = scrollTop;
768
+ }
769
+ }
770
+ //右部固定内容区
771
+ if ($table.getElementsByClassName("ant-table-fixed-right")[0]) {
772
+ var $right = $table.getElementsByClassName("ant-table-fixed-right")[0].getElementsByClassName("ant-table-body-inner")[0].childNodes[0].childNodes[0];
773
+ if ($right && obj !== "right" && $right.scrollTop !== scrollTop) {
774
+ loadCount++;
775
+ $right.scrollTop = scrollTop;
776
+ }
777
+ }
778
+ } else {
779
+ loadCount--;
780
+ }
781
+ };
782
+ };
783
+
784
+ exports.default = SelectorTable;