@bit-sun/business-component 2.4.12 → 2.4.14

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.
package/dist/index.esm.js CHANGED
@@ -2723,7 +2723,7 @@ var handleSourceName = function handleSourceName(sName) {
2723
2723
  var Option$1 = Select.Option;
2724
2724
  var SearchSelect = /*#__PURE__*/forwardRef(function (props, ref) {
2725
2725
  var value = props.value,
2726
- onChange = props.onChange,
2726
+ onChangeTemp = props.onChange,
2727
2727
  _props$selectProps = props.selectProps,
2728
2728
  selectProps = _props$selectProps === void 0 ? {} : _props$selectProps,
2729
2729
  _props$modalTableProp = props.modalTableProps,
@@ -3142,7 +3142,18 @@ var SearchSelect = /*#__PURE__*/forwardRef(function (props, ref) {
3142
3142
  }); // 调用api方法
3143
3143
  }
3144
3144
  };
3145
-
3145
+ // 下拉框改变事件
3146
+ var onChange = function onChange() {
3147
+ var _props$selectProps2;
3148
+ onChangeTemp.apply(void 0, arguments);
3149
+ if (props === null || props === void 0 ? void 0 : props.selectChangeCallback) {
3150
+ props.selectChangeCallback.apply(props, arguments);
3151
+ }
3152
+ if (props === null || props === void 0 ? void 0 : (_props$selectProps2 = props.selectProps) === null || _props$selectProps2 === void 0 ? void 0 : _props$selectProps2.selectChangeCallback) {
3153
+ var _props$selectProps3;
3154
+ (_props$selectProps3 = props.selectProps).selectChangeCallback.apply(_props$selectProps3, arguments);
3155
+ }
3156
+ };
3146
3157
  useEffect(function () {
3147
3158
  if (init) {
3148
3159
  run('init');
@@ -10179,12 +10190,14 @@ var TreeSearchSelect = function TreeSearchSelect(props) {
10179
10190
  _remoteSource$initial = remoteSource.initialParams,
10180
10191
  initialParams = _remoteSource$initial === void 0 ? {} : _remoteSource$initial,
10181
10192
  _remoteSource$treeChi = remoteSource.treeChildrenRoom,
10182
- treeChildrenRoom = _remoteSource$treeChi === void 0 ? 'children' : _remoteSource$treeChi;
10193
+ treeChildrenRoom = _remoteSource$treeChi === void 0 ? 'children' : _remoteSource$treeChi,
10194
+ _remoteSource$special = remoteSource.specialBracket,
10195
+ specialBracket = _remoteSource$special === void 0 ? false : _remoteSource$special;
10183
10196
  var mapSearchTree = function mapSearchTree(treeDataItem) {
10184
10197
  var haveChildren = Array.isArray(treeDataItem[treeChildrenRoom]) && treeDataItem[treeChildrenRoom].length > 0; // 盘算是否为父节点
10185
10198
  var isRoot = (treeDataItem === null || treeDataItem === void 0 ? void 0 : treeDataItem.id) == '0'; // 判断是否为根节点
10186
10199
  return {
10187
- title: treeDataItem[resKeyValue[1]],
10200
+ title: specialBracket ? "\u3010".concat(treeDataItem[resKeyValue[0]], "\u3011").concat(treeDataItem[resKeyValue[1]]) : treeDataItem[resKeyValue[1]],
10188
10201
  key: treeDataItem[resKeyValue[0]],
10189
10202
  value: treeDataItem[resKeyValue[0]],
10190
10203
  parentId: treeDataItem.parent,
package/dist/index.js CHANGED
@@ -2743,7 +2743,7 @@ var handleSourceName = function handleSourceName(sName) {
2743
2743
  var Option$1 = antd.Select.Option;
2744
2744
  var SearchSelect = /*#__PURE__*/React.forwardRef(function (props, ref) {
2745
2745
  var value = props.value,
2746
- onChange = props.onChange,
2746
+ onChangeTemp = props.onChange,
2747
2747
  _props$selectProps = props.selectProps,
2748
2748
  selectProps = _props$selectProps === void 0 ? {} : _props$selectProps,
2749
2749
  _props$modalTableProp = props.modalTableProps,
@@ -3162,7 +3162,18 @@ var SearchSelect = /*#__PURE__*/React.forwardRef(function (props, ref) {
3162
3162
  }); // 调用api方法
3163
3163
  }
3164
3164
  };
3165
-
3165
+ // 下拉框改变事件
3166
+ var onChange = function onChange() {
3167
+ var _props$selectProps2;
3168
+ onChangeTemp.apply(void 0, arguments);
3169
+ if (props === null || props === void 0 ? void 0 : props.selectChangeCallback) {
3170
+ props.selectChangeCallback.apply(props, arguments);
3171
+ }
3172
+ if (props === null || props === void 0 ? void 0 : (_props$selectProps2 = props.selectProps) === null || _props$selectProps2 === void 0 ? void 0 : _props$selectProps2.selectChangeCallback) {
3173
+ var _props$selectProps3;
3174
+ (_props$selectProps3 = props.selectProps).selectChangeCallback.apply(_props$selectProps3, arguments);
3175
+ }
3176
+ };
3166
3177
  React.useEffect(function () {
3167
3178
  if (init) {
3168
3179
  run('init');
@@ -10199,12 +10210,14 @@ var TreeSearchSelect = function TreeSearchSelect(props) {
10199
10210
  _remoteSource$initial = remoteSource.initialParams,
10200
10211
  initialParams = _remoteSource$initial === void 0 ? {} : _remoteSource$initial,
10201
10212
  _remoteSource$treeChi = remoteSource.treeChildrenRoom,
10202
- treeChildrenRoom = _remoteSource$treeChi === void 0 ? 'children' : _remoteSource$treeChi;
10213
+ treeChildrenRoom = _remoteSource$treeChi === void 0 ? 'children' : _remoteSource$treeChi,
10214
+ _remoteSource$special = remoteSource.specialBracket,
10215
+ specialBracket = _remoteSource$special === void 0 ? false : _remoteSource$special;
10203
10216
  var mapSearchTree = function mapSearchTree(treeDataItem) {
10204
10217
  var haveChildren = Array.isArray(treeDataItem[treeChildrenRoom]) && treeDataItem[treeChildrenRoom].length > 0; // 盘算是否为父节点
10205
10218
  var isRoot = (treeDataItem === null || treeDataItem === void 0 ? void 0 : treeDataItem.id) == '0'; // 判断是否为根节点
10206
10219
  return {
10207
- title: treeDataItem[resKeyValue[1]],
10220
+ title: specialBracket ? "\u3010".concat(treeDataItem[resKeyValue[0]], "\u3011").concat(treeDataItem[resKeyValue[1]]) : treeDataItem[resKeyValue[1]],
10208
10221
  key: treeDataItem[resKeyValue[0]],
10209
10222
  value: treeDataItem[resKeyValue[0]],
10210
10223
  parentId: treeDataItem.parent,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bit-sun/business-component",
3
- "version": "2.4.12",
3
+ "version": "2.4.14",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -16,7 +16,7 @@ const { Option } = Select;
16
16
  const SearchSelect = forwardRef((props: any, ref: any) => {
17
17
  const {
18
18
  value, // 必传
19
- onChange,
19
+ onChange: onChangeTemp,
20
20
  selectProps = {},
21
21
  modalTableProps = {},
22
22
  labelInValue = false,
@@ -390,6 +390,17 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
390
390
  }
391
391
  }
392
392
 
393
+ // 下拉框改变事件
394
+ const onChange = (...arg) => {
395
+ onChangeTemp(...arg)
396
+ if(props?.selectChangeCallback){
397
+ props.selectChangeCallback(...arg)
398
+ }
399
+ if(props?.selectProps?.selectChangeCallback) {
400
+ props.selectProps.selectChangeCallback(...arg)
401
+ }
402
+ }
403
+
393
404
  useEffect(() => {
394
405
  if (init) {
395
406
  run('init')
@@ -41,26 +41,29 @@ const TreeSearchSelect = (props: any) => {
41
41
  resKeyValue = ['id', 'name'],
42
42
  initialParams = {},
43
43
  treeChildrenRoom = 'children',// 树状结构的子集容器 默认为 'children'
44
+ specialBracket = false
44
45
  } = remoteSource;
45
46
 
46
47
  const mapSearchTree = (treeDataItem: any) => {
47
48
  const haveChildren = Array.isArray(treeDataItem[treeChildrenRoom]) && treeDataItem[treeChildrenRoom].length > 0; // 盘算是否为父节点
48
49
  const isRoot = treeDataItem?.id == '0'; // 判断是否为根节点
49
50
  return {
50
- title: treeDataItem[resKeyValue[1]],
51
+ title: specialBracket
52
+ ? `【${treeDataItem[resKeyValue[0]]}】${treeDataItem[resKeyValue[1]]}`
53
+ : treeDataItem[resKeyValue[1]],
51
54
  key: treeDataItem[resKeyValue[0]],
52
55
  value: treeDataItem[resKeyValue[0]],
53
56
  parentId: treeDataItem.parent,
54
57
  data: { ...treeDataItem },
55
58
  isLeaf: !haveChildren,
56
- disabled: isDisabled(haveChildren,isRoot),
59
+ disabled: isDisabled(haveChildren, isRoot),
57
60
  children: haveChildren ? treeDataItem[treeChildrenRoom].map((i: any) => mapSearchTree(i)) : [],
58
61
  };
59
62
  };
60
63
 
61
- const isDisabled = (isParent: boolean,isRoot: boolean) => {
64
+ const isDisabled = (isParent: boolean, isRoot: boolean) => {
62
65
  if (isChoose) {
63
- if(rootDisabled && isRoot){
66
+ if (rootDisabled && isRoot) {
64
67
  return rootDisabled
65
68
  }
66
69
  return false;
@@ -74,11 +77,11 @@ const TreeSearchSelect = (props: any) => {
74
77
  [`${paramsKey}`]: q,
75
78
  ...initialParams,
76
79
  }
77
- axios.get(`${url}?${stringify(paramsData)}`, {headers}).then(async (res: any) => {
80
+ axios.get(`${url}?${stringify(paramsData)}`, { headers }).then(async (res: any) => {
78
81
  const resData = res?.data || [];
79
82
  let coverData;
80
83
 
81
- if(judgeIsRequestSuccess(resData)) {
84
+ if (judgeIsRequestSuccess(resData)) {
82
85
  const { data } = resData;
83
86
  if (remoteSource.converter) {
84
87
  coverData = await remoteSource.converter({ data: [data] })
@@ -97,14 +100,14 @@ const TreeSearchSelect = (props: any) => {
97
100
 
98
101
  const formatData = (value: any) => {
99
102
  if (labelInValue) {
100
- const formatResult = multiple||treeCheckable ? value.map((i: any) => ({...i, key: i.value})) : { ...value, key: value?.value };
103
+ const formatResult = multiple || treeCheckable ? value.map((i: any) => ({ ...i, key: i.value })) : { ...value, key: value?.value };
101
104
  return formatResult
102
105
  } else {
103
- const formatResult = multiple||treeCheckable ? value.map((i: any) => (i?.value || i)) : (_.get(value?.[0], 'value') || value)
106
+ const formatResult = multiple || treeCheckable ? value.map((i: any) => (i?.value || i)) : (_.get(value?.[0], 'value') || value)
104
107
  return formatResult
105
108
  }
106
109
  }
107
- const parallelData = (data: any,result: any) => {
110
+ const parallelData = (data: any, result: any) => {
108
111
  data.forEach((i: any) => {
109
112
  result.push(i);
110
113
  if (i[treeChildrenRoom]) {
@@ -113,31 +116,31 @@ const TreeSearchSelect = (props: any) => {
113
116
  });
114
117
  return result;
115
118
  }
116
- const getSelectItem = (tData: any,selectValue: any) => {
117
- const handleList = tData||[];
119
+ const getSelectItem = (tData: any, selectValue: any) => {
120
+ const handleList = tData || [];
118
121
  let result = [];
119
- if(labelInValue) {
120
- result = multiple||treeCheckable ? (selectValue?.map((i: any) => {
121
- if(handleList.some((s: any) => s.key == i.value)){
122
+ if (labelInValue) {
123
+ result = multiple || treeCheckable ? (selectValue?.map((i: any) => {
124
+ if (handleList.some((s: any) => s.key == i.value)) {
122
125
  return handleList.find((s: any) => s.key == i.value)
123
126
  }
124
- }) || []) : (handleList?.find((s: any) => s.key == selectValue?.value)||{})
127
+ }) || []) : (handleList?.find((s: any) => s.key == selectValue?.value) || {})
125
128
  } else {
126
129
  const cValue = _.get(selectValue?.[0], 'value', selectValue);
127
- result = multiple||treeCheckable ? (selectValue?.map((i: any) => {
128
- if(handleList.some((s: any) => s.key == i)){
130
+ result = multiple || treeCheckable ? (selectValue?.map((i: any) => {
131
+ if (handleList.some((s: any) => s.key == i)) {
129
132
  return handleList.find((s: any) => s.key == i)
130
133
  }
131
- }) || []) : (handleList?.find((s: any) => s.key == cValue)||{})
134
+ }) || []) : (handleList?.find((s: any) => s.key == cValue) || {})
132
135
  }
133
136
  return result;
134
137
  }
135
138
  const handleChange = (data: any, dataName: any) => {
136
139
  const handleData = formatData(data);
137
140
  // 获取选中树节点当条数据,并返回给调用业务
138
- const parallelTreeData = parallelData(treeData,[])
139
- const currentItem = getSelectItem(parallelTreeData,data)
140
- onChange(handleData,data,currentItem,parallelTreeData);
141
+ const parallelTreeData = parallelData(treeData, [])
142
+ const currentItem = getSelectItem(parallelTreeData, data)
143
+ onChange(handleData, data, currentItem, parallelTreeData);
141
144
  onChangeName && onChangeName(dataName);
142
145
  getTreeData && getTreeData(treeData); // 把树节点暴露出去
143
146
  ctx?.form?.setFieldValue(ctx.name, handleData);
@@ -148,17 +151,17 @@ const TreeSearchSelect = (props: any) => {
148
151
  }, []);
149
152
 
150
153
  const maxTagPlaceholder = (selectedValues: any) => {
151
- const onClose = (e: any,item: any) => {
154
+ const onClose = (e: any, item: any) => {
152
155
  e.preventDefault();
153
- 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)
154
- const newValueName = labelInValue ? null: JSON.parse(JSON.stringify(valueName)).filter((i: any) => i !== item.label)
156
+ 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)
157
+ const newValueName = labelInValue ? null : JSON.parse(JSON.stringify(valueName)).filter((i: any) => i !== item.label)
155
158
  handleChange(newValue, newValueName);
156
159
  }
157
160
  return (
158
161
  <Tooltip title={selectedValues.map((i: any) => (
159
162
  <Tag
160
163
  closable={true}
161
- onClose={(e) => onClose(e,i)}
164
+ onClose={(e) => onClose(e, i)}
162
165
  style={{ marginRight: 3, background: '#f5f5f5', height: '24px', border: '1px solid #f0f0f0' }}
163
166
  >
164
167
  {i.label}
@@ -190,7 +193,7 @@ const TreeSearchSelect = (props: any) => {
190
193
  multiple={multiple} // 支持多选(当设置 treeCheckable 时自动变为 true)
191
194
  maxTagPlaceholder={maxTagPlaceholder}
192
195
  onChange={handleChange}
193
- disabled={disabled || mode==='view' || ctx?.mode === 'view'}
196
+ disabled={disabled || mode === 'view' || ctx?.mode === 'view'}
194
197
  getPopupContainer={(triggerNode) => (getPopupContainer && getPopupContainer(triggerNode)) || document.body}
195
198
  >
196
199
  </TreeSelect>