@kmkf-fe-packages/basic-components 2.0.54-beta.66 → 2.0.54-beta.68

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.
package/dist/index.esm.js CHANGED
@@ -20583,9 +20583,10 @@ var MsgStatus = function MsgStatus(props) {
20583
20583
  }, "\u5931\u8D25\u539F\u56E0\uFF1A", (_value$changeIndex3 = value[changeIndex]) === null || _value$changeIndex3 === void 0 ? void 0 : _value$changeIndex3.reason) : null) : null);
20584
20584
  };
20585
20585
 
20586
- var _excluded$n = ["showOnly", "getOptionsAsync"];
20586
+ var _excluded$n = ["mode", "showOnly", "getOptionsAsync"];
20587
20587
  var AsyncSelect = function AsyncSelect(props) {
20588
- var _props$showOnly = props.showOnly,
20588
+ var mode = props.mode,
20589
+ _props$showOnly = props.showOnly,
20589
20590
  showOnly = _props$showOnly === void 0 ? false : _props$showOnly,
20590
20591
  getOptionsAsync = props.getOptionsAsync,
20591
20592
  otherProps = _objectWithoutProperties(props, _excluded$n);
@@ -20599,11 +20600,24 @@ var AsyncSelect = function AsyncSelect(props) {
20599
20600
  });
20600
20601
  }, []);
20601
20602
  var options = [].concat(_toConsumableArray(props.options || []), _toConsumableArray(data || []));
20603
+ var getValueString = function getValueString(value) {
20604
+ var list = options;
20605
+ if (!mode) {
20606
+ var selectedItem = list.find(function (item) {
20607
+ return item.value === value;
20608
+ });
20609
+ return selectedItem ? selectedItem.label : value !== null && value !== void 0 ? value : '--';
20610
+ } else if (mode === 'multiple' && Array.isArray(value)) {
20611
+ var _list$filter$map$join;
20612
+ return (_list$filter$map$join = list.filter(function (item) {
20613
+ return value.includes(item.value);
20614
+ }).map(function (item) {
20615
+ return item.label;
20616
+ }).join(',')) !== null && _list$filter$map$join !== void 0 ? _list$filter$map$join : '--';
20617
+ }
20618
+ };
20602
20619
  if (showOnly) {
20603
- var selectedItem = options.find(function (option) {
20604
- return option.value === props.value;
20605
- });
20606
- return selectedItem ? selectedItem.label : props.value;
20620
+ return getValueString(props.value);
20607
20621
  }
20608
20622
  return /*#__PURE__*/React.createElement(Select, _objectSpread2(_objectSpread2({
20609
20623
  showSearch: true,
@@ -20612,7 +20626,8 @@ var AsyncSelect = function AsyncSelect(props) {
20612
20626
  },
20613
20627
  notFoundContent: null
20614
20628
  }, otherProps), {}, {
20615
- options: options
20629
+ options: options,
20630
+ mode: mode
20616
20631
  }));
20617
20632
  };
20618
20633
 
@@ -21482,7 +21497,7 @@ var css_248z$d = ".index-module_imageBox__1f2AI {\n display: flex;\n flex-wrap
21482
21497
  var styles$6 = {"imageBox":"index-module_imageBox__1f2AI","addBtn":"index-module_addBtn__1DY59","tips":"index-module_tips__1XQjf"};
21483
21498
  styleInject(css_248z$d);
21484
21499
 
21485
- var _excluded$r = ["maxCount", "maxSize", "onChange", "value", "disabled", "hostUrl", "actionUrl"];
21500
+ var _excluded$r = ["maxCount", "maxSize", "onChange", "value", "disabled", "hostUrl", "canDownload", "actionUrl"];
21486
21501
  var Dragger$1 = Upload.Dragger;
