@bit-sun/business-component 2.2.49 → 2.3.1

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.
Files changed (31) hide show
  1. package/dist/common/ENUM.d.ts +40 -0
  2. package/dist/components/Functional/BsAntdSula/BsCascader/index.d.ts +18 -0
  3. package/dist/components/Functional/BsAntdSula/index.d.ts +1 -0
  4. package/dist/components/Solution/RuleComponent/Formula.d.ts +8 -0
  5. package/dist/components/Solution/RuleComponent/services.d.ts +1 -0
  6. package/dist/index.d.ts +3 -0
  7. package/dist/index.esm.js +10513 -11455
  8. package/dist/index.js +10827 -11765
  9. package/dist/utils/index.d.ts +1 -0
  10. package/dist/utils/utils.d.ts +7 -0
  11. package/package.json +2 -1
  12. package/src/common/ENUM.ts +41 -0
  13. package/src/components/Business/JsonQueryTable/components/FieldsSettingsTable.tsx +4 -0
  14. package/src/components/Business/JsonQueryTable/index.tsx +248 -33
  15. package/src/components/Functional/BsAntdSula/BsCascader/index.md +62 -0
  16. package/src/components/Functional/BsAntdSula/BsCascader/index.tsx +178 -0
  17. package/src/components/Functional/BsAntdSula/index.ts +2 -0
  18. package/src/components/Functional/EllipsisTooltip/index.d.ts +5 -0
  19. package/src/components/Functional/EllipsisTooltip/index.js +36 -0
  20. package/src/components/Functional/EllipsisTooltip/index.md +30 -0
  21. package/src/components/Solution/RuleComponent/Formula.tsx +335 -0
  22. package/src/components/Solution/RuleComponent/index.d.ts +29 -0
  23. package/src/components/Solution/RuleComponent/index.js +2028 -0
  24. package/src/components/Solution/RuleComponent/index.less +230 -0
  25. package/src/components/Solution/RuleComponent/renderSpecificAction.js +99 -0
  26. package/src/components/Solution/RuleComponent/ruleFiled.js +2074 -0
  27. package/src/components/Solution/RuleComponent/services.ts +13 -0
  28. package/src/components/Solution/RuleComponent/util.js +139 -0
  29. package/src/index.ts +4 -0
  30. package/src/utils/index.ts +1 -0
  31. package/src/utils/utils.ts +29 -0
