@zgfe/business-lib 1.1.3-user.0 → 1.1.3-user.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.
@@ -1,9 +1,10 @@
1
1
  import React, { useContext } from 'react';
2
- import { Space } from 'antd';
2
+ import { Space, Tooltip } from 'antd';
3
3
  import { PlusOutlined } from '@ant-design/icons';
4
4
  import './styles/conditionTypeList.less';
5
5
  import { BizUserConditionContext } from '.';
6
6
  import BizGlobalDataContext from '../context';
7
+ import IconFont from '../icon/iconFont';
7
8
 
8
9
  var ConditionTypeList = function ConditionTypeList(props) {
9
10
  var onAdd = props.onAdd,
@@ -13,7 +14,8 @@ var ConditionTypeList = function ConditionTypeList(props) {
13
14
  var _useContext = useContext(BizUserConditionContext),
14
15
  textMode = _useContext.textMode,
15
16
  openTagCondition = _useContext.openTagCondition,
16
- openCdpCondition = _useContext.openCdpCondition;
17
+ openCdpCondition = _useContext.openCdpCondition,
18
+ cdpTip = _useContext.cdpTip;
17
19
 
18
20
  var _useContext2 = useContext(BizGlobalDataContext),
19
21
  menuNameMap = _useContext2.menuNameMap;
@@ -67,7 +69,11 @@ var ConditionTypeList = function ConditionTypeList(props) {
67
69
  onClick: function onClick() {
68
70
  return onAdd('cdp');
69
71
  }
70
- }, /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(PlusOutlined, null), /*#__PURE__*/React.createElement("span", null, "\u660E\u7EC6\u6570\u636E"))) : null));
72
+ }, /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(PlusOutlined, null), /*#__PURE__*/React.createElement("span", null, "\u660E\u7EC6\u6570\u636E"), cdpTip ? /*#__PURE__*/React.createElement(Tooltip, {
73
+ title: cdpTip
74
+ }, /*#__PURE__*/React.createElement(IconFont, {
75
+ type: "tishiicon"
76
+ })) : null)) : null));
71
77
  };
72
78
 