21487
21502
  var fn$4 = function fn() {
21488
21503
  return void 0;
@@ -21501,6 +21516,8 @@ var KmVideo = function KmVideo(_ref) {
21501
21516
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
21502
21517
  _ref$hostUrl = _ref.hostUrl,
21503
21518
  hostUrl = _ref$hostUrl === void 0 ? '' : _ref$hostUrl,
21519
+ _ref$canDownload = _ref.canDownload,
21520
+ canDownload = _ref$canDownload === void 0 ? false : _ref$canDownload,
21504
21521
  _ref$actionUrl = _ref.actionUrl,
21505
21522
  actionUrl = _ref$actionUrl === void 0 ? '/qy/common/uploadWorkOrderImg' : _ref$actionUrl,
21506
21523
  resetProps = _objectWithoutProperties(_ref, _excluded$r);
@@ -21588,6 +21605,25 @@ var KmVideo = function KmVideo(_ref) {
21588
21605
  return _ref2.apply(this, arguments);
21589
21606
  };
21590
21607
  }();
21608
+ var download = function download(url, name) {
21609
+ if (url === null || url === void 0 ? void 0 : url.startsWith('https://erp-storage-video.oss-cn-beijing.aliyuncs.com')) {
21610
+ window.open(url);
21611
+ return;
21612
+ }
21613
+ fetch(url).then(function (res) {
21614
+ return res.blob();
21615
+ }).then(function (blob) {
21616
+ var a = document.createElement('a');
21617
+ document.body.appendChild(a);
21618
+ a.style.display = 'none';
21619
+ var url = window.URL.createObjectURL(blob);
21620
+ a.href = url;
21621
+ a.download = name;
21622
+ a.click();
21623
+ document.body.removeChild(a);
21624
+ window.URL.revokeObjectURL(url);
21625
+ });
21626
+ };
21591
21627
  var handleChange = function handleChange(list) {
21592
21628
  valueRef.current = list;
21593
21629
  onChange(list);
@@ -21671,7 +21707,12 @@ var KmVideo = function KmVideo(_ref) {
21671
21707
  title: fileName,
21672
21708
  footer: null,
21673
21709
  onCancel: handleCancel
21674
- }, /*#__PURE__*/React.createElement(CopyToClipboard, {
21710
+ }, canDownload ? /*#__PURE__*/React.createElement(Button, {
21711
+ type: "link",
21712
+ onClick: function onClick() {
21713
+ return download(fileUrl, fileName);
21714
+ }
21715
+ }, "\u4E0B\u8F7D") : /*#__PURE__*/React.createElement(CopyToClipboard, {
21675
21716
  text: fileUrl,
21676
21717
  onCopy: function onCopy() {
21677
21718
  message.success('复制成功');
package/dist/index.js CHANGED
@@ -20595,9 +20595,10 @@ var MsgStatus = function MsgStatus(props) {
20595
20595
  }, "\u5931\u8D25\u539F\u56E0\uFF1A", (_value$changeIndex3 = value[changeIndex]) === null || _value$changeIndex3 === void 0 ? void 0 : _value$changeIndex3.reason) : null) : null);
20596
20596
  };
20597
20597
 
20598
- var _excluded$n = ["showOnly", "getOptionsAsync"];
20598
+ var _excluded$n = ["mode", "showOnly", "getOptionsAsync"];
20599
20599
  var AsyncSelect = function AsyncSelect(props) {
20600
- var _props$showOnly = props.showOnly,
20600
+ var mode = props.mode,
20601
+ _props$showOnly = props.showOnly,
20601
20602
  showOnly = _props$showOnly === void 0 ? false : _props$showOnly,
20602
20603
  getOptionsAsync = props.getOptionsAsync,
20603
20604
  otherProps = _objectWithoutProperties(props, _excluded$n);
@@ -20611,11 +20612,24 @@ var AsyncSelect = function AsyncSelect(props) {
20611
20612
  });
20612
20613
  }, []);
20613
20614
  var options = [].concat(_toConsumableArray(props.options || []), _toConsumableArray(data || []));
20615
+ var getValueString = function getValueString(value) {
20616
+ var list = options;
20617
+ if (!mode) {
20618
+ var selectedItem = list.find(function (item) {
20619
+ return item.value === value;
20620
+ });
20621
+ return selectedItem ? selectedItem.label : value !== null && value !== void 0 ? value : '--';
20622
+ } else if (mode === 'multiple' && Array.isArray(value)) {
20623
+ var _list$filter$map$join;
20624
+ return (_list$filter$map$join = list.filter(function (item) {
20625
+ return value.includes(item.value);
20626
+ }).map(function (item) {
20627
+ return item.label;
20628
+ }).join(',')) !== null && _list$filter$map$join !== void 0 ? _list$filter$map$join : '--';
20629
+ }
20630
+ };
20614
20631
  if (showOnly) {
20615
- var selectedItem = options.find(function (option) {
20616
- return option.value === props.value;
20617
- });
20618
- return selectedItem ? selectedItem.label : props.value;
20632
+ return getValueString(props.value);
20619
20633
  }
20620
20634
  return /*#__PURE__*/React__default['default'].createElement(antd.Select, _objectSpread2(_objectSpread2({
20621
20635
  showSearch: true,
@@ -20624,7 +20638,8 @@ var AsyncSelect = function AsyncSelect(props) {
20624
20638
  },
20625
20639
  notFoundContent: null
20626
20640
  }, otherProps), {}, {
20627
- options: options
20641
+ options: options,
20642
+ mode: mode
20628
20643
  }));
20629
20644
  };
20630
20645
 
@@ -21494,7 +21509,7 @@ var css_248z$d = ".index-module_imageBox__1f2AI {\n display: flex;\n flex-wrap
21494
21509
  var styles$6 = {"imageBox":"index-module_imageBox__1f2AI","addBtn":"index-module_addBtn__1DY59","tips":"index-module_tips__1XQjf"};
21495
21510
  styleInject(css_248z$d);
21496
21511
 
21497
- var _excluded$r = ["maxCount", "maxSize", "onChange", "value", "disabled", "hostUrl", "actionUrl"];
21512
+ var _excluded$r = ["maxCount", "maxSize", "onChange", "value", "disabled", "hostUrl", "canDownload", "actionUrl"];
21498
21513
  var Dragger$1 = antd.Upload.Dragger;
