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

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 (34) 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 +16 -1
  8. package/dist/index.d.ts +2 -0
  9. package/dist/index.esm.js +1954 -984
  10. package/dist/index.js +1953 -981
  11. package/package.json +3 -3
  12. package/src/components/Business/BsSulaQueryTable/utils.tsx +5 -4
  13. package/src/components/Business/PropertyModal/index.less +58 -0
  14. package/src/components/Business/PropertyModal/index.md +33 -0
  15. package/src/components/Business/PropertyModal/index.tsx +271 -0
  16. package/src/components/Business/PropertyModal/mockData.ts +160 -0
  17. package/src/components/Business/PropertyModal/propertyGroup.tsx +205 -0
  18. package/src/components/Business/SearchSelect/BusinessUtils.tsx +55 -3
  19. package/src/components/Business/SearchSelect/index.md +3 -4
  20. package/src/components/Business/columnSettingTable/columnSetting.tsx +2 -1
  21. package/src/components/Business/columnSettingTable/components/TableSumComponent.tsx +25 -0
  22. package/src/components/Business/columnSettingTable/components/style.less +25 -0
  23. package/src/components/Business/columnSettingTable/index.tsx +3 -28
  24. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +2 -27
  25. package/src/components/Functional/DataValidation/index.tsx +1 -0
  26. package/src/components/Functional/QueryMutipleSelect/index.less +117 -0
  27. package/src/components/Functional/QueryMutipleSelect/index.md +41 -0
  28. package/src/components/Functional/QueryMutipleSelect/index.tsx +242 -0
  29. package/src/components/Functional/SearchSelect/index.less +33 -1
  30. package/src/components/Functional/SearchSelect/index.tsx +76 -269
  31. package/src/components/Functional/SearchSelect/utils.tsx +400 -0
  32. package/src/components/Solution/RuleComponent/ruleFiled.js +93 -93
  33. package/src/index.ts +2 -0
  34. package/src/components/Functional/SearchSelect/utils.ts +0 -38
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bit-sun/business-component",
3
- "version": "4.0.12-alpha.9",
3
+ "version": "4.0.13-alpha.2",
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",
@@ -30,6 +30,8 @@ import { getMenuAuthDataKey } from '@/utils/LocalstorageUtils';
30
30
  import noImg from '../../../assets/list-no-img.svg';
31
31
  import qs from 'qs';
32
32
  import { shouldUseAuth } from '@/utils';
33
+ import * as ReactDOMServer from 'react-dom/server';
34
+
33
35
 
