cloud-b2b 1.1.59 → 1.1.61

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/{src → es}/Search2/Search.less +0 -1
  30. package/es/Sidebar/Sidebar.js +144 -0
  31. package/es/Sidebar2/Sidebar.js +165 -0
  32. package/es/SuperForm/SuperForm.js +598 -0
  33. package/es/SuperForm2/SuperForm.js +687 -0
  34. package/es/SuperIcon/SuperIcon.js +27 -0
  35. package/es/SuperPagination/SuperPagination.js +109 -0
  36. package/es/SuperTab/SuperTab.js +107 -0
  37. package/es/SuperTab2/SuperTab2.js +145 -0
  38. package/es/SuperTable/DragSortRow.js +97 -0
  39. package/es/SuperTable/FilterDropDown.js +164 -0
  40. package/es/SuperTable/SuperTable.js +808 -0
  41. package/es/SuperTable/fixed.js +34 -0
  42. package/es/SuperTable2/SuperTable2.js +926 -0
  43. package/{src → es}/SuperTable2/SuperTable2.less +2 -1
  44. package/es/SuperTable2/SuperTableCell.js +234 -0
  45. package/es/SuperTable3/FilterDropDown.js +164 -0
  46. package/es/SuperTable3/SuperTable.js +665 -0
  47. package/es/SuperTable3/fixed.js +34 -0
  48. package/es/SuperToolbar/SuperToolbar.js +195 -0
  49. package/es/SuperUpload/SuperUpload.js +356 -0
  50. package/es/Title/Title.js +33 -0
  51. package/es/Viewer/ImageViews.js +258 -0
  52. package/es/Viewer/Viewer.js +122 -0
  53. package/es/WingBlank/WingBlank.js +16 -0
  54. package/es/helper.js +240 -0
  55. package/{src → es}/history.js +6 -6
  56. package/es/index.js +38 -0
  57. package/{src → es}/style.less +2 -1
  58. package/es/variables.js +6 -0
  59. package/lib/Area/Area.js +149 -0
  60. package/lib/Area/package.json +6 -0
  61. package/lib/Card/Card.js +27 -0
  62. package/lib/Card/package.json +6 -0
  63. package/lib/CodeInput/CodeInput.js +131 -0
  64. package/lib/CodeInput/package.json +6 -0
  65. package/lib/Control/Control.js +450 -0
  66. package/lib/Control/event.js +51 -0
  67. package/lib/Control/package.json +6 -0
  68. package/lib/Enhance/Dialogs.js +60 -0
  69. package/lib/Enhance/Loading.js +138 -0
  70. package/lib/Enhance/index.js +25 -0
  71. package/lib/Enhance/package.json +6 -0
  72. package/lib/Header/Header.js +169 -0
  73. package/lib/Header/Header.less +95 -0
  74. package/lib/Header/Vertical.js +114 -0
  75. package/lib/Header/Vertical.less +60 -0
  76. package/lib/Header/package.json +6 -0
  77. package/lib/ImageView/ImageView.js +108 -0
  78. package/lib/ImageView/ImageView.less +14 -0
  79. package/lib/ImageView/package.json +6 -0
  80. package/lib/Indent/Indent.js +27 -0
  81. package/lib/Indent/package.json +6 -0
  82. package/lib/InpurCascader/InputCascader.js +124 -0
  83. package/lib/InpurCascader/package.json +6 -0
  84. package/lib/InputEditor/InputEditor.js +181 -0
  85. package/lib/InputEditor/inputEditor.less +8 -0
  86. package/lib/InputEditor/package.json +6 -0
  87. package/lib/InputSearch/InputSearch.js +274 -0
  88. package/lib/InputSearch/package.json +6 -0
  89. package/lib/InputSelect/InputSelect.js +168 -0
  90. package/lib/InputSelect/package.json +6 -0
  91. package/lib/InputTreeSelect/InputTreeSelect.js +128 -0
  92. package/lib/InputTreeSelect/package.json +6 -0
  93. package/lib/InputWriting/InputWriting.js +93 -0
  94. package/lib/InputWriting/package.json +6 -0
  95. package/lib/Layout/Layout.js +209 -0
  96. package/lib/Layout/Layout.less +28 -0
  97. package/lib/Layout/package.json +6 -0
  98. package/lib/LayoutLink/LayoutLink.js +86 -0
  99. package/lib/LayoutLink/LayoutLink.less +53 -0
  100. package/lib/LayoutLink/package.json +6 -0
  101. package/lib/Link/Link.js +93 -0
  102. package/lib/Link/package.json +6 -0
  103. package/lib/Loading/Loading.js +21 -0
  104. package/lib/Loading/Loading.less +13 -0
  105. package/lib/Loading/package.json +6 -0
  106. package/lib/Loading2/Loading2.js +17 -0
  107. package/lib/Loading2/Loading2.less +19 -0
  108. package/lib/Loading2/package.json +6 -0
  109. package/lib/ModalWithDrag/ModalWithDrag.js +37 -0
  110. package/lib/ModalWithDrag/ModalWithDrag.less +6 -0
  111. package/lib/ModalWithDrag/drag.js +124 -0
  112. package/lib/ModalWithDrag/package.json +6 -0
  113. package/lib/NumberInput/NumberInput.js +208 -0
  114. package/lib/NumberInput/package.json +6 -0
  115. package/lib/Search/Search.js +510 -0
  116. package/lib/Search/Search.less +63 -0
  117. package/lib/Search/package.json +6 -0
  118. package/lib/Search2/Search.js +609 -0
  119. package/lib/Search2/Search.less +64 -0
  120. package/lib/Search2/package.json +6 -0
  121. package/lib/Sidebar/Sidebar.js +152 -0
  122. package/lib/Sidebar/Sidebar.less +78 -0
  123. package/lib/Sidebar/package.json +6 -0
  124. package/lib/Sidebar2/Sidebar.js +173 -0
  125. package/lib/Sidebar2/Sidebar.less +153 -0
  126. package/lib/Sidebar2/package.json +6 -0
  127. package/lib/SuperForm/SuperForm.js +610 -0
  128. package/lib/SuperForm/SuperForm.less +52 -0
  129. package/lib/SuperForm/package.json +6 -0
  130. package/lib/SuperForm2/SuperForm.js +699 -0
  131. package/lib/SuperForm2/SuperForm.less +52 -0
  132. package/lib/SuperForm2/package.json +6 -0
  133. package/lib/SuperIcon/SuperIcon.js +35 -0
  134. package/lib/SuperIcon/package.json +6 -0
  135. package/lib/SuperPagination/SuperPagination.js +117 -0
  136. package/lib/SuperPagination/package.json +6 -0
  137. package/lib/SuperTab/SuperTab.js +115 -0
  138. package/lib/SuperTab/SuperTab.less +43 -0
  139. package/lib/SuperTab/package.json +6 -0
  140. package/lib/SuperTab2/SuperTab2.js +153 -0
  141. package/lib/SuperTab2/SuperTab2.less +18 -0
  142. package/lib/SuperTab2/package.json +6 -0
  143. package/lib/SuperTable/DragSortRow.js +105 -0
  144. package/lib/SuperTable/DragSortRow.less +17 -0
  145. package/lib/SuperTable/FilterDropDown.js +172 -0
  146. package/lib/SuperTable/FilterDropDown.less +30 -0
  147. package/lib/SuperTable/SuperTable.js +816 -0
  148. package/lib/SuperTable/SuperTable.less +132 -0
  149. package/lib/SuperTable/fixed.js +42 -0
  150. package/lib/SuperTable/package.json +6 -0
  151. package/lib/SuperTable2/SuperTable2.js +939 -0
  152. package/lib/SuperTable2/SuperTable2.less +119 -0
  153. package/lib/SuperTable2/SuperTableCell.js +239 -0
  154. package/lib/SuperTable2/package.json +6 -0
  155. package/lib/SuperTable3/FilterDropDown.js +172 -0
  156. package/lib/SuperTable3/FilterDropDown.less +29 -0
  157. package/lib/SuperTable3/SuperTable.js +673 -0
  158. package/lib/SuperTable3/SuperTable.less +99 -0
  159. package/lib/SuperTable3/fixed.js +42 -0
  160. package/lib/SuperTable3/package.json +6 -0
  161. package/lib/SuperToolbar/SuperToolbar.js +203 -0
  162. package/lib/SuperToolbar/SuperToolbar.less +17 -0
  163. package/lib/SuperToolbar/package.json +6 -0
  164. package/lib/SuperUpload/SuperUpload.js +368 -0
  165. package/lib/SuperUpload/SuperUpload.less +28 -0
  166. package/lib/SuperUpload/package.json +6 -0
  167. package/lib/Title/Title.js +41 -0
  168. package/lib/Title/Title.less +35 -0
  169. package/lib/Title/package.json +6 -0
  170. package/lib/Viewer/ImageViews.js +266 -0
  171. package/lib/Viewer/Viewer.js +130 -0
  172. package/lib/Viewer/Viewer.less +67 -0
  173. package/lib/Viewer/imgView.less +59 -0
  174. package/lib/Viewer/package.json +7 -0
  175. package/lib/WingBlank/WingBlank.js +24 -0
  176. package/lib/WingBlank/WingBlank.less +12 -0
  177. package/lib/WingBlank/package.json +6 -0
  178. package/lib/adjust.less +89 -0
  179. package/lib/helper.js +246 -0
  180. package/lib/history.js +12 -0
  181. package/lib/index.js +278 -0
  182. package/lib/index.less +32 -0
  183. package/lib/style.less +31 -0
  184. package/lib/variables.js +14 -0
  185. package/lib/variables.less +73 -0
  186. package/package.json +22 -44
  187. package/src/Area/Area.js +0 -94
  188. package/src/Card/Card.js +0 -16
  189. package/src/CodeInput/CodeInput.js +0 -76
  190. package/src/Control/Control.js +0 -338
  191. package/src/Control/event.js +0 -45
  192. package/src/Enhance/Dialogs.js +0 -24
  193. package/src/Enhance/Loading.js +0 -83
  194. package/src/Header/Header.js +0 -149
  195. package/src/Header/Vertical.js +0 -74
  196. package/src/ImageView/ImageView.js +0 -62
  197. package/src/Indent/Indent.js +0 -12
  198. package/src/InpurCascader/InputCascader.js +0 -83
  199. package/src/InputEditor/InputEditor.js +0 -93
  200. package/src/InputSearch/InputSearch.js +0 -186
  201. package/src/InputSelect/InputSelect.js +0 -103
  202. package/src/InputTreeSelect/InputTreeSelect.js +0 -87
  203. package/src/InputWriting/InputWriting.js +0 -65
  204. package/src/Layout/Layout.js +0 -121
  205. package/src/LayoutLink/LayoutLink.js +0 -59
  206. package/src/Link/Link.js +0 -57
  207. package/src/Loading/Loading.js +0 -15
  208. package/src/Loading2/Loading2.js +0 -15
  209. package/src/ModalWithDrag/ModalWithDrag.js +0 -17
  210. package/src/NumberInput/NumberInput.js +0 -137
  211. package/src/Search/Search.js +0 -368
  212. package/src/Search2/Search.js +0 -436
  213. package/src/Sidebar/Sidebar.js +0 -111
  214. package/src/Sidebar2/Sidebar.js +0 -143
  215. package/src/SuperForm/SuperForm.js +0 -519
  216. package/src/SuperForm2/SuperForm.js +0 -588
  217. package/src/SuperIcon/SuperIcon.js +0 -14
  218. package/src/SuperPagination/SuperPagination.js +0 -65
  219. package/src/SuperTab/SuperTab.js +0 -84
  220. package/src/SuperTab2/SuperTab2.js +0 -94
  221. package/src/SuperTable/DragSortRow.js +0 -62
  222. package/src/SuperTable/FilterDropDown.js +0 -111
  223. package/src/SuperTable/SuperTable.js +0 -590
  224. package/src/SuperTable/fixed.js +0 -34
  225. package/src/SuperTable2/SuperTable2.js +0 -624
  226. package/src/SuperTable2/SuperTableCell.js +0 -175
  227. package/src/SuperTable3/FilterDropDown.js +0 -111
  228. package/src/SuperTable3/SuperTable.js +0 -498
  229. package/src/SuperTable3/fixed.js +0 -34
  230. package/src/SuperToolbar/SuperToolbar.js +0 -128
  231. package/src/SuperUpload/SuperUpload.js +0 -137
  232. package/src/Title/Title.js +0 -18
  233. package/src/Viewer/ImageViews.js +0 -220
  234. package/src/Viewer/Viewer.js +0 -97
  235. package/src/WingBlank/WingBlank.js +0 -14
  236. package/src/helper.js +0 -185
  237. package/src/index.js +0 -39
  238. package/src/variables.js +0 -5
  239. package/test/index.html +0 -10
  240. package/test/test.js +0 -16
  241. package/test/test.less +0 -12
  242. package/test/webpack.config.js +0 -71
  243. package/tools/babel.config.js +0 -14
  244. package/tools/build.js +0 -70
  245. package/tools/publish.js +0 -9
  246. package/tools/util.js +0 -53
  247. /package/{src → es}/Area/package.json +0 -0
  248. /package/{src → es}/Card/package.json +0 -0
  249. /package/{src → es}/CodeInput/package.json +0 -0
  250. /package/{src → es}/Control/package.json +0 -0
  251. /package/{src → es}/Enhance/package.json +0 -0
  252. /package/{src → es}/Header/Header.less +0 -0
  253. /package/{src → es}/Header/Vertical.less +0 -0
  254. /package/{src → es}/Header/package.json +0 -0
  255. /package/{src → es}/ImageView/ImageView.less +0 -0
  256. /package/{src → es}/ImageView/package.json +0 -0
  257. /package/{src → es}/Indent/package.json +0 -0
  258. /package/{src → es}/InpurCascader/package.json +0 -0
  259. /package/{src → es}/InputEditor/inputEditor.less +0 -0
  260. /package/{src → es}/InputEditor/package.json +0 -0
  261. /package/{src → es}/InputSearch/package.json +0 -0
  262. /package/{src → es}/InputSelect/package.json +0 -0
  263. /package/{src → es}/InputTreeSelect/package.json +0 -0
  264. /package/{src → es}/InputWriting/package.json +0 -0
  265. /package/{src → es}/Layout/Layout.less +0 -0
  266. /package/{src → es}/Layout/package.json +0 -0
  267. /package/{src → es}/LayoutLink/LayoutLink.less +0 -0
  268. /package/{src → es}/LayoutLink/package.json +0 -0
  269. /package/{src → es}/Link/package.json +0 -0
  270. /package/{src → es}/Loading/Loading.less +0 -0
  271. /package/{src → es}/Loading/package.json +0 -0
  272. /package/{src → es}/Loading2/Loading2.less +0 -0
  273. /package/{src → es}/Loading2/package.json +0 -0
  274. /package/{src → es}/ModalWithDrag/ModalWithDrag.less +0 -0
  275. /package/{src → es}/ModalWithDrag/package.json +0 -0
  276. /package/{src → es}/NumberInput/package.json +0 -0
  277. /package/{src → es}/Search/Search.less +0 -0
  278. /package/{src → es}/Search/package.json +0 -0
  279. /package/{src → es}/Search2/package.json +0 -0
  280. /package/{src → es}/Sidebar/Sidebar.less +0 -0
  281. /package/{src → es}/Sidebar/package.json +0 -0
  282. /package/{src → es}/Sidebar2/Sidebar.less +0 -0
  283. /package/{src → es}/Sidebar2/package.json +0 -0
  284. /package/{src → es}/SuperForm/SuperForm.less +0 -0
  285. /package/{src → es}/SuperForm/package.json +0 -0
  286. /package/{src → es}/SuperForm2/SuperForm.less +0 -0
  287. /package/{src → es}/SuperForm2/package.json +0 -0
  288. /package/{src → es}/SuperIcon/package.json +0 -0
  289. /package/{src → es}/SuperPagination/package.json +0 -0
  290. /package/{src → es}/SuperTab/SuperTab.less +0 -0
  291. /package/{src → es}/SuperTab/package.json +0 -0
  292. /package/{src → es}/SuperTab2/SuperTab2.less +0 -0
  293. /package/{src → es}/SuperTab2/package.json +0 -0
  294. /package/{src → es}/SuperTable/DragSortRow.less +0 -0
  295. /package/{src → es}/SuperTable/FilterDropDown.less +0 -0
  296. /package/{src → es}/SuperTable/SuperTable.less +0 -0
  297. /package/{src → es}/SuperTable/package.json +0 -0
  298. /package/{src → es}/SuperTable2/package.json +0 -0
  299. /package/{src → es}/SuperTable3/FilterDropDown.less +0 -0
  300. /package/{src → es}/SuperTable3/SuperTable.less +0 -0
  301. /package/{src → es}/SuperTable3/package.json +0 -0
  302. /package/{src → es}/SuperToolbar/SuperToolbar.less +0 -0
  303. /package/{src → es}/SuperToolbar/package.json +0 -0
  304. /package/{src → es}/SuperUpload/SuperUpload.less +0 -0
  305. /package/{src → es}/SuperUpload/package.json +0 -0
  306. /package/{src → es}/Title/Title.less +0 -0
  307. /package/{src → es}/Title/package.json +0 -0
  308. /package/{src → es}/Viewer/Viewer.less +0 -0
  309. /package/{src → es}/Viewer/imgView.less +0 -0
  310. /package/{src → es}/Viewer/package.json +0 -0
  311. /package/{src → es}/WingBlank/WingBlank.less +0 -0
  312. /package/{src → es}/WingBlank/package.json +0 -0
  313. /package/{src → es}/adjust.less +0 -0
  314. /package/{src → es}/variables.less +0 -0
@@ -1,624 +0,0 @@
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;