@bit-sun/business-component 4.2.0-alpha.0 → 4.2.0-alpha.1

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.
@@ -57,6 +57,7 @@ declare class TableColumnSetting extends React.Component<TableColumnSettingProps
57
57
  DraggableBodyRow: ({ className, style, ...restProps }: any) => React.JSX.Element;
58
58
  onChange: (e: any, title: any) => void;
59
59
  handleReset: () => void;
60
+ handleResetSetting: () => Promise<unknown>;
60
61
  onSearch: (e: any) => void;
61
62
  onSearchSort: (e: any) => void;
62
63
  render(): React.JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bit-sun/business-component",
3
- "version": "4.2.0-alpha.0",
3
+ "version": "4.2.0-alpha.1",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -27,13 +27,13 @@
27
27
  ]
28
28
  },
29
29
  "peerDependencies": {
30
- "antd": "^4.17.2",
31
- "bssula": "^4.1.16",
32
- "umi-plugin-bssula": "^4.3.9-alpha.0",
33
- "umi": "3.5.20",
34
30
  "@ant-design/pro-layout": "^6.5.0",
31
+ "antd": "^4.17.2",
32
+ "bssula": "4.4.3-alpha.1",
35
33
  "react-dnd": "^16.0.1",
36
- "react-dnd-html5-backend": "^16.0.1"
34
+ "react-dnd-html5-backend": "^16.0.1",
35
+ "umi": "^3.5.20",
36
+ "umi-plugin-bssula": "4.4.3-alpha.1"
37
37
  },
38
38
  "dependencies": {
39
39
  "@ant-design/icons": "^4.7.0",
@@ -51,7 +51,7 @@
51
51
  "moment": "^2.25.3",
52
52
  "qs": "^6.11.2",
53
53
  "querystring": "^0.2.1",
54
- "react": "^16.12.0",
54
+ "react": "17.0.2",
55
55
  "react-beautiful-dnd": "10.0.0",
56
56
  "react-dom": "^16.12.0",
57
57
  "react-resizable": "^3.0.4",
@@ -59,14 +59,14 @@
59
59
  "serialize-javascript": "^6.0.0",
60
60
  "umi-request": "^1.4.0",
61
61
  "warning": "^4.0.3",
62
- "xlsx": "^0.18.5"
62
+ "xlsx": "0.18.5"
63
63
  },
64
64
  "devDependencies": {
65
- "@ant-design/pro-layout": "^7.1.3",
65
+ "@ant-design/pro-layout": "7.1.3",
66
66
  "@types/js-cookie": "^3.0.6",
67
67
  "@types/lodash": "^4.14.185",
68
- "@types/react": "^18.3.3",
69
- "@types/react-dom": "^18.3.0",
68
+ "@types/react": "17.0.2",
69
+ "@types/react-dom": "17.0.2",
70
70
  "@umijs/test": "^3.0.5",
71
71
  "acorn": "^7.2.0",
72
72
  "acorn-walk": "^7.1.1",
@@ -54,7 +54,12 @@ export default () => {
54
54
  console.log('save call', rows);
55
55
  return Promise.resolve(true);
56
56
  // return Promise.reject('FAILE')
57
- }
57
+ },
58
+ // 批量个格式化,回调函数
59
+ batchFormatCallback: (rows) => {
60
+ return rows; // 返回格式化之后的数据
61
+ },
62
+ batchFormatBtnTitle: '批量格式化',
58
63
  }
