cloud-b2b 1.0.1 → 1.0.4

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.
Files changed (54) hide show
  1. package/es/Area/Area.js +166 -0
  2. package/es/Area/package.json +6 -0
  3. package/es/Control/Control.js +27 -1
  4. package/es/Header/Header.js +1 -1
  5. package/es/Header/Header.less +12 -11
  6. package/es/HomeHeader/Header.less +1 -1
  7. package/es/Sidebar/Sidebar.js +2 -2
  8. package/es/Sidebar/Sidebar.less +10 -9
  9. package/es/SuperForm/SuperForm.js +74 -27
  10. package/es/SuperTable/DragSortRow.js +125 -0
  11. package/es/SuperTable/DragSortRow.less +17 -0
  12. package/es/SuperTable/FilterDropDown.js +188 -0
  13. package/es/SuperTable/FilterDropDown.less +30 -0
  14. package/es/SuperTable/SuperTable.js +933 -0
  15. package/es/SuperTable/SuperTable.less +135 -0
  16. package/es/SuperTable/fixed.js +42 -0
  17. package/es/SuperTable/package.json +6 -0
  18. package/es/SuperTable2/SuperTable2.js +700 -0
  19. package/es/SuperTable2/SuperTable2.less +116 -0
  20. package/es/SuperTable2/SuperTableCell.js +215 -0
  21. package/es/SuperTable2/package.json +6 -0
  22. package/es/Title/Title.less +35 -35
  23. package/es/Title/package.json +6 -6
  24. package/es/adjust.less +89 -0
  25. package/es/index.js +4 -1
  26. package/es/style.less +20 -1
  27. package/lib/Area/Area.js +194 -0
  28. package/lib/Area/package.json +6 -0
  29. package/lib/Control/Control.js +29 -1
  30. package/lib/Header/Header.js +1 -1
  31. package/lib/Header/Header.less +12 -11
  32. package/lib/HomeHeader/Header.less +1 -1
  33. package/lib/Sidebar/Sidebar.js +2 -2
  34. package/lib/Sidebar/Sidebar.less +10 -9
  35. package/lib/SuperForm/SuperForm.js +72 -27
  36. package/lib/SuperTable/DragSortRow.js +142 -0
  37. package/lib/SuperTable/DragSortRow.less +17 -0
  38. package/lib/SuperTable/FilterDropDown.js +205 -0
  39. package/lib/SuperTable/FilterDropDown.less +30 -0
  40. package/lib/SuperTable/SuperTable.js +937 -0
  41. package/lib/SuperTable/SuperTable.less +135 -0
  42. package/lib/SuperTable/fixed.js +55 -0
  43. package/lib/SuperTable/package.json +6 -0
  44. package/lib/SuperTable2/SuperTable2.js +725 -0
  45. package/lib/SuperTable2/SuperTable2.less +116 -0
  46. package/lib/SuperTable2/SuperTableCell.js +231 -0
  47. package/lib/SuperTable2/package.json +6 -0
  48. package/lib/Title/Title.less +35 -35
  49. package/lib/Title/package.json +6 -6
  50. package/lib/adjust.less +89 -0
  51. package/lib/index.js +28 -1
  52. package/lib/index.less +5 -0
  53. package/lib/style.less +20 -1
  54. package/package.json +1 -1
