@bit-sun/business-component 2.0.26 → 2.0.28
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/columnSettingTable/columnSetting.d.ts +54 -0
- package/dist/components/Business/columnSettingTable/index.d.ts +15 -0
- package/dist/components/Business/columnSettingTable/sulaSettingTable.d.ts +16 -0
- package/dist/components/Business/columnSettingTable/utils.d.ts +8 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +6583 -6737
- package/dist/index.js +6582 -6735
- package/lib/assets/arrow_top.png +0 -0
- package/lib/assets/drag.svg +17 -0
- package/lib/assets/exportFail.svg +38 -0
- package/lib/assets/exportProcessing.svg +29 -0
- package/lib/assets/exportSuccess.svg +35 -0
- package/lib/assets/exportlogo.png +0 -0
- package/lib/assets/label_icon_bottom.svg +26 -0
- package/lib/assets/upExport.svg +23 -0
- package/package.json +61 -52
- package/src/assets/close.svg +26 -0
- package/src/assets/icon-shezhi.svg +18 -0
- package/src/components/Business/columnSettingTable/columnSetting.tsx +595 -0
- package/src/components/Business/columnSettingTable/index.less +247 -0
- package/src/components/Business/columnSettingTable/index.md +358 -0
- package/src/components/Business/columnSettingTable/index.tsx +217 -0
- package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +225 -0
- package/src/components/Business/columnSettingTable/utils.tsx +69 -0
- package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +1 -0
- package/src/components/Functional/SearchSelect/index.tsx +66 -57
- package/src/index.ts +3 -1
- package/typings.d.ts +2 -1
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Table, Tooltip, Typography } from 'antd';
|
|
3
|
+
import { Resizable } from 'react-resizable';
|
|
4
|
+
import ColumnSetting from './columnSetting';
|
|
5
|
+
import { getItemDefaultWidth, handleTextOverflow } from './utils';
|
|
6
|
+
import { noEmptyArray } from './utils';
|
|
7
|
+
const { Text } = Typography;
|
|
8
|
+
export default class ColumnSettingTable extends React.Component {
|
|
9
|
+
state: any;
|
|
10
|
+
constructor(props: any) {
|
|
11
|
+
super(props);
|
|
12
|
+
this.state = {
|
|
13
|
+
showColumns: [],
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
componentDidMount() {
|
|
18
|
+
const { columns }: any = this.props;
|
|
19
|
+
this.setInitialShowColumn(columns || [])
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
componentWillReceiveProps(nextProps: any) {
|
|
23
|
+
// if (JSON.stringify(this.props.columns) !== JSON.stringify(nextProps.columns)) {
|
|
24
|
+
// }
|
|
25
|
+
this.setInitialShowColumn(nextProps.columns || [])
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
setInitialShowColumn = (columns: any[]) => {
|
|
29
|
+
// 获取当前列表定义数据
|
|
30
|
+
let columnConfig = this.getConfigFromlocalstorage();
|
|
31
|
+
let showColumns = columnConfig.length ? columnConfig.map((item: any) => {
|
|
32
|
+
let inner = columns.filter(innerItem => (
|
|
33
|
+
innerItem.dataIndex && innerItem.dataIndex === item.dataIndex
|
|
34
|
+
) || (innerItem.key && innerItem.key === item.key))[0];
|
|
35
|
+
return {
|
|
36
|
+
...inner,
|
|
37
|
+
...item,
|
|
38
|
+
}
|
|
39
|
+
}).filter((item: any) => !item.hidden)
|
|
40
|
+
:
|
|
41
|
+
(columns || []).filter((item: any) => !item.hidden);
|
|
42
|
+
this.setState({
|
|
43
|
+
showColumns,
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
setShowColumns = (newColumns: Array<any>) => {
|
|
49
|
+
this.setState({
|
|
50
|
+
showColumns: [...newColumns]
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
getConfigFromlocalstorage = () => {
|
|
55
|
+
const { tableCode }: any = this.props;
|
|
56
|
+
if (!tableCode) return [];
|
|
57
|
+
let config = localStorage.getItem('columnCondition') || '[]';
|
|
58
|
+
let configArray = JSON.parse(config);
|
|
59
|
+
let configSetting = configArray.filter(
|
|
60
|
+
(item:any) => item.code === tableCode,
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
if (configSetting.length) {
|
|
64
|
+
return JSON.parse(configSetting[0].detail || '[]');
|
|
65
|
+
}
|
|
66
|
+
return [];
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
getTableSummaryInfo = () => {
|
|
70
|
+
const { summary = undefined, rowSelection }: any = this.props;
|
|
71
|
+
const { showColumns }: any = this.state;
|
|
72
|
+
let summaryRow = rowSelection ? [{}, ...showColumns] : [...showColumns];
|
|
73
|
+
let summaryInitial = summary().cont;
|
|
74
|
+
let summaryDom: any = <Table.Summary.Row>
|
|
75
|
+
{
|
|
76
|
+
[...summaryRow].map((item: any, index: number) => {
|
|
77
|
+
return (
|
|
78
|
+
<Table.Summary.Cell index={index}>
|
|
79
|
+
<Text type="danger">
|
|
80
|
+
{
|
|
81
|
+
summaryInitial.filter((inner:any) => inner.key === item.dataIndex || inner.key === item.key).length ?
|
|
82
|
+
`${item.title}: ${summaryInitial.filter((inner:any) => inner.key === item.dataIndex || inner.key === item.key)[0].value}` : ''
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
</Text>
|
|
86
|
+
</Table.Summary.Cell>
|
|
87
|
+
)
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
</Table.Summary.Row >;
|
|
91
|
+
return () => summaryDom
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
handledynamicColumns = (col: any[]) => {
|
|
95
|
+
let { dynamicColumns, modeType }: any = this.props;
|
|
96
|
+
col = col.map((item: any) => {
|
|
97
|
+
let target = dynamicColumns.find((d: any) => item.dataIndex === d.key || item.key === d.key)
|
|
98
|
+
if (modeType === 'view' && target) {
|
|
99
|
+
item.render = target?.render;
|
|
100
|
+
}
|
|
101
|
+
return { ...item };
|
|
102
|
+
})
|
|
103
|
+
return [...col]
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
handleResize = (index: any) => (_: any, { size }: any) => {
|
|
107
|
+
let newColumns = this.state.showColumns.map((col: any) => ({ ...col }));
|
|
108
|
+
const handleIndex = (arr: any, indexArr: any) => {
|
|
109
|
+
let i = indexArr.shift();
|
|
110
|
+
if (indexArr.length > 0) {
|
|
111
|
+
handleIndex(arr[i].children, indexArr);
|
|
112
|
+
} else {
|
|
113
|
+
arr[i] = {
|
|
114
|
+
...arr[i],
|
|
115
|
+
width: size.width,
|
|
116
|
+
};
|
|
117
|
+
if (arr[i].textOverflow) {
|
|
118
|
+
arr[i].render = ({ text }: any) => handleTextOverflow(text, size.width);
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
handleIndex(newColumns, [...index]);
|
|
123
|
+
this.setState({
|
|
124
|
+
showColumns: [...newColumns]
|
|
125
|
+
})
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
ResizeableTitle = (props: any) => {
|
|
129
|
+
const { onResize, width, ...restProps } = props;
|
|
130
|
+
|
|
131
|
+
if (!width) {
|
|
132
|
+
return <th {...restProps} />;
|
|
133
|
+
}
|
|
134
|
+
return (
|
|
135
|
+
<Resizable
|
|
136
|
+
width={width}
|
|
137
|
+
height={0}
|
|
138
|
+
onResize={onResize}
|
|
139
|
+
draggableOpts={{ enableUserSelectHack: false }}
|
|
140
|
+
>
|
|
141
|
+
<th {...restProps} />
|
|
142
|
+
</Resizable>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
render() {
|
|
147
|
+
const { columns, tableCode, summary = undefined, dynamicColumns = [], ...restProps }: any = this.props;
|
|
148
|
+
let otherTableInfo = {
|
|
149
|
+
...restProps,
|
|
150
|
+
};
|
|
151
|
+
let showSummary = null;
|
|
152
|
+
if (this.state.showColumns.length) {
|
|
153
|
+
if (summary && summary().diy) {
|
|
154
|
+
showSummary = this.getTableSummaryInfo();
|
|
155
|
+
} else {
|
|
156
|
+
showSummary = summary;
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const handleColumns = (arr: any, indexArr: any[]) => {
|
|
161
|
+
arr.forEach((item: any, index: any) => {
|
|
162
|
+
let indexArrInside = [...indexArr, index].filter((i: any) => i || i === 0)
|
|
163
|
+
if (noEmptyArray(item.children)) {
|
|
164
|
+
handleColumns(item.children, indexArrInside);
|
|
165
|
+
} else {
|
|
166
|
+
item.width = item.width || getItemDefaultWidth(item);
|
|
167
|
+
item.onHeaderCell = (column: any) => ({
|
|
168
|
+
...item,
|
|
169
|
+
width:
|
|
170
|
+
typeof column.width === 'number'
|
|
171
|
+
? column.width
|
|
172
|
+
: parseInt(column.width.replace('px', '')),
|
|
173
|
+
onResize: this.handleResize(indexArrInside),
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
})
|
|
177
|
+
};
|
|
178
|
+
let showCol = this.state.showColumns.map((item: any) => {
|
|
179
|
+
return ({ ...item })
|
|
180
|
+
})
|
|
181
|
+
handleColumns(showCol, []);
|
|
182
|
+
if (dynamicColumns.length) {
|
|
183
|
+
showCol = this.handledynamicColumns(showCol);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
otherTableInfo = {
|
|
187
|
+
...otherTableInfo,
|
|
188
|
+
summary: showSummary,
|
|
189
|
+
}
|
|
190
|
+
return (
|
|
191
|
+
<div>
|
|
192
|
+
<div style={{ overflow: 'hidden', padding: '0 8px 10px 0' }}>
|
|
193
|
+
<span style={{ float: 'right' }} className="ant-dropdown-link">
|
|
194
|
+
<ColumnSetting
|
|
195
|
+
setShowColumns={this.setShowColumns}
|
|
196
|
+
showColumns={this.state.showColumns}
|
|
197
|
+
datasource={columns || []}
|
|
198
|
+
tableCode={tableCode}
|
|
199
|
+
/>
|
|
200
|
+
</span>
|
|
201
|
+
</div>
|
|
202
|
+
<Table
|
|
203
|
+
columns={showCol}
|
|
204
|
+
components={{
|
|
205
|
+
header: {
|
|
206
|
+
cell: this.ResizeableTitle,
|
|
207
|
+
},
|
|
208
|
+
}}
|
|
209
|
+
{
|
|
210
|
+
...otherTableInfo
|
|
211
|
+
}
|
|
212
|
+
/>
|
|
213
|
+
</div >
|
|
214
|
+
)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Table as SulaTable, request } from 'bssula';
|
|
3
|
+
import { Resizable } from 'react-resizable';
|
|
4
|
+
import ColumnSetting from './columnSetting';
|
|
5
|
+
import { getItemDefaultWidth, handleTextOverflow } from './utils';
|
|
6
|
+
import { noEmptyArray } from './utils';
|
|
7
|
+
import {
|
|
8
|
+
Table,
|
|
9
|
+
Typography,
|
|
10
|
+
} from 'antd';
|
|
11
|
+
const { Text } = Typography;
|
|
12
|
+
export default class ColumnSettingSulaTable extends React.Component {
|
|
13
|
+
sulaTableRef: React.RefObject<unknown>;
|
|
14
|
+
state: any;
|
|
15
|
+
constructor(props: any) {
|
|
16
|
+
super(props);
|
|
17
|
+
this.state = {
|
|
18
|
+
showColumns: [],
|
|
19
|
+
}
|
|
20
|
+
this.sulaTableRef = React.createRef();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
componentDidMount() {
|
|
24
|
+
const { columns }: any = this.props;
|
|
25
|
+
this.setInitialShowColumn(columns || [])
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
componentWillReceiveProps(nextProps: any) {
|
|
29
|
+
// if (JSON.stringify(this.props.columns) !== JSON.stringify(nextProps.columns)) {
|
|
30
|
+
// }
|
|
31
|
+
this.setInitialShowColumn(nextProps.columns || [])
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
setInitialShowColumn = (columns: any[]) => {
|
|
35
|
+
// 获取当前列表定义数据
|
|
36
|
+
let columnConfig = this.getConfigFromlocalstorage();
|
|
37
|
+
let showColumns = columnConfig.length ? columnConfig.map((item:any) => {
|
|
38
|
+
let inner = columns.filter(innerItem => (
|
|
39
|
+
innerItem.dataIndex && innerItem.dataIndex === item.dataIndex
|
|
40
|
+
) || (innerItem.key && innerItem.key === item.key))[0];
|
|
41
|
+
return {
|
|
42
|
+
...inner,
|
|
43
|
+
...item,
|
|
44
|
+
}
|
|
45
|
+
}).filter((item: any) => !item.hidden)
|
|
46
|
+
:
|
|
47
|
+
(columns || []).filter((item: any) => !item.hidden);
|
|
48
|
+
this.setState({
|
|
49
|
+
showColumns,
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
setShowColumns = (newColumns: Array<any>) => {
|
|
55
|
+
this.setState({
|
|
56
|
+
showColumns: [...newColumns]
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
getConfigFromlocalstorage = () => {
|
|
61
|
+
const { tableCode }:any = this.props;
|
|
62
|
+
if (!tableCode) return [];
|
|
63
|
+
let config = localStorage.getItem('columnCondition') || '[]';
|
|
64
|
+
let configArray = JSON.parse(config);
|
|
65
|
+
let configSetting = configArray.filter(
|
|
66
|
+
(item: any) => item.code === tableCode,
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
if (configSetting.length) {
|
|
70
|
+
return JSON.parse(configSetting[0].detail || '[]');
|
|
71
|
+
}
|
|
72
|
+
return [];
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
getTableSummaryInfo = () => {
|
|
76
|
+
const { summary = undefined, rowSelection }: any = this.props;
|
|
77
|
+
const { showColumns }: any = this.state;
|
|
78
|
+
let summaryRow = rowSelection ? [{}, ...showColumns] : [...showColumns];
|
|
79
|
+
let summaryInitial = summary().cont;
|
|
80
|
+
let summaryDom: any = <Table.Summary.Row>
|
|
81
|
+
{
|
|
82
|
+
[...summaryRow].map((item: any, index: number) => {
|
|
83
|
+
return (
|
|
84
|
+
<Table.Summary.Cell index={rowSelection ? index : index-1}>
|
|
85
|
+
<Text type="danger">
|
|
86
|
+
{
|
|
87
|
+
summaryInitial.filter((inner:any) => inner.key === item.dataIndex || inner.key === item.key).length ?
|
|
88
|
+
`${item.title}: ${summaryInitial.filter((inner:any) => inner.key === item.dataIndex || inner.key === item.key)[0].value}` : ''
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
</Text>
|
|
92
|
+
</Table.Summary.Cell>
|
|
93
|
+
)
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
</Table.Summary.Row >;
|
|
97
|
+
return () => summaryDom
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
handledynamicColumns = (col: any[]) => {
|
|
101
|
+
let { dynamicColumns, modeType }: any = this.props;
|
|
102
|
+
col = col.map((item: any) => {
|
|
103
|
+
let target = dynamicColumns.find((d: any) => item.dataIndex === d.key || item.key === d.key)
|
|
104
|
+
if (modeType === 'view' && target) {
|
|
105
|
+
item.render = target?.render;
|
|
106
|
+
}
|
|
107
|
+
return { ...item };
|
|
108
|
+
})
|
|
109
|
+
return [...col]
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
handleResize = (index: any) => (_: any, { size }: any) => {
|
|
113
|
+
let newColumns = this.state.showColumns.map((col: any) => ({ ...col }));
|
|
114
|
+
const handleIndex = (arr: any, indexArr: any) => {
|
|
115
|
+
let i = indexArr.shift();
|
|
116
|
+
if (indexArr.length > 0) {
|
|
117
|
+
handleIndex(arr[i].children, indexArr);
|
|
118
|
+
} else {
|
|
119
|
+
arr[i] = {
|
|
120
|
+
...arr[i],
|
|
121
|
+
width: size.width,
|
|
122
|
+
};
|
|
123
|
+
if (arr[i].textOverflow) {
|
|
124
|
+
arr[i].render = ({ text }: any) => handleTextOverflow(text, size.width);
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
handleIndex(newColumns, [...index]);
|
|
129
|
+
this.setState({
|
|
130
|
+
showColumns: [...newColumns]
|
|
131
|
+
})
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
ResizeableTitle = (props: any) => {
|
|
135
|
+
const { onResize, width, ...restProps } = props;
|
|
136
|
+
|
|
137
|
+
if (!width) {
|
|
138
|
+
return <th {...restProps} />;
|
|
139
|
+
}
|
|
140
|
+
return (
|
|
141
|
+
<Resizable
|
|
142
|
+
width={width}
|
|
143
|
+
height={0}
|
|
144
|
+
onResize={onResize}
|
|
145
|
+
draggableOpts={{ enableUserSelectHack: false }}
|
|
146
|
+
>
|
|
147
|
+
<th {...restProps} />
|
|
148
|
+
</Resizable>
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
render() {
|
|
153
|
+
const { style=null, columns, tableCode, summary = undefined, dynamicColumns = [], ...restProps }: any = this.props;
|
|
154
|
+
let otherTableInfo = {
|
|
155
|
+
...restProps,
|
|
156
|
+
};
|
|
157
|
+
let showSummary = null;
|
|
158
|
+
if (this.state.showColumns.length) {
|
|
159
|
+
if (summary && summary().diy) {
|
|
160
|
+
showSummary = this.getTableSummaryInfo();
|
|
161
|
+
} else {
|
|
162
|
+
showSummary = summary;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const handleColumns = (arr: any, indexArr: any[]) => {
|
|
167
|
+
arr.forEach((item: any, index: any) => {
|
|
168
|
+
let indexArrInside = [...indexArr, index].filter((i: any) => i || i === 0)
|
|
169
|
+
if (noEmptyArray(item.children)) {
|
|
170
|
+
handleColumns(item.children, indexArrInside);
|
|
171
|
+
} else {
|
|
172
|
+
item.width = item.width || getItemDefaultWidth(item);
|
|
173
|
+
item.onHeaderCell = (column: any) => ({
|
|
174
|
+
...item,
|
|
175
|
+
width:
|
|
176
|
+
typeof column.width === 'number'
|
|
177
|
+
? column.width
|
|
178
|
+
: parseInt(column.width.replace('px', '')),
|
|
179
|
+
onResize: this.handleResize(indexArrInside),
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
})
|
|
183
|
+
};
|
|
184
|
+
let showCol = this.state.showColumns.map((item: any) => {
|
|
185
|
+
return ({ ...item })
|
|
186
|
+
})
|
|
187
|
+
handleColumns(showCol, []);
|
|
188
|
+
if (dynamicColumns.length) {
|
|
189
|
+
showCol = this.handledynamicColumns(showCol);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
otherTableInfo = {
|
|
193
|
+
...otherTableInfo,
|
|
194
|
+
summary: showSummary,
|
|
195
|
+
}
|
|
196
|
+
return (
|
|
197
|
+
<div>
|
|
198
|
+
<div style={{ overflow: 'hidden', padding: '0 8px 10px 0' }}>
|
|
199
|
+
<span style={{ float: 'right' }} className="ant-dropdown-link">
|
|
200
|
+
<ColumnSetting
|
|
201
|
+
setShowColumns={this.setShowColumns}
|
|
202
|
+
showColumns={this.state.showColumns}
|
|
203
|
+
datasource={columns || []}
|
|
204
|
+
tableCode={tableCode}
|
|
205
|
+
/>
|
|
206
|
+
</span>
|
|
207
|
+
</div>
|
|
208
|
+
<SulaTable
|
|
209
|
+
ref={this.sulaTableRef}
|
|
210
|
+
style={style}
|
|
211
|
+
columns={showCol}
|
|
212
|
+
components={{
|
|
213
|
+
header: {
|
|
214
|
+
cell: this.ResizeableTitle,
|
|
215
|
+
},
|
|
216
|
+
}}
|
|
217
|
+
{
|
|
218
|
+
...otherTableInfo
|
|
219
|
+
}
|
|
220
|
+
/>
|
|
221
|
+
</div >
|
|
222
|
+
)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Tooltip,
|
|
4
|
+
} from 'antd';
|
|
5
|
+
/**
|
|
6
|
+
* 非空数组
|
|
7
|
+
* @param arr 要判断的数据
|
|
8
|
+
* @returns boolean
|
|
9
|
+
*/
|
|
10
|
+
export const noEmptyArray = (arr: any[]) =>
|
|
11
|
+
Array.isArray(arr) && arr.length > 0;
|
|
12
|
+
|
|
13
|
+
//设置queryTable默认列宽
|
|
14
|
+
export const getItemDefaultWidth = (item: any) => {
|
|
15
|
+
let defaultWidth = 200;
|
|
16
|
+
let lowerCaseKey = (item.key || item.dataIndex).toLowerCase();
|
|
17
|
+
switch (true) {
|
|
18
|
+
case item?.title === '操作' || lowerCaseKey === 'operate':
|
|
19
|
+
defaultWidth = 60;
|
|
20
|
+
break;
|
|
21
|
+
case lowerCaseKey.indexOf('number') > -1:
|
|
22
|
+
case lowerCaseKey.indexOf('quantity') > -1:
|
|
23
|
+
case lowerCaseKey.indexOf('amount') > -1:
|
|
24
|
+
defaultWidth = 90;
|
|
25
|
+
break;
|
|
26
|
+
case (lowerCaseKey.indexOf('no') > -1):
|
|
27
|
+
defaultWidth = 200;
|
|
28
|
+
break;
|
|
29
|
+
case lowerCaseKey.indexOf('code') > -1:
|
|
30
|
+
defaultWidth = 170;
|
|
31
|
+
break;
|
|
32
|
+
case lowerCaseKey.indexOf('time') > -1:
|
|
33
|
+
defaultWidth = 130;
|
|
34
|
+
break;
|
|
35
|
+
case lowerCaseKey.indexOf('status') > -1:
|
|
36
|
+
defaultWidth = 100;
|
|
37
|
+
break;
|
|
38
|
+
case lowerCaseKey.indexOf('user') > -1:
|
|
39
|
+
defaultWidth = 130;
|
|
40
|
+
break;
|
|
41
|
+
default:
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
return defaultWidth;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// 带有toptile 清提示 ...
|
|
48
|
+
export const handleTextOverflow = (
|
|
49
|
+
text: string | undefined,
|
|
50
|
+
width: number = 130,
|
|
51
|
+
) => {
|
|
52
|
+
return (
|
|
53
|
+
<Tooltip title={text || '- -'}>
|
|
54
|
+
<span
|
|
55
|
+
style={{
|
|
56
|
+
width: width ? width + 'px' : '130px',
|
|
57
|
+
display: 'inline-block',
|
|
58
|
+
textOverflow: 'ellipsis',
|
|
59
|
+
overflow: 'hidden',
|
|
60
|
+
whiteSpace: 'nowrap',
|
|
61
|
+
position: 'relative',
|
|
62
|
+
top: '5px',
|
|
63
|
+
}}
|
|
64
|
+
>
|
|
65
|
+
{text || '- -'}
|
|
66
|
+
</span>
|
|
67
|
+
</Tooltip>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
@@ -72,10 +72,10 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
72
72
|
let searchParams = {};
|
|
73
73
|
if (typeof selectParamsKey === 'string') {
|
|
74
74
|
let selectParamsInitValue = initVal
|
|
75
|
-
if(labelInValue) {
|
|
76
|
-
selectParamsInitValue = Array.isArray(initVal)? initVal.map((i: any) => i.value || i.key).join(','): initVal
|
|
75
|
+
if (labelInValue) {
|
|
76
|
+
selectParamsInitValue = Array.isArray(initVal) ? initVal.map((i: any) => i.value || i.key).join(',') : initVal
|
|
77
77
|
} else {
|
|
78
|
-
selectParamsInitValue = Array.isArray(initVal)? initVal.join(','): initVal
|
|
78
|
+
selectParamsInitValue = Array.isArray(initVal) ? initVal.join(',') : initVal
|
|
79
79
|
}
|
|
80
80
|
searchParams = v ? { [selectParamsInitKey]: selectParamsInitValue } : { [selectParamsKey]: searchValue }
|
|
81
81
|
}
|
|
@@ -120,6 +120,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
120
120
|
setItems([]);
|
|
121
121
|
setItemsTotal(0);
|
|
122
122
|
},
|
|
123
|
+
getTableFormRef: () => form,
|
|
123
124
|
}))
|
|
124
125
|
|
|
125
126
|
// 获取数据源 (type: 1下拉框 2弹框 不传值默认为下拉框)
|
|
@@ -593,11 +594,19 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
593
594
|
|
|
594
595
|
const formItem = (list) => {
|
|
595
596
|
if (isModalVisible && list?.length) {
|
|
597
|
+
const setDisabled = (name: any) => {
|
|
598
|
+
const { fixedparamsDisabled = false, fixedparameter = [] }: any = requestConfig;
|
|
599
|
+
if (fixedparamsDisabled && fixedparameter.find((item: any) => item === name)) {
|
|
600
|
+
return true
|
|
601
|
+
} else {
|
|
602
|
+
return false
|
|
603
|
+
}
|
|
604
|
+
};
|
|
596
605
|
return list.map((i: any) => {
|
|
597
606
|
if (i?.type === 'select' || i?.field?.type === 'select') {
|
|
598
607
|
return (
|
|
599
608
|
<Form.Item name={i.name} label={i.label} key={i.name}>
|
|
600
|
-
<Select style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props}>
|
|
609
|
+
<Select style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props} disabled={setDisabled(i.name)}>
|
|
601
610
|
{i?.initialSource?.length && i?.initialSource.map((m: any) => (
|
|
602
611
|
<Option value={m.value} key={m.value}>{m.text}</Option>
|
|
603
612
|
))}
|
|
@@ -609,7 +618,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
609
618
|
if (i?.type === 'treeSelect' || i?.field?.type === 'treeSelect') {
|
|
610
619
|
return (
|
|
611
620
|
<Form.Item name={i.name} label={i.label} key={i.name}>
|
|
612
|
-
<TreeSelect style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props}></TreeSelect>
|
|
621
|
+
<TreeSelect style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props} disabled={setDisabled(i.name)}></TreeSelect>
|
|
613
622
|
</Form.Item>
|
|
614
623
|
)
|
|
615
624
|
}
|
|
@@ -618,7 +627,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
618
627
|
return (
|
|
619
628
|
<div>
|
|
620
629
|
<Form.Item name={i.name} label={i.label} key={i.name}>
|
|
621
|
-
<BusinessSearchSelect {...i.field.props} />
|
|
630
|
+
<BusinessSearchSelect {...i.field.props} disabled={setDisabled(i.name)} />
|
|
622
631
|
</Form.Item>
|
|
623
632
|
</div>
|
|
624
633
|
)
|
|
@@ -641,7 +650,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
641
650
|
// 默认type是input
|
|
642
651
|
return (
|
|
643
652
|
<Form.Item name={i.name} label={i.label} key={i.name}>
|
|
644
|
-
<Input style={{ width: '100%' }} placeholder='请输入' allowClear maxLength={100} {...i?.field?.props} />
|
|
653
|
+
<Input style={{ width: '100%' }} placeholder='请输入' allowClear maxLength={100} {...i?.field?.props} disabled={setDisabled(i.name)} />
|
|
645
654
|
</Form.Item>
|
|
646
655
|
)
|
|
647
656
|
})
|
|
@@ -679,57 +688,57 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
679
688
|
showModal()
|
|
680
689
|
}}>{fieldComponent}</div>) :
|
|
681
690
|
(<div className="search_select_show" id={`search_select_div_${uniqueValue}`}>
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
691
|
+
<Select
|
|
692
|
+
virtual
|
|
693
|
+
labelInValue={labelInValue}
|
|
694
|
+
value={value}
|
|
695
|
+
onChange={onChange}
|
|
696
|
+
disabled={props.disabled}
|
|
697
|
+
dropdownRender={menu => (
|
|
698
|
+
<>
|
|
699
|
+
<Input
|
|
700
|
+
value={searchValue}
|
|
701
|
+
style={{ width: '98%', marginLeft: '1%' }}
|
|
702
|
+
placeholder="请输入"
|
|
703
|
+
onChange={e => onSearchChange(e)}
|
|
704
|
+
onBlur={onSearchBlur}
|
|
705
|
+
onKeyDown={(e) => {
|
|
706
|
+
// 阻止多选的冒泡
|
|
707
|
+
e.stopPropagation()
|
|
708
|
+
}}
|
|
709
|
+
/>
|
|
710
|
+
<Divider style={{ margin: '8px 0' }} />
|
|
711
|
+
{menu}
|
|
712
|
+
</>
|
|
713
|
+
)}
|
|
714
|
+
notFoundContent={
|
|
715
|
+
fetching ? <Spin size="small" /> :
|
|
716
|
+
<div style={{ textAlign: 'center' }}>
|
|
717
|
+
<div style={{ marginBottom: 16 }}>
|
|
718
|
+
<CopyOutlined style={{ fontSize: '50px' }} />
|
|
719
|
+
</div>
|
|
720
|
+
<div>无匹配结果,请更换其他内容再试</div>
|
|
710
721
|
</div>
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
)}
|
|
732
|
-
</div>)}
|
|
722
|
+
}
|
|
723
|
+
onPopupScroll={SelectScroll}
|
|
724
|
+
style={{ width: needModalTable ? 'calc(100% - 30px)' : 'calc(100%)' }}
|
|
725
|
+
placeholder="请选择"
|
|
726
|
+
maxTagPlaceholder={maxTagPlaceholder}
|
|
727
|
+
{...currentSelectProps}
|
|
728
|
+
getPopupContainer={() => (getPopupContainer && getPopupContainer()) || document.getElementById(`search_select_div_${uniqueValue}`)}
|
|
729
|
+
>
|
|
730
|
+
{items.map(item => (
|
|
731
|
+
<Option key={item.value} label={item.text}>
|
|
732
|
+
{LightHeightOption({ text: `${item.textShowKey} ${Array.isArray(item.textShowText) && item.textShowText.join(' ') || item.textShowText}`, filterTxt: searchValue })}
|
|
733
|
+
</Option>
|
|
734
|
+
))}
|
|
735
|
+
</Select>
|
|
736
|
+
{needModalTable && (
|
|
737
|
+
<Button style={{ width: '30px', padding: '2px', height: 'auto' }} onClick={showModal} type="primary">
|
|
738
|
+
<SearchOutlined />
|
|
739
|
+
</Button>
|
|
740
|
+
)}
|
|
741
|
+
</div>)}
|
|
733
742
|
{needModalTable && isModalVisible && (
|
|
734
743
|
<Modal
|
|
735
744
|
width='80%'
|