@zgfe/business-lib 1.0.30-alpha.0 → 1.0.30-user.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.
@@ -5,5 +5,7 @@ declare const Apis: {
5
5
  addPanel: string;
6
6
  updatePanelTarget: string;
7
7
  queryPanelGroup: string;
8
+ queryDatasetList: string;
9
+ queryDatasetDetail: string;
8
10
  };
9
11
  export default Apis;
@@ -4,6 +4,8 @@ var Apis = {
4
4
  esQuery: '/data/queryEsData.jsp',
5
5
  addPanel: '/apppanel/addPanelElement.jsp',
6
6
  updatePanelTarget: '/apppanel/updateElemet.jsp',
7
- queryPanelGroup: '/apppanel/panels.jsp'
7
+ queryPanelGroup: '/apppanel/panels.jsp',
8
+ queryDatasetList: '/zg/web/cdp/inner/dataset/list',
9
+ queryDatasetDetail: '/zg/web/cdp/inner/dataset/detail'
8
10
  };
9
11
  export default Apis;
@@ -7,8 +7,7 @@
7
7
  margin: 0 auto;
8
8
  &-menu {
9
9
  flex: none;
10
- padding-top: @padding-md;
11
- padding-bottom: @padding-md - 2;
10
+ padding: @padding-sm 0;
12
11
  color: @text-color-secondary;
13
12
  a {
14
13
  margin-right: @margin-md;
@@ -20,7 +19,7 @@
20
19
  }
21
20
  &-content {
22
21
  flex: 1;
23
- padding: @padding-sm @padding-lg @padding-lg @padding-lg;
22
+ padding: @padding-md @padding-lg @padding-lg @padding-lg;
24
23
  overflow-y: auto;
25
24
  background-color: @white;
26
25
  border-radius: @border-radius-normal;
@@ -12,7 +12,8 @@ var ConditionTypeList = function ConditionTypeList(props) {
12
12
 
13
13
  var _useContext = useContext(BizUserConditionContext),
14
14
  textMode = _useContext.textMode,
15
- openTagCondition = _useContext.openTagCondition;
15
+ openTagCondition = _useContext.openTagCondition,
16
+ openCdpCondition = _useContext.openCdpCondition;
16
17
 
17
18
  var _useContext2 = useContext(BizGlobalDataContext),
18
19
  menuNameMap = _useContext2.menuNameMap;
@@ -61,7 +62,12 @@ var ConditionTypeList = function ConditionTypeList(props) {
61
62
  onClick: function onClick() {
62
63
  return onAdd('tag');
63
64
  }
64
- }, /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(PlusOutlined, null), /*#__PURE__*/React.createElement("span", null, "\u7528\u6237\u6807\u7B7E"))) : null));
65
+ }, /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(PlusOutlined, null), /*#__PURE__*/React.createElement("span", null, "\u7528\u6237\u6807\u7B7E"))) : null, openCdpCondition && (!menuNameMap || menuNameMap['cdp']) ? /*#__PURE__*/React.createElement("li", {
66
+ className: "condition-type",
67
+ onClick: function onClick() {
68
+ return onAdd('cdp');
69
+ }
70
+ }, /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(PlusOutlined, null), /*#__PURE__*/React.createElement("span", null, "\u660E\u7EC6\u6570\u636E"))) : null));
65
71
  };
66
72
 
