cloud-b2b 1.1.9 → 1.1.10

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.
@@ -11,6 +11,7 @@ import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
11
11
  import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
12
12
  import _getIteratorMethod from "@babel/runtime-corejs3/core-js/get-iterator-method";
13
13
  import _Table from "antd/es/table";
14
+ import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/objectWithoutProperties";
14
15
  import _extends from "@babel/runtime-corejs3/helpers/extends";
15
16
  import _Switch from "antd/es/switch";
16
17
  import _Button from "antd/es/button";
@@ -23,6 +24,7 @@ import _inherits from "@babel/runtime-corejs3/helpers/inherits";
23
24
  import _possibleConstructorReturn from "@babel/runtime-corejs3/helpers/possibleConstructorReturn";
24
25
  import _getPrototypeOf from "@babel/runtime-corejs3/helpers/getPrototypeOf";
25
26
  import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
27
+ var _excluded = ["onRowClick"];
26
28
 
27
29
  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
30
 
@@ -41,6 +43,7 @@ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance
41
43
  import _bindInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/bind";
42
44
  import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
43
45
  import _reduceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reduce";
46
+ import _someInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/some";
44
47
  import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
45
48
 
46
49
  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); }; }
@@ -56,6 +59,7 @@ import fixed from '../SuperTable/fixed';
56
59
  import SuperToolbar from '../SuperToolbar';
57
60
  import variables from '../variables';
58
61
  import helper, { getObjectExclude } from '../helper';
