cloud-b2b 1.1.50 → 1.1.51

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 (309) hide show
  1. package/package.json +44 -22
  2. package/src/Area/Area.js +94 -0
  3. package/src/Card/Card.js +16 -0
  4. package/src/CodeInput/CodeInput.js +76 -0
  5. package/src/Control/Control.js +338 -0
  6. package/src/Control/event.js +45 -0
  7. package/src/Enhance/Dialogs.js +24 -0
  8. package/src/Enhance/Loading.js +83 -0
  9. package/{es → src}/Enhance/index.js +8 -8
  10. package/src/Header/Header.js +149 -0
  11. package/src/Header/Vertical.js +74 -0
  12. package/src/ImageView/ImageView.js +62 -0
  13. package/src/Indent/Indent.js +12 -0
  14. package/src/InpurCascader/InputCascader.js +83 -0
  15. package/src/InputEditor/InputEditor.js +93 -0
  16. package/src/InputSearch/InputSearch.js +186 -0
  17. package/src/InputSelect/InputSelect.js +103 -0
  18. package/src/InputTreeSelect/InputTreeSelect.js +87 -0
  19. package/src/InputWriting/InputWriting.js +65 -0
  20. package/src/Layout/Layout.js +121 -0
  21. package/src/LayoutLink/LayoutLink.js +59 -0
  22. package/src/Link/Link.js +57 -0
  23. package/src/Loading/Loading.js +15 -0
  24. package/src/Loading2/Loading2.js +15 -0
  25. package/src/ModalWithDrag/ModalWithDrag.js +17 -0
  26. package/src/ModalWithDrag/drag.js +128 -0
  27. package/src/NumberInput/NumberInput.js +137 -0
  28. package/src/Search/Search.js +368 -0
  29. package/src/Sidebar/Sidebar.js +111 -0
  30. package/src/Sidebar2/Sidebar.js +143 -0
  31. package/src/SuperForm/SuperForm.js +516 -0
  32. package/src/SuperForm2/SuperForm.js +588 -0
  33. package/src/SuperIcon/SuperIcon.js +14 -0
  34. package/src/SuperPagination/SuperPagination.js +65 -0
  35. package/src/SuperTab/SuperTab.js +84 -0
  36. package/src/SuperTab2/SuperTab2.js +94 -0
  37. package/src/SuperTable/DragSortRow.js +62 -0
  38. package/src/SuperTable/FilterDropDown.js +111 -0
  39. package/src/SuperTable/SuperTable.js +590 -0
  40. package/src/SuperTable/fixed.js +34 -0
  41. package/src/SuperTable2/SuperTable2.js +600 -0
  42. package/src/SuperTable2/SuperTableCell.js +144 -0
  43. package/src/SuperTable3/FilterDropDown.js +111 -0
  44. package/src/SuperTable3/SuperTable.js +498 -0
  45. package/src/SuperTable3/fixed.js +34 -0
  46. package/src/SuperToolbar/SuperToolbar.js +128 -0
  47. package/src/SuperUpload/SuperUpload.js +137 -0
  48. package/src/Title/Title.js +18 -0
  49. package/src/Viewer/ImageViews.js +220 -0
  50. package/src/Viewer/Viewer.js +97 -0
  51. package/src/WingBlank/WingBlank.js +14 -0
  52. package/src/helper.js +185 -0
  53. package/src/history.js +6 -0
  54. package/src/index.js +38 -0
  55. package/src/variables.js +5 -0
  56. package/test/index.html +10 -0
  57. package/test/test.js +16 -0
  58. package/test/test.less +12 -0
  59. package/test/webpack.config.js +71 -0
  60. package/tools/babel.config.js +14 -0
  61. package/tools/build.js +70 -0
  62. package/tools/publish.js +9 -0
  63. package/tools/util.js +53 -0
  64. package/es/Area/Area.js +0 -170
  65. package/es/Card/Card.js +0 -20
  66. package/es/CodeInput/CodeInput.js +0 -152
  67. package/es/Control/Control.js +0 -496
  68. package/es/Control/event.js +0 -57
  69. package/es/Enhance/Dialogs.js +0 -67
  70. package/es/Enhance/Loading.js +0 -151
  71. package/es/Header/Header.js +0 -194
  72. package/es/Header/Vertical.js +0 -129
  73. package/es/ImageView/ImageView.js +0 -117
  74. package/es/Indent/Indent.js +0 -23
  75. package/es/InpurCascader/InputCascader.js +0 -135
  76. package/es/InputEditor/InputEditor.js +0 -113
  77. package/es/InputSearch/InputSearch.js +0 -311
  78. package/es/InputSelect/InputSelect.js +0 -191
  79. package/es/InputTreeSelect/InputTreeSelect.js +0 -147
  80. package/es/InputWriting/InputWriting.js +0 -107
  81. package/es/Layout/Layout.js +0 -232
  82. package/es/LayoutLink/LayoutLink.js +0 -82
  83. package/es/Link/Link.js +0 -108
  84. package/es/Loading/Loading.js +0 -15
  85. package/es/Loading2/Loading2.js +0 -11
  86. package/es/ModalWithDrag/ModalWithDrag.js +0 -34
  87. package/es/ModalWithDrag/drag.js +0 -133
  88. package/es/NumberInput/NumberInput.js +0 -240
  89. package/es/Search/Search.js +0 -595
  90. package/es/Sidebar/Sidebar.js +0 -165
  91. package/es/Sidebar2/Sidebar.js +0 -192
  92. package/es/SuperForm/SuperForm.js +0 -720
  93. package/es/SuperForm2/SuperForm.js +0 -828
  94. package/es/SuperIcon/SuperIcon.js +0 -30
  95. package/es/SuperPagination/SuperPagination.js +0 -126
  96. package/es/SuperTab/SuperTab.js +0 -130
  97. package/es/SuperTab2/SuperTab2.js +0 -167
  98. package/es/SuperTable/DragSortRow.js +0 -125
  99. package/es/SuperTable/FilterDropDown.js +0 -188
  100. package/es/SuperTable/SuperTable.js +0 -940
  101. package/es/SuperTable/fixed.js +0 -42
  102. package/es/SuperTable2/SuperTable2.js +0 -1019
  103. package/es/SuperTable2/SuperTableCell.js +0 -242
  104. package/es/SuperTable3/FilterDropDown.js +0 -188
  105. package/es/SuperTable3/SuperTable.js +0 -790
  106. package/es/SuperTable3/fixed.js +0 -42
  107. package/es/SuperToolbar/SuperToolbar.js +0 -223
  108. package/es/SuperUpload/SuperUpload.js +0 -434
  109. package/es/Title/Title.js +0 -36
  110. package/es/Viewer/ImageViews.js +0 -311
  111. package/es/Viewer/Viewer.js +0 -149
  112. package/es/WingBlank/WingBlank.js +0 -20
  113. package/es/helper.js +0 -169
  114. package/es/history.js +0 -5
  115. package/es/index.js +0 -37
  116. package/es/variables.js +0 -4
  117. package/lib/Area/Area.js +0 -198
  118. package/lib/Area/package.json +0 -6
  119. package/lib/Card/Card.js +0 -38
  120. package/lib/Card/package.json +0 -6
  121. package/lib/CodeInput/CodeInput.js +0 -179
  122. package/lib/CodeInput/package.json +0 -6
  123. package/lib/Control/Control.js +0 -548
  124. package/lib/Control/event.js +0 -68
  125. package/lib/Control/package.json +0 -6
  126. package/lib/Enhance/Dialogs.js +0 -87
  127. package/lib/Enhance/Loading.js +0 -175
  128. package/lib/Enhance/index.js +0 -35
  129. package/lib/Enhance/package.json +0 -6
  130. package/lib/Header/Header.js +0 -215
  131. package/lib/Header/Header.less +0 -95
  132. package/lib/Header/Vertical.js +0 -150
  133. package/lib/Header/Vertical.less +0 -60
  134. package/lib/Header/package.json +0 -6
  135. package/lib/ImageView/ImageView.js +0 -134
  136. package/lib/ImageView/ImageView.less +0 -14
  137. package/lib/ImageView/package.json +0 -6
  138. package/lib/Indent/Indent.js +0 -38
  139. package/lib/Indent/package.json +0 -6
  140. package/lib/InpurCascader/InputCascader.js +0 -156
  141. package/lib/InpurCascader/package.json +0 -6
  142. package/lib/InputEditor/InputEditor.js +0 -131
  143. package/lib/InputEditor/inputEditor.less +0 -8
  144. package/lib/InputEditor/package.json +0 -6
  145. package/lib/InputSearch/InputSearch.js +0 -327
  146. package/lib/InputSearch/package.json +0 -6
  147. package/lib/InputSelect/InputSelect.js +0 -214
  148. package/lib/InputSelect/package.json +0 -6
  149. package/lib/InputTreeSelect/InputTreeSelect.js +0 -169
  150. package/lib/InputTreeSelect/package.json +0 -6
  151. package/lib/InputWriting/InputWriting.js +0 -123
  152. package/lib/InputWriting/package.json +0 -6
  153. package/lib/Layout/Layout.js +0 -258
  154. package/lib/Layout/Layout.less +0 -28
  155. package/lib/Layout/package.json +0 -6
  156. package/lib/LayoutLink/LayoutLink.js +0 -114
  157. package/lib/LayoutLink/LayoutLink.less +0 -53
  158. package/lib/LayoutLink/package.json +0 -6
  159. package/lib/Link/Link.js +0 -130
  160. package/lib/Link/package.json +0 -6
  161. package/lib/Loading/Loading.js +0 -30
  162. package/lib/Loading/Loading.less +0 -13
  163. package/lib/Loading/package.json +0 -6
  164. package/lib/Loading2/Loading2.js +0 -26
  165. package/lib/Loading2/Loading2.less +0 -19
  166. package/lib/Loading2/package.json +0 -6
  167. package/lib/ModalWithDrag/ModalWithDrag.js +0 -53
  168. package/lib/ModalWithDrag/ModalWithDrag.less +0 -6
  169. package/lib/ModalWithDrag/drag.js +0 -147
  170. package/lib/ModalWithDrag/package.json +0 -6
  171. package/lib/NumberInput/NumberInput.js +0 -262
  172. package/lib/NumberInput/package.json +0 -6
  173. package/lib/Search/Search.js +0 -616
  174. package/lib/Search/Search.less +0 -63
  175. package/lib/Search/package.json +0 -6
  176. package/lib/Sidebar/Sidebar.js +0 -186
  177. package/lib/Sidebar/Sidebar.less +0 -78
  178. package/lib/Sidebar/package.json +0 -6
  179. package/lib/Sidebar2/Sidebar.js +0 -213
  180. package/lib/Sidebar2/Sidebar.less +0 -153
  181. package/lib/Sidebar2/package.json +0 -6
  182. package/lib/SuperForm/SuperForm.js +0 -731
  183. package/lib/SuperForm/SuperForm.less +0 -52
  184. package/lib/SuperForm/package.json +0 -6
  185. package/lib/SuperForm2/SuperForm.js +0 -834
  186. package/lib/SuperForm2/SuperForm.less +0 -52
  187. package/lib/SuperForm2/package.json +0 -6
  188. package/lib/SuperIcon/SuperIcon.js +0 -47
  189. package/lib/SuperIcon/package.json +0 -6
  190. package/lib/SuperPagination/SuperPagination.js +0 -145
  191. package/lib/SuperPagination/package.json +0 -6
  192. package/lib/SuperTab/SuperTab.js +0 -146
  193. package/lib/SuperTab/SuperTab.less +0 -43
  194. package/lib/SuperTab/package.json +0 -6
  195. package/lib/SuperTab2/SuperTab2.js +0 -191
  196. package/lib/SuperTab2/SuperTab2.less +0 -18
  197. package/lib/SuperTab2/package.json +0 -6
  198. package/lib/SuperTable/DragSortRow.js +0 -142
  199. package/lib/SuperTable/DragSortRow.less +0 -17
  200. package/lib/SuperTable/FilterDropDown.js +0 -205
  201. package/lib/SuperTable/FilterDropDown.less +0 -30
  202. package/lib/SuperTable/SuperTable.js +0 -945
  203. package/lib/SuperTable/SuperTable.less +0 -132
  204. package/lib/SuperTable/fixed.js +0 -55
  205. package/lib/SuperTable/package.json +0 -6
  206. package/lib/SuperTable2/SuperTable2.js +0 -1047
  207. package/lib/SuperTable2/SuperTable2.less +0 -118
  208. package/lib/SuperTable2/SuperTableCell.js +0 -258
  209. package/lib/SuperTable2/package.json +0 -6
  210. package/lib/SuperTable3/FilterDropDown.js +0 -205
  211. package/lib/SuperTable3/FilterDropDown.less +0 -29
  212. package/lib/SuperTable3/SuperTable.js +0 -795
  213. package/lib/SuperTable3/SuperTable.less +0 -99
  214. package/lib/SuperTable3/fixed.js +0 -55
  215. package/lib/SuperTable3/package.json +0 -6
  216. package/lib/SuperToolbar/SuperToolbar.js +0 -248
  217. package/lib/SuperToolbar/SuperToolbar.less +0 -17
  218. package/lib/SuperToolbar/package.json +0 -6
  219. package/lib/SuperUpload/SuperUpload.js +0 -481
  220. package/lib/SuperUpload/SuperUpload.less +0 -28
  221. package/lib/SuperUpload/package.json +0 -6
  222. package/lib/Title/Title.js +0 -54
  223. package/lib/Title/Title.less +0 -35
  224. package/lib/Title/package.json +0 -6
  225. package/lib/Viewer/ImageViews.js +0 -323
  226. package/lib/Viewer/Viewer.js +0 -167
  227. package/lib/Viewer/Viewer.less +0 -67
  228. package/lib/Viewer/imgView.less +0 -59
  229. package/lib/Viewer/package.json +0 -7
  230. package/lib/WingBlank/WingBlank.js +0 -37
  231. package/lib/WingBlank/WingBlank.less +0 -12
  232. package/lib/WingBlank/package.json +0 -6
  233. package/lib/adjust.less +0 -89
  234. package/lib/helper.js +0 -204
  235. package/lib/history.js +0 -18
  236. package/lib/index.js +0 -347
  237. package/lib/index.less +0 -31
  238. package/lib/style.less +0 -30
  239. package/lib/variables.js +0 -16
  240. package/lib/variables.less +0 -73
  241. /package/{es → src}/Area/package.json +0 -0
  242. /package/{es → src}/Card/package.json +0 -0
  243. /package/{es → src}/CodeInput/package.json +0 -0
  244. /package/{es → src}/Control/package.json +0 -0
  245. /package/{es → src}/Enhance/package.json +0 -0
  246. /package/{es → src}/Header/Header.less +0 -0
  247. /package/{es → src}/Header/Vertical.less +0 -0
  248. /package/{es → src}/Header/package.json +0 -0
  249. /package/{es → src}/ImageView/ImageView.less +0 -0
  250. /package/{es → src}/ImageView/package.json +0 -0
  251. /package/{es → src}/Indent/package.json +0 -0
  252. /package/{es → src}/InpurCascader/package.json +0 -0
  253. /package/{es → src}/InputEditor/inputEditor.less +0 -0
  254. /package/{es → src}/InputEditor/package.json +0 -0
  255. /package/{es → src}/InputSearch/package.json +0 -0
  256. /package/{es → src}/InputSelect/package.json +0 -0
  257. /package/{es → src}/InputTreeSelect/package.json +0 -0
  258. /package/{es → src}/InputWriting/package.json +0 -0
  259. /package/{es → src}/Layout/Layout.less +0 -0
  260. /package/{es → src}/Layout/package.json +0 -0
  261. /package/{es → src}/LayoutLink/LayoutLink.less +0 -0
  262. /package/{es → src}/LayoutLink/package.json +0 -0
  263. /package/{es → src}/Link/package.json +0 -0
  264. /package/{es → src}/Loading/Loading.less +0 -0
  265. /package/{es → src}/Loading/package.json +0 -0
  266. /package/{es → src}/Loading2/Loading2.less +0 -0
  267. /package/{es → src}/Loading2/package.json +0 -0
  268. /package/{es → src}/ModalWithDrag/ModalWithDrag.less +0 -0
  269. /package/{es → src}/ModalWithDrag/package.json +0 -0
  270. /package/{es → src}/NumberInput/package.json +0 -0
  271. /package/{es → src}/Search/Search.less +0 -0
  272. /package/{es → src}/Search/package.json +0 -0
  273. /package/{es → src}/Sidebar/Sidebar.less +0 -0
  274. /package/{es → src}/Sidebar/package.json +0 -0
  275. /package/{es → src}/Sidebar2/Sidebar.less +0 -0
  276. /package/{es → src}/Sidebar2/package.json +0 -0
  277. /package/{es → src}/SuperForm/SuperForm.less +0 -0
  278. /package/{es → src}/SuperForm/package.json +0 -0
  279. /package/{es → src}/SuperForm2/SuperForm.less +0 -0
  280. /package/{es → src}/SuperForm2/package.json +0 -0
  281. /package/{es → src}/SuperIcon/package.json +0 -0
  282. /package/{es → src}/SuperPagination/package.json +0 -0
  283. /package/{es → src}/SuperTab/SuperTab.less +0 -0
  284. /package/{es → src}/SuperTab/package.json +0 -0
  285. /package/{es → src}/SuperTab2/SuperTab2.less +0 -0
  286. /package/{es → src}/SuperTab2/package.json +0 -0
  287. /package/{es → src}/SuperTable/DragSortRow.less +0 -0
  288. /package/{es → src}/SuperTable/FilterDropDown.less +0 -0
  289. /package/{es → src}/SuperTable/SuperTable.less +0 -0
  290. /package/{es → src}/SuperTable/package.json +0 -0
  291. /package/{es → src}/SuperTable2/SuperTable2.less +0 -0
  292. /package/{es → src}/SuperTable2/package.json +0 -0
  293. /package/{es → src}/SuperTable3/FilterDropDown.less +0 -0
  294. /package/{es → src}/SuperTable3/SuperTable.less +0 -0
  295. /package/{es → src}/SuperTable3/package.json +0 -0
  296. /package/{es → src}/SuperToolbar/SuperToolbar.less +0 -0
  297. /package/{es → src}/SuperToolbar/package.json +0 -0
  298. /package/{es → src}/SuperUpload/SuperUpload.less +0 -0
  299. /package/{es → src}/SuperUpload/package.json +0 -0
  300. /package/{es → src}/Title/Title.less +0 -0
  301. /package/{es → src}/Title/package.json +0 -0
  302. /package/{es → src}/Viewer/Viewer.less +0 -0
  303. /package/{es → src}/Viewer/imgView.less +0 -0
  304. /package/{es → src}/Viewer/package.json +0 -0
  305. /package/{es → src}/WingBlank/WingBlank.less +0 -0
  306. /package/{es → src}/WingBlank/package.json +0 -0
  307. /package/{es → src}/adjust.less +0 -0
  308. /package/{es → src}/style.less +0 -0
  309. /package/{es → src}/variables.less +0 -0
