@bit-sun/business-component 2.3.3 → 2.3.5

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.
@@ -1,2 +1,4 @@
1
- declare const handleDefaultProps: (type: string) => {};
1
+ declare const handleDefaultProps: (type: string, otherRequestConfig: {
2
+ extralHeaders?: string;
3
+ } | undefined) => {};
2
4
  export { handleDefaultProps };
package/dist/index.esm.js CHANGED
@@ -9688,6 +9688,7 @@ var TreeSearchSelect = function TreeSearchSelect(props) {
9688
9688
  disabled = props.disabled,
9689
9689
  restProps = _objectWithoutProperties(props, _excluded$5);
9690
9690
  var url = remoteSource.url,
9691
+ headers = remoteSource.headers,
9691
9692
  _remoteSource$paramsK = remoteSource.paramsKey,
9692
9693
  paramsKey = _remoteSource$paramsK === void 0 ? 'qp-name-like' : _remoteSource$paramsK,
9693
9694
  _remoteSource$resKeyV = remoteSource.resKeyValue,
@@ -9718,7 +9719,9 @@ var TreeSearchSelect = function TreeSearchSelect(props) {
9718
9719
  /* 实时查询 但是目前用的直接是完整数据源, 所以没有使用 */
9719
9720
  var handleSearch = function handleSearch(q) {
9720
9721
  var paramsData = _objectSpread2(_defineProperty({}, "".concat(paramsKey), q), initialParams);
9721
- axios.get("".concat(url, "?").concat(stringify(paramsData))).then( /*#__PURE__*/function () {
9722
+ axios.get("".concat(url, "?").concat(stringify(paramsData)), {
9723
+ headers: headers
9724
+ }).then( /*#__PURE__*/function () {
9722
9725
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(res) {
9723
9726
  var _ctx$form;
9724
9727
  var resData, coverData, data, dataList;
@@ -9858,7 +9861,7 @@ var TreeSearchSelect = function TreeSearchSelect(props) {
9858
9861
  })));
9859
9862
  };
9860
9863
 
9861
- var handleDefaultProps = function handleDefaultProps(type) {
9864
+ var handleDefaultProps = function handleDefaultProps(type, otherRequestConfig) {
9862
9865
  var result = {};
9863
9866
  switch (type) {
9864
9867
  case 'department':
@@ -9867,6 +9870,7 @@ var handleDefaultProps = function handleDefaultProps(type) {
9867
9870
  isChoose: true,
9868
9871
  remoteSource: {
9869
9872
  url: "/user/orgViewNode/common/getTreeForOrgViewAndTenant",
9873
+ headers: otherRequestConfig === null || otherRequestConfig === void 0 ? void 0 : otherRequestConfig.extralHeaders,
9870
9874
  initialParams: {
9871
9875
  'orgViewCode': 'administrative-organization-view'
9872
9876
  },
@@ -9879,6 +9883,7 @@ var handleDefaultProps = function handleDefaultProps(type) {
9879
9883
  isChoose: true,
9880
9884
  remoteSource: {
9881
9885
  url: "/user/orgViewNode/common/getTreeForOrgViewAndTenant",
9886
+ headers: otherRequestConfig === null || otherRequestConfig === void 0 ? void 0 : otherRequestConfig.extralHeaders,
9882
9887
  initialParams: {
9883
9888
  'orgViewCode': 'sales-organizational-view',
9884
9889
  'qp-status-eq': 10
@@ -9892,6 +9897,7 @@ var handleDefaultProps = function handleDefaultProps(type) {
9892
9897
  isChoose: true,
9893
9898
  remoteSource: {
9894
9899
  url: "/user/orgViewNode/common/getTreeForOrgViewAndTenant",
9900
+ headers: otherRequestConfig === null || otherRequestConfig === void 0 ? void 0 : otherRequestConfig.extralHeaders,
9895
9901
  initialParams: {
9896
9902
  'orgViewCode': 'purchase-organizational-view',
9897
9903
  'qp-status-eq': 10
@@ -9905,6 +9911,7 @@ var handleDefaultProps = function handleDefaultProps(type) {
9905
9911
  isChoose: true,
9906
9912
  remoteSource: {
9907
9913
  url: "/user/orgViewNode/common/getTreeForOrgViewAndTenant",
9914
+ headers: otherRequestConfig === null || otherRequestConfig === void 0 ? void 0 : otherRequestConfig.extralHeaders,
9908
9915
  initialParams: {
9909
9916
  'orgViewCode': 'stock-organizational-view',
9910
9917
  'qp-status-eq': 10
@@ -9918,6 +9925,7 @@ var handleDefaultProps = function handleDefaultProps(type) {
9918
9925
  isChoose: true,
9919
9926
  remoteSource: {
9920
9927
  url: "/channel-manage/tagNode/getTree/10",
9928
+ headers: otherRequestConfig === null || otherRequestConfig === void 0 ? void 0 : otherRequestConfig.extralHeaders,
9921
9929
  resKeyValue: ['code', 'name']
9922
9930
  }
9923
9931
  };
@@ -9928,6 +9936,7 @@ var handleDefaultProps = function handleDefaultProps(type) {
9928
9936
  isChoose: true,
9929
9937
  remoteSource: {
9930
9938
  url: "/user/orgViewNode/common/getTreeForOrgViewAndTenant",
9939
+ headers: otherRequestConfig === null || otherRequestConfig === void 0 ? void 0 : otherRequestConfig.extralHeaders,
9931
9940
  initialParams: {
9932
9941
  'orgViewCode': 'administrative-organization-view'
9933
9942
  },
@@ -9942,7 +9951,7 @@ var handleDefaultProps = function handleDefaultProps(type) {
9942
9951
  var MemoTreeSearchSelect = /*#__PURE__*/React.memo(TreeSearchSelect);
9943
9952
  var BusinessTreeSearchSelect = function BusinessTreeSearchSelect(props) {
9944
9953
  var businessType = (props === null || props === void 0 ? void 0 : props.businessType) || 'department';
9945
- var handleBusinessProps = handleDefaultProps(businessType);
9954
+ var handleBusinessProps = handleDefaultProps(businessType, props === null || props === void 0 ? void 0 : props.requestConfig);
9946
9955
  var currentProps = useMemo(function () {
9947
9956
  return _objectSpread2(_objectSpread2({}, handleBusinessProps), props);
9948
9957
  }, [props === null || props === void 0 ? void 0 : props.value]);
@@ -16950,7 +16959,6 @@ var index$6 = /*#__PURE__*/forwardRef(function (props, ref) {
16950
16959
  colLastData: [],
16951
16960
  rowHeader: [],
16952
16961
  rowLastData: [],
16953
- colHeaderWidth: 400,
16954
16962
  colHeaderToTop: 0
16955
16963
  }),
16956
16964
  _useState4 = _slicedToArray(_useState3, 2),
@@ -16969,27 +16977,36 @@ var index$6 = /*#__PURE__*/forwardRef(function (props, ref) {
16969
16977
  viewCount = _useState10[0],
16970
16978
  setViewCount = _useState10[1]; //虚拟表格每次渲染数量
16971
16979
  var itemWidth = 100; // 表格每一项宽度
16980
+ var _useState11 = useState((props === null || props === void 0 ? void 0 : props.colHeaderWidth) || 400),
16981
+ _useState12 = _slicedToArray(_useState11, 2),
16982
+ realColHeaderWidth = _useState12[0],
16983
+ setLeftWidth = _useState12[1];
16972
16984
  var viewPort = useRef(null);
16973
16985
  var topScrollBar = useRef(null);
16986
+ var leftTableRef = useRef(null);
16974
16987
  //起始渲染item
16975
- var _useState11 = useState(0),
16976
- _useState12 = _slicedToArray(_useState11, 2),
16977
- startIndex = _useState12[0],
16978
- setStartIndex = _useState12[1];
16988
+ var _useState13 = useState(0),
16989
+ _useState14 = _slicedToArray(_useState13, 2),
16990
+ startIndex = _useState14[0],
16991
+ setStartIndex = _useState14[1];
16979
16992
  //结束渲染item
16980
16993
  var endIndex = useMemo(function () {
16981
16994
  return startIndex + viewCount;
16982
16995
  }, [startIndex, viewCount]);
16983
16996
  //表格偏移量
16984
- var _useState13 = useState(0),
16985
- _useState14 = _slicedToArray(_useState13, 2),
16986
- offsetWidth = _useState14[0],
16987
- setOffset = _useState14[1];
16997
+ var _useState15 = useState(0),
16998
+ _useState16 = _slicedToArray(_useState15, 2),
16999
+ offsetWidth = _useState16[0],
17000
+ setOffset = _useState16[1];
16988
17001
  useEffect(function () {
16989
- var viewPortWidth = viewPort.current.clientWidth;
16990
- var defaultTableWidth = viewPortWidth - (props.colHeaderWidth || 400);
16991
- var viewCount = Math.floor(defaultTableWidth / itemWidth) + 2 <= 10 ? 10 : Math.floor(defaultTableWidth / itemWidth) + 2;
16992
- setViewCount(viewCount);
17002
+ setTimeout(function () {
17003
+ var realLeftTableWidth = leftTableRef.current.clientWidth;
17004
+ var viewPortWidth = viewPort.current.clientWidth;
17005
+ var defaultTableWidth = viewPortWidth - realLeftTableWidth;
17006
+ var viewCount = Math.floor(defaultTableWidth / itemWidth) + 2 <= 10 ? 10 : Math.floor(defaultTableWidth / itemWidth) + 2;
17007
+ setViewCount(viewCount);
17008
+ setLeftWidth(realLeftTableWidth);
17009
+ });
16993
17010
  }, []);
16994
17011
  var onScroll = function onScroll() {
16995
17012
  if (topScrollBar.current) {
@@ -16997,6 +17014,9 @@ var index$6 = /*#__PURE__*/forwardRef(function (props, ref) {
16997
17014
  }
16998
17015
  var scrollWidth = viewPort.current.scrollLeft;
16999
17016
  var startIndex = Math.floor(scrollWidth / itemWidth);
17017
+ if (startIndex + viewCount >= colTableData.length) {
17018
+ startIndex = colTableData.length - viewCount;
17019
+ }
17000
17020
  var offsetWidth = startIndex * itemWidth;
17001
17021
  setStartIndex(startIndex);
17002
17022
  setOffset(offsetWidth);
@@ -17014,9 +17034,7 @@ var index$6 = /*#__PURE__*/forwardRef(function (props, ref) {
17014
17034
  // 设置表头相关信息
17015
17035
  useEffect(function () {
17016
17036
  var colData = props.colData,
17017
- rowData = props.rowData,
17018
- _props$colHeaderWidth = props.colHeaderWidth,
17019
- colHeaderWidth = _props$colHeaderWidth === void 0 ? 400 : _props$colHeaderWidth;
17037
+ rowData = props.rowData;
17020
17038
  var tableType;
17021
17039
  if (colData && colData.length && rowData && rowData.length) {
17022
17040
  tableType = 'multi-header-table';
@@ -17029,7 +17047,6 @@ var index$6 = /*#__PURE__*/forwardRef(function (props, ref) {
17029
17047
  rowHeader: [],
17030
17048
  rowLastData: []
17031
17049
  }, colHeaderData), rowHeaderData), {}, {
17032
- colHeaderWidth: colHeaderWidth,
17033
17050
  colHeaderToTop: ((rowHeader === null || rowHeader === void 0 ? void 0 : rowHeader.length) || 0) * 40,
17034
17051
  tableType: tableType
17035
17052
  }));
@@ -17042,7 +17059,6 @@ var index$6 = /*#__PURE__*/forwardRef(function (props, ref) {
17042
17059
  rowHeader: [],
17043
17060
  rowLastData: []
17044
17061
  }, _colHeaderData), {}, {
17045
- colHeaderWidth: colHeaderWidth || 400,
17046
17062
  colHeaderToTop: 0,
17047
17063
  tableType: tableType
17048
17064
  }));
@@ -17084,7 +17100,7 @@ var index$6 = /*#__PURE__*/forwardRef(function (props, ref) {
17084
17100
  tableProps = props.tableProps;
17085
17101
  var tableWidth = width ? "".concat(width, "px") : '100%';
17086
17102
  var tableHeight = "".concat(height || 400, "px");
17087
- var rightAreaWidth = 'calc(100% - ' + "".concat(config.colHeaderWidth, "px") + ')';
17103
+ var rightAreaWidth = 'calc(100% - ' + "".concat(realColHeaderWidth, "px") + ')';
17088
17104
  return /*#__PURE__*/React.createElement("div", {
17089
17105
  style: {
17090
17106
  width: tableWidth,
@@ -17100,7 +17116,7 @@ var index$6 = /*#__PURE__*/forwardRef(function (props, ref) {
17100
17116
  ref: topScrollBar
17101
17117
  }), /*#__PURE__*/React.createElement("div", {
17102
17118
  style: {
17103
- width: "".concat(config.colHeaderWidth + 1 + placeholderWidth, "px"),
17119
+ width: "".concat(realColHeaderWidth + placeholderWidth, "px"),
17104
17120
  position: 'absolute',
17105
17121
  top: 0,
17106
17122
  left: 0,
@@ -17108,7 +17124,7 @@ var index$6 = /*#__PURE__*/forwardRef(function (props, ref) {
17108
17124
  }
17109
17125
  }), /*#__PURE__*/React.createElement("table", {
17110
17126
  style: {
17111
- width: "".concat(config.colHeaderWidth + 1, "px"),
17127
+ width: "".concat(realColHeaderWidth, "px"),
17112
17128
  height: "".concat(config.colHeaderToTop, "px"),
17113
17129
  display: config.tableType === 'col-header-table' ? 'none' : ''
17114
17130
  },
@@ -17117,11 +17133,12 @@ var index$6 = /*#__PURE__*/forwardRef(function (props, ref) {
17117
17133
  style: {
17118
17134
  tableLayout: 'auto',
17119
17135
  minWidth: '100px',
17120
- width: "".concat(config.colHeaderWidth + 1, "px"),
17136
+ width: "".concat(realColHeaderWidth, "px"),
17121
17137
  top: "".concat(config.colHeaderToTop, "px"),
17122
17138
  left: '0px',
17123
17139
  position: 'sticky'
17124
17140
  },
17141
+ ref: leftTableRef,
17125
17142
  className: 'south__west'.concat(" ", 'editTable__block', " ", 'table_border_style')
17126
17143
  }, /*#__PURE__*/React.createElement("tbody", null, config.colHeader.map(function (item, index) {
17127
17144
  return /*#__PURE__*/React.createElement("tr", null, item.map(function (innerItem) {
@@ -17147,7 +17164,7 @@ var index$6 = /*#__PURE__*/forwardRef(function (props, ref) {
17147
17164
  style: {
17148
17165
  width: '100%',
17149
17166
  top: 0,
17150
- left: "".concat(config.colHeaderWidth, "px"),
17167
+ left: "".concat(realColHeaderWidth, "px"),
17151
17168
  position: 'absolute',
17152
17169
  display: config.tableType === 'col-header-table' ? 'none' : ''
17153
17170
  }
@@ -17173,7 +17190,7 @@ var index$6 = /*#__PURE__*/forwardRef(function (props, ref) {
17173
17190
  }))), /*#__PURE__*/React.createElement("div", {
17174
17191
  style: {
17175
17192
  position: 'absolute',
17176
- left: "".concat(config.colHeaderWidth, "px"),
17193
+ left: "".concat(realColHeaderWidth, "px"),
17177
17194
  top: "".concat(config.colHeaderToTop, "px"),
17178
17195
  minWidth: rightAreaWidth,
17179
17196
  zIndex: 0
package/dist/index.js CHANGED
@@ -9707,6 +9707,7 @@ var TreeSearchSelect = function TreeSearchSelect(props) {
9707
9707
  disabled = props.disabled,
9708
9708
  restProps = _objectWithoutProperties(props, _excluded$5);
9709
9709
  var url = remoteSource.url,
9710
+ headers = remoteSource.headers,
9710
9711
  _remoteSource$paramsK = remoteSource.paramsKey,
9711
9712
  paramsKey = _remoteSource$paramsK === void 0 ? 'qp-name-like' : _remoteSource$paramsK,
9712
9713
  _remoteSource$resKeyV = remoteSource.resKeyValue,
@@ -9737,7 +9738,9 @@ var TreeSearchSelect = function TreeSearchSelect(props) {
9737
9738
  /* 实时查询 但是目前用的直接是完整数据源, 所以没有使用 */
9738
9739
  var handleSearch = function handleSearch(q) {
9739
9740
  var paramsData = _objectSpread2(_defineProperty({}, "".concat(paramsKey), q), initialParams);
9740
- axios__default['default'].get("".concat(url, "?").concat(querystring.stringify(paramsData))).then( /*#__PURE__*/function () {
9741
+ axios__default['default'].get("".concat(url, "?").concat(querystring.stringify(paramsData)), {
9742
+ headers: headers
9743
+ }).then( /*#__PURE__*/function () {
9741
9744
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(res) {
9742
9745
  var _ctx$form;
9743
9746
  var resData, coverData, data, dataList;
@@ -9877,7 +9880,7 @@ var TreeSearchSelect = function TreeSearchSelect(props) {
9877
9880
  })));
9878
9881
  };
9879
9882
 
9880
- var handleDefaultProps = function handleDefaultProps(type) {
9883
+ var handleDefaultProps = function handleDefaultProps(type, otherRequestConfig) {
9881
9884
  var result = {};
9882
9885
  switch (type) {
9883
9886
  case 'department':
@@ -9886,6 +9889,7 @@ var handleDefaultProps = function handleDefaultProps(type) {
9886
9889
  isChoose: true,
9887
9890
  remoteSource: {
9888
9891
  url: "/user/orgViewNode/common/getTreeForOrgViewAndTenant",
9892
+ headers: otherRequestConfig === null || otherRequestConfig === void 0 ? void 0 : otherRequestConfig.extralHeaders,
9889
9893
  initialParams: {
9890
9894
  'orgViewCode': 'administrative-organization-view'
9891
9895
  },
@@ -9898,6 +9902,7 @@ var handleDefaultProps = function handleDefaultProps(type) {
9898
9902
  isChoose: true,
9899
9903
  remoteSource: {
9900
9904
  url: "/user/orgViewNode/common/getTreeForOrgViewAndTenant",
9905
+ headers: otherRequestConfig === null || otherRequestConfig === void 0 ? void 0 : otherRequestConfig.extralHeaders,
9901
9906
  initialParams: {
9902
9907
  'orgViewCode': 'sales-organizational-view',
9903
9908
  'qp-status-eq': 10
@@ -9911,6 +9916,7 @@ var handleDefaultProps = function handleDefaultProps(type) {
9911
9916
  isChoose: true,
9912
9917
  remoteSource: {
9913
9918
  url: "/user/orgViewNode/common/getTreeForOrgViewAndTenant",
9919
+ headers: otherRequestConfig === null || otherRequestConfig === void 0 ? void 0 : otherRequestConfig.extralHeaders,
9914
9920
  initialParams: {
9915
9921
  'orgViewCode': 'purchase-organizational-view',
9916
9922
  'qp-status-eq': 10
@@ -9924,6 +9930,7 @@ var handleDefaultProps = function handleDefaultProps(type) {
9924
9930
  isChoose: true,
9925
9931
  remoteSource: {
9926
9932
  url: "/user/orgViewNode/common/getTreeForOrgViewAndTenant",
9933
+ headers: otherRequestConfig === null || otherRequestConfig === void 0 ? void 0 : otherRequestConfig.extralHeaders,
9927
9934
  initialParams: {
9928
9935
  'orgViewCode': 'stock-organizational-view',
9929
9936
  'qp-status-eq': 10
@@ -9937,6 +9944,7 @@ var handleDefaultProps = function handleDefaultProps(type) {
9937
9944
  isChoose: true,
9938
9945
  remoteSource: {
9939
9946
  url: "/channel-manage/tagNode/getTree/10",
9947
+ headers: otherRequestConfig === null || otherRequestConfig === void 0 ? void 0 : otherRequestConfig.extralHeaders,
9940
9948
  resKeyValue: ['code', 'name']
9941
9949
  }
9942
9950
  };
@@ -9947,6 +9955,7 @@ var handleDefaultProps = function handleDefaultProps(type) {
9947
9955
  isChoose: true,
9948
9956
  remoteSource: {
9949
9957
  url: "/user/orgViewNode/common/getTreeForOrgViewAndTenant",
9958
+ headers: otherRequestConfig === null || otherRequestConfig === void 0 ? void 0 : otherRequestConfig.extralHeaders,
9950
9959
  initialParams: {
9951
9960
  'orgViewCode': 'administrative-organization-view'
9952
9961
  },
@@ -9961,7 +9970,7 @@ var handleDefaultProps = function handleDefaultProps(type) {
9961
9970
  var MemoTreeSearchSelect = /*#__PURE__*/React__default['default'].memo(TreeSearchSelect);
9962
9971
  var BusinessTreeSearchSelect = function BusinessTreeSearchSelect(props) {
9963
9972
  var businessType = (props === null || props === void 0 ? void 0 : props.businessType) || 'department';
9964
- var handleBusinessProps = handleDefaultProps(businessType);
9973
+ var handleBusinessProps = handleDefaultProps(businessType, props === null || props === void 0 ? void 0 : props.requestConfig);
9965
9974
  var currentProps = React.useMemo(function () {
9966
9975
  return _objectSpread2(_objectSpread2({}, handleBusinessProps), props);
9967
9976
  }, [props === null || props === void 0 ? void 0 : props.value]);
@@ -16969,7 +16978,6 @@ var index$6 = /*#__PURE__*/React.forwardRef(function (props, ref) {
16969
16978
  colLastData: [],
16970
16979
  rowHeader: [],
16971
16980
  rowLastData: [],
16972
- colHeaderWidth: 400,
16973
16981
  colHeaderToTop: 0
16974
16982
  }),
16975
16983
  _useState4 = _slicedToArray(_useState3, 2),
@@ -16988,27 +16996,36 @@ var index$6 = /*#__PURE__*/React.forwardRef(function (props, ref) {
16988
16996
  viewCount = _useState10[0],
16989
16997
  setViewCount = _useState10[1]; //虚拟表格每次渲染数量
16990
16998
  var itemWidth = 100; // 表格每一项宽度
16999
+ var _useState11 = React.useState((props === null || props === void 0 ? void 0 : props.colHeaderWidth) || 400),
17000
+ _useState12 = _slicedToArray(_useState11, 2),
17001
+ realColHeaderWidth = _useState12[0],
17002
+ setLeftWidth = _useState12[1];
16991
17003
  var viewPort = React.useRef(null);
16992
17004
  var topScrollBar = React.useRef(null);
17005
+ var leftTableRef = React.useRef(null);
16993
17006
  //起始渲染item
16994
- var _useState11 = React.useState(0),
16995
- _useState12 = _slicedToArray(_useState11, 2),
16996
- startIndex = _useState12[0],
16997
- setStartIndex = _useState12[1];
17007
+ var _useState13 = React.useState(0),
17008
+ _useState14 = _slicedToArray(_useState13, 2),
17009
+ startIndex = _useState14[0],
17010
+ setStartIndex = _useState14[1];
16998
17011
  //结束渲染item
16999
17012
  var endIndex = React.useMemo(function () {
17000
17013
  return startIndex + viewCount;
17001
17014
  }, [startIndex, viewCount]);
17002
17015
  //表格偏移量
17003
- var _useState13 = React.useState(0),
17004
- _useState14 = _slicedToArray(_useState13, 2),
17005
- offsetWidth = _useState14[0],
17006
- setOffset = _useState14[1];
17016
+ var _useState15 = React.useState(0),
17017
+ _useState16 = _slicedToArray(_useState15, 2),
17018
+ offsetWidth = _useState16[0],
17019
+ setOffset = _useState16[1];
17007
17020
  React.useEffect(function () {
17008
- var viewPortWidth = viewPort.current.clientWidth;
17009
- var defaultTableWidth = viewPortWidth - (props.colHeaderWidth || 400);
17010
- var viewCount = Math.floor(defaultTableWidth / itemWidth) + 2 <= 10 ? 10 : Math.floor(defaultTableWidth / itemWidth) + 2;
17011
- setViewCount(viewCount);
17021
+ setTimeout(function () {
17022
+ var realLeftTableWidth = leftTableRef.current.clientWidth;
17023
+ var viewPortWidth = viewPort.current.clientWidth;
17024
+ var defaultTableWidth = viewPortWidth - realLeftTableWidth;
17025
+ var viewCount = Math.floor(defaultTableWidth / itemWidth) + 2 <= 10 ? 10 : Math.floor(defaultTableWidth / itemWidth) + 2;
17026
+ setViewCount(viewCount);
17027
+ setLeftWidth(realLeftTableWidth);
17028
+ });
17012
17029
  }, []);
17013
17030
  var onScroll = function onScroll() {
17014
17031
  if (topScrollBar.current) {
@@ -17016,6 +17033,9 @@ var index$6 = /*#__PURE__*/React.forwardRef(function (props, ref) {
17016
17033
  }
17017
17034
  var scrollWidth = viewPort.current.scrollLeft;
17018
17035
  var startIndex = Math.floor(scrollWidth / itemWidth);
17036
+ if (startIndex + viewCount >= colTableData.length) {
17037
+ startIndex = colTableData.length - viewCount;
17038
+ }
17019
17039
  var offsetWidth = startIndex * itemWidth;
17020
17040
  setStartIndex(startIndex);
17021
17041
  setOffset(offsetWidth);
@@ -17033,9 +17053,7 @@ var index$6 = /*#__PURE__*/React.forwardRef(function (props, ref) {
17033
17053
  // 设置表头相关信息
17034
17054
  React.useEffect(function () {
17035
17055
  var colData = props.colData,
17036
- rowData = props.rowData,
17037
- _props$colHeaderWidth = props.colHeaderWidth,
17038
- colHeaderWidth = _props$colHeaderWidth === void 0 ? 400 : _props$colHeaderWidth;
17056
+ rowData = props.rowData;
17039
17057
  var tableType;
17040
17058
  if (colData && colData.length && rowData && rowData.length) {
17041
17059
  tableType = 'multi-header-table';
@@ -17048,7 +17066,6 @@ var index$6 = /*#__PURE__*/React.forwardRef(function (props, ref) {
17048
17066
  rowHeader: [],
17049
17067
  rowLastData: []
17050
17068
  }, colHeaderData), rowHeaderData), {}, {
17051
- colHeaderWidth: colHeaderWidth,
17052
17069
  colHeaderToTop: ((rowHeader === null || rowHeader === void 0 ? void 0 : rowHeader.length) || 0) * 40,
17053
17070
  tableType: tableType
17054
17071
  }));
@@ -17061,7 +17078,6 @@ var index$6 = /*#__PURE__*/React.forwardRef(function (props, ref) {
17061
17078
  rowHeader: [],
17062
17079
  rowLastData: []
17063
17080
  }, _colHeaderData), {}, {
17064
- colHeaderWidth: colHeaderWidth || 400,
17065
17081
  colHeaderToTop: 0,
17066
17082
  tableType: tableType
17067
17083
  }));
@@ -17103,7 +17119,7 @@ var index$6 = /*#__PURE__*/React.forwardRef(function (props, ref) {
17103
17119
  tableProps = props.tableProps;
17104
17120
  var tableWidth = width ? "".concat(width, "px") : '100%';
17105
17121
  var tableHeight = "".concat(height || 400, "px");
17106
- var rightAreaWidth = 'calc(100% - ' + "".concat(config.colHeaderWidth, "px") + ')';
17122
+ var rightAreaWidth = 'calc(100% - ' + "".concat(realColHeaderWidth, "px") + ')';
17107
17123
  return /*#__PURE__*/React__default['default'].createElement("div", {
17108
17124
  style: {
17109
17125
  width: tableWidth,
@@ -17119,7 +17135,7 @@ var index$6 = /*#__PURE__*/React.forwardRef(function (props, ref) {
17119
17135
  ref: topScrollBar
17120
17136
  }), /*#__PURE__*/React__default['default'].createElement("div", {
17121
17137
  style: {
17122
- width: "".concat(config.colHeaderWidth + 1 + placeholderWidth, "px"),
17138
+ width: "".concat(realColHeaderWidth + placeholderWidth, "px"),
17123
17139
  position: 'absolute',
17124
17140
  top: 0,
17125
17141
  left: 0,
@@ -17127,7 +17143,7 @@ var index$6 = /*#__PURE__*/React.forwardRef(function (props, ref) {
17127
17143
  }
17128
17144
  }), /*#__PURE__*/React__default['default'].createElement("table", {
17129
17145
  style: {
17130
- width: "".concat(config.colHeaderWidth + 1, "px"),
17146
+ width: "".concat(realColHeaderWidth, "px"),
17131
17147
  height: "".concat(config.colHeaderToTop, "px"),
17132
17148
  display: config.tableType === 'col-header-table' ? 'none' : ''
17133
17149
  },
@@ -17136,11 +17152,12 @@ var index$6 = /*#__PURE__*/React.forwardRef(function (props, ref) {
17136
17152
  style: {
17137
17153
  tableLayout: 'auto',
17138
17154
  minWidth: '100px',
17139
- width: "".concat(config.colHeaderWidth + 1, "px"),
17155
+ width: "".concat(realColHeaderWidth, "px"),
17140
17156
  top: "".concat(config.colHeaderToTop, "px"),
17141
17157
  left: '0px',
17142
17158
  position: 'sticky'
17143
17159
  },
17160
+ ref: leftTableRef,
17144
17161
  className: 'south__west'.concat(" ", 'editTable__block', " ", 'table_border_style')
17145
17162
  }, /*#__PURE__*/React__default['default'].createElement("tbody", null, config.colHeader.map(function (item, index) {
17146
17163
  return /*#__PURE__*/React__default['default'].createElement("tr", null, item.map(function (innerItem) {
@@ -17166,7 +17183,7 @@ var index$6 = /*#__PURE__*/React.forwardRef(function (props, ref) {
17166
17183
  style: {
17167
17184
  width: '100%',
17168
17185
  top: 0,
17169
- left: "".concat(config.colHeaderWidth, "px"),
17186
+ left: "".concat(realColHeaderWidth, "px"),
17170
17187
  position: 'absolute',
17171
17188
  display: config.tableType === 'col-header-table' ? 'none' : ''
17172
17189
  }
@@ -17192,7 +17209,7 @@ var index$6 = /*#__PURE__*/React.forwardRef(function (props, ref) {
17192
17209
  }))), /*#__PURE__*/React__default['default'].createElement("div", {
17193
17210
  style: {
17194
17211
  position: 'absolute',
17195
- left: "".concat(config.colHeaderWidth, "px"),
17212
+ left: "".concat(realColHeaderWidth, "px"),
17196
17213
  top: "".concat(config.colHeaderToTop, "px"),
17197
17214
  minWidth: rightAreaWidth,
17198
17215
  zIndex: 0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bit-sun/business-component",
3
- "version": "2.3.3",
3
+ "version": "2.3.5",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -7,8 +7,7 @@ const MemoTreeSearchSelect = React.memo(TreeSearchSelect)
7
7
  const BusinessTreeSearchSelect = (props: any) => {
8
8
  const businessType = props?.businessType || 'department';
9
9
 
10
- const handleBusinessProps = handleDefaultProps(businessType);
11
-
10
+ const handleBusinessProps = handleDefaultProps(businessType, props?.requestConfig);
12
11
  const currentProps = useMemo(() => {
13
12
  return {
14
13
  ...handleBusinessProps,
@@ -1,4 +1,4 @@
1
- const handleDefaultProps = (type: string) => {
1
+ const handleDefaultProps = (type: string, otherRequestConfig: {extralHeaders?: string}|undefined) => {
2
2
  let result = {};
3
3
  switch (type){
4
4
  case 'department':
@@ -7,6 +7,7 @@ const handleDefaultProps = (type: string) => {
7
7
  isChoose: true,
8
8
  remoteSource: {
9
9
  url: `/user/orgViewNode/common/getTreeForOrgViewAndTenant`,
10
+ headers: otherRequestConfig?.extralHeaders,
10
11
  initialParams: { 'orgViewCode': 'administrative-organization-view' },
11
12
  resKeyValue: ['code', 'name'],
12
13
  },
@@ -17,6 +18,7 @@ const handleDefaultProps = (type: string) => {
17
18
  isChoose: true,
18
19
  remoteSource: {
19
20
  url: `/user/orgViewNode/common/getTreeForOrgViewAndTenant`,
21
+ headers: otherRequestConfig?.extralHeaders,
20
22
  initialParams: { 'orgViewCode': 'sales-organizational-view', 'qp-status-eq': 10 }, // status: 10启用 20禁用
21
23
  resKeyValue: ['code', 'name'],
22
24
  },
@@ -27,6 +29,7 @@ const handleDefaultProps = (type: string) => {
27
29
  isChoose: true,
28
30
  remoteSource: {
29
31
  url: `/user/orgViewNode/common/getTreeForOrgViewAndTenant`,
32
+ headers: otherRequestConfig?.extralHeaders,
30
33
  initialParams: { 'orgViewCode': 'purchase-organizational-view', 'qp-status-eq': 10 },
31
34
  resKeyValue: ['code', 'name'],
32
35
  },
@@ -37,6 +40,7 @@ const handleDefaultProps = (type: string) => {
37
40
  isChoose: true,
38
41
  remoteSource: {
39
42
  url: `/user/orgViewNode/common/getTreeForOrgViewAndTenant`,
43
+ headers: otherRequestConfig?.extralHeaders,
40
44
  initialParams: { 'orgViewCode': 'stock-organizational-view', 'qp-status-eq': 10 },
41
45
  resKeyValue: ['code', 'name'],
42
46
  },
@@ -47,6 +51,7 @@ const handleDefaultProps = (type: string) => {
47
51
  isChoose: true,
48
52
  remoteSource: {
49
53
  url: `/channel-manage/tagNode/getTree/10`,
54
+ headers: otherRequestConfig?.extralHeaders,
50
55
  resKeyValue: ['code', 'name'],
51
56
  },
52
57
  };
@@ -57,6 +62,7 @@ const handleDefaultProps = (type: string) => {
57
62
  isChoose: true,
58
63
  remoteSource: {
59
64
  url: `/user/orgViewNode/common/getTreeForOrgViewAndTenant`,
65
+ headers: otherRequestConfig?.extralHeaders,
60
66
  initialParams: { 'orgViewCode': 'administrative-organization-view' },
61
67
  resKeyValue: ['code', 'name'],
62
68
  },
@@ -22,7 +22,7 @@ export default () => {
22
22
  const colTableRef = useRef(null);
23
23
 
24
24
  let colTableData = [];
25
- for (let i = 1; i < 10001; i++) {
25
+ for (let i = 1; i < 1001; i++) {
26
26
  colTableData.push({
27
27
  '1111-1-2': '1',
28
28
  '1111-1-3': '2',
@@ -35,7 +35,7 @@ export default () => {
35
35
  'fixed2': `标题1-${i}`,
36
36
  })
37
37
  }
38
- for (let j = 1; j < 10001; j++) {
38
+ for (let j = 1; j < 1001; j++) {
39
39
  colTableData.push({
40
40
  '1111-1-2': '1',
41
41
  '1111-1-3': '2',
@@ -13,16 +13,17 @@ export default forwardRef((props, ref) => {
13
13
  colLastData: [],
14
14
  rowHeader: [],
15
15
  rowLastData: [],
16
- colHeaderWidth: 400,
17
16
  colHeaderToTop: 0,
18
17
  });
19
18
  const [colTableData, setColTableData] = useState([]); //纵向表头数据
20
19
  const [multiTableData, setMmultiTableData] = useState({}); //多表头数据
21
20
  const [viewCount, setViewCount] = useState(10); //虚拟表格每次渲染数量
22
21
  const itemWidth = 100; // 表格每一项宽度
22
+ const [realColHeaderWidth, setLeftWidth] = useState(props?.colHeaderWidth || 400);
23
23
 
24
24
  const viewPort = useRef(null);
25
- const topScrollBar = useRef(null)
25
+ const topScrollBar = useRef(null);
26
+ const leftTableRef = useRef(null);
26
27
 
27
28
  //起始渲染item
28
29
  const [startIndex, setStartIndex] = useState(0);
@@ -36,10 +37,14 @@ export default forwardRef((props, ref) => {
36
37
  const [offsetWidth, setOffset] = useState(0);
37
38
 
38
39
  useEffect(() => { //根据容器宽度计算每次渲染个数
39
- let viewPortWidth = viewPort.current.clientWidth;
40
- let defaultTableWidth = viewPortWidth - (props.colHeaderWidth || 400);
41
- let viewCount = Math.floor(defaultTableWidth/itemWidth) + 2 <= 10 ? 10 : Math.floor(defaultTableWidth/itemWidth) + 2;
42
- setViewCount(viewCount)
40
+ setTimeout(() => {
41
+ let realLeftTableWidth = leftTableRef.current.clientWidth;
42
+ let viewPortWidth = viewPort.current.clientWidth;
43
+ let defaultTableWidth = viewPortWidth - realLeftTableWidth;
44
+ let viewCount = Math.floor(defaultTableWidth/itemWidth) + 2 <= 10 ? 10 : Math.floor(defaultTableWidth/itemWidth) + 2;
45
+ setViewCount(viewCount)
46
+ setLeftWidth(realLeftTableWidth);
47
+ })
43
48
  }, [])
44
49
 
45
50
  const onScroll = () => {
@@ -47,7 +52,10 @@ export default forwardRef((props, ref) => {
47
52
  topScrollBar.current.scrollTo(viewPort.current.scrollLeft, 0)
48
53
  }
49
54
  const scrollWidth = viewPort.current.scrollLeft;
50
- const startIndex = Math.floor(scrollWidth/itemWidth);
55
+ let startIndex = Math.floor(scrollWidth/itemWidth);
56
+ if ( startIndex + viewCount >= colTableData.length) {
57
+ startIndex = colTableData.length - viewCount;
58
+ }
51
59
  const offsetWidth = startIndex * itemWidth;
52
60
  setStartIndex(startIndex);
53
61
  setOffset(offsetWidth);
@@ -66,7 +74,7 @@ export default forwardRef((props, ref) => {
66
74
 
67
75
  // 设置表头相关信息
68
76
  useEffect(() => {
69
- const { colData, rowData, colHeaderWidth=400 } = props;
77
+ const { colData, rowData } = props;
70
78
  let tableType;
71
79
  if (colData && colData.length && rowData && rowData.length) {
72
80
  tableType = 'multi-header-table';
@@ -80,7 +88,6 @@ export default forwardRef((props, ref) => {
80
88
  rowLastData: [],
81
89
  ...colHeaderData,
82
90
  ...rowHeaderData,
83
- colHeaderWidth: colHeaderWidth,
84
91
  colHeaderToTop: (rowHeader?.length || 0)*40,
85
92
  tableType: tableType
86
93
  })
@@ -93,7 +100,6 @@ export default forwardRef((props, ref) => {
93
100
  rowHeader: [],
94
101
  rowLastData: [],
95
102
  ...colHeaderData,
96
- colHeaderWidth: colHeaderWidth || 400,
97
103
  colHeaderToTop: 0,
98
104
  tableType: tableType
99
105
  })
@@ -143,7 +149,7 @@ export default forwardRef((props, ref) => {
143
149
  const {width, height, tableProps } = props;
144
150
  let tableWidth = width ? `${width}px` : '100%';
145
151
  let tableHeight = `${height || 400}px`;
146
- const rightAreaWidth = 'calc(100% - ' + `${config.colHeaderWidth}px` + ')';
152
+ const rightAreaWidth = 'calc(100% - ' + `${realColHeaderWidth}px` + ')';
147
153
  return (
148
154
  <div
149
155
  style={{width: tableWidth, height: tableHeight}}
@@ -158,7 +164,7 @@ export default forwardRef((props, ref) => {
158
164
  ref={topScrollBar}
159
165
  />
160
166
  <div style={{
161
- width: `${config.colHeaderWidth + 1 + placeholderWidth}px`,
167
+ width: `${realColHeaderWidth + placeholderWidth}px`,
162
168
  position: 'absolute',
163
169
  top: 0,
164
170
  left: 0,
@@ -168,7 +174,7 @@ export default forwardRef((props, ref) => {
168
174
  {/* -------------------------------------左上角区域--------------------------------------- */}
169
175
  <table
170
176
  style={{
171
- width: `${config.colHeaderWidth+1}px`,
177
+ width: `${realColHeaderWidth}px`,
172
178
  height: `${config.colHeaderToTop}px`,
173
179
  display: config.tableType === 'col-header-table' ? 'none' : '',
174
180
  }}
@@ -181,11 +187,12 @@ export default forwardRef((props, ref) => {
181
187
  style={{
182
188
  tableLayout:'auto',
183
189
  minWidth: '100px',
184
- width: `${config.colHeaderWidth+1}px`,
190
+ width: `${realColHeaderWidth}px`,
185
191
  top: `${config.colHeaderToTop}px`,
186
192
  left: '0px',
187
193
  position: 'sticky',
188
194
  }}
195
+ ref={leftTableRef}
189
196
  className={`${'south__west'} ${'editTable__block'} ${'table_border_style'}`}
190
197
  >
191
198
  <tbody>
@@ -225,7 +232,7 @@ export default forwardRef((props, ref) => {
225
232
  style={{
226
233
  width: '100%',
227
234
  top: 0,
228
- left: `${config.colHeaderWidth}px`,
235
+ left: `${realColHeaderWidth}px`,
229
236
  position: 'absolute',
230
237
  display: config.tableType === 'col-header-table' ? 'none' : ''
231
238
  }}
@@ -271,7 +278,7 @@ export default forwardRef((props, ref) => {
271
278
  <div
272
279
  style={{
273
280
  position: 'absolute',
274
- left: `${config.colHeaderWidth}px`,
281
+ left: `${realColHeaderWidth}px`,
275
282
  top: `${config.colHeaderToTop}px`,
276
283
  minWidth: rightAreaWidth,
277
284
  zIndex: 0,
@@ -34,6 +34,7 @@ const TreeSearchSelect = (props: any) => {
34
34
 
35
35
  const {
36
36
  url,
37
+ headers,
37
38
  paramsKey = 'qp-name-like',
38
39
  resKeyValue = ['id', 'name'],
39
40
  initialParams = {},
@@ -66,7 +67,7 @@ const TreeSearchSelect = (props: any) => {
66
67
  [`${paramsKey}`]: q,
67
68
  ...initialParams,
68
69
  }
69
- axios.get(`${url}?${stringify(paramsData)}`).then(async (res: any) => {
70
+ axios.get(`${url}?${stringify(paramsData)}`, {headers}).then(async (res: any) => {
70
71
  const resData = res?.data || [];
71
72
  let coverData;
72
73