cloud-b2b 1.1.59 → 1.1.60

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 (314) hide show
  1. package/es/Area/Area.js +141 -0
  2. package/es/Card/Card.js +19 -0
  3. package/es/CodeInput/CodeInput.js +123 -0
  4. package/es/Control/Control.js +444 -0
  5. package/es/Control/event.js +43 -0
  6. package/es/Enhance/Dialogs.js +52 -0
  7. package/es/Enhance/Loading.js +131 -0
  8. package/{src → es}/Enhance/index.js +6 -8
  9. package/es/Header/Header.js +162 -0
  10. package/es/Header/Vertical.js +106 -0
  11. package/es/ImageView/ImageView.js +100 -0
  12. package/es/Indent/Indent.js +19 -0
  13. package/es/InpurCascader/InputCascader.js +117 -0
  14. package/es/InputEditor/InputEditor.js +173 -0
  15. package/es/InputSearch/InputSearch.js +266 -0
  16. package/es/InputSelect/InputSelect.js +160 -0
  17. package/es/InputTreeSelect/InputTreeSelect.js +121 -0
  18. package/es/InputWriting/InputWriting.js +85 -0
  19. package/es/Layout/Layout.js +201 -0
  20. package/es/LayoutLink/LayoutLink.js +73 -0
  21. package/es/Link/Link.js +85 -0
  22. package/es/Loading/Loading.js +13 -0
  23. package/es/Loading2/Loading2.js +9 -0
  24. package/es/ModalWithDrag/ModalWithDrag.js +29 -0
  25. package/{src → es}/ModalWithDrag/drag.js +116 -128
  26. package/es/NumberInput/NumberInput.js +200 -0
  27. package/es/Search/Search.js +497 -0
  28. package/es/Search2/Search.js +597 -0
  29. package/es/Sidebar/Sidebar.js +144 -0
  30. package/es/Sidebar2/Sidebar.js +165 -0
  31. package/es/SuperForm/SuperForm.js +598 -0
  32. package/es/SuperForm2/SuperForm.js +687 -0
  33. package/es/SuperIcon/SuperIcon.js +27 -0
  34. package/es/SuperPagination/SuperPagination.js +109 -0
  35. package/es/SuperTab/SuperTab.js +107 -0
  36. package/es/SuperTab2/SuperTab2.js +145 -0
  37. package/es/SuperTable/DragSortRow.js +97 -0
  38. package/es/SuperTable/FilterDropDown.js +164 -0
  39. package/es/SuperTable/SuperTable.js +808 -0
  40. package/es/SuperTable/fixed.js +34 -0
  41. package/es/SuperTable2/SuperTable2.js +926 -0
  42. package/es/SuperTable2/SuperTableCell.js +234 -0
  43. package/es/SuperTable3/FilterDropDown.js +164 -0
  44. package/es/SuperTable3/SuperTable.js +665 -0
  45. package/es/SuperTable3/fixed.js +34 -0
  46. package/es/SuperToolbar/SuperToolbar.js +195 -0
  47. package/es/SuperUpload/SuperUpload.js +356 -0
  48. package/es/Title/Title.js +33 -0
  49. package/es/Viewer/ImageViews.js +258 -0
  50. package/es/Viewer/Viewer.js +122 -0
  51. package/es/WingBlank/WingBlank.js +16 -0
  52. package/es/helper.js +240 -0
  53. package/{src → es}/history.js +6 -6
  54. package/es/index.js +38 -0
  55. package/es/variables.js +6 -0
  56. package/lib/Area/Area.js +149 -0
  57. package/lib/Area/package.json +6 -0
  58. package/lib/Card/Card.js +27 -0
  59. package/lib/Card/package.json +6 -0
  60. package/lib/CodeInput/CodeInput.js +131 -0
  61. package/lib/CodeInput/package.json +6 -0
  62. package/lib/Control/Control.js +450 -0
  63. package/lib/Control/event.js +51 -0
  64. package/lib/Control/package.json +6 -0
  65. package/lib/Enhance/Dialogs.js +60 -0
  66. package/lib/Enhance/Loading.js +138 -0
  67. package/lib/Enhance/index.js +25 -0
  68. package/lib/Enhance/package.json +6 -0
  69. package/lib/Header/Header.js +169 -0
  70. package/lib/Header/Header.less +95 -0
  71. package/lib/Header/Vertical.js +114 -0
  72. package/lib/Header/Vertical.less +60 -0
  73. package/lib/Header/package.json +6 -0
  74. package/lib/ImageView/ImageView.js +108 -0
  75. package/lib/ImageView/ImageView.less +14 -0
  76. package/lib/ImageView/package.json +6 -0
  77. package/lib/Indent/Indent.js +27 -0
  78. package/lib/Indent/package.json +6 -0
  79. package/lib/InpurCascader/InputCascader.js +124 -0
  80. package/lib/InpurCascader/package.json +6 -0
  81. package/lib/InputEditor/InputEditor.js +181 -0
  82. package/lib/InputEditor/inputEditor.less +8 -0
  83. package/lib/InputEditor/package.json +6 -0
  84. package/lib/InputSearch/InputSearch.js +274 -0
  85. package/lib/InputSearch/package.json +6 -0
  86. package/lib/InputSelect/InputSelect.js +168 -0
  87. package/lib/InputSelect/package.json +6 -0
  88. package/lib/InputTreeSelect/InputTreeSelect.js +128 -0
  89. package/lib/InputTreeSelect/package.json +6 -0
  90. package/lib/InputWriting/InputWriting.js +93 -0
  91. package/lib/InputWriting/package.json +6 -0
  92. package/lib/Layout/Layout.js +209 -0
  93. package/lib/Layout/Layout.less +28 -0
  94. package/lib/Layout/package.json +6 -0
  95. package/lib/LayoutLink/LayoutLink.js +86 -0
  96. package/lib/LayoutLink/LayoutLink.less +53 -0
  97. package/lib/LayoutLink/package.json +6 -0
  98. package/lib/Link/Link.js +93 -0
  99. package/lib/Link/package.json +6 -0
  100. package/lib/Loading/Loading.js +21 -0
  101. package/lib/Loading/Loading.less +13 -0
  102. package/lib/Loading/package.json +6 -0
  103. package/lib/Loading2/Loading2.js +17 -0
  104. package/lib/Loading2/Loading2.less +19 -0
  105. package/lib/Loading2/package.json +6 -0
  106. package/lib/ModalWithDrag/ModalWithDrag.js +37 -0
  107. package/lib/ModalWithDrag/ModalWithDrag.less +6 -0
  108. package/lib/ModalWithDrag/drag.js +124 -0
  109. package/lib/ModalWithDrag/package.json +6 -0
  110. package/lib/NumberInput/NumberInput.js +208 -0
  111. package/lib/NumberInput/package.json +6 -0
  112. package/lib/Search/Search.js +510 -0
  113. package/lib/Search/Search.less +63 -0
  114. package/lib/Search/package.json +6 -0
  115. package/lib/Search2/Search.js +609 -0
  116. package/lib/Search2/Search.less +65 -0
  117. package/lib/Search2/package.json +6 -0
  118. package/lib/Sidebar/Sidebar.js +152 -0
  119. package/lib/Sidebar/Sidebar.less +78 -0
  120. package/lib/Sidebar/package.json +6 -0
  121. package/lib/Sidebar2/Sidebar.js +173 -0
  122. package/lib/Sidebar2/Sidebar.less +153 -0
  123. package/lib/Sidebar2/package.json +6 -0
  124. package/lib/SuperForm/SuperForm.js +610 -0
  125. package/lib/SuperForm/SuperForm.less +52 -0
  126. package/lib/SuperForm/package.json +6 -0
  127. package/lib/SuperForm2/SuperForm.js +699 -0
  128. package/lib/SuperForm2/SuperForm.less +52 -0
  129. package/lib/SuperForm2/package.json +6 -0
  130. package/lib/SuperIcon/SuperIcon.js +35 -0
  131. package/lib/SuperIcon/package.json +6 -0
  132. package/lib/SuperPagination/SuperPagination.js +117 -0
  133. package/lib/SuperPagination/package.json +6 -0
  134. package/lib/SuperTab/SuperTab.js +115 -0
  135. package/lib/SuperTab/SuperTab.less +43 -0
  136. package/lib/SuperTab/package.json +6 -0
  137. package/lib/SuperTab2/SuperTab2.js +153 -0
  138. package/lib/SuperTab2/SuperTab2.less +18 -0
  139. package/lib/SuperTab2/package.json +6 -0
  140. package/lib/SuperTable/DragSortRow.js +105 -0
  141. package/lib/SuperTable/DragSortRow.less +17 -0
  142. package/lib/SuperTable/FilterDropDown.js +172 -0
  143. package/lib/SuperTable/FilterDropDown.less +30 -0
  144. package/lib/SuperTable/SuperTable.js +816 -0
  145. package/lib/SuperTable/SuperTable.less +132 -0
  146. package/lib/SuperTable/fixed.js +42 -0
  147. package/lib/SuperTable/package.json +6 -0
  148. package/lib/SuperTable2/SuperTable2.js +939 -0
  149. package/lib/SuperTable2/SuperTable2.less +118 -0
  150. package/lib/SuperTable2/SuperTableCell.js +239 -0
  151. package/lib/SuperTable2/package.json +6 -0
  152. package/lib/SuperTable3/FilterDropDown.js +172 -0
  153. package/lib/SuperTable3/FilterDropDown.less +29 -0
  154. package/lib/SuperTable3/SuperTable.js +673 -0
  155. package/lib/SuperTable3/SuperTable.less +99 -0
  156. package/lib/SuperTable3/fixed.js +42 -0
  157. package/lib/SuperTable3/package.json +6 -0
  158. package/lib/SuperToolbar/SuperToolbar.js +203 -0
  159. package/lib/SuperToolbar/SuperToolbar.less +17 -0
  160. package/lib/SuperToolbar/package.json +6 -0
  161. package/lib/SuperUpload/SuperUpload.js +368 -0
  162. package/lib/SuperUpload/SuperUpload.less +28 -0
  163. package/lib/SuperUpload/package.json +6 -0
  164. package/lib/Title/Title.js +41 -0
  165. package/lib/Title/Title.less +35 -0
  166. package/lib/Title/package.json +6 -0
  167. package/lib/Viewer/ImageViews.js +266 -0
  168. package/lib/Viewer/Viewer.js +130 -0
  169. package/lib/Viewer/Viewer.less +67 -0
  170. package/lib/Viewer/imgView.less +59 -0
  171. package/lib/Viewer/package.json +7 -0
  172. package/lib/WingBlank/WingBlank.js +24 -0
  173. package/lib/WingBlank/WingBlank.less +12 -0
  174. package/lib/WingBlank/package.json +6 -0
  175. package/lib/adjust.less +89 -0
  176. package/lib/helper.js +246 -0
  177. package/lib/history.js +12 -0
  178. package/lib/index.js +278 -0
  179. package/lib/index.less +32 -0
  180. package/lib/style.less +30 -0
  181. package/lib/variables.js +14 -0
  182. package/lib/variables.less +73 -0
  183. package/package.json +22 -44
  184. package/src/Area/Area.js +0 -94
  185. package/src/Card/Card.js +0 -16
  186. package/src/CodeInput/CodeInput.js +0 -76
  187. package/src/Control/Control.js +0 -338
  188. package/src/Control/event.js +0 -45
  189. package/src/Enhance/Dialogs.js +0 -24
  190. package/src/Enhance/Loading.js +0 -83
  191. package/src/Header/Header.js +0 -149
  192. package/src/Header/Vertical.js +0 -74
  193. package/src/ImageView/ImageView.js +0 -62
  194. package/src/Indent/Indent.js +0 -12
  195. package/src/InpurCascader/InputCascader.js +0 -83
  196. package/src/InputEditor/InputEditor.js +0 -93
  197. package/src/InputSearch/InputSearch.js +0 -186
  198. package/src/InputSelect/InputSelect.js +0 -103
  199. package/src/InputTreeSelect/InputTreeSelect.js +0 -87
  200. package/src/InputWriting/InputWriting.js +0 -65
  201. package/src/Layout/Layout.js +0 -121
  202. package/src/LayoutLink/LayoutLink.js +0 -59
  203. package/src/Link/Link.js +0 -57
  204. package/src/Loading/Loading.js +0 -15
  205. package/src/Loading2/Loading2.js +0 -15
  206. package/src/ModalWithDrag/ModalWithDrag.js +0 -17
  207. package/src/NumberInput/NumberInput.js +0 -137
  208. package/src/Search/Search.js +0 -368
  209. package/src/Search2/Search.js +0 -436
  210. package/src/Sidebar/Sidebar.js +0 -111
  211. package/src/Sidebar2/Sidebar.js +0 -143
  212. package/src/SuperForm/SuperForm.js +0 -519
  213. package/src/SuperForm2/SuperForm.js +0 -588
  214. package/src/SuperIcon/SuperIcon.js +0 -14
  215. package/src/SuperPagination/SuperPagination.js +0 -65
  216. package/src/SuperTab/SuperTab.js +0 -84
  217. package/src/SuperTab2/SuperTab2.js +0 -94
  218. package/src/SuperTable/DragSortRow.js +0 -62
  219. package/src/SuperTable/FilterDropDown.js +0 -111
  220. package/src/SuperTable/SuperTable.js +0 -590
  221. package/src/SuperTable/fixed.js +0 -34
  222. package/src/SuperTable2/SuperTable2.js +0 -624
  223. package/src/SuperTable2/SuperTableCell.js +0 -175
  224. package/src/SuperTable3/FilterDropDown.js +0 -111
  225. package/src/SuperTable3/SuperTable.js +0 -498
  226. package/src/SuperTable3/fixed.js +0 -34
  227. package/src/SuperToolbar/SuperToolbar.js +0 -128
  228. package/src/SuperUpload/SuperUpload.js +0 -137
  229. package/src/Title/Title.js +0 -18
  230. package/src/Viewer/ImageViews.js +0 -220
  231. package/src/Viewer/Viewer.js +0 -97
  232. package/src/WingBlank/WingBlank.js +0 -14
  233. package/src/helper.js +0 -185
  234. package/src/index.js +0 -39
  235. package/src/variables.js +0 -5
  236. package/test/index.html +0 -10
  237. package/test/test.js +0 -16
  238. package/test/test.less +0 -12
  239. package/test/webpack.config.js +0 -71
  240. package/tools/babel.config.js +0 -14
  241. package/tools/build.js +0 -70
  242. package/tools/publish.js +0 -9
  243. package/tools/util.js +0 -53
  244. /package/{src → es}/Area/package.json +0 -0
  245. /package/{src → es}/Card/package.json +0 -0
  246. /package/{src → es}/CodeInput/package.json +0 -0
  247. /package/{src → es}/Control/package.json +0 -0
  248. /package/{src → es}/Enhance/package.json +0 -0
  249. /package/{src → es}/Header/Header.less +0 -0
  250. /package/{src → es}/Header/Vertical.less +0 -0
  251. /package/{src → es}/Header/package.json +0 -0
  252. /package/{src → es}/ImageView/ImageView.less +0 -0
  253. /package/{src → es}/ImageView/package.json +0 -0
  254. /package/{src → es}/Indent/package.json +0 -0
  255. /package/{src → es}/InpurCascader/package.json +0 -0
  256. /package/{src → es}/InputEditor/inputEditor.less +0 -0
  257. /package/{src → es}/InputEditor/package.json +0 -0
  258. /package/{src → es}/InputSearch/package.json +0 -0
  259. /package/{src → es}/InputSelect/package.json +0 -0
  260. /package/{src → es}/InputTreeSelect/package.json +0 -0
  261. /package/{src → es}/InputWriting/package.json +0 -0
  262. /package/{src → es}/Layout/Layout.less +0 -0
  263. /package/{src → es}/Layout/package.json +0 -0
  264. /package/{src → es}/LayoutLink/LayoutLink.less +0 -0
  265. /package/{src → es}/LayoutLink/package.json +0 -0
  266. /package/{src → es}/Link/package.json +0 -0
  267. /package/{src → es}/Loading/Loading.less +0 -0
  268. /package/{src → es}/Loading/package.json +0 -0
  269. /package/{src → es}/Loading2/Loading2.less +0 -0
  270. /package/{src → es}/Loading2/package.json +0 -0
  271. /package/{src → es}/ModalWithDrag/ModalWithDrag.less +0 -0
  272. /package/{src → es}/ModalWithDrag/package.json +0 -0
  273. /package/{src → es}/NumberInput/package.json +0 -0
  274. /package/{src → es}/Search/Search.less +0 -0
  275. /package/{src → es}/Search/package.json +0 -0
  276. /package/{src → es}/Search2/Search.less +0 -0
  277. /package/{src → es}/Search2/package.json +0 -0
  278. /package/{src → es}/Sidebar/Sidebar.less +0 -0
  279. /package/{src → es}/Sidebar/package.json +0 -0
  280. /package/{src → es}/Sidebar2/Sidebar.less +0 -0
  281. /package/{src → es}/Sidebar2/package.json +0 -0
  282. /package/{src → es}/SuperForm/SuperForm.less +0 -0
  283. /package/{src → es}/SuperForm/package.json +0 -0
  284. /package/{src → es}/SuperForm2/SuperForm.less +0 -0
  285. /package/{src → es}/SuperForm2/package.json +0 -0
  286. /package/{src → es}/SuperIcon/package.json +0 -0
  287. /package/{src → es}/SuperPagination/package.json +0 -0
  288. /package/{src → es}/SuperTab/SuperTab.less +0 -0
  289. /package/{src → es}/SuperTab/package.json +0 -0
  290. /package/{src → es}/SuperTab2/SuperTab2.less +0 -0
  291. /package/{src → es}/SuperTab2/package.json +0 -0
  292. /package/{src → es}/SuperTable/DragSortRow.less +0 -0
  293. /package/{src → es}/SuperTable/FilterDropDown.less +0 -0
  294. /package/{src → es}/SuperTable/SuperTable.less +0 -0
  295. /package/{src → es}/SuperTable/package.json +0 -0
  296. /package/{src → es}/SuperTable2/SuperTable2.less +0 -0
  297. /package/{src → es}/SuperTable2/package.json +0 -0
  298. /package/{src → es}/SuperTable3/FilterDropDown.less +0 -0
  299. /package/{src → es}/SuperTable3/SuperTable.less +0 -0
  300. /package/{src → es}/SuperTable3/package.json +0 -0
  301. /package/{src → es}/SuperToolbar/SuperToolbar.less +0 -0
  302. /package/{src → es}/SuperToolbar/package.json +0 -0
  303. /package/{src → es}/SuperUpload/SuperUpload.less +0 -0
  304. /package/{src → es}/SuperUpload/package.json +0 -0
  305. /package/{src → es}/Title/Title.less +0 -0
  306. /package/{src → es}/Title/package.json +0 -0
  307. /package/{src → es}/Viewer/Viewer.less +0 -0
  308. /package/{src → es}/Viewer/imgView.less +0 -0
  309. /package/{src → es}/Viewer/package.json +0 -0
  310. /package/{src → es}/WingBlank/WingBlank.less +0 -0
  311. /package/{src → es}/WingBlank/package.json +0 -0
  312. /package/{src → es}/adjust.less +0 -0
  313. /package/{src → es}/style.less +0 -0
  314. /package/{src → es}/variables.less +0 -0
