@bit-sun/business-component 2.0.12 → 2.0.13
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/.editorconfig +16 -16
- package/.fatherrc.ts +4 -4
- package/.gitlab-ci.yml +174 -135
- package/.prettierignore +7 -7
- package/.prettierrc +11 -11
- package/.umirc.ts +74 -90
- package/README.md +27 -27
- package/dist/components/Business/SearchSelect/index.d.ts +1 -1
- package/dist/components/Functional/SearchSelect/index.d.ts +1 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.esm.js +6794 -7350
- package/dist/index.js +6793 -7348
- package/docs/index.md +21 -21
- package/package.json +51 -60
- package/src/components/Business/AddSelectBusiness/index.md +41 -41
- package/src/components/Business/AddSelectBusiness/index.tsx +288 -300
- package/src/components/Business/CommodityEntry/index.md +69 -69
- package/src/components/Business/CommodityEntry/index.tsx +78 -78
- package/src/components/Business/SearchSelect/BusinessUtils.ts +1445 -1445
- package/src/components/Business/SearchSelect/common.ts +53 -53
- package/src/components/Business/SearchSelect/index.md +1137 -1136
- package/src/components/Business/SearchSelect/index.tsx +44 -49
- package/src/components/Business/SearchSelect/utils.ts +99 -99
- package/src/components/Business/TreeSearchSelect/index.md +126 -126
- package/src/components/Business/TreeSearchSelect/index.tsx +34 -34
- package/src/components/Business/TreeSearchSelect/utils.ts +60 -60
- package/src/components/Functional/AddSelect/index.less +367 -352
- package/src/components/Functional/AddSelect/index.md +120 -120
- package/src/components/Functional/AddSelect/index.tsx +952 -896
- package/src/components/Functional/BillEntry/index.less +371 -371
- package/src/components/Functional/BillEntry/index.md +37 -37
- package/src/components/Functional/BillEntry/index.tsx +547 -561
- package/src/components/Functional/DataImport/index.less +63 -63
- package/src/components/Functional/DataImport/index.md +44 -44
- package/src/components/Functional/DataImport/index.tsx +689 -689
- package/src/components/Functional/DataValidation/index.less +63 -63
- package/src/components/Functional/DataValidation/index.md +38 -38
- package/src/components/Functional/DataValidation/index.tsx +680 -680
- package/src/components/Functional/QueryMutipleInput/index.less +37 -37
- package/src/components/Functional/QueryMutipleInput/index.md +33 -33
- package/src/components/Functional/QueryMutipleInput/index.tsx +128 -128
- package/src/components/Functional/SearchSelect/index.less +115 -115
- package/src/components/Functional/SearchSelect/index.md +141 -141
- package/src/components/Functional/SearchSelect/index.tsx +732 -791
- package/src/components/Functional/TreeSearchSelect/index.md +47 -47
- package/src/components/Functional/TreeSearchSelect/index.tsx +149 -149
- package/src/index.ts +22 -22
- package/src/utils/CheckOneUser/index.md +39 -39
- package/src/utils/CheckOneUser/index.ts +51 -51
- package/src/utils/requestUtils.ts +32 -32
- package/tsconfig.json +29 -29
- package/typings.d.ts +2 -2
- package/Dockerfile +0 -11
- package/dist/app.d.ts +0 -0
- package/dist/components/sulaQueryTable/BsSulaQueryTable.d.ts +0 -2
- package/dist/components/sulaQueryTable/draggableTable.d.ts +0 -22
- package/dist/components/sulaQueryTable/statusComponent.d.ts +0 -2
- package/dist/components/sulaQueryTable/utils.d.ts +0 -41
- package/nginx.conf +0 -43
- package/src/app.tsx +0 -3
- package/src/components/sulaQueryTable/BsSulaQueryTable.tsx +0 -368
- package/src/components/sulaQueryTable/draggableTable.tsx +0 -111
- package/src/components/sulaQueryTable/index.md +0 -271
- package/src/components/sulaQueryTable/status-component.less +0 -8
- package/src/components/sulaQueryTable/statusComponent.tsx +0 -42
- package/src/components/sulaQueryTable/utils.less +0 -48
- package/src/components/sulaQueryTable/utils.tsx +0 -336
- package/src/global.less +0 -97
|
@@ -1,368 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef } from 'react';
|
|
2
|
-
import { useLocation } from 'umi';
|
|
3
|
-
import { QueryTable } from 'bssula';
|
|
4
|
-
import { handleTextDouble, handleTextLineFeed, handleTextOverflow, handleTooltip, handleTooltipHours, tableColumnsImage, userColumns } from './utils';
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
CompressOutlined,
|
|
8
|
-
ExpandOutlined,
|
|
9
|
-
SettingOutlined,
|
|
10
|
-
} from '@ant-design/icons';
|
|
11
|
-
import { Dropdown, Menu, Tooltip } from 'antd';
|
|
12
|
-
import SortableTable from './draggableTable';
|
|
13
|
-
import { Resizable } from 'react-resizable';
|
|
14
|
-
|
|
15
|
-
const ResizeableTitle = props => {
|
|
16
|
-
const { onResize, width, ...restProps } = props;
|
|
17
|
-
|
|
18
|
-
if (!width) {
|
|
19
|
-
return <th {...restProps} />;
|
|
20
|
-
}
|
|
21
|
-
return (
|
|
22
|
-
<Resizable
|
|
23
|
-
width={width}
|
|
24
|
-
height={0}
|
|
25
|
-
onResize={onResize}
|
|
26
|
-
draggableOpts={{ enableUserSelectHack: false }}
|
|
27
|
-
>
|
|
28
|
-
<th {...restProps} />
|
|
29
|
-
</Resizable>
|
|
30
|
-
);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const BaseQueryTable = (props: any) => {
|
|
34
|
-
const refs = useRef(null);
|
|
35
|
-
const [pagePath, setPagePath] = useState('');
|
|
36
|
-
const { pathname } = useLocation();
|
|
37
|
-
const [id]: any = useState(Number(Math.random().toString().substr(2, 0) + Date.now()).toString(36))
|
|
38
|
-
const [isFullScreen, setIsFnllScreen]: any = useState(false)
|
|
39
|
-
// @ts-nocheck
|
|
40
|
-
const [value, setValue]: any = useState(props);
|
|
41
|
-
const [showColumn, setShowColumns] = useState([]);
|
|
42
|
-
|
|
43
|
-
// 获取 table columns中所有的 key 防止有的地方是 dataindex
|
|
44
|
-
const [checkedList, setCheckedList] = useState(
|
|
45
|
-
value.columns.map((d: any) => d.key || d.dataIndex),
|
|
46
|
-
);
|
|
47
|
-
const { isPage = true, pagination } = props;
|
|
48
|
-
|
|
49
|
-
const [height, setHeight]: any = useState('100vh')
|
|
50
|
-
|
|
51
|
-
// 获取table高度
|
|
52
|
-
const getTableHeight = () => {
|
|
53
|
-
const isFullScreen: any =
|
|
54
|
-
document.fullScreen || document.webkitIsFullScreen || document.mozFullScreen;
|
|
55
|
-
const h =
|
|
56
|
-
document.body.clientHeight -
|
|
57
|
-
(document.querySelector(".ant-form ant-form-horizontal")?.clientHeight || 0) -
|
|
58
|
-
(isFullScreen ? 0 : (document.querySelector(".ant-pro-page-container-warp")?.clientHeight || 0))
|
|
59
|
-
- 321 + (isFullScreen ? 150 : 0) +
|
|
60
|
-
"px";
|
|
61
|
-
setHeight(h)
|
|
62
|
-
setValue({ ...value })
|
|
63
|
-
|
|
64
|
-
};
|
|
65
|
-
// 处理按钮权限
|
|
66
|
-
useEffect(() => {
|
|
67
|
-
document.querySelector('.ant-table-wrapper').parentNode.parentNode.style = 'margin:0;background-color:#f3f3f3;padding:10px'
|
|
68
|
-
getTableHeight()
|
|
69
|
-
window.onresize = () => {
|
|
70
|
-
getTableHeight();
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
// @ts-ignore
|
|
74
|
-
setPagePath(pathname); // 做处理,记录当前页面渲染的初始pathname,用于进行判断当前列表页面数据是否需要重新渲染
|
|
75
|
-
if (props.notPermissionButtonNow) return;
|
|
76
|
-
|
|
77
|
-
const resourceCodeArray = {};
|
|
78
|
-
if (props.actionsRender && props.actionsRender.length) {
|
|
79
|
-
props.actionsRender.forEach((item: any) => {
|
|
80
|
-
if (item.code) {
|
|
81
|
-
if (resourceCodeArray[item.code]) {
|
|
82
|
-
resourceCodeArray[item.code + 1] = item;
|
|
83
|
-
} else {
|
|
84
|
-
resourceCodeArray[item.code] = item;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (props.columns && props.columns.length) {
|
|
91
|
-
props.columns.forEach((item: any) => {
|
|
92
|
-
if (item.isPermissionColumn && item.render && item.render.length) {
|
|
93
|
-
item.render.forEach((inneritem: any) => {
|
|
94
|
-
if (inneritem.code) {
|
|
95
|
-
if (resourceCodeArray[inneritem.code]) {
|
|
96
|
-
resourceCodeArray[inneritem.code + 1] = inneritem;
|
|
97
|
-
} else {
|
|
98
|
-
resourceCodeArray[inneritem.code] = inneritem;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
setCommonRenderFn(props.columns);
|
|
106
|
-
const authButton = localStorage.getItem('buttonAuth_FMS')
|
|
107
|
-
? JSON.parse(localStorage.getItem('buttonAuth_FMS') as string)
|
|
108
|
-
: [];
|
|
109
|
-
Object.keys(resourceCodeArray).forEach((item: any) => {
|
|
110
|
-
if (!authButton.filter((itemInner: any) => item === itemInner.code).length) {
|
|
111
|
-
resourceCodeArray[item].visible = false;
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}, []);
|
|
115
|
-
|
|
116
|
-
useEffect(() => {
|
|
117
|
-
const { columns } = value;
|
|
118
|
-
let showColumns = columns.filter(column => checkedList.indexOf(column.key || column.dataIndex) > -1);
|
|
119
|
-
showColumns.forEach((item, index) => {
|
|
120
|
-
item.width = item.width || 200;
|
|
121
|
-
item.onHeaderCell = (column) => ({
|
|
122
|
-
width: column.width,
|
|
123
|
-
onResize: handleResize(index),
|
|
124
|
-
})
|
|
125
|
-
})
|
|
126
|
-
setShowColumns([...showColumns])
|
|
127
|
-
}, [value, checkedList])
|
|
128
|
-
|
|
129
|
-
const setCommonRenderFn = (columns: any[]) => {
|
|
130
|
-
columns.forEach(column => {
|
|
131
|
-
if (column.showDetailUserInfo) {
|
|
132
|
-
column.render = ({ text }: any) => userColumns({ name: text })
|
|
133
|
-
}
|
|
134
|
-
})
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// 处理 table 基本参数
|
|
138
|
-
const setTableProps = () => {
|
|
139
|
-
let tableProps = value.tableProps || {};
|
|
140
|
-
tableProps = {
|
|
141
|
-
...tableProps,
|
|
142
|
-
size: value.size || 'middle',
|
|
143
|
-
defaultPageSize: 20,
|
|
144
|
-
pageSize: 20,
|
|
145
|
-
initialPaging: {
|
|
146
|
-
pagination: pagination
|
|
147
|
-
? false
|
|
148
|
-
: {
|
|
149
|
-
defaultPageSize: 20,
|
|
150
|
-
pageSize: 20,
|
|
151
|
-
showTotal: (total: any) => `共 ${total} 条`,
|
|
152
|
-
showQuickJumper: true,
|
|
153
|
-
hideOnSinglePage: value.hideOnSinglePage || false,
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
initialSelectedRowKeys: value.initialSelectedRowKeys || [],
|
|
157
|
-
expandable: value.expandable,
|
|
158
|
-
scroll: { x: props.overScrollX || 'max-content', y: height },
|
|
159
|
-
bordered: value.bordered || false,
|
|
160
|
-
sticky: true,
|
|
161
|
-
rowClassName: (record: object | null | undefined, index: number) => index % 2 === 0 ? 'table_base' : 'table_odd',
|
|
162
|
-
...value.tableProps,
|
|
163
|
-
components:{
|
|
164
|
-
header: {
|
|
165
|
-
cell: ResizeableTitle,
|
|
166
|
-
},
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
// @ts-ignore
|
|
172
|
-
if (tableProps?.initialPaging?.pagination) {
|
|
173
|
-
// @ts-ignore
|
|
174
|
-
tableProps.initialPaging.pagination.showSizeChanger = true;
|
|
175
|
-
}
|
|
176
|
-
return tableProps;
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
const menu = (
|
|
181
|
-
<Menu style={{ padding: '15px' }}>
|
|
182
|
-
<SortableTable
|
|
183
|
-
setCheckedList={setCheckedList}
|
|
184
|
-
value={value}
|
|
185
|
-
setValue={setValue}
|
|
186
|
-
checkedList={checkedList}
|
|
187
|
-
datasource={value?.columns || []}
|
|
188
|
-
/>
|
|
189
|
-
</Menu>
|
|
190
|
-
)
|
|
191
|
-
|
|
192
|
-
const ShowFullScreen = () => {
|
|
193
|
-
const isFullScreen: any =
|
|
194
|
-
document.fullScreen || document.webkitIsFullScreen || document.mozFullScreen;
|
|
195
|
-
let contentEle: any = document.querySelector(`#${id}`);
|
|
196
|
-
|
|
197
|
-
if (contentEle && !isFullScreen) {
|
|
198
|
-
let fullScreenEle =
|
|
199
|
-
contentEle.requestFullscreen ||
|
|
200
|
-
contentEle.mozRequestFullScreen ||
|
|
201
|
-
contentEle.webkitRequestFullScreen ||
|
|
202
|
-
contentEle.msRequestFullscreen;
|
|
203
|
-
if (fullScreenEle) {
|
|
204
|
-
fullScreenEle.call(contentEle);
|
|
205
|
-
setIsFnllScreen(true)
|
|
206
|
-
getTableHeight(true)
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
if (document && isFullScreen) {
|
|
211
|
-
let exitFullScreen =
|
|
212
|
-
document.exitFullscreen ||
|
|
213
|
-
document.mozCancelFullScreen ||
|
|
214
|
-
document.webkitCancelFullScreen ||
|
|
215
|
-
document.msExitFullscreen;
|
|
216
|
-
if (exitFullScreen) {
|
|
217
|
-
exitFullScreen.call(document);
|
|
218
|
-
setIsFnllScreen(false)
|
|
219
|
-
getTableHeight()
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
const handleTimeValue = () => {
|
|
226
|
-
let actionsRender = value.actionsRender || [];
|
|
227
|
-
actionsRender = [
|
|
228
|
-
...actionsRender,
|
|
229
|
-
{
|
|
230
|
-
type: 'text',
|
|
231
|
-
props: {
|
|
232
|
-
children: (
|
|
233
|
-
<>
|
|
234
|
-
<Dropdown overlay={menu} trigger={['click']}>
|
|
235
|
-
<Tooltip title="列设置">
|
|
236
|
-
<a className="ant-dropdown-link" onClick={(e) => e.preventDefault()}>
|
|
237
|
-
<SettingOutlined />
|
|
238
|
-
</a>
|
|
239
|
-
</Tooltip>
|
|
240
|
-
</Dropdown>
|
|
241
|
-
</>
|
|
242
|
-
),
|
|
243
|
-
},
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
type: 'text',
|
|
247
|
-
props: {
|
|
248
|
-
children: (
|
|
249
|
-
<a>
|
|
250
|
-
{
|
|
251
|
-
isFullScreen ? <Tooltip title='取消全屏'>
|
|
252
|
-
<CompressOutlined onClick={() => {
|
|
253
|
-
ShowFullScreen()
|
|
254
|
-
}} />
|
|
255
|
-
</Tooltip>
|
|
256
|
-
:
|
|
257
|
-
<Tooltip title='全屏'>
|
|
258
|
-
<ExpandOutlined onClick={() => {
|
|
259
|
-
ShowFullScreen()
|
|
260
|
-
}} />
|
|
261
|
-
</Tooltip>
|
|
262
|
-
}</a>
|
|
263
|
-
),
|
|
264
|
-
},
|
|
265
|
-
},
|
|
266
|
-
];
|
|
267
|
-
// 防止 多选框 过宽
|
|
268
|
-
if (value && value?.columns?.length > 0) {
|
|
269
|
-
if (value.rowSelection) {
|
|
270
|
-
value.rowSelection.columnWidth = 50;
|
|
271
|
-
}
|
|
272
|
-
value.columns.forEach((d: any) => {
|
|
273
|
-
// 处理要显示 时分秒的时间
|
|
274
|
-
if (d.timeRenderHour) {
|
|
275
|
-
d.render = ({ text }: any) => handleTooltipHours(text, d.timeRenderHour);
|
|
276
|
-
}
|
|
277
|
-
// 处理不显示 时分秒的时间
|
|
278
|
-
if (d.timeRender) {
|
|
279
|
-
d.render = ({ text }: any) => handleTooltip(text, d.timeRender);
|
|
280
|
-
}
|
|
281
|
-
// 处理文字太长
|
|
282
|
-
if (d.textOverflow) {
|
|
283
|
-
d.render = ({ text }: any) => handleTextOverflow(text);
|
|
284
|
-
}
|
|
285
|
-
if (d.images) {
|
|
286
|
-
d.render = ({ text }: any) => tableColumnsImage(text);
|
|
287
|
-
}
|
|
288
|
-
if (d.double) {
|
|
289
|
-
d.render = ({ record }: any) => handleTextDouble(record[d.textOne], record[d.textTwo]);
|
|
290
|
-
}
|
|
291
|
-
if (d.lineFeed) {
|
|
292
|
-
d.render = ({ text }: any) => handleTextLineFeed(text);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
// 处理序号
|
|
296
|
-
if (d.indexNumber) {
|
|
297
|
-
d.render = ({ index }: any) => index + 1;
|
|
298
|
-
}
|
|
299
|
-
// 没有值默认显示 - -
|
|
300
|
-
if (!d.render) {
|
|
301
|
-
d.render = ({ text }: any) => text || '- -';
|
|
302
|
-
}
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
return {
|
|
306
|
-
...value,
|
|
307
|
-
actionsRender,
|
|
308
|
-
};
|
|
309
|
-
};
|
|
310
|
-
|
|
311
|
-
// const setShowColumns = () => {
|
|
312
|
-
// const { columns } = value;
|
|
313
|
-
// return columns.filter(column => checkedList.indexOf(column.key || column.dataIndex) > -1);
|
|
314
|
-
// }
|
|
315
|
-
|
|
316
|
-
const handleResize = index => (e, { size }) => {
|
|
317
|
-
setShowColumns((columns: any) => {
|
|
318
|
-
let newColumns = [...columns];
|
|
319
|
-
newColumns[index] = {
|
|
320
|
-
...newColumns[index],
|
|
321
|
-
width: size.width,
|
|
322
|
-
};
|
|
323
|
-
return [...newColumns]
|
|
324
|
-
});
|
|
325
|
-
};
|
|
326
|
-
|
|
327
|
-
const config = {
|
|
328
|
-
visibleFieldsCount: 3,
|
|
329
|
-
itemLayout: {
|
|
330
|
-
span: 8, // 栅格占位格数
|
|
331
|
-
labelCol: {
|
|
332
|
-
// label标签布局;可设置 span、offset
|
|
333
|
-
span: 8,
|
|
334
|
-
},
|
|
335
|
-
wrapperCol: {
|
|
336
|
-
// value布局, 方式同labelCol(horizontal状态下配置)
|
|
337
|
-
span: 16,
|
|
338
|
-
},
|
|
339
|
-
},
|
|
340
|
-
rowSelection: false, // 默认无多选
|
|
341
|
-
...handleTimeValue(),
|
|
342
|
-
tableProps: setTableProps(),
|
|
343
|
-
columns: showColumn,
|
|
344
|
-
ref: props.forwardedRef || refs,
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
useEffect(() => {
|
|
348
|
-
if (!localStorage.getItem('isTabChange')) {
|
|
349
|
-
if (pagePath === pathname) {
|
|
350
|
-
// @ts-ignore
|
|
351
|
-
config.ref?.current?.tableRef?.current?.refreshTable();
|
|
352
|
-
}
|
|
353
|
-
} else {
|
|
354
|
-
setTimeout(() => {
|
|
355
|
-
// 处理页面刷新两面
|
|
356
|
-
localStorage.removeItem('isTabChange');
|
|
357
|
-
}, 0);
|
|
358
|
-
}
|
|
359
|
-
}, [pathname]);
|
|
360
|
-
|
|
361
|
-
return (
|
|
362
|
-
<div id={id} style={{ background: '#fff', overflowY: "auto" }}>
|
|
363
|
-
<QueryTable {...config} />
|
|
364
|
-
</div>
|
|
365
|
-
);
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
export default BaseQueryTable;
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Table, message } from 'antd';
|
|
3
|
-
import { SortableContainer, SortableElement, SortableHandle } from 'react-sortable-hoc';
|
|
4
|
-
import { MenuOutlined } from '@ant-design/icons';
|
|
5
|
-
import { arrayMoveImmutable } from 'array-move';
|
|
6
|
-
|
|
7
|
-
const DragHandle = SortableHandle(() => <MenuOutlined style={{ cursor: 'grab', color: '#999' }} />);
|
|
8
|
-
|
|
9
|
-
const columns = [
|
|
10
|
-
{
|
|
11
|
-
title: '列名称',
|
|
12
|
-
dataIndex: 'title',
|
|
13
|
-
className: 'drag-visible',
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
title: 'Sort',
|
|
17
|
-
dataIndex: 'sort',
|
|
18
|
-
width: 30,
|
|
19
|
-
className: 'drag-visible',
|
|
20
|
-
render: () => <DragHandle />,
|
|
21
|
-
},
|
|
22
|
-
];
|
|
23
|
-
|
|
24
|
-
const SortableItem = SortableElement((props:any) => <tr {...props} />);
|
|
25
|
-
const SortableBody = SortableContainer((props:any) => <tbody {...props} />);
|
|
26
|
-
|
|
27
|
-
class SortableTable extends React.Component {
|
|
28
|
-
state = {
|
|
29
|
-
dataSource: [],
|
|
30
|
-
columns: [],
|
|
31
|
-
selectedRowKeys: [],
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
componentDidMount(){
|
|
35
|
-
const { datasource, checkedList }: any = this.props;
|
|
36
|
-
this.setState({
|
|
37
|
-
dataSource: datasource.map(item => ({
|
|
38
|
-
...item,
|
|
39
|
-
key: item.key || item.dataIndex
|
|
40
|
-
})),
|
|
41
|
-
selectedRowKeys: [...checkedList]
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
onSortEnd = ({ oldIndex, newIndex }) => {
|
|
46
|
-
const { dataSource } = this.state;
|
|
47
|
-
const { value, setValue } = this.props;
|
|
48
|
-
if (dataSource[oldIndex]['fixed']) {
|
|
49
|
-
message.warning('固定列不可移动');
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
if (oldIndex !== newIndex) {
|
|
53
|
-
const newData = arrayMoveImmutable([].concat(dataSource), oldIndex, newIndex).filter(
|
|
54
|
-
el => !!el,
|
|
55
|
-
);
|
|
56
|
-
this.setState({ dataSource: newData });
|
|
57
|
-
setValue({
|
|
58
|
-
...value,
|
|
59
|
-
columns: [...newData]
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
DraggableContainer = props => (
|
|
65
|
-
<SortableBody
|
|
66
|
-
useDragHandle
|
|
67
|
-
disableAutoscroll
|
|
68
|
-
helperClass="row-dragging"
|
|
69
|
-
onSortEnd={this.onSortEnd}
|
|
70
|
-
{...props}
|
|
71
|
-
/>
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
DraggableBodyRow = ({ className, style, ...restProps }) => {
|
|
75
|
-
const { dataSource } = this.state;
|
|
76
|
-
// function findIndex base on Table rowKey props and should always be a right array index
|
|
77
|
-
const index = dataSource.findIndex(x => x.key === restProps['data-row-key']);
|
|
78
|
-
return <SortableItem index={index} {...restProps} />;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
onSelectChange = selectedRowKeys => {
|
|
82
|
-
const { setCheckedList } = this.props;
|
|
83
|
-
this.setState({ selectedRowKeys });
|
|
84
|
-
setCheckedList(selectedRowKeys);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
render() {
|
|
88
|
-
const { dataSource, selectedRowKeys } = this.state;
|
|
89
|
-
const rowSelection = {
|
|
90
|
-
selectedRowKeys,
|
|
91
|
-
onChange: this.onSelectChange,
|
|
92
|
-
};
|
|
93
|
-
return (
|
|
94
|
-
<Table
|
|
95
|
-
pagination={false}
|
|
96
|
-
dataSource={dataSource}
|
|
97
|
-
columns={columns}
|
|
98
|
-
rowKey='key'
|
|
99
|
-
rowSelection={rowSelection}
|
|
100
|
-
components={{
|
|
101
|
-
body: {
|
|
102
|
-
wrapper: this.DraggableContainer,
|
|
103
|
-
row: this.DraggableBodyRow,
|
|
104
|
-
},
|
|
105
|
-
}}
|
|
106
|
-
/>
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export default SortableTable;
|