cnhis-design-vue 2.1.57 → 2.1.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (574) hide show
  1. package/.prettierrc.js +27 -27
  2. package/CHANGELOG.md +2610 -2634
  3. package/README.md +90 -90
  4. package/commitlint.config.js +1 -1
  5. package/es/affix/index.js +8 -8
  6. package/es/age/index.js +18 -18
  7. package/es/alert/index.js +8 -8
  8. package/es/anchor/index.js +8 -8
  9. package/es/auto-complete/index.js +8 -8
  10. package/es/avatar/index.js +8 -8
  11. package/es/back-top/index.js +8 -8
  12. package/es/badge/index.js +8 -8
  13. package/es/base/index.js +8 -8
  14. package/es/big-table/index.js +345 -333
  15. package/es/big-table/style.css +1 -1
  16. package/es/breadcrumb/index.js +8 -8
  17. package/es/button/index.js +31 -31
  18. package/es/calendar/index.js +8 -8
  19. package/es/captcha/index.js +7 -7
  20. package/es/card/index.js +8 -8
  21. package/es/carousel/index.js +8 -8
  22. package/es/cascader/index.js +8 -8
  23. package/es/checkbox/index.js +17 -17
  24. package/es/col/index.js +8 -8
  25. package/es/collapse/index.js +8 -8
  26. package/es/color-picker/index.js +5 -5
  27. package/es/comment/index.js +8 -8
  28. package/es/config-provider/index.js +8 -8
  29. package/es/date-picker/index.js +30 -30
  30. package/es/descriptions/index.js +8 -8
  31. package/es/divider/index.js +8 -8
  32. package/es/drag-layout/index.js +5 -5
  33. package/es/drawer/index.js +8 -8
  34. package/es/dropdown/index.js +8 -8
  35. package/es/editor/index.js +1 -1
  36. package/es/ellipsis/index.js +1 -1
  37. package/es/empty/index.js +8 -8
  38. package/es/fabric-chart/index.js +724 -436
  39. package/es/fabric-chart/style.css +1 -1
  40. package/es/form/index.js +8 -8
  41. package/es/form-model/index.js +8 -8
  42. package/es/form-table/index.js +221 -189
  43. package/es/form-table/style.css +1 -1
  44. package/es/grid/index.js +4 -4
  45. package/es/index/index.js +2042 -1695
  46. package/es/index/style.css +1 -1
  47. package/es/input/index.js +11 -11
  48. package/es/input-number/index.js +8 -8
  49. package/es/keep-cache/index.js +9 -9
  50. package/es/layout/index.js +8 -8
  51. package/es/list/index.js +8 -8
  52. package/es/locale-provider/index.js +8 -8
  53. package/es/map/index.js +13 -13
  54. package/es/mentions/index.js +8 -8
  55. package/es/menu/index.js +8 -8
  56. package/es/message/index.js +8 -8
  57. package/es/multi-chat/index.js +116 -116
  58. package/es/multi-chat-client/index.js +110 -110
  59. package/es/multi-chat-history/index.js +6 -6
  60. package/es/multi-chat-record/index.js +27 -27
  61. package/es/multi-chat-setting/index.js +43 -43
  62. package/es/multi-chat-sip/index.js +1 -1
  63. package/es/notification/index.js +8 -8
  64. package/es/page-header/index.js +8 -8
  65. package/es/pagination/index.js +8 -8
  66. package/es/popconfirm/index.js +8 -8
  67. package/es/popover/index.js +8 -8
  68. package/es/progress/index.js +8 -8
  69. package/es/radio/index.js +17 -17
  70. package/es/rate/index.js +8 -8
  71. package/es/result/index.js +8 -8
  72. package/es/row/index.js +8 -8
  73. package/es/scale-container/index.js +28 -23
  74. package/es/scale-container/style.css +1 -1
  75. package/es/scale-view/index.js +158 -158
  76. package/es/select/index.js +44 -44
  77. package/es/select-label/index.js +50 -50
  78. package/es/select-person/index.js +20 -20
  79. package/es/shortcut-setter/index.js +10 -10
  80. package/es/skeleton/index.js +8 -8
  81. package/es/slider/index.js +8 -8
  82. package/es/space/index.js +8 -8
  83. package/es/spin/index.js +8 -8
  84. package/es/statistic/index.js +8 -8
  85. package/es/steps/index.js +8 -8
  86. package/es/switch/index.js +8 -8
  87. package/es/table-filter/index.js +253 -238
  88. package/es/table-filter/style.css +1 -1
  89. package/es/tabs/index.js +8 -8
  90. package/es/tag/index.js +9 -9
  91. package/es/time-picker/index.js +8 -8
  92. package/es/timeline/index.js +8 -8
  93. package/es/tooltip/index.js +8 -8
  94. package/es/transfer/index.js +8 -8
  95. package/es/tree/index.js +8 -8
  96. package/es/tree-select/index.js +8 -8
  97. package/es/upload/index.js +8 -8
  98. package/es/utils/clickoutside.js +7 -7
  99. package/es/utils/kty.min-1.0.0.js +5 -5
  100. package/es/utils/time-domain.js +16 -16
  101. package/es/utils/utils-map.js +32 -32
  102. package/es/utils/vexutils.js +27 -27
  103. package/es/verification-code/index.js +2 -2
  104. package/lib/cui.common.js +2172 -1825
  105. package/lib/cui.umd.js +2172 -1825
  106. package/lib/cui.umd.min.js +28 -28
  107. package/package.json +110 -110
  108. package/packages/affix/index.js +12 -12
  109. package/packages/affix/src/Affix.jsx +12 -12
  110. package/packages/age/index.js +27 -27
  111. package/packages/age/src/age/index.vue +139 -139
  112. package/packages/age/src/age-com/index.vue +209 -209
  113. package/packages/alert/index.js +12 -12
  114. package/packages/alert/src/Alert.jsx +11 -11
  115. package/packages/anchor/index.js +18 -18
  116. package/packages/anchor/src/Anchor.jsx +11 -11
  117. package/packages/anchor/src/Link.jsx +11 -11
  118. package/packages/auto-complete/index.js +12 -12
  119. package/packages/auto-complete/src/AutoComplete.jsx +12 -12
  120. package/packages/avatar/index.js +12 -12
  121. package/packages/avatar/src/Avatar.jsx +11 -11
  122. package/packages/back-top/index.js +12 -12
  123. package/packages/back-top/src/BackTop.jsx +11 -11
  124. package/packages/badge/index.js +12 -12
  125. package/packages/badge/src/Badge.jsx +11 -11
  126. package/packages/base/index.js +3 -3
  127. package/packages/big-table/index.js +16 -16
  128. package/packages/big-table/src/BigTable.vue +3150 -3144
  129. package/packages/big-table/src/Fieldset.vue +2067 -2067
  130. package/packages/big-table/src/assets/iconfont/iconfont.css +21 -21
  131. package/packages/big-table/src/assets/style/table-base.less +385 -385
  132. package/packages/big-table/src/assets/style/table-global.less +175 -175
  133. package/packages/big-table/src/components/AutoLayoutButton.vue +279 -279
  134. package/packages/big-table/src/components/NoData.vue +81 -81
  135. package/packages/big-table/src/components/TextOverTooltip.vue +120 -120
  136. package/packages/big-table/src/components/edit-form/EditForm.vue +509 -509
  137. package/packages/big-table/src/components/edit-form/edit-component/config-data/index.js +68 -68
  138. package/packages/big-table/src/components/edit-form/edit-component/edit-date-picker/edit-date-picker.vue +60 -60
  139. package/packages/big-table/src/components/edit-form/edit-component/edit-digital/edit-digital.vue +54 -54
  140. package/packages/big-table/src/components/edit-form/edit-component/edit-input/edit-input.vue +39 -39
  141. package/packages/big-table/src/components/edit-form/edit-component/edit-input-password/edit-input-password.vue +79 -79
  142. package/packages/big-table/src/components/edit-form/edit-component/edit-month-picker/edit-month-picker.vue +37 -37
  143. package/packages/big-table/src/components/edit-form/edit-component/edit-search/edit-search.vue +82 -82
  144. package/packages/big-table/src/components/edit-form/edit-component/edit-search-more/edit-search-more.vue +95 -95
  145. package/packages/big-table/src/components/edit-form/edit-component/edit-select/edit-select.vue +40 -40
  146. package/packages/big-table/src/components/edit-form/edit-component/edit-select-multiple/edit-select-multiple.vue +55 -55
  147. package/packages/big-table/src/components/edit-form/edit-component/edit-switch/edit-switch.vue +43 -43
  148. package/packages/big-table/src/components/edit-form/edit-component/edit-textarea/edit-textarea.vue +41 -41
  149. package/packages/big-table/src/components/edit-form/edit-component/edit-time-picker/edit-time-picker.vue +40 -40
  150. package/packages/big-table/src/components/edit-form/edit-component/mixins/bound-date.js +3 -3
  151. package/packages/big-table/src/components/edit-form/edit-component/mixins/dateType.js +217 -217
  152. package/packages/big-table/src/components/edit-form/edit-component/mixins/item-default.js +639 -639
  153. package/packages/big-table/src/components/edit-form/edit-component/mixins/search.js +1247 -1247
  154. package/packages/big-table/src/components/edit-form/edit-component/register-com.js +26 -26
  155. package/packages/big-table/src/components/edit-form/edit-item/form-event.js +80 -80
  156. package/packages/big-table/src/components/edit-form/edit-item/global-props.js +33 -33
  157. package/packages/big-table/src/components/edit-form/edit-item/index.js +4 -4
  158. package/packages/big-table/src/components/edit-form/edit-item/render-methods.js +28 -28
  159. package/packages/big-table/src/components/edit-form/edit-item/validate-rules.js +463 -463
  160. package/packages/big-table/src/components/edit-form/edit-mixins/form-commom.js +673 -673
  161. package/packages/big-table/src/components/edit-form/edit-mixins/index.js +3 -3
  162. package/packages/big-table/src/components/edit-form/edit-utils/index.js +112 -112
  163. package/packages/big-table/src/components/password-com.vue +58 -58
  164. package/packages/big-table/src/components/player-vod/index.vue +57 -57
  165. package/packages/big-table/src/components/player-vod/player.vue +189 -189
  166. package/packages/big-table/src/components/player-vod/video-list.vue +265 -265
  167. package/packages/big-table/src/components/player-vod/video-modal.vue +126 -126
  168. package/packages/big-table/src/utils/CustomPagination.vue +86 -86
  169. package/packages/big-table/src/utils/batchEditing.js +610 -610
  170. package/packages/big-table/src/utils/bigTableProps.js +103 -103
  171. package/packages/big-table/src/utils/format.js +557 -557
  172. package/packages/big-table/src/utils/nestTable.js +109 -109
  173. package/packages/big-table/src/utils/tableParse.js +234 -234
  174. package/packages/breadcrumb/index.js +21 -21
  175. package/packages/breadcrumb/src/Breadcrumb.jsx +11 -11
  176. package/packages/breadcrumb/src/BreadcrumbItem.jsx +11 -11
  177. package/packages/breadcrumb/src/BreadcrumbSeparator.jsx +11 -11
  178. package/packages/button/index.js +21 -21
  179. package/packages/button/src/Button.jsx +11 -11
  180. package/packages/button/src/ButtonGroup.jsx +11 -11
  181. package/packages/button/src/ButtonPrint/components/IdentityVerification.vue +181 -181
  182. package/packages/button/src/ButtonPrint/index.vue +766 -766
  183. package/packages/button/src/ButtonPrint/mixin/his-print.js +95 -95
  184. package/packages/calendar/index.js +12 -12
  185. package/packages/calendar/src/Calendar.jsx +11 -11
  186. package/packages/captcha/index.js +9 -9
  187. package/packages/captcha/src/Captcha.vue +164 -164
  188. package/packages/captcha/src/Index.vue +47 -47
  189. package/packages/captcha/src/SlideVerify.vue +285 -285
  190. package/packages/card/index.js +21 -21
  191. package/packages/card/src/Card.jsx +12 -12
  192. package/packages/card/src/CardGrid.js +7 -7
  193. package/packages/card/src/CardMeta.js +7 -7
  194. package/packages/carousel/index.js +12 -12
  195. package/packages/carousel/src/Carousel.jsx +12 -12
  196. package/packages/cascader/index.js +12 -12
  197. package/packages/cascader/src/Cascader.jsx +11 -11
  198. package/packages/checkbox/index.js +30 -30
  199. package/packages/checkbox/src/Checkbox.jsx +11 -11
  200. package/packages/checkbox/src/CheckboxImg/index.vue +141 -141
  201. package/packages/checkbox/src/Group.jsx +11 -11
  202. package/packages/col/index.js +13 -13
  203. package/packages/col/src/Col.jsx +11 -11
  204. package/packages/collapse/index.js +18 -18
  205. package/packages/collapse/src/Collapse.jsx +11 -11
  206. package/packages/collapse/src/Panel.jsx +11 -11
  207. package/packages/color-picker/index.js +10 -10
  208. package/packages/color-picker/src/color-picker.vue +191 -191
  209. package/packages/color-picker/src/style.less +109 -109
  210. package/packages/comment/index.js +12 -12
  211. package/packages/comment/src/Comment.jsx +11 -11
  212. package/packages/config-provider/index.js +12 -12
  213. package/packages/config-provider/src/ConfigProvider.jsx +11 -11
  214. package/packages/date-picker/index.js +26 -26
  215. package/packages/date-picker/src/DatePicker.jsx +12 -12
  216. package/packages/date-picker/src/MonthPicker.jsx +11 -11
  217. package/packages/date-picker/src/RangePicker.jsx +11 -11
  218. package/packages/date-picker/src/WeekPicker.jsx +11 -11
  219. package/packages/date-picker/src/utils/index.js +374 -374
  220. package/packages/descriptions/index.js +18 -18
  221. package/packages/descriptions/src/Descriptions.jsx +11 -11
  222. package/packages/descriptions/src/Item.jsx +11 -11
  223. package/packages/divider/index.js +12 -12
  224. package/packages/divider/src/Divider.jsx +11 -11
  225. package/packages/drag-layout/DragFormLeftItem.vue +173 -173
  226. package/packages/drag-layout/DragFormRightItem.vue +284 -284
  227. package/packages/drag-layout/I18n-mixins.js +10 -10
  228. package/packages/drag-layout/drag-layout.vue +778 -778
  229. package/packages/drag-layout/index.js +12 -12
  230. package/packages/drawer/index.js +12 -12
  231. package/packages/drawer/src/Drawer.jsx +11 -11
  232. package/packages/dropdown/index.js +12 -12
  233. package/packages/dropdown/src/Dropdown.jsx +11 -11
  234. package/packages/editor/index.js +9 -9
  235. package/packages/ellipsis/index.js +8 -8
  236. package/packages/ellipsis/src/Ellipsis.vue +65 -65
  237. package/packages/empty/index.js +12 -12
  238. package/packages/empty/src/Empty.jsx +11 -11
  239. package/packages/fabric-chart/index.js +9 -9
  240. package/packages/fabric-chart/src/FabricGrid.vue +67 -66
  241. package/packages/fabric-chart/src/components/DropPopup.vue +90 -90
  242. package/packages/fabric-chart/src/components/MouseRightClick.vue +168 -168
  243. package/packages/fabric-chart/src/components/TimeScaleValue.vue +114 -115
  244. package/packages/fabric-chart/src/const/defaultVaule.js +60 -59
  245. package/packages/fabric-chart/src/fabric-chart/FabricCanvas.vue +43 -9
  246. package/packages/fabric-chart/src/fabric-chart/FabricLines.vue +579 -552
  247. package/packages/fabric-chart/src/fabric-chart/FabricPolylines.vue +1142 -1126
  248. package/packages/fabric-chart/src/fabric-chart/FabricScaleValue.vue +134 -134
  249. package/packages/fabric-chart/src/fabric-chart/FabricTextGroup.vue +574 -566
  250. package/packages/fabric-chart/src/mixins/eventCommon.js +34 -1
  251. package/packages/fabric-chart/src/mixins/fabricCommon.js +95 -95
  252. package/packages/fabric-chart/src/mixins/fabricObject.js +193 -193
  253. package/packages/fabric-chart/src/mixins/type.js +5 -5
  254. package/packages/form/index.js +16 -16
  255. package/packages/form/src/Form.jsx +11 -11
  256. package/packages/form/src/Item.jsx +11 -11
  257. package/packages/form-model/index.js +14 -14
  258. package/packages/form-model/src/FormModel.jsx +11 -11
  259. package/packages/form-model/src/Item.jsx +11 -11
  260. package/packages/form-table/index.js +16 -16
  261. package/packages/form-table/src/FormTable.vue +1110 -1110
  262. package/packages/form-table/src/components/table-component/config-data/index.js +80 -80
  263. package/packages/form-table/src/components/table-component/global-props.js +22 -22
  264. package/packages/form-table/src/components/table-component/index.js +8 -8
  265. package/packages/form-table/src/components/table-component/mixins/bound-date.js +455 -455
  266. package/packages/form-table/src/components/table-component/mixins/dateType.js +217 -217
  267. package/packages/form-table/src/components/table-component/mixins/item-default.js +257 -257
  268. package/packages/form-table/src/components/table-component/mixins/search.js +1242 -1238
  269. package/packages/form-table/src/components/table-component/register-com.js +30 -30
  270. package/packages/form-table/src/components/table-component/table-age/table-age.vue +175 -175
  271. package/packages/form-table/src/components/table-component/table-date-picker/table-date-picker.vue +87 -87
  272. package/packages/form-table/src/components/table-component/table-digital/table-digital.vue +93 -93
  273. package/packages/form-table/src/components/table-component/table-input/table-input.vue +81 -81
  274. package/packages/form-table/src/components/table-component/table-input-password/table-input-password.vue +126 -126
  275. package/packages/form-table/src/components/table-component/table-month-picker/table-month-picker.vue +55 -55
  276. package/packages/form-table/src/components/table-component/table-search/table-search.vue +174 -174
  277. package/packages/form-table/src/components/table-component/table-search-more/table-search-more.vue +191 -191
  278. package/packages/form-table/src/components/table-component/table-select/table-select.vue +64 -64
  279. package/packages/form-table/src/components/table-component/table-select-multiple/table-select-multiple.vue +81 -81
  280. package/packages/form-table/src/components/table-component/table-textarea/table-textarea.vue +76 -76
  281. package/packages/form-table/src/components/table-component/table-time-picker/table-time-picker.vue +55 -55
  282. package/packages/form-table/src/components/table-component/table-tree-select/table-tree-select.vue +135 -135
  283. package/packages/form-table/src/components/table-component/text-over-tooltip/TextOverTooltip.vue +97 -97
  284. package/packages/form-table/src/components/table-item/form-event.js +81 -81
  285. package/packages/form-table/src/components/table-item/global-props.js +27 -27
  286. package/packages/form-table/src/components/table-item/index.js +4 -4
  287. package/packages/form-table/src/components/table-item/render-methods.js +28 -28
  288. package/packages/form-table/src/components/table-item/validate-rules.js +520 -520
  289. package/packages/form-table/src/components/table-mixins/form-commom.js +98 -98
  290. package/packages/form-table/src/components/table-mixins/index.js +3 -3
  291. package/packages/form-table/src/components/table-utils/index.js +112 -112
  292. package/packages/form-table/src/disabledDetail.less +46 -46
  293. package/packages/grid/index.js +10 -10
  294. package/packages/grid/src/grid.js +28 -28
  295. package/packages/icon/index.js +10 -10
  296. package/packages/icon/src/icon.js +13 -13
  297. package/packages/index.js +313 -313
  298. package/packages/input/index.js +30 -30
  299. package/packages/input/src/Group.jsx +11 -11
  300. package/packages/input/src/Input.jsx +11 -11
  301. package/packages/input/src/Password.jsx +11 -11
  302. package/packages/input/src/Search.jsx +11 -11
  303. package/packages/input/src/TextArea.jsx +11 -11
  304. package/packages/input/src/input-quick/components/quick-item.vue +284 -284
  305. package/packages/input/src/input-quick/components/quick-popover.vue +596 -596
  306. package/packages/input/src/input-quick/index.vue +137 -137
  307. package/packages/input-number/index.js +12 -12
  308. package/packages/input-number/src/InputNumber.jsx +11 -11
  309. package/packages/keep-cache/KeepCache.js +236 -236
  310. package/packages/keep-cache/index.css +2 -2
  311. package/packages/keep-cache/index.js +8 -8
  312. package/packages/layout/index.js +27 -27
  313. package/packages/layout/src/Content.jsx +11 -11
  314. package/packages/layout/src/Footer.jsx +11 -11
  315. package/packages/layout/src/Header.jsx +11 -11
  316. package/packages/layout/src/Layout.jsx +11 -11
  317. package/packages/layout/src/Sider.jsx +11 -11
  318. package/packages/list/index.js +21 -21
  319. package/packages/list/src/Item.jsx +11 -11
  320. package/packages/list/src/ItemMeta.jsx +11 -11
  321. package/packages/list/src/List.jsx +11 -11
  322. package/packages/locale-provider/index.js +12 -12
  323. package/packages/locale-provider/src/LocaleProvider.jsx +11 -11
  324. package/packages/map/index.js +9 -9
  325. package/packages/map/src/Map.vue +484 -484
  326. package/packages/map/src/popup-map.vue +53 -53
  327. package/packages/mentions/index.js +18 -18
  328. package/packages/mentions/src/Mentions.jsx +11 -11
  329. package/packages/mentions/src/Option.jsx +11 -11
  330. package/packages/menu/index.js +27 -27
  331. package/packages/menu/src/Divider.jsx +11 -11
  332. package/packages/menu/src/Item.jsx +11 -11
  333. package/packages/menu/src/ItemGroup.jsx +11 -11
  334. package/packages/menu/src/Menu.jsx +11 -11
  335. package/packages/menu/src/SubMenu.jsx +11 -11
  336. package/packages/message/index.js +8 -8
  337. package/packages/modal/index.js +10 -10
  338. package/packages/modal/src/Modal.js +7 -7
  339. package/packages/multi-chat/chat/addConference.vue +200 -200
  340. package/packages/multi-chat/chat/addMembers.vue +411 -411
  341. package/packages/multi-chat/chat/advancedFilter.vue +372 -372
  342. package/packages/multi-chat/chat/calling.vue +246 -246
  343. package/packages/multi-chat/chat/chatFooter.vue +1596 -1596
  344. package/packages/multi-chat/chat/chatHistory.vue +605 -605
  345. package/packages/multi-chat/chat/chatMain.vue +1486 -1486
  346. package/packages/multi-chat/chat/client/index.vue +149 -149
  347. package/packages/multi-chat/chat/delay.vue +177 -177
  348. package/packages/multi-chat/chat/evaluate.vue +343 -343
  349. package/packages/multi-chat/chat/messageRecord.vue +324 -324
  350. package/packages/multi-chat/chat/mixins/NoData.js +20 -20
  351. package/packages/multi-chat/chat/mixins/base.js +97 -97
  352. package/packages/multi-chat/chat/mixins/uniRTCAPI.js +80 -80
  353. package/packages/multi-chat/chat/mixins/viewerOptions.js +67 -67
  354. package/packages/multi-chat/chat/quickReply.vue +439 -439
  355. package/packages/multi-chat/chat/robot/index.vue +312 -312
  356. package/packages/multi-chat/chat/scrollList.vue +1238 -1238
  357. package/packages/multi-chat/chat/videoVoiceList.vue +348 -348
  358. package/packages/multi-chat/chat/voice.vue +431 -431
  359. package/packages/multi-chat/components/avatar.vue +113 -113
  360. package/packages/multi-chat/components/chat-tabs-header.vue +251 -251
  361. package/packages/multi-chat/components/classify-tabs.vue +185 -185
  362. package/packages/multi-chat/components/empty.vue +24 -24
  363. package/packages/multi-chat/components/modal-refuse-reason.vue +112 -112
  364. package/packages/multi-chat/components/modal-sip.vue +160 -160
  365. package/packages/multi-chat/components/modal-user-transfer.vue +98 -98
  366. package/packages/multi-chat/components/msg-describe.vue +138 -138
  367. package/packages/multi-chat/components/msg-picture.vue +68 -68
  368. package/packages/multi-chat/components/msg-prescription.vue +205 -205
  369. package/packages/multi-chat/components/read-record.vue +133 -133
  370. package/packages/multi-chat/components/read-status.vue +34 -34
  371. package/packages/multi-chat/components/user-status.vue +198 -198
  372. package/packages/multi-chat/index.js +7 -7
  373. package/packages/multi-chat/setting/authority/index.vue +156 -156
  374. package/packages/multi-chat/setting/authority/roleSetting.vue +204 -204
  375. package/packages/multi-chat/setting/baseInfo/index.vue +1316 -1316
  376. package/packages/multi-chat/setting/customerService/batchSelect.vue +403 -403
  377. package/packages/multi-chat/setting/customerService/index.vue +273 -273
  378. package/packages/multi-chat/setting/event/edit/condition.vue +128 -128
  379. package/packages/multi-chat/setting/event/edit/index.vue +437 -437
  380. package/packages/multi-chat/setting/event/edit/notice.vue +129 -129
  381. package/packages/multi-chat/setting/event/edit/strategy.vue +98 -98
  382. package/packages/multi-chat/setting/event/index.vue +249 -249
  383. package/packages/multi-chat/setting/index.vue +269 -269
  384. package/packages/multi-chat/setting/page.vue +14 -14
  385. package/packages/multi-chat/setting/sessionList/index.vue +412 -412
  386. package/packages/multi-chat/setting/sessionList/messageRecord.vue +372 -372
  387. package/packages/multi-chat/setting/userConfig/index.vue +124 -124
  388. package/packages/multi-chat/setting/worktime/index.vue +274 -274
  389. package/packages/multi-chat/store/actions.js +452 -452
  390. package/packages/multi-chat/store/getters.js +371 -371
  391. package/packages/multi-chat/store/helper.js +66 -66
  392. package/packages/multi-chat/store/index.js +50 -50
  393. package/packages/multi-chat/store/mutation.js +296 -296
  394. package/packages/multi-chat/store/state.js +117 -117
  395. package/packages/multi-chat/style/emoji.css +315 -315
  396. package/packages/multi-chat/style/message.mixin.less +38 -38
  397. package/packages/multi-chat/utils/chatSock.js +93 -93
  398. package/packages/multi-chat/utils/compressImage.js +115 -115
  399. package/packages/multi-chat/utils/emoji.json +68 -68
  400. package/packages/multi-chat/utils/index.js +259 -259
  401. package/packages/multi-chat/utils/observer-scroll.js +49 -49
  402. package/packages/multi-chat/utils/panelsetting.js +48 -48
  403. package/packages/multi-chat-client/index.js +7 -7
  404. package/packages/multi-chat-history/index.js +7 -7
  405. package/packages/multi-chat-record/index.js +7 -7
  406. package/packages/multi-chat-setting/index.js +7 -7
  407. package/packages/multi-chat-sip/index.js +6 -6
  408. package/packages/notification/index.js +8 -8
  409. package/packages/page-header/index.js +12 -12
  410. package/packages/page-header/src/PageHeader.jsx +11 -11
  411. package/packages/pagination/index.js +12 -12
  412. package/packages/pagination/src/Pagination.jsx +11 -11
  413. package/packages/popconfirm/index.js +12 -12
  414. package/packages/popconfirm/src/Popconfirm.jsx +11 -11
  415. package/packages/popover/index.js +12 -12
  416. package/packages/popover/src/Popover.jsx +11 -11
  417. package/packages/progress/index.js +12 -12
  418. package/packages/progress/src/Progress.jsx +11 -11
  419. package/packages/radio/index.js +33 -33
  420. package/packages/radio/src/Group.jsx +11 -11
  421. package/packages/radio/src/Radio.jsx +11 -11
  422. package/packages/radio/src/RadioButton.jsx +11 -11
  423. package/packages/radio/src/RadioImg/index.vue +124 -124
  424. package/packages/rate/index.js +12 -12
  425. package/packages/rate/src/Rate.jsx +11 -11
  426. package/packages/result/index.js +12 -12
  427. package/packages/result/src/Result.jsx +11 -11
  428. package/packages/row/index.js +12 -12
  429. package/packages/row/src/Row.jsx +11 -11
  430. package/packages/scale-container/index.js +8 -8
  431. package/packages/scale-container/src/ScaleContainer.vue +197 -194
  432. package/packages/scale-view/NoData.vue +81 -81
  433. package/packages/scale-view/answerParse.vue +133 -133
  434. package/packages/scale-view/customList.vue +801 -801
  435. package/packages/scale-view/data.js +80 -80
  436. package/packages/scale-view/evaluateCountdown.vue +155 -155
  437. package/packages/scale-view/evaluatePage.vue +202 -202
  438. package/packages/scale-view/formitem/data.js +3991 -3991
  439. package/packages/scale-view/formitem/index.js +6 -6
  440. package/packages/scale-view/formitem/r-address.vue +238 -238
  441. package/packages/scale-view/formitem/r-choice.vue +726 -726
  442. package/packages/scale-view/formitem/r-input.vue +92 -92
  443. package/packages/scale-view/formitem/r-prompt.vue +52 -52
  444. package/packages/scale-view/formitem/r-time.vue +285 -285
  445. package/packages/scale-view/formitem/r-upload-custom-list.vue +242 -242
  446. package/packages/scale-view/formitem/r-upload.vue +287 -287
  447. package/packages/scale-view/formitem/text-over-tooltip/TextOverTooltip.vue +98 -98
  448. package/packages/scale-view/index.js +17 -17
  449. package/packages/scale-view/mixin/NoData.js +38 -38
  450. package/packages/scale-view/mixin/evaluate.js +146 -146
  451. package/packages/scale-view/mixin/index.js +337 -337
  452. package/packages/scale-view/mixin/judgeTypes.js +267 -267
  453. package/packages/scale-view/scaleView.vue +2010 -2010
  454. package/packages/select/index.js +27 -27
  455. package/packages/select/src/CustomSelect/index.vue +130 -130
  456. package/packages/select/src/OptGroup.jsx +11 -11
  457. package/packages/select/src/Option.jsx +11 -11
  458. package/packages/select/src/Select/Select.vue +231 -231
  459. package/packages/select/src/Select/index.js +12 -12
  460. package/packages/select/src/TableSelect/index.vue +514 -514
  461. package/packages/select-label/index.js +14 -14
  462. package/packages/select-label/label-classify.vue +129 -129
  463. package/packages/select-label/labelFormContent.vue +787 -787
  464. package/packages/select-label/select-label.vue +581 -581
  465. package/packages/select-person/index.js +10 -10
  466. package/packages/select-person/search-tree.vue +373 -373
  467. package/packages/select-person/select-person.vue +1696 -1696
  468. package/packages/shortcut-setter/index.js +12 -12
  469. package/packages/shortcut-setter/src/ShortcutSetter.vue +55 -55
  470. package/packages/shortcut-setter/src/ShortcutSetterItem.vue +84 -84
  471. package/packages/shortcut-setter/src/utils/index.js +63 -63
  472. package/packages/skeleton/index.js +12 -12
  473. package/packages/skeleton/src/Skeleton.jsx +11 -11
  474. package/packages/slider/index.js +12 -12
  475. package/packages/slider/src/Slider.jsx +11 -11
  476. package/packages/space/index.js +12 -12
  477. package/packages/space/src/Space.jsx +11 -11
  478. package/packages/spin/index.js +12 -12
  479. package/packages/spin/src/Spin.jsx +11 -11
  480. package/packages/statistic/index.js +18 -18
  481. package/packages/statistic/src/Countdown.jsx +11 -11
  482. package/packages/statistic/src/Statistic.jsx +11 -11
  483. package/packages/steps/index.js +18 -18
  484. package/packages/steps/src/Step.jsx +11 -11
  485. package/packages/steps/src/Steps.jsx +11 -11
  486. package/packages/switch/index.js +12 -12
  487. package/packages/switch/src/Switch.jsx +11 -11
  488. package/packages/table-filter/index.js +27 -27
  489. package/packages/table-filter/src/base-search-com/BaseSearch.vue +2572 -2572
  490. package/packages/table-filter/src/classification/Classification-com.vue +1756 -1756
  491. package/packages/table-filter/src/classification/search-class-name.vue +266 -266
  492. package/packages/table-filter/src/classification/search-professional-model.vue +680 -680
  493. package/packages/table-filter/src/components/TextOverTooltip.vue +107 -107
  494. package/packages/table-filter/src/components/age-com/index.vue +205 -205
  495. package/packages/table-filter/src/components/button-group/ButtonGroup.vue +162 -162
  496. package/packages/table-filter/src/components/button-icon/button-icon.js +33 -33
  497. package/packages/table-filter/src/components/button-icon/getBtnIcon.js +34 -34
  498. package/packages/table-filter/src/components/c-tree-select/tree-select.vue +336 -336
  499. package/packages/table-filter/src/components/drop-button/drop-button.vue +224 -224
  500. package/packages/table-filter/src/components/drop-button/head-btn-icon.js +33 -33
  501. package/packages/table-filter/src/components/drop-view/drop-view.vue +89 -89
  502. package/packages/table-filter/src/components/multi-select/multi-select.vue +227 -227
  503. package/packages/table-filter/src/components/out-quick-search/out-quick-search.vue +340 -340
  504. package/packages/table-filter/src/components/range-age/index.vue +172 -172
  505. package/packages/table-filter/src/components/search-condition/SearchCondition.vue +1897 -1897
  506. package/packages/table-filter/src/components/search-condition/fieldTypeList.js +169 -169
  507. package/packages/table-filter/src/components/search-filter/SearchFilter.vue +278 -278
  508. package/packages/table-filter/src/components/search-modal/set-classification.vue +310 -310
  509. package/packages/table-filter/src/components/table-modal/TableModal.vue +473 -463
  510. package/packages/table-filter/src/const/dataOptions.js +43 -43
  511. package/packages/table-filter/src/const/index.js +1 -1
  512. package/packages/table-filter/src/index.vue +584 -584
  513. package/packages/table-filter/src/mixins/mixins.js +694 -694
  514. package/packages/table-filter/src/mixins/tableSearchCon.js +128 -128
  515. package/packages/table-filter/src/mixins/wordBookutils.js +102 -102
  516. package/packages/table-filter/src/quick-search/QuickSearch.vue +2125 -2125
  517. package/packages/tabs/index.js +18 -18
  518. package/packages/tabs/src/TabPane.jsx +11 -11
  519. package/packages/tabs/src/Tabs.jsx +11 -11
  520. package/packages/tag/index.js +21 -21
  521. package/packages/tag/src/CheckableTag.jsx +11 -11
  522. package/packages/tag/src/Tag.jsx +11 -11
  523. package/packages/tag/src/TagGroup.vue +621 -621
  524. package/packages/time-picker/index.js +12 -12
  525. package/packages/time-picker/src/TimePicker.jsx +11 -11
  526. package/packages/timeline/index.js +14 -14
  527. package/packages/timeline/src/Item.jsx +11 -11
  528. package/packages/timeline/src/Timeline.jsx +11 -11
  529. package/packages/tooltip/index.js +12 -12
  530. package/packages/tooltip/src/Tooltip.jsx +11 -11
  531. package/packages/transfer/index.js +12 -12
  532. package/packages/transfer/src/Transfer.jsx +11 -11
  533. package/packages/tree/index.js +18 -18
  534. package/packages/tree/src/Tree.jsx +11 -11
  535. package/packages/tree/src/TreeNode.jsx +11 -11
  536. package/packages/tree-select/index.js +18 -18
  537. package/packages/tree-select/src/TreeNode.jsx +11 -11
  538. package/packages/tree-select/src/TreeSelect.jsx +11 -11
  539. package/packages/upload/chunk-upload/chunk-upload-new.vue +1001 -1001
  540. package/packages/upload/chunk-upload/vod-chunk-upload.vue +749 -749
  541. package/packages/upload/chunk-upload/vod-upload-modal.vue +100 -100
  542. package/packages/upload/index.js +12 -12
  543. package/packages/upload/src/Upload.jsx +11 -11
  544. package/packages/verification-code/SlideVerify.vue +306 -306
  545. package/packages/verification-code/index.js +17 -17
  546. package/packages/verification-code/verification-code.vue +147 -147
  547. package/src/component/player-vod/index.vue +57 -57
  548. package/src/component/player-vod/player.vue +188 -188
  549. package/src/component/player-vod/video-list.vue +262 -262
  550. package/src/component/player-vod/video-modal.vue +128 -128
  551. package/src/component/select-options/index.vue +430 -413
  552. package/src/component/select-pages/index.vue +95 -95
  553. package/src/component/svg/index.vue +59 -59
  554. package/src/core/create.js +6 -6
  555. package/src/core/event.js +23 -23
  556. package/src/core/table-methods.js +444 -444
  557. package/src/directive/flexibleResize.js +151 -151
  558. package/src/directive/preventReClick.js +12 -12
  559. package/src/directive/scroll.js +230 -230
  560. package/src/global/variable.js +2 -2
  561. package/src/style/normalize.css +424 -424
  562. package/src/style/style.less +49 -49
  563. package/src/utils/UniRTCv2.js +626 -626
  564. package/src/utils/chatFetch.js +61 -61
  565. package/src/utils/clickoutside.js +75 -75
  566. package/src/utils/crypto.js +25 -25
  567. package/src/utils/index.js +81 -81
  568. package/src/utils/kty-sdk.js +582 -582
  569. package/src/utils/kty.min-1.0.0.js +14378 -14378
  570. package/src/utils/sip-device.js +79 -79
  571. package/src/utils/time-domain.js +193 -193
  572. package/src/utils/trtc.js +1 -1
  573. package/src/utils/utils-map.js +484 -484
  574. package/src/utils/vexutils.js +836 -836