67
73
  ConditionTypeList.defaultProps = {
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { AllConditionBasePropsI, BizUserConditionT } from '../types';
3
+ import './styles/cdpCondition.less';
4
+ interface CdpConditionProps extends AllConditionBasePropsI<BizUserConditionT.CdpConditionDetail[]> {
5
+ defaultValue?: BizUserConditionT.CdpCondition;
6
+ }
7
+ declare const CdpCondition: React.FC<CdpConditionProps>;
8
+ export default CdpCondition;
@@ -0,0 +1,326 @@
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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
+
9
+ 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."); }
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 _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; }
14
+
15
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
16
+
17
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
+
19
+ import React, { useContext, useEffect, useState } from 'react';
20
+ import BizSelect from '../../select';
21
+ import { PropType } from '../types';
22
+ import './styles/cdpCondition.less';
23
+ import _ from 'lodash';
24
+ import { dateOperate, numberOperate, stringOperate } from '../../attrConditions/utils/operates';
25
+ import { DatePicker, Input } from 'antd';
26
+ import moment from 'moment';
27
+ import { BizUserConditionContext } from '..';
28
+ import request from '../../utils/ajax';
29
+ import Apis from '../../constants/apis';
30
+ import BizGlobalDataContext from '../../context';
31
+ var classPrefix = 'biz-user-condition-cdp';
32
+
33
+ var CdpConditionItem = function CdpConditionItem(props) {
34
+ var _useContext = useContext(BizGlobalDataContext),
35
+ currentApp = _useContext.currentApp;
36
+
37
+ var _useContext2 = useContext(BizUserConditionContext),
38
+ _useContext2$datasetL = _useContext2.datasetList,
39
+ datasetList = _useContext2$datasetL === void 0 ? [] : _useContext2$datasetL;
40
+
41
+ var _useState = useState(function () {
42
+ if (props.value) {
43
+ return {
44
+ id: props.value.datasetId,
45
+ tableName: props.value.datasetTable
46
+ };
47
+ }
48
+
49
+ return;
50
+ }),
51
+ _useState2 = _slicedToArray(_useState, 2),
52
+ dataset = _useState2[0],
53
+ setDataset = _useState2[1];
54
+
55
+ var _useState3 = useState(),
56
+ _useState4 = _slicedToArray(_useState3, 2),
57
+ field = _useState4[0],
58
+ setField = _useState4[1];
59
+
60
+ var _useState5 = useState(),
61
+ _useState6 = _slicedToArray(_useState5, 2),
62
+ operator = _useState6[0],
63
+ setOperator = _useState6[1];
64
+
65
+ var _useState7 = useState(),
66
+ _useState8 = _slicedToArray(_useState7, 2),
67
+ fieldValue = _useState8[0],
68
+ setFieldValue = _useState8[1];
69
+
70
+ var _useState9 = useState([]),
71
+ _useState10 = _slicedToArray(_useState9, 2),
72
+ fieldList = _useState10[0],
73
+ setFieldList = _useState10[1];
74
+
75
+ var _useState11 = useState(true),
76
+ _useState12 = _slicedToArray(_useState11, 2),
77
+ isFirst = _useState12[0],
78
+ setIsFirst = _useState12[1];
79
+
80
+ useEffect(function () {
81
+ if (!props.value) {
82
+ setIsFirst(false);
83
+ return;
84
+ }
85
+
86
+ var _props$value = props.value,
87
+ datasetId = _props$value.datasetId,
88
+ datasetTable = _props$value.datasetTable,
89
+ fieldName = _props$value.fieldName,
90
+ fieldType = _props$value.fieldType,
91
+ webType = _props$value.webType,
92
+ operator = _props$value.operator,
93
+ params = _props$value.params;
94
+ setDataset({
95
+ id: datasetId,
96
+ tableName: datasetTable
97
+ });
98
+ setField({
99
+ name: fieldName,
100
+ type: fieldType,
101
+ webType: webType
102
+ });
103
+ setOperator({
104
+ value: operator
105
+ });
106
+
107
+ if (params) {
108
+ setFieldValue(params);
109
+ }
110
+
111
+ onDatasetChange(datasetId);
112
+ setTimeout(function () {
113
+ setIsFirst(false);
114
+ }, 0);
115
+ }, []);
116
+ useEffect(function () {
117
+ if (isFirst) return;
118
+ if (!dataset) return;
119
+ props.onChange({
120
+ datasetId: dataset.id,
121
+ datasetTable: dataset.tableName,
122
+ fieldName: field === null || field === void 0 ? void 0 : field.name,
123
+ fieldType: field === null || field === void 0 ? void 0 : field.type,
124
+ webType: field === null || field === void 0 ? void 0 : field.webType,
125
+ paramType: field === null || field === void 0 ? void 0 : field.webType,
126
+ operator: operator === null || operator === void 0 ? void 0 : operator.value,
127
+ params: fieldValue
128
+ });
129
+ }, [dataset, field, operator, fieldValue]);
130
+ useEffect(function () {
131
+ if (isFirst) return;
132
+ if (['absolute', 'relative', 'is null', 'is not null'].includes(operator === null || operator === void 0 ? void 0 : operator.value)) setFieldValue([]);
133
+ }, [operator]);
134
+
135
+ var onDatasetChange = function onDatasetChange(datasetId) {
136
+ if (!datasetId) {
137
+ setFieldList([]);
138
+ return;
139
+ }
140
+
141
+ request(Apis.queryDatasetDetail, {
142
+ method: 'post',
143
+ data: {
144
+ appId: currentApp === null || currentApp === void 0 ? void 0 : currentApp.appId,
145
+ platform: currentApp === null || currentApp === void 0 ? void 0 : currentApp.platform,
146
+ datasetId: datasetId
147
+ }
148
+ }).then(function (result) {
149
+ setFieldList(result.data || []);
150
+ }).catch(function (e) {
151
+ console.error(e);
152
+ setFieldList([]);
153
+ });
154
+ };
155
+
156
+ var onTableChange = function onTableChange(data) {
157
+ setDataset(data);
158
+ setField({
159
+ name: undefined
160
+ });
161
+ setOperator(undefined);
162
+ setFieldValue([]);
163
+ onDatasetChange(data.id);
164
+ };
165
+
166
+ var onFieldChange = function onFieldChange(data) {
167
+ setField(data);
168
+ setOperator(getOptions(data.webType)[0]);
169
+ setFieldValue([]);
170
+ };
171
+
172
+ var onOperateChange = function onOperateChange(operate) {
173
+ setOperator(operate);
174
+ };
175
+
176
+ function getOptions(type) {
177
+ var list = [];
178
+
179
+ switch (type) {
180
+ case PropType.DATE:
181
+ list = dateOperate;
182
+ break;
183
+
184
+ case PropType.NUMBER:
185
+ list = numberOperate;
186
+ break;
187
+
188
+ case PropType.STRING:
189
+ list = stringOperate;
190
+ break;
191
+
192
+ default:
193
+ list = [];
194
+ }
195
+
196
+ return list;
197
+ }
198
+
199
+ function renderByType() {
200
+ if (!field || !field.name) return null;
201
+ var optionList = getOptions(field.webType);
202
+ return /*#__PURE__*/React.createElement("div", {
203
+ className: "".concat(classPrefix, "-condition-group")
204
+ }, /*#__PURE__*/React.createElement(BizSelect, {
205
+ className: "".concat(classPrefix, "-select-condition"),
206
+ options: optionList,
207
+ labelField: "name",
208
+ keyField: "value",
209
+ overlayWidth: 96,
210
+ value: operator,
211
+ onChange: onOperateChange
212
+ }), function () {
213
+ switch (field.webType) {
214
+ case PropType.DATE:
215
+ if ((operator === null || operator === void 0 ? void 0 : operator.value) === 'absolute') return /*#__PURE__*/React.createElement(DatePicker.RangePicker, {
216
+ className: "".concat(classPrefix, "-value date"),
217
+ format: 'YYYY-MM-DD',
218
+ defaultValue: function () {
219
+ if (_.isArray(fieldValue)) return fieldValue.map(function (d) {
220
+ return moment(d);
221
+ });
222
+ return undefined;
223
+ }(),
224
+ onChange: function onChange() {
225
+ setFieldValue(arguments.length <= 1 ? undefined : arguments[1]);
226
+ }
227
+ });
228
+ if ((operator === null || operator === void 0 ? void 0 : operator.value) === 'relative') return /*#__PURE__*/React.createElement(Input, {
229
+ key: "relative-date",
230
+ className: "".concat(classPrefix, "-value date"),
231
+ type: "number",
232
+ defaultValue: fieldValue && fieldValue[0],
233
+ onChange: function onChange(e) {
234
+ e.persist();
235
+ setFieldValue([e.target.value]);
236
+ },
237
+ suffix: "\u5929"
238
+ });
239
+
240
+ case PropType.STRING:
241
+ if (['is null', 'is not null'].includes(operator === null || operator === void 0 ? void 0 : operator.value)) return null;
242
+ return /*#__PURE__*/React.createElement(Input, {
243
+ className: "".concat(classPrefix, "-value"),
244
+ value: fieldValue && fieldValue[0],
245
+ onChange: function onChange(e) {
246
+ e.persist();
247
+ setFieldValue([e.target.value]);
248
+ }
249
+ });
250
+
251
+ case PropType.NUMBER:
252
+ return /*#__PURE__*/React.createElement(Input, {
253
+ type: "number",
254
+ className: "".concat(classPrefix, "-value"),
255
+ value: fieldValue && fieldValue[0],
256
+ onChange: function onChange(e) {
257
+ e.persist();
258
+ setFieldValue([e.target.value]);
259
+ }
260
+ });
261
+ }
262
+ }());
263
+ }
264
+
265
+ return /*#__PURE__*/React.createElement("div", {
266
+ className: "".concat(classPrefix, "-content")
267
+ }, /*#__PURE__*/React.createElement(BizSelect, {
268
+ className: "".concat(classPrefix, "-select-dataset"),
269
+ options: datasetList,
270
+ placeholder: "\u9009\u62E9\u660E\u7EC6\u8868",
271
+ labelField: "datasetName",
272
+ keyField: "tableName",
273
+ value: dataset,
274
+ onChange: onTableChange
275
+ }), dataset ? /*#__PURE__*/React.createElement("div", {
276
+ className: "".concat(classPrefix, "-item")
277
+ }, /*#__PURE__*/React.createElement(BizSelect, {
278
+ className: "".concat(classPrefix, "-select-field"),
279
+ options: fieldList,
280
+ placeholder: "\u9009\u62E9\u5B57\u6BB5",
281
+ labelField: "name",
282
+ keyField: "name",
283
+ value: field,
284
+ onChange: onFieldChange
285
+ }), renderByType()) : null);
286
+ };
287
+
288
+ var CdpCondition = function CdpCondition(props) {
289
+ var dataId = props.dataId,
290
+ defaultValue = props.defaultValue,
291
+ onChange = props.onChange;
292
+
293
+ var _useState13 = useState([undefined]),
294
+ _useState14 = _slicedToArray(_useState13, 2),
295
+ cdpConditions = _useState14[0],
296
+ setCdpConditions = _useState14[1];
297
+
298
+ useEffect(function () {
299
+ if (defaultValue && defaultValue.dataset) {
300
+ setCdpConditions(defaultValue.dataset.length ? defaultValue.dataset : [undefined]);
301
+ }
302
+ }, []);
303
+
304
+ var onChangeCondition = function onChangeCondition(condition, index) {
305
+ var resData = _.cloneDeep(cdpConditions);
306
+
307
+ resData[index] = _objectSpread({}, condition);
308
+ onChange(dataId, resData);
309
+ };
310
+
311
+ return /*#__PURE__*/React.createElement("div", {
312
+ className: classPrefix
313
+ }, /*#__PURE__*/React.createElement("div", {
314
+ className: "".concat(classPrefix, "-label")
315
+ }, "\u660E\u7EC6\u6570\u636E"), cdpConditions.map(function (item, index) {
316
+ return /*#__PURE__*/React.createElement(CdpConditionItem, {
317
+ value: item,
318
+ key: (item === null || item === void 0 ? void 0 : item.fieldName) || index,
319
+ onChange: function onChange(data) {
320
+ return onChangeCondition(data, index);
321
+ }
322
+ });
323
+ }));
324
+ };
325
+
326
+ export default CdpCondition;
@@ -18,6 +18,10 @@ export declare const operatorMap: {
18
18
  '>': string;
19
19
  '>=': string;
20
20
  '<=': string;
21
+ lt: string;
22
+ gt: string;
23
+ ge: string;
24
+ le: string;
21
25
  };
