@bit-sun/business-component 2.2.3 → 2.2.5
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/components/Business/BsSulaQueryTable/SearchItemSetting.d.ts +59 -0
- package/dist/index.esm.js +564 -30
- package/dist/index.js +564 -30
- package/dist/utils/enumConfig.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +538 -0
- package/src/components/Business/BsSulaQueryTable/index.tsx +69 -20
- package/src/components/Business/BsSulaQueryTable/setting.tsx +1 -1
- package/src/components/Functional/TreeSearchSelect/index.tsx +13 -2
- package/src/utils/enumConfig.ts +1 -0
|
@@ -8,11 +8,13 @@ import {
|
|
|
8
8
|
authFn,
|
|
9
9
|
queryParams,
|
|
10
10
|
} from './utils';
|
|
11
|
-
import { Menu, Tooltip, } from 'antd';
|
|
11
|
+
import { Menu, Tooltip, Dropdown } from 'antd';
|
|
12
12
|
import SortableTable from './setting';
|
|
13
|
+
import SearchItemTable from "./SearchItemSetting";
|
|
13
14
|
import { Resizable } from 'react-resizable';
|
|
14
15
|
import quanping from '../../../assets/icon-quanping.svg';
|
|
15
16
|
import scanning from '../../../assets/scanning.svg';
|
|
17
|
+
import shezhi from '../../../assets/icon-shezhi.svg';
|
|
16
18
|
import { debounce } from 'lodash';
|
|
17
19
|
import ExportIcon from '@/components/Functional/ExportFunctions/ExportIcon';
|
|
18
20
|
import ENUM from '@/utils/enumConfig';
|
|
@@ -52,8 +54,8 @@ export default (props: any) => {
|
|
|
52
54
|
const [isFullScreen, setIsFnllScreen]: any = useState(false);
|
|
53
55
|
// @ts-nocheck
|
|
54
56
|
const [value, setValue]: any = useState(props);
|
|
55
|
-
const [showColumn, setShowColumns] = useState([]);
|
|
56
|
-
|
|
57
|
+
const [showColumn, setShowColumns] = useState([]); // 列字段
|
|
58
|
+
const [showSearchFields, setShowSearchFields] = useState([]); //搜索项字段
|
|
57
59
|
const { isPage = true, pagination, tableCode } = props;
|
|
58
60
|
|
|
59
61
|
const [height, setHeight]: any = useState('100vh');
|
|
@@ -93,8 +95,8 @@ export default (props: any) => {
|
|
|
93
95
|
return isFull;
|
|
94
96
|
}
|
|
95
97
|
|
|
96
|
-
const getConfigFromlocalstorage = () => {
|
|
97
|
-
let config = localStorage.getItem(
|
|
98
|
+
const getConfigFromlocalstorage = (type: string) => {
|
|
99
|
+
let config = localStorage.getItem(type) || '[]';
|
|
98
100
|
let configArray = JSON.parse(config);
|
|
99
101
|
let configSetting = configArray.filter(
|
|
100
102
|
(item) => item.code === bsTableCode,
|
|
@@ -154,7 +156,7 @@ export default (props: any) => {
|
|
|
154
156
|
columns: [...props.columns],
|
|
155
157
|
});
|
|
156
158
|
const { columns } = props;
|
|
157
|
-
let columnConfig = getConfigFromlocalstorage();
|
|
159
|
+
let columnConfig = getConfigFromlocalstorage(ENUM.BROWSER_CACHE.COLUMN_CONDITION);
|
|
158
160
|
let showColumns = columnConfig.length ? columnConfig.map((item) => {
|
|
159
161
|
let inner = columns.filter(
|
|
160
162
|
(inneritem) => {
|
|
@@ -188,12 +190,35 @@ export default (props: any) => {
|
|
|
188
190
|
});
|
|
189
191
|
});
|
|
190
192
|
setShowColumns([...showColumns]);
|
|
193
|
+
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const setInitialSearchFieldsInfo = () =>{
|
|
197
|
+
//获取搜索字段的缓存配置
|
|
198
|
+
const { fields } = props;
|
|
199
|
+
let searchFieldsConfig = getConfigFromlocalstorage(ENUM.BROWSER_CACHE.SEARCH_FIELDS_CONDITION);
|
|
200
|
+
let showSearchFields = searchFieldsConfig.length ? searchFieldsConfig.map((item) => {
|
|
201
|
+
let inner = fields.filter(
|
|
202
|
+
(inneritem) => {
|
|
203
|
+
let innerKey = Array.isArray(inneritem.name) ? JSON.stringify(inneritem.name) : inneritem.name;
|
|
204
|
+
let itemKey = Array.isArray(item.name) ? JSON.stringify(item.name) : item.name;
|
|
205
|
+
return innerKey && innerKey === itemKey;
|
|
206
|
+
}
|
|
207
|
+
)[0];
|
|
208
|
+
|
|
209
|
+
return {
|
|
210
|
+
...inner,
|
|
211
|
+
...item,
|
|
212
|
+
};
|
|
213
|
+
}) : fields;
|
|
214
|
+
setShowSearchFields([...showSearchFields])
|
|
191
215
|
}
|
|
192
216
|
|
|
193
217
|
//组件初始挂载
|
|
194
218
|
useEffect(() => {
|
|
195
219
|
getTableHeight();
|
|
196
220
|
setInitialTableInfo();
|
|
221
|
+
setInitialSearchFieldsInfo();
|
|
197
222
|
window.addEventListener('resize', (e) => {
|
|
198
223
|
watchWinResize();
|
|
199
224
|
});
|
|
@@ -209,6 +234,14 @@ export default (props: any) => {
|
|
|
209
234
|
}
|
|
210
235
|
}, [props?.columns])
|
|
211
236
|
|
|
237
|
+
useEffect(() => {
|
|
238
|
+
if (props?.fields && value?.fields) {
|
|
239
|
+
let newKeys = props.fields.map((d: any) => Array.isArray(d.name) ? JSON.stringify(d.name) : (d.name));
|
|
240
|
+
let oldKeys = value.fields.map((d: any) => Array.isArray(d.name) ? JSON.stringify(d.name) : (d.name));
|
|
241
|
+
JSON.stringify(newKeys) !== JSON.stringify(oldKeys) && setInitialSearchFieldsInfo();
|
|
242
|
+
}
|
|
243
|
+
},[props?.fields])
|
|
244
|
+
|
|
212
245
|
useEffect(() => {
|
|
213
246
|
setInitialTableInfo();
|
|
214
247
|
}, [props?.refreshColumns]);
|
|
@@ -335,19 +368,34 @@ export default (props: any) => {
|
|
|
335
368
|
type: 'text',
|
|
336
369
|
props: {
|
|
337
370
|
children: (
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
371
|
+
<span className="ant-dropdown-link">
|
|
372
|
+
<Dropdown overlay={
|
|
373
|
+
<Menu >
|
|
374
|
+
<Menu.Item>
|
|
375
|
+
<SortableTable
|
|
376
|
+
ref={sortTableRef}
|
|
377
|
+
setShowColumns={setShowColumns}
|
|
378
|
+
showColumn={showColumn}
|
|
379
|
+
datasource={value?.columns || []}
|
|
380
|
+
bsTableCode={bsTableCode}
|
|
381
|
+
/>
|
|
382
|
+
</Menu.Item>
|
|
383
|
+
<Menu.Item>
|
|
384
|
+
<SearchItemTable
|
|
385
|
+
ref={sortTableRef}
|
|
386
|
+
setShowSearchFields={setShowSearchFields}
|
|
387
|
+
showSearchFields={showSearchFields}
|
|
388
|
+
datasource={value?.fields || []}
|
|
389
|
+
bsTableCode={bsTableCode}
|
|
390
|
+
/>
|
|
391
|
+
</Menu.Item>
|
|
392
|
+
</Menu>
|
|
393
|
+
} placement="bottom" >
|
|
394
|
+
<span className="ant-dropdown-link">
|
|
395
|
+
<img width={32} src={shezhi} />
|
|
396
|
+
</span>
|
|
397
|
+
</Dropdown>
|
|
398
|
+
</span>
|
|
351
399
|
),
|
|
352
400
|
},
|
|
353
401
|
},
|
|
@@ -450,6 +498,7 @@ export default (props: any) => {
|
|
|
450
498
|
...handleTimeValue(),
|
|
451
499
|
tableProps: setTableProps(),
|
|
452
500
|
columns: [...showColumn],
|
|
501
|
+
fields: [...showSearchFields],
|
|
453
502
|
ref: props.forwardedRef || refs,
|
|
454
503
|
isFullScreen,
|
|
455
504
|
};
|
|
@@ -474,7 +523,7 @@ export default (props: any) => {
|
|
|
474
523
|
summary: props.summary,
|
|
475
524
|
statusMapping: props.statusMapping,
|
|
476
525
|
}),
|
|
477
|
-
[value, checkedList, showColumn, props.statusMapping],
|
|
526
|
+
[value, checkedList, showColumn, props.statusMapping, showSearchFields],
|
|
478
527
|
);
|
|
479
528
|
return <MemoQueryTable {...memoConfig} />;
|
|
480
529
|
};
|
|
@@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';
|
|
|
2
2
|
import { TreeSelect, Tooltip, Tag } from 'antd';
|
|
3
3
|
import axios from 'axios';
|
|
4
4
|
import { stringify } from 'querystring';
|
|
5
|
+
import _ from "lodash"
|
|
5
6
|
|
|
6
7
|
const TreeSearchSelect = (props: any) => {
|
|
7
8
|
const [treeData, setTreeData] = useState([]);
|
|
@@ -85,11 +86,21 @@ const TreeSearchSelect = (props: any) => {
|
|
|
85
86
|
});
|
|
86
87
|
};
|
|
87
88
|
|
|
89
|
+
const formatData = (value: any) => {
|
|
90
|
+
if (labelInValue) {
|
|
91
|
+
const formatResult = multiple ? value.map((i: any) => ({...i, key: i.value})) : { ...value, key: value?.value };
|
|
92
|
+
return formatResult
|
|
93
|
+
} else {
|
|
94
|
+
const formatResult = multiple ? value.map((i: any) => (i?.value || i)) : (_.get(value[0], 'value') || value)
|
|
95
|
+
return formatResult
|
|
96
|
+
}
|
|
97
|
+
}
|
|
88
98
|
const handleChange = (data: any, dataName: any) => {
|
|
89
|
-
|
|
99
|
+
const handleData = formatData(data);
|
|
100
|
+
onChange(handleData,data);
|
|
90
101
|
onChangeName && onChangeName(dataName);
|
|
91
102
|
getTreeData && getTreeData(treeData); // 把树节点暴露出去
|
|
92
|
-
ctx?.form?.setFieldValue(ctx.name,
|
|
103
|
+
ctx?.form?.setFieldValue(ctx.name, handleData);
|
|
93
104
|
};
|
|
94
105
|
|
|
95
106
|
useEffect(() => {
|