cloud-b2b 1.1.57 → 1.1.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (308) hide show
  1. package/package.json +44 -22
  2. package/src/Area/Area.js +94 -0
  3. package/src/Card/Card.js +16 -0
  4. package/src/CodeInput/CodeInput.js +76 -0
  5. package/src/Control/Control.js +338 -0
  6. package/src/Control/event.js +45 -0
  7. package/src/Enhance/Dialogs.js +24 -0
  8. package/src/Enhance/Loading.js +83 -0
  9. package/{es → src}/Enhance/index.js +8 -6
  10. package/src/Header/Header.js +149 -0
  11. package/src/Header/Vertical.js +74 -0
  12. package/src/ImageView/ImageView.js +62 -0
  13. package/src/Indent/Indent.js +12 -0
  14. package/src/InpurCascader/InputCascader.js +83 -0
  15. package/src/InputEditor/InputEditor.js +93 -0
  16. package/src/InputSearch/InputSearch.js +186 -0
  17. package/src/InputSelect/InputSelect.js +103 -0
  18. package/src/InputTreeSelect/InputTreeSelect.js +87 -0
  19. package/src/InputWriting/InputWriting.js +65 -0
  20. package/src/Layout/Layout.js +121 -0
  21. package/src/LayoutLink/LayoutLink.js +59 -0
  22. package/src/Link/Link.js +57 -0
  23. package/src/Loading/Loading.js +15 -0
  24. package/src/Loading2/Loading2.js +15 -0
  25. package/src/ModalWithDrag/ModalWithDrag.js +17 -0
  26. package/{es → src}/ModalWithDrag/drag.js +128 -116
  27. package/src/NumberInput/NumberInput.js +137 -0
  28. package/src/Search/Search.js +368 -0
  29. package/src/Search2/Search.js +436 -0
  30. package/{lib/Search → src/Search2}/Search.less +65 -63
  31. package/{lib/Search → src/Search2}/package.json +6 -6
  32. package/src/Sidebar/Sidebar.js +111 -0
  33. package/src/Sidebar2/Sidebar.js +143 -0
  34. package/src/SuperForm/SuperForm.js +519 -0
  35. package/src/SuperForm2/SuperForm.js +588 -0
  36. package/src/SuperIcon/SuperIcon.js +14 -0
  37. package/src/SuperPagination/SuperPagination.js +65 -0
  38. package/src/SuperTab/SuperTab.js +84 -0
  39. package/src/SuperTab2/SuperTab2.js +94 -0
  40. package/src/SuperTable/DragSortRow.js +62 -0
  41. package/src/SuperTable/FilterDropDown.js +111 -0
  42. package/src/SuperTable/SuperTable.js +590 -0
  43. package/src/SuperTable/fixed.js +34 -0
  44. package/src/SuperTable2/SuperTable2.js +624 -0
  45. package/src/SuperTable2/SuperTableCell.js +175 -0
  46. package/src/SuperTable3/FilterDropDown.js +111 -0
  47. package/src/SuperTable3/SuperTable.js +498 -0
  48. package/src/SuperTable3/fixed.js +34 -0
  49. package/src/SuperToolbar/SuperToolbar.js +128 -0
  50. package/src/SuperUpload/SuperUpload.js +137 -0
  51. package/src/Title/Title.js +18 -0
  52. package/src/Viewer/ImageViews.js +220 -0
  53. package/src/Viewer/Viewer.js +97 -0
  54. package/src/WingBlank/WingBlank.js +14 -0
  55. package/src/helper.js +185 -0
  56. package/{es → src}/history.js +6 -6
  57. package/src/index.js +39 -0
  58. package/src/variables.js +5 -0
  59. package/test/index.html +10 -0
  60. package/test/test.js +16 -0
  61. package/test/test.less +12 -0
  62. package/test/webpack.config.js +71 -0
  63. package/tools/babel.config.js +14 -0
  64. package/tools/build.js +70 -0
  65. package/tools/publish.js +9 -0
  66. package/tools/util.js +53 -0
  67. package/es/Area/Area.js +0 -138
  68. package/es/Card/Card.js +0 -19
  69. package/es/CodeInput/CodeInput.js +0 -120
  70. package/es/Control/Control.js +0 -444
  71. package/es/Control/event.js +0 -43
  72. package/es/Enhance/Dialogs.js +0 -49
  73. package/es/Enhance/Loading.js +0 -128
  74. package/es/Header/Header.js +0 -159
  75. package/es/Header/Vertical.js +0 -103
  76. package/es/ImageView/ImageView.js +0 -97
  77. package/es/Indent/Indent.js +0 -19
  78. package/es/InpurCascader/InputCascader.js +0 -114
  79. package/es/InputEditor/InputEditor.js +0 -171
  80. package/es/InputSearch/InputSearch.js +0 -263
  81. package/es/InputSelect/InputSelect.js +0 -157
  82. package/es/InputTreeSelect/InputTreeSelect.js +0 -118
  83. package/es/InputWriting/InputWriting.js +0 -82
  84. package/es/Layout/Layout.js +0 -198
  85. package/es/LayoutLink/LayoutLink.js +0 -73
  86. package/es/Link/Link.js +0 -82
  87. package/es/Loading/Loading.js +0 -13
  88. package/es/Loading2/Loading2.js +0 -9
  89. package/es/ModalWithDrag/ModalWithDrag.js +0 -29
  90. package/es/NumberInput/NumberInput.js +0 -197
  91. package/es/Search/Search.js +0 -494
  92. package/es/Sidebar/Sidebar.js +0 -141
  93. package/es/Sidebar2/Sidebar.js +0 -162
  94. package/es/SuperForm/SuperForm.js +0 -593
  95. package/es/SuperForm2/SuperForm.js +0 -682
  96. package/es/SuperIcon/SuperIcon.js +0 -27
  97. package/es/SuperPagination/SuperPagination.js +0 -106
  98. package/es/SuperTab/SuperTab.js +0 -104
  99. package/es/SuperTab2/SuperTab2.js +0 -142
  100. package/es/SuperTable/DragSortRow.js +0 -94
  101. package/es/SuperTable/FilterDropDown.js +0 -161
  102. package/es/SuperTable/SuperTable.js +0 -805
  103. package/es/SuperTable/fixed.js +0 -34
  104. package/es/SuperTable2/SuperTable2.js +0 -923
  105. package/es/SuperTable2/SuperTableCell.js +0 -215
  106. package/es/SuperTable3/FilterDropDown.js +0 -161
  107. package/es/SuperTable3/SuperTable.js +0 -662
  108. package/es/SuperTable3/fixed.js +0 -34
  109. package/es/SuperToolbar/SuperToolbar.js +0 -192
  110. package/es/SuperUpload/SuperUpload.js +0 -356
  111. package/es/Title/Title.js +0 -33
  112. package/es/Viewer/ImageViews.js +0 -255
  113. package/es/Viewer/Viewer.js +0 -119
  114. package/es/WingBlank/WingBlank.js +0 -16
  115. package/es/helper.js +0 -241
  116. package/es/index.js +0 -37
  117. package/es/variables.js +0 -6
  118. package/lib/Area/Area.js +0 -146
  119. package/lib/Area/package.json +0 -6
  120. package/lib/Card/Card.js +0 -27
  121. package/lib/Card/package.json +0 -6
  122. package/lib/CodeInput/CodeInput.js +0 -128
  123. package/lib/CodeInput/package.json +0 -6
  124. package/lib/Control/Control.js +0 -450
  125. package/lib/Control/event.js +0 -51
  126. package/lib/Control/package.json +0 -6
  127. package/lib/Enhance/Dialogs.js +0 -57
  128. package/lib/Enhance/Loading.js +0 -135
  129. package/lib/Enhance/index.js +0 -25
  130. package/lib/Enhance/package.json +0 -6
  131. package/lib/Header/Header.js +0 -166
  132. package/lib/Header/Header.less +0 -95
  133. package/lib/Header/Vertical.js +0 -111
  134. package/lib/Header/Vertical.less +0 -60
  135. package/lib/Header/package.json +0 -6
  136. package/lib/ImageView/ImageView.js +0 -105
  137. package/lib/ImageView/ImageView.less +0 -14
  138. package/lib/ImageView/package.json +0 -6
  139. package/lib/Indent/Indent.js +0 -27
  140. package/lib/Indent/package.json +0 -6
  141. package/lib/InpurCascader/InputCascader.js +0 -121
  142. package/lib/InpurCascader/package.json +0 -6
  143. package/lib/InputEditor/InputEditor.js +0 -179
  144. package/lib/InputEditor/inputEditor.less +0 -8
  145. package/lib/InputEditor/package.json +0 -6
  146. package/lib/InputSearch/InputSearch.js +0 -271
  147. package/lib/InputSearch/package.json +0 -6
  148. package/lib/InputSelect/InputSelect.js +0 -165
  149. package/lib/InputSelect/package.json +0 -6
  150. package/lib/InputTreeSelect/InputTreeSelect.js +0 -125
  151. package/lib/InputTreeSelect/package.json +0 -6
  152. package/lib/InputWriting/InputWriting.js +0 -90
  153. package/lib/InputWriting/package.json +0 -6
  154. package/lib/Layout/Layout.js +0 -206
  155. package/lib/Layout/Layout.less +0 -28
  156. package/lib/Layout/package.json +0 -6
  157. package/lib/LayoutLink/LayoutLink.js +0 -85
  158. package/lib/LayoutLink/LayoutLink.less +0 -53
  159. package/lib/LayoutLink/package.json +0 -6
  160. package/lib/Link/Link.js +0 -90
  161. package/lib/Link/package.json +0 -6
  162. package/lib/Loading/Loading.js +0 -21
  163. package/lib/Loading/Loading.less +0 -13
  164. package/lib/Loading/package.json +0 -6
  165. package/lib/Loading2/Loading2.js +0 -17
  166. package/lib/Loading2/Loading2.less +0 -19
  167. package/lib/Loading2/package.json +0 -6
  168. package/lib/ModalWithDrag/ModalWithDrag.js +0 -37
  169. package/lib/ModalWithDrag/ModalWithDrag.less +0 -6
  170. package/lib/ModalWithDrag/drag.js +0 -124
  171. package/lib/ModalWithDrag/package.json +0 -6
  172. package/lib/NumberInput/NumberInput.js +0 -205
  173. package/lib/NumberInput/package.json +0 -6
  174. package/lib/Search/Search.js +0 -506
  175. package/lib/Sidebar/Sidebar.js +0 -149
  176. package/lib/Sidebar/Sidebar.less +0 -78
  177. package/lib/Sidebar/package.json +0 -6
  178. package/lib/Sidebar2/Sidebar.js +0 -170
  179. package/lib/Sidebar2/Sidebar.less +0 -153
  180. package/lib/Sidebar2/package.json +0 -6
  181. package/lib/SuperForm/SuperForm.js +0 -604
  182. package/lib/SuperForm/SuperForm.less +0 -52
  183. package/lib/SuperForm/package.json +0 -6
  184. package/lib/SuperForm2/SuperForm.js +0 -693
  185. package/lib/SuperForm2/SuperForm.less +0 -52
  186. package/lib/SuperForm2/package.json +0 -6
  187. package/lib/SuperIcon/SuperIcon.js +0 -35
  188. package/lib/SuperIcon/package.json +0 -6
  189. package/lib/SuperPagination/SuperPagination.js +0 -114
  190. package/lib/SuperPagination/package.json +0 -6
  191. package/lib/SuperTab/SuperTab.js +0 -112
  192. package/lib/SuperTab/SuperTab.less +0 -43
  193. package/lib/SuperTab/package.json +0 -6
  194. package/lib/SuperTab2/SuperTab2.js +0 -150
  195. package/lib/SuperTab2/SuperTab2.less +0 -18
  196. package/lib/SuperTab2/package.json +0 -6
  197. package/lib/SuperTable/DragSortRow.js +0 -102
  198. package/lib/SuperTable/DragSortRow.less +0 -17
  199. package/lib/SuperTable/FilterDropDown.js +0 -169
  200. package/lib/SuperTable/FilterDropDown.less +0 -30
  201. package/lib/SuperTable/SuperTable.js +0 -813
  202. package/lib/SuperTable/SuperTable.less +0 -132
  203. package/lib/SuperTable/fixed.js +0 -42
  204. package/lib/SuperTable/package.json +0 -6
  205. package/lib/SuperTable2/SuperTable2.js +0 -935
  206. package/lib/SuperTable2/SuperTable2.less +0 -118
  207. package/lib/SuperTable2/SuperTableCell.js +0 -220
  208. package/lib/SuperTable2/package.json +0 -6
  209. package/lib/SuperTable3/FilterDropDown.js +0 -169
  210. package/lib/SuperTable3/FilterDropDown.less +0 -29
  211. package/lib/SuperTable3/SuperTable.js +0 -670
  212. package/lib/SuperTable3/SuperTable.less +0 -99
  213. package/lib/SuperTable3/fixed.js +0 -42
  214. package/lib/SuperTable3/package.json +0 -6
  215. package/lib/SuperToolbar/SuperToolbar.js +0 -200
  216. package/lib/SuperToolbar/SuperToolbar.less +0 -17
  217. package/lib/SuperToolbar/package.json +0 -6
  218. package/lib/SuperUpload/SuperUpload.js +0 -367
  219. package/lib/SuperUpload/SuperUpload.less +0 -28
  220. package/lib/SuperUpload/package.json +0 -6
  221. package/lib/Title/Title.js +0 -41
  222. package/lib/Title/Title.less +0 -35
  223. package/lib/Title/package.json +0 -6
  224. package/lib/Viewer/ImageViews.js +0 -263
  225. package/lib/Viewer/Viewer.js +0 -127
  226. package/lib/Viewer/Viewer.less +0 -67
  227. package/lib/Viewer/imgView.less +0 -59
  228. package/lib/Viewer/package.json +0 -7
  229. package/lib/WingBlank/WingBlank.js +0 -24
  230. package/lib/WingBlank/WingBlank.less +0 -12
  231. package/lib/WingBlank/package.json +0 -6
  232. package/lib/adjust.less +0 -89
  233. package/lib/helper.js +0 -247
  234. package/lib/history.js +0 -12
  235. package/lib/index.js +0 -271
  236. package/lib/index.less +0 -31
  237. package/lib/style.less +0 -30
  238. package/lib/variables.js +0 -14
  239. package/lib/variables.less +0 -73
  240. /package/{es → src}/Area/package.json +0 -0
  241. /package/{es → src}/Card/package.json +0 -0
  242. /package/{es → src}/CodeInput/package.json +0 -0
  243. /package/{es → src}/Control/package.json +0 -0
  244. /package/{es → src}/Enhance/package.json +0 -0
  245. /package/{es → src}/Header/Header.less +0 -0
  246. /package/{es → src}/Header/Vertical.less +0 -0
  247. /package/{es → src}/Header/package.json +0 -0
  248. /package/{es → src}/ImageView/ImageView.less +0 -0
  249. /package/{es → src}/ImageView/package.json +0 -0
  250. /package/{es → src}/Indent/package.json +0 -0
  251. /package/{es → src}/InpurCascader/package.json +0 -0
  252. /package/{es → src}/InputEditor/inputEditor.less +0 -0
  253. /package/{es → src}/InputEditor/package.json +0 -0
  254. /package/{es → src}/InputSearch/package.json +0 -0
  255. /package/{es → src}/InputSelect/package.json +0 -0
  256. /package/{es → src}/InputTreeSelect/package.json +0 -0
  257. /package/{es → src}/InputWriting/package.json +0 -0
  258. /package/{es → src}/Layout/Layout.less +0 -0
  259. /package/{es → src}/Layout/package.json +0 -0
  260. /package/{es → src}/LayoutLink/LayoutLink.less +0 -0
  261. /package/{es → src}/LayoutLink/package.json +0 -0
  262. /package/{es → src}/Link/package.json +0 -0
  263. /package/{es → src}/Loading/Loading.less +0 -0
  264. /package/{es → src}/Loading/package.json +0 -0
  265. /package/{es → src}/Loading2/Loading2.less +0 -0
  266. /package/{es → src}/Loading2/package.json +0 -0
  267. /package/{es → src}/ModalWithDrag/ModalWithDrag.less +0 -0
  268. /package/{es → src}/ModalWithDrag/package.json +0 -0
  269. /package/{es → src}/NumberInput/package.json +0 -0
  270. /package/{es → src}/Search/Search.less +0 -0
  271. /package/{es → src}/Search/package.json +0 -0
  272. /package/{es → src}/Sidebar/Sidebar.less +0 -0
  273. /package/{es → src}/Sidebar/package.json +0 -0
  274. /package/{es → src}/Sidebar2/Sidebar.less +0 -0
  275. /package/{es → src}/Sidebar2/package.json +0 -0
  276. /package/{es → src}/SuperForm/SuperForm.less +0 -0
  277. /package/{es → src}/SuperForm/package.json +0 -0
  278. /package/{es → src}/SuperForm2/SuperForm.less +0 -0
  279. /package/{es → src}/SuperForm2/package.json +0 -0
  280. /package/{es → src}/SuperIcon/package.json +0 -0
  281. /package/{es → src}/SuperPagination/package.json +0 -0
  282. /package/{es → src}/SuperTab/SuperTab.less +0 -0
  283. /package/{es → src}/SuperTab/package.json +0 -0
  284. /package/{es → src}/SuperTab2/SuperTab2.less +0 -0
  285. /package/{es → src}/SuperTab2/package.json +0 -0
  286. /package/{es → src}/SuperTable/DragSortRow.less +0 -0
  287. /package/{es → src}/SuperTable/FilterDropDown.less +0 -0
  288. /package/{es → src}/SuperTable/SuperTable.less +0 -0
  289. /package/{es → src}/SuperTable/package.json +0 -0
  290. /package/{es → src}/SuperTable2/SuperTable2.less +0 -0
  291. /package/{es → src}/SuperTable2/package.json +0 -0
  292. /package/{es → src}/SuperTable3/FilterDropDown.less +0 -0
  293. /package/{es → src}/SuperTable3/SuperTable.less +0 -0
  294. /package/{es → src}/SuperTable3/package.json +0 -0
  295. /package/{es → src}/SuperToolbar/SuperToolbar.less +0 -0
  296. /package/{es → src}/SuperToolbar/package.json +0 -0
  297. /package/{es → src}/SuperUpload/SuperUpload.less +0 -0
  298. /package/{es → src}/SuperUpload/package.json +0 -0
  299. /package/{es → src}/Title/Title.less +0 -0
  300. /package/{es → src}/Title/package.json +0 -0
  301. /package/{es → src}/Viewer/Viewer.less +0 -0
  302. /package/{es → src}/Viewer/imgView.less +0 -0
  303. /package/{es → src}/Viewer/package.json +0 -0
  304. /package/{es → src}/WingBlank/WingBlank.less +0 -0
  305. /package/{es → src}/WingBlank/package.json +0 -0
  306. /package/{es → src}/adjust.less +0 -0
  307. /package/{es → src}/style.less +0 -0
  308. /package/{es → src}/variables.less +0 -0
