vxe-pc-ui 3.0.0 → 3.0.1

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 (331) hide show
  1. package/es/button/src/button.js +3 -0
  2. package/es/carousel/index.js +12 -0
  3. package/es/carousel/src/carousel-item.js +100 -0
  4. package/es/carousel/src/carousel.js +418 -0
  5. package/es/carousel/src/util.js +17 -0
  6. package/es/carousel/style.css +185 -0
  7. package/es/carousel/style.min.css +1 -0
  8. package/es/carousel-item/index.js +12 -0
  9. package/es/carousel-item/style.css +0 -0
  10. package/es/carousel-item/style.min.css +0 -0
  11. package/es/checkbox/index.js +12 -0
  12. package/es/checkbox/src/checkbox.js +159 -0
  13. package/es/checkbox/src/group.js +154 -0
  14. package/es/checkbox/style.css +117 -0
  15. package/es/checkbox/style.min.css +1 -0
  16. package/es/checkbox-group/index.js +12 -0
  17. package/es/checkbox-group/style.css +0 -0
  18. package/es/checkbox-group/style.min.css +0 -0
  19. package/es/components.js +39 -39
  20. package/es/date-picker/src/date-picker.js +3 -0
  21. package/es/icon/style.css +1 -1
  22. package/es/icon-picker/index.js +12 -0
  23. package/es/icon-picker/src/icon-picker.js +668 -0
  24. package/es/icon-picker/style.css +207 -0
  25. package/es/icon-picker/style.min.css +1 -0
  26. package/es/input/index.js +12 -0
  27. package/es/input/src/input.js +2892 -0
  28. package/es/input/style.css +941 -0
  29. package/es/input/style.min.css +1 -0
  30. package/es/layout-footer/src/layout-footer.js +2 -1
  31. package/es/layout-header/src/layout-header.js +2 -1
  32. package/es/optgroup/index.js +12 -0
  33. package/es/optgroup/style.css +0 -0
  34. package/es/optgroup/style.min.css +0 -0
  35. package/es/option/index.js +12 -0
  36. package/es/option/style.css +0 -0
  37. package/es/option/style.min.css +0 -0
  38. package/es/pager/index.js +12 -0
  39. package/es/pager/src/pager.js +687 -0
  40. package/es/password-input/index.js +12 -0
  41. package/es/password-input/src/password-input.js +388 -0
  42. package/es/password-input/style.css +604 -0
  43. package/es/password-input/style.min.css +1 -0
  44. package/es/pulldown/src/pulldown.js +5 -1
  45. package/es/select/index.js +12 -0
  46. package/es/select/src/optgroup.js +90 -0
  47. package/es/select/src/option-info.js +16 -0
  48. package/es/select/src/option.js +86 -0
  49. package/es/select/src/select.js +1269 -0
  50. package/es/select/src/util.js +35 -0
  51. package/es/select/style.css +207 -0
  52. package/es/select/style.min.css +1 -0
  53. package/es/style.css +1 -1
  54. package/es/style.min.css +1 -1
  55. package/es/tab-pane/index.js +12 -0
  56. package/es/tab-pane/style.css +0 -0
  57. package/es/tab-pane/style.min.css +0 -0
  58. package/es/tabs/index.js +12 -0
  59. package/es/tabs/src/tab-pane.js +119 -0
  60. package/es/tabs/src/tabs.js +593 -0
  61. package/es/tabs/src/util.js +17 -0
  62. package/es/tabs/style.css +342 -0
  63. package/es/tabs/style.min.css +1 -0
  64. package/es/ui/index.js +1 -1
  65. package/es/ui/src/log.js +1 -1
  66. package/es/vxe-carousel/index.js +3 -0
  67. package/es/vxe-carousel/style.css +185 -0
  68. package/es/vxe-carousel/style.min.css +1 -0
  69. package/es/vxe-carousel-item/index.js +3 -0
  70. package/es/vxe-carousel-item/style.css +0 -0
  71. package/es/vxe-carousel-item/style.min.css +0 -0
  72. package/es/vxe-checkbox/index.js +3 -0
  73. package/es/vxe-checkbox/style.css +117 -0
  74. package/es/vxe-checkbox/style.min.css +1 -0
  75. package/es/vxe-checkbox-group/index.js +3 -0
  76. package/es/vxe-checkbox-group/style.css +0 -0
  77. package/es/vxe-checkbox-group/style.min.css +0 -0
  78. package/es/vxe-icon-picker/index.js +3 -0
  79. package/es/vxe-icon-picker/style.css +207 -0
  80. package/es/vxe-icon-picker/style.min.css +1 -0
  81. package/es/vxe-input/index.js +3 -0
  82. package/es/vxe-input/style.css +941 -0
  83. package/es/vxe-input/style.min.css +1 -0
  84. package/es/vxe-optgroup/index.js +3 -0
  85. package/es/vxe-optgroup/style.css +0 -0
  86. package/es/vxe-optgroup/style.min.css +0 -0
  87. package/es/vxe-option/index.js +3 -0
  88. package/es/vxe-option/style.css +0 -0
  89. package/es/vxe-option/style.min.css +0 -0
  90. package/es/vxe-password-input/index.js +3 -0
  91. package/es/vxe-password-input/style.css +604 -0
  92. package/es/vxe-password-input/style.min.css +1 -0
  93. package/es/vxe-select/index.js +3 -0
  94. package/es/vxe-select/style.css +207 -0
  95. package/es/vxe-select/style.min.css +1 -0
  96. package/es/vxe-tab-pane/index.js +3 -0
  97. package/es/vxe-tab-pane/style.css +0 -0
  98. package/es/vxe-tab-pane/style.min.css +0 -0
  99. package/es/vxe-tabs/index.js +3 -0
  100. package/es/vxe-tabs/style.css +342 -0
  101. package/es/vxe-tabs/style.min.css +1 -0
  102. package/lib/button/src/button.js +3 -0
  103. package/lib/button/src/button.min.js +1 -1
  104. package/lib/carousel/index.js +19 -0
  105. package/lib/carousel/index.min.js +1 -0
  106. package/lib/carousel/src/carousel-item.js +107 -0
  107. package/lib/carousel/src/carousel-item.min.js +1 -0
  108. package/lib/carousel/src/carousel.js +437 -0
  109. package/lib/carousel/src/carousel.min.js +1 -0
  110. package/lib/carousel/src/util.js +27 -0
  111. package/lib/carousel/src/util.min.js +1 -0
  112. package/lib/carousel/style/index.js +1 -0
  113. package/lib/carousel/style/style.css +185 -0
  114. package/lib/carousel/style/style.min.css +1 -0
  115. package/lib/carousel-item/index.js +19 -0
  116. package/lib/carousel-item/index.min.js +1 -0
  117. package/lib/carousel-item/style/index.js +1 -0
  118. package/lib/carousel-item/style/style.css +0 -0
  119. package/lib/carousel-item/style/style.min.css +0 -0
  120. package/lib/checkbox/index.js +19 -0
  121. package/lib/checkbox/index.min.js +1 -0
  122. package/lib/checkbox/src/checkbox.js +169 -0
  123. package/lib/checkbox/src/checkbox.min.js +1 -0
  124. package/lib/checkbox/src/group.js +164 -0
  125. package/lib/checkbox/src/group.min.js +1 -0
  126. package/lib/checkbox/style/index.js +1 -0
  127. package/lib/checkbox/style/style.css +117 -0
  128. package/lib/checkbox/style/style.min.css +1 -0
  129. package/lib/checkbox-group/index.js +19 -0
  130. package/lib/checkbox-group/index.min.js +1 -0
  131. package/lib/checkbox-group/style/index.js +1 -0
  132. package/lib/checkbox-group/style/style.css +0 -0
  133. package/lib/checkbox-group/style/style.min.css +0 -0
  134. package/lib/components.js +159 -60
  135. package/lib/components.min.js +1 -1
  136. package/lib/date-picker/src/date-picker.js +3 -0
  137. package/lib/date-picker/src/date-picker.min.js +1 -1
  138. package/lib/icon/style/style.css +1 -1
  139. package/lib/icon/style/style.min.css +1 -1
  140. package/lib/icon-picker/index.js +19 -0
  141. package/lib/icon-picker/index.min.js +1 -0
  142. package/lib/icon-picker/src/icon-picker.js +646 -0
  143. package/lib/icon-picker/src/icon-picker.min.js +1 -0
  144. package/lib/icon-picker/style/index.js +1 -0
  145. package/lib/icon-picker/style/style.css +207 -0
  146. package/lib/icon-picker/style/style.min.css +1 -0
  147. package/lib/index.umd.js +15870 -7738
  148. package/lib/index.umd.min.js +1 -1
  149. package/lib/input/index.js +19 -0
  150. package/lib/input/index.min.js +1 -0
  151. package/lib/input/src/input.js +2897 -0
  152. package/lib/input/src/input.min.js +1 -0
  153. package/lib/input/style/index.js +1 -0
  154. package/lib/input/style/style.css +941 -0
  155. package/lib/input/style/style.min.css +1 -0
  156. package/lib/layout-footer/src/layout-footer.js +2 -1
  157. package/lib/layout-header/src/layout-header.js +2 -1
  158. package/lib/optgroup/index.js +19 -0
  159. package/lib/optgroup/index.min.js +1 -0
  160. package/lib/optgroup/style/index.js +1 -0
  161. package/lib/optgroup/style/style.css +0 -0
  162. package/lib/optgroup/style/style.min.css +0 -0
  163. package/lib/option/index.js +19 -0
  164. package/lib/option/index.min.js +1 -0
  165. package/lib/option/style/index.js +1 -0
  166. package/lib/option/style/style.css +0 -0
  167. package/lib/option/style/style.min.css +0 -0
  168. package/lib/pager/index.js +19 -0
  169. package/lib/pager/index.min.js +1 -0
  170. package/lib/pager/src/pager.js +714 -0
  171. package/lib/pager/src/pager.min.js +1 -0
  172. package/lib/password-input/index.js +19 -0
  173. package/lib/password-input/index.min.js +1 -0
  174. package/lib/password-input/src/password-input.js +398 -0
  175. package/lib/password-input/src/password-input.min.js +1 -0
  176. package/lib/password-input/style/index.js +1 -0
  177. package/lib/password-input/style/style.css +604 -0
  178. package/lib/password-input/style/style.min.css +1 -0
  179. package/lib/pulldown/src/pulldown.js +5 -1
  180. package/lib/pulldown/src/pulldown.min.js +1 -1
  181. package/lib/select/index.js +19 -0
  182. package/lib/select/index.min.js +1 -0
  183. package/lib/select/src/optgroup.js +97 -0
  184. package/lib/select/src/optgroup.min.js +1 -0
  185. package/lib/select/src/option-info.js +33 -0
  186. package/lib/select/src/option-info.min.js +1 -0
  187. package/lib/select/src/option.js +93 -0
  188. package/lib/select/src/option.min.js +1 -0
  189. package/lib/select/src/select.js +1315 -0
  190. package/lib/select/src/select.min.js +1 -0
  191. package/lib/select/src/util.js +50 -0
  192. package/lib/select/src/util.min.js +1 -0
  193. package/lib/select/style/index.js +1 -0
  194. package/lib/select/style/style.css +207 -0
  195. package/lib/select/style/style.min.css +1 -0
  196. package/lib/style.css +1 -1
  197. package/lib/style.min.css +1 -1
  198. package/lib/tab-pane/index.js +19 -0
  199. package/lib/tab-pane/index.min.js +1 -0
  200. package/lib/tab-pane/style/index.js +1 -0
  201. package/lib/tab-pane/style/style.css +0 -0
  202. package/lib/tab-pane/style/style.min.css +0 -0
  203. package/lib/tabs/index.js +19 -0
  204. package/lib/tabs/index.min.js +1 -0
  205. package/lib/tabs/src/tab-pane.js +128 -0
  206. package/lib/tabs/src/tab-pane.min.js +1 -0
  207. package/lib/tabs/src/tabs.js +630 -0
  208. package/lib/tabs/src/tabs.min.js +1 -0
  209. package/lib/tabs/src/util.js +29 -0
  210. package/lib/tabs/src/util.min.js +1 -0
  211. package/lib/tabs/style/index.js +1 -0
  212. package/lib/tabs/style/style.css +342 -0
  213. package/lib/tabs/style/style.min.css +1 -0
  214. package/lib/ui/index.js +1 -1
  215. package/lib/ui/index.min.js +1 -1
  216. package/lib/ui/src/log.js +1 -1
  217. package/lib/ui/src/log.min.js +1 -1
  218. package/lib/vxe-carousel/index.js +23 -0
  219. package/lib/vxe-carousel/index.min.js +1 -0
  220. package/lib/vxe-carousel/style/index.js +1 -0
  221. package/lib/vxe-carousel/style/style.css +185 -0
  222. package/lib/vxe-carousel/style/style.min.css +1 -0
  223. package/lib/vxe-carousel-item/index.js +23 -0
  224. package/lib/vxe-carousel-item/index.min.js +1 -0
  225. package/lib/vxe-carousel-item/style/index.js +1 -0
  226. package/lib/vxe-carousel-item/style/style.css +0 -0
  227. package/lib/vxe-carousel-item/style/style.min.css +0 -0
  228. package/lib/vxe-checkbox/index.js +23 -0
  229. package/lib/vxe-checkbox/index.min.js +1 -0
  230. package/lib/vxe-checkbox/style/index.js +1 -0
  231. package/lib/vxe-checkbox/style/style.css +117 -0
  232. package/lib/vxe-checkbox/style/style.min.css +1 -0
  233. package/lib/vxe-checkbox-group/index.js +23 -0
  234. package/lib/vxe-checkbox-group/index.min.js +1 -0
  235. package/lib/vxe-checkbox-group/style/index.js +1 -0
  236. package/lib/vxe-checkbox-group/style/style.css +0 -0
  237. package/lib/vxe-checkbox-group/style/style.min.css +0 -0
  238. package/lib/vxe-icon-picker/index.js +23 -0
  239. package/lib/vxe-icon-picker/index.min.js +1 -0
  240. package/lib/vxe-icon-picker/style/index.js +1 -0
  241. package/lib/vxe-icon-picker/style/style.css +207 -0
  242. package/lib/vxe-icon-picker/style/style.min.css +1 -0
  243. package/lib/vxe-input/index.js +23 -0
  244. package/lib/vxe-input/index.min.js +1 -0
  245. package/lib/vxe-input/style/index.js +1 -0
  246. package/lib/vxe-input/style/style.css +941 -0
  247. package/lib/vxe-input/style/style.min.css +1 -0
  248. package/lib/vxe-optgroup/index.js +23 -0
  249. package/lib/vxe-optgroup/index.min.js +1 -0
  250. package/lib/vxe-optgroup/style/index.js +1 -0
  251. package/lib/vxe-optgroup/style/style.css +0 -0
  252. package/lib/vxe-optgroup/style/style.min.css +0 -0
  253. package/lib/vxe-option/index.js +23 -0
  254. package/lib/vxe-option/index.min.js +1 -0
  255. package/lib/vxe-option/style/index.js +1 -0
  256. package/lib/vxe-option/style/style.css +0 -0
  257. package/lib/vxe-option/style/style.min.css +0 -0
  258. package/lib/vxe-password-input/index.js +23 -0
  259. package/lib/vxe-password-input/index.min.js +1 -0
  260. package/lib/vxe-password-input/style/index.js +1 -0
  261. package/lib/vxe-password-input/style/style.css +604 -0
  262. package/lib/vxe-password-input/style/style.min.css +1 -0
  263. package/lib/vxe-select/index.js +23 -0
  264. package/lib/vxe-select/index.min.js +1 -0
  265. package/lib/vxe-select/style/index.js +1 -0
  266. package/lib/vxe-select/style/style.css +207 -0
  267. package/lib/vxe-select/style/style.min.css +1 -0
  268. package/lib/vxe-tab-pane/index.js +23 -0
  269. package/lib/vxe-tab-pane/index.min.js +1 -0
  270. package/lib/vxe-tab-pane/style/index.js +1 -0
  271. package/lib/vxe-tab-pane/style/style.css +0 -0
  272. package/lib/vxe-tab-pane/style/style.min.css +0 -0
  273. package/lib/vxe-tabs/index.js +23 -0
  274. package/lib/vxe-tabs/index.min.js +1 -0
  275. package/lib/vxe-tabs/style/index.js +1 -0
  276. package/lib/vxe-tabs/style/style.css +342 -0
  277. package/lib/vxe-tabs/style/style.min.css +1 -0
  278. package/package.json +1 -1
  279. package/packages/button/src/button.ts +3 -0
  280. package/packages/carousel/index.ts +16 -0
  281. package/packages/carousel/src/carousel-item.ts +114 -0
  282. package/packages/carousel/src/carousel.ts +449 -0
  283. package/packages/carousel/src/util.ts +21 -0
  284. package/packages/carousel-item/index.ts +16 -0
  285. package/packages/checkbox/index.ts +16 -0
  286. package/packages/checkbox/src/checkbox.ts +176 -0
  287. package/packages/checkbox/src/group.ts +178 -0
  288. package/packages/checkbox-group/index.ts +16 -0
  289. package/packages/components.ts +39 -39
  290. package/packages/date-picker/src/date-picker.ts +3 -0
  291. package/packages/icon-picker/index.ts +16 -0
  292. package/packages/icon-picker/src/icon-picker.ts +711 -0
  293. package/packages/input/index.ts +16 -0
  294. package/packages/input/src/input.ts +2995 -0
  295. package/packages/layout-footer/src/layout-footer.ts +4 -3
  296. package/packages/layout-header/src/layout-header.ts +2 -1
  297. package/packages/optgroup/index.ts +16 -0
  298. package/packages/option/index.ts +16 -0
  299. package/packages/pager/index.ts +16 -0
  300. package/packages/pager/src/pager.ts +743 -0
  301. package/packages/password-input/index.ts +16 -0
  302. package/packages/password-input/src/password-input.ts +427 -0
  303. package/packages/pulldown/src/pulldown.ts +5 -1
  304. package/packages/select/index.ts +16 -0
  305. package/packages/select/src/optgroup.ts +107 -0
  306. package/packages/select/src/option-info.ts +20 -0
  307. package/packages/select/src/option.ts +103 -0
  308. package/packages/select/src/select.ts +1325 -0
  309. package/packages/select/src/util.ts +46 -0
  310. package/packages/tab-pane/index.ts +16 -0
  311. package/packages/tabs/index.ts +16 -0
  312. package/packages/tabs/src/tab-pane.ts +136 -0
  313. package/packages/tabs/src/tabs.ts +630 -0
  314. package/packages/tabs/src/util.ts +21 -0
  315. package/types/components/carousel.d.ts +5 -0
  316. package/types/components/icon-picker.d.ts +4 -0
  317. package/types/components/input.d.ts +9 -1
  318. package/types/components/optgroup.d.ts +10 -4
  319. package/types/components/tabs.d.ts +4 -0
  320. /package/es/icon/style/{iconfont.1725630285930.ttf → iconfont.1725723159302.ttf} +0 -0
  321. /package/es/icon/style/{iconfont.1725630285930.woff → iconfont.1725723159302.woff} +0 -0
  322. /package/es/icon/style/{iconfont.1725630285930.woff2 → iconfont.1725723159302.woff2} +0 -0
  323. /package/es/{iconfont.1725630285930.ttf → iconfont.1725723159302.ttf} +0 -0
  324. /package/es/{iconfont.1725630285930.woff → iconfont.1725723159302.woff} +0 -0
  325. /package/es/{iconfont.1725630285930.woff2 → iconfont.1725723159302.woff2} +0 -0
  326. /package/lib/icon/style/{iconfont.1725630285930.ttf → iconfont.1725723159302.ttf} +0 -0
  327. /package/lib/icon/style/{iconfont.1725630285930.woff → iconfont.1725723159302.woff} +0 -0
  328. /package/lib/icon/style/{iconfont.1725630285930.woff2 → iconfont.1725723159302.woff2} +0 -0
  329. /package/lib/{iconfont.1725630285930.ttf → iconfont.1725723159302.ttf} +0 -0
  330. /package/lib/{iconfont.1725630285930.woff → iconfont.1725723159302.woff} +0 -0
  331. /package/lib/{iconfont.1725630285930.woff2 → iconfont.1725723159302.woff2} +0 -0
