@bit-sun/business-component 3.1.7 → 3.1.8

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 (219) hide show
  1. package/.editorconfig +16 -16
  2. package/.fatherrc.ts +5 -5
  3. package/.gitlab-ci.yml +179 -179
  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 +191 -151
  9. package/dist/index.js +191 -150
  10. package/dist/utils/utils.d.ts +1 -0
  11. package/docs/index.md +21 -21
  12. package/lib/assets/drag.svg +17 -17
  13. package/lib/assets/exportFail.svg +37 -37
  14. package/lib/assets/exportProcessing.svg +28 -28
  15. package/lib/assets/exportSuccess.svg +34 -34
  16. package/lib/assets/label_icon_bottom.svg +25 -25
  17. package/lib/assets/upExport.svg +22 -22
  18. package/package.json +88 -88
  19. package/src/assets/32.svg +27 -27
  20. package/src/assets/addIcon.svg +17 -17
  21. package/src/assets/allfunc.svg +27 -27
  22. package/src/assets/arrowRight.svg +24 -24
  23. package/src/assets/arrow_top.svg +17 -17
  24. package/src/assets/btn-delete.svg +29 -29
  25. package/src/assets/btn-edit.svg +19 -19
  26. package/src/assets/btn-more.svg +17 -17
  27. package/src/assets/btn-submit.svg +19 -19
  28. package/src/assets/caidan.svg +11 -11
  29. package/src/assets/close.svg +26 -26
  30. package/src/assets/drag.svg +17 -17
  31. package/src/assets/exportFail.svg +37 -37
  32. package/src/assets/exportProcessing.svg +28 -28
  33. package/src/assets/exportSuccess.svg +34 -34
  34. package/src/assets/fixed-left-active.svg +11 -11
  35. package/src/assets/fixed-left.svg +15 -15
  36. package/src/assets/fixed-right-active.svg +11 -11
  37. package/src/assets/fixed-right.svg +15 -15
  38. package/src/assets/guanbi.svg +15 -15
  39. package/src/assets/icon-quanping.svg +15 -15
  40. package/src/assets/icon-shezhi.svg +17 -17
  41. package/src/assets/label_icon_bottom.svg +25 -25
  42. package/src/assets/list-no-img.svg +21 -21
  43. package/src/assets/morentouxiang-32.svg +23 -23
  44. package/src/assets/scanning.svg +24 -24
  45. package/src/assets/upExport.svg +22 -22
  46. package/src/common/ENUM.ts +41 -41
  47. package/src/components/Business/AddSelectBusiness/index.md +398 -398
  48. package/src/components/Business/AddSelectBusiness/index.tsx +1116 -1116
  49. package/src/components/Business/BsLayouts/Components/AllFunc/drawContent.tsx +112 -112
  50. package/src/components/Business/BsLayouts/Components/AllFunc/index.less +153 -153
  51. package/src/components/Business/BsLayouts/Components/AllFunc/index.tsx +70 -70
  52. package/src/components/Business/BsLayouts/Components/ChooseStore/index.tsx +193 -193
  53. package/src/components/Business/BsLayouts/Components/ChooseStore/services.ts +10 -10
  54. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.less +90 -90
  55. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.tsx +37 -37
  56. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.tsx +242 -242
  57. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.tsx +384 -384
  58. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.tsx +285 -285
  59. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.tsx +74 -74
  60. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/drawContent.less +170 -170
  61. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.less +64 -64
  62. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.tsx +153 -153
  63. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.less +72 -72
  64. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.tsx +163 -163
  65. package/src/components/Business/BsLayouts/Components/RightContent/LoginModal.tsx +85 -85
  66. package/src/components/Business/BsLayouts/Components/RightContent/home.less +218 -218
  67. package/src/components/Business/BsLayouts/Components/RightContent/i18n.ts +8 -8
  68. package/src/components/Business/BsLayouts/Components/RightContent/index.tsx +172 -172
  69. package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +160 -160
  70. package/src/components/Business/BsLayouts/Components/SearchFunc/index.tsx +75 -75
  71. package/src/components/Business/BsLayouts/index.less +79 -79
  72. package/src/components/Business/BsLayouts/index.tsx +1606 -1606
  73. package/src/components/Business/BsLayouts/service.ts +10 -10
  74. package/src/components/Business/BsLayouts/utils.tsx +205 -205
  75. package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +566 -566
  76. package/src/components/Business/BsSulaQueryTable/bssulaquerytable.less +5 -5
  77. package/src/components/Business/BsSulaQueryTable/index.less +227 -227
  78. package/src/components/Business/BsSulaQueryTable/index.tsx +765 -772
  79. package/src/components/Business/BsSulaQueryTable/setting.tsx +888 -888
  80. package/src/components/Business/BsSulaQueryTable/utils.less +65 -65
  81. package/src/components/Business/BsSulaQueryTable/utils.tsx +709 -709
  82. package/src/components/Business/CommodityEntry/index.md +84 -84
  83. package/src/components/Business/CommodityEntry/index.tsx +82 -82
  84. package/src/components/Business/CommonAlert/index.tsx +23 -23
  85. package/src/components/Business/CommonGuideWrapper/index.less +121 -121
  86. package/src/components/Business/CommonGuideWrapper/index.md +39 -39
  87. package/src/components/Business/CommonGuideWrapper/index.tsx +94 -94
  88. package/src/components/Business/DetailPageWrapper/index.less +87 -87
  89. package/src/components/Business/DetailPageWrapper/index.tsx +327 -327
  90. package/src/components/Business/DetailPageWrapper/utils.tsx +166 -166
  91. package/src/components/Business/HomePageWrapper/index.less +33 -33
  92. package/src/components/Business/HomePageWrapper/index.md +45 -45
  93. package/src/components/Business/HomePageWrapper/index.tsx +162 -162
  94. package/src/components/Business/JsonQueryTable/components/FieldsModifyModal.tsx +823 -823
  95. package/src/components/Business/JsonQueryTable/components/FieldsSettingsTable.tsx +205 -205
  96. package/src/components/Business/JsonQueryTable/components/Formula.tsx +205 -205
  97. package/src/components/Business/JsonQueryTable/components/MaintainOptions.tsx +127 -127
  98. package/src/components/Business/JsonQueryTable/configButton/index.js +20 -20
  99. package/src/components/Business/JsonQueryTable/configTree/component/compactArrayView.js +25 -25
  100. package/src/components/Business/JsonQueryTable/configTree/component/compactObjectView.js +30 -30
  101. package/src/components/Business/JsonQueryTable/configTree/index.js +82 -82
  102. package/src/components/Business/JsonQueryTable/configTree/index.less +44 -44
  103. package/src/components/Business/JsonQueryTable/configTree/parser/highlight.js +57 -57
  104. package/src/components/Business/JsonQueryTable/configTree/parser/index.js +124 -124
  105. package/src/components/Business/JsonQueryTable/configTree/render/iconRender.js +29 -29
  106. package/src/components/Business/JsonQueryTable/configTree/render/nameRender.js +22 -22
  107. package/src/components/Business/JsonQueryTable/configTree/treeNode.js +116 -116
  108. package/src/components/Business/JsonQueryTable/drawer/index.tsx +12 -12
  109. package/src/components/Business/JsonQueryTable/function.ts +62 -62
  110. package/src/components/Business/JsonQueryTable/index.less +16 -16
  111. package/src/components/Business/JsonQueryTable/index.md +328 -328
  112. package/src/components/Business/JsonQueryTable/index.tsx +534 -534
  113. package/src/components/Business/JsonQueryTable/jsonEditor/index.js +346 -346
  114. package/src/components/Business/JsonQueryTable/jsonEditor/index.less +22 -22
  115. package/src/components/Business/JsonQueryTable/jsonEditor/lint/basicType.js +147 -147
  116. package/src/components/Business/JsonQueryTable/jsonEditor/lint/index.js +389 -389
  117. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/actions.js +118 -118
  118. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/dependency.js +22 -22
  119. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/index.js +21 -21
  120. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/request.js +65 -65
  121. package/src/components/Business/JsonQueryTable/static.ts +450 -450
  122. package/src/components/Business/SearchSelect/BusinessUtils.tsx +2162 -2162
  123. package/src/components/Business/SearchSelect/common.ts +134 -134
  124. package/src/components/Business/SearchSelect/index.md +1512 -1512
  125. package/src/components/Business/SearchSelect/index.tsx +55 -55
  126. package/src/components/Business/SearchSelect/utils.ts +125 -125
  127. package/src/components/Business/StateFlow/index.less +130 -130
  128. package/src/components/Business/StateFlow/index.md +60 -60
  129. package/src/components/Business/StateFlow/index.tsx +29 -29
  130. package/src/components/Business/TreeSearchSelect/index.md +211 -211
  131. package/src/components/Business/TreeSearchSelect/index.tsx +33 -33
  132. package/src/components/Business/TreeSearchSelect/utils.ts +104 -104
  133. package/src/components/Business/columnSettingTable/columnSetting.tsx +816 -816
  134. package/src/components/Business/columnSettingTable/index.less +253 -253
  135. package/src/components/Business/columnSettingTable/index.md +357 -357
  136. package/src/components/Business/columnSettingTable/index.tsx +225 -226
  137. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +232 -233
  138. package/src/components/Business/columnSettingTable/utils.tsx +87 -87
  139. package/src/components/Business/moreTreeTable/FixedScrollBar.tsx +87 -87
  140. package/src/components/Business/moreTreeTable/hooks/useSticky.ts +21 -21
  141. package/src/components/Business/moreTreeTable/index.less +99 -99
  142. package/src/components/Business/moreTreeTable/index.md +448 -448
  143. package/src/components/Business/moreTreeTable/index.tsx +387 -387
  144. package/src/components/Business/moreTreeTable/utils.ts +126 -126
  145. package/src/components/Functional/AccessWrapper/index.tsx +33 -33
  146. package/src/components/Functional/AddSelect/helps.ts +81 -81
  147. package/src/components/Functional/AddSelect/index.less +367 -367
  148. package/src/components/Functional/AddSelect/index.md +155 -155
  149. package/src/components/Functional/AddSelect/index.tsx +1064 -1065
  150. package/src/components/Functional/AuthButton/index.tsx +15 -15
  151. package/src/components/Functional/BillEntry/index.less +371 -371
  152. package/src/components/Functional/BillEntry/index.md +39 -39
  153. package/src/components/Functional/BillEntry/index.tsx +771 -772
  154. package/src/components/Functional/BsAntdSula/BsCascader/index.md +62 -62
  155. package/src/components/Functional/BsAntdSula/BsCascader/index.tsx +178 -178
  156. package/src/components/Functional/BsAntdSula/index.ts +2 -2
  157. package/src/components/Functional/DataImport/index.less +63 -63
  158. package/src/components/Functional/DataImport/index.md +44 -44
  159. package/src/components/Functional/DataImport/index.tsx +783 -783
  160. package/src/components/Functional/DataValidation/index.less +63 -63
  161. package/src/components/Functional/DataValidation/index.md +52 -52
  162. package/src/components/Functional/DataValidation/index.tsx +788 -788
  163. package/src/components/Functional/EllipsisTooltip/index.d.ts +5 -5
  164. package/src/components/Functional/EllipsisTooltip/index.js +36 -36
  165. package/src/components/Functional/EllipsisTooltip/index.md +30 -30
  166. package/src/components/Functional/ExportFunctions/ExportIcon/index.md +37 -37
  167. package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +65 -65
  168. package/src/components/Functional/QueryMutipleInput/index.less +37 -37
  169. package/src/components/Functional/QueryMutipleInput/index.md +33 -33
  170. package/src/components/Functional/QueryMutipleInput/index.tsx +129 -129
  171. package/src/components/Functional/SearchSelect/index.less +121 -121
  172. package/src/components/Functional/SearchSelect/index.md +141 -141
  173. package/src/components/Functional/SearchSelect/index.tsx +1041 -1041
  174. package/src/components/Functional/SearchSelect/utils.ts +3 -3
  175. package/src/components/Functional/TreeSearchSelect/index.md +47 -47
  176. package/src/components/Functional/TreeSearchSelect/index.tsx +224 -224
  177. package/src/components/Solution/RuleComponent/Formula.tsx +335 -335
  178. package/src/components/Solution/RuleComponent/InnerSelect.tsx +62 -62
  179. package/src/components/Solution/RuleComponent/RenderCompItem.tsx +670 -670
  180. package/src/components/Solution/RuleComponent/index.d.ts +29 -29
  181. package/src/components/Solution/RuleComponent/index.js +1601 -1601
  182. package/src/components/Solution/RuleComponent/index.less +247 -247
  183. package/src/components/Solution/RuleComponent/renderSpecificAction.js +99 -99
  184. package/src/components/Solution/RuleComponent/ruleFiled.js +2293 -2293
  185. package/src/components/Solution/RuleComponent/services.ts +13 -13
  186. package/src/components/Solution/RuleComponent/util.js +143 -143
  187. package/src/components/Solution/RuleSetter/RuleInstance.tsx +6 -6
  188. package/src/components/Solution/RuleSetter/baseRule.tsx +394 -394
  189. package/src/components/Solution/RuleSetter/function.ts +437 -437
  190. package/src/components/Solution/RuleSetter/index.less +221 -221
  191. package/src/components/Solution/RuleSetter/index.tsx +208 -208
  192. package/src/components/Solution/RuleSetter/service.js +276 -276
  193. package/src/index.ts +41 -41
  194. package/src/plugin/TableColumnSetting/index.less +247 -247
  195. package/src/plugin/TableColumnSetting/index.md +50 -50
  196. package/src/plugin/TableColumnSetting/index.tsx +725 -725
  197. package/src/plugin/TableColumnSetting/utils.ts +19 -19
  198. package/src/styles/bsDefault.less +1933 -1933
  199. package/src/utils/CheckOneUser/index.md +39 -39
  200. package/src/utils/CheckOneUser/index.ts +51 -51
  201. package/src/utils/CustomLoginInfo.ts +55 -55
  202. package/src/utils/LocalstorageUtils.ts +134 -134
  203. package/src/utils/TableUtils.less +51 -51
  204. package/src/utils/TableUtils.tsx +691 -691
  205. package/src/utils/auth.ts +38 -38
  206. package/src/utils/businessUtils.ts +434 -434
  207. package/src/utils/checkUtils.ts +39 -39
  208. package/src/utils/constant.ts +38 -38
  209. package/src/utils/enumConfig.ts +17 -17
  210. package/src/utils/getFormMode.js +12 -12
  211. package/src/utils/index.ts +19 -19
  212. package/src/utils/request.ts +53 -53
  213. package/src/utils/requestUtils.ts +193 -193
  214. package/src/utils/serialize.js +7 -7
  215. package/src/utils/utils.ts +245 -238
  216. package/src/utils/xlsxUtil.tsx +145 -145
  217. package/tsconfig.json +29 -29
  218. package/typings.d.ts +4 -4
  219. package/.yarnclean +0 -45
