@bit-sun/business-component 4.0.12-alpha.9 → 4.0.13-alpha.11

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 (35) hide show
  1. package/dist/components/Business/BsSulaQueryTable/utils.d.ts +1 -1
  2. package/dist/components/Business/PropertyModal/index.d.ts +23 -0
  3. package/dist/components/Business/PropertyModal/mockData.d.ts +10 -0
  4. package/dist/components/Business/PropertyModal/propertyGroup.d.ts +4 -0
  5. package/dist/components/Business/columnSettingTable/components/TableSumComponent.d.ts +4 -0
  6. package/dist/components/Functional/QueryMutipleSelect/index.d.ts +5 -0
  7. package/dist/components/Functional/SearchSelect/utils.d.ts +18 -1
  8. package/dist/index.d.ts +2 -0
  9. package/dist/index.esm.js +1635 -635
  10. package/dist/index.js +1632 -630
  11. package/package.json +4 -3
  12. package/src/components/Business/BsSulaQueryTable/setting.tsx +3 -3
  13. package/src/components/Business/BsSulaQueryTable/utils.tsx +6 -4
  14. package/src/components/Business/PropertyModal/index.less +58 -0
  15. package/src/components/Business/PropertyModal/index.md +33 -0
  16. package/src/components/Business/PropertyModal/index.tsx +271 -0
  17. package/src/components/Business/PropertyModal/mockData.ts +160 -0
  18. package/src/components/Business/PropertyModal/propertyGroup.tsx +205 -0
  19. package/src/components/Business/SearchSelect/BusinessUtils.tsx +60 -3
  20. package/src/components/Business/SearchSelect/index.md +4 -5
  21. package/src/components/Business/columnSettingTable/columnSetting.tsx +2 -1
  22. package/src/components/Business/columnSettingTable/components/TableSumComponent.tsx +25 -0
  23. package/src/components/Business/columnSettingTable/components/style.less +25 -0
  24. package/src/components/Business/columnSettingTable/index.tsx +3 -28
  25. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +2 -27
  26. package/src/components/Functional/DataValidation/index.tsx +1 -0
  27. package/src/components/Functional/QueryMutipleSelect/index.less +117 -0
  28. package/src/components/Functional/QueryMutipleSelect/index.md +40 -0
  29. package/src/components/Functional/QueryMutipleSelect/index.tsx +242 -0
  30. package/src/components/Functional/SearchSelect/index.less +45 -7
  31. package/src/components/Functional/SearchSelect/index.tsx +85 -303
  32. package/src/components/Functional/SearchSelect/utils.tsx +439 -0
  33. package/src/components/Solution/RuleComponent/ruleFiled.js +93 -93
  34. package/src/index.ts +2 -0
  35. package/src/components/Functional/SearchSelect/utils.ts +0 -38