@@ -0,0 +1,2892 @@
1
+ import { defineVxeComponent } from '../../ui/src/comp';
2
+ import XEUtils from 'xe-utils';
3
+ import { getConfig, getIcon, getI18n, globalEvents, GLOBAL_EVENT_KEYS, createEvent, globalMixins, renderEmptyElement } from '../../ui';
4
+ import { getFuncText, getLastZIndex, nextZIndex } from '../../ui/src/utils';
5
+ import { hasClass, getAbsolutePos, getEventTargetNode } from '../../ui/src/dom';
6
+ import { toStringTimeDate, getDateQuarter } from '../../date-picker/src/util';
7
+ import { handleNumber, toFloatValueFixed } from '../../number-input/src/util';
8
+ import { getSlotVNs } from '../..//ui/src/vn';
9
+ export default defineVxeComponent({
10
+ name: 'VxeInput',
11
+ mixins: [
12
+ globalMixins.sizeMixin
13
+ ],
14
+ model: {
15
+ prop: 'value',
16
+ event: 'modelValue'
17
+ },
18
+ props: {
19
+ value: [String, Number, Date],
20
+ immediate: {
21
+ type: Boolean,
22
+ default: true
23
+ },
24
+ name: String,
25
+ type: {
26
+ type: String,
27
+ default: 'text'
28
+ },
29
+ clearable: {
30
+ type: Boolean,
31
+ default: () => getConfig().input.clearable
32
+ },
33
+ readonly: {
34
+ type: Boolean,
35
+ default: null
36
+ },
37
+ disabled: {
38
+ type: Boolean,
39
+ default: null
40
+ },
41
+ placeholder: String,
42
+ maxLength: [String, Number],
43
+ autoComplete: {
44
+ type: String,
45
+ default: 'off'
46
+ },
47
+ align: String,
48
+ form: String,
49
+ className: String,
50
+ size: {
51
+ type: String,
52
+ default: () => getConfig().input.size || getConfig().size
53
+ },
54
+ multiple: Boolean,
55
+ // text
56
+ showWordCount: Boolean,
57
+ countMethod: Function,
58
+ // number、integer、float
59
+ min: {
60
+ type: [String, Number],
61
+ default: null
62
+ },
63
+ max: {
64
+ type: [String, Number],
65
+ default: null
66
+ },
67
+ step: [String, Number],
68
+ exponential: {
69
+ type: Boolean,
70
+ default: () => getConfig().input.exponential
71
+ },
72
+ // number、integer、float、password
73
+ controls: {
74
+ type: Boolean,
75
+ default: () => getConfig().input.controls
76
+ },
77
+ // float
78
+ digits: {
79
+ type: [String, Number],
80
+ default: () => getConfig().input.digits
81
+ },
82
+ // date、week、month、quarter、year
83
+ startDate: {
84
+ type: [String, Number, Date],
85
+ default: () => getConfig().input.startDate
86
+ },
87
+ endDate: {
88
+ type: [String, Number, Date],
89
+ default: () => getConfig().input.endDate
90
+ },
91
+ minDate: [String, Number, Date],
92
+ maxDate: [String, Number, Date],
93
+ // 已废弃 startWeek,被 startDay 替换
94
+ startWeek: Number,
95
+ startDay: {
96
+ type: [String, Number],
97
+ default: () => getConfig().input.startDay
98
+ },
99
+ labelFormat: String,
100
+ valueFormat: String,
101
+ editable: {
102
+ type: Boolean,
103
+ default: true
104
+ },
105
+ festivalMethod: {
106
+ type: Function,
107
+ default: () => getConfig().input.festivalMethod
108
+ },
109
+ disabledMethod: {
110
+ type: Function,
111
+ default: () => getConfig().input.disabledMethod
112
+ },
113
+ // week
114
+ selectDay: {
115
+ type: [String, Number],
116
+ default: () => getConfig().input.selectDay
117
+ },
118
+ prefixIcon: String,
119
+ suffixIcon: String,
120
+ placement: String,
121
+ transfer: {
122
+ type: Boolean,
123
+ default: null
124
+ },
125
+ // 已废弃
126
+ maxlength: [String, Number],
127
+ // 已废弃
128
+ autocomplete: String
129
+ },
130
+ inject: {
131
+ $xeModal: {
132
+ default: null
133
+ },
134
+ $xeDrawer: {
135
+ default: null
136
+ },
137
+ $xeTable: {
138
+ default: null
139
+ },
140
+ $xeForm: {
141
+ default: null
142
+ },
143
+ formItemInfo: {
144
+ from: 'xeFormItemInfo',
145
+ default: null
146
+ }
147
+ },
148
+ provide() {
149
+ const $xeSelect = this;
150
+ return {
151
+ $xeSelect
152
+ };
153
+ },
154
+ data() {
155
+ const xID = XEUtils.uniqueId();
156
+ const reactData = {
157
+ initialized: false,
158
+ panelIndex: 0,
159
+ showPwd: false,
160
+ visiblePanel: false,
161
+ isAniVisible: false,
162
+ panelStyle: {},
163
+ panelPlacement: '',
164
+ isActivated: false,
165
+ inputValue: '',
166
+ datetimePanelValue: null,
167
+ datePanelValue: null,
168
+ datePanelLabel: '',
169
+ datePanelType: 'day',
170
+ selectMonth: null,
171
+ currentDate: null
172
+ };
173
+ const internalData = {
174
+ yearSize: 12,
175
+ monthSize: 20,
176
+ quarterSize: 8,
177
+ hpTimeout: undefined,
178
+ dnTimeout: undefined
179
+ };
180
+ return {
181
+ xID,
182
+ reactData,
183
+ internalData
184
+ };
185
+ },
186
+ computed: Object.assign(Object.assign({}, {}), { computeBtnTransfer() {
187
+ const $xeInput = this;
188
+ const props = $xeInput;
189
+ const $xeTable = $xeInput.$xeTable;
190
+ const $xeModal = $xeInput.$xeModal;
191
+ const $xeDrawer = $xeInput.$xeDrawer;
192
+ const $xeForm = $xeInput.$xeForm;
193
+ const { transfer } = props;
194
+ if (transfer === null) {
195
+ const globalTransfer = getConfig().input.transfer;
196
+ if (XEUtils.isBoolean(globalTransfer)) {
197
+ return globalTransfer;
198
+ }
199
+ if ($xeTable || $xeModal || $xeDrawer || $xeForm) {
200
+ return true;
201
+ }
202
+ }
203
+ return transfer;
204
+ },
205
+ computeFormReadonly() {
206
+ const $xeInput = this;
207
+ const $xeForm = $xeInput.$xeForm;
208
+ if ($xeForm) {
209
+ return $xeForm.readonly;
210
+ }
211
+ return false;
212
+ },
213
+ computeIsReadonly() {
214
+ const $xeInput = this;
215
+ const props = $xeInput;
216
+ const { readonly } = props;
217
+ return readonly;
218
+ },
219
+ computeIsDisabled() {
220
+ const $xeInput = this;
221
+ const props = $xeInput;
222
+ const $xeForm = $xeInput.$xeForm;
223
+ const { disabled } = props;
224
+ if (disabled === null) {
225
+ if ($xeForm) {
226
+ return $xeForm.disabled;
227
+ }
228
+ return false;
229
+ }
230
+ return disabled;
231
+ },
232
+ computeInpMaxLength() {
233
+ const $xeInput = this;
234
+ const props = $xeInput;
235
+ const { maxLength, maxlength } = props;
236
+ const maxLen = maxLength || maxlength;
237
+ const isNumType = $xeInput.computeIsNumType;
238
+ // 数值最大长度限制 16 位,包含小数
239
+ if (isNumType) {
240
+ if (!XEUtils.toNumber(maxLen)) {
241
+ return 16;
242
+ }
243
+ }
244
+ return maxLen;
245
+ },
246
+ computeIsDateTimeType() {
247
+ const $xeInput = this;
248
+ const props = $xeInput;
249
+ const { type } = props;
250
+ return type === 'time' || type === 'datetime';
251
+ },
252
+ computeIsNumType() {
253
+ const $xeInput = this;
254
+ const props = $xeInput;
255
+ return ['number', 'integer', 'float'].indexOf(props.type) > -1;
256
+ },
257
+ computeInputCount() {
258
+ const $xeInput = this;
259
+ const reactData = $xeInput.reactData;
260
+ return XEUtils.getSize(reactData.inputValue);
261
+ },
262
+ computeIsCountError() {
263
+ const $xeInput = this;
264
+ const inputCount = $xeInput.computeInputCount;
265
+ const inpMaxLength = $xeInput.computeInpMaxLength;
266
+ return inpMaxLength && inputCount > XEUtils.toNumber(inpMaxLength);
267
+ },
268
+ computeIsDatePickerType() {
269
+ const $xeInput = this;
270
+ const props = $xeInput;
271
+ const isDateTimeType = $xeInput.computeIsDateTimeType;
272
+ return isDateTimeType || ['date', 'week', 'month', 'quarter', 'year'].indexOf(props.type) > -1;
273
+ },
274
+ computeIsPawdType() {
275
+ const $xeInput = this;
276
+ const props = $xeInput;
277
+ return props.type === 'password';
278
+ },
279
+ computeIsSearchType() {
280
+ const $xeInput = this;
281
+ const props = $xeInput;
282
+ return props.type === 'search';
283
+ },
284
+ computeDigitsValue() {
285
+ const $xeInput = this;
286
+ const props = $xeInput;
287
+ return XEUtils.toInteger(props.digits) || 1;
288
+ },
289
+ computeStepValue() {
290
+ const $xeInput = this;
291
+ const props = $xeInput;
292
+ const { type } = props;
293
+ const digitsValue = $xeInput.computeDigitsValue;
294
+ const step = props.step;
295
+ if (type === 'integer') {
296
+ return XEUtils.toInteger(step) || 1;
297
+ }
298
+ else if (type === 'float') {
299
+ return XEUtils.toNumber(step) || (1 / Math.pow(10, digitsValue));
300
+ }
301
+ return XEUtils.toNumber(step) || 1;
302
+ },
303
+ computeIsClearable() {
304
+ const $xeInput = this;
305
+ const props = $xeInput;
306
+ const { type } = props;
307
+ const isNumType = $xeInput.computeIsNumType;
308
+ const isDatePickerType = $xeInput.computeIsDatePickerType;
309
+ const isPawdType = $xeInput.computeIsPawdType;
310
+ return props.clearable && (isPawdType || isNumType || isDatePickerType || type === 'text' || type === 'search');
311
+ },
312
+ computeDateStartTime() {
313
+ const $xeInput = this;
314
+ const props = $xeInput;
315
+ return props.startDate ? XEUtils.toStringDate(props.startDate) : null;
316
+ },
317
+ computeDateEndTime() {
318
+ const $xeInput = this;
319
+ const props = $xeInput;
320
+ return props.endDate ? XEUtils.toStringDate(props.endDate) : null;
321
+ },
322
+ computeSupportMultiples() {
323
+ const $xeInput = this;
324
+ const props = $xeInput;
325
+ return ['date', 'week', 'month', 'quarter', 'year'].indexOf(props.type) > -1;
326
+ },
327
+ computeDateListValue() {
328
+ const $xeInput = this;
329
+ const props = $xeInput;
330
+ const { value, multiple } = props;
331
+ const isDatePickerType = $xeInput.computeIsDatePickerType;
332
+ const dateValueFormat = $xeInput.computeDateValueFormat;
333
+ if (multiple && value && isDatePickerType) {
334
+ return XEUtils.toValueString(value).split(',').map(item => {
335
+ const date = $xeInput.parseDate(item, dateValueFormat);
336
+ if (XEUtils.isValidDate(date)) {
337
+ return date;
338
+ }
339
+ return date;
340
+ });
341
+ }
342
+ return [];
343
+ },
344
+ computeDateMultipleValue() {
345
+ const $xeInput = this;
346
+ const dateListValue = $xeInput.computeDateListValue;
347
+ const dateValueFormat = $xeInput.computeDateValueFormat;
348
+ return dateListValue.map(date => XEUtils.toDateString(date, dateValueFormat));
349
+ },
350
+ computeDateMultipleLabel() {
351
+ const $xeInput = this;
352
+ const dateListValue = $xeInput.computeDateListValue;
353
+ const dateLabelFormat = $xeInput.computeDateLabelFormat;
354
+ return dateListValue.map(date => XEUtils.toDateString(date, dateLabelFormat)).join(', ');
355
+ },
356
+ computeDateValueFormat() {
357
+ const $xeInput = this;
358
+ const props = $xeInput;
359
+ const { type, valueFormat } = props;
360
+ if (valueFormat) {
361
+ return valueFormat;
362
+ }
363
+ if (type === 'time') {
364
+ return 'HH:mm:ss';
365
+ }
366
+ if (type === 'datetime') {
367
+ return 'yyyy-MM-dd HH:mm:ss';
368
+ }
369
+ return 'yyyy-MM-dd';
370
+ },
371
+ computeDateValue() {
372
+ const $xeInput = this;
373
+ const props = $xeInput;
374
+ const { value } = props;
375
+ const isDatePickerType = $xeInput.computeIsDatePickerType;
376
+ const dateValueFormat = $xeInput.computeDateValueFormat;
377
+ let val = null;
378
+ if (value && isDatePickerType) {
379
+ const date = $xeInput.parseDate(value, dateValueFormat);
380
+ if (XEUtils.isValidDate(date)) {
381
+ val = date;
382
+ }
383
+ }
384
+ return val;
385
+ },
386
+ computeIsDisabledPrevDateBtn() {
387
+ const $xeInput = this;
388
+ const reactData = $xeInput.reactData;
389
+ const dateStartTime = $xeInput.computeDateStartTime;
390
+ const { selectMonth } = reactData;
391
+ if (selectMonth && dateStartTime) {
392
+ return selectMonth <= dateStartTime;
393
+ }
394
+ return false;
395
+ },
396
+ computeIsDisabledNextDateBtn() {
397
+ const $xeInput = this;
398
+ const reactData = $xeInput.reactData;
399
+ const dateEndTime = $xeInput.computeDateEndTime;
400
+ const { selectMonth } = reactData;
401
+ if (selectMonth && dateEndTime) {
402
+ return selectMonth >= dateEndTime;
403
+ }
404
+ return false;
405
+ },
406
+ computeDateTimeLabel() {
407
+ const $xeInput = this;
408
+ const reactData = $xeInput.reactData;
409
+ const { datetimePanelValue } = reactData;
410
+ const hasTimeSecond = $xeInput.computeHasTimeSecond;
411
+ if (datetimePanelValue) {
412
+ return XEUtils.toDateString(datetimePanelValue, hasTimeSecond ? 'HH:mm:ss' : 'HH:mm');
413
+ }
414
+ return '';
415
+ },
416
+ computeDateHMSTime() {
417
+ const $xeInput = this;
418
+ const dateValue = $xeInput.computeDateValue;
419
+ const isDateTimeType = $xeInput.computeIsDateTimeType;
420
+ return dateValue && isDateTimeType ? (dateValue.getHours() * 3600 + dateValue.getMinutes() * 60 + dateValue.getSeconds()) * 1000 : 0;
421
+ },
422
+ computeDateLabelFormat() {
423
+ const $xeInput = this;
424
+ const props = $xeInput;
425
+ const { labelFormat } = props;
426
+ const isDatePickerType = $xeInput.computeIsDatePickerType;
427
+ const dateValueFormat = $xeInput.computeDateValueFormat;
428
+ if (isDatePickerType) {
429
+ return labelFormat || dateValueFormat || getI18n(`vxe.input.date.labelFormat.${props.type}`);
430
+ }
431
+ return '';
432
+ },
433
+ computeYearList() {
434
+ const $xeInput = this;
435
+ const reactData = $xeInput.reactData;
436
+ const internalData = $xeInput.internalData;
437
+ const { selectMonth, currentDate } = reactData;
438
+ const { yearSize } = internalData;
439
+ const years = [];
440
+ if (selectMonth && currentDate) {
441
+ const currFullYear = currentDate.getFullYear();
442
+ const selectFullYear = selectMonth.getFullYear();
443
+ const startYearDate = new Date(selectFullYear - selectFullYear % yearSize, 0, 1);
444
+ for (let index = -4; index < yearSize + 4; index++) {
445
+ const date = XEUtils.getWhatYear(startYearDate, index, 'first');
446
+ const itemFullYear = date.getFullYear();
447
+ years.push({
448
+ date,
449
+ isCurrent: true,
450
+ isPrev: index < 0,
451
+ isNow: currFullYear === itemFullYear,
452
+ isNext: index >= yearSize,
453
+ year: itemFullYear
454
+ });
455
+ }
456
+ }
457
+ return years;
458
+ },
459
+ computeSelectDatePanelLabel() {
460
+ const $xeInput = this;
461
+ const reactData = $xeInput.reactData;
462
+ const isDatePickerType = $xeInput.computeIsDatePickerType;
463
+ if (isDatePickerType) {
464
+ const { datePanelType, selectMonth } = reactData;
465
+ const yearList = $xeInput.computeYearList;
466
+ let year = '';
467
+ let month;
468
+ if (selectMonth) {
469
+ year = selectMonth.getFullYear();
470
+ month = selectMonth.getMonth() + 1;
471
+ }
472
+ if (datePanelType === 'quarter') {
473
+ return getI18n('vxe.input.date.quarterLabel', [year]);
474
+ }
475
+ else if (datePanelType === 'month') {
476
+ return getI18n('vxe.input.date.monthLabel', [year]);
477
+ }
478
+ else if (datePanelType === 'year') {
479
+ return yearList.length ? `${yearList[0].year} - ${yearList[yearList.length - 1].year}` : '';
480
+ }
481
+ return getI18n('vxe.input.date.dayLabel', [year, month ? getI18n(`vxe.input.date.m${month}`) : '-']);
482
+ }
483
+ return '';
484
+ },
485
+ computeFirstDayOfWeek() {
486
+ const $xeInput = this;
487
+ const props = $xeInput;
488
+ const { startDay, startWeek } = props;
489
+ return XEUtils.toNumber(XEUtils.isNumber(startDay) || XEUtils.isString(startDay) ? startDay : startWeek);
490
+ },
491
+ computeWeekDatas() {
492
+ const $xeInput = this;
493
+ const weeks = [];
494
+ const isDatePickerType = $xeInput.computeIsDatePickerType;
495
+ if (isDatePickerType) {
496
+ let sWeek = $xeInput.computeFirstDayOfWeek;
497
+ weeks.push(sWeek);
498
+ for (let index = 0; index < 6; index++) {
499
+ if (sWeek >= 6) {
500
+ sWeek = 0;
501
+ }
502
+ else {
503
+ sWeek++;
504
+ }
505
+ weeks.push(sWeek);
506
+ }
507
+ }
508
+ return weeks;
509
+ },
510
+ computeDateHeaders() {
511
+ const $xeInput = this;
512
+ const isDatePickerType = $xeInput.computeIsDatePickerType;
513
+ if (isDatePickerType) {
514
+ const weekDatas = $xeInput.computeWeekDatas;
515
+ return weekDatas.map((day) => {
516
+ return {
517
+ value: day,
518
+ label: getI18n(`vxe.input.date.weeks.w${day}`)
519
+ };
520
+ });
521
+ }
522
+ return [];
523
+ },
524
+ computeWeekHeaders() {
525
+ const $xeInput = this;
526
+ const isDatePickerType = $xeInput.computeIsDatePickerType;
527
+ if (isDatePickerType) {
528
+ const dateHeaders = $xeInput.computeDateHeaders;
529
+ return [{ label: getI18n('vxe.input.date.weeks.w') }].concat(dateHeaders);
530
+ }
531
+ return [];
532
+ },
533
+ computeYearDatas() {
534
+ const $xeInput = this;
535
+ const yearList = $xeInput.computeYearList;
536
+ return XEUtils.chunk(yearList, 4);
537
+ },
538
+ computeQuarterList() {
539
+ const $xeInput = this;
540
+ const reactData = $xeInput.reactData;
541
+ const internalData = $xeInput.internalData;
542
+ const { selectMonth, currentDate } = reactData;
543
+ const { quarterSize } = internalData;
544
+ const quarters = [];
545
+ if (selectMonth && currentDate) {
546
+ const currFullYear = currentDate.getFullYear();
547
+ const currQuarter = getDateQuarter(currentDate);
548
+ const firstYear = XEUtils.getWhatYear(selectMonth, 0, 'first');
549
+ const selFullYear = firstYear.getFullYear();
550
+ for (let index = -2; index < quarterSize - 2; index++) {
551
+ const date = XEUtils.getWhatQuarter(firstYear, index);
552
+ const itemFullYear = date.getFullYear();
553
+ const itemQuarter = getDateQuarter(date);
554
+ const isPrev = itemFullYear < selFullYear;
555
+ quarters.push({
556
+ date,
557
+ isPrev,
558
+ isCurrent: itemFullYear === selFullYear,
559
+ isNow: itemFullYear === currFullYear && itemQuarter === currQuarter,
560
+ isNext: !isPrev && itemFullYear > selFullYear,
561
+ quarter: itemQuarter
562
+ });
563
+ }
564
+ }
565
+ return quarters;
566
+ },
567
+ computeQuarterDatas() {
568
+ const $xeInput = this;
569
+ const quarterList = $xeInput.computeQuarterList;
570
+ return XEUtils.chunk(quarterList, 2);
571
+ },
572
+ computeMonthList() {
573
+ const $xeInput = this;
574
+ const reactData = $xeInput.reactData;
575
+ const internalData = $xeInput.internalData;
576
+ const { selectMonth, currentDate } = reactData;
577
+ const { monthSize } = internalData;
578
+ const months = [];
579
+ if (selectMonth && currentDate) {
580
+ const currFullYear = currentDate.getFullYear();
581
+ const currMonth = currentDate.getMonth();
582
+ const selFullYear = XEUtils.getWhatYear(selectMonth, 0, 'first').getFullYear();
583
+ for (let index = -4; index < monthSize - 4; index++) {
584
+ const date = XEUtils.getWhatYear(selectMonth, 0, index);
585
+ const itemFullYear = date.getFullYear();
586
+ const itemMonth = date.getMonth();
587
+ const isPrev = itemFullYear < selFullYear;
588
+ months.push({
589
+ date,
590
+ isPrev,
591
+ isCurrent: itemFullYear === selFullYear,
592
+ isNow: itemFullYear === currFullYear && itemMonth === currMonth,
593
+ isNext: !isPrev && itemFullYear > selFullYear,
594
+ month: itemMonth
595
+ });
596
+ }
597
+ }
598
+ return months;
599
+ },
600
+ computeMonthDatas() {
601
+ const $xeInput = this;
602
+ const monthList = $xeInput.computeMonthList;
603
+ return XEUtils.chunk(monthList, 4);
604
+ },
605
+ computeDayList() {
606
+ const $xeInput = this;
607
+ const reactData = $xeInput.reactData;
608
+ const { selectMonth, currentDate } = reactData;
609
+ const days = [];
610
+ if (selectMonth && currentDate) {
611
+ const dateHMSTime = $xeInput.computeDateHMSTime;
612
+ const weekDatas = $xeInput.computeWeekDatas;
613
+ const currFullYear = currentDate.getFullYear();
614
+ const currMonth = currentDate.getMonth();
615
+ const currDate = currentDate.getDate();
616
+ const selFullYear = selectMonth.getFullYear();
617
+ const selMonth = selectMonth.getMonth();
618
+ const selDay = selectMonth.getDay();
619
+ const prevOffsetDate = -weekDatas.indexOf(selDay);
620
+ const startDayDate = new Date(XEUtils.getWhatDay(selectMonth, prevOffsetDate).getTime() + dateHMSTime);
621
+ for (let index = 0; index < 42; index++) {
622
+ const date = XEUtils.getWhatDay(startDayDate, index);
623
+ const itemFullYear = date.getFullYear();
624
+ const itemMonth = date.getMonth();
625
+ const itemDate = date.getDate();
626
+ const isPrev = date < selectMonth;
627
+ days.push({
628
+ date,
629
+ isPrev,
630
+ isCurrent: itemFullYear === selFullYear && itemMonth === selMonth,
631
+ isNow: itemFullYear === currFullYear && itemMonth === currMonth && itemDate === currDate,
632
+ isNext: !isPrev && selMonth !== itemMonth,
633
+ label: itemDate
634
+ });
635
+ }
636
+ }
637
+ return days;
638
+ },
639
+ computeDayDatas() {
640
+ const $xeInput = this;
641
+ const dayList = $xeInput.computeDayList;
642
+ return XEUtils.chunk(dayList, 7);
643
+ },
644
+ computeWeekDates() {
645
+ const $xeInput = this;
646
+ const dayDatas = $xeInput.computeDayDatas;
647
+ const firstDayOfWeek = $xeInput.computeFirstDayOfWeek;
648
+ return dayDatas.map((list) => {
649
+ const firstItem = list[0];
650
+ const item = {
651
+ date: firstItem.date,
652
+ isWeekNumber: true,
653
+ isPrev: false,
654
+ isCurrent: false,
655
+ isNow: false,
656
+ isNext: false,
657
+ label: XEUtils.getYearWeek(firstItem.date, firstDayOfWeek)
658
+ };
659
+ return [item].concat(list);
660
+ });
661
+ },
662
+ computeHourList() {
663
+ const $xeInput = this;
664
+ const list = [];
665
+ const isDateTimeType = $xeInput.computeIsDateTimeType;
666
+ if (isDateTimeType) {
667
+ for (let index = 0; index < 24; index++) {
668
+ list.push({
669
+ value: index,
670
+ label: ('' + index).padStart(2, '0')
671
+ });
672
+ }
673
+ }
674
+ return list;
675
+ },
676
+ computeMinuteList() {
677
+ const $xeInput = this;
678
+ const list = [];
679
+ const isDateTimeType = $xeInput.computeIsDateTimeType;
680
+ if (isDateTimeType) {
681
+ for (let index = 0; index < 60; index++) {
682
+ list.push({
683
+ value: index,
684
+ label: ('' + index).padStart(2, '0')
685
+ });
686
+ }
687
+ }
688
+ return list;
689
+ },
690
+ computeHasTimeMinute() {
691
+ const $xeInput = this;
692
+ const dateValueFormat = $xeInput.computeDateValueFormat;
693
+ return !/HH/.test(dateValueFormat) || /mm/.test(dateValueFormat);
694
+ },
695
+ computeHasTimeSecond() {
696
+ const $xeInput = this;
697
+ const dateValueFormat = $xeInput.computeDateValueFormat;
698
+ return !/HH/.test(dateValueFormat) || /ss/.test(dateValueFormat);
699
+ },
700
+ computeSecondList() {
701
+ const $xeInput = this;
702
+ const minuteList = $xeInput.computeMinuteList;
703
+ return minuteList;
704
+ },
705
+ computeInputReadonly() {
706
+ const $xeInput = this;
707
+ const props = $xeInput;
708
+ const { type, editable, multiple } = props;
709
+ const isReadonly = $xeInput.computeIsReadonly;
710
+ return isReadonly || multiple || !editable || type === 'week' || type === 'quarter';
711
+ },
712
+ computeInputType() {
713
+ const $xeInput = this;
714
+ const props = $xeInput;
715
+ const reactData = $xeInput.reactData;
716
+ const { type } = props;
717
+ const { showPwd } = reactData;
718
+ const isNumType = $xeInput.computeIsNumType;
719
+ const isDatePickerType = $xeInput.computeIsDatePickerType;
720
+ const isPawdType = $xeInput.computeIsPawdType;
721
+ if (isDatePickerType || isNumType || (isPawdType && showPwd) || type === 'number') {
722
+ return 'text';
723
+ }
724
+ return type;
725
+ },
726
+ computeInpPlaceholder() {
727
+ const $xeInput = this;
728
+ const props = $xeInput;
729
+ const { placeholder } = props;
730
+ if (placeholder) {
731
+ return getFuncText(placeholder);
732
+ }
733
+ const globalPlaceholder = getConfig().input.placeholder;
734
+ if (globalPlaceholder) {
735
+ return getFuncText(globalPlaceholder);
736
+ }
737
+ return getI18n('vxe.base.pleaseInput');
738
+ },
739
+ computeInpImmediate() {
740
+ const $xeInput = this;
741
+ const props = $xeInput;
742
+ const { type, immediate } = props;
743
+ return immediate || !(type === 'text' || type === 'number' || type === 'integer' || type === 'float');
744
+ },
745
+ computeNumValue() {
746
+ const $xeInput = this;
747
+ const props = $xeInput;
748
+ const reactData = $xeInput.reactData;
749
+ const { type } = props;
750
+ const { inputValue } = reactData;
751
+ const isNumType = $xeInput.computeIsNumType;
752
+ if (isNumType) {
753
+ return type === 'integer' ? XEUtils.toInteger(handleNumber(inputValue)) : XEUtils.toNumber(handleNumber(inputValue));
754
+ }
755
+ return 0;
756
+ },
757
+ computeIsDisabledSubtractNumber() {
758
+ const $xeInput = this;
759
+ const props = $xeInput;
760
+ const reactData = $xeInput.reactData;
761
+ const { min } = props;
762
+ const { inputValue } = reactData;
763
+ const isNumType = $xeInput.computeIsNumType;
764
+ const numValue = $xeInput.computeNumValue;
765
+ // 当有值时再进行判断
766
+ if ((inputValue || inputValue === 0) && isNumType && min !== null) {
767
+ return numValue <= XEUtils.toNumber(min);
768
+ }
769
+ return false;
770
+ },
771
+ computeIsDisabledAddNumber() {
772
+ const $xeInput = this;
773
+ const props = $xeInput;
774
+ const reactData = $xeInput.reactData;
775
+ const { max } = props;
776
+ const { inputValue } = reactData;
777
+ const isNumType = $xeInput.computeIsNumType;
778
+ const numValue = $xeInput.computeNumValue;
779
+ // 当有值时再进行判断
780
+ if ((inputValue || inputValue === 0) && isNumType && max !== null) {
781
+ return numValue >= XEUtils.toNumber(max);
782
+ }
783
+ return false;
784
+ } }),
785
+ methods: {
786
+ //
787
+ // Method
788
+ //
789
+ dispatchEvent(type, params, evnt) {
790
+ const $xeInput = this;
791
+ $xeInput.$emit(type, createEvent(evnt, { $input: $xeInput }, params));
792
+ },
793
+ focus() {
794
+ const $xeInput = this;
795
+ const reactData = $xeInput.reactData;
796
+ const inputElem = $xeInput.$refs.refInputTarget;
797
+ reactData.isActivated = true;
798
+ inputElem.focus();
799
+ return $xeInput.$nextTick();
800
+ },
801
+ blur() {
802
+ const $xeInput = this;
803
+ const reactData = $xeInput.reactData;
804
+ const inputElem = $xeInput.$refs.refInputTarget;
805
+ inputElem.blur();
806
+ reactData.isActivated = false;
807
+ return $xeInput.$nextTick();
808
+ },
809
+ select() {
810
+ const $xeInput = this;
811
+ const reactData = $xeInput.reactData;
812
+ const inputElem = $xeInput.$refs.refInputTarget;
813
+ inputElem.select();
814
+ reactData.isActivated = false;
815
+ return $xeInput.$nextTick();
816
+ },
817
+ parseDate(value, format) {
818
+ const $xeInput = this;
819
+ const props = $xeInput;
820
+ const { type } = props;
821
+ if (type === 'time') {
822
+ return toStringTimeDate(value);
823
+ }
824
+ return XEUtils.toStringDate(value, format);
825
+ },
826
+ getNumberValue(val) {
827
+ const $xeInput = this;
828
+ const props = $xeInput;
829
+ const { type, exponential } = props;
830
+ const inpMaxLength = $xeInput.computeInpMaxLength;
831
+ const digitsValue = $xeInput.computeDigitsValue;
832
+ const restVal = (type === 'float' ? toFloatValueFixed(val, digitsValue) : XEUtils.toValueString(val));
833
+ if (exponential && (val === restVal || XEUtils.toValueString(val).toLowerCase() === XEUtils.toNumber(restVal).toExponential())) {
834
+ return val;
835
+ }
836
+ return restVal.slice(0, inpMaxLength);
837
+ },
838
+ triggerEvent(evnt) {
839
+ const $xeInput = this;
840
+ const reactData = $xeInput.reactData;
841
+ const { inputValue } = reactData;
842
+ $xeInput.dispatchEvent(evnt.type, { value: inputValue }, evnt);
843
+ },
844
+ emitModel(value, evnt) {
845
+ const $xeInput = this;
846
+ const props = $xeInput;
847
+ const reactData = $xeInput.reactData;
848
+ const $xeForm = $xeInput.$xeForm;
849
+ const formItemInfo = $xeInput.formItemInfo;
850
+ reactData.inputValue = value;
851
+ $xeInput.$emit('modelValue', value);
852
+ $xeInput.dispatchEvent('input', { value }, evnt);
853
+ if (XEUtils.toValueString(props.value) !== value) {
854
+ $xeInput.dispatchEvent('change', { value }, evnt);
855
+ // 自动更新校验状态
856
+ if ($xeForm && formItemInfo) {
857
+ $xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, value);
858
+ }
859
+ }
860
+ },
861
+ emitInputEvent(value, evnt) {
862
+ const $xeInput = this;
863
+ const reactData = $xeInput.reactData;
864
+ const isDatePickerType = $xeInput.computeIsDatePickerType;
865
+ const inpImmediate = $xeInput.computeInpImmediate;
866
+ reactData.inputValue = value;
867
+ if (!isDatePickerType) {
868
+ if (inpImmediate) {
869
+ $xeInput.emitModel(value, evnt);
870
+ }
871
+ else {
872
+ $xeInput.dispatchEvent('input', { value }, evnt);
873
+ }
874
+ }
875
+ },
876
+ inputEvent(evnt) {
877
+ const $xeInput = this;
878
+ const inputElem = evnt.target;
879
+ const value = inputElem.value;
880
+ $xeInput.emitInputEvent(value, evnt);
881
+ },
882
+ changeEvent(evnt) {
883
+ const $xeInput = this;
884
+ const inpImmediate = $xeInput.computeInpImmediate;
885
+ if (!inpImmediate) {
886
+ $xeInput.triggerEvent(evnt);
887
+ }
888
+ },
889
+ focusEvent(evnt) {
890
+ const $xeInput = this;
891
+ const reactData = $xeInput.reactData;
892
+ reactData.isActivated = true;
893
+ const isDatePickerType = $xeInput.computeIsDatePickerType;
894
+ if (isDatePickerType) {
895
+ $xeInput.datePickerOpenEvent(evnt);
896
+ }
897
+ $xeInput.triggerEvent(evnt);
898
+ },
899
+ clickPrefixEvent(evnt) {
900
+ const $xeInput = this;
901
+ const reactData = $xeInput.reactData;
902
+ const isDisabled = $xeInput.computeIsDisabled;
903
+ if (!isDisabled) {
904
+ const { inputValue } = reactData;
905
+ $xeInput.dispatchEvent('prefix-click', { value: inputValue }, evnt);
906
+ }
907
+ },
908
+ hidePanel() {
909
+ const $xeInput = this;
910
+ const reactData = $xeInput.reactData;
911
+ const internalData = $xeInput.internalData;
912
+ return new Promise(resolve => {
913
+ reactData.visiblePanel = false;
914
+ internalData.hpTimeout = window.setTimeout(() => {
915
+ reactData.isAniVisible = false;
916
+ resolve();
917
+ }, 350);
918
+ });
919
+ },
920
+ clearValueEvent(evnt, value) {
921
+ const $xeInput = this;
922
+ const props = $xeInput;
923
+ const { type } = props;
924
+ const isNumType = $xeInput.computeIsNumType;
925
+ const isDatePickerType = $xeInput.computeIsDatePickerType;
926
+ if (isDatePickerType) {
927
+ $xeInput.hidePanel();
928
+ }
929
+ if (isNumType || ['text', 'search', 'password'].indexOf(type) > -1) {
930
+ $xeInput.focus();
931
+ }
932
+ $xeInput.emitModel('', evnt);
933
+ $xeInput.dispatchEvent('clear', { value }, evnt);
934
+ },
935
+ clickSuffixEvent(evnt) {
936
+ const $xeInput = this;
937
+ const reactData = $xeInput.reactData;
938
+ const isDisabled = $xeInput.computeIsDisabled;
939
+ if (!isDisabled) {
940
+ const { inputValue } = reactData;
941
+ $xeInput.dispatchEvent('suffix-click', { value: inputValue }, evnt);
942
+ }
943
+ },
944
+ dateParseValue(value) {
945
+ const $xeInput = this;
946
+ const props = $xeInput;
947
+ const reactData = $xeInput.reactData;
948
+ const { type } = props;
949
+ const dateLabelFormat = $xeInput.computeDateLabelFormat;
950
+ const dateValueFormat = $xeInput.computeDateValueFormat;
951
+ const firstDayOfWeek = $xeInput.computeFirstDayOfWeek;
952
+ let dValue = null;
953
+ let dLabel = '';
954
+ if (value) {
955
+ dValue = $xeInput.parseDate(value, dateValueFormat);
956
+ }
957
+ if (XEUtils.isValidDate(dValue)) {
958
+ dLabel = XEUtils.toDateString(dValue, dateLabelFormat, { firstDay: firstDayOfWeek });
959
+ // 由于年份和第几周是冲突的行为,所以需要特殊处理,判断是否跨年
960
+ if (dateLabelFormat && type === 'week') {
961
+ const firstWeekDate = XEUtils.getWhatWeek(dValue, 0, firstDayOfWeek, firstDayOfWeek);
962
+ if (firstWeekDate.getFullYear() < dValue.getFullYear()) {
963
+ const yyIndex = dateLabelFormat.indexOf('yyyy');
964
+ if (yyIndex > -1) {
965
+ const yyNum = Number(dLabel.substring(yyIndex, yyIndex + 4));
966
+ if (yyNum && !isNaN(yyNum)) {
967
+ dLabel = dLabel.replace(`${yyNum}`, `${yyNum - 1}`);
968
+ }
969
+ }
970
+ }
971
+ }
972
+ }
973
+ else {
974
+ dValue = null;
975
+ }
976
+ reactData.datePanelValue = dValue;
977
+ reactData.datePanelLabel = dLabel;
978
+ },
979
+ /**
980
+ * 值变化时处理
981
+ */
982
+ changeValue() {
983
+ const $xeInput = this;
984
+ const props = $xeInput;
985
+ const reactData = $xeInput.reactData;
986
+ const isDatePickerType = $xeInput.computeIsDatePickerType;
987
+ const { inputValue } = reactData;
988
+ if (isDatePickerType) {
989
+ $xeInput.dateParseValue(inputValue);
990
+ reactData.inputValue = props.multiple ? $xeInput.computeDateMultipleLabel : reactData.datePanelLabel;
991
+ }
992
+ },
993
+ /**
994
+ * 检查初始值
995
+ */
996
+ initValue() {
997
+ const $xeInput = this;
998
+ const props = $xeInput;
999
+ const reactData = $xeInput.reactData;
1000
+ const { type } = props;
1001
+ const { inputValue } = reactData;
1002
+ const isDatePickerType = $xeInput.computeIsDatePickerType;
1003
+ const digitsValue = $xeInput.computeDigitsValue;
1004
+ if (isDatePickerType) {
1005
+ $xeInput.changeValue();
1006
+ }
1007
+ else if (type === 'float') {
1008
+ if (inputValue) {
1009
+ const validValue = toFloatValueFixed(inputValue, digitsValue);
1010
+ if (inputValue !== validValue) {
1011
+ $xeInput.emitModel(validValue, { type: 'init' });
1012
+ }
1013
+ }
1014
+ }
1015
+ },
1016
+ validMaxNum(num) {
1017
+ const $xeInput = this;
1018
+ const props = $xeInput;
1019
+ return props.max === null || XEUtils.toNumber(num) <= XEUtils.toNumber(props.max);
1020
+ },
1021
+ validMinNum(num) {
1022
+ const $xeInput = this;
1023
+ const props = $xeInput;
1024
+ return props.min === null || XEUtils.toNumber(num) >= XEUtils.toNumber(props.min);
1025
+ },
1026
+ dateRevert() {
1027
+ const $xeInput = this;
1028
+ const props = $xeInput;
1029
+ const reactData = $xeInput.reactData;
1030
+ reactData.inputValue = props.multiple ? $xeInput.computeDateMultipleLabel : reactData.datePanelLabel;
1031
+ },
1032
+ dateCheckMonth(date) {
1033
+ const $xeInput = this;
1034
+ const reactData = $xeInput.reactData;
1035
+ const month = XEUtils.getWhatMonth(date, 0, 'first');
1036
+ if (!XEUtils.isEqual(month, reactData.selectMonth)) {
1037
+ reactData.selectMonth = month;
1038
+ }
1039
+ },
1040
+ dateChange(date) {
1041
+ const $xeInput = this;
1042
+ const props = $xeInput;
1043
+ const reactData = $xeInput.reactData;
1044
+ const { multiple } = props;
1045
+ const { datetimePanelValue } = reactData;
1046
+ const isDateTimeType = $xeInput.computeIsDateTimeType;
1047
+ const dateValueFormat = $xeInput.computeDateValueFormat;
1048
+ const firstDayOfWeek = $xeInput.computeFirstDayOfWeek;
1049
+ if (props.type === 'week') {
1050
+ const sWeek = XEUtils.toNumber(props.selectDay);
1051
+ date = XEUtils.getWhatWeek(date, 0, sWeek, firstDayOfWeek);
1052
+ }
1053
+ else if (isDateTimeType) {
1054
+ date.setHours(datetimePanelValue.getHours());
1055
+ date.setMinutes(datetimePanelValue.getMinutes());
1056
+ date.setSeconds(datetimePanelValue.getSeconds());
1057
+ }
1058
+ const inpVal = XEUtils.toDateString(date, dateValueFormat, { firstDay: firstDayOfWeek });
1059
+ $xeInput.dateCheckMonth(date);
1060
+ if (multiple) {
1061
+ // 如果为多选
1062
+ const dateMultipleValue = $xeInput.computeDateMultipleValue;
1063
+ if (isDateTimeType) {
1064
+ // 如果是datetime特殊类型
1065
+ const dateListValue = [...$xeInput.computeDateListValue];
1066
+ const datetimeRest = [];
1067
+ const eqIndex = XEUtils.findIndexOf(dateListValue, val => XEUtils.isDateSame(date, val, 'yyyyMMdd'));
1068
+ if (eqIndex === -1) {
1069
+ dateListValue.push(date);
1070
+ }
1071
+ else {
1072
+ dateListValue.splice(eqIndex, 1);
1073
+ }
1074
+ dateListValue.forEach(item => {
1075
+ if (item) {
1076
+ item.setHours(datetimePanelValue.getHours());
1077
+ item.setMinutes(datetimePanelValue.getMinutes());
1078
+ item.setSeconds(datetimePanelValue.getSeconds());
1079
+ datetimeRest.push(item);
1080
+ }
1081
+ });
1082
+ $xeInput.emitModel(datetimeRest.map(date => XEUtils.toDateString(date, dateValueFormat)).join(','), { type: 'update' });
1083
+ }
1084
+ else {
1085
+ // 如果是日期类型
1086
+ if (dateMultipleValue.some(val => XEUtils.isEqual(val, inpVal))) {
1087
+ $xeInput.emitModel(dateMultipleValue.filter(val => !XEUtils.isEqual(val, inpVal)).join(','), { type: 'update' });
1088
+ }
1089
+ else {
1090
+ $xeInput.emitModel(dateMultipleValue.concat([inpVal]).join(','), { type: 'update' });
1091
+ }
1092
+ }
1093
+ }
1094
+ else {
1095
+ // 如果为单选
1096
+ if (!XEUtils.isEqual(props.value, inpVal)) {
1097
+ $xeInput.emitModel(inpVal, { type: 'update' });
1098
+ }
1099
+ }
1100
+ },
1101
+ afterCheckValue() {
1102
+ const $xeInput = this;
1103
+ const props = $xeInput;
1104
+ const reactData = $xeInput.reactData;
1105
+ const { type, min, max, exponential } = props;
1106
+ const { inputValue, datetimePanelValue } = reactData;
1107
+ const isNumType = $xeInput.computeIsNumType;
1108
+ const isDatePickerType = $xeInput.computeIsDatePickerType;
1109
+ const dateLabelFormat = $xeInput.computeDateLabelFormat;
1110
+ const inputReadonly = $xeInput.computeInputReadonly;
1111
+ if (!inputReadonly) {
1112
+ if (isNumType) {
1113
+ if (inputValue) {
1114
+ let inpNumVal = type === 'integer' ? XEUtils.toInteger(handleNumber(inputValue)) : XEUtils.toNumber(handleNumber(inputValue));
1115
+ if (!$xeInput.validMinNum(inpNumVal)) {
1116
+ inpNumVal = min;
1117
+ }
1118
+ else if (!$xeInput.validMaxNum(inpNumVal)) {
1119
+ inpNumVal = max;
1120
+ }
1121
+ if (exponential) {
1122
+ const inpStringVal = XEUtils.toValueString(inputValue).toLowerCase();
1123
+ if (inpStringVal === XEUtils.toNumber(inpNumVal).toExponential()) {
1124
+ inpNumVal = inpStringVal;
1125
+ }
1126
+ }
1127
+ $xeInput.emitModel($xeInput.getNumberValue(inpNumVal), { type: 'check' });
1128
+ }
1129
+ }
1130
+ else if (isDatePickerType) {
1131
+ if (inputValue) {
1132
+ let inpDateVal = $xeInput.parseDate(inputValue, dateLabelFormat);
1133
+ if (XEUtils.isValidDate(inpDateVal)) {
1134
+ if (type === 'time') {
1135
+ inpDateVal = XEUtils.toDateString(inpDateVal, dateLabelFormat);
1136
+ if (inputValue !== inpDateVal) {
1137
+ $xeInput.emitModel(inpDateVal, { type: 'check' });
1138
+ }
1139
+ reactData.inputValue = inpDateVal;
1140
+ }
1141
+ else {
1142
+ let isChange = false;
1143
+ const firstDayOfWeek = $xeInput.computeFirstDayOfWeek;
1144
+ if (type === 'datetime') {
1145
+ const dateValue = $xeInput.computeDateValue;
1146
+ if (inputValue !== XEUtils.toDateString(dateValue, dateLabelFormat) || inputValue !== XEUtils.toDateString(inpDateVal, dateLabelFormat)) {
1147
+ isChange = true;
1148
+ datetimePanelValue.setHours(inpDateVal.getHours());
1149
+ datetimePanelValue.setMinutes(inpDateVal.getMinutes());
1150
+ datetimePanelValue.setSeconds(inpDateVal.getSeconds());
1151
+ }
1152
+ }
1153
+ else {
1154
+ isChange = true;
1155
+ }
1156
+ reactData.inputValue = XEUtils.toDateString(inpDateVal, dateLabelFormat, { firstDay: firstDayOfWeek });
1157
+ if (isChange) {
1158
+ $xeInput.dateChange(inpDateVal);
1159
+ }
1160
+ }
1161
+ }
1162
+ else {
1163
+ $xeInput.dateRevert();
1164
+ }
1165
+ }
1166
+ else {
1167
+ $xeInput.emitModel('', { type: 'check' });
1168
+ }
1169
+ }
1170
+ }
1171
+ },
1172
+ blurEvent(evnt) {
1173
+ const $xeInput = this;
1174
+ const reactData = $xeInput.reactData;
1175
+ const { inputValue } = reactData;
1176
+ const inpImmediate = $xeInput.computeInpImmediate;
1177
+ if (!inpImmediate) {
1178
+ $xeInput.emitModel(inputValue, evnt);
1179
+ }
1180
+ $xeInput.afterCheckValue();
1181
+ if (!reactData.visiblePanel) {
1182
+ reactData.isActivated = false;
1183
+ }
1184
+ $xeInput.dispatchEvent('blur', { value: inputValue }, evnt);
1185
+ },
1186
+ // 密码
1187
+ passwordToggleEvent(evnt) {
1188
+ const $xeInput = this;
1189
+ const reactData = $xeInput.reactData;
1190
+ const { showPwd } = reactData;
1191
+ const isDisabled = $xeInput.computeIsDisabled;
1192
+ const isReadonly = $xeInput.computeIsReadonly;
1193
+ if (!isDisabled && !isReadonly) {
1194
+ reactData.showPwd = !showPwd;
1195
+ }
1196
+ $xeInput.dispatchEvent('toggle-visible', { visible: reactData.showPwd }, evnt);
1197
+ },
1198
+ // 搜索
1199
+ searchEvent(evnt) {
1200
+ const $xeInput = this;
1201
+ $xeInput.dispatchEvent('search-click', {}, evnt);
1202
+ },
1203
+ // 数值
1204
+ numberChange(isPlus, evnt) {
1205
+ const $xeInput = this;
1206
+ const props = $xeInput;
1207
+ const reactData = $xeInput.reactData;
1208
+ const { min, max, type } = props;
1209
+ const { inputValue } = reactData;
1210
+ const stepValue = $xeInput.computeStepValue;
1211
+ const numValue = type === 'integer' ? XEUtils.toInteger(handleNumber(inputValue)) : XEUtils.toNumber(handleNumber(inputValue));
1212
+ const newValue = isPlus ? XEUtils.add(numValue, stepValue) : XEUtils.subtract(numValue, stepValue);
1213
+ let restNum;
1214
+ if (!$xeInput.validMinNum(newValue)) {
1215
+ restNum = min;
1216
+ }
1217
+ else if (!$xeInput.validMaxNum(newValue)) {
1218
+ restNum = max;
1219
+ }
1220
+ else {
1221
+ restNum = newValue;
1222
+ }
1223
+ $xeInput.emitInputEvent($xeInput.getNumberValue(restNum), evnt);
1224
+ },
1225
+ numberNextEvent(evnt) {
1226
+ const $xeInput = this;
1227
+ const isDisabled = $xeInput.computeIsDisabled;
1228
+ const isReadonly = $xeInput.computeIsReadonly;
1229
+ const isDisabledSubtractNumber = $xeInput.computeIsDisabledSubtractNumber;
1230
+ $xeInput.numberStopDown();
1231
+ if (!isDisabled && !isReadonly && !isDisabledSubtractNumber) {
1232
+ $xeInput.numberChange(false, evnt);
1233
+ }
1234
+ $xeInput.dispatchEvent('next-number', {}, evnt);
1235
+ },
1236
+ numberDownNextEvent(evnt) {
1237
+ const $xeInput = this;
1238
+ const internalData = $xeInput.internalData;
1239
+ internalData.dnTimeout = window.setTimeout(() => {
1240
+ $xeInput.numberNextEvent(evnt);
1241
+ $xeInput.numberDownNextEvent(evnt);
1242
+ }, 60);
1243
+ },
1244
+ numberPrevEvent(evnt) {
1245
+ const $xeInput = this;
1246
+ const isDisabled = $xeInput.computeIsDisabled;
1247
+ const isReadonly = $xeInput.computeIsReadonly;
1248
+ const isDisabledAddNumber = $xeInput.computeIsDisabledAddNumber;
1249
+ $xeInput.numberStopDown();
1250
+ if (!isDisabled && !isReadonly && !isDisabledAddNumber) {
1251
+ $xeInput.numberChange(true, evnt);
1252
+ }
1253
+ $xeInput.dispatchEvent('prev-number', {}, evnt);
1254
+ },
1255
+ numberKeydownEvent(evnt) {
1256
+ const $xeInput = this;
1257
+ const isUpArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_UP);
1258
+ const isDwArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_DOWN);
1259
+ if (isUpArrow || isDwArrow) {
1260
+ evnt.preventDefault();
1261
+ if (isUpArrow) {
1262
+ $xeInput.numberPrevEvent(evnt);
1263
+ }
1264
+ else {
1265
+ $xeInput.numberNextEvent(evnt);
1266
+ }
1267
+ }
1268
+ },
1269
+ keydownEvent(evnt) {
1270
+ const $xeInput = this;
1271
+ const props = $xeInput;
1272
+ const { exponential, controls } = props;
1273
+ const isNumType = $xeInput.computeIsNumType;
1274
+ if (isNumType) {
1275
+ const isCtrlKey = evnt.ctrlKey;
1276
+ const isShiftKey = evnt.shiftKey;
1277
+ const isAltKey = evnt.altKey;
1278
+ const keyCode = evnt.keyCode;
1279
+ const isEsc = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ESCAPE);
1280
+ const isUpArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_UP);
1281
+ const isDwArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_DOWN);
1282
+ if (!isCtrlKey && !isShiftKey && !isAltKey && (globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.SPACEBAR) || ((!exponential || keyCode !== 69) && (keyCode >= 65 && keyCode <= 90)) || (keyCode >= 186 && keyCode <= 188) || keyCode >= 191)) {
1283
+ evnt.preventDefault();
1284
+ }
1285
+ if (isEsc) {
1286
+ $xeInput.afterCheckValue();
1287
+ }
1288
+ else if (isUpArrow || isDwArrow) {
1289
+ if (controls) {
1290
+ $xeInput.numberKeydownEvent(evnt);
1291
+ }
1292
+ }
1293
+ }
1294
+ $xeInput.triggerEvent(evnt);
1295
+ },
1296
+ keyupEvent(evnt) {
1297
+ const $xeInput = this;
1298
+ $xeInput.triggerEvent(evnt);
1299
+ },
1300
+ // 数值
1301
+ numberStopDown() {
1302
+ const $xeInput = this;
1303
+ const internalData = $xeInput.internalData;
1304
+ const { dnTimeout } = internalData;
1305
+ if (dnTimeout) {
1306
+ clearTimeout(dnTimeout);
1307
+ internalData.dnTimeout = undefined;
1308
+ }
1309
+ },
1310
+ numberDownPrevEvent(evnt) {
1311
+ const $xeInput = this;
1312
+ const internalData = $xeInput.internalData;
1313
+ internalData.dnTimeout = window.setTimeout(() => {
1314
+ $xeInput.numberPrevEvent(evnt);
1315
+ $xeInput.numberDownPrevEvent(evnt);
1316
+ }, 60);
1317
+ },
1318
+ numberMousedownEvent(evnt) {
1319
+ const $xeInput = this;
1320
+ const internalData = $xeInput.internalData;
1321
+ $xeInput.numberStopDown();
1322
+ if (evnt.button === 0) {
1323
+ const isPrevNumber = hasClass(evnt.currentTarget, 'is--prev');
1324
+ if (isPrevNumber) {
1325
+ $xeInput.numberPrevEvent(evnt);
1326
+ }
1327
+ else {
1328
+ $xeInput.numberNextEvent(evnt);
1329
+ }
1330
+ internalData.dnTimeout = window.setTimeout(() => {
1331
+ if (isPrevNumber) {
1332
+ $xeInput.numberDownPrevEvent(evnt);
1333
+ }
1334
+ else {
1335
+ $xeInput.numberDownNextEvent(evnt);
1336
+ }
1337
+ }, 500);
1338
+ }
1339
+ },
1340
+ wheelEvent(evnt) {
1341
+ const $xeInput = this;
1342
+ const props = $xeInput;
1343
+ const reactData = $xeInput.reactData;
1344
+ const isNumType = $xeInput.computeIsNumType;
1345
+ if (isNumType && props.controls) {
1346
+ if (reactData.isActivated) {
1347
+ const delta = evnt.deltaY;
1348
+ if (delta > 0) {
1349
+ $xeInput.numberNextEvent(evnt);
1350
+ }
1351
+ else if (delta < 0) {
1352
+ $xeInput.numberPrevEvent(evnt);
1353
+ }
1354
+ evnt.preventDefault();
1355
+ }
1356
+ }
1357
+ $xeInput.triggerEvent(evnt);
1358
+ },
1359
+ // 日期
1360
+ dateMonthHandle(date, offsetMonth) {
1361
+ const $xeInput = this;
1362
+ const reactData = $xeInput.reactData;
1363
+ reactData.selectMonth = XEUtils.getWhatMonth(date, offsetMonth, 'first');
1364
+ },
1365
+ dateNowHandle() {
1366
+ const $xeInput = this;
1367
+ const reactData = $xeInput.reactData;
1368
+ const currentDate = XEUtils.getWhatDay(Date.now(), 0, 'first');
1369
+ reactData.currentDate = currentDate;
1370
+ $xeInput.dateMonthHandle(currentDate, 0);
1371
+ },
1372
+ dateToggleTypeEvent() {
1373
+ const $xeInput = this;
1374
+ const reactData = $xeInput.reactData;
1375
+ let { datePanelType } = reactData;
1376
+ if (datePanelType === 'month' || datePanelType === 'quarter') {
1377
+ datePanelType = 'year';
1378
+ }
1379
+ else {
1380
+ datePanelType = 'month';
1381
+ }
1382
+ reactData.datePanelType = datePanelType;
1383
+ },
1384
+ datePrevEvent(evnt) {
1385
+ const $xeInput = this;
1386
+ const props = $xeInput;
1387
+ const reactData = $xeInput.reactData;
1388
+ const internalData = $xeInput.internalData;
1389
+ const { type } = props;
1390
+ const { datePanelType, selectMonth } = reactData;
1391
+ const { yearSize } = internalData;
1392
+ const isDisabledPrevDateBtn = $xeInput.computeIsDisabledPrevDateBtn;
1393
+ if (!isDisabledPrevDateBtn) {
1394
+ if (type === 'year') {
1395
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, -yearSize, 'first');
1396
+ }
1397
+ else if (type === 'month' || type === 'quarter') {
1398
+ if (datePanelType === 'year') {
1399
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, -yearSize, 'first');
1400
+ }
1401
+ else {
1402
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, -1, 'first');
1403
+ }
1404
+ }
1405
+ else {
1406
+ if (datePanelType === 'year') {
1407
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, -yearSize, 'first');
1408
+ }
1409
+ else if (datePanelType === 'month') {
1410
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, -1, 'first');
1411
+ }
1412
+ else {
1413
+ reactData.selectMonth = XEUtils.getWhatMonth(selectMonth, -1, 'first');
1414
+ }
1415
+ }
1416
+ $xeInput.dispatchEvent('date-prev', { type }, evnt);
1417
+ }
1418
+ },
1419
+ dateTodayMonthEvent(evnt) {
1420
+ const $xeInput = this;
1421
+ const props = $xeInput;
1422
+ const reactData = $xeInput.reactData;
1423
+ $xeInput.dateNowHandle();
1424
+ if (!props.multiple) {
1425
+ $xeInput.dateChange(reactData.currentDate);
1426
+ $xeInput.hidePanel();
1427
+ }
1428
+ $xeInput.dispatchEvent('date-today', { type: props.type }, evnt);
1429
+ },
1430
+ dateNextEvent(evnt) {
1431
+ const $xeInput = this;
1432
+ const props = $xeInput;
1433
+ const reactData = $xeInput.reactData;
1434
+ const internalData = $xeInput.internalData;
1435
+ const { type } = props;
1436
+ const { datePanelType, selectMonth } = reactData;
1437
+ const { yearSize } = internalData;
1438
+ const isDisabledNextDateBtn = $xeInput.computeIsDisabledNextDateBtn;
1439
+ if (!isDisabledNextDateBtn) {
1440
+ if (type === 'year') {
1441
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, yearSize, 'first');
1442
+ }
1443
+ else if (type === 'month' || type === 'quarter') {
1444
+ if (datePanelType === 'year') {
1445
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, yearSize, 'first');
1446
+ }
1447
+ else {
1448
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, 1, 'first');
1449
+ }
1450
+ }
1451
+ else {
1452
+ if (datePanelType === 'year') {
1453
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, yearSize, 'first');
1454
+ }
1455
+ else if (datePanelType === 'month') {
1456
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, 1, 'first');
1457
+ }
1458
+ else {
1459
+ reactData.selectMonth = XEUtils.getWhatMonth(selectMonth, 1, 'first');
1460
+ }
1461
+ }
1462
+ $xeInput.dispatchEvent('date-next', { type }, evnt);
1463
+ }
1464
+ },
1465
+ isDateDisabled(item) {
1466
+ const $xeInput = this;
1467
+ const props = $xeInput;
1468
+ const reactData = $xeInput.reactData;
1469
+ const { disabledMethod } = props;
1470
+ const { datePanelType } = reactData;
1471
+ return disabledMethod && disabledMethod({ type: datePanelType, viewType: datePanelType, date: item.date, $input: $xeInput });
1472
+ },
1473
+ dateSelectItem(date) {
1474
+ const $xeInput = this;
1475
+ const props = $xeInput;
1476
+ const reactData = $xeInput.reactData;
1477
+ const { type, multiple } = props;
1478
+ const { datePanelType } = reactData;
1479
+ if (type === 'month') {
1480
+ if (datePanelType === 'year') {
1481
+ reactData.datePanelType = 'month';
1482
+ $xeInput.dateCheckMonth(date);
1483
+ }
1484
+ else {
1485
+ $xeInput.dateChange(date);
1486
+ if (!multiple) {
1487
+ $xeInput.hidePanel();
1488
+ }
1489
+ }
1490
+ }
1491
+ else if (type === 'year') {
1492
+ $xeInput.dateChange(date);
1493
+ if (!multiple) {
1494
+ $xeInput.hidePanel();
1495
+ }
1496
+ }
1497
+ else if (type === 'quarter') {
1498
+ if (datePanelType === 'year') {
1499
+ reactData.datePanelType = 'quarter';
1500
+ $xeInput.dateCheckMonth(date);
1501
+ }
1502
+ else {
1503
+ $xeInput.dateChange(date);
1504
+ if (!multiple) {
1505
+ $xeInput.hidePanel();
1506
+ }
1507
+ }
1508
+ }
1509
+ else {
1510
+ if (datePanelType === 'month') {
1511
+ reactData.datePanelType = type === 'week' ? type : 'day';
1512
+ $xeInput.dateCheckMonth(date);
1513
+ }
1514
+ else if (datePanelType === 'year') {
1515
+ reactData.datePanelType = 'month';
1516
+ $xeInput.dateCheckMonth(date);
1517
+ }
1518
+ else {
1519
+ $xeInput.dateChange(date);
1520
+ if (type === 'datetime') {
1521
+ // 日期带时间
1522
+ }
1523
+ else {
1524
+ if (!multiple) {
1525
+ $xeInput.hidePanel();
1526
+ }
1527
+ }
1528
+ }
1529
+ }
1530
+ },
1531
+ dateSelectEvent(item) {
1532
+ const $xeInput = this;
1533
+ if (!$xeInput.isDateDisabled(item)) {
1534
+ $xeInput.dateSelectItem(item.date);
1535
+ }
1536
+ },
1537
+ dateMoveDay(offsetDay) {
1538
+ const $xeInput = this;
1539
+ if (!$xeInput.isDateDisabled({ date: offsetDay })) {
1540
+ const dayList = $xeInput.computeDayList;
1541
+ if (!dayList.some((item) => XEUtils.isDateSame(item.date, offsetDay, 'yyyyMMdd'))) {
1542
+ $xeInput.dateCheckMonth(offsetDay);
1543
+ }
1544
+ $xeInput.dateParseValue(offsetDay);
1545
+ }
1546
+ },
1547
+ dateMoveYear(offsetYear) {
1548
+ const $xeInput = this;
1549
+ if (!$xeInput.isDateDisabled({ date: offsetYear })) {
1550
+ const yearList = $xeInput.computeYearList;
1551
+ if (!yearList.some((item) => XEUtils.isDateSame(item.date, offsetYear, 'yyyy'))) {
1552
+ $xeInput.dateCheckMonth(offsetYear);
1553
+ }
1554
+ $xeInput.dateParseValue(offsetYear);
1555
+ }
1556
+ },
1557
+ dateMoveQuarter(offsetQuarter) {
1558
+ const $xeInput = this;
1559
+ if (!$xeInput.isDateDisabled({ date: offsetQuarter })) {
1560
+ const quarterList = $xeInput.computeQuarterList;
1561
+ if (!quarterList.some((item) => XEUtils.isDateSame(item.date, offsetQuarter, 'yyyyq'))) {
1562
+ $xeInput.dateCheckMonth(offsetQuarter);
1563
+ }
1564
+ $xeInput.dateParseValue(offsetQuarter);
1565
+ }
1566
+ },
1567
+ dateMoveMonth(offsetMonth) {
1568
+ const $xeInput = this;
1569
+ if (!$xeInput.isDateDisabled({ date: offsetMonth })) {
1570
+ const monthList = $xeInput.computeMonthList;
1571
+ if (!monthList.some((item) => XEUtils.isDateSame(item.date, offsetMonth, 'yyyyMM'))) {
1572
+ $xeInput.dateCheckMonth(offsetMonth);
1573
+ }
1574
+ $xeInput.dateParseValue(offsetMonth);
1575
+ }
1576
+ },
1577
+ dateMouseenterEvent(item) {
1578
+ const $xeInput = this;
1579
+ const reactData = $xeInput.reactData;
1580
+ if (!$xeInput.isDateDisabled(item)) {
1581
+ const { datePanelType } = reactData;
1582
+ if (datePanelType === 'month') {
1583
+ $xeInput.dateMoveMonth(item.date);
1584
+ }
1585
+ else if (datePanelType === 'quarter') {
1586
+ $xeInput.dateMoveQuarter(item.date);
1587
+ }
1588
+ else if (datePanelType === 'year') {
1589
+ $xeInput.dateMoveYear(item.date);
1590
+ }
1591
+ else {
1592
+ $xeInput.dateMoveDay(item.date);
1593
+ }
1594
+ }
1595
+ },
1596
+ updateTimePos(liElem) {
1597
+ if (liElem) {
1598
+ const height = liElem.offsetHeight;
1599
+ const ulElem = liElem.parentNode;
1600
+ ulElem.scrollTop = liElem.offsetTop - height * 4;
1601
+ }
1602
+ },
1603
+ dateTimeChangeEvent(evnt) {
1604
+ const $xeInput = this;
1605
+ const reactData = $xeInput.reactData;
1606
+ reactData.datetimePanelValue = new Date(reactData.datetimePanelValue.getTime());
1607
+ $xeInput.updateTimePos(evnt.currentTarget);
1608
+ },
1609
+ dateHourEvent(evnt, item) {
1610
+ const $xeInput = this;
1611
+ const reactData = $xeInput.reactData;
1612
+ reactData.datetimePanelValue.setHours(item.value);
1613
+ $xeInput.dateTimeChangeEvent(evnt);
1614
+ },
1615
+ dateConfirmEvent() {
1616
+ const $xeInput = this;
1617
+ const props = $xeInput;
1618
+ const reactData = $xeInput.reactData;
1619
+ const { multiple } = props;
1620
+ const { datetimePanelValue } = reactData;
1621
+ const dateValue = $xeInput.computeDateValue;
1622
+ const isDateTimeType = $xeInput.computeIsDateTimeType;
1623
+ if (isDateTimeType) {
1624
+ const dateValueFormat = $xeInput.computeDateValueFormat;
1625
+ if (multiple) {
1626
+ // 如果为多选
1627
+ const dateMultipleValue = $xeInput.computeDateMultipleValue;
1628
+ if (isDateTimeType) {
1629
+ // 如果是datetime特殊类型
1630
+ const dateListValue = [...$xeInput.computeDateListValue];
1631
+ const datetimeRest = [];
1632
+ dateListValue.forEach(item => {
1633
+ if (item) {
1634
+ item.setHours(datetimePanelValue.getHours());
1635
+ item.setMinutes(datetimePanelValue.getMinutes());
1636
+ item.setSeconds(datetimePanelValue.getSeconds());
1637
+ datetimeRest.push(item);
1638
+ }
1639
+ });
1640
+ $xeInput.emitModel(datetimeRest.map(date => XEUtils.toDateString(date, dateValueFormat)).join(','), { type: 'update' });
1641
+ }
1642
+ else {
1643
+ // 如果是日期类型
1644
+ $xeInput.emitModel(dateMultipleValue.join(','), { type: 'update' });
1645
+ }
1646
+ }
1647
+ else {
1648
+ $xeInput.dateChange(dateValue || reactData.currentDate);
1649
+ }
1650
+ }
1651
+ $xeInput.hidePanel();
1652
+ },
1653
+ dateMinuteEvent(evnt, item) {
1654
+ const $xeInput = this;
1655
+ const reactData = $xeInput.reactData;
1656
+ reactData.datetimePanelValue.setMinutes(item.value);
1657
+ $xeInput.dateTimeChangeEvent(evnt);
1658
+ },
1659
+ dateSecondEvent(evnt, item) {
1660
+ const $xeInput = this;
1661
+ const reactData = $xeInput.reactData;
1662
+ reactData.datetimePanelValue.setSeconds(item.value);
1663
+ $xeInput.dateTimeChangeEvent(evnt);
1664
+ },
1665
+ dateOffsetEvent(evnt) {
1666
+ const $xeInput = this;
1667
+ const reactData = $xeInput.reactData;
1668
+ const { isActivated, datePanelValue, datePanelType } = reactData;
1669
+ if (isActivated) {
1670
+ evnt.preventDefault();
1671
+ const isLeftArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_LEFT);
1672
+ const isUpArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_UP);
1673
+ const isRightArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_RIGHT);
1674
+ const isDwArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_DOWN);
1675
+ if (datePanelType === 'year') {
1676
+ let offsetYear = XEUtils.getWhatYear(datePanelValue || Date.now(), 0, 'first');
1677
+ if (isLeftArrow) {
1678
+ offsetYear = XEUtils.getWhatYear(offsetYear, -1);
1679
+ }
1680
+ else if (isUpArrow) {
1681
+ offsetYear = XEUtils.getWhatYear(offsetYear, -4);
1682
+ }
1683
+ else if (isRightArrow) {
1684
+ offsetYear = XEUtils.getWhatYear(offsetYear, 1);
1685
+ }
1686
+ else if (isDwArrow) {
1687
+ offsetYear = XEUtils.getWhatYear(offsetYear, 4);
1688
+ }
1689
+ $xeInput.dateMoveYear(offsetYear);
1690
+ }
1691
+ else if (datePanelType === 'quarter') {
1692
+ let offsetQuarter = XEUtils.getWhatQuarter(datePanelValue || Date.now(), 0, 'first');
1693
+ if (isLeftArrow) {
1694
+ offsetQuarter = XEUtils.getWhatQuarter(offsetQuarter, -1);
1695
+ }
1696
+ else if (isUpArrow) {
1697
+ offsetQuarter = XEUtils.getWhatQuarter(offsetQuarter, -2);
1698
+ }
1699
+ else if (isRightArrow) {
1700
+ offsetQuarter = XEUtils.getWhatQuarter(offsetQuarter, 1);
1701
+ }
1702
+ else if (isDwArrow) {
1703
+ offsetQuarter = XEUtils.getWhatQuarter(offsetQuarter, 2);
1704
+ }
1705
+ $xeInput.dateMoveQuarter(offsetQuarter);
1706
+ }
1707
+ else if (datePanelType === 'month') {
1708
+ let offsetMonth = XEUtils.getWhatMonth(datePanelValue || Date.now(), 0, 'first');
1709
+ if (isLeftArrow) {
1710
+ offsetMonth = XEUtils.getWhatMonth(offsetMonth, -1);
1711
+ }
1712
+ else if (isUpArrow) {
1713
+ offsetMonth = XEUtils.getWhatMonth(offsetMonth, -4);
1714
+ }
1715
+ else if (isRightArrow) {
1716
+ offsetMonth = XEUtils.getWhatMonth(offsetMonth, 1);
1717
+ }
1718
+ else if (isDwArrow) {
1719
+ offsetMonth = XEUtils.getWhatMonth(offsetMonth, 4);
1720
+ }
1721
+ $xeInput.dateMoveMonth(offsetMonth);
1722
+ }
1723
+ else {
1724
+ let offsetDay = datePanelValue || XEUtils.getWhatDay(Date.now(), 0, 'first');
1725
+ const firstDayOfWeek = $xeInput.computeFirstDayOfWeek;
1726
+ if (isLeftArrow) {
1727
+ offsetDay = XEUtils.getWhatDay(offsetDay, -1);
1728
+ }
1729
+ else if (isUpArrow) {
1730
+ offsetDay = XEUtils.getWhatWeek(offsetDay, -1, firstDayOfWeek);
1731
+ }
1732
+ else if (isRightArrow) {
1733
+ offsetDay = XEUtils.getWhatDay(offsetDay, 1);
1734
+ }
1735
+ else if (isDwArrow) {
1736
+ offsetDay = XEUtils.getWhatWeek(offsetDay, 1, firstDayOfWeek);
1737
+ }
1738
+ $xeInput.dateMoveDay(offsetDay);
1739
+ }
1740
+ }
1741
+ },
1742
+ datePgOffsetEvent(evnt) {
1743
+ const $xeInput = this;
1744
+ const reactData = $xeInput.reactData;
1745
+ const { isActivated } = reactData;
1746
+ if (isActivated) {
1747
+ const isPgUp = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.PAGE_UP);
1748
+ evnt.preventDefault();
1749
+ if (isPgUp) {
1750
+ $xeInput.datePrevEvent(evnt);
1751
+ }
1752
+ else {
1753
+ $xeInput.dateNextEvent(evnt);
1754
+ }
1755
+ }
1756
+ },
1757
+ dateOpenPanel() {
1758
+ const $xeInput = this;
1759
+ const props = $xeInput;
1760
+ const reactData = $xeInput.reactData;
1761
+ const { type } = props;
1762
+ const isDateTimeType = $xeInput.computeIsDateTimeType;
1763
+ const dateValue = $xeInput.computeDateValue;
1764
+ if (['year', 'quarter', 'month', 'week'].indexOf(type) > -1) {
1765
+ reactData.datePanelType = type;
1766
+ }
1767
+ else {
1768
+ reactData.datePanelType = 'day';
1769
+ }
1770
+ reactData.currentDate = XEUtils.getWhatDay(Date.now(), 0, 'first');
1771
+ if (dateValue) {
1772
+ $xeInput.dateMonthHandle(dateValue, 0);
1773
+ $xeInput.dateParseValue(dateValue);
1774
+ }
1775
+ else {
1776
+ $xeInput.dateNowHandle();
1777
+ }
1778
+ if (isDateTimeType) {
1779
+ reactData.datetimePanelValue = reactData.datePanelValue || XEUtils.getWhatDay(Date.now(), 0, 'first');
1780
+ $xeInput.$nextTick(() => {
1781
+ const timeBodyElem = $xeInput.$refs.refInputTimeBody;
1782
+ XEUtils.arrayEach(timeBodyElem.querySelectorAll('li.is--selected'), (elem) => {
1783
+ $xeInput.updateTimePos(elem);
1784
+ });
1785
+ });
1786
+ }
1787
+ },
1788
+ // 弹出面板
1789
+ updateZindex() {
1790
+ const $xeInput = this;
1791
+ const reactData = $xeInput.reactData;
1792
+ if (reactData.panelIndex < getLastZIndex()) {
1793
+ reactData.panelIndex = nextZIndex();
1794
+ }
1795
+ },
1796
+ updatePlacement() {
1797
+ const $xeInput = this;
1798
+ const props = $xeInput;
1799
+ const reactData = $xeInput.reactData;
1800
+ return $xeInput.$nextTick().then(() => {
1801
+ const { placement } = props;
1802
+ const { panelIndex } = reactData;
1803
+ const targetElem = $xeInput.$refs.refInputTarget;
1804
+ const panelElem = $xeInput.$refs.refInputPanel;
1805
+ const btnTransfer = $xeInput.computeBtnTransfer;
1806
+ if (targetElem && panelElem) {
1807
+ const targetHeight = targetElem.offsetHeight;
1808
+ const targetWidth = targetElem.offsetWidth;
1809
+ const panelHeight = panelElem.offsetHeight;
1810
+ const panelWidth = panelElem.offsetWidth;
1811
+ const marginSize = 5;
1812
+ const panelStyle = {
1813
+ zIndex: panelIndex
1814
+ };
1815
+ const { boundingTop, boundingLeft, visibleHeight, visibleWidth } = getAbsolutePos(targetElem);
1816
+ let panelPlacement = 'bottom';
1817
+ if (btnTransfer) {
1818
+ let left = boundingLeft;
1819
+ let top = boundingTop + targetHeight;
1820
+ if (placement === 'top') {
1821
+ panelPlacement = 'top';
1822
+ top = boundingTop - panelHeight;
1823
+ }
1824
+ else if (!placement) {
1825
+ // 如果下面不够放,则向上
1826
+ if (top + panelHeight + marginSize > visibleHeight) {
1827
+ panelPlacement = 'top';
1828
+ top = boundingTop - panelHeight;
1829
+ }
1830
+ // 如果上面不够放,则向下(优先)
1831
+ if (top < marginSize) {
1832
+ panelPlacement = 'bottom';
1833
+ top = boundingTop + targetHeight;
1834
+ }
1835
+ }
1836
+ // 如果溢出右边
1837
+ if (left + panelWidth + marginSize > visibleWidth) {
1838
+ left -= left + panelWidth + marginSize - visibleWidth;
1839
+ }
1840
+ // 如果溢出左边
1841
+ if (left < marginSize) {
1842
+ left = marginSize;
1843
+ }
1844
+ Object.assign(panelStyle, {
1845
+ left: `${left}px`,
1846
+ top: `${top}px`,
1847
+ minWidth: `${targetWidth}px`
1848
+ });
1849
+ }
1850
+ else {
1851
+ if (placement === 'top') {
1852
+ panelPlacement = 'top';
1853
+ panelStyle.bottom = `${targetHeight}px`;
1854
+ }
1855
+ else if (!placement) {
1856
+ // 如果下面不够放,则向上
1857
+ panelStyle.top = `${targetHeight}px`;
1858
+ if (boundingTop + targetHeight + panelHeight > visibleHeight) {
1859
+ // 如果上面不够放,则向下(优先)
1860
+ if (boundingTop - targetHeight - panelHeight > marginSize) {
1861
+ panelPlacement = 'top';
1862
+ panelStyle.top = '';
1863
+ panelStyle.bottom = `${targetHeight}px`;
1864
+ }
1865
+ }
1866
+ }
1867
+ }
1868
+ reactData.panelStyle = panelStyle;
1869
+ reactData.panelPlacement = panelPlacement;
1870
+ return $xeInput.$nextTick();
1871
+ }
1872
+ });
1873
+ },
1874
+ showPanel() {
1875
+ const $xeInput = this;
1876
+ const reactData = $xeInput.reactData;
1877
+ const internalData = $xeInput.internalData;
1878
+ const { visiblePanel } = reactData;
1879
+ const { hpTimeout } = internalData;
1880
+ const isDisabled = $xeInput.computeIsDisabled;
1881
+ const isDatePickerType = $xeInput.computeIsDatePickerType;
1882
+ const btnTransfer = $xeInput.computeBtnTransfer;
1883
+ if (!isDisabled && !visiblePanel) {
1884
+ const panelElem = $xeInput.$refs.refInputPanel;
1885
+ if (!reactData.initialized) {
1886
+ reactData.initialized = true;
1887
+ if (btnTransfer) {
1888
+ if (panelElem) {
1889
+ document.body.appendChild(panelElem);
1890
+ }
1891
+ }
1892
+ }
1893
+ if (hpTimeout) {
1894
+ clearTimeout(hpTimeout);
1895
+ internalData.hpTimeout = undefined;
1896
+ }
1897
+ reactData.isActivated = true;
1898
+ reactData.isAniVisible = true;
1899
+ if (isDatePickerType) {
1900
+ $xeInput.dateOpenPanel();
1901
+ }
1902
+ setTimeout(() => {
1903
+ reactData.visiblePanel = true;
1904
+ }, 10);
1905
+ $xeInput.updateZindex();
1906
+ return $xeInput.updatePlacement();
1907
+ }
1908
+ return $xeInput.$nextTick();
1909
+ },
1910
+ datePickerOpenEvent(evnt) {
1911
+ const $xeInput = this;
1912
+ const isReadonly = $xeInput.computeIsReadonly;
1913
+ if (!isReadonly) {
1914
+ evnt.preventDefault();
1915
+ $xeInput.showPanel();
1916
+ }
1917
+ },
1918
+ clickEvent(evnt) {
1919
+ const $xeInput = this;
1920
+ $xeInput.triggerEvent(evnt);
1921
+ },
1922
+ handleGlobalMousedownEvent(evnt) {
1923
+ const $xeInput = this;
1924
+ const reactData = $xeInput.reactData;
1925
+ const { visiblePanel, isActivated } = reactData;
1926
+ const isDatePickerType = $xeInput.computeIsDatePickerType;
1927
+ const el = $xeInput.$refs.refElem;
1928
+ const panelWrapperElem = $xeInput.$refs.refPanelWrapper;
1929
+ const isDisabled = $xeInput.computeIsDisabled;
1930
+ if (!isDisabled && isActivated) {
1931
+ reactData.isActivated = getEventTargetNode(evnt, el).flag || getEventTargetNode(evnt, panelWrapperElem).flag;
1932
+ if (!reactData.isActivated) {
1933
+ // 如果是日期类型
1934
+ if (isDatePickerType) {
1935
+ if (visiblePanel) {
1936
+ $xeInput.hidePanel();
1937
+ $xeInput.afterCheckValue();
1938
+ }
1939
+ }
1940
+ else {
1941
+ $xeInput.afterCheckValue();
1942
+ }
1943
+ }
1944
+ }
1945
+ },
1946
+ handleGlobalKeydownEvent(evnt) {
1947
+ const $xeInput = this;
1948
+ const props = $xeInput;
1949
+ const reactData = $xeInput.reactData;
1950
+ const { clearable } = props;
1951
+ const { visiblePanel } = reactData;
1952
+ const isDisabled = $xeInput.computeIsDisabled;
1953
+ const isDatePickerType = $xeInput.computeIsDatePickerType;
1954
+ if (!isDisabled) {
1955
+ const isTab = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.TAB);
1956
+ const isDel = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.DELETE);
1957
+ const isEsc = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ESCAPE);
1958
+ const isEnter = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ENTER);
1959
+ const isLeftArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_LEFT);
1960
+ const isUpArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_UP);
1961
+ const isRightArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_RIGHT);
1962
+ const isDwArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_DOWN);
1963
+ const isPgUp = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.PAGE_UP);
1964
+ const isPgDn = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.PAGE_DOWN);
1965
+ const operArrow = isLeftArrow || isUpArrow || isRightArrow || isDwArrow;
1966
+ let isActivated = reactData.isActivated;
1967
+ if (isTab) {
1968
+ if (isActivated) {
1969
+ $xeInput.afterCheckValue();
1970
+ }
1971
+ isActivated = false;
1972
+ reactData.isActivated = isActivated;
1973
+ }
1974
+ else if (operArrow) {
1975
+ if (isDatePickerType) {
1976
+ if (isActivated) {
1977
+ if (visiblePanel) {
1978
+ $xeInput.dateOffsetEvent(evnt);
1979
+ }
1980
+ else if (isUpArrow || isDwArrow) {
1981
+ $xeInput.datePickerOpenEvent(evnt);
1982
+ }
1983
+ }
1984
+ }
1985
+ }
1986
+ else if (isEnter) {
1987
+ if (isDatePickerType) {
1988
+ if (visiblePanel) {
1989
+ if (reactData.datePanelValue) {
1990
+ $xeInput.dateSelectItem(reactData.datePanelValue);
1991
+ }
1992
+ else {
1993
+ $xeInput.hidePanel();
1994
+ }
1995
+ }
1996
+ else if (isActivated) {
1997
+ $xeInput.datePickerOpenEvent(evnt);
1998
+ }
1999
+ }
2000
+ }
2001
+ else if (isPgUp || isPgDn) {
2002
+ if (isDatePickerType) {
2003
+ if (isActivated) {
2004
+ $xeInput.datePgOffsetEvent(evnt);
2005
+ }
2006
+ }
2007
+ }
2008
+ if (isTab || isEsc) {
2009
+ if (visiblePanel) {
2010
+ $xeInput.hidePanel();
2011
+ }
2012
+ }
2013
+ else if (isDel && clearable) {
2014
+ if (isActivated) {
2015
+ $xeInput.clearValueEvent(evnt, null);
2016
+ }
2017
+ }
2018
+ }
2019
+ },
2020
+ handleGlobalMousewheelEvent(evnt) {
2021
+ const $xeInput = this;
2022
+ const reactData = $xeInput.reactData;
2023
+ const { visiblePanel } = reactData;
2024
+ const isDisabled = $xeInput.computeIsDisabled;
2025
+ if (!isDisabled) {
2026
+ if (visiblePanel) {
2027
+ const panelWrapperElem = $xeInput.$refs.refPanelWrapper;
2028
+ if (getEventTargetNode(evnt, panelWrapperElem).flag) {
2029
+ $xeInput.updatePlacement();
2030
+ }
2031
+ else {
2032
+ $xeInput.hidePanel();
2033
+ $xeInput.afterCheckValue();
2034
+ }
2035
+ }
2036
+ }
2037
+ },
2038
+ handleGlobalBlurEvent() {
2039
+ const $xeInput = this;
2040
+ const reactData = $xeInput.reactData;
2041
+ const { isActivated, visiblePanel } = reactData;
2042
+ if (visiblePanel) {
2043
+ $xeInput.hidePanel();
2044
+ $xeInput.afterCheckValue();
2045
+ }
2046
+ else if (isActivated) {
2047
+ $xeInput.afterCheckValue();
2048
+ }
2049
+ },
2050
+ //
2051
+ // Render
2052
+ //
2053
+ renderDateLabel(h, item, label) {
2054
+ const $xeInput = this;
2055
+ const props = $xeInput;
2056
+ const reactData = $xeInput.reactData;
2057
+ const { festivalMethod } = props;
2058
+ if (festivalMethod) {
2059
+ const { datePanelType } = reactData;
2060
+ const festivalRest = festivalMethod({ type: datePanelType, viewType: datePanelType, date: item.date, $input: $xeInput });
2061
+ const festivalItem = festivalRest ? (XEUtils.isString(festivalRest) ? { label: festivalRest } : festivalRest) : {};
2062
+ const extraItem = festivalItem.extra ? (XEUtils.isString(festivalItem.extra) ? { label: festivalItem.extra } : festivalItem.extra) : null;
2063
+ const labels = [
2064
+ h('span', {
2065
+ class: ['vxe-input--date-label', {
2066
+ 'is-notice': festivalItem.notice
2067
+ }]
2068
+ }, extraItem && extraItem.label
2069
+ ? [
2070
+ h('span', `${label || ''}`),
2071
+ h('span', {
2072
+ class: ['vxe-input--date-label--extra', extraItem.important ? 'is-important' : '', extraItem.className],
2073
+ style: extraItem.style
2074
+ }, XEUtils.toValueString(extraItem.label))
2075
+ ]
2076
+ : [`${label || ''}`])
2077
+ ];
2078
+ const festivalLabel = festivalItem.label;
2079
+ if (festivalLabel) {
2080
+ // 默认最多支持3个节日重叠
2081
+ const festivalLabels = XEUtils.toValueString(festivalLabel).split(',');
2082
+ labels.push(h('span', {
2083
+ class: ['vxe-input--date-festival', festivalItem.important ? 'is-important' : '', festivalItem.className],
2084
+ style: festivalItem.style
2085
+ }, [
2086
+ festivalLabels.length > 1
2087
+ ? h('span', {
2088
+ class: ['vxe-input--date-festival--overlap', `overlap--${festivalLabels.length}`]
2089
+ }, festivalLabels.map(label => h('span', label.substring(0, 3))))
2090
+ : h('span', {
2091
+ class: 'vxe-input--date-festival--label'
2092
+ }, festivalLabels[0].substring(0, 3))
2093
+ ]));
2094
+ }
2095
+ return labels;
2096
+ }
2097
+ return [`${label || ''}`];
2098
+ },
2099
+ renderDateDayTable(h) {
2100
+ const $xeInput = this;
2101
+ const props = $xeInput;
2102
+ const reactData = $xeInput.reactData;
2103
+ const { multiple } = props;
2104
+ const { datePanelType, datePanelValue } = reactData;
2105
+ const dateValue = $xeInput.computeDateValue;
2106
+ const dateHeaders = $xeInput.computeDateHeaders;
2107
+ const dayDatas = $xeInput.computeDayDatas;
2108
+ const dateListValue = $xeInput.computeDateListValue;
2109
+ const matchFormat = 'yyyyMMdd';
2110
+ return [
2111
+ h('table', {
2112
+ class: `vxe-input--date-${datePanelType}-view`,
2113
+ attrs: {
2114
+ cellspacing: 0,
2115
+ cellpadding: 0,
2116
+ border: 0
2117
+ }
2118
+ }, [
2119
+ h('thead', [
2120
+ h('tr', dateHeaders.map((item) => {
2121
+ return h('th', item.label);
2122
+ }))
2123
+ ]),
2124
+ h('tbody', dayDatas.map((rows) => {
2125
+ return h('tr', rows.map((item) => {
2126
+ return h('td', {
2127
+ class: {
2128
+ 'is--prev': item.isPrev,
2129
+ 'is--current': item.isCurrent,
2130
+ 'is--now': item.isNow,
2131
+ 'is--next': item.isNext,
2132
+ 'is--disabled': $xeInput.isDateDisabled(item),
2133
+ 'is--selected': multiple ? dateListValue.some(val => XEUtils.isDateSame(val, item.date, matchFormat)) : XEUtils.isDateSame(dateValue, item.date, matchFormat),
2134
+ 'is--hover': XEUtils.isDateSame(datePanelValue, item.date, matchFormat)
2135
+ },
2136
+ on: {
2137
+ click: () => $xeInput.dateSelectEvent(item),
2138
+ mouseenter: () => $xeInput.dateMouseenterEvent(item)
2139
+ }
2140
+ }, $xeInput.renderDateLabel(h, item, item.label));
2141
+ }));
2142
+ }))
2143
+ ])
2144
+ ];
2145
+ },
2146
+ renderDateWeekTable(h) {
2147
+ const $xeInput = this;
2148
+ const props = $xeInput;
2149
+ const reactData = $xeInput.reactData;
2150
+ const { multiple } = props;
2151
+ const { datePanelType, datePanelValue } = reactData;
2152
+ const dateValue = $xeInput.computeDateValue;
2153
+ const weekHeaders = $xeInput.computeWeekHeaders;
2154
+ const weekDates = $xeInput.computeWeekDates;
2155
+ const dateListValue = $xeInput.computeDateListValue;
2156
+ const matchFormat = 'yyyyMMdd';
2157
+ return [
2158
+ h('table', {
2159
+ class: `vxe-input--date-${datePanelType}-view`,
2160
+ attrs: {
2161
+ cellspacing: 0,
2162
+ cellpadding: 0,
2163
+ border: 0
2164
+ }
2165
+ }, [
2166
+ h('thead', [
2167
+ h('tr', weekHeaders.map((item) => {
2168
+ return h('th', item.label);
2169
+ }))
2170
+ ]),
2171
+ h('tbody', weekDates.map((rows) => {
2172
+ const isSelected = multiple ? rows.some((item) => dateListValue.some(val => XEUtils.isDateSame(val, item.date, matchFormat))) : rows.some((item) => XEUtils.isDateSame(dateValue, item.date, matchFormat));
2173
+ const isHover = rows.some((item) => XEUtils.isDateSame(datePanelValue, item.date, matchFormat));
2174
+ return h('tr', rows.map((item) => {
2175
+ return h('td', {
2176
+ class: {
2177
+ 'is--prev': item.isPrev,
2178
+ 'is--current': item.isCurrent,
2179
+ 'is--now': item.isNow,
2180
+ 'is--next': item.isNext,
2181
+ 'is--disabled': $xeInput.isDateDisabled(item),
2182
+ 'is--selected': isSelected,
2183
+ 'is--hover': isHover
2184
+ },
2185
+ on: {
2186
+ click: () => $xeInput.dateSelectEvent(item),
2187
+ mouseenter: () => $xeInput.dateMouseenterEvent(item)
2188
+ }
2189
+ }, $xeInput.renderDateLabel(h, item, item.label));
2190
+ }));
2191
+ }))
2192
+ ])
2193
+ ];
2194
+ },
2195
+ renderDateMonthTable(h) {
2196
+ const $xeInput = this;
2197
+ const props = $xeInput;
2198
+ const reactData = $xeInput.reactData;
2199
+ const { multiple } = props;
2200
+ const { datePanelType, datePanelValue } = reactData;
2201
+ const dateValue = $xeInput.computeDateValue;
2202
+ const monthDatas = $xeInput.computeMonthDatas;
2203
+ const dateListValue = $xeInput.computeDateListValue;
2204
+ const matchFormat = 'yyyyMM';
2205
+ return [
2206
+ h('table', {
2207
+ class: `vxe-input--date-${datePanelType}-view`,
2208
+ attrs: {
2209
+ cellspacing: 0,
2210
+ cellpadding: 0,
2211
+ border: 0
2212
+ }
2213
+ }, [
2214
+ h('tbody', monthDatas.map((rows) => {
2215
+ return h('tr', rows.map((item) => {
2216
+ return h('td', {
2217
+ class: {
2218
+ 'is--prev': item.isPrev,
2219
+ 'is--current': item.isCurrent,
2220
+ 'is--now': item.isNow,
2221
+ 'is--next': item.isNext,
2222
+ 'is--disabled': $xeInput.isDateDisabled(item),
2223
+ 'is--selected': multiple ? dateListValue.some(val => XEUtils.isDateSame(val, item.date, matchFormat)) : XEUtils.isDateSame(dateValue, item.date, matchFormat),
2224
+ 'is--hover': XEUtils.isDateSame(datePanelValue, item.date, matchFormat)
2225
+ },
2226
+ on: {
2227
+ click: () => $xeInput.dateSelectEvent(item),
2228
+ mouseenter: () => $xeInput.dateMouseenterEvent(item)
2229
+ }
2230
+ }, $xeInput.renderDateLabel(h, item, getI18n(`vxe.input.date.months.m${item.month}`)));
2231
+ }));
2232
+ }))
2233
+ ])
2234
+ ];
2235
+ },
2236
+ renderDateQuarterTable(h) {
2237
+ const $xeInput = this;
2238
+ const props = $xeInput;
2239
+ const reactData = $xeInput.reactData;
2240
+ const { multiple } = props;
2241
+ const { datePanelType, datePanelValue } = reactData;
2242
+ const dateValue = $xeInput.computeDateValue;
2243
+ const quarterDatas = $xeInput.computeQuarterDatas;
2244
+ const dateListValue = $xeInput.computeDateListValue;
2245
+ const matchFormat = 'yyyyq';
2246
+ return [
2247
+ h('table', {
2248
+ class: `vxe-input--date-${datePanelType}-view`,
2249
+ attrs: {
2250
+ cellspacing: 0,
2251
+ cellpadding: 0,
2252
+ border: 0
2253
+ }
2254
+ }, [
2255
+ h('tbody', quarterDatas.map((rows) => {
2256
+ return h('tr', rows.map((item) => {
2257
+ return h('td', {
2258
+ class: {
2259
+ 'is--prev': item.isPrev,
2260
+ 'is--current': item.isCurrent,
2261
+ 'is--now': item.isNow,
2262
+ 'is--next': item.isNext,
2263
+ 'is--disabled': $xeInput.isDateDisabled(item),
2264
+ 'is--selected': multiple ? dateListValue.some(val => XEUtils.isDateSame(val, item.date, matchFormat)) : XEUtils.isDateSame(dateValue, item.date, matchFormat),
2265
+ 'is--hover': XEUtils.isDateSame(datePanelValue, item.date, matchFormat)
2266
+ },
2267
+ on: {
2268
+ click: () => $xeInput.dateSelectEvent(item),
2269
+ mouseenter: () => $xeInput.dateMouseenterEvent(item)
2270
+ }
2271
+ }, $xeInput.renderDateLabel(h, item, getI18n(`vxe.input.date.quarters.q${item.quarter}`)));
2272
+ }));
2273
+ }))
2274
+ ])
2275
+ ];
2276
+ },
2277
+ renderDateYearTable(h) {
2278
+ const $xeInput = this;
2279
+ const props = $xeInput;
2280
+ const reactData = $xeInput.reactData;
2281
+ const { multiple } = props;
2282
+ const { datePanelType, datePanelValue } = reactData;
2283
+ const dateValue = $xeInput.computeDateValue;
2284
+ const yearDatas = $xeInput.computeYearDatas;
2285
+ const dateListValue = $xeInput.computeDateListValue;
2286
+ const matchFormat = 'yyyy';
2287
+ return [
2288
+ h('table', {
2289
+ class: `vxe-input--date-${datePanelType}-view`,
2290
+ attrs: {
2291
+ cellspacing: 0,
2292
+ cellpadding: 0,
2293
+ border: 0
2294
+ }
2295
+ }, [
2296
+ h('tbody', yearDatas.map((rows) => {
2297
+ return h('tr', rows.map((item) => {
2298
+ return h('td', {
2299
+ class: {
2300
+ 'is--prev': item.isPrev,
2301
+ 'is--current': item.isCurrent,
2302
+ 'is--now': item.isNow,
2303
+ 'is--next': item.isNext,
2304
+ 'is--disabled': $xeInput.isDateDisabled(item),
2305
+ 'is--selected': multiple ? dateListValue.some(val => XEUtils.isDateSame(val, item.date, matchFormat)) : XEUtils.isDateSame(dateValue, item.date, matchFormat),
2306
+ 'is--hover': XEUtils.isDateSame(datePanelValue, item.date, matchFormat)
2307
+ },
2308
+ on: {
2309
+ click: () => $xeInput.dateSelectEvent(item),
2310
+ mouseenter: () => $xeInput.dateMouseenterEvent(item)
2311
+ }
2312
+ }, $xeInput.renderDateLabel(h, item, item.year));
2313
+ }));
2314
+ }))
2315
+ ])
2316
+ ];
2317
+ },
2318
+ renderDateTable(h) {
2319
+ const $xeInput = this;
2320
+ const reactData = $xeInput.reactData;
2321
+ const { datePanelType } = reactData;
2322
+ switch (datePanelType) {
2323
+ case 'week':
2324
+ return $xeInput.renderDateWeekTable(h);
2325
+ case 'month':
2326
+ return $xeInput.renderDateMonthTable(h);
2327
+ case 'quarter':
2328
+ return $xeInput.renderDateQuarterTable(h);
2329
+ case 'year':
2330
+ return $xeInput.renderDateYearTable(h);
2331
+ }
2332
+ return $xeInput.renderDateDayTable(h);
2333
+ },
2334
+ renderDatePanel(h) {
2335
+ const $xeInput = this;
2336
+ const props = $xeInput;
2337
+ const reactData = $xeInput.reactData;
2338
+ const { multiple } = props;
2339
+ const { datePanelType } = reactData;
2340
+ const isDisabledPrevDateBtn = $xeInput.computeIsDisabledPrevDateBtn;
2341
+ const isDisabledNextDateBtn = $xeInput.computeIsDisabledNextDateBtn;
2342
+ const selectDatePanelLabel = $xeInput.computeSelectDatePanelLabel;
2343
+ return [
2344
+ h('div', {
2345
+ class: 'vxe-input--date-picker-header'
2346
+ }, [
2347
+ h('div', {
2348
+ class: 'vxe-input--date-picker-type-wrapper'
2349
+ }, [
2350
+ datePanelType === 'year'
2351
+ ? h('span', {
2352
+ class: 'vxe-input--date-picker-label'
2353
+ }, selectDatePanelLabel)
2354
+ : h('span', {
2355
+ class: 'vxe-input--date-picker-btn',
2356
+ on: {
2357
+ click: $xeInput.dateToggleTypeEvent
2358
+ }
2359
+ }, selectDatePanelLabel)
2360
+ ]),
2361
+ h('div', {
2362
+ class: 'vxe-input--date-picker-btn-wrapper'
2363
+ }, [
2364
+ h('span', {
2365
+ class: ['vxe-input--date-picker-btn vxe-input--date-picker-prev-btn', {
2366
+ 'is--disabled': isDisabledPrevDateBtn
2367
+ }],
2368
+ on: {
2369
+ click: $xeInput.datePrevEvent
2370
+ }
2371
+ }, [
2372
+ h('i', {
2373
+ class: 'vxe-icon-caret-left'
2374
+ })
2375
+ ]),
2376
+ h('span', {
2377
+ class: 'vxe-input--date-picker-btn vxe-input--date-picker-current-btn',
2378
+ on: {
2379
+ click: $xeInput.dateTodayMonthEvent
2380
+ }
2381
+ }, [
2382
+ h('i', {
2383
+ class: 'vxe-icon-dot'
2384
+ })
2385
+ ]),
2386
+ h('span', {
2387
+ class: ['vxe-input--date-picker-btn vxe-input--date-picker-next-btn', {
2388
+ 'is--disabled': isDisabledNextDateBtn
2389
+ }],
2390
+ on: {
2391
+ click: $xeInput.dateNextEvent
2392
+ }
2393
+ }, [
2394
+ h('i', {
2395
+ class: 'vxe-icon-caret-right'
2396
+ })
2397
+ ]),
2398
+ multiple && $xeInput.computeSupportMultiples
2399
+ ? h('span', {
2400
+ class: 'vxe-input--date-picker-btn vxe-input--date-picker-confirm-btn'
2401
+ }, [
2402
+ h('button', {
2403
+ class: 'vxe-input--date-picker-confirm',
2404
+ attrs: {
2405
+ type: 'button'
2406
+ },
2407
+ on: {
2408
+ click: $xeInput.dateConfirmEvent
2409
+ }
2410
+ }, getI18n('vxe.button.confirm'))
2411
+ ])
2412
+ : null
2413
+ ])
2414
+ ]),
2415
+ h('div', {
2416
+ class: 'vxe-input--date-picker-body'
2417
+ }, $xeInput.renderDateTable(h))
2418
+ ];
2419
+ },
2420
+ renderTimePanel(h) {
2421
+ const $xeInput = this;
2422
+ const reactData = $xeInput.reactData;
2423
+ const { datetimePanelValue } = reactData;
2424
+ const dateTimeLabel = $xeInput.computeDateTimeLabel;
2425
+ const hourList = $xeInput.computeHourList;
2426
+ const hasTimeMinute = $xeInput.computeHasTimeMinute;
2427
+ const minuteList = $xeInput.computeMinuteList;
2428
+ const hasTimeSecond = $xeInput.computeHasTimeSecond;
2429
+ const secondList = $xeInput.computeSecondList;
2430
+ return [
2431
+ h('div', {
2432
+ class: 'vxe-input--time-picker-header'
2433
+ }, [
2434
+ hasTimeMinute
2435
+ ? h('span', {
2436
+ class: 'vxe-input--time-picker-title'
2437
+ }, dateTimeLabel)
2438
+ : renderEmptyElement($xeInput),
2439
+ h('div', {
2440
+ class: 'vxe-input--time-picker-btn'
2441
+ }, [
2442
+ h('button', {
2443
+ class: 'vxe-input--time-picker-confirm',
2444
+ attrs: {
2445
+ type: 'button'
2446
+ },
2447
+ on: {
2448
+ click: $xeInput.dateConfirmEvent
2449
+ }
2450
+ }, getI18n('vxe.button.confirm'))
2451
+ ])
2452
+ ]),
2453
+ h('div', {
2454
+ ref: 'refInputTimeBody',
2455
+ class: 'vxe-input--time-picker-body'
2456
+ }, [
2457
+ h('ul', {
2458
+ class: 'vxe-input--time-picker-hour-list'
2459
+ }, hourList.map((item, index) => {
2460
+ return h('li', {
2461
+ key: index,
2462
+ class: {
2463
+ 'is--selected': datetimePanelValue && datetimePanelValue.getHours() === item.value
2464
+ },
2465
+ on: {
2466
+ click: (evnt) => $xeInput.dateHourEvent(evnt, item)
2467
+ }
2468
+ }, item.label);
2469
+ })),
2470
+ hasTimeMinute
2471
+ ? h('ul', {
2472
+ class: 'vxe-input--time-picker-minute-list'
2473
+ }, minuteList.map((item, index) => {
2474
+ return h('li', {
2475
+ key: index,
2476
+ class: {
2477
+ 'is--selected': datetimePanelValue && datetimePanelValue.getMinutes() === item.value
2478
+ },
2479
+ on: {
2480
+ click: (evnt) => $xeInput.dateMinuteEvent(evnt, item)
2481
+ }
2482
+ }, item.label);
2483
+ }))
2484
+ : renderEmptyElement($xeInput),
2485
+ hasTimeMinute && hasTimeSecond
2486
+ ? h('ul', {
2487
+ class: 'vxe-input--time-picker-second-list'
2488
+ }, secondList.map((item, index) => {
2489
+ return h('li', {
2490
+ key: index,
2491
+ class: {
2492
+ 'is--selected': datetimePanelValue && datetimePanelValue.getSeconds() === item.value
2493
+ },
2494
+ on: {
2495
+ click: (evnt) => $xeInput.dateSecondEvent(evnt, item)
2496
+ }
2497
+ }, item.label);
2498
+ }))
2499
+ : renderEmptyElement($xeInput)
2500
+ ])
2501
+ ];
2502
+ },
2503
+ renderPanel(h) {
2504
+ const $xeInput = this;
2505
+ const props = $xeInput;
2506
+ const reactData = $xeInput.reactData;
2507
+ const { type } = props;
2508
+ const { initialized, isAniVisible, visiblePanel, panelPlacement, panelStyle } = reactData;
2509
+ const vSize = $xeInput.computeSize;
2510
+ const btnTransfer = $xeInput.computeBtnTransfer;
2511
+ const isDatePickerType = $xeInput.computeIsDatePickerType;
2512
+ const renders = [];
2513
+ if (isDatePickerType) {
2514
+ if (type === 'datetime') {
2515
+ renders.push(h('div', {
2516
+ key: type,
2517
+ ref: 'refPanelWrapper',
2518
+ class: 'vxe-input--panel-layout-wrapper'
2519
+ }, [
2520
+ h('div', {
2521
+ class: 'vxe-input--panel-left-wrapper'
2522
+ }, $xeInput.renderDatePanel(h)),
2523
+ h('div', {
2524
+ class: 'vxe-input--panel-right-wrapper'
2525
+ }, $xeInput.renderTimePanel(h))
2526
+ ]));
2527
+ }
2528
+ else if (type === 'time') {
2529
+ renders.push(h('div', {
2530
+ key: type,
2531
+ ref: 'refPanelWrapper',
2532
+ class: 'vxe-input--panel-wrapper'
2533
+ }, $xeInput.renderTimePanel(h)));
2534
+ }
2535
+ else {
2536
+ renders.push(h('div', {
2537
+ key: type || 'default',
2538
+ ref: 'refPanelWrapper',
2539
+ class: 'vxe-input--panel-wrapper'
2540
+ }, $xeInput.renderDatePanel(h)));
2541
+ }
2542
+ return h('div', {
2543
+ ref: 'refInputPanel',
2544
+ class: ['vxe-table--ignore-clear vxe-input--panel', `type--${type}`, {
2545
+ [`size--${vSize}`]: vSize,
2546
+ 'is--transfer': btnTransfer,
2547
+ 'ani--leave': isAniVisible,
2548
+ 'ani--enter': visiblePanel
2549
+ }],
2550
+ attrs: {
2551
+ placement: panelPlacement
2552
+ },
2553
+ style: panelStyle
2554
+ }, initialized ? renders : []);
2555
+ }
2556
+ return renderEmptyElement($xeInput);
2557
+ },
2558
+ renderNumberIcon(h) {
2559
+ const $xeInput = this;
2560
+ const isDisabledAddNumber = $xeInput.computeIsDisabledAddNumber;
2561
+ const isDisabledSubtractNumber = $xeInput.computeIsDisabledSubtractNumber;
2562
+ return h('div', {
2563
+ class: 'vxe-input--control-icon'
2564
+ }, [
2565
+ h('div', {
2566
+ class: 'vxe-input--number-icon'
2567
+ }, [
2568
+ h('div', {
2569
+ class: ['vxe-input--number-btn is--prev', {
2570
+ 'is--disabled': isDisabledAddNumber
2571
+ }],
2572
+ on: {
2573
+ mousedown: $xeInput.numberMousedownEvent,
2574
+ mouseup: $xeInput.numberStopDown,
2575
+ mouseleave: $xeInput.numberStopDown
2576
+ }
2577
+ }, [
2578
+ h('i', {
2579
+ class: getIcon().NUMBER_INPUT_PREV_NUM
2580
+ })
2581
+ ]),
2582
+ h('div', {
2583
+ class: ['vxe-input--number-btn is--next', {
2584
+ 'is--disabled': isDisabledSubtractNumber
2585
+ }],
2586
+ on: {
2587
+ mousedown: $xeInput.numberMousedownEvent,
2588
+ mouseup: $xeInput.numberStopDown,
2589
+ mouseleave: $xeInput.numberStopDown
2590
+ }
2591
+ }, [
2592
+ h('i', {
2593
+ class: getIcon().NUMBER_INPUT_NEXT_NUM
2594
+ })
2595
+ ])
2596
+ ])
2597
+ ]);
2598
+ },
2599
+ renderDatePickerIcon(h) {
2600
+ const $xeInput = this;
2601
+ return h('div', {
2602
+ class: 'vxe-input--control-icon',
2603
+ on: {
2604
+ click: $xeInput.datePickerOpenEvent
2605
+ }
2606
+ }, [
2607
+ h('i', {
2608
+ class: ['vxe-input--date-picker-icon', getIcon().DATE_PICKER_DATE]
2609
+ })
2610
+ ]);
2611
+ },
2612
+ renderSearchIcon(h) {
2613
+ const $xeInput = this;
2614
+ return h('div', {
2615
+ class: 'vxe-input--control-icon',
2616
+ on: {
2617
+ click: $xeInput.searchEvent
2618
+ }
2619
+ }, [
2620
+ h('i', {
2621
+ class: ['vxe-input--search-icon', getIcon().INPUT_SEARCH]
2622
+ })
2623
+ ]);
2624
+ },
2625
+ renderPasswordIcon(h) {
2626
+ const $xeInput = this;
2627
+ const reactData = $xeInput.reactData;
2628
+ const { showPwd } = reactData;
2629
+ return h('div', {
2630
+ class: 'vxe-input--control-icon',
2631
+ on: {
2632
+ click: $xeInput.passwordToggleEvent
2633
+ }
2634
+ }, [
2635
+ h('i', {
2636
+ class: ['vxe-input--password-icon', showPwd ? getIcon().PASSWORD_INPUT_SHOW_PWD : getIcon().PASSWORD_INPUT_HIDE_PWD]
2637
+ })
2638
+ ]);
2639
+ },
2640
+ renderPrefixIcon(h) {
2641
+ const $xeInput = this;
2642
+ const props = $xeInput;
2643
+ const slots = $xeInput.$scopedSlots;
2644
+ const { prefixIcon } = props;
2645
+ const prefixSlot = slots.prefix;
2646
+ return prefixSlot || prefixIcon
2647
+ ? h('div', {
2648
+ class: 'vxe-input--prefix',
2649
+ on: {
2650
+ click: $xeInput.clickPrefixEvent
2651
+ }
2652
+ }, [
2653
+ h('div', {
2654
+ class: 'vxe-input--prefix-icon'
2655
+ }, prefixSlot
2656
+ ? getSlotVNs(prefixSlot({}))
2657
+ : [
2658
+ h('i', {
2659
+ class: prefixIcon
2660
+ })
2661
+ ])
2662
+ ])
2663
+ : null;
2664
+ },
2665
+ renderSuffixIcon(h) {
2666
+ const $xeInput = this;
2667
+ const props = $xeInput;
2668
+ const slots = $xeInput.$scopedSlots;
2669
+ const reactData = $xeInput.reactData;
2670
+ const { suffixIcon } = props;
2671
+ const { inputValue } = reactData;
2672
+ const suffixSlot = slots.suffix;
2673
+ const isDisabled = $xeInput.computeIsDisabled;
2674
+ const isNumType = $xeInput.computeIsNumType;
2675
+ const isDatePickerType = $xeInput.computeIsDatePickerType;
2676
+ const isPawdType = $xeInput.computeIsPawdType;
2677
+ const isSearchType = $xeInput.computeIsSearchType;
2678
+ const isClearable = $xeInput.computeIsClearable;
2679
+ const isExtraBtn = isPawdType || isNumType || isDatePickerType || isSearchType;
2680
+ return isClearable || suffixSlot || suffixIcon || isExtraBtn
2681
+ ? h('div', {
2682
+ class: ['vxe-input--suffix', {
2683
+ 'is--clear': isClearable && !isDisabled && !(inputValue === '' || XEUtils.eqNull(inputValue))
2684
+ }]
2685
+ }, [
2686
+ isClearable
2687
+ ? h('div', {
2688
+ class: 'vxe-input--clear-icon',
2689
+ on: {
2690
+ click: $xeInput.clearValueEvent
2691
+ }
2692
+ }, [
2693
+ h('i', {
2694
+ class: getIcon().INPUT_CLEAR
2695
+ })
2696
+ ])
2697
+ : renderEmptyElement($xeInput),
2698
+ isExtraBtn ? $xeInput.renderExtraSuffixIcon(h) : renderEmptyElement($xeInput),
2699
+ suffixSlot || suffixIcon
2700
+ ? h('div', {
2701
+ class: 'vxe-input--suffix-icon',
2702
+ on: {
2703
+ click: $xeInput.clickSuffixEvent
2704
+ }
2705
+ }, suffixSlot
2706
+ ? getSlotVNs(suffixSlot({}))
2707
+ : [
2708
+ h('i', {
2709
+ class: suffixIcon
2710
+ })
2711
+ ])
2712
+ : renderEmptyElement($xeInput)
2713
+ ])
2714
+ : null;
2715
+ },
2716
+ renderExtraSuffixIcon(h) {
2717
+ const $xeInput = this;
2718
+ const props = $xeInput;
2719
+ const { controls } = props;
2720
+ const isNumType = $xeInput.computeIsNumType;
2721
+ const isDatePickerType = $xeInput.computeIsDatePickerType;
2722
+ const isPawdType = $xeInput.computeIsPawdType;
2723
+ const isSearchType = $xeInput.computeIsSearchType;
2724
+ if (isPawdType) {
2725
+ return $xeInput.renderPasswordIcon(h);
2726
+ }
2727
+ if (isNumType) {
2728
+ if (controls) {
2729
+ return $xeInput.renderNumberIcon(h);
2730
+ }
2731
+ }
2732
+ if (isDatePickerType) {
2733
+ return $xeInput.renderDatePickerIcon(h);
2734
+ }
2735
+ if (isSearchType) {
2736
+ return $xeInput.renderSearchIcon(h);
2737
+ }
2738
+ return renderEmptyElement($xeInput);
2739
+ },
2740
+ renderVN(h) {
2741
+ const $xeInput = this;
2742
+ const props = $xeInput;
2743
+ const reactData = $xeInput.reactData;
2744
+ const { className, controls, type, align, showWordCount, countMethod, name, autoComplete, autocomplete } = props;
2745
+ const { inputValue, visiblePanel, isActivated } = reactData;
2746
+ const vSize = $xeInput.computeSize;
2747
+ const isDisabled = $xeInput.computeIsDisabled;
2748
+ const formReadonly = $xeInput.computeFormReadonly;
2749
+ if (formReadonly) {
2750
+ return h('div', {
2751
+ ref: 'refElem',
2752
+ class: ['vxe-input--readonly', `type--${type}`, className]
2753
+ }, inputValue);
2754
+ }
2755
+ const isCountError = $xeInput.computeIsCountError;
2756
+ const inputCount = $xeInput.computeInputCount;
2757
+ const inputReadonly = $xeInput.computeInputReadonly;
2758
+ const inpMaxLength = $xeInput.computeInpMaxLength;
2759
+ const inputType = $xeInput.computeInputType;
2760
+ const inpPlaceholder = $xeInput.computeInpPlaceholder;
2761
+ const isClearable = $xeInput.computeIsClearable;
2762
+ const isWordCount = showWordCount && ['text', 'search'].includes(type);
2763
+ const prefix = $xeInput.renderPrefixIcon(h);
2764
+ const suffix = $xeInput.renderSuffixIcon(h);
2765
+ return h('div', {
2766
+ ref: 'refElem',
2767
+ class: ['vxe-input', `type--${type}`, className, {
2768
+ [`size--${vSize}`]: vSize,
2769
+ [`is--${align}`]: align,
2770
+ 'is--controls': controls,
2771
+ 'is--prefix': !!prefix,
2772
+ 'is--suffix': !!suffix,
2773
+ 'is--visible': visiblePanel,
2774
+ 'is--count': isWordCount,
2775
+ 'is--disabled': isDisabled,
2776
+ 'is--active': isActivated,
2777
+ 'show--clear': isClearable && !isDisabled && !(inputValue === '' || XEUtils.eqNull(inputValue))
2778
+ }],
2779
+ attrs: {
2780
+ spellcheck: false
2781
+ }
2782
+ }, [
2783
+ prefix || renderEmptyElement($xeInput),
2784
+ h('div', {
2785
+ class: 'vxe-input--wrapper'
2786
+ }, [
2787
+ h('input', {
2788
+ ref: 'refInputTarget',
2789
+ class: 'vxe-input--inner',
2790
+ domProps: {
2791
+ value: inputValue
2792
+ },
2793
+ attrs: {
2794
+ name,
2795
+ type: inputType,
2796
+ placeholder: inpPlaceholder,
2797
+ maxlength: inpMaxLength,
2798
+ readonly: inputReadonly,
2799
+ disabled: isDisabled,
2800
+ autocomplete: autoComplete || autocomplete
2801
+ },
2802
+ on: {
2803
+ keydown: $xeInput.keydownEvent,
2804
+ keyup: $xeInput.keyupEvent,
2805
+ wheel: $xeInput.wheelEvent,
2806
+ click: $xeInput.clickEvent,
2807
+ input: $xeInput.inputEvent,
2808
+ change: $xeInput.changeEvent,
2809
+ focus: $xeInput.focusEvent,
2810
+ blur: $xeInput.blurEvent
2811
+ }
2812
+ })
2813
+ ]),
2814
+ suffix || renderEmptyElement($xeInput),
2815
+ // 下拉面板
2816
+ $xeInput.renderPanel(h),
2817
+ // 字数统计
2818
+ isWordCount
2819
+ ? h('span', {
2820
+ class: ['vxe-input--count', {
2821
+ 'is--error': isCountError
2822
+ }]
2823
+ }, countMethod ? `${countMethod({ value: inputValue })}` : `${inputCount}${inpMaxLength ? `/${inpMaxLength}` : ''}`)
2824
+ : renderEmptyElement($xeInput)
2825
+ ]);
2826
+ }
2827
+ },
2828
+ watch: {
2829
+ value(val) {
2830
+ const $xeInput = this;
2831
+ const reactData = $xeInput.reactData;
2832
+ reactData.inputValue = val;
2833
+ $xeInput.changeValue();
2834
+ },
2835
+ type() {
2836
+ const $xeInput = this;
2837
+ const props = $xeInput;
2838
+ const reactData = $xeInput.reactData;
2839
+ // 切换类型是重置内置变量
2840
+ Object.assign(reactData, {
2841
+ inputValue: props.value,
2842
+ datetimePanelValue: null,
2843
+ datePanelValue: null,
2844
+ datePanelLabel: '',
2845
+ datePanelType: 'day',
2846
+ selectMonth: null,
2847
+ currentDate: null
2848
+ });
2849
+ $xeInput.initValue();
2850
+ },
2851
+ computeDateLabelFormat() {
2852
+ const $xeInput = this;
2853
+ const props = $xeInput;
2854
+ const reactData = $xeInput.reactData;
2855
+ const isDatePickerType = $xeInput.computeIsDatePickerType;
2856
+ if (isDatePickerType) {
2857
+ $xeInput.dateParseValue(reactData.datePanelValue);
2858
+ reactData.inputValue = props.multiple ? $xeInput.computeDateMultipleLabel : reactData.datePanelLabel;
2859
+ }
2860
+ }
2861
+ },
2862
+ created() {
2863
+ const $xeInput = this;
2864
+ const props = $xeInput;
2865
+ const reactData = $xeInput.reactData;
2866
+ reactData.inputValue = props.value;
2867
+ $xeInput.initValue();
2868
+ },
2869
+ mounted() {
2870
+ const $xeInput = this;
2871
+ globalEvents.on($xeInput, 'mousewheel', $xeInput.handleGlobalMousewheelEvent);
2872
+ globalEvents.on($xeInput, 'mousedown', $xeInput.handleGlobalMousedownEvent);
2873
+ globalEvents.on($xeInput, 'keydown', $xeInput.handleGlobalKeydownEvent);
2874
+ globalEvents.on($xeInput, 'blur', $xeInput.handleGlobalBlurEvent);
2875
+ },
2876
+ beforeDestroy() {
2877
+ const $xeInput = this;
2878
+ const panelElem = $xeInput.$refs.refInputPanel;
2879
+ if (panelElem && panelElem.parentNode) {
2880
+ panelElem.parentNode.removeChild(panelElem);
2881
+ }
2882
+ $xeInput.numberStopDown();
2883
+ $xeInput.afterCheckValue();
2884
+ globalEvents.off($xeInput, 'mousewheel');
2885
+ globalEvents.off($xeInput, 'mousedown');
2886
+ globalEvents.off($xeInput, 'keydown');
2887
+ globalEvents.off($xeInput, 'blur');
2888
+ },
2889
+ render(h) {
2890
+ return this.renderVN(h);
2891
+ }
2892
+ });