62
+ import DragSortRow from "../SuperTable/DragSortRow";
59
63
  var TypeEnum = ['readonly', 'index', 'checkbox', 'text', 'number', 'select', //存储value
60
64
  'selectText', //存储title
61
65
  'search', 'searchText', 'selectSearch', //多选下拉搜索
@@ -111,8 +115,11 @@ var CallbackType = {
111
115
  onToolbar: PropTypes.func,
112
116
  onDoubleClick: PropTypes.func,
113
117
  onTableFileChange: PropTypes.func,
114
- buildSuperUploadProps: PropTypes.func //构建type===uploadImg时,SuperUpload组件需要的公共属性函数,已在项目公共文件state.js中提供,可直接引用
115
-
118
+ buildSuperUploadProps: PropTypes.func,
119
+ //构建type===uploadImg时,SuperUpload组件需要的公共属性函数,已在项目公共文件state.js中提供,可直接引用
120
+ onImgTileClick: PropTypes.func,
121
+ //点击img类型标题触发事件
122
+ onMoveRow: PropTypes.func
116
123
  };
117
124
  /**
118
125
  * base[可选]:序号的开始数字,所有回调函数中的序号值都会加上这个值,默认值为0
@@ -213,6 +220,22 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
213
220
  };
214
221
  });
215
222
 
223
+ _defineProperty(_assertThisInitialized(_this), "onImgTileClick", function (col, value, rowIndex) {
224
+ return function () {
225
+ var _ref9 = _this.props.callback || {},
226
+ onImgTileClick = _ref9.onImgTileClick;
227
+
228
+ onImgTileClick && onImgTileClick(col, value, rowIndex);
229
+ };
230
+ });
231
+
232
+ _defineProperty(_assertThisInitialized(_this), "onMoveRow", function (dragIndex, targetIndex) {
233
+ var _ref10 = _this.props.callback || {},
234
+ onMoveRow = _ref10.onMoveRow;
235
+
236
+ onMoveRow && onMoveRow(dragIndex, targetIndex);
237
+ });
238
+
216
239
  _defineProperty(_assertThisInitialized(_this), "closeValid", function () {
217
240
  var _this$props = _this.props,
218
241
  valid = _this$props.valid,
@@ -352,8 +375,8 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
352
375
  var split = index2 === list.length - 1 ? '' : ',';
353
376
 
354
377
  var onClick = function onClick() {
355
- var _ref9 = _this.props.callback || {},
356
- onLink = _ref9.onLink;
378
+ var _ref11 = _this.props.callback || {},
379
+ onLink = _ref11.onLink;
357
380
 
358
381
  onLink && onLink(col.key, index, item2);
359
382
  };
@@ -367,8 +390,8 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
367
390
  var title = typeof col.link === 'string' ? col.link : value;
368
391
 
369
392
  var onClick = function onClick() {
370
- var _ref10 = _this.props.callback || {},
371
- onLink = _ref10.onLink;
393
+ var _ref12 = _this.props.callback || {},
394
+ onLink = _ref12.onLink;
372
395
 
373
396
  onLink && onLink(col.key, index, record);
374
397
  };
@@ -472,7 +495,7 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
472
495
  }) : /*#__PURE__*/React.createElement("div", {
473
496
  role: 'imgBox',
474
497
  style: {
475
- maxWidth: '120px'
498
+ maxWidth: "".concat(col.width, "px")
476
499
  }
477
500
  }, /*#__PURE__*/React.createElement("img", {
478
501
  src: value.img,
@@ -486,8 +509,13 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
486
509
  }
487
510
  }, /*#__PURE__*/React.createElement("span", {
488
511
  style: {
489
- display: 'block'
490
- }
512
+ display: 'block',
513
+ whiteSpace: 'nowrap',
514
+ overflow: 'hidden',
515
+ textOverflow: 'ellipsis',
516
+ width: '80px'
517
+ },
518
+ onClick: _this.onImgTileClick(col, record, index)
491
519
  }, value.title), helper.isEmpty2(value.remark) ? null : /*#__PURE__*/React.createElement("span", {
492
520
  style: {
493
521
  color: '#333'
@@ -553,12 +581,12 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
553
581
  }
554
582
  });
555
583
 
556
- _defineProperty(_assertThisInitialized(_this), "getColumnTitle", function (_ref11) {
557
- var required = _ref11.required,
558
- title = _ref11.title,
559
- type = _ref11.type,
560
- key = _ref11.key,
561
- showAdd = _ref11.showAdd;
584
+ _defineProperty(_assertThisInitialized(_this), "getColumnTitle", function (_ref13) {
585
+ var required = _ref13.required,
586
+ title = _ref13.title,
587
+ type = _ref13.type,
588
+ key = _ref13.key,
589
+ showAdd = _ref13.showAdd;
562
590
 
563
591
  if (type === 'checkbox') {
564
592
  var status = _this.getCheckedStatus(key);
@@ -574,9 +602,9 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
574
602
  }
575
603
  });
576
604
 
577
- _defineProperty(_assertThisInitialized(_this), "getColumnClassName", function (_ref12) {
578
- var type = _ref12.type,
579
- align = _ref12.align;
605
+ _defineProperty(_assertThisInitialized(_this), "getColumnClassName", function (_ref14) {
606
+ var type = _ref14.type,
607
+ align = _ref14.align;
580
608
 
581
609
  if (type === 'index' || type === 'checkbox') {
582
610
  return 'ant-table-selection-column';
@@ -597,15 +625,15 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
597
625
  var readonly = _this.props.readonly;
598
626
  return _mapInstanceProperty(_context9 = _filterInstanceProperty(cols).call(cols, function (col) {
599
627
  return !col.hide;
600
- })).call(_context9, function (_ref13, index) {
628
+ })).call(_context9, function (_ref15, index) {
601
629
  var _context10;
602
630
 
603
- var col = _extends({}, _ref13);
631
+ var col = _extends({}, _ref15);
604
632
 
605
633
  col.className = _this.getColumnClassName(col);
606
634
  col.title = _this.getColumnTitle(col);
607
635
  col.dataIndex = col.key;
608
- col.width = col.width || _includesInstanceProperty(_context10 = ['index', 'checked']).call(_context10, col.key) ? 70 : 120; // const {props = {}} = col;
636
+ col.width = col.width ? col.width : _includesInstanceProperty(_context10 = ['index', 'checked']).call(_context10, col.key) ? 70 : col.type === 'img' ? 200 : 120; // const {props = {}} = col;
609
637
  // const {edit = false} = props
610
638
  // if (!(readonly || col.type === 'readonly') || !this.canReadonly(col.type)) {
611
639
  // if ( !edit && ['text', 'number', 'select', 'date', 'search', 'readonly', 'textArea', 'selectSearch'].includes(col.type)){
@@ -626,12 +654,12 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
626
654
 
627
655
  _defineProperty(_assertThisInitialized(_this), "getDataSource", function (items, cols) {
628
656
  return _mapInstanceProperty(items).call(items, function (item, index) {
629
- return _reduceInstanceProperty(cols).call(cols, function (result, _ref14) {
657
+ return _reduceInstanceProperty(cols).call(cols, function (result, _ref16) {
630
658
  var _context11;
631
659
 
632
- var key = _ref14.key,
633
- type = _ref14.type,
634
- options = _ref14.options;
660
+ var key = _ref16.key,
661
+ type = _ref16.type,
662
+ options = _ref16.options;
635
663
 
636
664
  if (!_this.props.readonly && type && type !== 'readonly' && (!item.isReadonly || _Array$isArray(item.isReadonly) && !_includesInstanceProperty(_context11 = item.isReadonly).call(_context11, key))) {
637
665
  result[key] = item[key];
@@ -666,42 +694,172 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
666
694
  };
667
695
  });
668
696
 
669
- _defineProperty(_assertThisInitialized(_this), "getProps", function () {
670
- var _context12;
697
+ _defineProperty(_assertThisInitialized(_this), "getSelectedRowKeys", function (items) {
698
+ return _reduceInstanceProperty(items).call(items, function (result, item, index) {
699
+ item.checked && result.push(index);
700
+ return result;
701
+ }, []);
702
+ });
671
703
 
704
+ _defineProperty(_assertThisInitialized(_this), "getPropsByCheckbox2", function (items) {
672
705
  var _this$props3 = _this.props,
673
- cols = _this$props3.cols,
674
- items = _this$props3.items,
675
- _this$props3$style = _this$props3.style,
676
- style = _this$props3$style === void 0 ? {} : _this$props3$style,
677
- _this$props3$footer = _this$props3.footer,
678
- footer = _this$props3$footer === void 0 ? null : _this$props3$footer,
679
- _this$props3$paginati = _this$props3.pagination,
680
- pagination = _this$props3$paginati === void 0 ? false : _this$props3$paginati,
706
+ _this$props3$checkbox = _this$props3.checkbox,
707
+ checkbox = _this$props3$checkbox === void 0 ? true : _this$props3$checkbox,
708
+ _this$props3$radio = _this$props3.radio,
709
+ radio = _this$props3$radio === void 0 ? false : _this$props3$radio,
710
+ isolation = _this$props3.isolation,
711
+ _this$props3$checkedR = _this$props3.checkedRows,
712
+ checkedRows = _this$props3$checkedR === void 0 ? [] : _this$props3$checkedR,
681
713
  _this$props3$isEmphas = _this$props3.isEmphasized,
682
714
  isEmphasized = _this$props3$isEmphas === void 0 ? false : _this$props3$isEmphas,
683
- maxHeight = _this$props3.maxHeight,
684
- _this$props3$expanded = _this$props3.expandedRowRender,
685
- expandedRowRender = _this$props3$expanded === void 0 ? undefined : _this$props3$expanded,
686
- _this$props3$onExpand = _this$props3.onExpand,
687
- onExpand = _this$props3$onExpand === void 0 ? undefined : _this$props3$onExpand;
715
+ _this$props3$isWeaken = _this$props3.isWeaken,
716
+ isWeaken = _this$props3$isWeaken === void 0 ? true : _this$props3$isWeaken;
717
+
718
+ var rowClassName1 = function rowClassName1(record) {
719
+ if (items[record.key].__total) return variables('SuperTable').totalRow;
720
+ if (items[record.key].__warningRow) return variables('SuperTable').warningRow;
721
+ return _includesInstanceProperty(checkedRows).call(checkedRows, record.key) ? variables('SuperTable').select : '';
722
+ };
723
+
724
+ var rowClassName2 = function rowClassName2(record) {
725
+ if (items[record.key].__total) return variables('SuperTable').totalRow;
726
+ if (items[record.key].__warningRow) return variables('SuperTable').warningRow;
727
+
728
+ if (isEmphasized && items[record.key].__isEmphasized) {
729
+ return items[record.key].checked ? variables('SuperTable').emphasizedSelectRow : variables('SuperTable').emphasizedUnselectRow;
730
+ }
731
+
732
+ if (isWeaken && items[record.key].__isWeaken) {
733
+ return items[record.key].checked ? variables('SuperTable').weakenedSelectRow : variables('SuperTable').weakenedUnselectRow;
734
+ }
735
+
736
+ return items[record.key].checked ? variables('SuperTable').select : '';
737
+ };
738
+
739
+ if (checkbox) {
740
+ if (radio) {
741
+ return {
742
+ rowClassName: rowClassName1,
743
+ onRowClick: _this.onRadioRowClick,
744
+ rowSelection: {
745
+ type: 'radio',
746
+ selectedRowKeys: checkedRows,
747
+ onChange: _this.onRadioChange
748
+ }
749
+ };
750
+ } else if (isolation) {
751
+ return {
752
+ rowClassName: rowClassName1,
753
+ onRowClick: _this.onRowClick,
754
+ rowSelection: {
755
+ selectedRowKeys: checkedRows,
756
+ onChange: _this.onCheckChange,
757
+ getCheckboxProps: function getCheckboxProps(record) {
758
+ var checked = _includesInstanceProperty(checkedRows).call(checkedRows, record.key);
759
+
760
+ return {
761
+ checked: checked,
762
+ disabled: items[record.key].__isWeaken,
763
+ style: items[record.key].__total ? {
764
+ display: 'none'
765
+ } : {}
766
+ };
767
+ }
768
+ }
769
+ };
770
+ } else {
771
+ return {
772
+ rowClassName: rowClassName2,
773
+ onRowClick: _this.onRowClick,
774
+ rowSelection: {
775
+ selectedRowKeys: _this.getSelectedRowKeys(items),
776
+ onChange: _this.onChange,
777
+ getCheckboxProps: function getCheckboxProps(record) {
778
+ var checked = isWeaken && items[record.key].__isWeaken ? false : !!record.checked;
779
+ return {
780
+ checked: checked,
781
+ disabled: items[record.key].__isWeaken,
782
+ style: items[record.key].__total ? {
783
+ display: 'none'
784
+ } : {}
785
+ };
786
+ }
787
+ }
788
+ };
789
+ }
790
+ } else {
791
+ return {
792
+ rowClassName: rowClassName2
793
+ };
794
+ }
795
+ });
796
+
797
+ _defineProperty(_assertThisInitialized(_this), "getRowPropsForDrag", function () {
798
+ return function (record, index) {
799
+ return {
800
+ index: index,
801
+ onMoveRow: _this.onMoveRow
802
+ };
803
+ };
804
+ });
805
+
806
+ _defineProperty(_assertThisInitialized(_this), "getRowProps", function (onRowClick) {
807
+ return function (record) {
808
+ return {
809
+ onClick: function onClick() {
810
+ return onRowClick && onRowClick(record);
811
+ },
812
+ onDoubleClick: function onDoubleClick() {
813
+ return _this.onDoubleClick(record);
814
+ }
815
+ };
816
+ };
817
+ });
818
+
819
+ _defineProperty(_assertThisInitialized(_this), "getProps", function () {
820
+ var _context12;
821
+
822
+ var _this$props4 = _this.props,
823
+ cols = _this$props4.cols,
824
+ items = _this$props4.items,
825
+ _this$props4$style = _this$props4.style,
826
+ style = _this$props4$style === void 0 ? {} : _this$props4$style,
827
+ _this$props4$footer = _this$props4.footer,
828
+ footer = _this$props4$footer === void 0 ? null : _this$props4$footer,
829
+ _this$props4$paginati = _this$props4.pagination,
830
+ pagination = _this$props4$paginati === void 0 ? false : _this$props4$paginati,
831
+ dragSort = _this$props4.dragSort,
832
+ _this$props4$isEmphas = _this$props4.isEmphasized,
833
+ isEmphasized = _this$props4$isEmphas === void 0 ? false : _this$props4$isEmphas,
834
+ maxHeight = _this$props4.maxHeight,
835
+ _this$props4$expanded = _this$props4.expandedRowRender,
836
+ expandedRowRender = _this$props4$expanded === void 0 ? undefined : _this$props4$expanded,
837
+ _this$props4$onExpand = _this$props4.onExpand,
838
+ onExpand = _this$props4$onExpand === void 0 ? undefined : _this$props4$onExpand;
688
839
 
689
840
  var widthX = _reduceInstanceProperty(_context12 = _filterInstanceProperty(cols).call(cols, function (col) {
690
841
  return !col.hide;
691
842
  })).call(_context12, function (width, item) {
692
843
  var _context13;
693
844
 
694
- return width += item.width ? item.width : _includesInstanceProperty(_context13 = ['index', 'checked']).call(_context13, item.key) ? 70 : 120;
845
+ return width += item.width ? item.width : _includesInstanceProperty(_context13 = ['index', 'checked']).call(_context13, item.key) ? 70 : item.type === 'img' ? 200 : 120;
695
846
  }, 0);
696
847
 
697
848
  var scrollProps = !helper.isEmpty2(expandedRowRender) ? {
698
849
  expandedRowRender: expandedRowRender
699
850
  } : {
700
851
  scroll: {
701
- x: widthX,
852
+ x: _someInstanceProperty(cols).call(cols, function (item) {
853
+ return !helper.isEmpty2(item.fixed);
854
+ }) ? widthX : true,
702
855
  y: maxHeight
703
856
  }
704
857
  };
858
+
859
+ var _this$getPropsByCheck = _this.getPropsByCheckbox2(items),
860
+ onRowClick = _this$getPropsByCheck.onRowClick,
861
+ extraProps = _objectWithoutProperties(_this$getPropsByCheck, _excluded);
862
+
705
863
  return _objectSpread(_objectSpread({
706
864
  className: !isEmphasized ? variables('SuperTable2') : variables('SuperTable2').noTransition,
707
865
  columns: _this.getColumns(cols),
@@ -712,6 +870,12 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
712
870
  size: 'small',
713
871
  pagination: pagination,
714
872
  footer: footer,
873
+ onRow: dragSort ? _this.getRowPropsForDrag() : _this.getRowProps(onRowClick),
874
+ components: dragSort ? {
875
+ body: {
876
+ row: DragSortRow
877
+ }
878
+ } : {},
715
879
  locale: _this.props.emptyText ? {
716
880
  emptyText: _this.props.emptyText
717
881
  } : null
@@ -767,7 +931,8 @@ _defineProperty(SuperTable2, "propTypes", {
767
931
  emptyText: PropTypes.string,
768
932
  footer: PropTypes.func,
769
933
  callback: PropTypes.shape(CallbackType),
770
- isEmphasized: PropTypes.bool
934
+ isEmphasized: PropTypes.bool,
935
+ dragSort: PropTypes.bool
771
936
  });
772
937
 
773
938
  export default SuperTable2;
@@ -40,6 +40,10 @@ _Object$defineProperty(exports, "__esModule", {
40
40
 
41
41
  exports["default"] = void 0;
42
42
 
43
+ var _table = _interopRequireDefault(require("antd/lib/table"));
44
+
45
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
46
+
43
47
  var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
44
48
 
45
49
  var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
@@ -54,9 +58,9 @@ var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-sta
54
58
 
55
59
  var _reduce = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
56
60
 
57
- var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
61
+ var _some = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/some"));
58
62
 
59
- var _table = _interopRequireDefault(require("antd/lib/table"));
63
+ var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
60
64
 
61
65
  var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
62
66
 
@@ -100,6 +104,10 @@ var _variables = _interopRequireDefault(require("../variables"));
100
104
 
101
105
  var _helper = _interopRequireWildcard(require("../helper"));
102
106
 
107
+ var _DragSortRow = _interopRequireDefault(require("../SuperTable/DragSortRow"));
108
+
109
+ var _excluded = ["onRowClick"];
110
+
103
111
  function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
104
112
 
105
113
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -173,8 +181,11 @@ var CallbackType = {
173
181
  onToolbar: _propTypes["default"].func,
174
182
  onDoubleClick: _propTypes["default"].func,
175
183
  onTableFileChange: _propTypes["default"].func,
176
- buildSuperUploadProps: _propTypes["default"].func //构建type===uploadImg时,SuperUpload组件需要的公共属性函数,已在项目公共文件state.js中提供,可直接引用
177
-
184
+ buildSuperUploadProps: _propTypes["default"].func,
185
+ //构建type===uploadImg时,SuperUpload组件需要的公共属性函数,已在项目公共文件state.js中提供,可直接引用
186
+ onImgTileClick: _propTypes["default"].func,
187
+ //点击img类型标题触发事件
188
+ onMoveRow: _propTypes["default"].func
178
189
  };
179
190
  /**
180
191
  * base[可选]:序号的开始数字,所有回调函数中的序号值都会加上这个值,默认值为0
@@ -266,6 +277,20 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
266
277
  onDoubleClick && onDoubleClick(key, value);
267
278
  };
268
279
  });
280
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onImgTileClick", function (col, value, rowIndex) {
281
+ return function () {
282
+ var _ref9 = _this.props.callback || {},
283
+ onImgTileClick = _ref9.onImgTileClick;
284
+
285
+ onImgTileClick && onImgTileClick(col, value, rowIndex);
286
+ };
287
+ });
288
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onMoveRow", function (dragIndex, targetIndex) {
289
+ var _ref10 = _this.props.callback || {},
290
+ onMoveRow = _ref10.onMoveRow;
291
+
292
+ onMoveRow && onMoveRow(dragIndex, targetIndex);
293
+ });
269
294
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "closeValid", function () {
270
295
  var _this$props = _this.props,
271
296
  valid = _this$props.valid,
@@ -401,8 +426,8 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
401
426
  var split = index2 === list.length - 1 ? '' : ',';
402
427
 
403
428
  var onClick = function onClick() {
404
- var _ref9 = _this.props.callback || {},
405
- onLink = _ref9.onLink;
429
+ var _ref11 = _this.props.callback || {},
430
+ onLink = _ref11.onLink;
406
431
 
407
432
  onLink && onLink(col.key, index, item2);
408
433
  };
@@ -416,8 +441,8 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
416
441
  var title = typeof col.link === 'string' ? col.link : value;
417
442
 
418
443
  var onClick = function onClick() {
419
- var _ref10 = _this.props.callback || {},
420
- onLink = _ref10.onLink;
444
+ var _ref12 = _this.props.callback || {},
445
+ onLink = _ref12.onLink;
421
446
 
422
447
  onLink && onLink(col.key, index, record);
423
448
  };
@@ -519,7 +544,7 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
519
544
  }) : /*#__PURE__*/_react["default"].createElement("div", {
520
545
  role: 'imgBox',
521
546
  style: {
522
- maxWidth: '120px'
547
+ maxWidth: "".concat(col.width, "px")
523
548
  }
524
549
  }, /*#__PURE__*/_react["default"].createElement("img", {
525
550
  src: value.img,
@@ -533,8 +558,13 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
533
558
  }
534
559
  }, /*#__PURE__*/_react["default"].createElement("span", {
535
560
  style: {
536
- display: 'block'
537
- }
561
+ display: 'block',
562
+ whiteSpace: 'nowrap',
563
+ overflow: 'hidden',
564
+ textOverflow: 'ellipsis',
565
+ width: '80px'
566
+ },
567
+ onClick: _this.onImgTileClick(col, record, index)
538
568
  }, value.title), _helper["default"].isEmpty2(value.remark) ? null : /*#__PURE__*/_react["default"].createElement("span", {
539
569
  style: {
540
570
  color: '#333'
@@ -597,12 +627,12 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
597
627
  return null;
598
628
  }
599
629
  });
600
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getColumnTitle", function (_ref11) {
601
- var required = _ref11.required,
602
- title = _ref11.title,
603
- type = _ref11.type,
604
- key = _ref11.key,
605
- showAdd = _ref11.showAdd;
630
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getColumnTitle", function (_ref13) {
631
+ var required = _ref13.required,
632
+ title = _ref13.title,
633
+ type = _ref13.type,
634
+ key = _ref13.key,
635
+ showAdd = _ref13.showAdd;
606
636
 
607
637
  if (type === 'checkbox') {
608
638
  var status = _this.getCheckedStatus(key);
@@ -617,9 +647,9 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
617
647
  }, title, _this.toAdd(key, showAdd));
618
648
  }
619
649
  });
620
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getColumnClassName", function (_ref12) {
621
- var type = _ref12.type,
622
- align = _ref12.align;
650
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getColumnClassName", function (_ref14) {
651
+ var type = _ref14.type,
652
+ align = _ref14.align;
623
653
 
624
654
  if (type === 'index' || type === 'checkbox') {
625
655
  return 'ant-table-selection-column';
@@ -638,14 +668,14 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
638
668
  var readonly = _this.props.readonly;
639
669
  return (0, _map["default"])(_context9 = (0, _filter["default"])(cols).call(cols, function (col) {
640
670
  return !col.hide;
641
- })).call(_context9, function (_ref13, index) {
671
+ })).call(_context9, function (_ref15, index) {
642
672
  var _context10;
643
673
 
644
- var col = (0, _extends2["default"])({}, _ref13);
674
+ var col = (0, _extends2["default"])({}, _ref15);
645
675
  col.className = _this.getColumnClassName(col);
646
676
  col.title = _this.getColumnTitle(col);
647
677
  col.dataIndex = col.key;
648
- col.width = col.width || (0, _includes["default"])(_context10 = ['index', 'checked']).call(_context10, col.key) ? 70 : 120; // const {props = {}} = col;
678
+ col.width = col.width ? col.width : (0, _includes["default"])(_context10 = ['index', 'checked']).call(_context10, col.key) ? 70 : col.type === 'img' ? 200 : 120; // const {props = {}} = col;
649
679
  // const {edit = false} = props
650
680
  // if (!(readonly || col.type === 'readonly') || !this.canReadonly(col.type)) {
651
681
  // if ( !edit && ['text', 'number', 'select', 'date', 'search', 'readonly', 'textArea', 'selectSearch'].includes(col.type)){
@@ -665,12 +695,12 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
665
695
  });
666
696
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getDataSource", function (items, cols) {
667
697
  return (0, _map["default"])(items).call(items, function (item, index) {
668
- return (0, _reduce["default"])(cols).call(cols, function (result, _ref14) {
698
+ return (0, _reduce["default"])(cols).call(cols, function (result, _ref16) {
669
699
  var _context11;
670
700
 
671
- var key = _ref14.key,
672
- type = _ref14.type,
673
- options = _ref14.options;
701
+ var key = _ref16.key,
702
+ type = _ref16.type,
703
+ options = _ref16.options;
674
704
 
675
705
  if (!_this.props.readonly && type && type !== 'readonly' && (!item.isReadonly || (0, _isArray["default"])(item.isReadonly) && !(0, _includes["default"])(_context11 = item.isReadonly).call(_context11, key))) {
676
706
  result[key] = item[key];
@@ -703,40 +733,165 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
703
733
  rowClassName: rowClassName
704
734
  };
705
735
  });
706
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getProps", function () {
707
- var _context12;
708
-
736
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getSelectedRowKeys", function (items) {
737
+ return (0, _reduce["default"])(items).call(items, function (result, item, index) {
738
+ item.checked && result.push(index);
739
+ return result;
740
+ }, []);
741
+ });
742
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getPropsByCheckbox2", function (items) {
709
743
  var _this$props3 = _this.props,
710
- cols = _this$props3.cols,
711
- items = _this$props3.items,
712
- _this$props3$style = _this$props3.style,
713
- style = _this$props3$style === void 0 ? {} : _this$props3$style,
714
- _this$props3$footer = _this$props3.footer,
715
- footer = _this$props3$footer === void 0 ? null : _this$props3$footer,
716
- _this$props3$paginati = _this$props3.pagination,
717
- pagination = _this$props3$paginati === void 0 ? false : _this$props3$paginati,
744
+ _this$props3$checkbox = _this$props3.checkbox,
745
+ checkbox = _this$props3$checkbox === void 0 ? true : _this$props3$checkbox,
746
+ _this$props3$radio = _this$props3.radio,
747
+ radio = _this$props3$radio === void 0 ? false : _this$props3$radio,
748
+ isolation = _this$props3.isolation,
749
+ _this$props3$checkedR = _this$props3.checkedRows,
750
+ checkedRows = _this$props3$checkedR === void 0 ? [] : _this$props3$checkedR,
718
751
  _this$props3$isEmphas = _this$props3.isEmphasized,
719
752
  isEmphasized = _this$props3$isEmphas === void 0 ? false : _this$props3$isEmphas,
720
- maxHeight = _this$props3.maxHeight,
721
- _this$props3$expanded = _this$props3.expandedRowRender,
722
- expandedRowRender = _this$props3$expanded === void 0 ? undefined : _this$props3$expanded,
723
- _this$props3$onExpand = _this$props3.onExpand,
724
- onExpand = _this$props3$onExpand === void 0 ? undefined : _this$props3$onExpand;
753
+ _this$props3$isWeaken = _this$props3.isWeaken,
754
+ isWeaken = _this$props3$isWeaken === void 0 ? true : _this$props3$isWeaken;
755
+
756
+ var rowClassName1 = function rowClassName1(record) {
757
+ if (items[record.key].__total) return (0, _variables["default"])('SuperTable').totalRow;
758
+ if (items[record.key].__warningRow) return (0, _variables["default"])('SuperTable').warningRow;
759
+ return (0, _includes["default"])(checkedRows).call(checkedRows, record.key) ? (0, _variables["default"])('SuperTable').select : '';
760
+ };
761
+
762
+ var rowClassName2 = function rowClassName2(record) {
763
+ if (items[record.key].__total) return (0, _variables["default"])('SuperTable').totalRow;
764
+ if (items[record.key].__warningRow) return (0, _variables["default"])('SuperTable').warningRow;
765
+
766
+ if (isEmphasized && items[record.key].__isEmphasized) {
767
+ return items[record.key].checked ? (0, _variables["default"])('SuperTable').emphasizedSelectRow : (0, _variables["default"])('SuperTable').emphasizedUnselectRow;
768
+ }
769
+
770
+ if (isWeaken && items[record.key].__isWeaken) {
771
+ return items[record.key].checked ? (0, _variables["default"])('SuperTable').weakenedSelectRow : (0, _variables["default"])('SuperTable').weakenedUnselectRow;
772
+ }
773
+
774
+ return items[record.key].checked ? (0, _variables["default"])('SuperTable').select : '';
775
+ };
776
+
777
+ if (checkbox) {
778
+ if (radio) {
779
+ return {
780
+ rowClassName: rowClassName1,
781
+ onRowClick: _this.onRadioRowClick,
782
+ rowSelection: {
783
+ type: 'radio',
784
+ selectedRowKeys: checkedRows,
785
+ onChange: _this.onRadioChange
786
+ }
787
+ };
788
+ } else if (isolation) {
789
+ return {
790
+ rowClassName: rowClassName1,
791
+ onRowClick: _this.onRowClick,
792
+ rowSelection: {
793
+ selectedRowKeys: checkedRows,
794
+ onChange: _this.onCheckChange,
795
+ getCheckboxProps: function getCheckboxProps(record) {
796
+ var checked = (0, _includes["default"])(checkedRows).call(checkedRows, record.key);
797
+ return {
798
+ checked: checked,
799
+ disabled: items[record.key].__isWeaken,
800
+ style: items[record.key].__total ? {
801
+ display: 'none'
802
+ } : {}
803
+ };
804
+ }
805
+ }
806
+ };
807
+ } else {
808
+ return {
809
+ rowClassName: rowClassName2,
810
+ onRowClick: _this.onRowClick,
811
+ rowSelection: {
812
+ selectedRowKeys: _this.getSelectedRowKeys(items),
813
+ onChange: _this.onChange,
814
+ getCheckboxProps: function getCheckboxProps(record) {
815
+ var checked = isWeaken && items[record.key].__isWeaken ? false : !!record.checked;
816
+ return {
817
+ checked: checked,
818
+ disabled: items[record.key].__isWeaken,
819
+ style: items[record.key].__total ? {
820
+ display: 'none'
821
+ } : {}
822
+ };
823
+ }
824
+ }
825
+ };
826
+ }
827
+ } else {
828
+ return {
829
+ rowClassName: rowClassName2
830
+ };
831
+ }
832
+ });
833
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getRowPropsForDrag", function () {
834
+ return function (record, index) {
835
+ return {
836
+ index: index,
837
+ onMoveRow: _this.onMoveRow
838
+ };
839
+ };
840
+ });
841
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getRowProps", function (onRowClick) {
842
+ return function (record) {
843
+ return {
844
+ onClick: function onClick() {
845
+ return onRowClick && onRowClick(record);
846
+ },
847
+ onDoubleClick: function onDoubleClick() {
848
+ return _this.onDoubleClick(record);
849
+ }
850
+ };
851
+ };
852
+ });
853
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getProps", function () {
854
+ var _context12;
855
+
856
+ var _this$props4 = _this.props,
857
+ cols = _this$props4.cols,
858
+ items = _this$props4.items,
859
+ _this$props4$style = _this$props4.style,
860
+ style = _this$props4$style === void 0 ? {} : _this$props4$style,
861
+ _this$props4$footer = _this$props4.footer,
862
+ footer = _this$props4$footer === void 0 ? null : _this$props4$footer,
863
+ _this$props4$paginati = _this$props4.pagination,
864
+ pagination = _this$props4$paginati === void 0 ? false : _this$props4$paginati,
865
+ dragSort = _this$props4.dragSort,
866
+ _this$props4$isEmphas = _this$props4.isEmphasized,
867
+ isEmphasized = _this$props4$isEmphas === void 0 ? false : _this$props4$isEmphas,
868
+ maxHeight = _this$props4.maxHeight,
869
+ _this$props4$expanded = _this$props4.expandedRowRender,
870
+ expandedRowRender = _this$props4$expanded === void 0 ? undefined : _this$props4$expanded,
871
+ _this$props4$onExpand = _this$props4.onExpand,
872
+ onExpand = _this$props4$onExpand === void 0 ? undefined : _this$props4$onExpand;
725
873
  var widthX = (0, _reduce["default"])(_context12 = (0, _filter["default"])(cols).call(cols, function (col) {
726
874
  return !col.hide;
727
875
  })).call(_context12, function (width, item) {
728
876
  var _context13;
729
877
 
730
- return width += item.width ? item.width : (0, _includes["default"])(_context13 = ['index', 'checked']).call(_context13, item.key) ? 70 : 120;
878
+ return width += item.width ? item.width : (0, _includes["default"])(_context13 = ['index', 'checked']).call(_context13, item.key) ? 70 : item.type === 'img' ? 200 : 120;
731
879
  }, 0);
732
880
  var scrollProps = !_helper["default"].isEmpty2(expandedRowRender) ? {
733
881
  expandedRowRender: expandedRowRender
734
882
  } : {
735
883
  scroll: {
736
- x: widthX,
884
+ x: (0, _some["default"])(cols).call(cols, function (item) {
885
+ return !_helper["default"].isEmpty2(item.fixed);
886
+ }) ? widthX : true,
737
887
  y: maxHeight
738
888
  }
739
889
  };
890
+
891
+ var _this$getPropsByCheck = _this.getPropsByCheckbox2(items),
892
+ onRowClick = _this$getPropsByCheck.onRowClick,
893
+ extraProps = (0, _objectWithoutProperties2["default"])(_this$getPropsByCheck, _excluded);
894
+
740
895
  return _objectSpread(_objectSpread({
741
896
  className: !isEmphasized ? (0, _variables["default"])('SuperTable2') : (0, _variables["default"])('SuperTable2').noTransition,
742
897
  columns: _this.getColumns(cols),
@@ -747,6 +902,12 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
747
902
  size: 'small',
748
903
  pagination: pagination,
749
904
  footer: footer,
905
+ onRow: dragSort ? _this.getRowPropsForDrag() : _this.getRowProps(onRowClick),
906
+ components: dragSort ? {
907
+ body: {
908
+ row: _DragSortRow["default"]
909
+ }
910
+ } : {},
750
911
  locale: _this.props.emptyText ? {
751
912
  emptyText: _this.props.emptyText
752
913
  } : null
@@ -800,7 +961,8 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
800
961
  emptyText: _propTypes["default"].string,
801
962
  footer: _propTypes["default"].func,
802
963
  callback: _propTypes["default"].shape(CallbackType),
803
- isEmphasized: _propTypes["default"].bool
964
+ isEmphasized: _propTypes["default"].bool,
965
+ dragSort: _propTypes["default"].bool
804
966
  });
805
967
  var _default = SuperTable2;
806
968
  exports["default"] = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloud-b2b",
3
- "version": "1.1.9",
3
+ "version": "1.1.10",
4
4
  "description": "A react component library dependent antd",
5
5
  "keywords": [
6
6
  "react",