@@ -0,0 +1,700 @@
1
+ import _Reflect$construct from "@babel/runtime-corejs3/core-js-stable/reflect/construct";
2
+ import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
3
+ import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
4
+ import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
5
+ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
6
+ import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
7
+ import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
8
+ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
9
+ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
10
+ import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
11
+ import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
12
+ import _getIteratorMethod from "@babel/runtime-corejs3/core-js/get-iterator-method";
13
+ import _Table from "antd/es/table";
14
+ import _extends from "@babel/runtime-corejs3/helpers/extends";
15
+ import _Switch from "antd/es/switch";
16
+ import _Button from "antd/es/button";
17
+ import _Checkbox from "antd/es/checkbox";
18
+ import _Icon from "antd/es/icon";
19
+ import _classCallCheck from "@babel/runtime-corejs3/helpers/classCallCheck";
20
+ import _createClass from "@babel/runtime-corejs3/helpers/createClass";
21
+ import _assertThisInitialized from "@babel/runtime-corejs3/helpers/assertThisInitialized";
22
+ import _inherits from "@babel/runtime-corejs3/helpers/inherits";
23
+ import _possibleConstructorReturn from "@babel/runtime-corejs3/helpers/possibleConstructorReturn";
24
+ import _getPrototypeOf from "@babel/runtime-corejs3/helpers/getPrototypeOf";
25
+ import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
26
+
27
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (_Array$isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
28
+
29
+ function _unsupportedIterableToArray(o, minLen) { var _context12; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context12 = Object.prototype.toString.call(o)).call(_context12, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
30
+
31
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
32
+
33
+ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
34
+
35
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context10, _context11; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context10 = ownKeys(Object(source), !0)).call(_context10, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context11 = ownKeys(Object(source))).call(_context11, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
36
+
37
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
38
+ import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
39
+ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
40
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
41
+ import _bindInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/bind";
42
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
43
+ import _reduceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reduce";
44
+ import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
45
+
46
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
47
+
48
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
49
+
50
+ import React from 'react';
51
+ import PropTypes from 'prop-types';
52
+ import ReactDOM from 'react-dom';
53
+ import { getTitle } from '../Control';
54
+ import SuperTableCell from './SuperTableCell';
55
+ import fixed from '../SuperTable/fixed';
56
+ import SuperToolbar from '../SuperToolbar';
57
+ import variables from '../variables';
58
+ var TypeEnum = ['readonly', 'index', 'checkbox', 'text', 'number', 'select', //存储value
59
+ 'selectText', //存储title
60
+ 'search', 'searchText', 'selectSearch', //多选下拉搜索
61
+ 'date', 'button', 'custom', 'switch', 'textArea', 'link', 'toolbar', //按钮组
62
+ 'img' //图片标题组 value为{src,title}时显示图片标题 为字符串时 只显示图片
63
+ ];
64
+ /**
65
+ * key:标识所在列,在一个表格中必须唯一
66
+ * title:列的标题,type为checkbox时,title为空字符串时,表头才会显示为复选框
67
+ * type:嵌入的表单元素类型
68
+ * link: 是否为超链接,type未设置时,该属性才生效。为true表示内容来至items,为字符串表示超链接内容就是该字符串
69
+ * options: 对象(包含value和title)数组
70
+ * props:传递参数给被嵌入的组件
71
+ * width: 嵌入的组件的宽度,默认值为100
72
+ * align:对齐方式,index默认center,其他类型默认为left
73
+ * showAdd: 表头是否显示+号,默认为false,加号会触发onAdd事件
74
+ * hide: 为true时隐藏该列
75
+ */
76
+
77
+ var ColType = {
78
+ key: PropTypes.string.isRequired,
79
+ title: PropTypes.string.isRequired,
80
+ type: PropTypes.oneOf(TypeEnum),
81
+ link: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
82
+ align: PropTypes.oneOf(['left', 'center', 'right']),
83
+ width: PropTypes.number,
84
+ options: PropTypes.array,
85
+ showAdd: PropTypes.any,
86
+ hide: PropTypes.bool,
87
+ props: PropTypes.any
88
+ };
89
+ /**
90
+ * onCheck:点击复选框时触发,原型func(rowIndex, keyName, checked)
91
+ * onContentChange: 输入框内容改变时触发,原型为function(rowIndex, keyName, value)
92
+ * onSearch:search组件输入内容时触发,原型为function(rowIndex, keyName, value)
93
+ * onLink: 点击超链接时触发,原型为function(keyName, rowIndex, item)
94
+ * onAdd:点击+号时触发,原型为function(keyName)
95
+ * onRenderCustom:(废弃)用于渲染type为custom类型的单元格,原型为function(rowIndex, keyName, value,props)
96
+ * onToolbar:点击表格列按钮组时触发,原型为function(按钮组列的key,rowIndex,该行数据的值,按钮key)
97
+ */
98
+
99
+ var CallbackType = {
100
+ onExitValid: PropTypes.func,
101
+ onCheck: PropTypes.func,
102
+ onContentChange: PropTypes.func,
103
+ onSearch: PropTypes.func,
104
+ onLink: PropTypes.func,
105
+ onAdd: PropTypes.func,
106
+ onRenderCustom: PropTypes.func,
107
+ onToolbar: PropTypes.func
108
+ };
109
+ /**
110
+ * base[可选]:序号的开始数字,所有回调函数中的序号值都会加上这个值,默认值为0
111
+ * isEmphasized: [可选],是否强调,行字体加粗显示, 除了isEmphasized设置为true之外,加粗行数据里要设置__isEmphasized为true
112
+ */
113
+
114
+ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
115
+ _inherits(SuperTable2, _React$Component);
116
+
117
+ var _super = _createSuper(SuperTable2);
118
+
119
+ function SuperTable2() {
120
+ var _context;
121
+
122
+ var _this;
123
+
124
+ _classCallCheck(this, SuperTable2);
125
+
126
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
127
+ args[_key] = arguments[_key];
128
+ }
129
+
130
+ _this = _super.call.apply(_super, _concatInstanceProperty(_context = [this]).call(_context, args));
131
+
132
+ _defineProperty(_assertThisInitialized(_this), "onSwitch", function (key, rowIndex) {
133
+ return function (value) {
134
+ var _ref = _this.props.callback || {},
135
+ onContentChange = _ref.onContentChange;
136
+
137
+ onContentChange && onContentChange(_this.getIndex(rowIndex), key, value);
138
+ };
139
+ });
140
+
141
+ _defineProperty(_assertThisInitialized(_this), "onCheck", function (key, rowIndex) {
142
+ return function (e) {
143
+ var _ref2 = _this.props.callback || {},
144
+ onCheck = _ref2.onCheck;
145
+
146
+ onCheck && onCheck(_this.getIndex(rowIndex), key, e.target.checked);
147
+ };
148
+ });
149
+
150
+ _defineProperty(_assertThisInitialized(_this), "onChange", function (key, rowIndex) {
151
+ return function (value) {
152
+ var _ref3 = _this.props.callback || {},
153
+ onContentChange = _ref3.onContentChange;
154
+
155
+ _this.closeValid();
156
+
157
+ onContentChange && onContentChange(_this.getIndex(rowIndex), key, value);
158
+ };
159
+ });
160
+
161
+ _defineProperty(_assertThisInitialized(_this), "onSearch", function (key, rowIndex, config) {
162
+ return function (value) {
163
+ var _ref4 = _this.props.callback || {},
164
+ onSearch = _ref4.onSearch;
165
+
166
+ onSearch && onSearch(_this.getIndex(rowIndex), key, value, config);
167
+ };
168
+ });
169
+
170
+ _defineProperty(_assertThisInitialized(_this), "onAdd", function (key) {
171
+ return function () {
172
+ var _ref5 = _this.props.callback || {},
173
+ onAdd = _ref5.onAdd;
174
+
175
+ onAdd && onAdd(key);
176
+ };
177
+ });
178
+
179
+ _defineProperty(_assertThisInitialized(_this), "onRowAdd", function (key, index) {
180
+ return function () {
181
+ var _ref6 = _this.props.callback || {},
182
+ onLink = _ref6.onLink;
183
+
184
+ onLink && onLink(key, index, _this.props.items[index]);
185
+ };
186
+ });
187
+
188
+ _defineProperty(_assertThisInitialized(_this), "onBlur", function () {
189
+ _this.closeValid();
190
+ });
191
+
192
+ _defineProperty(_assertThisInitialized(_this), "closeValid", function () {
193
+ var _this$props = _this.props,
194
+ valid = _this$props.valid,
195
+ _this$props$callback = _this$props.callback,
196
+ callback = _this$props$callback === void 0 ? {} : _this$props$callback;
197
+ valid && callback.onExitValid();
198
+ });
199
+
200
+ _defineProperty(_assertThisInitialized(_this), "getOptions", function (key, colOptions, index) {
201
+ var options = _this.props.items[index].options;
202
+ var options2 = _this.props.options;
203
+
204
+ if (options && _Array$isArray(options[key])) {
205
+ return options[key];
206
+ } else if (options2 && _Array$isArray(options2[key])) {
207
+ return options2[key];
208
+ } else {
209
+ return colOptions;
210
+ }
211
+ });
212
+
213
+ _defineProperty(_assertThisInitialized(_this), "validField", function (required, value) {
214
+ if (!_this.props.valid || _this.error || !required || value) {
215
+ return false;
216
+ } else if (typeof value === 'number') {
217
+ return false;
218
+ } else {
219
+ _this.error = true;
220
+ return true;
221
+ }
222
+ });
223
+
224
+ _defineProperty(_assertThisInitialized(_this), "renderEditableCell", function (config, value, index) {
225
+ var key = config.key,
226
+ type = config.type,
227
+ options = config.options,
228
+ props = config.props,
229
+ required = config.required,
230
+ width = config.width,
231
+ showRowAdd = config.showRowAdd;
232
+
233
+ var _this$props$items$ind = _this.props.items[index],
234
+ readonly = _this$props$items$ind.readonly,
235
+ _this$props$items$ind2 = _this$props$items$ind.isReadonly,
236
+ isReadonly = _this$props$items$ind2 === void 0 ? [] : _this$props$items$ind2,
237
+ _this$props$items$ind3 = _this$props$items$ind.isRequired,
238
+ isRequired = _this$props$items$ind3 === void 0 ? [] : _this$props$items$ind3,
239
+ _this$props$items$ind4 = _this$props$items$ind._extraProps,
240
+ _extraProps = _this$props$items$ind4 === void 0 ? {} : _this$props$items$ind4;
241
+
242
+ var cellProps = {
243
+ value: value,
244
+ width: width,
245
+ type: readonly || _Array$isArray(isReadonly) && _includesInstanceProperty(isReadonly).call(isReadonly, key) ? 'readonly' : type,
246
+ props: readonly ? {} : props,
247
+ error: _this.validField(required, value),
248
+ options: _this.getOptions(key, options, index),
249
+ onChange: _this.onChange(key, index),
250
+ onSearch: _this.onSearch(key, index, config),
251
+ onBlur: _this.onBlur
252
+ };
253
+
254
+ if (showRowAdd && _Array$isArray(isRequired) && _includesInstanceProperty(isRequired).call(isRequired, key)) {
255
+ cellProps.error = _this.validField(true, value);
256
+ cellProps.props = _objectSpread(_objectSpread({}, cellProps.props), _extraProps);
257
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", {
258
+ style: {
259
+ color: 'red',
260
+ display: 'inline-block'
261
+ }
262
+ }, "*"), /*#__PURE__*/React.createElement("span", {
263
+ style: {
264
+ marginLeft: '5px',
265
+ display: 'inline-block',
266
+ width: 'calc(100% - 12px)'
267
+ }
268
+ }, /*#__PURE__*/React.createElement(SuperTableCell, cellProps)), /*#__PURE__*/React.createElement("span", {
269
+ style: {
270
+ color: '#2196f3',
271
+ verticalAlign: 'super'
272
+ }
273
+ }, /*#__PURE__*/React.createElement(_Icon, {
274
+ type: "plus-circle-o",
275
+ role: "add",
276
+ onClick: _this.onRowAdd(key, index)
277
+ })));
278
+ }
279
+
280
+ if (_Array$isArray(isRequired) && _includesInstanceProperty(isRequired).call(isRequired, key)) {
281
+ cellProps.error = _this.validField(true, value);
282
+ cellProps.props = _objectSpread(_objectSpread({}, cellProps.props), _extraProps);
283
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", {
284
+ style: {
285
+ color: 'red',
286
+ display: 'inline-block'
287
+ }
288
+ }, "*"), /*#__PURE__*/React.createElement("span", {
289
+ style: {
290
+ marginLeft: '5px',
291
+ display: 'inline-block',
292
+ width: 'calc(100% - 12px)'
293
+ }
294
+ }, /*#__PURE__*/React.createElement(SuperTableCell, cellProps)));
295
+ }
296
+
297
+ if (showRowAdd) {
298
+ return /*#__PURE__*/React.createElement("div", {
299
+ style: {
300
+ clear: 'both'
301
+ }
302
+ }, /*#__PURE__*/React.createElement("span", {
303
+ style: {
304
+ marginRight: '5px',
305
+ "float": 'left'
306
+ }
307
+ }, /*#__PURE__*/React.createElement(SuperTableCell, cellProps)), /*#__PURE__*/React.createElement("span", {
308
+ style: {
309
+ color: '#2196f3',
310
+ verticalAlign: 'middle'
311
+ }
312
+ }, /*#__PURE__*/React.createElement(_Icon, {
313
+ type: "plus-circle-o",
314
+ role: "add",
315
+ onClick: _this.onRowAdd(key, index)
316
+ })));
317
+ }
318
+
319
+ return /*#__PURE__*/React.createElement(SuperTableCell, cellProps);
320
+ });
321
+
322
+ _defineProperty(_assertThisInitialized(_this), "renderLinkCell", function (col, value, record, index) {
323
+ if (col.link === 'list') {
324
+ var list = value && _Array$isArray(value) ? value : [];
325
+ return /*#__PURE__*/React.createElement("div", null, _mapInstanceProperty(list).call(list, function (item2, index2) {
326
+ var _context2;
327
+
328
+ var split = index2 === list.length - 1 ? '' : ',';
329
+
330
+ var onClick = function onClick() {
331
+ var _ref7 = _this.props.callback || {},
332
+ onLink = _ref7.onLink;
333
+
334
+ onLink && onLink(col.key, index, item2);
335
+ };
336
+
337
+ return /*#__PURE__*/React.createElement("a", {
338
+ key: index2,
339
+ onClick: onClick
340
+ }, _concatInstanceProperty(_context2 = "".concat(item2[col.linkTitleKey])).call(_context2, split));
341
+ }));
342
+ } else {
343
+ var title = typeof col.link === 'string' ? col.link : value;
344
+
345
+ var onClick = function onClick() {
346
+ var _ref8 = _this.props.callback || {},
347
+ onLink = _ref8.onLink;
348
+
349
+ onLink && onLink(col.key, index, record);
350
+ };
351
+
352
+ return /*#__PURE__*/React.createElement("a", {
353
+ onClick: onClick
354
+ }, title);
355
+ }
356
+ });
357
+
358
+ _defineProperty(_assertThisInitialized(_this), "getIndex", function (index) {
359
+ return (_this.props.base || 0) + index;
360
+ });
361
+
362
+ _defineProperty(_assertThisInitialized(_this), "getCellRender", function (col) {
363
+ return function (value, record, index) {
364
+ var _context3, _context4, _context5;
365
+
366
+ var realType = record._isEdit === true && _this.canReadonly(col.type) ? col.editType : col.type;
367
+
368
+ if (!realType) {
369
+ return /*#__PURE__*/React.createElement("div", {
370
+ style: {
371
+ maxWidth: "".concat(col.width - 16, "px"),
372
+ overflow: 'hidden',
373
+ textOverflow: 'ellipsis'
374
+ },
375
+ title: value
376
+ }, value);
377
+ }
378
+
379
+ switch (realType) {
380
+ case 'checkbox':
381
+ return /*#__PURE__*/React.createElement(_Checkbox, {
382
+ onChange: _this.onCheck(col.key, record.key),
383
+ checked: value || false
384
+ });
385
+
386
+ case 'index':
387
+ return _this.getIndex(index) + 1;
388
+
389
+ case 'link':
390
+ return _this.renderLinkCell(col, value, record, record.key);
391
+
392
+ case 'button':
393
+ var onClick = _this.props.callback.onLink ? _bindInstanceProperty(_context3 = _this.props.callback.onLink).call(_context3, null, col.key, record.key, record) : undefined;
394
+
395
+ if (col.icon === 'add') {
396
+ return /*#__PURE__*/React.createElement(_Button, {
397
+ onClick: onClick,
398
+ type: "primary",
399
+ shape: "circle",
400
+ size: "small",
401
+ ghost: true,
402
+ icon: "plus"
403
+ });
404
+ } else {
405
+ return /*#__PURE__*/React.createElement(_Button, {
406
+ onClick: onClick,
407
+ size: "small",
408
+ ghost: true,
409
+ type: col.bsStyle
410
+ }, record[col.key] || col.typeRelated);
411
+ }
412
+
413
+ case 'switch':
414
+ return value === 'noneDisplay' ? /*#__PURE__*/React.createElement("div", null) : /*#__PURE__*/React.createElement(_Switch, {
415
+ checkedChildren: col.props.checkedChildren || '',
416
+ unCheckedChildren: col.props.unCheckedChildren || '',
417
+ onChange: _this.onSwitch(col.key, record.key),
418
+ size: "default",
419
+ checked: value || false,
420
+ disabled: !(record._isEdit === true)
421
+ });
422
+
423
+ case 'custom':
424
+ return _this.props.callback.onRenderCustom(record.key, col.key, value, col.props);
425
+
426
+ case 'toolbar':
427
+ var props = {
428
+ onClick: _this.props.callback.onToolbar ? _bindInstanceProperty(_context4 = _this.props.callback.onToolbar).call(_context4, null, col.key, record.key, record) : undefined,
429
+ buttons: _filterInstanceProperty(_context5 = col.props.buttons).call(_context5, function (item) {
430
+ return item.defaultShow === !record._isEdit;
431
+ })
432
+ };
433
+ return /*#__PURE__*/React.createElement(SuperToolbar, props);
434
+
435
+ case 'img':
436
+ return value ? typeof value === 'string' ? /*#__PURE__*/React.createElement("img", {
437
+ src: value,
438
+ style: {
439
+ maxWidth: '100px'
440
+ }
441
+ }) : /*#__PURE__*/React.createElement("div", {
442
+ role: 'imgBox'
443
+ }, /*#__PURE__*/React.createElement("img", {
444
+ src: value.img,
445
+ style: {
446
+ maxWidth: '100px'
447
+ }
448
+ }), /*#__PURE__*/React.createElement("span", null, value.title)) : /*#__PURE__*/React.createElement("div", null);
449
+
450
+ default:
451
+ return _this.renderEditableCell(_objectSpread(_objectSpread({}, col), {}, {
452
+ type: realType
453
+ }), value, record.key);
454
+ }
455
+ };
456
+ });
457
+
458
+ _defineProperty(_assertThisInitialized(_this), "getCheckedStatus", function (key) {
459
+ var has = false,
460
+ not = false;
461
+ var items = _this.props.items;
462
+
463
+ var _iterator = _createForOfIteratorHelper(items),
464
+ _step;
465
+
466
+ try {
467
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
468
+ var item = _step.value;
469
+ item[key] ? has = true : not = true;
470
+ }
471
+ } catch (err) {
472
+ _iterator.e(err);
473
+ } finally {
474
+ _iterator.f();
475
+ }
476
+
477
+ return {
478
+ checked: has && !not,
479
+ indeterminate: has && not
480
+ };
481
+ });
482
+
483
+ _defineProperty(_assertThisInitialized(_this), "toAdd", function (key, showAdd) {
484
+ if (showAdd) {
485
+ var onClick = _this.onAdd(key);
486
+
487
+ return /*#__PURE__*/React.createElement(_Icon, {
488
+ type: "plus-circle-o",
489
+ role: "add",
490
+ onClick: onClick
491
+ });
492
+ } else {
493
+ return null;
494
+ }
495
+ });
496
+
497
+ _defineProperty(_assertThisInitialized(_this), "getColumnTitle", function (_ref9) {
498
+ var required = _ref9.required,
499
+ title = _ref9.title,
500
+ type = _ref9.type,
501
+ key = _ref9.key,
502
+ showAdd = _ref9.showAdd;
503
+
504
+ if (type === 'checkbox') {
505
+ var status = _this.getCheckedStatus(key);
506
+
507
+ return /*#__PURE__*/React.createElement(_Checkbox, _extends({
508
+ onChange: _this.onCheck(key, -1)
509
+ }, status));
510
+ } else {
511
+ var className = required ? 'ant-form-item-required' : '';
512
+ return /*#__PURE__*/React.createElement("span", {
513
+ className: className
514
+ }, title, _this.toAdd(key, showAdd));
515
+ }
516
+ });
517
+
518
+ _defineProperty(_assertThisInitialized(_this), "getColumnClassName", function (_ref10) {
519
+ var type = _ref10.type,
520
+ align = _ref10.align;
521
+
522
+ if (type === 'index' || type === 'checkbox') {
523
+ return 'ant-table-selection-column';
524
+ } else {
525
+ return align ? variables('SuperTable2')[align] : '';
526
+ }
527
+ });
528
+
529
+ _defineProperty(_assertThisInitialized(_this), "canReadonly", function (type) {
530
+ var _context6;
531
+
532
+ return !_includesInstanceProperty(_context6 = ['index', 'checkbox', 'link', 'button', 'switch', 'custom', 'img', 'toolbar']).call(_context6, type);
533
+ });
534
+
535
+ _defineProperty(_assertThisInitialized(_this), "getColumns", function (cols) {
536
+ var _context7;
537
+
538
+ var readonly = _this.props.readonly;
539
+ return _mapInstanceProperty(_context7 = _filterInstanceProperty(cols).call(cols, function (col) {
540
+ return !col.hide;
541
+ })).call(_context7, function (_ref11, index) {
542
+ var col = _extends({}, _ref11);
543
+
544
+ col.className = _this.getColumnClassName(col);
545
+ col.title = _this.getColumnTitle(col);
546
+ col.dataIndex = col.key;
547
+ col.width = col.width || 120; // const {props = {}} = col;
548
+ // const {edit = false} = props
549
+ // if (!(readonly || col.type === 'readonly') || !this.canReadonly(col.type)) {
550
+ // if ( !edit && ['text', 'number', 'select', 'date', 'search', 'readonly', 'textArea', 'selectSearch'].includes(col.type)){
551
+ // return col
552
+ // }
553
+ // }
554
+
555
+ col.render = _this.getCellRender(col);
556
+
557
+ if (col.link) {
558
+ col.type = 'link';
559
+ col.render = _this.getCellRender(col);
560
+ }
561
+
562
+ return col;
563
+ });
564
+ });
565
+
566
+ _defineProperty(_assertThisInitialized(_this), "getDataSource", function (items, cols) {
567
+ return _mapInstanceProperty(items).call(items, function (item, index) {
568
+ return _reduceInstanceProperty(cols).call(cols, function (result, _ref12) {
569
+ var _context8;
570
+
571
+ var key = _ref12.key,
572
+ type = _ref12.type,
573
+ options = _ref12.options;
574
+
575
+ if (!_this.props.readonly && type && type !== 'readonly' && (!item.isReadonly || _Array$isArray(item.isReadonly) && !_includesInstanceProperty(_context8 = item.isReadonly).call(_context8, key))) {
576
+ result[key] = item[key];
577
+ } else {
578
+ result[key] = getTitle(item[key], options);
579
+ }
580
+
581
+ return result;
582
+ }, _objectSpread(_objectSpread({}, item), {}, {
583
+ key: index,
584
+ disabled: item.isCanConfigHide
585
+ }));
586
+ });
587
+ });
588
+
589
+ _defineProperty(_assertThisInitialized(_this), "getPropsByCheckbox", function () {
590
+ var _this$props2 = _this.props,
591
+ items = _this$props2.items,
592
+ _this$props2$isEmphas = _this$props2.isEmphasized,
593
+ isEmphasized = _this$props2$isEmphas === void 0 ? false : _this$props2$isEmphas;
594
+
595
+ var rowClassName = function rowClassName(record) {
596
+ if (isEmphasized && items[record.key].__isEmphasized) {
597
+ return items[record.key].checked ? variables('SuperTable2').emphasizedSelectRow : variables('SuperTable2').emphasizedUnselectRow;
598
+ }
599
+
600
+ return items[record.key].checked ? variables('SuperTable2').select : '';
601
+ };
602
+
603
+ return {
604
+ rowClassName: rowClassName
605
+ };
606
+ });
607
+
608
+ _defineProperty(_assertThisInitialized(_this), "getProps", function () {
609
+ var _context9;
610
+
611
+ var _this$props3 = _this.props,
612
+ cols = _this$props3.cols,
613
+ items = _this$props3.items,
614
+ _this$props3$style = _this$props3.style,
615
+ style = _this$props3$style === void 0 ? {} : _this$props3$style,
616
+ _this$props3$footer = _this$props3.footer,
617
+ footer = _this$props3$footer === void 0 ? null : _this$props3$footer,
618
+ _this$props3$paginati = _this$props3.pagination,
619
+ pagination = _this$props3$paginati === void 0 ? false : _this$props3$paginati,
620
+ _this$props3$isEmphas = _this$props3.isEmphasized,
621
+ isEmphasized = _this$props3$isEmphas === void 0 ? false : _this$props3$isEmphas,
622
+ maxHeight = _this$props3.maxHeight;
623
+
624
+ var widthX = _reduceInstanceProperty(_context9 = _filterInstanceProperty(cols).call(cols, function (col) {
625
+ return !col.hide;
626
+ })).call(_context9, function (width, item) {
627
+ return width += item.width ? item.width : 120;
628
+ }, 0);
629
+
630
+ return _objectSpread({
631
+ className: !isEmphasized ? variables('SuperTable2') : variables('SuperTable2').noTransition,
632
+ columns: _this.getColumns(cols),
633
+ dataSource: _this.getDataSource(items, cols),
634
+ style: _Object$assign({}, {
635
+ whiteSpace: 'nowrap'
636
+ }, style),
637
+ size: 'small',
638
+ scroll: {
639
+ x: widthX,
640
+ y: maxHeight
641
+ },
642
+ pagination: pagination,
643
+ footer: footer,
644
+ locale: _this.props.emptyText ? {
645
+ emptyText: _this.props.emptyText
646
+ } : null
647
+ }, _this.getPropsByCheckbox());
648
+ });
649
+
650
+ _defineProperty(_assertThisInitialized(_this), "setScroll", function () {
651
+ if (_this.props.maxHeight && _this.props.items.length) {
652
+ var root = ReactDOM.findDOMNode(_assertThisInitialized(_this));
653
+ var container = root.getElementsByClassName('ant-table-body')[0];
654
+ var header = root.getElementsByClassName('ant-table-thead')[0];
655
+ fixed(container, header, _this.props.maxHeight);
656
+ }
657
+ });
658
+
659
+ return _this;
660
+ }
661
+
662
+ _createClass(SuperTable2, [{
663
+ key: "componentDidMount",
664
+ value: function componentDidMount() {
665
+ this.setScroll();
666
+ }
667
+ }, {
668
+ key: "componentDidUpdate",
669
+ value: function componentDidUpdate() {
670
+ this.setScroll();
671
+ }
672
+ }, {
673
+ key: "render",
674
+ value: function render() {
675
+ this.error = false;
676
+ return /*#__PURE__*/React.createElement(_Table, _extends({}, this.getProps(), {
677
+ key: this.props.items.length
678
+ }));
679
+ }
680
+ }]);
681
+
682
+ return SuperTable2;
683
+ }(React.Component);
684
+
685
+ _defineProperty(SuperTable2, "propTypes", {
686
+ cols: PropTypes.arrayOf(PropTypes.shape(ColType)).isRequired,
687
+ items: PropTypes.array.isRequired,
688
+ base: PropTypes.number,
689
+ options: PropTypes.object,
690
+ valid: PropTypes.bool,
691
+ readonly: PropTypes.bool,
692
+ style: PropTypes.object,
693
+ maxHeight: PropTypes.string,
694
+ emptyText: PropTypes.string,
695
+ footer: PropTypes.func,
696
+ callback: PropTypes.shape(CallbackType),
697
+ isEmphasized: PropTypes.bool
698
+ });
699
+
700
+ export default SuperTable2;