22
26
  export declare const durationHandler: {
23
27
  [key: string]: any;
@@ -17,7 +17,11 @@ export var operatorMap = {
17
17
  '<': '<',
18
18
  '>': '>',
19
19
  '>=': '≥',
20
- '<=': '≤'
20
+ '<=': '≤',
21
+ lt: '<',
22
+ gt: '>',
23
+ ge: '≥',
24
+ le: '≤'
21
25
  };
22
26
  export var durationHandler = {
23
27
  1: {
@@ -0,0 +1,31 @@
1
+ @import '../../../assets/styles/variable.less';
2
+
3
+ .biz-user-condition-cdp {
4
+ display: flex;
5
+
6
+ &-content,
7
+ &-condition-group {
8
+ display: flex;
9
+ }
10
+
11
+ &-label {
12
+ margin-right: @margin-xs;
13
+ line-height: 32px;
14
+ }
15
+
16
+ &-item {
17
+ display: flex;
18
+ margin-left: @margin-xs;
19
+ }
20
+
21
+ &-select-dataset {
22
+ width: 255px;
23
+ }
24
+ &-select-field {
25
+ width: 129px;
26
+ }
27
+ &-select-condition {
28
+ width: 96px;
29
+ margin: 0 @margin-xs;
30
+ }
31
+ }
@@ -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;
5
+ condition: BizUserConditionT.ActiveCondition | BizUserConditionT.AddCondition | BizUserConditionT.PropCondition | BizUserConditionT.EventCondition | BizUserConditionT.TagsCondition | BizUserConditionT.CdpCondition;
6
6
  showOrDesc: boolean;
7
7
  }
8
8
  declare const Text: React.FC<TextProps>;
@@ -40,30 +40,34 @@ var Text = function Text(props) {
40
40
  userTagsData = _useContext3.userTagsData;
41
41
 
42
42
  function render() {
43
- var data = condition;
43
+ if (condition.labels) {
44
+ return renderTags(condition);
45
+ }
44
46
 
45
- if (data.labels) {
46
- return renderTags(data);
47
+ if (condition.dataset) {
48
+ return renderCdp(condition);
47
49
  }
48
50
 
49
- if (String(condition.eventId) === '-4') {
51
+ var data = condition;
52
+
53
+ if (String(data.eventId) === '-4') {
50
54
  return renderPeriod({
51
55
  before: '活跃于'
52
- }, condition.runPeriod);
56
+ }, data.runPeriod);
53
57
  }
54
58
 
55
- if (String(condition.eventId) === '-3') {
59
+ if (String(data.eventId) === '-3') {
56
60
  return renderPeriod({
57
61
  before: '新增于'
58
- }, condition.runPeriod);
62
+ }, data.runPeriod);
59
63
  }
60
64
 
61
- if (condition.eventId === undefined) {
62
- return renderProps(condition.attrs[0], 'user');
65
+ if (data.eventId === undefined) {
66
+ return renderProps(data.attrs[0], 'user');
63
67
  }
64
68
 
65
- if (condition.eventId) {
66
- return renderEvent(condition);
69
+ if (data.eventId) {
70
+ return renderEvent(data);
67
71
  }
68
72
  }
69
73
 
@@ -206,6 +210,51 @@ var Text = function Text(props) {
206
210
  }), /*#__PURE__*/React.createElement("span", null, ")")));
207
211
  }
