cloud-b2b 1.1.51 → 1.1.53

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