@bit-sun/business-component 2.0.37 → 2.0.39-alpha.0

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