three-trees-ui 1.0.0

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 (384) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +32 -0
  3. package/lib/demo.html +10 -0
  4. package/lib/three-trees-ui.common.js +49136 -0
  5. package/lib/three-trees-ui.css +1 -0
  6. package/lib/three-trees-ui.umd.js +49146 -0
  7. package/lib/three-trees-ui.umd.min.js +1 -0
  8. package/package.json +137 -0
  9. package/packages/AddQueryStrategy/index.js +7 -0
  10. package/packages/AddQueryStrategy/src/main.vue +236 -0
  11. package/packages/Autocomplete/index.js +7 -0
  12. package/packages/Autocomplete/src/main.vue +201 -0
  13. package/packages/Avatar/index.js +7 -0
  14. package/packages/Avatar/src/AvatarImage.vue +218 -0
  15. package/packages/Button/index.js +7 -0
  16. package/packages/Button/src/main.vue +90 -0
  17. package/packages/Cascader/index.js +7 -0
  18. package/packages/Cascader/src/main.vue +210 -0
  19. package/packages/Chart/index.js +7 -0
  20. package/packages/Chart/src/Chart.vue +856 -0
  21. package/packages/Checkbox/index.js +7 -0
  22. package/packages/Checkbox/src/main.vue +205 -0
  23. package/packages/Collapse/index.js +7 -0
  24. package/packages/Collapse/src/HtCollapse.vue +85 -0
  25. package/packages/Collapse/src/HtCollapseItem.vue +21 -0
  26. package/packages/CollapseItem/index.js +7 -0
  27. package/packages/CustomComponent/index.js +6 -0
  28. package/packages/CustomComponent/src/main.vue +87 -0
  29. package/packages/CustomDialog/index.js +7 -0
  30. package/packages/CustomDialog/src/customDialog.js +126 -0
  31. package/packages/CustomDialog/src/customDialog.vue +1864 -0
  32. package/packages/CustomDialog/src/customMobileDialog.vue +1619 -0
  33. package/packages/CustomDialog/src/main.vue +485 -0
  34. package/packages/DataView/index.js +7 -0
  35. package/packages/DataView/src/DataView.vue +45 -0
  36. package/packages/Date/index.js +7 -0
  37. package/packages/Date/src/main.vue +182 -0
  38. package/packages/DatePicker/index.js +7 -0
  39. package/packages/DatePicker/src/main.vue +155 -0
  40. package/packages/Demension/index.js +7 -0
  41. package/packages/Demension/src/main.vue +382 -0
  42. package/packages/Dialog/index.js +7 -0
  43. package/packages/Dialog/src/main.vue +169 -0
  44. package/packages/Dictionary/index.js +7 -0
  45. package/packages/Dictionary/src/main.vue +211 -0
  46. package/packages/DimensionSelector/index.js +7 -0
  47. package/packages/DimensionSelector/src/main.vue +526 -0
  48. package/packages/DimensionSelectorInput/index.js +7 -0
  49. package/packages/DimensionSelectorInput/src/main.vue +161 -0
  50. package/packages/Divider/index.js +7 -0
  51. package/packages/Divider/src/main.vue +38 -0
  52. package/packages/Duration/index.js +7 -0
  53. package/packages/Duration/src/main.vue +180 -0
  54. package/packages/Editor/index.js +7 -0
  55. package/packages/Editor/src/main.vue +320 -0
  56. package/packages/Explain/index.js +7 -0
  57. package/packages/Explain/src/main.vue +126 -0
  58. package/packages/FieldTail/index.js +7 -0
  59. package/packages/FieldTail/src/main.vue +188 -0
  60. package/packages/File/index.js +7 -0
  61. package/packages/File/src/FileCard.vue +169 -0
  62. package/packages/File/src/FileList.vue +180 -0
  63. package/packages/File/src/FileTable.vue +223 -0
  64. package/packages/File/src/main.vue +499 -0
  65. package/packages/FileUpload/index.js +7 -0
  66. package/packages/FileUpload/src/main.vue +242 -0
  67. package/packages/FlowChart/index.js +7 -0
  68. package/packages/FlowChart/src/main.vue +386 -0
  69. package/packages/FormItem/index.js +7 -0
  70. package/packages/FormItem/src/main.vue +175 -0
  71. package/packages/Global/index.js +12 -0
  72. package/packages/Global/src/GlobalQuery.vue +225 -0
  73. package/packages/Global/src/GlobalValidate.vue +132 -0
  74. package/packages/HistoricalApproval/index.js +7 -0
  75. package/packages/HistoricalApproval/src/main.vue +427 -0
  76. package/packages/Icon/index.js +7 -0
  77. package/packages/Icon/src/icons/ad.js +14 -0
  78. package/packages/Icon/src/icons/address-book.js +14 -0
  79. package/packages/Icon/src/icons/arrow.js +14 -0
  80. package/packages/Icon/src/icons/attachment.js +18 -0
  81. package/packages/Icon/src/icons/balance.js +14 -0
  82. package/packages/Icon/src/icons/ban.js +14 -0
  83. package/packages/Icon/src/icons/bell.js +14 -0
  84. package/packages/Icon/src/icons/block.js +26 -0
  85. package/packages/Icon/src/icons/book.js +14 -0
  86. package/packages/Icon/src/icons/bookmark.js +14 -0
  87. package/packages/Icon/src/icons/bug.js +22 -0
  88. package/packages/Icon/src/icons/bullhorn.js +14 -0
  89. package/packages/Icon/src/icons/calc.js +14 -0
  90. package/packages/Icon/src/icons/checkbox.js +14 -0
  91. package/packages/Icon/src/icons/circle.js +14 -0
  92. package/packages/Icon/src/icons/close.js +14 -0
  93. package/packages/Icon/src/icons/cloud-sun.js +14 -0
  94. package/packages/Icon/src/icons/coffee.js +14 -0
  95. package/packages/Icon/src/icons/component.js +14 -0
  96. package/packages/Icon/src/icons/compress.js +14 -0
  97. package/packages/Icon/src/icons/copyright.js +14 -0
  98. package/packages/Icon/src/icons/demension.js +18 -0
  99. package/packages/Icon/src/icons/dialog.js +14 -0
  100. package/packages/Icon/src/icons/down-unfold.js +18 -0
  101. package/packages/Icon/src/icons/download.js +14 -0
  102. package/packages/Icon/src/icons/duration.js +14 -0
  103. package/packages/Icon/src/icons/excel.js +18 -0
  104. package/packages/Icon/src/icons/expand.js +14 -0
  105. package/packages/Icon/src/icons/export.js +21 -0
  106. package/packages/Icon/src/icons/eye-slash.js +14 -0
  107. package/packages/Icon/src/icons/eye.js +14 -0
  108. package/packages/Icon/src/icons/file.js +18 -0
  109. package/packages/Icon/src/icons/form.js +14 -0
  110. package/packages/Icon/src/icons/ganged.js +14 -0
  111. package/packages/Icon/src/icons/gaode.js +27 -0
  112. package/packages/Icon/src/icons/gift.js +14 -0
  113. package/packages/Icon/src/icons/home.js +14 -0
  114. package/packages/Icon/src/icons/hotent.js +26 -0
  115. package/packages/Icon/src/icons/image.js +14 -0
  116. package/packages/Icon/src/icons/import.js +18 -0
  117. package/packages/Icon/src/icons/index.js +75 -0
  118. package/packages/Icon/src/icons/info.js +21 -0
  119. package/packages/Icon/src/icons/job.js +18 -0
  120. package/packages/Icon/src/icons/laptop.js +14 -0
  121. package/packages/Icon/src/icons/line.js +34 -0
  122. package/packages/Icon/src/icons/lock.js +14 -0
  123. package/packages/Icon/src/icons/map.js +18 -0
  124. package/packages/Icon/src/icons/more.js +19 -0
  125. package/packages/Icon/src/icons/move.js +14 -0
  126. package/packages/Icon/src/icons/org-tree.js +33 -0
  127. package/packages/Icon/src/icons/org-tree2.js +42 -0
  128. package/packages/Icon/src/icons/org.js +18 -0
  129. package/packages/Icon/src/icons/palette.js +14 -0
  130. package/packages/Icon/src/icons/plan.js +17 -0
  131. package/packages/Icon/src/icons/post.js +23 -0
  132. package/packages/Icon/src/icons/ppt.js +18 -0
  133. package/packages/Icon/src/icons/question.js +18 -0
  134. package/packages/Icon/src/icons/radio.js +14 -0
  135. package/packages/Icon/src/icons/refresh.js +14 -0
  136. package/packages/Icon/src/icons/role.js +38 -0
  137. package/packages/Icon/src/icons/search.js +14 -0
  138. package/packages/Icon/src/icons/select.js +14 -0
  139. package/packages/Icon/src/icons/setting.js +18 -0
  140. package/packages/Icon/src/icons/simple-collapse.js +18 -0
  141. package/packages/Icon/src/icons/simple-expand.js +14 -0
  142. package/packages/Icon/src/icons/sort.js +22 -0
  143. package/packages/Icon/src/icons/table.js +14 -0
  144. package/packages/Icon/src/icons/time.js +14 -0
  145. package/packages/Icon/src/icons/tree.js +14 -0
  146. package/packages/Icon/src/icons/typography.js +18 -0
  147. package/packages/Icon/src/icons/up-fold.js +18 -0
  148. package/packages/Icon/src/icons/upload.js +18 -0
  149. package/packages/Icon/src/icons/user.js +14 -0
  150. package/packages/Icon/src/icons/users.js +30 -0
  151. package/packages/Icon/src/icons/video.js +14 -0
  152. package/packages/Icon/src/icons/word.js +19 -0
  153. package/packages/Icon/src/main.vue +432 -0
  154. package/packages/Iframe/index.js +6 -0
  155. package/packages/Iframe/src/main.vue +208 -0
  156. package/packages/Image/index.js +7 -0
  157. package/packages/Image/src/main.vue +70 -0
  158. package/packages/Input/index.js +7 -0
  159. package/packages/Input/src/main.vue +659 -0
  160. package/packages/JobDialog/index.js +7 -0
  161. package/packages/JobDialog/src/main.vue +197 -0
  162. package/packages/JobSelector/index.js +7 -0
  163. package/packages/JobSelector/src/JobSelectorDialog.vue +305 -0
  164. package/packages/JobSelector/src/JobSelectorMobileDialog.vue +293 -0
  165. package/packages/JobSelector/src/main.vue +346 -0
  166. package/packages/JobSelectorInput/index.js +7 -0
  167. package/packages/JobSelectorInput/src/main.vue +166 -0
  168. package/packages/ListSelector/index.js +7 -0
  169. package/packages/ListSelector/src/ListSelector.vue +499 -0
  170. package/packages/Map/index.js +7 -0
  171. package/packages/Map/src/Map.vue +434 -0
  172. package/packages/Milepost/index.js +7 -0
  173. package/packages/Milepost/src/main.vue +45 -0
  174. package/packages/OnlineForm/index.js +7 -0
  175. package/packages/OnlineForm/src/Form.vue +659 -0
  176. package/packages/OrgPostDialog/index.js +7 -0
  177. package/packages/OrgPostDialog/src/main.vue +331 -0
  178. package/packages/OrgSelector/index.js +7 -0
  179. package/packages/OrgSelector/src/OrgSelectorDialog.vue +334 -0
  180. package/packages/OrgSelector/src/OrgSelectorMobileDialog.vue +307 -0
  181. package/packages/OrgSelector/src/Organization.vue +131 -0
  182. package/packages/OrgSelector/src/PolicyUser.vue +141 -0
  183. package/packages/OrgSelector/src/main.vue +409 -0
  184. package/packages/OrgSelectorInput/index.js +7 -0
  185. package/packages/OrgSelectorInput/src/OrgSelectorInput.vue +324 -0
  186. package/packages/PostDialog/index.js +7 -0
  187. package/packages/PostDialog/src/main.vue +309 -0
  188. package/packages/PostSelector/index.js +7 -0
  189. package/packages/PostSelector/src/Organization.vue +131 -0
  190. package/packages/PostSelector/src/PolicyUser.vue +141 -0
  191. package/packages/PostSelector/src/PostSelectorDialog.vue +342 -0
  192. package/packages/PostSelector/src/PostSelectorMobileDialog.vue +307 -0
  193. package/packages/PostSelector/src/main.vue +374 -0
  194. package/packages/PostSelectorInput/index.js +7 -0
  195. package/packages/PostSelectorInput/src/PostSelectorInput.vue +317 -0
  196. package/packages/Preview/index.js +7 -0
  197. package/packages/Preview/src/FillPage.vue +311 -0
  198. package/packages/Preview/src/FrameViewer.vue +157 -0
  199. package/packages/Preview/src/Loading.vue +126 -0
  200. package/packages/Preview/src/PdfViewer.vue +125 -0
  201. package/packages/Preview/src/TextViewer.vue +99 -0
  202. package/packages/Preview/src/main.vue +242 -0
  203. package/packages/Preview/src/watermark.js +124 -0
  204. package/packages/ProcessRecord/index.js +7 -0
  205. package/packages/ProcessRecord/src/main.vue +396 -0
  206. package/packages/Qrcode/index.js +7 -0
  207. package/packages/Qrcode/src/Qrcode.vue +110 -0
  208. package/packages/QuerySqlPreview/index.js +7 -0
  209. package/packages/QuerySqlPreview/src/QuerySqlPreview.vue +163 -0
  210. package/packages/Radio/index.js +7 -0
  211. package/packages/Radio/src/main.vue +174 -0
  212. package/packages/Rate/index.js +7 -0
  213. package/packages/Rate/src/main.vue +141 -0
  214. package/packages/ReadonlyInput/index.js +7 -0
  215. package/packages/ReadonlyInput/src/main.vue +92 -0
  216. package/packages/RelevantFlow/index.js +7 -0
  217. package/packages/RelevantFlow/src/main.vue +579 -0
  218. package/packages/RelevantFlow/src/relevantFlow.js +35 -0
  219. package/packages/RoleDialog/index.js +7 -0
  220. package/packages/RoleDialog/src/main.vue +198 -0
  221. package/packages/RoleSelector/index.js +7 -0
  222. package/packages/RoleSelector/src/RoleSelectorDialog.vue +307 -0
  223. package/packages/RoleSelector/src/RoleSelectorMobileDialog.vue +293 -0
  224. package/packages/RoleSelector/src/main.vue +367 -0
  225. package/packages/RoleSelectorInput/index.js +7 -0
  226. package/packages/RoleSelectorInput/src/main.vue +166 -0
  227. package/packages/SaveButton/index.js +7 -0
  228. package/packages/SaveButton/src/main.vue +73 -0
  229. package/packages/Select/index.js +7 -0
  230. package/packages/Select/src/main.vue +376 -0
  231. package/packages/SelectTree/index.js +7 -0
  232. package/packages/SelectTree/src/SelectTree.vue +360 -0
  233. package/packages/Selector/index.js +7 -0
  234. package/packages/Selector/src/main.vue +623 -0
  235. package/packages/SidebarDialog/index.js +7 -0
  236. package/packages/SidebarDialog/src/main.vue +156 -0
  237. package/packages/Slider/index.js +7 -0
  238. package/packages/Slider/src/main.vue +141 -0
  239. package/packages/Step/index.js +7 -0
  240. package/packages/StepLayout/index.js +7 -0
  241. package/packages/Steps/index.js +7 -0
  242. package/packages/Steps/src/Step.vue +139 -0
  243. package/packages/Steps/src/StepLayout.vue +35 -0
  244. package/packages/Steps/src/Steps.vue +65 -0
  245. package/packages/Subtable/index.js +33 -0
  246. package/packages/Subtable/src/SubDialog.vue +2145 -0
  247. package/packages/Subtable/src/SubExportDialog.vue +115 -0
  248. package/packages/Subtable/src/SubImportDialog.vue +340 -0
  249. package/packages/Subtable/src/SubPagination.vue +128 -0
  250. package/packages/Subtable/src/SubtableBackfill.vue +150 -0
  251. package/packages/Subtable/src/dialog.js +42 -0
  252. package/packages/Switch/index.js +7 -0
  253. package/packages/Switch/src/main.vue +92 -0
  254. package/packages/Table/index.js +7 -0
  255. package/packages/Table/src/CustomColumn.vue +353 -0
  256. package/packages/Table/src/Table.vue +1031 -0
  257. package/packages/TableColumn/index.js +7 -0
  258. package/packages/TableColumn/src/main.vue +189 -0
  259. package/packages/TableSearchField/index.js +7 -0
  260. package/packages/TableSearchField/src/main.vue +334 -0
  261. package/packages/TableSearchPanel/index.js +7 -0
  262. package/packages/TableSearchPanel/src/main.vue +182 -0
  263. package/packages/Tabs/index.js +7 -0
  264. package/packages/Tabs/src/Tabs.vue +140 -0
  265. package/packages/Tag/index.js +7 -0
  266. package/packages/Tag/src/main.vue +266 -0
  267. package/packages/TemplateBatchUpdate/index.js +7 -0
  268. package/packages/TemplateBatchUpdate/src/TemplateBatchUpdateDialog.vue +175 -0
  269. package/packages/TemplateForm/index.js +7 -0
  270. package/packages/TemplateForm/src/main.vue +661 -0
  271. package/packages/TemplateFormDialog/index.js +7 -0
  272. package/packages/TemplateFormDialog/src/main.vue +97 -0
  273. package/packages/TemplateIframeDialog/index.js +7 -0
  274. package/packages/TemplateIframeDialog/src/main.vue +72 -0
  275. package/packages/TemplateImportResult/index.js +7 -0
  276. package/packages/TemplateImportResult/src/main.vue +206 -0
  277. package/packages/TemplatePreview/index.js +19 -0
  278. package/packages/TemplatePreview/src/TemplatePreview.vue +239 -0
  279. package/packages/TemplatePreview/src/TemplatePreviewFile.vue +179 -0
  280. package/packages/TemplatePreview/src/TemplatePreviewImage.vue +83 -0
  281. package/packages/TemplateTaskCirculate/index.js +7 -0
  282. package/packages/TemplateTaskCirculate/src/main.vue +258 -0
  283. package/packages/Text/index.js +7 -0
  284. package/packages/Text/src/main.vue +58 -0
  285. package/packages/TimePicker/index.js +7 -0
  286. package/packages/TimePicker/src/main.vue +149 -0
  287. package/packages/TimeSelect/index.js +7 -0
  288. package/packages/TimeSelect/src/main.vue +106 -0
  289. package/packages/Tree/index.js +7 -0
  290. package/packages/Tree/src/main.vue +443 -0
  291. package/packages/TreeDialog/index.js +7 -0
  292. package/packages/TreeDialog/src/main.vue +322 -0
  293. package/packages/TreeListDialog/index.js +7 -0
  294. package/packages/TreeListDialog/src/main.vue +219 -0
  295. package/packages/Typography/index.js +8 -0
  296. package/packages/Typography/src/create-header.js +72 -0
  297. package/packages/UserDialog/index.js +7 -0
  298. package/packages/UserDialog/src/main.vue +393 -0
  299. package/packages/UserSelector/index.js +7 -0
  300. package/packages/UserSelector/src/Organization.vue +131 -0
  301. package/packages/UserSelector/src/PolicyUser.vue +141 -0
  302. package/packages/UserSelector/src/RoleUser.vue +139 -0
  303. package/packages/UserSelector/src/TopContactUser.vue +109 -0
  304. package/packages/UserSelector/src/UserSelectorDialog.vue +370 -0
  305. package/packages/UserSelector/src/UserSelectorMobileDialog.vue +332 -0
  306. package/packages/UserSelector/src/main.vue +519 -0
  307. package/packages/UserSelectorInput/index.js +7 -0
  308. package/packages/UserSelectorInput/src/main.vue +374 -0
  309. package/packages/picture/index.js +7 -0
  310. package/packages/picture/src/main.vue +736 -0
  311. package/packages/plugins/Echarts.js +30 -0
  312. package/packages/plugins/Map.js +29 -0
  313. package/packages/plugins/Preview.js +49 -0
  314. package/packages/plugins/Qrcode.js +7 -0
  315. package/packages/plugins/XLSX.js +7 -0
  316. package/packages/plugins/wangeditor.js +19 -0
  317. package/src/assets/icon_found_img.png +0 -0
  318. package/src/assets/no-data.png +0 -0
  319. package/src/assets/table-no-data.png +0 -0
  320. package/src/directive/badge.js +53 -0
  321. package/src/directive/copy.js +47 -0
  322. package/src/directive/ellipsis.js +6 -0
  323. package/src/directive/expandClick.js +23 -0
  324. package/src/directive/express.js +86 -0
  325. package/src/directive/form.js +122 -0
  326. package/src/directive/format.js +24 -0
  327. package/src/directive/formulas.js +710 -0
  328. package/src/directive/index.js +42 -0
  329. package/src/directive/permissionLine.js +59 -0
  330. package/src/directive/permissionLineLable.js +56 -0
  331. package/src/directive/permit.js +23 -0
  332. package/src/directive/popconfirm.js +86 -0
  333. package/src/directive/relatedQuery.js +61 -0
  334. package/src/directive/resize.js +18 -0
  335. package/src/directive/subSort.js +18 -0
  336. package/src/directive/tableDrag.js +25 -0
  337. package/src/directive/tooltip.js +37 -0
  338. package/src/filter/computerSize.js +23 -0
  339. package/src/filter/dateFormat.js +10 -0
  340. package/src/filter/index.js +10 -0
  341. package/src/index.js +295 -0
  342. package/src/locale/format.js +44 -0
  343. package/src/locale/index.js +48 -0
  344. package/src/locale/lang/en.js +59 -0
  345. package/src/locale/lang/zh-CN.js +59 -0
  346. package/src/locale/lang/zh-TW.js +57 -0
  347. package/src/locale/validate/dict.js +278 -0
  348. package/src/math.js +270 -0
  349. package/src/mixins/dialog.js +16 -0
  350. package/src/mixins/emitter.js +33 -0
  351. package/src/mixins/form.js +33 -0
  352. package/src/mixins/formDataUpdate.js +32 -0
  353. package/src/mixins/ganged.js +131 -0
  354. package/src/mixins/inputName.js +30 -0
  355. package/src/mixins/linkage.js +414 -0
  356. package/src/mixins/locale.js +9 -0
  357. package/src/mixins/mobileMode.js +27 -0
  358. package/src/mixins/onlineHottable.js +128 -0
  359. package/src/mixins/onlineSubtable.js +538 -0
  360. package/src/mixins/permission.js +94 -0
  361. package/src/mixins/querySqlPreview.js +852 -0
  362. package/src/mixins/regionValidator.js +70 -0
  363. package/src/mixins/script.js +37 -0
  364. package/src/mixins/templatePreview.js +4527 -0
  365. package/src/plugins/loading/index.js +37 -0
  366. package/src/plugins/loading/index.vue +18 -0
  367. package/src/service.js +336 -0
  368. package/src/services/CustomQuery.js +197 -0
  369. package/src/services/SubPagination.js +132 -0
  370. package/src/services/commonScripts.js +45 -0
  371. package/src/styles/index.scss +7 -0
  372. package/src/styles/selector.css +140 -0
  373. package/src/styles/selector.min.css +1 -0
  374. package/src/styles/selector.scss +130 -0
  375. package/src/styles/variables.css +67 -0
  376. package/src/styles/variables.min.css +1 -0
  377. package/src/styles/variables.scss +109 -0
  378. package/src/util/base64.js +46 -0
  379. package/src/util/brower.js +15 -0
  380. package/src/util/clone.js +61 -0
  381. package/src/util/path.js +4 -0
  382. package/src/util/request.js +14 -0
  383. package/src/utils.js +1242 -0
  384. package/src/validate.js +256 -0