21499
21514
  var fn$4 = function fn() {
21500
21515
  return void 0;
@@ -21513,6 +21528,8 @@ var KmVideo = function KmVideo(_ref) {
21513
21528
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
21514
21529
  _ref$hostUrl = _ref.hostUrl,
21515
21530
  hostUrl = _ref$hostUrl === void 0 ? '' : _ref$hostUrl,
21531
+ _ref$canDownload = _ref.canDownload,
21532
+ canDownload = _ref$canDownload === void 0 ? false : _ref$canDownload,
21516
21533
  _ref$actionUrl = _ref.actionUrl,
21517
21534
  actionUrl = _ref$actionUrl === void 0 ? '/qy/common/uploadWorkOrderImg' : _ref$actionUrl,
21518
21535
  resetProps = _objectWithoutProperties(_ref, _excluded$r);
@@ -21600,6 +21617,25 @@ var KmVideo = function KmVideo(_ref) {
21600
21617
  return _ref2.apply(this, arguments);
21601
21618
  };
21602
21619
  }();
21620
+ var download = function download(url, name) {
21621
+ if (url === null || url === void 0 ? void 0 : url.startsWith('https://erp-storage-video.oss-cn-beijing.aliyuncs.com')) {
21622
+ window.open(url);
21623
+ return;
21624
+ }
21625
+ fetch(url).then(function (res) {
21626
+ return res.blob();
21627
+ }).then(function (blob) {
21628
+ var a = document.createElement('a');
21629
+ document.body.appendChild(a);
21630
+ a.style.display = 'none';
21631
+ var url = window.URL.createObjectURL(blob);
21632
+ a.href = url;
21633
+ a.download = name;
21634
+ a.click();
21635
+ document.body.removeChild(a);
21636
+ window.URL.revokeObjectURL(url);
21637
+ });
21638
+ };
21603
21639
  var handleChange = function handleChange(list) {
21604
21640
  valueRef.current = list;
21605
21641
  onChange(list);
@@ -21683,7 +21719,12 @@ var KmVideo = function KmVideo(_ref) {
21683
21719
  title: fileName,
21684
21720
  footer: null,
21685
21721
  onCancel: handleCancel
21686
- }, /*#__PURE__*/React__default['default'].createElement(reactCopyToClipboard.CopyToClipboard, {
21722
+ }, canDownload ? /*#__PURE__*/React__default['default'].createElement(antd.Button, {
21723
+ type: "link",
21724
+ onClick: function onClick() {
21725
+ return download(fileUrl, fileName);
21726
+ }
21727
+ }, "\u4E0B\u8F7D") : /*#__PURE__*/React__default['default'].createElement(reactCopyToClipboard.CopyToClipboard, {
21687
21728
  text: fileUrl,
21688
21729
  onCopy: function onCopy() {
21689
21730
  antd.message.success('复制成功');
@@ -1,5 +1,6 @@
1
1
  import { SelectProps } from 'antd';
2
2
  declare const AsyncSelect: (props: SelectProps & {
3
+ mode: string;
3
4
  showOnly?: boolean;
4
5
  getOptionsAsync?: () => Promise<Required<SelectProps>['options']>;
5
6
  }) => any;
@@ -16,5 +16,5 @@ export interface ApaasUploadProps extends Omit<UploadProps, 'onChange' | 'value'
16
16
  actionUrl?: string;
17
17
  canDownload?: boolean;
18
18
  }
19
- declare const KmVideo: ({ maxCount, maxSize, onChange, value, disabled, hostUrl, actionUrl, ...resetProps }: ApaasUploadProps) => React.JSX.Element;
19
+ declare const KmVideo: ({ maxCount, maxSize, onChange, value, disabled, hostUrl, canDownload, actionUrl, ...resetProps }: ApaasUploadProps) => React.JSX.Element;
20
20
  export default KmVideo;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kmkf-fe-packages/basic-components",
3
- "version": "2.0.54-beta.66",
3
+ "version": "2.0.54-beta.68",
4
4
  "description": "> TODO: description",
5
5
  "homepage": "",
6
6
  "license": "ISC",
@@ -20,7 +20,7 @@
20
20
  "watch": "nodemon --ignore dist/ --ignore node_modules/ --watch src/ -C -e ts,tsx,less --debug -x 'yarn async'"
21
21
  },
22
22
  "dependencies": {
23
- "@kmkf-fe-packages/kmkf-utils": "2.0.54-beta.66",
23
+ "@kmkf-fe-packages/kmkf-utils": "2.0.54-beta.68",
24
24
  "ahooks": "^3.7.4",
25
25
  "bignumber.js": "^9.1.2",
26
26
  "kmkf-monitor": "^0.8.9",
@@ -65,5 +65,5 @@
65
65
  "publishConfig": {
66
66
  "access": "public"
67
67
  },
68
- "gitHead": "e4bfdc5da169d200052e3c17d406c6b1c863f312"
68
+ "gitHead": "4894e019bb46e437693b0355b52233fb74d2f4b6"
69
69
  }