@bit-sun/business-component 4.0.12-alpha.28 → 4.0.12-alpha.29

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bit-sun/business-component",
3
- "version": "4.0.12-alpha.28",
3
+ "version": "4.0.12-alpha.29",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -28,8 +28,8 @@
28
28
  },
29
29
  "peerDependencies": {
30
30
  "antd": "^4.17.2",
31
- "bssula": "4.0.12-alpha.6",
32
- "umi-plugin-bssula": "4.0.8-alpha.3",
31
+ "bssula": "4.1.1",
32
+ "umi-plugin-bssula": "4.1.1",
33
33
  "umi": "^3.5.20",
34
34
  "@ant-design/pro-layout": "^6.5.0",
35
35
  "react-dnd": "^16.0.1",
@@ -326,9 +326,38 @@ export function commonFun (type?: string, prefixUrl: any, parentProps?:any) {
326
326
  ...selectConfigProps,
327
327
  }
328
328
  tableSearchForm = [
329
- { name: 'qp-skuCode-in', label: 'SKU编码',type:'multipleQueryInput' },
329
+ { name: 'qp-skuCode-in', label: 'SKU编码', field: {
330
+ type:'multipleQuerySearchSelect',
331
+ props: {
332
+ selectProps: {
333
+ mode: "multiple",
334
+ },
335
+ requestConfig: {
336
+ url: '/items/sku//listNoPage/Simple',
337
+ filter: 'qp-name-like', // qp-skuCode-like
338
+ // filter: 'qp-itemCode,name-orGroup,like',
339
+ mappingTextField: 'name',
340
+ mappingValueField: 'skuCode',
341
+ sourceName: 'qp-skuCode-in',
342
+ specialBracket: true,
343
+ },
344
+ }
345
+ } },
330
346
  { name: 'qp-skuName-like', label: 'SKU名称' },
331
- { name: 'qp-itemCode-like', label: 'SPU编码' },
347
+ { name: 'qp-itemCode-in', label: 'SPU编码', field: {
348
+ type:'multipleQuerySearchSelect',
349
+ props: {
350
+ requestConfig: {
351
+ url: '/items/item/listNoPage/Simple',
352
+ filter: 'qp-name-like', // qp-itemCode-like
353
+ // filter: 'qp-skuCode,name-orGroup,like',
354
+ mappingTextField: 'name',
355
+ mappingValueField: 'itemCode',
356
+ sourceName: 'qp-itemCode-in',
357
+ specialBracket: true,
358
+ },
359
+ }
360
+ } },
332
361
  { name: 'qp-eancode-in', label: '商品条码', field: {
333
362
  type: 'multipleQueryInput',
334
363
  props: {
@@ -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,245 @@
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
+ if(value) {
51
+ setPopValue(value);
52
+ onValueChange(value);
53
+ }
54
+ }, [value]);
55
+
56
+ useEffect(() => {
57
+ setUniqueValue(makeUniqueValue());
58
+ }, [resultSourceKey])
59
+
60
+ const showModal = () => {
61
+ setIsModalVisible(true);
62
+ //弹窗打开时 默认搜索内容换行显示
63
+ setPopValue((data: any) => data?.replace(/,/g, '\n'));
64
+ };
65
+
66
+ const handleOk = () => {
67
+ formaData(popvalue);
68
+ setIsModalVisible(false);
69
+ };
70
+
71
+ const formaData = (v: any) => {
72
+ let formatValue: any = ToCDB(v)
73
+ ?.split(/[/\n/\s,;]/)
74
+ ?.filter((item) => item)
75
+ ?.join(',');
76
+ console.log(formatValue,'1111formatValue')
77
+ setValue(formatValue);
78
+ };
79
+
80
+ const handleCancel = () => {
81
+ setIsModalVisible(false);
82
+ };
83
+
84
+ const outerChange = (v: any) => {
85
+ formaData(v)
86
+ };
87
+
88
+ const onChange = (e: any) => {
89
+ const v = e.target.value;
90
+ setPopValue(v);
91
+ };
92
+
93
+ // 获取下拉框数据源-不分页
94
+ const getData = (params: any = {}, callback?: any) => {
95
+ if (!requestConfig) return;
96
+ if (!url) return;
97
+
98
+ setFetching(true)
99
+
100
+ const queryParams = {
101
+ ...otherParams, // 默认参数
102
+ ...params,
103
+ };
104
+ if (isNil(queryParams[selectParamsKey])) {
105
+ queryParams[selectParamsKey] = searchValue;
106
+ }
107
+
108
+ let getRequest;
109
+ const methodName = method?.toLocaleLowerCase();
110
+ if(['post','patch','put'].includes(methodName)) {
111
+ getRequest = request[methodName](`${url}${convertUrlQueryParams(queryParams)}`,convertBodyParams(queryParams))
112
+ } else {
113
+ getRequest = request.get( `${url}${convertUrlQueryParams(queryParams)}`,{headers: { ...extralHeaders }})
114
+ }
115
+
116
+ if (!getRequest) return;
117
+
118
+ getRequest.then((result: any) => {
119
+ setFetching(false)
120
+ result = result.data;
121
+ if (judgeIsRequestError(result)) {
122
+ message.error(result.msg);
123
+ return;
124
+ }
125
+ const res = result.data;
126
+ const dSource: any = convertResData(requestConfig, res, { selectMode, labelInValue: currentSelectProps?.labelInValue, value, type: 1, items: source, needTopSelectedSource: false });
127
+
128
+ if(callback) {
129
+ callback(source)
130
+ } else {
131
+ setSource(dSource)
132
+ }
133
+ })
134
+ .catch((err: any) => { setFetching(false) });
135
+ }
136
+ const onSearchChange = (v: any) => {
137
+ setSearchValue(v);
138
+ run();
139
+ }
140
+
141
+ return (
142
+ <div className={'query_select'}>
143
+ <div className="query_select_show" id={`query_multiple_select_div_${uniqueValue}`}>
144
+ <Select
145
+ value={getValue(value, selectMode)}
146
+ onChange={outerChange}
147
+ open={open}
148
+ onBlur={(v: any) => {
149
+ onSearchChange(v)
150
+ setOpen(false);
151
+ }}
152
+ onClick={() => setOpen(true)}
153
+ onPaste={(e: any) => {
154
+ formaData(e.clipboardData.getData('text'));
155
+ e.preventDefault();
156
+ }}
157
+ onSearch={(v) => onSearchChange(v)}
158
+ onSelect={() => {
159
+ if(selectMode) return;
160
+ setTimeout(() => {
161
+ setOpen(false)
162
+ }, 0)
163
+ }}
164
+ style={{ width: 'calc(100%)' }}
165
+ suffixIcon={<div className={`query_select_expand_button`} onClick={showModal}><DashOutlined /></div>}
166
+ placeholder="请选择"
167
+ maxTagPlaceholder={(v)=> maxTagPlaceholder(v,{ selectProps:currentSelectProps, onChange:outerChange, value:getValue(value, selectMode), setIsMaxTagsOpen:()=>{} })}
168
+ notFoundContent={
169
+ fetching ? (
170
+ <Spin size="small" className='searchSelectSpin' />
171
+ ) : (
172
+ <div style={{ textAlign: 'center' }}>
173
+ <div>{searchValue?'无匹配结果,请更换其他内容再试':`请录入内容模糊查询`}</div>
174
+ </div>
175
+ )
176
+ }
177
+ getPopupContainer={(triggerNode) => triggerNode.parentElement}
178
+ {...currentSelectProps}
179
+ >
180
+ {source.map((item: any) => (
181
+ <Select.Option key={item.value} label={item.text}>
182
+ {LightHeightOption({
183
+ text: handleSelectOptionsShowValue(specialBracket, noNeedSplit, item),
184
+ filterTxt: searchValue,
185
+ needToolTips: false
186
+ })}
187
+ </Select.Option>
188
+ ))}
189
+ </Select>
190
+ </div>
191
+ <Modal
192
+ width={600}
193
+ title="多值录入"
194
+ visible={isModalVisible}
195
+ onOk={handleOk}
196
+ onCancel={handleCancel}
197
+ className='multiInput_modal'
198
+ bodyStyle={{
199
+ padding: '10px 16px'
200
+ }}
201
+ footer={[
202
+ <ConfigProvider autoInsertSpaceInButton = { false }>
203
+ <Button key="back" onClick={handleCancel}>
204
+ 取消
205
+ </Button>
206
+ </ConfigProvider>,
207
+ <ConfigProvider autoInsertSpaceInButton = { false }>
208
+ <Button key="submit" type="primary" onClick={handleOk}>
209
+ 录入
210
+ </Button>
211
+ </ConfigProvider>,
212
+ ]}
213
+ >
214
+ <div className={'query_select_wrapper'}>
215
+ <div className={'query_select_wrapper_top'}>如需同时使用多个值进行查询,请使用逗号,分号、空格或换行进行值的分割,中英文格式的符号均支持</div>
216
+ <div className={'query_select_textArea'}>
217
+ <Input.TextArea
218
+ placeholder='在此录入...'
219
+ value={popvalue}
220
+ onChange={onChange}
221
+ rows={12}
222
+ showCount={false}
223
+ />
224
+ </div>
225
+ </div>
226
+ </Modal>
227
+ </div>
228
+ );
229
+ };
230
+
231
+ function ToCDB(selectStr: any) {
232
+ var tmp = '';
233
+ if(!selectStr?.length) return '';
234
+ const str = Array.isArray(selectStr) ? selectStr.join(',') : selectStr;
235
+ for (var i = 0; i < str?.length; i++) {
236
+ if (str?.charCodeAt?.(i) > 65248 && str?.charCodeAt?.(i) < 65375) {
237
+ tmp += String.fromCharCode(str?.charCodeAt(i) - 65248);
238
+ } else {
239
+ tmp += String.fromCharCode(str.charCodeAt(i));
240
+ }
241
+ }
242
+ return tmp;
243
+ }
244
+
245
+ export default QueryMutipleSearchSelect;
@@ -159,7 +159,6 @@
159
159
  background-color: #fff;
160
160
  .ant-form {
161
161
  padding: 0;
162
- overflow: hidden;
163
162
  display: flex;
164
163
  align-items: flex-start;
165
164