package/src/utils.js ADDED
@@ -0,0 +1,1242 @@
1
+ import Vue from 'vue'
2
+
3
+ var utils = {
4
+ // 判断是否移动端设备
5
+ isMobile() {
6
+ const info = navigator.userAgent
7
+ const agents = [
8
+ 'Android',
9
+ 'iPhone',
10
+ 'SymbianOS',
11
+ 'Windows Phone',
12
+ 'iPod',
13
+ 'iPad',
14
+ ]
15
+ for (let i = 0; i < agents.length; i++) {
16
+ if (info.indexOf(agents[i]) >= 0) return true
17
+ }
18
+ return false
19
+ },
20
+ isEmpty: (value) => {
21
+ if (value === null || value === undefined || value === '') {
22
+ return true
23
+ }
24
+ return false
25
+ },
26
+ /**
27
+ *
28
+ *是否无效值
29
+ * @param {*} value
30
+ */
31
+ isVoid: (value) => {
32
+ return value === undefined || value === null || value === ''
33
+ },
34
+
35
+ /**
36
+ *
37
+ *去除对象中的无效值
38
+ * @param {*} object
39
+ * @return {*}
40
+ */
41
+ validObject: (object) => {
42
+ if (!object) {
43
+ return {}
44
+ }
45
+ const result = { ...object }
46
+ Object.keys(result).forEach((key) => {
47
+ const value = result[key]
48
+ if (utils.isVoid(value)) {
49
+ delete result[key]
50
+ }
51
+ })
52
+ return result
53
+ },
54
+ // 获取随机的名称
55
+ getName: () => {
56
+ return Math.random()
57
+ .toString(36)
58
+ .substr(2, 10)
59
+ },
60
+ // 获取控件是否可编辑
61
+ getWriteable: (permission) => {
62
+ if (permission === 'n' || permission === 'r') {
63
+ return false
64
+ }
65
+ return true
66
+ },
67
+ // 合并验证规则(如果rules和appendRules均为字符串格式,合并后仍为字符串格式;如果其中一个为Object格式,合并后为Object格式。)
68
+ mergeValidate: (rules, appendRules) => {
69
+ if (
70
+ !appendRules ||
71
+ (appendRules.constructor !== Object && appendRules.constructor !== String)
72
+ ) {
73
+ return rules
74
+ }
75
+ let rulesTypeIsString = true,
76
+ appendTypeIsString = appendRules.constructor === String,
77
+ finalTypeIsString = true
78
+ if (rules === undefined || rules === null) {
79
+ rulesTypeIsString = appendTypeIsString
80
+ rules = appendTypeIsString ? '' : {}
81
+ } else if (rules.constructor === Object || rules.constructor === String) {
82
+ rulesTypeIsString = rules.constructor === String
83
+ } else {
84
+ throw `rules的类型为${typeof rules},只能为Object类型或String类型。`
85
+ }
86
+ finalTypeIsString = rulesTypeIsString && appendTypeIsString
87
+ // 仍然以String格式
88
+ if (finalTypeIsString) {
89
+ const ruleAry = utils.stringSplit(rules, '|')
90
+ const appendAry = utils.stringSplit(appendRules, '|')
91
+ let ruleObj = {},
92
+ appendObj = {}
93
+ ruleAry.forEach((r) => {
94
+ const k = utils.stringSplit(r, ':')[0]
95
+ ruleObj[k] = r
96
+ })
97
+ appendAry.forEach((a) => {
98
+ const k = utils.stringSplit(a, ':')[0]
99
+ appendObj[k] = a
100
+ })
101
+ // 如果旧规则中存在与追加规则中的同名规则,则使用追加规则覆盖旧规则。
102
+ const mergeObj = Object.assign(ruleObj, appendObj)
103
+ return Object.values(mergeObj).join('|')
104
+ }
105
+ // 转换为Object格式
106
+ else {
107
+ let ruleObj = {},
108
+ appendObj = {}
109
+ if (rulesTypeIsString) {
110
+ ruleObj = utils.validateString2Object(rules)
111
+ } else {
112
+ ruleObj = { ...rules }
113
+ }
114
+ if (appendTypeIsString) {
115
+ appendObj = utils.validateString2Object(appendRules)
116
+ } else {
117
+ appendObj = { ...appendRules }
118
+ }
119
+ return Object.assign(ruleObj, appendObj)
120
+ }
121
+ },
122
+ // 减少校验规则
123
+ reduceValidate: (rules, reduceRules) => {
124
+ if (
125
+ !rules ||
126
+ !reduceRules ||
127
+ (reduceRules.constructor !== Object && reduceRules.constructor !== String)
128
+ ) {
129
+ return rules
130
+ }
131
+ // 要减少的校验规则的名称集合
132
+ let reduceRuleNames = []
133
+ if (reduceRules.constructor === String) {
134
+ const reduceRuleObj = utils.validateString2Object(reduceRules)
135
+ reduceRuleNames = Object.keys(reduceRuleObj)
136
+ } else {
137
+ reduceRuleNames = Object.keys(reduceRules)
138
+ }
139
+
140
+ if (rules.constructor === Object) {
141
+ Object.keys(rules).forEach((k) => {
142
+ if (reduceRuleNames.some((n) => n == k)) {
143
+ delete rules[k]
144
+ }
145
+ })
146
+ return rules
147
+ } else if (rules.constructor === String) {
148
+ const ruleAry = utils.stringSplit(rules, '|')
149
+ const nRuleAry = ruleAry.reduce((ary, r) => {
150
+ const name = utils.stringSplit(r, ':')[0]
151
+ if (reduceRuleNames.every((m) => m != name)) {
152
+ ary.push(r)
153
+ }
154
+ return ary
155
+ }, [])
156
+ return nRuleAry.join('|')
157
+ } else {
158
+ throw `rules的类型为${typeof rules},只能为Object类型或String类型。`
159
+ }
160
+ },
161
+ // 字符串格式的校验规则转为对象格式
162
+ validateString2Object: (rule) => {
163
+ if (!rule || rule.constructor !== String) {
164
+ return rule
165
+ }
166
+ let obj = {}
167
+ const ary = utils.stringSplit(rule, '|')
168
+ ary.forEach((m) => {
169
+ const regAndArgs = utils.stringSplit(m, ':')
170
+ if (regAndArgs.length == 1) {
171
+ obj[regAndArgs[0]] = true
172
+ } else if (regAndArgs.length > 1) {
173
+ const args = utils.stringSplit(regAndArgs[1], ',')
174
+ obj[regAndArgs[0]] = args
175
+ }
176
+ })
177
+ return obj
178
+ },
179
+ // 判断校验规则中是否至少包含指定规则中的一个
180
+ someRuleInValidate: (validate, rules) => {
181
+ if (
182
+ !validate ||
183
+ (validate.constructor !== Object && validate.constructor !== String) ||
184
+ !rules ||
185
+ rules.constructor !== Array ||
186
+ rules.length == 0
187
+ ) {
188
+ return false
189
+ }
190
+ let objs = validate
191
+ if (validate.constructor === String) {
192
+ objs = utils.validateString2Object(validate)
193
+ }
194
+ return Object.keys(objs).some((item) => rules.indexOf(item) > -1)
195
+ },
196
+ // 字符串str按照sep分割为数组,并清理掉数组结果中的空白项。
197
+ stringSplit: (str, sep) => {
198
+ if (
199
+ !str ||
200
+ str.constructor !== String ||
201
+ !sep ||
202
+ sep.constructor !== String
203
+ ) {
204
+ return []
205
+ }
206
+ let ary = str.split(sep)
207
+ ary = ary.map((p) => {
208
+ return p.trim()
209
+ })
210
+ ary = ary.trim()
211
+ return ary
212
+ },
213
+ // 获取控件是否添加必填校验
214
+ addRequiredOrNot: (permission, validate) => {
215
+ let finalValidate = validate
216
+ if (permission === 'b') {
217
+ finalValidate = utils.mergeValidate('required', validate)
218
+ }
219
+ return finalValidate || ''
220
+ },
221
+ // 格式化日期时间
222
+ formatDate: (value) => {
223
+ let date = null
224
+ if (!value) {
225
+ return date
226
+ }
227
+ if (value.constructor == Date && !isNaN(value.getTime())) {
228
+ date = value
229
+ } else if (value.constructor == String || value.constructor == Number) {
230
+ date = new Date(value)
231
+ } else {
232
+ throw '格式化日期时,传入的数据格式不正确。'
233
+ }
234
+ let y = date.getFullYear()
235
+ let MM = date.getMonth() + 1
236
+ MM = MM < 10 ? '0' + MM : MM
237
+ let d = date.getDate()
238
+ d = d < 10 ? '0' + d : d
239
+ let h = date.getHours()
240
+ h = h < 10 ? '0' + h : h
241
+ let m = date.getMinutes()
242
+ m = m < 10 ? '0' + m : m
243
+ let s = date.getSeconds()
244
+ s = s < 10 ? '0' + s : s
245
+ return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s
246
+ },
247
+ // 格式化日期
248
+ formatDateYear: (value) => {
249
+ let date = new Date(value)
250
+ let y = date.getFullYear()
251
+ let MM = date.getMonth() + 1
252
+ MM = MM < 10 ? '0' + MM : MM
253
+ let d = date.getDate()
254
+ d = d < 10 ? '0' + d : d
255
+ return y + '-' + MM + '-' + d
256
+ },
257
+ // 日期1是否早于日期2
258
+ dateIsBefore: (dateOne, dateTwo, canEquals) => {
259
+ if (!dateOne || !dateTwo) {
260
+ return true
261
+ }
262
+ //兼容苹果浏览器写法 "- 符号替换成/"
263
+ dateOne = dateOne.replace(/-/g, '/')
264
+ dateTwo = dateTwo.replace(/-/g, '/')
265
+ var date1 =
266
+ new Date(dateOne).getTime() ||
267
+ new Date(new Date().format('yyyy-MM-dd') + ' ' + dateOne).getTime()
268
+ var date2 =
269
+ new Date(dateTwo).getTime() ||
270
+ new Date(new Date().format('yyyy-MM-dd') + ' ' + dateTwo).getTime()
271
+ if (!canEquals) {
272
+ //大于。v2>v1 。
273
+ if (date2 > date1) {
274
+ return true
275
+ } else {
276
+ return false
277
+ }
278
+ } else {
279
+ //大于等于。v2>=v1 。只要v1不大于v2即可
280
+ if (date1 > date2) {
281
+ return false
282
+ } else {
283
+ return true
284
+ }
285
+ }
286
+ },
287
+ // 日期计算,不传单位时,默认以'天'为单位计算
288
+ dateCalc: (startDate, endDate, op) => {
289
+ if (
290
+ !startDate ||
291
+ !endDate ||
292
+ startDate.length == 0 ||
293
+ endDate.length == 0
294
+ ) {
295
+ return 0
296
+ }
297
+ if (!op || op.constructor != String) {
298
+ op = 'day'
299
+ }
300
+ const opAry = ['year', 'month', 'day', 'hour', 'minute', 'second']
301
+ if (opAry.indexOf(op) == -1) {
302
+ throw `计算日期的单位只能从${opAry}中选择`
303
+ }
304
+ let date1 = new Date(Date.parse(startDate.replace(/-/g, '/'))).getTime()
305
+ let date2 = new Date(Date.parse(endDate.replace(/-/g, '/'))).getTime()
306
+ if (!Number.isInteger(date1) || !Number.isInteger(date2)) {
307
+ const now = new Date()
308
+ let nowStr =
309
+ now.getFullYear() + '/' + (now.getMonth() + 1) + '/' + now.getDate()
310
+ if (!Number.isInteger(date1)) {
311
+ date1 = new Date(`${nowStr} ${startDate}`).getTime()
312
+ }
313
+ if (!Number.isInteger(date1)) {
314
+ date2 = new Date(`${nowStr} ${endDate}`).getTime()
315
+ }
316
+ if (!Number.isInteger(date1) || !Number.isInteger(date2)) {
317
+ return 0
318
+ }
319
+ }
320
+
321
+ let res = 0
322
+ let days = date2 - date1
323
+ switch (op) {
324
+ case 'year':
325
+ res = parseInt(days / (1000 * 60 * 60 * 24 * 30 * 12))
326
+ break
327
+ case 'month':
328
+ res = parseInt(days / (1000 * 60 * 60 * 24 * 30))
329
+ break
330
+ case 'day':
331
+ res = parseInt(days / (1000 * 60 * 60 * 24))
332
+ break
333
+ case 'hour':
334
+ res = parseInt(days / (1000 * 60 * 60))
335
+ break
336
+ case 'minute':
337
+ res = parseInt(days / (1000 * 60))
338
+ break
339
+ case 'second':
340
+ res = parseInt(days / 1000)
341
+ }
342
+ return res
343
+ },
344
+ // 计算两个日期的间隔时间,分别返回{ days, hours, minutes, seconds }的时间差
345
+ dateDuration: (startDate, endDate) => {
346
+ const days = utils.dateCalc(startDate, endDate, 'day')
347
+ const hours = utils.dateCalc(startDate, endDate, 'hour')
348
+ const minutes = utils.dateCalc(startDate, endDate, 'minute')
349
+ const seconds = utils.dateCalc(startDate, endDate, 'second')
350
+ return { days, hours, minutes, seconds }
351
+ },
352
+ // 树形结构数组 转换成平铺数组
353
+ nest2tile: (arr, childrenKey, obtainChildren) => {
354
+ if (!arr || arr.constructor !== Array) return
355
+ if (!childrenKey) {
356
+ childrenKey = 'children'
357
+ }
358
+ return [].concat(
359
+ ...arr.map((item) => {
360
+ let _item = { ...item }
361
+ if (obtainChildren == undefined || obtainChildren == false) {
362
+ delete _item[childrenKey]
363
+ }
364
+ if (item[childrenKey] && item[childrenKey].length) {
365
+ return [].concat(
366
+ _item,
367
+ ...utils.nest2tile(
368
+ item[childrenKey] || [],
369
+ childrenKey,
370
+ obtainChildren
371
+ )
372
+ )
373
+ } else {
374
+ return [].concat(_item)
375
+ }
376
+ })
377
+ )
378
+ },
379
+ // 平铺结构转嵌套结构
380
+ tile2nest: (array, key, pKey, childrenKey) => {
381
+ if (!array || array.constructor !== Array) {
382
+ return array
383
+ }
384
+ // 复制一份,避免修改原始数组
385
+ let ary = [...array]
386
+ key = key || 'id'
387
+ pKey = pKey || 'parentId'
388
+ childrenKey = childrenKey || 'children'
389
+ // 定义一个待移除数组
390
+ let ary2remove = []
391
+ ary.map((item) => {
392
+ // isLeaf 字段 'Y' or 'N' 转换为 true or false
393
+ if (item.isLeaf == 'N') {
394
+ item.isLeaf = false
395
+ }
396
+ if (item.isLeaf == 'Y') {
397
+ item.isLeaf = true
398
+ }
399
+ if (item[key] !== item[pKey]) {
400
+ // 找父节点
401
+ let p = ary.filter((c) => c[key] === item[pKey])
402
+ if (p && p.length == 1) {
403
+ p[0][childrenKey] = p[0][childrenKey] || []
404
+ // 将子节点放到父节点中
405
+ p[0][childrenKey].push(item)
406
+ ary2remove.push(item[key])
407
+ }
408
+ }
409
+ })
410
+ // 遍历移除待删除对象
411
+ ary2remove.map((item) => {
412
+ ary = ary.filter((c) => c[key] !== item)
413
+ })
414
+ return ary
415
+ },
416
+ // 获取控件所在表单对应的实例对象
417
+ getOnlineFormInstance: (instance) => {
418
+ if (instance == instance.$root) {
419
+ return instance
420
+ }
421
+ if (!instance) {
422
+ throw 'VueComponent实例为空.'
423
+ }
424
+ if (instance.hasOwnProperty('watchMap')) {
425
+ return instance
426
+ } else if (instance.$parent) {
427
+ return utils.getOnlineFormInstance(instance.$parent)
428
+ }
429
+ },
430
+ // 获取在线表单的HtRuntimeTemplate实例
431
+ getRuntimeTemplateOnlineForm: (instance) => {
432
+ if (instance == instance.$root) {
433
+ return instance
434
+ }
435
+ if (!instance) {
436
+ throw 'VueComponent实例为空.'
437
+ }
438
+ if (instance.$options.componentName == 'HtRuntimeTemplate') {
439
+ return instance
440
+ } else if (instance.$parent) {
441
+ return utils.getRuntimeTemplateOnlineForm(instance.$parent)
442
+ }
443
+ },
444
+ // 获取子表每一行所在的作用域元素及索引
445
+ getSubScopeElAndIndex: (el) => {
446
+ let subScopeEl = utils.getParentElementByAttribute(el, 'data-subname')
447
+ if (!subScopeEl) {
448
+ subScopeEl = utils.getParentElementByClassNamePrefix(el, 'data-subname__')
449
+ }
450
+ if (!subScopeEl) {
451
+ return { subScopeEl: null, index: null, subname: null }
452
+ }
453
+ let index = subScopeEl.dataset['index']
454
+ if (index === undefined) {
455
+ const dataIndexClass = subScopeEl.className
456
+ .split(' ')
457
+ .find((c) => c.startsWith('data-index__'))
458
+ if (dataIndexClass) {
459
+ index = dataIndexClass.replace('data-index__', 0)
460
+ }
461
+ }
462
+ if (index === undefined) {
463
+ throw '要计算的子表行未获取到index属性.'
464
+ }
465
+ index = Number.parseInt(index)
466
+ let subname = subScopeEl.dataset['subname']
467
+ if (!subname) {
468
+ const dataSubnameClass = subScopeEl.className
469
+ .split(' ')
470
+ .find((c) => c.startsWith('data-subname__'))
471
+ if (dataSubnameClass) {
472
+ subname = dataSubnameClass.replace('data-subname__', '')
473
+ }
474
+ }
475
+ // 判断是否子表有分页
476
+ if (subname) {
477
+ let subPageMap = utils.getSubtablePageVue(el)
478
+ if (
479
+ subPageMap &&
480
+ subPageMap.internalCurrentPage > 1 &&
481
+ index <
482
+ (subPageMap.internalCurrentPage - 1) * subPageMap.internalPageSize
483
+ ) {
484
+ index =
485
+ (subPageMap.internalCurrentPage - 1) * subPageMap.internalPageSize +
486
+ index
487
+ subScopeEl.dataset['index'] = index
488
+ }
489
+ }
490
+ return { subScopeEl, index, subname }
491
+ },
492
+ getSubtablePageVue(el) {
493
+ while (el && el.parentElement.nodeName != 'TABLE') {
494
+ el = el.parentElement
495
+ }
496
+ if (
497
+ el &&
498
+ el.parentElement &&
499
+ el.parentElement.getElementsByClassName('el-pagination') &&
500
+ el.parentElement.getElementsByClassName('el-pagination')[0] &&
501
+ el.parentElement.getElementsByClassName('el-pagination')[0].__vue__._data
502
+ ) {
503
+ return el.parentElement.getElementsByClassName('el-pagination')[0].__vue__
504
+ ._data
505
+ }
506
+ return null
507
+ },
508
+ // 在子表指定行中通过v-model表达式获取input对应的vue实例
509
+ getSubInputScopeByModelExpression: (subScopeEl, expression) => {
510
+ const inputAry = subScopeEl.getElementsByClassName('inputs')
511
+ let result = null
512
+ for (var i = 0, c; (c = inputAry[i++]); ) {
513
+ let expressionName =
514
+ c.__vue__.$vnode.data.model && c.__vue__.$vnode.data.model.expression
515
+ ? c.__vue__.$vnode.data.model.expression
516
+ : ''
517
+ // 兼容front端使用
518
+ if (
519
+ c.__vue__.$vnode &&
520
+ c.__vue__.$vnode.componentOptions &&
521
+ c.__vue__.$vnode.componentOptions.propsData &&
522
+ c.__vue__.$vnode.componentOptions.propsData.modelExpression
523
+ ) {
524
+ expressionName =
525
+ c.__vue__.$vnode.componentOptions.propsData.modelExpression
526
+ }
527
+ if (
528
+ c &&
529
+ c.__vue__ &&
530
+ c.__vue__.$vnode.data.model &&
531
+ expressionName === expression
532
+ ) {
533
+ result = c.__vue__
534
+ }
535
+ }
536
+ return result
537
+ },
538
+ // 获取在线表单的json格式字符串的表单数据(validate参数决定是否需要对表单进行验证)
539
+ validateForm: (instance, scopeName) => {
540
+ return new Promise((resolve, reject) => {
541
+ instance.$root.$validator.validateAll(scopeName).then((result) => {
542
+ if (result) {
543
+ resolve(result)
544
+ } else {
545
+ reject(instance.$root.$validator.errors.items)
546
+ }
547
+ })
548
+ })
549
+ },
550
+ // 获取指定dom元素的父级中具有指定属性的dom元素
551
+ getParentElementByAttribute: (el, attribute) => {
552
+ if (el === null || el === undefined) {
553
+ return null
554
+ }
555
+ if (!el.hasAttribute || typeof el.hasAttribute != 'function') {
556
+ throw '传入的元素el不能为空且必须为HTMLHtmlElement类型.'
557
+ }
558
+ if (!attribute || attribute.constructor !== String) {
559
+ throw '传入的属性attribute不能为空且必须为String类型.'
560
+ }
561
+ if (el.hasAttribute(attribute)) {
562
+ return el
563
+ } else if (el.tagName === 'HTML') {
564
+ return null
565
+ } else {
566
+ return utils.getParentElementByAttribute(el.parentElement, attribute)
567
+ }
568
+ },
569
+ // 获取指定dom元素的父级中具有指定class前缀的dom元素
570
+ getParentElementByClassNamePrefix: (el, classNamePrefix) => {
571
+ if (el === null || el === undefined) {
572
+ return null
573
+ }
574
+ if (!el.hasAttribute || typeof el.hasAttribute != 'function') {
575
+ throw '传入的元素el不能为空且必须为HTMLHtmlElement类型.'
576
+ }
577
+ if (!classNamePrefix || classNamePrefix.constructor !== String) {
578
+ throw '传入的classNamePrefix不能为空且必须为String类型.'
579
+ }
580
+ const classNames = el.className.split(' ')
581
+ if (classNames && classNames.some((c) => c.startsWith(classNamePrefix))) {
582
+ return el
583
+ } else if (el.tagName === 'HTML') {
584
+ return null
585
+ } else {
586
+ return utils.getParentElementByClassNamePrefix(
587
+ el.parentElement,
588
+ classNamePrefix
589
+ )
590
+ }
591
+ },
592
+ // 从父级dom元素中获取指定属性的值
593
+ getSomeAttributeFromParentElement: (el, attribute) => {
594
+ let pEl = utils.getParentElementByAttribute(el, attribute)
595
+ if (pEl && pEl.getAttribute && pEl.getAttribute.constructor === Function) {
596
+ return pEl.getAttribute(attribute)
597
+ }
598
+ return null
599
+ },
600
+ // 将子表属性路径转换为完整的属性路径,例如:item.name => data.sub[0].name
601
+ getWholePathOfSub: function getWholePathOfSub(subPath, mainPath, index) {
602
+ if (!subPath || !mainPath || index === null || !Number.isInteger(index)) {
603
+ return null
604
+ }
605
+
606
+ var match = subPath.split('.')
607
+
608
+ if (match && match.length > 1) {
609
+ return ''
610
+ .concat(mainPath, '[')
611
+ .concat(index, '].')
612
+ .concat(match[match.length - 1])
613
+ }
614
+
615
+ return null
616
+ },
617
+ // 通过路径取得对象中的属性
618
+ getValueByPath: (obj, path, subIndex) => {
619
+ if (!obj || !path || path.constructor != String) {
620
+ return null
621
+ }
622
+ if (!/^\w?.*[\w|\]]$/.test(path)) {
623
+ return null
624
+ }
625
+ let pathAry = path.split('.')
626
+ if (pathAry.length == 1) {
627
+ return obj[path]
628
+ } else if (pathAry.length > 1) {
629
+ let ret = obj
630
+ for (var i = 0; i < pathAry.length; i++) {
631
+ if (ret === null || ret === undefined) {
632
+ return null
633
+ }
634
+ const key = pathAry[i]
635
+ const match = /^(\w+)\[(\d+)\]$/.exec(key)
636
+ if (match) {
637
+ ret = ret[match[1]][match[2]]
638
+ } else if (ret && ret.constructor === Array) {
639
+ let index = 0
640
+ if (subIndex != null && subIndex != undefined) {
641
+ let preIndex = Number.parseInt(subIndex)
642
+ if (!isNaN(preIndex)) {
643
+ index = preIndex
644
+ }
645
+ }
646
+ ret = ret[index][key]
647
+ } else {
648
+ ret = ret[key]
649
+ }
650
+ }
651
+ return ret
652
+ }
653
+ return null
654
+ },
655
+ // 通过路径设置对象中的属性
656
+ setValueByPath: (obj, path, value, subIndex) => {
657
+ if (!obj || !path || path.constructor != String) {
658
+ return
659
+ }
660
+ if (!/^\w?.*[\w|\]]$/.test(path)) {
661
+ return
662
+ }
663
+ let pathAry = path.split('.')
664
+ if (pathAry.length == 1) {
665
+ obj[path] = value
666
+ } else if (pathAry.length > 1) {
667
+ let ret = obj
668
+ for (var i = 0; i < pathAry.length; i++) {
669
+ const key = pathAry[i]
670
+ const match = /^(\w+)\[(\d+)\]$/.exec(key)
671
+ if (i == pathAry.length - 1) {
672
+ if (match) {
673
+ ret[match[1]][match[2]] = value
674
+ } else if (ret && ret.constructor === Array) {
675
+ let index = 0
676
+ if (subIndex != null && subIndex != undefined) {
677
+ let preIndex = Number.parseInt(subIndex)
678
+ if (!isNaN(preIndex)) {
679
+ index = preIndex
680
+ }
681
+ }
682
+ if (!ret[index][key]) {
683
+ Vue.prototype.$set(ret[index], key, value)
684
+ } else {
685
+ ret[index][key] = value
686
+ }
687
+ } else {
688
+ ret[key] = value
689
+ }
690
+ } else {
691
+ if (match) {
692
+ ret = ret[match[1]][match[2]]
693
+ } else {
694
+ ret = ret[key]
695
+ }
696
+ }
697
+ }
698
+ }
699
+ },
700
+ /**
701
+ * 将字符串转为json对象。
702
+ * @param jsonStr
703
+ * @param type 可不填写parseToJson
704
+ * @returns
705
+ */
706
+ parseToJson: (jsonStr, type) => {
707
+ type = type || 1
708
+ if (!jsonStr || jsonStr === '') return null
709
+ try {
710
+ let obj
711
+ switch (type) {
712
+ case 1:
713
+ obj = JSON.parse(jsonStr)
714
+ break
715
+ case 2:
716
+ obj = eval(`(${jsonStr})`)
717
+ break
718
+ default:
719
+ throw '解析json对象错误'
720
+ }
721
+ return obj
722
+ } catch (e) {
723
+ return utils.parseToJson(jsonStr, type + 1)
724
+ }
725
+ },
726
+ /**
727
+ * 将数字转换成人名币大写。
728
+ *
729
+ * @param currencyDigits
730
+ * @returns
731
+ */
732
+ convertCurrency: (currencyDigits) => {
733
+ var MAXIMUM_NUMBER = 99999999999.99
734
+ var CN_ZERO = '零'
735
+ var CN_ONE = '壹'
736
+ var CN_TWO = '贰'
737
+ var CN_THREE = '叁'
738
+ var CN_FOUR = '肆'
739
+ var CN_FIVE = '伍'
740
+ var CN_SIX = '陆'
741
+ var CN_SEVEN = '柒'
742
+ var CN_EIGHT = '捌'
743
+ var CN_NINE = '玖'
744
+ var CN_TEN = '拾'
745
+ var CN_HUNDRED = '佰'
746
+ var CN_THOUSAND = '仟'
747
+ var CN_TEN_THOUSAND = '万'
748
+ var CN_HUNDRED_MILLION = '亿'
749
+ var CN_SYMBOL = ''
750
+ var CN_DOLLAR = '元'
751
+ var CN_TEN_CENT = '角'
752
+ var CN_CENT = '分'
753
+ var CN_INTEGER = '整'
754
+ var integral
755
+ var decimal
756
+ var outputCharacters
757
+ var parts
758
+ var digits, radices, bigRadices, decimals
759
+ var zeroCount
760
+ var i, p, d
761
+ var quotient, modulus
762
+ currencyDigits = currencyDigits.toString()
763
+ if (currencyDigits == '') {
764
+ return ''
765
+ }
766
+ if (currencyDigits.match(/[^,.\d]/) != null) {
767
+ return ''
768
+ }
769
+ if (
770
+ currencyDigits.match(
771
+ /^((\d{1,3}(,\d{3})*(.((\d{3},)*\d{1,3}))?)|(\d+(.\d+)?))$/
772
+ ) == null
773
+ ) {
774
+ return ''
775
+ }
776
+ currencyDigits = currencyDigits.replace(/,/g, '')
777
+ currencyDigits = currencyDigits.replace(/^0+/, '')
778
+
779
+ if (Number(currencyDigits) > MAXIMUM_NUMBER) {
780
+ return ''
781
+ }
782
+
783
+ parts = currencyDigits.split('.')
784
+ if (parts.length > 1) {
785
+ integral = parts[0]
786
+ decimal = parts[1]
787
+
788
+ decimal = decimal.substr(0, 2)
789
+ } else {
790
+ integral = parts[0]
791
+ decimal = ''
792
+ }
793
+
794
+ digits = new Array(
795
+ CN_ZERO,
796
+ CN_ONE,
797
+ CN_TWO,
798
+ CN_THREE,
799
+ CN_FOUR,
800
+ CN_FIVE,
801
+ CN_SIX,
802
+ CN_SEVEN,
803
+ CN_EIGHT,
804
+ CN_NINE
805
+ )
806
+ radices = new Array('', CN_TEN, CN_HUNDRED, CN_THOUSAND)
807
+ bigRadices = new Array('', CN_TEN_THOUSAND, CN_HUNDRED_MILLION)
808
+ decimals = new Array(CN_TEN_CENT, CN_CENT)
809
+
810
+ outputCharacters = ''
811
+
812
+ if (Number(integral) > 0) {
813
+ zeroCount = 0
814
+ for (i = 0; i < integral.length; i++) {
815
+ p = integral.length - i - 1
816
+ d = integral.substr(i, 1)
817
+ quotient = p / 4
818
+ modulus = p % 4
819
+ if (d == '0') {
820
+ zeroCount++
821
+ } else {
822
+ if (zeroCount > 0) {
823
+ outputCharacters += digits[0]
824
+ }
825
+ zeroCount = 0
826
+ outputCharacters += digits[Number(d)] + radices[modulus]
827
+ }
828
+ if (modulus == 0 && zeroCount < 4) {
829
+ outputCharacters += bigRadices[quotient]
830
+ }
831
+ }
832
+ outputCharacters += CN_DOLLAR
833
+ }
834
+
835
+ if (decimal != '') {
836
+ for (i = 0; i < decimal.length; i++) {
837
+ d = decimal.substr(i, 1)
838
+ if (d != '0') {
839
+ outputCharacters += digits[Number(d)] + decimals[i]
840
+ }
841
+ }
842
+ }
843
+
844
+ if (outputCharacters == '') {
845
+ outputCharacters = CN_ZERO + CN_DOLLAR
846
+ }
847
+ if (decimal == '') {
848
+ outputCharacters += CN_INTEGER
849
+ }
850
+ outputCharacters = CN_SYMBOL + outputCharacters
851
+ return outputCharacters
852
+ },
853
+ /**
854
+ * 通过name获取页面url地址参数
855
+ * @param name
856
+ * @returns
857
+ *
858
+ */
859
+ getUrlKey: (name) => {
860
+ return (
861
+ decodeURIComponent(
862
+ (new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(
863
+ location.href
864
+ ) || ['', ''])[1].replace(/\+/g, '%20')
865
+ ) || null
866
+ )
867
+ },
868
+ // 返回调整顺序后的数组 part:数组中的一个或多个元素, direct:调整的方向 up:向上 down:向下
869
+ arrayMove: (ary, part, direct) => {
870
+ direct = direct || 'down'
871
+ if (!part || (part.constructor !== Object && part.constructor !== Array)) {
872
+ return ary
873
+ }
874
+ if (part.constructor === Object) {
875
+ part = [part]
876
+ }
877
+ if (direct == 'up') {
878
+ part.forEach((m) => {
879
+ let index = ary.indexOf(m, 1)
880
+ if (index > 0) {
881
+ let newAry = [...ary]
882
+ newAry[index - 1] = ary[index]
883
+ newAry[index] = ary[index - 1]
884
+ ary = newAry
885
+ }
886
+ })
887
+ } else if (direct == 'down') {
888
+ for (var i = part.length - 1, m; (m = part[i--]); ) {
889
+ let index = ary.indexOf(m, 0)
890
+ if (index > -1 && index < ary.length - 1) {
891
+ let newAry = [...ary]
892
+ newAry[index + 1] = ary[index]
893
+ newAry[index] = ary[index + 1]
894
+ ary = newAry
895
+ }
896
+ }
897
+ }
898
+ return ary
899
+ },
900
+ // 通过配置中指定的key所对应的属性路径在当前表单中获取对应的值,支持通过data.main.name 或者是 item.name来分别获取主表数据及子表数据的情况
901
+ getValueByConfigKey: (inst, config, key) => {
902
+ if (!config.hasOwnProperty(key)) {
903
+ throw `config对象中未找到属性${key}`
904
+ }
905
+ const keyPath = config[key]
906
+ // 获取当前组件所在的表单
907
+ const formInst = utils.getOnlineFormInstance(inst.$parent)
908
+ // 获取当前组件是否在子表中的某一行
909
+ const { subScopeEl, index, subname } = utils.getSubScopeElAndIndex(inst.$el)
910
+ if (subScopeEl) {
911
+ //判断是否有孙表
912
+ let paths = subname
913
+ if (paths.split('.').length == 4 && paths.indexOf('[') == -1) {
914
+ //孙表回填路径
915
+ paths =
916
+ paths.split('.')[0] +
917
+ '.' +
918
+ paths.split('.')[1] +
919
+ '.' +
920
+ paths.split('.')[2] +
921
+ '[' +
922
+ index +
923
+ ']' +
924
+ '.' +
925
+ paths.split('.')[3]
926
+ }
927
+ // 将item.name这样的路径替换为data.sub[0].name这样的全路径格式
928
+ let wholeKeyPath = utils.getWholePathOfSub(keyPath, paths, index)
929
+ return utils.getValueByPath(formInst, wholeKeyPath)
930
+ } else {
931
+ return utils.getValueByPath(formInst, keyPath)
932
+ }
933
+ },
934
+ // 通过配置中指定的key来设置值到对应的属性路径上,支持设置主表数据data.main.name 或设置子表数据item.name
935
+ setValueByConfigKey: (inst, config, key, value) => {
936
+ if (!config.hasOwnProperty(key)) {
937
+ return
938
+ }
939
+ const keyPath = config[key]
940
+ // 获取当前组件所在的表单
941
+ const formInst = utils.getOnlineFormInstance(inst.$parent)
942
+ // 获取当前组件是否在子表中的某一行
943
+ const { subScopeEl, index, subname } = utils.getSubScopeElAndIndex(inst.$el)
944
+ if (subScopeEl) {
945
+ //判断是否有孙表
946
+ let paths = subname
947
+ if (paths.split('.').length == 4 && paths.indexOf('[') == -1) {
948
+ //孙表回填路径
949
+ paths =
950
+ paths.split('.')[0] +
951
+ '.' +
952
+ paths.split('.')[1] +
953
+ '.' +
954
+ paths.split('.')[2] +
955
+ '[' +
956
+ index +
957
+ ']' +
958
+ '.' +
959
+ paths.split('.')[3]
960
+ }
961
+ // 将item.name这样的路径替换为data.sub[0].name这样的全路径格式
962
+ let wholeKeyPath = utils.getWholePathOfSub(keyPath, paths, index)
963
+ utils.setValueByPath(formInst, wholeKeyPath, value)
964
+ } else {
965
+ utils.setValueByPath(formInst, keyPath, value)
966
+ }
967
+ },
968
+ // 判断两个对象是否相等(props为属性数组,有传入时,只比对传入的属性是否相等)
969
+ objectEquals: (obj1, obj2, props) => {
970
+ if (!props || props.constructor !== Array) {
971
+ props = []
972
+ }
973
+ if (!obj1 || !obj2) {
974
+ return obj1 === obj2
975
+ }
976
+ for (let propName in obj1) {
977
+ if (props.length > 0 && props.indexOf(propName) === -1) {
978
+ continue
979
+ }
980
+ if (obj1.hasOwnProperty(propName) != obj2.hasOwnProperty(propName)) {
981
+ return false
982
+ } else if (typeof obj1[propName] != typeof obj2[propName]) {
983
+ return false
984
+ }
985
+ }
986
+ for (let propName in obj2) {
987
+ if (props.length > 0 && props.indexOf(propName) === -1) {
988
+ continue
989
+ }
990
+ if (obj1.hasOwnProperty(propName) != obj2.hasOwnProperty(propName)) {
991
+ return false
992
+ } else if (typeof obj1[propName] != typeof obj2[propName]) {
993
+ return false
994
+ }
995
+ if (!obj1.hasOwnProperty(propName)) {
996
+ continue
997
+ }
998
+ if (obj1[propName] instanceof Array && obj2[propName] instanceof Array) {
999
+ if (!utils.arrayEquals(obj1[propName], obj2[propName])) {
1000
+ return false
1001
+ }
1002
+ } else if (
1003
+ obj1[propName] instanceof Object &&
1004
+ obj2[propName] instanceof Object
1005
+ ) {
1006
+ if (!utils.objectEquals(obj1[propName], obj2[propName])) {
1007
+ return false
1008
+ }
1009
+ } else if (obj1[propName] != obj2[propName]) {
1010
+ return false
1011
+ }
1012
+ }
1013
+ return true
1014
+ },
1015
+ // 判断两个数组是否相等,支持数组中元素为对象时的深度对比
1016
+ arrayEquals: (ary1, ary2) => {
1017
+ if (!ary1 || !ary2) {
1018
+ return ary1 === ary2
1019
+ }
1020
+
1021
+ if (ary1.length != ary2.length) {
1022
+ return false
1023
+ }
1024
+
1025
+ for (var i = 0, l = ary1.length; i < l; i++) {
1026
+ if (ary1[i] instanceof Array && ary2[i] instanceof Array) {
1027
+ if (!utils.arrayEquals(ary1[i], ary2[i])) {
1028
+ return false
1029
+ }
1030
+ } else if (ary1[i] instanceof Object && ary2[i] instanceof Object) {
1031
+ if (!utils.objectEquals(ary1[i], ary2[i])) {
1032
+ return false
1033
+ }
1034
+ } else if (ary1[i] != ary2[i]) {
1035
+ return false
1036
+ }
1037
+ }
1038
+ return true
1039
+ },
1040
+ // 以第一行文本的缩进空格数为基准,后续的每一行都去掉这个基准所对应的空格。
1041
+ trimEachLine: (text) => {
1042
+ if (!text || text.constructor != String || text.indexOf('\n') == -1) {
1043
+ return text
1044
+ }
1045
+ let ary = text.split('\n'),
1046
+ totem = 0
1047
+ return ary.reduce((prev, cur, index) => {
1048
+ if (index == 1) {
1049
+ const match = /^(\s+).*$/.exec(cur)
1050
+ match && match.length == 2 && (totem = match[1].length)
1051
+ }
1052
+ return prev + '\n' + cur.slice(totem, cur.length)
1053
+ })
1054
+ },
1055
+ // 获取字符串的哈希编码
1056
+ hashCode: (text) => {
1057
+ var hash = 0,
1058
+ char
1059
+ if (text.length == 0) return hash
1060
+ for (var i = 0; i < text.length; i++) {
1061
+ char = text.charCodeAt(i)
1062
+ hash = (hash << 5) - hash + char
1063
+ hash = hash & hash
1064
+ }
1065
+ return hash
1066
+ },
1067
+ // 使用ctx对象中的值替换掉exp中所有的${key}
1068
+ parseExp: (exp, ctx) => {
1069
+ if (!exp || exp.constructor != String) return exp
1070
+ ctx = ctx || {}
1071
+ var reg = /(\$\{(\w+)\})/,
1072
+ match = null,
1073
+ count = 0
1074
+
1075
+ while ((match = reg.exec(exp))) {
1076
+ count++
1077
+ // 避免死循环
1078
+ if (count > 999) {
1079
+ break
1080
+ }
1081
+ if (match != null) {
1082
+ exp = exp.replace(
1083
+ match[1],
1084
+ ctx.hasOwnProperty(match[2]) ? ctx[match[2]] : ''
1085
+ )
1086
+ }
1087
+ }
1088
+ return exp
1089
+ },
1090
+ /**
1091
+ * 数字格式转换成千分位
1092
+ *@param{Object}num
1093
+ */
1094
+ thousandBit: (num) => {
1095
+ if ((num + '').trim() == '') {
1096
+ return ''
1097
+ }
1098
+ if (isNaN(num)) {
1099
+ return num
1100
+ }
1101
+ num = num + ''
1102
+ if (/^.*\..*$/.test(num)) {
1103
+ const pointIndex = num.lastIndexOf('.')
1104
+ const pointPart = num.substring(pointIndex + 1, num.length)
1105
+ let intPart = num.substring(0, pointIndex)
1106
+ intPart = intPart + ''
1107
+ const re = /(-?\d+)(\d{3})/
1108
+ while (re.test(intPart)) {
1109
+ intPart = intPart.replace(re, '$1,$2')
1110
+ }
1111
+ num = intPart + '.' + pointPart
1112
+ } else {
1113
+ num = num + ''
1114
+ const re = /(-?\d+)(\d{3})/
1115
+ while (re.test(num)) {
1116
+ num = num.replace(re, '$1,$2')
1117
+ }
1118
+ }
1119
+ return num
1120
+ },
1121
+ // 解析URL地址,如果url地址包含了${form}这样的占位符,会按照sso.js中配置的对应服务的地址替换。
1122
+ parseUrl: (url) => {
1123
+ if (url === '') return
1124
+ var ctx = window.context,
1125
+ reg = /^(\$\{(\w+)\})\/.*$/
1126
+
1127
+ var match = reg.exec(url)
1128
+ if (match != null) {
1129
+ var name = match[2],
1130
+ mc = match[1],
1131
+ val = ctx[name]
1132
+ if (!val) {
1133
+ throw new Error(
1134
+ "The '" +
1135
+ name +
1136
+ "' in url:" +
1137
+ url +
1138
+ ' does not defined in context provider.'
1139
+ )
1140
+ }
1141
+ return url.replace(mc, val)
1142
+ } else {
1143
+ return url
1144
+ }
1145
+ },
1146
+ }
1147
+
1148
+ // 在数组上扩展一个删除指定项的方法
1149
+ Array.prototype.remove = function(item) {
1150
+ let index = this.findIndex((v) => v === item)
1151
+ if (index > -1) {
1152
+ this.splice(index, 1)
1153
+ }
1154
+ }
1155
+
1156
+ // 在数组上扩展一个去重的方法
1157
+ Array.prototype.unique = function(arg) {
1158
+ const res = new Map()
1159
+ return this.filter((m) => {
1160
+ if (arg) {
1161
+ return !res.has(m[arg]) && res.set(m[arg], 1)
1162
+ } else {
1163
+ return !res.has(m) && res.set(m, 1)
1164
+ }
1165
+ })
1166
+ }
1167
+
1168
+ // 去除数组中的空字符串选项
1169
+ Array.prototype.trim = function() {
1170
+ return this.filter((m) => m !== '')
1171
+ }
1172
+
1173
+ // 按照数组中的指定key将数组进行分组
1174
+ Array.prototype.groupByKey = function(key) {
1175
+ let res = {}
1176
+ this.forEach((m) => {
1177
+ let group = res[m[key]]
1178
+ if (!group) {
1179
+ group = []
1180
+ res[m[key]] = group
1181
+ }
1182
+ group.push(m)
1183
+ })
1184
+ return res
1185
+ }
1186
+
1187
+ // 将数组对象中的某一个属性值单独抽取出来成为一个新的数组 [{id:'1',name:'苹果'},{id:'2',name:'香蕉'}].extractByKey("id") ==> ['1','2']
1188
+ Array.prototype.extractByKey = function(key) {
1189
+ let set = new Set()
1190
+ this.forEach((m) => {
1191
+ if (key && m[key]) {
1192
+ set.add(m[key])
1193
+ }
1194
+ })
1195
+ return Array.from(set)
1196
+ }
1197
+
1198
+ /**
1199
+ * 日期格式化。
1200
+ * 日期格式:
1201
+ * yyyy,yy 年份
1202
+ * MM 大写表示月份
1203
+ * dd 表示日期
1204
+ * hh 表示小时
1205
+ * mm 表示分钟
1206
+ * ss 表示秒
1207
+ * q 表示季度
1208
+ * 实例如下:
1209
+ * var now = new Date();
1210
+ * var nowStr = now.format("yyyy-MM-dd hh:mm:ss");
1211
+ */
1212
+ Date.prototype.format = function(format) {
1213
+ var o = {
1214
+ 'M+': this.getMonth() + 1, //month
1215
+ 'd+': this.getDate(), //day
1216
+ 'h+': this.getHours(), //hour
1217
+ 'H+': this.getHours(), //hour
1218
+ 'm+': this.getMinutes(), //minute
1219
+ 's+': this.getSeconds(), //second
1220
+ 'q+': Math.floor((this.getMonth() + 3) / 3), //quarter
1221
+ S: this.getMilliseconds(), //millisecond
1222
+ }
1223
+
1224
+ if (/(y+)/.test(format)) {
1225
+ format = format.replace(
1226
+ RegExp.$1,
1227
+ (this.getFullYear() + '').substr(4 - RegExp.$1.length)
1228
+ )
1229
+ }
1230
+
1231
+ for (var k in o) {
1232
+ if (new RegExp('(' + k + ')').test(format)) {
1233
+ format = format.replace(
1234
+ RegExp.$1,
1235
+ RegExp.$1.length == 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length)
1236
+ )
1237
+ }
1238
+ }
1239
+ return format
1240
+ }
1241
+
1242
+ export default utils