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