@@ -0,0 +1,588 @@
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, Tooltip} from 'antd';
7
+ import variables from '../variables';
8
+
9
+ const FormItem = Form.Item;
10
+ const defaultSize = 'large';
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
+ 'captcha',
30
+ 'area',
31
+ 'uploadImg',
32
+ 'cascader',
33
+ 'checkbox',
34
+ 'treeSelect'
35
+ ];
36
+
37
+ /**
38
+ * key:[必须],用于唯一标识该Form下的一个表单元素
39
+ * title:[必须],表单元素的标签
40
+ * type:[必须],表单元素类型
41
+ * required: [可选],是否为必填项
42
+ * options: [可选],对象数组(type为readonly,radio,search, searchText,select, selectText时有效)
43
+ * span: [可选],占据的列数,默认为1
44
+ * showAdd: [可选],是否显示+号,点击+号会触发onAdd事件,默认为false
45
+ * rule: [可选],用于设置校验规则
46
+ */
47
+ const ControlType = {
48
+ key: PropTypes.string.isRequired,
49
+ title: PropTypes.string,
50
+ type: PropTypes.oneOf(TYPE).isRequired,
51
+ required: PropTypes.bool,
52
+ options: PropTypes.array,
53
+ span: PropTypes.number,
54
+ onCheckItem: PropTypes.any,
55
+ showAdd: PropTypes.any,
56
+ rule: PropTypes.object,
57
+ props: PropTypes.object,
58
+ };
59
+
60
+ class Controlled extends React.Component {
61
+ constructor(props) {
62
+ super(props);
63
+ this.state = {value: props.value};
64
+ }
65
+
66
+ componentWillReceiveProps(nextProps) {
67
+ if (this.props.value !== nextProps.value) {
68
+ this.setState({value: nextProps.value});
69
+ }
70
+ }
71
+
72
+ onChange = (value) => {
73
+ const {onChange} = this.props;
74
+ this.setState({value});
75
+ onChange && onChange(value);
76
+ };
77
+
78
+ render() {
79
+ const props = {
80
+ ...this.props,
81
+ size:'large',
82
+ value: this.state.value,
83
+ onChange: this.onChange
84
+ };
85
+ return <Control {...props} />;
86
+ }
87
+ }
88
+
89
+ /**
90
+ * colNum:[可选],表单的列数,默认为4
91
+ * readonly: [可选],为true时,所有表单元素都是只读的; 为字符串数组时,用于指定key的表单元素是只读的
92
+ * hideControls: [可选],指定key的表单元素被隐藏
93
+ * options: [可选],键值对,值与ControlType中options作用相同,但优先级更高
94
+ * onChange:内容改变时触发,原型为func(key, value)
95
+ * onSearch:搜索框中用户输入时触发,原型为func(key, title, control)
96
+ * onAdd: 点击+号时触发,原型为func(key)
97
+ * checkable:是否显示checkbox选择框
98
+ * onOpenChange:控制日期框显示隐藏回调func(key, open)
99
+ * onAreaSearch:联级选择器触发,原型为func(key - 当前联级key, title - 输入值, parentKey - 主体联级key)
100
+ * onFileChange:上传组件触发,原型为func(key,{fileList, fileDeleteList})
101
+ */
102
+ class SuperForm2 extends React.Component {
103
+ static propTypes = {
104
+ controls: PropTypes.arrayOf(PropTypes.shape(ControlType)).isRequired,
105
+ value: PropTypes.object,
106
+ colNum: PropTypes.number,
107
+ valid: PropTypes.bool,
108
+ readonly: PropTypes.oneOfType([PropTypes.bool, PropTypes.array]),
109
+ hideControls: PropTypes.array,
110
+ options: PropTypes.object,
111
+ onChange: PropTypes.func,
112
+ onSearch: PropTypes.func,
113
+ onExitValid: PropTypes.func,
114
+ onAdd: PropTypes.func,
115
+ checkable: PropTypes.bool,
116
+ onOpenChange: PropTypes.func,
117
+ onGetCode: PropTypes.func,
118
+ onFileChange: PropTypes.func,
119
+ onAreaSearch: PropTypes.func,
120
+ buildSuperUploadProps: PropTypes.func, //构建type===uploadImg时,SuperUpload组件需要的公共属性函数,已在项目公共文件state.js中提供,可直接引用
121
+ layout: PropTypes.string,
122
+ };
123
+
124
+ onAdd = (key, title) => {
125
+ const {onAdd} = this.props;
126
+ onAdd && onAdd(key, title);
127
+ };
128
+
129
+ onFileChange = ({key}, file) => {
130
+ const {onFileChange} = this.props;
131
+ onFileChange && onFileChange(key, file);
132
+ };
133
+
134
+ onChange = (key, value) => {
135
+ const {onChange} = this.props;
136
+ if (onChange) {
137
+ this.onExitValid(key);
138
+ onChange(key, value);
139
+ }
140
+ };
141
+
142
+ onGetCode = (key, value) => {
143
+ const {onGetCode} = this.props;
144
+ onGetCode && onGetCode();
145
+ }
146
+
147
+ onBlur = (key, value) => {
148
+ const {onChange} = this.props;
149
+ if (onChange) {
150
+ this.onExitValid(key);
151
+ onChange(key, value);
152
+ }
153
+ };
154
+
155
+ onExitValid = (key,value) => {
156
+ if (key === this.validKey) {
157
+ this.validKey = '';
158
+ this.props.onExitValid();
159
+ }
160
+ this.props.onChangeOperate && this.props.onChangeOperate(key,value);
161
+ };
162
+
163
+ // 动态生成getValidState方法
164
+ initValidState = () => {
165
+ const {value, valid} = this.props;
166
+ const invalid = () => null;
167
+ const _valid = ({key, required}) => {
168
+ if (required) {
169
+ if (!value || helper.isEmpty2(value[key]) || ( !Array.isArray(value[key]) && typeof value[key] === 'object' && helper.isEmpty(value[key].value))) {
170
+ this.getValidState = invalid;
171
+ this.validKey = key;
172
+ return 'error';
173
+ }
174
+ }
175
+ return null;
176
+ };
177
+ this.getValidState = valid ? _valid : invalid;
178
+ };
179
+
180
+ validDate = ({key, type}) => (date) => {
181
+ const {value={}} = this.props;
182
+ if (!date || !value[key]) {
183
+ return false;
184
+ } else {
185
+ if (type === '>') {
186
+ return date.format('YYYY-MM-DD') < value[key];
187
+ } else if (type === '<') {
188
+ return date.format('YYYY-MM-DD') > value[key];
189
+ } else {
190
+ return false;
191
+ }
192
+ }
193
+ };
194
+
195
+ getPopupContainer = () => {
196
+ const {container} = this.props;
197
+ if (typeof container === 'undefined') {
198
+ return ReactDOM.findDOMNode(this);
199
+ } else if (typeof container === 'boolean') {
200
+ return document.body;
201
+ } else {
202
+ return ReactDOM.findDOMNode(container);
203
+ }
204
+ };
205
+
206
+ getMaxWidth = () => {
207
+ const {colNum=defaultColNum} = this.props;
208
+ return colNum * 1200;
209
+ };
210
+
211
+ getContainer = () => {
212
+ return this.props.getContainer;
213
+ };
214
+
215
+ getControls = () => {
216
+ const {hideControls, controls} = this.props;
217
+ if (!hideControls) {
218
+ return controls;
219
+ } else {
220
+ return controls.filter(control => !hideControls.some(key => control.key === key));
221
+ }
222
+ };
223
+
224
+ getType = ({key, type}) => {
225
+ const {readonly} = this.props;
226
+ if (['area', 'uploadImg'].includes(type)){
227
+ return type;
228
+ } else if (!readonly) {
229
+ return type;
230
+ } else if (readonly === true) {
231
+ return 'readonly';
232
+ } else if (Array.isArray(readonly) && readonly.some(readonlyKey => readonlyKey === key)) {
233
+ return 'readonly';
234
+ } else {
235
+ return type;
236
+ }
237
+ };
238
+
239
+ specialProps = (type, {key, props={}, type:originType}) => {
240
+ if (type === 'readonly') {
241
+ if (originType === 'textArea') {
242
+ return {
243
+ type: 'textArea',
244
+ readonly: true,
245
+ onBlur: this.onExitValid.bind(this, key)
246
+ }
247
+ } else if (originType === 'uploadImg') {
248
+ const commonProps = this.props.buildSuperUploadProps ? this.props.buildSuperUploadProps() : {};
249
+ return {
250
+ ...props,
251
+ ...commonProps,
252
+ readonly: true,
253
+ onBlur: this.onExitValid.bind(this, key)
254
+ };
255
+ } else {
256
+ return {
257
+ onBlur: this.onExitValid.bind(this, key)
258
+ };
259
+ }
260
+ } else if (type === 'text' || type === 'textArea') {
261
+ return {
262
+ ...props,
263
+ onChange: this.onExitValid.bind(this, key),
264
+ onBlur: this.onChange.bind(this, key)
265
+ }
266
+ } else if (type === 'date') {
267
+ const propsObj = {
268
+ ...props,
269
+ onChange: this.onBlur.bind(this, key),
270
+ onBlur: this.onExitValid.bind(this, key)
271
+ };
272
+ if (this.props.onOpenChange && typeof this.props.onOpenChange === 'function') {
273
+ propsObj.onOpenChange = this.props.onOpenChange.bind(this, key);
274
+ }
275
+ return propsObj;
276
+ }else if (type === 'captcha'){
277
+ return {
278
+ ...props,
279
+ onChange: this.onBlur.bind(this, key),
280
+ onBlur: this.onExitValid.bind(this, key),
281
+ onGetCode: this.onGetCode.bind(this, key)
282
+ }
283
+ } else if (type === 'area'){
284
+ return {
285
+ ...props,
286
+ onChange: this.onBlur.bind(this, key),
287
+ onBlur: this.onExitValid.bind(this, key),
288
+ onAreaSearch: this.props.onAreaSearch
289
+ }
290
+ } else if (type === 'uploadImg') {
291
+ const commonProps = this.props.buildSuperUploadProps ? this.props.buildSuperUploadProps() : {};
292
+ return {
293
+ ...props,
294
+ ...commonProps,
295
+ onChange: this.onBlur.bind(this, key),
296
+ onBlur: this.onExitValid.bind(this, key)
297
+ };
298
+ } else if (type === 'double'){
299
+ return props
300
+ }else {
301
+ return {
302
+ ...props,
303
+ onChange: this.onBlur.bind(this, key),
304
+ onBlur: this.onExitValid.bind(this, key)
305
+ };
306
+ }
307
+ };
308
+
309
+ getControlProps = (control, status) => {
310
+ const {value={},readonly} = this.props;
311
+ const type = this.getType(control);
312
+ const props = this.specialProps(type, control);
313
+ return {
314
+ autoFocus: !!status,
315
+ type, ...props,
316
+ size: defaultSize,
317
+ value: makeString(value[control.key]),
318
+ };
319
+ };
320
+
321
+ getOptions = (key, options) => {
322
+ const higher = this.props.options || {};
323
+ return higher[key] || options;
324
+ };
325
+
326
+ toEmpty = (props) => {
327
+
328
+ };
329
+
330
+ toText = (props) => {
331
+ return <Controlled {...props} />;
332
+ };
333
+
334
+ toPassword = (props) => {
335
+ return <Controlled {...props} />;
336
+ };
337
+
338
+ toEditor = (props,control) => {
339
+ props.inputKey =control.key
340
+ return <Controlled {...props} />;
341
+ };
342
+
343
+ toSelectWriting = (props,control) => {
344
+ return <Controlled {...props} />;
345
+ };
346
+
347
+
348
+ toTextArea = (props, control) => {
349
+ if(control.allFullFather){
350
+ props.rows = control.rows;
351
+ props.maxLength = control.maxLength;
352
+ props.style = {
353
+ 'resize': 'none'
354
+ };
355
+ }else{
356
+ props.autoSize = {minRows: 1, maxRows: 5};
357
+ }
358
+ return <Controlled {...props} />;
359
+ };
360
+
361
+ toNumber = (props) => {
362
+ props.defaultValue = props.value;
363
+ delete props.value;
364
+ return <Control {...props} />;
365
+ };
366
+ toDoubleInput=(props, control, cc)=>{
367
+ props.defaultValue = props.value;
368
+ props.doubleKey = props.key;
369
+ props.doubleValue = helper.getObject(cc, props.key);
370
+ props.onChangeKey1 = this.onChange.bind(this, props.key[0])
371
+ props.onChangeKey2 = this.onChange.bind(this, props.key[1])
372
+ delete props.value;
373
+ return <Control {...props} />;
374
+ }
375
+ toSelect = (props, {options, key}) => {
376
+ props.getPopupContainer = this.getPopupContainer;
377
+ props.options = this.getOptions(key, options);
378
+ props.dropdownMatchSelectWidth = false;
379
+ return <Control {...props} />;
380
+ };
381
+ toTreeSelect = (props,filter) => {
382
+ const container = this.getContainer();
383
+ container && (props.getPopupContainer = container);
384
+ props.options = this.getOptions(filter);
385
+ props.onSearch = this.createSearchEvent(filter);
386
+ props.placeholder = filter.placeholder || '';
387
+ return <Control {...props} />;
388
+ };
389
+ createSearchEvent = (control) => {
390
+ if (this.props.onSearch) {
391
+ return value => this.props.onSearch(control.key, value, control);
392
+ } else {
393
+ return null;
394
+ }
395
+ };
396
+
397
+ createGetCodeEvent = (control) => {
398
+ if (this.props.onGetCode) {
399
+ return value => this.props.onGetCode(control.key, value, control);
400
+ } else {
401
+ return null;
402
+ }
403
+ };
404
+
405
+ toSearch = (props, control) => {
406
+ props.getPopupContainer = this.getPopupContainer;
407
+ props.options = this.getOptions(control.key, control.options);
408
+ props.onSearch = this.createSearchEvent(control);
409
+ props.dropdownMatchSelectWidth = false;
410
+ props.size = 'large';
411
+ return <Control {...props} />;
412
+ };
413
+
414
+ toDate = (props, {rule}) => {
415
+ props.getCalendarContainer = this.getPopupContainer;
416
+ props.style = {width: '100%'};
417
+ rule && (props.disabledDate = this.validDate(rule));
418
+ return <Control {...props} />;
419
+ };
420
+
421
+ toRadioGroup = (props, {key, options}) => {
422
+ props.options = this.getOptions(key, options);
423
+ return <Control {...props} />;
424
+ };
425
+
426
+ captcha = (props, control) => {
427
+ props.onGetCode = this.props.onGetCode;
428
+ return <Control {...props} />
429
+ }
430
+
431
+ toReadonly = (props, {options, key}) => {
432
+ props.value = getTitle(props.value, this.getOptions(key, options));
433
+ return <Control {...props} />;
434
+ };
435
+
436
+ selectSearch = (props, control) => {
437
+ props.getPopupContainer = this.getPopupContainer;
438
+ props.options = this.getOptions(control.key, control.options);
439
+ props.onSearch = this.createSearchEvent(control);
440
+ props.dropdownMatchSelectWidth = false;
441
+ return <Control {...props} />;
442
+ };
443
+
444
+ area = (props, {key,options}) => {
445
+ const {readonly} = this.props;
446
+ props.parentKey = key;
447
+ props.options = this.getOptions(key, options);
448
+ props.dropdownMatchSelectWidth = false;
449
+ props.readonly = readonly === true || Array.isArray(readonly) && readonly.some(readonlyKey => readonlyKey === key) ? true : false;
450
+ return <Control {...props} />;
451
+ };
452
+
453
+ uploadImg = (props, control) => {
454
+ const {readonly} = this.props;
455
+ props.required = control.required || false;
456
+ props.onFileChange = this.onFileChange.bind(this,control);
457
+ props.readonly = readonly === true || Array.isArray(readonly) && readonly.some(readonlyKey => readonlyKey === control.key) ? true : false;
458
+ return <Control {...props} />
459
+ };
460
+
461
+ toCascader = (props, control) => {
462
+ const container = this.getContainer();
463
+ container && (props.getPopupContainer = container);
464
+ props.options = control.options || [];
465
+ props.onSearch = this.createSearchEvent(control);
466
+ props.placeholder = props.placeholder || '';
467
+ props.loadData = this.createSearchEvent(control);
468
+ return <Control {...props} />;
469
+ };
470
+
471
+ toCheckbox = (props, control) => {
472
+ const options = control.options || [];
473
+ return <Checkbox.Group options={options} onChange={this.onBlur.bind(this, control.key)} value={this.props.value[control.key]} />
474
+ };
475
+
476
+ toControl = (props, control) => {
477
+ switch (props.type) {
478
+ case 'readonly':
479
+ return this.toReadonly(props, control);
480
+ case 'double':
481
+ return this.toDoubleInput(props, control, this.props.value);
482
+ case 'text':
483
+ return this.toText(props, control);
484
+ case 'number':
485
+ return this.toNumber(props, control);
486
+ case 'select':
487
+ case 'selectText':
488
+ return this.toSelect(props, control);
489
+ case 'search':
490
+ case 'searchText':
491
+ return this.toSearch(props, control);
492
+ case 'date':
493
+ return this.toDate(props, control);
494
+ case 'radioGroup':
495
+ return this.toRadioGroup(props, control);
496
+ case 'textArea':
497
+ return this.toTextArea(props, control);
498
+ case 'password':
499
+ return this.toPassword(props, control);
500
+ case 'editor':
501
+ return this.toEditor(props, control);
502
+ case 'selectWriting' :
503
+ return this.toSelectWriting(props,control)
504
+ case 'selectSearch':
505
+ return this.selectSearch(props, control);
506
+ case 'empty':
507
+ return this.toEmpty(props, control);
508
+ case 'captcha':
509
+ return this.captcha(props, control);
510
+ case 'area':
511
+ return this.area(props, control);
512
+ case 'uploadImg':
513
+ return this.uploadImg(props, control);
514
+ case 'cascader':
515
+ return this.toCascader(props, control);
516
+ case 'treeSelect':
517
+ return this.toTreeSelect(props, control);
518
+ case 'checkbox':
519
+ return this.toCheckbox(props, control);
520
+ default:
521
+ return 'type error';
522
+ }
523
+ };
524
+
525
+ toLabel = ({title, showAdd, key,showInfo,showInfoTitle}, type) => {
526
+ if (showAdd && (type !== 'readonly')) {
527
+ const onClick = this.onAdd.bind(this, key, title);
528
+ return <span>{title}<Icon role='add' type='plus-circle-o' onClick={onClick}/></span>;
529
+ } else if (showInfo){
530
+ return <span>{title}<Tooltip title={showInfoTitle}><Icon type="info-circle" /></Tooltip></span>
531
+ }
532
+ else {
533
+ return title;
534
+ }
535
+ };
536
+
537
+ toCol = (span, control) => {
538
+ const factor = control.span || 1;
539
+ const status = this.getValidState(control);
540
+ const controlProps = this.getControlProps(control, status);
541
+ const itemProps = {
542
+ label: this.toLabel(control, controlProps.type),
543
+ required: control.required,
544
+ validateStatus: status
545
+ };
546
+ const {checkable,onCheckItem} = this.props;
547
+ return control.type !== 'empty' ? (
548
+ <Col span={span * factor} key={control.key}>
549
+ {checkable && <Checkbox className={variables('SuperForm2').checkbox} onChange={onCheckItem.bind(this,control)} checked={control.checked} />}
550
+ <FormItem {...itemProps} className={checkable ? variables('SuperForm2').formItemWithCheckbox : '' } labelCol={{xs:{span: 24},sm:{span:8}}} wrapperCol={{xs:{span:24},sm:{span:16}}}>
551
+ {this.toControl(controlProps, control)}
552
+ </FormItem>
553
+ </Col>
554
+ ) : (
555
+ <Col span={span * factor} key={control.key} style={{height: '44px'}}/>
556
+ );
557
+ };
558
+
559
+ toCols = () => {
560
+ let {colNum=defaultColNum,allFullFather} = this.props;
561
+ if(allFullFather){
562
+ colNum = 1;
563
+ }
564
+ const span = 24 / colNum;
565
+ return this.getControls().map(control => {
566
+ if(allFullFather){
567
+ control.allFullFather = allFullFather;
568
+ }
569
+ return this.toCol(span, control)
570
+ });
571
+ };
572
+
573
+ render() {
574
+ this.initValidState();
575
+ const {layout='horizontal'} = this.props;
576
+ return (
577
+ <div className={variables('SuperForm2')}>
578
+ <Form layout={layout} style={{maxWidth: this.props.allFullFather ? '100%' : this.getMaxWidth()}}>
579
+ <Row gutter={20}>
580
+ {this.toCols()}
581
+ </Row>
582
+ </Form>
583
+ </div>
584
+ );
585
+ }
586
+ }
587
+
588
+ export default SuperForm2;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import {Icon} from 'antd';
3
+
4
+ const SuperIcon = ({type, style={}, ...props}) => {
5
+ if (!type) {
6
+ return <Icon style={style} {...props} />;
7
+ } else if (type.substring(0, 4) !== 'pld-') {
8
+ return <Icon type={type} style={style} {...props} />;
9
+ } else {
10
+ return <i className={`pldicon anticon anticon-${type}`} style={style} />
11
+ }
12
+ };
13
+
14
+ export default SuperIcon;
@@ -0,0 +1,65 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import {Pagination} from 'antd';
4
+
5
+ /**
6
+ * maxRecords: 最大记录数
7
+ * selRecords: [可选]已选记录条数
8
+ * currentPage:当前页码
9
+ * pageSize:页面大小
10
+ * align: 分页组件的对齐方式,默认居右
11
+ * pageSizeType: 字符串数组,页面大小规格
12
+ * description:字符串描述,类似'共有{maxRecords}条记录'
13
+ * onPageChange:跳转到新的一页时触发,原型func(pageNumber)
14
+ * onPageSizeChange: 页大小改变时触发,原型func(pageSize, pageNumber)
15
+ */
16
+ class SuperPagination extends React.Component {
17
+ static propTypes = {
18
+ maxRecords: PropTypes.number,
19
+ selRecords: PropTypes.number,
20
+ currentPage: PropTypes.number,
21
+ pageSize: PropTypes.number,
22
+ align: PropTypes.oneOf(['left', 'right', 'center']),
23
+ pageSizeType: PropTypes.array,
24
+ description: PropTypes.string,
25
+ style: PropTypes.object,
26
+ onPageNumberChange: PropTypes.func,
27
+ onPageSizeChange: PropTypes.func
28
+ };
29
+
30
+ onChange = (page) => {
31
+ const {callback = {}} = this.props;
32
+ const onPageNumberChange = this.props.onPageNumberChange || callback.onPageNumberChange;
33
+ onPageNumberChange && onPageNumberChange(page);
34
+ };
35
+
36
+ onShowSizeChange = (current, size) => {
37
+ const {callback = {}} = this.props;
38
+ const onPageSizeChange = this.props.onPageSizeChange || callback.onPageSizeChange;
39
+ onPageSizeChange && onPageSizeChange(size, current || 1);
40
+ };
41
+
42
+ render() {
43
+ const {currentPage, maxRecords, pageSize, pageSizeType, align, description, selRecords, page={}, option={}, style={}} = this.props;
44
+ const desp = description || (this.props.config || {}).pageDesp || '';
45
+ const props = {
46
+ current: currentPage || page.currentPage,
47
+ total: maxRecords || page.maxRecords,
48
+ pageSize: pageSize || page.pageSize,
49
+ showSizeChanger: true,
50
+ showQuickJumper: true,
51
+ pageSizeOptions: pageSizeType || option.pageSizeType || [],
52
+ onChange: this.onChange,
53
+ onShowSizeChange: this.onShowSizeChange,
54
+ showTotal: (total) => desp.replace('{maxRecords}', total).replace('{selRecords}', selRecords || 0),
55
+ style: Object.assign({}, style, {
56
+ display: 'inline-block',
57
+ textAlign: 'left',
58
+ verticalAlign: 'top'
59
+ })
60
+ };
61
+ return <div style={{textAlign: align || 'right'}}><Pagination {...props} /></div>;
62
+ }
63
+ }
64
+
65
+ export default SuperPagination;