dlt-for-react 1.0.13 → 1.0.14

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,1045 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = undefined;
7
+
8
+ var _pagination = require("antd/lib/pagination");
9
+
10
+ var _pagination2 = _interopRequireDefault(_pagination);
11
+
12
+ var _spin = require("antd/lib/spin");
13
+
14
+ var _spin2 = _interopRequireDefault(_spin);
15
+
16
+ var _empty = require("antd/lib/empty");
17
+
18
+ var _empty2 = _interopRequireDefault(_empty);
19
+
20
+ var _row = require("antd/lib/row");
21
+
22
+ var _row2 = _interopRequireDefault(_row);
23
+
24
+ var _col = require("antd/lib/col");
25
+
26
+ var _col2 = _interopRequireDefault(_col);
27
+
28
+ var _button = require("antd/lib/button");
29
+
30
+ var _button2 = _interopRequireDefault(_button);
31
+
32
+ var _checkbox = require("antd/lib/checkbox");
33
+
34
+ var _checkbox2 = _interopRequireDefault(_checkbox);
35
+
36
+ var _radio = require("antd/lib/radio");
37
+
38
+ var _radio2 = _interopRequireDefault(_radio);
39
+
40
+ var _select = require("antd/lib/select");
41
+
42
+ var _select2 = _interopRequireDefault(_select);
43
+
44
+ var _extends2 = require("babel-runtime/helpers/extends");
45
+
46
+ var _extends3 = _interopRequireDefault(_extends2);
47
+
48
+ var _dropdown = require("antd/lib/dropdown");
49
+
50
+ var _dropdown2 = _interopRequireDefault(_dropdown);
51
+
52
+ var _icon = require("antd/lib/icon");
53
+
54
+ var _icon2 = _interopRequireDefault(_icon);
55
+
56
+ var _menu = require("antd/lib/menu");
57
+
58
+ var _menu2 = _interopRequireDefault(_menu);
59
+
60
+ var _divider = require("antd/lib/divider");
61
+
62
+ var _divider2 = _interopRequireDefault(_divider);
63
+
64
+ var _message2 = require("antd/lib/message");
65
+
66
+ var _message3 = _interopRequireDefault(_message2);
67
+
68
+ var _getPrototypeOf = require("babel-runtime/core-js/object/get-prototype-of");
69
+
70
+ var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
71
+
72
+ var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
73
+
74
+ var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
75
+
76
+ var _createClass2 = require("babel-runtime/helpers/createClass");
77
+
78
+ var _createClass3 = _interopRequireDefault(_createClass2);
79
+
80
+ var _possibleConstructorReturn2 = require("babel-runtime/helpers/possibleConstructorReturn");
81
+
82
+ var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
83
+
84
+ var _inherits2 = require("babel-runtime/helpers/inherits");
85
+
86
+ var _inherits3 = _interopRequireDefault(_inherits2);
87
+
88
+ var _input = require("antd/lib/input");
89
+
90
+ var _input2 = _interopRequireDefault(_input);
91
+
92
+ require("antd/lib/pagination/style");
93
+
94
+ require("antd/lib/spin/style");
95
+
96
+ require("antd/lib/empty/style");
97
+
98
+ require("antd/lib/row/style");
99
+
100
+ require("antd/lib/col/style");
101
+
102
+ require("antd/lib/button/style");
103
+
104
+ require("antd/lib/checkbox/style");
105
+
106
+ require("antd/lib/radio/style");
107
+
108
+ require("antd/lib/select/style");
109
+
110
+ require("antd/lib/dropdown/style");
111
+
112
+ require("antd/lib/icon/style");
113
+
114
+ require("antd/lib/menu/style");
115
+
116
+ require("antd/lib/divider/style");
117
+
118
+ require("antd/lib/message/style");
119
+
120
+ require("antd/lib/input/style");
121
+
122
+ var _react = require("react");
123
+
124
+ var _react2 = _interopRequireDefault(_react);
125
+
126
+ var _NHCore = require("../../utils/NHCore");
127
+
128
+ var _classnames = require("classnames");
129
+
130
+ var _classnames2 = _interopRequireDefault(_classnames);
131
+
132
+ var _NHFetch = require("../../utils/NHFetch");
133
+
134
+ var _NHFetch2 = _interopRequireDefault(_NHFetch);
135
+
136
+ var _getLoginUser = require("../../utils/getLoginUser");
137
+
138
+ var _getLoginUser2 = _interopRequireDefault(_getLoginUser);
139
+
140
+ var _createUuid = require("../../utils/createUuid");
141
+
142
+ var _createUuid2 = _interopRequireDefault(_createUuid);
143
+
144
+ require("../../../assets/components/KyTableCardList/index.less");
145
+
146
+ var _reactCustomScrollbars = require("react-custom-scrollbars");
147
+
148
+ var _highSearchForm = require("./highSearchForm");
149
+
150
+ var _highSearchForm2 = _interopRequireDefault(_highSearchForm);
151
+
152
+ var _KyIcon = require("../KyIcon");
153
+
154
+ var _KyIcon2 = _interopRequireDefault(_KyIcon);
155
+
156
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
157
+
158
+ /*******
159
+ * @description: 科研卡片表格-KyTableCardList
160
+ * @author: 琴时
161
+ */
162
+ var Search = _input2.default.Search;
163
+
164
+ var KyTableCardList = function (_React$Component) {
165
+ (0, _inherits3.default)(KyTableCardList, _React$Component);
166
+
167
+ function KyTableCardList(props) {
168
+ (0, _classCallCheck3.default)(this, KyTableCardList);
169
+
170
+ var _this = (0, _possibleConstructorReturn3.default)(this, (KyTableCardList.__proto__ || (0, _getPrototypeOf2.default)(KyTableCardList)).call(this, props));
171
+
172
+ _this.refreshHeight = function () {
173
+ //如果需要自适应高度
174
+ if (!_this.props.autoHeightFlag && document.getElementsByClassName(_this.state.className)) {
175
+ var lastHeight = _this.state.height;
176
+ var height = (0, _NHCore.getSuitHeight)(document.getElementsByClassName(_this.state.className)[0]);
177
+ height = _this.props.windowH - 64;
178
+ var titleHeight = _this.props.titleHeight || _this.props.titleHeight === 0 ? _this.props.titleHeight : 40;
179
+ //如果不显示头部,则头部的高度为0
180
+ if (_this.props.showHeader !== true) {
181
+ titleHeight = 0;
182
+ }
183
+ var reduceHeight = 40 + titleHeight;
184
+ if (_this.props.footerFlag === false) {
185
+ reduceHeight = 5 + titleHeight;
186
+ }
187
+ height = height - reduceHeight;
188
+ if (!lastHeight || lastHeight != height) {
189
+ _this.setState({ height: height });
190
+ }
191
+ }
192
+ };
193
+
194
+ _this.getHightSearchData = function (callback) {
195
+ var params = _this.getFilterParams();
196
+ var _this$props = _this.props,
197
+ baseUrl = _this$props.baseUrl,
198
+ url = _this$props.url;
199
+
200
+ baseUrl = baseUrl || window.baseUrl || "";
201
+ params.pagination = {
202
+ page: 1,
203
+ pageSize: 1 << 31 - 1
204
+ };
205
+ var url_final = baseUrl + "/proData/gridList";
206
+ url_final = url || url_final;
207
+ (0, _NHFetch2.default)(url_final, "POST", params).then(function (res) {
208
+ if (res) {
209
+ _this.setState({
210
+ hightSearchData: res.data ? res.data.list : []
211
+ }, function () {
212
+ callback && typeof callback === "function" && callback();
213
+ });
214
+ }
215
+ }).catch(function (res) {
216
+ // console.log(res);
217
+ });
218
+ };
219
+
220
+ _this.onSearch = function () {
221
+ _this.filterTableData();
222
+ };
223
+
224
+ _this.onAdvanceSearch = function () {
225
+ var searchParams = {};
226
+ _this.highSearchForm.validateFields(function (err, values) {
227
+ if (!err) {
228
+ for (var key in values) {
229
+ if (values[key]) {
230
+ if (key.endsWith("_date")) {
231
+ if (values[key] && values[key].length > 0) {
232
+ searchParams[key.replace("date", "LTEQ")] = values[key][1].valueOf();
233
+ searchParams[key.replace("date", "GTEQ")] = values[key][0].valueOf();
234
+ }
235
+ } else if (key.endsWith("_time_start")) {
236
+ searchParams[key.replace("time_start", "GTEQ")] = values[key].valueOf();
237
+ } else if (key.endsWith("_time_end")) {
238
+ searchParams[key.replace("time_end", "LTEQ")] = values[key].valueOf();
239
+ } else if (key.endsWith("_number_start")) {
240
+ searchParams[key.replace("number_start", "GTEQ")] = values[key].valueOf();
241
+ } else if (key.endsWith("_number_end")) {
242
+ searchParams[key.replace("number_end", "LTEQ")] = values[key].valueOf();
243
+ } else if (key.startsWith("S") && !key.endsWith("_IN")) {
244
+ if (values[key].trim() !== "") {
245
+ searchParams[key] = values[key].trim();
246
+ }
247
+ } else if (key.endsWith("_IN")) {
248
+ if (values[key] && values[key].length > 0) {
249
+ searchParams[key] = values[key];
250
+ }
251
+ } else {
252
+ searchParams[key] = values[key];
253
+ }
254
+ }
255
+ }
256
+ }
257
+ });
258
+ _this.setState({ searchParams: searchParams }, _this.filterTableData);
259
+ };
260
+
261
+ _this.onRest = function () {
262
+ _this.highSearchForm && _this.highSearchForm.resetFields();
263
+ _this.setState({
264
+ searchParams: {}, //自定义的搜索条件
265
+ searchTextMap: {}, //下拉框查询的值,用作查询
266
+ searchValue: "",
267
+ searchField: _this.state.tySearchAllField,
268
+ filters: {}, //多选方式过滤的值
269
+ sorter: {}, //排序字段
270
+ selectedRows: [], //选中的数据
271
+ selectedRowKeys: [], //选中的数据的主键loading
272
+ radioValue: "",
273
+ checkBoxValue: []
274
+ }, _this.filterTableData);
275
+ };
276
+
277
+ _this.onInputChange = function (e) {
278
+ var key = e.target.name.split("-")[0];
279
+ var searchTextMap = _this.state.searchTextMap;
280
+ searchTextMap[key] = e.target.value;
281
+ _this.setState({ searchTextMap: searchTextMap });
282
+ };
283
+
284
+ _this.filterTableData = function () {
285
+ _this.setState({
286
+ pageData: {
287
+ total: _this.state.pageData.total,
288
+ pageSize: _this.state.pageData.pageSize,
289
+ page: 1
290
+ }
291
+ }, _this.readTableData);
292
+ };
293
+
294
+ _this.readTableData = function () {
295
+ var params = _this.getFilterParams();
296
+ _this.setState({ loading: true });
297
+ var _this$props2 = _this.props,
298
+ url = _this$props2.url,
299
+ baseUrl = _this$props2.baseUrl,
300
+ onDataLoadFinish = _this$props2.onDataLoadFinish;
301
+
302
+ baseUrl = url || baseUrl || window.baseUrl || "";
303
+ (0, _NHFetch2.default)(baseUrl + "/proData/gridList", "POST", params).then(function (res) {
304
+ _this.setState({
305
+ data: res.data ? res.data.list : [],
306
+ selectedRowKeys: [],
307
+ selectedRows: [],
308
+ pageData: {
309
+ total: res.data ? res.data.total : 0,
310
+ pageSize: _this.state.pageData.pageSize,
311
+ page: _this.state.pageData.page
312
+ },
313
+ loading: false
314
+ });
315
+ if (res && res.code !== 200) {
316
+ return _message3.default.error("数据获取失败!");
317
+ }
318
+ onDataLoadFinish && onDataLoadFinish(res.data ? res.data.list : []);
319
+ }).catch(function (res) {
320
+ _this.setState({
321
+ loading: false,
322
+ data: [],
323
+ pageData: {
324
+ total: 0,
325
+ pageSize: _this.state.pageData.pageSize,
326
+ page: 1
327
+ }
328
+ });
329
+ return res;
330
+ });
331
+ };
332
+
333
+ _this.getFilterParams = function () {
334
+ var pagination = _this.state.pageData; //分页的参数
335
+ var filters = _this.state.filters; //多选过滤的数据
336
+ var sorter = _this.state.sorter; //过滤的数据
337
+ var searchTextMap = _this.state.searchTextMap; //字段上搜索栏的值
338
+ var searchParams = _this.state.searchParams || {}; //传递过来的查询参数
339
+ var sqlParams = _this.props.sqlParams; //在sql语句中的参数
340
+ var initParams = _this.props.initParams; //初始化参数
341
+ var rangeFilter = _this.props.rangeFilter; //是否根据职务范围过滤
342
+ //对里面可能存在的参数值为sql语句进行处理
343
+ searchParams = _this.encodeSql(searchParams);
344
+ sqlParams = _this.encodeSql(sqlParams);
345
+ initParams = _this.encodeSql(initParams);
346
+
347
+ var params = {
348
+ pagination: pagination,
349
+ filters: filters,
350
+ sorter: sorter,
351
+ searchTextMap: searchTextMap,
352
+ searchParams: searchParams,
353
+ sqlParams: sqlParams,
354
+ initParams: initParams,
355
+ sign: _this.props.sign
356
+ };
357
+
358
+ //如果启用职位范围过滤
359
+ if (rangeFilter) {
360
+ var userId = (0, _getLoginUser2.default)() ? (0, _getLoginUser2.default)().userId : "";
361
+ params.rangeFilter = { id: userId };
362
+ }
363
+ return params;
364
+ };
365
+
366
+ _this.encodeSql = function (params) {
367
+ for (var key in params) {
368
+ if (key.toUpperCase().startsWith("SQL_") && params[key]) {
369
+ params[key] = params[key];
370
+ } else if (key.toUpperCase().startsWith("G_") && params[key]) {
371
+ params[key] = _this.encodeSql(params[key]);
372
+ }
373
+ }
374
+ return params;
375
+ };
376
+
377
+ _this.zdySearchTextChange = function (e) {
378
+ _this.setState({
379
+ searchValue: e.target.value
380
+ });
381
+ if (e.target.value && _this.state.searchField) {
382
+ var searchParams = {};
383
+ searchParams[_this.state.searchField] = e.target.value.trim();
384
+ _this.setState({
385
+ searchParams: searchParams
386
+ });
387
+ } else {
388
+ _this.setState({
389
+ searchParams: {}
390
+ });
391
+ }
392
+ };
393
+
394
+ _this.zdySearchFieldChange = function (value) {
395
+ _this.setState({
396
+ searchField: value
397
+ });
398
+ if (value && _this.state.searchValue) {
399
+ var searchValue = _this.state.searchValue;
400
+ var searchParams = {};
401
+ searchParams[value] = searchValue;
402
+ _this.setState({
403
+ searchParams: searchParams
404
+ });
405
+ } else {
406
+ _this.setState({
407
+ searchParams: {}
408
+ });
409
+ }
410
+ };
411
+
412
+ _this.onShowSizeChange = function (current, pageSize) {
413
+ var pageData = {
414
+ total: _this.state.pageData.total,
415
+ pageSize: pageSize,
416
+ page: current
417
+ };
418
+ _this.setState({ pageData: pageData }, function () {
419
+ _this.readTableData();
420
+ });
421
+ };
422
+
423
+ _this.onRadioChange = function (e) {
424
+ var searchParams = _this.state.searchParams;
425
+ var radioKey = _this.props.radioKey;
426
+
427
+ var radioValue = e.target.value;
428
+ searchParams[radioKey] = radioValue;
429
+ _this.setState({
430
+ radioValue: radioValue,
431
+ searchParams: searchParams
432
+ });
433
+ };
434
+
435
+ _this.onCheckboxChange = function () {
436
+ var row = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
437
+ var searchParams = _this.state.searchParams;
438
+ var checkboxKey = _this.props.checkboxKey;
439
+
440
+ searchParams[checkboxKey] = row;
441
+ if (!row || row.length) delete searchParams[checkboxKey];
442
+ _this.setState({
443
+ checkBoxValue: row,
444
+ searchParams: searchParams
445
+ });
446
+ };
447
+
448
+ _this.getBgColor = function (row, config, bgIndex) {
449
+ /**
450
+ * 卡片背景颜色会根据不同状态展示不同颜色
451
+ * config中两种配置方式
452
+ * callback优先级比colorList高
453
+ */
454
+ /**
455
+ * {
456
+ title: '状态列',
457
+ dataIndex: 'STATUS_NAME',
458
+ isState: true, //配置状态列==>必须为true
459
+ //方式一
460
+ colorList: [
461
+ { status: '状态值1', color: ['#DBDBDB','rgba(0,0,0,0.6500)'] }, //灰色
462
+ { status: '状态值2', color: ['#397EF0','#397EF0'] }, //蓝色
463
+ { status: '状态值3', color: ['#FAAD14','#FAAD14'] }, //橙色
464
+ ...
465
+ ],//['背景颜色','状态字体颜色']
466
+ //方式二
467
+ callback: text => {
468
+ let temp = {
469
+ 状态值1: ['#DBDBDB','rgba(0,0,0,0.6500)'],
470
+ 状态值2: ['#397EF0','#397EF0'],
471
+ 状态值3: ['#FAAD14','#FAAD14'],
472
+ ...
473
+ };
474
+ return temp[text];
475
+ },
476
+ },
477
+ */
478
+ var temp = [{ status: "-1", color: ["#FF4D4F", "#FF4D4F"] }, //红色
479
+ { status: "0", color: ["#DBDBDB", "rgba(0,0,0,0.65)"] }, //灰色
480
+ { status: "1", color: ["#397EF0", "#397EF0"] }, //蓝色
481
+ { status: "2", color: ["#FAAD14", "#FAAD14"] }, //橙色
482
+ { status: "3", color: ["#23D688", "#23D688"] }];
483
+ var defaultColor = _this.props.defaultColor; //没有匹配成功则使用默认色
484
+
485
+ var _ref = config || {},
486
+ _ref$colorList = _ref.colorList,
487
+ colorList = _ref$colorList === undefined ? temp : _ref$colorList,
488
+ dataIndex = _ref.dataIndex,
489
+ callback = _ref.callback;
490
+
491
+ if (!config) return defaultColor[bgIndex];
492
+ if (callback) {
493
+ var callbackCol = callback(row[dataIndex], row) || defaultColor;
494
+ return callbackCol[bgIndex];
495
+ }
496
+ var item = colorList.find(function (item) {
497
+ return row[dataIndex] === item.status;
498
+ });
499
+ var color = item ? item.color : defaultColor;
500
+ return color[bgIndex];
501
+ };
502
+
503
+ _this.getAction = function (row, action) {
504
+ var action1 = action.filter(function (item) {
505
+ return (item.auth === undefined || (0, _NHCore.hasAuth)(item.auth)) && (item.isShow === undefined || item.isShow(row));
506
+ });
507
+ var action2 = action1.splice(2);
508
+ var dom = action1.map(function (item, index) {
509
+ var disabled = item.disabled && item.disabled(row);
510
+ var icon = item.icon,
511
+ type = item.type;
512
+
513
+ return _react2.default.createElement(
514
+ _react2.default.Fragment,
515
+ { key: index },
516
+ index !== 0 && _react2.default.createElement(_divider2.default, { className: "border", type: "vertical" }),
517
+ _react2.default.createElement(
518
+ "a",
519
+ {
520
+ onClick: function onClick() {
521
+ item.onClick && item.onClick(row);
522
+ },
523
+ disabled: disabled,
524
+ className: "action"
525
+ },
526
+ item.title || item.TITLE,
527
+ icon && _react2.default.createElement(_KyIcon2.default, { icon: icon, type: type, className: "operate-icon" })
528
+ )
529
+ );
530
+ });
531
+ if (action2.length > 0) {
532
+ var menuItems = action2.map(function (item, index) {
533
+ var disabled = item.disabled && item.disabled(row);
534
+ var icon = item.icon,
535
+ type = item.type;
536
+
537
+ return _react2.default.createElement(
538
+ _menu2.default.Item,
539
+ { key: index + 2 },
540
+ _react2.default.createElement(
541
+ "a",
542
+ {
543
+ onClick: function onClick() {
544
+ item.onClick && item.onClick(row);
545
+ },
546
+ disabled: disabled,
547
+ className: "action"
548
+ },
549
+ item.title || item.TITLE,
550
+ icon && _react2.default.createElement(_KyIcon2.default, { icon: icon, type: type, className: "operate-icon" })
551
+ )
552
+ );
553
+ });
554
+ var menu = _react2.default.createElement(
555
+ _menu2.default,
556
+ null,
557
+ menuItems
558
+ );
559
+ var temp = _react2.default.createElement(
560
+ _react2.default.Fragment,
561
+ { key: (0, _createUuid2.default)() },
562
+ _react2.default.createElement(_divider2.default, { className: "border", type: "vertical" }),
563
+ _react2.default.createElement(
564
+ _dropdown2.default,
565
+ { overlay: menu },
566
+ _react2.default.createElement(
567
+ "a",
568
+ { className: "action" },
569
+ "\u66F4\u591A ",
570
+ _react2.default.createElement(_icon2.default, { type: "down", className: "iconDown" })
571
+ )
572
+ )
573
+ );
574
+ dom.push(temp);
575
+ }
576
+ return dom;
577
+ };
578
+
579
+ _this.handleClick = function (row) {
580
+ _this.props.onClick && _this.props.onClick(row);
581
+ };
582
+
583
+ _this.state = {
584
+ filterDropdownVisibleMap: {},
585
+ searchParams: (0, _extends3.default)({}, _this.props.searchParams), //自定义的搜索条件
586
+ searchTextMap: {}, //下拉框查询的值,用作查询
587
+ filters: {}, //多选方式过滤的值
588
+ sorter: {}, //排序字段
589
+ selectedRows: [], //选中的数据
590
+ selectedRowKeys: [], //选中的数据的主键loading
591
+ loading: false,
592
+ data: [], //数据
593
+ pageData: {
594
+ //分页设置的是三个参数
595
+ total: 0,
596
+ pageSize: !props.footerFlag ? 10000000 : 20, //当前页默认多少条数据
597
+ page: 1
598
+ },
599
+ height: _this.props.height, //列表的高度
600
+ width: undefined, //列表的宽度
601
+ className: (0, _createUuid2.default)(),
602
+ tySearchAllField: "", //通用查询的所有字段
603
+ searchValue: "", //通用查询的值
604
+ searchField: "", //通用查询的字段
605
+ highSearch: false,
606
+ hightSearchData: [],
607
+ radioValue: "",
608
+ checkBoxValue: [],
609
+ oneField: false
610
+ };
611
+ return _this;
612
+ }
613
+ //在组件挂载之前调用一次。如果在这个函数里面调用setState,本次的render函数可以看到更新后的state,并且只渲染一次。
614
+
615
+ //设置可以传递参数的默认值
616
+
617
+
618
+ (0, _createClass3.default)(KyTableCardList, [{
619
+ key: "componentWillMount",
620
+ value: function componentWillMount() {
621
+ this.filterTableData();
622
+ //循环判断哪些字段需要通用查询的搜索条件
623
+ if (this.props.searchDivFlag) {
624
+ var tySearchAllField = "multiField"; //自定义查询的所有字段
625
+ var num = 0;
626
+ var firstField = "";
627
+ this.props.columns.forEach(function (item) {
628
+ if (item.commonSearch !== false && item.dataIndex !== undefined) {
629
+ num++;
630
+ firstField = item.dataIndex;
631
+ tySearchAllField += "," + item.dataIndex.toLowerCase();
632
+ }
633
+ });
634
+ if (num === 1) tySearchAllField = firstField;
635
+ this.setState({
636
+ tySearchAllField: tySearchAllField,
637
+ searchField: tySearchAllField,
638
+ oneField: num === 1
639
+ });
640
+ }
641
+ }
642
+ //在组件挂载之后调用一次。
643
+
644
+ }, {
645
+ key: "componentDidMount",
646
+ value: function componentDidMount() {
647
+ this.refreshHeight();
648
+ // 加载高级搜索数据
649
+ if (this.props.columns.some(function (item) {
650
+ return item.searchType === "select";
651
+ })) {
652
+ this.getHightSearchData();
653
+ }
654
+ }
655
+ }, {
656
+ key: "componentDidUpdate",
657
+ value: function componentDidUpdate() {
658
+ this.refreshHeight();
659
+ }
660
+
661
+ //固定通用方法
662
+ //搜索操作
663
+
664
+
665
+ //重置操作
666
+
667
+
668
+ //搜索栏数据框值改变的时候执行的操作
669
+
670
+ //重新加载数据数据的方法(从第一页开始)
671
+
672
+ //在当前页刷新数据
673
+
674
+
675
+ //pageSize 变化的回调
676
+
677
+ }, {
678
+ key: "render",
679
+ value: function render() {
680
+ var _this2 = this;
681
+
682
+ var _state = this.state,
683
+ className = _state.className,
684
+ data = _state.data,
685
+ pageData = _state.pageData,
686
+ highSearch = _state.highSearch,
687
+ loading = _state.loading,
688
+ height = _state.height,
689
+ searchField = _state.searchField,
690
+ tySearchAllField = _state.tySearchAllField,
691
+ searchValue = _state.searchValue,
692
+ radioValue = _state.radioValue,
693
+ checkBoxValue = _state.checkBoxValue,
694
+ oneField = _state.oneField;
695
+ var _props = this.props,
696
+ classNamePro = _props.className,
697
+ searchDivFlag = _props.searchDivFlag,
698
+ children = _props.children,
699
+ pageSizeOptions = _props.pageSizeOptions,
700
+ footerFlag = _props.footerFlag,
701
+ radioList = _props.radioList,
702
+ radioText = _props.radioText,
703
+ searchText = _props.searchText,
704
+ resetText = _props.resetText,
705
+ checkBoxText = _props.checkBoxText,
706
+ checkBoxList = _props.checkBoxList,
707
+ columns = _props.columns,
708
+ action = _props.action;
709
+ /****************************以下获取能用于搜索的参数*********************************/
710
+
711
+ var maxSearchTitle = 2;
712
+ var searchLength = 0;
713
+ var showHeight = false; //是否显示使用高级搜索的开关
714
+ var titleKey = "title";
715
+ var status = null;
716
+ var subhead = null;
717
+ var newColumns = columns.filter(function (item) {
718
+ return !item.isTitle && !item.isState && !item.isSubhead;
719
+ });
720
+ var tyOptions = [];
721
+ columns.forEach(function (item, index) {
722
+ if (item.searchType) showHeight = true;
723
+ if (item.isTitle) titleKey = item.dataIndex;
724
+ if (item.isState) status = item;
725
+ if (item.isSubhead) subhead = item;
726
+ if (item.commonSearch !== false) {
727
+ searchLength++;
728
+ if (item.title.length > maxSearchTitle) {
729
+ maxSearchTitle = item.title.length;
730
+ }
731
+ tyOptions.push(_react2.default.createElement(
732
+ _select2.default.Option,
733
+ { value: item.dataIndex, key: index },
734
+ item.title
735
+ ));
736
+ }
737
+ });
738
+ return _react2.default.createElement(
739
+ "div",
740
+ { className: "ky-table-card-list" },
741
+ searchDivFlag ? highSearch ? _react2.default.createElement(
742
+ "div",
743
+ { className: "highSearch-box" },
744
+ _react2.default.createElement(_highSearchForm2.default, {
745
+ onCancel: function onCancel() {
746
+ return _this2.setState({
747
+ highSearch: false,
748
+ searchParams: {},
749
+ searchTextMap: {},
750
+ searchValue: "",
751
+ searchField: _this2.state.tySearchAllField
752
+ });
753
+ },
754
+ ref: function ref(_ref2) {
755
+ return _this2.highSearchForm = _ref2;
756
+ },
757
+ columns: columns,
758
+ tableData: this.state.hightSearchData,
759
+ onSearch: this.onAdvanceSearch,
760
+ onRest: this.onRest,
761
+ refreshHeight: this.refreshHeight,
762
+ getHightSearchData: this.getHightSearchData
763
+ })
764
+ ) : _react2.default.createElement(
765
+ "div",
766
+ { className: "searchDiv" },
767
+ _react2.default.createElement(
768
+ _select2.default,
769
+ {
770
+ className: oneField ? "hide_select_field_icon" : "",
771
+ value: searchField,
772
+ onChange: this.zdySearchFieldChange,
773
+ dropdownMatchSelectWidth: false,
774
+ dropdownStyle: {
775
+ width: searchLength > 6 ? 80 + (maxSearchTitle - 2) * 15 : "auto"
776
+ }
777
+ },
778
+ !oneField && _react2.default.createElement(
779
+ _select2.default.Option,
780
+ { value: tySearchAllField },
781
+ "\u5168\u90E8"
782
+ ),
783
+ tyOptions
784
+ ),
785
+ _react2.default.createElement(Search, {
786
+ placeholder: "\u8BF7\u8F93\u5165\u67E5\u8BE2\u6761\u4EF6",
787
+ onSearch: this.onSearch,
788
+ value: searchValue,
789
+ onChange: this.zdySearchTextChange,
790
+ className: "search-input"
791
+ }),
792
+ radioList && radioList.length > 0 &&
793
+ // 自定义单选查询区域
794
+ _react2.default.createElement(
795
+ "span",
796
+ { className: "search-radio" },
797
+ radioText,
798
+ "\uFF1A",
799
+ _react2.default.createElement(
800
+ _radio2.default.Group,
801
+ { onChange: this.onRadioChange, value: radioValue },
802
+ radioList.map(function (item) {
803
+ return _react2.default.createElement(
804
+ _radio2.default,
805
+ { value: item.value || item.VALUE },
806
+ item.label || item.LABEL
807
+ );
808
+ })
809
+ )
810
+ ),
811
+ checkBoxList && checkBoxList.length > 0 &&
812
+ // 自定义多选选查询区域
813
+ _react2.default.createElement(
814
+ "span",
815
+ { className: "search-checkbox" },
816
+ checkBoxText,
817
+ "\uFF1A",
818
+ _react2.default.createElement(_checkbox2.default.Group, {
819
+ options: checkBoxList,
820
+ onChange: this.onCheckboxChange,
821
+ value: checkBoxValue
822
+ })
823
+ ),
824
+ _react2.default.createElement(
825
+ _button2.default,
826
+ {
827
+ type: "primary",
828
+ className: "search-btn",
829
+ onClick: this.onSearch
830
+ },
831
+ searchText
832
+ ),
833
+ _react2.default.createElement(
834
+ _button2.default,
835
+ { type: "Default", onClick: this.onRest },
836
+ resetText
837
+ ),
838
+ _react2.default.createElement(
839
+ "a",
840
+ {
841
+ onClick: function onClick() {
842
+ _this2.setState({ highSearch: true }, _this2.refreshHeight);
843
+ },
844
+ className: "height-text",
845
+ style: { display: showHeight ? "inline" : "none" }
846
+ },
847
+ "[\u9AD8\u7EA7\u641C\u7D22]"
848
+ )
849
+ ) : "",
850
+ children && _react2.default.createElement(
851
+ "div",
852
+ { style: { marginBottom: "12px" } },
853
+ _react2.default.createElement(
854
+ _row2.default,
855
+ { gutter: 16 },
856
+ _react2.default.createElement(
857
+ _col2.default,
858
+ { span: 12 },
859
+ children
860
+ )
861
+ )
862
+ ),
863
+ _react2.default.createElement(
864
+ "div",
865
+ { className: (0, _classnames2.default)(className, classNamePro) },
866
+ _react2.default.createElement(
867
+ _reactCustomScrollbars.Scrollbars,
868
+ {
869
+ className: "custom_scrollbars",
870
+ autoHide: true,
871
+ autoHeight: true,
872
+ autoHeightMin: 0,
873
+ autoHeightMax: height,
874
+ thumbMinSize: 30,
875
+ universal: true
876
+ },
877
+ _react2.default.createElement(
878
+ _spin2.default,
879
+ { spinning: loading },
880
+ _react2.default.createElement(
881
+ "div",
882
+ { className: "content-box" },
883
+ data && data.length > 0 ? data.map(function (item, index) {
884
+ return _react2.default.createElement(
885
+ "div",
886
+ { className: "card-list", key: index },
887
+ _react2.default.createElement("div", {
888
+ className: "statusLine",
889
+ style: {
890
+ background: _this2.getBgColor(item, status, 0)
891
+ }
892
+ }),
893
+ _react2.default.createElement(
894
+ "div",
895
+ { className: "item-left" },
896
+ _react2.default.createElement(
897
+ "div",
898
+ { className: "title_box" },
899
+ _react2.default.createElement(
900
+ "p",
901
+ {
902
+ className: "title",
903
+ onClick: function onClick() {
904
+ _this2.handleClick(item);
905
+ }
906
+ },
907
+ item[titleKey]
908
+ ),
909
+ subhead && _react2.default.createElement(
910
+ "div",
911
+ { className: "subhead" },
912
+ _react2.default.createElement(
913
+ "span",
914
+ { className: "subhead_label" },
915
+ subhead.title,
916
+ "\uFF1A"
917
+ ),
918
+ _react2.default.createElement(
919
+ "span",
920
+ { className: "subhead_value" },
921
+ subhead.render ? subhead.render(item[subhead.dataIndex], item, index) : item[subhead.dataIndex]
922
+ )
923
+ )
924
+ ),
925
+ _react2.default.createElement(
926
+ _row2.default,
927
+ null,
928
+ newColumns.map(function (itemM, indexM) {
929
+ return _react2.default.createElement(
930
+ _col2.default,
931
+ {
932
+ span: 24 / newColumns.length,
933
+ key: indexM,
934
+ className: itemM.dataIndex,
935
+ style: {
936
+ width: itemM.width,
937
+ minWidth: itemM.minWidth
938
+ }
939
+ },
940
+ _react2.default.createElement(
941
+ "div",
942
+ {
943
+ className: (0, _classnames2.default)("label", "label_" + itemM.dataIndex)
944
+ },
945
+ itemM.title,
946
+ "\uFF1A"
947
+ ),
948
+ _react2.default.createElement(
949
+ "div",
950
+ {
951
+ className: (0, _classnames2.default)("value", "value_" + itemM.dataIndex)
952
+ },
953
+ itemM.render ? itemM.render(item[itemM.dataIndex], item, itemM) : item[itemM.dataIndex]
954
+ )
955
+ );
956
+ })
957
+ )
958
+ ),
959
+ status && _react2.default.createElement(
960
+ "div",
961
+ { className: "status" },
962
+ _react2.default.createElement("div", {
963
+ className: "dot",
964
+ style: {
965
+ background: _this2.getBgColor(item, status, 0)
966
+ }
967
+ }),
968
+ _react2.default.createElement(
969
+ "span",
970
+ {
971
+ className: "status-text",
972
+ style: {
973
+ color: _this2.getBgColor(item, status, 1)
974
+ }
975
+ },
976
+ status.render ? status.render(item[status.dataIndex], item, status, index) : item[status.dataIndex]
977
+ )
978
+ ),
979
+ _react2.default.createElement(
980
+ "div",
981
+ { className: "operate" },
982
+ _this2.getAction(item, action)
983
+ )
984
+ );
985
+ }) : _react2.default.createElement(_empty2.default, { image: _empty2.default.PRESENTED_IMAGE_SIMPLE })
986
+ )
987
+ )
988
+ )
989
+ ),
990
+ footerFlag && _react2.default.createElement(
991
+ "div",
992
+ { className: "card-list-pagination" },
993
+ _react2.default.createElement(_pagination2.default, {
994
+ size: "small",
995
+ showSizeChanger: true,
996
+ showQuickJumper: true,
997
+ onChange: this.onShowSizeChange,
998
+ onShowSizeChange: this.onShowSizeChange,
999
+ current: pageData.page //当前页数
1000
+ , total: pageData.total //数据总数
1001
+ , pageSize: pageData.pageSize //每页的条数
1002
+ , showTotal: function showTotal(total, range) {
1003
+ return "\u5F53\u524D" + range[0] + "-" + range[1] + "\u6761 \u603B\u6570" + total + "\u6761";
1004
+ },
1005
+ pageSizeOptions: pageSizeOptions
1006
+ })
1007
+ )
1008
+ );
1009
+ }
1010
+ }]);
1011
+ return KyTableCardList;
1012
+ }(_react2.default.Component);
1013
+
1014
+ KyTableCardList.defaultProps = {
1015
+ sign: undefined, //【强制存在】数据源的标志
1016
+ searchParams: {}, //【推荐存在】查询条件的参数
1017
+ sqlParams: {}, //【根据需求判断】放在sql语句语句中的参数
1018
+ initParams: {}, //初始化过滤的参数,这个不会根据重置而改变
1019
+ checkbox: true, //【根据需求判断】是否需要checkbox
1020
+ autoHeightFlag: false, //【根据需求判断】是否根据内容自适应高度,默认为false,表示高度固定
1021
+ height: undefined, //【根据需求判断】自定义的高度
1022
+ footerFlag: true, //【根据需求判断】是否需要尾部,不需要尾部的时候,不会进行分页,
1023
+ searchDivFlag: true, //【根据需求判断】是否需要自带查询操作,默认需要
1024
+ columns: [], //数据列配置
1025
+ action: [], //操作列配置
1026
+ bordered: true, //是否展示外边框和列边框
1027
+ titleHeight: 40, //Title头部的高度,这个主要是为了解决出现多级表头的时候,高度计算会出现问题
1028
+ showHeader: true, //是否显示头部
1029
+ url: undefined, //后台访问地址,传了此路径就表示后台查询使用此路径而不是使用通用路径
1030
+ rangeFilter: false, //是否开启职务范围过滤
1031
+ onDataLoadFinish: undefined, //加载数据完成的回调方法
1032
+ baseUrl: undefined, //请求路径的前缀,可通过改参数控制访问的后端服务,如果不设置,则会去访问当前前端服务对应的后端服务,例如:api/sm-bpm-expansion
1033
+
1034
+ radioList: [], //单选查询数据源
1035
+ radioText: "任务状态", //单选查询label
1036
+ radioKey: "S_ZT_IN", //单选查询字段名称
1037
+ checkBoxList: [], //多选查询数据源
1038
+ checkBoxText: "任务状态", //多选查询label
1039
+ checkboxKey: "S_STATE_IN", //多选查询字段名称
1040
+ pageSizeOptions: ["10", "20", "50", "100", "200", "500"],
1041
+ searchText: "查询",
1042
+ resetText: "取消",
1043
+ defaultColor: ["#397EF0", "#397EF0"] //卡片默认主题颜色['背景颜色','状态字体颜色']
1044
+ };
1045
+ exports.default = KyTableCardList;