@@ -0,0 +1,600 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import ReactDOM from 'react-dom';
4
+ import Control, {getTitle} from '../Control';
5
+ import {Table, Checkbox, Button, Icon, Switch} from 'antd';
6
+ import SuperTableCell from './SuperTableCell';
7
+ import fixed from '../SuperTable/fixed';
8
+ import SuperToolbar from '../SuperToolbar';
9
+ import variables from '../variables';
10
+ import helper, {getObjectExclude} from '../helper';
11
+ import DragSortRow from "../SuperTable/DragSortRow";
12
+
13
+ const TypeEnum = [
14
+ 'readonly',
15
+ 'index',
16
+ 'checkbox',
17
+ 'text',
18
+ 'number',
19
+ 'select', //存储value
20
+ 'selectText', //存储title
21
+ 'search',
22
+ 'searchText',
23
+ 'selectSearch', //多选下拉搜索
24
+ 'date',
25
+ 'button',
26
+ 'custom',
27
+ 'switch',
28
+ 'textArea',
29
+ 'link',
30
+ 'toolbar', //按钮组
31
+ 'img', //图片标题组 value为{src,title}时显示图片标题 为字符串时 只显示图片
32
+ 'uploadImg',
33
+ 'double'
34
+ ];
35
+
36
+ /**
37
+ * key:标识所在列,在一个表格中必须唯一
38
+ * title:列的标题,type为checkbox时,title为空字符串时,表头才会显示为复选框
39
+ * type:嵌入的表单元素类型
40
+ * link: 是否为超链接,type未设置时,该属性才生效。为true表示内容来至items,为字符串表示超链接内容就是该字符串
41
+ * options: 对象(包含value和title)数组
42
+ * props:传递参数给被嵌入的组件
43
+ * width: 嵌入的组件的宽度,默认值为100
44
+ * align:对齐方式,index默认center,其他类型默认为left
45
+ * showAdd: 表头是否显示+号,默认为false,加号会触发onAdd事件
46
+ * hide: 为true时隐藏该列
47
+ */
48
+ const ColType = {
49
+ key: PropTypes.string.isRequired,
50
+ title: PropTypes.string.isRequired,
51
+ type: PropTypes.oneOf(TypeEnum),
52
+ link: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
53
+ align: PropTypes.oneOf(['left', 'center', 'right']),
54
+ width: PropTypes.number,
55
+ options: PropTypes.array,
56
+ showAdd: PropTypes.any,
57
+ hide: PropTypes.bool,
58
+ props: PropTypes.any
59
+ };
60
+
61
+ /**
62
+ * onCheck:点击复选框时触发,原型func(rowIndex, keyName, checked)
63
+ * onContentChange: 输入框内容改变时触发,原型为function(rowIndex, keyName, value)
64
+ * onBlur: 输入框失去焦点时触发,原型为function(rowIndex, keyName, value)
65
+ * onSearch:search组件输入内容时触发,原型为function(rowIndex, keyName, value, col)
66
+ * onLink: 点击超链接时触发,原型为function(keyName, rowIndex, item)
67
+ * onAdd:点击+号时触发,原型为function(keyName)
68
+ * onRenderCustom:(废弃)用于渲染type为custom类型的单元格,原型为function(rowIndex, keyName, value,props)
69
+ * onToolbar:点击表格列按钮组时触发,原型为function(按钮组列的key,rowIndex,该行数据的值,按钮key);
70
+ * onDoubleClick: 双击单元格触发(只针对于type类型为空的情况下)
71
+ */
72
+ const CallbackType = {
73
+ onExitValid: PropTypes.func,
74
+ onCheck: PropTypes.func,
75
+ onContentChange: PropTypes.func,
76
+ onBlur: PropTypes.func,
77
+ onSearch: PropTypes.func,
78
+ onLink: PropTypes.func,
79
+ onAdd: PropTypes.func,
80
+ onRenderCustom: PropTypes.func,
81
+ onToolbar:PropTypes.func,
82
+ onDoubleClick:PropTypes.func,
83
+ onTableFileChange:PropTypes.func,
84
+ buildSuperUploadProps: PropTypes.func, //构建type===uploadImg时,SuperUpload组件需要的公共属性函数,已在项目公共文件state.js中提供,可直接引用
85
+ onImgTileClick:PropTypes.func, //点击img类型标题触发事件
86
+ onMoveRow: PropTypes.func
87
+ };
88
+
89
+ /**
90
+ * base[可选]:序号的开始数字,所有回调函数中的序号值都会加上这个值,默认值为0
91
+ * isEmphasized: [可选],是否强调,行字体加粗显示, 除了isEmphasized设置为true之外,加粗行数据里要设置__isEmphasized为true
92
+ */
93
+ class SuperTable2 extends React.Component {
94
+ static propTypes = {
95
+ cols: PropTypes.arrayOf(PropTypes.shape(ColType)).isRequired,
96
+ items: PropTypes.array.isRequired,
97
+ base: PropTypes.number,
98
+ options: PropTypes.object,
99
+ valid: PropTypes.bool,
100
+ readonly: PropTypes.bool,
101
+ style: PropTypes.object,
102
+ maxHeight: PropTypes.string,
103
+ emptyText: PropTypes.string,
104
+ footer: PropTypes.func,
105
+ callback: PropTypes.shape(CallbackType),
106
+ isEmphasized: PropTypes.bool,
107
+ dragSort: PropTypes.bool,
108
+ };
109
+
110
+ onSwitch = (key, rowIndex) => (value) => {
111
+ const {onContentChange} = this.props.callback || {};
112
+ onContentChange && onContentChange(this.getIndex(rowIndex), key, value);
113
+ };
114
+
115
+ onCheck = (key, rowIndex) => (e) => {
116
+ const {onCheck} = this.props.callback || {};
117
+ onCheck && onCheck(this.getIndex(rowIndex), key, e.target.checked);
118
+ };
119
+
120
+ onChange = (key, rowIndex) => (value) => {
121
+ const {onContentChange} = this.props.callback || {};
122
+ this.closeValid();
123
+ onContentChange && onContentChange(this.getIndex(rowIndex), key, value);
124
+ };
125
+ onDoubleChange1 = (key, rowIndex) => (doublekey,value) => {
126
+ const {onContentChange} = this.props.callback || {};
127
+ this.closeValid();
128
+ onContentChange && onContentChange(this.getIndex(rowIndex), doublekey, value);
129
+ };
130
+
131
+ onSearch = (key, rowIndex, config) => (value) => {
132
+ const {onSearch} = this.props.callback || {};
133
+ onSearch && onSearch(this.getIndex(rowIndex), key, value, config);
134
+ };
135
+
136
+ onAdd = (key) => () => {
137
+ const {onAdd} = this.props.callback || {};
138
+ onAdd && onAdd(key);
139
+ };
140
+
141
+ onRowAdd = (key, index) => () => {
142
+ const {onLink} = this.props.callback || {};
143
+ onLink && onLink(key, index, this.props.items[index]);
144
+ };
145
+
146
+ onBlur = (key, rowIndex) => (value) => {
147
+ const {onBlur} = this.props.callback || {};
148
+ this.closeValid();
149
+ onBlur && onBlur(this.getIndex(rowIndex), key, value);
150
+ };
151
+
152
+ onDoubleClick = (key, value) => () => {
153
+ const {onDoubleClick} = this.props.callback || {};
154
+ onDoubleClick && onDoubleClick(key, value);
155
+ };
156
+
157
+ onImgTileClick = (col, value, rowIndex) => () => {
158
+ const {onImgTileClick} = this.props.callback || {};
159
+ onImgTileClick && onImgTileClick(col, value, rowIndex);
160
+ };
161
+
162
+ onMoveRow = (dragIndex, targetIndex) => {
163
+ const {onMoveRow} = this.props.callback || {};
164
+ onMoveRow && onMoveRow(dragIndex, targetIndex);
165
+ };
166
+
167
+ closeValid = () => {
168
+ const {valid, callback={}} = this.props;
169
+ valid && callback.onExitValid();
170
+ };
171
+
172
+ getOptions = (key, colOptions, index) => {
173
+ const {options} = this.props.items[index];
174
+ const {options: options2} = this.props;
175
+ if (options && Array.isArray(options[key])) {
176
+ return options[key];
177
+ } else if (options2 && Array.isArray(options2[key])) {
178
+ return options2[key];
179
+ } else {
180
+ return colOptions;
181
+ }
182
+ };
183
+
184
+ validField = (required, value) => {
185
+ if (!this.props.valid || this.error || !required || value) {
186
+ return false;
187
+ } else if (typeof value === 'number') {
188
+ return false;
189
+ } else {
190
+ this.error = true;
191
+ return true;
192
+ }
193
+ };
194
+
195
+ renderEditableCell = (config, value, index) => {
196
+ const {key, type, options, props, required, width, showRowAdd} = config;
197
+ const {readonly, isReadonly=[], isRequired=[],_extraProps={}} = this.props.items[index];
198
+ const cellProps = {
199
+ value, width,
200
+ items:this.props.items[index],
201
+ type: readonly || (Array.isArray(isReadonly) && isReadonly.includes(key)) || this.props.readonly ? 'readonly' : type,
202
+ props: readonly ? {} : props,
203
+ error: this.validField(required, value),
204
+ options: this.getOptions(key, options, index),
205
+ onChange: this.onChange(key, index),
206
+ onSearch: this.onSearch(key, index, config),
207
+ onBlur: this.onBlur(key, index)
208
+ };
209
+ if(showRowAdd && Array.isArray(isRequired) && isRequired.includes(key)){
210
+ cellProps.error = this.validField(true, value);
211
+ cellProps.props = {...cellProps.props, ..._extraProps};
212
+ return (<div>
213
+ <span style={{color: 'red', display: 'inline-block'}}>*</span>
214
+ <span style={{marginLeft: '5px', display: 'inline-block', width: 'calc(100% - 12px)'}}>
215
+ <SuperTableCell {...cellProps} />
216
+ </span>
217
+ <span style={{color: '#2196f3', verticalAlign: 'super'}}>
218
+ <Icon type='plus-circle-o' role='add' onClick={this.onRowAdd(key, index)}/>
219
+ </span>
220
+ </div>);
221
+ }
222
+ if(Array.isArray(isRequired) && isRequired.includes(key)){
223
+ cellProps.error = this.validField(true, value);
224
+ cellProps.props = {...cellProps.props, ..._extraProps};
225
+ return (<div>
226
+ <span style={{color: 'red', display: 'inline-block'}}>*</span>
227
+ <span style={{marginLeft: '5px', display: 'inline-block', width: 'calc(100% - 12px)'}}>
228
+ <SuperTableCell {...cellProps} />
229
+ </span>
230
+ </div>);
231
+ }
232
+ if(showRowAdd){
233
+ return (<div style={{clear: 'both'}}>
234
+ <span style={{marginRight: '5px', float: 'left'}}><SuperTableCell {...cellProps} /></span>
235
+ <span style={{color: '#2196f3', verticalAlign: 'middle'}}>
236
+ <Icon type='plus-circle-o' role='add' onClick={this.onRowAdd(key, index)}/>
237
+ </span>
238
+ </div>);
239
+ }
240
+ return <SuperTableCell {...cellProps} />;
241
+ };
242
+ renderDoubleEditableCell = (config, value, index) => {
243
+ const {key, type, options, props, required, width, showRowAdd} = config;
244
+ const {readonly, isReadonly=[], isRequired=[],_extraProps={}} = this.props.items[index];
245
+ const cellProps = {
246
+ value, width,
247
+ items:this.props.items[index],
248
+ type: readonly || (Array.isArray(isReadonly) && isReadonly.includes(key)) || this.props.readonly ? 'readonly' : type,
249
+ props: readonly ? {} : props,
250
+ error: this.validField(required, value),
251
+ options: this.getOptions(key, options, index),
252
+ onChange: this.onDoubleChange1(key, index),
253
+ onSearch: this.onSearch(key, index, config),
254
+ onBlur: this.onBlur(key, index)
255
+ };
256
+ return <SuperTableCell {...cellProps} />;
257
+ };
258
+ renderLinkCell = (col, value, record, index) => {
259
+ if (col.link === 'list') {
260
+ const list = value && Array.isArray(value) ? value : [];
261
+ return (
262
+ <div style={{ whiteSpace: 'pre-wrap' }}>
263
+ {list.map((item2, index2) => {
264
+ const split = index2 === list.length-1 ? '' : ',';
265
+ const onClick = () => {
266
+ const {onLink} = this.props.callback || {};
267
+ onLink && onLink(col.key, index, item2);
268
+ };
269
+ return <a key={index2} onClick={onClick}>{`${item2[col.linkTitleKey]}${split}`}</a>;
270
+ })}
271
+ </div>
272
+ )
273
+ } else {
274
+ const title = typeof col.link === 'string' ? col.link : value;
275
+ const onClick = () => {
276
+ const {onLink} = this.props.callback || {};
277
+ onLink && onLink(col.key, index, record);
278
+ };
279
+ return <a style={{whiteSpace:'normal',wordBreak:"break-all"}} onClick={onClick}>{title}</a>;
280
+ }
281
+ };
282
+
283
+ getIndex = (index) => {
284
+ return (this.props.base || 0) + index;
285
+ };
286
+
287
+ getCellRender = (col) => (value, record, index) => {
288
+ const realType = record._isEdit === true && this.canReadonly(col.type) ? col.editType : col.type;
289
+ if (!realType) {
290
+ return (<div onDoubleClick={this.onDoubleClick(col.key, record.key)}
291
+ style={{minHeight:'20px',minWidth:'100px',maxWidth:`${col.width - 16}px`,
292
+ color: col.isNeedShow ? '#1890ff' : '',
293
+ overflow:'hidden',textOverflow:'ellipsis', display:'-webkit-box', WebkitLineClamp: 2,
294
+ WebkitBoxOrient:"vertical",whiteSpace:'break-spaces'}}
295
+ title={value}>{value}</div>)
296
+ }
297
+ switch (realType) {
298
+ case 'checkbox':
299
+ return <Checkbox onChange={this.onCheck(col.key, record.key)} checked={value || false}/>;
300
+ case 'index':
301
+ return this.getIndex(index) + 1;
302
+ case 'link':
303
+ return this.renderLinkCell(col, value, record, record.key);
304
+ case 'button':
305
+ const onClick = this.props.callback.onLink ? this.props.callback.onLink.bind(null, col.key, record.key, record) : undefined;
306
+ if (col.icon === 'add') {
307
+ return <Button onClick={onClick} type="primary" shape="circle" size='small' ghost icon='plus'/>;
308
+ } else {
309
+ return <Button onClick={onClick} size='small' ghost type={col.bsStyle}>{record[col.key] || col.typeRelated}</Button>;
310
+ }
311
+ case 'switch':
312
+ return typeof value === 'string' ? <div>{value}</div> :
313
+ <Switch checkedChildren={col.props.checkedChildren || ''} unCheckedChildren={col.props.unCheckedChildren || ''}
314
+ onChange={this.onSwitch(col.key, record.key)} size='default' checked={typeof(value) === 'number' ? Boolean(value) : value || false} disabled={!(record._isEdit === true)}/>;
315
+ case 'custom':
316
+ return this.props.callback.onRenderCustom(record.key, col.key, value, col.props, col);
317
+ case 'toolbar': //showByKey为true时,每条数据中与按钮key相同的属性值决定按钮是否显示,建议key用下划线开始命名,避免与后台数据冲突
318
+ const props = {
319
+ onClick:this.props.callback.onToolbar ? this.props.callback.onToolbar.bind(null, col.key, record.key, record) : undefined,
320
+ buttons: col.props.showByKey ? col.props.buttons.filter(item =>record[item.key] === true) : col.props.buttons.filter(item => {return item.defaultShow === !record._isEdit})
321
+ };
322
+ return <SuperToolbar {...props} />;
323
+ case 'img':
324
+ return value ? ( typeof(value) === 'string' ?
325
+ <img src={value.includes('http') ? value : `${window.location.origin}/api/proxy/file-center-service/${value}`} style={{width:'80px', height: '80px'}}/> :
326
+ ( <div role={'imgBox'} style={{maxWidth:`${col.width}px`}}>
327
+ <img src={ value.img === '' ?'/productDefault.png' : value.img.includes('http') ? value.img : `${window.location.origin}/api/proxy/file-center-service/${value.img}`}
328
+ onError={(e) => e.target.src = '/productDefault.png'}
329
+ style={{width:'80px', height: '80px'}}/>
330
+ <div style={{display:'inline-block'}}>
331
+ <span style={{display:'block',whiteSpace:'nowrap',overflow:'hidden',textOverflow:'ellipsis', width:'100px'}} onClick={this.onImgTileClick(col,record,index)}>{value.title}</span>
332
+ {helper.isEmpty2(value.remark) ? null : <span style={{display:'block',whiteSpace:'nowrap',overflow:'hidden',textOverflow:'ellipsis', width:'100px',color:'#333'}}>{value.remark}</span> }
333
+ </div>
334
+ </div>
335
+ )
336
+ ) : (<div></div>)
337
+ case 'uploadImg':
338
+ const commonProps = this.props.callback.buildSuperUploadProps ? this.props.callback.buildSuperUploadProps() : {};
339
+ const uploadProps = {
340
+ onFileChange:this.props.callback.onTableFileChange ? this.props.callback.onTableFileChange.bind(null, col.key, index) : undefined,
341
+ type:col.type,...col.props,
342
+ ...this.props,
343
+ ...commonProps,
344
+ value:this.props.items[index][col.key]
345
+ };
346
+ return <Control {...uploadProps} />
347
+ case 'double':
348
+ return this.renderDoubleEditableCell({...col,type:realType}, value, record.key);
349
+ default:
350
+ return this.renderEditableCell({...col,type:realType}, value, record.key);
351
+ }
352
+ };
353
+
354
+ getCheckedStatus = (key) => {
355
+ let has = false, not = false;
356
+ const {items} = this.props;
357
+ for (const item of items) {
358
+ item[key] ? (has = true) : (not = true);
359
+ }
360
+ return {checked: has && !not, indeterminate: has && not};
361
+ };
362
+
363
+ toAdd = (key, showAdd) => {
364
+ if (showAdd) {
365
+ const onClick = this.onAdd(key);
366
+ return <Icon type='plus-circle-o' role='add' onClick={onClick} />;
367
+ } else {
368
+ return null;
369
+ }
370
+ };
371
+
372
+ getColumnTitle = ({required, title, type, key, showAdd}) => {
373
+ if (type === 'checkbox') {
374
+ const status = this.getCheckedStatus(key);
375
+ return <Checkbox onChange={this.onCheck(key, -1)} {...status} />;
376
+ } else {
377
+ const className = required ? 'ant-form-item-required' : '';
378
+ return (
379
+ <span className={className}>
380
+ {title}
381
+ {this.toAdd(key, showAdd)}
382
+ </span>
383
+ );
384
+ }
385
+ };
386
+
387
+ getColumnClassName = ({type, align}) => {
388
+ if (type === 'index' || type === 'checkbox') {
389
+ return 'ant-table-selection-column';
390
+ } else {
391
+ return align ? variables('SuperTable2')[align] : '';
392
+ }
393
+ };
394
+
395
+ canReadonly = (type) => {
396
+ return !['index', 'checkbox', 'link', 'button', 'switch', 'custom', 'img','toolbar','uploadImg','double'].includes(type);
397
+ };
398
+
399
+ getColumns = (cols) => {
400
+ const readonly = this.props.readonly;
401
+ return cols.filter(col => !col.hide).map(({...col},index) => {
402
+ col.className = this.getColumnClassName(col);
403
+ col.title = this.getColumnTitle(col);
404
+ col.dataIndex = col.key;
405
+ col.width = col.width ? col.width : (['index','checked'].includes(col.key) ? 70 : (col.type === 'img' ? 200 : 120));
406
+ // const {props = {}} =
407
+ // const {edit = false} = props
408
+ // if (!(readonly || col.type === 'readonly') || !this.canReadonly(col.type)) {
409
+ // if ( !edit && ['text', 'number', 'select', 'date', 'search', 'readonly', 'textArea', 'selectSearch'].includes(col.type)){
410
+ // return col
411
+ // }
412
+ // }
413
+ col.readonly = readonly;
414
+ col.render = this.getCellRender(col);
415
+ if (col.link) {
416
+ col.type = 'link';
417
+ col.render = this.getCellRender(col);
418
+ }else if (col.showPrice || col.decimalPlaces){
419
+ col.render = (text, record, index) => {
420
+ if (col.showPrice && text) {
421
+ text=helper.toThousands(text,col.decimalPlaces?col.decimalPlaces:2,)
422
+ return `¥${text}`
423
+ }else{
424
+ return text?`¥${text.toFixed(2)}`:text
425
+ }
426
+ }
427
+ }
428
+ return col;
429
+ });
430
+ };
431
+
432
+ getDataSource = (items, cols) => {
433
+ return items.map((item, index) => {
434
+ return cols.reduce((result, {key, type, options}) => {
435
+ if ((!this.props.readonly && type && type !== 'readonly' &&
436
+ (!item.isReadonly || (Array.isArray(item.isReadonly) && !item.isReadonly.includes(key)))) || ['img', 'switch', 'custom', 'img','toolbar','uploadImg'].includes(type)) {
437
+ result[key] = item[key];
438
+ } else {
439
+ result[key] = getTitle(item[key], options);
440
+ }
441
+ return result;
442
+ }, {...item, key: index, disabled: item.isCanConfigHide});
443
+ });
444
+ };
445
+
446
+ getPropsByCheckbox = () => {
447
+ const {items, isEmphasized=false} = this.props;
448
+ const rowClassName = (record) => {
449
+ if (isEmphasized && items[record.key].__isEmphasized) {
450
+ return items[record.key].checked ? variables('SuperTable2').emphasizedSelectRow : variables('SuperTable2').emphasizedUnselectRow;
451
+ }
452
+ return items[record.key].checked ? variables('SuperTable2').select : '';
453
+ };
454
+ return {rowClassName};
455
+ };
456
+
457
+ getSelectedRowKeys = (items) => {
458
+ return items.reduce((result, item, index) => {
459
+ item.checked && result.push(index);
460
+ return result;
461
+ }, []);
462
+ };
463
+
464
+ getPropsByCheckbox2 = (items) => {
465
+ const {checkbox=true, radio=false, isolation, checkedRows=[],isEmphasized=false, isWeaken=true} = this.props;
466
+ const rowClassName1 = (record) => {
467
+ if (items[record.key].__total) return variables('SuperTable').totalRow;
468
+ if(items[record.key].__warningRow) return variables('SuperTable').warningRow;
469
+ return checkedRows.includes(record.key) ? variables('SuperTable').select : '';
470
+ };
471
+ const rowClassName2 = (record) => {
472
+ if (items[record.key].__total) return variables('SuperTable').totalRow;
473
+ if(items[record.key].__warningRow) return variables('SuperTable').warningRow;
474
+ if (isEmphasized && items[record.key].__isEmphasized) {
475
+ return items[record.key].checked ? variables('SuperTable').emphasizedSelectRow : variables('SuperTable').emphasizedUnselectRow;
476
+ }
477
+ if (isWeaken && items[record.key].__isWeaken) {
478
+ return items[record.key].checked ? variables('SuperTable').weakenedSelectRow : variables('SuperTable').weakenedUnselectRow;
479
+ }
480
+ return items[record.key].checked ? variables('SuperTable').select : '';
481
+ };
482
+ if (checkbox) {
483
+ if (radio) {
484
+ return {
485
+ rowClassName: rowClassName1,
486
+ onRowClick: this.onRadioRowClick,
487
+ rowSelection: {
488
+ type: 'radio',
489
+ selectedRowKeys: checkedRows,
490
+ onChange: this.onRadioChange
491
+ }
492
+ }
493
+ } else if (isolation) {
494
+ return {
495
+ rowClassName: rowClassName1,
496
+ onRowClick: this.onRowClick,
497
+ rowSelection: {
498
+ selectedRowKeys: checkedRows,
499
+ onChange: this.onCheckChange,
500
+ getCheckboxProps: (record) => {
501
+ const checked = checkedRows.includes(record.key);
502
+ return {
503
+ checked,
504
+ disabled: items[record.key].__isWeaken,
505
+ style: items[record.key].__total ? {display: 'none'} : {}
506
+ }
507
+ },
508
+ }
509
+ }
510
+ } else {
511
+ return {
512
+ rowClassName: rowClassName2,
513
+ onRowClick: this.onRowClick,
514
+ rowSelection: {
515
+ selectedRowKeys: this.getSelectedRowKeys(items),
516
+ onChange: this.onChange,
517
+ getCheckboxProps: (record) => {
518
+ const checked = isWeaken && items[record.key].__isWeaken ? false : !!record.checked;
519
+ return {
520
+ checked,
521
+ disabled: items[record.key].__isWeaken,
522
+ style: items[record.key].__total ? {display: 'none'} : {}
523
+ }
524
+ },
525
+ }
526
+ }
527
+ }
528
+ } else {
529
+ return {
530
+ rowClassName: rowClassName2,
531
+ };
532
+ }
533
+ };
534
+
535
+ getRowPropsForDrag = () => {
536
+ return (record, index) => {
537
+ return {
538
+ index,
539
+ onMoveRow: this.onMoveRow
540
+ };
541
+ }
542
+ };
543
+
544
+ getRowProps = (onRowClick) => {
545
+ return (record) => {
546
+ return {
547
+ onClick: () => onRowClick && onRowClick(record),
548
+ onDoubleClick: () => this.onDoubleClick(record)
549
+ };
550
+ };
551
+ };
552
+
553
+ getProps = () => {
554
+ const {cols, items, style={},footer=null, pagination = false,dragSort, isEmphasized=false, maxHeight,expandedRowRender=undefined,onExpand=undefined} = this.props;
555
+ const widthX = cols.filter(col => !col.hide).reduce((width,item) => {
556
+ return width += item.width ? item.width : ['index','checked'].includes(item.key) ? 70 : item.type === 'img' ? 200 : 120;
557
+ },0);
558
+ const scrollProps = !helper.isEmpty2(expandedRowRender) ? {expandedRowRender} : {scroll: {x: cols.some(item => !(helper.isEmpty2(item.fixed))) ? widthX : true, y: maxHeight}}
559
+ const {onRowClick, ...extraProps} = this.getPropsByCheckbox2(items);
560
+ return {
561
+ className: !isEmphasized ? variables('SuperTable2') : variables('SuperTable2').noTransition,
562
+ columns: this.getColumns(cols),
563
+ dataSource: this.getDataSource(items, cols),
564
+ style: Object.assign({}, {whiteSpace: 'nowrap'}, style),
565
+ size: 'small',
566
+ pagination,
567
+ footer,
568
+ onRow: dragSort ? this.getRowPropsForDrag(): this.getRowProps(onRowClick),
569
+ components: dragSort ? {body: {row: DragSortRow}} : {},
570
+ locale: this.props.emptyText ? {emptyText: this.props.emptyText} : null,
571
+ ...this.getPropsByCheckbox(),
572
+ onExpand,
573
+ ...scrollProps
574
+ };
575
+ };
576
+
577
+ setScroll = () => {
578
+ if (this.props.maxHeight && this.props.items.length) {
579
+ const root = ReactDOM.findDOMNode(this);
580
+ const container = root.getElementsByClassName('ant-table-body')[0];
581
+ const header = root.getElementsByClassName('ant-table-thead')[0];
582
+ fixed(container, header, this.props.maxHeight);
583
+ }
584
+ };
585
+
586
+ componentDidMount() {
587
+ this.setScroll();
588
+ }
589
+
590
+ componentDidUpdate() {
591
+ this.setScroll();
592
+ }
593
+
594
+ render() {
595
+ this.error = false;
596
+ return <Table {...this.getProps()} key={this.props.items.length} />;
597
+ }
598
+ }
599
+
600
+ export default SuperTable2;