@bit-sun/business-component 2.0.32 → 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 (100) hide show
  1. package/.editorconfig +16 -16
  2. package/.fatherrc.ts +4 -4
  3. package/.gitlab-ci.yml +174 -174
  4. package/.prettierignore +7 -7
  5. package/.prettierrc +11 -11
  6. package/.umirc.ts +74 -74
  7. package/README.md +27 -27
  8. package/dist/index.esm.js +5763 -7663
  9. package/dist/index.js +5760 -7660
  10. package/docs/index.md +21 -21
  11. package/lib/assets/drag.svg +17 -17
  12. package/lib/assets/exportFail.svg +37 -37
  13. package/lib/assets/exportProcessing.svg +28 -28
  14. package/lib/assets/exportSuccess.svg +34 -34
  15. package/lib/assets/label_icon_bottom.svg +25 -25
  16. package/lib/assets/upExport.svg +22 -22
  17. package/package.json +66 -69
  18. package/src/assets/btn-delete.svg +29 -29
  19. package/src/assets/btn-edit.svg +19 -19
  20. package/src/assets/btn-more.svg +17 -17
  21. package/src/assets/btn-submit.svg +19 -19
  22. package/src/assets/close.svg +26 -26
  23. package/src/assets/drag.svg +17 -17
  24. package/src/assets/exportFail.svg +37 -37
  25. package/src/assets/exportProcessing.svg +28 -28
  26. package/src/assets/exportSuccess.svg +34 -34
  27. package/src/assets/fixed-left-active.svg +11 -11
  28. package/src/assets/fixed-left.svg +15 -15
  29. package/src/assets/fixed-right-active.svg +11 -11
  30. package/src/assets/fixed-right.svg +15 -15
  31. package/src/assets/icon-quanping.svg +15 -15
  32. package/src/assets/icon-shezhi.svg +17 -17
  33. package/src/assets/label_icon_bottom.svg +25 -25
  34. package/src/assets/scanning.svg +24 -24
  35. package/src/assets/upExport.svg +22 -22
  36. package/src/components/Business/AddSelectBusiness/index.md +41 -41
  37. package/src/components/Business/AddSelectBusiness/index.tsx +290 -290
  38. package/src/components/Business/BsSulaQueryTable/index.less +219 -219
  39. package/src/components/Business/BsSulaQueryTable/index.tsx +534 -534
  40. package/src/components/Business/BsSulaQueryTable/setting.tsx +817 -817
  41. package/src/components/Business/BsSulaQueryTable/utils.less +65 -65
  42. package/src/components/Business/BsSulaQueryTable/utils.tsx +690 -690
  43. package/src/components/Business/CommodityEntry/index.md +70 -70
  44. package/src/components/Business/CommodityEntry/index.tsx +80 -80
  45. package/src/components/Business/CommonAlert/index.tsx +23 -23
  46. package/src/components/Business/CommonGuideWrapper/index.less +111 -111
  47. package/src/components/Business/CommonGuideWrapper/index.md +39 -39
  48. package/src/components/Business/CommonGuideWrapper/index.tsx +83 -83
  49. package/src/components/Business/DetailPageWrapper/index.less +79 -79
  50. package/src/components/Business/DetailPageWrapper/index.tsx +324 -324
  51. package/src/components/Business/DetailPageWrapper/utils.tsx +110 -110
  52. package/src/components/Business/HomePageWrapper/index.less +33 -33
  53. package/src/components/Business/HomePageWrapper/index.md +45 -45
  54. package/src/components/Business/HomePageWrapper/index.tsx +150 -150
  55. package/src/components/Business/SearchSelect/BusinessUtils.ts +1448 -1448
  56. package/src/components/Business/SearchSelect/common.ts +53 -53
  57. package/src/components/Business/SearchSelect/index.md +1137 -1137
  58. package/src/components/Business/SearchSelect/index.tsx +51 -51
  59. package/src/components/Business/SearchSelect/utils.ts +99 -99
  60. package/src/components/Business/StateFlow/index.less +130 -130
  61. package/src/components/Business/StateFlow/index.md +60 -60
  62. package/src/components/Business/StateFlow/index.tsx +29 -29
  63. package/src/components/Business/TreeSearchSelect/index.md +126 -126
  64. package/src/components/Business/TreeSearchSelect/index.tsx +34 -34
  65. package/src/components/Business/TreeSearchSelect/utils.ts +60 -60
  66. package/src/components/Business/columnSettingTable/columnSetting.tsx +762 -762
  67. package/src/components/Business/columnSettingTable/index.less +247 -247
  68. package/src/components/Business/columnSettingTable/index.md +357 -357
  69. package/src/components/Business/columnSettingTable/index.tsx +225 -225
  70. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +233 -233
  71. package/src/components/Business/columnSettingTable/utils.tsx +68 -68
  72. package/src/components/Functional/AddSelect/index.less +367 -367
  73. package/src/components/Functional/AddSelect/index.md +122 -122
  74. package/src/components/Functional/AddSelect/index.tsx +962 -962
  75. package/src/components/Functional/BillEntry/index.less +371 -371
  76. package/src/components/Functional/BillEntry/index.md +37 -37
  77. package/src/components/Functional/BillEntry/index.tsx +547 -547
  78. package/src/components/Functional/DataImport/index.less +63 -63
  79. package/src/components/Functional/DataImport/index.md +44 -44
  80. package/src/components/Functional/DataImport/index.tsx +689 -689
  81. package/src/components/Functional/DataValidation/index.less +63 -63
  82. package/src/components/Functional/DataValidation/index.md +38 -38
  83. package/src/components/Functional/DataValidation/index.tsx +681 -681
  84. package/src/components/Functional/ExportFunctions/ExportIcon/index.md +37 -37
  85. package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +59 -59
  86. package/src/components/Functional/QueryMutipleInput/index.less +37 -37
  87. package/src/components/Functional/QueryMutipleInput/index.md +33 -33
  88. package/src/components/Functional/QueryMutipleInput/index.tsx +128 -128
  89. package/src/components/Functional/SearchSelect/index.less +115 -115
  90. package/src/components/Functional/SearchSelect/index.md +141 -141
  91. package/src/components/Functional/SearchSelect/index.tsx +812 -812
  92. package/src/components/Functional/TreeSearchSelect/index.md +47 -47
  93. package/src/components/Functional/TreeSearchSelect/index.tsx +149 -149
  94. package/src/index.ts +30 -30
  95. package/src/utils/CheckOneUser/index.md +39 -39
  96. package/src/utils/CheckOneUser/index.ts +51 -51
  97. package/src/utils/requestUtils.ts +32 -32
  98. package/src/utils/utils.ts +22 -22
  99. package/tsconfig.json +29 -29
  100. package/typings.d.ts +4 -4
