@bit-sun/business-component 4.0.12-alpha.3 → 4.0.12-alpha.30
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/dist/components/Business/PropertyModal/index.d.ts +23 -0
- package/dist/components/Business/PropertyModal/mockData.d.ts +10 -0
- package/dist/components/Business/PropertyModal/propertyGroup.d.ts +4 -0
- package/dist/components/Business/columnSettingTable/components/TableSumComponent.d.ts +4 -0
- package/dist/components/Functional/QueryMutipleSelect/index.d.ts +5 -0
- package/dist/components/Functional/SearchSelect/utils.d.ts +16 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +2012 -883
- package/dist/index.js +2011 -880
- package/package.json +3 -3
- package/src/components/Business/BsSulaQueryTable/index.md +113 -20
- package/src/components/Business/BsSulaQueryTable/index.tsx +109 -7
- package/src/components/Business/PropertyModal/index.less +58 -0
- package/src/components/Business/PropertyModal/index.md +33 -0
- package/src/components/Business/PropertyModal/index.tsx +271 -0
- package/src/components/Business/PropertyModal/mockData.ts +160 -0
- package/src/components/Business/PropertyModal/propertyGroup.tsx +205 -0
- package/src/components/Business/SearchSelect/BusinessUtils.tsx +55 -3
- package/src/components/Business/SearchSelect/index.md +3 -4
- package/src/components/Business/SearchSelect/index.tsx +4 -1
- package/src/components/Business/columnSettingTable/components/TableSumComponent.tsx +25 -0
- package/src/components/Business/columnSettingTable/components/style.less +25 -0
- package/src/components/Business/columnSettingTable/index.md +5 -8
- package/src/components/Business/columnSettingTable/index.tsx +3 -28
- package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +116 -37
- package/src/components/Functional/QueryMutipleSelect/index.less +117 -0
- package/src/components/Functional/QueryMutipleSelect/index.md +41 -0
- package/src/components/Functional/QueryMutipleSelect/index.tsx +242 -0
- package/src/components/Functional/SearchSelect/index.less +40 -2
- package/src/components/Functional/SearchSelect/index.tsx +84 -283
- package/src/components/Functional/SearchSelect/utils.tsx +400 -0
- package/src/components/Solution/RuleComponent/ruleFiled.js +93 -93
- package/src/index.ts +2 -0
- package/src/styles/bsDefault.less +0 -1
- package/src/components/Functional/SearchSelect/utils.ts +0 -38
|
@@ -6,6 +6,7 @@ import { getItemDefaultWidth, getShowColumns, handleTextOverflow } from './utils
|
|
|
6
6
|
import { noEmptyArray } from './utils';
|
|
7
7
|
import ENUM from '@/utils/enumConfig';
|
|
8
8
|
import { handleAntdColumnsSpecialParams } from '@/utils/utils';
|
|
9
|
+
import TableSumComponent from './components/TableSumComponent';
|
|
9
10
|
const { Text } = Typography;
|
|
10
11
|
export default class ColumnSettingTable extends React.Component {
|
|
11
12
|
state: any;
|
|
@@ -230,34 +231,8 @@ export default class ColumnSettingTable extends React.Component {
|
|
|
230
231
|
}
|
|
231
232
|
/>
|
|
232
233
|
{Array.isArray(summary) && (
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
className='table-bssula-summary'
|
|
236
|
-
style={{
|
|
237
|
-
right: '20%',
|
|
238
|
-
bottom: 0,
|
|
239
|
-
whiteSpace: 'nowrap',
|
|
240
|
-
overflowX: 'auto',
|
|
241
|
-
}}
|
|
242
|
-
>
|
|
243
|
-
{summary.map(item => (
|
|
244
|
-
<Text type='danger'>
|
|
245
|
-
{item.label}: <span className='table-bssula-summary-count'>{item.count || 0}</span>
|
|
246
|
-
</Text>
|
|
247
|
-
))}
|
|
248
|
-
</div>
|
|
249
|
-
<div style={{
|
|
250
|
-
width: '16px',
|
|
251
|
-
height: '26px',
|
|
252
|
-
opacity: 0.32,
|
|
253
|
-
transform: 'scaleX(-1)',
|
|
254
|
-
backgroundImage:'linear-gradient(270deg, #ffffff00 0%, #A4A4A4 100%)',
|
|
255
|
-
right: '20%',
|
|
256
|
-
position: 'absolute',
|
|
257
|
-
bottom: 0,
|
|
258
|
-
}}></div>
|
|
259
|
-
</>
|
|
260
|
-
)}
|
|
234
|
+
<TableSumComponent summary={summary} />
|
|
235
|
+
)}
|
|
261
236
|
</div >
|
|
262
237
|
)
|
|
263
238
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import { Table as SulaTable, request } from 'bssula';
|
|
3
3
|
import { Resizable } from 'react-resizable';
|
|
4
4
|
import ColumnSetting from './columnSetting';
|
|
@@ -9,8 +9,10 @@ import {
|
|
|
9
9
|
Typography,
|
|
10
10
|
} from 'antd';
|
|
11
11
|
import ENUM from '@/utils/enumConfig';
|
|
12
|
-
import { handleBssulaColumnsSpecialParams, parseWidth } from '@/utils/utils';
|
|
12
|
+
import { handleBssulaColumnsSpecialParams, parseWidth, uuid } from '@/utils/utils';
|
|
13
|
+
import TableSumComponent from './components/TableSumComponent';
|
|
13
14
|
const { Text } = Typography;
|
|
15
|
+
|
|
14
16
|
export default class ColumnSettingSulaTable extends React.Component {
|
|
15
17
|
sulaTableRef: React.RefObject<unknown>;
|
|
16
18
|
state: any;
|
|
@@ -126,21 +128,123 @@ export default class ColumnSettingSulaTable extends React.Component {
|
|
|
126
128
|
|
|
127
129
|
ResizeableTitle = (props: any) => {
|
|
128
130
|
const { onResize, width, ...restProps } = props;
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
|
|
132
|
+
const [innerWidth, setInnerWidth] = useState(width);
|
|
133
|
+
const [isResizing, setIsResizing] = useState(false); // 标记是否正在拖拽
|
|
134
|
+
const [isDragging, setIsDragging] = useState(false); // 标记拖拽句柄是否被拖拽
|
|
135
|
+
const [startX, setStartX] = useState(0); // 初始X坐标
|
|
136
|
+
const markerPosition = useRef({ left: 0, top: 0 });
|
|
137
|
+
const currentStart = useRef(0);
|
|
138
|
+
const uuidref = useRef(uuid());
|
|
139
|
+
|
|
140
|
+
const prevWidthRef = useRef(width);
|
|
141
|
+
|
|
142
|
+
const handleMouseDown = (e: any) => {
|
|
143
|
+
currentStart.current = e.clientX;
|
|
144
|
+
markerPosition.current = { left: e.clientX, top: e.clientY }
|
|
145
|
+
setIsResizing(true);
|
|
146
|
+
document.addEventListener('mousemove', handleMouseMove);
|
|
147
|
+
document.addEventListener('mouseup', handleMouseUp);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const handleMouseMove = (e: any) => {
|
|
151
|
+
e.stopPropagation();
|
|
152
|
+
e.preventDefault();
|
|
153
|
+
// 更新标记位置
|
|
154
|
+
markerPosition.current = { left: e.clientX, top: e.clientY }
|
|
155
|
+
const dom: HTMLElement | null = document.getElementById('text1');
|
|
156
|
+
|
|
157
|
+
if (dom && dom.style) {
|
|
158
|
+
dom.style.left = `${e.clientX}px`;
|
|
159
|
+
dom.style.top = `${e.clientY - 20}px`;
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const handleMouseUp = (e: any) => {
|
|
164
|
+
document.removeEventListener('mousemove', handleMouseMove);
|
|
165
|
+
document.removeEventListener('mouseup', handleMouseUp);
|
|
166
|
+
setIsResizing(false);
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const handleresize = (e: any, data: any, title: string) => {
|
|
170
|
+
const newWidth = data?.size?.width || 0;
|
|
171
|
+
setInnerWidth(newWidth); // 更新内部分宽度
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const handleResizeStart = () => {
|
|
175
|
+
setIsResizing(true);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
const handleResizeStop = (e: any, data: any) => {
|
|
179
|
+
setIsResizing(false);
|
|
180
|
+
if (onResize) {
|
|
181
|
+
onResize(e, data);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
useEffect(() => {
|
|
186
|
+
if (width !== prevWidthRef.current) {
|
|
187
|
+
prevWidthRef.current = width;
|
|
188
|
+
setInnerWidth(width);
|
|
189
|
+
}
|
|
190
|
+
}, [width]);
|
|
191
|
+
|
|
192
|
+
const thStyle = {
|
|
193
|
+
boxShadow: isResizing ? '2px 2px 10px rgba(0, 0, 0, 0.3)' : 'none',
|
|
194
|
+
};
|
|
195
|
+
|
|
133
196
|
return (
|
|
134
197
|
<Resizable
|
|
135
|
-
width={
|
|
198
|
+
width={innerWidth}
|
|
136
199
|
height={0}
|
|
137
|
-
|
|
138
|
-
|
|
200
|
+
handle={
|
|
201
|
+
<div>
|
|
202
|
+
<div
|
|
203
|
+
style={{
|
|
204
|
+
width: '10px',
|
|
205
|
+
height: '30px',
|
|
206
|
+
cursor: 'col-resize', // 拖动时改变鼠标样式
|
|
207
|
+
position: 'absolute',
|
|
208
|
+
zIndex: 10,
|
|
209
|
+
top: 0,
|
|
210
|
+
right: 0,
|
|
211
|
+
}}
|
|
212
|
+
onMouseDown={handleMouseDown}
|
|
213
|
+
// onDrag={handleDrag}
|
|
214
|
+
>
|
|
215
|
+
</div>
|
|
216
|
+
{isResizing && <div
|
|
217
|
+
id="text1"
|
|
218
|
+
style={{
|
|
219
|
+
position: 'fixed',
|
|
220
|
+
left: markerPosition.current.left, // 跟随鼠标偏移一点
|
|
221
|
+
top: markerPosition.current.top - 20,
|
|
222
|
+
backgroundColor: '#1890ff',
|
|
223
|
+
color: 'white',
|
|
224
|
+
borderRadius: '4px',
|
|
225
|
+
zIndex: 9999,
|
|
226
|
+
pointerEvents: 'none',
|
|
227
|
+
height: '40px',
|
|
228
|
+
width: 2
|
|
229
|
+
}}
|
|
230
|
+
>
|
|
231
|
+
</div>}
|
|
232
|
+
</div>
|
|
233
|
+
}
|
|
234
|
+
onResize={(e: any, data: any) => {handleresize(e, data, restProps.title)}}
|
|
235
|
+
onResizeStart={handleResizeStart}
|
|
236
|
+
onResizeStop={handleResizeStop}
|
|
237
|
+
draggableOpts={{
|
|
238
|
+
enableUserSelectHack: true,
|
|
239
|
+
grid: [20, 20],
|
|
240
|
+
axis: 'x',
|
|
241
|
+
bounds: 'parent',
|
|
242
|
+
}}
|
|
139
243
|
>
|
|
140
244
|
<th {...restProps} />
|
|
141
245
|
</Resizable>
|
|
142
246
|
);
|
|
143
|
-
}
|
|
247
|
+
};
|
|
144
248
|
|
|
145
249
|
getTableScrollXWidth = (cols: any[]) => {
|
|
146
250
|
if (cols.every((item: any) => item.width)) {
|
|
@@ -197,6 +301,7 @@ export default class ColumnSettingSulaTable extends React.Component {
|
|
|
197
301
|
...scroll,
|
|
198
302
|
x: restProps.overScrollX || this.getTableScrollXWidth(showCol)
|
|
199
303
|
},
|
|
304
|
+
sticky: true,
|
|
200
305
|
...(
|
|
201
306
|
showSummary ? { summary: showSummary } : {}
|
|
202
307
|
)
|
|
@@ -226,33 +331,7 @@ export default class ColumnSettingSulaTable extends React.Component {
|
|
|
226
331
|
}
|
|
227
332
|
/>
|
|
228
333
|
{Array.isArray(summary) && (
|
|
229
|
-
|
|
230
|
-
<div
|
|
231
|
-
className='table-bssula-summary'
|
|
232
|
-
style={{
|
|
233
|
-
right: '20%',
|
|
234
|
-
bottom: 0,
|
|
235
|
-
whiteSpace: 'nowrap',
|
|
236
|
-
overflowX: 'auto',
|
|
237
|
-
}}
|
|
238
|
-
>
|
|
239
|
-
{summary.map(item => (
|
|
240
|
-
<Text type='danger'>
|
|
241
|
-
{item.label}: <span className='table-bssula-summary-count'>{item.count || 0}</span>
|
|
242
|
-
</Text>
|
|
243
|
-
))}
|
|
244
|
-
</div>
|
|
245
|
-
<div style={{
|
|
246
|
-
width: '16px',
|
|
247
|
-
height: '26px',
|
|
248
|
-
opacity: 0.32,
|
|
249
|
-
transform: 'scaleX(-1)',
|
|
250
|
-
backgroundImage:'linear-gradient(270deg, #ffffff00 0%, #A4A4A4 100%)',
|
|
251
|
-
right: '20%',
|
|
252
|
-
position: 'absolute',
|
|
253
|
-
bottom: 0,
|
|
254
|
-
}}></div>
|
|
255
|
-
</>
|
|
334
|
+
<TableSumComponent summary={summary} />
|
|
256
335
|
)}
|
|
257
336
|
</div >
|
|
258
337
|
)
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
@border-color: #d9d9d9;
|
|
2
|
+
@primary-color: #005cff;
|
|
3
|
+
|
|
4
|
+
.query_select {
|
|
5
|
+
// 选择器 隐藏滚动条 横向滑动
|
|
6
|
+
.ant-select-selector{
|
|
7
|
+
height: 24px;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
.ant-select-selection-overflow{
|
|
10
|
+
height: 40px;
|
|
11
|
+
flex-wrap: nowrap;
|
|
12
|
+
overflow-x: auto;
|
|
13
|
+
}
|
|
14
|
+
.ant-select-selection-overflow-item {
|
|
15
|
+
align-self: auto;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
&_show {
|
|
19
|
+
display: flex;
|
|
20
|
+
|
|
21
|
+
// 下拉框清除图标位置调整
|
|
22
|
+
.ant-select-clear {
|
|
23
|
+
right: 33px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// 解决多选宽度不够 滑动会白一块的问题
|
|
27
|
+
.ant-select-multiple.ant-select-show-arrow .ant-select-selector, .ant-select-multiple.ant-select-allow-clear .ant-select-selector {
|
|
28
|
+
padding-right: 28px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.ant-select-dropdown {
|
|
32
|
+
top: 24px !important;
|
|
33
|
+
left: -110px !important;
|
|
34
|
+
width: calc(100% + 110px) !important;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&_expand_button {
|
|
39
|
+
position: relative;
|
|
40
|
+
right: -11px;
|
|
41
|
+
width: 30px;
|
|
42
|
+
border-left: 1px solid @border-color;
|
|
43
|
+
height: 24px;
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
font-size: 12px;
|
|
46
|
+
color: rgba(0, 0, 0, 0.85);
|
|
47
|
+
span {
|
|
48
|
+
position: absolute;
|
|
49
|
+
left: 50%;
|
|
50
|
+
top: 50%;
|
|
51
|
+
transform: translate(-50%, -50%);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
&_expand_button:hover {
|
|
55
|
+
background-color: @primary-color;
|
|
56
|
+
color: #fff;
|
|
57
|
+
border-top-right-radius: 2px;
|
|
58
|
+
border-bottom-right-radius: 2px;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&_wrapper {
|
|
62
|
+
&_top {
|
|
63
|
+
color: #8E8E8E;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&_textArea {
|
|
68
|
+
margin-top: 10px;
|
|
69
|
+
.ant-input {
|
|
70
|
+
height: 300px;
|
|
71
|
+
background: #FAFAFA;
|
|
72
|
+
border: 0.8px solid #E0E0E0;
|
|
73
|
+
resize: none;
|
|
74
|
+
border-radius: 0;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.multiInput_modal{
|
|
80
|
+
.ant-modal-header{
|
|
81
|
+
height: 32px;
|
|
82
|
+
padding: 0 16px;
|
|
83
|
+
font-size: 12px;
|
|
84
|
+
}
|
|
85
|
+
.ant-modal-title{
|
|
86
|
+
line-height: 32px;
|
|
87
|
+
}
|
|
88
|
+
.ant-modal-close-x{
|
|
89
|
+
width: 32px;
|
|
90
|
+
height: 32px;
|
|
91
|
+
line-height: 32px;
|
|
92
|
+
}
|
|
93
|
+
.ant-modal-footer{
|
|
94
|
+
padding-right: 8px;
|
|
95
|
+
height: 44px;
|
|
96
|
+
.ant-btn + .ant-btn:not(.ant-dropdown-trigger) {
|
|
97
|
+
margin-left: 6px;
|
|
98
|
+
}
|
|
99
|
+
.ant-btn {
|
|
100
|
+
width: 56px;
|
|
101
|
+
height: 28px;
|
|
102
|
+
font-weight: 500;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.searchSelectMaxTagToolTip {
|
|
108
|
+
.ant-tooltip-inner {
|
|
109
|
+
max-height: 72px;
|
|
110
|
+
overflow-x: auto;
|
|
111
|
+
padding: 0px;
|
|
112
|
+
}
|
|
113
|
+
.ant-tag {
|
|
114
|
+
display: flex;
|
|
115
|
+
width: fit-content;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
nav:
|
|
3
|
+
title: '组件'
|
|
4
|
+
order: 1
|
|
5
|
+
group:
|
|
6
|
+
title: 功能组件
|
|
7
|
+
order: 0
|
|
8
|
+
title: 批量搜索查询组件
|
|
9
|
+
order: 2
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## QueryMutipleInput
|
|
13
|
+
|
|
14
|
+
Demo:
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import React, { useRef } from 'react';
|
|
18
|
+
import { QueryMutipleSearchSelect } from '../../../index';
|
|
19
|
+
|
|
20
|
+
export default () => {
|
|
21
|
+
const requestConfig = {
|
|
22
|
+
url: '/items/item/listNoPage/Simple',
|
|
23
|
+
filter: 'qp-name-like', // qp-itemCode-like
|
|
24
|
+
// filter: 'qp-skuCode,name-orGroup,like',
|
|
25
|
+
mappingTextField: 'name',
|
|
26
|
+
mappingValueField: 'itemCode',
|
|
27
|
+
sourceName: 'qp-itemCode-in'
|
|
28
|
+
}
|
|
29
|
+
const handleOnChange = (value) => {
|
|
30
|
+
console.log(value);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<div>
|
|
35
|
+
<QueryMutipleSearchSelect onValueChange={handleOnChange} requestConfig={requestConfig} />
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
More skills for writing demo: https://d.umijs.org/guide/demo-principle
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { useDebounceFn } from 'ahooks';
|
|
3
|
+
import _, { isNil } from "lodash"
|
|
4
|
+
import { Select, Input, Button, Modal, ConfigProvider, Spin, message } from 'antd';
|
|
5
|
+
import { DashOutlined } from '@ant-design/icons';
|
|
6
|
+
import request from '@/utils/request';
|
|
7
|
+
import { judgeIsRequestError } from '@/utils/requestUtils';
|
|
8
|
+
import './index.less';
|
|
9
|
+
import { convertUrlQueryParams, convertBodyParams, convertResData, handleSourceName, makeUniqueValue, LightHeightOption, handleSelectOptionsShowValue, maxTagPlaceholder } from '../SearchSelect/utils';
|
|
10
|
+
|
|
11
|
+
export const getValue = (value: any, selectMode?: any) => {
|
|
12
|
+
return selectMode ? (typeof value == 'string' && value?.length && value?.split?.(',')||[]) : value;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const QueryMutipleSearchSelect = ({ onValueChange, requestConfig={}, selectProps={}, ctx }: any) => {
|
|
16
|
+
const { filter, method = 'get', url, extralHeaders = {}, otherParams = {}, specialBracket = false, noNeedSplit = false, } = requestConfig;
|
|
17
|
+
const selectParamsKey = filter || 'qp-codeAndName-like';
|
|
18
|
+
const resultSourceKey = handleSourceName(requestConfig?.sourceName || ctx?.name || 'skuCode')
|
|
19
|
+
const currentSelectProps = {
|
|
20
|
+
showArrow: true,
|
|
21
|
+
showSearch: true,
|
|
22
|
+
filterOption: false,
|
|
23
|
+
allowClear: true,
|
|
24
|
+
listHeight: 160,
|
|
25
|
+
labelInValue: false,
|
|
26
|
+
maxTagCount: 4,
|
|
27
|
+
...selectProps,
|
|
28
|
+
}
|
|
29
|
+
const selectMode = selectProps?.mode // 设定当前选择器 为单选或者多选模式 无设定为单选模式(默认)
|
|
30
|
+
|
|
31
|
+
const [isModalVisible, setIsModalVisible] = useState(false);
|
|
32
|
+
const [open, setOpen] = useState(false);
|
|
33
|
+
const [value, setValue] = useState<any>();
|
|
34
|
+
const [popvalue, setPopValue] = useState();
|
|
35
|
+
const [source, setSource] = useState([]);
|
|
36
|
+
const { run } = useDebounceFn(
|
|
37
|
+
() => {
|
|
38
|
+
getData()
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
wait: 1000,
|
|
42
|
+
},
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const [fetching, setFetching] = useState(false);
|
|
46
|
+
const [searchValue, setSearchValue] = useState('');
|
|
47
|
+
const [uniqueValue, setUniqueValue] = useState(resultSourceKey);
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
setPopValue(value);
|
|
51
|
+
onValueChange(value);
|
|
52
|
+
}, [value]);
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
setUniqueValue(makeUniqueValue());
|
|
56
|
+
}, [resultSourceKey])
|
|
57
|
+
|
|
58
|
+
const showModal = () => {
|
|
59
|
+
setIsModalVisible(true);
|
|
60
|
+
//弹窗打开时 默认搜索内容换行显示
|
|
61
|
+
setPopValue((data: any) => data?.replace(/,/g, '\n'));
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const handleOk = () => {
|
|
65
|
+
formaData(popvalue);
|
|
66
|
+
setIsModalVisible(false);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const formaData = (v: any) => {
|
|
70
|
+
let formatValue: any = ToCDB(v)
|
|
71
|
+
?.split(/[/\n/\s,;]/)
|
|
72
|
+
?.filter((item) => item)
|
|
73
|
+
?.join(',');
|
|
74
|
+
setValue(formatValue);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const handleCancel = () => {
|
|
78
|
+
setIsModalVisible(false);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const outerChange = (v: any) => {
|
|
82
|
+
formaData(v)
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const onChange = (e: any) => {
|
|
86
|
+
const v = e.target.value;
|
|
87
|
+
setPopValue(v);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// 获取下拉框数据源-不分页
|
|
91
|
+
const getData = (params: any = {}, callback?: any) => {
|
|
92
|
+
if (!requestConfig) return;
|
|
93
|
+
if (!url) return;
|
|
94
|
+
|
|
95
|
+
setFetching(true)
|
|
96
|
+
|
|
97
|
+
const queryParams = {
|
|
98
|
+
...otherParams, // 默认参数
|
|
99
|
+
...params,
|
|
100
|
+
};
|
|
101
|
+
if (isNil(queryParams[selectParamsKey])) {
|
|
102
|
+
queryParams[selectParamsKey] = searchValue;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
let getRequest;
|
|
106
|
+
const methodName = method?.toLocaleLowerCase();
|
|
107
|
+
if(['post','patch','put'].includes(methodName)) {
|
|
108
|
+
getRequest = request[methodName](`${url}${convertUrlQueryParams(queryParams)}`,convertBodyParams(queryParams))
|
|
109
|
+
} else {
|
|
110
|
+
getRequest = request.get( `${url}${convertUrlQueryParams(queryParams)}`,{headers: { ...extralHeaders }})
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (!getRequest) return;
|
|
114
|
+
|
|
115
|
+
getRequest.then((result: any) => {
|
|
116
|
+
setFetching(false)
|
|
117
|
+
result = result.data;
|
|
118
|
+
if (judgeIsRequestError(result)) {
|
|
119
|
+
message.error(result.msg);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const res = result.data;
|
|
123
|
+
const dSource: any = convertResData(requestConfig, res, { selectMode, labelInValue: currentSelectProps?.labelInValue, value, type: 1, items: source, needTopSelectedSource: false });
|
|
124
|
+
|
|
125
|
+
if(callback) {
|
|
126
|
+
callback(source)
|
|
127
|
+
} else {
|
|
128
|
+
setSource(dSource)
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
.catch((err: any) => { setFetching(false) });
|
|
132
|
+
}
|
|
133
|
+
const onSearchChange = (v: any) => {
|
|
134
|
+
setSearchValue(v);
|
|
135
|
+
run();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<div className={'query_select'}>
|
|
140
|
+
<div className="query_select_show" id={`query_multiple_select_div_${uniqueValue}`}>
|
|
141
|
+
<Select
|
|
142
|
+
value={getValue(value, selectMode)}
|
|
143
|
+
onChange={outerChange}
|
|
144
|
+
open={open}
|
|
145
|
+
onBlur={(v: any) => {
|
|
146
|
+
onSearchChange(v)
|
|
147
|
+
setOpen(false);
|
|
148
|
+
}}
|
|
149
|
+
onClick={() => setOpen(true)}
|
|
150
|
+
onPaste={(e: any) => {
|
|
151
|
+
formaData(e.clipboardData.getData('text'));
|
|
152
|
+
e.preventDefault();
|
|
153
|
+
}}
|
|
154
|
+
onSearch={(v) => onSearchChange(v)}
|
|
155
|
+
onSelect={() => {
|
|
156
|
+
if(selectMode) return;
|
|
157
|
+
setTimeout(() => {
|
|
158
|
+
setOpen(false)
|
|
159
|
+
}, 0)
|
|
160
|
+
}}
|
|
161
|
+
style={{ width: 'calc(100%)' }}
|
|
162
|
+
suffixIcon={<div className={`query_select_expand_button`} onClick={showModal}><DashOutlined /></div>}
|
|
163
|
+
placeholder="请选择"
|
|
164
|
+
maxTagPlaceholder={(v)=> maxTagPlaceholder(v,{ selectProps:currentSelectProps, onChange:outerChange, value:getValue(value, selectMode), setIsMaxTagsOpen:()=>{} })}
|
|
165
|
+
notFoundContent={
|
|
166
|
+
fetching ? (
|
|
167
|
+
<Spin size="small" className='searchSelectSpin' />
|
|
168
|
+
) : (
|
|
169
|
+
<div style={{ textAlign: 'center' }}>
|
|
170
|
+
<div>{searchValue?'无匹配结果,请更换其他内容再试':`请录入内容模糊查询`}</div>
|
|
171
|
+
</div>
|
|
172
|
+
)
|
|
173
|
+
}
|
|
174
|
+
getPopupContainer={(triggerNode) => triggerNode.parentElement}
|
|
175
|
+
{...currentSelectProps}
|
|
176
|
+
>
|
|
177
|
+
{source.map((item: any) => (
|
|
178
|
+
<Select.Option key={item.value} label={item.text}>
|
|
179
|
+
{LightHeightOption({
|
|
180
|
+
text: handleSelectOptionsShowValue(specialBracket, noNeedSplit, item),
|
|
181
|
+
filterTxt: searchValue,
|
|
182
|
+
needToolTips: false
|
|
183
|
+
})}
|
|
184
|
+
</Select.Option>
|
|
185
|
+
))}
|
|
186
|
+
</Select>
|
|
187
|
+
</div>
|
|
188
|
+
<Modal
|
|
189
|
+
width={600}
|
|
190
|
+
title="多值录入"
|
|
191
|
+
visible={isModalVisible}
|
|
192
|
+
onOk={handleOk}
|
|
193
|
+
onCancel={handleCancel}
|
|
194
|
+
className='multiInput_modal'
|
|
195
|
+
bodyStyle={{
|
|
196
|
+
padding: '10px 16px'
|
|
197
|
+
}}
|
|
198
|
+
footer={[
|
|
199
|
+
<ConfigProvider autoInsertSpaceInButton = { false }>
|
|
200
|
+
<Button key="back" onClick={handleCancel}>
|
|
201
|
+
取消
|
|
202
|
+
</Button>
|
|
203
|
+
</ConfigProvider>,
|
|
204
|
+
<ConfigProvider autoInsertSpaceInButton = { false }>
|
|
205
|
+
<Button key="submit" type="primary" onClick={handleOk}>
|
|
206
|
+
录入
|
|
207
|
+
</Button>
|
|
208
|
+
</ConfigProvider>,
|
|
209
|
+
]}
|
|
210
|
+
>
|
|
211
|
+
<div className={'query_select_wrapper'}>
|
|
212
|
+
<div className={'query_select_wrapper_top'}>如需同时使用多个值进行查询,请使用逗号,分号、空格或换行进行值的分割,中英文格式的符号均支持</div>
|
|
213
|
+
<div className={'query_select_textArea'}>
|
|
214
|
+
<Input.TextArea
|
|
215
|
+
placeholder='在此录入...'
|
|
216
|
+
value={popvalue}
|
|
217
|
+
onChange={onChange}
|
|
218
|
+
rows={12}
|
|
219
|
+
showCount={false}
|
|
220
|
+
/>
|
|
221
|
+
</div>
|
|
222
|
+
</div>
|
|
223
|
+
</Modal>
|
|
224
|
+
</div>
|
|
225
|
+
);
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
function ToCDB(selectStr: any) {
|
|
229
|
+
var tmp = '';
|
|
230
|
+
if(!selectStr?.length) return '';
|
|
231
|
+
const str = Array.isArray(selectStr) ? selectStr.join(',') : selectStr;
|
|
232
|
+
for (var i = 0; i < str?.length; i++) {
|
|
233
|
+
if (str?.charCodeAt?.(i) > 65248 && str?.charCodeAt?.(i) < 65375) {
|
|
234
|
+
tmp += String.fromCharCode(str?.charCodeAt(i) - 65248);
|
|
235
|
+
} else {
|
|
236
|
+
tmp += String.fromCharCode(str.charCodeAt(i));
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return tmp;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export default QueryMutipleSearchSelect;
|