@zgfe/business-lib 1.1.40 → 1.1.41-attribution.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config.js +41 -0
- package/es/addToPanel/demo/edit.js +5 -3
- package/es/addToPanel/index.js +1 -4
- package/es/addToPanel/types.d.ts +2 -2
- package/es/addToScene/index.js +4 -14
- package/es/addToScene/types.d.ts +1 -1
- package/es/attrCondition/demo/group.d.ts +2 -0
- package/es/attrCondition/demo/group.js +25 -0
- package/es/attrCondition/demo/index.d.ts +2 -0
- package/es/attrCondition/demo/index.js +16 -0
- package/es/attrCondition/group.d.ts +4 -0
- package/es/attrCondition/group.js +59 -0
- package/es/attrCondition/index.d.ts +5 -0
- package/es/attrCondition/index.js +67 -0
- package/es/attrCondition/styles/index.less +61 -0
- package/es/attrCondition/useAttrCondition.d.ts +13 -0
- package/es/attrCondition/useAttrCondition.js +91 -0
- package/es/attrCondition/useConditionGroup.d.ts +10 -0
- package/es/attrCondition/useConditionGroup.js +127 -0
- package/es/attrConditions/components/stringList.js +3 -1
- package/es/attrConditions/components/valuesList.js +6 -4
- package/es/attrConditions/group.js +11 -118
- package/es/attrConditions/index.js +13 -79
- package/es/attributeSelector/demo/index.js +4 -2
- package/es/attributeSelector/listPanel.js +2 -1
- package/es/constants/apis.d.ts +2 -0
- package/es/constants/apis.js +4 -2
- package/es/context/index.d.ts +1 -0
- package/es/datePicker/datePicker.d.ts +1 -0
- package/es/datePicker/datePicker.js +12 -3
- package/es/datePicker/demo/day.js +14 -2
- package/es/datePicker/index.js +18 -7
- package/es/datePicker/types.d.ts +1 -0
- package/es/demoWrapper/content.d.ts +2 -1
- package/es/demoWrapper/content.js +19 -18
- package/es/demoWrapper/head.js +4 -4
- package/es/demoWrapper/index.js +7 -4
- package/es/demoWrapper/types.d.ts +2 -0
- package/es/eventSelector/demo/index.js +2 -1
- package/es/eventSelector/index.js +2 -1
- package/es/eventSelector/listPanel.js +10 -3
- package/es/eventSelector/option.d.ts +1 -0
- package/es/eventSelector/option.js +4 -2
- package/es/eventSelector/styles/index.less +6 -0
- package/es/eventSelector/types.d.ts +2 -0
- package/es/index.d.ts +5 -1
- package/es/index.js +5 -1
- package/es/layout/optionTitle/components/btnMenu/api.d.ts +4 -0
- package/es/layout/optionTitle/components/btnMenu/api.js +7 -0
- package/es/layout/optionTitle/components/btnMenu/demo.d.ts +2 -0
- package/es/layout/optionTitle/components/btnMenu/demo.js +80 -0
- package/es/layout/optionTitle/components/btnMenu/index.d.ts +5 -0
- package/es/layout/optionTitle/components/btnMenu/index.js +48 -0
- package/es/layout/optionTitle/components/btnMenu/index.less +18 -0
- package/es/layout/optionTitle/components/title/demo.d.ts +2 -0
- package/es/layout/optionTitle/components/title/demo.js +50 -0
- package/es/layout/optionTitle/components/title/index.d.ts +5 -0
- package/es/layout/optionTitle/components/title/index.js +106 -0
- package/es/layout/optionTitle/components/title/index.less +42 -0
- package/es/layout/optionTitle/data.d.ts +3 -0
- package/es/layout/optionTitle/data.js +77 -0
- package/es/layout/optionTitle/demo/index.d.ts +2 -0
- package/es/layout/optionTitle/demo/index.js +116 -0
- package/es/layout/optionTitle/demo/index.less +12 -0
- package/es/layout/optionTitle/demo/layout.d.ts +3 -0
- package/es/layout/optionTitle/demo/layout.js +41 -0
- package/es/layout/optionTitle/demo/panelCreate.d.ts +2 -0
- package/es/layout/optionTitle/demo/panelCreate.js +114 -0
- package/es/layout/optionTitle/index.d.ts +6 -0
- package/es/layout/optionTitle/index.js +156 -0
- package/es/layout/optionTitle/layout.d.ts +5 -0
- package/es/layout/optionTitle/layout.js +38 -0
- package/es/layout/optionTitle/styles/index.less +19 -0
- package/es/layout/optionTitle/styles/layout.less +43 -0
- package/es/layout/optionTitle/styles/search.less +27 -0
- package/es/layout/optionTitle/types.d.ts +85 -0
- package/es/layout/optionTitle/types.js +15 -0
- package/es/layout/optionTitle/typesValue.d.ts +4 -0
- package/es/layout/optionTitle/typesValue.js +7 -0
- package/es/utils/ajax.js +2 -4
- package/package.json +4 -3
package/config.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 对关键配置信息进行本地化存储,避免多人项目配置代码冲突
|
|
6
|
+
* @param defaultConfig
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
function getConfig(defaultConfig, basePath) {
|
|
10
|
+
const configPath = path.resolve(basePath, '.config.json');
|
|
11
|
+
let resConfig = defaultConfig;
|
|
12
|
+
try {
|
|
13
|
+
if (fs.existsSync(configPath)) {
|
|
14
|
+
const config = fs.readFileSync(configPath, 'utf-8');
|
|
15
|
+
if (!config || config === '{}') {
|
|
16
|
+
throw new Error('配置文件为空');
|
|
17
|
+
}
|
|
18
|
+
const configObj = JSON.parse(config);
|
|
19
|
+
// 如果读取的配置文件,数据结构与默认配置不一致,则更新配置文件,更新规则:以默认配置为准,保留用户自定义配置
|
|
20
|
+
const isSame = Object.keys(defaultConfig).every((key) => {
|
|
21
|
+
return configObj.hasOwnProperty(key);
|
|
22
|
+
});
|
|
23
|
+
if (!isSame) {
|
|
24
|
+
resConfig = Object.assign({}, defaultConfig, configObj);
|
|
25
|
+
throw new Error('配置文件数据结构不一致');
|
|
26
|
+
}
|
|
27
|
+
resConfig = configObj;
|
|
28
|
+
} else {
|
|
29
|
+
throw new Error('配置文件不存在');
|
|
30
|
+
}
|
|
31
|
+
} catch (e) {
|
|
32
|
+
console.log(e.message);
|
|
33
|
+
fs.writeFileSync(configPath, JSON.stringify(resConfig, null, 2));
|
|
34
|
+
}
|
|
35
|
+
console.log('配置详情', resConfig);
|
|
36
|
+
return resConfig;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports = {
|
|
40
|
+
getConfig,
|
|
41
|
+
};
|
|
@@ -5,7 +5,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
5
5
|
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; } }
|
|
6
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
7
|
import React, { useState } from 'react';
|
|
8
|
-
import { BizAddToPanel } from '@zgfe/business-lib';
|
|
8
|
+
import { BizAddToPanel, DemoWrapper } from '@zgfe/business-lib';
|
|
9
9
|
import { Button } from 'antd';
|
|
10
10
|
var chartTypes = [{
|
|
11
11
|
label: '趋势图',
|
|
@@ -53,7 +53,9 @@ export default (function () {
|
|
|
53
53
|
_useState2 = _slicedToArray(_useState, 2),
|
|
54
54
|
showDialog = _useState2[0],
|
|
55
55
|
setShowDialog = _useState2[1];
|
|
56
|
-
return /*#__PURE__*/React.createElement(
|
|
56
|
+
return /*#__PURE__*/React.createElement(DemoWrapper, {
|
|
57
|
+
needMeta: true
|
|
58
|
+
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Button, {
|
|
57
59
|
onClick: function onClick() {
|
|
58
60
|
setShowDialog(true);
|
|
59
61
|
}
|
|
@@ -69,5 +71,5 @@ export default (function () {
|
|
|
69
71
|
onOk: function onOk() {
|
|
70
72
|
setShowDialog(false);
|
|
71
73
|
}
|
|
72
|
-
}));
|
|
74
|
+
})));
|
|
73
75
|
});
|
package/es/addToPanel/index.js
CHANGED
|
@@ -216,10 +216,7 @@ var BizAddToPanel = function BizAddToPanel(props) {
|
|
|
216
216
|
rules: [{
|
|
217
217
|
validator: function validator(_, value) {
|
|
218
218
|
if (props.type === 'edit') {
|
|
219
|
-
|
|
220
|
-
message: '指标名称不能为空'
|
|
221
|
-
});
|
|
222
|
-
return Promise.reject();
|
|
219
|
+
return Promise.resolve();
|
|
223
220
|
}
|
|
224
221
|
if (!value || !/\S+/.test(value)) return Promise.reject('请输入指标名称!');
|
|
225
222
|
if (!/^[\S\s]{1,20}$/.test(value)) return Promise.reject('指标名称最多为20个字符!');
|
package/es/addToPanel/types.d.ts
CHANGED
package/es/addToScene/index.js
CHANGED
|
@@ -56,10 +56,10 @@ var BizAddToScene = function BizAddToScene(props) {
|
|
|
56
56
|
appId: currentApp === null || currentApp === void 0 ? void 0 : currentApp.appId,
|
|
57
57
|
platform: 0,
|
|
58
58
|
groupId: form.group.groupId,
|
|
59
|
-
json:
|
|
59
|
+
json: {
|
|
60
60
|
chosen_data: [],
|
|
61
61
|
data: params
|
|
62
|
-
}
|
|
62
|
+
},
|
|
63
63
|
name: form.name
|
|
64
64
|
};
|
|
65
65
|
if (form.group.groupId === 0) {
|
|
@@ -70,21 +70,11 @@ var BizAddToScene = function BizAddToScene(props) {
|
|
|
70
70
|
data: data
|
|
71
71
|
}).then(function (res) {
|
|
72
72
|
setLoading(false);
|
|
73
|
-
|
|
74
|
-
if (result.code === 10001) {
|
|
73
|
+
if (res.data) {
|
|
75
74
|
notification.success({
|
|
76
75
|
message: '添加成功'
|
|
77
76
|
});
|
|
78
77
|
if (props.onOk) props.onOk(res);
|
|
79
|
-
} else if (result.code === -10010) {
|
|
80
|
-
notification.error({
|
|
81
|
-
message: '添加失败',
|
|
82
|
-
description: data.groupId === 0 ? '场景分类已存在' : '场景名称已存在'
|
|
83
|
-
});
|
|
84
|
-
} else {
|
|
85
|
-
notification.error({
|
|
86
|
-
message: '添加失败'
|
|
87
|
-
});
|
|
88
78
|
}
|
|
89
79
|
}).catch(function () {
|
|
90
80
|
setLoading(false);
|
|
@@ -104,7 +94,7 @@ var BizAddToScene = function BizAddToScene(props) {
|
|
|
104
94
|
});
|
|
105
95
|
return;
|
|
106
96
|
}
|
|
107
|
-
setGroupList(res.
|
|
97
|
+
setGroupList(res.data);
|
|
108
98
|
});
|
|
109
99
|
}
|
|
110
100
|
useEffect(function () {
|
package/es/addToScene/types.d.ts
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import { BizAttrConditionGroup, DemoWrapper } from '@zgfe/business-lib';
|
|
3
|
+
import { Button } from 'antd';
|
|
4
|
+
export default (function () {
|
|
5
|
+
var groupRef = useRef(null);
|
|
6
|
+
return /*#__PURE__*/React.createElement(DemoWrapper, {
|
|
7
|
+
needMeta: true
|
|
8
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
9
|
+
style: {
|
|
10
|
+
padding: '16px',
|
|
11
|
+
background: '#fff'
|
|
12
|
+
}
|
|
13
|
+
}, /*#__PURE__*/React.createElement(BizAttrConditionGroup, {
|
|
14
|
+
ref: groupRef,
|
|
15
|
+
enableDelete: true
|
|
16
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
17
|
+
style: {
|
|
18
|
+
marginTop: '16px'
|
|
19
|
+
}
|
|
20
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
21
|
+
onClick: function onClick() {
|
|
22
|
+
groupRef.current.add();
|
|
23
|
+
}
|
|
24
|
+
}, "\u6DFB\u52A0\u6761\u4EF6"))));
|
|
25
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BizAttrCondition, DemoWrapper } from '@zgfe/business-lib';
|
|
3
|
+
export default (function () {
|
|
4
|
+
return /*#__PURE__*/React.createElement(DemoWrapper, {
|
|
5
|
+
needMeta: true
|
|
6
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
7
|
+
style: {
|
|
8
|
+
padding: '16px',
|
|
9
|
+
background: '#fff'
|
|
10
|
+
}
|
|
11
|
+
}, /*#__PURE__*/React.createElement(BizAttrCondition, {
|
|
12
|
+
onChange: function onChange(condition) {
|
|
13
|
+
console.log(condition);
|
|
14
|
+
}
|
|
15
|
+
})));
|
|
16
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import useConditionGroup from './useConditionGroup';
|
|
3
|
+
import { Skeleton, Space } from 'antd';
|
|
4
|
+
import BizAttrCondition from '.';
|
|
5
|
+
var BizAttrConditionGroup = function BizAttrConditionGroup(props, ref) {
|
|
6
|
+
var eventIdList = props.eventIdList,
|
|
7
|
+
enableDelete = props.enableDelete,
|
|
8
|
+
enableEventProp = props.enableEventProp,
|
|
9
|
+
enableUserProp = props.enableUserProp,
|
|
10
|
+
enableEnvProp = props.enableEnvProp,
|
|
11
|
+
disableItemList = props.disableItemList;
|
|
12
|
+
var _useConditionGroup = useConditionGroup(props, ref),
|
|
13
|
+
loading = _useConditionGroup.loading,
|
|
14
|
+
conditions = _useConditionGroup.conditions,
|
|
15
|
+
_onChange = _useConditionGroup.onChange,
|
|
16
|
+
onClickRelation = _useConditionGroup.onClickRelation,
|
|
17
|
+
_onDelete = _useConditionGroup.onDelete,
|
|
18
|
+
relation = _useConditionGroup.relation;
|
|
19
|
+
var classPrefix = 'biz-attr-condition-group';
|
|
20
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
21
|
+
className: classPrefix
|
|
22
|
+
}, /*#__PURE__*/React.createElement(Skeleton, {
|
|
23
|
+
loading: loading,
|
|
24
|
+
active: true,
|
|
25
|
+
paragraph: {
|
|
26
|
+
rows: 2
|
|
27
|
+
}
|
|
28
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
29
|
+
className: "".concat(classPrefix, "-handle")
|
|
30
|
+
}, conditions.length > 1 && /*#__PURE__*/React.createElement("div", {
|
|
31
|
+
className: "".concat(classPrefix, "-operate"),
|
|
32
|
+
onClick: onClickRelation
|
|
33
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
34
|
+
className: "".concat(classPrefix, "-operate-text ").concat(relation === 'and' || props.onlyAnd ? 'active' : '')
|
|
35
|
+
}, "\u4E14"), !props.onlyAnd && /*#__PURE__*/React.createElement("div", {
|
|
36
|
+
className: "".concat(classPrefix, "-operate-text ").concat(relation === 'or' ? 'active' : '')
|
|
37
|
+
}, "\u6216"))), /*#__PURE__*/React.createElement(Space, {
|
|
38
|
+
className: "".concat(classPrefix, "-container"),
|
|
39
|
+
direction: "vertical"
|
|
40
|
+
}, conditions.map(function (item, index) {
|
|
41
|
+
return /*#__PURE__*/React.createElement(BizAttrCondition, {
|
|
42
|
+
key: item.key,
|
|
43
|
+
value: item.data,
|
|
44
|
+
eventIdList: eventIdList,
|
|
45
|
+
enableDelete: enableDelete,
|
|
46
|
+
enableEventProp: enableEventProp,
|
|
47
|
+
enableUserProp: enableUserProp,
|
|
48
|
+
enableEnvProp: enableEnvProp,
|
|
49
|
+
disableItemList: disableItemList,
|
|
50
|
+
onChange: function onChange(data) {
|
|
51
|
+
return _onChange(data, index);
|
|
52
|
+
},
|
|
53
|
+
onDelete: function onDelete() {
|
|
54
|
+
return _onDelete(index);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}))));
|
|
58
|
+
};
|
|
59
|
+
export default /*#__PURE__*/React.forwardRef(BizAttrConditionGroup);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Skeleton, Space } from 'antd';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import BizAttributeSelector from '../attributeSelector';
|
|
4
|
+
import BizOperateList from '../attrConditions/components/operateList';
|
|
5
|
+
import ValuesList from '../attrConditions/components/valuesList';
|
|
6
|
+
import useAttrCondition from './useAttrCondition';
|
|
7
|
+
import './styles/index.less';
|
|
8
|
+
import IconFont from '../icon/iconFont';
|
|
9
|
+
var classPrefix = 'biz-attr-condition';
|
|
10
|
+
var BizAttrCondition = function BizAttrCondition(props) {
|
|
11
|
+
var eventIdList = props.eventIdList,
|
|
12
|
+
enableDelete = props.enableDelete,
|
|
13
|
+
enableEventProp = props.enableEventProp,
|
|
14
|
+
enableUserProp = props.enableUserProp,
|
|
15
|
+
enableEnvProp = props.enableEnvProp,
|
|
16
|
+
disableItemList = props.disableItemList,
|
|
17
|
+
theme = props.theme;
|
|
18
|
+
var _useAttrCondition = useAttrCondition(props),
|
|
19
|
+
loading = _useAttrCondition.loading,
|
|
20
|
+
attr = _useAttrCondition.attr,
|
|
21
|
+
operate = _useAttrCondition.operate,
|
|
22
|
+
values = _useAttrCondition.values,
|
|
23
|
+
onChangeAttr = _useAttrCondition.onChangeAttr,
|
|
24
|
+
onChangeOperate = _useAttrCondition.onChangeOperate,
|
|
25
|
+
onChangeValues = _useAttrCondition.onChangeValues,
|
|
26
|
+
onDelete = _useAttrCondition.onDelete;
|
|
27
|
+
return /*#__PURE__*/React.createElement(Space, {
|
|
28
|
+
className: classPrefix
|
|
29
|
+
}, !loading ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(BizAttributeSelector, {
|
|
30
|
+
value: attr,
|
|
31
|
+
eventIdList: eventIdList,
|
|
32
|
+
enableEventProp: enableEventProp,
|
|
33
|
+
enableUserProp: enableUserProp,
|
|
34
|
+
enableEnvProp: enableEnvProp,
|
|
35
|
+
disableItemList: disableItemList,
|
|
36
|
+
onChange: onChangeAttr,
|
|
37
|
+
theme: theme,
|
|
38
|
+
destroyPopupOnHide: props.destroyPopupOnHide,
|
|
39
|
+
placeholder: "\u8BF7\u9009\u62E9\u5C5E\u6027"
|
|
40
|
+
}), /*#__PURE__*/React.createElement(BizOperateList, {
|
|
41
|
+
theme: theme,
|
|
42
|
+
attr: attr,
|
|
43
|
+
defaultValue: operate,
|
|
44
|
+
onChange: onChangeOperate
|
|
45
|
+
}), /*#__PURE__*/React.createElement(ValuesList, {
|
|
46
|
+
attr: attr,
|
|
47
|
+
operate: operate,
|
|
48
|
+
defaultValue: values,
|
|
49
|
+
onChange: onChangeValues,
|
|
50
|
+
theme: theme
|
|
51
|
+
}), enableDelete && /*#__PURE__*/React.createElement(IconFont, {
|
|
52
|
+
type: "qingchu",
|
|
53
|
+
className: "".concat(classPrefix, "-btn-del"),
|
|
54
|
+
onClick: onDelete
|
|
55
|
+
})) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Skeleton.Input, {
|
|
56
|
+
active: true
|
|
57
|
+
}), /*#__PURE__*/React.createElement(Skeleton.Input, {
|
|
58
|
+
active: true
|
|
59
|
+
}), /*#__PURE__*/React.createElement(Skeleton.Input, {
|
|
60
|
+
active: true
|
|
61
|
+
})));
|
|
62
|
+
};
|
|
63
|
+
BizAttrCondition.defaultProps = {
|
|
64
|
+
border: false,
|
|
65
|
+
theme: ''
|
|
66
|
+
};
|
|
67
|
+
export default BizAttrCondition;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
@import '../../assets/styles/inner.less';
|
|
2
|
+
.biz-attr-condition {
|
|
3
|
+
&-btn-del {
|
|
4
|
+
color: #9aa1a9;
|
|
5
|
+
&:hover {
|
|
6
|
+
color: @error-color;
|
|
7
|
+
cursor: pointer;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
.biz-attr-select-handle {
|
|
11
|
+
width: 184px;
|
|
12
|
+
padding: 0;
|
|
13
|
+
border: none;
|
|
14
|
+
}
|
|
15
|
+
.ant-space-item:nth-of-type(3) {
|
|
16
|
+
width: 184px;
|
|
17
|
+
}
|
|
18
|
+
&-group {
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: row;
|
|
21
|
+
&-container {
|
|
22
|
+
flex: 1;
|
|
23
|
+
}
|
|
24
|
+
&-handle {
|
|
25
|
+
position: relative;
|
|
26
|
+
width: 1px;
|
|
27
|
+
margin-right: 16px;
|
|
28
|
+
margin-left: 8px;
|
|
29
|
+
background: @border-color-base;
|
|
30
|
+
}
|
|
31
|
+
&-operate {
|
|
32
|
+
position: absolute;
|
|
33
|
+
top: 50%;
|
|
34
|
+
left: 50%;
|
|
35
|
+
width: 16px;
|
|
36
|
+
transform: translate(-50%, -50%);
|
|
37
|
+
}
|
|
38
|
+
&-operate-text {
|
|
39
|
+
width: 16px;
|
|
40
|
+
height: 16px;
|
|
41
|
+
font-size: 12px;
|
|
42
|
+
line-height: 16px;
|
|
43
|
+
text-align: center;
|
|
44
|
+
|
|
45
|
+
.__default-hover();
|
|
46
|
+
|
|
47
|
+
&:first-child {
|
|
48
|
+
border-radius: @border-radius-sx @border-radius-sx 0px 0px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&:last-child {
|
|
52
|
+
border-radius: 0px 0px @border-radius-sx @border-radius-sx;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&.active {
|
|
56
|
+
color: #fff;
|
|
57
|
+
background: @primary-color;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AttrConditionTypes } from '../attrConditions/types';
|
|
2
|
+
import { AttributeSelect } from '../attributeSelector/types';
|
|
3
|
+
declare const useAttrCondition: (props: AttrConditionTypes.ItemProp) => {
|
|
4
|
+
attr: AttributeSelect.Value | undefined;
|
|
5
|
+
operate: import("../attrConditions/types").OperateTypes | undefined;
|
|
6
|
+
values: string[] | undefined;
|
|
7
|
+
loading: boolean;
|
|
8
|
+
onDelete: () => void;
|
|
9
|
+
onChangeAttr: (attrData: AttributeSelect.Value) => void;
|
|
10
|
+
onChangeOperate: (data: any) => void;
|
|
11
|
+
onChangeValues: (data: any) => void;
|
|
12
|
+
};
|
|
13
|
+
export default useAttrCondition;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
3
|
+
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); }
|
|
4
|
+
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; }
|
|
5
|
+
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; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { useEffect, useState } from 'react';
|
|
8
|
+
import { PropCategory } from '../attributeSelector/types';
|
|
9
|
+
import { getCondition } from '../attrConditions';
|
|
10
|
+
var useAttrCondition = function useAttrCondition(props) {
|
|
11
|
+
var _props$defaultValue, _props$value, _props$defaultValue2, _props$value2;
|
|
12
|
+
var _useState = useState(),
|
|
13
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
14
|
+
attr = _useState2[0],
|
|
15
|
+
setAttr = _useState2[1];
|
|
16
|
+
var _useState3 = useState(((_props$defaultValue = props.defaultValue) === null || _props$defaultValue === void 0 ? void 0 : _props$defaultValue.operator) || ((_props$value = props.value) === null || _props$value === void 0 ? void 0 : _props$value.operator)),
|
|
17
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
18
|
+
operate = _useState4[0],
|
|
19
|
+
setOperate = _useState4[1];
|
|
20
|
+
var _useState5 = useState(((_props$defaultValue2 = props.defaultValue) === null || _props$defaultValue2 === void 0 ? void 0 : _props$defaultValue2.values) || ((_props$value2 = props.value) === null || _props$value2 === void 0 ? void 0 : _props$value2.values)),
|
|
21
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
22
|
+
values = _useState6[0],
|
|
23
|
+
setValues = _useState6[1];
|
|
24
|
+
var _useState7 = useState(true),
|
|
25
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
26
|
+
loading = _useState8[0],
|
|
27
|
+
setLoading = _useState8[1];
|
|
28
|
+
useEffect(function () {
|
|
29
|
+
var data = props.defaultValue || props.value;
|
|
30
|
+
if (data) {
|
|
31
|
+
var attrData;
|
|
32
|
+
if (data.propCategory === PropCategory.EventProp) {
|
|
33
|
+
if (data.attrId) {
|
|
34
|
+
attrData = {
|
|
35
|
+
id: data.attrId,
|
|
36
|
+
propCategory: data.propCategory,
|
|
37
|
+
type: data.type,
|
|
38
|
+
key: data.attrId,
|
|
39
|
+
label: data.label,
|
|
40
|
+
dimensionSub: data.dimensionSub || 'event_attr'
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
} else if (data.propCategory === PropCategory.UserProp || data.propCategory === PropCategory.EnvProp) {
|
|
44
|
+
if (data.attrName) {
|
|
45
|
+
var aId = data.attrId || 0;
|
|
46
|
+
attrData = {
|
|
47
|
+
id: aId,
|
|
48
|
+
name: data.attrName,
|
|
49
|
+
propCategory: data.propCategory,
|
|
50
|
+
type: data.type,
|
|
51
|
+
category: data.category,
|
|
52
|
+
key: "".concat(data.propCategory, "-").concat(data.dimensionSub || data.attrName, "-").concat(aId),
|
|
53
|
+
subtype: data.subtype,
|
|
54
|
+
dimensionSub: data.dimensionSub || data.attrName
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
setAttr(attrData);
|
|
59
|
+
}
|
|
60
|
+
setLoading(false);
|
|
61
|
+
}, []);
|
|
62
|
+
var onDelete = function onDelete() {
|
|
63
|
+
if (props.onDelete) props.onDelete();
|
|
64
|
+
};
|
|
65
|
+
useEffect(function () {
|
|
66
|
+
if (props.onChange) {
|
|
67
|
+
if (!attr) return;
|
|
68
|
+
props.onChange(getCondition(attr, operate, values));
|
|
69
|
+
}
|
|
70
|
+
}, [attr, operate, values]);
|
|
71
|
+
var onChangeAttr = function onChangeAttr(attrData) {
|
|
72
|
+
setAttr(attrData);
|
|
73
|
+
};
|
|
74
|
+
var onChangeOperate = function onChangeOperate(data) {
|
|
75
|
+
setOperate(data);
|
|
76
|
+
};
|
|
77
|
+
var onChangeValues = function onChangeValues(data) {
|
|
78
|
+
setValues(data);
|
|
79
|
+
};
|
|
80
|
+
return {
|
|
81
|
+
attr: attr,
|
|
82
|
+
operate: operate,
|
|
83
|
+
values: values,
|
|
84
|
+
loading: loading,
|
|
85
|
+
onDelete: onDelete,
|
|
86
|
+
onChangeAttr: onChangeAttr,
|
|
87
|
+
onChangeOperate: onChangeOperate,
|
|
88
|
+
onChangeValues: onChangeValues
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
export default useAttrCondition;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AttrConditionTypes } from '../attrConditions/types';
|
|
2
|
+
declare const useConditionGroup: (props: AttrConditionTypes.GroupProp, ref: React.ForwardedRef<any>) => {
|
|
3
|
+
relation: "and" | "or";
|
|
4
|
+
conditions: AttrConditionTypes.GroupAddKey[];
|
|
5
|
+
loading: boolean;
|
|
6
|
+
onClickRelation: (e: any) => void;
|
|
7
|
+
onChange: (data: AttrConditionTypes.ItemValue, index: number) => void;
|
|
8
|
+
onDelete: (index: number) => void;
|
|
9
|
+
};
|
|
10
|
+
export default useConditionGroup;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
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."); }
|
|
3
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
4
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
5
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
+
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."); }
|
|
7
|
+
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); }
|
|
8
|
+
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; }
|
|
9
|
+
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; } }
|
|
10
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
+
import { useState, useEffect, useImperativeHandle } from 'react';
|
|
12
|
+
import _ from 'lodash';
|
|
13
|
+
var useConditionGroup = function useConditionGroup(props, ref) {
|
|
14
|
+
var onConditionsCount = props.onConditionsCount;
|
|
15
|
+
var _useState = useState('and'),
|
|
16
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
17
|
+
relation = _useState2[0],
|
|
18
|
+
setRelation = _useState2[1];
|
|
19
|
+
var _useState3 = useState([]),
|
|
20
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
21
|
+
conditions = _useState4[0],
|
|
22
|
+
setConditions = _useState4[1];
|
|
23
|
+
var _useState5 = useState(true),
|
|
24
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
25
|
+
loading = _useState6[0],
|
|
26
|
+
setLoading = _useState6[1];
|
|
27
|
+
useEffect(function () {
|
|
28
|
+
var data = props.defaultValue || props.value;
|
|
29
|
+
if (data) {
|
|
30
|
+
if (data.relation) setRelation(props.onlyAnd ? 'and' : data.relation);
|
|
31
|
+
if (data.conditions) {
|
|
32
|
+
setConditions(function () {
|
|
33
|
+
return addKeyToGroup(data.conditions);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
setLoading(false);
|
|
38
|
+
}, []);
|
|
39
|
+
useImperativeHandle(ref, function () {
|
|
40
|
+
return {
|
|
41
|
+
add: function add() {
|
|
42
|
+
onConditionsCount && onConditionsCount(conditions.length + 1);
|
|
43
|
+
setConditions(function (conditions) {
|
|
44
|
+
conditions.push({
|
|
45
|
+
key: Math.random()
|
|
46
|
+
});
|
|
47
|
+
return _toConsumableArray(conditions);
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
setValue: function setValue(data) {
|
|
51
|
+
if (data) {
|
|
52
|
+
if (data.relation) setRelation(props.onlyAnd ? 'and' : data.relation);
|
|
53
|
+
if (data.conditions) {
|
|
54
|
+
setConditions(function () {
|
|
55
|
+
return addKeyToGroup(data.conditions);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
setRelation('and');
|
|
60
|
+
setConditions([]);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
var addKeyToGroup = function addKeyToGroup(data) {
|
|
66
|
+
return data.map(function (item) {
|
|
67
|
+
return {
|
|
68
|
+
key: Math.random(),
|
|
69
|
+
data: item
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
var removeKeyToGroup = function removeKeyToGroup(data) {
|
|
74
|
+
var group = [];
|
|
75
|
+
data.forEach(function (item) {
|
|
76
|
+
if (item.data) group.push(item.data);
|
|
77
|
+
});
|
|
78
|
+
return group;
|
|
79
|
+
};
|
|
80
|
+
var onClickRelation = function onClickRelation(e) {
|
|
81
|
+
e.stopPropagation();
|
|
82
|
+
var data = e.target.innerText === '且' ? 'and' : 'or';
|
|
83
|
+
setRelation(data);
|
|
84
|
+
if (props.onChange) {
|
|
85
|
+
var group = removeKeyToGroup(conditions);
|
|
86
|
+
props.onChange({
|
|
87
|
+
relation: data,
|
|
88
|
+
conditions: group
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
var onChange = function onChange(data, index) {
|
|
93
|
+
var conditionArr = _.cloneDeep(conditions);
|
|
94
|
+
conditionArr[index].data = data;
|
|
95
|
+
setConditions(conditionArr);
|
|
96
|
+
onConditionsCount && onConditionsCount(conditionArr.length);
|
|
97
|
+
if (props.onChange) {
|
|
98
|
+
var group = removeKeyToGroup(conditionArr);
|
|
99
|
+
props.onChange({
|
|
100
|
+
relation: relation,
|
|
101
|
+
conditions: group
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
var onDelete = function onDelete(index) {
|
|
106
|
+
var conditionArr = _.cloneDeep(conditions);
|
|
107
|
+
conditionArr.splice(index, 1);
|
|
108
|
+
setConditions(conditionArr);
|
|
109
|
+
onConditionsCount && onConditionsCount(conditionArr.length);
|
|
110
|
+
if (props.onChange) {
|
|
111
|
+
var group = removeKeyToGroup(conditionArr);
|
|
112
|
+
props.onChange({
|
|
113
|
+
relation: relation,
|
|
114
|
+
conditions: group
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
return {
|
|
119
|
+
relation: relation,
|
|
120
|
+
conditions: conditions,
|
|
121
|
+
loading: loading,
|
|
122
|
+
onClickRelation: onClickRelation,
|
|
123
|
+
onChange: onChange,
|
|
124
|
+
onDelete: onDelete
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
export default useConditionGroup;
|
|
@@ -141,6 +141,7 @@ var StringList = function StringList(props) {
|
|
|
141
141
|
size: "middle",
|
|
142
142
|
className: "".concat(classPrefix, "-multi-select"),
|
|
143
143
|
options: [],
|
|
144
|
+
placeholder: "\u8BF7\u9009\u62E9\u5C5E\u6027\u503C",
|
|
144
145
|
disable: true
|
|
145
146
|
});
|
|
146
147
|
}
|
|
@@ -156,7 +157,8 @@ var StringList = function StringList(props) {
|
|
|
156
157
|
keyField: "value",
|
|
157
158
|
options: options,
|
|
158
159
|
onChange: onChange,
|
|
159
|
-
onSearch: setSearchValue
|
|
160
|
+
onSearch: setSearchValue,
|
|
161
|
+
placeholder: "\u8BF7\u9009\u62E9\u5C5E\u6027\u503C"
|
|
160
162
|
});
|
|
161
163
|
};
|
|
162
164
|
export default StringList;
|