34
36
  export const handleStatusBadge = (text: any, color: any) => {
35
37
  return (
@@ -721,8 +723,7 @@ export const authFn = (code?: any) => {
721
723
  export const renderToString = (
722
724
  render: ReactElement<any, string | JSXElementConstructor<any>> | string,
723
725
  ) => {
724
- return render;
725
- // return typeof render === 'string'
726
- // ? render
727
- // : ReactDOMServer.renderToString(render);
726
+ return typeof render === 'string'
727
+ ? render
728
+ : ReactDOMServer.renderToString(render);
728
729
  };
@@ -0,0 +1,58 @@
1
+ .property_classify_content {
2
+ margin-bottom: 15px;
3
+ }
4
+
5
+ .property_classify_content1 {
6
+ max-height: 350px;
7
+ overflow-y: scroll;
8
+ overflow-x: hidden;
9
+ }
10
+ //滚动条
11
+ /* 滚动槽(轨道)宽高 */
12
+ .property_classify_content1::-webkit-scrollbar {
13
+ width: 5px; /*对垂直流动条有效*/
14
+ height: 5px; /*对水平流动条有效*/
15
+ }
16
+ /* 滚动槽(轨道)样式 */
17
+ .property_classify_content1::-webkit-scrollbar-track {
18
+ background-color: #ffffff;
19
+ border-radius: 8px;
20
+ }
21
+
22
+ /*定义滑块颜色、内阴影及圆角*/
23
+ .property_classify_content1::-webkit-scrollbar-thumb {
24
+ border-radius: 7px;
25
+ background-color: #CECECE;
26
+ }
27
+
28
+ /*定义两端按钮的样式*/
29
+ .property_classify_content1::-webkit-scrollbar-button {
30
+ display: none;
31
+ }
32
+
33
+ .propertyGroup_container {
34
+ display: flex;
35
+ margin-bottom: 16px;
36
+ .propertyGroup_container_left {
37
+ width: 100px;
38
+ flex-shrink: 0;
39
+ flex-grow: 0;
40
+ }
41
+ .propertyGroup_container_right {
42
+ width: 560px;
43
+ flex-shrink: 0;
44
+ flex-grow: 0;
45
+ display: flex;
46
+ flex-wrap: wrap;
47
+ }
48
+ .ant-checkbox-wrapper + .ant-checkbox-wrapper {
49
+ margin-left: 0px;
50
+ }
51
+ }
52
+
53
+ .propertyGroup_checkbox_container {
54
+ width: 80px;
55
+ overflow: hidden;
56
+ text-overflow: ellipsis;
57
+ white-space: nowrap;
58
+ }
@@ -0,0 +1,33 @@
1
+ ---
2
+ nav:
3
+ title: '组件'
4
+ order: 1
5
+ group:
6
+ title: 业务组件
7
+ order: 1
8
+ title: PropertySelector 属性选择器
9
+ order: 1
10
+ ---
11
+
12
+ # PropertySelector
13
+
14
+ ## 属性选择器
15
+
16
+ ```tsx
17
+ import React, { useState } from 'react';
18
+ import PropertySelector from './index.tsx';
19
+
20
+ export default () => {
21
+
22
+ const [value, setValue] = useState({});
23
+
24
+ return (
25
+ <div style={{ width: '200px' }}>
26
+ <PropertySelector
27
+ value={value}
28
+ onChange={(value) => setValue(value)}
29
+ />
30
+ </div>
31
+ );
32
+ };
33
+ ```
@@ -0,0 +1,271 @@
1
+ import React, { useEffect, useState, useRef } from "react";
2
+ import { Modal, Select, Tag } from "antd";
3
+ import "./index.less";
4
+ import { MockPropertyList } from "./mockData";
5
+ import PropertyGroup from "./propertyGroup";
6
+ import { CaretUpOutlined, CaretDownOutlined, CaretUpFilled, CaretDownFilled } from '@ant-design/icons';
7
+ import request from '@/utils/request';
8
+ import { judgeIsRequestError } from "@/utils";
9
+
10
+ interface propertyValueType {
11
+ propertyName: string;
12
+ propertyCode: string;
13
+ isCommonUse?: Boolean | String;
14
+ detailList: Array<{
15
+ name: string;
16
+ value: string;
17
+ isCommonUse?: Boolean | String;
18
+ }>;
19
+ }
20
+
21
+ interface valueType {
22
+ classifyCode: string;
23
+ classifyName: string;
24
+ propertyList: propertyValueType[];
25
+ }
26
+
27
+ interface PropertyGroupValueType {
28
+ propertyCode: string;
29
+ propertyName: string;
30
+ detailList: Array<{
31
+ name: string;
32
+ value: string;
33
+ }>;
34
+ }
35
+ const PropertySelector = ({
36
+ value,
37
+ onChange,
38
+ width,
39
+ ...restProps
40
+ }: { value: valueType, onChange: any, width: string }
41
+ ) => {
42
+ const settingValue = useRef<valueType>({
43
+ classifyCode: '',
44
+ classifyName: '',
45
+ propertyList: []
46
+ });
47
+ const [choosedValues, setChoosedValues] = useState<any[]>([]);
48
+ const [choosedClassify, setChoosedClassify] = useState('');
49
+ const [commonProperty, setCommonUseProperty] = useState<any[]>([]);
50
+ const [notCommonProperty, setNotCommonProperty] = useState<any[]>([]);
51
+
52
+ const [visible, setVisible] = useState(false);
53
+ const [showNotCommon, setShowNotCommon] = useState(false); // 是否展示非常用属性
54
+ const [classifyOptionList, setClassifyOptionList] = useState<any[]>([]);
55
+ const [listKey, setListKey] = useState('1');
56
+
57
+ useEffect(() => {
58
+ request({
59
+ url: '/items/class/withProperty?pageSize=500&currentPage=1',
60
+ method: 'GET',
61
+ })
62
+ .then(({data}: any) => {
63
+ if (judgeIsRequestError(data)) {
64
+ return
65
+ }
66
+ const items = data.data?.items || [];
67
+ setClassifyOptionList(items.map((item: any) => ({
68
+ label: item.name,
69
+ value: item.id,
70
+ })))
71
+ })
72
+ }, [])
73
+
74
+ useEffect(() => {
75
+ if (!choosedClassify) return;
76
+ request({
77
+ url: `/items/classProperty/${choosedClassify}`,
78
+ method: 'GET',
79
+ })
80
+ .then(({data}: any) => {
81
+ if (judgeIsRequestError(data)) {
82
+ return
83
+ }
84
+
85
+ const newArr = (data?.data || []).map((item: any) => {
86
+ return {
87
+ propertyCode: item.property?.propertyCode,
88
+ propertyName: item.property?.name,
89
+ propertyId: item.property?.id,
90
+ isCommonUse: item.property?.isCommonUse === 'commonUse',
91
+ detailList: (item.propertyValueList || []).map((detail: any) => ({
92
+ name: detail.value,
93
+ value: detail.value,
94
+ isCommonUse: detail.isCommonUse === 'commonUse',
95
+ }))
96
+ }
97
+ })
98
+
99
+ setCommonUseProperty(newArr.filter((item: any) => item.isCommonUse))
100
+ setNotCommonProperty(newArr.filter((item: any) => !item.isCommonUse))
101
+ setListKey(listKey === '1' ? '2' : '1');
102
+ })
103
+ }, [choosedClassify])
104
+
105
+
106
+ useEffect(() => {
107
+ if (visible) {
108
+ // 获取选中品类信息
109
+ setChoosedClassify(value?.classifyCode || classifyOptionList[0]?.value);
110
+ }
111
+ // 获取选中属性值展示
112
+ const choosedPropertyList = (value?.propertyList || []).map(item => (item.detailList || []).map(detail => detail.name)).flat();
113
+ if ((value?.propertyList || []).some(item => !item.isCommonUse)) {
114
+ setShowNotCommon(true);
115
+ }
116
+ settingValue.current = {
117
+ ...value,
118
+ classifyCode: value?.classifyCode || classifyOptionList[0]?.value,
119
+ };
120
+ setChoosedValues(choosedPropertyList);
121
+
122
+ }, [value, visible])
123
+
124
+ // 关闭弹窗回传组件值
125
+ const handleConfirm = () => {
126
+ setVisible(false);
127
+ onChange(settingValue.current);
128
+ }
129
+ const onCancel = () => {
130
+ setVisible(false);
131
+ }
132
+
133
+ // 获取选中属性值信息
134
+ const handleProperyItemChange = (value: PropertyGroupValueType) => {
135
+ const newDetailList = settingValue.current?.propertyList || [];
136
+ const itemIndex = newDetailList.findIndex((item: any) => item.propertyCode === value.propertyCode);
137
+ if (itemIndex !== -1) {
138
+ newDetailList[itemIndex] = value;
139
+ } else {
140
+ newDetailList.push(value);
141
+ }
142
+ settingValue.current = {
143
+ ...settingValue.current,
144
+ propertyList: newDetailList.filter(item => item.detailList && item.detailList.length),
145
+ };
146
+ }
147
+
148
+ //修改品类值
149
+ const onClassifyChange = (value: string, option: any) => {
150
+ setChoosedClassify(value);
151
+ settingValue.current = {
152
+ classifyCode: value,
153
+ classifyName: option.children,
154
+ propertyList: [],
155
+ };
156
+ };
157
+
158
+ const tagRender = (props: any) => {
159
+ const { label, value, closable, onClose } = props;
160
+ const onPreventMouseDown = (event: any) => {
161
+ event.preventDefault();
162
+ event.stopPropagation();
163
+ };
164
+ return (
165
+ <Tag
166
+ closable={false}
167
+ style={{ marginRight: 3, height: '20px', fontSize: '12px' }}
168
+ >
169
+ {label}
170
+ </Tag>
171
+ );
172
+ };
173
+
174
+ return (
175
+ <div>
176
+ <Select
177
+ maxTagCount={1}
178
+ tagRender={tagRender}
179
+ {...restProps}
180
+ mode="multiple"
181
+ value={choosedValues}
182
+ onClick={() => {
183
+ setVisible(true)
184
+ }}
185
+ style={{ width: width || '100%' }}
186
+ open={false}
187
+ />
188
+ <Modal
189
+ title="属性设置"
190
+ width={700}
191
+ open={visible}
192
+ onOk={handleConfirm}
193
+ destroyOnClose
194
+ onCancel={onCancel}
195
+ cancelText={'取消'}
196
+ okText={'确定'}
197
+ >
198
+ <div>
199
+ <div className={'property_classify_content'}>
200
+ <span style={{ marginRight: '10px' }}>品类模板</span>
201
+ <Select
202
+ style={{ width: '200px' }}
203
+ value={choosedClassify}
204
+ options={classifyOptionList}
205
+ onChange={(value, option) => {
206
+ onClassifyChange(value, option);
207
+ }}
208
+ />
209
+ </div>
210
+ <div className={'property_classify_content1'} key={listKey}>
211
+ <div>
212
+ {
213
+ commonProperty.map(item => (
214
+ <PropertyGroup
215
+ modalVisilbe={visible}
216
+ itemValue={settingValue.current}
217
+ propertyData={item}
218
+ handleProperyItemChange={handleProperyItemChange}
219
+ />
220
+ ))
221
+ }
222
+ </div>
223
+ <div>
224
+ {
225
+ showNotCommon && notCommonProperty.map(item => (
226
+ <PropertyGroup
227
+ modalVisilbe={visible}
228
+ itemValue={settingValue.current}
229
+ propertyData={item}
230
+ handleProperyItemChange={handleProperyItemChange}
231
+ />
232
+ ))
233
+ }
234
+ </div>
235
+ </div>
236
+ {
237
+ !!notCommonProperty.length && (
238
+ <div>
239
+ <div
240
+ style={{ width: '50px', cursor: 'pointer', color: '#005cff', fontSize: '10px' }}
241
+ onClick={() => setShowNotCommon(!showNotCommon)}
242
+ >
243
+ {
244
+ showNotCommon && (
245
+ <>
246
+ <CaretUpOutlined />
247
+ 收起
248
+ </>
249
+ )
250
+ }
251
+ {
252
+ !showNotCommon && (
253
+ <>
254
+ <CaretDownOutlined />
255
+ 展开
256
+ </>
257
+ )
258
+ }
259
+ </div>
260
+ </div>
261
+ )
262
+ }
263
+ </div>
264
+
265
+ </Modal>
266
+ </div>
267
+ )
268
+ }
269
+
270
+ export default PropertySelector;
271
+
@@ -0,0 +1,160 @@
1
+ export const MockPropertyList = [
2
+ {
3
+ propertyCode: 'year',
4
+ propertyName: '年份',
5
+ isCommonUse: true,
6
+ detailList: [
7
+ {
8
+ name: '2022',
9
+ value: '2022',
10
+ isCommonUse: true,
11
+ },
12
+ {
13
+ name: '2023',
14
+ value: '2023',
15
+ isCommonUse: true,
16
+ },
17
+ {
18
+ name: '2024',
19
+ value: '2024',
20
+ isCommonUse: true,
21
+ },
22
+ ]
23
+ },
24
+ {
25
+ propertyCode: 'season',
26
+ propertyName: '季节',
27
+ isCommonUse: true,
28
+ detailList: [
29
+ {
30
+ name: '春',
31
+ value: '1',
32
+ isCommonUse: true,
33
+ },
34
+ {
35
+ name: '夏',
36
+ value: '2',
37
+ isCommonUse: true,
38
+ },
39
+ {
40
+ name: '秋',
41
+ value: '3',
42
+ isCommonUse: true,
43
+ },
44
+ {
45
+ name: '冬',
46
+ value: '4',
47
+ isCommonUse: true,
48
+ },
49
+ ]
50
+ },
51
+ {
52
+ propertyCode: 'color',
53
+ propertyName: '色号',
54
+ isCommonUse: true,
55
+ detailList: [
56
+ {
57
+ name: '赤',
58
+ value: '1',
59
+ isCommonUse: true,
60
+ },
61
+ {
62
+ name: '橙',
63
+ value: '2',
64
+ isCommonUse: true,
65
+ },
66
+ {
67
+ name: '红',
68
+ value: '3',
69
+ isCommonUse: true,
70
+ },
71
+ {
72
+ name: '绿',
73
+ value: '4',
74
+ isCommonUse: true,
75
+ },
76
+ {
77
+ name: '青',
78
+ value: '5',
79
+ isCommonUse: true,
80
+ },
81
+ {
82
+ name: '蓝',
83
+ value: '6',
84
+ isCommonUse: true,
85
+ },
86
+ {
87
+ name: '紫',
88
+ value: '7',
89
+ isCommonUse: true,
90
+ },
91
+ {
92
+ name: '橘红',
93
+ value: '8',
94
+ isCommonUse: false,
95
+ },
96
+ {
97
+ name: '天蓝',
98
+ value: '9',
99
+ isCommonUse: false,
100
+ },
101
+ {
102
+ name: '银白',
103
+ value: '10',
104
+ isCommonUse: false,
105
+ },
106
+ {
107
+ name: '紫',
108
+ value: '11',
109
+ isCommonUse: false,
110
+ },
111
+ ]
112
+ },
113
+ {
114
+ propertyCode: 'brandCode',
115
+ propertyName: '品牌',
116
+ isCommonUse: false,
117
+ detailList: [
118
+ {
119
+ name: '品牌2',
120
+ value: '2',
121
+ isCommonUse: true,
122
+ },
123
+ {
124
+ name: '品牌3',
125
+ value: '3',
126
+ isCommonUse: true,
127
+ },
128
+ {
129
+ name: '品牌4',
130
+ value: '4',
131
+ isCommonUse: true,
132
+ },
133
+
134
+ ]
135
+ },
136
+ {
137
+ propertyCode: 'size',
138
+ propertyName: '尺码',
139
+ isCommonUse: false,
140
+ detailList: [
141
+ {
142
+ name: 'M',
143
+ value: '2',
144
+ isCommonUse: true,
145
+ },
146
+ {
147
+ name: 'L',
148
+ value: '3',
149
+ isCommonUse: true,
150
+ },
151
+ {
152
+ name: 'XL',
153
+ value: '4',
154
+ isCommonUse: true,
155
+ },
156
+
157
+ ]
158
+ },
159
+
160
+ ]