@@ -1,1126 +1,1142 @@
1
- <template>
2
- <div class="poly-line">
3
- <MouseRightClick v-if="isRightVisible" :getContainer="getContainer" :nodeList="rightClickNode" :rightPos="rightPos" @nodeClick="handleRightClick" @closeRight="isRightVisible = false" />
4
-
5
- <DropPopup v-show="isDropVisible" :val="dropVal" :dropPos="dropPos" />
6
- </div>
7
- </template>
8
-
9
- <script>
10
- import FabricCommon from '../mixins/fabricCommon';
11
- import draw from '../mixins/draw';
12
- import eventCommon from '../mixins/eventCommon';
13
- import MouseRightClick from '../components/MouseRightClick';
14
- import DropPopup from '../components/DropPopup';
15
- import defaultVaule from '../const/defaultVaule';
16
-
17
- /**
18
- * @description: 递归遍历节点,设置颜色属性
19
- * @param {fabric.Object[]} pointArr
20
- * @param {string}} color
21
- * @return {*}
22
- */
23
-
24
- function resetPointColor(pointArr, color) {
25
- pointArr.forEach(point => {
26
- const { fill, stroke } = point;
27
- if (fill && !fill.includes('#fff') && fill !== 'transparent') {
28
- point.set({ fill: color });
29
- }
30
- if (stroke && !stroke.includes('#fff') && stroke !== 'transparent') {
31
- point.set({ stroke: color });
32
- }
33
- if (point._objects?.length) {
34
- resetPointColor(point._objects, color);
35
- }
36
- });
37
- }
38
- const setPointLineColor = (point, color, conditionHasLine2) => {
39
- point.line1?.set({ stroke: color });
40
- conditionHasLine2 && point.line2?.set({ stroke: color });
41
- };
42
-
43
- const isEffectiveNode = node => {
44
- return node?.time && (node?.value || node?.value === 0);
45
- };
46
- const rightClickNode = [
47
- { name: '新增节点', type: 'add' },
48
- { name: '检测项设置', type: 'set' },
49
- { name: '删除节点', type: 'delete' }
50
- ];
51
- const rightClickNodeConnect = [
52
- { name: '新增节点连接右侧节点', type: 'add' },
53
- { name: '新增节点连接左侧节点', type: 'add' }
54
- ];
55
- export default {
56
- name: 'fabric-polylines',
57
- mixins: [FabricCommon, draw, eventCommon],
58
- inject: ['$propItems'],
59
- props: {
60
- polyline: {
61
- type: Array,
62
- required: true
63
- },
64
- other: {
65
- type: Object,
66
- default: () => {}
67
- }
68
- },
69
- components: {
70
- MouseRightClick,
71
- DropPopup
72
- },
73
- data() {
74
- return {
75
- isDropVisible: false,
76
- dropVal: {},
77
- dropPos: { clientX: 0, clientY: 0 },
78
- isRightVisible: false,
79
- rightPos: { clientX: 0, clientY: 0 },
80
- rightClickNode: [],
81
- activeEvent: null, // 当前可右键活动的对象
82
- addPointList: [], // 快速新增的节点list
83
- addPointObjList: [], // 批量新增节点对象的缓存
84
- isSelectArea: false, // 是否正在选区
85
- selectArea: null, // 选区矩形对象
86
- currentDelPoint: null, // 缓存当前可批量删除的项目线段上的点
87
- polylinePointList: [] // 缓存折线项目节点
88
- };
89
- },
90
- computed: {
91
- eventStyle() {
92
- return this.propItems.eventStyle;
93
- },
94
- spaceWidth() {
95
- const { xCellWidth, table } = this.propItems;
96
- // const addPointSpaceGridNumbers = table.addPointSpaceGridNumbers || [];
97
- let addPointSpaceGridNumber = table.addPointSpaceGridNumber || 1;
98
- const spaceWidth = xCellWidth * addPointSpaceGridNumber;
99
- return spaceWidth;
100
- }
101
- },
102
-
103
- watch: {},
104
-
105
- mounted() {},
106
-
107
- methods: {
108
- init() {
109
- this.drawPolylineTitle();
110
- this.polylinePointList = [];
111
- this.polyline.forEach((polylineType, polylineTypeId) => {
112
- this.createPolyline(polylineType, polylineTypeId);
113
- });
114
-
115
- this.eventStyle.evented && this.createEvent();
116
- },
117
- createEvent() {
118
- this.canvas.on('mouse:up', event => {
119
- if (event.button === 3) {
120
- const { x, y } = event.pointer;
121
- const { originX, originY, endX, endY } = this.$propItems();
122
- if (!(x < originX || x > endX || y < originY || y > endY)) {
123
- this.activeEvent = event;
124
- document.querySelector('.upper-canvas').addEventListener('contextmenu', this.addEventListenerContextmenu, true);
125
- }
126
- // this.willUpdateLine = line;
127
- }
128
- // 左键松开鼠标-批量删除
129
- this.isSelectArea = false;
130
- if (event.button === 1 && !event.target && this.selectArea) {
131
- const points = this.selectArea.ponits;
132
- const delList = this.getAreaPonits(points);
133
- delList.length === 0 && this.removeSelectArea();
134
- if (delList.length > 0 && this.selectArea) {
135
- this.$emit('pointOperation', 'delete', delList);
136
- this.currentDelPoint = null;
137
- }
138
- }
139
- });
140
- let selectAreaOrigin = { left: 0, top: 0 };
141
- this.canvas.on('mouse:down', event => {
142
- if (event.button === 1 && !event.target) {
143
- this.isSelectArea = true;
144
- selectAreaOrigin.left = event.pointer.x;
145
- selectAreaOrigin.top = event.pointer.y;
146
- }
147
- });
148
- this.canvas.on('mouse:move', event => {
149
- this.isSelectArea && this.createSelectArea(event, selectAreaOrigin);
150
- });
151
- },
152
- // 获取选区内包含的节点
153
- getAreaPonits(points) {
154
- const delList = [];
155
- const [x1, y1, x2, y2] = points;
156
- this.canvas.forEachObject(obj => {
157
- const { id, left, top } = obj;
158
- const isArea = left >= x1 && left <= x2 && top >= y1 && top <= y2;
159
- if (id && /_polyline(Point)_/.test(id) && !id.includes('isTitle') && isArea) {
160
- if (this.currentDelPoint) {
161
- const { polylineIndex } = this.currentDelPoint;
162
- if (polylineIndex == obj.polylineIndex) {
163
- delList.push(this.getDataById(id));
164
- }
165
- } else {
166
- delList.push(this.getDataById(id));
167
- }
168
- }
169
- });
170
- return delList;
171
- },
172
- // 创建选区
173
- createSelectArea(event, selectAreaOrigin) {
174
- this.selectArea && this.canvas.remove(this.selectArea);
175
- this.selectArea = new this.fabric.Rect({
176
- ...defaultVaule.style,
177
- fill: '#CAF982',
178
- opacity: 0.4,
179
- left: selectAreaOrigin.left,
180
- top: selectAreaOrigin.top,
181
- width: event.pointer.x - selectAreaOrigin.left,
182
- height: event.pointer.y - selectAreaOrigin.top,
183
- ponits: [selectAreaOrigin.left, selectAreaOrigin.top, event.pointer.x, event.pointer.y]
184
- });
185
- this.canvas.add(this.selectArea);
186
- // this.canvas.renderAll();
187
- },
188
- // 每一个折线类别
189
- createPolyline(polylineType, polylineTypeId) {
190
- polylineType.dataList.forEach((polylineItem, polylineIndex) => {
191
- this.drawPolyline(polylineItem, polylineIndex, polylineType, polylineTypeId);
192
- });
193
- },
194
- // 绘制左侧折线标题
195
- drawPolylineTitle() {
196
- const { canvasHeight, treeTableminCellWidth, originX, xScaleList, xScaleCellList, endX } = this.propItems;
197
- const leftYScalevalue = this.polyline.find(v => v.position === 'left');
198
- const lableMargin = leftYScalevalue.lableMargin || [5, 30];
199
- const lableLineHeight = leftYScalevalue.lableLineHeight || 20;
200
- const style = leftYScalevalue.style || { fontSize: 12, fill: '#000' };
201
-
202
- const leftTitleList = [];
203
-
204
- const minTime = Math.min(...xScaleList);
205
- const maxTime = Math.max(...xScaleList);
206
-
207
- this.polyline.forEach((item, index) => {
208
- item.dataList.forEach((v, i) => {
209
- const point = v.list.find(k => isEffectiveNode(k) && new Date(k.time).getTime() >= minTime && new Date(k.time).getTime() <= maxTime);
210
- const firstPointLeft = point ? this.cumputedX(point.time) : 0;
211
- const rightLimit = point ? firstPointLeft - this.spaceWidth : '';
212
- // 配置是否可拖动标题图标批量增加-
213
- const isAdd = (firstPointLeft || endX) - this.spaceWidth >= originX;
214
- leftTitleList.push({
215
- title: v.title,
216
- type: v.type,
217
- pointAttr: v.pointAttr,
218
- lineAttr: v.lineAttr,
219
- polylineTypeId: index,
220
- polylineIndex: i,
221
- isAdd,
222
- rightLimit
223
- });
224
- });
225
- });
226
-
227
- // 配置左侧title图标(但不是折线项目)
228
- if (this.other?.list && Array.isArray(this.other.list)) {
229
- const otherList = this.other.list.map(v => {
230
- return {
231
- title: v.name,
232
- type: v.type,
233
- pointAttr: v,
234
- isAdd: false,
235
- polylineTypeId: -1,
236
- polylineIndex: -1
237
- };
238
- });
239
- if (this.other.position && this.other.position === 'top') {
240
- leftTitleList.push(...otherList);
241
- } else {
242
- leftTitleList.unshift(...otherList);
243
- }
244
- }
245
-
246
- const eventStyle = { selectable: false, evented: false };
247
- leftTitleList.forEach(async (v, i) => {
248
- const baseTop = canvasHeight - lableMargin[1];
249
- const top = baseTop - i * lableLineHeight;
250
- const left = lableMargin[0] + treeTableminCellWidth;
251
- const pointId = `${v.polylineTypeId}_${v.polylineIndex}_-1_polylinePoint_'${new Date().getTime()}_isTitle`;
252
- const { fill: fillColor = '#000', stroke } = v.pointAttr;
253
- let text = new this.fabric.Text(String(v.title), {
254
- fontSize: style.fontSize,
255
- fill: fillColor && stroke ? stroke : fillColor,
256
- left,
257
- top,
258
- originY: 'center',
259
- ...defaultVaule.style,
260
- id: pointId
261
- });
262
- const iconLeft = text.width + text.left + 10;
263
- const option = {
264
- left: iconLeft,
265
- top,
266
- ...v.pointAttr,
267
- originY: 'center',
268
- originX: 'center',
269
- lineAttr: v.lineAttr || '',
270
- pointAttr: v.pointAttr,
271
- id: pointId,
272
- polylineTypeId: v.polylineTypeId,
273
- polylineIndex: v.polylineIndex,
274
- ...(v.isAdd && this.eventStyle.evented ? {} : eventStyle),
275
- rightLimit: v.rightLimit || ''
276
- };
277
- let ele;
278
- if (v.type === 'img' && v.pointAttr?.iconClassName) {
279
- ele = await this.createImage(v.pointAttr.iconClassName, v.pointAttr);
280
- }
281
- const icon = await this.createPoint(v.type, {
282
- ele: ele || '',
283
- ...option
284
- });
285
- icon.hasControls = icon.hasBorders = false;
286
- let originTop = top;
287
- let cloneIconId;
288
- icon.on('moving', () => {
289
- // 优化左侧图标太小不容易选中的问题
290
- if (!icon.url && icon.scaleX == 1.8 && icon.scaleY == 1.8) {
291
- icon.set({
292
- scaleX: 1,
293
- scaleY: 1
294
- });
295
- }
296
-
297
- if (!cloneIconId) {
298
- cloneIconId = '_polylinePoint_temp_' + new Date().getTime();
299
- icon.clone(clonedObj => {
300
- clonedObj.set({
301
- id: cloneIconId // 此id必须,用于remove节点的时候
302
- });
303
- clonedObj.bringForward();
304
- this.canvas.add(clonedObj);
305
- });
306
- }
307
-
308
- icon.set({ originX: 'center' });
309
- this.moveLimit(icon);
310
- icon.left >= originX && icon.left < originX + 5 && (originTop = icon.top);
311
- if (icon.left >= originX) {
312
- this.showDrapPopup(icon);
313
- } else {
314
- this.isDropVisible = false;
315
- }
316
- // this.canvas.renderAll();
317
- });
318
- // 标题折线点停止拖拽后 更新
319
- icon.on('moved', () => {
320
- this.setLeft(icon);
321
- icon.set({
322
- id: icon.id.replace('_isTitle', '')
323
- });
324
- // this.canvas.renderAll();
325
- this.removeTitle();
326
- this.removePolyline(cloneIconId);
327
-
328
- if (icon.id.includes('_polylinePoint_') && this.isDropVisible) {
329
- this.isDropVisible = false;
330
- if (icon.left >= originX) {
331
- // this.setEmitFunction(icon);
332
- this.setAddPointList(icon);
333
- this.$emit('pointOperation', 'increasePointBatch', this.addPointList);
334
- this.addPointList = [];
335
- }
336
- }
337
- this.removePolyline(icon.id);
338
- // 重绘折线标题
339
- this.drawPolylineTitle();
340
- });
341
-
342
- // 优化左侧图标太小不容易选中的问题
343
- if (icon.evented && !icon.url) {
344
- const maxVal = Math.max(icon.width * icon.scale, icon.height * icon.scale);
345
- if (maxVal < 7) {
346
- icon.set({
347
- scaleX: 1.8,
348
- scaleY: 1.8
349
- });
350
- }
351
- }
352
-
353
- this.canvas.add(text, icon);
354
- // this.canvas.requestRenderAll();
355
- });
356
- },
357
- // 限制节点新增位置与右侧节点间隔的spaceWidth格子树必须为整数
358
- setLeft(icon) {
359
- const { originX } = this.propItems;
360
- let tempLeft = icon.rightLimit;
361
-
362
- if (!tempLeft) return;
363
- const leftLimit = icon.left + this.spaceWidth;
364
- let i = 0;
365
- while (tempLeft >= leftLimit) {
366
- tempLeft = icon.rightLimit - i * this.spaceWidth;
367
- i++;
368
- }
369
- icon.left = tempLeft < originX ? originX : tempLeft;
370
- },
371
- // 点移动限制
372
- moveLimit(point) {
373
- point.setCoords();
374
- const { treeTableminCellWidth, endX } = this.propItems;
375
- const leftLimit = treeTableminCellWidth;
376
- const rightLimit = point.rightLimit || endX;
377
- if (point.top < this.propItems.originY) {
378
- point.set('top', this.propItems.originY);
379
- }
380
- if (point.top > this.propItems.endY) {
381
- point.set('top', this.propItems.endY);
382
- }
383
- if (point.left < leftLimit) {
384
- point.set('left', leftLimit);
385
- }
386
- if (point.left > rightLimit) {
387
- point.set('left', rightLimit);
388
- }
389
- },
390
- removeTitle() {
391
- this.canvas.forEachObject(obj => {
392
- if (obj.id && obj.id.includes('isTitle')) {
393
- this.canvas.remove(obj);
394
- }
395
- });
396
- },
397
- isLimit(time) {
398
- const minMinute = Math.min(...this.propItems.xScaleList);
399
- const maxMinute = Math.max(...this.propItems.xScaleList);
400
- const getTime = new Date(time).getTime();
401
- return getTime >= minMinute && getTime <= maxMinute;
402
- },
403
- // 创建危急值和差异值
404
- createAttrVaule(attr, polyline, polylineIndex, polylineType, polylineTypeId) {
405
- const { list } = polyline;
406
- const valueObj = polyline[attr] || {};
407
- if (!valueObj.max && !valueObj.min) return;
408
-
409
- const { originX, endX } = this.propItems;
410
- const isMax = valueObj.max?.show && valueObj.max?.value && list.some(v => +v.value >= +valueObj.max.value && this.isLimit(v.time));
411
- const isMin = valueObj.min?.show && valueObj.min?.value && list.some(v => +v.value <= +valueObj.min.value && this.isLimit(v.time));
412
- const lines = [];
413
-
414
- const drawLine = ({ value, lineStyle }) => {
415
- const top = this.cumputedY(polylineType, +value);
416
- return this.drawLine([originX, top, endX, top], { polylineIndex, lineIndex: 0, polylineTypeId, ...(lineStyle || defaultVaule.criticalStyle) });
417
- };
418
- const drawText = ({ name, nameStyle }, top) => {
419
- return new this.fabric.Text(String(name || ''), {
420
- ...defaultVaule.style,
421
- ...defaultVaule.textStyle,
422
- ...nameStyle,
423
- originY: 'bottom',
424
- left: originX + 5,
425
- top: top - 5
426
- });
427
- };
428
-
429
- if (isMax) {
430
- const line = drawLine(valueObj.max);
431
- const text = drawText(valueObj.max, line.top);
432
- line.text = text;
433
- lines.push(line, text);
434
- }
435
- if (isMin) {
436
- const line = drawLine(valueObj.min);
437
- const text = drawText(valueObj.min, line.top);
438
- line.text = text;
439
- lines.push(line, text);
440
- }
441
- this.canvas.add(...lines);
442
- // this.canvas.renderAll();
443
- },
444
- /**
445
- * 绘制一条折线
446
- * @param {polyline} 折线属性
447
- * @param {polyline.type} 折线点形状 circle: 圆 | triangle: 三角
448
- * @param {polyline.pointAttr} 参数 fill: 填充色 | stroke: 描边色 | strokeWidth: 宽度 | radius: 半径 | width: 宽度 | height: 高度
449
- * @param {polyline.list} 折线点坐标数组
450
- * @param {polylineIndex} 当前折线 index
451
- */
452
- drawPolyline(polyline, polylineIndex, polylineType, polylineTypeId) {
453
- const { originY, endY } = this.propItems;
454
- const { pointAttr, lineAttr } = polyline;
455
- this._iconClassName = polyline.type === 'img' && pointAttr.iconClassName ? pointAttr.iconClassName : '';
456
-
457
- const list = polyline.list;
458
- const pointList = [];
459
- let lineList = [];
460
- const _this = this;
461
- function getPointer(point) {
462
- let isInit = false;
463
- let points = null;
464
- if (isEffectiveNode(point) && _this.isLimit(point.time)) {
465
- const x = _this.cumputedX(point.time);
466
- const y = _this.cumputedY(polylineType, point.value);
467
- isInit = y < originY || y > endY;
468
- points = [x, y < originY ? originY : y > endY ? endY : y];
469
- }
470
- return { isInit, points };
471
- }
472
- list.forEach((linePoints, index) => {
473
- // 当前点
474
- let { points, isInit } = getPointer(linePoints);
475
-
476
- // 下一个点
477
- const nextPoints = list[index + 1];
478
- let { points: nextPoint } = getPointer(nextPoints);
479
-
480
- let line;
481
- let point;
482
- let previousLine;
483
- line = points && nextPoint ? this.drawLine([...points, ...nextPoint], { polylineIndex, polylineTypeId, lineIndex: index, ...lineAttr }) : null;
484
- previousLine = lineList[index - 1];
485
- const pointOthers = { polylineTypeId, polylineIndex, pointIndex: index, ...pointAttr, lineAttr };
486
- if (points) {
487
- Object.assign(pointOthers, {
488
- originLeft: points[0],
489
- originTop: points[1],
490
- time: linePoints.time
491
- });
492
- point = previousLine ? this.drawPoint(...points, previousLine, line, polyline.type, pointOthers, isInit) : this.drawPoint(...points, null, line, polyline.type, pointOthers, isInit);
493
- }
494
- lineList.push(line);
495
- point && pointList.push(point);
496
- });
497
-
498
- Promise.all(pointList).then(res => {
499
- const polylineObj = this.polylinePointList.find(v => v.polylineTypeId == polylineTypeId && v.polylineIndex == polylineIndex);
500
- const pointerList = res.map(v => v.left);
501
- if (polylineObj) {
502
- Object.assign(polylineObj, {
503
- pointerList,
504
- pointList: res
505
- });
506
- polylineObj.pointerList = pointerList;
507
- } else {
508
- this.polylinePointList.push({
509
- polylineTypeId,
510
- polylineIndex,
511
- pointerList,
512
- color: lineAttr.stroke,
513
- pointList: res
514
- });
515
- }
516
- lineList = lineList.filter(v => v);
517
- let prevPoint = null;
518
- res = res.filter(v => {
519
- if (v && prevPoint) {
520
- prevPoint.nextPoint = v; // 记录下一个点 id
521
- v.prevPoint = prevPoint;
522
- }
523
- prevPoint = v || prevPoint;
524
- return v;
525
- });
526
- this.canvas.add(...lineList, ...res);
527
- // this.canvas.requestRenderAll();
528
- });
529
-
530
- this.createAttrVaule('critical', polyline, polylineIndex, polylineType, polylineTypeId);
531
- this.createAttrVaule('diffValue', polyline, polylineIndex, polylineType, polylineTypeId);
532
- },
533
- // 计算y轴坐标
534
- cumputedY(polylineType, linePointY) {
535
- const { position = 'left', list = [] } = polylineType;
536
- const key = position === 'left' ? 'Left' : 'Right';
537
- const yScaleCell = this.propItems[`yScaleCell${key}`];
538
- const yCellUnit = linePointY - Math.min(...list);
539
- return this.propItems.endY - yScaleCell * yCellUnit;
540
- },
541
- /**
542
- * 绘制折线点
543
- * @param {left, top} 折线点坐标
544
- * @param {line1, line2} 与折线点关联的线
545
- * @param {type} 折线点类型
546
- * @param {others} 参数 polylineIndex | pointIndex | ...polyline.pointAttr
547
- */
548
- async drawPoint(left, top, line1, line2, type, others, isInit) {
549
- const pointId = `${others.polylineTypeId}_${others.polylineIndex}_${others.pointIndex}_polylinePoint_${new Date().getTime()}`;
550
- const ele = this._iconClassName && (await this.createImage(this._iconClassName, others));
551
- let point = await this.createPoint(type, {
552
- id: pointId,
553
- left: left,
554
- top: top,
555
- ele: ele || '',
556
- ...defaultVaule.pointStyle,
557
- ...others,
558
- ...(!this.eventStyle.evented
559
- ? {
560
- lockMovementX: true,
561
- lockMovementY: true
562
- }
563
- : {})
564
- });
565
- point.hasControls = point.hasBorders = false;
566
- line1 && (point.line1 = line1);
567
- line2 && (point.line2 = line2);
568
- point.on('mouseover', () => {
569
- this.showDrapPopup(point);
570
- this.pointToFront(point);
571
- });
572
- point.on('mouseout', () => {
573
- this.isDropVisible = false;
574
- });
575
- // 折线点移动中 实时更新相关联的线的坐标
576
- if (this.eventStyle.evented) {
577
- point.on('moving', () => {
578
- this.pointMoveLimit(point, false);
579
- this.pointMoveUpdateLine(point);
580
- this.addPoint(point);
581
- // this.canvas.renderAll();
582
- this.showDrapPopup(point);
583
- });
584
- // 折线点停止拖拽后 更新polyline中对应的坐标
585
- point.on('moved', () => {
586
- if (point && point.id.includes('_polylinePoint_')) {
587
- this.isDropVisible = false;
588
- this.setEmitFunction(point);
589
- this.addPointObjList = [];
590
- }
591
- });
592
- point.on('mouseup', event => {
593
- const { button, isClick } = event;
594
- if (button == 1 && isClick) {
595
- // 可配置批量删除当前项目上的点了
596
- this.currentDelPoint = point;
597
- }
598
- });
599
- }
600
-
601
- // 超出表格最高或最低值则需要触发pointChange事件并且不能更新视图,否则连接节点判断不会成功
602
- isInit && this.setEmitFunction(point, isInit);
603
-
604
- return point;
605
- },
606
- // 拖动停止后 设置回调触发方法
607
- setEmitFunction(point, isInit = false) {
608
- const { operable } = this.propItems;
609
- const { data, x, y } = this.getValue(point);
610
- Object.assign(data, {
611
- value: { time: operable.lockMovementX ? point.time : x, value: y },
612
- isInit
613
- });
614
- if (this.addPointList.length === 0) {
615
- if (point.prevPoint?.time.includes(x) || point.nextPoint?.time.includes(x)) {
616
- // 此方法更新节点后其事件都失效了,暂时采用下方repaintPolyline方法更新整条节点
617
- // point.setCoords();
618
- // point.set('left', point.originLeft);
619
- // point.set({
620
- // left: point.originLeft,
621
- // top: point.originTop
622
- // });
623
- // this.pointMoveUpdateLine(point);
624
- this.repaintPolyline(data.position, data.dataIndex);
625
- return;
626
- }
627
- this.$emit('pointChange', data);
628
- } else {
629
- this.$nextTick(() => {
630
- // 拖动新增节点时默认所有节点可删除
631
- this.currentDelPoint = null;
632
- });
633
- const lastPoint = this.addPointList[this.addPointList.length - 1];
634
- const position = this.polyline[point.polylineTypeId].position;
635
- const [firstPoint] = this.addPointList;
636
- // 如果是重合/连线节点
637
- if (point.get('scaleX') !== point.scale) {
638
- const addOjb = {
639
- ...lastPoint,
640
- value: {
641
- time: this.getXValue(this._concatPoint?.left),
642
- value: this.getYValue(position, this._concatPoint?.top)
643
- }
644
- };
645
- if (lastPoint.value.time == addOjb.value.time) {
646
- this.addPointList.splice(-1, 1, addOjb);
647
- } else {
648
- this.addPointList.push(addOjb);
649
- }
650
- this.addPointList.forEach(v => Object.assign(v, { isConcat: true, concatIndex: this._concatIndex }));
651
- } else if (point.line2 || (point.nextPoint && lastPoint.left >= point.nextPoint.left)) {
652
- // 1、存在右连线 2、无右侧连线,并且存在下一个节点的情况
653
- this.addPointList = [];
654
- this.repaintPolyline(position, point.polylineIndex);
655
- return;
656
- }
657
- !point.line2 && firstPoint.left <= point.originLeft && this.addPointList.splice(0, 1);
658
- !point.id.includes('isTitle') && this.removePolyline(point.id);
659
- if (this.addPointList.length > 0) {
660
- this.$emit('pointOperation', 'increasePointBatch', this.addPointList);
661
- this.addPointList = [];
662
- } else {
663
- this.repaintPolyline(position, point.polylineIndex);
664
- }
665
- }
666
- },
667
- // 设置批量新增数据
668
- setAddPointList(point) {
669
- const { data, x, y } = this.getValue(point);
670
- data.value = { time: x, value: y };
671
- data.left = point.left;
672
- data.top = top;
673
- this.addPointList.push(data);
674
- },
675
- // 纠正线段坐标
676
- setLinePatch(point) {
677
- const { originLeft, originTop } = point;
678
- for (let i = 0, len = this.addPointList.length; i < len; i++) {
679
- const currentPoint = this.addPointList[i];
680
- const prevPoint = this.addPointList[i - 1] || { left: point.prePoint?.left ?? originLeft, top: point.prePoint?.top ?? originTop };
681
- const currentPointObj = this.addPointObjList.find(obj => obj.left === currentPoint.left);
682
- if (currentPointObj?.line1?.x1 !== prevPoint.left) {
683
- currentPointObj.line1.set({
684
- x1: prevPoint.left,
685
- y1: prevPoint.top,
686
- x2: currentPoint.left,
687
- y2: currentPoint.top
688
- });
689
- }
690
- }
691
- },
692
- // 检查批量新增拖动过程中是否存在漏点的情况
693
- checkPoints(point) {
694
- const { originLeft, originTop, left, polylineTypeId } = point;
695
- const PointLens = Math.floor((left - originLeft) / this.spaceWidth);
696
- if (PointLens > 1 && this.addPointList?.length <= PointLens) {
697
- const position = this.polyline[polylineTypeId].position;
698
- for (let k = 0; k <= PointLens; k++) {
699
- if (k > 0) {
700
- const curLeft = originLeft + this.spaceWidth * k;
701
- // 判断this.addPointList中的left是否包含curLeft,不包含就说明是漏了
702
- const hasPoint = this.addPointList.some(p => Math.abs(p.left - curLeft) <= 0.001);
703
- // const hasPoint = this.addPointList.some(v => v.left == curLeft);
704
- if (!hasPoint) {
705
- let index;
706
- const pointObj = this.addPointList.find((v, i) => {
707
- if (v.left > curLeft) {
708
- index = i;
709
- }
710
- return v.left > curLeft;
711
- });
712
- if (pointObj) {
713
- let cloneObj = JSON.parse(JSON.stringify(pointObj));
714
- const prePoint = this.addPointList[index - 1] || {
715
- left: originLeft,
716
- top: originTop
717
- };
718
- const len = ~~((pointObj.left - (curLeft - this.spaceWidth)) / this.spaceWidth);
719
- const spaceHeight = (pointObj.top - prePoint.top) / len;
720
- cloneObj.top = prePoint.top + spaceHeight;
721
- cloneObj.value.time = this.getXValue(curLeft);
722
- cloneObj.value.value = this.getYValue(position, cloneObj.top);
723
- cloneObj.left = curLeft;
724
- this.addPointList.splice(index, 0, cloneObj);
725
- this.clonePoint(point, [prePoint.left, prePoint.top, cloneObj.left, cloneObj.top]);
726
- }
727
- }
728
- }
729
- }
730
- }
731
- // 纠正节点上的line1的坐标
732
- this.setLinePatch(point);
733
- },
734
- /**
735
- * @description: 拖动批量新增节点
736
- * @param {*} point 拖动的最后一个节点
737
- * @return {*}
738
- */
739
- addPoint(point) {
740
- let { left, top, originLeft, originTop } = point;
741
- const currentLeft = left;
742
-
743
- const startLength = this.addPointList.length;
744
- const n = 6; // 拖动范围,在需要增加节点的刻度左右吸入的范围值
745
- const residue = (left - originLeft) % this.spaceWidth;
746
-
747
- const condition = residue > 0 && (residue > this.spaceWidth - n || residue < n);
748
- const conditionNoLine2 = !point.line2 && left > originLeft;
749
- const conditionHasLine2 = point.line2 && left > originLeft + this.spaceWidth;
750
-
751
- // if (!point.line2 && left > originLeft && condition) {
752
- if (condition && (conditionNoLine2 || conditionHasLine2)) {
753
- if (residue > this.spaceWidth - n) left = left - residue + this.spaceWidth;
754
- if (residue < n) left = left - residue;
755
- point.set({
756
- left
757
- });
758
-
759
- // const i = Math.floor((left - originLeft) / this.spaceWidth);
760
- // 复制点和线
761
- if (conditionNoLine2 || conditionHasLine2) {
762
- // point.line1 && this.removePolyline(point.line1.id);
763
- setPointLineColor(point, 'transparent', conditionHasLine2);
764
- this.addPointList.length == 0 && this.clonePoint(point, [point.line1 ? point.line1.x1 : originLeft, point.line1 ? point.line1.y1 : originTop, originLeft, originTop]);
765
- if (this.addPointList.every(v => v.left !== left)) {
766
- // const points1 = i === 1 ? [originLeft, originTop] : point.prePoints;
767
- const points1 = this.addPointList.length == 0 ? [originLeft, originTop] : point.prePoints;
768
- if (points1) {
769
- // this.setAddPointList(point);
770
- // 调用上面方法就会导致线段绘制失败,目前还不知道为啥子
771
- const { data, x, y } = this.getValue(point);
772
- data.value = { time: x, value: y };
773
- data.left = left;
774
- data.top = top;
775
- // 避免重复添加
776
- if (this.addPointObjList.every(o => o.left !== left)) {
777
- this.addPointList.push(data);
778
- this.clonePoint(point, [...points1, left, top]);
779
- }
780
- }
781
- }
782
- this.checkPoints(point);
783
- }
784
- }
785
-
786
- // 断点相连
787
- function concatPoint(target) {
788
- const { left: targetLeft, top: targetTop } = target;
789
- point.setCoords();
790
- if (left >= targetLeft - n && left <= targetLeft + n && top <= targetTop + n && top >= targetTop - n) {
791
- point.set({
792
- left: targetLeft,
793
- top: targetTop,
794
- scaleX: point.scale === 1 ? 2.5 : 0.1,
795
- scaleY: point.scale === 1 ? 2.5 : 0.1
796
- });
797
- } else {
798
- point.set({
799
- scaleX: point.scale,
800
- scaleY: point.scale
801
- });
802
- }
803
- }
804
-
805
- // 检查是否显示重合连线放大节点的标识
806
- const { polylineTypeId, polylineIndex } = point;
807
- const polylineObj = this.polylinePointList.find(v => v.polylineTypeId == polylineTypeId && v.polylineIndex == polylineIndex);
808
- polylineObj?.pointList.forEach(v => v.bringToFront());
809
- if (point.nextPoint) {
810
- this._concatIndex = polylineObj?.pointerList.findIndex(v => v + n > left && v > originLeft);
811
- if (!~this._concatIndex) {
812
- point.set({
813
- scaleX: point.scale,
814
- scaleY: point.scale
815
- });
816
- } else {
817
- concatPoint(polylineObj?.pointList[this._concatIndex]);
818
- }
819
- this._concatPoint = polylineObj?.pointList?.[this._concatIndex] || null;
820
-
821
- // 被覆盖节点置灰配置
822
- polylineObj?.pointerList.forEach((v, i) => {
823
- const obj = polylineObj?.pointList[i];
824
- if (v > originLeft && v < left) {
825
- // 此处需要递归遍历group节点的所有子节点,然后更改其颜色
826
- resetPointColor([obj], '#999');
827
- obj.line2?.set({ stroke: '#999' });
828
- } else {
829
- resetPointColor([obj], polylineObj.color);
830
- obj.line2?.set({ stroke: polylineObj.color });
831
- }
832
- });
833
- if ((point.line1 || point.line2) && left < originLeft + this.spaceWidth) {
834
- setPointLineColor(point, polylineObj.color, true);
835
- } else {
836
- setPointLineColor(point, 'transparent', true);
837
- }
838
- }
839
-
840
- // 如果往回拖动则删除经过的已存在的节点
841
- if (startLength > 0 && currentLeft <= this.addPointList[startLength - 1].left) {
842
- this.removePolyline('increasePointBatch', left);
843
- this.addPointList = this.addPointList.filter(v => v.left < left);
844
- const endLength = this.addPointList.length;
845
- if (endLength === 0) {
846
- setPointLineColor(point, polylineObj?.color, conditionHasLine2);
847
- this.removePolyline('increasePointBatch', originLeft);
848
- }
849
- if (endLength > 0) {
850
- point.set({
851
- prePoints: [this.addPointList[endLength - 1].left, this.addPointList[endLength - 1].top]
852
- });
853
- }
854
- }
855
- },
856
- clonePoint(point, points) {
857
- let evented, selectable, lineIndex, polylineIndex, lineAttr, polylineTypeId;
858
- evented = selectable = false;
859
- lineAttr = { ...point.lineAttr };
860
- lineIndex = point.pointIndex;
861
- polylineIndex = point.polylineIndex;
862
- polylineTypeId = point.polylineTypeId;
863
-
864
- // return new Promise((resolve, reject) => {
865
- point.clone(clonedObj => {
866
- clonedObj.set({
867
- left: points[2],
868
- top: points[3],
869
- idClone: 'increasePointBatch',
870
- id: '_polylinePoint_' + new Date().getTime(), // 此id必须,用于remove节点的时候
871
- polylineTypeId,
872
- polylineIndex: point.polylineIndex,
873
- scaleX: point.scale,
874
- scaleY: point.scale
875
- });
876
- clonedObj.hasControls = clonedObj.hasBorders = false;
877
- point.prePoints = [point.left, point.top];
878
- const line = this.drawLine([...points], { evented, selectable, ...lineAttr, polylineIndex, polylineTypeId, lineIndex });
879
- clonedObj.line1 = line;
880
- this.canvas.sendBackwards(line);
881
- clonedObj.bringForward();
882
- this.canvas.add(clonedObj);
883
- this.addPointObjList.push(clonedObj);
884
- // resolve(clonedObj);
885
- });
886
- // });
887
- },
888
- getValue(point) {
889
- const x = this.getXValue(point.left);
890
- if (point.id) {
891
- const data = this.getDataById(point.id);
892
- const position = data.position;
893
- const y = this.getYValue(position, point.top);
894
- return { data, x, y };
895
- } else {
896
- const left = this.getYValue('left', point.top);
897
- const right = this.getYValue('right', point.top);
898
- return { x, left, right };
899
- }
900
- },
901
- getYValue(position, top) {
902
- const key = position == 'left' ? 'Left' : 'Right';
903
- const list = this.polyline.find(item => item.position == position)?.list || [];
904
- const v = list.length ? Math.min(...list) : 0;
905
- const y = (this.propItems.endY - top) / this.propItems[`yScaleCell${key}`] + v;
906
- return y;
907
- },
908
- /**
909
- * 绘制折线点
910
- * @param {lines} 线坐标 [x1, y1, x2, y2]
911
- * @param {others} 参数 polylineIndex | pointIndex | ...polyline.lineAttr
912
- */
913
- drawLine(lines, others) {
914
- const lineId = `${others.lineIndex}_${others.polylineIndex}_polylineLine_${new Date().getTime()}`;
915
- const line = new this.fabric.Line(lines, {
916
- id: lineId,
917
- hoverCursor: 'default',
918
- // objectCaching: false,
919
- selectable: false,
920
- evented: false,
921
- ...others
922
- });
923
-
924
- return line;
925
- },
926
- showDrapPopup(point) {
927
- this.isDropVisible = true;
928
- this.dropPos = {
929
- left: point.left,
930
- top: point.top,
931
- margin: { top: this.propItems.yCellHeight }
932
- };
933
- let { x, y, data } = this.getValue(point);
934
- const getY = y => {
935
- if (data?.position == 'right') {
936
- if (y.toString().includes('.')) {
937
- const [m, n] = y.toString().split('.');
938
- return (parseFloat(`${m}.${n.slice(0, 1)}`) * 10) / 10;
939
- }
940
- return y;
941
- } else {
942
- return Math.round(y);
943
- }
944
- };
945
- this.dropVal = {
946
- title: data.title,
947
- list: [
948
- { id: '11', name: '时间', value: x },
949
- { id: '22', name: '值', value: getY(y) }
950
- ]
951
- };
952
- },
953
- // 折线点移动时 setCoords()方法手动更新相关联的线坐标
954
- pointMoveUpdateLine(point) {
955
- if (point.line1) {
956
- point.line1.setCoords();
957
- point.line1.set({ x2: point.left, y2: point.top });
958
- }
959
- if (point.line2) {
960
- point.line2.setCoords();
961
- point.line2.set({ x1: point.left, y1: point.top });
962
- }
963
- },
964
- // 打开右键菜单
965
- openRightModal(event) {
966
- this.rightPos = {
967
- clientX: event.e.clientX || event.e.pageX,
968
- clientY: event.e.clientY || event.e.pageY
969
- };
970
- this.isRightVisible = false;
971
- const target = event.target;
972
- const id = target ? target.id : '';
973
- this.$nextTick(() => {
974
- if (id && id.includes('_polylinePoint_')) {
975
- this._currentPoint = target;
976
- let nodeConnect = [];
977
- if (this.propItems.operable.connect) {
978
- if (!target.line2 && target.nextPoint) {
979
- nodeConnect = rightClickNodeConnect.slice(0, 1);
980
- }
981
- if (!target.line1 && target.prevPoint) {
982
- nodeConnect = rightClickNodeConnect.slice(1);
983
- }
984
- if (!target.line1 && !target.line2 && target.prevPoint && target.nextPoint) {
985
- nodeConnect = rightClickNodeConnect.slice();
986
- }
987
- }
988
- this.rightClickNode = Object.freeze(
989
- rightClickNode
990
- .slice(0, 1)
991
- .concat(nodeConnect)
992
- .concat(rightClickNode.slice(-1))
993
- );
994
- this.isRightVisible = true;
995
- } else if (!id) {
996
- const { operable } = this.propItems;
997
- this._currentPoint = null;
998
- this.rightClickNode = Object.freeze(operable.set ? rightClickNode.slice(0, 2) : rightClickNode.slice(0, 1));
999
- this.isRightVisible = true;
1000
- }
1001
- });
1002
- },
1003
- // 关闭右键菜单,打开添加节点弹窗表单
1004
- handleRightClick({ type, name }) {
1005
- this.isRightVisible = false;
1006
- const id = this._currentPoint?.id;
1007
- const { left, top } = this._active;
1008
- let data = id ? this.getDataById(id) : this.getValue({ left, top });
1009
- if (type == 'add') {
1010
- if (name.includes('左')) {
1011
- data.range = {
1012
- time: [this._currentPoint.prevPoint.time, this._currentPoint.time],
1013
- direction: 'left'
1014
- };
1015
- }
1016
- if (name.includes('右')) {
1017
- data.range = {
1018
- time: [this._currentPoint.time, this._currentPoint.nextPoint.time],
1019
- direction: 'right'
1020
- };
1021
- }
1022
- }
1023
- this.$emit('pointOperation', type, data);
1024
- this._currentPoint = null;
1025
- },
1026
- getDataById(id) {
1027
- const arr = id.replace(/_?[a-zA-Z]+.+$/, '').split('_');
1028
- const [typeIndex, lineIndex, pointIndex] = arr;
1029
- const data = this.polyline[typeIndex];
1030
- const value = data?.dataList?.[lineIndex]?.list?.[pointIndex]?.data || '';
1031
- return {
1032
- title: data?.dataList?.[lineIndex].title || '',
1033
- position: data.position,
1034
- dataIndex: lineIndex,
1035
- pointIndex: pointIndex,
1036
- data: value
1037
- };
1038
- },
1039
- isOnePolyLine(obj, polylineTypeId, polylineIndex) {
1040
- // 排除左侧标题
1041
- const isPolyLine = obj.polylineTypeId === polylineTypeId && obj.polylineIndex === polylineIndex;
1042
- if (obj.id && /_polyline(Point|Line)_/.test(obj.id) && !obj.id.includes('isTitle') && isPolyLine) return true;
1043
- return;
1044
- },
1045
- // 将当条线段以及点层级置顶
1046
- // 线段不能先置顶,会挡住其他线段上的点
1047
- pointToFront(point) {
1048
- this.canvas.forEachObject(obj => {
1049
- if (this.isOnePolyLine(obj, point.polylineTypeId, point.polylineIndex)) {
1050
- this.canvas.bringToFront(obj);
1051
- }
1052
- });
1053
- },
1054
- removePolyline(id, left, position, polylineIndex) {
1055
- // 根据id或者idClone删除
1056
- if (id) {
1057
- const pointId = left ? 'idClone' : 'id';
1058
- if (pointId === 'idClone') {
1059
- this.addPointObjList.forEach(obj => {
1060
- if (obj.left >= left) {
1061
- this.canvas.remove(obj);
1062
- obj.line1 && this.canvas.remove(obj.line1);
1063
- }
1064
- });
1065
- this.addPointObjList = this.addPointObjList.filter(obj => obj.left < left);
1066
- } else {
1067
- const point = this.canvas.getObjects().filter(item => item[pointId] === id);
1068
- if (point && point.length > 0) {
1069
- point.forEach(v => {
1070
- if (!left) {
1071
- this.canvas.remove(v);
1072
- v.line1 && this.canvas.remove(v.line1);
1073
- }
1074
- });
1075
- }
1076
- }
1077
-
1078
- return;
1079
- }
1080
- // 删除一条线
1081
- if (position && (polylineIndex === 0 || polylineIndex)) {
1082
- const polylineTypeId = this.polyline.findIndex(v => v.position === position);
1083
- this.canvas.forEachObject(obj => {
1084
- if (this.isOnePolyLine(obj, polylineTypeId, polylineIndex)) {
1085
- obj.text && this.canvas.remove(obj.text);
1086
- obj.line1 && this.canvas.remove(obj.line1);
1087
- obj.line2 && this.canvas.remove(obj.line2);
1088
- this.canvas.remove(obj);
1089
- }
1090
- });
1091
- return;
1092
- }
1093
- // 删除折线图上的所有点和线
1094
- this.canvas.forEachObject(obj => {
1095
- if (obj.id && /_polyline(Point|Line)_/.test(obj.id) && !obj.id.includes('isTitle')) {
1096
- obj.text && this.canvas.remove(obj.text);
1097
- this.canvas.remove(obj);
1098
- }
1099
- });
1100
- },
1101
- removeSelectArea() {
1102
- if (this.selectArea) {
1103
- this.canvas.remove(this.selectArea);
1104
- this.selectArea = null;
1105
- }
1106
- },
1107
- repaintPolyline(position, dadaIndex) {
1108
- if (arguments.length < 2) {
1109
- if (this.polyline.length) {
1110
- this.removePolyline();
1111
- }
1112
- this.polylinePointList = [];
1113
- this.polyline.forEach((polylineType, polylineTypeId) => {
1114
- this.createPolyline(polylineType, polylineTypeId);
1115
- });
1116
- this.removeTitle();
1117
- this.drawPolylineTitle();
1118
- } else {
1119
- const polylineTypeId = this.polyline.findIndex(v => v.position === position);
1120
- this.removePolyline(null, null, position, parseInt(dadaIndex));
1121
- this.drawPolyline(this.polyline[polylineTypeId].dataList[parseInt(dadaIndex)], parseInt(dadaIndex), this.polyline[polylineTypeId], polylineTypeId);
1122
- }
1123
- }
1124
- }
1125
- };
1126
- </script>
1
+ <template>
2
+ <div class="poly-line">
3
+ <MouseRightClick v-show="isRightVisible" :getContainer="getContainer" :nodeList="rightClickNode" :rightPos="rightPos" @nodeClick="handleRightClick" @closeRight="isRightVisible = false" />
4
+
5
+ <DropPopup v-show="isDropVisible" :val="dropVal" :dropPos="dropPos" />
6
+ </div>
7
+ </template>
8
+
9
+ <script>
10
+ import FabricCommon from '../mixins/fabricCommon';
11
+ import draw from '../mixins/draw';
12
+ import eventCommon from '../mixins/eventCommon';
13
+ import MouseRightClick from '../components/MouseRightClick';
14
+ import DropPopup from '../components/DropPopup';
15
+ import defaultVaule from '../const/defaultVaule';
16
+
17
+ /**
18
+ * @description: 递归遍历节点,设置颜色属性
19
+ * @param {fabric.Object[]} pointArr
20
+ * @param {string}} color
21
+ * @return {*}
22
+ */
23
+
24
+ function resetPointColor(pointArr, color) {
25
+ pointArr.forEach(point => {
26
+ const { fill, stroke } = point;
27
+ if (fill && !fill.includes('#fff') && fill !== 'transparent') {
28
+ point.set({ fill: color });
29
+ }
30
+ if (stroke && !stroke.includes('#fff') && stroke !== 'transparent') {
31
+ point.set({ stroke: color });
32
+ }
33
+ if (point._objects?.length) {
34
+ resetPointColor(point._objects, color);
35
+ }
36
+ });
37
+ }
38
+ const setPointLineColor = (point, color, conditionHasLine2) => {
39
+ point.line1?.set({ stroke: color });
40
+ conditionHasLine2 && point.line2?.set({ stroke: color });
41
+ };
42
+
43
+ const isEffectiveNode = node => {
44
+ return node?.time && (node?.value || node?.value === 0);
45
+ };
46
+ const rightClickNode = [
47
+ { name: '新增节点', type: 'add' },
48
+ { name: '检测项设置', type: 'set' },
49
+ { name: '删除节点', type: 'delete' }
50
+ ];
51
+ const rightClickNodeConnect = [
52
+ { name: '新增节点连接右侧节点', type: 'add' },
53
+ { name: '新增节点连接左侧节点', type: 'add' }
54
+ ];
55
+ export default {
56
+ name: 'fabric-polylines',
57
+ mixins: [FabricCommon, draw, eventCommon],
58
+ inject: ['$propItems'],
59
+ props: {
60
+ polyline: {
61
+ type: Array,
62
+ required: true
63
+ },
64
+ other: {
65
+ type: Object,
66
+ default: () => {}
67
+ }
68
+ },
69
+ components: {
70
+ MouseRightClick,
71
+ DropPopup
72
+ },
73
+ data() {
74
+ return {
75
+ isDropVisible: false,
76
+ dropVal: {},
77
+ dropPos: { clientX: 0, clientY: 0 },
78
+ isRightVisible: false,
79
+ rightPos: { clientX: 0, clientY: 0 },
80
+ rightClickNode: [],
81
+ activeEvent: null, // 当前可右键活动的对象
82
+ addPointList: [], // 快速新增的节点list
83
+ addPointObjList: [], // 批量新增节点对象的缓存
84
+ isSelectArea: false, // 是否正在选区
85
+ selectArea: null, // 选区矩形对象
86
+ currentDelPoint: null, // 缓存当前可批量删除的项目线段上的点
87
+ polylinePointList: [] // 缓存折线项目节点
88
+ };
89
+ },
90
+ computed: {
91
+ eventStyle() {
92
+ return this.propItems.eventStyle;
93
+ },
94
+ spaceWidth() {
95
+ const { xCellWidth, table } = this.propItems;
96
+ // const addPointSpaceGridNumbers = table.addPointSpaceGridNumbers || [];
97
+ let addPointSpaceGridNumber = table.addPointSpaceGridNumber || 1;
98
+ const spaceWidth = xCellWidth * addPointSpaceGridNumber;
99
+ return spaceWidth;
100
+ }
101
+ },
102
+
103
+ watch: {},
104
+
105
+ mounted() {},
106
+
107
+ methods: {
108
+ init() {
109
+ this.drawPolylineTitle();
110
+ this.polylinePointList = [];
111
+ this.polyline.forEach((polylineType, polylineTypeId) => {
112
+ this.createPolyline(polylineType, polylineTypeId);
113
+ });
114
+
115
+ this.eventStyle.evented && this.createEvent();
116
+ },
117
+ createEvent() {
118
+ this.canvas.on('mouse:up', event => {
119
+ if (event.button === 3) {
120
+ const { x, y } = event.pointer;
121
+ const { originX, originY, endX, endY } = this.$propItems();
122
+ if (!(x < originX || x > endX || y < originY || y > endY)) {
123
+ this.activeEvent = event;
124
+ document.querySelector('.upper-canvas').addEventListener('contextmenu', this.addEventListenerContextmenu, true);
125
+ }
126
+ // this.willUpdateLine = line;
127
+ }
128
+ // 左键松开鼠标-批量删除
129
+ this.isSelectArea = false;
130
+ if (event.button === 1 && !event.target && this.selectArea) {
131
+ const points = this.selectArea.ponits;
132
+ const delList = this.getAreaPonits(points);
133
+ delList.length === 0 && this.removeSelectArea();
134
+ if (delList.length > 0 && this.selectArea) {
135
+ this.$emit('pointOperation', 'delete', delList);
136
+ this.currentDelPoint = null;
137
+ }
138
+ }
139
+ });
140
+ let selectAreaOrigin = { left: 0, top: 0 };
141
+ this.canvas.on('mouse:down', event => {
142
+ if (event.button === 1 && !event.target) {
143
+ this.isSelectArea = true;
144
+ selectAreaOrigin.left = event.pointer.x;
145
+ selectAreaOrigin.top = event.pointer.y;
146
+ }
147
+ });
148
+ this.canvas.on('mouse:move', event => {
149
+ this.isSelectArea && this.createSelectArea(event, selectAreaOrigin);
150
+ });
151
+ },
152
+ handleMoving(event) {
153
+ const { pointer } = event;
154
+ const { x, y } = pointer;
155
+ this.dropPointer = { ...pointer };
156
+ const left = this.getYValue('left', y);
157
+ const right = this.getYValue('right', y);
158
+ const movingPopupContentList = [
159
+ { id: '1', name: '时间', value: this.getXValue(x) },
160
+ {
161
+ id: '2',
162
+ name: '值',
163
+ value: `${this.formatValue('left', left)} / ${this.formatValue('right', right)}℃`
164
+ }
165
+ ];
166
+ this.movingShowPopup(movingPopupContentList);
167
+ },
168
+ // 获取选区内包含的节点
169
+ getAreaPonits(points) {
170
+ const delList = [];
171
+ const [x1, y1, x2, y2] = points;
172
+ this.canvas.forEachObject(obj => {
173
+ const { id, left, top } = obj;
174
+ const isArea = left >= x1 && left <= x2 && top >= y1 && top <= y2;
175
+ if (id && /_polyline(Point)_/.test(id) && !id.includes('isTitle') && isArea) {
176
+ if (this.currentDelPoint) {
177
+ const { polylineIndex } = this.currentDelPoint;
178
+ if (polylineIndex == obj.polylineIndex) {
179
+ delList.push(this.getDataById(id));
180
+ }
181
+ } else {
182
+ delList.push(this.getDataById(id));
183
+ }
184
+ }
185
+ });
186
+ return delList;
187
+ },
188
+ // 创建选区
189
+ createSelectArea(event, selectAreaOrigin) {
190
+ this.selectArea && this.canvas.remove(this.selectArea);
191
+ this.selectArea = new this.fabric.Rect({
192
+ ...defaultVaule.style,
193
+ fill: '#CAF982',
194
+ opacity: 0.4,
195
+ left: selectAreaOrigin.left,
196
+ top: selectAreaOrigin.top,
197
+ width: event.pointer.x - selectAreaOrigin.left,
198
+ height: event.pointer.y - selectAreaOrigin.top,
199
+ ponits: [selectAreaOrigin.left, selectAreaOrigin.top, event.pointer.x, event.pointer.y]
200
+ });
201
+ this.canvas.add(this.selectArea);
202
+ // this.canvas.renderAll();
203
+ },
204
+ // 每一个折线类别
205
+ createPolyline(polylineType, polylineTypeId) {
206
+ polylineType.dataList.forEach((polylineItem, polylineIndex) => {
207
+ this.drawPolyline(polylineItem, polylineIndex, polylineType, polylineTypeId);
208
+ });
209
+ },
210
+ // 绘制左侧折线标题
211
+ drawPolylineTitle() {
212
+ const { canvasHeight, treeTableminCellWidth, originX, xScaleList, xScaleCellList, endX } = this.propItems;
213
+ const leftYScalevalue = this.polyline.find(v => v.position === 'left');
214
+ const lableMargin = leftYScalevalue.lableMargin || [5, 30];
215
+ const lableLineHeight = leftYScalevalue.lableLineHeight || 20;
216
+ const style = leftYScalevalue.style || { fontSize: 12, fill: '#000' };
217
+
218
+ const leftTitleList = [];
219
+
220
+ const minTime = Math.min(...xScaleList);
221
+ const maxTime = Math.max(...xScaleList);
222
+
223
+ this.polyline.forEach((item, index) => {
224
+ item.dataList.forEach((v, i) => {
225
+ const point = v.list.find(k => isEffectiveNode(k) && new Date(k.time).getTime() >= minTime && new Date(k.time).getTime() <= maxTime);
226
+ const firstPointLeft = point ? this.cumputedX(point.time) : 0;
227
+ const rightLimit = point ? firstPointLeft - this.spaceWidth : '';
228
+ // 配置是否可拖动标题图标批量增加-
229
+ const isAdd = (firstPointLeft || endX) - this.spaceWidth >= originX;
230
+ leftTitleList.push({
231
+ title: v.title,
232
+ type: v.type,
233
+ pointAttr: v.pointAttr,
234
+ lineAttr: v.lineAttr,
235
+ polylineTypeId: index,
236
+ polylineIndex: i,
237
+ isAdd,
238
+ rightLimit
239
+ });
240
+ });
241
+ });
242
+
243
+ // 配置左侧title图标(但不是折线项目)
244
+ if (this.other?.list && Array.isArray(this.other.list)) {
245
+ const otherList = this.other.list.map(v => {
246
+ return {
247
+ title: v.name,
248
+ type: v.type,
249
+ pointAttr: v,
250
+ isAdd: false,
251
+ polylineTypeId: -1,
252
+ polylineIndex: -1
253
+ };
254
+ });
255
+ if (this.other.position && this.other.position === 'top') {
256
+ leftTitleList.push(...otherList);
257
+ } else {
258
+ leftTitleList.unshift(...otherList);
259
+ }
260
+ }
261
+
262
+ const eventStyle = { selectable: false, evented: false };
263
+ leftTitleList.forEach(async (v, i) => {
264
+ const baseTop = canvasHeight - lableMargin[1];
265
+ const top = baseTop - i * lableLineHeight;
266
+ const left = lableMargin[0] + treeTableminCellWidth;
267
+ const pointId = `${v.polylineTypeId}_${v.polylineIndex}_-1_polylinePoint_'${new Date().getTime()}_isTitle`;
268
+ const { fill: fillColor = '#000', stroke } = v.pointAttr;
269
+ let text = new this.fabric.Text(String(v.title), {
270
+ fontSize: style.fontSize,
271
+ fill: fillColor && stroke ? stroke : fillColor,
272
+ left,
273
+ top,
274
+ originY: 'center',
275
+ ...defaultVaule.style,
276
+ id: pointId
277
+ });
278
+ const iconLeft = text.width + text.left + 10;
279
+ const option = {
280
+ left: iconLeft,
281
+ top,
282
+ ...v.pointAttr,
283
+ originY: 'center',
284
+ originX: 'center',
285
+ lineAttr: v.lineAttr || '',
286
+ pointAttr: v.pointAttr,
287
+ id: pointId,
288
+ polylineTypeId: v.polylineTypeId,
289
+ polylineIndex: v.polylineIndex,
290
+ ...(v.isAdd && this.eventStyle.evented ? {} : eventStyle),
291
+ rightLimit: v.rightLimit || ''
292
+ };
293
+ let ele;
294
+ if (v.type === 'img' && v.pointAttr?.iconClassName) {
295
+ ele = await this.createImage(v.pointAttr.iconClassName, v.pointAttr);
296
+ }
297
+ const icon = await this.createPoint(v.type, {
298
+ ele: ele || '',
299
+ ...option
300
+ });
301
+ icon.hasControls = icon.hasBorders = false;
302
+ let originTop = top;
303
+ let cloneIconId;
304
+ icon.on('moving', () => {
305
+ // 优化左侧图标太小不容易选中的问题
306
+ if (!icon.url && icon.scaleX == 1.8 && icon.scaleY == 1.8) {
307
+ icon.set({
308
+ scaleX: 1,
309
+ scaleY: 1
310
+ });
311
+ }
312
+
313
+ if (!cloneIconId) {
314
+ cloneIconId = '_polylinePoint_temp_' + new Date().getTime();
315
+ icon.clone(clonedObj => {
316
+ clonedObj.set({
317
+ id: cloneIconId // 此id必须,用于remove节点的时候
318
+ });
319
+ clonedObj.bringForward();
320
+ this.canvas.add(clonedObj);
321
+ });
322
+ }
323
+
324
+ icon.set({ originX: 'center' });
325
+ this.moveLimit(icon);
326
+ icon.left >= originX && icon.left < originX + 5 && (originTop = icon.top);
327
+ if (icon.left >= originX) {
328
+ this.showDrapPopup(icon);
329
+ } else {
330
+ this.isDropVisible = false;
331
+ }
332
+ // this.canvas.renderAll();
333
+ });
334
+ // 标题折线点停止拖拽后 更新
335
+ icon.on('moved', () => {
336
+ this.setLeft(icon);
337
+ icon.set({
338
+ id: icon.id.replace('_isTitle', '')
339
+ });
340
+ // this.canvas.renderAll();
341
+ this.removeTitle();
342
+ this.removePolyline(cloneIconId);
343
+
344
+ if (icon.id.includes('_polylinePoint_') && this.isDropVisible) {
345
+ this.isDropVisible = false;
346
+ if (icon.left >= originX) {
347
+ // this.setEmitFunction(icon);
348
+ this.setAddPointList(icon);
349
+ this.$emit('pointOperation', 'increasePointBatch', this.addPointList);
350
+ this.addPointList = [];
351
+ }
352
+ }
353
+ this.removePolyline(icon.id);
354
+ // 重绘折线标题
355
+ this.drawPolylineTitle();
356
+ });
357
+
358
+ // 优化左侧图标太小不容易选中的问题
359
+ if (icon.evented && !icon.url) {
360
+ const maxVal = Math.max(icon.width * icon.scale, icon.height * icon.scale);
361
+ if (maxVal < 7) {
362
+ icon.set({
363
+ scaleX: 1.8,
364
+ scaleY: 1.8
365
+ });
366
+ }
367
+ }
368
+
369
+ this.canvas.add(text, icon);
370
+ // this.canvas.requestRenderAll();
371
+ });
372
+ },
373
+ // 限制节点新增位置与右侧节点间隔的spaceWidth格子树必须为整数
374
+ setLeft(icon) {
375
+ const { originX } = this.propItems;
376
+ let tempLeft = icon.rightLimit;
377
+
378
+ if (!tempLeft) return;
379
+ const leftLimit = icon.left + this.spaceWidth;
380
+ let i = 0;
381
+ while (tempLeft >= leftLimit) {
382
+ tempLeft = icon.rightLimit - i * this.spaceWidth;
383
+ i++;
384
+ }
385
+ icon.left = tempLeft < originX ? originX : tempLeft;
386
+ },
387
+ // 点移动限制
388
+ moveLimit(point) {
389
+ point.setCoords();
390
+ const { treeTableminCellWidth, endX } = this.propItems;
391
+ const leftLimit = treeTableminCellWidth;
392
+ const rightLimit = point.rightLimit || endX;
393
+ if (point.top < this.propItems.originY) {
394
+ point.set('top', this.propItems.originY);
395
+ }
396
+ if (point.top > this.propItems.endY) {
397
+ point.set('top', this.propItems.endY);
398
+ }
399
+ if (point.left < leftLimit) {
400
+ point.set('left', leftLimit);
401
+ }
402
+ if (point.left > rightLimit) {
403
+ point.set('left', rightLimit);
404
+ }
405
+ },
406
+ removeTitle() {
407
+ this.canvas.forEachObject(obj => {
408
+ if (obj.id && obj.id.includes('isTitle')) {
409
+ this.canvas.remove(obj);
410
+ }
411
+ });
412
+ },
413
+ isLimit(time) {
414
+ const minMinute = Math.min(...this.propItems.xScaleList);
415
+ const maxMinute = Math.max(...this.propItems.xScaleList);
416
+ const getTime = new Date(time).getTime();
417
+ return getTime >= minMinute && getTime <= maxMinute;
418
+ },
419
+ // 创建危急值和差异值
420
+ createAttrVaule(attr, polyline, polylineIndex, polylineType, polylineTypeId) {
421
+ const { list } = polyline;
422
+ const valueObj = polyline[attr] || {};
423
+ if (!valueObj.max && !valueObj.min) return;
424
+
425
+ const { originX, endX } = this.propItems;
426
+ const isMax = valueObj.max?.show && valueObj.max?.value && list.some(v => +v.value >= +valueObj.max.value && this.isLimit(v.time));
427
+ const isMin = valueObj.min?.show && valueObj.min?.value && list.some(v => +v.value <= +valueObj.min.value && this.isLimit(v.time));
428
+ const lines = [];
429
+
430
+ const drawLine = ({ value, lineStyle }) => {
431
+ const top = this.cumputedY(polylineType, +value);
432
+ return this.drawLine([originX, top, endX, top], { polylineIndex, lineIndex: 0, polylineTypeId, ...(lineStyle || defaultVaule.criticalStyle) });
433
+ };
434
+ const drawText = ({ name, nameStyle }, top) => {
435
+ return new this.fabric.Text(String(name || ''), {
436
+ ...defaultVaule.style,
437
+ ...defaultVaule.textStyle,
438
+ ...nameStyle,
439
+ originY: 'bottom',
440
+ left: originX + 5,
441
+ top: top - 5
442
+ });
443
+ };
444
+
445
+ if (isMax) {
446
+ const line = drawLine(valueObj.max);
447
+ const text = drawText(valueObj.max, line.top);
448
+ line.text = text;
449
+ lines.push(line, text);
450
+ }
451
+ if (isMin) {
452
+ const line = drawLine(valueObj.min);
453
+ const text = drawText(valueObj.min, line.top);
454
+ line.text = text;
455
+ lines.push(line, text);
456
+ }
457
+ this.canvas.add(...lines);
458
+ // this.canvas.renderAll();
459
+ },
460
+ /**
461
+ * 绘制一条折线
462
+ * @param {polyline} 折线属性
463
+ * @param {polyline.type} 折线点形状 circle: 圆 | triangle: 三角
464
+ * @param {polyline.pointAttr} 参数 fill: 填充色 | stroke: 描边色 | strokeWidth: 宽度 | radius: 半径 | width: 宽度 | height: 高度
465
+ * @param {polyline.list} 折线点坐标数组
466
+ * @param {polylineIndex} 当前折线 index
467
+ */
468
+ drawPolyline(polyline, polylineIndex, polylineType, polylineTypeId) {
469
+ const { originY, endY } = this.propItems;
470
+ const { pointAttr, lineAttr } = polyline;
471
+ this._iconClassName = polyline.type === 'img' && pointAttr.iconClassName ? pointAttr.iconClassName : '';
472
+
473
+ const list = polyline.list;
474
+ const pointList = [];
475
+ let lineList = [];
476
+ const _this = this;
477
+ function getPointer(point) {
478
+ let isInit = false;
479
+ let points = null;
480
+ if (isEffectiveNode(point) && _this.isLimit(point.time)) {
481
+ const x = _this.cumputedX(point.time);
482
+ const y = _this.cumputedY(polylineType, point.value);
483
+ isInit = y < originY || y > endY;
484
+ points = [x, y < originY ? originY : y > endY ? endY : y];
485
+ }
486
+ return { isInit, points };
487
+ }
488
+ list.forEach((linePoints, index) => {
489
+ // 当前点
490
+ let { points, isInit } = getPointer(linePoints);
491
+
492
+ // 下一个点
493
+ const nextPoints = list[index + 1];
494
+ let { points: nextPoint } = getPointer(nextPoints);
495
+
496
+ let line;
497
+ let point;
498
+ let previousLine;
499
+ line = points && nextPoint ? this.drawLine([...points, ...nextPoint], { polylineIndex, polylineTypeId, lineIndex: index, ...lineAttr }) : null;
500
+ previousLine = lineList[index - 1];
501
+ const pointOthers = { polylineTypeId, polylineIndex, pointIndex: index, ...pointAttr, lineAttr };
502
+ if (points) {
503
+ Object.assign(pointOthers, {
504
+ originLeft: points[0],
505
+ originTop: points[1],
506
+ time: linePoints.time
507
+ });
508
+ point = previousLine ? this.drawPoint(...points, previousLine, line, polyline.type, pointOthers, isInit) : this.drawPoint(...points, null, line, polyline.type, pointOthers, isInit);
509
+ }
510
+ lineList.push(line);
511
+ point && pointList.push(point);
512
+ });
513
+
514
+ Promise.all(pointList).then(res => {
515
+ const polylineObj = this.polylinePointList.find(v => v.polylineTypeId == polylineTypeId && v.polylineIndex == polylineIndex);
516
+ const pointerList = res.map(v => v.left);
517
+ if (polylineObj) {
518
+ Object.assign(polylineObj, {
519
+ pointerList,
520
+ pointList: res
521
+ });
522
+ polylineObj.pointerList = pointerList;
523
+ } else {
524
+ this.polylinePointList.push({
525
+ polylineTypeId,
526
+ polylineIndex,
527
+ pointerList,
528
+ color: lineAttr.stroke,
529
+ pointList: res
530
+ });
531
+ }
532
+ lineList = lineList.filter(v => v);
533
+ let prevPoint = null;
534
+ res = res.filter(v => {
535
+ if (v && prevPoint) {
536
+ prevPoint.nextPoint = v; // 记录下一个点 id
537
+ v.prevPoint = prevPoint;
538
+ }
539
+ prevPoint = v || prevPoint;
540
+ return v;
541
+ });
542
+ this.canvas.add(...lineList, ...res);
543
+ // this.canvas.requestRenderAll();
544
+ });
545
+
546
+ this.createAttrVaule('critical', polyline, polylineIndex, polylineType, polylineTypeId);
547
+ this.createAttrVaule('diffValue', polyline, polylineIndex, polylineType, polylineTypeId);
548
+ },
549
+ // 计算y轴坐标
550
+ cumputedY(polylineType, linePointY) {
551
+ const { position = 'left', list = [] } = polylineType;
552
+ const key = position === 'left' ? 'Left' : 'Right';
553
+ const yScaleCell = this.propItems[`yScaleCell${key}`];
554
+ const yCellUnit = linePointY - Math.min(...list);
555
+ return this.propItems.endY - yScaleCell * yCellUnit;
556
+ },
557
+ /**
558
+ * 绘制折线点
559
+ * @param {left, top} 折线点坐标
560
+ * @param {line1, line2} 与折线点关联的线
561
+ * @param {type} 折线点类型
562
+ * @param {others} 参数 polylineIndex | pointIndex | ...polyline.pointAttr
563
+ */
564
+ async drawPoint(left, top, line1, line2, type, others, isInit) {
565
+ const pointId = `${others.polylineTypeId}_${others.polylineIndex}_${others.pointIndex}_polylinePoint_${new Date().getTime()}`;
566
+ const ele = this._iconClassName && (await this.createImage(this._iconClassName, others));
567
+ let point = await this.createPoint(type, {
568
+ id: pointId,
569
+ left: left,
570
+ top: top,
571
+ ele: ele || '',
572
+ ...defaultVaule.pointStyle,
573
+ ...others,
574
+ ...(!this.eventStyle.evented
575
+ ? {
576
+ lockMovementX: true,
577
+ lockMovementY: true
578
+ }
579
+ : {})
580
+ });
581
+ point.hasControls = point.hasBorders = false;
582
+ line1 && (point.line1 = line1);
583
+ line2 && (point.line2 = line2);
584
+ point.on('mouseover', () => {
585
+ this.showDrapPopup(point);
586
+ this.pointToFront(point);
587
+ });
588
+ point.on('mouseout', () => {
589
+ this.isDropVisible = false;
590
+ });
591
+ // 折线点移动中 实时更新相关联的线的坐标
592
+ if (this.eventStyle.evented) {
593
+ point.on('moving', () => {
594
+ this.pointMoveLimit(point, false);
595
+ this.pointMoveUpdateLine(point);
596
+ this.addPoint(point);
597
+ // this.canvas.renderAll();
598
+ this.showDrapPopup(point);
599
+ });
600
+ // 折线点停止拖拽后 更新polyline中对应的坐标
601
+ point.on('moved', () => {
602
+ if (point && point.id.includes('_polylinePoint_')) {
603
+ this.isDropVisible = false;
604
+ this.setEmitFunction(point);
605
+ this.addPointObjList = [];
606
+ }
607
+ });
608
+ point.on('mouseup', event => {
609
+ const { button, isClick } = event;
610
+ if (button == 1 && isClick) {
611
+ // 可配置批量删除当前项目上的点了
612
+ this.currentDelPoint = point;
613
+ }
614
+ });
615
+ }
616
+
617
+ // 超出表格最高或最低值则需要触发pointChange事件并且不能更新视图,否则连接节点判断不会成功
618
+ isInit && this.setEmitFunction(point, isInit);
619
+
620
+ return point;
621
+ },
622
+ // 拖动停止后 设置回调触发方法
623
+ setEmitFunction(point, isInit = false) {
624
+ const { operable } = this.propItems;
625
+ const { data, x, y } = this.getValue(point);
626
+ Object.assign(data, {
627
+ value: { time: operable.lockMovementX ? point.time : x, value: y },
628
+ isInit
629
+ });
630
+ if (this.addPointList.length === 0) {
631
+ if (point.prevPoint?.time.includes(x) || point.nextPoint?.time.includes(x)) {
632
+ // 此方法更新节点后其事件都失效了,暂时采用下方repaintPolyline方法更新整条节点
633
+ // point.setCoords();
634
+ // point.set('left', point.originLeft);
635
+ // point.set({
636
+ // left: point.originLeft,
637
+ // top: point.originTop
638
+ // });
639
+ // this.pointMoveUpdateLine(point);
640
+ this.repaintPolyline(data.position, data.dataIndex);
641
+ return;
642
+ }
643
+ this.$emit('pointChange', data);
644
+ } else {
645
+ this.$nextTick(() => {
646
+ // 拖动新增节点时默认所有节点可删除
647
+ this.currentDelPoint = null;
648
+ });
649
+ const lastPoint = this.addPointList[this.addPointList.length - 1];
650
+ const position = this.polyline[point.polylineTypeId].position;
651
+ const [firstPoint] = this.addPointList;
652
+ // 如果是重合/连线节点
653
+ if (point.get('scaleX') !== point.scale) {
654
+ const addOjb = {
655
+ ...lastPoint,
656
+ value: {
657
+ time: this.getXValue(this._concatPoint?.left),
658
+ value: this.getYValue(position, this._concatPoint?.top)
659
+ }
660
+ };
661
+ if (lastPoint.value.time == addOjb.value.time) {
662
+ this.addPointList.splice(-1, 1, addOjb);
663
+ } else {
664
+ this.addPointList.push(addOjb);
665
+ }
666
+ this.addPointList.forEach(v => Object.assign(v, { isConcat: true, concatIndex: this._concatIndex }));
667
+ } else if (point.line2 || (point.nextPoint && lastPoint.left >= point.nextPoint.left)) {
668
+ // 1、存在右连线 2、无右侧连线,并且存在下一个节点的情况
669
+ this.addPointList = [];
670
+ this.repaintPolyline(position, point.polylineIndex);
671
+ return;
672
+ }
673
+ !point.line2 && firstPoint.left <= point.originLeft && this.addPointList.splice(0, 1);
674
+ !point.id.includes('isTitle') && this.removePolyline(point.id);
675
+ if (this.addPointList.length > 0) {
676
+ this.$emit('pointOperation', 'increasePointBatch', this.addPointList);
677
+ this.addPointList = [];
678
+ } else {
679
+ this.repaintPolyline(position, point.polylineIndex);
680
+ }
681
+ }
682
+ },
683
+ // 设置批量新增数据
684
+ setAddPointList(point) {
685
+ const { data, x, y } = this.getValue(point);
686
+ data.value = { time: x, value: y };
687
+ data.left = point.left;
688
+ data.top = top;
689
+ this.addPointList.push(data);
690
+ },
691
+ // 纠正线段坐标
692
+ setLinePatch(point) {
693
+ const { originLeft, originTop } = point;
694
+ for (let i = 0, len = this.addPointList.length; i < len; i++) {
695
+ const currentPoint = this.addPointList[i];
696
+ const prevPoint = this.addPointList[i - 1] || { left: point.prePoint?.left ?? originLeft, top: point.prePoint?.top ?? originTop };
697
+ const currentPointObj = this.addPointObjList.find(obj => obj.left === currentPoint.left);
698
+ if (currentPointObj?.line1?.x1 !== prevPoint.left) {
699
+ currentPointObj.line1.set({
700
+ x1: prevPoint.left,
701
+ y1: prevPoint.top,
702
+ x2: currentPoint.left,
703
+ y2: currentPoint.top
704
+ });
705
+ }
706
+ }
707
+ },
708
+ // 检查批量新增拖动过程中是否存在漏点的情况
709
+ checkPoints(point) {
710
+ const { originLeft, originTop, left, polylineTypeId } = point;
711
+ const PointLens = Math.floor((left - originLeft) / this.spaceWidth);
712
+ if (PointLens > 1 && this.addPointList?.length <= PointLens) {
713
+ const position = this.polyline[polylineTypeId].position;
714
+ for (let k = 0; k <= PointLens; k++) {
715
+ if (k > 0) {
716
+ const curLeft = originLeft + this.spaceWidth * k;
717
+ // 判断this.addPointList中的left是否包含curLeft,不包含就说明是漏了
718
+ const hasPoint = this.addPointList.some(p => Math.abs(p.left - curLeft) <= 0.001);
719
+ // const hasPoint = this.addPointList.some(v => v.left == curLeft);
720
+ if (!hasPoint) {
721
+ let index;
722
+ const pointObj = this.addPointList.find((v, i) => {
723
+ if (v.left > curLeft) {
724
+ index = i;
725
+ }
726
+ return v.left > curLeft;
727
+ });
728
+ if (pointObj) {
729
+ let cloneObj = JSON.parse(JSON.stringify(pointObj));
730
+ const prePoint = this.addPointList[index - 1] || {
731
+ left: originLeft,
732
+ top: originTop
733
+ };
734
+ const len = ~~((pointObj.left - (curLeft - this.spaceWidth)) / this.spaceWidth);
735
+ const spaceHeight = (pointObj.top - prePoint.top) / len;
736
+ cloneObj.top = prePoint.top + spaceHeight;
737
+ cloneObj.value.time = this.getXValue(curLeft);
738
+ cloneObj.value.value = this.getYValue(position, cloneObj.top);
739
+ cloneObj.left = curLeft;
740
+ this.addPointList.splice(index, 0, cloneObj);
741
+ this.clonePoint(point, [prePoint.left, prePoint.top, cloneObj.left, cloneObj.top]);
742
+ }
743
+ }
744
+ }
745
+ }
746
+ }
747
+ // 纠正节点上的line1的坐标
748
+ this.setLinePatch(point);
749
+ },
750
+ /**
751
+ * @description: 拖动批量新增节点
752
+ * @param {*} point 拖动的最后一个节点
753
+ * @return {*}
754
+ */
755
+ addPoint(point) {
756
+ let { left, top, originLeft, originTop } = point;
757
+ const currentLeft = left;
758
+
759
+ const startLength = this.addPointList.length;
760
+ const n = 6; // 拖动范围,在需要增加节点的刻度左右吸入的范围值
761
+ const residue = (left - originLeft) % this.spaceWidth;
762
+
763
+ const condition = residue > 0 && (residue > this.spaceWidth - n || residue < n);
764
+ const conditionNoLine2 = !point.line2 && left > originLeft;
765
+ const conditionHasLine2 = point.line2 && left > originLeft + this.spaceWidth;
766
+
767
+ // if (!point.line2 && left > originLeft && condition) {
768
+ if (condition && (conditionNoLine2 || conditionHasLine2)) {
769
+ if (residue > this.spaceWidth - n) left = left - residue + this.spaceWidth;
770
+ if (residue < n) left = left - residue;
771
+ point.set({
772
+ left
773
+ });
774
+
775
+ // const i = Math.floor((left - originLeft) / this.spaceWidth);
776
+ // 复制点和线
777
+ if (conditionNoLine2 || conditionHasLine2) {
778
+ // point.line1 && this.removePolyline(point.line1.id);
779
+ setPointLineColor(point, 'transparent', conditionHasLine2);
780
+ this.addPointList.length == 0 && this.clonePoint(point, [point.line1 ? point.line1.x1 : originLeft, point.line1 ? point.line1.y1 : originTop, originLeft, originTop]);
781
+ if (this.addPointList.every(v => v.left !== left)) {
782
+ // const points1 = i === 1 ? [originLeft, originTop] : point.prePoints;
783
+ const points1 = this.addPointList.length == 0 ? [originLeft, originTop] : point.prePoints;
784
+ if (points1) {
785
+ // this.setAddPointList(point);
786
+ // 调用上面方法就会导致线段绘制失败,目前还不知道为啥子
787
+ const { data, x, y } = this.getValue(point);
788
+ data.value = { time: x, value: y };
789
+ data.left = left;
790
+ data.top = top;
791
+ // 避免重复添加
792
+ if (this.addPointObjList.every(o => o.left !== left)) {
793
+ this.addPointList.push(data);
794
+ this.clonePoint(point, [...points1, left, top]);
795
+ }
796
+ }
797
+ }
798
+ this.checkPoints(point);
799
+ }
800
+ }
801
+
802
+ // 断点相连
803
+ function concatPoint(target) {
804
+ const { left: targetLeft, top: targetTop } = target;
805
+ point.setCoords();
806
+ if (left >= targetLeft - n && left <= targetLeft + n && top <= targetTop + n && top >= targetTop - n) {
807
+ point.set({
808
+ left: targetLeft,
809
+ top: targetTop,
810
+ scaleX: point.scale === 1 ? 2.5 : 0.1,
811
+ scaleY: point.scale === 1 ? 2.5 : 0.1
812
+ });
813
+ } else {
814
+ point.set({
815
+ scaleX: point.scale,
816
+ scaleY: point.scale
817
+ });
818
+ }
819
+ }
820
+
821
+ // 检查是否显示重合连线放大节点的标识
822
+ const { polylineTypeId, polylineIndex } = point;
823
+ const polylineObj = this.polylinePointList.find(v => v.polylineTypeId == polylineTypeId && v.polylineIndex == polylineIndex);
824
+ polylineObj?.pointList.forEach(v => v.bringToFront());
825
+ if (point.nextPoint) {
826
+ this._concatIndex = polylineObj?.pointerList.findIndex(v => v + n > left && v > originLeft);
827
+ if (!~this._concatIndex) {
828
+ point.set({
829
+ scaleX: point.scale,
830
+ scaleY: point.scale
831
+ });
832
+ } else {
833
+ concatPoint(polylineObj?.pointList[this._concatIndex]);
834
+ }
835
+ this._concatPoint = polylineObj?.pointList?.[this._concatIndex] || null;
836
+
837
+ // 被覆盖节点置灰配置
838
+ polylineObj?.pointerList.forEach((v, i) => {
839
+ const obj = polylineObj?.pointList[i];
840
+ if (v > originLeft && v < left) {
841
+ // 此处需要递归遍历group节点的所有子节点,然后更改其颜色
842
+ resetPointColor([obj], '#999');
843
+ obj.line2?.set({ stroke: '#999' });
844
+ } else {
845
+ resetPointColor([obj], polylineObj.color);
846
+ obj.line2?.set({ stroke: polylineObj.color });
847
+ }
848
+ });
849
+ if ((point.line1 || point.line2) && left < originLeft + this.spaceWidth) {
850
+ setPointLineColor(point, polylineObj.color, true);
851
+ } else {
852
+ setPointLineColor(point, 'transparent', true);
853
+ }
854
+ }
855
+
856
+ // 如果往回拖动则删除经过的已存在的节点
857
+ if (startLength > 0 && currentLeft <= this.addPointList[startLength - 1].left) {
858
+ this.removePolyline('increasePointBatch', left);
859
+ this.addPointList = this.addPointList.filter(v => v.left < left);
860
+ const endLength = this.addPointList.length;
861
+ if (endLength === 0) {
862
+ setPointLineColor(point, polylineObj?.color, conditionHasLine2);
863
+ this.removePolyline('increasePointBatch', originLeft);
864
+ }
865
+ if (endLength > 0) {
866
+ point.set({
867
+ prePoints: [this.addPointList[endLength - 1].left, this.addPointList[endLength - 1].top]
868
+ });
869
+ }
870
+ }
871
+ },
872
+ clonePoint(point, points) {
873
+ let evented, selectable, lineIndex, polylineIndex, lineAttr, polylineTypeId;
874
+ evented = selectable = false;
875
+ lineAttr = { ...point.lineAttr };
876
+ lineIndex = point.pointIndex;
877
+ polylineIndex = point.polylineIndex;
878
+ polylineTypeId = point.polylineTypeId;
879
+
880
+ // return new Promise((resolve, reject) => {
881
+ point.clone(clonedObj => {
882
+ clonedObj.set({
883
+ left: points[2],
884
+ top: points[3],
885
+ idClone: 'increasePointBatch',
886
+ id: '_polylinePoint_' + new Date().getTime(), // 此id必须,用于remove节点的时候
887
+ polylineTypeId,
888
+ polylineIndex: point.polylineIndex,
889
+ scaleX: point.scale,
890
+ scaleY: point.scale
891
+ });
892
+ clonedObj.hasControls = clonedObj.hasBorders = false;
893
+ point.prePoints = [point.left, point.top];
894
+ const line = this.drawLine([...points], { evented, selectable, ...lineAttr, polylineIndex, polylineTypeId, lineIndex });
895
+ clonedObj.line1 = line;
896
+ this.canvas.sendBackwards(line);
897
+ clonedObj.bringForward();
898
+ this.canvas.add(clonedObj);
899
+ this.addPointObjList.push(clonedObj);
900
+ // resolve(clonedObj);
901
+ });
902
+ // });
903
+ },
904
+ getValue(point) {
905
+ const x = this.getXValue(point.left);
906
+ if (point.id) {
907
+ const data = this.getDataById(point.id);
908
+ const position = data.position;
909
+ const y = this.getYValue(position, point.top);
910
+ return { data, x, y };
911
+ } else {
912
+ const left = this.getYValue('left', point.top);
913
+ const right = this.getYValue('right', point.top);
914
+ return { x, left, right };
915
+ }
916
+ },
917
+ getYValue(position, top) {
918
+ const key = position == 'left' ? 'Left' : 'Right';
919
+ const list = this.polyline.find(item => item.position == position)?.list || [];
920
+ const v = list.length ? Math.min(...list) : 0;
921
+ const y = (this.propItems.endY - top) / this.propItems[`yScaleCell${key}`] + v;
922
+ return y;
923
+ },
924
+ /**
925
+ * 绘制折线点
926
+ * @param {lines} 线坐标 [x1, y1, x2, y2]
927
+ * @param {others} 参数 polylineIndex | pointIndex | ...polyline.lineAttr
928
+ */
929
+ drawLine(lines, others) {
930
+ const lineId = `${others.lineIndex}_${others.polylineIndex}_polylineLine_${new Date().getTime()}`;
931
+ const line = new this.fabric.Line(lines, {
932
+ id: lineId,
933
+ hoverCursor: 'default',
934
+ // objectCaching: false,
935
+ selectable: false,
936
+ evented: false,
937
+ ...others
938
+ });
939
+
940
+ return line;
941
+ },
942
+ formatValue(position, y) {
943
+ if (position == 'right') {
944
+ if (y.toString().includes('.')) {
945
+ const [m, n] = y.toString().split('.');
946
+ return (parseFloat(`${m}.${n.slice(0, 1)}`) * 10) / 10;
947
+ }
948
+ return y;
949
+ } else {
950
+ return Math.round(y);
951
+ }
952
+ },
953
+ showDrapPopup(point) {
954
+ this.isDropVisible = true;
955
+ this.dropPos = {
956
+ left: point.left,
957
+ top: point.top,
958
+ margin: { top: this.propItems.yCellHeight }
959
+ };
960
+ let { x, y, data } = this.getValue(point);
961
+ this.dropVal = {
962
+ title: data.title,
963
+ list: [
964
+ { id: '11', name: '时间', value: x },
965
+ { id: '22', name: '值', value: this.formatValue(data.position, y) }
966
+ ]
967
+ };
968
+ },
969
+ // 折线点移动时 setCoords()方法手动更新相关联的线坐标
970
+ pointMoveUpdateLine(point) {
971
+ if (point.line1) {
972
+ point.line1.setCoords();
973
+ point.line1.set({ x2: point.left, y2: point.top });
974
+ }
975
+ if (point.line2) {
976
+ point.line2.setCoords();
977
+ point.line2.set({ x1: point.left, y1: point.top });
978
+ }
979
+ },
980
+ // 打开右键菜单
981
+ openRightModal(event) {
982
+ this.rightPos = {
983
+ clientX: event.e.clientX || event.e.pageX,
984
+ clientY: event.e.clientY || event.e.pageY
985
+ };
986
+ this.isRightVisible = false;
987
+ const target = event.target;
988
+ const id = target ? target.id : '';
989
+ this.$nextTick(() => {
990
+ if (id && id.includes('_polylinePoint_')) {
991
+ this._currentPoint = target;
992
+ let nodeConnect = [];
993
+ if (this.propItems.operable.connect) {
994
+ if (!target.line2 && target.nextPoint) {
995
+ nodeConnect = rightClickNodeConnect.slice(0, 1);
996
+ }
997
+ if (!target.line1 && target.prevPoint) {
998
+ nodeConnect = rightClickNodeConnect.slice(1);
999
+ }
1000
+ if (!target.line1 && !target.line2 && target.prevPoint && target.nextPoint) {
1001
+ nodeConnect = rightClickNodeConnect.slice();
1002
+ }
1003
+ }
1004
+ this.rightClickNode = Object.freeze(
1005
+ rightClickNode
1006
+ .slice(0, 1)
1007
+ .concat(nodeConnect)
1008
+ .concat(rightClickNode.slice(-1))
1009
+ );
1010
+ this.isRightVisible = true;
1011
+ } else if (!id) {
1012
+ const { operable } = this.propItems;
1013
+ this._currentPoint = null;
1014
+ this.rightClickNode = Object.freeze(operable.set ? rightClickNode.slice(0, 2) : rightClickNode.slice(0, 1));
1015
+ this.isRightVisible = true;
1016
+ }
1017
+ });
1018
+ },
1019
+ // 关闭右键菜单,打开添加节点弹窗表单
1020
+ handleRightClick({ type, name }) {
1021
+ this.isRightVisible = false;
1022
+ const id = this._currentPoint?.id;
1023
+ const { left, top } = this._active;
1024
+ let data = id ? this.getDataById(id) : this.getValue({ left, top });
1025
+ if (type == 'add') {
1026
+ if (name.includes('左')) {
1027
+ data.range = {
1028
+ time: [this._currentPoint.prevPoint.time, this._currentPoint.time],
1029
+ direction: 'left'
1030
+ };
1031
+ }
1032
+ if (name.includes('')) {
1033
+ data.range = {
1034
+ time: [this._currentPoint.time, this._currentPoint.nextPoint.time],
1035
+ direction: 'right'
1036
+ };
1037
+ }
1038
+ }
1039
+ this.$emit('pointOperation', type, data);
1040
+ this._currentPoint = null;
1041
+ },
1042
+ getDataById(id) {
1043
+ const arr = id.replace(/_?[a-zA-Z]+.+$/, '').split('_');
1044
+ const [typeIndex, lineIndex, pointIndex] = arr;
1045
+ const data = this.polyline[typeIndex];
1046
+ const value = data?.dataList?.[lineIndex]?.list?.[pointIndex]?.data || '';
1047
+ return {
1048
+ title: data?.dataList?.[lineIndex].title || '',
1049
+ position: data.position,
1050
+ dataIndex: lineIndex,
1051
+ pointIndex: pointIndex,
1052
+ data: value
1053
+ };
1054
+ },
1055
+ isOnePolyLine(obj, polylineTypeId, polylineIndex) {
1056
+ // 排除左侧标题
1057
+ const isPolyLine = obj.polylineTypeId === polylineTypeId && obj.polylineIndex === polylineIndex;
1058
+ if (obj.id && /_polyline(Point|Line)_/.test(obj.id) && !obj.id.includes('isTitle') && isPolyLine) return true;
1059
+ return;
1060
+ },
1061
+ // 将当条线段以及点层级置顶
1062
+ // 线段不能先置顶,会挡住其他线段上的点
1063
+ pointToFront(point) {
1064
+ this.canvas.forEachObject(obj => {
1065
+ if (this.isOnePolyLine(obj, point.polylineTypeId, point.polylineIndex)) {
1066
+ this.canvas.bringToFront(obj);
1067
+ }
1068
+ });
1069
+ },
1070
+ removePolyline(id, left, position, polylineIndex) {
1071
+ // 根据id或者idClone删除
1072
+ if (id) {
1073
+ const pointId = left ? 'idClone' : 'id';
1074
+ if (pointId === 'idClone') {
1075
+ this.addPointObjList.forEach(obj => {
1076
+ if (obj.left >= left) {
1077
+ this.canvas.remove(obj);
1078
+ obj.line1 && this.canvas.remove(obj.line1);
1079
+ }
1080
+ });
1081
+ this.addPointObjList = this.addPointObjList.filter(obj => obj.left < left);
1082
+ } else {
1083
+ const point = this.canvas.getObjects().filter(item => item[pointId] === id);
1084
+ if (point && point.length > 0) {
1085
+ point.forEach(v => {
1086
+ if (!left) {
1087
+ this.canvas.remove(v);
1088
+ v.line1 && this.canvas.remove(v.line1);
1089
+ }
1090
+ });
1091
+ }
1092
+ }
1093
+
1094
+ return;
1095
+ }
1096
+ // 删除一条线
1097
+ if (position && (polylineIndex === 0 || polylineIndex)) {
1098
+ const polylineTypeId = this.polyline.findIndex(v => v.position === position);
1099
+ this.canvas.forEachObject(obj => {
1100
+ if (this.isOnePolyLine(obj, polylineTypeId, polylineIndex)) {
1101
+ obj.text && this.canvas.remove(obj.text);
1102
+ obj.line1 && this.canvas.remove(obj.line1);
1103
+ obj.line2 && this.canvas.remove(obj.line2);
1104
+ this.canvas.remove(obj);
1105
+ }
1106
+ });
1107
+ return;
1108
+ }
1109
+ // 删除折线图上的所有点和线
1110
+ this.canvas.forEachObject(obj => {
1111
+ if (obj.id && /_polyline(Point|Line)_/.test(obj.id) && !obj.id.includes('isTitle')) {
1112
+ obj.text && this.canvas.remove(obj.text);
1113
+ this.canvas.remove(obj);
1114
+ }
1115
+ });
1116
+ },
1117
+ removeSelectArea() {
1118
+ if (this.selectArea) {
1119
+ this.canvas.remove(this.selectArea);
1120
+ this.selectArea = null;
1121
+ }
1122
+ },
1123
+ repaintPolyline(position, dadaIndex) {
1124
+ if (arguments.length < 2) {
1125
+ if (this.polyline.length) {
1126
+ this.removePolyline();
1127
+ }
1128
+ this.polylinePointList = [];
1129
+ this.polyline.forEach((polylineType, polylineTypeId) => {
1130
+ this.createPolyline(polylineType, polylineTypeId);
1131
+ });
1132
+ this.removeTitle();
1133
+ this.drawPolylineTitle();
1134
+ } else {
1135
+ const polylineTypeId = this.polyline.findIndex(v => v.position === position);
1136
+ this.removePolyline(null, null, position, parseInt(dadaIndex));
1137
+ this.drawPolyline(this.polyline[polylineTypeId].dataList[parseInt(dadaIndex)], parseInt(dadaIndex), this.polyline[polylineTypeId], polylineTypeId);
1138
+ }
1139
+ }
1140
+ }
1141
+ };
1142
+ </script>