@@ -1,690 +1,690 @@
1
- // @ts-nocheck
2
- import React, { useState } from 'react';
3
- import {
4
- Tooltip,
5
- Badge,
6
- Image,
7
- Space,
8
- Menu,
9
- Dropdown,
10
- Input,
11
- Button,
12
- InputNumber,
13
- Popover,
14
- Card,
15
- Avatar,
16
- } from 'antd';
17
- import moment from 'moment';
18
- import {
19
- CloseSquareOutlined,
20
- CopyOutlined,
21
- DeleteOutlined,
22
- EditOutlined,
23
- EyeOutlined,
24
- SendOutlined,
25
- WarningOutlined,
26
- } from '@ant-design/icons';
27
- import './utils.less';
28
- import { request } from 'bssula';
29
-
30
- export const handleStatusBadge = (text: any, color: any) => {
31
- return (
32
- <Badge
33
- style={{
34
- width: '150px',
35
- display: 'inline-block',
36
- textOverflow: 'ellipsis',
37
- overflow: 'hidden',
38
- whiteSpace: 'nowrap',
39
- }}
40
- text={text}
41
- color={color}
42
- ></Badge>
43
- );
44
- };
45
-
46
- export const HandleTotalCount = (totalParams: any) => {
47
- const { total = {}, totalLeft, totalRight } = totalParams;
48
- return (
49
- <div className="total_warp">
50
- <div className="total_warp_left">
51
- {totalLeft.map((d: any) => (
52
- <div>
53
- <span className="total_warp_num">{total[d.value] || 0}</span>
54
- <span className="total_warp_title">{d.key}</span>
55
- </div>
56
- ))}
57
- </div>
58
- <div className="total_warp_right">
59
- {totalRight.map((d: any) => (
60
- <div>
61
- <span className="total_warp_num">{total[d.value] || 0}</span>
62
- <span className="total_warp_title">{d.key}</span>
63
- </div>
64
- ))}
65
- </div>
66
- </div>
67
- );
68
- };
69
-
70
- export const updateGuanDate = (requestParams: any, dateKeyParams: any = {}) => {
71
- return {
72
- type: 'modalForm',
73
- width: 800,
74
- props: {
75
- maskClosable: false,
76
- },
77
- title: '修改单据日期',
78
- mode: 'create', // 新建/编辑/查看
79
- initialValues: (ctx: any) => {
80
- if (!ctx.record) return;
81
- return {
82
- ...ctx.record,
83
- date: dateKeyParams.initDate
84
- ? ctx.record[dateKeyParams.initDate]
85
- : ctx.record.orderDate,
86
- };
87
- },
88
- fields: [
89
- {
90
- name: dateKeyParams.outDate || `date`,
91
- label: '单据日期',
92
- field: {
93
- type: 'datepicker',
94
- props: {
95
- autoSize: true,
96
- placeholder: '请选择',
97
- disabledDate: (currentDate: any) =>
98
- currentDate.valueOf() <
99
- moment().subtract(Number(moment().format('D')), 'days'),
100
- style: { width: '100%' },
101
- },
102
- },
103
- initialValue: moment().utcOffset(8),
104
- rules: [{ required: true, message: '请选择单据日期' }],
105
- },
106
- ],
107
- submitButtonProps: {
108
- children: '确认',
109
- },
110
- backButtonProps: {
111
- children: '取消',
112
- },
113
- submit: requestParams,
114
- };
115
- };
116
-
117
- export const renderZeroInSummary = (value: any) =>
118
- value != '0' ? value / 1000 : '- -';
119
-
120
- export const calculateValidPeriod = (start: any, end: any) => {
121
- return `${moment(end).diff(start, 'days')} 天` || '- -';
122
- };
123
-
124
- // 带有toptile 清提示 并且会换行的
125
- export const handleTextDouble = (
126
- textOne: string | undefined,
127
- textTwo: string | undefined,
128
- ) => {
129
- return (
130
- <>
131
- <div style={{ marginBottom: -8 }}>{textOne}</div>
132
- <div>{textTwo}</div>
133
- </>
134
- );
135
- };
136
-
137
- // 带有toptile 清提示 ...
138
- export const handleTextLineFeed = (
139
- text: string | undefined,
140
- width: number = 130,
141
- ) => {
142
- return (
143
- <Tooltip title={text || '- -'}>
144
- <span
145
- style={{
146
- width: width ? width + 'px' : '130px',
147
- display: 'inline-block',
148
- position: 'relative',
149
- whiteSpace: 'pre-line',
150
- top: '5px',
151
- }}
152
- >
153
- {text || '- -'}
154
- </span>
155
- </Tooltip>
156
- );
157
- };
158
-
159
- // 带有toptile 清提示 ...
160
- export const handleTextOverflow = (
161
- text: string | undefined,
162
- width: number = 130,
163
- ) => {
164
- return (
165
- <Tooltip title={text || '- -'}>
166
- <span
167
- style={{
168
- width: width ? width + 'px' : '130px',
169
- display: 'inline-block',
170
- textOverflow: 'ellipsis',
171
- overflow: 'hidden',
172
- whiteSpace: 'nowrap',
173
- position: 'relative',
174
- top: '5px',
175
- }}
176
- >
177
- {text || '- -'}
178
- </span>
179
- </Tooltip>
180
- );
181
- };
182
-
183
- // 处理时间 带时分秒
184
-
185
- export const handleTooltip = (text: any, timeTrue?: boolean) => {
186
- return (
187
- <Tooltip title={timeTrue ? handleCommonTimeRender(text) : text}>
188
- {timeTrue ? handleCommonTimeRender(text) : text}
189
- </Tooltip>
190
- );
191
- };
192
-
193
- // 处理时间 不带时分秒
194
- export const handleTooltipHours = (text: any, timeTrue?: boolean) => {
195
- return (
196
- <Tooltip title={timeTrue ? handleCommonTimeRenderHours(text) : text}>
197
- {timeTrue ? handleCommonTimeRenderHours(text) : text}
198
- </Tooltip>
199
- );
200
- };
201
-
202
- /*
203
- 列表展示缩略图片
204
- url 图片 url
205
- {
206
- width: 图片宽度
207
- height: 图片高度
208
- }
209
- */
210
- type tableColumnsImageType = {
211
- width?: number | string;
212
- height?: number | string;
213
- [key: string]: any;
214
- };
215
-
216
- export const tableColumnsImage = (
217
- url?: string,
218
- paramsObj?: tableColumnsImageType,
219
- ) => {
220
- // 测试使用 测试类型缩小 随时可删除 start
221
- const imgHtml = document.querySelector('.ant-image-mask-info')!;
222
- if (imgHtml) {
223
- let str = imgHtml?.innerHTML;
224
- str = str?.replace('预览', '');
225
- imgHtml.innerHTML = str;
226
- }
227
- // 测试使用 测试类型缩小 end
228
-
229
- return (
230
- <>
231
- {url ? (
232
- <div className={`clomnsImg`}>
233
- <Image src={url} width="44px" height="44px" {...paramsObj}></Image>
234
- </div>
235
- ) : (
236
- <img
237
- width={44}
238
- {...paramsObj}
239
- src={
240
- 'https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png'
241
- }
242
- ></img>
243
- )}
244
- </>
245
- );
246
- };
247
-
248
- type UserColumnsType = {
249
- name: string; //用户名
250
- department?: string; //部门
251
- position?: string; //职位
252
- company?: string; //公司
253
- avatar?: string; //头像
254
- };
255
- export const userColumns = (props: UserColumnsType) => {
256
- const {
257
- name = '',
258
- department,
259
- position,
260
- company,
261
- avatar = '',
262
- }: UserColumnsType = props;
263
-
264
- return (
265
- <Popover
266
- overlayClassName={'user_info_card'}
267
- overlayInnerStyle={{ padding: '0px' }}
268
- placement="bottom"
269
- title={null}
270
- content={userInfoCard(props)}
271
- >
272
- <div className="user_columns_warp">
273
- <img
274
- style={{ borderRadius: '50%' }}
275
- src={
276
- avatar ||
277
- 'https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png'
278
- }
279
- ></img>
280
- <span>{name}</span>
281
- </div>
282
- </Popover>
283
- );
284
- };
285
-
286
- export const userInfoCard = (props: any) => {
287
- return (
288
- <Card
289
- style={{ width: 200 }}
290
- cover={
291
- <img
292
- alt="example"
293
- height={90}
294
- src={
295
- props.avatar ||
296
- 'https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png'
297
- }
298
- />
299
- }
300
- >
301
- <div className={'cardContent'} style={{ padding: '0 15px' }}>
302
- <div className={'user_card_header'}>
303
- <Avatar
304
- style={{ border: '2px solid #ffffff' }}
305
- size={64}
306
- src={
307
- props.avatar ||
308
- 'https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png'
309
- }
310
- />
311
- <div className={'card_name'}>{props.name}</div>
312
- <div className={'card_company'}>{props.company || 'XXXXX'}</div>
313
- </div>
314
- <p className={'card_detailInfo'}>
315
- 部门:{' '}
316
- <span className={'card_department'}>
317
- {props.department || 'XXXXX'}
318
- </span>
319
- </p>
320
- <p className={'card_detailInfo'}>
321
- 职位: {props.position || 'XXXXX'}
322
- </p>
323
- </div>
324
- </Card>
325
- );
326
- };
327
-
328
- export function handleCommonTimeRenderHours(text: any, format?: any) {
329
- const formatType = format || 'YYYY-MM-DD';
330
- return (text && moment(text).format(formatType)) || '- -';
331
- }
332
-
333
- export function handleCommonTimeRender(text: any, format?: any) {
334
- const formatType = format || 'YYYY-MM-DD HH:mm:ss';
335
- return (text && moment(text).format(formatType)) || '- -';
336
- }
337
-
338
- interface ColumnsEditInterfave {
339
- text?: string;
340
- record?: any;
341
- type?: string;
342
- reqName: string;
343
- successMessage?: string;
344
- urlPathId?: boolean;
345
- disabled: boolean;
346
- requestProps: {
347
- url: string;
348
- converter?: Function;
349
- method?: string;
350
- };
351
- [key: string]: any;
352
- }
353
- /*
354
- text 当前项
355
- record 当前行
356
- table sula table 的实例
357
- type 默认 input 可选 number 输入框类型
358
- inpProps 输入框透传 props
359
- requestProps {} bssula 的 request
360
- reqName 修改数据传给后端的key
361
- urlPathId 默认 true 会在 requestProps.url 上面 拼接 /:id
362
- successMessage 默认提示操作成功 可传入 string
363
- disabled 什么时候禁用 boolean 类型
364
- */
365
- export const ColumnsEdit = (props: ColumnsEditInterfave) => {
366
- const {
367
- text = '',
368
- record,
369
- table,
370
- type = 'input',
371
- inpProps = {},
372
- requestProps = {
373
- url: '',
374
- },
375
- reqName,
376
- urlPathId = true,
377
- successMessage = '操作成功',
378
- disabled,
379
- }: ColumnsEditInterfave = props;
380
- const [visible, setvisible] = useState(false);
381
- const [inputValue, setInputValue]: [
382
- inputValue: string | number,
383
- setInputValue: Function,
384
- ] = useState(text);
385
-
386
- const onSubmit = () => {
387
- const url = urlPathId
388
- ? requestProps.url + `/${record.id}`
389
- : requestProps.url;
390
- request({
391
- url: url,
392
- method: requestProps.method || 'patch',
393
- convertParams: () => {
394
- return {
395
- ...record,
396
- [reqName]: inputValue,
397
- };
398
- },
399
- successMessage,
400
- converter(ctx: any) {
401
- if (
402
- requestProps.converter &&
403
- typeof requestProps.converter === 'function'
404
- ) {
405
- requestProps.converter(ctx);
406
- return;
407
- }
408
- setvisible(false);
409
- table.resetTable();
410
- },
411
- });
412
- };
413
-
414
- const menu = (
415
- <Menu>
416
- <Menu.Item>
417
- {type === 'input' && (
418
- <Input
419
- disabled={disabled}
420
- onChange={(e: any) => {
421
- const v = e.target.value;
422
- setInputValue(v);
423
- }}
424
- style={{ width: 170 }}
425
- value={inputValue}
426
- {...inpProps}
427
- ></Input>
428
- )}
429
- {type === 'number' && (
430
- <InputNumber
431
- disabled={disabled}
432
- onBlur={(e: any) => {
433
- const v = parseFloat(e.target.value);
434
- if (!isNaN(v)) {
435
- setInputValue(v);
436
- }
437
- }}
438
- style={{ width: 170 }}
439
- value={inputValue}
440
- {...inpProps}
441
- ></InputNumber>
442
- )}
443
- </Menu.Item>
444
- <Menu.Divider />
445
- <Menu.Item>
446
- <div style={{ textAlign: 'right' }}>
447
- <Space>
448
- <Button
449
- onClick={() => {
450
- setvisible(false);
451
- }}
452
- >
453
- 取消
454
- </Button>
455
- <Button
456
- type="primary"
457
- disabled={disabled}
458
- onClick={() => onSubmit()}
459
- >
460
- 确定
461
- </Button>
462
- </Space>
463
- </div>
464
- </Menu.Item>
465
- </Menu>
466
- );
467
- return (
468
- <div key={record.id}>
469
- <Space>
470
- {text}
471
- <Dropdown
472
- visible={visible}
473
- overlay={menu}
474
- trigger={['click']}
475
- placement="bottomLeft"
476
- >
477
- <EditOutlined
478
- style={{ color: '#B0B4B7' }}
479
- onClick={() => {
480
- setvisible(!visible);
481
- }}
482
- className="cur"
483
- />
484
- </Dropdown>
485
- </Space>
486
- </div>
487
- );
488
- };
489
-
490
- // 带有toptile 清提示 并且会换行的
491
- export const handleTextDoubleOrId = (
492
- textOne: string | undefined,
493
- textTwo: string | undefined,
494
- ) => {
495
- return (
496
- <>
497
- <div style={{ color: '#000', marginBottom: -8 }}>{textOne}</div>
498
- <span style={{ color: '#848484' }}>ID : {textTwo}</span>
499
- </>
500
- );
501
- };
502
-
503
- export const textIcon = (type: string | number, text?: string) => {
504
- if (!type) return;
505
- if (type == 1) {
506
- return (
507
- <a className="cloumnsIconA">
508
- <EyeOutlined />
509
- <span>详情</span>
510
- </a>
511
- );
512
- }
513
- if (type == 2) {
514
- return (
515
- <a className="cloumnsIconA">
516
- <EyeOutlined />
517
- <span>查看</span>
518
- </a>
519
- );
520
- }
521
- if (type == 3) {
522
- return (
523
- <a className="cloumnsIconA">
524
- <DeleteOutlined />
525
- <span>删除</span>
526
- </a>
527
- );
528
- }
529
- if (type == 4) {
530
- return (
531
- <a className="cloumnsIconA">
532
- <EditOutlined />
533
- <span>编辑</span>
534
- </a>
535
- );
536
- }
537
- if (type == 5) {
538
- return (
539
- <a className="cloumnsIconA">
540
- <CopyOutlined />
541
- <span>复制</span>
542
- </a>
543
- );
544
- }
545
- if (type == 6) {
546
- return (
547
- <a className="cloumnsIconA">
548
- <CloseSquareOutlined />
549
- <span>作废</span>
550
- </a>
551
- );
552
- }
553
- if (type == 7) {
554
- return (
555
- <a className="cloumnsIconA">
556
- <WarningOutlined />
557
- <span>终止</span>
558
- </a>
559
- );
560
- }
561
- if (type == 8) {
562
- return (
563
- <a className="cloumnsIconA">
564
- <SendOutlined />
565
- <span>{text}</span>
566
- </a>
567
- );
568
- }
569
- };
570
-
571
- // 四舍五入两位小数,没有小数点就显示整数
572
- export const renderFixed2 = (text: any) => text;
573
-
574
- //设置queryTable默认列宽
575
- export const getItemDefaultWidth = (item: any) => {
576
- let defaultWidth = 200;
577
- let lowerCaseKey = (item.key || item.dataIndex).toLowerCase();
578
- switch (true) {
579
- case item?.title === '操作' || lowerCaseKey === 'operate':
580
- defaultWidth = 60;
581
- break;
582
- case lowerCaseKey.indexOf('number') > -1:
583
- case lowerCaseKey.indexOf('quantity') > -1:
584
- case lowerCaseKey.indexOf('amount') > -1:
585
- defaultWidth = 90;
586
- break;
587
- case (lowerCaseKey.indexOf('no') > -1):
588
- defaultWidth = 200;
589
- break;
590
- case lowerCaseKey.indexOf('code') > -1:
591
- defaultWidth = 170;
592
- break;
593
- case lowerCaseKey.indexOf('time') > -1:
594
- defaultWidth = 130;
595
- break;
596
- case lowerCaseKey.indexOf('status') > -1:
597
- defaultWidth = 100;
598
- break;
599
- case lowerCaseKey.indexOf('user') > -1:
600
- defaultWidth = 130;
601
- break;
602
- default:
603
- break;
604
- }
605
- return defaultWidth;
606
- };
607
-
608
- /**
609
- * 查询参数处理
610
- * @param params 要应用于查询的参数
611
- * @returns 返回处理后的查询参数
612
- */
613
- export function queryParams(params: any, flag?: any) {
614
- for (const key in params) {
615
- if (Object.prototype.hasOwnProperty.call(params, key)) {
616
- const element = params[key];
617
- if (element && key.indexOf('*number*') >= 0) {
618
- const dataParams = key.split('*number*');
619
- dataParams.forEach((value, index) => {
620
- params[value] = element[index];
621
- });
622
- delete params[key];
623
- } else if (element && key.indexOf('*address*') >= 0) {
624
- const dataParams = key.split('*address*');
625
- dataParams.forEach((value, index) => {
626
- params[value] = element.PCDCode[index];
627
- });
628
- delete params[key];
629
- } else if (element && key.indexOf('*costType*') >= 0) {
630
- const dataParams = key.split('*costType*');
631
- // eslint-disable-next-line prefer-destructuring
632
- params[dataParams[0]] = element[1];
633
- delete params[key];
634
- } else if (element && key.indexOf('*fullDate*') >= 0) {
635
- const dataParams = key.split('*fullDate*');
636
- dataParams.forEach((value, index) => {
637
- if (index === 0) {
638
- params[value] = moment(element[index])
639
- .millisecond(0)
640
- .second(0)
641
- .minute(0)
642
- .hour(0)
643
- .format('YYYY-MM-DD HH:mm:ss');
644
- } else {
645
- params[value] = moment(element[index])
646
- .millisecond(59)
647
- .second(59)
648
- .minute(59)
649
- .hour(23)
650
- .format('YYYY-MM-DD HH:mm:ss');
651
- }
652
- });
653
- delete params[key];
654
- } else if (element && key.indexOf('*') >= 0) {
655
- const dataParams = key.split('*');
656
- dataParams.forEach((value, index) => {
657
- params[value] = element[index].format('YYYY-MM-DD HH:mm:ss');
658
- });
659
- delete params[key];
660
- } else if (element && key.indexOf('_likeIn_') >= 0) {
661
- const dataParams = key.split('_likeIn_');
662
- if (element.indexOf(',') >= 0) {
663
- params[`qp-${dataParams[0]}-in`] = element.split(',').join(',');
664
- params[`qp-${dataParams[0]}-like`] = null;
665
- } else {
666
- params[`qp-${dataParams[0]}-like`] = element;
667
- params[`qp-${dataParams[0]}-in`] = null;
668
- }
669
- delete params[key];
670
- } else if (Array.isArray(element)) {
671
- params[key] = element.join(',');
672
- }
673
- }
674
- }
675
- return flag ? params : qs.stringify(params);
676
- }
677
-
678
- /**
679
- * 根据用户权限检验对应按钮是够显示 !!!!现在先去掉
680
- * @param code 对应权限值
681
- * @returns boolean
682
- */
683
- export const authFn = (code?: any) => {
684
- const authButton = localStorage.getItem('menuAuth_mainProject')
685
- ? JSON.parse(localStorage.getItem('menuAuth_mainProject') as string)
686
- : [];
687
- return authButton.findIndex((d: any) => d === code) !== -1;
688
- };
689
-
690
-
1
+ // @ts-nocheck
2
+ import React, { useState } from 'react';
3
+ import {
4
+ Tooltip,
5
+ Badge,
6
+ Image,
7
+ Space,
8
+ Menu,
9
+ Dropdown,
10
+ Input,
11
+ Button,
12
+ InputNumber,
13
+ Popover,
14
+ Card,
15
+ Avatar,
16
+ } from 'antd';
17
+ import moment from 'moment';
18
+ import {
19
+ CloseSquareOutlined,
20
+ CopyOutlined,
21
+ DeleteOutlined,
22
+ EditOutlined,
23
+ EyeOutlined,
24
+ SendOutlined,
25
+ WarningOutlined,
26
+ } from '@ant-design/icons';
27
+ import './utils.less';
28
+ import { request } from 'bssula';
29
+
30
+ export const handleStatusBadge = (text: any, color: any) => {
31
+ return (
32
+ <Badge
33
+ style={{
34
+ width: '150px',
35
+ display: 'inline-block',
36
+ textOverflow: 'ellipsis',
37
+ overflow: 'hidden',
38
+ whiteSpace: 'nowrap',
39
+ }}
40
+ text={text}
41
+ color={color}
42
+ ></Badge>
43
+ );
44
+ };
45
+
46
+ export const HandleTotalCount = (totalParams: any) => {
47
+ const { total = {}, totalLeft, totalRight } = totalParams;
48
+ return (
49
+ <div className="total_warp">
50
+ <div className="total_warp_left">
51
+ {totalLeft.map((d: any) => (
52
+ <div>
53
+ <span className="total_warp_num">{total[d.value] || 0}</span>
54
+ <span className="total_warp_title">{d.key}</span>
55
+ </div>
56
+ ))}
57
+ </div>
58
+ <div className="total_warp_right">
59
+ {totalRight.map((d: any) => (
60
+ <div>
61
+ <span className="total_warp_num">{total[d.value] || 0}</span>
62
+ <span className="total_warp_title">{d.key}</span>
63
+ </div>
64
+ ))}
65
+ </div>
66
+ </div>
67
+ );
68
+ };
69
+
70
+ export const updateGuanDate = (requestParams: any, dateKeyParams: any = {}) => {
71
+ return {
72
+ type: 'modalForm',
73
+ width: 800,
74
+ props: {
75
+ maskClosable: false,
76
+ },
77
+ title: '修改单据日期',
78
+ mode: 'create', // 新建/编辑/查看
79
+ initialValues: (ctx: any) => {
80
+ if (!ctx.record) return;
81
+ return {
82
+ ...ctx.record,
83
+ date: dateKeyParams.initDate
84
+ ? ctx.record[dateKeyParams.initDate]
85
+ : ctx.record.orderDate,
86
+ };
87
+ },
88
+ fields: [
89
+ {
90
+ name: dateKeyParams.outDate || `date`,
91
+ label: '单据日期',
92
+ field: {
93
+ type: 'datepicker',
94
+ props: {
95
+ autoSize: true,
96
+ placeholder: '请选择',
97
+ disabledDate: (currentDate: any) =>
98
+ currentDate.valueOf() <
99
+ moment().subtract(Number(moment().format('D')), 'days'),
100
+ style: { width: '100%' },
101
+ },
102
+ },
103
+ initialValue: moment().utcOffset(8),
104
+ rules: [{ required: true, message: '请选择单据日期' }],
105
+ },
106
+ ],
107
+ submitButtonProps: {
108
+ children: '确认',
109
+ },
110
+ backButtonProps: {
111
+ children: '取消',
112
+ },
113
+ submit: requestParams,
114
+ };
115
+ };
116
+
117
+ export const renderZeroInSummary = (value: any) =>
118
+ value != '0' ? value / 1000 : '- -';
119
+
120
+ export const calculateValidPeriod = (start: any, end: any) => {
121
+ return `${moment(end).diff(start, 'days')} 天` || '- -';
122
+ };
123
+
124
+ // 带有toptile 清提示 并且会换行的
125
+ export const handleTextDouble = (
126
+ textOne: string | undefined,
127
+ textTwo: string | undefined,
128
+ ) => {
129
+ return (
130
+ <>
131
+ <div style={{ marginBottom: -8 }}>{textOne}</div>
132
+ <div>{textTwo}</div>
133
+ </>
134
+ );
135
+ };
136
+
137
+ // 带有toptile 清提示 ...
138
+ export const handleTextLineFeed = (
139
+ text: string | undefined,
140
+ width: number = 130,
141
+ ) => {
142
+ return (
143
+ <Tooltip title={text || '- -'}>
144
+ <span
145
+ style={{
146
+ width: width ? width + 'px' : '130px',
147
+ display: 'inline-block',
148
+ position: 'relative',
149
+ whiteSpace: 'pre-line',
150
+ top: '5px',
151
+ }}
152
+ >
153
+ {text || '- -'}
154
+ </span>
155
+ </Tooltip>
156
+ );
157
+ };
158
+
159
+ // 带有toptile 清提示 ...
160
+ export const handleTextOverflow = (
161
+ text: string | undefined,
162
+ width: number = 130,
163
+ ) => {
164
+ return (
165
+ <Tooltip title={text || '- -'}>
166
+ <span
167
+ style={{
168
+ width: width ? width + 'px' : '130px',
169
+ display: 'inline-block',
170
+ textOverflow: 'ellipsis',
171
+ overflow: 'hidden',
172
+ whiteSpace: 'nowrap',
173
+ position: 'relative',
174
+ top: '5px',
175
+ }}
176
+ >
177
+ {text || '- -'}
178
+ </span>
179
+ </Tooltip>
180
+ );
181
+ };
182
+
183
+ // 处理时间 带时分秒
184
+
185
+ export const handleTooltip = (text: any, timeTrue?: boolean) => {
186
+ return (
187
+ <Tooltip title={timeTrue ? handleCommonTimeRender(text) : text}>
188
+ {timeTrue ? handleCommonTimeRender(text) : text}
189
+ </Tooltip>
190
+ );
191
+ };
192
+
193
+ // 处理时间 不带时分秒
194
+ export const handleTooltipHours = (text: any, timeTrue?: boolean) => {
195
+ return (
196
+ <Tooltip title={timeTrue ? handleCommonTimeRenderHours(text) : text}>
197
+ {timeTrue ? handleCommonTimeRenderHours(text) : text}
198
+ </Tooltip>
199
+ );
200
+ };
201
+
202
+ /*
203
+ 列表展示缩略图片
204
+ url 图片 url
205
+ {
206
+ width: 图片宽度
207
+ height: 图片高度
208
+ }
209
+ */
210
+ type tableColumnsImageType = {
211
+ width?: number | string;
212
+ height?: number | string;
213
+ [key: string]: any;
214
+ };
215
+
216
+ export const tableColumnsImage = (
217
+ url?: string,
218
+ paramsObj?: tableColumnsImageType,
219
+ ) => {
220
+ // 测试使用 测试类型缩小 随时可删除 start
221
+ const imgHtml = document.querySelector('.ant-image-mask-info')!;
222
+ if (imgHtml) {
223
+ let str = imgHtml?.innerHTML;
224
+ str = str?.replace('预览', '');
225
+ imgHtml.innerHTML = str;
226
+ }
227
+ // 测试使用 测试类型缩小 end
228
+
229
+ return (
230
+ <>
231
+ {url ? (
232
+ <div className={`clomnsImg`}>
233
+ <Image src={url} width="44px" height="44px" {...paramsObj}></Image>
234
+ </div>
235
+ ) : (
236
+ <img
237
+ width={44}
238
+ {...paramsObj}
239
+ src={
240
+ 'https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png'
241
+ }
242
+ ></img>
243
+ )}
244
+ </>
245
+ );
246
+ };
247
+
248
+ type UserColumnsType = {
249
+ name: string; //用户名
250
+ department?: string; //部门
251
+ position?: string; //职位
252
+ company?: string; //公司
253
+ avatar?: string; //头像
254
+ };
255
+ export const userColumns = (props: UserColumnsType) => {
256
+ const {
257
+ name = '',
258
+ department,
259
+ position,
260
+ company,
261
+ avatar = '',
262
+ }: UserColumnsType = props;
263
+
264
+ return (
265
+ <Popover
266
+ overlayClassName={'user_info_card'}
267
+ overlayInnerStyle={{ padding: '0px' }}
268
+ placement="bottom"
269
+ title={null}
270
+ content={userInfoCard(props)}
271
+ >
272
+ <div className="user_columns_warp">
273
+ <img
274
+ style={{ borderRadius: '50%' }}
275
+ src={
276
+ avatar ||
277
+ 'https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png'
278
+ }
279
+ ></img>
280
+ <span>{name}</span>
281
+ </div>
282
+ </Popover>
283
+ );
284
+ };
285
+
286
+ export const userInfoCard = (props: any) => {
287
+ return (
288
+ <Card
289
+ style={{ width: 200 }}
290
+ cover={
291
+ <img
292
+ alt="example"
293
+ height={90}
294
+ src={
295
+ props.avatar ||
296
+ 'https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png'
297
+ }
298
+ />
299
+ }
300
+ >
301
+ <div className={'cardContent'} style={{ padding: '0 15px' }}>
302
+ <div className={'user_card_header'}>
303
+ <Avatar
304
+ style={{ border: '2px solid #ffffff' }}
305
+ size={64}
306
+ src={
307
+ props.avatar ||
308
+ 'https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png'
309
+ }
310
+ />
311
+ <div className={'card_name'}>{props.name}</div>
312
+ <div className={'card_company'}>{props.company || 'XXXXX'}</div>
313
+ </div>
314
+ <p className={'card_detailInfo'}>
315
+ 部门:{' '}
316
+ <span className={'card_department'}>
317
+ {props.department || 'XXXXX'}
318
+ </span>
319
+ </p>
320
+ <p className={'card_detailInfo'}>
321
+ 职位: {props.position || 'XXXXX'}
322
+ </p>
323
+ </div>
324
+ </Card>
325
+ );
326
+ };
327
+
328
+ export function handleCommonTimeRenderHours(text: any, format?: any) {
329
+ const formatType = format || 'YYYY-MM-DD';
330
+ return (text && moment(text).format(formatType)) || '- -';
331
+ }
332
+
333
+ export function handleCommonTimeRender(text: any, format?: any) {
334
+ const formatType = format || 'YYYY-MM-DD HH:mm:ss';
335
+ return (text && moment(text).format(formatType)) || '- -';
336
+ }
337
+
338
+ interface ColumnsEditInterfave {
339
+ text?: string;
340
+ record?: any;
341
+ type?: string;
342
+ reqName: string;
343
+ successMessage?: string;
344
+ urlPathId?: boolean;
345
+ disabled: boolean;
346
+ requestProps: {
347
+ url: string;
348
+ converter?: Function;
349
+ method?: string;
350
+ };
351
+ [key: string]: any;
352
+ }
353
+ /*
354
+ text 当前项
355
+ record 当前行
356
+ table sula table 的实例
357
+ type 默认 input 可选 number 输入框类型
358
+ inpProps 输入框透传 props
359
+ requestProps {} bssula 的 request
360
+ reqName 修改数据传给后端的key
361
+ urlPathId 默认 true 会在 requestProps.url 上面 拼接 /:id
362
+ successMessage 默认提示操作成功 可传入 string
363
+ disabled 什么时候禁用 boolean 类型
364
+ */
365
+ export const ColumnsEdit = (props: ColumnsEditInterfave) => {
366
+ const {
367
+ text = '',
368
+ record,
369
+ table,
370
+ type = 'input',
371
+ inpProps = {},
372
+ requestProps = {
373
+ url: '',
374
+ },
375
+ reqName,
376
+ urlPathId = true,
377
+ successMessage = '操作成功',
378
+ disabled,
379
+ }: ColumnsEditInterfave = props;
380
+ const [visible, setvisible] = useState(false);
381
+ const [inputValue, setInputValue]: [
382
+ inputValue: string | number,
383
+ setInputValue: Function,
384
+ ] = useState(text);
385
+
386
+ const onSubmit = () => {
387
+ const url = urlPathId
388
+ ? requestProps.url + `/${record.id}`
389
+ : requestProps.url;
390
+ request({
391
+ url: url,
392
+ method: requestProps.method || 'patch',
393
+ convertParams: () => {
394
+ return {
395
+ ...record,
396
+ [reqName]: inputValue,
397
+ };
398
+ },
399
+ successMessage,
400
+ converter(ctx: any) {
401
+ if (
402
+ requestProps.converter &&
403
+ typeof requestProps.converter === 'function'
404
+ ) {
405
+ requestProps.converter(ctx);
406
+ return;
407
+ }
408
+ setvisible(false);
409
+ table.resetTable();
410
+ },
411
+ });
412
+ };
413
+
414
+ const menu = (
415
+ <Menu>
416
+ <Menu.Item>
417
+ {type === 'input' && (
418
+ <Input
419
+ disabled={disabled}
420
+ onChange={(e: any) => {
421
+ const v = e.target.value;
422
+ setInputValue(v);
423
+ }}
424
+ style={{ width: 170 }}
425
+ value={inputValue}
426
+ {...inpProps}
427
+ ></Input>
428
+ )}
429
+ {type === 'number' && (
430
+ <InputNumber
431
+ disabled={disabled}
432
+ onBlur={(e: any) => {
433
+ const v = parseFloat(e.target.value);
434
+ if (!isNaN(v)) {
435
+ setInputValue(v);
436
+ }
437
+ }}
438
+ style={{ width: 170 }}
439
+ value={inputValue}
440
+ {...inpProps}
441
+ ></InputNumber>
442
+ )}
443
+ </Menu.Item>
444
+ <Menu.Divider />
445
+ <Menu.Item>
446
+ <div style={{ textAlign: 'right' }}>
447
+ <Space>
448
+ <Button
449
+ onClick={() => {
450
+ setvisible(false);
451
+ }}
452
+ >
453
+ 取消
454
+ </Button>
455
+ <Button
456
+ type="primary"
457
+ disabled={disabled}
458
+ onClick={() => onSubmit()}
459
+ >
460
+ 确定
461
+ </Button>
462
+ </Space>
463
+ </div>
464
+ </Menu.Item>
465
+ </Menu>
466
+ );
467
+ return (
468
+ <div key={record.id}>
469
+ <Space>
470
+ {text}
471
+ <Dropdown
472
+ visible={visible}
473
+ overlay={menu}
474
+ trigger={['click']}
475
+ placement="bottomLeft"
476
+ >
477
+ <EditOutlined
478
+ style={{ color: '#B0B4B7' }}
479
+ onClick={() => {
480
+ setvisible(!visible);
481
+ }}
482
+ className="cur"
483
+ />
484
+ </Dropdown>
485
+ </Space>
486
+ </div>
487
+ );
488
+ };
489
+
490
+ // 带有toptile 清提示 并且会换行的
491
+ export const handleTextDoubleOrId = (
492
+ textOne: string | undefined,
493
+ textTwo: string | undefined,
494
+ ) => {
495
+ return (
496
+ <>
497
+ <div style={{ color: '#000', marginBottom: -8 }}>{textOne}</div>
498
+ <span style={{ color: '#848484' }}>ID : {textTwo}</span>
499
+ </>
500
+ );
501
+ };
502
+
503
+ export const textIcon = (type: string | number, text?: string) => {
504
+ if (!type) return;
505
+ if (type == 1) {
506
+ return (
507
+ <a className="cloumnsIconA">
508
+ <EyeOutlined />
509
+ <span>详情</span>
510
+ </a>
511
+ );
512
+ }
513
+ if (type == 2) {
514
+ return (
515
+ <a className="cloumnsIconA">
516
+ <EyeOutlined />
517
+ <span>查看</span>
518
+ </a>
519
+ );
520
+ }
521
+ if (type == 3) {
522
+ return (
523
+ <a className="cloumnsIconA">
524
+ <DeleteOutlined />
525
+ <span>删除</span>
526
+ </a>
527
+ );
528
+ }
529
+ if (type == 4) {
530
+ return (
531
+ <a className="cloumnsIconA">
532
+ <EditOutlined />
533
+ <span>编辑</span>
534
+ </a>
535
+ );
536
+ }
537
+ if (type == 5) {
538
+ return (
539
+ <a className="cloumnsIconA">
540
+ <CopyOutlined />
541
+ <span>复制</span>
542
+ </a>
543
+ );
544
+ }
545
+ if (type == 6) {
546
+ return (
547
+ <a className="cloumnsIconA">
548
+ <CloseSquareOutlined />
549
+ <span>作废</span>
550
+ </a>
551
+ );
552
+ }
553
+ if (type == 7) {
554
+ return (
555
+ <a className="cloumnsIconA">
556
+ <WarningOutlined />
557
+ <span>终止</span>
558
+ </a>
559
+ );
560
+ }
561
+ if (type == 8) {
562
+ return (
563
+ <a className="cloumnsIconA">
564
+ <SendOutlined />
565
+ <span>{text}</span>
566
+ </a>
567
+ );
568
+ }
569
+ };
570
+
571
+ // 四舍五入两位小数,没有小数点就显示整数
572
+ export const renderFixed2 = (text: any) => text;
573
+
574
+ //设置queryTable默认列宽
575
+ export const getItemDefaultWidth = (item: any) => {
576
+ let defaultWidth = 200;
577
+ let lowerCaseKey = (item.key || item.dataIndex).toLowerCase();
578
+ switch (true) {
579
+ case item?.title === '操作' || lowerCaseKey === 'operate':
580
+ defaultWidth = 60;
581
+ break;
582
+ case lowerCaseKey.indexOf('number') > -1:
583
+ case lowerCaseKey.indexOf('quantity') > -1:
584
+ case lowerCaseKey.indexOf('amount') > -1:
585
+ defaultWidth = 90;
586
+ break;
587
+ case (lowerCaseKey.indexOf('no') > -1):
588
+ defaultWidth = 200;
589
+ break;
590
+ case lowerCaseKey.indexOf('code') > -1:
591
+ defaultWidth = 170;
592
+ break;
593
+ case lowerCaseKey.indexOf('time') > -1:
594
+ defaultWidth = 130;
595
+ break;
596
+ case lowerCaseKey.indexOf('status') > -1:
597
+ defaultWidth = 100;
598
+ break;
599
+ case lowerCaseKey.indexOf('user') > -1:
600
+ defaultWidth = 130;
601
+ break;
602
+ default:
603
+ break;
604
+ }
605
+ return defaultWidth;
606
+ };
607
+
608
+ /**
609
+ * 查询参数处理
610
+ * @param params 要应用于查询的参数
611
+ * @returns 返回处理后的查询参数
612
+ */
613
+ export function queryParams(params: any, flag?: any) {
614
+ for (const key in params) {
615
+ if (Object.prototype.hasOwnProperty.call(params, key)) {
616
+ const element = params[key];
617
+ if (element && key.indexOf('*number*') >= 0) {
618
+ const dataParams = key.split('*number*');
619
+ dataParams.forEach((value, index) => {
620
+ params[value] = element[index];
621
+ });
622
+ delete params[key];
623
+ } else if (element && key.indexOf('*address*') >= 0) {
624
+ const dataParams = key.split('*address*');
625
+ dataParams.forEach((value, index) => {
626
+ params[value] = element.PCDCode[index];
627
+ });
628
+ delete params[key];
629
+ } else if (element && key.indexOf('*costType*') >= 0) {
630
+ const dataParams = key.split('*costType*');
631
+ // eslint-disable-next-line prefer-destructuring
632
+ params[dataParams[0]] = element[1];
633
+ delete params[key];
634
+ } else if (element && key.indexOf('*fullDate*') >= 0) {
635
+ const dataParams = key.split('*fullDate*');
636
+ dataParams.forEach((value, index) => {
637
+ if (index === 0) {
638
+ params[value] = moment(element[index])
639
+ .millisecond(0)
640
+ .second(0)
641
+ .minute(0)
642
+ .hour(0)
643
+ .format('YYYY-MM-DD HH:mm:ss');
644
+ } else {
645
+ params[value] = moment(element[index])
646
+ .millisecond(59)
647
+ .second(59)
648
+ .minute(59)
649
+ .hour(23)
650
+ .format('YYYY-MM-DD HH:mm:ss');
651
+ }
652
+ });
653
+ delete params[key];
654
+ } else if (element && key.indexOf('*') >= 0) {
655
+ const dataParams = key.split('*');
656
+ dataParams.forEach((value, index) => {
657
+ params[value] = element[index].format('YYYY-MM-DD HH:mm:ss');
658
+ });
659
+ delete params[key];
660
+ } else if (element && key.indexOf('_likeIn_') >= 0) {
661
+ const dataParams = key.split('_likeIn_');
662
+ if (element.indexOf(',') >= 0) {
663
+ params[`qp-${dataParams[0]}-in`] = element.split(',').join(',');
664
+ params[`qp-${dataParams[0]}-like`] = null;
665
+ } else {
666
+ params[`qp-${dataParams[0]}-like`] = element;
667
+ params[`qp-${dataParams[0]}-in`] = null;
668
+ }
669
+ delete params[key];
670
+ } else if (Array.isArray(element)) {
671
+ params[key] = element.join(',');
672
+ }
673
+ }
674
+ }
675
+ return flag ? params : qs.stringify(params);
676
+ }
677
+
678
+ /**
679
+ * 根据用户权限检验对应按钮是够显示 !!!!现在先去掉
680
+ * @param code 对应权限值
681
+ * @returns boolean
682
+ */
683
+ export const authFn = (code?: any) => {
684
+ const authButton = localStorage.getItem('menuAuth_mainProject')
685
+ ? JSON.parse(localStorage.getItem('menuAuth_mainProject') as string)
686
+ : [];
687
+ return authButton.findIndex((d: any) => d === code) !== -1;
688
+ };
689
+
690
+