73
79
  ConditionTypeList.defaultProps = {
@@ -198,6 +198,7 @@ var CdpConditionItem = function CdpConditionItem(props) {
198
198
 
199
199
  var onOperateChange = function onOperateChange(operate) {
200
200
  setOperator(operate);
201
+ setFieldValue([]);
201
202
  };
202
203
 
203
204
  function getOptions(type) {
@@ -260,7 +261,7 @@ var CdpConditionItem = function CdpConditionItem(props) {
260
261
  defaultValue: fieldValue && fieldValue[0],
261
262
  onChange: function onChange(e) {
262
263
  e.persist();
263
- setFieldValue([e.target.value]);
264
+ setFieldValue([e.target.value, '1']);
264
265
  },
265
266
  suffix: "\u5929"
266
267
  });
@@ -346,7 +347,7 @@ var CdpCondition = function CdpCondition(props) {
346
347
  }, "\u660E\u7EC6\u6570\u636E"), cdpConditions.map(function (item, index) {
347
348
  return /*#__PURE__*/React.createElement(CdpConditionItem, {
348
349
  value: item,
349
- key: (item === null || item === void 0 ? void 0 : item.fieldName) || index,
350
+ key: "".concat(item === null || item === void 0 ? void 0 : item.datasetId).concat(item === null || item === void 0 ? void 0 : item.operator).concat(index),
350
351
  onChange: function onChange(data) {
351
352
  return onChangeCondition(data, index);
352
353
  }
@@ -217,9 +217,7 @@ var Text = function Text(props) {
217
217
  backgroundColor: '#effcff',
218
218
  padding: '6px 7px'
219
219
  }
220
- }, /*#__PURE__*/React.createElement("span", {
221
- className: "".concat(classPrefix, "-text-desc-value")
222
- }, /*#__PURE__*/React.createElement("span", null, "("), dataset.map(function (value) {
220
+ }, dataset.map(function (value) {
223
221
  if (!value) return null;
224
222
  var operator = value.operator,
225
223
  _value$params = value.params,
@@ -252,7 +250,7 @@ var Text = function Text(props) {
252
250
  return /*#__PURE__*/React.createElement("span", {
253
251
  key: Math.random()
254
252
  }, "".concat(value.datasetName, "\u4E2D").concat(value.fieldName).concat(valuesDom));
255
- }), /*#__PURE__*/React.createElement("span", null, ")")));
253
+ }));
256
254
  }
257
255
 
258
256
  function renderPropValues(attr) {
@@ -50,7 +50,7 @@ export default (function () {
50
50
  }, [conditions]);
51
51
 
52
52
  function onChange(value) {
53
- console.log('change:', JSON.stringify(value));
53
+ console.log('change:', JSON.parse(JSON.stringify(value)));
54
54
  }
55
55
 
56
56
  var descDom = /*#__PURE__*/React.createElement(BizUserCondition, {
@@ -1,3 +1,5 @@
1
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || 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(_e2) { throw _e2; }, 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(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
+
1
3
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
4
 
3
5
  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."); }
@@ -24,7 +26,6 @@ import RelationLabel from './relationLabel';
24
26
  import OrConditions from './orConditions';
25
27
  import './styles/index.less';
26
28
  import { buildCondition } from './util';
27
- import _ from 'lodash';
28
29
  import BizGlobalDataContext from '../context';
29
30
  import IconFont from '../icon/iconFont';
30
31
  import request from '../utils/ajax';
@@ -54,7 +55,8 @@ var BizUserCondition = function BizUserCondition(props) {
54
55
  defaultValue = props.defaultValue,
55
56
  openTagCondition = props.openTagCondition,
56
57
  openCdpCondition = props.openCdpCondition,
57
- userTagsData = props.userTagsData;
58
+ userTagsData = props.userTagsData,
59
+ cdpTip = props.cdpTip;
58
60
 
59
61
  var _useState = useState([]),
60
62
  _useState2 = _slicedToArray(_useState, 2),
@@ -67,11 +69,35 @@ var BizUserCondition = function BizUserCondition(props) {
67
69
  setDataList = _useState4[1];
68
70
 
69
71
  var _useState5 = useState(function () {
72
+ var list = [];
73
+
70
74
  if (defaultValue) {
71
- return _.cloneDeep(defaultValue);
75
+ var showTag = openTagCondition && (!menuNameMap || menuNameMap['userTags']);
76
+ var showCdp = openCdpCondition && (!menuNameMap || menuNameMap['dataset']);
77
+ var flag = false;
78
+ defaultValue.forEach(function (item) {
79
+ var showItem = _toConsumableArray(item);
80
+
81
+ if (!(showTag && showCdp)) {
82
+ item.forEach(function (data, index) {
83
+ if (data.dataset && !showCdp || data.labels && !showTag) {
84
+ showItem.splice(index, 1);
85
+ flag = true;
86
+ }
87
+ });
88
+ }
89
+
90
+ if (showItem.length > 0) {
91
+ list.push(showItem);
92
+ }
93
+ });
94
+
95
+ if (flag) {
96
+ props.onChange(list);
97
+ }
72
98
  }
73
99
 
74
- return [];
100
+ return list;
75
101
  }),
76
102
  _useState6 = _slicedToArray(_useState5, 2),
77
103
  value = _useState6[0],
@@ -108,6 +134,42 @@ var BizUserCondition = function BizUserCondition(props) {
108
134
  setLoading(false);
109
135
  }
110
136
  }, []);
137
+ var haveCdpValues = useMemo(function () {
138
+ var flag = false;
139
+
140
+ var _iterator = _createForOfIteratorHelper(value),
141
+ _step;
142
+
143
+ try {
144
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
145
+ var condition = _step.value;
146
+
147
+ var _iterator2 = _createForOfIteratorHelper(condition),
148
+ _step2;
149
+
150
+ try {
151
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
152
+ var item = _step2.value;
153
+
154
+ if (item.dataset) {
155
+ flag = true;
156
+ break;
157
+ }
158
+ }
159
+ } catch (err) {
160
+ _iterator2.e(err);
161
+ } finally {
162
+ _iterator2.f();
163
+ }
164
+ }
165
+ } catch (err) {
166
+ _iterator.e(err);
167
+ } finally {
168
+ _iterator.f();
169
+ }
170
+
171
+ return flag;
172
+ }, [value]);
111
173
 
112
174
  function initShowList() {
113
175
  var showList = [];
@@ -193,6 +255,7 @@ var BizUserCondition = function BizUserCondition(props) {
193
255
  textMode: props.textMode,
194
256
  openTagCondition: openTagCondition,
195
257
  openCdpCondition: openCdpCondition,
258
+ cdpTip: cdpTip,
196
259
  userTagsData: userTagsData !== null && userTagsData !== void 0 ? userTagsData : [],
197
260
  isRealTime: props.isRealTime,
198
261
  envNameList: envNameList,
@@ -220,11 +283,11 @@ var BizUserCondition = function BizUserCondition(props) {
220
283
  show: value.length < andConditionNum,
221
284
  label: "\u4E14",
222
285
  onAdd: onAdd
223
- }), openCdpCondition && (!menuNameMap || menuNameMap['dataset']) ? /*#__PURE__*/React.createElement("div", {
286
+ }), openCdpCondition && (!menuNameMap || menuNameMap['dataset']) && !props.textMode && haveCdpValues ? /*#__PURE__*/React.createElement("div", {
224
287
  className: "".concat(classPrefix, "-tip")
225
288
  }, ' ', /*#__PURE__*/React.createElement(IconFont, {
226
289
  type: "tishiicon"
227
- }), "\u660E\u7EC6\u8868\u4E2D\u9700\u5B58\u5728\u300Cuser_id\u300D\u6761\u4EF6\u65B9\u53EF\u751F\u6548\u3002") : null));
290
+ }), "\u660E\u7EC6\u8868\u4E2D\u9700\u5B58\u5728\u300Capp_user_id\u300D\u6761\u4EF6\u65B9\u53EF\u751F\u6548\u3002") : null));
228
291
  };
