@zgfe/business-lib 1.0.1-beta.0 → 1.0.3-beta.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 (58) hide show
  1. package/es/analysisLayout/index.js +11 -9
  2. package/es/attrConditions/components/stringList.js +1 -0
  3. package/es/attrConditions/components/valuesList.js +4 -2
  4. package/es/attrConditions/group.js +1 -2
  5. package/es/attributeSelector/index.js +6 -4
  6. package/es/attributeSelector/listPanel.js +11 -9
  7. package/es/chart/index.js +12 -10
  8. package/es/components/iconFont.js +4 -2
  9. package/es/dialog/components/itemNode.d.ts +1 -0
  10. package/es/dialog/components/itemNode.js +15 -13
  11. package/es/dialog/components/list.js +7 -5
  12. package/es/dialog/components/selectToInput.js +8 -6
  13. package/es/dialog/index.js +14 -11
  14. package/es/dialog/types.d.ts +1 -1
  15. package/es/eventSelector/listPanel.js +4 -2
  16. package/es/index.d.ts +2 -1
  17. package/es/index.js +2 -1
  18. package/es/select/handle.d.ts +2 -2
  19. package/es/select/handle.js +8 -8
  20. package/es/select/index.js +6 -4
  21. package/es/table/index.js +12 -10
  22. package/es/targetConditionGroup/index.js +5 -2
  23. package/es/targetSelector/index.js +6 -4
  24. package/es/userCondition/conditionTypeList.d.ts +10 -0
  25. package/es/userCondition/conditionTypeList.js +43 -0
  26. package/es/userCondition/conditionWrap.d.ts +7 -0
  27. package/es/userCondition/conditionWrap.js +18 -0
  28. package/es/userCondition/conditions/eventCondition.d.ts +8 -0
  29. package/es/userCondition/conditions/eventCondition.js +104 -0
  30. package/es/userCondition/conditions/periodCondition.d.ts +11 -0
  31. package/es/userCondition/conditions/periodCondition.js +156 -0
  32. package/es/userCondition/conditions/propCondition.d.ts +11 -0
  33. package/es/userCondition/conditions/propCondition.js +147 -0
  34. package/es/userCondition/conditions/runTimesCondition.d.ts +9 -0
  35. package/es/userCondition/conditions/runTimesCondition.js +78 -0
  36. package/es/userCondition/conditions/styles/eventCondition.less +49 -0
  37. package/es/userCondition/conditions/styles/periodCondition.less +14 -0
  38. package/es/userCondition/conditions/styles/propCondition.less +36 -0
  39. package/es/userCondition/conditions/styles/runTimesCondition.less +16 -0
  40. package/es/userCondition/demo/index.d.ts +2 -0
  41. package/es/userCondition/demo/index.js +97 -0
  42. package/es/userCondition/index.d.ts +7 -0
  43. package/es/userCondition/index.js +146 -0
  44. package/es/userCondition/orConditions.d.ts +5 -0
  45. package/es/userCondition/orConditions.js +202 -0
  46. package/es/userCondition/relationLabel.d.ts +6 -0
  47. package/es/userCondition/relationLabel.js +12 -0
  48. package/es/userCondition/styles/conditionTypeList.less +31 -0
  49. package/es/userCondition/styles/conditionWrap.less +14 -0
  50. package/es/userCondition/styles/index.less +13 -0
  51. package/es/userCondition/styles/orConditions.less +16 -0
  52. package/es/userCondition/styles/relationLabel.less +18 -0
  53. package/es/userCondition/types.d.ts +79 -0
  54. package/es/userCondition/types.js +1 -0
  55. package/es/userCondition/util.d.ts +2 -0
  56. package/es/userCondition/util.js +54 -0
  57. package/es/userGroup/index.js +6 -4
  58. package/package.json +2 -2
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ import { Space } from 'antd';
3
+ import { PlusOutlined } from '@ant-design/icons';
4
+ import './styles/conditionTypeList.less';
5
+
6
+ var ConditionTypeList = function ConditionTypeList(props) {
7
+ var onAdd = props.onAdd,
8
+ label = props.label,
9
+ show = props.show;
10
+ if (!show) return null;
11
+ return /*#__PURE__*/React.createElement("div", {
12
+ className: "biz-user-condition-type-list"
13
+ }, label ? /*#__PURE__*/React.createElement("div", {
14
+ className: "biz-user-condition-type-label"
15
+ }, label) : null, /*#__PURE__*/React.createElement("ul", {
16
+ className: "biz-user-condition-type-container"
17
+ }, /*#__PURE__*/React.createElement("li", {
18
+ className: "condition-type",
19
+ onClick: function onClick() {
20
+ return onAdd('event');
21
+ }
22
+ }, /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(PlusOutlined, null), /*#__PURE__*/React.createElement("span", null, "\u505A\u8FC7\uFF08\u6CA1\u505A\u8FC7\uFF09\u2026"))), /*#__PURE__*/React.createElement("li", {
23
+ className: "condition-type",
24
+ onClick: function onClick() {
25
+ return onAdd('add');
26
+ }
27
+ }, /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(PlusOutlined, null), /*#__PURE__*/React.createElement("span", null, "\u65B0\u589E\u4E8E"))), /*#__PURE__*/React.createElement("li", {
28
+ className: "condition-type",
29
+ onClick: function onClick() {
30
+ return onAdd('active');
31
+ }
32
+ }, /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(PlusOutlined, null), /*#__PURE__*/React.createElement("span", null, "\u6D3B\u8DC3\u4E8E"))), /*#__PURE__*/React.createElement("li", {
33
+ className: "condition-type",
34
+ onClick: function onClick() {
35
+ return onAdd('prop');
36
+ }
37
+ }, /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(PlusOutlined, null), /*#__PURE__*/React.createElement("span", null, "\u7528\u6237\u5C5E\u6027\u6EE1\u8DB3")))));
38
+ };
39
+
40
+ ConditionTypeList.defaultProps = {
41
+ show: true
42
+ };
43
+ export default ConditionTypeList;
@@ -0,0 +1,7 @@
1
+ import React, { PropsWithChildren } from 'react';
2
+ import './styles/conditionWrap.less';
3
+ export interface ConditionWrapPropsI {
4
+ onDelte: () => void;
5
+ }
6
+ declare const ConditionWrap: React.FC<PropsWithChildren<ConditionWrapPropsI>>;
7
+ export default ConditionWrap;
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { CloseOutlined } from '@ant-design/icons';
3
+ import './styles/conditionWrap.less';
4
+
5
+ var ConditionWrap = function ConditionWrap(props) {
6
+ return /*#__PURE__*/React.createElement("div", {
7
+ className: "biz-user-condition-item-wrap"
8
+ }, /*#__PURE__*/React.createElement("div", {
9
+ className: "biz-user-condition-item"
10
+ }, props.children), /*#__PURE__*/React.createElement("div", {
11
+ className: "biz-user-condition-item-delete",
12
+ onClick: function onClick() {
13
+ return props.onDelte();
14
+ }
15
+ }, /*#__PURE__*/React.createElement(CloseOutlined, null)));
16
+ };
17
+
18
+ export default ConditionWrap;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { AllConditionBasePropsI, BizUserConditionT } from '../types';
3
+ import './styles/eventCondition.less';
4
+ export interface EventConditionPropsI extends AllConditionBasePropsI<any> {
5
+ condition: BizUserConditionT.EventCondition;
6
+ }
7
+ declare const EventCondition: React.FC<EventConditionPropsI>;
8
+ export default EventCondition;
@@ -0,0 +1,104 @@
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
+
7
+ import React from 'react';
8
+ import { RightOutlined } from '@ant-design/icons';
9
+ import BizEventSelector from '../../eventSelector';
10
+ import RunTimesCondition from './runTimesCondition';
11
+ import PeriodCondition from './periodCondition';
12
+ import PropCondition from './propCondition';
13
+ import './styles/eventCondition.less';
14
+ import { classPrefix } from '..';
15
+
16
+ var EventCondition = function EventCondition(props) {
17
+ var condition = props.condition,
18
+ dataId = props.dataId;
19
+
20
+ function onChange(data) {
21
+ props.onChange(dataId, data);
22
+ }
23
+
24
+ function onEventChange(data) {
25
+ var event = data.event;
26
+ onChange(_objectSpread(_objectSpread({}, condition), {}, {
27
+ eventId: event.id
28
+ }));
29
+ }
30
+
31
+ function onRunTimesChange(newRunTimes) {
32
+ onChange(_objectSpread(_objectSpread({}, condition), {}, {
33
+ runTimes: newRunTimes
34
+ }));
35
+ }
36
+
37
+ function onPeriodChange(_dataId, newPeriod) {
38
+ onChange(_objectSpread(_objectSpread({}, condition), {}, {
39
+ runPeriod: newPeriod
40
+ }));
41
+ }
42
+
43
+ function onAttrChange(_dataId, newAttrs) {
44
+ onChange(_objectSpread(_objectSpread({}, condition), {}, {
45
+ attrs: newAttrs
46
+ }));
47
+ }
48
+
49
+ function onAddAttr() {
50
+ onChange(_objectSpread(_objectSpread({}, condition), {}, {
51
+ attrs: [{
52
+ attrId: 0,
53
+ attrName: ''
54
+ }]
55
+ }));
56
+ }
57
+
58
+ return /*#__PURE__*/React.createElement("div", {
59
+ className: "".concat(classPrefix, "-event-condition")
60
+ }, /*#__PURE__*/React.createElement("div", {
61
+ className: "".concat(classPrefix, "-event-condition-left")
62
+ }, /*#__PURE__*/React.createElement("div", {
63
+ className: "".concat(classPrefix, "-event-condition-label")
64
+ }, /*#__PURE__*/React.createElement("span", null, "\u505A\u8FC7")), /*#__PURE__*/React.createElement("div", {
65
+ className: "".concat(classPrefix, "-event")
66
+ }, /*#__PURE__*/React.createElement(BizEventSelector, {
67
+ showAllEvent: false,
68
+ defaultValue: {
69
+ event: {
70
+ id: condition.eventId
71
+ }
72
+ },
73
+ onChange: onEventChange
74
+ })), /*#__PURE__*/React.createElement("div", {
75
+ className: "".concat(classPrefix, "-event-condition-expand-attr"),
76
+ onClick: onAddAttr
77
+ }, /*#__PURE__*/React.createElement(RightOutlined, null))), /*#__PURE__*/React.createElement("div", {
78
+ className: "".concat(classPrefix, "-event-condition-right")
79
+ }, condition.attrs.length && condition.eventId ? /*#__PURE__*/React.createElement("div", {
80
+ className: "".concat(classPrefix, "-event-condition-attrs")
81
+ }, /*#__PURE__*/React.createElement(PropCondition, {
82
+ isEvent: true,
83
+ dataId: dataId,
84
+ attrs: condition.attrs,
85
+ onChange: onAttrChange,
86
+ eventId: condition.eventId
87
+ })) : null, /*#__PURE__*/React.createElement("div", {
88
+ className: "".concat(classPrefix, "-event-condition-times-period-wrap")
89
+ }, /*#__PURE__*/React.createElement("div", {
90
+ className: "".concat(classPrefix, "-event-condition-runtimes")
91
+ }, /*#__PURE__*/React.createElement(RunTimesCondition, {
92
+ onChange: onRunTimesChange,
93
+ runTimes: condition.runTimes
94
+ })), /*#__PURE__*/React.createElement("div", {
95
+ className: "".concat(classPrefix, "-event-condition-period")
96
+ }, /*#__PURE__*/React.createElement(PeriodCondition, {
97
+ dataId: dataId,
98
+ runPeriod: condition.runPeriod,
99
+ onChange: onPeriodChange,
100
+ isEvent: true
101
+ })))));
102
+ };
103
+
104
+ export default EventCondition;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { AllConditionBasePropsI, RunPeriodI } from '../types';
3
+ import './styles/periodCondition.less';
4
+ export interface PeriodConditionPropsI extends AllConditionBasePropsI<RunPeriodI> {
5
+ label?: string | React.ReactDOM;
6
+ isEvent?: boolean;
7
+ runPeriod: RunPeriodI;
8
+ isRealTime?: boolean;
9
+ }
10
+ declare const PeriodCondition: React.FC<PeriodConditionPropsI>;
11
+ export default PeriodCondition;
@@ -0,0 +1,156 @@
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
+
7
+ import React from 'react';
8
+ import BizSelect from '../../select';
9
+ import { Input, DatePicker, Checkbox } from 'antd';
10
+ import moment from 'moment';
11
+ import './styles/periodCondition.less';
12
+ import { classPrefix } from '..';
13
+ var RangePicker = DatePicker.RangePicker;
14
+ var operatorMap = {
15
+ relative: '最近',
16
+ absolute: '固定时段',
17
+ unlimited_time: '任意时间',
18
+ join_time: '新增后'
19
+ };
20
+
21
+ var PeriodCondition = function PeriodCondition(props) {
22
+ var dataId = props.dataId,
23
+ label = props.label,
24
+ isEvent = props.isEvent,
25
+ runPeriod = props.runPeriod;
26
+ var options = [{
27
+ text: '最近',
28
+ value: 'relative'
29
+ }, {
30
+ text: '固定时段',
31
+ value: 'absolute'
32
+ }];
33
+
34
+ if (isEvent) {
35
+ options = options.concat([{
36
+ text: '任意时间',
37
+ value: 'unlimited_time'
38
+ }, {
39
+ text: '新增后',
40
+ value: 'join_time'
41
+ }]);
42
+ }
43
+
44
+ function onChange(data) {
45
+ props.onChange(dataId, data);
46
+ }
47
+
48
+ function onOperatorChange(option) {
49
+ var newData = {
50
+ operator: option.value
51
+ };
52
+
53
+ if (newData.operator === 'absolute') {
54
+ var endDate = moment().format('YYYY-MM-DD');
55
+ var startDate = moment().subtract(7, 'days').format('YYYY-MM-DD');
56
+ newData.values = [startDate, endDate];
57
+ }
58
+
59
+ if (newData.operator === 'relative') {
60
+ newData.values = ['30', '0'];
61
+ }
62
+
63
+ if (newData.operator === 'join_time') {
64
+ newData.values = ['3', '0'];
65
+ }
66
+
67
+ onChange(newData);
68
+ }
69
+
70
+ function onDateChange(newData) {
71
+ if (runPeriod.operator === 'absolute') {
72
+ var dateRange = newData;
73
+ var newValues = dateRange.map(function (date) {
74
+ return date.format('YYYY-MM-DD');
75
+ });
76
+ onChange(_objectSpread(_objectSpread({}, runPeriod), {}, {
77
+ values: newValues
78
+ }));
79
+ } else if (runPeriod.operator === 'relative' || runPeriod.operator === 'join_time') {
80
+ var newValue = newData.target.value;
81
+ onChange(_objectSpread(_objectSpread({}, runPeriod), {}, {
82
+ values: [newValue, runPeriod.values[1]]
83
+ }));
84
+ }
85
+ }
86
+
87
+ function onChangeToday(e) {
88
+ var newValues = [runPeriod.values[0], '0'];
89
+
90
+ if (e.target.checked) {
91
+ newValues[1] = '1';
92
+ console.log(newValues);
93
+ }
94
+
95
+ onChange(_objectSpread(_objectSpread({}, runPeriod), {}, {
96
+ values: newValues
97
+ }));
98
+ }
99
+
100
+ function renderValues() {
101
+ var operator = runPeriod.operator,
102
+ values = runPeriod.values;
103
+
104
+ if (operator === 'relative' || operator === 'join_time') {
105
+ return /*#__PURE__*/React.createElement(Input, {
106
+ size: "large",
107
+ value: values[0],
108
+ onChange: onDateChange,
109
+ style: {
110
+ width: 58
111
+ }
112
+ });
113
+ }
114
+
115
+ if (operator === 'absolute') {
116
+ return /*#__PURE__*/React.createElement(RangePicker, {
117
+ defaultValue: [moment(values[0]), moment(values[1])],
118
+ onChange: onDateChange,
119
+ allowClear: false
120
+ });
121
+ }
122
+ }
123
+
124
+ return /*#__PURE__*/React.createElement("div", {
125
+ className: "".concat(classPrefix, "-period-condition")
126
+ }, label ? /*#__PURE__*/React.createElement("div", {
127
+ className: "".concat(classPrefix, "-period-condition-label")
128
+ }, label) : null, /*#__PURE__*/React.createElement("div", {
129
+ className: "".concat(classPrefix, "-period-condition-operator")
130
+ }, /*#__PURE__*/React.createElement(BizSelect, {
131
+ overlayWidth: 129,
132
+ options: options,
133
+ labelField: "text",
134
+ keyField: "value",
135
+ value: {
136
+ value: runPeriod.operator,
137
+ text: operatorMap[runPeriod.operator]
138
+ },
139
+ onChange: onOperatorChange
140
+ })), /*#__PURE__*/React.createElement("div", {
141
+ className: "".concat(classPrefix, "-period-condition-values")
142
+ }, renderValues()), /*#__PURE__*/React.createElement("div", {
143
+ className: "".concat(classPrefix, "-period-condition-unit")
144
+ }, "\u5929"), props.isRealTime && runPeriod.operator === 'relative' ? /*#__PURE__*/React.createElement("div", {
145
+ className: "".concat(classPrefix, "-period-condition-today")
146
+ }, /*#__PURE__*/React.createElement(Checkbox, {
147
+ checked: runPeriod.values[1] === '1',
148
+ onChange: onChangeToday
149
+ }, "\u4E0D\u5305\u542B\u4ECA\u5929")) : null);
150
+ };
151
+
152
+ PeriodCondition.defaultProps = {
153
+ isEvent: false,
154
+ isRealTime: false
155
+ };
156
+ export default PeriodCondition;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { AllConditionBasePropsI, BizUserConditionT } from '../types';
3
+ import './styles/propCondition.less';
4
+ export interface PropConditionPropsI extends AllConditionBasePropsI<any> {
5
+ isEvent?: boolean;
6
+ label?: string | React.ReactDOM;
7
+ eventId?: number;
8
+ attrs: BizUserConditionT.AttrCondition[];
9
+ }
10
+ declare const PropCondition: React.FC<PropConditionPropsI>;
11
+ export default PropCondition;
@@ -0,0 +1,147 @@
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
+
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 _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
12
+
13
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
14
+
15
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
16
+
17
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
18
+
19
+ import React from 'react';
20
+ import { PlusOutlined } from '@ant-design/icons';
21
+ import BizConditionItem from '../../attrConditions';
22
+ import './styles/propCondition.less';
23
+ import { useContext } from 'react';
24
+ import { BizUserConditionContext, classPrefix } from '..';
25
+ var numAttrTypeMap = {
26
+ 1: 'cont-string',
27
+ 2: 'cont-num',
28
+ 3: 'cont-date'
29
+ };
30
+ var attrNumTypeMap = {
31
+ 'cont-string': 1,
32
+ 'cont-num': 2,
33
+ 'cont-date': 3
34
+ };
35
+
36
+ var PropCondition = function PropCondition(props) {
37
+ var _useContext = useContext(BizUserConditionContext),
38
+ eventAttrNum = _useContext.eventAttrNum;
39
+
40
+ var isEvent = props.isEvent,
41
+ label = props.label,
42
+ attrs = props.attrs,
43
+ dataId = props.dataId;
44
+
45
+ function _onChange(data, i) {
46
+ var attrName = data.attrName,
47
+ attrId = data.attrId,
48
+ category = data.category,
49
+ type = data.type,
50
+ operation = data.operation,
51
+ values = data.values;
52
+
53
+ var newAttrs = _toConsumableArray(attrs);
54
+
55
+ var newAttr = {
56
+ attrName: attrName,
57
+ attrId: attrId,
58
+ category: category,
59
+ operator: operation,
60
+ params: values,
61
+ attrType: numAttrTypeMap[type]
62
+ };
63
+ newAttrs[i] = newAttr;
64
+ props.onChange(dataId, newAttrs);
65
+ }
66
+
67
+ function onAddAttr() {
68
+ props.onChange(dataId, [].concat(_toConsumableArray(attrs), [{
69
+ attrId: 0
70
+ }]));
71
+ }
72
+
73
+ function onRemoveAttr(i) {
74
+ var newAttrs = _toConsumableArray(attrs);
75
+
76
+ newAttrs.splice(i, 1);
77
+ props.onChange(dataId, newAttrs);
78
+ }
79
+
80
+ function getPropCategory(attrName) {
81
+ if (!isEvent) return 'userProp';
82
+ return attrName === undefined ? 'eventProp' : 'envProp';
83
+ }
84
+
85
+ function renderAttr(attr, i) {
86
+ var attrId = attr.attrId,
87
+ attrName = attr.attrName,
88
+ category = attr.category,
89
+ operator = attr.operator,
90
+ params = attr.params,
91
+ attrType = attr.attrType;
92
+ console.log(attrType);
93
+ var props = {};
94
+
95
+ if ((attrName || attrId) && operator) {
96
+ props.value = {
97
+ attrName: attrName,
98
+ category: category || 'custom',
99
+ operation: operator,
100
+ values: params || [],
101
+ propCategory: getPropCategory(attrName),
102
+ type: attrNumTypeMap[attrType]
103
+ };
104
+ props.key = attrName || attrId;
105
+ attrId && (props.value.attrId = attrId);
106
+ }
107
+
108
+ console.log(props);
109
+ return /*#__PURE__*/React.createElement("div", {
110
+ className: "".concat(classPrefix, "-prop-condition-attr"),
111
+ key: attrName || attrId || Math.random()
112
+ }, /*#__PURE__*/React.createElement("div", {
113
+ className: "".concat(classPrefix, "-prop-condition-item-wrap")
114
+ }, /*#__PURE__*/React.createElement(BizConditionItem, _objectSpread({
115
+ onChange: function onChange(data) {
116
+ return _onChange(data, i);
117
+ },
118
+ enableUserProp: !isEvent,
119
+ enableEnvProp: isEvent,
120
+ enableEventProp: isEvent,
121
+ onDelete: function onDelete() {
122
+ return onRemoveAttr(i);
123
+ },
124
+ enableDelete: isEvent
125
+ }, props))));
126
+ }
127
+
128
+ return /*#__PURE__*/React.createElement("div", {
129
+ className: "".concat(classPrefix, "-prop-condition")
130
+ }, label ? /*#__PURE__*/React.createElement("div", {
131
+ className: "".concat(classPrefix, "-prop-condition-label")
132
+ }, label) : null, /*#__PURE__*/React.createElement("div", {
133
+ className: "".concat(classPrefix, "-prop-condition-attrs")
134
+ }, attrs.map(function (attr, i) {
135
+ return renderAttr(attr, i);
136
+ })), attrs.length < eventAttrNum && isEvent ? /*#__PURE__*/React.createElement("div", {
137
+ className: "".concat(classPrefix, "-prop-condition-add")
138
+ }, /*#__PURE__*/React.createElement("div", {
139
+ className: "".concat(classPrefix, "-prop-add-btn"),
140
+ onClick: onAddAttr
141
+ }, /*#__PURE__*/React.createElement(PlusOutlined, null))) : null);
142
+ };
143
+
144
+ PropCondition.defaultProps = {
145
+ isEvent: false
146
+ };
147
+ export default PropCondition;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { RunTimesI } from '../types';
3
+ import './styles/runTimesCondition.less';
4
+ export interface RunTimesConditionPropsI {
5
+ runTimes: RunTimesI;
6
+ onChange: (data: RunTimesI) => void;
7
+ }
8
+ declare const RunTimesCondition: React.FC<RunTimesConditionPropsI>;
9
+ export default RunTimesCondition;
@@ -0,0 +1,78 @@
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
+
7
+ import React from 'react';
8
+ import { Input, Tooltip, Space } from 'antd';
9
+ import { InfoCircleOutlined } from '@ant-design/icons';
10
+ import BizSelect from '../../select';
11
+ import './styles/runTimesCondition.less';
12
+ import { classPrefix } from '..';
13
+ var options = [{
14
+ value: '>',
15
+ text: '>'
16
+ }, {
17
+ value: '=',
18
+ text: '='
19
+ }, {
20
+ value: '<',
21
+ text: '<'
22
+ }, {
23
+ value: '>=',
24
+ text: '>='
25
+ }, {
26
+ value: '<=',
27
+ text: '<='
28
+ }, {
29
+ value: 'not equal',
30
+ text: '≠'
31
+ }];
32
+
33
+ var RunTimesCondition = function RunTimesCondition(props) {
34
+ var runTimes = props.runTimes,
35
+ onChange = props.onChange;
36
+
37
+ function onOperatorChange(data) {
38
+ onChange(_objectSpread(_objectSpread({}, runTimes), {}, {
39
+ operator: data.value
40
+ }));
41
+ }
42
+
43
+ function onValueChange(e) {
44
+ var value = e.target.value;
45
+ onChange(_objectSpread(_objectSpread({}, runTimes), {}, {
46
+ values: [value]
47
+ }));
48
+ }
49
+
50
+ return /*#__PURE__*/React.createElement("div", {
51
+ className: "".concat(classPrefix, "-runtimes-condition")
52
+ }, /*#__PURE__*/React.createElement("div", {
53
+ className: "".concat(classPrefix, "-runtimes-condition-operator")
54
+ }, /*#__PURE__*/React.createElement(BizSelect, {
55
+ options: options,
56
+ labelField: "text",
57
+ keyField: "value",
58
+ value: {
59
+ value: runTimes.operator,
60
+ text: runTimes.operator === 'not equal' ? '≠' : runTimes.operator
61
+ },
62
+ onChange: onOperatorChange
63
+ })), /*#__PURE__*/React.createElement("div", {
64
+ className: "".concat(classPrefix, "-runtimes-condition-value")
65
+ }, /*#__PURE__*/React.createElement(Input, {
66
+ size: "large",
67
+ value: runTimes.values[0],
68
+ onChange: onValueChange
69
+ })), /*#__PURE__*/React.createElement("div", {
70
+ className: "".concat(classPrefix, "-runtimes-condition-unit")
71
+ }, /*#__PURE__*/React.createElement(Space, null, "\u6B21", /*#__PURE__*/React.createElement(Tooltip, {
72
+ title: "\u89E6\u53D1\u6B21\u6570\u4E3A0\u7B49\u540C\u4E8E\u6CA1\u6709\u89E6\u53D1"
73
+ }, /*#__PURE__*/React.createElement("span", {
74
+ className: "".concat(classPrefix, "-runtimes-tip")
75
+ }, /*#__PURE__*/React.createElement(InfoCircleOutlined, null))))));
76
+ };
77
+
78
+ export default RunTimesCondition;
@@ -0,0 +1,49 @@
1
+ @import '../../../assets/styles/variable.less';
2
+ .biz-user-condition-event-condition {
3
+ display: flex;
4
+ &-left {
5
+ display: flex;
6
+ }
7
+ &-right {
8
+ flex: 1;
9
+ }
10
+ .biz-user-condition-event {
11
+ width: 355px;
12
+ .biz-event-select-handle {
13
+ border-top-right-radius: 0;
14
+ border-bottom-right-radius: 0;
15
+ }
16
+ }
17
+ &-times-period-wrap {
18
+ display: flex;
19
+ }
20
+ &-expand-attr {
21
+ display: flex;
22
+ align-items: center;
23
+ justify-content: center;
24
+ width: 30px;
25
+ height: 42px;
26
+ margin-right: @margin-xs;
27
+ border: 1px solid @border-color-base;
28
+ border-left: none;
29
+ border-radius: @border-radius-small;
30
+ border-top-left-radius: 0;
31
+ border-bottom-left-radius: 0;
32
+ cursor: pointer;
33
+ }
34
+ &-attrs {
35
+ flex: 1;
36
+ width: 100%;
37
+ // margin-right: @margin-xs;
38
+ margin-bottom: @margin-xs;
39
+ }
40
+ &-label {
41
+ display: flex;
42
+ align-items: center;
43
+ height: 42px;
44
+ margin-right: @margin-xs;
45
+ }
46
+ &-runtimes {
47
+ margin-right: @margin-xs;
48
+ }
49
+ }
@@ -0,0 +1,14 @@
1
+ @import '../../../assets/styles/variable.less';
2
+ .biz-user-condition-period-condition {
3
+ display: flex;
4
+ align-items: center;
5
+ &-label,
6
+ &-operator,
7
+ &-values,
8
+ &-unit {
9
+ margin-right: @margin-xs;
10
+ }
11
+ &-operator {
12
+ width: 129px;
13
+ }
14
+ }