@chaoswise/business 1.0.5 → 2.1.0

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 (82) hide show
  1. package/lib/I18nInput/index.d.ts +31 -0
  2. package/lib/I18nInput/index.js +379 -0
  3. package/lib/I18nInput/index.less +7 -0
  4. package/lib/index.d.ts +1 -0
  5. package/lib/index.js +1 -4
  6. package/lib/locales/en_US.json +1 -1
  7. package/lib/locales/index.d.ts +7 -0
  8. package/lib/locales/index.js +28 -13
  9. package/lib/locales/intl.d.ts +11 -0
  10. package/lib/locales/intl.js +39 -24
  11. package/lib/locales/ja_JP.json +1 -0
  12. package/lib/locales/normalizeLocale.d.ts +2 -0
  13. package/lib/locales/normalizeLocale.js +27 -0
  14. package/lib/locales/withLocale.d.ts +28 -0
  15. package/lib/locales/withLocale.js +2 -2
  16. package/lib/locales/zh_CN.json +1 -1
  17. package/lib/locales/zh_HK.json +1 -0
  18. package/lib/locales/zh_TW.json +1 -1
  19. package/package.json +10 -5
  20. package/lib/AggregateSearch/CLSPL/CLQLLexer.js +0 -78
  21. package/lib/AggregateSearch/CLSPL/CLQLParser.js +0 -2724
  22. package/lib/AggregateSearch/CLSPL/CLQLParserListener.js +0 -347
  23. package/lib/AggregateSearch/CLSPL/CLQLParserVisitor.js +0 -251
  24. package/lib/AggregateSearch/CLSPL/SPLStagy.js +0 -197
  25. package/lib/AggregateSearch/CLSPL/index.js +0 -196
  26. package/lib/AggregateSearch/CLSPL/makeTokenizeFn.js +0 -18
  27. package/lib/AggregateSearch/CLSPL/token.js +0 -7
  28. package/lib/AggregateSearch/components/CloseAllIcon/index.js +0 -13
  29. package/lib/AggregateSearch/components/CloseAllIcon/index.less +0 -11
  30. package/lib/AggregateSearch/components/DropDown/assets/combined.svg +0 -22
  31. package/lib/AggregateSearch/components/DropDown/assets/copy.svg +0 -22
  32. package/lib/AggregateSearch/components/DropDown/assets/delete.svg +0 -24
  33. package/lib/AggregateSearch/components/DropDown/assets/home.svg +0 -20
  34. package/lib/AggregateSearch/components/DropDown/assets/key.svg +0 -21
  35. package/lib/AggregateSearch/components/DropDown/assets/star.svg +0 -22
  36. package/lib/AggregateSearch/components/DropDown/assets/time-circle.svg +0 -20
  37. package/lib/AggregateSearch/components/DropDown/assets/value.svg +0 -23
  38. package/lib/AggregateSearch/components/DropDown/config.js +0 -54
  39. package/lib/AggregateSearch/components/DropDown/index.js +0 -584
  40. package/lib/AggregateSearch/components/DropDown/index.less +0 -118
  41. package/lib/AggregateSearch/components/SwitchBtn/assets/tag-icon.svg +0 -17
  42. package/lib/AggregateSearch/components/SwitchBtn/assets/text-icon.svg +0 -18
  43. package/lib/AggregateSearch/components/SwitchBtn/index.js +0 -27
  44. package/lib/AggregateSearch/components/SwitchBtn/index.less +0 -31
  45. package/lib/AggregateSearch/hooks/useDropDown.js +0 -428
  46. package/lib/AggregateSearch/index.js +0 -520
  47. package/lib/AggregateSearch/index.less +0 -225
  48. package/lib/AggregateSearch/utils/index.js +0 -391
  49. package/lib/ContentEditableSearch/components/CloseAllIcon/index.js +0 -13
  50. package/lib/ContentEditableSearch/components/CloseAllIcon/index.less +0 -11
  51. package/lib/ContentEditableSearch/index.js +0 -157
  52. package/lib/ContentEditableSearch/index.less +0 -65
  53. package/lib/ContentEditableSearch/utils/index.js +0 -98
  54. package/lib/PropertyControlViewer/assets/doCommon.less +0 -75
  55. package/lib/PropertyControlViewer/assets/doSelect.less +0 -74
  56. package/lib/PropertyControlViewer/assets/index.less +0 -189
  57. package/lib/PropertyControlViewer/components/DoAppIcon/CustomIcon/iconfont.js +0 -1
  58. package/lib/PropertyControlViewer/components/DoAppIcon/CustomIcon/index.js +0 -29
  59. package/lib/PropertyControlViewer/components/DoAppIcon/iconData/IconJson.js +0 -0
  60. package/lib/PropertyControlViewer/components/DoAppIcon/index.js +0 -41
  61. package/lib/PropertyControlViewer/components/DoCiUnitBitmap.js +0 -50
  62. package/lib/PropertyControlViewer/components/DoCommon.js +0 -36
  63. package/lib/PropertyControlViewer/components/DoDefaultPlaceholder.js +0 -9
  64. package/lib/PropertyControlViewer/components/DoImage.js +0 -107
  65. package/lib/PropertyControlViewer/components/DoQuote/components/QuoteView.js +0 -63
  66. package/lib/PropertyControlViewer/components/DoQuote/components/TableQuoteView.js +0 -18
  67. package/lib/PropertyControlViewer/components/DoQuote/index.js +0 -16
  68. package/lib/PropertyControlViewer/components/DoSelect.js +0 -80
  69. package/lib/PropertyControlViewer/components/DoTable.js +0 -44
  70. package/lib/PropertyControlViewer/components/DoUser.js +0 -61
  71. package/lib/PropertyControlViewer/components/TagShowMoreList/index.js +0 -132
  72. package/lib/PropertyControlViewer/components/TagShowMoreList/index.less +0 -106
  73. package/lib/PropertyControlViewer/config/constants.js +0 -84
  74. package/lib/PropertyControlViewer/config/utils.js +0 -353
  75. package/lib/PropertyControlViewer/index.js +0 -195
  76. package/lib/PropertyControlViewer/index.less +0 -107
  77. package/lib/Watermark/index.js +0 -187
  78. package/lib/Watermark/index.less +0 -17
  79. package/lib/demo.js +0 -0
  80. package/lib/locale/en_US.js +0 -9
  81. package/lib/locale/index.js +0 -12
  82. package/lib/locale/zh_CN.js +0 -9