@@ -0,0 +1,2 @@
1
+
2
+ export { default as BsCascader } from './BsCascader'
@@ -0,0 +1,5 @@
1
+ export class EllipsisTooltip {
2
+ maxLength: number;
3
+ title: string;
4
+ style?: any
5
+ }
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import { Tooltip } from 'antd';
3
+
4
+ class EllipsisTooltip extends React.Component {
5
+ state = {
6
+ visible: false,
7
+ };
8
+
9
+ handleVisibleChange = (visible) => {
10
+ if (this.props.title.length > this.props.maxLength) {
11
+ this.setState({
12
+ visible,
13
+ });
14
+ }
15
+ };
16
+
17
+ render() {
18
+ const style = {
19
+ ...this.props.style,
20
+ };
21
+
22
+ return (
23
+ <Tooltip
24
+ visible={this.state.visible}
25
+ onVisibleChange={this.handleVisibleChange}
26
+ title={this.props.title}
27
+ >
28
+ <div className="customEllipse" style={style}>
29
+ {this.props.showInfo && this.props.showInfo ||
30
+ (this.props.title.length > this.props.maxLength ? `${this.props.title.substring(0, this.props.maxLength)}...` : this.props.title)}
31
+ </div>
32
+ </Tooltip>
33
+ );
34
+ }
35
+ }
36
+ export default EllipsisTooltip;
@@ -0,0 +1,30 @@
1
+ ---
2
+ nav:
3
+ title: '组件'
4
+ order: 1
5
+ group:
6
+ title: 功能组件
7
+ order: 0
8
+ title: 字符超长处理组件
9
+ order: 6
10
+ ---
11
+
12
+ ## EllipsisTooltip
13
+
14
+ 字符超长处理组件
15
+
16
+ ```tsx
17
+ import React, { useRef } from 'react';
18
+ import { EllipsisTooltip } from '../../../index';
19
+
20
+ export default () => {
21
+
22
+ return (
23
+ <div>
24
+ <EllipsisTooltip maxLength={10} title={'一二三四五六七八九十十一十二十三'} />
25
+ </div>
26
+ );
27
+ };
28
+ ```
29
+
30
+ More skills for writing demo: https://d.umijs.org/guide/demo-principle
@@ -0,0 +1,335 @@
1
+ import { Button, Modal, Row, Col, Input, message, Divider } from 'antd';
2
+ import React, { useState, useEffect } from 'react';
3
+ import { CloseCircleOutlined } from '@ant-design/icons';
4
+ import {
5
+ SortableContainer,
6
+ SortableElement,
7
+ } from 'react-sortable-hoc';
8
+ import { arrayMoveImmutable } from 'array-move';
9
+
10
+ const App = ({ setValue, formula, record, sourceData, disabled }: {
11
+ setValue: any,
12
+ record: any,
13
+ sourceData: any,
14
+ formula?: any,
15
+ disabled?: boolean
16
+ }) => {
17
+ const [formul, setFormul] = useState(record.expression);
18
+ const [state, UpdateState] = useState([]);
19
+ const [fieldList, UpdateFiedList] = useState([]);
20
+ const [isStaticNumber, setIsStaticNumber] = useState(false);
21
+
22
+ useEffect(() => {
23
+ if (sourceData) {
24
+ setInitialData(sourceData);
25
+ return;
26
+ }
27
+ }, [sourceData]);
28
+
29
+ const setInitialData = (fieldData: any) => {
30
+ UpdateFiedList(fieldData);
31
+ let res: any = [];
32
+ let handleResData: any = [];
33
+ fieldData.forEach((i: any) => {
34
+ if (i?.propertyList?.length) {
35
+ handleResData = handleResData.concat(i.propertyList);
36
+ }
37
+ });
38
+ formul &&
39
+ formul.replace(
40
+ /([a-zA-Z_]+\.\w+)|\+|\-|\*|\/|\(|\)|((\d+\.\d+)|\d+)/g,
41
+ (item: any) => {
42
+ const numberReg = new RegExp(/^\d+/);
43
+ if (numberReg.test(item)) {
44
+ res = res.concat([{ name: item, value: item }]);
45
+ return;
46
+ }
47
+ if (handleResData.filter((initem: any) => initem.value === item).length) {
48
+ res = res.concat(
49
+ handleResData.filter((initem: any) => initem.value === item),
50
+ );
51
+ } else {
52
+ res = res.concat(
53
+ ['+', '-', '*', '/', '(', ')']
54
+ .filter((initem) => initem === item)
55
+ .map((item) => ({ value: item, name: item })),
56
+ );
57
+ }
58
+ },
59
+ );
60
+ UpdateState(res);
61
+ };
62
+
63
+ const [isModalVisible, setIsModalVisible] = useState(false);
64
+
65
+ const showModal = () => {
66
+ setIsModalVisible(true);
67
+ };
68
+
69
+ const handleOk = () => {
70
+ setIsModalVisible(false);
71
+ let formulString = state
72
+ .map((item: any) => {
73
+ if (
74
+ ['+', '-', '*', '/', '(', ')'].indexOf(item.value) == -1 &&
75
+ typeof item.value != 'number'
76
+ ) {
77
+ return `{${item.value}}`;
78
+ }
79
+ return item.value;
80
+ })
81
+ .join('');
82
+ setFormul(formulString);
83
+ setValue(state, formatFormul(formulString));
84
+ };
85
+
86
+ const handleCancel = () => {
87
+ setIsModalVisible(false);
88
+ };
89
+
90
+ const onSortEnd = ({ oldIndex, newIndex }: { oldIndex: number, newIndex: number }) => {
91
+ UpdateState(arrayMoveImmutable(state, oldIndex, newIndex));
92
+ };
93
+
94
+ const deleteItem = (value: any, indexOrder: number) => {
95
+ UpdateState([].concat(state).filter((item, index) => index !== indexOrder));
96
+ };
97
+
98
+ const SortableItem = SortableElement(({ value, sortIndex }: {value: string, sortIndex: number}) => {
99
+ return (
100
+ <span
101
+ style={{
102
+ // height: '100px',
103
+ padding: '5px 10px',
104
+ margin: '10px',
105
+ height: '40px',
106
+ lineHeight: '30px',
107
+ flexBasis: '1',
108
+ border: '1px solid #e8eaee',
109
+ borderRadius: '5px',
110
+ cursor: 'pointer',
111
+ }}
112
+ >
113
+ {value} &nbsp;{' '}
114
+ <CloseCircleOutlined
115
+ onClick={(e) => {
116
+ deleteItem(value, sortIndex);
117
+ }}
118
+ />
119
+ </span>
120
+ );
121
+ });
122
+
123
+ const SortableList = SortableContainer(({ items }: any) => {
124
+ return (
125
+ <div style={{ display: 'flex', flexWrap: 'wrap' }}>
126
+ {items.map((value: any, index: any) => (
127
+ <>
128
+ {/* @ts-ignore */}
129
+ <SortableItem key={`item-${value.value}`} sortIndex={index} index={index} value={value.name} />
130
+ </>
131
+ ))}
132
+ </div>
133
+ );
134
+ });
135
+
136
+ const add = (item: any) => {
137
+ {/* @ts-ignore */}
138
+ UpdateState([...state, item]);
139
+ };
140
+
141
+ const formatFormul = (formulaString?: string) => {
142
+ let tempFormulaString = formulaString || formul;
143
+ if (!fieldList.length || !tempFormulaString) return '';
144
+ let flattedFieldList: any = [];
145
+ fieldList.forEach((i: any) => {
146
+ if (i?.propertyList?.length) {
147
+ flattedFieldList = flattedFieldList.concat(i.propertyList);
148
+ }
149
+ });
150
+ let res = tempFormulaString.replace(/[a-zA-Z_]+\.\w+/g, (item: any) => {
151
+ // 支持固定值也就是数字,所以排除了数字
152
+ return flattedFieldList.filter((inneritem: any) => inneritem.value === item)[0]
153
+ ?.name;
154
+ });
155
+ return res.replace(/(\{|\})/g, '');
156
+ };
157
+
158
+ return (
159
+ <>
160
+ <>
161
+ <Input value={formatFormul()} style={{ width: '540px' }} disabled />
162
+ <Button type="primary" onClick={showModal} disabled={disabled}>
163
+ 编辑表达式
164
+ </Button>
165
+ <Modal
166
+ title="编辑表达式"
167
+ visible={isModalVisible}
168
+ onOk={handleOk}
169
+ onCancel={handleCancel}
170
+ width={1000}
171
+ >
172
+ <div style={{ height: '600px' }}>
173
+ <Row>
174
+ <Col span={6}>
175
+ <div
176
+ style={{
177
+ border: '1px solid #e8eaee',
178
+ padding: '10px',
179
+ borderRadius: '5px',
180
+ overflow: 'auto',
181
+ maxHeight: '600px',
182
+ }}
183
+ >
184
+ {[...fieldList].map((item: any) => (
185
+ <div key={item.id}>
186
+ <div style={{ fontWeight: 'bolder', fontSize: '14px' }}>
187
+ {item.name}
188
+ </div>
189
+ <div
190
+ style={{
191
+ display: 'flex',
192
+ justifyContent: 'space-around',
193
+ flexWrap: 'wrap',
194
+ }}
195
+ >
196
+ {(item?.propertyList || []).map((s: any) => (
197
+ <span
198
+ key={`${item.id}${s.id}`}
199
+ onClick={() => {
200
+ add(s);
201
+ }}
202
+ style={{
203
+ width: '80px',
204
+ // height: '100px',
205
+ padding: '10px',
206
+ margin: '10px 0px',
207
+ flexBasis: '1',
208
+ border: '1px solid #e8eaee',
209
+ borderRadius: '5px',
210
+ cursor: 'pointer',
211
+ }}
212
+ >
213
+ {s.name}
214
+ </span>
215
+ ))}
216
+ </div>
217
+ <Divider />
218
+ </div>
219
+ ))}
220
+ </div>
221
+ </Col>
222
+ <Col span={18}>
223
+ 表达式
224
+ <Row>
225
+ <div>
226
+ {['+', '-', '*', '/', '(', ')'].map((item) => (
227
+ <span
228
+ onClick={() => {
229
+ add({ name: item, value: item });
230
+ }}
231
+ style={{
232
+ width: '50px',
233
+ textAlign: 'center',
234
+ display: 'inline-block',
235
+ padding: '5px 10px',
236
+ margin: '10px',
237
+ height: '40px',
238
+ lineHeight: '30px',
239
+ flexBasis: '1',
240
+ border: '1px solid #e8eaee',
241
+ borderRadius: '5px',
242
+ cursor: 'pointer',
243
+ }}
244
+ >
245
+ {item}
246
+ </span>
247
+ ))}
248
+ <span
249
+ onClick={(e) => {
250
+ setIsStaticNumber(!isStaticNumber);
251
+ }}
252
+ style={{
253
+ width: isStaticNumber ? '110px' : '65px',
254
+ textAlign: 'center',
255
+ display: 'inline-block',
256
+ padding: '5px 10px',
257
+ margin: '10px',
258
+ height: '40px',
259
+ lineHeight: '30px',
260
+ flexBasis: '1',
261
+ border: '1px solid #e8eaee',
262
+ borderRadius: '5px',
263
+ cursor: 'pointer',
264
+ }}
265
+ >
266
+ {isStaticNumber ? (
267
+ <Input
268
+ autoFocus={true}
269
+ onClick={(e) => e.stopPropagation()}
270
+ onPressEnter={(e: any) => {
271
+ const value = Number(e.target.value);
272
+ if (Object.is(value, NaN)) {
273
+ message.warn('包含非数字');
274
+ return;
275
+ }
276
+ if (value < 0) {
277
+ message.warn('不支持负数,请使用减号');
278
+ return;
279
+ }
280
+ if (!value) {
281
+ setIsStaticNumber(false);
282
+ return;
283
+ }
284
+ add({ name: value, value: e.target.value });
285
+ setIsStaticNumber(false);
286
+ }}
287
+ onBlur={(e) => {
288
+ const value = Number(e.target.value);
289
+ if (Object.is(value, NaN)) {
290
+ message.warn('包含非数字');
291
+ return;
292
+ }
293
+ if (value < 0) {
294
+ message.warn('不支持负数,请使用减号');
295
+ return;
296
+ }
297
+ if (!value) {
298
+ setIsStaticNumber(false);
299
+ return;
300
+ }
301
+ add({ name: value, value: e.target.value });
302
+ setIsStaticNumber(false);
303
+ }}
304
+ />
305
+ ) : (
306
+ '固定值'
307
+ )}
308
+ </span>
309
+ </div>
310
+ </Row>
311
+ <Row>
312
+ <div
313
+ style={{
314
+ width: '700px',
315
+ padding: '10px',
316
+ marginLeft: '10px',
317
+ flexBasis: '1',
318
+ border: '1px solid #e8eaee',
319
+ minHeight: '560px',
320
+ }}
321
+ >
322
+ {/* @ts-ignore */}
323
+ <SortableList distance={20} helperClass="row-dragging" items={state} axis="xy" onSortEnd={onSortEnd} />
324
+ </div>
325
+ </Row>
326
+ </Col>
327
+ </Row>
328
+ </div>
329
+ </Modal>
330
+ </>
331
+ </>
332
+ );
333
+ };
334
+
335
+ export default App;
@@ -0,0 +1,29 @@
1
+ export class RuleComponent {
2
+ /** regularDataList必填,规则模板配置的条件对象---可选对象树数据源 */
3
+ regularDataList: any;
4
+ /** operationList必填,可选操作符数据源 */
5
+ operationList: any;
6
+ /** ruleClassData必填,规则组件配置数据 */
7
+ ruleClassData: any;
8
+ /** callBack必填,数据交互 */
9
+ callBack: any;
10
+ /** systemVariableList选填,规则模板配置的变量--插入参数数据源 */
11
+ systemVariableList?:any;
12
+ /** initialThresholdQuery非必填,处理条件对象操作符后面框的数据源参数 */
13
+ initialThresholdQuery?: any;
14
+
15
+ /** ruleGroupInfo选填,当前规则实例所属规则模板-关联的规则组信息 */
16
+ ruleGroupInfo?: any
17
+ /** ruleTypeData选填,动作数据源 */
18
+ ruleTypeData?: any;
19
+ /** ruleTypeData选填,返回值数据源 */
20
+ ruleReturnConfig?: any;
21
+ /** handleOperatingAction非必填,onlyAction为true时 父子组件之间数据交互 */
22
+ handleOperatingAction?: any;
23
+
24
+ disabled?: boolean;
25
+ canDelete?: boolean;
26
+ onlyOneRule?: boolean;
27
+ onlyCondition?: boolean;
28
+ onlyAction?: boolean;
29
+ }