@zgfe/business-lib 1.0.0-beta.4 → 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.
@@ -108,7 +108,9 @@ var BizAnalysisLayout = function BizAnalysisLayout(props) {
108
108
  }
109
109
  }, /*#__PURE__*/React.createElement("div", {
110
110
  className: "biz-layout-panel"
111
- }, leftPanel), /*#__PURE__*/React.createElement("div", {
111
+ }, /*#__PURE__*/React.createElement("div", {
112
+ className: "biz-left-content"
113
+ }, leftPanel)), /*#__PURE__*/React.createElement("div", {
112
114
  className: "biz-layout-bottom"
113
115
  }, leftHandle)), showLeft ? /*#__PURE__*/React.createElement(Tooltip, {
114
116
  title: function title() {
@@ -5,8 +5,7 @@
5
5
  display: flex;
6
6
  width: 100%;
7
7
  height: 100%;
8
- min-height: 900px;
9
- overflow-y: auto;
8
+ overflow: hidden;
10
9
 
11
10
  .biz-layout-left {
12
11
  position: relative;
@@ -35,6 +34,9 @@
35
34
  height: calc(100% - 30px);
36
35
  padding: @searchPadding;
37
36
  overflow: auto;
37
+ .biz-left-content {
38
+ min-height: 600px;
39
+ }
38
40
  }
39
41
 
40
42
  .biz-layout-bottom {
@@ -64,13 +66,13 @@
64
66
  .biz-layout-right {
65
67
  box-sizing: border-box;
66
68
  padding: @contentPadding;
67
- overflow-x: auto;
68
- overflow-y: hidden;
69
+ overflow: auto;
69
70
  background-color: #fff;
70
71
 
71
72
  .biz-right-content {
72
73
  min-width: 600px;
73
74
  height: 100%;
75
+ min-height: 600px;
74
76
  }
75
77
  }
76
78
  }
@@ -1,6 +1,9 @@
1
1
  import React from 'react';
2
2
  import { SelectProps } from 'antd';
3
3
  import '../style/index.less';
4
+ interface ValueType {
5
+ [prop: string]: any;
6
+ }
4
7
  interface fieldNamesProps {
5
8
  label: string;
6
9
  value: string;
@@ -12,6 +15,11 @@ interface SelectInputProps extends SelectProps {
12
15
  * @default false
13
16
  */
14
17
  name?: string;
18
+ /**
19
+ * @description 扩展名称
20
+ * @default -
21
+ */
22
+ extendName?: string;
15
23
  /**
16
24
  * @description 创建option回调
17
25
  * @default false
@@ -31,13 +39,12 @@ interface SelectInputProps extends SelectProps {
31
39
  * @description 默认值
32
40
  * @default false
33
41
  */
34
- value?: string | number;
42
+ value?: ValueType;
35
43
  /**
36
44
  * @description 值改变回调
37
45
  * @default -
38
46
  */
39
- onChange?: (value?: string | number) => void;
40
- onChangeType?: (type: boolean) => void;
47
+ onChange?: (value?: ValueType) => void;
41
48
  }
42
49
  declare const BizSelectToInput: React.FC<SelectInputProps>;
43
50
  export default BizSelectToInput;
@@ -1,4 +1,4 @@
1
- var _excluded = ["options", "search", "create", "name", "value", "onChange", "onChangeType"];
1
+ var _excluded = ["options", "search", "create", "name", "extendName", "fieldNames", "value", "onChange"];
2
2
 
3
3
  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; }
4
4
 
@@ -25,8 +25,19 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
25
25
  import React, { useEffect, useState } from 'react';
26
26
  import { BizSelect } from '../..';
27
27
  import IconFont from '../../components/iconFont';
28
- import { Input } from 'antd';
28
+ import { Input, Radio, Space, Tooltip } from 'antd';
29
29
  import '../style/index.less';
30
+ var inputOptions = [{
31
+ label: '公开',
32
+ value: 1
33
+ }, {
34
+ label: '指定人员明显',
35
+ value: 2,
36
+ title: '通过看板的共享功能指定可见成员'
37
+ }, {
38
+ label: '仅自己可见',
39
+ value: 3
40
+ }];
30
41
 
31
42
  var BizSelectToInput = function BizSelectToInput(props) {
32
43
  var options = props.options,
@@ -36,9 +47,14 @@ var BizSelectToInput = function BizSelectToInput(props) {
36
47
  create = _props$create === void 0 ? true : _props$create,
37
48
  _props$name = props.name,
38
49
  name = _props$name === void 0 ? '' : _props$name,
50
+ extendName = props.extendName,
51
+ _props$fieldNames = props.fieldNames,
52
+ fieldNames = _props$fieldNames === void 0 ? {
53
+ label: 'label',
54
+ value: 'value'
55
+ } : _props$fieldNames,
39
56
  value = props.value,
40
57
  _onChange = props.onChange,
41
- onChangeType = props.onChangeType,
42
58
  res = _objectWithoutProperties(props, _excluded);
43
59
 
44
60
  var _useState = useState(true),
@@ -56,26 +72,53 @@ var BizSelectToInput = function BizSelectToInput(props) {
56
72
  isFirst = _useState6[0],
57
73
  setIsFirst = _useState6[1];
58
74
 
75
+ var _useState7 = useState(3),
76
+ _useState8 = _slicedToArray(_useState7, 2),
77
+ radioData = _useState8[0],
78
+ setRadioData = _useState8[1];
79
+
80
+ var _useState9 = useState(''),
81
+ _useState10 = _slicedToArray(_useState9, 2),
82
+ inputData = _useState10[0],
83
+ setInputData = _useState10[1];
84
+
59
85
  useEffect(function () {
60
86
  if (isFirst) {
61
87
  setIsFirst(false);
62
88
  return;
63
89
  }
64
90
 
65
- onChangeType && onChangeType(isSelect);
66
-
67
91
  if (isSelect) {
68
92
  _onChange && _onChange(selectValue);
69
93
  } else {
70
94
  _onChange && _onChange();
71
95
  }
72
96
  }, [isSelect]);
97
+ useEffect(function () {
98
+ if (isFirst) return;
99
+ var data = null;
100
+
101
+ if (inputData) {
102
+ if (extendName) {
103
+ var _data;
104
+
105
+ data = (_data = {}, _defineProperty(_data, fieldNames.value, 0), _defineProperty(_data, fieldNames.label, inputData), _defineProperty(_data, extendName, radioData), _data);
106
+ } else {
107
+ var _data2;
108
+
109
+ data = (_data2 = {}, _defineProperty(_data2, fieldNames.value, 0), _defineProperty(_data2, fieldNames.label, value), _data2);
110
+ }
111
+ }
112
+
113
+ _onChange && _onChange(data);
114
+ }, [radioData, inputData]);
73
115
  return /*#__PURE__*/React.createElement("div", null, isSelect ? /*#__PURE__*/React.createElement(BizSelect, _objectSpread(_objectSpread({
74
116
  options: options,
75
117
  search: search,
76
118
  create: create,
77
119
  size: "middle",
78
- value: selectValue,
120
+ fieldNames: fieldNames,
121
+ value: selectValue && selectValue[fieldNames.value],
79
122
  name: name
80
123
  }, res), {}, {
81
124
  createOption: function createOption() {
@@ -83,13 +126,13 @@ var BizSelectToInput = function BizSelectToInput(props) {
83
126
  return false;
84
127
  });
85
128
  },
86
- onChange: function onChange(value) {
87
- _onChange && _onChange(value);
129
+ onChange: function onChange(value, data) {
130
+ _onChange && _onChange(data);
88
131
  setSelectValue(function () {
89
- return value;
132
+ return data;
90
133
  });
91
134
  }
92
- })) : /*#__PURE__*/React.createElement("div", {
135
+ })) : /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
93
136
  className: "biz-flex"
94
137
  }, /*#__PURE__*/React.createElement(Input, {
95
138
  className: "biz-input",
@@ -102,7 +145,9 @@ var BizSelectToInput = function BizSelectToInput(props) {
102
145
  })
103
146
  },
104
147
  onBlur: function onBlur(e) {
105
- _onChange && _onChange(e.target.value);
148
+ setInputData(function () {
149
+ return e.target.value;
150
+ });
106
151
  }
107
152
  }), /*#__PURE__*/React.createElement(IconFont, {
108
153
  className: "biz-icon biz-icon-switch",
@@ -112,7 +157,25 @@ var BizSelectToInput = function BizSelectToInput(props) {
112
157
  return true;
113
158
  });
114
159
  }
115
- })));
160
+ })), extendName && /*#__PURE__*/React.createElement("div", {
161
+ className: "biz-form-radio"
162
+ }, /*#__PURE__*/React.createElement(Radio.Group, {
163
+ value: radioData,
164
+ onChange: function onChange(e) {
165
+ setRadioData(function () {
166
+ return e.target.value;
167
+ });
168
+ }
169
+ }, /*#__PURE__*/React.createElement(Space, {
170
+ direction: "horizontal"
171
+ }, inputOptions.map(function (item) {
172
+ return /*#__PURE__*/React.createElement(Radio, {
173
+ key: item.value,
174
+ value: item.value
175
+ }, item.title ? /*#__PURE__*/React.createElement(Tooltip, {
176
+ title: item.title
177
+ }, item.label) : item.label);
178
+ }))))));
116
179
  };
