@zgfe/business-lib 1.0.0-beta.3 → 1.0.0-beta.6
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/analysisLayout/index.d.ts +28 -0
- package/es/analysisLayout/index.js +6 -2
- package/es/analysisLayout/index.less +10 -3
- package/es/attributeSelector/index.d.ts +4 -2
- package/es/attributeSelector/index.js +30 -15
- package/es/chart/demo/bar.js +2 -2
- package/es/chart/demo/data/data2.d.ts +8 -0
- package/es/chart/demo/data/data2.js +7 -0
- package/es/chart/demo/data/data3.d.ts +10 -0
- package/es/chart/demo/data/data3.js +584 -0
- package/es/chart/demo/map.d.ts +2 -0
- package/es/chart/demo/map.js +11 -0
- package/es/chart/index.d.ts +29 -9
- package/es/chart/index.js +30 -71
- package/es/chart/type.d.ts +22 -0
- package/es/chart/type.js +1 -0
- package/es/chart/{chartConfig.d.ts → util/chartConfig.d.ts} +68 -3
- package/es/chart/{chartConfig.js → util/chartConfig.js} +85 -11
- package/es/chart/{color.d.ts → util/color.d.ts} +0 -0
- package/es/chart/{color.js → util/color.js} +0 -0
- package/es/chart/util/data/china.js +530 -0
- package/es/chart/util/data/cityGeoCoord.d.ts +22553 -0
- package/es/chart/util/data/cityGeoCoord.js +22552 -0
- package/es/chart/util/data/provinceGeoCoord.d.ts +343 -0
- package/es/chart/util/data/provinceGeoCoord.js +9258 -0
- package/es/chart/util/formatData.d.ts +13 -0
- package/es/chart/util/formatData.js +56 -0
- package/es/chart/util/{format.d.ts → formatOption.d.ts} +2 -1
- package/es/chart/util/{format.js → formatOption.js} +31 -1
- package/es/chart/util/mapUtil.d.ts +8 -0
- package/es/chart/util/mapUtil.js +195 -0
- package/es/commonStyle/icon.less +19 -3
- package/es/commonStyle/theme.less +5 -2
- package/es/dialog/components/selectToInput.d.ts +10 -3
- package/es/dialog/components/selectToInput.js +75 -12
- package/es/dialog/demo/index.js +27 -20
- package/es/dialog/index.d.ts +34 -2
- package/es/dialog/index.js +129 -55
- package/es/dialog/style/index.less +11 -1
- package/es/eventSelector/index.d.ts +5 -0
- package/es/eventSelector/index.js +111 -32
- package/es/globalAttributes/index.d.ts +3 -2
- package/es/globalAttributes/index.js +18 -23
- package/es/index.d.ts +2 -1
- package/es/index.js +2 -1
- package/es/multipleSelector/index.js +32 -4
- package/es/select/demo/index.js +2 -1
- package/es/select/index.d.ts +9 -1
- package/es/select/index.js +4 -2
- package/es/table/demo/index2.js +45 -3
- package/es/table/demo/index3.d.ts +2 -0
- package/es/table/demo/index3.js +227 -0
- package/es/table/index.d.ts +1 -1
- package/es/targetConditionGroup/components/conditionGroup.d.ts +4 -4
- package/es/targetConditionGroup/components/conditionGroup.js +27 -26
- package/es/targetConditionGroup/components/conditionItem.d.ts +4 -4
- package/es/targetConditionGroup/components/conditionItem.js +81 -108
- package/es/targetConditionGroup/data/operates.js +5 -5
- package/es/targetConditionGroup/demo/group.d.ts +2 -0
- package/es/targetConditionGroup/demo/group.js +42 -0
- package/es/targetConditionGroup/demo/index.js +15 -25
- package/es/targetConditionGroup/group.d.ts +56 -0
- package/es/targetConditionGroup/group.js +204 -0
- package/es/targetConditionGroup/index.d.ts +6 -0
- package/es/targetConditionGroup/index.js +148 -83
- package/es/targetConditionGroup/index.less +12 -0
- package/es/targetConditionGroup/type.d.ts +47 -2
- package/es/targetSelector/demo/form.js +1 -1
- package/es/targetSelector/demo/index.js +1 -1
- package/es/targetSelector/index.d.ts +17 -1
- package/es/targetSelector/index.js +56 -10
- package/package.json +1 -1
|
@@ -35,7 +35,7 @@ var BizGlobalAttributes = function BizGlobalAttributes(props) {
|
|
|
35
35
|
value = _props$value === void 0 ? {} : _props$value,
|
|
36
36
|
options = props.options,
|
|
37
37
|
_props$max = props.max,
|
|
38
|
-
max = _props$max === void 0 ?
|
|
38
|
+
max = _props$max === void 0 ? 10 : _props$max,
|
|
39
39
|
eventIds = props.eventIds,
|
|
40
40
|
_onChange = props.onChange;
|
|
41
41
|
|
|
@@ -47,43 +47,38 @@ var BizGlobalAttributes = function BizGlobalAttributes(props) {
|
|
|
47
47
|
useEffect(function () {
|
|
48
48
|
var defaultAttrs = Object.keys(defaultValue).length > 0 ? defaultValue : value;
|
|
49
49
|
var arr = [];
|
|
50
|
-
var
|
|
51
|
-
|
|
50
|
+
var relation = defaultAttrs.relation,
|
|
51
|
+
conditions = defaultAttrs.conditions;
|
|
52
52
|
|
|
53
|
-
if (
|
|
54
|
-
arr =
|
|
53
|
+
if (conditions) {
|
|
54
|
+
arr = conditions.map(function (item) {
|
|
55
55
|
var data = _objectSpread({}, item);
|
|
56
56
|
|
|
57
57
|
var attrId = Math.random().toString();
|
|
58
|
-
return {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
};
|
|
58
|
+
return _objectSpread({
|
|
59
|
+
key: attrId
|
|
60
|
+
}, item); // return { attrId, data };
|
|
62
61
|
});
|
|
63
|
-
} else {
|
|
64
|
-
arr = [{
|
|
65
|
-
attrId: Math.random().toString()
|
|
66
|
-
}];
|
|
67
62
|
}
|
|
68
63
|
|
|
69
64
|
setAttrsData(function (data) {
|
|
70
65
|
return {
|
|
71
|
-
|
|
72
|
-
|
|
66
|
+
relation: relation,
|
|
67
|
+
conditions: _toConsumableArray(arr)
|
|
73
68
|
};
|
|
74
69
|
});
|
|
75
70
|
}, []);
|
|
76
71
|
|
|
77
72
|
var _addAttribute = function _addAttribute() {
|
|
78
73
|
setAttrsData(function (data) {
|
|
79
|
-
var
|
|
80
|
-
|
|
81
|
-
}
|
|
74
|
+
var item = {
|
|
75
|
+
key: Math.random().toString()
|
|
76
|
+
};
|
|
82
77
|
|
|
83
|
-
if (!data.
|
|
84
|
-
data.
|
|
78
|
+
if (!data.conditions) {
|
|
79
|
+
data.conditions = [item];
|
|
85
80
|
} else {
|
|
86
|
-
data.
|
|
81
|
+
data.conditions.push(item);
|
|
87
82
|
}
|
|
88
83
|
|
|
89
84
|
return _objectSpread({}, data);
|
|
@@ -93,14 +88,14 @@ var BizGlobalAttributes = function BizGlobalAttributes(props) {
|
|
|
93
88
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(BizConditionGroup, {
|
|
94
89
|
defaultValue: attrsData,
|
|
95
90
|
options: options,
|
|
96
|
-
|
|
91
|
+
eventId: eventIds,
|
|
97
92
|
onChange: function onChange(data) {
|
|
98
93
|
setAttrsData(function () {
|
|
99
94
|
return _objectSpread({}, data);
|
|
100
95
|
});
|
|
101
96
|
_onChange && _onChange(_objectSpread({}, data));
|
|
102
97
|
}
|
|
103
|
-
}), attrsData.
|
|
98
|
+
}), attrsData.conditions && attrsData.conditions.length < max && /*#__PURE__*/React.createElement("div", {
|
|
104
99
|
className: "biz-icon-add",
|
|
105
100
|
style: {
|
|
106
101
|
marginTop: '16px'
|
package/es/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import BizAttributeSelector from './attributeSelector';
|
|
|
9
9
|
import BizGroupSelect from './attributeSelector/group';
|
|
10
10
|
import BizMultipleSelector from './multipleSelector';
|
|
11
11
|
import BizTargetCondition from './targetConditionGroup';
|
|
12
|
+
import BizTargetConditionGroup from './targetConditionGroup/group';
|
|
12
13
|
import BizConditionGroup from './targetConditionGroup/components/conditionGroup';
|
|
13
14
|
import BizDatePicker from './datePicker';
|
|
14
15
|
import BizGlobalAttributes from './globalAttributes';
|
|
@@ -20,4 +21,4 @@ import IconFont from './components/iconFont';
|
|
|
20
21
|
import { util, ajax } from './utils';
|
|
21
22
|
import { GlobalContextProps } from './utils/type';
|
|
22
23
|
declare const BizGlobalDataContext: import("react").Context<GlobalContextProps>;
|
|
23
|
-
export { BizSelect, BizDialog, BizChart, BizTable, BizAnalysisLayout, BizUserGroup, BizUserCluster, IconFont, BizTargetSelector, BizEventSelector, BizGroupSelect, BizAttributeSelector, BizGlobalDataContext, BizMultipleSelector, BizTargetCondition, BizDatePicker, BizConditionGroup, BizGlobalAttributes, ajax, util, };
|
|
24
|
+
export { BizSelect, BizDialog, BizChart, BizTable, BizAnalysisLayout, BizUserGroup, BizUserCluster, IconFont, BizTargetSelector, BizEventSelector, BizGroupSelect, BizAttributeSelector, BizGlobalDataContext, BizMultipleSelector, BizTargetCondition, BizTargetConditionGroup, BizDatePicker, BizConditionGroup, BizGlobalAttributes, ajax, util, };
|
package/es/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import { createContext } from 'react';
|
|
|
9
9
|
import BizGroupSelect from './attributeSelector/group';
|
|
10
10
|
import BizMultipleSelector from './multipleSelector';
|
|
11
11
|
import BizTargetCondition from './targetConditionGroup';
|
|
12
|
+
import BizTargetConditionGroup from './targetConditionGroup/group';
|
|
12
13
|
import BizConditionGroup from './targetConditionGroup/components/conditionGroup';
|
|
13
14
|
import BizDatePicker from './datePicker';
|
|
14
15
|
import BizGlobalAttributes from './globalAttributes';
|
|
@@ -19,4 +20,4 @@ import BizTable from './table';
|
|
|
19
20
|
import IconFont from './components/iconFont';
|
|
20
21
|
import { util, ajax } from './utils';
|
|
21
22
|
var BizGlobalDataContext = /*#__PURE__*/createContext({});
|
|
22
|
-
export { BizSelect, BizDialog, BizChart, BizTable, BizAnalysisLayout, BizUserGroup, BizUserCluster, IconFont, BizTargetSelector, BizEventSelector, BizGroupSelect, BizAttributeSelector, BizGlobalDataContext, BizMultipleSelector, BizTargetCondition, BizDatePicker, BizConditionGroup, BizGlobalAttributes, ajax, util };
|
|
23
|
+
export { BizSelect, BizDialog, BizChart, BizTable, BizAnalysisLayout, BizUserGroup, BizUserCluster, IconFont, BizTargetSelector, BizEventSelector, BizGroupSelect, BizAttributeSelector, BizGlobalDataContext, BizMultipleSelector, BizTargetCondition, BizTargetConditionGroup, BizDatePicker, BizConditionGroup, BizGlobalAttributes, ajax, util };
|
|
@@ -10,6 +10,14 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
10
10
|
|
|
11
11
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
12
12
|
|
|
13
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
14
|
+
|
|
15
|
+
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."); }
|
|
16
|
+
|
|
17
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
18
|
+
|
|
19
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
20
|
+
|
|
13
21
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
14
22
|
|
|
15
23
|
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."); }
|
|
@@ -22,7 +30,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
22
30
|
|
|
23
31
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
24
32
|
|
|
25
|
-
import React, { useState } from 'react';
|
|
33
|
+
import React, { useEffect, useState } from 'react';
|
|
26
34
|
import { Select } from 'antd';
|
|
27
35
|
import IconFont from '../components/iconFont';
|
|
28
36
|
import './index.less';
|
|
@@ -36,13 +44,28 @@ var BizMultipleSelector = function BizMultipleSelector(props) {
|
|
|
36
44
|
options = props.options,
|
|
37
45
|
_props$placeholder = props.placeholder,
|
|
38
46
|
placeholder = _props$placeholder === void 0 ? '请选择' : _props$placeholder,
|
|
39
|
-
|
|
47
|
+
_onChange = props.onChange; // 是否是聚焦状态
|
|
40
48
|
|
|
41
49
|
var _useState = useState(false),
|
|
42
50
|
_useState2 = _slicedToArray(_useState, 2),
|
|
43
51
|
focused = _useState2[0],
|
|
44
52
|
setFocused = _useState2[1];
|
|
45
53
|
|
|
54
|
+
var _useState3 = useState([]),
|
|
55
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
56
|
+
multiValue = _useState4[0],
|
|
57
|
+
setMultiValue = _useState4[1];
|
|
58
|
+
|
|
59
|
+
useEffect(function () {
|
|
60
|
+
var data = defaultValue || value || [];
|
|
61
|
+
|
|
62
|
+
if (JSON.stringify(data) !== JSON.stringify(multiValue)) {
|
|
63
|
+
setMultiValue(function () {
|
|
64
|
+
return _toConsumableArray(data);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}, [defaultValue, value]);
|
|
68
|
+
|
|
46
69
|
var tagRender = function tagRender(props) {
|
|
47
70
|
var label = props.label,
|
|
48
71
|
res = _objectWithoutProperties(props, _excluded);
|
|
@@ -69,10 +92,15 @@ var BizMultipleSelector = function BizMultipleSelector(props) {
|
|
|
69
92
|
width: '100%'
|
|
70
93
|
},
|
|
71
94
|
placeholder: placeholder,
|
|
72
|
-
|
|
95
|
+
value: multiValue,
|
|
73
96
|
menuItemSelectedIcon: null,
|
|
74
97
|
listHeight: 400,
|
|
75
|
-
onChange: onChange
|
|
98
|
+
onChange: function onChange(data) {
|
|
99
|
+
setMultiValue(function () {
|
|
100
|
+
return _toConsumableArray(data);
|
|
101
|
+
});
|
|
102
|
+
_onChange && _onChange(data);
|
|
103
|
+
},
|
|
76
104
|
optionLabelProp: "label",
|
|
77
105
|
tagRender: tagRender,
|
|
78
106
|
onFocus: function onFocus() {
|
package/es/select/demo/index.js
CHANGED
package/es/select/index.d.ts
CHANGED
|
@@ -6,11 +6,19 @@ interface fieldNamesProps {
|
|
|
6
6
|
value: string;
|
|
7
7
|
}
|
|
8
8
|
interface BizSelectProps {
|
|
9
|
+
/**
|
|
10
|
+
* @description 自定义节点
|
|
11
|
+
* @default { label: 'label', value: 'value' }
|
|
12
|
+
*/
|
|
9
13
|
fieldNames?: fieldNamesProps;
|
|
14
|
+
/**
|
|
15
|
+
* @description 默认值
|
|
16
|
+
* @default -
|
|
17
|
+
*/
|
|
10
18
|
defaultValue?: string | number;
|
|
11
19
|
/**
|
|
12
20
|
* @description 下拉名称
|
|
13
|
-
* @default
|
|
21
|
+
* @default '''
|
|
14
22
|
*/
|
|
15
23
|
name?: string;
|
|
16
24
|
/**
|
package/es/select/index.js
CHANGED
|
@@ -141,12 +141,14 @@ var BizSelect = function BizSelect(props) {
|
|
|
141
141
|
setSelectValue(function () {
|
|
142
142
|
return value;
|
|
143
143
|
});
|
|
144
|
-
_onChange && _onChange(value, option);
|
|
144
|
+
_onChange && _onChange(value, option.data);
|
|
145
145
|
}
|
|
146
146
|
}), currentOption.map(function (item) {
|
|
147
147
|
return /*#__PURE__*/React.createElement(Option, {
|
|
148
148
|
value: item[fieldNames.value] || item,
|
|
149
|
-
key: item[fieldNames.value] || item
|
|
149
|
+
key: item[fieldNames.value] || item,
|
|
150
|
+
disabled: item.disabled,
|
|
151
|
+
data: item
|
|
150
152
|
}, item.icon && /*#__PURE__*/React.createElement(IconFont, {
|
|
151
153
|
style: {
|
|
152
154
|
marginRight: '7px',
|
package/es/table/demo/index2.js
CHANGED
|
@@ -1,9 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
|
|
3
|
+
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."); }
|
|
4
|
+
|
|
5
|
+
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); }
|
|
6
|
+
|
|
7
|
+
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; }
|
|
8
|
+
|
|
9
|
+
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; }
|
|
10
|
+
|
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
|
|
13
|
+
import React, { useEffect, useState } from 'react';
|
|
2
14
|
import { BizTable } from '@zgfe/business-lib';
|
|
3
|
-
import
|
|
15
|
+
import { columns } from './data/table';
|
|
4
16
|
export default (function () {
|
|
17
|
+
var _useState = useState([]),
|
|
18
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
19
|
+
tableData = _useState2[0],
|
|
20
|
+
setTableData = _useState2[1];
|
|
21
|
+
|
|
22
|
+
var getData = function getData(pagination) {
|
|
23
|
+
var current = pagination && pagination.current || 0;
|
|
24
|
+
var data = [];
|
|
25
|
+
|
|
26
|
+
for (var i = 0; i < 10; i++) {
|
|
27
|
+
data.push({
|
|
28
|
+
key: current * 10 + i,
|
|
29
|
+
name: "Edrward ".concat(current * 10 + i),
|
|
30
|
+
age: 32,
|
|
31
|
+
address: "London Park no. ".concat(current * 10 + i)
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
setTableData(function () {
|
|
36
|
+
return data;
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
useEffect(function () {
|
|
41
|
+
getData();
|
|
42
|
+
}, []);
|
|
5
43
|
return /*#__PURE__*/React.createElement(BizTable, {
|
|
6
44
|
columns: columns,
|
|
7
|
-
dataSource: tableData
|
|
45
|
+
dataSource: tableData,
|
|
46
|
+
total: 1000,
|
|
47
|
+
onChange: function onChange(pagination) {
|
|
48
|
+
return getData(pagination);
|
|
49
|
+
}
|
|
8
50
|
});
|
|
9
51
|
});
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
|
|
3
|
+
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."); }
|
|
4
|
+
|
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
+
|
|
7
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
8
|
+
|
|
9
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
|
+
|
|
11
|
+
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."); }
|
|
12
|
+
|
|
13
|
+
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); }
|
|
14
|
+
|
|
15
|
+
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; }
|
|
16
|
+
|
|
17
|
+
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; }
|
|
18
|
+
|
|
19
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
|
+
|
|
21
|
+
import React, { useEffect, useState } from 'react';
|
|
22
|
+
import { BizTable } from '@zgfe/business-lib';
|
|
23
|
+
var dataSource2 = [{
|
|
24
|
+
key: 1,
|
|
25
|
+
attr1: 10,
|
|
26
|
+
attr2: 100,
|
|
27
|
+
attr3: 42,
|
|
28
|
+
name: '指标1',
|
|
29
|
+
val1: 22,
|
|
30
|
+
val2: 21
|
|
31
|
+
}, {
|
|
32
|
+
key: 2,
|
|
33
|
+
attr1: 10,
|
|
34
|
+
attr2: 300,
|
|
35
|
+
attr3: 42,
|
|
36
|
+
name: '指标2',
|
|
37
|
+
val1: 22,
|
|
38
|
+
val2: 21
|
|
39
|
+
}, {
|
|
40
|
+
key: 3,
|
|
41
|
+
attr1: 10,
|
|
42
|
+
attr2: 100,
|
|
43
|
+
attr3: 40,
|
|
44
|
+
name: '指标3',
|
|
45
|
+
val1: 22,
|
|
46
|
+
val2: 21
|
|
47
|
+
}, {
|
|
48
|
+
key: 4,
|
|
49
|
+
attr1: 20,
|
|
50
|
+
attr2: 200,
|
|
51
|
+
attr3: 40,
|
|
52
|
+
name: '指标4',
|
|
53
|
+
val1: 22,
|
|
54
|
+
val2: 21
|
|
55
|
+
}, {
|
|
56
|
+
key: 5,
|
|
57
|
+
attr1: 20,
|
|
58
|
+
attr2: 200,
|
|
59
|
+
attr3: 40,
|
|
60
|
+
name: '指标5',
|
|
61
|
+
val1: 22,
|
|
62
|
+
val2: 21
|
|
63
|
+
}, {
|
|
64
|
+
key: 6,
|
|
65
|
+
attr1: 30,
|
|
66
|
+
attr2: 220,
|
|
67
|
+
attr3: 40,
|
|
68
|
+
name: '指标6',
|
|
69
|
+
val1: 22,
|
|
70
|
+
val2: 21
|
|
71
|
+
}, {
|
|
72
|
+
key: 7,
|
|
73
|
+
attr1: 40,
|
|
74
|
+
attr2: 220,
|
|
75
|
+
attr3: 40,
|
|
76
|
+
name: '指标7',
|
|
77
|
+
val1: 22,
|
|
78
|
+
val2: 21
|
|
79
|
+
}, {
|
|
80
|
+
key: 8,
|
|
81
|
+
attr1: 50,
|
|
82
|
+
attr2: 300,
|
|
83
|
+
attr3: 40,
|
|
84
|
+
name: '指标8',
|
|
85
|
+
val1: 22,
|
|
86
|
+
val2: 21
|
|
87
|
+
}, {
|
|
88
|
+
key: 9,
|
|
89
|
+
attr1: 50,
|
|
90
|
+
attr2: 300,
|
|
91
|
+
attr3: 40,
|
|
92
|
+
name: '指标9',
|
|
93
|
+
val1: 22,
|
|
94
|
+
val2: 21
|
|
95
|
+
}, {
|
|
96
|
+
key: 10,
|
|
97
|
+
attr1: 50,
|
|
98
|
+
attr2: 20,
|
|
99
|
+
attr3: 40,
|
|
100
|
+
name: '指标10',
|
|
101
|
+
val1: 22,
|
|
102
|
+
val2: 21
|
|
103
|
+
}];
|
|
104
|
+
var column2 = [{
|
|
105
|
+
title: '属性一',
|
|
106
|
+
dataIndex: 'attr1',
|
|
107
|
+
onCell: function onCell(row) {
|
|
108
|
+
return {
|
|
109
|
+
rowSpan: row.attr1RowSpan
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
}, {
|
|
113
|
+
title: '属性二',
|
|
114
|
+
dataIndex: 'attr2',
|
|
115
|
+
onCell: function onCell(row) {
|
|
116
|
+
return {
|
|
117
|
+
rowSpan: row.attr2RowSpan
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}, {
|
|
121
|
+
title: '属性三',
|
|
122
|
+
dataIndex: 'attr3',
|
|
123
|
+
onCell: function onCell(row) {
|
|
124
|
+
return {
|
|
125
|
+
rowSpan: row.attr3RowSpan
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}, {
|
|
129
|
+
title: '名称',
|
|
130
|
+
dataIndex: 'name'
|
|
131
|
+
}, {
|
|
132
|
+
title: '值1',
|
|
133
|
+
dataIndex: 'val1'
|
|
134
|
+
}, {
|
|
135
|
+
title: '值2',
|
|
136
|
+
dataIndex: 'val2'
|
|
137
|
+
}];
|
|
138
|
+
export default (function () {
|
|
139
|
+
var _useState = useState([]),
|
|
140
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
141
|
+
tableData = _useState2[0],
|
|
142
|
+
setTableData = _useState2[1]; // 排序
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
var sortData = function sortData(data) {
|
|
146
|
+
var compare = function compare(a, b) {
|
|
147
|
+
if (a.attr1 !== b.attr1) {
|
|
148
|
+
return a.attr1 - b.attr1;
|
|
149
|
+
} else if (a.attr2 !== b.attr2) {
|
|
150
|
+
return a.attr2 - b.attr2;
|
|
151
|
+
} else {
|
|
152
|
+
return a.attr3 - b.attr3;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
data.sort(compare);
|
|
157
|
+
console.log('sort after>>', data);
|
|
158
|
+
return data;
|
|
159
|
+
}; // 获取合并行数
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
var mergeRow = function mergeRow(source, field, field2, field3) {
|
|
163
|
+
var count = 0,
|
|
164
|
+
scount = 0,
|
|
165
|
+
tcount = 0; //重复项的第一项,第二项,第三项
|
|
166
|
+
|
|
167
|
+
var indexCount = 1; //下一项
|
|
168
|
+
|
|
169
|
+
var data = JSON.parse(JSON.stringify(source));
|
|
170
|
+
|
|
171
|
+
while (indexCount < data.length) {
|
|
172
|
+
var item = data.slice(count, count + 1)[0]; //获取没有比较的第一个对象
|
|
173
|
+
|
|
174
|
+
if (!item["".concat(field, "RowSpan")]) {
|
|
175
|
+
item["".concat(field, "RowSpan")] = 1; //初始化为1
|
|
176
|
+
|
|
177
|
+
item["".concat(field2, "RowSpan")] = 1; //初始化为1
|
|
178
|
+
|
|
179
|
+
item["".concat(field3, "RowSpan")] = 1; //初始化为1
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (item[field] === data[indexCount][field]) {
|
|
183
|
+
//第一个对象与后面的对象相比,有相同项就累加,并且后面相同项设置为0
|
|
184
|
+
item["".concat(field, "RowSpan")]++;
|
|
185
|
+
data[indexCount]["".concat(field, "RowSpan")] = 0; // 第二项比较
|
|
186
|
+
|
|
187
|
+
if (data[scount][field2] === data[indexCount][field2]) {
|
|
188
|
+
data[scount]["".concat(field2, "RowSpan")]++;
|
|
189
|
+
data[indexCount]["".concat(field2, "RowSpan")] = 0;
|
|
190
|
+
|
|
191
|
+
if (data[tcount][field3] === data[indexCount][field3]) {
|
|
192
|
+
data[tcount]["".concat(field3, "RowSpan")]++;
|
|
193
|
+
data[indexCount]["".concat(field3, "RowSpan")] = 0;
|
|
194
|
+
} else {
|
|
195
|
+
data[indexCount]["".concat(field3, "RowSpan")] = 1;
|
|
196
|
+
tcount = indexCount;
|
|
197
|
+
}
|
|
198
|
+
} else {
|
|
199
|
+
data[indexCount]["".concat(field2, "RowSpan")] = 1;
|
|
200
|
+
data[indexCount]["".concat(field3, "RowSpan")] = 1;
|
|
201
|
+
scount = indexCount;
|
|
202
|
+
tcount = indexCount;
|
|
203
|
+
}
|
|
204
|
+
} else {
|
|
205
|
+
count = indexCount;
|
|
206
|
+
scount = indexCount;
|
|
207
|
+
tcount = indexCount;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
indexCount++;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
console.log('for>>', data);
|
|
214
|
+
return data;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
useEffect(function () {
|
|
218
|
+
var data = mergeRow(sortData(dataSource2), 'attr1', 'attr2', 'attr3');
|
|
219
|
+
setTableData(function () {
|
|
220
|
+
return _toConsumableArray(data);
|
|
221
|
+
});
|
|
222
|
+
}, []);
|
|
223
|
+
return /*#__PURE__*/React.createElement(BizTable, {
|
|
224
|
+
dataSource: tableData,
|
|
225
|
+
columns: column2
|
|
226
|
+
});
|
|
227
|
+
});
|
package/es/table/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { AttrGroup } from '../type';
|
|
3
3
|
import './style/group.less';
|
|
4
4
|
interface ConditionGroupProps {
|
|
5
5
|
/**
|
|
@@ -7,7 +7,7 @@ interface ConditionGroupProps {
|
|
|
7
7
|
* @description.zh-CN
|
|
8
8
|
* @default
|
|
9
9
|
*/
|
|
10
|
-
defaultValue?:
|
|
10
|
+
defaultValue?: AttrGroup;
|
|
11
11
|
/**
|
|
12
12
|
* @description 属性配置项
|
|
13
13
|
* @description.zh-CN
|
|
@@ -18,13 +18,13 @@ interface ConditionGroupProps {
|
|
|
18
18
|
* @description 如果是事件属性,则传事件id,多个用逗号隔开
|
|
19
19
|
* @default -
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
eventId?: string | number;
|
|
22
22
|
/**
|
|
23
23
|
* @description 参数改变回调
|
|
24
24
|
* @description.zh-CN
|
|
25
25
|
* @default
|
|
26
26
|
*/
|
|
27
|
-
onChange?: (data:
|
|
27
|
+
onChange?: (data: AttrGroup) => void;
|
|
28
28
|
}
|
|
29
29
|
declare const BizConditionGroup: React.FC<ConditionGroupProps>;
|
|
30
30
|
export default BizConditionGroup;
|
|
@@ -32,44 +32,45 @@ import util from '../../utils/util';
|
|
|
32
32
|
var BizConditionGroup = function BizConditionGroup(props) {
|
|
33
33
|
var _props$defaultValue = props.defaultValue,
|
|
34
34
|
defaultValue = _props$defaultValue === void 0 ? {
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
relation: 'and',
|
|
36
|
+
conditions: []
|
|
37
37
|
} : _props$defaultValue,
|
|
38
38
|
options = props.options,
|
|
39
|
-
|
|
39
|
+
eventId = props.eventId,
|
|
40
40
|
_onChange = props.onChange;
|
|
41
41
|
|
|
42
|
-
var _useState = useState(
|
|
42
|
+
var _useState = useState([]),
|
|
43
43
|
_useState2 = _slicedToArray(_useState, 2),
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
conditions = _useState2[0],
|
|
45
|
+
setConditions = _useState2[1];
|
|
46
46
|
|
|
47
|
-
var _useState3 = useState(
|
|
47
|
+
var _useState3 = useState('and'),
|
|
48
48
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
49
49
|
operate = _useState4[0],
|
|
50
50
|
setOperate = _useState4[1];
|
|
51
51
|
|
|
52
52
|
useEffect(function () {
|
|
53
|
-
if (util.equal(
|
|
54
|
-
|
|
55
|
-
return defaultValue.
|
|
53
|
+
if (util.equal(conditions, defaultValue.conditions)) return;
|
|
54
|
+
setConditions(function () {
|
|
55
|
+
return defaultValue.conditions ? _toConsumableArray(defaultValue.conditions) : [];
|
|
56
56
|
});
|
|
57
|
+
setOperate(defaultValue.relation || 'and');
|
|
57
58
|
}, [defaultValue]);
|
|
58
59
|
return /*#__PURE__*/React.createElement("div", {
|
|
59
60
|
className: "biz-attr-group-container"
|
|
60
61
|
}, /*#__PURE__*/React.createElement("div", {
|
|
61
62
|
className: "biz-attr-group-operate"
|
|
62
|
-
},
|
|
63
|
+
}, conditions.length > 1 && /*#__PURE__*/React.createElement("div", {
|
|
63
64
|
className: "biz-attr-operate",
|
|
64
65
|
onClick: function onClick(e) {
|
|
65
66
|
e.stopPropagation();
|
|
66
|
-
var
|
|
67
|
+
var relation = e.target.innerText === '且' ? 'and' : 'or';
|
|
67
68
|
setOperate(function () {
|
|
68
|
-
return
|
|
69
|
+
return relation;
|
|
69
70
|
});
|
|
70
71
|
_onChange && _onChange({
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
relation: relation,
|
|
73
|
+
conditions: conditions
|
|
73
74
|
});
|
|
74
75
|
}
|
|
75
76
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -78,28 +79,28 @@ var BizConditionGroup = function BizConditionGroup(props) {
|
|
|
78
79
|
className: operate === 'or' ? 'active' : ''
|
|
79
80
|
}, "\u6216"))), /*#__PURE__*/React.createElement("div", {
|
|
80
81
|
className: "biz-attr-group-content"
|
|
81
|
-
},
|
|
82
|
+
}, conditions.map(function (item, index) {
|
|
82
83
|
return /*#__PURE__*/React.createElement(BizConditionItem, {
|
|
83
|
-
key: item.
|
|
84
|
+
key: item.key || index,
|
|
84
85
|
options: options,
|
|
85
|
-
|
|
86
|
-
defaultValue: item
|
|
86
|
+
eventId: eventId,
|
|
87
|
+
defaultValue: item,
|
|
87
88
|
onDelete: function onDelete() {
|
|
88
|
-
|
|
89
|
+
setConditions(function (data) {
|
|
89
90
|
data.splice(index, 1);
|
|
90
91
|
_onChange && _onChange({
|
|
91
|
-
|
|
92
|
-
|
|
92
|
+
relation: operate,
|
|
93
|
+
conditions: _toConsumableArray(data)
|
|
93
94
|
});
|
|
94
95
|
return _toConsumableArray(data);
|
|
95
96
|
});
|
|
96
97
|
},
|
|
97
98
|
onChange: function onChange(data) {
|
|
98
|
-
|
|
99
|
-
attr[index]
|
|
99
|
+
setConditions(function (attr) {
|
|
100
|
+
attr[index] = _objectSpread({}, data);
|
|
100
101
|
_onChange && _onChange({
|
|
101
|
-
|
|
102
|
-
|
|
102
|
+
relation: operate,
|
|
103
|
+
conditions: _toConsumableArray(attr)
|
|
103
104
|
});
|
|
104
105
|
return _toConsumableArray(attr);
|
|
105
106
|
});
|