@zgfe/business-lib 1.0.0-beta.2 → 1.0.0-beta.5
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/chart/demo/bar.js +0 -1
- 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 +13 -9
- package/es/chart/index.js +17 -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} +67 -2
- package/es/chart/{chartConfig.js → util/chartConfig.js} +76 -5
- 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/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 +123 -53
- package/es/dialog/style/index.less +8 -0
- 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/data/operates.js +5 -5
- package/package.json +1 -1
package/es/dialog/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
var _excluded = ["width", "title", "initialValues", "fields", "visible", "showMark", "layout", "onOk", "onCancel"];
|
|
2
2
|
|
|
3
|
-
function
|
|
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; }
|
|
3
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
6
4
|
|
|
7
5
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
8
6
|
|
|
@@ -24,6 +22,10 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
24
22
|
|
|
25
23
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
26
24
|
|
|
25
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
26
|
+
|
|
27
|
+
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; }
|
|
28
|
+
|
|
27
29
|
import { Form, Input, Modal, Radio, Space } from 'antd';
|
|
28
30
|
import React, { useEffect, useState } from 'react';
|
|
29
31
|
import BizSelectToInput from './components/selectToInput';
|
|
@@ -45,7 +47,8 @@ var BizDialog = function BizDialog(props) {
|
|
|
45
47
|
_props$layout = props.layout,
|
|
46
48
|
layout = _props$layout === void 0 ? 'horizontal' : _props$layout,
|
|
47
49
|
_onOk = props.onOk,
|
|
48
|
-
_onCancel = props.onCancel
|
|
50
|
+
_onCancel = props.onCancel,
|
|
51
|
+
res = _objectWithoutProperties(props, _excluded);
|
|
49
52
|
|
|
50
53
|
var _Form$useForm = Form.useForm(),
|
|
51
54
|
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
@@ -56,74 +59,74 @@ var BizDialog = function BizDialog(props) {
|
|
|
56
59
|
formFields = _useState2[0],
|
|
57
60
|
setFormFields = _useState2[1];
|
|
58
61
|
|
|
59
|
-
var getFormItem = function getFormItem(
|
|
60
|
-
var type =
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
var getFormItem = function getFormItem(_ref) {
|
|
63
|
+
var type = _ref.type,
|
|
64
|
+
label = _ref.label,
|
|
65
|
+
options = _ref.options,
|
|
66
|
+
placeholder = _ref.placeholder,
|
|
67
|
+
_ref$fieldNames = _ref.fieldNames,
|
|
68
|
+
fieldNames = _ref$fieldNames === void 0 ? {
|
|
69
|
+
label: 'label',
|
|
70
|
+
value: 'value'
|
|
71
|
+
} : _ref$fieldNames,
|
|
72
|
+
extendName = _ref.extendName,
|
|
73
|
+
direction = _ref.direction,
|
|
74
|
+
onChange = _ref.onChange;
|
|
63
75
|
|
|
64
76
|
if (type === 'selectToInput') {
|
|
65
77
|
return /*#__PURE__*/React.createElement(BizSelectToInput, {
|
|
66
|
-
name:
|
|
78
|
+
name: label,
|
|
67
79
|
options: options,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
var arr = [];
|
|
73
|
-
fields.forEach(function (item) {
|
|
74
|
-
var field = _objectSpread({}, item);
|
|
75
|
-
|
|
76
|
-
if (children.indexOf(item.name) > -1) {
|
|
77
|
-
field.hidden = isSelect;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
arr.push(field);
|
|
81
|
-
});
|
|
82
|
-
setFormFields(function () {
|
|
83
|
-
return [].concat(arr);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
}
|
|
80
|
+
fieldNames: fieldNames,
|
|
81
|
+
extendName: extendName,
|
|
82
|
+
onChange: onChange
|
|
87
83
|
});
|
|
88
84
|
} else if (type === 'select') {
|
|
89
85
|
return /*#__PURE__*/React.createElement(BizSelect, {
|
|
90
86
|
options: options,
|
|
91
|
-
name:
|
|
92
|
-
size: "middle"
|
|
87
|
+
name: label,
|
|
88
|
+
size: "middle",
|
|
89
|
+
onChange: onChange
|
|
93
90
|
});
|
|
94
91
|
} else if (type === 'input') {
|
|
95
92
|
return /*#__PURE__*/React.createElement(Input, {
|
|
96
93
|
className: "biz-input",
|
|
97
|
-
placeholder:
|
|
94
|
+
placeholder: placeholder || "\u8BF7\u8F93\u5165".concat(label),
|
|
98
95
|
autoComplete: "off",
|
|
99
96
|
allowClear: {
|
|
100
97
|
clearIcon: /*#__PURE__*/React.createElement(IconFont, {
|
|
101
98
|
className: "biz-icon",
|
|
102
99
|
type: 'icon-qingchu'
|
|
103
100
|
})
|
|
104
|
-
}
|
|
101
|
+
},
|
|
102
|
+
onChange: onChange
|
|
105
103
|
});
|
|
106
104
|
} else if (type === 'password') {
|
|
107
105
|
return /*#__PURE__*/React.createElement(Input.Password, {
|
|
108
106
|
className: "biz-input",
|
|
109
|
-
placeholder:
|
|
107
|
+
placeholder: placeholder || "\u8BF7\u8F93\u5165".concat(label),
|
|
108
|
+
onChange: onChange
|
|
110
109
|
});
|
|
111
110
|
} else if (type === 'tab') {
|
|
112
111
|
return /*#__PURE__*/React.createElement(BizTab, {
|
|
113
|
-
options: options
|
|
112
|
+
options: options,
|
|
113
|
+
onChange: onChange
|
|
114
114
|
});
|
|
115
115
|
} else if (type === 'radio') {
|
|
116
|
-
return /*#__PURE__*/React.createElement(Radio.Group,
|
|
117
|
-
|
|
118
|
-
},
|
|
116
|
+
return /*#__PURE__*/React.createElement(Radio.Group, {
|
|
117
|
+
onChange: onChange
|
|
118
|
+
}, /*#__PURE__*/React.createElement(Space, {
|
|
119
|
+
direction: direction || 'horizontal'
|
|
120
|
+
}, options && options.map(function (item) {
|
|
119
121
|
return /*#__PURE__*/React.createElement(Radio, {
|
|
120
|
-
key: item.value,
|
|
121
|
-
value: item.value
|
|
122
|
-
}, item.label);
|
|
122
|
+
key: item[fieldNames.value],
|
|
123
|
+
value: item[fieldNames.value]
|
|
124
|
+
}, item[fieldNames.label]);
|
|
123
125
|
})));
|
|
124
126
|
} else if (type === 'list') {
|
|
125
127
|
return /*#__PURE__*/React.createElement(BizList, {
|
|
126
|
-
options: options.length > 0 ? options : undefined
|
|
128
|
+
options: options && options.length > 0 ? options : undefined,
|
|
129
|
+
onChange: onChange
|
|
127
130
|
});
|
|
128
131
|
}
|
|
129
132
|
};
|
|
@@ -171,17 +174,84 @@ var BizDialog = function BizDialog(props) {
|
|
|
171
174
|
initialValues: initialValues,
|
|
172
175
|
layout: layout
|
|
173
176
|
}, formFields === null || formFields === void 0 ? void 0 : formFields.map(function (item, index) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
177
|
+
// 判断是否有依赖项,如果依赖项的值符合,则展示,否则不展示
|
|
178
|
+
if (item.dependenceFields && Object.keys(item.dependenceFields).length > 0) {
|
|
179
|
+
var keys = Object.keys(item.dependenceFields);
|
|
180
|
+
var dependenceFields = item.dependenceFields;
|
|
181
|
+
return /*#__PURE__*/React.createElement(Form.Item, {
|
|
182
|
+
key: item.name,
|
|
183
|
+
noStyle: true,
|
|
184
|
+
shouldUpdate: function shouldUpdate(prevValues, curValues) {
|
|
185
|
+
var flag = false;
|
|
186
|
+
|
|
187
|
+
var _iterator = _createForOfIteratorHelper(keys),
|
|
188
|
+
_step;
|
|
189
|
+
|
|
190
|
+
try {
|
|
191
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
192
|
+
var key = _step.value;
|
|
193
|
+
|
|
194
|
+
if (prevValues[key] !== curValues[key]) {
|
|
195
|
+
flag = true;
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
} catch (err) {
|
|
200
|
+
_iterator.e(err);
|
|
201
|
+
} finally {
|
|
202
|
+
_iterator.f();
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return flag;
|
|
206
|
+
}
|
|
207
|
+
}, function (_ref2) {
|
|
208
|
+
var getFieldValue = _ref2.getFieldValue;
|
|
209
|
+
var flag = true;
|
|
210
|
+
|
|
211
|
+
var _iterator2 = _createForOfIteratorHelper(keys),
|
|
212
|
+
_step2;
|
|
213
|
+
|
|
214
|
+
try {
|
|
215
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
216
|
+
var key = _step2.value;
|
|
217
|
+
|
|
218
|
+
if (getFieldValue(key) !== dependenceFields[key]) {
|
|
219
|
+
flag = false;
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
} catch (err) {
|
|
224
|
+
_iterator2.e(err);
|
|
225
|
+
} finally {
|
|
226
|
+
_iterator2.f();
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return flag ? /*#__PURE__*/React.createElement(Form.Item, {
|
|
230
|
+
label: item.label,
|
|
231
|
+
name: item.name,
|
|
232
|
+
hidden: item.hidden,
|
|
233
|
+
rules: item.rules,
|
|
234
|
+
help: item.help,
|
|
235
|
+
wrapperCol: {
|
|
236
|
+
offset: !item.label && layout === 'horizontal' ? 2 : 0
|
|
237
|
+
},
|
|
238
|
+
shouldUpdate: true
|
|
239
|
+
}, getFormItem(item)) : null;
|
|
240
|
+
});
|
|
241
|
+
} else {
|
|
242
|
+
return /*#__PURE__*/React.createElement(Form.Item, {
|
|
243
|
+
key: item.name,
|
|
244
|
+
label: item.label,
|
|
245
|
+
name: item.name,
|
|
246
|
+
hidden: item.hidden,
|
|
247
|
+
rules: item.rules,
|
|
248
|
+
help: item.help,
|
|
249
|
+
wrapperCol: {
|
|
250
|
+
offset: !item.label && layout === 'horizontal' ? 2 : 0
|
|
251
|
+
},
|
|
252
|
+
shouldUpdate: true
|
|
253
|
+
}, getFormItem(item));
|
|
254
|
+
}
|
|
185
255
|
})));
|
|
186
256
|
};
|
|
187
257
|
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
&.ant-form-horizontal .ant-form-item-label > label {
|
|
45
45
|
height: 40px;
|
|
46
46
|
}
|
|
47
|
+
|
|
47
48
|
&.ant-form-vertical .ant-form-item-label {
|
|
48
49
|
margin-bottom: 12px;
|
|
49
50
|
color: @titleColor;
|
|
@@ -74,3 +75,10 @@
|
|
|
74
75
|
max-height: 400px;
|
|
75
76
|
overflow: auto;
|
|
76
77
|
}
|
|
78
|
+
|
|
79
|
+
.biz-form-radio {
|
|
80
|
+
width: 100%;
|
|
81
|
+
height: 40px;
|
|
82
|
+
color: @titleColor;
|
|
83
|
+
line-height: 40px;
|
|
84
|
+
}
|
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
|
@@ -72,13 +72,13 @@ export var dimensionOperate = [{
|
|
|
72
72
|
value: 'number'
|
|
73
73
|
}, {
|
|
74
74
|
name: '次数',
|
|
75
|
-
value: '
|
|
75
|
+
value: 'times'
|
|
76
76
|
}, {
|
|
77
77
|
name: '活跃比',
|
|
78
|
-
value: '
|
|
78
|
+
value: 'active_ratio'
|
|
79
79
|
}, {
|
|
80
80
|
name: '人均次数',
|
|
81
|
-
value: '
|
|
81
|
+
value: 'per'
|
|
82
82
|
}, {
|
|
83
83
|
name: '金额',
|
|
84
84
|
value: 'money',
|
|
@@ -87,10 +87,10 @@ export var dimensionOperate = [{
|
|
|
87
87
|
value: 'sum'
|
|
88
88
|
}, {
|
|
89
89
|
name: '均值',
|
|
90
|
-
value: '
|
|
90
|
+
value: 'avg'
|
|
91
91
|
}, {
|
|
92
92
|
name: '分布',
|
|
93
|
-
value: '
|
|
93
|
+
value: 'duration_times'
|
|
94
94
|
}, {
|
|
95
95
|
name: '中位数',
|
|
96
96
|
value: 'median'
|