ai.touchui-vue 1.30.2 → 1.30.3

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 (724) hide show
  1. package/README.md +21 -21
  2. package/lib/ai.touchui-vue.common.js +2087 -2092
  3. package/lib/chat.js +5 -5
  4. package/lib/collapse.js +2 -1
  5. package/lib/color.js +5 -5
  6. package/lib/date-picker.js +2 -1
  7. package/lib/date-range.js +11 -12
  8. package/lib/export.js +3 -3
  9. package/lib/index.js +1 -1
  10. package/lib/locale/format.js +10 -10
  11. package/lib/menu-icon.js +295 -295
  12. package/lib/mixins/migrating.js +20 -20
  13. package/lib/mixins/transition.js +14 -14
  14. package/lib/org.js +2 -1
  15. package/lib/page.js +2 -1
  16. package/lib/range.js +3 -3
  17. package/lib/static/{net-mix.293a4b6.svg → net-mix.dc6e414.svg} +7 -7
  18. package/lib/table.js +734 -740
  19. package/lib/utils/clickoutside.js +11 -11
  20. package/lib/utils/dom.js +13 -13
  21. package/lib/utils/filetransfer.js +4 -4
  22. package/lib/utils/jsencrypt/JSEncrypt.js +77 -77
  23. package/lib/utils/jsencrypt/JSEncryptRSAKey.js +115 -115
  24. package/lib/utils/jsencrypt/jselib/asn1js/asn1.js +4 -4
  25. package/lib/utils/jsencrypt/jselib/jsrsasign/asn1-1.0.js +734 -734
  26. package/lib/utils/jsencrypt/jselib/jsrsasign/yahoo.js +22 -22
  27. package/lib/utils/jsencrypt.js +260 -260
  28. package/lib/utils/md5.js +3 -3
  29. package/lib/utils/mime.js +2 -2
  30. package/lib/utils/ratio.js +54 -53
  31. package/lib/utils/sign.js +12 -12
  32. package/lib/utils/util.js +3 -3
  33. package/lib/utils/validate.js +11 -11
  34. package/package.json +159 -159
  35. package/packages/affix/index.js +8 -8
  36. package/packages/affix/src/affix.vue +139 -139
  37. package/packages/align/index.js +8 -8
  38. package/packages/align/src/directive.js +29 -29
  39. package/packages/animation/index.js +8 -8
  40. package/packages/animation/src/animation.vue +68 -68
  41. package/packages/article/index.js +8 -8
  42. package/packages/article/src/article.vue +23 -23
  43. package/packages/box/index.js +8 -8
  44. package/packages/box/src/box.vue +170 -170
  45. package/packages/button/index.js +8 -8
  46. package/packages/button/src/button.vue +162 -162
  47. package/packages/calendar/index.js +8 -8
  48. package/packages/calendar/src/calendar.vue +1142 -1142
  49. package/packages/card/index.js +10 -10
  50. package/packages/card/src/card-item.vue +92 -92
  51. package/packages/card/src/card.vue +175 -175
  52. package/packages/card-item/index.js +8 -8
  53. package/packages/cascader/index.js +8 -8
  54. package/packages/cascader/src/cascader.vue +814 -814
  55. package/packages/center-scroll/index.js +8 -8
  56. package/packages/center-scroll/src/center-scroll.vue +147 -147
  57. package/packages/chat/index.js +12 -12
  58. package/packages/chat/src/chat.vue +116 -116
  59. package/packages/checkbox/index.js +8 -8
  60. package/packages/checkbox/src/checkbox.vue +262 -262
  61. package/packages/checkboxes/index.js +8 -8
  62. package/packages/checkboxes/src/checkboxes.vue +97 -97
  63. package/packages/collapse/index.js +10 -10
  64. package/packages/collapse/src/collapse-item.vue +188 -188
  65. package/packages/collapse/src/collapse.vue +100 -100
  66. package/packages/color/index.js +8 -8
  67. package/packages/color/src/directive.js +42 -42
  68. package/packages/countdown/index.js +8 -8
  69. package/packages/countdown/src/countdown.vue +128 -128
  70. package/packages/date-picker/index.js +8 -8
  71. package/packages/date-picker/src/date-picker.vue +432 -432
  72. package/packages/date-picker/src/picker.vue +342 -342
  73. package/packages/date-range/index.js +8 -8
  74. package/packages/date-range/src/date-range.vue +384 -384
  75. package/packages/dialog/index.js +8 -8
  76. package/packages/dialog/src/dialog.vue +287 -287
  77. package/packages/dis/index.js +8 -8
  78. package/packages/dis/src/directive.js +42 -42
  79. package/packages/ellipsis/index.js +8 -8
  80. package/packages/ellipsis/src/ellipsis.vue +306 -306
  81. package/packages/emote/index.js +8 -8
  82. package/packages/emote/src/emote.vue +38 -38
  83. package/packages/export/index.js +8 -8
  84. package/packages/export/src/ajax.js +73 -73
  85. package/packages/export/src/export.vue +289 -289
  86. package/packages/filter/index.js +8 -8
  87. package/packages/filter/src/filter.vue +245 -245
  88. package/packages/fix/index.js +8 -8
  89. package/packages/fix/src/fix.vue +221 -221
  90. package/packages/float/index.js +16 -16
  91. package/packages/float/src/directive.js +20 -20
  92. package/packages/float/src/main.vue +642 -642
  93. package/packages/float/src/trigger.vue +31 -31
  94. package/packages/flow/index.js +8 -8
  95. package/packages/flow/src/flow.vue +234 -234
  96. package/packages/flow/src/flowItem.vue +61 -61
  97. package/packages/flow/src/flowLine.vue +168 -168
  98. package/packages/form/index.js +10 -10
  99. package/packages/form/src/form-item.vue +96 -96
  100. package/packages/form/src/form.vue +184 -184
  101. package/packages/grid/index.js +10 -10
  102. package/packages/grid/src/grid-item.vue +65 -65
  103. package/packages/grid/src/grid.vue +190 -190
  104. package/packages/grid-item/index.js +8 -8
  105. package/packages/guider/index.js +8 -8
  106. package/packages/guider/src/guider.vue +168 -168
  107. package/packages/header/index.js +8 -8
  108. package/packages/header/src/header.vue +111 -111
  109. package/packages/hide/index.js +8 -8
  110. package/packages/hide/src/directive.js +57 -57
  111. package/packages/icon/index.js +8 -8
  112. package/packages/icon/src/icon.vue +79 -79
  113. package/packages/import/index.js +8 -8
  114. package/packages/import/src/import.vue +279 -279
  115. package/packages/input/index.js +8 -8
  116. package/packages/input/src/calcTextareaHeight.js +104 -104
  117. package/packages/input/src/input.vue +653 -653
  118. package/packages/ip/index.js +8 -8
  119. package/packages/ip/src/ip.vue +143 -143
  120. package/packages/line/index.js +8 -8
  121. package/packages/line/src/line.vue +29 -29
  122. package/packages/loading/index.js +8 -8
  123. package/packages/loading/src/loading.js +58 -58
  124. package/packages/longtap/index.js +8 -8
  125. package/packages/longtap/src/longtap.js +95 -95
  126. package/packages/menu-icon/index.js +8 -8
  127. package/packages/menu-icon/src/menu-icon.vue +206 -206
  128. package/packages/message/index.js +8 -8
  129. package/packages/message/src/message.vue +9 -9
  130. package/packages/msg/index.js +8 -8
  131. package/packages/msg/src/msg.vue +227 -227
  132. package/packages/org/index.js +8 -8
  133. package/packages/org/src/org.vue +113 -113
  134. package/packages/org/src/orgItem.vue +63 -63
  135. package/packages/padding/index.js +8 -8
  136. package/packages/padding/src/padding.vue +105 -105
  137. package/packages/page/index.js +8 -8
  138. package/packages/page/src/page.vue +297 -297
  139. package/packages/param/index.js +8 -8
  140. package/packages/param/src/param.vue +226 -226
  141. package/packages/pic/index.js +8 -8
  142. package/packages/pic/src/pic-viewer.vue +331 -331
  143. package/packages/pic/src/pic.vue +144 -144
  144. package/packages/popup/index.js +12 -12
  145. package/packages/popup/src/popup-group.vue +47 -47
  146. package/packages/popup/src/popup-item.vue +163 -163
  147. package/packages/popup/src/popup.vue +350 -350
  148. package/packages/progress/index.js +8 -8
  149. package/packages/progress/src/progress.vue +306 -306
  150. package/packages/range/index.js +8 -8
  151. package/packages/range/src/range.vue +612 -612
  152. package/packages/rate/index.js +8 -8
  153. package/packages/rate/src/rate.vue +129 -129
  154. package/packages/reverser/index.js +8 -8
  155. package/packages/reverser/src/reverser.vue +49 -49
  156. package/packages/scroll/index.js +12 -12
  157. package/packages/scroll/src/scroll-point.vue +24 -24
  158. package/packages/scroll/src/scroll-sticky.vue +60 -60
  159. package/packages/scroll/src/scroll.vue +381 -381
  160. package/packages/segment/index.js +8 -8
  161. package/packages/segment/src/segment.vue +618 -618
  162. package/packages/select/index.js +8 -8
  163. package/packages/select/src/select.vue +1445 -1445
  164. package/packages/size/index.js +8 -8
  165. package/packages/size/src/directive.js +33 -33
  166. package/packages/skeleton/index.js +8 -8
  167. package/packages/skeleton/src/skeleton.vue +179 -179
  168. package/packages/slide/index.js +8 -8
  169. package/packages/slide/src/slide.vue +147 -147
  170. package/packages/space/index.js +8 -8
  171. package/packages/space/src/space.vue +53 -53
  172. package/packages/step/index.js +8 -8
  173. package/packages/step/src/step.vue +122 -122
  174. package/packages/submit/index.js +8 -8
  175. package/packages/submit/src/submit.vue +103 -103
  176. package/packages/switch/index.js +9 -9
  177. package/packages/switch/src/component.vue +131 -131
  178. package/packages/tab/index.js +10 -10
  179. package/packages/tab/src/tab-item.vue +85 -85
  180. package/packages/tab/src/tab.vue +590 -590
  181. package/packages/table/index.js +8 -8
  182. package/packages/table/src/table-body.vue +301 -301
  183. package/packages/table/src/table-config.vue +139 -139
  184. package/packages/table/src/table-head.vue +239 -239
  185. package/packages/table/src/table.vue +1455 -1458
  186. package/packages/tag/index.js +8 -8
  187. package/packages/tag/src/tag.vue +129 -129
  188. package/packages/theme/package.json +33 -33
  189. package/packages/theme/src/global/mixin.less +416 -416
  190. package/packages/theme/src/global/reset.less +27 -27
  191. package/packages/theme/src/less/component/affix.less +8 -8
  192. package/packages/theme/src/less/component/article-dark.less +6 -6
  193. package/packages/theme/src/less/component/article.less +39 -39
  194. package/packages/theme/src/less/component/box-dark.less +85 -85
  195. package/packages/theme/src/less/component/box.less +272 -272
  196. package/packages/theme/src/less/component/calendar-dark.less +111 -111
  197. package/packages/theme/src/less/component/calendar.less +282 -282
  198. package/packages/theme/src/less/component/card-dark.less +17 -17
  199. package/packages/theme/src/less/component/card.less +89 -89
  200. package/packages/theme/src/less/component/chat-dark.less +47 -47
  201. package/packages/theme/src/less/component/chat.less +71 -71
  202. package/packages/theme/src/less/component/code-dark.less +41 -41
  203. package/packages/theme/src/less/component/code.less +33 -33
  204. package/packages/theme/src/less/component/cover.less +4 -4
  205. package/packages/theme/src/less/component/dialog-dark.less +54 -54
  206. package/packages/theme/src/less/component/dialog.less +49 -49
  207. package/packages/theme/src/less/component/filter-dark.less +31 -31
  208. package/packages/theme/src/less/component/filter.less +97 -97
  209. package/packages/theme/src/less/component/float-dark.less +26 -26
  210. package/packages/theme/src/less/component/float.less +61 -61
  211. package/packages/theme/src/less/component/form-dark.less +45 -45
  212. package/packages/theme/src/less/component/form.less +322 -322
  213. package/packages/theme/src/less/component/gantt-dark.less +44 -44
  214. package/packages/theme/src/less/component/gantt.less +52 -52
  215. package/packages/theme/src/less/component/guider-dark.less +6 -6
  216. package/packages/theme/src/less/component/guider.less +15 -15
  217. package/packages/theme/src/less/component/header-dark.less +41 -41
  218. package/packages/theme/src/less/component/header.less +121 -121
  219. package/packages/theme/src/less/component/keyboard-dark.less +15 -15
  220. package/packages/theme/src/less/component/keyboard.less +21 -21
  221. package/packages/theme/src/less/component/line-dark.less +20 -20
  222. package/packages/theme/src/less/component/line.less +21 -21
  223. package/packages/theme/src/less/component/msg-dark.less +42 -42
  224. package/packages/theme/src/less/component/msg.less +102 -102
  225. package/packages/theme/src/less/component/page-dark.less +26 -26
  226. package/packages/theme/src/less/component/page.less +26 -26
  227. package/packages/theme/src/less/component/param-dark.less +31 -31
  228. package/packages/theme/src/less/component/param.less +136 -136
  229. package/packages/theme/src/less/component/popup-dark.less +20 -20
  230. package/packages/theme/src/less/component/popup.less +85 -85
  231. package/packages/theme/src/less/component/print.less +121 -121
  232. package/packages/theme/src/less/component/scroll-dark.less +19 -19
  233. package/packages/theme/src/less/component/scroll.less +47 -47
  234. package/packages/theme/src/less/component/skeleton-dark.less +29 -29
  235. package/packages/theme/src/less/component/skeleton.less +78 -78
  236. package/packages/theme/src/less/component/slide.less +70 -70
  237. package/packages/theme/src/less/component/space.less +2 -2
  238. package/packages/theme/src/less/component/step-dark.less +165 -165
  239. package/packages/theme/src/less/component/step.less +147 -147
  240. package/packages/theme/src/less/component/submit.less +40 -40
  241. package/packages/theme/src/less/component/tab-dark.less +221 -221
  242. package/packages/theme/src/less/component/tab.less +459 -459
  243. package/packages/theme/src/less/component/table-dark.less +196 -196
  244. package/packages/theme/src/less/component/table.less +425 -425
  245. package/packages/theme/src/less/component/timeline-dark.less +13 -13
  246. package/packages/theme/src/less/component/timeline.less +114 -114
  247. package/packages/theme/src/less/component/tip-dark.less +76 -76
  248. package/packages/theme/src/less/component/tip.less +139 -139
  249. package/packages/theme/src/less/component/tooltip-dark.less +105 -105
  250. package/packages/theme/src/less/component/tooltip.less +159 -159
  251. package/packages/theme/src/less/component/tree-dark.less +56 -56
  252. package/packages/theme/src/less/component/tree.less +148 -148
  253. package/packages/theme/src/less/element/align.less +32 -32
  254. package/packages/theme/src/less/element/animation.less +5 -5
  255. package/packages/theme/src/less/element/button-dark.less +29 -29
  256. package/packages/theme/src/less/element/button.less +65 -65
  257. package/packages/theme/src/less/element/center-scroll-dark.less +3 -3
  258. package/packages/theme/src/less/element/center-scroll.less +6 -6
  259. package/packages/theme/src/less/element/checkbox-dark.less +68 -68
  260. package/packages/theme/src/less/element/checkbox.less +73 -73
  261. package/packages/theme/src/less/element/color-dark.less +15 -15
  262. package/packages/theme/src/less/element/color.less +33 -33
  263. package/packages/theme/src/less/element/dis.less +9 -9
  264. package/packages/theme/src/less/element/ellipsis.less +35 -35
  265. package/packages/theme/src/less/element/emote.less +5 -5
  266. package/packages/theme/src/less/element/font-dark.less +9 -9
  267. package/packages/theme/src/less/element/font.less +8 -8
  268. package/packages/theme/src/less/element/hide-dark.less +114 -114
  269. package/packages/theme/src/less/element/hide.less +114 -114
  270. package/packages/theme/src/less/element/icon.less +297 -297
  271. package/packages/theme/src/less/element/input-dark.less +205 -205
  272. package/packages/theme/src/less/element/input.less +405 -405
  273. package/packages/theme/src/less/element/menu-icon.less +1 -1
  274. package/packages/theme/src/less/element/pic.less +18 -18
  275. package/packages/theme/src/less/element/progress-dark.less +37 -37
  276. package/packages/theme/src/less/element/progress.less +82 -82
  277. package/packages/theme/src/less/element/radio-dark.less +18 -18
  278. package/packages/theme/src/less/element/radio.less +11 -11
  279. package/packages/theme/src/less/element/range-dark.less +24 -24
  280. package/packages/theme/src/less/element/range.less +56 -56
  281. package/packages/theme/src/less/element/rate.less +17 -17
  282. package/packages/theme/src/less/element/segment-dark.less +119 -119
  283. package/packages/theme/src/less/element/segment.less +197 -197
  284. package/packages/theme/src/less/element/select-dark.less +167 -167
  285. package/packages/theme/src/less/element/select.less +431 -431
  286. package/packages/theme/src/less/element/size.less +10 -10
  287. package/packages/theme/src/less/element/switch-dark.less +7 -7
  288. package/packages/theme/src/less/element/switch.less +37 -37
  289. package/packages/theme/src/less/element/tag-dark.less +115 -115
  290. package/packages/theme/src/less/element/tag.less +159 -159
  291. package/packages/theme/src/less/element/upload-dark.less +26 -26
  292. package/packages/theme/src/less/element/upload.less +64 -64
  293. package/packages/theme/src/less/layout/fix.less +2 -2
  294. package/packages/theme/src/less/layout/flow.less +47 -47
  295. package/packages/theme/src/less/layout/grid-dark.less +28 -28
  296. package/packages/theme/src/less/layout/grid.less +172 -172
  297. package/packages/theme/src/less/layout/org-dark.less +2 -2
  298. package/packages/theme/src/less/layout/org.less +72 -72
  299. package/packages/theme/src/less/layout/padding.less +1 -1
  300. package/packages/theme/src/less/layout/reverser.less +8 -8
  301. package/packages/theme/src/less/theme/B-Design.less +159 -159
  302. package/packages/theme/src/less/theme/aiplan.less +159 -159
  303. package/packages/theme/src/less/theme/aiplangd.less +159 -159
  304. package/packages/theme/src/less/theme/chbn.less +159 -159
  305. package/packages/theme/src/less/theme/default.less +160 -160
  306. package/packages/theme/src/less/theme/dt.less +159 -159
  307. package/packages/theme/src/less/theme/ecloud.less +159 -159
  308. package/packages/theme/src/less/theme/hongkong.less +159 -159
  309. package/packages/theme/src/less/theme/narrow.less +160 -160
  310. package/packages/theme/src/less/theme/sdpf.less +160 -160
  311. package/packages/theme/src/less/theme/upc.less +159 -159
  312. package/packages/theme/src/less/theme/website.less +159 -159
  313. package/packages/theme/src/less/theme/zj.less +159 -159
  314. package/packages/timeline/index.js +8 -8
  315. package/packages/timeline/src/timeline.vue +84 -84
  316. package/packages/tip/index.js +8 -8
  317. package/packages/tip/src/tip.vue +226 -226
  318. package/packages/tooltip/index.js +8 -8
  319. package/packages/tooltip/src/directive.js +180 -180
  320. package/packages/tooltip/src/tooltip.vue +467 -467
  321. package/packages/transfer/index.js +8 -8
  322. package/packages/transfer/src/transfer.vue +293 -293
  323. package/packages/tree/index.js +8 -8
  324. package/packages/tree/src/tree.vue +518 -518
  325. package/packages/tree/src/treeItem.vue +443 -443
  326. package/packages/upload/index.js +8 -8
  327. package/packages/upload/src/upload.vue +860 -860
  328. package/src/index.js +207 -207
  329. package/src/locale/format.js +46 -46
  330. package/src/locale/index.js +48 -48
  331. package/src/locale/lang/en.js +207 -207
  332. package/src/locale/lang/zh-CN.js +207 -207
  333. package/src/mixins/blur.js +9 -9
  334. package/src/mixins/emitter.js +33 -33
  335. package/src/mixins/focus.js +9 -9
  336. package/src/mixins/locale.js +9 -9
  337. package/src/mixins/migrating.js +54 -54
  338. package/src/mixins/tip.js +10 -10
  339. package/src/mixins/transition.js +130 -130
  340. package/src/msg/index.js +107 -107
  341. package/src/svg/menu/main/abnormal-mix.svg +5 -5
  342. package/src/svg/menu/main/abnormal.svg +5 -5
  343. package/src/svg/menu/main/accountManager-mix.svg +5 -5
  344. package/src/svg/menu/main/accountManager.svg +5 -5
  345. package/src/svg/menu/main/agreement-mix.svg +7 -7
  346. package/src/svg/menu/main/agreement.svg +7 -7
  347. package/src/svg/menu/main/ai-mix.svg +5 -5
  348. package/src/svg/menu/main/archives-mix.svg +6 -6
  349. package/src/svg/menu/main/arrearsReport-mix.svg +17 -17
  350. package/src/svg/menu/main/arrearsReport.svg +17 -17
  351. package/src/svg/menu/main/bill-mix.svg +13 -13
  352. package/src/svg/menu/main/bill.svg +13 -13
  353. package/src/svg/menu/main/box-mix.svg +5 -5
  354. package/src/svg/menu/main/broadband-mix.svg +4 -4
  355. package/src/svg/menu/main/broadband.svg +4 -4
  356. package/src/svg/menu/main/card-mix.svg +5 -5
  357. package/src/svg/menu/main/card.svg +5 -5
  358. package/src/svg/menu/main/cash-mix.svg +5 -5
  359. package/src/svg/menu/main/cash.svg +5 -5
  360. package/src/svg/menu/main/cloud-mix.svg +4 -4
  361. package/src/svg/menu/main/cloud.svg +4 -4
  362. package/src/svg/menu/main/clue-mix.svg +10 -10
  363. package/src/svg/menu/main/clue.svg +10 -10
  364. package/src/svg/menu/main/commonUse-mix.svg +4 -4
  365. package/src/svg/menu/main/commonUse.svg +4 -4
  366. package/src/svg/menu/main/construction-mix.svg +7 -7
  367. package/src/svg/menu/main/construction.svg +7 -7
  368. package/src/svg/menu/main/contract-mix.svg +8 -8
  369. package/src/svg/menu/main/contract.svg +8 -8
  370. package/src/svg/menu/main/credit-mix.svg +5 -5
  371. package/src/svg/menu/main/credit.svg +5 -5
  372. package/src/svg/menu/main/data-mix.svg +5 -5
  373. package/src/svg/menu/main/data.svg +5 -5
  374. package/src/svg/menu/main/date-mix.svg +7 -7
  375. package/src/svg/menu/main/deposit-mix.svg +4 -4
  376. package/src/svg/menu/main/device-mix.svg +4 -4
  377. package/src/svg/menu/main/device.svg +4 -4
  378. package/src/svg/menu/main/discrepancy-mix.svg +5 -5
  379. package/src/svg/menu/main/door-mix.svg +6 -6
  380. package/src/svg/menu/main/fault-mix.svg +12 -12
  381. package/src/svg/menu/main/fault.svg +16 -16
  382. package/src/svg/menu/main/finance-mix.svg +11 -11
  383. package/src/svg/menu/main/finance.svg +13 -13
  384. package/src/svg/menu/main/flow-mix.svg +4 -4
  385. package/src/svg/menu/main/flow.svg +4 -4
  386. package/src/svg/menu/main/folder-mix.svg +4 -4
  387. package/src/svg/menu/main/folder.svg +4 -4
  388. package/src/svg/menu/main/friendly-mix.svg +5 -5
  389. package/src/svg/menu/main/fusion-mix.svg +5 -5
  390. package/src/svg/menu/main/fusion.svg +5 -5
  391. package/src/svg/menu/main/gift-mix.svg +8 -8
  392. package/src/svg/menu/main/gift.svg +8 -8
  393. package/src/svg/menu/main/gps-mix.svg +6 -6
  394. package/src/svg/menu/main/gps.svg +6 -6
  395. package/src/svg/menu/main/grid-mix.svg +7 -7
  396. package/src/svg/menu/main/grid.svg +7 -7
  397. package/src/svg/menu/main/group-mix.svg +4 -4
  398. package/src/svg/menu/main/group.svg +4 -4
  399. package/src/svg/menu/main/home-mix.svg +5 -5
  400. package/src/svg/menu/main/home.svg +8 -8
  401. package/src/svg/menu/main/ict-mix.svg +4 -4
  402. package/src/svg/menu/main/industry-mix.svg +5 -5
  403. package/src/svg/menu/main/industry.svg +5 -5
  404. package/src/svg/menu/main/info-mix.svg +9 -9
  405. package/src/svg/menu/main/info.svg +9 -9
  406. package/src/svg/menu/main/integral-mix.svg +5 -5
  407. package/src/svg/menu/main/integral.svg +5 -5
  408. package/src/svg/menu/main/internet-mix.svg +5 -5
  409. package/src/svg/menu/main/internet.svg +5 -5
  410. package/src/svg/menu/main/inventory-mix.svg +5 -5
  411. package/src/svg/menu/main/invoice-mix.svg +6 -6
  412. package/src/svg/menu/main/invoice.svg +14 -14
  413. package/src/svg/menu/main/iot-mix.svg +5 -5
  414. package/src/svg/menu/main/iot.svg +5 -5
  415. package/src/svg/menu/main/label-mix.svg +4 -4
  416. package/src/svg/menu/main/label.svg +4 -4
  417. package/src/svg/menu/main/love-mix.svg +6 -6
  418. package/src/svg/menu/main/love.svg +13 -13
  419. package/src/svg/menu/main/m1-mix.svg +4 -4
  420. package/src/svg/menu/main/m1.svg +4 -4
  421. package/src/svg/menu/main/m2-mix.svg +12 -12
  422. package/src/svg/menu/main/m2.svg +11 -11
  423. package/src/svg/menu/main/m3-mix.svg +6 -6
  424. package/src/svg/menu/main/m3.svg +7 -7
  425. package/src/svg/menu/main/m4-mix.svg +5 -5
  426. package/src/svg/menu/main/m4.svg +7 -7
  427. package/src/svg/menu/main/m5-mix.svg +8 -8
  428. package/src/svg/menu/main/m5.svg +10 -10
  429. package/src/svg/menu/main/mail-mix.svg +5 -5
  430. package/src/svg/menu/main/manual-mix.svg +11 -11
  431. package/src/svg/menu/main/manual.svg +11 -11
  432. package/src/svg/menu/main/market-mix.svg +4 -4
  433. package/src/svg/menu/main/market.svg +4 -4
  434. package/src/svg/menu/main/member-mix.svg +6 -6
  435. package/src/svg/menu/main/member.svg +6 -6
  436. package/src/svg/menu/main/menu-mix.svg +4 -4
  437. package/src/svg/menu/main/menu.svg +4 -4
  438. package/src/svg/menu/main/message-mix.svg +11 -11
  439. package/src/svg/menu/main/message.svg +11 -11
  440. package/src/svg/menu/main/namelist-mix.svg +4 -4
  441. package/src/svg/menu/main/namelist.svg +4 -4
  442. package/src/svg/menu/main/net-mix.svg +7 -7
  443. package/src/svg/menu/main/niche-mix.svg +12 -12
  444. package/src/svg/menu/main/niche.svg +12 -12
  445. package/src/svg/menu/main/notice-mix.svg +4 -4
  446. package/src/svg/menu/main/notice.svg +4 -4
  447. package/src/svg/menu/main/number-mix.svg +6 -6
  448. package/src/svg/menu/main/operations-mix.svg +4 -4
  449. package/src/svg/menu/main/operations.svg +4 -4
  450. package/src/svg/menu/main/order-mix.svg +8 -8
  451. package/src/svg/menu/main/order.svg +8 -8
  452. package/src/svg/menu/main/person-mix.svg +6 -6
  453. package/src/svg/menu/main/person.svg +6 -6
  454. package/src/svg/menu/main/phone-mix.svg +4 -4
  455. package/src/svg/menu/main/phone.svg +4 -4
  456. package/src/svg/menu/main/phoneBill-mix.svg +6 -6
  457. package/src/svg/menu/main/phoneBill.svg +6 -6
  458. package/src/svg/menu/main/preferential-mix.svg +5 -5
  459. package/src/svg/menu/main/preferential.svg +5 -5
  460. package/src/svg/menu/main/print-mix.svg +5 -5
  461. package/src/svg/menu/main/problem-mix.svg +4 -4
  462. package/src/svg/menu/main/problem.svg +4 -4
  463. package/src/svg/menu/main/process-mix.svg +4 -4
  464. package/src/svg/menu/main/process.svg +4 -4
  465. package/src/svg/menu/main/product-mix.svg +5 -5
  466. package/src/svg/menu/main/product.svg +6 -6
  467. package/src/svg/menu/main/qrCode-mix.svg +8 -8
  468. package/src/svg/menu/main/qrCode.svg +8 -8
  469. package/src/svg/menu/main/refuelingBag-mix-mix.svg +4 -4
  470. package/src/svg/menu/main/refuelingBag-mix.svg +4 -4
  471. package/src/svg/menu/main/reportForm-mix.svg +8 -8
  472. package/src/svg/menu/main/reportForm.svg +8 -8
  473. package/src/svg/menu/main/risk-mix.svg +16 -16
  474. package/src/svg/menu/main/risk.svg +17 -17
  475. package/src/svg/menu/main/robot-mix.svg +9 -9
  476. package/src/svg/menu/main/robot.svg +9 -9
  477. package/src/svg/menu/main/satisfaction-mix.svg +4 -4
  478. package/src/svg/menu/main/satisfaction.svg +4 -4
  479. package/src/svg/menu/main/scratchCard-mix.svg +4 -4
  480. package/src/svg/menu/main/sim-mix.svg +4 -4
  481. package/src/svg/menu/main/sim.svg +4 -4
  482. package/src/svg/menu/main/staging-mix.svg +4 -4
  483. package/src/svg/menu/main/staging.svg +4 -4
  484. package/src/svg/menu/main/survey-mix.svg +5 -5
  485. package/src/svg/menu/main/survey.svg +5 -5
  486. package/src/svg/menu/main/tasks-mix.svg +8 -8
  487. package/src/svg/menu/main/tasks.svg +8 -8
  488. package/src/svg/menu/main/telephone-mix.svg +4 -4
  489. package/src/svg/menu/main/topUp-mix.svg +5 -5
  490. package/src/svg/menu/main/trajectory-mix.svg +11 -11
  491. package/src/svg/menu/main/trajectory.svg +23 -23
  492. package/src/svg/menu/main/transmit-mix.svg +5 -5
  493. package/src/svg/menu/main/tv-mix.svg +6 -6
  494. package/src/svg/menu/main/unlock-mix.svg +4 -4
  495. package/src/svg/menu/main/unlock.svg +4 -4
  496. package/src/svg/menu/main/view-mix.svg +5 -5
  497. package/src/svg/menu/main/view.svg +5 -5
  498. package/src/svg/menu/main/visits-mix.svg +19 -19
  499. package/src/svg/menu/main/visits.svg +19 -19
  500. package/src/svg/menu/main/voice-mix.svg +4 -4
  501. package/src/svg/menu/main/voice.svg +4 -4
  502. package/src/svg/menu/main/wiki-mix.svg +4 -4
  503. package/src/svg/menu/main/wiki.svg +4 -4
  504. package/src/svg/menu/main/workOrder-mix.svg +6 -6
  505. package/src/svg/menu/main/workOrder.svg +14 -14
  506. package/src/svg/menu/patch/Mo-space.svg +2 -2
  507. package/src/svg/menu/patch/Mo.svg +3 -3
  508. package/src/svg/menu/patch/add-space.svg +3 -3
  509. package/src/svg/menu/patch/add.svg +3 -3
  510. package/src/svg/menu/patch/address-space.svg +3 -3
  511. package/src/svg/menu/patch/address.svg +3 -3
  512. package/src/svg/menu/patch/approve-space.svg +3 -3
  513. package/src/svg/menu/patch/approve.svg +4 -4
  514. package/src/svg/menu/patch/avoid-space.svg +3 -3
  515. package/src/svg/menu/patch/avoid.svg +3 -3
  516. package/src/svg/menu/patch/batch-space.svg +3 -3
  517. package/src/svg/menu/patch/batch.svg +5 -5
  518. package/src/svg/menu/patch/broadband-space.svg +3 -3
  519. package/src/svg/menu/patch/broadband.svg +4 -4
  520. package/src/svg/menu/patch/cancellation-space.svg +3 -3
  521. package/src/svg/menu/patch/cancellation.svg +3 -3
  522. package/src/svg/menu/patch/center-space.svg +3 -3
  523. package/src/svg/menu/patch/center.svg +5 -5
  524. package/src/svg/menu/patch/change-space.svg +3 -3
  525. package/src/svg/menu/patch/change.svg +4 -4
  526. package/src/svg/menu/patch/click-space.svg +3 -3
  527. package/src/svg/menu/patch/click.svg +4 -4
  528. package/src/svg/menu/patch/close-1-space.svg +3 -3
  529. package/src/svg/menu/patch/close-1.svg +3 -3
  530. package/src/svg/menu/patch/close-space.svg +2 -2
  531. package/src/svg/menu/patch/close.svg +3 -3
  532. package/src/svg/menu/patch/collect-space.svg +3 -3
  533. package/src/svg/menu/patch/collect.svg +3 -3
  534. package/src/svg/menu/patch/comment-space.svg +3 -3
  535. package/src/svg/menu/patch/comment.svg +3 -3
  536. package/src/svg/menu/patch/confirm-space.svg +3 -3
  537. package/src/svg/menu/patch/confirm.svg +3 -3
  538. package/src/svg/menu/patch/contract-space.svg +3 -3
  539. package/src/svg/menu/patch/contract.svg +3 -3
  540. package/src/svg/menu/patch/credit-space.svg +3 -3
  541. package/src/svg/menu/patch/credit.svg +5 -5
  542. package/src/svg/menu/patch/dataMonitoring-space.svg +3 -3
  543. package/src/svg/menu/patch/dataMonitoring.svg +3 -3
  544. package/src/svg/menu/patch/dedicatedCircuit-space.svg +3 -3
  545. package/src/svg/menu/patch/dedicatedCircuit.svg +3 -3
  546. package/src/svg/menu/patch/detail-space.svg +3 -3
  547. package/src/svg/menu/patch/detail.svg +3 -3
  548. package/src/svg/menu/patch/disassemb-space.svg +3 -3
  549. package/src/svg/menu/patch/disassemb.svg +3 -3
  550. package/src/svg/menu/patch/earnestMoney-space.svg +3 -3
  551. package/src/svg/menu/patch/earnestMoney.svg +3 -3
  552. package/src/svg/menu/patch/empower-space.svg +3 -3
  553. package/src/svg/menu/patch/empower.svg +3 -3
  554. package/src/svg/menu/patch/entrust-space.svg +3 -3
  555. package/src/svg/menu/patch/entrust.svg +3 -3
  556. package/src/svg/menu/patch/expedite-space.svg +4 -4
  557. package/src/svg/menu/patch/expedite.svg +4 -4
  558. package/src/svg/menu/patch/flow-space.svg +3 -3
  559. package/src/svg/menu/patch/flow.svg +3 -3
  560. package/src/svg/menu/patch/folder-space.svg +3 -3
  561. package/src/svg/menu/patch/folder.svg +3 -3
  562. package/src/svg/menu/patch/forbidden-space.svg +3 -3
  563. package/src/svg/menu/patch/forbidden.svg +3 -3
  564. package/src/svg/menu/patch/forward-space.svg +3 -3
  565. package/src/svg/menu/patch/forward.svg +3 -3
  566. package/src/svg/menu/patch/fusion-space.svg +3 -3
  567. package/src/svg/menu/patch/fusion.svg +6 -6
  568. package/src/svg/menu/patch/history-space.svg +3 -3
  569. package/src/svg/menu/patch/history.svg +3 -3
  570. package/src/svg/menu/patch/information-space.svg +3 -3
  571. package/src/svg/menu/patch/information.svg +3 -3
  572. package/src/svg/menu/patch/insert-space.svg +3 -3
  573. package/src/svg/menu/patch/insert.svg +3 -3
  574. package/src/svg/menu/patch/letv-space.svg +3 -3
  575. package/src/svg/menu/patch/letv.svg +3 -3
  576. package/src/svg/menu/patch/link-space.svg +3 -3
  577. package/src/svg/menu/patch/link.svg +3 -3
  578. package/src/svg/menu/patch/location-space.svg +3 -3
  579. package/src/svg/menu/patch/location.svg +3 -3
  580. package/src/svg/menu/patch/message-space.svg +3 -3
  581. package/src/svg/menu/patch/message.svg +4 -4
  582. package/src/svg/menu/patch/minus-space.svg +3 -3
  583. package/src/svg/menu/patch/minus.svg +3 -3
  584. package/src/svg/menu/patch/mms-space.svg +3 -3
  585. package/src/svg/menu/patch/mms.svg +3 -3
  586. package/src/svg/menu/patch/monitor-space.svg +3 -3
  587. package/src/svg/menu/patch/monitor.svg +3 -3
  588. package/src/svg/menu/patch/move-space.svg +3 -3
  589. package/src/svg/menu/patch/move.svg +3 -3
  590. package/src/svg/menu/patch/negative-space.svg +2 -2
  591. package/src/svg/menu/patch/negative.svg +3 -3
  592. package/src/svg/menu/patch/net-space.svg +2 -2
  593. package/src/svg/menu/patch/net.svg +3 -3
  594. package/src/svg/menu/patch/news-space.svg +3 -3
  595. package/src/svg/menu/patch/news.svg +3 -3
  596. package/src/svg/menu/patch/notice-space.svg +4 -4
  597. package/src/svg/menu/patch/notice.svg +5 -5
  598. package/src/svg/menu/patch/officialBusiness-space.svg +3 -3
  599. package/src/svg/menu/patch/officialBusiness.svg +4 -4
  600. package/src/svg/menu/patch/pay-space.svg +3 -3
  601. package/src/svg/menu/patch/pay.svg +3 -3
  602. package/src/svg/menu/patch/phone-space.svg +3 -3
  603. package/src/svg/menu/patch/phone.svg +5 -5
  604. package/src/svg/menu/patch/print-space.svg +3 -3
  605. package/src/svg/menu/patch/print.svg +5 -5
  606. package/src/svg/menu/patch/product-space.svg +3 -3
  607. package/src/svg/menu/patch/product.svg +5 -5
  608. package/src/svg/menu/patch/reservation-space.svg +3 -3
  609. package/src/svg/menu/patch/reservation.svg +3 -3
  610. package/src/svg/menu/patch/sale-space.svg +3 -3
  611. package/src/svg/menu/patch/sale.svg +5 -5
  612. package/src/svg/menu/patch/search-space.svg +3 -3
  613. package/src/svg/menu/patch/search.svg +3 -3
  614. package/src/svg/menu/patch/secure-space.svg +3 -3
  615. package/src/svg/menu/patch/secure.svg +5 -5
  616. package/src/svg/menu/patch/setup-space.svg +3 -3
  617. package/src/svg/menu/patch/setup.svg +3 -3
  618. package/src/svg/menu/patch/shift-space.svg +3 -3
  619. package/src/svg/menu/patch/shift.svg +3 -3
  620. package/src/svg/menu/patch/situation-space.svg +3 -3
  621. package/src/svg/menu/patch/situation.svg +3 -3
  622. package/src/svg/menu/patch/special-space.svg +3 -3
  623. package/src/svg/menu/patch/special.svg +3 -3
  624. package/src/svg/menu/patch/tabulation-space.svg +3 -3
  625. package/src/svg/menu/patch/tabulation.svg +8 -8
  626. package/src/svg/menu/patch/track-space.svg +3 -3
  627. package/src/svg/menu/patch/track.svg +5 -5
  628. package/src/svg/menu/patch/transaction-space.svg +3 -3
  629. package/src/svg/menu/patch/transaction.svg +6 -6
  630. package/src/svg/menu/patch/user-space.svg +3 -3
  631. package/src/svg/menu/patch/user.svg +3 -3
  632. package/src/svg/menu/patch/visualize-space.svg +3 -3
  633. package/src/svg/menu/patch/visualize.svg +4 -4
  634. package/src/svg/menu/patch/vnet-space.svg +3 -3
  635. package/src/svg/menu/patch/vnet.svg +3 -3
  636. package/src/tip/tip.js +160 -160
  637. package/src/utils/after-leave.js +27 -27
  638. package/src/utils/ajax.js +59 -59
  639. package/src/utils/array.js +24 -24
  640. package/src/utils/clickoutside.js +105 -105
  641. package/src/utils/compare.js +16 -16
  642. package/src/utils/date.js +34 -34
  643. package/src/utils/disabledArea.js +18 -18
  644. package/src/utils/dom.js +301 -301
  645. package/src/utils/filetransfer.js +287 -287
  646. package/src/utils/isModified.js +20 -20
  647. package/src/utils/jsencrypt/JSEncrypt.js +192 -192
  648. package/src/utils/jsencrypt/JSEncryptRSAKey.js +320 -320
  649. package/src/utils/jsencrypt/index.js +3 -3
  650. package/src/utils/jsencrypt/jselib/asn1js/asn1.d.ts +51 -51
  651. package/src/utils/jsencrypt/jselib/asn1js/asn1.js +565 -565
  652. package/src/utils/jsencrypt/jselib/asn1js/base64.d.ts +5 -5
  653. package/src/utils/jsencrypt/jselib/asn1js/base64.js +88 -88
  654. package/src/utils/jsencrypt/jselib/asn1js/hex.d.ts +3 -3
  655. package/src/utils/jsencrypt/jselib/asn1js/hex.js +64 -64
  656. package/src/utils/jsencrypt/jselib/asn1js/int10.d.ts +9 -9
  657. package/src/utils/jsencrypt/jselib/asn1js/int10.js +87 -87
  658. package/src/utils/jsencrypt/jselib/asn1js/oids.d.ts +9778 -9778
  659. package/src/utils/jsencrypt/jselib/asn1js/oids.js +1962 -1962
  660. package/src/utils/jsencrypt/jselib/jsbn/base64.d.ts +3 -3
  661. package/src/utils/jsencrypt/jselib/jsbn/base64.js +76 -76
  662. package/src/utils/jsencrypt/jselib/jsbn/jsbn.d.ts +98 -98
  663. package/src/utils/jsencrypt/jselib/jsbn/jsbn.js +1754 -1754
  664. package/src/utils/jsencrypt/jselib/jsbn/prng4.d.ts +10 -10
  665. package/src/utils/jsencrypt/jselib/jsbn/prng4.js +46 -46
  666. package/src/utils/jsencrypt/jselib/jsbn/rng.d.ts +3 -3
  667. package/src/utils/jsencrypt/jselib/jsbn/rng.js +78 -78
  668. package/src/utils/jsencrypt/jselib/jsbn/rsa.d.ts +23 -23
  669. package/src/utils/jsencrypt/jselib/jsbn/rsa.js +373 -373
  670. package/src/utils/jsencrypt/jselib/jsbn/util.d.ts +7 -7
  671. package/src/utils/jsencrypt/jselib/jsbn/util.js +58 -58
  672. package/src/utils/jsencrypt/jselib/jsrsasign/asn1-1.0.js +1593 -1593
  673. package/src/utils/jsencrypt/jselib/jsrsasign/yahoo.js +63 -63
  674. package/src/utils/jsencrypt/util.js +58 -58
  675. package/src/utils/jsencrypt.js +263 -263
  676. package/src/utils/md5.js +203 -203
  677. package/src/utils/merge.js +15 -15
  678. package/src/utils/mime.js +75 -75
  679. package/src/utils/print.js +39 -39
  680. package/src/utils/ratio.js +230 -230
  681. package/src/utils/respo.js +9 -9
  682. package/src/utils/shared.js +7 -7
  683. package/src/utils/sign.js +185 -185
  684. package/src/utils/string.js +13 -13
  685. package/src/utils/theme.js +91 -91
  686. package/src/utils/types.js +40 -40
  687. package/src/utils/util.js +286 -286
  688. package/src/utils/uuid.js +12 -12
  689. package/src/utils/validate.js +373 -373
  690. package/packages/.DS_Store +0 -0
  691. package/packages/article/.DS_Store +0 -0
  692. package/packages/chat/.DS_Store +0 -0
  693. package/packages/chat/src/.DS_Store +0 -0
  694. package/packages/date-picker/.DS_Store +0 -0
  695. package/packages/dis/.DS_Store +0 -0
  696. package/packages/emote/.DS_Store +0 -0
  697. package/packages/filter/.DS_Store +0 -0
  698. package/packages/filter/src/.DS_Store +0 -0
  699. package/packages/float/.DS_Store +0 -0
  700. package/packages/flow/.DS_Store +0 -0
  701. package/packages/guider/.DS_Store +0 -0
  702. package/packages/ip/.DS_Store +0 -0
  703. package/packages/org/.DS_Store +0 -0
  704. package/packages/page/.DS_Store +0 -0
  705. package/packages/page/src/.DS_Store +0 -0
  706. package/packages/pic/.DS_Store +0 -0
  707. package/packages/rate/.DS_Store +0 -0
  708. package/packages/reverser/.DS_Store +0 -0
  709. package/packages/reverser/src/.DS_Store +0 -0
  710. package/packages/segment/.DS_Store +0 -0
  711. package/packages/slide/.DS_Store +0 -0
  712. package/packages/tab/.DS_Store +0 -0
  713. package/packages/table/.DS_Store +0 -0
  714. package/packages/theme/src/.DS_Store +0 -0
  715. package/packages/theme/src/img/.DS_Store +0 -0
  716. package/packages/theme/src/img/emote/.DS_Store +0 -0
  717. package/packages/theme/src/less/.DS_Store +0 -0
  718. package/packages/theme/src/less/theme/.DS_Store +0 -0
  719. package/packages/tooltip/.DS_Store +0 -0
  720. package/packages/tree/.DS_Store +0 -0
  721. package/packages/upload/.DS_Store +0 -0
  722. package/src/.DS_Store +0 -0
  723. package/src/svg/.DS_Store +0 -0
  724. package/src/svg/menu/.DS_Store +0 -0
