@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.
Files changed (35) hide show
  1. package/dist/components/Business/PropertyModal/index.d.ts +23 -0
  2. package/dist/components/Business/PropertyModal/mockData.d.ts +10 -0
  3. package/dist/components/Business/PropertyModal/propertyGroup.d.ts +4 -0
  4. package/dist/components/Business/columnSettingTable/components/TableSumComponent.d.ts +4 -0
  5. package/dist/components/Functional/QueryMutipleSelect/index.d.ts +5 -0
  6. package/dist/components/Functional/SearchSelect/utils.d.ts +16 -1
  7. package/dist/index.d.ts +2 -0
  8. package/dist/index.esm.js +2012 -883
  9. package/dist/index.js +2011 -880
  10. package/package.json +3 -3
  11. package/src/components/Business/BsSulaQueryTable/index.md +113 -20
  12. package/src/components/Business/BsSulaQueryTable/index.tsx +109 -7
  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/SearchSelect/index.tsx +4 -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.md +5 -8
  24. package/src/components/Business/columnSettingTable/index.tsx +3 -28
  25. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +116 -37
  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 +40 -2
  30. package/src/components/Functional/SearchSelect/index.tsx +84 -283
  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/styles/bsDefault.less +0 -1
  35. 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.3",
3
+ "version": "4.0.12-alpha.30",
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",
@@ -23,6 +23,28 @@ import { BsSulaQueryTable } from '../../../index.ts';
23
23
  export default () => {
24
24
  const config = {
25
25
  needPageHeader: false,
26
+ remoteDataSource: {
27
+ url: `https://randomuser.me/api`,
28
+ method: 'GET',
29
+ convertParams({ params }) {
30
+ return {
31
+ results: params.pageSize,
32
+ ...params,
33
+ };
34
+ },
35
+ converter({ data }) {
36
+ return {
37
+ list: data.results.map((item, index) => {
38
+ return {
39
+ ...item,
40
+ id: `${index}`,
41
+ name: `${item.name.first} ${item.name.last}`,
42
+ };
43
+ }),
44
+ total: 100,
45
+ };
46
+ },
47
+ },
26
48
  summary: [{
27
49
  label: '总金额',
28
50
  count: 100
@@ -72,26 +94,97 @@ export default () => {
72
94
  ],
73
95
  columns: [
74
96
  {
75
- dataIndex: 'code',
76
- title: '应用编码',
77
- tableHeadFilterKey: 'qp-code-eq',
78
- },
79
- {
80
- dataIndex: 'operator',
81
- title: '操作',
82
- fixed: 'right',
83
- render: [
84
- {
85
- type: 'link',
86
- code: 'User_ApplicationList_edit',
87
- props: {
88
- type: 'primary',
89
- children: '编辑',
90
- },
91
- visible: '#{record.status === 1}',
92
- action: ['refreshTable'],
93
- },
94
- ],
97
+ key: 'id',
98
+ title: 'ID',
99
+ },
100
+ {
101
+ key: 'name',
102
+ title: '姓名',
103
+ width: 30,
104
+ },
105
+ {
106
+ key: 'nat',
107
+ title: '国家',
108
+ },
109
+ {
110
+ key: 'gender',
111
+ title: '性别',
112
+ render: ({ text }) => {
113
+ return text === 'male' ? '男' : '女';
114
+ },
115
+ },
116
+ {
117
+ key: 'email',
118
+ title: '邮箱',
119
+ },
120
+ {
121
+ key: 'id',
122
+ title: 'ID',
123
+ },
124
+ {
125
+ key: 'name',
126
+ title: '姓名',
127
+ },
128
+ {
129
+ key: 'nat',
130
+ title: '国家',
131
+ },
132
+ {
133
+ key: 'gender',
134
+ title: '性别',
135
+ render: ({ text }) => {
136
+ return text === 'male' ? '男' : '女';
137
+ },
138
+ },
139
+ {
140
+ key: 'email',
141
+ title: '邮箱',
142
+ },
143
+ {
144
+ key: 'id',
145
+ title: 'ID',
146
+ },
147
+ {
148
+ key: 'name',
149
+ title: '姓名',
150
+ },
151
+ {
152
+ key: 'nat',
153
+ title: '国家',
154
+ },
155
+ {
156
+ key: 'gender',
157
+ title: '性别',
158
+ render: ({ text }) => {
159
+ return text === 'male' ? '男' : '女';
160
+ },
161
+ },
162
+ {
163
+ key: 'email',
164
+ title: '邮箱',
165
+ },
166
+ {
167
+ key: 'id',
168
+ title: 'ID',
169
+ },
170
+ {
171
+ key: 'name',
172
+ title: '姓名',
173
+ },
174
+ {
175
+ key: 'nat',
176
+ title: '国家',
177
+ },
178
+ {
179
+ key: 'gender',
180
+ title: '性别',
181
+ render: ({ text }) => {
182
+ return text === 'male' ? '男' : '女';
183
+ },
184
+ },
185
+ {
186
+ key: 'email',
187
+ title: '邮箱',
95
188
  },
96
189
  ],
97
190
  rowKey: 'id',
@@ -41,18 +41,120 @@ interface Field {
41
41
  const MemoQueryTable = React.memo(QueryTable);
42
42
  const { Text } = Typography;
43
43
 
44
- const ResizeableTitle = (props) => {
44
+ const ResizeableTitle = (props: any) => {
45
45
  const { onResize, width, ...restProps } = props;
46
+
47
+ const [innerWidth, setInnerWidth] = useState(width);
48
+ const [isResizing, setIsResizing] = useState(false); // 标记是否正在拖拽
49
+ const [isDragging, setIsDragging] = useState(false); // 标记拖拽句柄是否被拖拽
50
+ const [startX, setStartX] = useState(0); // 初始X坐标
51
+ const markerPosition = useRef({ left: 0, top: 0 });
52
+ const currentStart = useRef(0);
53
+ const uuidref = useRef(uuid());
54
+
55
+ const prevWidthRef = useRef(width);
56
+
57
+ const handleMouseDown = (e: any) => {
58
+ currentStart.current = e.clientX;
59
+ markerPosition.current = { left: e.clientX, top: e.clientY }
60
+ setIsResizing(true);
61
+ document.addEventListener('mousemove', handleMouseMove);
62
+ document.addEventListener('mouseup', handleMouseUp);
63
+ };
64
+
65
+ const handleMouseMove = (e: any) => {
66
+ e.stopPropagation();
67
+ e.preventDefault();
68
+ // 更新标记位置
69
+ markerPosition.current = { left: e.clientX, top: e.clientY }
70
+ const dom: HTMLElement | null = document.getElementById('text1');
71
+
72
+ if (dom && dom.style) {
73
+ dom.style.left = `${e.clientX}px`;
74
+ dom.style.top = `${e.clientY - 20}px`;
75
+ }
76
+ };
77
+
78
+ const handleMouseUp = (e: any) => {
79
+ document.removeEventListener('mousemove', handleMouseMove);
80
+ document.removeEventListener('mouseup', handleMouseUp);
81
+ setIsResizing(false);
82
+ };
83
+
84
+ const handleresize = (e: any, data: any, title: string) => {
85
+ const newWidth = data?.size?.width || 0;
86
+ setInnerWidth(newWidth); // 更新内部分宽度
87
+ };
88
+
89
+ const handleResizeStart = () => {
90
+ setIsResizing(true);
91
+ };
92
+
93
+ const handleResizeStop = (e: any, data: any) => {
94
+ setIsResizing(false);
95
+ if (onResize) {
96
+ onResize(e, data);
97
+ }
98
+ };
99
+
100
+ useEffect(() => {
101
+ if (width !== prevWidthRef.current) {
102
+ prevWidthRef.current = width;
103
+ setInnerWidth(width);
104
+ }
105
+ }, [width]);
106
+
107
+ const thStyle = {
108
+ boxShadow: isResizing ? '2px 2px 10px rgba(0, 0, 0, 0.3)' : 'none',
109
+ };
46
110
 
47
- if (!width) {
48
- return <th {...restProps} />;
49
- }
50
111
  return (
51
112
  <Resizable
52
- width={width}
113
+ width={innerWidth}
53
114
  height={0}
54
- onResize={onResize}
55
- draggableOpts={{ enableUserSelectHack: false }}
115
+ handle={
116
+ <div>
117
+ <div
118
+ style={{
119
+ width: '10px',
120
+ height: '30px',
121
+ cursor: 'col-resize', // 拖动时改变鼠标样式
122
+ position: 'absolute',
123
+ zIndex: 10,
124
+ top: 0,
125
+ right: 0,
126
+ }}
127
+ onMouseDown={handleMouseDown}
128
+ // onDrag={handleDrag}
129
+ >
130
+ </div>
131
+ {isResizing && <div
132
+ id="text1"
133
+ style={{
134
+ position: 'fixed',
135
+ left: markerPosition.current.left, // 跟随鼠标偏移一点
136
+ top: markerPosition.current.top - 20,
137
+ backgroundColor: '#1890ff',
138
+ color: 'white',
139
+ borderRadius: '4px',
140
+ zIndex: 9999,
141
+ pointerEvents: 'none',
142
+ height: '40px',
143
+ width: 2
144
+ }}
145
+ >
146
+ </div>}
147
+ </div>
148
+ }
149
+ onResize={(e: any, data: any) => {handleresize(e, data, restProps.title)}}
150
+ onResizeStart={handleResizeStart}
151
+ onResizeStop={handleResizeStop}
152
+ draggableOpts={{
153
+ enableUserSelectHack: true,
154
+ grid: [20, 20],
155
+ axis: 'x',
156
+ bounds: 'parent',
157
+ }}
56
158
  >
57
159
  <th {...restProps} />
58
160
  </Resizable>
@@ -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
+