@@ -1,498 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import ReactDOM from 'react-dom';
4
- import {getTitle} from '../Control';
5
- import {Table, Tooltip} from 'antd';
6
- import FilterDropDown from './FilterDropDown';
7
- import fixed from './fixed';
8
- import variables from '../variables';
9
-
10
- /**
11
- * sorter: [可选],不传表示该列不支持排序;为string表示按字符串排序;为number表示按数字大小排序
12
- * filter: [可选],是否支持过滤,默认为false
13
- * link: [可选],为true表示超链接,内容来至items;为字符串表示超链接,内容就是该字符串;为字符串‘list’表示超链接数组,内容就是该items对应key对象数组的linkTitleKey属性拼接
14
- * linkTitleKey: [可选],当link为'list'表示超链接组时,该值表示要拼接展示的属性key值
15
- * isDateFilterByStartAndEnd: [可选],为true时做过滤操作会显示时间段搜索,默认为false
16
- *
17
- */
18
- const ColType = {
19
- key: PropTypes.string.isRequired,
20
- title: PropTypes.string,
21
- align: PropTypes.oneOf(['left', 'center', 'right']),
22
- sorter: PropTypes.oneOf(['string', 'number']),
23
- filter: PropTypes.bool,
24
- hide: PropTypes.bool,
25
- options: PropTypes.array,
26
- link: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
27
- linkTitleKey: PropTypes.string,
28
- noWrap: PropTypes.bool,
29
- isDateFilterByStartAndEnd: PropTypes.bool,
30
- };
31
-
32
- const ItemType = {
33
- checked: PropTypes.bool
34
- };
35
-
36
- /**
37
- * onCheck:点击复选框时触发, 原型为onCheck(checkedRows)
38
- * onRadio: 点击单选按钮时触发,原型为func(checkedRows)
39
- * onDoubleClick: 行双击时触发,原型func(rowIndex)
40
- * onLink: 点击超链接时触发,原型为func(key, rowIndex, item)
41
- * onTableChange: 排序信息改变时触发,原型为func(sortInfo, filterInfo)
42
- */
43
- const CallbackType = {
44
- onCheck: PropTypes.func,
45
- onRadio: PropTypes.func,
46
- onDoubleClick: PropTypes.func,
47
- onLink: PropTypes.func,
48
- onTableChange: PropTypes.func,
49
- };
50
-
51
- /**
52
- * checkbox: [可选],是否有复选框,默认为true
53
- * isPaging: [可选],是否分页,默认为false
54
- * radio: [可选],是否为单选按钮,当checkbox为true时生效,默认值为false
55
- * checkedRows: [可选],选中的行数,radio为true时生效
56
- * index: [可选],是否有序号,默认值为true
57
- * indexTitle:[可选],序号标题,默认为'序号'
58
- * sortInfo: [可选],排序信息,默认为null
59
- * filterInfo: [可选],过滤信息,默认为null
60
- * maxHeight: [可选],设置表格的最大高度
61
- * childrenKey: [可选],设置子列表数据的key,默认children
62
- */
63
- class SuperTable extends React.Component {
64
- static propTypes = {
65
- cols: PropTypes.arrayOf(PropTypes.shape(ColType)).isRequired,
66
- items: PropTypes.arrayOf(PropTypes.shape(ItemType)).isRequired,
67
- isPaging:PropTypes.bool,
68
- checkbox: PropTypes.bool,
69
- radio: PropTypes.bool,
70
- checkedRows: PropTypes.array,
71
- index: PropTypes.bool,
72
- indexTitle: PropTypes.string,
73
- sortInfo: PropTypes.object,
74
- filterInfo: PropTypes.object,
75
- maxHeight: PropTypes.string,
76
- callback: PropTypes.shape(CallbackType),
77
- childrenKey: PropTypes.string,
78
- };
79
-
80
- state = {filterVisibleKey: ''};
81
-
82
- onTableChange = (pagination, filters, sorter) => {
83
- const {onTableChange} = this.props.callback || {};
84
- const {filterInfo=null} = this.props;
85
- onTableChange && onTableChange(sorter, filterInfo);
86
- };
87
-
88
- onChange = (selectedKeyArr=[]) => {
89
- const {onCheck} = this.props.callback || {};
90
- if (onCheck) {
91
- const {items=[]} = this.props;
92
- let offset = 0;
93
- const realSlectedList = selectedKeyArr.length > items.length ? selectedKeyArr.slice(0, selectedKeyArr.length + offset) : selectedKeyArr;
94
- const selectedKeys = realSlectedList;
95
- const newItems = items;
96
- if (selectedKeys.length === 0) {
97
- onCheck(true, false, -1);
98
- } else if (selectedKeys.length === newItems.length) {
99
- const checked = newItems.every(o => o.checked);
100
- onCheck(true, !checked, -1);
101
- } else {
102
- const defaultSelectedKeys = this.getSelectedRowKeys(newItems);
103
- if (selectedKeys.length > defaultSelectedKeys.length) {
104
- if (this.props.isPaging && selectedKeys.length - defaultSelectedKeys.length > 1) {
105
- return onCheck(true, true, -1);
106
- }
107
- onCheck(false, true, selectedKeys[selectedKeys.length - 1]);
108
- } else {
109
- const index = defaultSelectedKeys.findIndex(key => !selectedKeys.some(select => select === key));
110
- onCheck(false, false, defaultSelectedKeys[index]);
111
- }
112
- }
113
- }
114
- };
115
-
116
- onCheckChange = (selectedKeys) => {
117
- const {onCheck} = this.props.callback || {};
118
- onCheck && onCheck(selectedKeys);
119
- };
120
-
121
- onRadioChange = (selectedKeys) => {
122
- const {onRadio} = this.props.callback || {};
123
- onRadio && onRadio(selectedKeys);
124
- };
125
-
126
- onRadioRowClick = (record) => {
127
- const {onRadio} = this.props.callback || {};
128
- onRadio && onRadio([record.key]);
129
- };
130
-
131
- onRowClick = (record) => {
132
- const {items} = this.props;
133
- if (items.length <= record.key) return;
134
- clearTimeout(this.timer);
135
- this.timer = setTimeout(() => {
136
- const {onCheck} = this.props.callback || {};
137
- if (onCheck) {
138
- const {checkedRows=[]} = this.props;
139
- if (checkedRows.includes(record.key)) {
140
- onCheck(checkedRows.filter(key => record.key !== key));
141
- } else {
142
- onCheck(checkedRows.concat(record.key));
143
- }
144
- }
145
- }, 250);
146
- };
147
-
148
- onDoubleClick = (record) => {
149
- clearTimeout(this.timer);
150
- const {onDoubleClick} = this.props.callback || {};
151
- onDoubleClick && onDoubleClick(record.key);
152
- };
153
-
154
- onLink = (key, index, item, e) => {
155
- const {onLink} = this.props.callback || {};
156
- onLink && onLink(key, index, item);
157
- e.stopPropagation();
158
- };
159
-
160
- onLinkDouble = (e) => {
161
- e.stopPropagation();
162
- };
163
-
164
- getSelectedRowKeys = (items) => {
165
- return items.reduce((result, item, index) => {
166
- item.checked && result.push(index);
167
- return result;
168
- }, []);
169
- };
170
-
171
- getIndexInfo = (items=[]) => {
172
- const {index=true, indexTitle='序号'} = this.props;
173
- return index ? [{key: 'index', title: indexTitle, render: (text, record, index) => (index + 1)}] : [];
174
- };
175
-
176
- setSortInfo = (col, sortInfo) => {
177
- if (col.sorter === 'string') {
178
- col.sortOrder = sortInfo.columnKey === col.key && sortInfo.order;
179
- col.sorter = (row1, row2) => {
180
- const a = !col.link ? row1[col.key] : row1[col.key].props.children;
181
- const b = !col.link ? row2[col.key] : row2[col.key].props.children;
182
- if (a > b) {
183
- return 1;
184
- } else if (a === b) {
185
- return 0;
186
- } else {
187
- return -1;
188
- }
189
- };
190
- } else if (col.sorter === 'number') {
191
- col.sortOrder = sortInfo.columnKey === col.key && sortInfo.order;
192
- col.sorter = (a, b) => a[col.key] - b[col.key];
193
- } else {
194
- delete col.sorter;
195
- }
196
- };
197
-
198
- setFilterInfo = (col, filterInfo, visibleKey) => {
199
- if (col.filter) {
200
- const {isDateFilterByStartAndEnd=false} = col;
201
- const onSearch = (value) => {
202
- const {onTableChange} = this.props.callback || {};
203
- const {sortInfo=null} = this.props;
204
- const newFilterInfo = Object.assign({}, filterInfo, {[col.key]: value});
205
- this.setState({filterVisibleKey: ''});
206
- onTableChange && onTableChange(sortInfo, newFilterInfo);
207
- };
208
- const value = filterInfo[col.key];
209
- col.filteredValue = value ? [value] : null;
210
- col.filterDropdownVisible = visibleKey === col.key;
211
- const onClose = () => {
212
- this.setState({filterVisibleKey: ''});
213
- };
214
- col.filterDropdown = <FilterDropDown {...{value, onSearch, onClose, isDateFilterByStartAndEnd}} />;
215
- col.onFilterDropdownVisibleChange = (visible) => {
216
- if (isDateFilterByStartAndEnd) {
217
- visible && this.setState({filterVisibleKey: col.key});
218
- } else {
219
- this.setState({filterVisibleKey: visible ? col.key : ''});
220
- }
221
- };
222
- col.onFilter = (value, record) => {
223
- const content = !col.link ? record[col.key] : record[col.key].props.children;
224
- if(!col.isDateFilterByStartAndEnd){
225
- const con = Array.isArray(content) ? content : String(content);
226
- return con.includes(value);
227
- } else {
228
- return !((value.start && new Date(value.start) > new Date(content)) || (value.end && value.end < content));
229
- }
230
- }
231
- }
232
- delete col.filter;
233
- };
234
-
235
- linkList = (key, index, item, linkTitleKey='fileName') => {
236
- const list = item[key] || [];
237
- return (
238
- <div>
239
- {list.map((item2, index2) => {
240
- const split = index2 === list.length-1 ? '' : ',';
241
- const onClick = this.onLink.bind(null, key, index, item2);
242
- return <a key={index2} onClick={onClick} onDoubleClick={this.onLinkDouble}>{`${item2[linkTitleKey]}${split}`}</a>;
243
- })}
244
- </div>
245
- )
246
- };
247
-
248
- waring = (key,index,item,warningKey) => {
249
- const text = item[key] ? item[key] : '';
250
- const color = item[warningKey] == 1 ?'red' :'rgba(0, 0, 0, 0.65)';
251
- return (
252
- <div>
253
- <p style={{color:color}}>{text.title ? text.title : text}</p>
254
- </div>
255
- )
256
- };
257
-
258
- defaultList = (key,index,item,text,link) => {
259
- const onClick = this.onLink.bind(null, key, index, item);
260
- if (link && (typeof link === 'string')) {
261
- return <a onClick={onClick} onDoubleClick={this.onLinkDouble}>{text}</a>;
262
- }
263
- return (
264
- <div>
265
- <p>{text}</p>
266
- </div>
267
- )
268
- };
269
-
270
- getColumns = (cols, items) => {
271
- const {sortInfo, filterInfo} = this.props;
272
- const {filterVisibleKey} = this.state;
273
- return this.getIndexInfo(items).concat(cols.filter(col => !col.hide)).map(({...col}) => {
274
- col.dataIndex = col.key;
275
- col.className = col.key === 'index' ? 'ant-table-selection-column' : (col.align ? s[col.align] : '');
276
- col.noWrap && (col.className = variables('SuperTable3').noWrap);
277
- this.setSortInfo(col, sortInfo || {});
278
- this.setFilterInfo(col, filterInfo || {}, filterVisibleKey);
279
-
280
- if(col.defaultValue){
281
- col.render = (text, record, index) => this.defaultList(col.key, index, items[index],col.defaultValue,col.link)
282
- }else if (col.link === 'list') {
283
- col.render = (text, record, index) => this.linkList(col.key, index, items[index], col.linkTitleKey);
284
- }else if (col.link && (typeof col.link === 'string')) {
285
- col.render = (text, record, index) => this.link(col.key, index, items[index], col.link);
286
- }else if(col.isWarning){
287
- col.render = (text, record, index) => this.waring(col.key, index, items[index],col.warningKey);
288
- }else if (col.tooltip) {
289
- col.render = (text, record, index) => this.tooltip(col.key, index, items[index], col);
290
- }
291
- return col;
292
- });
293
- };
294
-
295
- getText = (value, options) => {
296
- if (Array.isArray(value)) {
297
- return value.map(v => getTitle(v, options)).toString();
298
- } else {
299
- return getTitle(value, options);
300
- }
301
- };
302
-
303
- link = (key, index, item, text) => {
304
- const onClick = this.onLink.bind(null, key, index, item);
305
- return <a onClick={onClick} onDoubleClick={this.onLinkDouble}>{text}</a>;
306
- };
307
-
308
- tooltip = (key, index, item, {tooltip:tipLen, options}) => {
309
- const text = this.getText(item[key], options);
310
- const needTip = tipLen > 1 && text && typeof text === 'string' && text.length > tipLen;
311
- return needTip ? (
312
- <Tooltip title={text}>
313
- <span>{text.slice(0, tipLen) + '...'}</span>
314
- </Tooltip>
315
- ) : <span>{Array.isArray(text) ? text.join(',') : text}</span>;
316
- };
317
-
318
- getImgSrc = (value, options) => {
319
- const index = options.findIndex(obj => obj.value == value);
320
- return index === -1 ? null : options[index].img;
321
- };
322
-
323
- /**
324
- *
325
- * @param item{array}:列数据
326
- * @param key{string}:字段key
327
- * @param options{array}:字段options
328
- * @param dataSource{string,array}:数据源,如果列数据有多层则用此决定
329
- */
330
- getSourceText = (item,key,options,dataSource) => {
331
- let value = {};
332
- if(typeof dataSource === 'string'){
333
- value = item[dataSource] || {};
334
- }else if(Array.isArray(dataSource)){
335
- dataSource.forEach((source,index) => {
336
- /*如果字段重复则用dataSource取到结果,key不作为取字段的标准*/
337
- if(index === 0){
338
- value = item[source] || {};
339
- }else {
340
- value = value[source] || {}
341
- }
342
- })
343
- }
344
- /*如果上面已经取到结果则不进入*/
345
- if(typeof value !== 'string'){
346
- value = value[key];
347
- }
348
- return this.getText(value, options);
349
- };
350
-
351
-
352
- getDataSource = (items, cols) => {
353
- const getItemObj = (item, index) => {
354
- return cols.reduce((result, {key, options, link, icon,dataSource}) => {
355
- if (link) {
356
- if (typeof link === 'boolean') {
357
- result[key] = this.link(key, index, item, this.getText(item[key], options));
358
- }
359
- } else if (icon) { //单独的icon列,icon=true数据值根据options获得显示的图片url
360
- const src = this.getImgSrc(item[key], options);
361
- const onClick = this.onLink.bind(null, key, index, item);
362
- result[key] = src ? <img src={src} onClick={onClick} /> : '';
363
- } else if(dataSource){
364
- result[key] = this.getSourceText(item,key,options,dataSource);
365
- }else {
366
- result[key] = this.getText(item[key], options);
367
- }
368
- return result;
369
- }, {key: index, checked: !!item.checked});
370
- };
371
-
372
- const data = items.map((item, index) => {
373
- return {
374
- ...getItemObj(item, index),
375
- children: item.children ? item.children.map((item2, index2) => getItemObj(item2, `${index}-${index2}`)) : null
376
- };
377
- });
378
- return data;
379
- };
380
-
381
- getPropsByCheckbox = () => {
382
- const {checkbox=true, checkedRows=[]} = this.props;
383
- const rowClassName1 = (record) => {
384
- return checkedRows.includes(record.key) ? variables('SuperTable3').select : '';
385
- };
386
- if (checkbox) {
387
- return {
388
- rowClassName: rowClassName1,
389
- onRowClick: this.onRowClick,
390
- rowSelection: {
391
- selectedRowKeys: checkedRows,
392
- onChange: this.onCheckChange,
393
- getCheckboxProps: (record) => {
394
- const checked = checkedRows.includes(record.key);
395
- return {
396
- checked,
397
- }
398
- },
399
- }
400
- }
401
- }
402
- };
403
-
404
- getRowProps = (onRowClick) => {
405
- return (record) => {
406
- return {
407
- onClick: () => onRowClick && onRowClick(record),
408
- onDoubleClick: () => this.onDoubleClick(record)
409
- };
410
- };
411
- };
412
-
413
- getItems = () => {
414
- const {items, childrenKey} = this.props;
415
- let resItems = items;
416
- if (childrenKey) {
417
- resItems = items.map(o => o[childrenKey] && o[childrenKey].length ? {...o, children: o[childrenKey]} : o);
418
- }
419
- return resItems;
420
- };
421
-
422
- toTotalFooter = () => {
423
- const {cols, items, checkedRows} = this.props;
424
- const totalCols = cols.filter(item => item.total);
425
- if (totalCols.length > 0) {
426
- const checkedItems = items.filter((item, index) => checkedRows.includes(index));
427
- const countItems = checkedItems.length ? checkedItems : items;
428
- const totalItems = totalCols.map(({title, key, props={}}) => {
429
- const value = countItems.reduce((result, item) => parseFloat((result + Number(item[key] || 0)).toFixed(props.precision || 6)), 0);
430
- return {title, value};
431
- });
432
- return (
433
- <div style={{height: '36px',lineHeight: '36px'}}>
434
- <span style={{marginRight: `15px`}}>{checkedItems.length ? '【当页勾选汇总】' : '【当页汇总】'}</span>
435
- {totalItems.map(({title, value}, index) => {
436
- return (
437
- <span key={index} style={{marginRight: `10px`}}>
438
- <span>{title}: </span>
439
- <span style={{color: '#01a4ff'}}>{value}</span>
440
- </span>
441
- )
442
- })}
443
- </div>
444
- );
445
- } else {
446
- return null;
447
- }
448
- };
449
-
450
- getProps = () => {
451
- const {cols, isPaging=false, footer = null} = this.props;
452
- const items = this.getItems();
453
- const {onRowClick, ...extraProps} = this.getPropsByCheckbox(items);
454
- const renderProps = {
455
- className: variables('SuperTable3'),
456
- columns: this.getColumns(cols, items),
457
- dataSource: this.getDataSource(items, cols),
458
- size: 'small',
459
- pagination: isPaging,
460
- scroll: {x: true},
461
- onChange: this.onTableChange,
462
- onRow: this.getRowProps(onRowClick),
463
- components: {},
464
- footer: footer ? footer : this.toTotalFooter,
465
- ...extraProps
466
- };
467
- return renderProps;
468
- };
469
-
470
- setScroll = () => {
471
- const {maxHeight} = this.props;
472
- if (maxHeight && this.getItems().length) {
473
- const root = ReactDOM.findDOMNode(this);
474
- const container = root.getElementsByClassName('ant-table-body')[0];
475
- const header = root.getElementsByClassName('ant-table-thead')[0];
476
- fixed(container, header, maxHeight);
477
- }
478
- };
479
-
480
- shouldComponentUpdate(props, state) {
481
- const keys = ['cols', 'items', 'maxHeight', 'checkedRows', 'sortInfo', 'filterInfo'];
482
- return keys.some(key => props[key] !== this.props[key]) || state.filterVisibleKey !== this.state.filterVisibleKey;
483
- }
484
-
485
- componentDidMount() {
486
- this.setScroll();
487
- }
488
-
489
- componentDidUpdate() {
490
- this.setScroll();
491
- }
492
-
493
- render() {
494
- return <Table {...this.getProps()} key={this.props.items.length} />;
495
- }
496
- }
497
-
498
- export default SuperTable;
@@ -1,34 +0,0 @@
1
-
2
- const isFirefox = () => {
3
- return navigator.userAgent.indexOf('Firefox') > 0;
4
- };
5
-
6
- const getComputedStyle = (element) => {
7
- return window.getComputedStyle ? window.getComputedStyle(element, null) : element.currentStyle;
8
- }
9
-
10
- const fixed = (container, header, maxHeight, totalFooter={}) => {
11
- container.style.overflowY = 'auto';
12
- container.style.maxHeight = maxHeight;
13
- if (isFirefox()) {
14
- container.style.position = 'relative';
15
- header.style.top = '0';
16
- header.style.position = 'sticky';
17
- header.style.zIndex = '1';
18
- } else {
19
- header.parentNode.appendChild(header);
20
- }
21
- const containerHeight = Number(getComputedStyle(container).height.replace('px', ''))
22
- const translateHeight = containerHeight - 10 - container.scrollHeight;
23
- const {pageTotalElement, searchTotalElement} = totalFooter;
24
- pageTotalElement && (pageTotalElement.style.transform = `translateY(${translateHeight + container.scrollTop}px)`);
25
- searchTotalElement && (searchTotalElement.style.transform = `translateY(${translateHeight + container.scrollTop}px)`);
26
- container.onscroll = () => {
27
- if (container.scrollTop + containerHeight - 10 > container.scrollHeight) return;
28
- !isFirefox() && (header.style.transform = `translateY(${container.scrollTop}px)`);
29
- pageTotalElement && (pageTotalElement.style.transform = `translateY(${translateHeight + container.scrollTop}px)`);
30
- searchTotalElement && (searchTotalElement.style.transform = `translateY(${translateHeight + container.scrollTop}px)`);
31
- };
32
- };
33
-
34
- export default fixed;
@@ -1,128 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import {Button, Popconfirm, Icon, Dropdown, Menu} from 'antd';
4
- import variables from '../variables';
5
- const MenuItem = Menu.Item;
6
- const SubMenu = Menu.SubMenu;
7
-
8
- let clicktag = 0; //被点击标识
9
-
10
- /**
11
- * key: 用于标识菜单项
12
- * title: 菜单项上的文字
13
- * subMenu: [可选],菜单项子列表,包含key和title的对象数组,此时点击菜单项不触发事件,只有点击子列表项才会触发onSubClick事件
14
- */
15
- const MenuType = {
16
- key: PropTypes.string.isRequired,
17
- title: PropTypes.string.isRequired,
18
- subMenu: PropTypes.array
19
- };
20
-
21
- /**
22
- * key: 用于标识按钮
23
- * title: 按钮上的文字
24
- * bsStyle: 按钮样式,与antd中Button的type取值一样
25
- * confirm: 触发按钮事件前,是否需要用户确认,以及确认的提示文字;为空串则不会触发确认提示
26
- * menu: [可选],下拉菜单项,有此属性时点击按钮不触发事件,菜单项如果仅是包含key和title的对象,点击菜单项会触发onClick事件
27
- * 菜单项如果是包含key、title、subMenu的对象,则点击此菜单项不触发事件,必须点击子列表项时才会触发onSubClick事件
28
- * loading: 是否正在加载,与antd中Button的loading取值一样
29
- */
30
- const ButtonType = {
31
- key: PropTypes.string.isRequired,
32
- title: PropTypes.string.isRequired,
33
- bsStyle: PropTypes.string,
34
- confirm: PropTypes.string,
35
- menu: PropTypes.arrayOf(PropTypes.shape(MenuType)),
36
- loading: PropTypes.bool,
37
- };
38
-
39
- const ButtonEx = ({type, children, ...props}) => {
40
- props[type === 'primary-o' ? 'data-btn-type' : 'type'] = type;
41
- return <Button {...props}>{children}</Button>;
42
- };
43
-
44
- /**
45
- * onClick: 纯按钮点击时或按钮下拉项中无子菜单列表项点击触发,原型为function(key)
46
- * onSubClick: 按钮为下拉时下拉项子列表项点击时触发,原型为function(key, subKey)
47
- */
48
- class SuperToolbar extends React.Component {
49
- static propTypes = {
50
- buttons: PropTypes.arrayOf(PropTypes.shape(ButtonType)).isRequired,
51
- size: PropTypes.oneOf(['small', 'default', 'large']),
52
- onClick: PropTypes.func,
53
- onSubClick: PropTypes.func
54
- };
55
-
56
- onClick = (e) => {
57
- const {onClick, onSubClick} = this.props;
58
- const key = typeof e === 'object' ? e.key : e;
59
- if (typeof e === 'object' && e.keyPath.length === 2 && onSubClick) {
60
- onSubClick(e.keyPath[1], e.keyPath[0]);
61
- } else if (onClick) {
62
- if(clicktag === 0){
63
- clicktag = 1;
64
- onClick(key);
65
- //1秒过后可以再次点击
66
- setTimeout(function () { clicktag = 0 }, 1000);
67
- }else{
68
- console.log('请勿频繁操作!');
69
- }
70
- }
71
- };
72
-
73
- toSubMenu = ({key, title, subMenu=[]}) => {
74
- return (
75
- <SubMenu key={key} title={title}>
76
- {subMenu.map(({key, title}) => <MenuItem key={key}>{title}</MenuItem>)}
77
- </SubMenu>
78
- );
79
- };
80
-
81
- toMenu = (menu) => {
82
- return (
83
- <Menu onClick={this.onClick}>
84
- {
85
- menu.map((item) => {
86
- const {key, title, subMenu} = item;
87
- if (subMenu) {
88
- return this.toSubMenu(item);
89
- } else {
90
- return <MenuItem key={key}>{title}</MenuItem>;
91
- }
92
- })
93
- }
94
- </Menu>
95
- );
96
- };
97
-
98
- toButton = ({key, title, bsStyle: type, confirm, menu, loading}) => {
99
- const onClick = this.onClick.bind(this, key);
100
- const {size='small'} = this.props;
101
- if (menu && menu.length) {
102
- return (
103
- <Dropdown key={key} trigger={['hover']} overlay={this.toMenu(menu)}>
104
- <ButtonEx {...{size, type}}>{title}<Icon type='down'/></ButtonEx>
105
- </Dropdown>
106
- );
107
- } else if (!confirm) {
108
- return <ButtonEx {...{key, size, type, onClick, loading}}>{title}</ButtonEx>;
109
- } else {
110
- return (
111
- <Popconfirm key={key} title={confirm} onConfirm={onClick}>
112
- <ButtonEx {...{size, type, loading}}>{title}</ButtonEx>
113
- </Popconfirm>
114
- );
115
- }
116
- };
117
-
118
- render() {
119
- const {buttons} = this.props;
120
- return (
121
- <div className={variables('SuperToolbar')} role='toolbar'>
122
- {buttons.map(this.toButton)}
123
- </div>
124
- );
125
- }
126
- }
127
-
128
- export default SuperToolbar;