cnhis-design-vue 2.1.56 → 2.1.58

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 +2653 -2551
  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 +308 -308
  15. package/es/breadcrumb/index.js +8 -8
  16. package/es/button/index.js +31 -31
  17. package/es/calendar/index.js +8 -8
  18. package/es/captcha/index.js +7 -7
  19. package/es/card/index.js +8 -8
  20. package/es/carousel/index.js +8 -8
  21. package/es/cascader/index.js +8 -8
  22. package/es/checkbox/index.js +17 -17
  23. package/es/col/index.js +8 -8
  24. package/es/collapse/index.js +8 -8
  25. package/es/color-picker/index.js +5 -5
  26. package/es/comment/index.js +8 -8
  27. package/es/config-provider/index.js +8 -8
  28. package/es/date-picker/index.js +30 -30
  29. package/es/descriptions/index.js +8 -8
  30. package/es/divider/index.js +8 -8
  31. package/es/drag-layout/index.js +5 -5
  32. package/es/drawer/index.js +8 -8
  33. package/es/dropdown/index.js +8 -8
  34. package/es/editor/index.js +1 -1
  35. package/es/ellipsis/index.js +3211 -0
  36. package/es/ellipsis/style.css +1 -0
  37. package/es/empty/index.js +8 -8
  38. package/es/fabric-chart/index.js +45 -45
  39. package/es/form/index.js +8 -8
  40. package/es/form-model/index.js +8 -8
  41. package/es/form-table/index.js +1623 -422
  42. package/es/form-table/style.css +1 -1
  43. package/es/grid/index.js +4 -4
  44. package/es/index/index.js +2599 -1411
  45. package/es/index/style.css +1 -1
  46. package/es/input/index.js +11 -11
  47. package/es/input-number/index.js +8 -8
  48. package/es/keep-cache/index.js +9 -9
  49. package/es/layout/index.js +8 -8
  50. package/es/list/index.js +8 -8
  51. package/es/locale-provider/index.js +8 -8
  52. package/es/map/index.js +13 -13
  53. package/es/mentions/index.js +8 -8
  54. package/es/menu/index.js +8 -8
  55. package/es/message/index.js +8 -8
  56. package/es/multi-chat/index.js +116 -116
  57. package/es/multi-chat-client/index.js +110 -110
  58. package/es/multi-chat-history/index.js +6 -6
  59. package/es/multi-chat-record/index.js +27 -27
  60. package/es/multi-chat-setting/index.js +43 -43
  61. package/es/multi-chat-sip/index.js +1 -1
  62. package/es/notification/index.js +8 -8
  63. package/es/page-header/index.js +8 -8
  64. package/es/pagination/index.js +8 -8
  65. package/es/popconfirm/index.js +8 -8
  66. package/es/popover/index.js +8 -8
  67. package/es/progress/index.js +8 -8
  68. package/es/radio/index.js +17 -17
  69. package/es/rate/index.js +8 -8
  70. package/es/result/index.js +8 -8
  71. package/es/row/index.js +8 -8
  72. package/es/scale-container/index.js +3361 -0
  73. package/es/scale-container/style.css +1 -0
  74. package/es/scale-view/index.js +158 -158
  75. package/es/select/index.js +83 -70
  76. package/es/select/style.css +1 -1
  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 +251 -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 +5011 -1618
  105. package/lib/cui.umd.js +5011 -1618
  106. package/lib/cui.umd.min.js +63 -57
  107. package/package.json +110 -108
  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 +3144 -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 +9 -0
  236. package/packages/ellipsis/src/Ellipsis.vue +65 -0
  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 +66 -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 +115 -115
  244. package/packages/fabric-chart/src/const/defaultVaule.js +59 -59
  245. package/packages/fabric-chart/src/fabric-chart/FabricLines.vue +552 -552
  246. package/packages/fabric-chart/src/fabric-chart/FabricPolylines.vue +1126 -1126
  247. package/packages/fabric-chart/src/fabric-chart/FabricScaleValue.vue +134 -134
  248. package/packages/fabric-chart/src/fabric-chart/FabricTextGroup.vue +566 -566
  249. package/packages/fabric-chart/src/mixins/fabricCommon.js +95 -95
  250. package/packages/fabric-chart/src/mixins/fabricObject.js +193 -193
  251. package/packages/fabric-chart/src/mixins/type.js +5 -5
  252. package/packages/form/index.js +16 -16
  253. package/packages/form/src/Form.jsx +11 -11
  254. package/packages/form/src/Item.jsx +11 -11
  255. package/packages/form-model/index.js +14 -14
  256. package/packages/form-model/src/FormModel.jsx +11 -11
  257. package/packages/form-model/src/Item.jsx +11 -11
  258. package/packages/form-table/index.js +16 -10
  259. package/packages/form-table/src/FormTable.vue +1110 -1110
  260. package/packages/form-table/src/components/table-component/config-data/index.js +80 -80
  261. package/packages/form-table/src/components/table-component/global-props.js +22 -22
  262. package/packages/form-table/src/components/table-component/index.js +8 -8
  263. package/packages/form-table/src/components/table-component/mixins/bound-date.js +455 -455
  264. package/packages/form-table/src/components/table-component/mixins/dateType.js +217 -217
  265. package/packages/form-table/src/components/table-component/mixins/item-default.js +257 -257
  266. package/packages/form-table/src/components/table-component/mixins/search.js +1242 -1228
  267. package/packages/form-table/src/components/table-component/register-com.js +30 -30
  268. package/packages/form-table/src/components/table-component/table-age/table-age.vue +175 -175
  269. package/packages/form-table/src/components/table-component/table-date-picker/table-date-picker.vue +87 -87
  270. package/packages/form-table/src/components/table-component/table-digital/table-digital.vue +93 -93
  271. package/packages/form-table/src/components/table-component/table-input/table-input.vue +81 -81
  272. package/packages/form-table/src/components/table-component/table-input-password/table-input-password.vue +126 -126
  273. package/packages/form-table/src/components/table-component/table-month-picker/table-month-picker.vue +55 -55
  274. package/packages/form-table/src/components/table-component/table-search/table-search.vue +174 -128
  275. package/packages/form-table/src/components/table-component/table-search-more/table-search-more.vue +191 -144
  276. package/packages/form-table/src/components/table-component/table-select/table-select.vue +64 -64
  277. package/packages/form-table/src/components/table-component/table-select-multiple/table-select-multiple.vue +81 -81
  278. package/packages/form-table/src/components/table-component/table-textarea/table-textarea.vue +76 -76
  279. package/packages/form-table/src/components/table-component/table-time-picker/table-time-picker.vue +55 -55
  280. package/packages/form-table/src/components/table-component/table-tree-select/table-tree-select.vue +135 -135
  281. package/packages/form-table/src/components/table-component/text-over-tooltip/TextOverTooltip.vue +97 -97
  282. package/packages/form-table/src/components/table-item/form-event.js +81 -81
  283. package/packages/form-table/src/components/table-item/global-props.js +27 -27
  284. package/packages/form-table/src/components/table-item/index.js +4 -4
  285. package/packages/form-table/src/components/table-item/render-methods.js +28 -28
  286. package/packages/form-table/src/components/table-item/validate-rules.js +520 -520
  287. package/packages/form-table/src/components/table-mixins/form-commom.js +98 -98
  288. package/packages/form-table/src/components/table-mixins/index.js +3 -3
  289. package/packages/form-table/src/components/table-utils/index.js +112 -112
  290. package/packages/form-table/src/disabledDetail.less +46 -46
  291. package/packages/grid/index.js +10 -10
  292. package/packages/grid/src/grid.js +28 -28
  293. package/packages/icon/index.js +10 -10
  294. package/packages/icon/src/icon.js +13 -13
  295. package/packages/index.js +313 -307
  296. package/packages/input/index.js +30 -30
  297. package/packages/input/src/Group.jsx +11 -11
  298. package/packages/input/src/Input.jsx +11 -11
  299. package/packages/input/src/Password.jsx +11 -11
  300. package/packages/input/src/Search.jsx +11 -11
  301. package/packages/input/src/TextArea.jsx +11 -11
  302. package/packages/input/src/input-quick/components/quick-item.vue +284 -284
  303. package/packages/input/src/input-quick/components/quick-popover.vue +596 -596
  304. package/packages/input/src/input-quick/index.vue +137 -137
  305. package/packages/input-number/index.js +12 -12
  306. package/packages/input-number/src/InputNumber.jsx +11 -11
  307. package/packages/keep-cache/KeepCache.js +236 -236
  308. package/packages/keep-cache/index.css +2 -2
  309. package/packages/keep-cache/index.js +8 -8
  310. package/packages/layout/index.js +27 -27
  311. package/packages/layout/src/Content.jsx +11 -11
  312. package/packages/layout/src/Footer.jsx +11 -11
  313. package/packages/layout/src/Header.jsx +11 -11
  314. package/packages/layout/src/Layout.jsx +11 -11
  315. package/packages/layout/src/Sider.jsx +11 -11
  316. package/packages/list/index.js +21 -21
  317. package/packages/list/src/Item.jsx +11 -11
  318. package/packages/list/src/ItemMeta.jsx +11 -11
  319. package/packages/list/src/List.jsx +11 -11
  320. package/packages/locale-provider/index.js +12 -12
  321. package/packages/locale-provider/src/LocaleProvider.jsx +11 -11
  322. package/packages/map/index.js +9 -9
  323. package/packages/map/src/Map.vue +484 -484
  324. package/packages/map/src/popup-map.vue +53 -53
  325. package/packages/mentions/index.js +18 -18
  326. package/packages/mentions/src/Mentions.jsx +11 -11
  327. package/packages/mentions/src/Option.jsx +11 -11
  328. package/packages/menu/index.js +27 -27
  329. package/packages/menu/src/Divider.jsx +11 -11
  330. package/packages/menu/src/Item.jsx +11 -11
  331. package/packages/menu/src/ItemGroup.jsx +11 -11
  332. package/packages/menu/src/Menu.jsx +11 -11
  333. package/packages/menu/src/SubMenu.jsx +11 -11
  334. package/packages/message/index.js +8 -8
  335. package/packages/modal/index.js +10 -10
  336. package/packages/modal/src/Modal.js +7 -7
  337. package/packages/multi-chat/chat/addConference.vue +200 -200
  338. package/packages/multi-chat/chat/addMembers.vue +411 -411
  339. package/packages/multi-chat/chat/advancedFilter.vue +372 -372
  340. package/packages/multi-chat/chat/calling.vue +246 -246
  341. package/packages/multi-chat/chat/chatFooter.vue +1596 -1596
  342. package/packages/multi-chat/chat/chatHistory.vue +605 -605
  343. package/packages/multi-chat/chat/chatMain.vue +1486 -1486
  344. package/packages/multi-chat/chat/client/index.vue +149 -149
  345. package/packages/multi-chat/chat/delay.vue +177 -177
  346. package/packages/multi-chat/chat/evaluate.vue +343 -343
  347. package/packages/multi-chat/chat/messageRecord.vue +324 -324
  348. package/packages/multi-chat/chat/mixins/NoData.js +20 -20
  349. package/packages/multi-chat/chat/mixins/base.js +97 -97
  350. package/packages/multi-chat/chat/mixins/uniRTCAPI.js +80 -80
  351. package/packages/multi-chat/chat/mixins/viewerOptions.js +67 -67
  352. package/packages/multi-chat/chat/quickReply.vue +439 -439
  353. package/packages/multi-chat/chat/robot/index.vue +312 -312
  354. package/packages/multi-chat/chat/scrollList.vue +1238 -1238
  355. package/packages/multi-chat/chat/videoVoiceList.vue +348 -348
  356. package/packages/multi-chat/chat/voice.vue +431 -431
  357. package/packages/multi-chat/components/avatar.vue +113 -113
  358. package/packages/multi-chat/components/chat-tabs-header.vue +251 -251
  359. package/packages/multi-chat/components/classify-tabs.vue +185 -185
  360. package/packages/multi-chat/components/empty.vue +24 -24
  361. package/packages/multi-chat/components/modal-refuse-reason.vue +112 -112
  362. package/packages/multi-chat/components/modal-sip.vue +160 -160
  363. package/packages/multi-chat/components/modal-user-transfer.vue +98 -98
  364. package/packages/multi-chat/components/msg-describe.vue +138 -138
  365. package/packages/multi-chat/components/msg-picture.vue +68 -68
  366. package/packages/multi-chat/components/msg-prescription.vue +205 -205
  367. package/packages/multi-chat/components/read-record.vue +133 -133
  368. package/packages/multi-chat/components/read-status.vue +34 -34
  369. package/packages/multi-chat/components/user-status.vue +198 -198
  370. package/packages/multi-chat/index.js +7 -7
  371. package/packages/multi-chat/setting/authority/index.vue +156 -156
  372. package/packages/multi-chat/setting/authority/roleSetting.vue +204 -204
  373. package/packages/multi-chat/setting/baseInfo/index.vue +1316 -1316
  374. package/packages/multi-chat/setting/customerService/batchSelect.vue +403 -403
  375. package/packages/multi-chat/setting/customerService/index.vue +273 -273
  376. package/packages/multi-chat/setting/event/edit/condition.vue +128 -128
  377. package/packages/multi-chat/setting/event/edit/index.vue +437 -437
  378. package/packages/multi-chat/setting/event/edit/notice.vue +129 -129
  379. package/packages/multi-chat/setting/event/edit/strategy.vue +98 -98
  380. package/packages/multi-chat/setting/event/index.vue +249 -249
  381. package/packages/multi-chat/setting/index.vue +269 -269
  382. package/packages/multi-chat/setting/page.vue +14 -14
  383. package/packages/multi-chat/setting/sessionList/index.vue +412 -412
  384. package/packages/multi-chat/setting/sessionList/messageRecord.vue +372 -372
  385. package/packages/multi-chat/setting/userConfig/index.vue +124 -124
  386. package/packages/multi-chat/setting/worktime/index.vue +274 -274
  387. package/packages/multi-chat/store/actions.js +452 -452
  388. package/packages/multi-chat/store/getters.js +371 -371
  389. package/packages/multi-chat/store/helper.js +66 -66
  390. package/packages/multi-chat/store/index.js +50 -50
  391. package/packages/multi-chat/store/mutation.js +296 -296
  392. package/packages/multi-chat/store/state.js +117 -117
  393. package/packages/multi-chat/style/emoji.css +315 -315
  394. package/packages/multi-chat/style/message.mixin.less +38 -38
  395. package/packages/multi-chat/utils/chatSock.js +93 -93
  396. package/packages/multi-chat/utils/compressImage.js +115 -115
  397. package/packages/multi-chat/utils/emoji.json +68 -68
  398. package/packages/multi-chat/utils/index.js +259 -259
  399. package/packages/multi-chat/utils/observer-scroll.js +49 -49
  400. package/packages/multi-chat/utils/panelsetting.js +48 -48
  401. package/packages/multi-chat-client/index.js +7 -7
  402. package/packages/multi-chat-history/index.js +7 -7
  403. package/packages/multi-chat-record/index.js +7 -7
  404. package/packages/multi-chat-setting/index.js +7 -7
  405. package/packages/multi-chat-sip/index.js +6 -6
  406. package/packages/notification/index.js +8 -8
  407. package/packages/page-header/index.js +12 -12
  408. package/packages/page-header/src/PageHeader.jsx +11 -11
  409. package/packages/pagination/index.js +12 -12
  410. package/packages/pagination/src/Pagination.jsx +11 -11
  411. package/packages/popconfirm/index.js +12 -12
  412. package/packages/popconfirm/src/Popconfirm.jsx +11 -11
  413. package/packages/popover/index.js +12 -12
  414. package/packages/popover/src/Popover.jsx +11 -11
  415. package/packages/progress/index.js +12 -12
  416. package/packages/progress/src/Progress.jsx +11 -11
  417. package/packages/radio/index.js +33 -33
  418. package/packages/radio/src/Group.jsx +11 -11
  419. package/packages/radio/src/Radio.jsx +11 -11
  420. package/packages/radio/src/RadioButton.jsx +11 -11
  421. package/packages/radio/src/RadioImg/index.vue +124 -124
  422. package/packages/rate/index.js +12 -12
  423. package/packages/rate/src/Rate.jsx +11 -11
  424. package/packages/result/index.js +12 -12
  425. package/packages/result/src/Result.jsx +11 -11
  426. package/packages/row/index.js +12 -12
  427. package/packages/row/src/Row.jsx +11 -11
  428. package/packages/scale-container/index.js +9 -0
  429. package/packages/scale-container/src/ScaleContainer.vue +197 -0
  430. package/packages/scale-container/src/scale.png +0 -0
  431. package/packages/scale-view/NoData.vue +81 -81
  432. package/packages/scale-view/answerParse.vue +133 -133
  433. package/packages/scale-view/customList.vue +801 -801
  434. package/packages/scale-view/data.js +80 -80
  435. package/packages/scale-view/evaluateCountdown.vue +155 -155
  436. package/packages/scale-view/evaluatePage.vue +202 -202
  437. package/packages/scale-view/formitem/data.js +3991 -3991
  438. package/packages/scale-view/formitem/index.js +6 -6
  439. package/packages/scale-view/formitem/r-address.vue +238 -238
  440. package/packages/scale-view/formitem/r-choice.vue +726 -726
  441. package/packages/scale-view/formitem/r-input.vue +92 -92
  442. package/packages/scale-view/formitem/r-prompt.vue +52 -52
  443. package/packages/scale-view/formitem/r-time.vue +285 -285
  444. package/packages/scale-view/formitem/r-upload-custom-list.vue +242 -242
  445. package/packages/scale-view/formitem/r-upload.vue +287 -287
  446. package/packages/scale-view/formitem/text-over-tooltip/TextOverTooltip.vue +98 -98
  447. package/packages/scale-view/index.js +17 -17
  448. package/packages/scale-view/mixin/NoData.js +38 -38
  449. package/packages/scale-view/mixin/evaluate.js +146 -146
  450. package/packages/scale-view/mixin/index.js +337 -337
  451. package/packages/scale-view/mixin/judgeTypes.js +267 -267
  452. package/packages/scale-view/scaleView.vue +2010 -2010
  453. package/packages/select/index.js +27 -27
  454. package/packages/select/src/CustomSelect/index.vue +130 -130
  455. package/packages/select/src/OptGroup.jsx +11 -11
  456. package/packages/select/src/Option.jsx +11 -11
  457. package/packages/select/src/Select/Select.vue +231 -231
  458. package/packages/select/src/Select/index.js +12 -12
  459. package/packages/select/src/TableSelect/index.vue +514 -514
  460. package/packages/select-label/index.js +14 -14
  461. package/packages/select-label/label-classify.vue +129 -129
  462. package/packages/select-label/labelFormContent.vue +787 -787
  463. package/packages/select-label/select-label.vue +581 -581
  464. package/packages/select-person/index.js +10 -10
  465. package/packages/select-person/search-tree.vue +373 -373
  466. package/packages/select-person/select-person.vue +1696 -1696
  467. package/packages/shortcut-setter/index.js +12 -12
  468. package/packages/shortcut-setter/src/ShortcutSetter.vue +55 -55
  469. package/packages/shortcut-setter/src/ShortcutSetterItem.vue +84 -84
  470. package/packages/shortcut-setter/src/utils/index.js +63 -63
  471. package/packages/skeleton/index.js +12 -12
  472. package/packages/skeleton/src/Skeleton.jsx +11 -11
  473. package/packages/slider/index.js +12 -12
  474. package/packages/slider/src/Slider.jsx +11 -11
  475. package/packages/space/index.js +12 -12
  476. package/packages/space/src/Space.jsx +11 -11
  477. package/packages/spin/index.js +12 -12
  478. package/packages/spin/src/Spin.jsx +11 -11
  479. package/packages/statistic/index.js +18 -18
  480. package/packages/statistic/src/Countdown.jsx +11 -11
  481. package/packages/statistic/src/Statistic.jsx +11 -11
  482. package/packages/steps/index.js +18 -18
  483. package/packages/steps/src/Step.jsx +11 -11
  484. package/packages/steps/src/Steps.jsx +11 -11
  485. package/packages/switch/index.js +12 -12
  486. package/packages/switch/src/Switch.jsx +11 -11
  487. package/packages/table-filter/index.js +27 -27
  488. package/packages/table-filter/src/base-search-com/BaseSearch.vue +2572 -2572
  489. package/packages/table-filter/src/classification/Classification-com.vue +1756 -1756
  490. package/packages/table-filter/src/classification/search-class-name.vue +266 -266
  491. package/packages/table-filter/src/classification/search-professional-model.vue +680 -680
  492. package/packages/table-filter/src/components/TextOverTooltip.vue +107 -107
  493. package/packages/table-filter/src/components/age-com/index.vue +205 -205
  494. package/packages/table-filter/src/components/button-group/ButtonGroup.vue +162 -162
  495. package/packages/table-filter/src/components/button-icon/button-icon.js +33 -33
  496. package/packages/table-filter/src/components/button-icon/getBtnIcon.js +34 -34
  497. package/packages/table-filter/src/components/c-tree-select/tree-select.vue +336 -336
  498. package/packages/table-filter/src/components/drop-button/drop-button.vue +224 -224
  499. package/packages/table-filter/src/components/drop-button/head-btn-icon.js +33 -33
  500. package/packages/table-filter/src/components/drop-view/drop-view.vue +89 -89
  501. package/packages/table-filter/src/components/multi-select/multi-select.vue +227 -227
  502. package/packages/table-filter/src/components/out-quick-search/out-quick-search.vue +340 -340
  503. package/packages/table-filter/src/components/range-age/index.vue +172 -172
  504. package/packages/table-filter/src/components/search-condition/SearchCondition.vue +1897 -1897
  505. package/packages/table-filter/src/components/search-condition/fieldTypeList.js +169 -169
  506. package/packages/table-filter/src/components/search-filter/SearchFilter.vue +278 -278
  507. package/packages/table-filter/src/components/search-modal/set-classification.vue +310 -310
  508. package/packages/table-filter/src/components/table-modal/TableModal.vue +463 -463
  509. package/packages/table-filter/src/const/dataOptions.js +43 -43
  510. package/packages/table-filter/src/const/index.js +1 -1
  511. package/packages/table-filter/src/index.vue +584 -584
  512. package/packages/table-filter/src/mixins/mixins.js +694 -694
  513. package/packages/table-filter/src/mixins/tableSearchCon.js +128 -128
  514. package/packages/table-filter/src/mixins/wordBookutils.js +102 -102
  515. package/packages/table-filter/src/quick-search/QuickSearch.vue +2125 -2125
  516. package/packages/tabs/index.js +18 -18
  517. package/packages/tabs/src/TabPane.jsx +11 -11
  518. package/packages/tabs/src/Tabs.jsx +11 -11
  519. package/packages/tag/index.js +21 -21
  520. package/packages/tag/src/CheckableTag.jsx +11 -11
  521. package/packages/tag/src/Tag.jsx +11 -11
  522. package/packages/tag/src/TagGroup.vue +621 -621
  523. package/packages/time-picker/index.js +12 -12
  524. package/packages/time-picker/src/TimePicker.jsx +11 -11
  525. package/packages/timeline/index.js +14 -14
  526. package/packages/timeline/src/Item.jsx +11 -11
  527. package/packages/timeline/src/Timeline.jsx +11 -11
  528. package/packages/tooltip/index.js +12 -12
  529. package/packages/tooltip/src/Tooltip.jsx +11 -11
  530. package/packages/transfer/index.js +12 -12
  531. package/packages/transfer/src/Transfer.jsx +11 -11
  532. package/packages/tree/index.js +18 -18
  533. package/packages/tree/src/Tree.jsx +11 -11
  534. package/packages/tree/src/TreeNode.jsx +11 -11
  535. package/packages/tree-select/index.js +18 -18
  536. package/packages/tree-select/src/TreeNode.jsx +11 -11
  537. package/packages/tree-select/src/TreeSelect.jsx +11 -11
  538. package/packages/upload/chunk-upload/chunk-upload-new.vue +1001 -1001
  539. package/packages/upload/chunk-upload/vod-chunk-upload.vue +749 -749
  540. package/packages/upload/chunk-upload/vod-upload-modal.vue +100 -100
  541. package/packages/upload/index.js +12 -12
  542. package/packages/upload/src/Upload.jsx +11 -11
  543. package/packages/verification-code/SlideVerify.vue +306 -306
  544. package/packages/verification-code/index.js +17 -17
  545. package/packages/verification-code/verification-code.vue +147 -147
  546. package/src/assets/img/nodata.png +0 -0
  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 -0
  552. package/src/component/select-pages/index.vue +95 -74
  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,1126 @@
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-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>