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,143 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import Link from '../Link';
4
- import {Icon} from 'antd';
5
- import variables from '../variables';
6
-
7
- const ITEM_HEIGHT = 40;
8
-
9
- /** 侧边栏二级条目的类型
10
- * key: 唯一标识一个条目
11
- * title:条目的标题
12
- * href: 为跳转页面的url
13
- */
14
- const ChildType = {
15
- key: PropTypes.string.isRequired,
16
- title: PropTypes.string.isRequired,
17
- href: PropTypes.string.isRequired
18
- };
19
-
20
- /** 侧边栏一级条目的类型
21
- * key: 唯一标识一个条目
22
- * title:条目的标题
23
- * isFolder:为true表明有下级菜单,此时href被忽略,children存放下级菜单的信息
24
- * href: isFolder为false时,为跳转页面的url,否则被忽略
25
- * children:isFolder为true时,存放下级菜单的信息,否则被忽略
26
- */
27
- const ItemType = {
28
- key: PropTypes.string.isRequired,
29
- title: PropTypes.string.isRequired,
30
- isFolder: PropTypes.bool,
31
- href: PropTypes.string,
32
- children: PropTypes.arrayOf(PropTypes.shape(ChildType))
33
- };
34
-
35
- /**
36
- * title: 侧边栏的标题
37
- * mode: 显示模式,默认为expand(展开)
38
- * activeKey:指定被选中的一级条目的key,不能是二级条目的key
39
- * items:存放所有侧边栏条目的信息
40
- * openKeys: 展开条目的key
41
- * style: 样式
42
- * onOpenChange: 展开条目信息改变时触发,原型为func(openKeys)
43
- * onModeChange: 模式改变时触发,原型为func(mode)
44
- */
45
- class Sidebar extends React.Component {
46
- static propTypes = {
47
- title: PropTypes.string,
48
- mode: PropTypes.oneOf(['collapse', 'expand']),
49
- activeKey: PropTypes.string,
50
- items: PropTypes.arrayOf(PropTypes.shape(ItemType)),
51
- openKeys: PropTypes.array,
52
- style: PropTypes.object,
53
- onOpenChange: PropTypes.func,
54
- onModeChange: PropTypes.func
55
- };
56
-
57
- onModeChange = () => {
58
- const mode = this.props.mode || 'expand';
59
- this.props.onModeChange(mode === 'expand' ? 'collapse' : 'expand');
60
- };
61
-
62
- isSelect = (item) => {
63
- return this.props.activeKey === item.key;
64
- };
65
-
66
- isOpen = (item) => {
67
- return this.props.openKeys.includes(item.key);
68
- };
69
-
70
- getHeight = (item) => {
71
- if (item.isFolder && this.isOpen(item)) {
72
- return (item.children.length + 1) * ITEM_HEIGHT;
73
- } else {
74
- return ITEM_HEIGHT;
75
- }
76
- };
77
-
78
- linkProps = (item) => {
79
- if (item.isFolder) {
80
- return {
81
- title: item.title,
82
- onClick: () => {
83
- if (this.isOpen(item)) {
84
- this.props.onOpenChange(this.props.openKeys.filter(key => item.key !== key));
85
- } else {
86
- this.props.onOpenChange([...this.props.openKeys, item.key]);
87
- }
88
- }
89
- }
90
- } else {
91
- return {
92
- title: item.title,
93
- to: item.href,
94
- 'data-select': this.isSelect(item)
95
- };
96
- }
97
- };
98
-
99
- renderChild = (item, index) => {
100
- return (
101
- <li key={index}>
102
- <Link {...this.linkProps(item)} data-role='child-item'>
103
- <span>{item.title}</span>
104
- {item.unreadTotal && item.unreadTotal>0 && <span className={variables('Sidebar2').unreadTotal}>{item.unreadTotal}</span>}
105
- </Link>
106
- </li>
107
- );
108
- };
109
-
110
- renderItem = (item, index) => {
111
- return (
112
- <li key={index} style={{height: this.getHeight(item)}}>
113
- <Link {...this.linkProps(item)} data-role='parent-item'>
114
- <span>{item.isFolder ? <Icon type='caret-right' data-open={this.isOpen(item)} /> : null}</span>
115
- <span>{item.title}</span>
116
- </Link>
117
- {item.isFolder && this.isOpen(item) ? <ul>{item.children.map(this.renderChild)}</ul> : null}
118
- </li>
119
- );
120
- };
121
-
122
- render() {
123
- return (
124
- <div className={variables('Sidebar2')} data-mode={this.props.mode || 'expand'}>
125
- <div>
126
- <span> </span>
127
- <span>{this.props.title}</span>
128
- </div>
129
- <ul>{this.props.items.map(this.renderItem)}</ul>
130
- {!this.props.onModeChange ? null : (
131
- <div data-role='shousuo' onClick={this.onModeChange}>
132
- <div>
133
- <i />
134
- <div><Icon type={this.props.mode === 'expand' ? 'left' : 'right'} /></div>
135
- </div>
136
- </div>
137
- )}
138
- </div>
139
- );
140
- }
141
- }
142
-
143
- export default Sidebar;
@@ -1,516 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import ReactDOM from 'react-dom';
4
- import helper from '../helper';
5
- import Control, {getTitle, makeString} from '../Control';
6
- import {Icon, Form, Row, Col,Checkbox} from 'antd';
7
- import variables from '../variables';
8
-
9
- const FormItem = Form.Item;
10
- const defaultSize = 'small';
11
- const defaultColNum = 4;
12
-
13
- const TYPE = [
14
- 'readonly',
15
- 'text',
16
- 'search',
17
- 'searchText',
18
- 'select',
19
- 'selectText',
20
- 'radioGroup',
21
- 'number',
22
- 'date',
23
- 'textArea',
24
- 'password',
25
- 'editor',
26
- 'selectWriting',
27
- 'selectSearch',
28
- 'empty',
29
- 'area',
30
- 'uploadImg',
31
- 'cascader',
32
- 'treeSelect'
33
- ];
34
-
35
- /**
36
- * key:[必须],用于唯一标识该Form下的一个表单元素
37
- * title:[必须],表单元素的标签
38
- * type:[必须],表单元素类型
39
- * required: [可选],是否为必填项
40
- * options: [可选],对象数组(type为readonly,radio,search, searchText,select, selectText时有效)
41
- * span: [可选],占据的列数,默认为1
42
- * showAdd: [可选],是否显示+号,点击+号会触发onAdd事件,默认为false
43
- * rule: [可选],用于设置校验规则
44
- * highLightKeys: [可选],用于设置高亮样式,仅只读字段生效
45
- */
46
- const ControlType = {
47
- key: PropTypes.string.isRequired,
48
- title: PropTypes.string,
49
- type: PropTypes.oneOf(TYPE).isRequired,
50
- required: PropTypes.bool,
51
- options: PropTypes.array,
52
- span: PropTypes.number,
53
- onCheckItem: PropTypes.any,
54
- showAdd: PropTypes.any,
55
- rule: PropTypes.object,
56
- props: PropTypes.object
57
- };
58
-
59
- class Controlled extends React.Component {
60
- constructor(props) {
61
- super(props);
62
- this.state = {value: props.value};
63
- }
64
-
65
- componentWillReceiveProps(nextProps) {
66
- if (this.props.value !== nextProps.value) {
67
- this.setState({value: nextProps.value});
68
- }
69
- }
70
-
71
- onChange = (value) => {
72
- const {onChange} = this.props;
73
- this.setState({value});
74
- onChange && onChange(value);
75
- };
76
-
77
- render() {
78
- const props = {
79
- ...this.props,
80
- value: this.state.value,
81
- onChange: this.onChange
82
- };
83
- return <Control {...props} />;
84
- }
85
- }
86
-
87
- /**
88
- * colNum:[可选],表单的列数,默认为4
89
- * readonly: [可选],为true时,所有表单元素都是只读的; 为字符串数组时,用于指定key的表单元素是只读的
90
- * hideControls: [可选],指定key的表单元素被隐藏
91
- * options: [可选],键值对,值与ControlType中options作用相同,但优先级更高
92
- * onChange:内容改变时触发,原型为func(key, value)
93
- * onSearch:搜索框中用户输入时触发,原型为func(key, title, control)
94
- * onAdd: 点击+号时触发,原型为func(key)
95
- * checkable:是否显示checkbox选择框
96
- * onOpenChange:控制日期框显示隐藏回调func(key, open)
97
- * onAreaSearch:联级选择器触发,原型为func(key - 当前联级key, title - 输入值, parentKey - 主体联级key)
98
- * OnFileChange:上传组件触发,原型为func(key,{fileList, fileDeleteList})
99
- */
100
- class SuperForm extends React.Component {
101
- static propTypes = {
102
- controls: PropTypes.arrayOf(PropTypes.shape(ControlType)).isRequired,
103
- value: PropTypes.object,
104
- colNum: PropTypes.number,
105
- valid: PropTypes.bool,
106
- readonly: PropTypes.oneOfType([PropTypes.bool, PropTypes.array]),
107
- hideControls: PropTypes.array,
108
- options: PropTypes.object,
109
- onChange: PropTypes.func,
110
- onSearch: PropTypes.func,
111
- onExitValid: PropTypes.func,
112
- onAdd: PropTypes.func,
113
- checkable: PropTypes.bool,
114
- onOpenChange: PropTypes.func,
115
- onAreaSearch: PropTypes.func,
116
- OnFileChange: PropTypes.func
117
- };
118
-
119
- onAdd = (key, title) => {
120
- const {onAdd} = this.props;
121
- onAdd && onAdd(key, title);
122
- };
123
-
124
- onChange = (key, value) => {
125
- const {onChange} = this.props;
126
- if (onChange) {
127
- this.onExitValid(key);
128
- onChange(key, value);
129
- }
130
- };
131
-
132
- onBlur = (key, value) => {
133
- const {onChange} = this.props;
134
- if (onChange) {
135
- this.onExitValid(key);
136
- onChange(key, value);
137
- }
138
- };
139
-
140
- onExitValid = (key,value) => {
141
- if (key === this.validKey) {
142
- this.validKey = '';
143
- this.props.onExitValid();
144
- }
145
- this.props.onChangeOperate && this.props.onChangeOperate(key,value);
146
- };
147
-
148
- // 动态生成getValidState方法
149
- initValidState = () => {
150
- const {value, valid} = this.props;
151
- const invalid = () => null;
152
- const _valid = ({key, required}) => {
153
- if (required) {
154
- if (!value || helper.isEmpty2(value[key]) || ( !Array.isArray(value[key]) && typeof value[key] === 'object' && helper.isEmpty(value[key].value))) {
155
- this.getValidState = invalid;
156
- this.validKey = key;
157
- return 'error';
158
- }
159
- }
160
- return null;
161
- };
162
- this.getValidState = valid ? _valid : invalid;
163
- };
164
-
165
- validDate = ({key, type}) => (date) => {
166
- const {value={}} = this.props;
167
- if (!date || !value[key]) {
168
- return false;
169
- } else {
170
- if (type === '>') {
171
- return date.format('YYYY-MM-DD') <= value[key];
172
- } else if (type === '<') {
173
- return date.format('YYYY-MM-DD') >= value[key];
174
- } else {
175
- return false;
176
- }
177
- }
178
- };
179
-
180
- getPopupContainer = () => {
181
- const {container} = this.props;
182
- if (typeof container === 'undefined') {
183
- return ReactDOM.findDOMNode(this);
184
- } else if (typeof container === 'boolean') {
185
- return document.body;
186
- } else {
187
- return ReactDOM.findDOMNode(container);
188
- }
189
- };
190
-
191
- getMaxWidth = () => {
192
- const {colNum=defaultColNum} = this.props;
193
- return colNum * 250;
194
- };
195
-
196
- getContainer = () => {
197
- return this.props.getContainer;
198
- };
199
-
200
- getControls = () => {
201
- const {hideControls, controls} = this.props;
202
- if (!hideControls) {
203
- return controls;
204
- } else {
205
- return controls.filter(control => !hideControls.some(key => control.key === key));
206
- }
207
- };
208
-
209
- getType = ({key, type}) => {
210
- const {readonly} = this.props;
211
- if (['area', 'uploadImg'].includes(type)){
212
- return type;
213
- }else if (!readonly) {
214
- return type;
215
- } else if (readonly === true) {
216
- return 'readonly';
217
- } else if (Array.isArray(readonly) && readonly.some(readonlyKey => readonlyKey === key)) {
218
- return 'readonly';
219
- } else {
220
- return type;
221
- }
222
- };
223
-
224
- specialProps = (type, {key, props={}, type:originType}) => {
225
- if (type === 'readonly') {
226
- const {highLightKeys=[]} = this.props;
227
- const style = highLightKeys.includes(key) ? {backgroundColor: 'red', color: 'white'} : {backgroundColor: '#f0f0f0'};
228
- if (originType === 'textArea') {
229
- return {
230
- type: 'textArea',
231
- readonly: true,
232
- style,
233
- onBlur: this.onExitValid.bind(this, key)
234
- }
235
- } else {
236
- return {
237
- style,
238
- onBlur: this.onExitValid.bind(this, key)
239
- };
240
- }
241
- } else if (type === 'text' || type === 'textArea') {
242
- return {
243
- ...props,
244
- onChange: this.onExitValid.bind(this, key),
245
- onBlur: this.onChange.bind(this, key)
246
- }
247
- } else if (type === 'date') {
248
- const propsObj = {
249
- ...props,
250
- onChange: this.onBlur.bind(this, key),
251
- onBlur: this.onExitValid.bind(this, key)
252
- };
253
- if (this.props.onOpenChange && typeof this.props.onOpenChange === 'function') {
254
- propsObj.onOpenChange = this.props.onOpenChange.bind(this, key);
255
- }
256
- return propsObj;
257
- }else if (type === 'area'){
258
- return {
259
- ...props,
260
- onChange: this.onBlur.bind(this, key),
261
- onBlur: this.onExitValid.bind(this, key),
262
- onAreaSearch: this.props.onAreaSearch
263
- }
264
- } else {
265
- return {
266
- ...props,
267
- onChange: this.onBlur.bind(this, key),
268
- onBlur: this.onExitValid.bind(this, key)
269
- };
270
- }
271
- };
272
-
273
- getControlProps = (control, status) => {
274
- const {value={}} = this.props;
275
- const type = this.getType(control);
276
- const props = this.specialProps(type, control);
277
- return {
278
- autoFocus: !!status,
279
- type, ...props,
280
- size: defaultSize,
281
- value: makeString(value[control.key])
282
- };
283
- };
284
-
285
- getOptions = (key, options) => {
286
- const higher = this.props.options || {};
287
- return higher[key] || options;
288
- };
289
-
290
- toEmpty = (props) => {
291
-
292
- };
293
-
294
- toText = (props) => {
295
- return <Controlled {...props} />;
296
- };
297
-
298
- toPassword = (props) => {
299
- return <Controlled {...props} />;
300
- };
301
-
302
- toEditor = (props,control) => {
303
- props.inputKey =control.key
304
- return <Controlled {...props} />;
305
- };
306
-
307
- toSelectWriting = (props,control) => {
308
- return <Controlled {...props} />;
309
- };
310
-
311
-
312
- toTextArea = (props, control) => {
313
- if(control.allFullFather){
314
- props.rows = control.rows;
315
- props.maxLength = control.maxLength;
316
- props.style = {
317
- 'resize': 'none'
318
- };
319
- }else{
320
- props.autoSize = {minRows: 1, maxRows: 5};
321
- }
322
- return <Controlled {...props} />;
323
- };
324
-
325
- toNumber = (props) => {
326
- props.defaultValue = props.value;
327
- delete props.value;
328
- return <Control {...props} />;
329
- };
330
-
331
- toSelect = (props, {options, key}) => {
332
- props.getPopupContainer = this.getPopupContainer;
333
- props.options = this.getOptions(key, options);
334
- props.dropdownMatchSelectWidth = false;
335
- return <Control {...props} />;
336
- };
337
-
338
- createSearchEvent = (control) => {
339
- if (this.props.onSearch) {
340
- return value => this.props.onSearch(control.key, value, control);
341
- } else {
342
- return null;
343
- }
344
- };
345
-
346
- toSearch = (props, control) => {
347
- props.getPopupContainer = this.getPopupContainer;
348
- props.options = this.getOptions(control.key, control.options);
349
- props.onSearch = this.createSearchEvent(control);
350
- props.dropdownMatchSelectWidth = false;
351
- return <Control {...props} />;
352
- };
353
-
354
- toDate = (props, {rule}) => {
355
- props.getCalendarContainer = this.getPopupContainer;
356
- props.style = {width: '100%'};
357
- rule && (props.disabledDate = this.validDate(rule));
358
- return <Control {...props} />;
359
- };
360
-
361
- toRadioGroup = (props, {key, options}) => {
362
- props.options = this.getOptions(key, options);
363
- return <Control {...props} />;
364
- };
365
-
366
- toReadonly = (props, {options, key}) => {
367
- props.value = getTitle(props.value, this.getOptions(key, options));
368
- return <Control {...props} />;
369
- };
370
-
371
- selectSearch = (props, control) => {
372
- props.getPopupContainer = this.getPopupContainer;
373
- props.options = this.getOptions(control.key, control.options);
374
- props.onSearch = this.createSearchEvent(control);
375
- props.dropdownMatchSelectWidth = false;
376
- return <Control {...props} />;
377
- };
378
-
379
- area = (props, {key,options}) => {
380
- const {readonly} = this.props;
381
- props.parentKey = key;
382
- props.options = this.getOptions(key, options);
383
- props.dropdownMatchSelectWidth = false;
384
- props.readonly = readonly === true || Array.isArray(readonly) && readonly.some(readonlyKey => readonlyKey === key) ? true : false;
385
- return <Control {...props} />;
386
- };
387
-
388
- uploadImg = (props, control) => {
389
- const {readonly} = this.props;
390
- props.required = control.required || false;
391
- props.onFileChange = this.onFileChange.bind(this,control);
392
- props.readonly = readonly === true || Array.isArray(readonly) && readonly.some(readonlyKey => readonlyKey === control.key) ? true : false;
393
- return <Control {...props} />
394
- };
395
-
396
- toCascader = (props, control) => {
397
- const container = this.getContainer();
398
- container && (props.getPopupContainer = container);
399
- props.options = control.options || [];
400
- props.onSearch = this.createSearchEvent(control);
401
- props.placeholder = props.placeholder || '';
402
- props.loadData = this.createSearchEvent(control);
403
- return <Control {...props} />;
404
- };
405
-
406
- toTreeSelect = (props,filter) => {
407
- const container = this.getContainer();
408
- container && (props.getPopupContainer = container);
409
- props.options = this.getOptions(filter);
410
- props.onSearch = this.createSearchEvent(filter);
411
- props.placeholder = filter.placeholder || '';
412
- return <Control {...props} />;
413
- };
414
- toControl = (props, control) => {
415
- switch (props.type) {
416
- case 'readonly':
417
- return this.toReadonly(props, control);
418
- case 'text':
419
- return this.toText(props, control);
420
- case 'number':
421
- return this.toNumber(props, control);
422
- case 'select':
423
- case 'selectText':
424
- return this.toSelect(props, control);
425
- case 'search':
426
- case 'searchText':
427
- return this.toSearch(props, control);
428
- case 'date':
429
- return this.toDate(props, control);
430
- case 'radioGroup':
431
- return this.toRadioGroup(props, control);
432
- case 'textArea':
433
- return this.toTextArea(props, control);
434
- case 'password':
435
- return this.toPassword(props, control);
436
- case 'editor':
437
- return this.toEditor(props, control);
438
- case 'selectWriting' :
439
- return this.toSelectWriting(props,control)
440
- case 'selectSearch':
441
- return this.selectSearch(props, control);
442
- case 'empty':
443
- return this.toEmpty(props, control);
444
- case 'area':
445
- return this.area(props, control);
446
- case 'uploadImg':
447
- return this.uploadImg(props, control);
448
- case 'cascader':
449
- return this.toCascader(props, control);
450
- case 'treeSelect':
451
- return this.toTreeSelect(props, control);
452
- default:
453
- return 'type error';
454
- }
455
- };
456
-
457
- toLabel = ({title, showAdd, key}, type) => {
458
- if (showAdd && (type !== 'readonly')) {
459
- const onClick = this.onAdd.bind(this, key, title);
460
- return <span>{title}<Icon role='add' type='plus-circle-o' onClick={onClick}/></span>;
461
- } else {
462
- return title;
463
- }
464
- };
465
-
466
- toCol = (span, control) => {
467
- const factor = control.span || 1;
468
- const status = this.getValidState(control);
469
- const controlProps = this.getControlProps(control, status);
470
- const itemProps = {
471
- label: this.toLabel(control, controlProps.type),
472
- required: control.required,
473
- validateStatus: status
474
- };
475
- const {checkable,onCheckItem} = this.props;
476
- return control.type !== 'empty' ? (
477
- <Col span={span * factor} key={control.key}>
478
- {checkable && <Checkbox className={variables('SuperForm').checkbox} onChange={onCheckItem.bind(this,control)} checked={control.checked} />}
479
- <FormItem {...itemProps} className={checkable ? variables('SuperForm').formItemWithCheckbox : ''}>
480
- {this.toControl(controlProps, control)}
481
- </FormItem>
482
- </Col>
483
- ) : (
484
- <Col span={span * factor} key={control.key} style={{height: '44px'}}/>
485
- );
486
- };
487
-
488
- toCols = () => {
489
- let {colNum=defaultColNum,allFullFather} = this.props;
490
- if(allFullFather){
491
- colNum = 1;
492
- }
493
- const span = 24 / colNum;
494
- return this.getControls().map(control => {
495
- if(allFullFather){
496
- control.allFullFather = allFullFather;
497
- }
498
- return this.toCol(span, control)
499
- });
500
- };
501
-
502
- render() {
503
- this.initValidState();
504
- return (
505
- <div className={variables('SuperForm')}>
506
- <Form layout='vertical' style={{maxWidth: this.props.allFullFather ? '100%' : this.getMaxWidth()}}>
507
- <Row gutter={20}>
508
- {this.toCols()}
509
- </Row>
510
- </Form>
511
- </div>
512
- );
513
- }
514
- }
515
-
516
- export default SuperForm;