117
180
 
118
181
  export default BizSelectToInput;
@@ -19,34 +19,35 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
19
  import React, { useState } from 'react';
20
20
  import { BizDialog } from '@zgfe/business-lib';
21
21
  import { Button } from 'antd';
22
- var options = ['分类一', '分类二', '分类三'];
22
+ var options = [{
23
+ id: 11,
24
+ name: '分类一'
25
+ }, {
26
+ id: 22,
27
+ name: '分类二'
28
+ }, {
29
+ id: 33,
30
+ name: '分分类三一'
31
+ }];
23
32
  var chartTypes = ['趋势图', '汇总图', '地图'];
24
33
  var fields = [{
25
34
  label: '分类',
26
35
  name: 'class',
36
+ extendName: 'range',
27
37
  type: 'selectToInput',
28
38
  options: options,
29
39
  children: ['range'],
40
+ fieldNames: {
41
+ label: 'name',
42
+ value: 'id'
43
+ },
30
44
  rules: [{
31
45
  required: true,
32
46
  message: '请选择分类'
33
- }]
34
- }, {
35
- label: '',
36
- name: 'range',
37
- type: 'radio',
38
- dependencies: 'class',
39
- hidden: true,
40
- options: [{
41
- label: '公开',
42
- value: 'public'
43
- }, {
44
- label: '指定人员明显',
45
- value: 'appoint'
46
- }, {
47
- label: '仅自己可见',
48
- value: 'own'
49
- }]
47
+ }],
48
+ onChange: function onChange(val) {
49
+ console.log('select>>>', val);
50
+ }
50
51
  }, {
51
52
  label: '名称',
52
53
  name: 'name',
@@ -69,8 +70,11 @@ var fields = [{
69
70
  name: 'show',
70
71
  type: 'radio',
71
72
  direction: 'vertical',
73
+ dependenceFields: {
74
+ chart: 'line'
75
+ },
72
76
  options: [{
73
- label: '动态显示数据最多的5个分组',
77
+ label: '动态显示数据最多的10个分组',
74
78
  value: 'dynamic'
75
79
  }, {
76
80
  label: '固定显示当前选择的分组',
@@ -82,7 +86,10 @@ var fields = [{
82
86
  }]
83
87
  }];
84
88
  var formData = {
85
- class: '分类一',
89
+ class: {
90
+ id: 11,
91
+ name: '分类一'
92
+ },
86
93
  range: 'public',
87
94
  show: 'dynamic'
88
95
  };
@@ -1,6 +1,18 @@
1
1
  import { FormItemProps, ModalProps } from 'antd';
2
2
  import React from 'react';
3
+ interface BizObjectDefaultProps {
4
+ [key: string]: any;
5
+ }
6
+ interface fieldNamesProps {
7
+ label: string;
8
+ value: string;
9
+ }
3
10
  interface FieldProps {
11
+ /**
12
+ * @description form.item名称
13
+ * @default -
14
+ */
15
+ label?: string;
4
16
  /**
5
17
  * @description form.item类型
6
18
  * @default input
@@ -11,13 +23,18 @@ interface FieldProps {
11
23
  * @default -
12
24
  */
13
25
  value?: string | number;
26
+ /**
27
+ * @description form.item 依赖项及其值 {age:20}
28
+ * @default -
29
+ */
30
+ dependenceFields?: BizObjectDefaultProps;
14
31
  /**
15
32
  * @description 提示
16
33
  * @default -
17
34
  */
18
35
  placeholder?: string;
19
36
  /**
20
- * @description form.item p排列方向
37
+ * @description form.item 排列方向 'horizontal' | 'vertical'
21
38
  * @default horizontal
22
39
  */
23
40
  direction?: 'horizontal' | 'vertical';
@@ -26,11 +43,26 @@ interface FieldProps {
26
43
  * @default -
27
44
  */
28
45
  options?: Array<any>;
46
+ /**
47
+ * @description 扩展名称
48
+ * @default -
49
+ */
50
+ extendName?: string;
51
+ /**
52
+ * @description 下拉框的自定义节点 label、value
53
+ * @default { label: 'label', value: 'value' }
54
+ */
55
+ fieldNames?: fieldNamesProps;
29
56
  /**
30
57
  * @description 影响的表单项
31
58
  * @default -
32
59
  */
33
60
  children?: Array<string>;
61
+ /**
62
+ * @description 值发生改变
63
+ * @default -
64
+ */
65
+ onChange?: () => void;
34
66
  }
35
67
  interface BizDialogProps {
36
68
  /**
@@ -64,5 +96,5 @@ interface BizDialogProps {
64
96
  */
65
97
  onCancel?: () => void;
66
98
  }
67
- declare const BizDialog: React.FC<ModalProps & BizDialogProps>;
99
+ declare const BizDialog: React.FC<ModalProps & BizDialogProps & FormItemProps>;
68
100
  export default BizDialog;
@@ -1,8 +1,6 @@
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; }
1
+ var _excluded = ["width", "title", "initialValues", "fields", "visible", "showMark", "layout", "onOk", "onCancel"];
2
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; }
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(data) {
60
- var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'input';
61
- var name = arguments.length > 2 ? arguments[2] : undefined;
62
- var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
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: name,
78
+ name: label,
67
79
  options: options,
68
- onChangeType: function onChangeType(isSelect) {
69
- if (data.children && data.children.length > 0) {
70
- var children = _toConsumableArray(data.children);
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: 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: data.placeholder || "\u8BF7\u8F93\u5165".concat(name),
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: data.placeholder || "\u8BF7\u8F93\u5165".concat(name)
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, null, /*#__PURE__*/React.createElement(Space, {
117
- direction: data.direction || 'horizontal'
118
- }, options.map(function (item) {
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
- return /*#__PURE__*/React.createElement(Form.Item, {
175
- key: item.name,
176
- label: item.label,
177
- name: item.name,
178
- hidden: item.hidden,
179
- rules: item.rules,
180
- help: item.help,
181
- wrapperCol: {
182
- offset: !item.label && layout === 'horizontal' ? 2 : 0
183
- }
184
- }, getFormItem(item, item.type, item.label, item.options));
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
+ }
@@ -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 false
21
+ * @default '''
14
22
  */
15
23
  name?: string;
16
24
  /**
@@ -141,13 +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
149
  key: item[fieldNames.value] || item,
150
- disabled: item.disabled
150
+ disabled: item.disabled,
151
+ data: item
151
152
  }, item.icon && /*#__PURE__*/React.createElement(IconFont, {
152
153
  style: {
153
154
  marginRight: '7px',
@@ -1,9 +1,51 @@
1
- import React from 'react';
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 tableData, { columns } from './data/table';
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,2 @@
1
+ declare const _default: () => JSX.Element;
2
+ export default _default;
@@ -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
+ });
@@ -11,7 +11,7 @@ interface BizTableProps {
11
11
  * @description 表头
12
12
  * @default line
13
13
  */
14
- columns?: (ColumnGroupType<object> | ColumnType<object>)[];
14
+ columns: (ColumnGroupType<object> | ColumnType<object>)[];
15
15
  /**
16
16
  * @description 数据总数
17
17
  * @default dataSource.length
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgfe/business-lib",
3
- "version": "1.0.0-beta.4",
3
+ "version": "1.0.0-beta.5",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",