@@ -1,709 +1,709 @@
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 { getMenuAuthDataKey } from '@/utils/LocalstorageUtils';
30
- import noImg from '../../../assets/list-no-img.svg';
31
- import qs from 'qs';
32
- import { shouldUseAuth } from '@/utils';
33
-
34
- export const handleStatusBadge = (text: any, color: any) => {
35
- return (
36
- <Badge
37
- style={{
38
- width: '150px',
39
- display: 'inline-block',
40
- textOverflow: 'ellipsis',
41
- overflow: 'hidden',
42
- whiteSpace: 'nowrap',
43
- }}
44
- text={text}
45
- color={color}
46
- ></Badge>
47
- );
48
- };
49
-
50
- export const HandleTotalCount = (totalParams: any) => {
51
- const { total = {}, totalLeft, totalRight } = totalParams;
52
- return (
53
- <div className="total_warp">
54
- <div className="total_warp_left">
55
- {totalLeft.map((d: any) => (
56
- <div>
57
- <span className="total_warp_num">{total[d.value] || 0}</span>
58
- <span className="total_warp_title">{d.key}</span>
59
- </div>
60
- ))}
61
- </div>
62
- <div className="total_warp_right">
63
- {totalRight.map((d: any) => (
64
- <div>
65
- <span className="total_warp_num">{total[d.value] || 0}</span>
66
- <span className="total_warp_title">{d.key}</span>
67
- </div>
68
- ))}
69
- </div>
70
- </div>
71
- );
72
- };
73
-
74
- export const updateGuanDate = (requestParams: any, dateKeyParams: any = {}) => {
75
- return {
76
- type: 'modalForm',
77
- width: 800,
78
- props: {
79
- maskClosable: false,
80
- },
81
- title: '修改单据日期',
82
- mode: 'create', // 新建/编辑/查看
83
- initialValues: (ctx: any) => {
84
- if (!ctx.record) return;
85
- return {
86
- ...ctx.record,
87
- date: dateKeyParams.initDate
88
- ? ctx.record[dateKeyParams.initDate]
89
- : ctx.record.orderDate,
90
- };
91
- },
92
- fields: [
93
- {
94
- name: dateKeyParams.outDate || `date`,
95
- label: '单据日期',
96
- field: {
97
- type: 'datepicker',
98
- props: {
99
- autoSize: true,
100
- placeholder: '请选择',
101
- disabledDate: (currentDate: any) =>
102
- currentDate.valueOf() <
103
- moment().subtract(Number(moment().format('D')), 'days'),
104
- style: { width: '100%' },
105
- },
106
- },
107
- initialValue: moment().utcOffset(8),
108
- rules: [{ required: true, message: '请选择单据日期' }],
109
- },
110
- ],
111
- submitButtonProps: {
112
- children: '确认',
113
- },
114
- backButtonProps: {
115
- children: '取消',
116
- },
117
- submit: requestParams,
118
- };
119
- };
120
-
121
- export const renderZeroInSummary = (value: any) =>
122
- value != '0' ? value / 1000 : '- -';
123
-
124
- export const calculateValidPeriod = (start: any, end: any) => {
125
- return `${moment(end).diff(start, 'days')} 天` || '- -';
126
- };
127
-
128
- // 带有toptile 清提示 并且会换行的
129
- export const handleTextDouble = (
130
- textOne: string | undefined,
131
- textTwo: string | undefined,
132
- ) => {
133
- return (
134
- <>
135
- <div style={{ marginBottom: -8 }}>{textOne}</div>
136
- <div>{textTwo}</div>
137
- </>
138
- );
139
- };
140
-
141
- // 带有toptile 清提示 ...
142
- export const handleTextLineFeed = (
143
- text: string | undefined,
144
- width: number = 130,
145
- ) => {
146
- return (
147
- <Tooltip title={text || '- -'}>
148
- <span
149
- style={{
150
- width: width ? width + 'px' : '130px',
151
- display: 'inline-block',
152
- position: 'relative',
153
- whiteSpace: 'pre-line',
154
- top: '5px',
155
- }}
156
- >
157
- {text || '- -'}
158
- </span>
159
- </Tooltip>
160
- );
161
- };
162
-
163
- // 带有toptile 清提示 ...
164
- export const handleTextOverflow = (
165
- text: string | undefined,
166
- width: number = 130,
167
- ) => {
168
- return (
169
- <Tooltip title={text || '- -'}>
170
- <span
171
- style={{
172
- width: width ? width + 'px' : '130px',
173
- display: 'inline-block',
174
- textOverflow: 'ellipsis',
175
- overflow: 'hidden',
176
- whiteSpace: 'nowrap',
177
- position: 'relative',
178
- top: '5px',
179
- }}
180
- >
181
- {text || '- -'}
182
- </span>
183
- </Tooltip>
184
- );
185
- };
186
-
187
- // 处理时间 带时分秒
188
-
189
- export const handleTooltip = (text: any, timeTrue?: boolean) => {
190
- return (
191
- <Tooltip title={timeTrue ? handleCommonTimeRender(text) : text}>
192
- {timeTrue ? handleCommonTimeRender(text) : text}
193
- </Tooltip>
194
- );
195
- };
196
-
197
- // 处理时间 不带时分秒
198
- export const handleTooltipHours = (text: any, timeTrue?: boolean) => {
199
- return (
200
- <Tooltip title={timeTrue ? handleCommonTimeRenderHours(text) : text}>
201
- {timeTrue ? handleCommonTimeRenderHours(text) : text}
202
- </Tooltip>
203
- );
204
- };
205
-
206
- /*
207
- 列表展示缩略图片
208
- url 图片 url
209
- {
210
- width: 图片宽度
211
- height: 图片高度
212
- }
213
- */
214
- type tableColumnsImageType = {
215
- width?: number | string;
216
- height?: number | string;
217
- [key: string]: any;
218
- };
219
-
220
- export const tableColumnsImage = (
221
- url?: string,
222
- paramsObj?: tableColumnsImageType,
223
- ) => {
224
- // 测试使用 测试类型缩小 随时可删除 start
225
- const imgHtml = document.querySelector('.ant-image-mask-info')!;
226
- if (imgHtml) {
227
- let str = imgHtml?.innerHTML;
228
- str = str?.replace('预览', '');
229
- imgHtml.innerHTML = str;
230
- }
231
- // 测试使用 测试类型缩小 end
232
-
233
- return (
234
- <>
235
- {url ? (
236
- <div className={`clomnsImg`}>
237
- <Image src={url} width="28px" height="28px" {...paramsObj}></Image>
238
- </div>
239
- ) : (
240
- <div className={`clomnsImg2`}>
241
- <img {...paramsObj} src={noImg}></img>
242
- </div>
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'}>职位: {props.position || 'XXXXX'}</p>
321
- </div>
322
- </Card>
323
- );
324
- };
325
-
326
- export function handleCommonTimeRenderHours(text: any, format?: any) {
327
- const formatType = format || 'YYYY-MM-DD';
328
- return (text && moment(text).format(formatType)) || '- -';
329
- }
330
-
331
- export function handleCommonTimeRender(text: any, format?: any) {
332
- const formatType = format || 'YYYY-MM-DD HH:mm:ss';
333
- return (text && moment(text).format(formatType)) || '- -';
334
- }
335
-
336
- interface ColumnsEditInterfave {
337
- text?: string;
338
- record?: any;
339
- type?: string;
340
- reqName: string;
341
- successMessage?: string;
342
- urlPathId?: boolean;
343
- disabled: boolean;
344
- requestProps: {
345
- url: string;
346
- converter?: Function;
347
- method?: string;
348
- };
349
- [key: string]: any;
350
- }
351
- /*
352
- text 当前项
353
- record 当前行
354
- table sula table 的实例
355
- type 默认 input 可选 number 输入框类型
356
- inpProps 输入框透传 props
357
- requestProps {} bssula 的 request
358
- reqName 修改数据传给后端的key
359
- urlPathId 默认 true 会在 requestProps.url 上面 拼接 /:id
360
- successMessage 默认提示操作成功 可传入 string
361
- disabled 什么时候禁用 boolean 类型
362
- */
363
- export const ColumnsEdit = (props: ColumnsEditInterfave) => {
364
- const {
365
- text = '',
366
- record,
367
- table,
368
- type = 'input',
369
- inpProps = {},
370
- requestProps = {
371
- url: '',
372
- },
373
- reqName,
374
- urlPathId = true,
375
- successMessage = '操作成功',
376
- disabled,
377
- }: ColumnsEditInterfave = props;
378
- const [visible, setvisible] = useState(false);
379
- const [inputValue, setInputValue]: [
380
- inputValue: string | number,
381
- setInputValue: Function,
382
- ] = useState(text);
383
-
384
- const onSubmit = () => {
385
- const url = urlPathId
386
- ? requestProps.url + `/${record.id}`
387
- : requestProps.url;
388
- request({
389
- url: url,
390
- method: requestProps.method || 'patch',
391
- convertParams: () => {
392
- return {
393
- ...record,
394
- [reqName]: inputValue,
395
- };
396
- },
397
- successMessage,
398
- converter(ctx: any) {
399
- if (
400
- requestProps.converter &&
401
- typeof requestProps.converter === 'function'
402
- ) {
403
- requestProps.converter(ctx);
404
- return;
405
- }
406
- setvisible(false);
407
- table.resetTable();
408
- },
409
- });
410
- };
411
-
412
- const menu = (
413
- <Menu>
414
- <Menu.Item>
415
- {type === 'input' && (
416
- <Input
417
- disabled={disabled}
418
- onChange={(e: any) => {
419
- const v = e.target.value;
420
- setInputValue(v);
421
- }}
422
- style={{ width: 170 }}
423
- value={inputValue}
424
- {...inpProps}
425
- ></Input>
426
- )}
427
- {type === 'number' && (
428
- <InputNumber
429
- disabled={disabled}
430
- onBlur={(e: any) => {
431
- const v = parseFloat(e.target.value);
432
- if (!isNaN(v)) {
433
- setInputValue(v);
434
- }
435
- }}
436
- style={{ width: 170 }}
437
- value={inputValue}
438
- {...inpProps}
439
- ></InputNumber>
440
- )}
441
- </Menu.Item>
442
- <Menu.Divider />
443
- <Menu.Item>
444
- <div style={{ textAlign: 'right' }}>
445
- <Space>
446
- <Button
447
- onClick={() => {
448
- setvisible(false);
449
- }}
450
- >
451
- 取消
452
- </Button>
453
- <Button
454
- type="primary"
455
- disabled={disabled}
456
- onClick={() => onSubmit()}
457
- >
458
- 确定
459
- </Button>
460
- </Space>
461
- </div>
462
- </Menu.Item>
463
- </Menu>
464
- );
465
- return (
466
- <div key={record.id}>
467
- <Space>
468
- {text}
469
- <Dropdown
470
- visible={visible}
471
- overlay={menu}
472
- trigger={['click']}
473
- placement="bottomLeft"
474
- >
475
- <EditOutlined
476
- style={{ color: '#B0B4B7' }}
477
- onClick={() => {
478
- setvisible(!visible);
479
- }}
480
- className="cur"
481
- />
482
- </Dropdown>
483
- </Space>
484
- </div>
485
- );
486
- };
487
-
488
- // 带有toptile 清提示 并且会换行的
489
- export const handleTextDoubleOrId = (
490
- textOne: string | undefined,
491
- textTwo: string | undefined,
492
- ) => {
493
- return (
494
- <>
495
- <div style={{ color: '#000', marginBottom: -8 }}>{textOne}</div>
496
- <span style={{ color: '#848484' }}>ID : {textTwo}</span>
497
- </>
498
- );
499
- };
500
-
501
- export const textIcon = (type: string | number, text?: string) => {
502
- if (!type) return;
503
- if (type == 1) {
504
- return (
505
- <a className="cloumnsIconA">
506
- <EyeOutlined />
507
- <span>详情</span>
508
- </a>
509
- );
510
- }
511
- if (type == 2) {
512
- return (
513
- <a className="cloumnsIconA">
514
- <EyeOutlined />
515
- <span>查看</span>
516
- </a>
517
- );
518
- }
519
- if (type == 3) {
520
- return (
521
- <a className="cloumnsIconA">
522
- <DeleteOutlined />
523
- <span>删除</span>
524
- </a>
525
- );
526
- }
527
- if (type == 4) {
528
- return (
529
- <a className="cloumnsIconA">
530
- <EditOutlined />
531
- <span>编辑</span>
532
- </a>
533
- );
534
- }
535
- if (type == 5) {
536
- return (
537
- <a className="cloumnsIconA">
538
- <CopyOutlined />
539
- <span>复制</span>
540
- </a>
541
- );
542
- }
543
- if (type == 6) {
544
- return (
545
- <a className="cloumnsIconA">
546
- <CloseSquareOutlined />
547
- <span>作废</span>
548
- </a>
549
- );
550
- }
551
- if (type == 7) {
552
- return (
553
- <a className="cloumnsIconA">
554
- <WarningOutlined />
555
- <span>终止</span>
556
- </a>
557
- );
558
- }
559
- if (type == 8) {
560
- return (
561
- <a className="cloumnsIconA">
562
- <SendOutlined />
563
- <span>{text}</span>
564
- </a>
565
- );
566
- }
567
- };
568
-
569
- // 四舍五入两位小数,没有小数点就显示整数
570
- export const renderFixed2 = (text: any) => text;
571
-
572
- //设置queryTable默认列宽
573
- export const getItemDefaultWidth = (item: any) => {
574
- let defaultWidth = 200;
575
- if (Array.isArray(item.key) || Array.isArray(item.dataIndex))
576
- return defaultWidth;
577
- let lowerCaseKey = (item.key || item.dataIndex)?.toLowerCase();
578
- if (!lowerCaseKey) return defaultWidth;
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('*multiInput') >= 0) {
656
- let name = '',
657
- value = element['value'];
658
- if (value.indexOf(',') >= 0) {
659
- name = `qp-${element['name']}-in`;
660
- } else {
661
- name = `qp-${element['name']}-like`;
662
- }
663
- params[name] = value;
664
- delete params[key];
665
- } else if (element && key.indexOf('*') >= 0) {
666
- const dataParams = key.split('*');
667
- dataParams.forEach((value, index) => {
668
- params[value] = element[index].format('YYYY-MM-DD HH:mm:ss');
669
- });
670
- delete params[key];
671
- } else if (element && key.indexOf('_likeIn_') >= 0) {
672
- const dataParams = key.split('_likeIn_');
673
- if (element.indexOf(',') >= 0) {
674
- params[`qp-${dataParams[0]}-in`] = element.split(',').join(',');
675
- params[`qp-${dataParams[0]}-like`] = null;
676
- } else {
677
- params[`qp-${dataParams[0]}-like`] = element;
678
- params[`qp-${dataParams[0]}-in`] = null;
679
- }
680
- delete params[key];
681
- } else if (Array.isArray(element)) {
682
- params[key] = element.join(',');
683
- }
684
- }
685
- }
686
- return flag ? params : qs.stringify(params);
687
- }
688
-
689
- /**
690
- * 根据用户权限检验对应按钮是够显示 !!!!现在先去掉
691
- * @param code 对应权限值
692
- * @returns boolean
693
- */
694
- export const authFn = (code?: any) => {
695
- if (!shouldUseAuth() || !code) return true;
696
- return JSON.parse(localStorage.getItem(getMenuAuthDataKey()) || '[]')?.find(
697
- (d: any) => d === code,
698
- );
699
- };
700
-
701
- // 可以将普通字符串 或者tsx 转换成字符串
702
- export const renderToString = (
703
- render: ReactElement<any, string | JSXElementConstructor<any>> | string,
704
- ) => {
705
- return render;
706
- // return typeof render === 'string'
707
- // ? render
708
- // : ReactDOMServer.renderToString(render);
709
- };
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 { getMenuAuthDataKey } from '@/utils/LocalstorageUtils';
30
+ import noImg from '../../../assets/list-no-img.svg';
31
+ import qs from 'qs';
32
+ import { shouldUseAuth } from '@/utils';
33
+
34
+ export const handleStatusBadge = (text: any, color: any) => {
35
+ return (
36
+ <Badge
37
+ style={{
38
+ width: '150px',
39
+ display: 'inline-block',
40
+ textOverflow: 'ellipsis',
41
+ overflow: 'hidden',
42
+ whiteSpace: 'nowrap',
43
+ }}
44
+ text={text}
45
+ color={color}
46
+ ></Badge>
47
+ );
48
+ };
49
+
50
+ export const HandleTotalCount = (totalParams: any) => {
51
+ const { total = {}, totalLeft, totalRight } = totalParams;
52
+ return (
53
+ <div className="total_warp">
54
+ <div className="total_warp_left">
55
+ {totalLeft.map((d: any) => (
56
+ <div>
57
+ <span className="total_warp_num">{total[d.value] || 0}</span>
58
+ <span className="total_warp_title">{d.key}</span>
59
+ </div>
60
+ ))}
61
+ </div>
62
+ <div className="total_warp_right">
63
+ {totalRight.map((d: any) => (
64
+ <div>
65
+ <span className="total_warp_num">{total[d.value] || 0}</span>
66
+ <span className="total_warp_title">{d.key}</span>
67
+ </div>
68
+ ))}
69
+ </div>
70
+ </div>
71
+ );
72
+ };
73
+
74
+ export const updateGuanDate = (requestParams: any, dateKeyParams: any = {}) => {
75
+ return {
76
+ type: 'modalForm',
77
+ width: 800,
78
+ props: {
79
+ maskClosable: false,
80
+ },
81
+ title: '修改单据日期',
82
+ mode: 'create', // 新建/编辑/查看
83
+ initialValues: (ctx: any) => {
84
+ if (!ctx.record) return;
85
+ return {
86
+ ...ctx.record,
87
+ date: dateKeyParams.initDate
88
+ ? ctx.record[dateKeyParams.initDate]
89
+ : ctx.record.orderDate,
90
+ };
91
+ },
92
+ fields: [
93
+ {
94
+ name: dateKeyParams.outDate || `date`,
95
+ label: '单据日期',
96
+ field: {
97
+ type: 'datepicker',
98
+ props: {
99
+ autoSize: true,
100
+ placeholder: '请选择',
101
+ disabledDate: (currentDate: any) =>
102
+ currentDate.valueOf() <
103
+ moment().subtract(Number(moment().format('D')), 'days'),
104
+ style: { width: '100%' },
105
+ },
106
+ },
107
+ initialValue: moment().utcOffset(8),
108
+ rules: [{ required: true, message: '请选择单据日期' }],
109
+ },
110
+ ],
111
+ submitButtonProps: {
112
+ children: '确认',
113
+ },
114
+ backButtonProps: {
115
+ children: '取消',
116
+ },
117
+ submit: requestParams,
118
+ };
119
+ };
120
+
121
+ export const renderZeroInSummary = (value: any) =>
122
+ value != '0' ? value / 1000 : '- -';
123
+
124
+ export const calculateValidPeriod = (start: any, end: any) => {
125
+ return `${moment(end).diff(start, 'days')} 天` || '- -';
126
+ };
127
+
128
+ // 带有toptile 清提示 并且会换行的
129
+ export const handleTextDouble = (
130
+ textOne: string | undefined,
131
+ textTwo: string | undefined,
132
+ ) => {
133
+ return (
134
+ <>
135
+ <div style={{ marginBottom: -8 }}>{textOne}</div>
136
+ <div>{textTwo}</div>
137
+ </>
138
+ );
139
+ };
140
+
141
+ // 带有toptile 清提示 ...
142
+ export const handleTextLineFeed = (
143
+ text: string | undefined,
144
+ width: number = 130,
145
+ ) => {
146
+ return (
147
+ <Tooltip title={text || '- -'}>
148
+ <span
149
+ style={{
150
+ width: width ? width + 'px' : '130px',
151
+ display: 'inline-block',
152
+ position: 'relative',
153
+ whiteSpace: 'pre-line',
154
+ top: '5px',
155
+ }}
156
+ >
157
+ {text || '- -'}
158
+ </span>
159
+ </Tooltip>
160
+ );
161
+ };
162
+
163
+ // 带有toptile 清提示 ...
164
+ export const handleTextOverflow = (
165
+ text: string | undefined,
166
+ width: number = 130,
167
+ ) => {
168
+ return (
169
+ <Tooltip title={text || '- -'}>
170
+ <span
171
+ style={{
172
+ width: width ? width + 'px' : '130px',
173
+ display: 'inline-block',
174
+ textOverflow: 'ellipsis',
175
+ overflow: 'hidden',
176
+ whiteSpace: 'nowrap',
177
+ position: 'relative',
178
+ top: '5px',
179
+ }}
180
+ >
181
+ {text || '- -'}
182
+ </span>
183
+ </Tooltip>
184
+ );
185
+ };
186
+
187
+ // 处理时间 带时分秒
188
+
189
+ export const handleTooltip = (text: any, timeTrue?: boolean) => {
190
+ return (
191
+ <Tooltip title={timeTrue ? handleCommonTimeRender(text) : text}>
192
+ {timeTrue ? handleCommonTimeRender(text) : text}
193
+ </Tooltip>
194
+ );
195
+ };
196
+
197
+ // 处理时间 不带时分秒
198
+ export const handleTooltipHours = (text: any, timeTrue?: boolean) => {
199
+ return (
200
+ <Tooltip title={timeTrue ? handleCommonTimeRenderHours(text) : text}>
201
+ {timeTrue ? handleCommonTimeRenderHours(text) : text}
202
+ </Tooltip>
203
+ );
204
+ };
205
+
206
+ /*
207
+ 列表展示缩略图片
208
+ url 图片 url
209
+ {
210
+ width: 图片宽度
211
+ height: 图片高度
212
+ }
213
+ */
214
+ type tableColumnsImageType = {
215
+ width?: number | string;
216
+ height?: number | string;
217
+ [key: string]: any;
218
+ };
219
+
220
+ export const tableColumnsImage = (
221
+ url?: string,
222
+ paramsObj?: tableColumnsImageType,
223
+ ) => {
224
+ // 测试使用 测试类型缩小 随时可删除 start
225
+ const imgHtml = document.querySelector('.ant-image-mask-info')!;
226
+ if (imgHtml) {
227
+ let str = imgHtml?.innerHTML;
228
+ str = str?.replace('预览', '');
229
+ imgHtml.innerHTML = str;
230
+ }
231
+ // 测试使用 测试类型缩小 end
232
+
233
+ return (
234
+ <>
235
+ {url ? (
236
+ <div className={`clomnsImg`}>
237
+ <Image src={url} width="28px" height="28px" {...paramsObj}></Image>
238
+ </div>
239
+ ) : (
240
+ <div className={`clomnsImg2`}>
241
+ <img {...paramsObj} src={noImg}></img>
242
+ </div>
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'}>职位: {props.position || 'XXXXX'}</p>
321
+ </div>
322
+ </Card>
323
+ );
324
+ };
325
+
326
+ export function handleCommonTimeRenderHours(text: any, format?: any) {
327
+ const formatType = format || 'YYYY-MM-DD';
328
+ return (text && moment(text).format(formatType)) || '- -';
329
+ }
330
+
331
+ export function handleCommonTimeRender(text: any, format?: any) {
332
+ const formatType = format || 'YYYY-MM-DD HH:mm:ss';
333
+ return (text && moment(text).format(formatType)) || '- -';
334
+ }
335
+
336
+ interface ColumnsEditInterfave {
337
+ text?: string;
338
+ record?: any;
339
+ type?: string;
340
+ reqName: string;
341
+ successMessage?: string;
342
+ urlPathId?: boolean;
343
+ disabled: boolean;
344
+ requestProps: {
345
+ url: string;
346
+ converter?: Function;
347
+ method?: string;
348
+ };
349
+ [key: string]: any;
350
+ }
351
+ /*
352
+ text 当前项
353
+ record 当前行
354
+ table sula table 的实例
355
+ type 默认 input 可选 number 输入框类型
356
+ inpProps 输入框透传 props
357
+ requestProps {} bssula 的 request
358
+ reqName 修改数据传给后端的key
359
+ urlPathId 默认 true 会在 requestProps.url 上面 拼接 /:id
360
+ successMessage 默认提示操作成功 可传入 string
361
+ disabled 什么时候禁用 boolean 类型
362
+ */
363
+ export const ColumnsEdit = (props: ColumnsEditInterfave) => {
364
+ const {
365
+ text = '',
366
+ record,
367
+ table,
368
+ type = 'input',
369
+ inpProps = {},
370
+ requestProps = {
371
+ url: '',
372
+ },
373
+ reqName,
374
+ urlPathId = true,
375
+ successMessage = '操作成功',
376
+ disabled,
377
+ }: ColumnsEditInterfave = props;
378
+ const [visible, setvisible] = useState(false);
379
+ const [inputValue, setInputValue]: [
380
+ inputValue: string | number,
381
+ setInputValue: Function,
382
+ ] = useState(text);
383
+
384
+ const onSubmit = () => {
385
+ const url = urlPathId
386
+ ? requestProps.url + `/${record.id}`
387
+ : requestProps.url;
388
+ request({
389
+ url: url,
390
+ method: requestProps.method || 'patch',
391
+ convertParams: () => {
392
+ return {
393
+ ...record,
394
+ [reqName]: inputValue,
395
+ };
396
+ },
397
+ successMessage,
398
+ converter(ctx: any) {
399
+ if (
400
+ requestProps.converter &&
401
+ typeof requestProps.converter === 'function'
402
+ ) {
403
+ requestProps.converter(ctx);
404
+ return;
405
+ }
406
+ setvisible(false);
407
+ table.resetTable();
408
+ },
409
+ });
410
+ };
411
+
412
+ const menu = (
413
+ <Menu>
414
+ <Menu.Item>
415
+ {type === 'input' && (
416
+ <Input
417
+ disabled={disabled}
418
+ onChange={(e: any) => {
419
+ const v = e.target.value;
420
+ setInputValue(v);
421
+ }}
422
+ style={{ width: 170 }}
423
+ value={inputValue}
424
+ {...inpProps}
425
+ ></Input>
426
+ )}
427
+ {type === 'number' && (
428
+ <InputNumber
429
+ disabled={disabled}
430
+ onBlur={(e: any) => {
431
+ const v = parseFloat(e.target.value);
432
+ if (!isNaN(v)) {
433
+ setInputValue(v);
434
+ }
435
+ }}
436
+ style={{ width: 170 }}
437
+ value={inputValue}
438
+ {...inpProps}
439
+ ></InputNumber>
440
+ )}
441
+ </Menu.Item>
442
+ <Menu.Divider />
443
+ <Menu.Item>
444
+ <div style={{ textAlign: 'right' }}>
445
+ <Space>
446
+ <Button
447
+ onClick={() => {
448
+ setvisible(false);
449
+ }}
450
+ >
451
+ 取消
452
+ </Button>
453
+ <Button
454
+ type="primary"
455
+ disabled={disabled}
456
+ onClick={() => onSubmit()}
457
+ >
458
+ 确定
459
+ </Button>
460
+ </Space>
461
+ </div>
462
+ </Menu.Item>
463
+ </Menu>
464
+ );
465
+ return (
466
+ <div key={record.id}>
467
+ <Space>
468
+ {text}
469
+ <Dropdown
470
+ visible={visible}
471
+ overlay={menu}
472
+ trigger={['click']}
473
+ placement="bottomLeft"
474
+ >
475
+ <EditOutlined
476
+ style={{ color: '#B0B4B7' }}
477
+ onClick={() => {
478
+ setvisible(!visible);
479
+ }}
480
+ className="cur"
481
+ />
482
+ </Dropdown>
483
+ </Space>
484
+ </div>
485
+ );
486
+ };
487
+
488
+ // 带有toptile 清提示 并且会换行的
489
+ export const handleTextDoubleOrId = (
490
+ textOne: string | undefined,
491
+ textTwo: string | undefined,
492
+ ) => {
493
+ return (
494
+ <>
495
+ <div style={{ color: '#000', marginBottom: -8 }}>{textOne}</div>
496
+ <span style={{ color: '#848484' }}>ID : {textTwo}</span>
497
+ </>
498
+ );
499
+ };
500
+
501
+ export const textIcon = (type: string | number, text?: string) => {
502
+ if (!type) return;
503
+ if (type == 1) {
504
+ return (
505
+ <a className="cloumnsIconA">
506
+ <EyeOutlined />
507
+ <span>详情</span>
508
+ </a>
509
+ );
510
+ }
511
+ if (type == 2) {
512
+ return (
513
+ <a className="cloumnsIconA">
514
+ <EyeOutlined />
515
+ <span>查看</span>
516
+ </a>
517
+ );
518
+ }
519
+ if (type == 3) {
520
+ return (
521
+ <a className="cloumnsIconA">
522
+ <DeleteOutlined />
523
+ <span>删除</span>
524
+ </a>
525
+ );
526
+ }
527
+ if (type == 4) {
528
+ return (
529
+ <a className="cloumnsIconA">
530
+ <EditOutlined />
531
+ <span>编辑</span>
532
+ </a>
533
+ );
534
+ }
535
+ if (type == 5) {
536
+ return (
537
+ <a className="cloumnsIconA">
538
+ <CopyOutlined />
539
+ <span>复制</span>
540
+ </a>
541
+ );
542
+ }
543
+ if (type == 6) {
544
+ return (
545
+ <a className="cloumnsIconA">
546
+ <CloseSquareOutlined />
547
+ <span>作废</span>
548
+ </a>
549
+ );
550
+ }
551
+ if (type == 7) {
552
+ return (
553
+ <a className="cloumnsIconA">
554
+ <WarningOutlined />
555
+ <span>终止</span>
556
+ </a>
557
+ );
558
+ }
559
+ if (type == 8) {
560
+ return (
561
+ <a className="cloumnsIconA">
562
+ <SendOutlined />
563
+ <span>{text}</span>
564
+ </a>
565
+ );
566
+ }
567
+ };
568
+
569
+ // 四舍五入两位小数,没有小数点就显示整数
570
+ export const renderFixed2 = (text: any) => text;
571
+
572
+ //设置queryTable默认列宽
573
+ export const getItemDefaultWidth = (item: any) => {
574
+ let defaultWidth = 200;
575
+ if (Array.isArray(item.key) || Array.isArray(item.dataIndex))
576
+ return defaultWidth;
577
+ let lowerCaseKey = (item.key || item.dataIndex)?.toLowerCase();
578
+ if (!lowerCaseKey) return defaultWidth;
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('*multiInput') >= 0) {
656
+ let name = '',
657
+ value = element['value'];
658
+ if (value.indexOf(',') >= 0) {
659
+ name = `qp-${element['name']}-in`;
660
+ } else {
661
+ name = `qp-${element['name']}-like`;
662
+ }
663
+ params[name] = value;
664
+ delete params[key];
665
+ } else if (element && key.indexOf('*') >= 0) {
666
+ const dataParams = key.split('*');
667
+ dataParams.forEach((value, index) => {
668
+ params[value] = element[index].format('YYYY-MM-DD HH:mm:ss');
669
+ });
670
+ delete params[key];
671
+ } else if (element && key.indexOf('_likeIn_') >= 0) {
672
+ const dataParams = key.split('_likeIn_');
673
+ if (element.indexOf(',') >= 0) {
674
+ params[`qp-${dataParams[0]}-in`] = element.split(',').join(',');
675
+ params[`qp-${dataParams[0]}-like`] = null;
676
+ } else {
677
+ params[`qp-${dataParams[0]}-like`] = element;
678
+ params[`qp-${dataParams[0]}-in`] = null;
679
+ }
680
+ delete params[key];
681
+ } else if (Array.isArray(element)) {
682
+ params[key] = element.join(',');
683
+ }
684
+ }
685
+ }
686
+ return flag ? params : qs.stringify(params);
687
+ }
688
+
689
+ /**
690
+ * 根据用户权限检验对应按钮是够显示 !!!!现在先去掉
691
+ * @param code 对应权限值
692
+ * @returns boolean
693
+ */
694
+ export const authFn = (code?: any) => {
695
+ if (!shouldUseAuth() || !code) return true;
696
+ return JSON.parse(localStorage.getItem(getMenuAuthDataKey()) || '[]')?.find(
697
+ (d: any) => d === code,
698
+ );
699
+ };
700
+
701
+ // 可以将普通字符串 或者tsx 转换成字符串
702
+ export const renderToString = (
703
+ render: ReactElement<any, string | JSXElementConstructor<any>> | string,
704
+ ) => {
705
+ return render;
706
+ // return typeof render === 'string'
707
+ // ? render
708
+ // : ReactDOMServer.renderToString(render);
709
+ };