@bit-sun/business-component 2.0.31 → 2.0.33

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.
Files changed (39) hide show
  1. package/dist/components/Business/BsSulaQueryTable/index.d.ts +2 -0
  2. package/dist/components/Business/BsSulaQueryTable/setting.d.ts +59 -0
  3. package/dist/components/Business/BsSulaQueryTable/utils.d.ts +98 -0
  4. package/dist/components/Business/CommonAlert/index.d.ts +3 -0
  5. package/dist/components/Business/DetailPageWrapper/index.d.ts +9 -0
  6. package/dist/components/Business/DetailPageWrapper/utils.d.ts +9 -0
  7. package/dist/components/Business/HomePageWrapper/index.d.ts +3 -0
  8. package/dist/components/Business/columnSettingTable/index.d.ts +1 -0
  9. package/dist/components/Business/columnSettingTable/sulaSettingTable.d.ts +1 -0
  10. package/dist/index.esm.js +205 -13
  11. package/dist/index.js +205 -13
  12. package/package.json +5 -2
  13. package/src/assets/btn-delete.svg +30 -0
  14. package/src/assets/btn-edit.svg +20 -0
  15. package/src/assets/btn-more.svg +18 -0
  16. package/src/assets/btn-submit.svg +20 -0
  17. package/src/assets/fixed-left-active.svg +12 -0
  18. package/src/assets/fixed-left.svg +16 -0
  19. package/src/assets/fixed-right-active.svg +12 -0
  20. package/src/assets/fixed-right.svg +16 -0
  21. package/src/assets/icon-quanping.svg +16 -0
  22. package/src/assets/scanning.svg +25 -0
  23. package/src/components/Business/BsSulaQueryTable/index.less +220 -0
  24. package/src/components/Business/BsSulaQueryTable/index.tsx +534 -0
  25. package/src/components/Business/BsSulaQueryTable/setting.tsx +817 -0
  26. package/src/components/Business/BsSulaQueryTable/utils.less +65 -0
  27. package/src/components/Business/BsSulaQueryTable/utils.tsx +690 -0
  28. package/src/components/Business/CommonAlert/index.less +0 -0
  29. package/src/components/Business/CommonAlert/index.tsx +23 -0
  30. package/src/components/Business/DetailPageWrapper/index.less +80 -0
  31. package/src/components/Business/DetailPageWrapper/index.tsx +325 -0
  32. package/src/components/Business/DetailPageWrapper/utils.tsx +111 -0
  33. package/src/components/Business/HomePageWrapper/index.less +33 -0
  34. package/src/components/Business/HomePageWrapper/index.md +45 -0
  35. package/src/components/Business/HomePageWrapper/index.tsx +150 -0
  36. package/src/components/Business/columnSettingTable/columnSetting.tsx +173 -5
  37. package/src/components/Business/columnSettingTable/index.tsx +9 -0
  38. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +9 -0
  39. package/src/index.ts +3 -0
