cloud-b2b 1.1.57 → 1.1.59

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