@@ -1,1445 +1,1445 @@
1
- <template>
2
- <span :id="id" ref="link" v-tip="changed ? t('to.common.originalValue', getLabel(valueStore[0])) : ''" class="to-select" :class="setClass" :style="setStyle" :tabindex="inputable || filterable ? '-1' : tabindex" @mousedown="layerMousedown" @focus="focus" @blur="blur" @keyup.enter="enter" @keyup.esc="closeLayer">
3
- <span v-if="verifiable && (rule || required || ToFormItem.required)" v-show="false" :trim="trim" :req="validateRequired" class="to-validate" :desc="validateDesc" :rule="rule" :value="validateValue"></span>
4
- <span v-if="$slots.prefix" class="to-selectPrefix"><slot name="prefix"></slot></span>
5
- <span class="to-selectContent" :class="setContentClass" @click="click">
6
-
7
- <!-- 前缀文本/图标 -->
8
- <to-icon v-if="icon" v-bind="iconProps" :value="icon" mode="none" class="to-selectIcon"></to-icon>
9
- <span v-if="prefix" class="to-selectPrefixLabel">{{ prefix }}</span>
10
-
11
- <!-- 原生模式 -->
12
- <template v-if="native">
13
- <span class="to-selectValue">
14
- <select ref="selector" v-model="iValue">
15
- <option v-if="clearable" value="">{{ placeholder }}</option>
16
- <option v-for="(item, index) in options" :key="index" :value="item[iValueText]">{{ item[iLabelText] }}</option>
17
- </select>
18
- </span>
19
- </template>
20
-
21
- <!-- 模拟选项 -->
22
- <template v-else>
23
-
24
- <!-- 单选 -->
25
- <template v-if="!multiple">
26
- <span v-if="(!inputable && !filterable && !setDataFn) || $phone" class="to-selectValue">
27
- <template v-if="selected[iLabelText]">{{ selected[iLabelText] }}</template>
28
- <template v-else>{{ placeholder }}</template>
29
- </span>
30
- <span v-else class="to-selectInput">
31
- <to-input v-if="inputable && !filterable && !setDataFn" ref="input" v-model="inputValue" :sp-chars="spChars" :tabindex="tabindex" :clearable="clearable" prevent-focus width="full" mode="none" :placeholder="placeholder" @focus="inputFocus" @keyup="inputInput" @blur="inputBlur"></to-input>
32
- <to-input v-if="filterable" ref="filter" v-model="filterValue" :focus-when-clear="focusWhenClear" :sp-chars="inputable ? spChars : false" :tabindex="tabindex" :clearable="clearable" prevent-focus width="full" mode="none" :placeholder="placeholder" @clear="filterClear" @focus="filterFocus" @keyup="filterInput" @blur="filterBlur"></to-input>
33
- <to-input v-if="setDataFn" v-model="setDataInputValue" :sp-chars="inputable ? spChars : false" :tabindex="tabindex" :clearable="clearable" prevent-focus width="full" mode="none" :placeholder="placeholder" @clear="filterClear" @focus="filterFocus" @keyup="filterInput" @blur="filterBlur"></to-input>
34
- </span>
35
- </template>
36
-
37
- <!-- 多选 -->
38
- <template v-else>
39
- <span v-if="selected.filter(item => !item.hide).length === 0 && !inputable && !filterable && !setDataFn" class="to-selectValue">{{ placeholder }}</span>
40
- <span v-if="(isAll && useAllText)" v-color="allTextColor" class="to-selectValue">{{ allText }}</span>
41
- <span class="to-selectTag">
42
- <template v-if="selected.length > 0 && !(isAll && useAllText)">
43
- <template v-for="(item, index) in selected">
44
- <to-tag v-if="!item.hide" :key="index" color="fg" mode="plain" :deletable="!disabled" @delete="removeTag(item)">{{ item[iLabelText] }}</to-tag>
45
- </template>
46
- </template>
47
- <template v-if="!$phone || ($phone && selected.length === 0)">
48
- <to-input v-if="inputable && !filterable" ref="input" v-model="multipleInputValue" :sp-chars="spChars" :readonly="$phone" prevent-focus mode="none" :placeholder="selected.filter(item => !item.hide).length > 0 ? '' : placeholder " @focus="multipleInputFocus" @blur="multipleInputBlur"></to-input>
49
- <to-input v-if="filterable" ref="filter" v-model="multipleFilterValue" :sp-chars="inputable ? spChars : false" :readonly="$phone" prevent-focus mode="none" :placeholder="selected.filter(item => !item.hide).length > 0 ? '' : placeholder " @focus="multipleFilterFocus" @blur="multipleFilterBlur"></to-input>
50
- <to-input v-if="setDataFn" ref="filter" v-model="setDataInputValue" :sp-chars="inputable ? spChars : false" prevent-focus mode="none" :placeholder="selected.filter(item => !item.hide).length > 0 ? '' : placeholder " @focus="multipleFilterFocus" @blur="multipleFilterBlur"></to-input>
51
- </template>
52
- </span>
53
- </template>
54
-
55
- <!-- 箭头 -->
56
- <span v-if="arrowType === 'browse'" class="to-selectBrowse">
57
- <to-icon value="browse" color="primary" mode="none" :link="inputable || filterable"></to-icon>
58
- </span>
59
- <span v-else-if="arrowType === 'next'" class="to-selectArrow to-selectArrow-right"></span>
60
- <span v-else class="to-selectArrow"></span>
61
-
62
- </template>
63
-
64
- <!-- 后缀文本 -->
65
- <span v-if="suffix" class="to-selectSuffixLabel">{{ suffix }}</span>
66
-
67
- </span>
68
- <span v-if="$slots.suffix" class="to-selectSuffix"><slot name="suffix"></slot></span>
69
- <span v-if="errorTip" v-color="'danger'" class="to-box-tip">
70
- <template v-if="errorType === 'rule'">
71
- <template v-if="inputable">输入有误</template>
72
- <template v-else>选择有误</template>
73
- <to-icon v-tip.danger="errorTip" value="help" color="danger" mode="toast" fillet="round"></to-icon>
74
- </template>
75
- <template v-else>
76
- 不能为空
77
- </template>
78
- </span>
79
- <to-float v-if="optionDisplay !== 'none'" ref="layer" :align="optionAlign" class="to-selectLayer" :lazy="lazy" :slide="layerSlide" :width="iOptionWidth" :position="layerPosition" @closed="layerClose" @mousedown="layerMousedown">
80
-
81
- <to-padding v-if="dataLoading" v-align="'center'" :value="2">
82
- <to-icon value="loading"></to-icon>
83
- </to-padding>
84
-
85
- <template v-else>
86
-
87
- <slot :data="options">
88
- <to-grid v-if="(optionDisplay === 'popup' || ((inputable || filterable) && $phone))" height="full" type="v">
89
- <to-grid-item side>
90
- <to-header level="0" :title="validateDesc ? t('to.select.float.title', validateDesc) : t('to.select.float.titlePlaceholder', validateDesc)" @back="closeLayer()">
91
- <to-button fillet="normal" icon="close" mode="none" color="primary" @click="clear(); closeLayer();">{{ t('to.common.clear') }}</to-button>
92
- </to-header>
93
- <to-padding v-if="filterable || inputable" position="side">
94
- <template v-if="multiple">
95
- <template v-if="inputable">
96
- <span class="to-select to-select-arrow-none" style="width:100%;" :class="fillet === 'normal' ? 'to-input-fillet-normal' : ''">
97
- <span class="to-selectContent">
98
- <span class="to-selectTag">
99
- <template v-if="selected.length > 0 && !(isAll && useAllText)">
100
- <template v-for="(item, index) in selected">
101
- <to-tag v-if="!item.hide" :key="index" color="fg" mode="plain" :deletable="!disabled" @delete="removeTag(item)">{{ item[iLabelText] }}</to-tag>
102
- </template>
103
- </template>
104
- <to-input v-if="filterable" ref="popupFilter" v-model="multipleFilterValue" :sp-chars="spChars" prevent-focus mode="none" :placeholder="selected.filter(item => !item.hide).length > 0 ? '' : placeholder ">
105
- <to-button icon="ok" mode="none" color="primary" @click="enter"></to-button>
106
- </to-input>
107
- <to-input v-else ref="popupInput" v-model="multipleInputValue" prevent-focus mode="none" :placeholder="selected.filter(item => !item.hide).length > 0 ? '' : placeholder ">
108
- <to-button icon="ok" mode="none" color="primary" @click="enter"></to-button>
109
- </to-input>
110
- </span>
111
- </span>
112
- </span>
113
- </template>
114
- <to-input v-else ref="popupFilter" v-model="multipleFilterValue" :sp-chars="false" width="full" prevent-focus :placeholder="selected.filter(item => !item.hide).length > 0 ? '' : placeholder "></to-input>
115
- </template>
116
- <template v-else>
117
- <to-input v-if="inputable" ref="popupInput" v-model="inputValue" :sp-chars="spChars" prevent-focus width="full" :placeholder="placeholder"></to-input>
118
- <to-input v-else ref="popupFilter" v-model="filterValue" :sp-chars="false" prevent-focus width="full" placeholder="筛选" @clear="filterClear"></to-input>
119
- </template>
120
- </to-padding>
121
- </to-grid-item>
122
- <to-grid-item>
123
-
124
- <!-- 无数据 -->
125
- <to-padding v-if="nodata" v-color="'info'" :value="2">
126
- {{ nodataText }}
127
- </to-padding>
128
-
129
- <!-- 无匹配项 -->
130
- <to-padding v-else-if="nomatch" v-color="'info'" :value="2">
131
- {{ nomatchText }}
132
- </to-padding>
133
-
134
- <to-scroll v-if="!nodata && !nomatch">
135
- <to-padding :value="0.5">
136
-
137
- <!-- 多选 -->
138
- <template v-if="multiple">
139
- <to-padding :value="0.5">
140
- <to-button mode="text" color="primary" fillet="normal" @click="selectAll">{{ t('to.common.selectAll') }}</to-button>
141
- <to-button mode="text" color="primary" fillet="normal" @click="Deselect">{{ t('to.common.Deselect') }}</to-button>
142
- </to-padding>
143
- <to-grid :col="optionCol">
144
- <to-grid-item v-for="item in options" v-show="multipleFilter(item)" :key="item[iValueText]" v-dis="!!item.disabled">
145
- <to-checkbox :wrap="optionWrap" :title="item[iLabelText]" width="full" :label="item[iLabelText]" :readonly="!!item.disabled" :value="Boolean(selected.find(el => el[iValueText] === item[iValueText]))" @change="value => {return multipleItemChange(value, item)}"></to-checkbox>
146
- </to-grid-item>
147
- </to-grid>
148
- </template>
149
-
150
- <!-- 单选 -->
151
- <template v-else>
152
- <to-grid :col="optionCol">
153
- <to-grid-item v-for="item in options" v-show="filter(item)" :key="item[iValueText]">
154
- <to-card v-dis="!!item.disabled" :wrap="optionWrap" :title="optionWrap ? '' : item[iLabelText]" link :color="selected[iValueText] === item[iValueText] ? 'primary' : 'default'" @click.stop="itemChange(item)">
155
- <template v-if="item[iLabelText]">{{ item[iLabelText] }}</template>
156
- <template v-else>{{ placeholder }}</template>
157
- </to-card>
158
- </to-grid-item>
159
- </to-grid>
160
- </template>
161
-
162
- </to-padding>
163
- </to-scroll>
164
- </to-grid-item>
165
- <to-grid-item side>
166
- <to-submit width="full" space="0">
167
- <to-button v-size="'l'" fillet="none" color="primary" mode="line" @click="phoneCloseLayer(); iValue = '';">{{ t('to.common.clear') }}</to-button>
168
- <to-button v-size="'l'" mode="fill" color="primary" fillet="none" @click="phoneCloseLayer();">{{ t('to.common.confirm') }}</to-button>
169
- </to-submit>
170
- </to-grid-item>
171
- </to-grid>
172
- <template v-else>
173
-
174
- <!-- 无数据 -->
175
- <to-padding v-if="nodata" v-color="'info'" :value="2">
176
- {{ nodataText }}
177
- </to-padding>
178
-
179
- <!-- 无匹配项 -->
180
- <to-padding v-else-if="nomatch" v-color="'info'" :value="2">
181
- {{ nomatchText }}
182
- </to-padding>
183
-
184
- <to-scroll v-if="!nodata && !nomatch">
185
- <to-padding :value="0.5">
186
-
187
- <!-- 多选 -->
188
- <template v-if="multiple">
189
- <to-padding :value="0.5">
190
- <to-button mode="text" color="primary" fillet="normal" @click="selectAll">{{ t('to.common.selectAll') }}</to-button>
191
- <to-button mode="text" color="primary" fillet="normal" @click="Deselect">{{ t('to.common.Deselect') }}</to-button>
192
- </to-padding>
193
- <to-grid :col="optionCol">
194
- <to-grid-item v-for="item in options" v-show="multipleFilter(item)" :key="item[iValueText]" v-dis="!!item.disabled">
195
- <to-checkbox :wrap="optionWrap" :title="item[iLabelText]" width="full" :label="item[iLabelText]" :readonly="!!item.disabled" :value="Boolean(selected.find(el => el[iValueText] === item[iValueText]))" @change="value => {return multipleItemChange(value, item)}"></to-checkbox>
196
- </to-grid-item>
197
- </to-grid>
198
- </template>
199
-
200
- <!-- 单选 -->
201
- <template v-else>
202
- <to-grid :col="optionCol">
203
- <to-grid-item v-for="item in options" v-show="filter(item)" :key="item[iValueText]">
204
- <to-card v-dis="!!item.disabled" :wrap="optionWrap" :title="optionWrap ? '' : item[iLabelText]" link :color="selected[iValueText] === item[iValueText] ? 'primary' : 'default'" @click.stop="itemChange(item)">
205
- <template v-if="item[iLabelText]">{{ item[iLabelText] }}</template>
206
- <template v-else>{{ placeholder }}</template>
207
- </to-card>
208
- </to-grid-item>
209
- </to-grid>
210
- </template>
211
-
212
- </to-padding>
213
- </to-scroll>
214
-
215
- </template>
216
- </slot>
217
-
218
- </template>
219
-
220
- </to-float>
221
- </span>
222
- </template>
223
- <script>
224
- import ajax from 'ai.touchui-vue/src/utils/ajax'
225
- import { unique } from '../../../src/utils/array.js'
226
- import Locale from 'ai.touchui-vue/src/mixins/locale'
227
- import Tip from 'ai.touchui-vue/src/mixins/tip'
228
- import { t } from 'ai.touchui-vue/src/locale'
229
- export default {
230
- name: 'ToSelect',
231
- componentName: 'ToSelect',
232
- mixins: [Locale, Tip],
233
- model: {
234
- event: 'change'
235
- },
236
- inject: {
237
- ToForm: {
238
- default: ''
239
- },
240
- ToFormItem: {
241
- default: ''
242
- }
243
- },
244
- props: {
245
- lazy: {
246
- type: Boolean,
247
- default() {
248
- if (this.$TouchUI && this.$TouchUI.select && this.$TouchUI.select.lazy === false) {
249
- return false
250
- } else {
251
- return true
252
- }
253
- }
254
- },
255
-
256
- // 原生模式(性能极端低下情况下使用)
257
- native: {
258
- type: Boolean,
259
- default() {
260
- if (this.$TouchUI) {
261
- return this.$TouchUI.select.native
262
- } else {
263
- return false
264
- }
265
- }
266
- },
267
-
268
- // 表单校验
269
- desc: {
270
- type: String,
271
- default: ''
272
- },
273
- rule: {
274
- type: String,
275
- default: ''
276
- },
277
- id: {
278
- type: String,
279
- default: ''
280
- },
281
- required: Boolean,
282
-
283
- // 安全---------
284
- spChars: {
285
- type: [String, Boolean],
286
- default: '/,\\,[,],{,},"' // 微软拼音输入法使用单引号做上屏前多个字符分隔符,不能过滤单引号
287
- },
288
-
289
- // 基本功能
290
- splitSymbol: {
291
- type: String,
292
- default: ''
293
- },
294
- tabindex: {
295
- type: String,
296
- default: '1'
297
- },
298
- valueText: {
299
- type: String,
300
- default: 'value'
301
- },
302
- labelText: {
303
- type: String,
304
- default: 'label'
305
- },
306
- value: {
307
- type: [String, Number, Array],
308
- default: ''
309
- },
310
- data: {
311
- type: [Array, String],
312
- default: () => t('to.common.data')
313
- },
314
- placeholder: {
315
- type: String,
316
- default: () => t('to.common.placeholder.select')
317
- },
318
- placeholderColor: {
319
- type: String,
320
- default: ''
321
- },
322
- nomatchText: {
323
- type: String,
324
- default: () => t('to.common.noMatch')
325
- },
326
- nodataText: {
327
- type: String,
328
- default: () => t('to.common.noData')
329
- },
330
- readonly: Boolean, // 是否只读
331
- multiple: Boolean, // 是否多选
332
- filterable: Boolean, // 是否开启选项过滤
333
- inputable: Boolean, // 是否动态增加 options
334
- useAllText: Boolean,
335
- allText: {
336
- type: String,
337
- default: () => t('to.select.input.allSelected')
338
- },
339
- allTextColor: {
340
- type: String,
341
- default: 'primary'
342
- },
343
- clearable: {
344
- type: Boolean,
345
- default: true
346
- },
347
- // 外观设置
348
- color: {
349
- type: String,
350
- default: 'default'
351
- },
352
- mode: {
353
- type: String,
354
- default: ''
355
- },
356
- fillet: {
357
- type: String,
358
- default() {
359
- return this.$TouchUI.select.fillet || this.$TouchUI.global.fillet || 'normal'
360
- }
361
- },
362
- filletPosition: {
363
- type: String,
364
- default: ''
365
- },
366
- width: {
367
- type: [Number, String],
368
- default: ''
369
- },
370
- arrowType: {
371
- // browse / ''
372
- type: String,
373
- default: ''
374
- },
375
- // 选项设置
376
- optionWidth: {
377
- type: [Number, String],
378
- default: ''
379
- },
380
- optionDisplay: {
381
- // none / *float / popup
382
- type: [Number, String],
383
- default: ''
384
- },
385
- optionCol: {
386
- type: [Number, String],
387
- default: 1
388
- },
389
- optionWrap: Boolean,
390
- optionAlign: {
391
- type: String,
392
- default: 'left'
393
- },
394
- // 异步数据参数
395
- httpRequest: {
396
- type: Function,
397
- default: ajax
398
- },
399
- api: {
400
- type: String,
401
- default: ''
402
- },
403
- apiParam: {
404
- type: Object,
405
- default: null
406
- },
407
- apiHeaders: {
408
- type: Object,
409
- default: () => {}
410
- },
411
- apiLabel: {
412
- type: String,
413
- default: ''
414
- },
415
- resPath: {
416
- type: String,
417
- default: ''
418
- },
419
- errorPath: {
420
- type: String,
421
- default: ''
422
- },
423
- successCode: {
424
- type: String,
425
- default: '0'
426
- },
427
- // 远程异步数据设置
428
- setDataFn: {
429
- type: Function,
430
- default: null
431
- },
432
- // 插件
433
- prefix: {
434
- type: String,
435
- default: ''
436
- },
437
- suffix: {
438
- type: String,
439
- default: ''
440
- },
441
- icon: {
442
- type: String,
443
- default: ''
444
- },
445
- iconProps: {
446
- type: Object,
447
- default: ()=>{}
448
- },
449
- // 基本功能
450
- trim: {
451
- type: Boolean,
452
- default: true
453
- },
454
- closeSelection: {
455
- // 多选时,每次选择都关闭弹窗
456
- type: Boolean,
457
- default: false
458
- },
459
- verifiable: {
460
- type: Boolean,
461
- default: true
462
- },
463
- comparable: Boolean,
464
- setLabelFn: undefined, // 传入一个 Function 设置每一项的 label,return String,
465
- wrap: Boolean,
466
- focusWhenClear: {
467
- // filterable模式下清空数据是否弹出下拉框
468
- type: Boolean,
469
- default: false
470
- },
471
- beforeChange: {
472
- type: Function,
473
- default: null
474
- },
475
- valueType: {
476
- type: String,
477
- default: ''
478
- }
479
- },
480
- data() {
481
- return {
482
- isChanging: false,
483
- errorTip: '',
484
- errorType: 'rule',
485
- iValue: '',
486
- valueStore: [],
487
- dataLoading: false,
488
- selected: null,
489
- inited: false,
490
- multipleInputValue: '',
491
- multipleFilterValue: '',
492
- setDataInputValue: '',
493
- filterValue: '',
494
- inputValue: '',
495
- focused: false,
496
- blurByLayer: false,
497
- options: [],
498
- anotherOptions: [], // 只作用于手机端
499
- layerSlide: false,
500
- layerPosition: 'auto',
501
- disabled: this.readonly,
502
- iApiHeaders: {},
503
- inputing: false
504
- }
505
- },
506
- computed: {
507
- showTag() {
508
- return this.inputable || this.filterable || this.setDataFn || (this.selected.length > 0 && !(this.isAll && this.useAllText))
509
- },
510
- isAll() {
511
- let arr = []
512
- this.options.map(item => {
513
- arr.push(item[this.iValueText])
514
- })
515
- if (arr.sort().toString() === this.iValue.toString().split(',').sort().toString()) {
516
- return true
517
- } else {
518
- return false
519
- }
520
- },
521
- nomatch() {
522
- let nomatch = true
523
- let value = this.multiple ? this.multipleFilterValue : this.filterValue
524
- if (value === '' || this.options.findIndex(option=>option[this.iLabelText].includes(value)) > -1) {
525
- nomatch = false
526
- }
527
- return nomatch
528
- },
529
- nodata() {
530
- return this.options.length === 0
531
- },
532
- label() {
533
- if (this.selected[this.iLabelText]) {
534
- return this.selected[this.iLabelText]
535
- } else {
536
- return ''
537
- }
538
- },
539
- labels() {
540
- let arr = []
541
- this.selected.map(item=>{
542
- arr.push(item[this.iLabelText])
543
- })
544
- return arr
545
- },
546
- setClass() {
547
- let arr = ['to-form-readonly']
548
- if (this.fillet !== 'none') {
549
- arr.push(`to-input-fillet-${this.fillet}`);
550
- }
551
- if (this.filletPosition) {
552
- arr.push(`to-input-fillet-position-${this.filletPosition}`);
553
- }
554
- if (this.multiple) {
555
- if (this.selected.length === 0) {
556
- arr.push('to-select-placeholder')
557
- }
558
- } else {
559
- if (this.selected[this.iValueText] === '') {
560
- arr.push('to-select-placeholder')
561
- }
562
- }
563
- if (this.errorTip) {
564
- arr.push('to-select-mode-line');
565
- arr.push('to-box-mode-line');
566
- arr.push('to-select-color-danger');
567
- arr.push('to-box-color-danger');
568
- arr.push('to-select-tip-show')
569
- } else {
570
- if (this.color) {
571
- if (this.color !== 'radam') {
572
- arr.push(`to-select-color-${this.color}`);
573
- arr.push(`to-box-color-${this.color}`);
574
- } else {
575
- let colors = this.$TouchUI.colors
576
- let number = Math.round(Math.random() * 6)
577
- arr.push(`to-select-color-${ colors[number]}`);
578
- arr.push(`to-box-color-${ colors[number]}`);
579
- }
580
- }
581
- if (this.mode) {
582
- arr.push(`to-select-mode-${this.mode}`)
583
- arr.push(`to-box-mode-${this.mode}`)
584
- } else if (this.ToForm && this.ToForm.type === 'list') {
585
- arr.push('to-select-mode-none')
586
- arr.push('to-box-mode-none')
587
- } else {
588
- arr.push('to-select-mode-toast')
589
- arr.push('to-box-mode-toast')
590
- }
591
- }
592
- if (this.placeholderColor) {
593
- arr.push(`to-select-placeholder-color-${this.placeholderColor}`)
594
- }
595
- if (this.focused) {
596
- arr.push('to-select-state-focus')
597
- }
598
- if (this.disabled) {
599
- arr.push('to-select-state-readonly')
600
- }
601
- if (this.changed) {
602
- arr.push('to-select-changed')
603
- }
604
- if (this.wrap) {
605
- arr.push('to-select-wrap')
606
- }
607
- if (this.native) {
608
- arr.push('to-select-native')
609
- }
610
- if ((this.ToForm && this.ToForm.comparable) || this.comparable) {
611
- arr.push('to-compare')
612
- }
613
- return arr
614
- },
615
- setStyle() {
616
- var obj = {}
617
- if (this.width) {
618
- if (!isNaN(this.width)) {
619
- obj.width = this.width + 'em';
620
- } else if (this.width === 'full') {
621
- obj.width = '100%';
622
- } else {
623
- obj.width = this.width;
624
- }
625
- }
626
- return obj
627
- },
628
- setContentClass() {
629
- let arr = []
630
- if (!this.inputable && !this.setDataFn && !this.filterable) {
631
- arr.push('to-box-link')
632
- }
633
- if (this.color) {
634
- arr.push(`to-box-color-${this.color}`)
635
- } else if (this.mode === 'fill' || this.mode === 'line') {
636
- arr.push('to-box-color-primary')
637
- } else {
638
- arr.push('to-box-color-fg')
639
- }
640
- if (this.mode) {
641
- arr.push(`to-box-mode-${this.mode}`)
642
- } else if (this.ToForm && this.ToForm.type === 'list') {
643
- arr.push('to-box-mode-none')
644
- } else {
645
- arr.push('to-box-mode-toast')
646
- }
647
- return arr
648
- },
649
- validateRequired() {
650
- if (this.required) {
651
- return 'true'
652
- } else if (this.ToFormItem && this.ToFormItem.required) {
653
- return 'true'
654
- } else {
655
- return 'false'
656
- }
657
- },
658
- validateDesc() {
659
- if (this.desc) {
660
- return this.desc
661
- } else if (this.ToFormItem && this.ToFormItem.label) {
662
- return this.ToFormItem.label
663
- } else {
664
- return ''
665
- }
666
- },
667
- validateValue() {
668
- if (this.multiple) {
669
- if (this.selected.length > 0) {
670
- return 'true'
671
- } else {
672
- return ''
673
- }
674
- } else {
675
- return this.selected[this.iValueText]
676
- }
677
- },
678
- changed() {
679
- if ((this.comparable || this.ToForm.comparable) && this.valueStore.length > 0 && this.iValue !== this.valueStore[0]) {
680
- return true
681
- } else {
682
- return false
683
- }
684
- }
685
- },
686
- watch: {
687
- readonly(val) {
688
- this.disabled = val
689
- },
690
- multiple: {
691
- handler(val) {
692
- if (val) {
693
- this.selected = []
694
- } else {
695
- this.selected = {}
696
- }
697
- },
698
- immediate: true
699
- },
700
- selected(val) {
701
- this.adjustLayer()
702
- if (this.multiple) {
703
- let arr = []
704
- val.map(item => {
705
- arr.push(item[this.iValueText])
706
- })
707
- if (this.inited) {
708
- this.iValue = arr.join(this.splitSymbol || ',')
709
- }
710
- } else {
711
- if (this.inited) {
712
- this.isChanging = true // 避免同时给 inputable 的 input 设置 inputValue 的时候触发 change 事件
713
- this.iValue = val[this.iValueText]
714
- setTimeout(() => {
715
- this.isChanging = false
716
- }, 100);
717
- }
718
- }
719
- if (!this.inited) {
720
- if (Array.isArray(this.value)) {
721
- this.iValue = this.value.join(',')
722
- } else {
723
- this.iValue = this.value
724
- }
725
- this.$nextTick(()=>{
726
- this.inited = true
727
- })
728
- }
729
- },
730
- value: {
731
- handler(val) {
732
- if (Array.isArray(val)) {
733
- this.iValue = val.join(',')
734
- } else {
735
- this.iValue = val
736
- }
737
- },
738
- immediate: true
739
- },
740
- iValue(val) {
741
- this.setSeleted(val)
742
- if (this.inited) {
743
- if (this.multiple && this.valueType === 'array') {
744
- this.$emit('change', val ? val.split(',') : [], this.selected)
745
- } else {
746
- this.$emit('change', val, this.selected)
747
- }
748
-
749
- const detail = {
750
- name: 'ToSelect',
751
- value: val,
752
- desc: this.validateDesc,
753
- selected: this.selected
754
- }
755
- this.$TouchUI.commitTouchReport(detail)
756
-
757
- if (this.native) {
758
- this.$refs.selector.blur()
759
- }
760
- }
761
- this.valueChange(val)
762
- },
763
- filterValue(val) {
764
- if (this.inputable) {
765
- this.$nextTick(()=>{
766
- this.iValue = val
767
- })
768
- }
769
- },
770
- inputValue() {
771
- if (!this.isChanging) {
772
- this.iValue = this.inputValue
773
- }
774
- },
775
- setDataInputValue(val) {
776
- if (this.setDataFn) {
777
- this.setDataFn(val)
778
- }
779
- if (this.inputable) {
780
- this.$nextTick(()=>{
781
- this.iValue = val
782
- })
783
- }
784
- },
785
- data: {
786
- handler() {
787
- this.setOptions()
788
- this.valueChange(this.iValue)
789
- },
790
- deep: true
791
- },
792
- api() {
793
- this.setOptions()
794
- }
795
- },
796
- created() {
797
- this.iLabelText = this.labelText
798
- this.iValueText = this.valueText
799
- this.iResPath = this.resPath
800
- this.iSuccessCode = this.successCode
801
- this.iApiParam = this.apiParam
802
- this.iApiHeaders = this.apiHeaders
803
- this.iApiLabel = this.apiLabel
804
- this.iErrorPath = this.errorPath
805
- this.iOptionWidth = this.optionWidth
806
- this.setOptions()
807
- // 弹出模式
808
- if (this.$platform === 'phone') {
809
- this.layerSlide = true
810
- this.layerPosition = 'bottom'
811
- }
812
- if (this.optionDisplay === 'popup' || (this.$phone && (this.filterable || this.inputable))) {
813
- this.layerSlide = true
814
- this.layerPosition = 'right'
815
- if (!this.optionWidth) {
816
- this.iOptionWidth = '100%'
817
- }
818
- }
819
- },
820
- methods: {
821
- valueChange(val) {
822
- if (!this.multiple) {
823
- if (this.inputable) {
824
- this.inputValue = this.getLabel(val) || val
825
- }
826
- if (this.filterable && !this.inputable) {
827
- this.filterValue = this.getLabel(val) || ''
828
- }
829
- if (this.filterable && this.inputable) {
830
- this.filterValue = this.getLabel(val) || val
831
- }
832
- if (this.setDataFn && !this.inputable) {
833
- this.setDataInputValue = this.getLabel(val) || ''
834
- }
835
- if (this.setDataFn && this.inputable) {
836
- this.setDataInputValue = this.getLabel(val) || val
837
- }
838
- }
839
- },
840
- setSeleted(val) {
841
- let selected = JSON.parse(JSON.stringify(this.selected))
842
- if (!this.multiple) {
843
- if (this.options.findIndex(option=>option[this.iValueText] === val) === -1) {
844
- selected = {
845
- [this.iLabelText]: val,
846
- [this.iValueText]: val
847
- }
848
- } else {
849
- selected = this.options.find(option=>option[this.iValueText] === val)
850
- }
851
- } else {
852
- if (val === '') {
853
- selected = []
854
- } else {
855
- const arr = Array.isArray(val) ? unique(val) : unique(val.split(this.splitSymbol || ','))
856
- let selectedArr = []
857
- arr.map(item => {
858
- if (item && item.trim()) {
859
- if (this.options.findIndex(option=>String(option[this.iValueText]) === String(item)) === -1) {
860
- selectedArr.push({
861
- [this.iLabelText]: item,
862
- [this.iValueText]: item,
863
- hide: !this.inputable // 当输入一个不存在的值的时候,如果可自定义则显示,否则不显示
864
- })
865
- } else {
866
- this.options.map(option => {
867
- if (String(option[this.iValueText]) === String(item)) {
868
- selectedArr.push(option)
869
- }
870
- })
871
- }
872
- }
873
- })
874
- selected = selectedArr
875
- }
876
- }
877
- if (this.beforeChange) {
878
- const fn = this.beforeChange(selected)
879
- if (fn && fn.then) {
880
- fn.then(flag => {
881
- this.selected = selected
882
- }).catch((e)=>{})
883
- } else {
884
- if (fn) {
885
- this.selected = selected
886
- }
887
- }
888
- } else {
889
- this.selected = selected
890
- }
891
-
892
- },
893
- enter() {
894
- if (!(this.multiple && this.inputable)) {
895
- this.toggleLayer()
896
- } else {
897
- // 判断重复项
898
- let value = this.filterable ? this.multipleFilterValue : this.multipleInputValue
899
- if (
900
- this.selected.find(item => item[this.iLabelText] === value) ||
901
- this.selected.find(item => item[this.iValueText] === value)
902
- ) {
903
- this.$tip.error(this.t('to.select.tip.error.repetition'))
904
- return
905
- }
906
- // 判断空项
907
- if (!value.trim()) {
908
- return
909
- }
910
- const newOption = {
911
- [this.iLabelText]: value,
912
- [this.iValueText]: value
913
- }
914
- if (this.beforeChange) {
915
- const fn = this.beforeChange(newOption)
916
- if (fn && fn.then) {
917
- fn.then(flag => {
918
- this.selected.push(newOption)
919
- }).catch((e)=>{})
920
- } else {
921
- if (fn) {
922
- this.selected.push(newOption)
923
- }
924
- }
925
- } else {
926
- this.selected.push(newOption)
927
- }
928
- if (this.filterable) {
929
- this.multipleFilterValue = ''
930
- } else {
931
- this.multipleInputValue = ''
932
- }
933
- if (this.$phone) {
934
- if (this.filterable) {
935
- setTimeout(() => {
936
- this.$refs.popupFilter.focus()
937
- }, 500);
938
- } else {
939
- setTimeout(() => {
940
- this.$refs.popupInput.focus()
941
- }, 500);
942
- }
943
- }
944
- }
945
- },
946
- filter(item) {
947
- if (!this.inputing) {
948
- return true
949
- }
950
- if (this.filterable) {
951
- return item[this.iLabelText].includes(this.filterValue)
952
- } else {
953
- return true
954
- }
955
- },
956
- multipleFilter(item) {
957
- if (this.filterable) {
958
- return item[this.iLabelText].includes(this.multipleFilterValue)
959
- } else {
960
- return true
961
- }
962
- },
963
- getLabel(val) {
964
- let obj = this.options.find(item => item[this.iValueText] === val)
965
- if (obj && obj[this.iLabelText]) {
966
- return obj[this.iLabelText]
967
- }
968
- },
969
- setOptions() {
970
- // 同步选项
971
- if (this.data) {
972
- if (typeof this.data === 'string') {
973
- // 字符串模式传值(如::data="选项1, 选项2, 选项3")
974
- let arr = []
975
- for (let i = 0; i < this.data.split(',').length; i++) {
976
- const el = this.data.split(',')[i]
977
- let obj = {}
978
- obj[this.iLabelText] = obj[this.iValueText] = el
979
- arr.push(obj)
980
- }
981
- if (this.$phone && this.filterable) {
982
- this.options = arr.slice(0, 100)
983
- this.anotherOptions = arr.slice(100)
984
- } else {
985
- this.options = arr
986
- }
987
- } else {
988
- // 如果是手机端,则先取前 100 项,再拼接后面的
989
- if (this.$phone && this.filterable) {
990
- this.options = this.data.slice(0, 100)
991
- this.anotherOptions = this.data.slice(100)
992
- } else {
993
- // 对象数组模式传值
994
- this.options = [...this.data]
995
- }
996
- // 如果设置了方法,则替换为方法
997
- if (typeof this.setLabelFn === 'function') {
998
- this.options.forEach(item => {
999
- item.label = this.setLabelFn(item)
1000
- })
1001
- }
1002
- }
1003
-
1004
- // 设置 selected
1005
- this.setSeleted(this.value)
1006
- this.setPlaceholder()
1007
- }
1008
-
1009
- // 异步选项
1010
- if (this.api) {
1011
- // 通过配置自动设置 labelText 与 valueText
1012
- if (this.$TouchUI.staticDataApiConfig.labelText && this.labelText === 'label') {
1013
- this.iLabelText = this.$TouchUI.staticDataApiConfig.labelText
1014
- }
1015
- if (this.$TouchUI.staticDataApiConfig.valueText && this.valueText === 'value') {
1016
- this.iValueText = this.$TouchUI.staticDataApiConfig.valueText
1017
- }
1018
- if (this.$TouchUI.staticDataApiConfig.resPath && !this.resPath) {
1019
- this.iResPath = this.$TouchUI.staticDataApiConfig.resPath
1020
- }
1021
- if (this.$TouchUI.staticDataApiConfig.apiParam && !this.apiParam) {
1022
- this.iApiParam = this.$TouchUI.staticDataApiConfig.apiParam
1023
- }
1024
- if (this.$TouchUI.staticDataApiConfig.apiHeaders && !this.apiHeaders) {
1025
- this.iApiHeaders = this.$TouchUI.staticDataApiConfig.apiHeaders
1026
- }
1027
- if (this.$TouchUI.staticDataApiConfig.apiLabel && !this.apiLabel) {
1028
- this.iApiLabel = this.$TouchUI.staticDataApiConfig.apiLabel
1029
- }
1030
- if (this.$TouchUI.staticDataApiConfig.errorPath && !this.errorPath) {
1031
- this.iErrorPath = this.$TouchUI.staticDataApiConfig.errorPath
1032
- }
1033
- if (this.$TouchUI.staticDataApiConfig.resPath && !this.successCode) {
1034
- this.iSuccessCode = this.$TouchUI.staticDataApiConfig.successCode
1035
- }
1036
-
1037
- // 从缓存中取数据,如果没有则异步获取
1038
- if (sessionStorage.getItem('static.' + this.api)) {
1039
- this.options = JSON.parse(sessionStorage.getItem('static.' + this.api))
1040
-
1041
- // 设置 selected
1042
- this.setSeleted(this.value)
1043
- this.setPlaceholder()
1044
- this.$emit('option-loaded', this.options)
1045
-
1046
- } else {
1047
- let action = ''
1048
- if (this.iApiLabel && this.api) {
1049
- Object.assign(this.iApiParam, { [this.iApiLabel]: this.api })
1050
- }
1051
- if (this.api.indexOf('http') > -1) {
1052
- action = this.api
1053
- } else {
1054
- if (this.$TouchUI.staticDataApiConfig.action && this.$TouchUI.staticDataApiConfig.action.indexOf('=') > -1 && this.$TouchUI.staticDataApiConfig.action.indexOf('?') > -1) {
1055
- // 兼容 GET 格式的 POST 请求
1056
- action = this.$TouchUI.staticDataApiConfig.action + this.api
1057
- } else {
1058
- action = this.$TouchUI.staticDataApiConfig.action
1059
- }
1060
- }
1061
- const options = {
1062
- data: this.iApiParam,
1063
- action,
1064
- headers: Object.assign({}, this.iApiHeaders),
1065
- onSuccess: res => {
1066
- if (typeof res === 'string') {
1067
- res = JSON.parse(res)
1068
- }
1069
-
1070
- // 直接返回一个 select 所需要的 data 对象时,不需要任何解析
1071
- // 如:[{name:'张三', id:0},{name:'李四', id:1}]
1072
- if (Array.isArray(res)) {
1073
- this.options = res
1074
- sessionStorage.setItem('static.' + this.api, JSON.stringify(res))
1075
-
1076
- // 设置 selected
1077
- this.setSeleted(this.value)
1078
- this.setPlaceholder()
1079
- this.$emit('option-loaded', this.options)
1080
- } else if (res.code === this.iSuccessCode) {
1081
- // 按照 json 格式返回,需要根据配置路径进行解析
1082
- // 如:{ code:'0', data:[{name:'张三', id:0},{name:'李四', id:1}]}
1083
- let data = []
1084
- if (this.iResPath) {
1085
- let resPath = this.iResPath.split('/')
1086
- resPath.forEach(el => {
1087
- data = res[el]
1088
- })
1089
- }
1090
- this.options = data
1091
- sessionStorage.setItem('static.' + this.api, JSON.stringify(data))
1092
-
1093
- // 设置 selected
1094
- this.setSeleted(this.value)
1095
- this.setPlaceholder()
1096
- this.$emit('option-loaded', this.options)
1097
- } else {
1098
- this.options = []
1099
- this.t('to.select.tip.error.res', `select api(${this.api})`)
1100
- }
1101
- },
1102
- onError: res => {
1103
- this.$tip.danger(this.t('to.select.tip.error.api', `select api(${this.api}) `))
1104
- }
1105
- }
1106
- const req = this.httpRequest(options)
1107
- if (req && req.then) {
1108
- req.then(options.onSuccess, options.onError)
1109
- }
1110
- }
1111
- }
1112
- },
1113
- setPlaceholder() {
1114
- if (this.native) {
1115
- return
1116
- }
1117
- // 设置 placeholder
1118
- if (!this.multiple && this.clearable && !this.inputable && !this.setDataFn && !this.filterable && (!this.optionDisplay || this.optionDisplay === 'float')) {
1119
- this.options.unshift({})
1120
- this.$set(this.options, 0, {
1121
- [this.iLabelText]: '',
1122
- [this.iValueText]: ''
1123
- })
1124
- }
1125
- },
1126
- setValue(val) {
1127
- this.iValue = val
1128
- if (!this.multiple || this.closeSelection) {
1129
- this.closeLayer()
1130
- }
1131
- },
1132
- selectAll() {
1133
- let arr = []
1134
- this.options.map(item=>{
1135
- if (!item.disabled) {
1136
- arr.push(item[this.iValueText])
1137
- }
1138
- })
1139
- this.iValue = arr.toString()
1140
- },
1141
- Deselect() {
1142
- let arr = []
1143
- this.options.map(item=>{
1144
- if (!item.disabled && !this.iValue.split(',').includes(item[this.iValueText])) {
1145
- arr.push(item[this.iValueText])
1146
- }
1147
- })
1148
- this.iValue = arr.toString()
1149
- },
1150
- clear() {
1151
- this.setValue('')
1152
- },
1153
- itemChange(item) {
1154
- if (item.disabled) {
1155
- return
1156
- }
1157
- this.setSeleted(item[this.iValueText])
1158
- // this.selected = item
1159
- this.$nextTick(()=>{
1160
- this.$emit('selected', item)
1161
- this.closeLayer()
1162
- })
1163
- },
1164
- adjustLayer() {
1165
- if (this.optionDisplay !== 'none' && this.$refs.layer.show) {
1166
- this.$nextTick(()=>{
1167
- this.$refs.layer.set(this.$refs.link)
1168
- })
1169
- }
1170
- },
1171
- openLayer() {
1172
- if (!this.disabled && this.optionDisplay !== 'none') {
1173
- this.$refs.layer.open('link')
1174
- if (this.filterable && this.$phone) {
1175
- setTimeout(() => {
1176
- if (this.$refs.popupFilter) {
1177
- this.$refs.popupFilter.focus()
1178
- }
1179
- this.$nextTick(() => {
1180
- this.options = this.options.concat(this.anotherOptions)
1181
- })
1182
- }, 500);
1183
- }
1184
- if (this.inputable && this.$phone) {
1185
- setTimeout(() => {
1186
- if (this.$refs.popupInput) {
1187
- this.$refs.popupInput.focus()
1188
- }
1189
- }, 500);
1190
- }
1191
- }
1192
- },
1193
- closeLayer() {
1194
- if (!this.disabled && this.optionDisplay !== 'none') {
1195
- this.inputing = false
1196
- this.phoneCloseLayer()
1197
- }
1198
- },
1199
- phoneCloseLayer() {
1200
- this.$refs.layer.close()
1201
- if (this.filterable && this.$phone) {
1202
- this.options = this.options.slice(0, 100)
1203
- }
1204
- },
1205
- toggleLayer() {
1206
- if (this.$refs.layer) {
1207
- if (this.$refs.layer.show) {
1208
- this.closeLayer()
1209
- } else {
1210
- this.openLayer()
1211
- }
1212
- }
1213
- },
1214
- click() {
1215
- if (!this.native) {
1216
- this.toggleLayer()
1217
- }
1218
- this.$emit('click')
1219
- },
1220
- layerClose() {
1221
- if (!this.multiple) {
1222
- if (this.filterable && !this.inputable) {
1223
- if (this.iValue) {
1224
- const label = this.getLabel(this.iValue)
1225
- if (label) {
1226
- this.filterValue = label
1227
- } else {
1228
- this.filterValue = ''
1229
- }
1230
- } else {
1231
- this.filterValue = ''
1232
- }
1233
- }
1234
- } else {
1235
- if (this.inputable) {
1236
- this.multipleInputValue = ''
1237
- }
1238
- if (this.filterable) {
1239
- this.multipleFilterValue = ''
1240
- }
1241
- }
1242
- },
1243
- layerMousedown() {
1244
- this.blurByLayer = true
1245
- let timer = null
1246
- timer = setTimeout(() => {
1247
- this.blurByLayer = false
1248
- clearTimeout(timer)
1249
- timer = null
1250
- }, 200);
1251
- },
1252
- focus() {
1253
- this.errorTip = ''
1254
- this.focused = true
1255
- },
1256
- blur() {
1257
- this.focused = false
1258
- if (!this.blurByLayer && !this.$phone) {
1259
- this.closeLayer()
1260
- }
1261
- },
1262
- inputBlur() {
1263
- this.focused = false
1264
- if (!this.blurByLayer && !this.$phone) {
1265
- this.closeLayer()
1266
- }
1267
- },
1268
- inputFocus() {
1269
- this.focused = true
1270
- if (this.value === '') {
1271
- this.openLayer()
1272
- }
1273
- },
1274
- inputInput(e) {
1275
- if (e && e.keyCode === 13) {
1276
- this.$emit('inputEnter')
1277
- }
1278
- this.$nextTick(()=>{
1279
- if (this.value === '') {
1280
- this.openLayer()
1281
- } else {
1282
- this.closeLayer()
1283
- }
1284
- })
1285
- },
1286
- filterBlur() {
1287
- this.focused = false
1288
- if (!this.blurByLayer && !this.$phone) {
1289
- this.closeLayer()
1290
- }
1291
- },
1292
- filterFocus() {
1293
- this.focused = true
1294
- this.openLayer()
1295
- },
1296
- filterInput(e) {
1297
- if (e && e.keyCode === 13) {
1298
- this.$emit('inputEnter')
1299
- }
1300
- this.$nextTick(()=>{
1301
- this.inputing = true
1302
- this.adjustLayer()
1303
- this.openLayer()
1304
- })
1305
- },
1306
- filterClear() {
1307
- this.iValue = ''
1308
- },
1309
- multipleInputBlur() {
1310
- this.focused = false
1311
- if (!this.blurByLayer && !this.$phone) {
1312
- this.closeLayer()
1313
- }
1314
- },
1315
- multipleInputFocus() {
1316
- this.focused = true
1317
- if (this.value === '') {
1318
- this.openLayer()
1319
- }
1320
- },
1321
- multipleItemChange(value, item) {
1322
- let val = this.selected.map(option => option[this.iValueText])
1323
- if (value) {
1324
- val.push(item[this.iValueText])
1325
- this.setSeleted(val.join(','))
1326
- } else {
1327
- this.removeItem(val, item[this.iValueText])
1328
- this.setSeleted(val.join(','))
1329
- }
1330
- if (this.inputable && !this.filterable) {
1331
- if (this.$phone) {
1332
- setTimeout(() => {
1333
- this.$refs.popupInput.focus()
1334
- }, 500);
1335
- } else {
1336
- setTimeout(() => {
1337
- this.$refs.input.focus()
1338
- }, 500);
1339
- }
1340
- this.multipleInputValue = ''
1341
- }
1342
- if (this.filterable) {
1343
- if (this.$phone) {
1344
- setTimeout(() => {
1345
- this.$refs.popupFilter.focus()
1346
- }, 500);
1347
- } else {
1348
- setTimeout(() => {
1349
- this.$refs.filter.focus()
1350
- }, 500);
1351
- }
1352
- this.multipleFilterValue = ''
1353
- }
1354
- if (this.setDataFn) {
1355
- setTimeout(() => {
1356
- this.$refs.filter.focus()
1357
- }, 500);
1358
- this.setDataInputValue = ''
1359
- }
1360
- },
1361
- removeTag(item) {
1362
- let val = this.selected.map(option => option[this.iValueText])
1363
- this.removeItem(val, item[this.iValueText])
1364
- this.setSeleted(val.join(','))
1365
- if (this.inputable) {
1366
- if (this.$phone) {
1367
- if (this.filterable) {
1368
- if (this.$refs.popupFilter) {
1369
- setTimeout(() => {
1370
- this.$refs.popupFilter.focus()
1371
- }, 500);
1372
- }
1373
- } else {
1374
- if (this.$refs.popupInput) {
1375
- setTimeout(() => {
1376
- this.$refs.popupInput.focus()
1377
- }, 500);
1378
- }
1379
- }
1380
- } else {
1381
- if (this.filterable) {
1382
- setTimeout(() => {
1383
- this.$refs.filter.focus()
1384
- }, 500);
1385
- } else {
1386
- setTimeout(() => {
1387
- this.$refs.input.focus()
1388
- }, 500);
1389
- }
1390
- }
1391
- }
1392
- },
1393
- multipleFilterBlur() {
1394
- this.focused = false
1395
- if (!this.blurByLayer && !this.$phone) {
1396
- this.closeLayer()
1397
- }
1398
- },
1399
- multipleFilterFocus() {
1400
- this.focused = true
1401
- if (this.value === '') {
1402
- this.openLayer()
1403
- }
1404
- },
1405
- removeItem(obj, val) {
1406
- let index
1407
-
1408
- // 字符串
1409
- if (typeof obj === 'string') {
1410
- let arr = obj.split(',')
1411
- index = arr.findIndex(item=>item === val)
1412
- obj = arr.join(',')
1413
- }
1414
-
1415
- // 字符串数组
1416
- else if (Array.isArray(obj) && typeof obj[0] === 'string') {
1417
- index = obj.findIndex(item=>item === val)
1418
- obj.splice(index, 1)
1419
- }
1420
-
1421
- // 对象数组
1422
- else {
1423
- index = obj.findIndex(item=>item[this.iValueText] === val)
1424
- obj.splice(index, 1)
1425
- }
1426
- },
1427
- setDataLoading(val) {
1428
- this.dataLoading = val
1429
- },
1430
-
1431
- // 记录历史值,以便对比或者取值
1432
- compare() {
1433
- this.valueStore.unshift(this.iValue)
1434
- },
1435
- setDisabled(f) {
1436
- this.disabled = f
1437
- },
1438
- // 撤销
1439
- restore() {
1440
- this.data = this.valueStore[0]
1441
- this.valueStore.splice(0, 1)
1442
- }
1443
- }
1444
- }
1445
- </script>
1
+ <template>
2
+ <span :id="id" ref="link" v-tip="changed ? t('to.common.originalValue', getLabel(valueStore[0])) : ''" class="to-select" :class="setClass" :style="setStyle" :tabindex="inputable || filterable ? '-1' : tabindex" @mousedown="layerMousedown" @focus="focus" @blur="blur" @keyup.enter="enter" @keyup.esc="closeLayer">
3
+ <span v-if="verifiable && (rule || required || ToFormItem.required)" v-show="false" :trim="trim" :req="validateRequired" class="to-validate" :desc="validateDesc" :rule="rule" :value="validateValue"></span>
4
+ <span v-if="$slots.prefix" class="to-selectPrefix"><slot name="prefix"></slot></span>
5
+ <span class="to-selectContent" :class="setContentClass" @click="click">
6
+
7
+ <!-- 前缀文本/图标 -->
8
+ <to-icon v-if="icon" v-bind="iconProps" :value="icon" mode="none" class="to-selectIcon"></to-icon>
9
+ <span v-if="prefix" class="to-selectPrefixLabel">{{ prefix }}</span>
10
+
11
+ <!-- 原生模式 -->
12
+ <template v-if="native">
13
+ <span class="to-selectValue">
14
+ <select ref="selector" v-model="iValue">
15
+ <option v-if="clearable" value="">{{ placeholder }}</option>
16
+ <option v-for="(item, index) in options" :key="index" :value="item[iValueText]">{{ item[iLabelText] }}</option>
17
+ </select>
18
+ </span>
19
+ </template>
20
+
21
+ <!-- 模拟选项 -->
22
+ <template v-else>
23
+
24
+ <!-- 单选 -->
25
+ <template v-if="!multiple">
26
+ <span v-if="(!inputable && !filterable && !setDataFn) || $phone" class="to-selectValue">
27
+ <template v-if="selected[iLabelText]">{{ selected[iLabelText] }}</template>
28
+ <template v-else>{{ placeholder }}</template>
29
+ </span>
30
+ <span v-else class="to-selectInput">
31
+ <to-input v-if="inputable && !filterable && !setDataFn" ref="input" v-model="inputValue" :sp-chars="spChars" :tabindex="tabindex" :clearable="clearable" prevent-focus width="full" mode="none" :placeholder="placeholder" @focus="inputFocus" @keyup="inputInput" @blur="inputBlur"></to-input>
32
+ <to-input v-if="filterable" ref="filter" v-model="filterValue" :focus-when-clear="focusWhenClear" :sp-chars="inputable ? spChars : false" :tabindex="tabindex" :clearable="clearable" prevent-focus width="full" mode="none" :placeholder="placeholder" @clear="filterClear" @focus="filterFocus" @keyup="filterInput" @blur="filterBlur"></to-input>
33
+ <to-input v-if="setDataFn" v-model="setDataInputValue" :sp-chars="inputable ? spChars : false" :tabindex="tabindex" :clearable="clearable" prevent-focus width="full" mode="none" :placeholder="placeholder" @clear="filterClear" @focus="filterFocus" @keyup="filterInput" @blur="filterBlur"></to-input>
34
+ </span>
35
+ </template>
36
+
37
+ <!-- 多选 -->
38
+ <template v-else>
39
+ <span v-if="selected.filter(item => !item.hide).length === 0 && !inputable && !filterable && !setDataFn" class="to-selectValue">{{ placeholder }}</span>
40
+ <span v-if="(isAll && useAllText)" v-color="allTextColor" class="to-selectValue">{{ allText }}</span>
41
+ <span class="to-selectTag">
42
+ <template v-if="selected.length > 0 && !(isAll && useAllText)">
43
+ <template v-for="(item, index) in selected">
44
+ <to-tag v-if="!item.hide" :key="index" color="fg" mode="plain" :deletable="!disabled" @delete="removeTag(item)">{{ item[iLabelText] }}</to-tag>
45
+ </template>
46
+ </template>
47
+ <template v-if="!$phone || ($phone && selected.length === 0)">
48
+ <to-input v-if="inputable && !filterable" ref="input" v-model="multipleInputValue" :sp-chars="spChars" :readonly="$phone" prevent-focus mode="none" :placeholder="selected.filter(item => !item.hide).length > 0 ? '' : placeholder " @focus="multipleInputFocus" @blur="multipleInputBlur"></to-input>
49
+ <to-input v-if="filterable" ref="filter" v-model="multipleFilterValue" :sp-chars="inputable ? spChars : false" :readonly="$phone" prevent-focus mode="none" :placeholder="selected.filter(item => !item.hide).length > 0 ? '' : placeholder " @focus="multipleFilterFocus" @blur="multipleFilterBlur"></to-input>
50
+ <to-input v-if="setDataFn" ref="filter" v-model="setDataInputValue" :sp-chars="inputable ? spChars : false" prevent-focus mode="none" :placeholder="selected.filter(item => !item.hide).length > 0 ? '' : placeholder " @focus="multipleFilterFocus" @blur="multipleFilterBlur"></to-input>
51
+ </template>
52
+ </span>
53
+ </template>
54
+
55
+ <!-- 箭头 -->
56
+ <span v-if="arrowType === 'browse'" class="to-selectBrowse">
57
+ <to-icon value="browse" color="primary" mode="none" :link="inputable || filterable"></to-icon>
58
+ </span>
59
+ <span v-else-if="arrowType === 'next'" class="to-selectArrow to-selectArrow-right"></span>
60
+ <span v-else class="to-selectArrow"></span>
61
+
62
+ </template>
63
+
64
+ <!-- 后缀文本 -->
65
+ <span v-if="suffix" class="to-selectSuffixLabel">{{ suffix }}</span>
66
+
67
+ </span>
68
+ <span v-if="$slots.suffix" class="to-selectSuffix"><slot name="suffix"></slot></span>
69
+ <span v-if="errorTip" v-color="'danger'" class="to-box-tip">
70
+ <template v-if="errorType === 'rule'">
71
+ <template v-if="inputable">输入有误</template>
72
+ <template v-else>选择有误</template>
73
+ <to-icon v-tip.danger="errorTip" value="help" color="danger" mode="toast" fillet="round"></to-icon>
74
+ </template>
75
+ <template v-else>
76
+ 不能为空
77
+ </template>
78
+ </span>
79
+ <to-float v-if="optionDisplay !== 'none'" ref="layer" :align="optionAlign" class="to-selectLayer" :lazy="lazy" :slide="layerSlide" :width="iOptionWidth" :position="layerPosition" @closed="layerClose" @mousedown="layerMousedown">
80
+
81
+ <to-padding v-if="dataLoading" v-align="'center'" :value="2">
82
+ <to-icon value="loading"></to-icon>
83
+ </to-padding>
84
+
85
+ <template v-else>
86
+
87
+ <slot :data="options">
88
+ <to-grid v-if="(optionDisplay === 'popup' || ((inputable || filterable) && $phone))" height="full" type="v">
89
+ <to-grid-item side>
90
+ <to-header level="0" :title="validateDesc ? t('to.select.float.title', validateDesc) : t('to.select.float.titlePlaceholder', validateDesc)" @back="closeLayer()">
91
+ <to-button fillet="normal" icon="close" mode="none" color="primary" @click="clear(); closeLayer();">{{ t('to.common.clear') }}</to-button>
92
+ </to-header>
93
+ <to-padding v-if="filterable || inputable" position="side">
94
+ <template v-if="multiple">
95
+ <template v-if="inputable">
96
+ <span class="to-select to-select-arrow-none" style="width:100%;" :class="fillet === 'normal' ? 'to-input-fillet-normal' : ''">
97
+ <span class="to-selectContent">
98
+ <span class="to-selectTag">
99
+ <template v-if="selected.length > 0 && !(isAll && useAllText)">
100
+ <template v-for="(item, index) in selected">
101
+ <to-tag v-if="!item.hide" :key="index" color="fg" mode="plain" :deletable="!disabled" @delete="removeTag(item)">{{ item[iLabelText] }}</to-tag>
102
+ </template>
103
+ </template>
104
+ <to-input v-if="filterable" ref="popupFilter" v-model="multipleFilterValue" :sp-chars="spChars" prevent-focus mode="none" :placeholder="selected.filter(item => !item.hide).length > 0 ? '' : placeholder ">
105
+ <to-button icon="ok" mode="none" color="primary" @click="enter"></to-button>
106
+ </to-input>
107
+ <to-input v-else ref="popupInput" v-model="multipleInputValue" prevent-focus mode="none" :placeholder="selected.filter(item => !item.hide).length > 0 ? '' : placeholder ">
108
+ <to-button icon="ok" mode="none" color="primary" @click="enter"></to-button>
109
+ </to-input>
110
+ </span>
111
+ </span>
112
+ </span>
113
+ </template>
114
+ <to-input v-else ref="popupFilter" v-model="multipleFilterValue" :sp-chars="false" width="full" prevent-focus :placeholder="selected.filter(item => !item.hide).length > 0 ? '' : placeholder "></to-input>
115
+ </template>
116
+ <template v-else>
117
+ <to-input v-if="inputable" ref="popupInput" v-model="inputValue" :sp-chars="spChars" prevent-focus width="full" :placeholder="placeholder"></to-input>
118
+ <to-input v-else ref="popupFilter" v-model="filterValue" :sp-chars="false" prevent-focus width="full" placeholder="筛选" @clear="filterClear"></to-input>
119
+ </template>
120
+ </to-padding>
121
+ </to-grid-item>
122
+ <to-grid-item>
123
+
124
+ <!-- 无数据 -->
125
+ <to-padding v-if="nodata" v-color="'info'" :value="2">
126
+ {{ nodataText }}
127
+ </to-padding>
128
+
129
+ <!-- 无匹配项 -->
130
+ <to-padding v-else-if="nomatch" v-color="'info'" :value="2">
131
+ {{ nomatchText }}
132
+ </to-padding>
133
+
134
+ <to-scroll v-if="!nodata && !nomatch">
135
+ <to-padding :value="0.5">
136
+
137
+ <!-- 多选 -->
138
+ <template v-if="multiple">
139
+ <to-padding :value="0.5">
140
+ <to-button mode="text" color="primary" fillet="normal" @click="selectAll">{{ t('to.common.selectAll') }}</to-button>
141
+ <to-button mode="text" color="primary" fillet="normal" @click="Deselect">{{ t('to.common.Deselect') }}</to-button>
142
+ </to-padding>
143
+ <to-grid :col="optionCol">
144
+ <to-grid-item v-for="item in options" v-show="multipleFilter(item)" :key="item[iValueText]" v-dis="!!item.disabled">
145
+ <to-checkbox :wrap="optionWrap" :title="item[iLabelText]" width="full" :label="item[iLabelText]" :readonly="!!item.disabled" :value="Boolean(selected.find(el => el[iValueText] === item[iValueText]))" @change="value => {return multipleItemChange(value, item)}"></to-checkbox>
146
+ </to-grid-item>
147
+ </to-grid>
148
+ </template>
149
+
150
+ <!-- 单选 -->
151
+ <template v-else>
152
+ <to-grid :col="optionCol">
153
+ <to-grid-item v-for="item in options" v-show="filter(item)" :key="item[iValueText]">
154
+ <to-card v-dis="!!item.disabled" :wrap="optionWrap" :title="optionWrap ? '' : item[iLabelText]" link :color="selected[iValueText] === item[iValueText] ? 'primary' : 'default'" @click.stop="itemChange(item)">
155
+ <template v-if="item[iLabelText]">{{ item[iLabelText] }}</template>
156
+ <template v-else>{{ placeholder }}</template>
157
+ </to-card>
158
+ </to-grid-item>
159
+ </to-grid>
160
+ </template>
161
+
162
+ </to-padding>
163
+ </to-scroll>
164
+ </to-grid-item>
165
+ <to-grid-item side>
166
+ <to-submit width="full" space="0">
167
+ <to-button v-size="'l'" fillet="none" color="primary" mode="line" @click="phoneCloseLayer(); iValue = '';">{{ t('to.common.clear') }}</to-button>
168
+ <to-button v-size="'l'" mode="fill" color="primary" fillet="none" @click="phoneCloseLayer();">{{ t('to.common.confirm') }}</to-button>
169
+ </to-submit>
170
+ </to-grid-item>
171
+ </to-grid>
172
+ <template v-else>
173
+
174
+ <!-- 无数据 -->
175
+ <to-padding v-if="nodata" v-color="'info'" :value="2">
176
+ {{ nodataText }}
177
+ </to-padding>
178
+
179
+ <!-- 无匹配项 -->
180
+ <to-padding v-else-if="nomatch" v-color="'info'" :value="2">
181
+ {{ nomatchText }}
182
+ </to-padding>
183
+
184
+ <to-scroll v-if="!nodata && !nomatch">
185
+ <to-padding :value="0.5">
186
+
187
+ <!-- 多选 -->
188
+ <template v-if="multiple">
189
+ <to-padding :value="0.5">
190
+ <to-button mode="text" color="primary" fillet="normal" @click="selectAll">{{ t('to.common.selectAll') }}</to-button>
191
+ <to-button mode="text" color="primary" fillet="normal" @click="Deselect">{{ t('to.common.Deselect') }}</to-button>
192
+ </to-padding>
193
+ <to-grid :col="optionCol">
194
+ <to-grid-item v-for="item in options" v-show="multipleFilter(item)" :key="item[iValueText]" v-dis="!!item.disabled">
195
+ <to-checkbox :wrap="optionWrap" :title="item[iLabelText]" width="full" :label="item[iLabelText]" :readonly="!!item.disabled" :value="Boolean(selected.find(el => el[iValueText] === item[iValueText]))" @change="value => {return multipleItemChange(value, item)}"></to-checkbox>
196
+ </to-grid-item>
197
+ </to-grid>
198
+ </template>
199
+
200
+ <!-- 单选 -->
201
+ <template v-else>
202
+ <to-grid :col="optionCol">
203
+ <to-grid-item v-for="item in options" v-show="filter(item)" :key="item[iValueText]">
204
+ <to-card v-dis="!!item.disabled" :wrap="optionWrap" :title="optionWrap ? '' : item[iLabelText]" link :color="selected[iValueText] === item[iValueText] ? 'primary' : 'default'" @click.stop="itemChange(item)">
205
+ <template v-if="item[iLabelText]">{{ item[iLabelText] }}</template>
206
+ <template v-else>{{ placeholder }}</template>
207
+ </to-card>
208
+ </to-grid-item>
209
+ </to-grid>
210
+ </template>
211
+
212
+ </to-padding>
213
+ </to-scroll>
214
+
215
+ </template>
216
+ </slot>
217
+
218
+ </template>
219
+
220
+ </to-float>
221
+ </span>
222
+ </template>
223
+ <script>
224
+ import ajax from 'ai.touchui-vue/src/utils/ajax'
225
+ import { unique } from '../../../src/utils/array.js'
226
+ import Locale from 'ai.touchui-vue/src/mixins/locale'
227
+ import Tip from 'ai.touchui-vue/src/mixins/tip'
228
+ import { t } from 'ai.touchui-vue/src/locale'
229
+ export default {
230
+ name: 'ToSelect',
231
+ componentName: 'ToSelect',
232
+ mixins: [Locale, Tip],
233
+ model: {
234
+ event: 'change'
235
+ },
236
+ inject: {
237
+ ToForm: {
238
+ default: ''
239
+ },
240
+ ToFormItem: {
241
+ default: ''
242
+ }
243
+ },
244
+ props: {
245
+ lazy: {
246
+ type: Boolean,
247
+ default() {
248
+ if (this.$TouchUI && this.$TouchUI.select && this.$TouchUI.select.lazy === false) {
249
+ return false
250
+ } else {
251
+ return true
252
+ }
253
+ }
254
+ },
255
+
256
+ // 原生模式(性能极端低下情况下使用)
257
+ native: {
258
+ type: Boolean,
259
+ default() {
260
+ if (this.$TouchUI) {
261
+ return this.$TouchUI.select.native
262
+ } else {
263
+ return false
264
+ }
265
+ }
266
+ },
267
+
268
+ // 表单校验
269
+ desc: {
270
+ type: String,
271
+ default: ''
272
+ },
273
+ rule: {
274
+ type: String,
275
+ default: ''
276
+ },
277
+ id: {
278
+ type: String,
279
+ default: ''
280
+ },
281
+ required: Boolean,
282
+
283
+ // 安全---------
284
+ spChars: {
285
+ type: [String, Boolean],
286
+ default: '/,\\,[,],{,},"' // 微软拼音输入法使用单引号做上屏前多个字符分隔符,不能过滤单引号
287
+ },
288
+
289
+ // 基本功能
290
+ splitSymbol: {
291
+ type: String,
292
+ default: ''
293
+ },
294
+ tabindex: {
295
+ type: String,
296
+ default: '1'
297
+ },
298
+ valueText: {
299
+ type: String,
300
+ default: 'value'
301
+ },
302
+ labelText: {
303
+ type: String,
304
+ default: 'label'
305
+ },
306
+ value: {
307
+ type: [String, Number, Array],
308
+ default: ''
309
+ },
310
+ data: {
311
+ type: [Array, String],
312
+ default: () => t('to.common.data')
313
+ },
314
+ placeholder: {
315
+ type: String,
316
+ default: () => t('to.common.placeholder.select')
317
+ },
318
+ placeholderColor: {
319
+ type: String,
320
+ default: ''
321
+ },
322
+ nomatchText: {
323
+ type: String,
324
+ default: () => t('to.common.noMatch')
325
+ },
326
+ nodataText: {
327
+ type: String,
328
+ default: () => t('to.common.noData')
329
+ },
330
+ readonly: Boolean, // 是否只读
331
+ multiple: Boolean, // 是否多选
332
+ filterable: Boolean, // 是否开启选项过滤
333
+ inputable: Boolean, // 是否动态增加 options
334
+ useAllText: Boolean,
335
+ allText: {
336
+ type: String,
337
+ default: () => t('to.select.input.allSelected')
338
+ },
339
+ allTextColor: {
340
+ type: String,
341
+ default: 'primary'
342
+ },
343
+ clearable: {
344
+ type: Boolean,
345
+ default: true
346
+ },
347
+ // 外观设置
348
+ color: {
349
+ type: String,
350
+ default: 'default'
351
+ },
352
+ mode: {
353
+ type: String,
354
+ default: ''
355
+ },
356
+ fillet: {
357
+ type: String,
358
+ default() {
359
+ return this.$TouchUI.select.fillet || this.$TouchUI.global.fillet || 'normal'
360
+ }
361
+ },
362
+ filletPosition: {
363
+ type: String,
364
+ default: ''
365
+ },
366
+ width: {
367
+ type: [Number, String],
368
+ default: ''
369
+ },
370
+ arrowType: {
371
+ // browse / ''
372
+ type: String,
373
+ default: ''
374
+ },
375
+ // 选项设置
376
+ optionWidth: {
377
+ type: [Number, String],
378
+ default: ''
379
+ },
380
+ optionDisplay: {
381
+ // none / *float / popup
382
+ type: [Number, String],
383
+ default: ''
384
+ },
385
+ optionCol: {
386
+ type: [Number, String],
387
+ default: 1
388
+ },
389
+ optionWrap: Boolean,
390
+ optionAlign: {
391
+ type: String,
392
+ default: 'left'
393
+ },
394
+ // 异步数据参数
395
+ httpRequest: {
396
+ type: Function,
397
+ default: ajax
398
+ },
399
+ api: {
400
+ type: String,
401
+ default: ''
402
+ },
403
+ apiParam: {
404
+ type: Object,
405
+ default: null
406
+ },
407
+ apiHeaders: {
408
+ type: Object,
409
+ default: () => {}
410
+ },
411
+ apiLabel: {
412
+ type: String,
413
+ default: ''
414
+ },
415
+ resPath: {
416
+ type: String,
417
+ default: ''
418
+ },
419
+ errorPath: {
420
+ type: String,
421
+ default: ''
422
+ },
423
+ successCode: {
424
+ type: String,
425
+ default: '0'
426
+ },
427
+ // 远程异步数据设置
428
+ setDataFn: {
429
+ type: Function,
430
+ default: null
431
+ },
432
+ // 插件
433
+ prefix: {
434
+ type: String,
435
+ default: ''
436
+ },
437
+ suffix: {
438
+ type: String,
439
+ default: ''
440
+ },
441
+ icon: {
442
+ type: String,
443
+ default: ''
444
+ },
445
+ iconProps: {
446
+ type: Object,
447
+ default: ()=>{}
448
+ },
449
+ // 基本功能
450
+ trim: {
451
+ type: Boolean,
452
+ default: true
453
+ },
454
+ closeSelection: {
455
+ // 多选时,每次选择都关闭弹窗
456
+ type: Boolean,
457
+ default: false
458
+ },
459
+ verifiable: {
460
+ type: Boolean,
461
+ default: true
462
+ },
463
+ comparable: Boolean,
464
+ setLabelFn: undefined, // 传入一个 Function 设置每一项的 label,return String,
465
+ wrap: Boolean,
466
+ focusWhenClear: {
467
+ // filterable模式下清空数据是否弹出下拉框
468
+ type: Boolean,
469
+ default: false
470
+ },
471
+ beforeChange: {
472
+ type: Function,
473
+ default: null
474
+ },
475
+ valueType: {
476
+ type: String,
477
+ default: ''
478
+ }
479
+ },
480
+ data() {
481
+ return {
482
+ isChanging: false,
483
+ errorTip: '',
484
+ errorType: 'rule',
485
+ iValue: '',
486
+ valueStore: [],
487
+ dataLoading: false,
488
+ selected: null,
489
+ inited: false,
490
+ multipleInputValue: '',
491
+ multipleFilterValue: '',
492
+ setDataInputValue: '',
493
+ filterValue: '',
494
+ inputValue: '',
495
+ focused: false,
496
+ blurByLayer: false,
497
+ options: [],
498
+ anotherOptions: [], // 只作用于手机端
499
+ layerSlide: false,
500
+ layerPosition: 'auto',
501
+ disabled: this.readonly,
502
+ iApiHeaders: {},
503
+ inputing: false
504
+ }
505
+ },
506
+ computed: {
507
+ showTag() {
508
+ return this.inputable || this.filterable || this.setDataFn || (this.selected.length > 0 && !(this.isAll && this.useAllText))
509
+ },
510
+ isAll() {
511
+ let arr = []
512
+ this.options.map(item => {
513
+ arr.push(item[this.iValueText])
514
+ })
515
+ if (arr.sort().toString() === this.iValue.toString().split(',').sort().toString()) {
516
+ return true
517
+ } else {
518
+ return false
519
+ }
520
+ },
521
+ nomatch() {
522
+ let nomatch = true
523
+ let value = this.multiple ? this.multipleFilterValue : this.filterValue
524
+ if (value === '' || this.options.findIndex(option=>option[this.iLabelText].includes(value)) > -1) {
525
+ nomatch = false
526
+ }
527
+ return nomatch
528
+ },
529
+ nodata() {
530
+ return this.options.length === 0
531
+ },
532
+ label() {
533
+ if (this.selected[this.iLabelText]) {
534
+ return this.selected[this.iLabelText]
535
+ } else {
536
+ return ''
537
+ }
538
+ },
539
+ labels() {
540
+ let arr = []
541
+ this.selected.map(item=>{
542
+ arr.push(item[this.iLabelText])
543
+ })
544
+ return arr
545
+ },
546
+ setClass() {
547
+ let arr = ['to-form-readonly']
548
+ if (this.fillet !== 'none') {
549
+ arr.push(`to-input-fillet-${this.fillet}`);
550
+ }
551
+ if (this.filletPosition) {
552
+ arr.push(`to-input-fillet-position-${this.filletPosition}`);
553
+ }
554
+ if (this.multiple) {
555
+ if (this.selected.length === 0) {
556
+ arr.push('to-select-placeholder')
557
+ }
558
+ } else {
559
+ if (this.selected[this.iValueText] === '') {
560
+ arr.push('to-select-placeholder')
561
+ }
562
+ }
563
+ if (this.errorTip) {
564
+ arr.push('to-select-mode-line');
565
+ arr.push('to-box-mode-line');
566
+ arr.push('to-select-color-danger');
567
+ arr.push('to-box-color-danger');
568
+ arr.push('to-select-tip-show')
569
+ } else {
570
+ if (this.color) {
571
+ if (this.color !== 'radam') {
572
+ arr.push(`to-select-color-${this.color}`);
573
+ arr.push(`to-box-color-${this.color}`);
574
+ } else {
575
+ let colors = this.$TouchUI.colors
576
+ let number = Math.round(Math.random() * 6)
577
+ arr.push(`to-select-color-${ colors[number]}`);
578
+ arr.push(`to-box-color-${ colors[number]}`);
579
+ }
580
+ }
581
+ if (this.mode) {
582
+ arr.push(`to-select-mode-${this.mode}`)
583
+ arr.push(`to-box-mode-${this.mode}`)
584
+ } else if (this.ToForm && this.ToForm.type === 'list') {
585
+ arr.push('to-select-mode-none')
586
+ arr.push('to-box-mode-none')
587
+ } else {
588
+ arr.push('to-select-mode-toast')
589
+ arr.push('to-box-mode-toast')
590
+ }
591
+ }
592
+ if (this.placeholderColor) {
593
+ arr.push(`to-select-placeholder-color-${this.placeholderColor}`)
594
+ }
595
+ if (this.focused) {
596
+ arr.push('to-select-state-focus')
597
+ }
598
+ if (this.disabled) {
599
+ arr.push('to-select-state-readonly')
600
+ }
601
+ if (this.changed) {
602
+ arr.push('to-select-changed')
603
+ }
604
+ if (this.wrap) {
605
+ arr.push('to-select-wrap')
606
+ }
607
+ if (this.native) {
608
+ arr.push('to-select-native')
609
+ }
610
+ if ((this.ToForm && this.ToForm.comparable) || this.comparable) {
611
+ arr.push('to-compare')
612
+ }
613
+ return arr
614
+ },
615
+ setStyle() {
616
+ var obj = {}
617
+ if (this.width) {
618
+ if (!isNaN(this.width)) {
619
+ obj.width = this.width + 'em';
620
+ } else if (this.width === 'full') {
621
+ obj.width = '100%';
622
+ } else {
623
+ obj.width = this.width;
624
+ }
625
+ }
626
+ return obj
627
+ },
628
+ setContentClass() {
629
+ let arr = []
630
+ if (!this.inputable && !this.setDataFn && !this.filterable) {
631
+ arr.push('to-box-link')
632
+ }
633
+ if (this.color) {
634
+ arr.push(`to-box-color-${this.color}`)
635
+ } else if (this.mode === 'fill' || this.mode === 'line') {
636
+ arr.push('to-box-color-primary')
637
+ } else {
638
+ arr.push('to-box-color-fg')
639
+ }
640
+ if (this.mode) {
641
+ arr.push(`to-box-mode-${this.mode}`)
642
+ } else if (this.ToForm && this.ToForm.type === 'list') {
643
+ arr.push('to-box-mode-none')
644
+ } else {
645
+ arr.push('to-box-mode-toast')
646
+ }
647
+ return arr
648
+ },
649
+ validateRequired() {
650
+ if (this.required) {
651
+ return 'true'
652
+ } else if (this.ToFormItem && this.ToFormItem.required) {
653
+ return 'true'
654
+ } else {
655
+ return 'false'
656
+ }
657
+ },
658
+ validateDesc() {
659
+ if (this.desc) {
660
+ return this.desc
661
+ } else if (this.ToFormItem && this.ToFormItem.label) {
662
+ return this.ToFormItem.label
663
+ } else {
664
+ return ''
665
+ }
666
+ },
667
+ validateValue() {
668
+ if (this.multiple) {
669
+ if (this.selected.length > 0) {
670
+ return 'true'
671
+ } else {
672
+ return ''
673
+ }
674
+ } else {
675
+ return this.selected[this.iValueText]
676
+ }
677
+ },
678
+ changed() {
679
+ if ((this.comparable || this.ToForm.comparable) && this.valueStore.length > 0 && this.iValue !== this.valueStore[0]) {
680
+ return true
681
+ } else {
682
+ return false
683
+ }
684
+ }
685
+ },
686
+ watch: {
687
+ readonly(val) {
688
+ this.disabled = val
689
+ },
690
+ multiple: {
691
+ handler(val) {
692
+ if (val) {
693
+ this.selected = []
694
+ } else {
695
+ this.selected = {}
696
+ }
697
+ },
698
+ immediate: true
699
+ },
700
+ selected(val) {
701
+ this.adjustLayer()
702
+ if (this.multiple) {
703
+ let arr = []
704
+ val.map(item => {
705
+ arr.push(item[this.iValueText])
706
+ })
707
+ if (this.inited) {
708
+ this.iValue = arr.join(this.splitSymbol || ',')
709
+ }
710
+ } else {
711
+ if (this.inited) {
712
+ this.isChanging = true // 避免同时给 inputable 的 input 设置 inputValue 的时候触发 change 事件
713
+ this.iValue = val[this.iValueText]
714
+ setTimeout(() => {
715
+ this.isChanging = false
716
+ }, 100);
717
+ }
718
+ }
719
+ if (!this.inited) {
720
+ if (Array.isArray(this.value)) {
721
+ this.iValue = this.value.join(',')
722
+ } else {
723
+ this.iValue = this.value
724
+ }
725
+ this.$nextTick(()=>{
726
+ this.inited = true
727
+ })
728
+ }
729
+ },
730
+ value: {
731
+ handler(val) {
732
+ if (Array.isArray(val)) {
733
+ this.iValue = val.join(',')
734
+ } else {
735
+ this.iValue = val
736
+ }
737
+ },
738
+ immediate: true
739
+ },
740
+ iValue(val) {
741
+ this.setSeleted(val)
742
+ if (this.inited) {
743
+ if (this.multiple && this.valueType === 'array') {
744
+ this.$emit('change', val ? val.split(',') : [], this.selected)
745
+ } else {
746
+ this.$emit('change', val, this.selected)
747
+ }
748
+
749
+ const detail = {
750
+ name: 'ToSelect',
751
+ value: val,
752
+ desc: this.validateDesc,
753
+ selected: this.selected
754
+ }
755
+ this.$TouchUI.commitTouchReport(detail)
756
+
757
+ if (this.native) {
758
+ this.$refs.selector.blur()
759
+ }
760
+ }
761
+ this.valueChange(val)
762
+ },
763
+ filterValue(val) {
764
+ if (this.inputable) {
765
+ this.$nextTick(()=>{
766
+ this.iValue = val
767
+ })
768
+ }
769
+ },
770
+ inputValue() {
771
+ if (!this.isChanging) {
772
+ this.iValue = this.inputValue
773
+ }
774
+ },
775
+ setDataInputValue(val) {
776
+ if (this.setDataFn) {
777
+ this.setDataFn(val)
778
+ }
779
+ if (this.inputable) {
780
+ this.$nextTick(()=>{
781
+ this.iValue = val
782
+ })
783
+ }
784
+ },
785
+ data: {
786
+ handler() {
787
+ this.setOptions()
788
+ this.valueChange(this.iValue)
789
+ },
790
+ deep: true
791
+ },
792
+ api() {
793
+ this.setOptions()
794
+ }
795
+ },
796
+ created() {
797
+ this.iLabelText = this.labelText
798
+ this.iValueText = this.valueText
799
+ this.iResPath = this.resPath
800
+ this.iSuccessCode = this.successCode
801
+ this.iApiParam = this.apiParam
802
+ this.iApiHeaders = this.apiHeaders
803
+ this.iApiLabel = this.apiLabel
804
+ this.iErrorPath = this.errorPath
805
+ this.iOptionWidth = this.optionWidth
806
+ this.setOptions()
807
+ // 弹出模式
808
+ if (this.$platform === 'phone') {
809
+ this.layerSlide = true
810
+ this.layerPosition = 'bottom'
811
+ }
812
+ if (this.optionDisplay === 'popup' || (this.$phone && (this.filterable || this.inputable))) {
813
+ this.layerSlide = true
814
+ this.layerPosition = 'right'
815
+ if (!this.optionWidth) {
816
+ this.iOptionWidth = '100%'
817
+ }
818
+ }
819
+ },
820
+ methods: {
821
+ valueChange(val) {
822
+ if (!this.multiple) {
823
+ if (this.inputable) {
824
+ this.inputValue = this.getLabel(val) || val
825
+ }
826
+ if (this.filterable && !this.inputable) {
827
+ this.filterValue = this.getLabel(val) || ''
828
+ }
829
+ if (this.filterable && this.inputable) {
830
+ this.filterValue = this.getLabel(val) || val
831
+ }
832
+ if (this.setDataFn && !this.inputable) {
833
+ this.setDataInputValue = this.getLabel(val) || ''
834
+ }
835
+ if (this.setDataFn && this.inputable) {
836
+ this.setDataInputValue = this.getLabel(val) || val
837
+ }
838
+ }
839
+ },
840
+ setSeleted(val) {
841
+ let selected = JSON.parse(JSON.stringify(this.selected))
842
+ if (!this.multiple) {
843
+ if (this.options.findIndex(option=>option[this.iValueText] === val) === -1) {
844
+ selected = {
845
+ [this.iLabelText]: val,
846
+ [this.iValueText]: val
847
+ }
848
+ } else {
849
+ selected = this.options.find(option=>option[this.iValueText] === val)
850
+ }
851
+ } else {
852
+ if (val === '') {
853
+ selected = []
854
+ } else {
855
+ const arr = Array.isArray(val) ? unique(val) : unique(val.split(this.splitSymbol || ','))
856
+ let selectedArr = []
857
+ arr.map(item => {
858
+ if (item && item.trim()) {
859
+ if (this.options.findIndex(option=>String(option[this.iValueText]) === String(item)) === -1) {
860
+ selectedArr.push({
861
+ [this.iLabelText]: item,
862
+ [this.iValueText]: item,
863
+ hide: !this.inputable // 当输入一个不存在的值的时候,如果可自定义则显示,否则不显示
864
+ })
865
+ } else {
866
+ this.options.map(option => {
867
+ if (String(option[this.iValueText]) === String(item)) {
868
+ selectedArr.push(option)
869
+ }
870
+ })
871
+ }
872
+ }
873
+ })
874
+ selected = selectedArr
875
+ }
876
+ }
877
+ if (this.beforeChange) {
878
+ const fn = this.beforeChange(selected)
879
+ if (fn && fn.then) {
880
+ fn.then(flag => {
881
+ this.selected = selected
882
+ }).catch((e)=>{})
883
+ } else {
884
+ if (fn) {
885
+ this.selected = selected
886
+ }
887
+ }
888
+ } else {
889
+ this.selected = selected
890
+ }
891
+
892
+ },
893
+ enter() {
894
+ if (!(this.multiple && this.inputable)) {
895
+ this.toggleLayer()
896
+ } else {
897
+ // 判断重复项
898
+ let value = this.filterable ? this.multipleFilterValue : this.multipleInputValue
899
+ if (
900
+ this.selected.find(item => item[this.iLabelText] === value) ||
901
+ this.selected.find(item => item[this.iValueText] === value)
902
+ ) {
903
+ this.$tip.error(this.t('to.select.tip.error.repetition'))
904
+ return
905
+ }
906
+ // 判断空项
907
+ if (!value.trim()) {
908
+ return
909
+ }
910
+ const newOption = {
911
+ [this.iLabelText]: value,
912
+ [this.iValueText]: value
913
+ }
914
+ if (this.beforeChange) {
915
+ const fn = this.beforeChange(newOption)
916
+ if (fn && fn.then) {
917
+ fn.then(flag => {
918
+ this.selected.push(newOption)
919
+ }).catch((e)=>{})
920
+ } else {
921
+ if (fn) {
922
+ this.selected.push(newOption)
923
+ }
924
+ }
925
+ } else {
926
+ this.selected.push(newOption)
927
+ }
928
+ if (this.filterable) {
929
+ this.multipleFilterValue = ''
930
+ } else {
931
+ this.multipleInputValue = ''
932
+ }
933
+ if (this.$phone) {
934
+ if (this.filterable) {
935
+ setTimeout(() => {
936
+ this.$refs.popupFilter.focus()
937
+ }, 500);
938
+ } else {
939
+ setTimeout(() => {
940
+ this.$refs.popupInput.focus()
941
+ }, 500);
942
+ }
943
+ }
944
+ }
945
+ },
946
+ filter(item) {
947
+ if (!this.inputing) {
948
+ return true
949
+ }
950
+ if (this.filterable) {
951
+ return item[this.iLabelText].includes(this.filterValue)
952
+ } else {
953
+ return true
954
+ }
955
+ },
956
+ multipleFilter(item) {
957
+ if (this.filterable) {
958
+ return item[this.iLabelText].includes(this.multipleFilterValue)
959
+ } else {
960
+ return true
961
+ }
962
+ },
963
+ getLabel(val) {
964
+ let obj = this.options.find(item => item[this.iValueText] === val)
965
+ if (obj && obj[this.iLabelText]) {
966
+ return obj[this.iLabelText]
967
+ }
968
+ },
969
+ setOptions() {
970
+ // 同步选项
971
+ if (this.data) {
972
+ if (typeof this.data === 'string') {
973
+ // 字符串模式传值(如::data="选项1, 选项2, 选项3")
974
+ let arr = []
975
+ for (let i = 0; i < this.data.split(',').length; i++) {
976
+ const el = this.data.split(',')[i]
977
+ let obj = {}
978
+ obj[this.iLabelText] = obj[this.iValueText] = el
979
+ arr.push(obj)
980
+ }
981
+ if (this.$phone && this.filterable) {
982
+ this.options = arr.slice(0, 100)
983
+ this.anotherOptions = arr.slice(100)
984
+ } else {
985
+ this.options = arr
986
+ }
987
+ } else {
988
+ // 如果是手机端,则先取前 100 项,再拼接后面的
989
+ if (this.$phone && this.filterable) {
990
+ this.options = this.data.slice(0, 100)
991
+ this.anotherOptions = this.data.slice(100)
992
+ } else {
993
+ // 对象数组模式传值
994
+ this.options = [...this.data]
995
+ }
996
+ // 如果设置了方法,则替换为方法
997
+ if (typeof this.setLabelFn === 'function') {
998
+ this.options.forEach(item => {
999
+ item.label = this.setLabelFn(item)
1000
+ })
1001
+ }
1002
+ }
1003
+
1004
+ // 设置 selected
1005
+ this.setSeleted(this.value)
1006
+ this.setPlaceholder()
1007
+ }
1008
+
1009
+ // 异步选项
1010
+ if (this.api) {
1011
+ // 通过配置自动设置 labelText 与 valueText
1012
+ if (this.$TouchUI.staticDataApiConfig.labelText && this.labelText === 'label') {
1013
+ this.iLabelText = this.$TouchUI.staticDataApiConfig.labelText
1014
+ }
1015
+ if (this.$TouchUI.staticDataApiConfig.valueText && this.valueText === 'value') {
1016
+ this.iValueText = this.$TouchUI.staticDataApiConfig.valueText
1017
+ }
1018
+ if (this.$TouchUI.staticDataApiConfig.resPath && !this.resPath) {
1019
+ this.iResPath = this.$TouchUI.staticDataApiConfig.resPath
1020
+ }
1021
+ if (this.$TouchUI.staticDataApiConfig.apiParam && !this.apiParam) {
1022
+ this.iApiParam = this.$TouchUI.staticDataApiConfig.apiParam
1023
+ }
1024
+ if (this.$TouchUI.staticDataApiConfig.apiHeaders && !this.apiHeaders) {
1025
+ this.iApiHeaders = this.$TouchUI.staticDataApiConfig.apiHeaders
1026
+ }
1027
+ if (this.$TouchUI.staticDataApiConfig.apiLabel && !this.apiLabel) {
1028
+ this.iApiLabel = this.$TouchUI.staticDataApiConfig.apiLabel
1029
+ }
1030
+ if (this.$TouchUI.staticDataApiConfig.errorPath && !this.errorPath) {
1031
+ this.iErrorPath = this.$TouchUI.staticDataApiConfig.errorPath
1032
+ }
1033
+ if (this.$TouchUI.staticDataApiConfig.resPath && !this.successCode) {
1034
+ this.iSuccessCode = this.$TouchUI.staticDataApiConfig.successCode
1035
+ }
1036
+
1037
+ // 从缓存中取数据,如果没有则异步获取
1038
+ if (sessionStorage.getItem('static.' + this.api)) {
1039
+ this.options = JSON.parse(sessionStorage.getItem('static.' + this.api))
1040
+
1041
+ // 设置 selected
1042
+ this.setSeleted(this.value)
1043
+ this.setPlaceholder()
1044
+ this.$emit('option-loaded', this.options)
1045
+
1046
+ } else {
1047
+ let action = ''
1048
+ if (this.iApiLabel && this.api) {
1049
+ Object.assign(this.iApiParam, { [this.iApiLabel]: this.api })
1050
+ }
1051
+ if (this.api.indexOf('http') > -1) {
1052
+ action = this.api
1053
+ } else {
1054
+ if (this.$TouchUI.staticDataApiConfig.action && this.$TouchUI.staticDataApiConfig.action.indexOf('=') > -1 && this.$TouchUI.staticDataApiConfig.action.indexOf('?') > -1) {
1055
+ // 兼容 GET 格式的 POST 请求
1056
+ action = this.$TouchUI.staticDataApiConfig.action + this.api
1057
+ } else {
1058
+ action = this.$TouchUI.staticDataApiConfig.action
1059
+ }
1060
+ }
1061
+ const options = {
1062
+ data: this.iApiParam,
1063
+ action,
1064
+ headers: Object.assign({}, this.iApiHeaders),
1065
+ onSuccess: res => {
1066
+ if (typeof res === 'string') {
1067
+ res = JSON.parse(res)
1068
+ }
1069
+
1070
+ // 直接返回一个 select 所需要的 data 对象时,不需要任何解析
1071
+ // 如:[{name:'张三', id:0},{name:'李四', id:1}]
1072
+ if (Array.isArray(res)) {
1073
+ this.options = res
1074
+ sessionStorage.setItem('static.' + this.api, JSON.stringify(res))
1075
+
1076
+ // 设置 selected
1077
+ this.setSeleted(this.value)
1078
+ this.setPlaceholder()
1079
+ this.$emit('option-loaded', this.options)
1080
+ } else if (res.code === this.iSuccessCode) {
1081
+ // 按照 json 格式返回,需要根据配置路径进行解析
1082
+ // 如:{ code:'0', data:[{name:'张三', id:0},{name:'李四', id:1}]}
1083
+ let data = []
1084
+ if (this.iResPath) {
1085
+ let resPath = this.iResPath.split('/')
1086
+ resPath.forEach(el => {
1087
+ data = res[el]
1088
+ })
1089
+ }
1090
+ this.options = data
1091
+ sessionStorage.setItem('static.' + this.api, JSON.stringify(data))
1092
+
1093
+ // 设置 selected
1094
+ this.setSeleted(this.value)
1095
+ this.setPlaceholder()
1096
+ this.$emit('option-loaded', this.options)
1097
+ } else {
1098
+ this.options = []
1099
+ this.t('to.select.tip.error.res', `select api(${this.api})`)
1100
+ }
1101
+ },
1102
+ onError: res => {
1103
+ this.$tip.danger(this.t('to.select.tip.error.api', `select api(${this.api}) `))
1104
+ }
1105
+ }
1106
+ const req = this.httpRequest(options)
1107
+ if (req && req.then) {
1108
+ req.then(options.onSuccess, options.onError)
1109
+ }
1110
+ }
1111
+ }
1112
+ },
1113
+ setPlaceholder() {
1114
+ if (this.native) {
1115
+ return
1116
+ }
1117
+ // 设置 placeholder
1118
+ if (!this.multiple && this.clearable && !this.inputable && !this.setDataFn && !this.filterable && (!this.optionDisplay || this.optionDisplay === 'float')) {
1119
+ this.options.unshift({})
1120
+ this.$set(this.options, 0, {
1121
+ [this.iLabelText]: '',
1122
+ [this.iValueText]: ''
1123
+ })
1124
+ }
1125
+ },
1126
+ setValue(val) {
1127
+ this.iValue = val
1128
+ if (!this.multiple || this.closeSelection) {
1129
+ this.closeLayer()
1130
+ }
1131
+ },
1132
+ selectAll() {
1133
+ let arr = []
1134
+ this.options.map(item=>{
1135
+ if (!item.disabled) {
1136
+ arr.push(item[this.iValueText])
1137
+ }
1138
+ })
1139
+ this.iValue = arr.toString()
1140
+ },
1141
+ Deselect() {
1142
+ let arr = []
1143
+ this.options.map(item=>{
1144
+ if (!item.disabled && !this.iValue.split(',').includes(item[this.iValueText])) {
1145
+ arr.push(item[this.iValueText])
1146
+ }
1147
+ })
1148
+ this.iValue = arr.toString()
1149
+ },
1150
+ clear() {
1151
+ this.setValue('')
1152
+ },
1153
+ itemChange(item) {
1154
+ if (item.disabled) {
1155
+ return
1156
+ }
1157
+ this.setSeleted(item[this.iValueText])
1158
+ // this.selected = item
1159
+ this.$nextTick(()=>{
1160
+ this.$emit('selected', item)
1161
+ this.closeLayer()
1162
+ })
1163
+ },
1164
+ adjustLayer() {
1165
+ if (this.optionDisplay !== 'none' && this.$refs.layer.show) {
1166
+ this.$nextTick(()=>{
1167
+ this.$refs.layer.set(this.$refs.link)
1168
+ })
1169
+ }
1170
+ },
1171
+ openLayer() {
1172
+ if (!this.disabled && this.optionDisplay !== 'none') {
1173
+ this.$refs.layer.open('link')
1174
+ if (this.filterable && this.$phone) {
1175
+ setTimeout(() => {
1176
+ if (this.$refs.popupFilter) {
1177
+ this.$refs.popupFilter.focus()
1178
+ }
1179
+ this.$nextTick(() => {
1180
+ this.options = this.options.concat(this.anotherOptions)
1181
+ })
1182
+ }, 500);
1183
+ }
1184
+ if (this.inputable && this.$phone) {
1185
+ setTimeout(() => {
1186
+ if (this.$refs.popupInput) {
1187
+ this.$refs.popupInput.focus()
1188
+ }
1189
+ }, 500);
1190
+ }
1191
+ }
1192
+ },
1193
+ closeLayer() {
1194
+ if (!this.disabled && this.optionDisplay !== 'none') {
1195
+ this.inputing = false
1196
+ this.phoneCloseLayer()
1197
+ }
1198
+ },
1199
+ phoneCloseLayer() {
1200
+ this.$refs.layer.close()
1201
+ if (this.filterable && this.$phone) {
1202
+ this.options = this.options.slice(0, 100)
1203
+ }
1204
+ },
1205
+ toggleLayer() {
1206
+ if (this.$refs.layer) {
1207
+ if (this.$refs.layer.show) {
1208
+ this.closeLayer()
1209
+ } else {
1210
+ this.openLayer()
1211
+ }
1212
+ }
1213
+ },
1214
+ click() {
1215
+ if (!this.native) {
1216
+ this.toggleLayer()
1217
+ }
1218
+ this.$emit('click')
1219
+ },
1220
+ layerClose() {
1221
+ if (!this.multiple) {
1222
+ if (this.filterable && !this.inputable) {
1223
+ if (this.iValue) {
1224
+ const label = this.getLabel(this.iValue)
1225
+ if (label) {
1226
+ this.filterValue = label
1227
+ } else {
1228
+ this.filterValue = ''
1229
+ }
1230
+ } else {
1231
+ this.filterValue = ''
1232
+ }
1233
+ }
1234
+ } else {
1235
+ if (this.inputable) {
1236
+ this.multipleInputValue = ''
1237
+ }
1238
+ if (this.filterable) {
1239
+ this.multipleFilterValue = ''
1240
+ }
1241
+ }
1242
+ },
1243
+ layerMousedown() {
1244
+ this.blurByLayer = true
1245
+ let timer = null
1246
+ timer = setTimeout(() => {
1247
+ this.blurByLayer = false
1248
+ clearTimeout(timer)
1249
+ timer = null
1250
+ }, 200);
1251
+ },
1252
+ focus() {
1253
+ this.errorTip = ''
1254
+ this.focused = true
1255
+ },
1256
+ blur() {
1257
+ this.focused = false
1258
+ if (!this.blurByLayer && !this.$phone) {
1259
+ this.closeLayer()
1260
+ }
1261
+ },
1262
+ inputBlur() {
1263
+ this.focused = false
1264
+ if (!this.blurByLayer && !this.$phone) {
1265
+ this.closeLayer()
1266
+ }
1267
+ },
1268
+ inputFocus() {
1269
+ this.focused = true
1270
+ if (this.value === '') {
1271
+ this.openLayer()
1272
+ }
1273
+ },
1274
+ inputInput(e) {
1275
+ if (e && e.keyCode === 13) {
1276
+ this.$emit('inputEnter')
1277
+ }
1278
+ this.$nextTick(()=>{
1279
+ if (this.value === '') {
1280
+ this.openLayer()
1281
+ } else {
1282
+ this.closeLayer()
1283
+ }
1284
+ })
1285
+ },
1286
+ filterBlur() {
1287
+ this.focused = false
1288
+ if (!this.blurByLayer && !this.$phone) {
1289
+ this.closeLayer()
1290
+ }
1291
+ },
1292
+ filterFocus() {
1293
+ this.focused = true
1294
+ this.openLayer()
1295
+ },
1296
+ filterInput(e) {
1297
+ if (e && e.keyCode === 13) {
1298
+ this.$emit('inputEnter')
1299
+ }
1300
+ this.$nextTick(()=>{
1301
+ this.inputing = true
1302
+ this.adjustLayer()
1303
+ this.openLayer()
1304
+ })
1305
+ },
1306
+ filterClear() {
1307
+ this.iValue = ''
1308
+ },
1309
+ multipleInputBlur() {
1310
+ this.focused = false
1311
+ if (!this.blurByLayer && !this.$phone) {
1312
+ this.closeLayer()
1313
+ }
1314
+ },
1315
+ multipleInputFocus() {
1316
+ this.focused = true
1317
+ if (this.value === '') {
1318
+ this.openLayer()
1319
+ }
1320
+ },
1321
+ multipleItemChange(value, item) {
1322
+ let val = this.selected.map(option => option[this.iValueText])
1323
+ if (value) {
1324
+ val.push(item[this.iValueText])
1325
+ this.setSeleted(val.join(','))
1326
+ } else {
1327
+ this.removeItem(val, item[this.iValueText])
1328
+ this.setSeleted(val.join(','))
1329
+ }
1330
+ if (this.inputable && !this.filterable) {
1331
+ if (this.$phone) {
1332
+ setTimeout(() => {
1333
+ this.$refs.popupInput.focus()
1334
+ }, 500);
1335
+ } else {
1336
+ setTimeout(() => {
1337
+ this.$refs.input.focus()
1338
+ }, 500);
1339
+ }
1340
+ this.multipleInputValue = ''
1341
+ }
1342
+ if (this.filterable) {
1343
+ if (this.$phone) {
1344
+ setTimeout(() => {
1345
+ this.$refs.popupFilter.focus()
1346
+ }, 500);
1347
+ } else {
1348
+ setTimeout(() => {
1349
+ this.$refs.filter.focus()
1350
+ }, 500);
1351
+ }
1352
+ this.multipleFilterValue = ''
1353
+ }
1354
+ if (this.setDataFn) {
1355
+ setTimeout(() => {
1356
+ this.$refs.filter.focus()
1357
+ }, 500);
1358
+ this.setDataInputValue = ''
1359
+ }
1360
+ },
1361
+ removeTag(item) {
1362
+ let val = this.selected.map(option => option[this.iValueText])
1363
+ this.removeItem(val, item[this.iValueText])
1364
+ this.setSeleted(val.join(','))
1365
+ if (this.inputable) {
1366
+ if (this.$phone) {
1367
+ if (this.filterable) {
1368
+ if (this.$refs.popupFilter) {
1369
+ setTimeout(() => {
1370
+ this.$refs.popupFilter.focus()
1371
+ }, 500);
1372
+ }
1373
+ } else {
1374
+ if (this.$refs.popupInput) {
1375
+ setTimeout(() => {
1376
+ this.$refs.popupInput.focus()
1377
+ }, 500);
1378
+ }
1379
+ }
1380
+ } else {
1381
+ if (this.filterable) {
1382
+ setTimeout(() => {
1383
+ this.$refs.filter.focus()
1384
+ }, 500);
1385
+ } else {
1386
+ setTimeout(() => {
1387
+ this.$refs.input.focus()
1388
+ }, 500);
1389
+ }
1390
+ }
1391
+ }
1392
+ },
1393
+ multipleFilterBlur() {
1394
+ this.focused = false
1395
+ if (!this.blurByLayer && !this.$phone) {
1396
+ this.closeLayer()
1397
+ }
1398
+ },
1399
+ multipleFilterFocus() {
1400
+ this.focused = true
1401
+ if (this.value === '') {
1402
+ this.openLayer()
1403
+ }
1404
+ },
1405
+ removeItem(obj, val) {
1406
+ let index
1407
+
1408
+ // 字符串
1409
+ if (typeof obj === 'string') {
1410
+ let arr = obj.split(',')
1411
+ index = arr.findIndex(item=>item === val)
1412
+ obj = arr.join(',')
1413
+ }
1414
+
1415
+ // 字符串数组
1416
+ else if (Array.isArray(obj) && typeof obj[0] === 'string') {
1417
+ index = obj.findIndex(item=>item === val)
1418
+ obj.splice(index, 1)
1419
+ }
1420
+
1421
+ // 对象数组
1422
+ else {
1423
+ index = obj.findIndex(item=>item[this.iValueText] === val)
1424
+ obj.splice(index, 1)
1425
+ }
1426
+ },
1427
+ setDataLoading(val) {
1428
+ this.dataLoading = val
1429
+ },
1430
+
1431
+ // 记录历史值,以便对比或者取值
1432
+ compare() {
1433
+ this.valueStore.unshift(this.iValue)
1434
+ },
1435
+ setDisabled(f) {
1436
+ this.disabled = f
1437
+ },
1438
+ // 撤销
1439
+ restore() {
1440
+ this.data = this.valueStore[0]
1441
+ this.valueStore.splice(0, 1)
1442
+ }
1443
+ }
1444
+ }
1445
+ </script>