@@ -0,0 +1,439 @@
1
+ import React from 'react';
2
+ import { stringify } from 'querystring';
3
+ import { omit, uniqBy, escapeRegExp } from "lodash";
4
+ import moment from 'moment';
5
+ import { Tooltip, Tag } from 'antd';
6
+
7
+ export const columnsPerRow = 4; // 每行的列数
8
+ export const ColSpan = 6; // 查询条件 每行col = 24 /columnsPerRow
9
+ export const handleSourceName = (sName: any) => {
10
+ return sName
11
+ }
12
+
13
+ // 生成唯一值
14
+ export const makeUniqueValue = () => {
15
+ const generateUnitKey = (((1 + Math.random()) * 0x10000) | 0).toString(16);
16
+ return generateUnitKey;
17
+ }
18
+
19
+ // ------------------------------------------处理样式相关--开始----------------------------------------
20
+ export const getFormRowInfo = (list: any) => {
21
+ const totalRows = Math.ceil(list.length / columnsPerRow); // 计算总行数
22
+ const lastRowColumns = (list.length+1) % columnsPerRow; // 计算最后一行的实际列数
23
+ const emptySlots = lastRowColumns === 0 ? 0 : columnsPerRow - lastRowColumns; // 计算最后一行的空位数
24
+ const emptyArray = new Array(emptySlots).fill(null); // 生成长度为 emptySlots 的数组
25
+ return { totalRows, emptyArray }
26
+ }
27
+
28
+ export const defaultVisibleFieldsCount = 7;
29
+ export const getVisibleFieldsCount = (modalTableProps: any) => {
30
+ const { visibleFieldsCount = defaultVisibleFieldsCount, tableSearchForm } = modalTableProps || {};
31
+ let count = visibleFieldsCount;
32
+ if (count === true) {
33
+ return tableSearchForm?.length;
34
+ }
35
+ return count!;
36
+ }
37
+ export const hasMoreQueryFields = (modalTableProps: any) => {
38
+ const { tableSearchForm } = modalTableProps || {}
39
+ const visibleFieldsCount = getVisibleFieldsCount(modalTableProps);
40
+ return visibleFieldsCount < tableSearchForm?.length;
41
+ }
42
+ export const getTableHeigth = (list: any) => {
43
+ const totalRows = Math.ceil((list?.length+1) / 4);
44
+ if(totalRows == 1) return 358; // modal弹窗760 调整为700 适应小屏
45
+ return 411 - totalRows*10
46
+ }
47
+
48
+ // ------------------------------------------处理样式相关--结束----------------------------------------
49
+
50
+
51
+ // ------------------------------------------处理数据相关--开始----------------------------------------
52
+ export const formatSelectedValue = (value: any) => {
53
+ return value?.map((s: any) => ({
54
+ value: s?.value||s,
55
+ key: s?.key||s?.value||s,
56
+ label: s?.label|| '',
57
+ }))||[];
58
+ }
59
+ export const getRealStr = (oldSelect: any,newSelect: any, record: any) => {
60
+ return oldSelect?.length ? oldSelect.some((o: any) => o.value == record?.value) ? oldSelect.filter((s: any) => s.value != record?.value) : [...oldSelect,...newSelect] : newSelect;
61
+ }
62
+ export const getCurrentSRKs = (selectMode: any,labelInValue:boolean,value: any) => {
63
+ return selectMode ? (labelInValue ? value?.map((s: any)=> (s?.value||s)) : value) : (labelInValue ? value?.value&&[value?.value]||[] : value&&[value]||[])
64
+ }
65
+ export const getRenderSource = (currentSRKs: any, items: any) => {
66
+ // 判空处理
67
+ if(!currentSRKs?.length) return items||[];
68
+
69
+ // 创建映射对象 用于记录原始选中顺序
70
+ const orderMap = new Map<number, number>();
71
+ currentSRKs?.forEach((value: any, index: number) => {
72
+ orderMap.set(value, index);
73
+ });
74
+
75
+ // 被选中数据集合,获取之后排序
76
+ const selectedOption = items?.filter((option: any) => currentSRKs?.includes(option.value))||[];
77
+ const selectedOptionSort = selectedOption?.sort((a: any, b: any) => {
78
+ return (orderMap.get(a.value) ?? Infinity) - (orderMap.get(b.value) ?? Infinity);
79
+ })||[];
80
+
81
+ // 未选中数据集合
82
+ const otherOptions = items?.filter((option: any) => !currentSRKs?.includes(option.value))||[];
83
+
84
+ return [
85
+ ...selectedOptionSort,
86
+ ...otherOptions
87
+ ]
88
+ }
89
+
90
+ // ------------------------------------------处理数据相关--结束----------------------------------------
91
+
92
+
93
+
94
+ // ------------------------------------------查询 & 数据源 相关处理--开始----------------------------------------
95
+ export const handleParams = (params: any) => {
96
+ for (const key in params) {
97
+ if (Object.prototype.hasOwnProperty.call(params, key)) {
98
+ const element = params[key];
99
+ if (element && key.indexOf('*number*') >= 0) {
100
+ const dataParams = key.split('*number*');
101
+ dataParams.forEach((value, index) => {
102
+ params[value] = element[index];
103
+ });
104
+ delete params[key];
105
+ } else if (element && key.indexOf('*address*') >= 0) {
106
+ const dataParams = key.split('*address*');
107
+ dataParams.forEach((value, index) => {
108
+ params[value] = element.PCDCode[index];
109
+ });
110
+ delete params[key];
111
+ } else if (element && key.indexOf('*costType*') >= 0) {
112
+ const dataParams = key.split('*costType*');
113
+ // eslint-disable-next-line prefer-destructuring
114
+ params[dataParams[0]] = element[1];
115
+ delete params[key];
116
+ } else if (element && key.indexOf('*fullDate*') >= 0) {
117
+ const dataParams = key.split('*fullDate*');
118
+ dataParams.forEach((value, index) => {
119
+ if (index === 0) {
120
+ params[value] = moment(element[index])
121
+ .millisecond(0)
122
+ .second(0)
123
+ .minute(0)
124
+ .hour(0)
125
+ .format('YYYY-MM-DD HH:mm:ss');
126
+ } else {
127
+ params[value] = moment(element[index])
128
+ .millisecond(59)
129
+ .second(59)
130
+ .minute(59)
131
+ .hour(23)
132
+ .format('YYYY-MM-DD HH:mm:ss');
133
+ }
134
+ });
135
+ delete params[key];
136
+ } else if (typeof element === 'boolean' && key.indexOf('*checkBox*') >= 0) {
137
+ const dataParams = key.split('*checkBox*');
138
+ if (element) {
139
+ params[dataParams[0]] = 0
140
+ }
141
+ delete params[key];
142
+ } else if (element && key.indexOf('*cascader*') >= 0) {
143
+ const dataParams = key.split('*cascader*');
144
+ params[dataParams[0]] = element[element.length - 1]
145
+ delete params[key];
146
+ } else if (element && key.indexOf('*date*') >= 0) {
147
+ const dataParams = key.split('*date*')
148
+ dataParams.forEach((value, index) => {
149
+ if (index === 0) {
150
+ params[value] = moment(element[index])
151
+ .format('YYYY-MM-DD');
152
+ } else {
153
+ params[value] = moment(element[index])
154
+ .format('YYYY-MM-DD');
155
+ }
156
+ });
157
+ delete params[key];
158
+ } else if (element && key.indexOf('*multiInput') >= 0) {
159
+ let name = '',
160
+ value = element['value'];
161
+ if (value.indexOf(',') >= 0) {
162
+ name = `qp-${element['name']}-in`;
163
+ } else {
164
+ name = `qp-${element['name']}-like`;
165
+ }
166
+ params[name] = value;
167
+ delete params[key];
168
+ }
169
+ else if (element && key.indexOf('*') >= 0) {
170
+ const dataParams = key.split('*');
171
+ dataParams.forEach((value, index) => {
172
+ params[value] = element[index].format('YYYY-MM-DD HH:mm:ss');
173
+ });
174
+ delete params[key];
175
+ } else if (element && key.indexOf('_selectNumberRange') >= 0) { // key = xxxxx_selectNumberRange qp-xxxxx-gt
176
+ const dataParams = key.split('_selectNumberRange')[0]
177
+ if (params[key][0] === 'range') {
178
+ if (params[key][1][0]) {
179
+ params[`qp-${dataParams}-ge`] = params[key][1][0]
180
+ }
181
+ if (params[key][1][1]) {
182
+ params[`qp-${dataParams}-le`] = params[key][1][1]
183
+ }
184
+ } else {
185
+ params[`qp-${dataParams}-${params[key][0]}`] = params[key][1]
186
+ }
187
+ delete params[key]
188
+ } else if (Array.isArray(element)) {
189
+ params[key] = element.join(',');
190
+ } else if (element == null || element === undefined || String(element).trim() === '') {
191
+ delete params[key]
192
+ }
193
+ }
194
+ }
195
+ }
196
+
197
+ //处理单据编号查询 如果是查询单条数据 就是模糊查询 两条以上就是精准查询
198
+ export const convertOrderNo = (params: any) => {
199
+ //需要处理得编号字段名
200
+ const arr = [
201
+ 'qp-skuCode-in',
202
+ 'qp-eancode-in',
203
+ 'qp-itemCode-in',
204
+ ];
205
+ for (let i = 0; i < arr.length; i++) {
206
+ if (params[arr[i]]) {
207
+ if (!params[arr[i]].includes(',')) {
208
+ params[arr[i].replace(/(.*)in/, '$1like')] = params[arr[i]];
209
+ delete params[arr[i]];
210
+ }
211
+ }
212
+ }
213
+ return params;
214
+ };
215
+
216
+ export const convertQueryParams = (params: any) => {
217
+ const result = convertOrderNo(params)
218
+ return omit(result,['UNIQUE_SPEC']); // 处理sku选择器属性参数
219
+ }
220
+ export const convertUrlQueryParams = (params: any) => {
221
+ // 非query请求:默认参数拼接URL,设置属性noUrlQueryParams可不拼接
222
+ return params?.noUrlQueryParams ? '' : `?${stringify(convertQueryParams(params))}`;
223
+ }
224
+
225
+ export const convertBodyParams = (params: any) => {
226
+ // 处理sku选择器属性参数
227
+ let unique_params = null;
228
+ if (params['UNIQUE_SPEC']) {
229
+ unique_params = params['UNIQUE_SPEC']?.propertyList || [];
230
+ }
231
+
232
+ // body参数来源:sku选择器固定参数 > 调用所传bodyParams > 默认参数-无
233
+ return unique_params || params?.bodyParams || null;
234
+ }
235
+
236
+
237
+ const convertRes = (data: any, otherParams: any) => {
238
+ const {
239
+ mappingTextField,
240
+ mappingTextShowTextField,
241
+ mappingTextShowKeyField,
242
+ mappingValueField,
243
+ specialBracket,
244
+ type,
245
+ queryParams,
246
+ } = otherParams;
247
+
248
+ return data.map((item: any, index: number) => {
249
+ let textShowText = item[mappingTextField];
250
+ if (mappingTextShowTextField) {
251
+ textShowText = []
252
+ if (Array.isArray(mappingTextShowTextField)) {
253
+ mappingTextShowTextField.forEach((r: any) => {
254
+ textShowText.push(item[r])
255
+ })
256
+ } else {
257
+ textShowText = item[mappingTextShowTextField]
258
+ }
259
+ }
260
+ if(!item?.children?.length) {delete item?.children};
261
+ return {
262
+ ...item,
263
+ text: specialBracket
264
+ ? `【${item[mappingValueField]}】${item[mappingTextField]}`
265
+ : item[mappingTextField],
266
+ textShowText,
267
+ textShowKey: item[mappingTextShowKeyField || mappingValueField],
268
+ value: item[mappingValueField],
269
+ ...(queryParams?.pageSize ? {keyIndex: type != 1 ? ((queryParams?.currentPage - 1) * queryParams?.pageSize + index + 1) : (index+1) } : {}),
270
+ };
271
+ })
272
+ }
273
+ export const convertResData = (requestConfig: any,res: any, selectProps: any) => {
274
+ const { isMap, mappingTextField, mappingTextShowTextField, specialBracket, mappingValueField, mappingTextShowKeyField } = requestConfig;
275
+ const { selectMode, labelInValue, value, type, items, queryParams, needTopSelectedSource = true } = selectProps;
276
+ const otherParams = {
277
+ mappingTextField,
278
+ mappingTextShowTextField,
279
+ mappingTextShowKeyField,
280
+ mappingValueField,
281
+ specialBracket,
282
+ type,
283
+ queryParams,
284
+ };
285
+
286
+ let source: any = [];
287
+
288
+ if (isMap) {
289
+ source = Object.keys(res).map((d, i) => {
290
+ return {
291
+ text: Object.values(res)[i],
292
+ value: d,
293
+ };
294
+ });
295
+ } else {
296
+ const keys = res.list ? 'list' : 'items';
297
+ source = res
298
+ ? res[keys]
299
+ ? convertRes(res[keys], otherParams)
300
+ : Array.isArray(res) &&
301
+ convertRes(res, otherParams)
302
+ : [];
303
+ }
304
+
305
+ // 补充搜索项--选中的数据添加到数据源中去
306
+ const currentSRKs = getCurrentSRKs(selectMode,labelInValue,value)
307
+ if(needTopSelectedSource && type === 1 && currentSRKs?.length && currentSRKs?.some((s: any)=> !source?.find((r: any)=> r.value==s))) {
308
+ const selectedOption = items.filter((option: any) => currentSRKs?.includes(option.value))||[];
309
+ source = (source||[]).concat(selectedOption)
310
+ }
311
+
312
+ // 数据源 不可以有重复key
313
+ source = Array.isArray(source) ? uniqBy(source, 'value') : [];
314
+
315
+ return source;
316
+ }
317
+
318
+ // ------------------------------------------查询 & 数据源 相关处理--结束----------------------------------------
319
+
320
+
321
+
322
+ // ------------------------------------------ 数据源展示 相关处理--开始----------------------------------------
323
+
324
+ export const handleSelectOptionsShowValue = (specialBracket: boolean, noNeedSplit: boolean, item: any) => {
325
+ let showText = Array.isArray(item.textShowText) &&
326
+ item.textShowText.join(' ') || item.textShowText;
327
+ if (noNeedSplit) {
328
+ return item.text;
329
+ } else {
330
+ return specialBracket
331
+ ? `【${item.textShowKey || ''}】${showText}`
332
+ : `${item.textShowKey || ''} ${showText}`
333
+ }
334
+ };
335
+
336
+ export const LightHeightOption = (props: any) => {
337
+ const {
338
+ filterTxt, text,
339
+ needToolTips = true
340
+ } = props
341
+ const heightLightTxt = (text: string, heightTxt: string) => {
342
+ if (heightTxt === '') {
343
+ return text
344
+ }
345
+ const searchString = escapeRegExp(heightTxt);
346
+ // 前面filterOption 不区分大小写,这里用i
347
+ const regexp = new RegExp(searchString, 'gi')
348
+ return text.replace(regexp, `<span style="color:red">${heightTxt}</span>`)
349
+ }
350
+ const renderContent = <div ref={(nodeElement) => {if (nodeElement) { nodeElement.innerHTML = heightLightTxt(text, filterTxt)} }} />
351
+
352
+ if(!needToolTips) return renderContent;
353
+ return (
354
+ <Tooltip title={text}>
355
+ {renderContent}
356
+ </Tooltip>
357
+ )
358
+ }
359
+
360
+ export const maxTagPlaceholder = (selectedValues: any, { selectProps, onChange, value, setIsMaxTagsOpen }: any) => {
361
+ const { labelInValue } = selectProps;
362
+ const onClose = (e: any, item: any) => {
363
+ e.preventDefault();
364
+ const newValue = labelInValue ? JSON.parse(JSON.stringify(value)).filter((i: any) => i.value !== item.value) : JSON.parse(JSON.stringify(value)).filter((i: any) => i !== item.value)
365
+ onChange(newValue);
366
+ }
367
+ return (
368
+ <Tooltip
369
+ overlayClassName='searchSelectMaxTagToolTip'
370
+ destroyTooltipOnHide
371
+ placement="topRight"
372
+ autoAdjustOverflow={false}
373
+ title={(
374
+ <div
375
+ style={{ margin: '6px 8px 0px' }}
376
+ onMouseEnter={() => {
377
+ setIsMaxTagsOpen?.(true)
378
+ }}
379
+ onMouseLeave={() => {
380
+ setIsMaxTagsOpen?.(false)
381
+ }}
382
+ >
383
+ {selectedValues.map((i: any) => (
384
+ <Tag
385
+ closable={true}
386
+ onClose={(e: any) => onClose(e, i)}
387
+ style={{ margin: '0px 3px 3px 0px', background: '#f5f5f5', height: '24px', border: '1px solid #f0f0f0' }}
388
+ >
389
+ {i.label}
390
+ </Tag>
391
+ ))}
392
+ </div>
393
+ )}
394
+ >
395
+ {`+ ${selectedValues?.length}`}
396
+ </Tooltip>
397
+ )
398
+ }
399
+
400
+ // 弹窗数据表头处理
401
+ export const handleTableColumns = (tableColumns: any) => {
402
+ // 按照默认设置排序 > 没有排序字段的展示所有列表头 > 没有表头列不展示
403
+ const showTableColumns = tableColumns?.filter((s: any) => typeof s.defaultSort == 'number')||tableColumns||[];
404
+ return showTableColumns?.sort((a: any,b: any)=> a.defaultSort-b.defaultSort)||[]
405
+ };
406
+
407
+ // ------------------------------------------ 数据源展示 相关处理--结束----------------------------------------
408
+
409
+
410
+
411
+ // ------------------------------------------ 选中数据展示 相关处理--开始----------------------------------------
412
+ const getShowLabelTextStr = ({ kongValue, selectMode, value, items }: any) => {
413
+ if (selectMode) {
414
+ return Array.isArray(value) && value?.map(item => item.label || item.text || '')?.join(',') || kongValue;
415
+ }
416
+ return (value?.label || value?.text || kongValue) as string;
417
+ };
418
+ const getSelectValueText = (v: any, items: any) => {
419
+ return (items || []).filter((item: any) => item.value === v)?.[0]?.text || v || '';
420
+ }
421
+ const getShowValueStr = ({ kongValue, selectMode, value, items }: any): string => {
422
+ if (selectMode) {
423
+ return Array.isArray(value) && value?.map(item => getSelectValueText(item, items))?.join(',') || kongValue;
424
+ }
425
+ return (getSelectValueText(value, items) || kongValue) as string;
426
+ }
427
+ export const getShowStr = ({ viewShowValueStr, labelInValue, selectMode, value, items }: any) => {
428
+ // 优先使用业务使用传入的展示
429
+ if(viewShowValueStr) return viewShowValueStr;
430
+
431
+ const kongValue = '无'
432
+ // 先判断labelInValue与否,labelInValue可以直接去value中获取字段名称,否则去下拉框数据里面去拿;
433
+ // 再判断是单选还是多选,数据类型不同取值方式也不同
434
+ if (labelInValue) {
435
+ return getShowLabelTextStr({ kongValue, selectMode, value, items});
436
+ }
437
+ return getShowValueStr({ kongValue, selectMode, value, items });
438
+ }
439
+ // ------------------------------------------ 选中数据展示 相关处理--结束---------------------------------------