@@ -0,0 +1,150 @@
1
+ // @ts-nocheck
2
+ import React, { useEffect, useState, useMemo } from 'react';
3
+ import { history } from 'umi';
4
+ import { memoizeOneFormatter, getBreadcrumbNameMap } from '../DetailPageWrapper/utils';
5
+ import pathToRegexp from 'path-to-regexp';
6
+ import { Breadcrumb, Space } from 'antd';
7
+ import './index.less';
8
+ import { useLocation, formatMessage } from 'umi';
9
+ import CommonAlert from '../CommonAlert';
10
+
11
+ export default (props: any) => {
12
+ const { pathname } = useLocation();
13
+ const [id]: any = useState(pathname + 'id');
14
+ const { children, ...restProps} = props;
15
+
16
+ return (
17
+ <div id={id} className={'home_page_wrapper'}>
18
+ <HeaderWrapper
19
+ pathname={pathname}
20
+ {
21
+ ...restProps
22
+ }
23
+ />
24
+ {props.children}
25
+ </div>
26
+ );
27
+ };
28
+
29
+ const HeaderWrapper = React.memo(
30
+ ({
31
+ pathname,
32
+ routes=[],
33
+ itemPath,
34
+ alertProps,
35
+ extra,
36
+ }: { pathname: string, routes: any[], itemPath: string, alertProps: any }) => {
37
+ const basePath = window.top == window ? '' : `/${itemPath}`;
38
+ const menuRoutes =
39
+ window.top == window
40
+ ? routes.find((item) => item.path === '/')?.routes || []
41
+ : JSON.parse(localStorage.getItem('limitedMenuData') || '[]');
42
+
43
+ const breadcrumbNameMap = getBreadcrumbNameMap(
44
+ memoizeOneFormatter(menuRoutes, ''),
45
+ );
46
+
47
+ const matchParamsPath = (pathname: string, breadcrumbNameMap: object) => {
48
+ const pathKey: any = Object.keys(breadcrumbNameMap).find((key) =>
49
+ pathToRegexp(key).test(pathname),
50
+ );
51
+ return breadcrumbNameMap[pathKey];
52
+ };
53
+
54
+ const getPageTitle = (pathname: string) => {
55
+ const currRouterData = matchParamsPath(
56
+ `${basePath}${pathname}`,
57
+ breadcrumbNameMap,
58
+ );
59
+
60
+ if (!currRouterData) {
61
+ return '';
62
+ }
63
+ const pageName = formatMessage({
64
+ id: currRouterData.locale || currRouterData.name,
65
+ defaultMessage: currRouterData.name,
66
+ });
67
+ return `${pageName}`;
68
+ };
69
+
70
+ const pageTitle = useMemo(() => getPageTitle(pathname), [pathname]);
71
+
72
+ useEffect(() => {}, [pathname]);
73
+
74
+ const breadcrumbArr = `${basePath}${pathname}`
75
+ .split('/')
76
+ .slice(1)
77
+ .map((_item, index, arr) =>
78
+ matchParamsPath(
79
+ `/${arr.slice(0, index + 1).join('/')}`,
80
+ breadcrumbNameMap,
81
+ ),
82
+ )
83
+ .filter((item) => item);
84
+
85
+
86
+ return (
87
+ <div>
88
+ <div className={'home_page_head'}>
89
+ <div>
90
+ <div className={'home_page_title'}>{pageTitle}</div>
91
+ <Breadcrumb>
92
+ {breadcrumbArr.map((item) => (
93
+ <Breadcrumb.Item
94
+ key={item.path}
95
+ onClick={() => {
96
+ if (
97
+ item.path &&
98
+ !item.children &&
99
+ !pathToRegexp(item.path).test(`${basePath}${pathname}`)
100
+ ) {
101
+ history.push({
102
+ pathname: item.path.replace(basePath, ''),
103
+ });
104
+ }
105
+ }}
106
+ >
107
+ <span
108
+ style={{
109
+ color: pathToRegexp(item.path).test(
110
+ `${basePath}${pathname}`,
111
+ )
112
+ ? '#000000d9'
113
+ : '',
114
+ }}
115
+ className="bread_name"
116
+ >
117
+ {item.name}
118
+ </span>
119
+ </Breadcrumb.Item>
120
+ ))}
121
+ </Breadcrumb>
122
+ </div>
123
+ {
124
+ extra ?
125
+ <Space>
126
+ {
127
+ extra
128
+ }
129
+ </Space> : ''
130
+ }
131
+ </div>
132
+ {
133
+ alertProps && (
134
+ <CommonAlert
135
+ {
136
+ ...alertProps
137
+ }
138
+ />
139
+ )
140
+ }
141
+ </div>
142
+ );
143
+ },
144
+ (prevProps, nextProps) => {
145
+ // if (prevProps.pathname === nextProps.pathname) {
146
+ // return true;
147
+ // }
148
+ return true;
149
+ },
150
+ );
@@ -11,6 +11,10 @@ import { arrayMoveImmutable } from 'array-move';
11
11
  import shezhi from '../../../assets/icon-shezhi.svg';
12
12
  import close from '../../../assets/close.svg';
13
13
  import drag from '../../../assets/drag.svg';
14
+ import fixedLeft from '../../../assets/fixed-left.svg';
15
+ import fixedLeftActive from '../../../assets/fixed-left-active.svg';
16
+ import fixedRight from '../../../assets/fixed-right.svg';
17
+ import fixedRightActive from '../../../assets/fixed-right-active.svg';
14
18
  import axios from 'axios';
15
19
  // import { request } from 'umi';
16
20
  import './index.less';
@@ -155,6 +159,164 @@ class SortableTable extends React.Component<SortTableProps> {
155
159
  className: 'drag-visible',
156
160
  width: 100,
157
161
  },