59
64
  return (
60
65
  <div>
@@ -272,7 +277,8 @@ export default () => {
272
277
  dataIndex: 'skuQuantity',
273
278
  isInputItem: true,
274
279
  inputProps: {
275
-
280
+ max: (record: any) => record?.availableStock, // 支持传入函数
281
+ max: 5, // 直接传入数值
276
282
  }
277
283
  },
278
284
  {
@@ -378,6 +378,7 @@ export const AddSkuSelect = (parProps: any) => {
378
378
  {
379
379
  name: 'qp-skuCode-like', label: 'SKU编码',type:'multipleQueryInput'
380
380
  },
381
+ { name: 'qp-itemCode-like', label: '款号(SPU)', type: 'multipleQueryInput', },
381
382
  { name: 'qp-skuName-like', label: 'SKU名称' },
382
383
  { name: 'qp-externalCode-like', label: '外部SPU编码' },
383
384
  ...(isNoUseItemBarcode ? []: [
@@ -476,6 +477,8 @@ export const AddSkuSelect = (parProps: any) => {
476
477
  onSaveCallback: parProps.onSaveCallback,
477
478
  businessType: 'sku',
478
479
  isAllowRepeatedSelect: !!parProps?.isAllowRepeatedSelect,
480
+ batchFormatCallback: parProps?.batchFormatCallback, // 批量格式-已选数据回调函数
481
+ batchFormatBtnTitle: parProps?.batchFormatBtnTitle, // 批量格式-按钮名称
479
482
  };
480
483
  const modalTableProps = {
481
484
  modalTableTitle: parProps.modalTableTitle || '选择商品',
@@ -55,7 +55,7 @@
55
55
  }
56
56
 
57
57
  .themeColor {
58
- color: #005cff;
58
+ color: #005CFF;
59
59
  }
60
60
 
61
61
  .itemPath {
@@ -44,7 +44,7 @@
44
44
  .account {
45
45
  .avatar {
46
46
  margin-right: 8px;
47
- color: #005cff;
47
+ color: #005CFF;
48
48
  vertical-align: top;
49
49
  background: rgba(255, 255, 255, 0.85);
50
50
  }
@@ -44,7 +44,7 @@
44
44
  .account {
45
45
  .avatar {
46
46
  margin-right: 8px;
47
- color: #005cff;
47
+ color: #005CFF;
48
48
  vertical-align: top;
49
49
  background: rgba(255, 255, 255, 0.85);
50
50
  }
@@ -117,7 +117,7 @@
117
117
  left: -1px;
118
118
  width: 92px;
119
119
  height: 40px;
120
- background: #005cff;
120
+ background: #005CFF;
121
121
  border-radius: 0px 4px 4px 0px;
122
122
  }
123
123
 
@@ -20,6 +20,7 @@ import { arrayMoveImmutable } from 'array-move';
20
20
  import close from '../../../assets/close.svg';
21
21
  import drag from '../../../assets/drag.svg';
22
22
  import shezhi from '../../../assets/icon-shezhi.svg';
23
+ import shezhi from '../../../assets/icon-shezhi.svg';
23
24
  import './index.less';
24
25
  import ENUM from '@/utils/enumConfig';
25
26
  import { handleRequestUrl, judgeIsRequestSuccess } from '@/utils/requestUtils';
@@ -587,7 +588,7 @@ class SearchItemTable extends React.Component {
587
588
  </div>
588
589
  </Modal>
589
590
  )}
590
- <div onClick={this.showModal} style={{fontSize:14, textAlign: 'center', border: '0.67px solid #D9D9D9', width: '24px', height: '24px', lineHeight: '20px'}}><img style={{width: '20px', height: '20px'}} src={shezhi} /></div>
591
+ <div onClick={this.showModal} style={{fontSize:14, cursor: 'pointer', textAlign: 'center', border: '0.67px solid #D9D9D9', width: '24px', height: '24px', lineHeight: '20px'}}><img style={{width: '20px', height: '20px'}} src={shezhi} /></div>
591
592
  </div>
592
593
  );
593
594
  }
@@ -52,7 +52,7 @@
52
52
  margin: 0 0 5px !important;
53
53
  }
54
54
  .card_department {
55
- color: #005cff !important;
55
+ color: #005CFF !important;
56
56
  }
57
57
 
58
58
  .user_info_card {
@@ -87,7 +87,9 @@ const AddSelect = (props: any) => {
87
87
  tableCodeList = [], // 非必填 默认取组件定义code,如需自定义----数组第一位为供选择商品的table的code,第二位为已选择商品的table的code
88
88
  businessType = 'sku',
89
89
  isAllowRepeatedSelect = false,
90
- clearTitle
90
+ clearTitle,
91
+ batchFormatCallback,
92
+ batchFormatBtnTitle,
91
93
  } = props;
92
94
  const { url, method = 'get', sourceKey, otherParams, isMap, mappingValueField = 'code', extralHeaders = {} } = requestConfig || {};
93
95
  const realButtonProps = {type: "primary", ...buttonProps};
@@ -214,9 +216,16 @@ const AddSelect = (props: any) => {
214
216
  // precision: unitAccuracy
215
217
  }
216
218
  }
219
+ // 如果属性为函数时,则执行该函数
220
+ const inputProps = Object.keys(item?.inputProps || {})?.reduce((acc, key) => {
221
+ const value = item?.inputProps?.[key];
222
+ acc[key] = typeof value === 'function' ? value?.(record) : value;
223
+ return acc;
224
+ }, {});
225
+
217
226
  return (
218
227
  <InputNumber
219
- {...item.inputProps}
228
+ {...inputProps}
220
229
  value={text || ''}
221
230
  min={0}
222
231
  autoFocus={record.needFocus}
@@ -615,6 +624,11 @@ const AddSelect = (props: any) => {
615
624
  }, 50)
616
625
  };
617
626
 
627
+ // 将格式化完的数据回显到 表格中
628
+ const batchFormatCallbackHandler = () => {
629
+ setPopValue([...batchFormatCallback?.(popvalue)]);
630
+ }
631
+
618
632
  const handleShowModal = () => {
619
633
  if(beforeShowModal) {
620
634
  beforeShowModal(popvalue).then(res => {
@@ -1049,7 +1063,10 @@ const AddSelect = (props: any) => {
1049
1063
  settingImgAttribute={{ width: 20, style: { marginTop: -2 } }}
1050
1064
  />
1051
1065
  </span>
1052
- <div style={{ marginRight: 8 }}><span onClick={deleteSelectRows} style={{ ...themeColor, cursor: 'pointer' }}>{clearTitle??'清空所选商品'}</span></div>
1066
+ <div style={{ marginRight: 8, display: 'flex', gap: '5px' }}>
1067
+ <span hidden={!batchFormatCallback} onClick={batchFormatCallbackHandler} style={{ cursor: 'pointer' }}>{batchFormatBtnTitle ?? '一键填充'}</span>
1068
+ <span onClick={deleteSelectRows} style={{ ...themeColor, cursor: 'pointer' }}>{clearTitle ?? '清空所选商品'}</span>
1069
+ </div>
1053
1070
  </div>
1054
1071
  </div>
1055
1072
  <Table
@@ -11,9 +11,9 @@ import { useDebounceFn } from 'ahooks';
11
11
  import { Input, Button, Modal, ConfigProvider } from 'antd';
12
12
  import './index.less';
13
13
 
14
- const QueryMutipleInput = ({ onValueChange,onPressEnter }) => {
14
+ const QueryMutipleInput = ({ onValueChange,onPressEnter, value: initialValue }) => {
15
15
  const [isModalVisible, setIsModalVisible] = useState(false);
16
- const [value, setValue] = useState('');
16
+ const [value, setValue] = useState(initialValue);
17
17
  const [popvalue, setPopValue] = useState('');
18
18
  const { run } = useDebounceFn(
19
19
  () => {
@@ -24,6 +24,14 @@ const QueryMutipleInput = ({ onValueChange,onPressEnter }) => {
24
24
  },
25
25
  );
26
26
 
27
+ /**
28
+ * 初始化参数
29
+ * 处理参数不展示和清空不同步的问题
30
+ */
31
+ useEffect(() => {
32
+ setValue(initialValue);
33
+ }, [initialValue]);
34
+
27
35
  useEffect(() => {
28
36
  setPopValue(value);
29
37
  onValueChange(value);
@@ -67,6 +75,7 @@ const QueryMutipleInput = ({ onValueChange,onPressEnter }) => {
67
75
  <Input
68
76
  value={value}
69
77
  onChange={outerChange}
78
+ allowClear
70
79
  onBlur={(e) => {
71
80
  formaData(e.target.value);
72
81
  }}
@@ -57,6 +57,7 @@ export default (props: Iprops) => {
57
57
  // handleEdit(ites.code, value);
58
58
  }}
59
59
  options={dataSource}
60
+ filterOption ={(input: any, option: any) => option?.label?.toLowerCase()?.indexOf(input?.toLowerCase()) >= 0}
60
61
  />
61
62
  );
62
63
  };
@@ -155,6 +155,7 @@ export default function RenderCompItem(props:any){
155
155
  onChange={(value) => {
156
156
  handleEdit(ites.code, value);
157
157
  }}
158
+ filterOption ={(input: any, option: any) => option?.text?.toLowerCase()?.indexOf(input?.toLowerCase()) >= 0}
158
159
  >
159
160
  {Object.keys(ites.enumeration).map((it) => (
160
161
  <Select.Option key={it} value={it}>
@@ -170,7 +171,7 @@ export default function RenderCompItem(props:any){
170
171
  <InnerSelect
171
172
  disabled={disabled}
172
173
  inputType={ites?.inputType}
173
- defaultValue={ites.defaultValue}
174
+ defaultValue={ites?.defaultValue}
174
175
  styleCommon={styleCommon}
175
176
  value={showValue(ites.code)}
176
177
  onChange={(value) => {
@@ -1140,7 +1140,12 @@ class RuleObjectComponent extends Component {
1140
1140
  let value = val;
1141
1141
  if (isObj(code)) {
1142
1142
  Object.keys(code).forEach((ite) => {
1143
- this.handleEditExtraInfoResponse(ite, code[ite], parentDetail,classDataIndex);
1143
+ this.handleEditExtraInfoResponse(
1144
+ ite,
1145
+ code[ite],
1146
+ parentDetail,
1147
+ classDataIndex,
1148
+ );
1144
1149
  });
1145
1150
  return;
1146
1151
  }
@@ -1148,9 +1153,16 @@ class RuleObjectComponent extends Component {
1148
1153
  value = val.map((m) => m.value || m).join(',');
1149
1154
  }
1150
1155
  if (isObj(val)) {
1151
- value = val.value || val.PCDCode?.join('/');
1156
+ value = val?.value || val.PCDCode?.join('/') || val;
1152
1157
  }
1153
- this.handleEditExtraInfoResponse('value', value, parentDetail,classDataIndex,code);
1158
+
1159
+ this.handleEditExtraInfoResponse(
1160
+ 'value',
1161
+ value,
1162
+ parentDetail,
1163
+ classDataIndex,
1164
+ code,
1165
+ );
1154
1166
  };
1155
1167
 
1156
1168
  return (
@@ -495,6 +495,56 @@ class TableColumnSetting extends React.Component<TableColumnSettingProps> {
495
495
  this.setInitValue(datasource);
496
496
  };
497
497
 
498
+ handleResetSetting = () => {
499
+ const { setShowColumns, datasource = [], setInitialTableInfo, appRequestConfig }: any = this.props;
500
+ let that = this;
501
+ let { bsTableCode } = this.state;
502
+
503
+ return new Promise((resolve: any, reject: any) => {
504
+ request({
505
+ url: handleRequestUrl('/user','/appConfig/saveUserOrder', appRequestConfig),
506
+ method: 'POST',
507
+ data: {
508
+ code: that.state.bsTableCode,
509
+ detail: '',
510
+ },
511
+ }).then((res:any) => {
512
+ if (judgeIsRequestSuccess(res?.data)) {
513
+ let config =
514
+ localStorage.getItem(ENUM.BROWSER_CACHE.COLUMN_CONDITION) || '[]';
515
+ let configArray = JSON.parse(config);
516
+ let currentSetting = configArray.filter(
517
+ (item) => item.code === bsTableCode,
518
+ );
519
+ if (currentSetting.length) {
520
+ currentSetting[0].detail = JSON.stringify([]);
521
+ } else {
522
+ configArray.push({
523
+ code: bsTableCode,
524
+ detail: JSON.stringify([]),
525
+ });
526
+ }
527
+
528
+ localStorage.setItem(
529
+ ENUM.BROWSER_CACHE.COLUMN_CONDITION,
530
+ JSON.stringify(configArray),
531
+ );
532
+
533
+ message.success('重置表头列成功!');
534
+
535
+ setInitialTableInfo(true);
536
+ this.setState({
537
+ visible: false,
538
+ });
539
+ } else {
540
+ message.error('重置表头列自定义失败,请稍后尝试');
541
+ reject('');
542
+ }
543
+ });
544
+ })
545
+ };
546
+
547
+
498
548
  onSearch = (e: any) => {
499
549
  this.setState({
500
550
  searchDataSource: e.target.value,
@@ -532,15 +582,31 @@ class TableColumnSetting extends React.Component<TableColumnSettingProps> {
532
582
  onOk={this.handleOk}
533
583
  onCancel={this.handleCancel}
534
584
  footer={[
535
- <Button key="back" onClick={this.handleReset}>
536
- 恢复默认
537
- </Button>,
538
- <Button key="submit" onClick={this.handleOk}>
539
- 取消
540
- </Button>,
541
- <Button key="submit" type="primary" onClick={this.handleOk}>
542
- 确认
543
- </Button>,
585
+ <div>
586
+ <Button
587
+ key="back"
588
+ onClick={this.handleReset}
589
+ style={{ marginRight: 0 }}
590
+ >
591
+ 恢复默认
592
+ </Button>
593
+ <Button key="back" onClick={this.handleResetSetting}>
594
+ 重置设置
595
+ </Button>
596
+ <span style={{fontSize: '12px', color: '8A8F8D'}}>(列表字段变更会影响列设置功能,变更后请点击重置然后重新设置)</span>
597
+ </div>,
598
+ <div>
599
+ <Button
600
+ key="submit"
601
+ onClick={this.handleCancel}
602
+ style={{ marginRight: 0 }}
603
+ >
604
+ 取消
605
+ </Button>
606
+ <Button key="submit" type="primary" onClick={this.handleOk}>
607
+ 确认
608
+ </Button>
609
+ </div>,
544
610
  ]}
545
611
  >
546
612
  <div className={'sort_table'}>
@@ -48,5 +48,5 @@
48
48
  }
49
49
 
50
50
  .card_department {
51
- color: #005cff !important;
51
+ color: #005CFF !important;
52
52
  }