@bit-sun/business-component 2.0.0 → 2.0.3

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 (26) hide show
  1. package/dist/components/Business/AddSelectBusiness/index.d.ts +1 -0
  2. package/dist/components/Business/TreeSearchSelect/index.d.ts +3 -0
  3. package/dist/components/Business/TreeSearchSelect/utils.d.ts +2 -0
  4. package/dist/components/Functional/AddSelect/index.d.ts +3 -0
  5. package/dist/components/Functional/TreeSearchSelect/index.d.ts +2 -0
  6. package/dist/index.d.ts +4 -0
  7. package/dist/index.esm.js +2189 -140
  8. package/dist/index.js +2191 -138
  9. package/dist/utils/CheckOneUser/index.d.ts +1 -1
  10. package/package.json +1 -1
  11. package/src/components/Business/AddSelectBusiness/index.md +37 -0
  12. package/src/components/Business/AddSelectBusiness/index.tsx +295 -0
  13. package/src/components/Business/CommodityEntry/index.md +2 -2
  14. package/src/components/Business/CommodityEntry/index.tsx +5 -2
  15. package/src/components/Business/SearchSelect/BusinessUtils.ts +2 -0
  16. package/src/components/Business/TreeSearchSelect/index.md +126 -0
  17. package/src/components/Business/TreeSearchSelect/index.tsx +34 -0
  18. package/src/components/Business/TreeSearchSelect/utils.ts +60 -0
  19. package/src/components/Functional/AddSelect/index.less +284 -0
  20. package/src/components/Functional/AddSelect/index.md +118 -0
  21. package/src/components/Functional/AddSelect/index.tsx +882 -0
  22. package/src/components/Functional/DataImport/index.tsx +0 -1
  23. package/src/components/Functional/DataValidation/index.tsx +8 -1
  24. package/src/components/Functional/TreeSearchSelect/index.md +47 -0
  25. package/src/components/Functional/TreeSearchSelect/index.tsx +148 -0
  26. package/src/index.ts +8 -0