162
+ {
163
+ title: '列首',
164
+ dataIndex: 'fixedLeft',
165
+ render: (text, record) => {
166
+ return (
167
+ <span
168
+ onClick={() => {
169
+ const { sortDataSource } = this.state;
170
+ if (record?.fixed !== 'left') {
171
+ let newSortData = sortDataSource.map((item) => {
172
+ if (item.title === record.title) {
173
+ return {
174
+ ...item,
175
+ fixed: 'left',
176
+ };
177
+ }
178
+ return item;
179
+ });
180
+ this.setState({
181
+ sortDataSource: [
182
+ ...newSortData.filter((item) => item.fixed === 'left'),
183
+ ...newSortData.filter((item) => !item.fixed),
184
+ ...newSortData.filter((item) => item.fixed === 'right'),
185
+ ],
186
+ dataSource: [
187
+ ...this.state.dataSource.map((item) => {
188
+ if (item.title === record.title) {
189
+ return {
190
+ ...item,
191
+ fixed: 'left',
192
+ };
193
+ }
194
+ return item;
195
+ }),
196
+ ],
197
+ });
198
+ } else {
199
+ let newSortData = sortDataSource.map((item) => {
200
+ if (item.title === record.title) {
201
+ return {
202
+ ...item,
203
+ fixed: null,
204
+ };
205
+ }
206
+ return item;
207
+ });
208
+ this.setState({
209
+ sortDataSource: [
210
+ ...newSortData.filter((item) => item.fixed === 'left'),
211
+ ...newSortData.filter((item) => !item.fixed),
212
+ ...newSortData.filter((item) => item.fixed === 'right'),
213
+ ],
214
+ dataSource: [
215
+ ...this.state.dataSource.map((item) => {
216
+ if (item.title === record.title) {
217
+ return {
218
+ ...item,
219
+ fixed: null,
220
+ };
221
+ }
222
+ return item;
223
+ }),
224
+ ],
225
+ });
226
+ }
227
+ }}
228
+ >
229
+ <Tooltip
230
+ placement="top"
231
+ title={record?.fixed === 'left' ? '取消固定' : '固定列首'}
232
+ >
233
+ <img
234
+ src={record?.fixed === 'left' ? fixedLeftActive : fixedLeft}
235
+ />
236
+ </Tooltip>
237
+ </span>
238
+ );
239
+ },
240
+ },
241
+ {
242
+ title: '列尾',
243
+ dataIndex: 'fixedRight',
244
+ render: (text, record) => {
245
+ return (
246
+ <span
247
+ onClick={() => {
248
+ const { sortDataSource } = this.state;
249
+ if (record?.fixed !== 'right') {
250
+ let newSortData = sortDataSource.map((item) => {
251
+ if (item.title === record.title) {
252
+ return {
253
+ ...item,
254
+ fixed: 'right',
255
+ };
256
+ }
257
+ return item;
258
+ });
259
+ this.setState({
260
+ sortDataSource: [
261
+ ...newSortData.filter((item) => item.fixed === 'left'),
262
+ ...newSortData.filter((item) => !item.fixed),
263
+ ...newSortData.filter((item) => item.fixed === 'right'),
264
+ ],
265
+ dataSource: [
266
+ ...this.state.dataSource.map((item) => {
267
+ if (item.title === record.title) {
268
+ return {
269
+ ...item,
270
+ fixed: 'right',
271
+ };
272
+ }
273
+ return item;
274
+ }),
275
+ ],
276
+ });
277
+ } else {
278
+ let newSortData = sortDataSource.map((item) => {
279
+ if (item.title === record.title) {
280
+ return {
281
+ ...item,
282
+ fixed: null,
283
+ };
284
+ }
285
+ return item;
286
+ });
287
+ this.setState({
288
+ sortDataSource: [
289
+ ...newSortData.filter((item) => item.fixed === 'left'),
290
+ ...newSortData.filter((item) => !item.fixed),
291
+ ...newSortData.filter((item) => item.fixed === 'right'),
292
+ ],
293
+ dataSource: [
294
+ ...this.state.dataSource.map((item) => {
295
+ if (item.title === record.title) {
296
+ return {
297
+ ...item,
298
+ fixed: null,
299
+ };
300
+ }
301
+ return item;
302
+ }),
303
+ ],
304
+ });
305
+ }
306
+ }}
307
+ >
308
+ <Tooltip
309
+ placement="top"
310
+ title={record?.fixed === 'right' ? '取消固定' : '固定列尾'}
311
+ >
312
+ <img
313
+ src={record?.fixed === 'right' ? fixedRightActive : fixedRight}
314
+ />
315
+ </Tooltip>
316
+ </span>
317
+ );
318
+ },
319
+ },
158
320
  {
159
321
  title: '删除',
160
322
  dataIndex: 'title1',
@@ -251,17 +413,23 @@ class SortableTable extends React.Component<SortTableProps> {
251
413
  onSortEnd = ({ oldIndex, newIndex }: any) => {
252
414
  const { sortDataSource } = this.state;
253
415
  const { value, setValue }: any = this.props;
254
- if (sortDataSource[oldIndex]['fixed']) {
255
- message.warning('固定列不可移动');
256
- return;
257
- }
416
+ // if (sortDataSource[oldIndex]['fixed']) {
417
+ // message.warning('固定列不可移动');
418
+ // return;
419
+ // }
258
420
  if (oldIndex !== newIndex) {
259
421
  const newData = arrayMoveImmutable(
260
422
  [].concat(sortDataSource),
261
423
  oldIndex,
262
424
  newIndex,
263
425
  ).filter((el) => !!el);
264
- this.setState({ sortDataSource: newData });
426
+ this.setState({
427
+ sortDataSource: [
428
+ ...newData.filter((item) => item.fixed === 'left'),
429
+ ...newData.filter((item) => !item.fixed),
430
+ ...newData.filter((item) => item.fixed === 'right'),
431
+ ],
432
+ });
265
433
  }
266
434
  };
267
435
 
@@ -143,6 +143,14 @@ export default class ColumnSettingTable extends React.Component {
143
143
  );
144
144
  }
145
145
 
146
+ getTableScrollXWidth = (cols: any[]) => {
147
+ if (cols.every((item: any) => item.width)) {
148
+ return cols.reduce((cur: any, obj: any) => cur += obj.width, 0)
149
+ } else {
150
+ return 'max-content'
151
+ }
152
+ };
153
+
146
154
  render() {
147
155
  const { columns, tableCode, summary = undefined, dynamicColumns = [], ...restProps }: any = this.props;
148
156
  let otherTableInfo = {
@@ -185,6 +193,7 @@ export default class ColumnSettingTable extends React.Component {
185
193
 
186
194
  otherTableInfo = {
187
195
  ...otherTableInfo,
196
+ scroll: { x: restProps.overScrollX || this.getTableScrollXWidth(showCol) },
188
197
  summary: showSummary,
189
198
  }
190
199
  return (
@@ -149,6 +149,14 @@ export default class ColumnSettingSulaTable extends React.Component {
149
149
  );
150
150
  }
151
151
 
152
+ getTableScrollXWidth = (cols: any[]) => {
153
+ if (cols.every((item: any) => item.width)) {
154
+ return cols.reduce((cur: any, obj: any) => cur += obj.width, 0)
155
+ } else {
156
+ return 'max-content'
157
+ }
158
+ };
159
+
152
160
  render() {
153
161
  const { style=null, columns, tableCode, summary = undefined, dynamicColumns = [], ...restProps }: any = this.props;
154
162
  let otherTableInfo = {
@@ -191,6 +199,7 @@ export default class ColumnSettingSulaTable extends React.Component {
191
199
 
192
200
  otherTableInfo = {
193
201
  ...otherTableInfo,
202
+ scroll: { x: restProps.overScrollX || this.getTableScrollXWidth(showCol) },
194
203
  summary: showSummary,
195
204
  }
196
205
  return (
package/src/index.ts CHANGED
@@ -25,3 +25,6 @@ export { default as GuideWrapper } from './components/Business/CommonGuideWrappe
25
25
  export { default as ExportIcon } from './components/Functional/ExportFunctions/ExportIcon';
26
26
  export { default as SulaColumnSettingTable} from './components/Business/columnSettingTable/sulaSettingTable';
27
27
  export { default as ColumnSettingTable} from './components/Business/columnSettingTable';
28
+ // export { default as DetailPageWrapper } from './components/Business/DetailPageWrapper';
29
+ // export { default as HomePageWrapper } from './components/Business/HomePageWrapper';
30
+ // export { default as BsSulaQueryTable } from './components/Business/BsSulaQueryTable';