@zgfe/business-lib 1.1.12 → 1.1.13-attr.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.
@@ -14,6 +14,7 @@ import React, { useEffect, useState } from 'react';
14
14
  import BizAttributeSelector from '../attributeSelector';
15
15
  import { PropCategory } from '../attributeSelector/types';
16
16
  import './styles/index.less';
17
+ import _ from 'lodash';
17
18
  import BizOperateList from './components/operateList';
18
19
  import ValuesList from './components/valuesList';
19
20
  import { Skeleton } from 'antd';
@@ -98,7 +99,7 @@ var BizConditionItem = function BizConditionItem(props) {
98
99
  if (props.onChange) {
99
100
  if (!attr) return;
100
101
  var responseData = {
101
- attrId: attr.id,
102
+ attrId: _.isNumber(attr.id) ? attr.id : parseInt(attr.id),
102
103
  propCategory: attr.propCategory,
103
104
  type: attr.type,
104
105
  operator: operate,
@@ -19,7 +19,7 @@ import userData from './userData.js';
19
19
  import convertAttributeData from '../util';
20
20
  export default (function () {
21
21
  var _useState = useState({
22
- id: 30183426,
22
+ id: '30183431,30183428',
23
23
  propCategory: 'eventProp'
24
24
  }),
25
25
  _useState2 = _slicedToArray(_useState, 2),
@@ -45,7 +45,8 @@ export default (function () {
45
45
  }, /*#__PURE__*/React.createElement(BizAttributeSelector, {
46
46
  enableEventProp: true,
47
47
  enableUserProp: true,
48
- eventIdList: [24143016],
48
+ showCommonAttr: true,
49
+ eventIdList: [24143016, 24143017],
49
50
  value: attribute,
50
51
  onChange: onChange,
51
52
  enableDelete: true,
@@ -4,6 +4,14 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
4
 
5
5
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
6
 
7
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
+
9
+ 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."); }
10
+
11
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
12
+
13
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
14
+
7
15
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
16
 
9
17
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -16,18 +24,20 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
16
24
 
17
25
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
26
 
19
- import React, { useContext, useEffect, useRef, useState } from 'react';
27
+ import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
20
28
  import './styles/index.less';
21
29
  import { Dropdown, Tooltip } from 'antd';
22
30
  import AttrListPanel from './listPanel';
23
31
  import IconFont from '../icon/iconFont';
24
32
  import { BizGlobalDataContext } from '..';
25
33
  import SelectHandle from '../select/handle';
34
+ import _ from 'lodash';
26
35
 
27
36
  var BizAttributeSelector = function BizAttributeSelector(props) {
28
37
  var enableDelete = props.enableDelete,
29
38
  placeholder = props.placeholder,
30
- theme = props.theme;
39
+ theme = props.theme,
40
+ eventIdList = props.eventIdList;
31
41
 
32
42
  var _useState = useState(),
33
43
  _useState2 = _slicedToArray(_useState, 2),
@@ -57,6 +67,17 @@ var BizAttributeSelector = function BizAttributeSelector(props) {
57
67
  width = _useState8[0],
58
68
  setWidth = _useState8[1];
59
69
 
70
+ var eventIdMap = useMemo(function () {
71
+ var eventIdMap = {};
72
+ var eventList = (eventGroupList || []).reduce(function (pre, group) {
73
+ return [].concat(_toConsumableArray(pre), _toConsumableArray(group.eventList));
74
+ }, []);
75
+ eventList.forEach(function (event) {
76
+ if (eventIdMap[event.id]) return;
77
+ eventIdMap[event.id] = event;
78
+ });
79
+ return eventIdMap;
80
+ }, [eventGroupList]);
60
81
  useEffect(function () {
61
82
  setWidth(boxRef.current.width || 284);
62
83
  if (!props.defaultValue) return;
@@ -68,17 +89,28 @@ var BizAttributeSelector = function BizAttributeSelector(props) {
68
89
 
69
90
  function getValue(param) {
70
91
  var res = undefined;
92
+ var resEvent = undefined;
71
93
 
72
94
  if ((param === null || param === void 0 ? void 0 : param.propCategory) === 'envProp') {
73
95
  eventEnvList === null || eventEnvList === void 0 ? void 0 : eventEnvList.forEach(function (attr) {
74
96
  if (attr.name === param.name) res = attr;
75
97
  });
76
98
  } else if ((param === null || param === void 0 ? void 0 : param.propCategory) === 'eventProp') {
77
- eventGroupList === null || eventGroupList === void 0 ? void 0 : eventGroupList.forEach(function (group) {
78
- group.eventList.forEach(function (event) {
79
- event.attrList.forEach(function (attr) {
80
- if (attr.id === param.id) res = attr;
81
- });
99
+ eventIdList === null || eventIdList === void 0 ? void 0 : eventIdList.forEach(function (id) {
100
+ var event = eventIdMap[id];
101
+ if (!event) return;
102
+ event.attrList.forEach(function (attr) {
103
+ if (typeof param.id == 'string' && param.id.includes(attr.id.toString())) {
104
+ if (resEvent) {
105
+ resEvent.id += ",".concat(attr.id);
106
+ resEvent.key += ",".concat(attr.key);
107
+ resEvent.eventId += ",".concat(attr.eventId);
108
+ } else {
109
+ resEvent = _.cloneDeep(attr);
110
+ }
111
+ } else if (attr.id === param.id) {
112
+ res = attr;
113
+ }
82
114
  });
83
115
  });
84
116
  } else if ((param === null || param === void 0 ? void 0 : param.propCategory) === 'userProp') {
@@ -87,7 +119,7 @@ var BizAttributeSelector = function BizAttributeSelector(props) {
87
119
  });
88
120
  }
89
121
 
90
- return res;
122
+ return resEvent || res;
91
123
  }
92
124
 
93
125
  function onDelete() {
@@ -152,6 +184,7 @@ BizAttributeSelector.defaultProps = {
152
184
  size: 'middle',
153
185
  propSymbol: '*',
154
186
  optionsHeaderTip: '带*的属性每日凌晨更新',
155
- destroyPopupOnHide: false
187
+ destroyPopupOnHide: false,
188
+ showCommonAttr: false
156
189
  };
157
190
  export default BizAttributeSelector;
@@ -1,3 +1,9 @@
1
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
+
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+
5
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+
1
7
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
8
 
3
9
  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."); }
@@ -33,7 +39,8 @@ var AttrListPanel = function AttrListPanel(props) {
33
39
  enableEnvProp = props.enableEnvProp,
34
40
  enableEventProp = props.enableEventProp,
35
41
  enableUserProp = props.enableUserProp,
36
- eventIdList = props.eventIdList;
42
+ eventIdList = props.eventIdList,
43
+ showCommonAttr = props.showCommonAttr;
37
44
 
38
45
  var _useState = useState(''),
39
46
  _useState2 = _slicedToArray(_useState, 2),
@@ -89,9 +96,34 @@ var AttrListPanel = function AttrListPanel(props) {
89
96
 
90
97
  if (enableEventProp) {
91
98
  var hasAnchor = false;
99
+ var eventShareAttrObj = {};
100
+ var eventShareAttrList = [];
92
101
  eventIdList === null || eventIdList === void 0 ? void 0 : eventIdList.forEach(function (id) {
93
102
  var event = eventIdMap[id];
94
103
  if (!event) return;
104
+ event.attrList.forEach(function (item) {
105
+ if (eventShareAttrObj[item.label]) {
106
+ var itemData = eventShareAttrObj[item.label];
107
+ itemData.frequency = itemData.frequency + 1;
108
+ itemData.id += ",".concat(item.id);
109
+ itemData.eventId += ",".concat(item.eventId);
110
+ itemData.key += ",".concat(item.key);
111
+ } else {
112
+ eventShareAttrObj[item.label] = _objectSpread(_objectSpread({}, item), {}, {
113
+ frequency: 1
114
+ });
115
+ }
116
+ });
117
+
118
+ if (Object.keys(eventShareAttrObj).length > 0) {
119
+ for (var key in eventShareAttrObj) {
120
+ if (eventShareAttrObj[key].frequency > 1) {
121
+ delete eventShareAttrObj[key].frequency;
122
+ eventShareAttrList.push(eventShareAttrObj[key]);
123
+ }
124
+ }
125
+ }
126
+
95
127
  var group = {
96
128
  isEvent: true,
97
129
  groupName: event.alias || event.name,
@@ -101,6 +133,15 @@ var AttrListPanel = function AttrListPanel(props) {
101
133
  };
102
134
  list.push(group);
103
135
  });
136
+
137
+ if (eventShareAttrList.length > 0 && showCommonAttr) {
138
+ list.unshift({
139
+ groupName: '事件共有属性',
140
+ anchor: hasAnchor ? String(Math.random()) : anchor.event,
141
+ key: "event-".concat(Math.random()),
142
+ children: eventShareAttrList.slice()
143
+ });
144
+ }
104
145
  }
105
146
 
106
147
  if (enableUserProp) {
@@ -31,7 +31,7 @@ export interface EventGroup {
31
31
  eventList: AnalysisEvent[];
32
32
  }
33
33
  export interface BasicProp {
34
- id: number;
34
+ id: number | string;
35
35
  label?: string;
36
36
  alias?: string;
37
37
  type?: PropType;
@@ -53,9 +53,9 @@ export interface EnvProp extends BasicProp {
53
53
  key?: string;
54
54
  }
55
55
  export interface EventProp extends BasicProp {
56
- eventId?: number;
56
+ eventId?: number | string;
57
57
  propCategory: 'eventProp';
58
- key?: number;
58
+ key?: number | string;
59
59
  }
60
60
  export interface PropGroups {
61
61
  eventGroupList?: EventGroup[];
@@ -82,10 +82,11 @@ export declare namespace AttributeSelect {
82
82
  theme?: string;
83
83
  destroyPopupOnHide?: boolean;
84
84
  size?: SizeType;
85
+ showCommonAttr?: boolean;
85
86
  }
86
87
  interface Option {
87
88
  groupName: string;
88
- isEvent: boolean;
89
+ isEvent?: boolean;
89
90
  key: string;
90
91
  anchor: string;
91
92
  children: Value[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgfe/business-lib",
3
- "version": "1.1.12",
3
+ "version": "1.1.13-attr.0",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -60,5 +60,5 @@
60
60
  "react": "^16.12.0 || ^17.0.0",
61
61
  "yorkie": "^2.0.0"
62
62
  },
63
- "gitHead": "5b2d20352f9fbb9919f21397c60a21aa55b9bd7f"
63
+ "gitHead": "60cbc94769458e0fc58942abc834d80c8ed2f113"
64
64
  }