229
292
 
230
293
  BizUserCondition.defaultProps = {
@@ -36,6 +36,7 @@ export declare namespace BizUserConditionT {
36
36
  userTagsData?: UserTagsDataI[];
37
37
  isRealTime?: boolean;
38
38
  openCdpCondition?: boolean;
39
+ cdpTip?: string;
39
40
  }
40
41
  interface UserTagsDataI {
41
42
  appId: number;
@@ -132,7 +133,7 @@ export declare namespace BizUserConditionT {
132
133
  orConditions: Conditions[number];
133
134
  }
134
135
  type ShowListT = ShowItemI[];
135
- type GlobalContext = Pick<BizUserConditionT.PropsI, 'orConditionNum' | 'eventAttrNum' | 'openTagCondition' | 'userTagsData' | 'openCdpCondition' | 'textMode' | 'isRealTime'> & {
136
+ type GlobalContext = Pick<BizUserConditionT.PropsI, 'orConditionNum' | 'eventAttrNum' | 'openTagCondition' | 'userTagsData' | 'openCdpCondition' | 'textMode' | 'isRealTime' | 'cdpTip'> & {
136
137
  envNameList: string[];
137
138
  userPropsMap: {
138
139
  [key: string]: UserProp;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgfe/business-lib",
3
- "version": "1.1.3-user.0",
3
+ "version": "1.1.3-user.10",
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": "26e6afc8e7d87d53736066f6380b8090b1016b9b"
63
+ "gitHead": "f9e277f36d5ac472fd9fb5cf5a840b82d8eb9cf8"
64
64
  }