@@ -1,132 +0,0 @@
1
- import _Popover from "@chaoswise/ui/lib/Popover";
2
- import _Tooltip from "@chaoswise/ui/lib/Tooltip";
3
- import _Avatar from "@chaoswise/ui/lib/Avatar";
4
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
5
- function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
6
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
8
- function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
9
- function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
10
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
11
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
12
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
13
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
14
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
15
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
16
- import React from 'react';
17
- import './index.less';
18
- import classnames from 'classnames';
19
- import DoAppIcon from '../DoAppIcon';
20
- import { isLightColorFunc } from '../../config/utils';
21
- var TagShowMoreList = function TagShowMoreList(props) {
22
- var _props$text = props.text,
23
- text = _props$text === void 0 ? [] : _props$text,
24
- _props$tagCount = props.tagCount,
25
- tagCount = _props$tagCount === void 0 ? 1 : _props$tagCount,
26
- tooltipContentFuc = props.tooltipContentFuc,
27
- _props$_style = props._style,
28
- _style = _props$_style === void 0 ? null : _props$_style,
29
- nameKey = props.nameKey,
30
- tagClickFuc = props.tagClickFuc,
31
- flag = props.flag,
32
- _props$option = props.option,
33
- option = _props$option === void 0 ? 'view' : _props$option;
34
- var getColorStyle = function getColorStyle(item) {
35
- if (item !== null && item !== void 0 && item.color) {
36
- return {
37
- background: item.color,
38
- color: isLightColorFunc(item.color) ? "#000" : "#fff",
39
- borderColor: 'transparent',
40
- display: 'flex',
41
- width: 'fit-content',
42
- maxWidth: '100%'
43
- };
44
- } else {
45
- return {
46
- border: 'none',
47
- background: 'transparent',
48
- display: 'flex',
49
- width: 'fit-content',
50
- maxWidth: '100%'
51
- };
52
- }
53
- };
54
- var generateItem_user = function generateItem_user(tags, _style, _className) {
55
- var classNameDiv = _className || 'wrapper-inner';
56
- return tags.map(function (item, index) {
57
- var _String;
58
- var _name = '';
59
- if (nameKey == 'userAlias') {
60
- _name = item.userAlias ? "".concat(item === null || item === void 0 ? void 0 : item.userName, "(").concat(item === null || item === void 0 ? void 0 : item.userAlias, ")") : item === null || item === void 0 ? void 0 : item.id;
61
- } else {
62
- _name = item[nameKey] || (item === null || item === void 0 ? void 0 : item.ciName) || (item === null || item === void 0 ? void 0 : item.id);
63
- }
64
- return /*#__PURE__*/React.createElement(_Tooltip, {
65
- title: tooltipContentFuc ? tooltipContentFuc(item) : _name,
66
- key: index,
67
- overlayStyle: {
68
- width: 'auto'
69
- },
70
- placement: "topLeft"
71
- }, /*#__PURE__*/React.createElement("div", {
72
- className: classNameDiv,
73
- style: _objectSpread(_objectSpread({}, _style), getColorStyle(item)),
74
- onClick: tagClickFuc ? function () {
75
- return tagClickFuc(item);
76
- } : function () {}
77
- }, /*#__PURE__*/React.createElement("div", {
78
- className: 'ellipsis-box',
79
- style: {
80
- maxWidth: text.length === 1 && option === 'view' || _className ? '100%' : option === 'view' ? 84 : 64
81
- }
82
- }, flag === "user" ? /*#__PURE__*/React.createElement(_Avatar, {
83
- size: 20,
84
- className: "tag-ci-detail-avatar"
85
- }, (_String = String(_name)) === null || _String === void 0 ? void 0 : _String.substring(0, 1)) : /*#__PURE__*/React.createElement(_Avatar, {
86
- size: 20,
87
- style: {
88
- backgroundColor: "rgb(228,246,255)",
89
- marginRight: 8
90
- },
91
- icon: /*#__PURE__*/React.createElement(DoAppIcon, {
92
- style: {
93
- color: "rgb(25,133,255)"
94
- },
95
- type: item.iconPath || 'icon-1'
96
- })
97
- }), _name || '-')));
98
- });
99
- };
100
- var renderItem = function renderItem() {
101
- var generateItem = generateItem_user;
102
- var tagsLength = text.length;
103
- if (tagsLength == 0) {
104
- return null;
105
- } else if (tagsLength <= tagCount) {
106
- return generateItem(text, _style);
107
- } else {
108
- var frontTags = generateItem(text.slice(0, tagCount));
109
- var afterArray = text.slice(tagCount, tagsLength);
110
- var contentData = /*#__PURE__*/React.createElement("div", {
111
- className: 'inner'
112
- }, generateItem(afterArray, _style, 'ant-popover-inner-content'));
113
- var fixedTags = [/*#__PURE__*/React.createElement(_Popover, {
114
- content: contentData,
115
- key: 10000000,
116
- overlayClassName: 'tag-wrapper-inner',
117
- overlayStyle: {
118
- padding: 8,
119
- width: 'auto'
120
- }
121
- }, /*#__PURE__*/React.createElement("div", {
122
- className: 'wrapper-inner-fixed',
123
- style: _style
124
- }, "+ ", afterArray.length))];
125
- return [].concat(_toConsumableArray(frontTags), fixedTags);
126
- }
127
- };
128
- return /*#__PURE__*/React.createElement("div", {
129
- className: classnames('wrapper')
130
- }, renderItem());
131
- };
132
- export default TagShowMoreList;
@@ -1,106 +0,0 @@
1
- .form-properties-box {
2
- .wrapper {
3
- height: 28px;
4
- font-size: 12px;
5
- display: flex;
6
- align-items: center;
7
-
8
- .wrapper-inner {
9
- float: left;
10
- height: 20px;
11
- line-height: 20px;
12
- margin-right: 8px;
13
- background: #fafafa;
14
- border: 1px solid #d9d9d9;
15
- border-radius: 2px;
16
- cursor: pointer;
17
- overflow: hidden;
18
- text-overflow: ellipsis;
19
- white-space: nowrap;
20
- }
21
-
22
- .wrapper-inner:last-child {
23
- margin-right: 0;
24
- }
25
-
26
- .wrapper-inner-fixed {
27
- float: left;
28
- height: 20px;
29
- line-height: 20px;
30
- margin-right: 2px;
31
- padding: 0px 6px;
32
- background: #fafafa;
33
- border: 1px solid #d9d9d9;
34
- border-radius: 2px;
35
- cursor: pointer;
36
- }
37
-
38
- &.edit-wrapper {
39
- .wrapper-inner {
40
- height: 28px;
41
- line-height: 28px;
42
- }
43
-
44
- .wrapper-inner-fixed {
45
- height: 28px;
46
- line-height: 28px;
47
- }
48
- }
49
- }
50
-
51
- .@{ant-prefix}-popover-inner-content:nth-child(4n) {
52
- margin-right: 0px;
53
- }
54
-
55
- .inner {
56
- max-width: 220px;
57
- font-size: 12px;
58
-
59
- .@{ant-prefix}-popover-inner-content {
60
- // float: left;
61
- // max-width: 85px;
62
- height: 28px;
63
- line-height: 28px;
64
- background: #fafafa;
65
- border: 1px solid #d9d9d9;
66
- border-radius: 2px;
67
- // padding: 0 6px;
68
- margin-bottom: 2px;
69
- cursor: pointer;
70
- // overflow: hidden;
71
- // text-overflow: ellipsis;
72
- // white-space: nowrap;
73
- }
74
- }
75
-
76
- .inner:after {
77
- /*伪元素是行内元素 正常浏览器清除浮动方法*/
78
- content: "";
79
- display: block;
80
- height: 0;
81
- clear: both;
82
- visibility: hidden;
83
- }
84
-
85
-
86
- .ellipsis-box {
87
- overflow: hidden;
88
- text-overflow: ellipsis;
89
- white-space: nowrap;
90
- }
91
-
92
-
93
- .tag-ci-detail-avatar {
94
- color: #fff;
95
- background-color: #008dff;
96
- margin-right: 8px;
97
- font-size: 10px !important;
98
- margin-top: -2px;
99
- }
100
-
101
- .tag-wrapper-inner {
102
- .@{ant-prefix}-popover-inner-content {
103
- padding: 8px !important;
104
- }
105
- }
106
- }
@@ -1,84 +0,0 @@
1
- import DoCommon from '../components/DoCommon';
2
- import DoUser from '../components/DoUser';
3
- import DoQuote from '../components/DoQuote';
4
- import DoSelect from '../components/DoSelect';
5
- import DoImage from '../components/DoImage';
6
- import DoTable from '../components/DoTable';
7
- import DoCiUnitBitmap from '../components/DoCiUnitBitmap';
8
- import DoDefaultPlaceholder from '../components/DoDefaultPlaceholder';
9
- export var DATE_FORMATE_ENUM = {
10
- 'yyyy': 'YYYY',
11
- 'yyyy-MM': 'YYYY-MM',
12
- 'yyyy-MM-dd': 'YYYY-MM-DD',
13
- 'yyyy-MM-dd HH': 'YYYY-MM-DD HH',
14
- 'yyyy-MM-dd HH:mm': 'YYYY-MM-DD HH:mm',
15
- 'yyyy-MM-dd HH:mm:ss': 'YYYY-MM-DD HH:mm:ss'
16
- };
17
- export var ATTR_DES_ENUM = {
18
- INPUT: {
19
- generate_comp: DoCommon
20
- },
21
- TEXTAREA: {
22
- generate_comp: DoCommon
23
- },
24
- SELECT: {
25
- generate_comp: DoSelect
26
- },
27
- RADIO: {
28
- generate_comp: DoSelect
29
- },
30
- CHECKBOX: {
31
- generate_comp: DoSelect
32
- },
33
- SWITCH: {
34
- generate_comp: DoCommon
35
- },
36
- NUMBER: {
37
- generate_comp: DoCommon
38
- },
39
- NUMBER_RANGE: {
40
- generate_comp: DoCommon
41
- },
42
- DATE: {
43
- generate_comp: DoCommon
44
- },
45
- IMAGE: {
46
- generate_comp: DoImage
47
- },
48
- FILE: {
49
- generate_comp: DoImage
50
- },
51
- UID: {
52
- generate_comp: DoCommon
53
- },
54
- AUTO_CALCULATE: {
55
- generate_comp: DoCommon
56
- },
57
- USER: {
58
- generate_comp: DoUser
59
- },
60
- USER_GROUP: {
61
- generate_comp: DoUser
62
- },
63
- TABLE: {
64
- generate_comp: DoTable
65
- },
66
- QUOTE: {
67
- generate_comp: DoQuote
68
- },
69
- UNIT_RANGE: {
70
- generate_comp: DoCommon
71
- },
72
- UNIT_BITMAP: {
73
- generate_comp: DoCiUnitBitmap
74
- },
75
- UNIT_SELECT: {
76
- generate_comp: DoCommon
77
- },
78
- RACK_UNIT: {
79
- generate_comp: DoCommon
80
- },
81
- default_placeholder: {
82
- generate_comp: DoDefaultPlaceholder
83
- }
84
- };
@@ -1,353 +0,0 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
- import moment from 'moment';
8
- import React from 'react';
9
- import { ATTR_DES_ENUM, DATE_FORMATE_ENUM } from './constants';
10
- import intl from '../../locales';
11
-
12
- //根据属性类型获取对应的组件
13
- export var getDescriptionComp = function getDescriptionComp(type) {
14
- if (ATTR_DES_ENUM[type]) {
15
- return ATTR_DES_ENUM[type].generate_comp;
16
- }
17
- return /*#__PURE__*/React.createElement("span", null, intl.get('fc7ca498-ab95-4a4b-9f5f-0d024cc127c3').d('暂未注册组件'));
18
- };
19
-
20
- // 时间格式化
21
- export var dateFormatFunc = function dateFormatFunc(timestamp) {
22
- var fmt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'YYYY-MM-DD HH:mm:ss';
23
- return timestamp ? moment(timestamp).format(fmt) : '-';
24
- };
25
-
26
- // 判断是否浅色
27
- export var isLightColorFunc = function isLightColorFunc(str) {
28
- // 16进制颜色转换成rgb数组
29
- var reg = /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;
30
- if (!reg.test(str)) {
31
- return;
32
- }
33
- var newStr = str.toLowerCase().replace(/\#/g, '');
34
- var len = newStr.length;
35
- if (len == 3) {
36
- var t = '';
37
- for (var i = 0; i < len; i++) {
38
- t += newStr.slice(i, i + 1).concat(newStr.slice(i, i + 1));
39
- }
40
- newStr = t;
41
- }
42
- var rgb = []; //将字符串分隔,两个两个的分隔
43
- for (var i = 0; i < 6; i = i + 2) {
44
- var s = newStr.slice(i, i + 2);
45
- rgb.push(parseInt('0x' + s));
46
- }
47
- //判断颜色
48
- return 0.213 * rgb[0] + 0.715 * rgb[1] + 0.072 * rgb[2] > 255 / 2;
49
- };
50
-
51
- //字符串截取一部分, 多余的显示省略号
52
- export var shortenStrFunc = function shortenStrFunc() {
53
- var str = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
54
- var maxLen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
55
- str = String(str);
56
- return str.length > maxLen ? str.substring(0, maxLen) + '...' : str;
57
- };
58
-
59
- //图片、附件
60
- export var downloadEvtFunc = function downloadEvtFunc(url) {
61
- // console.log(url, '触发下载的url');
62
- window.open(url, '_self');
63
- };
64
- export var getBase64 = function getBase64(file) {
65
- return new Promise(function (resolve, reject) {
66
- var reader = new FileReader();
67
- reader.readAsDataURL(file);
68
- reader.onload = function () {
69
- return resolve(reader.result);
70
- };
71
- reader.onerror = function (error) {
72
- return reject(error);
73
- };
74
- });
75
- };
76
-
77
- /**
78
- * 生成唯一id
79
- * @param {*}
80
- */
81
- export var guidFunc = function guidFunc() {
82
- var length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 32;
83
- var _str = new Array(length).fill('x').join('');
84
- return _str.replace(/[xy]/g, function (c) {
85
- var r = Math.random() * 16 | 0;
86
- var v = c === 'x' ? r : r & 0x3 | 0x8;
87
- return v.toString(16);
88
- });
89
- };
90
-
91
- // 判断值的类型是否符合规范
92
- export var judgmentTypeFunc = function judgmentTypeFunc(type, value) {
93
- var judgmentType = true; // 判断返回的value类型
94
- switch (type) {
95
- case 'INPUT':
96
- break;
97
- case 'SELECT':
98
- break;
99
- case 'TEXTAREA':
100
- break;
101
- case 'NUMBER':
102
- break;
103
- case 'UID':
104
- break;
105
- case 'AUTO_CALCULATE':
106
- break;
107
- case 'DATE':
108
- judgmentType = typeof value === 'string' || typeof value === 'number';
109
- break;
110
- case 'RADIO':
111
- judgmentType = typeof value === 'string';
112
- break;
113
- case 'CHECKBOX':
114
- break;
115
- case 'NUMBER_RANGE':
116
- break;
117
- case 'RACK_UNIT':
118
- break;
119
- case 'USER':
120
- break;
121
- case 'USER_GROUP':
122
- break;
123
- case 'QUOTE':
124
- break;
125
- case 'IMAGE':
126
- break;
127
- case 'FILE':
128
- break;
129
- case 'TABLE':
130
- judgmentType = Array.isArray(value) && (value === null || value === void 0 ? void 0 : value.length) > 0;
131
- break;
132
- case 'SWITCH':
133
- judgmentType = typeof value === 'boolean' || typeof value === 'string';
134
- break;
135
- case 'UNIT_BITMAP':
136
- judgmentType = Object.prototype.toString.call(value) === '[object Object]';
137
- break;
138
- default:
139
- judgmentType = true;
140
- break;
141
- }
142
- return judgmentType;
143
- };
144
- export var getDataFunc = function getDataFunc(value, item, rest) {
145
- var componentType = item.componentType,
146
- attrInfo = item.attrInfo,
147
- belongComponentType = item.belongComponentType,
148
- properties = item.properties;
149
- var fieldWidth = attrInfo.fieldWidth,
150
- enumList = attrInfo.enumList,
151
- offValue = attrInfo.offValue,
152
- onValue = attrInfo.onValue,
153
- dateFormat = attrInfo.dateFormat,
154
- unit = attrInfo.unit;
155
- var paragraphEllipsis = rest.paragraphEllipsis,
156
- tagCount = rest.tagCount,
157
- userTooltipContent = rest.userTooltipContent,
158
- userGroupTooltipContent = rest.userGroupTooltipContent,
159
- handleClickChange = rest.handleClickChange;
160
- var data = {};
161
- try {
162
- switch (componentType) {
163
- case 'INPUT':
164
- case 'TEXTAREA':
165
- data = {
166
- paragraphEllipsis: paragraphEllipsis || {
167
- rows: 5,
168
- expandable: true
169
- },
170
- list: [{
171
- value: unit ? value + ' ' + unit : value
172
- }]
173
- };
174
- break;
175
- case 'NUMBER':
176
- case 'UID':
177
- case 'AUTO_CALCULATE':
178
- data = {
179
- list: [{
180
- value: !(value === undefined || value === null || value === '') ? unit ? value + ' ' + unit : value : '-'
181
- }]
182
- };
183
- break;
184
- case 'RADIO':
185
- data = {
186
- tagCount: 1,
187
- list: (enumList || []).filter(function (i) {
188
- return (i === null || i === void 0 ? void 0 : i.itemCode) === value;
189
- }).map(function (m) {
190
- return {
191
- id: m === null || m === void 0 ? void 0 : m.itemCode,
192
- value: m === null || m === void 0 ? void 0 : m.itemName,
193
- color: m === null || m === void 0 ? void 0 : m.itemColour
194
- };
195
- })
196
- };
197
- break;
198
- case 'SELECT':
199
- data = {
200
- tagCount: belongComponentType === 'TABLE' ? 1 : tagCount ? tagCount : 10000,
201
- list: (enumList || []).filter(function (i) {
202
- return value === null || value === void 0 ? void 0 : value.includes(i === null || i === void 0 ? void 0 : i.itemCode);
203
- }).map(function (m) {
204
- return {
205
- id: m === null || m === void 0 ? void 0 : m.itemCode,
206
- value: m === null || m === void 0 ? void 0 : m.itemName,
207
- color: m === null || m === void 0 ? void 0 : m.itemColour
208
- };
209
- })
210
- };
211
- break;
212
- case 'CHECKBOX':
213
- data = {
214
- tagCount: tagCount || 10000,
215
- list: (enumList || []).filter(function (i) {
216
- return value === null || value === void 0 ? void 0 : value.includes(i === null || i === void 0 ? void 0 : i.itemCode);
217
- }).map(function (m) {
218
- return {
219
- id: m === null || m === void 0 ? void 0 : m.itemCode,
220
- value: m === null || m === void 0 ? void 0 : m.itemName,
221
- color: m === null || m === void 0 ? void 0 : m.itemColour
222
- };
223
- })
224
- };
225
- break;
226
- case 'SWITCH':
227
- var _value = String(value).toLowerCase();
228
- data = {
229
- list: [{
230
- value: _value == 'true' || _value === '1' ? onValue : offValue
231
- }]
232
- };
233
- break;
234
- case 'NUMBER_RANGE':
235
- data = {
236
- list: [{
237
- value: value ? unit ? (value === null || value === void 0 ? void 0 : value.join(' - ')) + ' ' + unit : value === null || value === void 0 ? void 0 : value.join(' - ') : '-'
238
- }]
239
- };
240
- break;
241
- case 'RACK_UNIT':
242
- data = {
243
- list: [{
244
- value: (value === null || value === void 0 ? void 0 : value.join(' - ')) || []
245
- }]
246
- };
247
- break;
248
- case 'DATE':
249
- var dataFormatString = DATE_FORMATE_ENUM[dateFormat] || 'YYYY-MM-DD HH:mm:ss';
250
- data = {
251
- list: [{
252
- value: dateFormatFunc(value, dataFormatString)
253
- }]
254
- };
255
- break;
256
- case 'USER':
257
- var userTooltip = {
258
- userName: intl.get('cfbba0e5-b133-4bd7-9b8c-3c92368fe049').d('姓名:'),
259
- userAlias: intl.get('b59f74be-dff0-4e3e-92db-354b475c3efd').d('用户名:'),
260
- department: intl.get('79279aa4-ad27-4082-8093-06122d68c611').d('部门:'),
261
- email: intl.get('88d7ad39-7f49-459f-a1fd-48dd4c0ff9d5').d('邮箱:'),
262
- mobile: intl.get('db3f4bef-089e-4144-861d-29f79fa4cd38').d('手机:')
263
- };
264
- data = {
265
- fieldWidth: fieldWidth,
266
- tooltipContent: userTooltipContent || userTooltip,
267
- belongComponentType: belongComponentType,
268
- componentType: componentType,
269
- list: (value ? Array.isArray(value) ? value : [value] : []).map(function (i) {
270
- i.id = i === null || i === void 0 ? void 0 : i.userId;
271
- i.name = i === null || i === void 0 ? void 0 : i.userName;
272
- return i;
273
- })
274
- };
275
- break;
276
- case 'USER_GROUP':
277
- var userGroupTooltip = {
278
- groupName: intl.get('0ee18787-448b-4f7b-a3f2-5067a38c9a26').d('用户组:'),
279
- groupDetails: intl.get('f307bd91-6737-4667-9e89-daec35b21198').d('描述:')
280
- };
281
- data = {
282
- fieldWidth: fieldWidth,
283
- tooltipContent: userGroupTooltipContent || userGroupTooltip,
284
- belongComponentType: belongComponentType,
285
- componentType: componentType,
286
- list: (value ? Array.isArray(value) ? value : [value] : []).map(function (i) {
287
- i.id = i === null || i === void 0 ? void 0 : i.groupId;
288
- i.name = i === null || i === void 0 ? void 0 : i.groupName;
289
- return i;
290
- })
291
- };
292
- break;
293
- case 'QUOTE':
294
- data = {
295
- fieldWidth: fieldWidth,
296
- attrSource: rest === null || rest === void 0 ? void 0 : rest.attrSource,
297
- handleClickChange: handleClickChange,
298
- list: value || []
299
- };
300
- break;
301
- case 'IMAGE':
302
- data = {
303
- type: 'image',
304
- list: (value || []).map(function (i) {
305
- return {
306
- uid: i.id,
307
- name: i === null || i === void 0 ? void 0 : i.imgName,
308
- status: 'done',
309
- url: i.url
310
- };
311
- })
312
- };
313
- break;
314
- case 'FILE':
315
- data = {
316
- type: 'file',
317
- list: (value || []).map(function (i) {
318
- return {
319
- uid: i.id,
320
- name: i.fileName,
321
- status: 'done',
322
- url: i.url
323
- };
324
- })
325
- };
326
- break;
327
- case 'UNIT_BITMAP':
328
- data = {
329
- list: (value === null || value === void 0 ? void 0 : value.units) || [],
330
- handleClickChange: handleClickChange
331
- };
332
- break;
333
- case 'TABLE':
334
- data = {
335
- properties: properties,
336
- handleClickChange: handleClickChange,
337
- list: (value || []).map(function (v, i) {
338
- return _objectSpread(_objectSpread({}, v), {}, {
339
- id: 'u' + guidFunc(5),
340
- count: i + 1
341
- });
342
- })
343
- };
344
- break;
345
- default:
346
- break;
347
- }
348
- return data;
349
- } catch (error) {
350
- console.log('数据不兼容报错:', error);
351
- return {};
352
- }
353
- };