208
212
 
213
+ function renderCdp(condition) {
214
+ var dataset = condition.dataset;
215
+ return /*#__PURE__*/React.createElement("span", {
216
+ style: {
217
+ backgroundColor: '#effcff',
218
+ padding: '6px 7px'
219
+ }
220
+ }, /*#__PURE__*/React.createElement("span", {
221
+ className: "".concat(classPrefix, "-text-desc-value")
222
+ }, /*#__PURE__*/React.createElement("span", null, "("), dataset.map(function (value) {
223
+ if (!value) return null;
224
+ var operator = value.operator,
225
+ _value$params = value.params,
226
+ params = _value$params === void 0 ? [] : _value$params;
227
+ var valuesDom = '';
228
+
229
+ var numOperatorMap = _objectSpread(_objectSpread({}, operatorMap), {}, {
230
+ 'not equal': '≠'
231
+ });
232
+
233
+ if (value.webType === 'date') {
234
+ if (operator === 'relative') {
235
+ valuesDom = "\u4E3A\u6700\u8FD1".concat(params[0], "\u5929");
236
+ }
237
+
238
+ if (operator === 'absolute') {
239
+ valuesDom = "\u4E3A".concat(params[0], "\u5230").concat(params[1]);
240
+ }
241
+ } else {
242
+ if (operator) {
243
+ var operateTxt = numOperatorMap[operator];
244
+ valuesDom = operateTxt;
245
+
246
+ if (params && params[0]) {
247
+ valuesDom += params[0];
248
+ }
249
+ }
250
+ }
251
+
252
+ return /*#__PURE__*/React.createElement("span", {
253
+ key: Math.random()
254
+ }, "".concat(value.datasetTable, "\u4E2D").concat(value.fieldName).concat(valuesDom));
255
+ }), /*#__PURE__*/React.createElement("span", null, ")")));
256
+ }
257
+
209
258
  function renderPropValues(attr) {
210
259
  if (attr.attrType === 'cont-date') {
211
260
  return renderDateValues(attr.operator, attr.params);
@@ -1,2 +1,3 @@
1
+ import '@zgfe/business-lib/es/assets/iconfont/iconfont.css';
1
2
  declare const _default: () => JSX.Element;
2
3
  export default _default;
@@ -16,6 +16,7 @@ import envData from '../../mock/env';
16
16
  import userData from '../../mock/user';
17
17
  import { BizUserCondition, BizGlobalDataContext, convertAttributeData } from '@zgfe/business-lib';
18
18
  import { conditions, tagList } from './mockData';
19
+ import '@zgfe/business-lib/es/assets/iconfont/iconfont.css';
19
20
  var getTagList = Promise.resolve(tagList);
20
21
  export default (function () {
21
22
  var _useState = useState({
@@ -49,7 +50,7 @@ export default (function () {
49
50
  }, [conditions]);
50
51
 
51
52
  function onChange(value) {
52
- console.log(JSON.stringify(value));
53
+ console.log('change:', JSON.stringify(value));
53
54
  }
54
55
 
55
56
  var descDom = /*#__PURE__*/React.createElement(BizUserCondition, {
@@ -57,6 +58,7 @@ export default (function () {
57
58
  onChange: onChange,
58
59
  eventAttrNum: 3,
59
60
  openTagCondition: true,
61
+ openCdpCondition: true,
60
62
  userTagsData: userTagsData,
61
63
  isRealTime: true
62
64
  });
@@ -66,7 +68,7 @@ export default (function () {
66
68
  userPropList: newStore.userPropList,
67
69
  eventEnvList: newStore.envPropList,
68
70
  currentApp: {
69
- appId: 160,
71
+ appId: 181,
70
72
  platform: 0
71
73
  }
72
74
  }
@@ -73,7 +73,7 @@ export declare const tagList: ({
73
73
  }[];
74
74
  startProcessTime: string;
75
75
  })[];
76
- export declare const conditions: {
76
+ export declare const conditions: ({
77
77
  attrs: {
78
78
  attrId: number;
79
79
  attrName: string;
@@ -82,4 +82,27 @@ export declare const conditions: {
82
82
  params: string[];
83
83
  attrType: string;
84
84
  }[];
85
- }[][];
85
+ dataset?: undefined;
86
+ } | {
87
+ dataset: {
88
+ datasetId: number;
89
+ datasetTable: string;
90
+ fieldName: string;
91
+ fieldType: string;
92
+ webType: string;
93
+ paramType: string;
94
+ operator: string;
95
+ params: string[];
96
+ }[];
97
+ attrs?: undefined;
98
+ })[][];
99
+ export declare const datasetList: {
100
+ id: number;
101
+ datasetName: string;
102
+ tableName: string;
103
+ }[];
104
+ export declare const datasetNames: {
105
+ name: string;
106
+ type: string;
107
+ webType: string;
108
+ }[];
@@ -543,4 +543,71 @@ export var conditions = [[{
543
543
  params: ['2022-09-07', '2022-09-08'],
544
544
  attrType: 'cont-date'
545
545
  }]
546
- }]];
546
+ }, {
547
+ dataset: [{
548
+ datasetId: 12,
549
+ datasetTable: 'table_2',
550
+ fieldName: 'b_id',
551
+ fieldType: 'bigint',
552
+ webType: 'string',
553
+ paramType: 'string',
554
+ operator: 'equal',
555
+ params: ['88']
556
+ }]
557
+ }], [{
558
+ dataset: [{
559
+ datasetId: 13,
560
+ datasetTable: 'table_3',
561
+ fieldName: 'a_id',
562
+ fieldType: 'bigint',
563
+ webType: 'number',
564
+ paramType: 'number',
565
+ operator: 'lt',
566
+ params: ['222']
567
+ }]
568
+ }, {
569
+ dataset: [{
570
+ datasetId: 16,
571
+ datasetTable: 'table_4',
572
+ fieldName: 'b_id',
573
+ fieldType: 'bigint',
574
+ webType: 'string',
575
+ paramType: 'string',
576
+ operator: 'is not null',
577
+ params: []
578
+ }]
579
+ }]];
580
+ export var datasetList = [{
581
+ id: 12,
582
+ datasetName: '数据集2',
583
+ tableName: 'table_2'
584
+ }, {
585
+ id: 13,
586
+ datasetName: '数据集3',
587
+ tableName: 'table_3'
588
+ }, {
589
+ id: 16,
590
+ datasetName: '数据集4',
591
+ tableName: 'table_4'
592
+ }, {
593
+ id: 18,
594
+ datasetName: '数据集5',
595
+ tableName: 'table_5'
596
+ }];
597
+ export var datasetNames = [{
598
+ name: 'a_id',
599
+ type: 'bigint',
600
+ webType: 'number'
601
+ }, {
602
+ name: 'b_id',
603
+ type: 'bigint',
604
+ webType: 'string'
605
+ }, {
606
+ name: 'e_id',
607
+ type: 'bigint',
608
+ webType: 'date'
609
+ }, {
610
+ name: 'f_id',
611
+ type: 'bigint',
612
+ webType: 'number'
613
+ }];
@@ -26,25 +26,33 @@ import './styles/index.less';
26
26
  import { buildCondition } from './util';
27
27
  import _ from 'lodash';
28
28
  import BizGlobalDataContext from '../context';
29
+ import IconFont from '../icon/iconFont';
30
+ import request from '../utils/ajax';
31
+ import Apis from '../constants/apis';
29
32
  export var BizUserConditionContext = /*#__PURE__*/createContext({
30
33
  orConditionNum: 2,
31
34
  eventAttrNum: 1,
32
35
  textMode: false,
33
36
  openTagCondition: false,
37
+ openCdpCondition: false,
34
38
  userTagsData: [],
35
39
  envNameList: [],
36
- userPropsMap: {}
40
+ userPropsMap: {},
41
+ datasetList: []
37
42
  });
38
43
  export var classPrefix = 'biz-user-condition';
39
44
 
40
45
  var BizUserCondition = function BizUserCondition(props) {
41
46
  var _useContext = useContext(BizGlobalDataContext),
42
47
  eventEnvList = _useContext.eventEnvList,
43
- userPropList = _useContext.userPropList;
48
+ userPropList = _useContext.userPropList,
49
+ menuNameMap = _useContext.menuNameMap,
50
+ currentApp = _useContext.currentApp;
44
51
 
45
52
  var andConditionNum = props.andConditionNum,
46
53
  defaultValue = props.defaultValue,
47
54
  openTagCondition = props.openTagCondition,
55
+ openCdpCondition = props.openCdpCondition,
48
56
  userTagsData = props.userTagsData;
49
57
 
50
58
  var _useState = useState([]),
@@ -68,6 +76,11 @@ var BizUserCondition = function BizUserCondition(props) {
68
76
  value = _useState6[0],
69
77
  setValue = _useState6[1];
70
78
 
79
+ var _useState7 = useState([]),
80
+ _useState8 = _slicedToArray(_useState7, 2),
81
+ dataset = _useState8[0],
82
+ setDataset = _useState8[1];
83
+
71
84
  var envNameList = useMemo(function () {
72
85
  return eventEnvList ? eventEnvList.map(function (env) {
73
86
  return env.name;
@@ -82,6 +95,10 @@ var BizUserCondition = function BizUserCondition(props) {
82
95
  }, [userPropList]);
83
96
  useEffect(function () {
84
97
  initShowList();
98
+
99
+ if (props.openCdpCondition && (!menuNameMap || menuNameMap['cdp'])) {
100
+ getDatasetList();
101
+ }
85
102
  }, []);
86
103
 
87
104
  function initShowList() {
@@ -140,16 +157,33 @@ var BizUserCondition = function BizUserCondition(props) {
140
157
  props.onChange && props.onChange(newValue);
141
158
  }
142
159
 
160
+ function getDatasetList() {
161
+ request(Apis.queryDatasetList, {
162
+ method: 'post',
163
+ data: {
164
+ appId: currentApp === null || currentApp === void 0 ? void 0 : currentApp.appId,
165
+ platform: currentApp === null || currentApp === void 0 ? void 0 : currentApp.platform
166
+ }
167
+ }).then(function (result) {
168
+ setDataset(result.data || []);
169
+ }).catch(function (e) {
170
+ console.error(e);
171
+ setDataset([]);
172
+ });
173
+ }
174
+
143
175
  return /*#__PURE__*/React.createElement(BizUserConditionContext.Provider, {
144
176
  value: {
145
177
  orConditionNum: props.orConditionNum || 2,
146
178
  eventAttrNum: props.eventAttrNum || 1,
147
179
  textMode: props.textMode,
148
180
  openTagCondition: openTagCondition,
181
+ openCdpCondition: openCdpCondition,
149
182
  userTagsData: userTagsData !== null && userTagsData !== void 0 ? userTagsData : [],
150
183
  isRealTime: props.isRealTime,
151
184
  envNameList: envNameList,
152
- userPropsMap: userPropsMap
185
+ userPropsMap: userPropsMap,
186
+ datasetList: dataset
153
187
  }
154
188
  }, /*#__PURE__*/React.createElement("div", {
155
189
  className: classPrefix
@@ -172,7 +206,11 @@ var BizUserCondition = function BizUserCondition(props) {
172
206
  show: value.length < andConditionNum,
173
207
  label: "\u4E14",
174
208
  onAdd: onAdd
175
- })));
209
+ }), openCdpCondition && (!menuNameMap || menuNameMap['cdp']) ? /*#__PURE__*/React.createElement("div", {
210
+ className: "".concat(classPrefix, "-tip")
211
+ }, ' ', /*#__PURE__*/React.createElement(IconFont, {
212
+ type: "tishiicon"
213
+ }), "\u660E\u7EC6\u8868\u4E2D\u9700\u5B58\u5728\u300Cuser_id\u300D\u6761\u4EF6\u65B9\u53EF\u751F\u6548\u3002") : null));
176
214
  };
177
215
 
178
216
  BizUserCondition.defaultProps = {
@@ -32,12 +32,14 @@ import EventCondition from './conditions/eventCondition';
32
32
  import TagsCondition from './conditions/tagsCondition';
33
33
  import { classPrefix } from '.';
34
34
  import Text from './conditions/textDesc';
35
+ import CdpCondition from './conditions/cdpCondition';
35
36
 
36
37
  var OrConditions = function OrConditions(props) {
37
38
  var _useContext = useContext(BizUserConditionContext),
38
39
  orConditionNum = _useContext.orConditionNum,
39
40
  textMode = _useContext.textMode,
40
- openTagCondition = _useContext.openTagCondition;
41
+ openTagCondition = _useContext.openTagCondition,
42
+ openCdpCondition = _useContext.openCdpCondition;
41
43
 
42
44
  var orConditions = props.orConditions,
43
45
  showAndDesc = props.showAndDesc;
@@ -121,6 +123,10 @@ var OrConditions = function OrConditions(props) {
121
123
  changeData('tag', id, newTags);
122
124
  }
123
125
 
126
+ function onChangeCdp(id, newCdp) {
127
+ changeData('cdp', id, newCdp);
128
+ }
129
+
124
130
  function changeData(type, id, newData) {
125
131
  var newValue = [];
126
132
  showList.forEach(function (data) {
@@ -133,6 +139,8 @@ var OrConditions = function OrConditions(props) {
133
139
  data.condition = newData;
134
140
  } else if (type === 'tag') {
135
141
  data.condition.labels = newData;
142
+ } else if (type === 'cdp') {
143
+ data.condition.dataset = newData;
136
144
  }
137
145
  }
138
146
 
@@ -185,34 +193,45 @@ var OrConditions = function OrConditions(props) {
185
193
  dataId: id,
186
194
  onChange: onChangeTags
187
195
  });
188
- } else if (condition.eventId === undefined) {
189
- conditionDom = /*#__PURE__*/React.createElement(PropCondition, {
190
- label: "\u5C5E\u6027",
191
- attrs: condition.attrs,
196
+ } else if (condition.dataset) {
197
+ if (!openCdpCondition) return null;
198
+ conditionDom = /*#__PURE__*/React.createElement(CdpCondition, {
199
+ defaultValue: condition,
192
200
  dataId: id,
193
- onChange: onChangeAttrs
201
+ onChange: onChangeCdp
194
202
  });
195
- } else if (String(condition.eventId) === '-3') {
196
- conditionDom = /*#__PURE__*/React.createElement(PeriodCondition, {
197
- label: "\u65B0\u589E\u4E8E",
198
- dataId: id,
199
- onChange: onChangeRunPeriod,
200
- runPeriod: condition.runPeriod
201
- });
202
- } else if (String(condition.eventId) === '-4') {
203
- conditionDom = /*#__PURE__*/React.createElement(PeriodCondition, {
204
- label: "\u6D3B\u8DC3\u4E8E",
205
- isRealTime: true,
206
- dataId: id,
207
- onChange: onChangeRunPeriod,
208
- runPeriod: condition.runPeriod
209
- });
210
- } else if (util.isNumber(condition.eventId)) {
211
- conditionDom = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EventCondition, {
212
- dataId: id,
213
- onChange: onChangeEvent,
214
- condition: condition
215
- }));
203
+ } else {
204
+ var conditionData = condition;
205
+
206
+ if (conditionData.eventId === undefined) {
207
+ conditionDom = /*#__PURE__*/React.createElement(PropCondition, {
208
+ label: "\u5C5E\u6027",
209
+ attrs: conditionData.attrs,
210
+ dataId: id,
211
+ onChange: onChangeAttrs
212
+ });
213
+ } else if (String(conditionData.eventId) === '-3') {
214
+ conditionDom = /*#__PURE__*/React.createElement(PeriodCondition, {
215
+ label: "\u65B0\u589E\u4E8E",
216
+ dataId: id,
217
+ onChange: onChangeRunPeriod,
218
+ runPeriod: conditionData.runPeriod
219
+ });
220
+ } else if (String(conditionData.eventId) === '-4') {
221
+ conditionDom = /*#__PURE__*/React.createElement(PeriodCondition, {
222
+ label: "\u6D3B\u8DC3\u4E8E",
223
+ isRealTime: true,
224
+ dataId: id,
225
+ onChange: onChangeRunPeriod,
226
+ runPeriod: conditionData.runPeriod
227
+ });
228
+ } else if (util.isNumber(conditionData.eventId)) {
229
+ conditionDom = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EventCondition, {
230
+ dataId: id,
231
+ onChange: onChangeEvent,
232
+ condition: condition
233
+ }));
234
+ }
216
235
  }
217
236
 
218
237
  return /*#__PURE__*/React.createElement(ConditionWrap, {
@@ -23,4 +23,11 @@
23
23
  margin-bottom: 0;
24
24
  }
25
25
  }
26
+ &-tip {
27
+ margin-top: @margin-lg;
28
+ color: @warning-color;
29
+ span {
30
+ margin-right: @margin-xs;
31
+ }
32
+ }
26
33
  }
@@ -15,8 +15,13 @@ export interface AllConditionBasePropsI<T> {
15
15
  dataId: number;
16
16
  onChange: (dataId: number, newData: T) => void;
17
17
  }
18
+ export declare enum PropType {
19
+ STRING = "string",
20
+ NUMBER = "number",
21
+ DATE = "date"
22
+ }
18
23
  export declare namespace BizUserConditionT {
19
- type ConditionType = 'add' | 'active' | 'event' | 'prop' | 'tag';
24
+ type ConditionType = 'add' | 'active' | 'event' | 'prop' | 'tag' | 'cdp';
20
25
  interface PropsI {
21
26
  defaultValue: BizUserConditionT.Conditions;
22
27
  onChange: (value: any[]) => void;
@@ -27,6 +32,7 @@ export declare namespace BizUserConditionT {
27
32
  openTagCondition?: boolean;
28
33
  userTagsData?: UserTagsDataI[];
29
34
  isRealTime?: boolean;
35
+ openCdpCondition?: boolean;
30
36
  }
31
37
  interface UserTagsDataI {
32
38
  appId: number;
@@ -91,18 +97,43 @@ export declare namespace BizUserConditionT {
91
97
  attrs: AttrCondition[];
92
98
  eventId: undefined;
93
99
  }
94
- type Condition = EventCondition | AddCondition | ActiveCondition | PropCondition | TagsCondition;
100
+ interface CdpDataSet {
101
+ id: number;
102
+ datasetName: string;
103
+ tableName: string;
104
+ }
105
+ interface CdpDataSetDetail {
106
+ name?: string;
107
+ type?: string;
108
+ webType?: PropType;
109
+ }
110
+ interface CdpConditionDetail {
111
+ datasetId?: number;
112
+ datasetTable?: string;
113
+ fieldName?: string;
114
+ fieldType?: string;
115
+ webType?: PropType;
116
+ operator?: string;
117
+ params?: string[];
118
+ paramType?: PropType;
119
+ }
120
+ interface CdpCondition {
121
+ dataset: (BizUserConditionT.CdpConditionDetail | undefined)[];
122
+ }
123
+ type Condition = EventCondition | AddCondition | ActiveCondition | PropCondition | TagsCondition | CdpCondition;
95
124
  type Conditions = Condition[][];
125
+ type OtherCondition = EventCondition | AddCondition | ActiveCondition | PropCondition;
96
126
  interface ShowItemI {
97
127
  id: number;
98
128
  orConditions: Conditions[number];
99
129
  }
100
130
  type ShowListT = ShowItemI[];
101
- type GlobalContext = Pick<BizUserConditionT.PropsI, 'orConditionNum' | 'eventAttrNum' | 'openTagCondition' | 'userTagsData' | 'textMode' | 'isRealTime'> & {
131
+ type GlobalContext = Pick<BizUserConditionT.PropsI, 'orConditionNum' | 'eventAttrNum' | 'openTagCondition' | 'userTagsData' | 'openCdpCondition' | 'textMode' | 'isRealTime'> & {
102
132
  envNameList: string[];
103
133
  userPropsMap: {
104
134
  [key: string]: UserProp;
105
135
  };
136
+ datasetList: CdpDataSet[];
106
137
  };
107
138
  }
108
139
  export declare namespace OrConditionsT {
@@ -1 +1,7 @@
1
- export {};
1
+ export var PropType;
2
+
3
+ (function (PropType) {
4
+ PropType["STRING"] = "string";
5
+ PropType["NUMBER"] = "number";
6
+ PropType["DATE"] = "date";
7
+ })(PropType || (PropType = {}));
@@ -1,6 +1,6 @@
1
1
  import type { GlobalContextProps } from '../context';
2
2
  import type { BizUserConditionT, Unpacked } from './types';
3
- export declare function buildCondition(type: BizUserConditionT.ConditionType): BizUserConditionT.EventCondition | BizUserConditionT.AddCondition | BizUserConditionT.ActiveCondition | BizUserConditionT.PropCondition;
3
+ export declare function buildCondition(type: BizUserConditionT.ConditionType): BizUserConditionT.EventCondition | BizUserConditionT.AddCondition | BizUserConditionT.ActiveCondition | BizUserConditionT.PropCondition | BizUserConditionT.CdpCondition;
4
4
  export declare function transformNumberOperate(key: string, output?: boolean): string;
5
5
  export declare function findEvent(eventId: number, eventGroupList: Unpacked<GlobalContextProps, 'eventGroupList'>): import("../attributeSelector/types").AnalysisEvent | null;
6
6
  export declare function findPropAndEnv(name: string, list: Unpacked<GlobalContextProps, 'userPropList' | 'eventEnvList'>): import("../attributeSelector/types").UserProp | import("../attributeSelector/types").EnvProp | null;
@@ -66,6 +66,11 @@ export function buildCondition(type) {
66
66
  },
67
67
  eventId: undefined
68
68
  };
69
+
70
+ case 'cdp':
71
+ return {
72
+ dataset: []
73
+ };
69
74
  }
70
75
  }
71
76
  export function transformNumberOperate(key) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgfe/business-lib",
3
- "version": "1.0.30-alpha.0",
3
+ "version": "1.0.30-user.0",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -58,5 +58,5 @@
58
58
  "react": "^16.12.0 || ^17.0.0",
59
59
  "yorkie": "^2.0.0"
60
60
  },
61
- "gitHead": "2413963520046325cf1efe05bd0dd749680c37a6"
61
+ "gitHead": "1937fcaa33dd321f961d65873b579565900e8ad4"
62
62
  }