@@ -1,2 +1,2 @@
1
- declare const _default: (storageKeyString: string, seconds?: number, tipsCallFunction?: (() => {}) | undefined) => void;
1
+ declare const _default: (storageKeyString: string, seconds?: number, tipsCallFunction?: () => {}) => void;
2
2
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bit-sun/business-component",
3
- "version": "2.0.0",
3
+ "version": "2.0.3",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -0,0 +1,37 @@
1
+ ---
2
+ nav:
3
+ title: '组件'
4
+ order: 1
5
+ group:
6
+ title: 业务组件
7
+ order: 1
8
+ title: 业务档录入器
9
+ order: 1
10
+ ---
11
+
12
+ # BusinessSearchSelect
13
+
14
+
15
+ ## 商品选择录入器
16
+
17
+ ```tsx
18
+ import React, { useState } from 'react';
19
+ import { Tabs } from 'antd';
20
+ import { AddSkuSelect } from '../../../index.ts';
21
+
22
+ export default () => {
23
+ const config = {
24
+ buttonText: 'context',
25
+ onSaveCallback: (rows) => {
26
+ console.log('save call', rows);
27
+ return Promise.resolve(true);
28
+ // return Promise.reject('FAILE')
29
+ }
30
+ }
31
+ return (
32
+ <div>
33
+ <AddSkuSelect {...config} />
34
+ </div>
35
+ );
36
+ };
37
+ ```
@@ -0,0 +1,295 @@
1
+ /*
2
+ * @Description:
3
+ * @Author: rodchen
4
+ * @Date: 2022-05-07 15:17:28
5
+ * @LastEditTime: 2022-05-08 21:01:21
6
+ * @LastEditors: rodchen
7
+ */
8
+ import React, { useState } from 'react';
9
+ import { Tooltip, Select } from 'antd';
10
+ import { AddSelect } from '../../../index';
11
+
12
+ export const AddSkuSelect = (parProps: any) => {
13
+ const selectProps = {
14
+ mode: 'multiple',
15
+ }
16
+ const [value, setValue] = useState(selectProps?.mode ? [] : null);
17
+ const props = {
18
+ buttonText: parProps.buttonText || '新增',
19
+ value,
20
+ // labelInValue: true, // 非必填 默认为false
21
+ requestConfig: {
22
+ url: `/items/sku/pager/v2`,
23
+ filter: 'qp-name-like', // 过滤参数 支持'qp-name-like'和['qp-name-like', 'qp-code-like']两种结构
24
+ otherParams: {}, // 默认参数
25
+ mappingTextField: 'name',
26
+ mappingValueField: 'skuCode',
27
+ },
28
+ selectProps,
29
+ onChange: (value: any) => {
30
+ console.log(value)
31
+ setValue(value)
32
+ },
33
+ onSaveCallback: parProps.onSaveCallback
34
+ // onSaveCallback: (rows) => {
35
+ // console.log('save call', rows);
36
+ // // return Promise.resolve(true);
37
+ // // return Promise.reject('FAILE')
38
+ // }
39
+ };
40
+ const modalTableProps = {
41
+ modalTableTitle: '选择商品',
42
+ tableSearchForm: [
43
+ {
44
+ name: 'qp-skuCode-like', label: 'SKU编码'
45
+ },
46
+ { name: 'qp-skuName-like', label: 'SKU名称' },
47
+ { name: 'qp-brandId-in', type: 'select', label: '品牌', field: {
48
+ type: 'select',
49
+ props: {
50
+ mode: 'multiple',
51
+ notFoundContent: '暂无数据',
52
+ allowClear: true,
53
+ showSearch: true,
54
+ showArrow: true,
55
+ maxTagCount: 1,
56
+ optionFilterProp: 'children',
57
+ filterOption: (input: string, option: { props: { children: string } }) =>
58
+ option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0,
59
+ },
60
+ } },
61
+ { name: 'qp-categoryId-in', type: 'treeSelect', label: '类目', field: {
62
+ type: 'treeSelect',
63
+ props: {
64
+ treeData: [],
65
+ treeCheckable: true,
66
+ showSearch: true,
67
+ allowClear: true,
68
+ showArrow: true,
69
+ treeNodeFilterProp: 'title',
70
+ treeDefaultExpandAll: true,
71
+ maxTagCount: 1,
72
+ placeholder: '请选择',
73
+ style: {
74
+ width: '100%',
75
+ },
76
+ dropdownStyle: { maxHeight: 400, maxWidth: 100, overflow: 'auto' }
77
+ },
78
+ } }
79
+ ],
80
+ tableColumns: [
81
+ {
82
+ title: 'SKU编码',
83
+ width: 150,
84
+ dataIndex: 'skuCode',
85
+ },
86
+ {
87
+ title: 'SKU名称',
88
+ width: 200,
89
+ ellipsis: {
90
+ showTitle: false,
91
+ },
92
+ render: (text: any) => (
93
+ <Tooltip placement="topLeft" title={text}>
94
+ {text}
95
+ </Tooltip>
96
+ ),
97
+ dataIndex: 'name',
98
+ },
99
+ {
100
+ title: '国际条码',
101
+ width: 100,
102
+ ellipsis: {
103
+ showTitle: false,
104
+ },
105
+ dataIndex: 'barCode',
106
+ render: (text: any) => (
107
+ <Tooltip placement="topLeft" title={text}>
108
+ {text}
109
+ </Tooltip>
110
+ ),
111
+ },
112
+ {
113
+ title: '所属SPU名称',
114
+ width: 100,
115
+ ellipsis: {
116
+ showTitle: false,
117
+ },
118
+ dataIndex: 'itemName',
119
+ render: (text: any) => (
120
+ <Tooltip placement="topLeft" title={text}>
121
+ {text}
122
+ </Tooltip>
123
+ ),
124
+ },
125
+ {
126
+ title: '所属SPU编码',
127
+ width: 100,
128
+ ellipsis: {
129
+ showTitle: false,
130
+ },
131
+ dataIndex: 'itemCode',
132
+ render: (text: any) => (
133
+ <Tooltip placement="topLeft" title={text}>
134
+ {text}
135
+ </Tooltip>
136
+ ),
137
+ },
138
+ {
139
+ title: '外部编码',
140
+ width: 100,
141
+ ellipsis: {
142
+ showTitle: false,
143
+ },
144
+ render: (text: any) => (
145
+ <Tooltip placement="topLeft" title={text}>
146
+ {text}
147
+ </Tooltip>
148
+ ),
149
+ dataIndex: 'externalCode',
150
+ },
151
+ {
152
+ title: '规格',
153
+ width: 100,
154
+ ellipsis: {
155
+ showTitle: false,
156
+ },
157
+ render: (text: any) => (
158
+ <Tooltip placement="topLeft" title={text}>
159
+ {text}
160
+ </Tooltip>
161
+ ),
162
+ dataIndex: 'propertyNameAndValue',
163
+ },
164
+ {
165
+ title: '类目',
166
+ width: 100,
167
+ ellipsis: {
168
+ showTitle: false,
169
+ },
170
+ render: (text: any) => (
171
+ <Tooltip placement="topLeft" title={text}>
172
+ {text}
173
+ </Tooltip>
174
+ ),
175
+ dataIndex: 'categoryName',
176
+ },
177
+ {
178
+ title: '品类',
179
+ width: 100,
180
+ ellipsis: {
181
+ showTitle: false,
182
+ },
183
+ render: (text: any) => (
184
+ <Tooltip placement="topLeft" title={text}>
185
+ {text}
186
+ </Tooltip>
187
+ ),
188
+ dataIndex: 'className',
189
+ },
190
+ {
191
+ title: '品牌',
192
+ width: 100,
193
+ ellipsis: {
194
+ showTitle: false,
195
+ },
196
+ render: (text: any) => (
197
+ <Tooltip placement="topLeft" title={text}>
198
+ {text}
199
+ </Tooltip>
200
+ ),
201
+ dataIndex: 'brandName',
202
+ },
203
+ ],
204
+ selectColumn: [
205
+ {
206
+ title: 'SKU编码',
207
+ width: 150,
208
+ dataIndex: 'skuCode',
209
+ },
210
+ {
211
+ title: 'SKU名称',
212
+ width: 200,
213
+ ellipsis: {
214
+ showTitle: false,
215
+ },
216
+ render: (text: any) => (
217
+ <Tooltip placement="topLeft" title={text}>
218
+ {text}
219
+ </Tooltip>
220
+ ),
221
+ dataIndex: 'name',
222
+ },
223
+ {
224
+ title: '数量',
225
+ width: 100,
226
+ isInputItem: true,
227
+ dataIndex: 'count',
228
+ },
229
+ {
230
+ title: '单位',
231
+ dataIndex: 'selectUnitCode',
232
+ width: 80,
233
+ ellipsis: {
234
+ showTitle: false,
235
+ },
236
+ render: (text: any, record: any) => {
237
+ let baseUnitCode = '';
238
+ if (record?.packingUnitList) {
239
+ let base = record.packingUnitList.filter((item: any) => item.unitCode)
240
+ if (base.length) {
241
+ baseUnitCode = base[0].unitCode
242
+ record.selectUnitCode = base[0].unitCode
243
+ }
244
+ }
245
+
246
+ if (baseUnitCode) {
247
+ return <>
248
+ <Select defaultValue={baseUnitCode} onChange={(value) => {record.selectUnitCode = value}} style={{width: '60px'}}>
249
+ {record.packingUnitList && record.packingUnitList.map((item: any) => {
250
+ return <Select.Option value={item.unitCode}>{item.name}</Select.Option>
251
+ })}
252
+ </Select>
253
+ </>
254
+ }
255
+ return <></>
256
+ },
257
+ },
258
+ {
259
+ title: '所属SPU编码',
260
+ width: 150,
261
+ ellipsis: {
262
+ showTitle: false,
263
+ },
264
+ dataIndex: 'itemCode',
265
+ render: (text: any) => (
266
+ <Tooltip placement="topLeft" title={text}>
267
+ {text}
268
+ </Tooltip>
269
+ ),
270
+ },
271
+ {
272
+ title: '规格',
273
+ width: 200,
274
+ ellipsis: {
275
+ showTitle: false,
276
+ },
277
+ render: (text: any) => (
278
+ <Tooltip placement="topLeft" title={text}>
279
+ {text}
280
+ </Tooltip>
281
+ ),
282
+ dataIndex: 'propertyNameAndValue',
283
+ }
284
+ ]
285
+ }
286
+
287
+ return (
288
+ <div>
289
+ <AddSelect
290
+ {...props}
291
+ modalTableProps={modalTableProps}
292
+ />
293
+ </div>
294
+ );
295
+ };
@@ -21,11 +21,11 @@ export default () => {
21
21
  const [choosedSku, setChoosedSku] = useState([]);
22
22
 
23
23
  const callbackHideModal = () => {
24
- alert('关闭弹窗处理函数回调,可以处理刷新表格等操作(非必传)')
24
+ console.log('关闭弹窗处理函数回调,可以处理刷新表格等操作(非必传)')
25
25
  }
26
26
 
27
27
  const callbackHandleOk = (resultData, callback) => {
28
- alert('确定操作,可获取到成功录入的商品,做一系列操作')
28
+ console.log('确定操作,可获取到成功录入的商品,做一系列操作')
29
29
  console.log(resultData)
30
30
  // 一般拿到导入数据是做请求接口操作
31
31
  // import {request} from "bssula";
@@ -9,10 +9,12 @@ const CommodityEntry = (props: any) => {
9
9
  const {
10
10
  buttonName=' + 录入商品',
11
11
  modalTitle = '录入商品',
12
+ buttonProps = {},
12
13
  callbackHideModal,
13
14
  callbackHandleOk,
14
15
  columns=["skuCode", "quantity", "price"],
15
- validDataUrl="/bop/api/recordDetailImport/check"
16
+ validDataUrl="/items/sku/import/check",
17
+ isBrandAuth = true // 默认做品牌过滤
16
18
  } = props;
17
19
 
18
20
  const [modalProps, setModalProps]: any = useState({
@@ -58,13 +60,14 @@ const CommodityEntry = (props: any) => {
58
60
 
59
61
  return (
60
62
  <div>
61
- <Button onClick={handleShowModal}>{buttonName}</Button>
63
+ <Button onClick={handleShowModal} {...buttonProps}>{buttonName}</Button>
62
64
  {modalProps.visible && (
63
65
  <Modal {...modalProps} onOk={handleOk} onCancel={handleCancel} destroyOnClose={true} zIndex={15}>
64
66
  <DataValidation
65
67
  onRef={(ref) => { dataValidationRef = ref }}
66
68
  columns={columns}
67
69
  validDataUrl={validDataUrl}
70
+ isBrandAuth={isBrandAuth}
68
71
  />
69
72
  </Modal>
70
73
  ) || ''}
@@ -381,6 +381,7 @@ export function commonFun (type?: string, prefixUrl: any, requestConfigProp?: an
381
381
  loadSelectSource(`${prefixUrl.formSelectFix}/brand/queryBrandList`, {
382
382
  pageSize: 5000,
383
383
  currentPage: 1,
384
+ 'ctl-withAuth': true
384
385
  }),
385
386
  loadSelectSource(`${prefixUrl.formSelectFix}/category/queryCategoryTree`, {
386
387
  pageSize: 5000,
@@ -549,6 +550,7 @@ export function commonFun (type?: string, prefixUrl: any, requestConfigProp?: an
549
550
  loadSelectSource(`${prefixUrl.formSelectFix}/brand/queryBrandList`, {
550
551
  pageSize: 5000,
551
552
  currentPage: 1,
553
+ 'ctl-withAuth': true
552
554
  }),
553
555
  loadSelectSource(`${prefixUrl.formSelectFix}/category/queryCategoryTree`, {
554
556
  pageSize: 5000,
@@ -0,0 +1,126 @@
1
+ ---
2
+ nav:
3
+ title: '组件'
4
+ order: 1
5
+ group:
6
+ title: 业务组件
7
+ order: 1
8
+ title: 树型业务选择器
9
+ order: 2
10
+ ---
11
+
12
+ ## BusinessTreeSearchSelect
13
+
14
+ Demo
15
+
16
+ 部门选择器:
17
+
18
+ ```tsx
19
+ import React, { useState } from 'react';
20
+ import { BusinessTreeSearchSelect } from '../../../index';
21
+
22
+ export default () => {
23
+
24
+ const [value, setValue] = useState();
25
+
26
+ const props = {
27
+ mode: 'create',
28
+ value,
29
+ onChange: (v) => {
30
+ setValue(v)
31
+ },
32
+ businessType: 'department'
33
+ };
34
+
35
+ return (
36
+ <div>
37
+ <BusinessTreeSearchSelect {...props} />
38
+ </div>
39
+ );
40
+ };
41
+ ```
42
+
43
+
44
+ 销售组织选择器:
45
+
46
+ ```tsx
47
+ import React, { useState } from 'react';
48
+ import { BusinessTreeSearchSelect } from '../../../index';
49
+
50
+ export default () => {
51
+
52
+ const [value, setValue] = useState();
53
+
54
+ const props = {
55
+ mode: 'create',
56
+ value,
57
+ onChange: (v) => {
58
+ setValue(v)
59
+ },
60
+ businessType: 'sales-organization'
61
+ };
62
+
63
+ return (
64
+ <div>
65
+ <BusinessTreeSearchSelect {...props} />
66
+ </div>
67
+ );
68
+ };
69
+ ```
70
+
71
+ 采购组织选择器:
72
+
73
+ ```tsx
74
+ import React, { useState } from 'react';
75
+ import { BusinessTreeSearchSelect } from '../../../index';
76
+
77
+ export default () => {
78
+
79
+ const [value, setValue] = useState();
80
+
81
+ const props = {
82
+ mode: 'create',
83
+ value,
84
+ onChange: (v) => {
85
+ setValue(v)
86
+ },
87
+ businessType: 'purchase-organization'
88
+ };
89
+
90
+ return (
91
+ <div>
92
+ <BusinessTreeSearchSelect {...props} />
93
+ </div>
94
+ );
95
+ };
96
+ ```
97
+
98
+ 库存组织选择器:
99
+
100
+ ```tsx
101
+ import React, { useState } from 'react';
102
+ import { BusinessTreeSearchSelect } from '../../../index';
103
+
104
+ export default () => {
105
+
106
+ const [value, setValue] = useState();
107
+
108
+ const props = {
109
+ mode: 'create',
110
+ value,
111
+ isChoose: false, // 控制是否父节点可选中,默认不可选中
112
+ onChange: (v) => {
113
+ setValue(v)
114
+ },
115
+ businessType: 'stock-organization'
116
+ };
117
+
118
+ return (
119
+ <div>
120
+ <BusinessTreeSearchSelect {...props} />
121
+ </div>
122
+ );
123
+ };
124
+ ```
125
+
126
+ More skills for writing demo: https://d.umijs.org/guide/demo-principle
@@ -0,0 +1,34 @@
1
+ import React, { useMemo } from 'react';
2
+ import { handleDefaultProps } from './utils';
3
+ import TreeSearchSelect from '@/components/Functional/TreeSearchSelect';
4
+
5
+ const MemoTreeSearchSelect = React.memo(TreeSearchSelect)
6
+
7
+ const BusinessTreeSearchSelect = (props: any) => {
8
+ const businessType = props?.businessType || 'department';
9
+
10
+ const handleBusinessProps = handleDefaultProps(businessType);
11
+
12
+ const currentProps = useMemo(() => {
13
+ return {
14
+ ...handleBusinessProps,
15
+ ...props,
16
+ }
17
+ }, [props?.value])
18
+
19
+ return (
20
+ <div>
21
+ <MemoTreeSearchSelect {...currentProps} />
22
+ </div>
23
+ );
24
+ };
25
+
26
+ export default React.memo(BusinessTreeSearchSelect, (props, nextProps) => {
27
+ if(props && props.labelInValue && props.value && JSON.stringify(props.value) !== JSON.stringify(nextProps.value)) {
28
+ return false
29
+ }
30
+ if(props && props.value !== nextProps.value) {
31
+ return false
32
+ }
33
+ return true
34
+ });
@@ -0,0 +1,60 @@
1
+ const handleDefaultProps = (type: string) => {
2
+ let result = {};
3
+ switch (type){
4
+ case 'department':
5
+ result = {
6
+ treeCheckable: true,
7
+ isChoose: true,
8
+ remoteSource: {
9
+ url: `/user/orgViewNode/common/getTreeForOrgViewAndTenant`,
10
+ initialParams: { 'orgViewCode': 'administrative-organization-view' },
11
+ resKeyValue: ['code', 'name'],
12
+ },
13
+ };
14
+ break;
15
+ case 'sales-organization':
16
+ result = {
17
+ isChoose: true,
18
+ remoteSource: {
19
+ url: `/user/orgViewNode/common/getTreeForOrgViewAndTenant`,
20
+ initialParams: { 'orgViewCode': 'sales-organizational-view' },
21
+ resKeyValue: ['code', 'name'],
22
+ },
23
+ };
24
+ break;
25
+ case 'purchase-organization':
26
+ result = {
27
+ isChoose: true,
28
+ remoteSource: {
29
+ url: `/user/orgViewNode/common/getTreeForOrgViewAndTenant`,
30
+ initialParams: { 'orgViewCode': 'purchase-organizational-view' },
31
+ resKeyValue: ['code', 'name'],
32
+ },
33
+ };
34
+ break;
35
+ case 'stock-organization':
36
+ result = {
37
+ isChoose: true,
38
+ remoteSource: {
39
+ url: `/user/orgViewNode/common/getTreeForOrgViewAndTenant`,
40
+ initialParams: { 'orgViewCode': 'stock-organizational-view' },
41
+ resKeyValue: ['code', 'name'],
42
+ },
43
+ };
44
+ break;
45
+ default:
46
+ result = {
47
+ treeCheckable: true,
48
+ isChoose: true,
49
+ remoteSource: {
50
+ url: `/user/orgViewNode/common/getTreeForOrgViewAndTenant`,
51
+ initialParams: { 'orgViewCode': 'administrative-organization-view' },
52
+ resKeyValue: ['code', 'name'],
53
+ },
54
+ };
55
+ break
56
+ }
57
+ return result;
58
+ }
59
+
60
+ export { handleDefaultProps }