@zgfe/business-lib 1.1.35 → 1.1.36
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.
- package/es/assets/styles/resetAntd.less +36 -12
- package/es/attrConditions/utils/operates.d.ts +50 -0
- package/es/attrConditions/utils/operates.js +126 -0
- package/es/constants/apis.d.ts +5 -0
- package/es/constants/apis.js +6 -1
- package/es/context/index.d.ts +2 -0
- package/es/userCondition/conditionTypeList.js +27 -7
- package/es/userCondition/conditions/business/operatorCondition.d.ts +11 -0
- package/es/userCondition/conditions/business/operatorCondition.js +181 -0
- package/es/userCondition/conditions/business/paramsCondition.d.ts +9 -0
- package/es/userCondition/conditions/business/paramsCondition.js +79 -0
- package/es/userCondition/conditions/businessCondition.d.ts +5 -0
- package/es/userCondition/conditions/businessCondition.js +252 -0
- package/es/userCondition/conditions/cdpCondition.js +1 -1
- package/es/userCondition/conditions/constants.d.ts +1 -0
- package/es/userCondition/conditions/constants.js +2 -1
- package/es/userCondition/conditions/dataAttribute.d.ts +10 -0
- package/es/userCondition/conditions/dataAttribute.js +251 -0
- package/es/userCondition/conditions/eventCondition.js +83 -2
- package/es/userCondition/conditions/order/runPeriodCondition.d.ts +11 -0
- package/es/userCondition/conditions/order/runPeriodCondition.js +142 -0
- package/es/userCondition/conditions/order/runTimesCondition.d.ts +11 -0
- package/es/userCondition/conditions/order/runTimesCondition.js +112 -0
- package/es/userCondition/conditions/textDesc.d.ts +1 -1
- package/es/userCondition/conditions/textDesc.js +160 -2
- package/es/userCondition/conditions/timeDimension.d.ts +10 -0
- package/es/userCondition/conditions/timeDimension.js +150 -0
- package/es/userCondition/demo/business.d.ts +3 -0
- package/es/userCondition/demo/business.js +71 -0
- package/es/userCondition/index.js +14 -2
- package/es/userCondition/orConditions.js +22 -2
- package/es/userCondition/types.d.ts +71 -5
- package/es/userCondition/types.js +8 -1
- package/es/userCondition/util.d.ts +1 -1
- package/es/userCondition/util.js +33 -0
- package/es/utils/ajax.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
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; }
|
|
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
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import '../styles/runTimesCondition.less';
|
|
9
|
+
import { classPrefix } from '../..';
|
|
10
|
+
import moment from 'moment';
|
|
11
|
+
import { DatePicker, Input } from 'antd';
|
|
12
|
+
var RangePicker = DatePicker.RangePicker;
|
|
13
|
+
var ParamsCondition = function ParamsCondition(props) {
|
|
14
|
+
var condition = props.condition,
|
|
15
|
+
index = props.index,
|
|
16
|
+
onChange = props.onChange;
|
|
17
|
+
var onValue0Change = function onValue0Change(e) {
|
|
18
|
+
var value = e.target.value;
|
|
19
|
+
condition.attrs[index].params[0] = value;
|
|
20
|
+
onChange(_objectSpread({}, condition));
|
|
21
|
+
};
|
|
22
|
+
var onValue1Change = function onValue1Change(e) {
|
|
23
|
+
var value = e.target.value;
|
|
24
|
+
condition.attrs[index].params[1] = value;
|
|
25
|
+
onChange(_objectSpread({}, condition));
|
|
26
|
+
};
|
|
27
|
+
function onDateChange(newData) {
|
|
28
|
+
if (condition.attrs[index].operator === 'absolute') {
|
|
29
|
+
var dateRange = newData;
|
|
30
|
+
var newValues = dateRange === null || dateRange === void 0 ? void 0 : dateRange.map(function (date) {
|
|
31
|
+
return date.format('YYYY-MM-DD');
|
|
32
|
+
});
|
|
33
|
+
condition.attrs[index].params = newValues;
|
|
34
|
+
onChange(_objectSpread({}, condition));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
38
|
+
className: "".concat(classPrefix, "-runtimes-condition")
|
|
39
|
+
}, condition.attrs[index].attrType === 'cont-num' || condition.attrs[index].attrType === 'cont-date' && condition.attrs[index].operator !== 'absolute' ? /*#__PURE__*/React.createElement("div", {
|
|
40
|
+
className: "".concat(classPrefix, "-period-condition")
|
|
41
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
42
|
+
key: "relative-date",
|
|
43
|
+
className: "".concat(classPrefix, "-select-condition"),
|
|
44
|
+
size: "middle",
|
|
45
|
+
type: condition.attrs[index].attrType === 'cont-date' ? 'number' : '',
|
|
46
|
+
placeholder: condition.attrs[index].operator === 'between' ? '输入最小值' : '请输入',
|
|
47
|
+
value: condition.attrs[index].params[0],
|
|
48
|
+
style: {
|
|
49
|
+
width: condition.attrs[index].operator === 'between' || condition.attrs[index].attrType === 'cont-date' && condition.attrs[index].operator ? 100 : 200
|
|
50
|
+
},
|
|
51
|
+
suffix: condition.attrs[index].attrType === 'cont-date' ? '天' : null,
|
|
52
|
+
onChange: onValue0Change
|
|
53
|
+
})) : null, condition.attrs[index].attrType === 'cont-num' && condition.attrs[index].operator === 'between' || condition.attrs[index].attrType === 'cont-date' && (condition.attrs[index].operator === 'relativeInterval' || condition.attrs[index].operator === 'futureInterval') ? /*#__PURE__*/React.createElement("div", {
|
|
54
|
+
className: "".concat(classPrefix, "-period-condition"),
|
|
55
|
+
style: {
|
|
56
|
+
marginLeft: 10
|
|
57
|
+
}
|
|
58
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
59
|
+
key: "relative-date",
|
|
60
|
+
className: "".concat(classPrefix, "-select-condition"),
|
|
61
|
+
size: "middle",
|
|
62
|
+
type: condition.attrs[index].attrType === 'cont-date' ? 'number' : '',
|
|
63
|
+
placeholder: '输入最大值',
|
|
64
|
+
value: condition.attrs[index].params[1],
|
|
65
|
+
style: {
|
|
66
|
+
width: 100
|
|
67
|
+
},
|
|
68
|
+
suffix: condition.attrs[index].attrType === 'cont-date' ? '天' : null,
|
|
69
|
+
onChange: onValue1Change
|
|
70
|
+
})) : null, condition.attrs[index].attrType === 'cont-date' && condition.attrs[index].operator === 'absolute' ? /*#__PURE__*/React.createElement("div", {
|
|
71
|
+
className: "".concat(classPrefix, "-runtimes-condition")
|
|
72
|
+
}, /*#__PURE__*/React.createElement(RangePicker, {
|
|
73
|
+
size: "middle",
|
|
74
|
+
defaultValue: [moment(condition.attrs[index].params[0]), moment(condition.attrs[index].params[1])],
|
|
75
|
+
onChange: onDateChange,
|
|
76
|
+
allowClear: false
|
|
77
|
+
})) : null));
|
|
78
|
+
};
|
|
79
|
+
export default ParamsCondition;
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
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; }
|
|
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
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
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."); }
|
|
9
|
+
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); }
|
|
10
|
+
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; }
|
|
11
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
import React, { useContext, useEffect, useState } from 'react';
|
|
14
|
+
import BizSelect from '../../select';
|
|
15
|
+
import { DownOutlined } from '@ant-design/icons';
|
|
16
|
+
import { Dropdown, Space, notification } from 'antd';
|
|
17
|
+
import request from '../../utils/ajax';
|
|
18
|
+
import './styles/periodCondition.less';
|
|
19
|
+
import { classPrefix } from '..';
|
|
20
|
+
import TimeDimension from './timeDimension';
|
|
21
|
+
import DataAttribute from './dataAttribute';
|
|
22
|
+
import IconFont from '../../icon/iconFont';
|
|
23
|
+
import BizGlobalDataContext from '../../context';
|
|
24
|
+
import RunPeriodCondition from './order/runPeriodCondition';
|
|
25
|
+
import Apis from '../../constants/apis';
|
|
26
|
+
var BusinessCondition = function BusinessCondition(props) {
|
|
27
|
+
var _condition$timeDimens, _condition$timeDimens3, _condition$attrs, _condition$timeDimens4, _condition$attrs2;
|
|
28
|
+
var condition = props.condition,
|
|
29
|
+
dataId = props.dataId,
|
|
30
|
+
label = props.label;
|
|
31
|
+
var _useContext = useContext(BizGlobalDataContext),
|
|
32
|
+
currentApp = _useContext.currentApp;
|
|
33
|
+
function onChange(data) {
|
|
34
|
+
props.onChange(dataId, data);
|
|
35
|
+
}
|
|
36
|
+
useEffect(function () {
|
|
37
|
+
if (label === '业务数据') {
|
|
38
|
+
queryServiceAttributeList();
|
|
39
|
+
}
|
|
40
|
+
}, []);
|
|
41
|
+
var items = [];
|
|
42
|
+
if (((_condition$timeDimens = condition.timeDimensions) === null || _condition$timeDimens === void 0 ? void 0 : _condition$timeDimens.length) < 3) {
|
|
43
|
+
items = items.concat([{
|
|
44
|
+
label: '时间维度',
|
|
45
|
+
key: 'time dimension'
|
|
46
|
+
}]);
|
|
47
|
+
}
|
|
48
|
+
if (label === '订单数据' && condition.attrs.length < 6) {
|
|
49
|
+
items = items.concat([{
|
|
50
|
+
label: '订单属性',
|
|
51
|
+
key: 'order attribute'
|
|
52
|
+
}]);
|
|
53
|
+
} else if (label === '业务数据' && condition.attrs.length < 6) {
|
|
54
|
+
items = items.concat([{
|
|
55
|
+
label: '业务属性',
|
|
56
|
+
key: 'service attribute'
|
|
57
|
+
}]);
|
|
58
|
+
}
|
|
59
|
+
var _useState = useState(condition.typeId ? '业务属性' : '订单属性'),
|
|
60
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
61
|
+
dataAttributeLabel = _useState2[0],
|
|
62
|
+
setDataAttributeLabel = _useState2[1];
|
|
63
|
+
var _useState3 = useState(),
|
|
64
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
65
|
+
serviceAttribute = _useState4[0],
|
|
66
|
+
setServiceAttribute = _useState4[1];
|
|
67
|
+
var _useState5 = useState([]),
|
|
68
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
69
|
+
serviceAttributeList = _useState6[0],
|
|
70
|
+
setServiceAttributeList = _useState6[1];
|
|
71
|
+
function queryServiceAttributeList() {
|
|
72
|
+
request(Apis.bizDataTypeList + "/".concat(currentApp === null || currentApp === void 0 ? void 0 : currentApp.appId), {
|
|
73
|
+
method: 'get'
|
|
74
|
+
}).then(function (res) {
|
|
75
|
+
if (res.data) {
|
|
76
|
+
var _res$data;
|
|
77
|
+
var list = (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.map(function (item) {
|
|
78
|
+
return {
|
|
79
|
+
name: item.typeName,
|
|
80
|
+
value: item.id
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
setServiceAttributeList(list);
|
|
84
|
+
} else {
|
|
85
|
+
setServiceAttributeList([]);
|
|
86
|
+
}
|
|
87
|
+
}).catch(function () {
|
|
88
|
+
setServiceAttributeList([]);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
var onClick = function onClick(_ref) {
|
|
92
|
+
var key = _ref.key;
|
|
93
|
+
if (key !== 'time dimension') {
|
|
94
|
+
var _items, _labelProps$;
|
|
95
|
+
var labelProps = (_items = items) === null || _items === void 0 ? void 0 : _items.filter(function (v) {
|
|
96
|
+
return (v === null || v === void 0 ? void 0 : v.key) === key;
|
|
97
|
+
});
|
|
98
|
+
setDataAttributeLabel((_labelProps$ = labelProps[0]) === null || _labelProps$ === void 0 ? void 0 : _labelProps$.label);
|
|
99
|
+
}
|
|
100
|
+
if (key === 'time dimension') {
|
|
101
|
+
var _condition$timeDimens2;
|
|
102
|
+
var obj = {
|
|
103
|
+
frequencyValues: [1],
|
|
104
|
+
frequencyOperator: '>',
|
|
105
|
+
timeDimension: 1,
|
|
106
|
+
timeOperator: 'all',
|
|
107
|
+
timeValues: []
|
|
108
|
+
};
|
|
109
|
+
if (((_condition$timeDimens2 = condition.timeDimensions) === null || _condition$timeDimens2 === void 0 ? void 0 : _condition$timeDimens2.length) !== 3) {
|
|
110
|
+
condition.timeDimensions.push(obj);
|
|
111
|
+
} else {
|
|
112
|
+
notification.info({
|
|
113
|
+
message: '时间维度最多增加3条'
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
} else {
|
|
117
|
+
var _obj = {
|
|
118
|
+
attrId: 0,
|
|
119
|
+
attrName: '',
|
|
120
|
+
operator: '',
|
|
121
|
+
params: [],
|
|
122
|
+
computeType: '',
|
|
123
|
+
attrType: '',
|
|
124
|
+
category: ''
|
|
125
|
+
};
|
|
126
|
+
var params = {
|
|
127
|
+
masterList: [],
|
|
128
|
+
bizDataAttrList: [],
|
|
129
|
+
paramsList: []
|
|
130
|
+
};
|
|
131
|
+
if (condition.attrs.length < 6) {
|
|
132
|
+
condition.attrs.push(_obj);
|
|
133
|
+
condition.paramsList.push(params);
|
|
134
|
+
} else {
|
|
135
|
+
notification.info({
|
|
136
|
+
message: '事件属性最多增加6条'
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
onChange(_objectSpread({}, condition));
|
|
141
|
+
};
|
|
142
|
+
function onTimeDimensionsDelete(index) {
|
|
143
|
+
condition.timeDimensions.splice(index, 1);
|
|
144
|
+
onChange(_objectSpread({}, condition));
|
|
145
|
+
}
|
|
146
|
+
function onAttrsDelete(index) {
|
|
147
|
+
condition.attrs.splice(index, 1);
|
|
148
|
+
onChange(_objectSpread({}, condition));
|
|
149
|
+
}
|
|
150
|
+
function onServiceAttributeChange(operate) {
|
|
151
|
+
condition.typeId = operate === null || operate === void 0 ? void 0 : operate.value;
|
|
152
|
+
condition.typeName = operate === null || operate === void 0 ? void 0 : operate.name;
|
|
153
|
+
onChange(_objectSpread({}, condition));
|
|
154
|
+
setServiceAttribute(operate);
|
|
155
|
+
}
|
|
156
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
157
|
+
className: "".concat(classPrefix, "-period-condition")
|
|
158
|
+
}, label === '业务数据' && !serviceAttribute ? /*#__PURE__*/React.createElement("div", {
|
|
159
|
+
className: "".concat(classPrefix, "-period-condition-operator")
|
|
160
|
+
}, /*#__PURE__*/React.createElement(BizSelect, {
|
|
161
|
+
className: "".concat(classPrefix, "-select-condition"),
|
|
162
|
+
options: serviceAttributeList,
|
|
163
|
+
labelField: "name",
|
|
164
|
+
keyField: "value",
|
|
165
|
+
value: {
|
|
166
|
+
name: condition.typeId,
|
|
167
|
+
value: condition.typeId
|
|
168
|
+
},
|
|
169
|
+
overlayWidth: 120,
|
|
170
|
+
onChange: onServiceAttributeChange
|
|
171
|
+
})) : null, label === '订单数据' ? /*#__PURE__*/React.createElement("div", {
|
|
172
|
+
className: "".concat(classPrefix, "-period-condition-label")
|
|
173
|
+
}, label) : /*#__PURE__*/React.createElement("div", {
|
|
174
|
+
className: "".concat(classPrefix, "-period-condition-label")
|
|
175
|
+
}, serviceAttribute === null || serviceAttribute === void 0 ? void 0 : serviceAttribute.name), /*#__PURE__*/React.createElement("div", {
|
|
176
|
+
className: "".concat(classPrefix, "-period-condition-values")
|
|
177
|
+
}, /*#__PURE__*/React.createElement(RunPeriodCondition, {
|
|
178
|
+
dataId: props.dataId,
|
|
179
|
+
condition: condition,
|
|
180
|
+
onChange: onChange
|
|
181
|
+
}))), (_condition$timeDimens3 = condition.timeDimensions) === null || _condition$timeDimens3 === void 0 ? void 0 : _condition$timeDimens3.map(function (_item, index) {
|
|
182
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
183
|
+
style: {
|
|
184
|
+
margin: '10px 0 0 65px'
|
|
185
|
+
},
|
|
186
|
+
className: "".concat(classPrefix, "-item"),
|
|
187
|
+
key: index
|
|
188
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
189
|
+
style: {
|
|
190
|
+
display: 'flex',
|
|
191
|
+
alignItems: 'center'
|
|
192
|
+
}
|
|
193
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
194
|
+
className: "".concat(classPrefix, "-period-condition-label")
|
|
195
|
+
}, "\u65F6\u95F4\u7EF4\u5EA6"), /*#__PURE__*/React.createElement(TimeDimension, {
|
|
196
|
+
dataId: props.dataId,
|
|
197
|
+
onChange: onChange,
|
|
198
|
+
condition: condition,
|
|
199
|
+
index: index
|
|
200
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
201
|
+
className: "biz-user-condition-item-delete",
|
|
202
|
+
onClick: function onClick() {
|
|
203
|
+
return onTimeDimensionsDelete(index);
|
|
204
|
+
}
|
|
205
|
+
}, /*#__PURE__*/React.createElement(IconFont, {
|
|
206
|
+
type: "qingchu"
|
|
207
|
+
}))));
|
|
208
|
+
}), (_condition$attrs = condition.attrs) === null || _condition$attrs === void 0 ? void 0 : _condition$attrs.map(function (_item, index) {
|
|
209
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
210
|
+
style: {
|
|
211
|
+
margin: '10px 0 0 65px'
|
|
212
|
+
},
|
|
213
|
+
className: "".concat(classPrefix, "-item"),
|
|
214
|
+
key: index
|
|
215
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
216
|
+
style: {
|
|
217
|
+
display: 'flex',
|
|
218
|
+
alignItems: 'center'
|
|
219
|
+
}
|
|
220
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
221
|
+
className: "".concat(classPrefix, "-period-condition-label")
|
|
222
|
+
}, dataAttributeLabel), /*#__PURE__*/React.createElement(DataAttribute, {
|
|
223
|
+
onChange: onChange,
|
|
224
|
+
condition: condition,
|
|
225
|
+
index: index,
|
|
226
|
+
serviceAttrType: serviceAttribute
|
|
227
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
228
|
+
className: "biz-user-condition-item-delete",
|
|
229
|
+
onClick: function onClick() {
|
|
230
|
+
return onAttrsDelete(index);
|
|
231
|
+
}
|
|
232
|
+
}, /*#__PURE__*/React.createElement(IconFont, {
|
|
233
|
+
type: "qingchu"
|
|
234
|
+
}))));
|
|
235
|
+
}), condition.typeId && label === '业务数据' || label === '订单数据' ? /*#__PURE__*/React.createElement("div", null, ((_condition$timeDimens4 = condition.timeDimensions) === null || _condition$timeDimens4 === void 0 ? void 0 : _condition$timeDimens4.length) !== 3 || ((_condition$attrs2 = condition.attrs) === null || _condition$attrs2 === void 0 ? void 0 : _condition$attrs2.length) !== 6 ? /*#__PURE__*/React.createElement("div", {
|
|
236
|
+
style: {
|
|
237
|
+
margin: '2px 0 0 65px',
|
|
238
|
+
color: '#4075fd',
|
|
239
|
+
fontSize: '12px'
|
|
240
|
+
}
|
|
241
|
+
}, /*#__PURE__*/React.createElement(Dropdown, {
|
|
242
|
+
menu: {
|
|
243
|
+
items: items,
|
|
244
|
+
onClick: onClick
|
|
245
|
+
}
|
|
246
|
+
}, /*#__PURE__*/React.createElement("a", {
|
|
247
|
+
onClick: function onClick(e) {
|
|
248
|
+
return e.preventDefault();
|
|
249
|
+
}
|
|
250
|
+
}, /*#__PURE__*/React.createElement(Space, null, "\u9AD8\u7EA7\u7B5B\u9009 ", /*#__PURE__*/React.createElement(DownOutlined, null))))) : null) : null);
|
|
251
|
+
};
|
|
252
|
+
export default BusinessCondition;
|
|
@@ -146,7 +146,7 @@ var CdpConditionItem = function CdpConditionItem(props) {
|
|
|
146
146
|
}
|
|
147
147
|
}).then(function (result) {
|
|
148
148
|
setLoading(false);
|
|
149
|
-
setFieldList(result.data || []);
|
|
149
|
+
setFieldList((result === null || result === void 0 ? void 0 : result.data) || []);
|
|
150
150
|
}).catch(function (e) {
|
|
151
151
|
console.error(e);
|
|
152
152
|
setLoading(false);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './styles/runTimesCondition.less';
|
|
3
|
+
export interface DataAttributePropsI {
|
|
4
|
+
condition: any;
|
|
5
|
+
index: number;
|
|
6
|
+
serviceAttrType: any;
|
|
7
|
+
onChange: (condition: any) => void;
|
|
8
|
+
}
|
|
9
|
+
declare const DataAttribute: React.FC<DataAttributePropsI>;
|
|
10
|
+
export default DataAttribute;
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
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; }
|
|
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
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
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."); }
|
|
9
|
+
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); }
|
|
10
|
+
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; }
|
|
11
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
import React, { useContext, useEffect, useState } from 'react';
|
|
14
|
+
import BizSelect from '../../select';
|
|
15
|
+
import './styles/runTimesCondition.less';
|
|
16
|
+
import { classPrefix } from '..';
|
|
17
|
+
import { stringOperate, orderTypeList, typeList, computeTypeList } from '../../attrConditions/utils/operates';
|
|
18
|
+
import moment from 'moment';
|
|
19
|
+
import request from '../../utils/ajax';
|
|
20
|
+
import BizGlobalDataContext from '../../context';
|
|
21
|
+
import ParamsCondition from './business/paramsCondition';
|
|
22
|
+
import OperatorCondition from './business/operatorCondition';
|
|
23
|
+
import Apis from '../../constants/apis';
|
|
24
|
+
var DataAttribute = function DataAttribute(props) {
|
|
25
|
+
var _condition$paramsList, _condition$paramsList2;
|
|
26
|
+
var condition = props.condition,
|
|
27
|
+
index = props.index,
|
|
28
|
+
onChange = props.onChange;
|
|
29
|
+
var list = [];
|
|
30
|
+
var operateList = [];
|
|
31
|
+
switch (condition.attrs[index].attrType) {
|
|
32
|
+
case 'cont-string':
|
|
33
|
+
list = typeList['cont-string'];
|
|
34
|
+
operateList = stringOperate;
|
|
35
|
+
break;
|
|
36
|
+
case 'cont-num':
|
|
37
|
+
list = computeTypeList;
|
|
38
|
+
operateList = typeList['cont-num'];
|
|
39
|
+
break;
|
|
40
|
+
default:
|
|
41
|
+
list = typeList['cont-date'];
|
|
42
|
+
operateList = typeList['cont-date'];
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
var _useState = useState((condition === null || condition === void 0 ? void 0 : condition.typeId) ? list : []),
|
|
46
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
47
|
+
masterList = _useState2[0],
|
|
48
|
+
setMasterList = _useState2[1];
|
|
49
|
+
var _useState3 = useState(operateList),
|
|
50
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
51
|
+
stringOperateList = _useState4[0],
|
|
52
|
+
setStringOperateList = _useState4[1];
|
|
53
|
+
var _useState5 = useState({}),
|
|
54
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
55
|
+
queryValueObj = _useState6[0],
|
|
56
|
+
setQueryValueObj = _useState6[1];
|
|
57
|
+
var _useState7 = useState([]),
|
|
58
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
59
|
+
bizDataAttrList = _useState8[0],
|
|
60
|
+
setBizDataAttrList = _useState8[1];
|
|
61
|
+
var _useContext = useContext(BizGlobalDataContext),
|
|
62
|
+
currentApp = _useContext.currentApp;
|
|
63
|
+
useEffect(function () {
|
|
64
|
+
if (condition === null || condition === void 0 ? void 0 : condition.typeId) {
|
|
65
|
+
queryBizDataAttrList(condition === null || condition === void 0 ? void 0 : condition.typeId);
|
|
66
|
+
} else {
|
|
67
|
+
setBizDataAttrList(orderTypeList);
|
|
68
|
+
}
|
|
69
|
+
}, [condition === null || condition === void 0 ? void 0 : condition.typeId]);
|
|
70
|
+
function queryAppList(type) {
|
|
71
|
+
request(type === 'master' ? Apis.orderAttributeMaster : Apis.orderAttributeSon, {
|
|
72
|
+
method: 'post',
|
|
73
|
+
data: {
|
|
74
|
+
appId: currentApp === null || currentApp === void 0 ? void 0 : currentApp.appId,
|
|
75
|
+
pageNum: 1,
|
|
76
|
+
pageSize: 9999
|
|
77
|
+
}
|
|
78
|
+
}).then(function (res) {
|
|
79
|
+
if (res.data) {
|
|
80
|
+
var _res$data;
|
|
81
|
+
var _list = (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.map(function (item) {
|
|
82
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
83
|
+
value: item.id
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
setMasterList(_list);
|
|
87
|
+
condition.paramsList[index].masterList = _list;
|
|
88
|
+
} else {
|
|
89
|
+
condition.paramsList[index].masterList = [];
|
|
90
|
+
setMasterList([]);
|
|
91
|
+
}
|
|
92
|
+
}).catch(function () {
|
|
93
|
+
setMasterList([]);
|
|
94
|
+
condition.paramsList[index].masterList = [];
|
|
95
|
+
});
|
|
96
|
+
onChange(_objectSpread({}, condition));
|
|
97
|
+
}
|
|
98
|
+
function queryBizDataAttrList(bizDataTypeId) {
|
|
99
|
+
request(Apis.bizDataAttrList, {
|
|
100
|
+
method: 'post',
|
|
101
|
+
data: {
|
|
102
|
+
bizDataTypeId: bizDataTypeId
|
|
103
|
+
}
|
|
104
|
+
}).then(function (res) {
|
|
105
|
+
if (res.data) {
|
|
106
|
+
var _res$data2;
|
|
107
|
+
var _list2 = (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.map(function (item) {
|
|
108
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
109
|
+
value: item.id
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
condition.paramsList[index].bizDataAttrList = _list2;
|
|
113
|
+
setBizDataAttrList(_list2);
|
|
114
|
+
} else {
|
|
115
|
+
condition.paramsList[index].bizDataAttrList = [];
|
|
116
|
+
setBizDataAttrList([]);
|
|
117
|
+
}
|
|
118
|
+
}).catch(function () {
|
|
119
|
+
condition.paramsList[index].bizDataAttrList = [];
|
|
120
|
+
setBizDataAttrList([]);
|
|
121
|
+
});
|
|
122
|
+
onChange(_objectSpread({}, condition));
|
|
123
|
+
}
|
|
124
|
+
var onOrderTypeListChange = function onOrderTypeListChange(operate) {
|
|
125
|
+
if (condition === null || condition === void 0 ? void 0 : condition.typeId) {
|
|
126
|
+
condition.attrs[index] = _objectSpread(_objectSpread({}, condition.attrs[index]), {}, {
|
|
127
|
+
category: 'custom',
|
|
128
|
+
attrId: operate.id,
|
|
129
|
+
attrName: operate.name
|
|
130
|
+
});
|
|
131
|
+
switch (operate.propType) {
|
|
132
|
+
case 1:
|
|
133
|
+
setMasterList(typeList['cont-string']);
|
|
134
|
+
condition.attrs[index].attrType = 'cont-string';
|
|
135
|
+
setQueryValueObj({
|
|
136
|
+
keyword: '',
|
|
137
|
+
operate: operate
|
|
138
|
+
});
|
|
139
|
+
break;
|
|
140
|
+
case 2:
|
|
141
|
+
setMasterList(computeTypeList);
|
|
142
|
+
setStringOperateList(typeList['cont-num']);
|
|
143
|
+
condition.attrs[index].attrType = 'cont-num';
|
|
144
|
+
break;
|
|
145
|
+
default:
|
|
146
|
+
setMasterList(typeList['cont-date']);
|
|
147
|
+
condition.attrs[index].attrType = 'cont-date';
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
} else {
|
|
151
|
+
setStringOperateList([]);
|
|
152
|
+
condition.attrs[index].orderType = operate.value;
|
|
153
|
+
queryAppList(operate.value);
|
|
154
|
+
}
|
|
155
|
+
onChange(_objectSpread({}, condition));
|
|
156
|
+
};
|
|
157
|
+
var onMasterListChange = function onMasterListChange(operate) {
|
|
158
|
+
condition.attrs[index].params = [];
|
|
159
|
+
if (!(condition === null || condition === void 0 ? void 0 : condition.typeId)) {
|
|
160
|
+
switch (operate.propType) {
|
|
161
|
+
case 1:
|
|
162
|
+
setStringOperateList(typeList['cont-string']);
|
|
163
|
+
condition.attrs[index].attrType = 'cont-string';
|
|
164
|
+
setQueryValueObj({
|
|
165
|
+
keyword: '',
|
|
166
|
+
operate: operate
|
|
167
|
+
});
|
|
168
|
+
break;
|
|
169
|
+
case 2:
|
|
170
|
+
setStringOperateList(typeList['cont-num']);
|
|
171
|
+
condition.attrs[index].attrType = 'cont-num';
|
|
172
|
+
break;
|
|
173
|
+
default:
|
|
174
|
+
setStringOperateList(typeList['cont-date']);
|
|
175
|
+
condition.attrs[index].attrType = 'cont-date';
|
|
176
|
+
if (condition.attrs[index].attrType === 'cont-date') {
|
|
177
|
+
var endDate = moment().format('YYYY-MM-DD');
|
|
178
|
+
var startDate = moment().subtract(7, 'days').format('YYYY-MM-DD');
|
|
179
|
+
condition.attrs[index].params = [startDate, endDate];
|
|
180
|
+
}
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
condition.attrs[index] = _objectSpread(_objectSpread({}, condition.attrs[index]), {}, {
|
|
184
|
+
attrId: operate.id,
|
|
185
|
+
computeType: 'origin',
|
|
186
|
+
attrName: operate.name,
|
|
187
|
+
attrMaping: operate.columnName,
|
|
188
|
+
operator: ''
|
|
189
|
+
});
|
|
190
|
+
} else {
|
|
191
|
+
switch (condition.attrs[index].attrType) {
|
|
192
|
+
case 'cont-string':
|
|
193
|
+
case 'cont-date':
|
|
194
|
+
condition.attrs[index] = _objectSpread(_objectSpread({}, condition.attrs[index]), {}, {
|
|
195
|
+
operator: operate.value,
|
|
196
|
+
computeType: 'origin',
|
|
197
|
+
params: []
|
|
198
|
+
});
|
|
199
|
+
if (condition.attrs[index].operator === 'absolute' && condition.attrs[index].attrType === 'cont-date') {
|
|
200
|
+
var _endDate = moment().format('YYYY-MM-DD');
|
|
201
|
+
var _startDate = moment().subtract(7, 'days').format('YYYY-MM-DD');
|
|
202
|
+
condition.attrs[index].params = [_startDate, _endDate];
|
|
203
|
+
}
|
|
204
|
+
break;
|
|
205
|
+
default:
|
|
206
|
+
condition.attrs[index].computeType = operate.value;
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
onChange(_objectSpread({}, condition));
|
|
211
|
+
};
|
|
212
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
213
|
+
className: "".concat(classPrefix, "-runtimes-condition")
|
|
214
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
215
|
+
className: "".concat(classPrefix, "-period-condition-operator")
|
|
216
|
+
}, /*#__PURE__*/React.createElement(BizSelect, {
|
|
217
|
+
className: "".concat(classPrefix, "-select-condition"),
|
|
218
|
+
options: bizDataAttrList.length > 0 ? bizDataAttrList : condition === null || condition === void 0 ? void 0 : (_condition$paramsList = condition.paramsList[index]) === null || _condition$paramsList === void 0 ? void 0 : _condition$paramsList.bizDataAttrList,
|
|
219
|
+
labelField: "name",
|
|
220
|
+
keyField: "value",
|
|
221
|
+
value: {
|
|
222
|
+
name: condition.typeId ? condition.attrs[index].attrName : condition.attrs[index].orderType,
|
|
223
|
+
value: condition.typeId ? condition.attrs[index].attrId : condition.attrs[index].orderType
|
|
224
|
+
},
|
|
225
|
+
overlayWidth: 120,
|
|
226
|
+
onChange: onOrderTypeListChange
|
|
227
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
228
|
+
className: "".concat(classPrefix, "-period-condition-operator")
|
|
229
|
+
}, /*#__PURE__*/React.createElement(BizSelect, {
|
|
230
|
+
className: "".concat(classPrefix, "-select-condition"),
|
|
231
|
+
options: masterList.length > 0 ? masterList : condition === null || condition === void 0 ? void 0 : (_condition$paramsList2 = condition.paramsList[index]) === null || _condition$paramsList2 === void 0 ? void 0 : _condition$paramsList2.masterList,
|
|
232
|
+
value: {
|
|
233
|
+
name: condition.typeId ? condition.attrs[index].attrType === 'cont-string' || condition.attrs[index].attrType === 'cont-date' ? condition.attrs[index].operator : condition.attrs[index].computeType : condition.attrs[index].attrName,
|
|
234
|
+
value: condition.typeId ? condition.attrs[index].attrType === 'cont-string' || condition.attrs[index].attrType === 'cont-date' ? condition.attrs[index].operator : condition.attrs[index].computeType : condition.attrs[index].attrId
|
|
235
|
+
},
|
|
236
|
+
labelField: "name",
|
|
237
|
+
keyField: "value",
|
|
238
|
+
onChange: onMasterListChange
|
|
239
|
+
})), /*#__PURE__*/React.createElement(OperatorCondition, {
|
|
240
|
+
queryValueObj: queryValueObj,
|
|
241
|
+
stringOperateList: stringOperateList,
|
|
242
|
+
index: index,
|
|
243
|
+
condition: condition,
|
|
244
|
+
onChange: onChange
|
|
245
|
+
}), /*#__PURE__*/React.createElement(ParamsCondition, {
|
|
246
|
+
index: index,
|
|
247
|
+
condition: condition,
|
|
248
|
+
onChange: onChange
|
|
249
|
+
}));
|
|
250
|
+
};
|
|
251
|
+
export default DataAttribute;
|