@zgfe/business-lib 1.1.34-alpha.5 → 1.1.34-alpha.7

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.
@@ -122,13 +122,13 @@ var BusinessCondition = function BusinessCondition(props) {
122
122
  newData.values = [startDate, endDate];
123
123
  }
124
124
  if (newData.operator === 'relative') {
125
- newData.values = ['30', '0'];
125
+ newData.values = [30, '0'];
126
126
  }
127
127
  if (newData.operator === 'unlimited_time') {
128
- newData.values = ['30', '0'];
128
+ newData.values = [30, '0'];
129
129
  }
130
130
  if (newData.operator === 'join_time') {
131
- newData.values = ['3', '0'];
131
+ newData.values = [3, '0'];
132
132
  }
133
133
  onChange(_objectSpread(_objectSpread({}, condition), {}, {
134
134
  runPeriod: newData
@@ -149,7 +149,7 @@ var BusinessCondition = function BusinessCondition(props) {
149
149
  var newValue = newData.target.value;
150
150
  onChange(_objectSpread(_objectSpread({}, condition), {}, {
151
151
  runPeriod: _objectSpread(_objectSpread({}, condition.runPeriod), {}, {
152
- values: [newValue, '0']
152
+ values: [Number(newValue), '0']
153
153
  })
154
154
  }));
155
155
  }
@@ -183,7 +183,7 @@ var BusinessCondition = function BusinessCondition(props) {
183
183
  }
184
184
  }
185
185
  var onOperateChange = function onOperateChange(operate) {
186
- condition.runTimes.values = [condition.runTimes.values[0]];
186
+ condition.runTimes.values = [Number(condition.runTimes.values[0])];
187
187
  onChange(_objectSpread(_objectSpread({}, condition), {}, {
188
188
  runTimes: _objectSpread(_objectSpread({}, condition.runTimes), {}, {
189
189
  operator: operate.value
@@ -192,7 +192,7 @@ var BusinessCondition = function BusinessCondition(props) {
192
192
  };
193
193
  var onOperateInput0Change = function onOperateInput0Change(value) {
194
194
  var newValue = value.target.value;
195
- condition.runTimes.values[0] = newValue;
195
+ condition.runTimes.values[0] = Number(newValue);
196
196
  onChange(_objectSpread({}, condition));
197
197
  };
198
198
  var onOperateInput1Change = function onOperateInput1Change(value) {
@@ -212,7 +212,7 @@ var BusinessCondition = function BusinessCondition(props) {
212
212
  if (key === 'time dimension') {
213
213
  var _condition$timeDimens2;
214
214
  var obj = {
215
- frequencyValues: ['1'],
215
+ frequencyValues: [1],
216
216
  frequencyOperator: '>',
217
217
  timeDimension: 1,
218
218
  timeOperator: 'all',
@@ -261,6 +261,7 @@ var BusinessCondition = function BusinessCondition(props) {
261
261
  }
262
262
  function onServiceAttributeChange(operate) {
263
263
  condition.typeId = operate === null || operate === void 0 ? void 0 : operate.value;
264
+ condition.typeName = operate === null || operate === void 0 ? void 0 : operate.name;
264
265
  onChange(_objectSpread({}, condition));
265
266
  setServiceAttribute(operate);
266
267
  }
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { BizUserConditionT } from '../types';
3
3
  import './styles/textDesc.less';
4
4
  export interface TextProps {
5
- condition: BizUserConditionT.ActiveCondition | BizUserConditionT.AddCondition | BizUserConditionT.PropCondition | BizUserConditionT.EventCondition | BizUserConditionT.TagsCondition | BizUserConditionT.CdpCondition;
5
+ condition: BizUserConditionT.ActiveCondition | BizUserConditionT.AddCondition | BizUserConditionT.PropCondition | BizUserConditionT.EventCondition | BizUserConditionT.TagsCondition | BizUserConditionT.CdpCondition | BizUserConditionT.OrderCondition | BizUserConditionT.BusinessCondition;
6
6
  showOrDesc: boolean;
7
7
  }
8
8
  declare const Text: React.FC<TextProps>;
@@ -13,6 +13,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
13
  import _ from 'lodash';
14
14
  import React, { useContext, useMemo } from 'react';
15
15
  import { BizUserConditionContext, classPrefix } from '..';
16
+ import { monthTimeOperatorType, monthValuesType, skyTimeOperatorType, timeDimensionType, timeValuesType, typeList, weekTimeOperatorType, weekValuesType, orderTypeList, computeTypeList, stringOperate } from '../../attrConditions/utils/operates';
16
17
  import BizGlobalDataContext from '../../context';
17
18
  import { findEvent, findPropAndEnv, buildSelectLayer } from '../util';
18
19
  import { durationHandler, operatorMap } from './constants';
@@ -36,6 +37,7 @@ var Text = function Text(props) {
36
37
  return renderCdp(condition);
37
38
  }
38
39
  var data = condition;
40
+ console.log(77773333, data, props);
39
41
  if (String(data.eventId) === '-4') {
40
42
  return renderPeriod({
41
43
  before: '活跃于'
@@ -49,6 +51,9 @@ var Text = function Text(props) {
49
51
  if (data.eventId === undefined) {
50
52
  return renderProps(data.attrs[0], 'user');
51
53
  }
54
+ if (String(data.eventId) === '-13') {
55
+ return renderOrder(data);
56
+ }
52
57
  if (data.eventId) {
53
58
  return renderEvent(data);
54
59
  }
@@ -103,6 +108,7 @@ var Text = function Text(props) {
103
108
  }
104
109
  var period = renderPeriod(periodLabel, condition.runPeriod, true);
105
110
  var runtimes = renderRuntimes(condition.runTimes);
111
+ var timeDimensions = renderTimeDimensions(condition.timeDimensions);
106
112
  var attrs = renderAttrs(event, condition.attrs);
107
113
  return /*#__PURE__*/React.createElement("span", {
108
114
  style: {
@@ -111,7 +117,67 @@ var Text = function Text(props) {
111
117
  }
112
118
  }, period, /*#__PURE__*/React.createElement("span", {
113
119
  className: "".concat(classPrefix, "-text-desc-value")
114
- }, event.alias || event.name), attrs, runtimes);
120
+ }, event.alias || event.name), attrs, timeDimensions, runtimes);
121
+ }
122
+ function renderOrder(condition) {
123
+ var periodLabel = {};
124
+ if (condition.runPeriod.operator === 'join_time') {
125
+ periodLabel.before = '在新增后';
126
+ periodLabel.after = '天内';
127
+ }
128
+ if (condition.runPeriod.operator === 'relative' || condition.runPeriod.operator === 'absolute') {
129
+ periodLabel.before = '在';
130
+ }
131
+ var period = renderPeriod(periodLabel, condition.runPeriod, true);
132
+ var frequencyValues = renderFrequencyValues(condition.runTimes.values, condition.runTimes.operator, '次数');
133
+ var timeDimensions = renderTimeDimensions(condition.timeDimensions);
134
+ var property = renderProperty(condition.attrs, '订单属性');
135
+ return /*#__PURE__*/React.createElement("span", {
136
+ style: {
137
+ backgroundColor: '#fffeeb',
138
+ padding: '6px 7px'
139
+ }
140
+ }, "\u8BA2\u5355\u6570\u636E ", period, timeDimensions, "\u8BA2\u5355\u5C5E\u6027 ", property, frequencyValues);
141
+ }
142
+ function renderProperty(attrs, label) {
143
+ var attrsDom = [];
144
+ attrs.forEach(function (item, i) {
145
+ var attrTypeList = [];
146
+ var operateList = [];
147
+ switch (item.attrType) {
148
+ case 'cont-string':
149
+ attrTypeList = typeList['cont-string'];
150
+ operateList = stringOperate;
151
+ break;
152
+ case 'cont-num':
153
+ attrTypeList = computeTypeList;
154
+ operateList = typeList['cont-num'];
155
+ break;
156
+ default:
157
+ attrTypeList = typeList['cont-date'];
158
+ operateList = typeList['cont-date'];
159
+ break;
160
+ }
161
+ var orderType = orderTypeList.filter(function (v) {
162
+ return v.value === item.orderType;
163
+ });
164
+ var attrType = attrTypeList.filter(function (v) {
165
+ return v.value === (item.attrType === 'cont-num' ? item.computeType : item.operator);
166
+ });
167
+ var operator = operateList.filter(function (v) {
168
+ return v.value === item.computeType;
169
+ });
170
+ var frequencyValues = renderFrequencyValues(item.params, item.operator, item.attrType === 'cont-date' ? '天数' : '');
171
+ if (label) {
172
+ var _orderType$, _attrType$, _operator$;
173
+ var dom = /*#__PURE__*/React.createElement("span", {
174
+ key: i
175
+ }, /*#__PURE__*/React.createElement("span", null, (_orderType$ = orderType[0]) === null || _orderType$ === void 0 ? void 0 : _orderType$.name), /*#__PURE__*/React.createElement("span", null, item.attrName), /*#__PURE__*/React.createElement("span", null, (_attrType$ = attrType[0]) === null || _attrType$ === void 0 ? void 0 : _attrType$.name), /*#__PURE__*/React.createElement("span", null, (_operator$ = operator[0]) === null || _operator$ === void 0 ? void 0 : _operator$.name), /*#__PURE__*/React.createElement("span", null, frequencyValues), i !== attrs.length - 1 ? ',' : '');
176
+ attrsDom.push(dom);
177
+ }
178
+ });
179
+ if (!attrsDom.length) return null;
180
+ return /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("span", null, "\uFF08"), attrsDom, /*#__PURE__*/React.createElement("span", null, "\uFF09"));
115
181
  }
116
182
  function renderAttrs(event, attrs) {
117
183
  var attrsDom = [];
@@ -145,6 +211,75 @@ var Text = function Text(props) {
145
211
  className: "".concat(classPrefix, "-text-desc-value")
146
212
  }, runTimes.values[0]));
147
213
  }
214
+ function renderFrequencyValues(frequencyValues, frequencyOperator, frequency) {
215
+ var _frequencyOperatorLis;
216
+ var frequencyValuesDom = [];
217
+ var frequencyOperatorList = typeList['cont-num'].filter(function (v) {
218
+ return v.value === frequencyOperator;
219
+ });
220
+ frequencyValues.forEach(function (item, i) {
221
+ var dom = /*#__PURE__*/React.createElement("span", {
222
+ key: i
223
+ }, /*#__PURE__*/React.createElement("span", null, item, i !== frequencyValues.length - 1 ? '到' : ''));
224
+ frequencyValuesDom.push(dom);
225
+ });
226
+ return /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("span", {
227
+ className: "".concat(classPrefix, "-text-desc-value")
228
+ }, frequency), /*#__PURE__*/React.createElement("span", {
229
+ className: "".concat(classPrefix, "-text-desc-value")
230
+ }, (_frequencyOperatorLis = frequencyOperatorList[0]) === null || _frequencyOperatorLis === void 0 ? void 0 : _frequencyOperatorLis.name), /*#__PURE__*/React.createElement("span", {
231
+ className: "".concat(classPrefix, "-text-desc-value")
232
+ }, frequencyValuesDom));
233
+ }
234
+ function renderTimeDimensions(timeDimensions) {
235
+ var timeDimensionsDom = [];
236
+ timeDimensions.forEach(function (item, i) {
237
+ var _label$, _operatorTypeList$;
238
+ var label = [];
239
+ var list = [];
240
+ var valuesList = [];
241
+ switch (item.timeDimension) {
242
+ case 1:
243
+ list = skyTimeOperatorType;
244
+ valuesList = timeValuesType;
245
+ break;
246
+ case 2:
247
+ list = weekTimeOperatorType;
248
+ valuesList = weekValuesType;
249
+ break;
250
+ default:
251
+ list = monthTimeOperatorType;
252
+ valuesList = monthValuesType;
253
+ break;
254
+ }
255
+ label = timeDimensionType.filter(function (v) {
256
+ return v.value === item.timeDimension;
257
+ });
258
+ var operatorTypeList = list.filter(function (v) {
259
+ return v.value === item.timeOperator;
260
+ });
261
+ var itemTimeValuesDom = [];
262
+ if (item.timeValues.length > 0) {
263
+ item.timeValues.forEach(function (_v, vIndex) {
264
+ var _valuesTypeList$;
265
+ var valuesTypeList = valuesList.filter(function (v) {
266
+ return v.value === _v;
267
+ });
268
+ var dom = /*#__PURE__*/React.createElement("span", {
269
+ key: vIndex
270
+ }, /*#__PURE__*/React.createElement("span", null, (_valuesTypeList$ = valuesTypeList[0]) === null || _valuesTypeList$ === void 0 ? void 0 : _valuesTypeList$.name, vIndex !== item.timeValues.length - 1 ? '到' : ''));
271
+ itemTimeValuesDom.push(dom);
272
+ });
273
+ }
274
+ var frequencyValues = renderFrequencyValues(item.frequencyValues, item.frequencyOperator, '次数');
275
+ var dom = /*#__PURE__*/React.createElement("span", {
276
+ key: i
277
+ }, /*#__PURE__*/React.createElement("span", null, (_label$ = label[0]) === null || _label$ === void 0 ? void 0 : _label$.name, (_operatorTypeList$ = operatorTypeList[0]) === null || _operatorTypeList$ === void 0 ? void 0 : _operatorTypeList$.name, itemTimeValuesDom, frequencyValues, i !== timeDimensions.length - 1 ? ',' : ''));
278
+ timeDimensionsDom.push(dom);
279
+ });
280
+ if (!timeDimensionsDom.length) return null;
281
+ return /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("span", null, "\uFF08"), "\u65F6\u95F4\u7EF4\u5EA6: ", timeDimensionsDom, /*#__PURE__*/React.createElement("span", null, "\uFF09"));
282
+ }
148
283
  function renderTags(condition) {
149
284
  var labels = condition.labels;
150
285
  return /*#__PURE__*/React.createElement("span", {
@@ -58,10 +58,10 @@ var BizUserCondition = function BizUserCondition(props) {
58
58
  var showTag = openTagCondition && (!menuNameMap || menuNameMap['userTags']);
59
59
  var showCdp = openCdpCondition && (!menuNameMap || menuNameMap['dataset']);
60
60
  var flag = false;
61
- defaultValue.forEach(function (item) {
61
+ defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.forEach(function (item) {
62
62
  var showItem = _toConsumableArray(item);
63
63
  if (!(showTag && showCdp)) {
64
- item.forEach(function (data, index) {
64
+ item === null || item === void 0 ? void 0 : item.forEach(function (data, index) {
65
65
  if (data.dataset && !showCdp || data.labels && !showTag) {
66
66
  showItem.splice(index, 1);
67
67
  flag = true;
@@ -117,6 +117,10 @@ var OrConditions = function OrConditions(props) {
117
117
  data.condition.labels = newData;
118
118
  } else if (type === 'cdp') {
119
119
  data.condition.dataset = newData;
120
+ } else if (type === 'business') {
121
+ data.condition = newData;
122
+ } else if (type === 'order') {
123
+ data.condition = newData;
120
124
  }
121
125
  }
122
126
  newValue.push(data.condition);
@@ -7,10 +7,18 @@ export interface RunPeriodI {
7
7
  operator: 'relative' | 'unlimited_time' | 'join_time' | 'absolute';
8
8
  values: string[];
9
9
  }
10
+ export interface RunPeriodII {
11
+ operator: 'relative' | 'unlimited_time' | 'join_time' | 'absolute';
12
+ values: any[];
13
+ }
10
14
  export interface RunTimesI {
11
15
  operator: '>' | '=' | '<' | '>=' | '<=' | '>=' | 'not equal' | 'between';
12
16
  values: string[];
13
17
  }
18
+ export interface RunTimesII {
19
+ operator: '>' | '=' | '<' | '>=' | '<=' | '>=' | 'not equal' | 'between';
20
+ values: any[];
21
+ }
14
22
  export interface AllConditionBasePropsI<T> {
15
23
  dataId: number;
16
24
  onChange: (dataId: number, newData: T) => void;
@@ -85,7 +93,7 @@ export declare namespace BizUserConditionT {
85
93
  timeOperator: string;
86
94
  timeValues: number[];
87
95
  frequencyOperator: string;
88
- frequencyValues: string[];
96
+ frequencyValues: any[];
89
97
  }
90
98
  interface EventCondition {
91
99
  attrs: AttrCondition[];
@@ -102,17 +110,18 @@ export declare namespace BizUserConditionT {
102
110
  }
103
111
  interface BusinessCondition {
104
112
  typeId: undefined;
113
+ typeName: undefined;
105
114
  attrs: AttrsCondition[];
106
115
  timeDimensions: TimeDimensionsCondition[];
107
- runTimes: RunTimesI;
108
- runPeriod: RunPeriodI;
116
+ runTimes: RunTimesII;
117
+ runPeriod: RunPeriodII;
109
118
  eventId: -14;
110
119
  }
111
120
  interface OrderCondition {
112
121
  attrs: AttrsCondition[];
113
122
  timeDimensions: TimeDimensionsCondition[];
114
- runTimes: RunTimesI;
115
- runPeriod: RunPeriodI;
123
+ runTimes: RunTimesII;
124
+ runPeriod: RunPeriodII;
116
125
  eventId: -13;
117
126
  }
118
127
  interface ActiveCondition {
@@ -158,9 +167,9 @@ export declare namespace BizUserConditionT {
158
167
  interface CdpCondition {
159
168
  dataset: (BizUserConditionT.CdpConditionDetail | undefined)[];
160
169
  }
161
- type Condition = EventCondition | AddCondition | ActiveCondition | PropCondition | TagsCondition | BusinessCondition | CdpCondition;
170
+ type Condition = EventCondition | AddCondition | ActiveCondition | PropCondition | TagsCondition | BusinessCondition | OrderCondition | CdpCondition;
162
171
  type Conditions = Condition[][];
163
- type OtherCondition = EventCondition | AddCondition | ActiveCondition | PropCondition;
172
+ type OtherCondition = EventCondition | AddCondition | ActiveCondition | PropCondition | BusinessCondition | OrderCondition;
164
173
  interface ShowItemI {
165
174
  id: number;
166
175
  orConditions: Conditions[number];
@@ -71,15 +71,16 @@ export function buildCondition(type) {
71
71
  return {
72
72
  eventId: -14,
73
73
  typeId: undefined,
74
+ typeName: undefined,
74
75
  runTimes: {
75
76
  operator: '>=',
76
- values: ['1']
77
+ values: [1]
77
78
  },
78
79
  attrs: [],
79
80
  timeDimensions: [],
80
81
  runPeriod: {
81
82
  operator: 'relative',
82
- values: ['30', '0']
83
+ values: [30, '0']
83
84
  }
84
85
  };
85
86
  case 'order':
@@ -87,13 +88,13 @@ export function buildCondition(type) {
87
88
  eventId: -13,
88
89
  runTimes: {
89
90
  operator: '>=',
90
- values: ['1']
91
+ values: [1]
91
92
  },
92
93
  attrs: [],
93
94
  timeDimensions: [],
94
95
  runPeriod: {
95
96
  operator: 'relative',
96
- values: ['30', '0']
97
+ values: [30, '0']
97
98
  }
98
99
  };
99
100
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgfe/business-lib",
3
- "version": "1.1.34-alpha.5",
3
+ "version": "1.1.34-alpha.7",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",