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.
- package/.prettierrc.js +27 -27
- package/CHANGELOG.md +2653 -2551
- package/README.md +90 -90
- package/commitlint.config.js +1 -1
- package/es/affix/index.js +8 -8
- package/es/age/index.js +18 -18
- package/es/alert/index.js +8 -8
- package/es/anchor/index.js +8 -8
- package/es/auto-complete/index.js +8 -8
- package/es/avatar/index.js +8 -8
- package/es/back-top/index.js +8 -8
- package/es/badge/index.js +8 -8
- package/es/base/index.js +8 -8
- package/es/big-table/index.js +308 -308
- package/es/breadcrumb/index.js +8 -8
- package/es/button/index.js +31 -31
- package/es/calendar/index.js +8 -8
- package/es/captcha/index.js +7 -7
- package/es/card/index.js +8 -8
- package/es/carousel/index.js +8 -8
- package/es/cascader/index.js +8 -8
- package/es/checkbox/index.js +17 -17
- package/es/col/index.js +8 -8
- package/es/collapse/index.js +8 -8
- package/es/color-picker/index.js +5 -5
- package/es/comment/index.js +8 -8
- package/es/config-provider/index.js +8 -8
- package/es/date-picker/index.js +30 -30
- package/es/descriptions/index.js +8 -8
- package/es/divider/index.js +8 -8
- package/es/drag-layout/index.js +5 -5
- package/es/drawer/index.js +8 -8
- package/es/dropdown/index.js +8 -8
- package/es/editor/index.js +1 -1
- package/es/ellipsis/index.js +3211 -0
- package/es/ellipsis/style.css +1 -0
- package/es/empty/index.js +8 -8
- package/es/fabric-chart/index.js +45 -45
- package/es/form/index.js +8 -8
- package/es/form-model/index.js +8 -8
- package/es/form-table/index.js +1623 -422
- package/es/form-table/style.css +1 -1
- package/es/grid/index.js +4 -4
- package/es/index/index.js +2599 -1411
- package/es/index/style.css +1 -1
- package/es/input/index.js +11 -11
- package/es/input-number/index.js +8 -8
- package/es/keep-cache/index.js +9 -9
- package/es/layout/index.js +8 -8
- package/es/list/index.js +8 -8
- package/es/locale-provider/index.js +8 -8
- package/es/map/index.js +13 -13
- package/es/mentions/index.js +8 -8
- package/es/menu/index.js +8 -8
- package/es/message/index.js +8 -8
- package/es/multi-chat/index.js +116 -116
- package/es/multi-chat-client/index.js +110 -110
- package/es/multi-chat-history/index.js +6 -6
- package/es/multi-chat-record/index.js +27 -27
- package/es/multi-chat-setting/index.js +43 -43
- package/es/multi-chat-sip/index.js +1 -1
- package/es/notification/index.js +8 -8
- package/es/page-header/index.js +8 -8
- package/es/pagination/index.js +8 -8
- package/es/popconfirm/index.js +8 -8
- package/es/popover/index.js +8 -8
- package/es/progress/index.js +8 -8
- package/es/radio/index.js +17 -17
- package/es/rate/index.js +8 -8
- package/es/result/index.js +8 -8
- package/es/row/index.js +8 -8
- package/es/scale-container/index.js +3361 -0
- package/es/scale-container/style.css +1 -0
- package/es/scale-view/index.js +158 -158
- package/es/select/index.js +83 -70
- package/es/select/style.css +1 -1
- package/es/select-label/index.js +50 -50
- package/es/select-person/index.js +20 -20
- package/es/shortcut-setter/index.js +10 -10
- package/es/skeleton/index.js +8 -8
- package/es/slider/index.js +8 -8
- package/es/space/index.js +8 -8
- package/es/spin/index.js +8 -8
- package/es/statistic/index.js +8 -8
- package/es/steps/index.js +8 -8
- package/es/switch/index.js +8 -8
- package/es/table-filter/index.js +251 -238
- package/es/table-filter/style.css +1 -1
- package/es/tabs/index.js +8 -8
- package/es/tag/index.js +9 -9
- package/es/time-picker/index.js +8 -8
- package/es/timeline/index.js +8 -8
- package/es/tooltip/index.js +8 -8
- package/es/transfer/index.js +8 -8
- package/es/tree/index.js +8 -8
- package/es/tree-select/index.js +8 -8
- package/es/upload/index.js +8 -8
- package/es/utils/clickoutside.js +7 -7
- package/es/utils/kty.min-1.0.0.js +5 -5
- package/es/utils/time-domain.js +16 -16
- package/es/utils/utils-map.js +32 -32
- package/es/utils/vexutils.js +27 -27
- package/es/verification-code/index.js +2 -2
- package/lib/cui.common.js +5011 -1618
- package/lib/cui.umd.js +5011 -1618
- package/lib/cui.umd.min.js +63 -57
- package/package.json +110 -108
- package/packages/affix/index.js +12 -12
- package/packages/affix/src/Affix.jsx +12 -12
- package/packages/age/index.js +27 -27
- package/packages/age/src/age/index.vue +139 -139
- package/packages/age/src/age-com/index.vue +209 -209
- package/packages/alert/index.js +12 -12
- package/packages/alert/src/Alert.jsx +11 -11
- package/packages/anchor/index.js +18 -18
- package/packages/anchor/src/Anchor.jsx +11 -11
- package/packages/anchor/src/Link.jsx +11 -11
- package/packages/auto-complete/index.js +12 -12
- package/packages/auto-complete/src/AutoComplete.jsx +12 -12
- package/packages/avatar/index.js +12 -12
- package/packages/avatar/src/Avatar.jsx +11 -11
- package/packages/back-top/index.js +12 -12
- package/packages/back-top/src/BackTop.jsx +11 -11
- package/packages/badge/index.js +12 -12
- package/packages/badge/src/Badge.jsx +11 -11
- package/packages/base/index.js +3 -3
- package/packages/big-table/index.js +16 -16
- package/packages/big-table/src/BigTable.vue +3144 -3144
- package/packages/big-table/src/Fieldset.vue +2067 -2067
- package/packages/big-table/src/assets/iconfont/iconfont.css +21 -21
- package/packages/big-table/src/assets/style/table-base.less +385 -385
- package/packages/big-table/src/assets/style/table-global.less +175 -175
- package/packages/big-table/src/components/AutoLayoutButton.vue +279 -279
- package/packages/big-table/src/components/NoData.vue +81 -81
- package/packages/big-table/src/components/TextOverTooltip.vue +120 -120
- package/packages/big-table/src/components/edit-form/EditForm.vue +509 -509
- package/packages/big-table/src/components/edit-form/edit-component/config-data/index.js +68 -68
- package/packages/big-table/src/components/edit-form/edit-component/edit-date-picker/edit-date-picker.vue +60 -60
- package/packages/big-table/src/components/edit-form/edit-component/edit-digital/edit-digital.vue +54 -54
- package/packages/big-table/src/components/edit-form/edit-component/edit-input/edit-input.vue +39 -39
- package/packages/big-table/src/components/edit-form/edit-component/edit-input-password/edit-input-password.vue +79 -79
- package/packages/big-table/src/components/edit-form/edit-component/edit-month-picker/edit-month-picker.vue +37 -37
- package/packages/big-table/src/components/edit-form/edit-component/edit-search/edit-search.vue +82 -82
- package/packages/big-table/src/components/edit-form/edit-component/edit-search-more/edit-search-more.vue +95 -95
- package/packages/big-table/src/components/edit-form/edit-component/edit-select/edit-select.vue +40 -40
- package/packages/big-table/src/components/edit-form/edit-component/edit-select-multiple/edit-select-multiple.vue +55 -55
- package/packages/big-table/src/components/edit-form/edit-component/edit-switch/edit-switch.vue +43 -43
- package/packages/big-table/src/components/edit-form/edit-component/edit-textarea/edit-textarea.vue +41 -41
- package/packages/big-table/src/components/edit-form/edit-component/edit-time-picker/edit-time-picker.vue +40 -40
- package/packages/big-table/src/components/edit-form/edit-component/mixins/bound-date.js +3 -3
- package/packages/big-table/src/components/edit-form/edit-component/mixins/dateType.js +217 -217
- package/packages/big-table/src/components/edit-form/edit-component/mixins/item-default.js +639 -639
- package/packages/big-table/src/components/edit-form/edit-component/mixins/search.js +1247 -1247
- package/packages/big-table/src/components/edit-form/edit-component/register-com.js +26 -26
- package/packages/big-table/src/components/edit-form/edit-item/form-event.js +80 -80
- package/packages/big-table/src/components/edit-form/edit-item/global-props.js +33 -33
- package/packages/big-table/src/components/edit-form/edit-item/index.js +4 -4
- package/packages/big-table/src/components/edit-form/edit-item/render-methods.js +28 -28
- package/packages/big-table/src/components/edit-form/edit-item/validate-rules.js +463 -463
- package/packages/big-table/src/components/edit-form/edit-mixins/form-commom.js +673 -673
- package/packages/big-table/src/components/edit-form/edit-mixins/index.js +3 -3
- package/packages/big-table/src/components/edit-form/edit-utils/index.js +112 -112
- package/packages/big-table/src/components/password-com.vue +58 -58
- package/packages/big-table/src/components/player-vod/index.vue +57 -57
- package/packages/big-table/src/components/player-vod/player.vue +189 -189
- package/packages/big-table/src/components/player-vod/video-list.vue +265 -265
- package/packages/big-table/src/components/player-vod/video-modal.vue +126 -126
- package/packages/big-table/src/utils/CustomPagination.vue +86 -86
- package/packages/big-table/src/utils/batchEditing.js +610 -610
- package/packages/big-table/src/utils/bigTableProps.js +103 -103
- package/packages/big-table/src/utils/format.js +557 -557
- package/packages/big-table/src/utils/nestTable.js +109 -109
- package/packages/big-table/src/utils/tableParse.js +234 -234
- package/packages/breadcrumb/index.js +21 -21
- package/packages/breadcrumb/src/Breadcrumb.jsx +11 -11
- package/packages/breadcrumb/src/BreadcrumbItem.jsx +11 -11
- package/packages/breadcrumb/src/BreadcrumbSeparator.jsx +11 -11
- package/packages/button/index.js +21 -21
- package/packages/button/src/Button.jsx +11 -11
- package/packages/button/src/ButtonGroup.jsx +11 -11
- package/packages/button/src/ButtonPrint/components/IdentityVerification.vue +181 -181
- package/packages/button/src/ButtonPrint/index.vue +766 -766
- package/packages/button/src/ButtonPrint/mixin/his-print.js +95 -95
- package/packages/calendar/index.js +12 -12
- package/packages/calendar/src/Calendar.jsx +11 -11
- package/packages/captcha/index.js +9 -9
- package/packages/captcha/src/Captcha.vue +164 -164
- package/packages/captcha/src/Index.vue +47 -47
- package/packages/captcha/src/SlideVerify.vue +285 -285
- package/packages/card/index.js +21 -21
- package/packages/card/src/Card.jsx +12 -12
- package/packages/card/src/CardGrid.js +7 -7
- package/packages/card/src/CardMeta.js +7 -7
- package/packages/carousel/index.js +12 -12
- package/packages/carousel/src/Carousel.jsx +12 -12
- package/packages/cascader/index.js +12 -12
- package/packages/cascader/src/Cascader.jsx +11 -11
- package/packages/checkbox/index.js +30 -30
- package/packages/checkbox/src/Checkbox.jsx +11 -11
- package/packages/checkbox/src/CheckboxImg/index.vue +141 -141
- package/packages/checkbox/src/Group.jsx +11 -11
- package/packages/col/index.js +13 -13
- package/packages/col/src/Col.jsx +11 -11
- package/packages/collapse/index.js +18 -18
- package/packages/collapse/src/Collapse.jsx +11 -11
- package/packages/collapse/src/Panel.jsx +11 -11
- package/packages/color-picker/index.js +10 -10
- package/packages/color-picker/src/color-picker.vue +191 -191
- package/packages/color-picker/src/style.less +109 -109
- package/packages/comment/index.js +12 -12
- package/packages/comment/src/Comment.jsx +11 -11
- package/packages/config-provider/index.js +12 -12
- package/packages/config-provider/src/ConfigProvider.jsx +11 -11
- package/packages/date-picker/index.js +26 -26
- package/packages/date-picker/src/DatePicker.jsx +12 -12
- package/packages/date-picker/src/MonthPicker.jsx +11 -11
- package/packages/date-picker/src/RangePicker.jsx +11 -11
- package/packages/date-picker/src/WeekPicker.jsx +11 -11
- package/packages/date-picker/src/utils/index.js +374 -374
- package/packages/descriptions/index.js +18 -18
- package/packages/descriptions/src/Descriptions.jsx +11 -11
- package/packages/descriptions/src/Item.jsx +11 -11
- package/packages/divider/index.js +12 -12
- package/packages/divider/src/Divider.jsx +11 -11
- package/packages/drag-layout/DragFormLeftItem.vue +173 -173
- package/packages/drag-layout/DragFormRightItem.vue +284 -284
- package/packages/drag-layout/I18n-mixins.js +10 -10
- package/packages/drag-layout/drag-layout.vue +778 -778
- package/packages/drag-layout/index.js +12 -12
- package/packages/drawer/index.js +12 -12
- package/packages/drawer/src/Drawer.jsx +11 -11
- package/packages/dropdown/index.js +12 -12
- package/packages/dropdown/src/Dropdown.jsx +11 -11
- package/packages/editor/index.js +9 -9
- package/packages/ellipsis/index.js +9 -0
- package/packages/ellipsis/src/Ellipsis.vue +65 -0
- package/packages/empty/index.js +12 -12
- package/packages/empty/src/Empty.jsx +11 -11
- package/packages/fabric-chart/index.js +9 -9
- package/packages/fabric-chart/src/FabricGrid.vue +66 -66
- package/packages/fabric-chart/src/components/DropPopup.vue +90 -90
- package/packages/fabric-chart/src/components/MouseRightClick.vue +168 -168
- package/packages/fabric-chart/src/components/TimeScaleValue.vue +115 -115
- package/packages/fabric-chart/src/const/defaultVaule.js +59 -59
- package/packages/fabric-chart/src/fabric-chart/FabricLines.vue +552 -552
- package/packages/fabric-chart/src/fabric-chart/FabricPolylines.vue +1126 -1126
- package/packages/fabric-chart/src/fabric-chart/FabricScaleValue.vue +134 -134
- package/packages/fabric-chart/src/fabric-chart/FabricTextGroup.vue +566 -566
- package/packages/fabric-chart/src/mixins/fabricCommon.js +95 -95
- package/packages/fabric-chart/src/mixins/fabricObject.js +193 -193
- package/packages/fabric-chart/src/mixins/type.js +5 -5
- package/packages/form/index.js +16 -16
- package/packages/form/src/Form.jsx +11 -11
- package/packages/form/src/Item.jsx +11 -11
- package/packages/form-model/index.js +14 -14
- package/packages/form-model/src/FormModel.jsx +11 -11
- package/packages/form-model/src/Item.jsx +11 -11
- package/packages/form-table/index.js +16 -10
- package/packages/form-table/src/FormTable.vue +1110 -1110
- package/packages/form-table/src/components/table-component/config-data/index.js +80 -80
- package/packages/form-table/src/components/table-component/global-props.js +22 -22
- package/packages/form-table/src/components/table-component/index.js +8 -8
- package/packages/form-table/src/components/table-component/mixins/bound-date.js +455 -455
- package/packages/form-table/src/components/table-component/mixins/dateType.js +217 -217
- package/packages/form-table/src/components/table-component/mixins/item-default.js +257 -257
- package/packages/form-table/src/components/table-component/mixins/search.js +1242 -1228
- package/packages/form-table/src/components/table-component/register-com.js +30 -30
- package/packages/form-table/src/components/table-component/table-age/table-age.vue +175 -175
- package/packages/form-table/src/components/table-component/table-date-picker/table-date-picker.vue +87 -87
- package/packages/form-table/src/components/table-component/table-digital/table-digital.vue +93 -93
- package/packages/form-table/src/components/table-component/table-input/table-input.vue +81 -81
- package/packages/form-table/src/components/table-component/table-input-password/table-input-password.vue +126 -126
- package/packages/form-table/src/components/table-component/table-month-picker/table-month-picker.vue +55 -55
- package/packages/form-table/src/components/table-component/table-search/table-search.vue +174 -128
- package/packages/form-table/src/components/table-component/table-search-more/table-search-more.vue +191 -144
- package/packages/form-table/src/components/table-component/table-select/table-select.vue +64 -64
- package/packages/form-table/src/components/table-component/table-select-multiple/table-select-multiple.vue +81 -81
- package/packages/form-table/src/components/table-component/table-textarea/table-textarea.vue +76 -76
- package/packages/form-table/src/components/table-component/table-time-picker/table-time-picker.vue +55 -55
- package/packages/form-table/src/components/table-component/table-tree-select/table-tree-select.vue +135 -135
- package/packages/form-table/src/components/table-component/text-over-tooltip/TextOverTooltip.vue +97 -97
- package/packages/form-table/src/components/table-item/form-event.js +81 -81
- package/packages/form-table/src/components/table-item/global-props.js +27 -27
- package/packages/form-table/src/components/table-item/index.js +4 -4
- package/packages/form-table/src/components/table-item/render-methods.js +28 -28
- package/packages/form-table/src/components/table-item/validate-rules.js +520 -520
- package/packages/form-table/src/components/table-mixins/form-commom.js +98 -98
- package/packages/form-table/src/components/table-mixins/index.js +3 -3
- package/packages/form-table/src/components/table-utils/index.js +112 -112
- package/packages/form-table/src/disabledDetail.less +46 -46
- package/packages/grid/index.js +10 -10
- package/packages/grid/src/grid.js +28 -28
- package/packages/icon/index.js +10 -10
- package/packages/icon/src/icon.js +13 -13
- package/packages/index.js +313 -307
- package/packages/input/index.js +30 -30
- package/packages/input/src/Group.jsx +11 -11
- package/packages/input/src/Input.jsx +11 -11
- package/packages/input/src/Password.jsx +11 -11
- package/packages/input/src/Search.jsx +11 -11
- package/packages/input/src/TextArea.jsx +11 -11
- package/packages/input/src/input-quick/components/quick-item.vue +284 -284
- package/packages/input/src/input-quick/components/quick-popover.vue +596 -596
- package/packages/input/src/input-quick/index.vue +137 -137
- package/packages/input-number/index.js +12 -12
- package/packages/input-number/src/InputNumber.jsx +11 -11
- package/packages/keep-cache/KeepCache.js +236 -236
- package/packages/keep-cache/index.css +2 -2
- package/packages/keep-cache/index.js +8 -8
- package/packages/layout/index.js +27 -27
- package/packages/layout/src/Content.jsx +11 -11
- package/packages/layout/src/Footer.jsx +11 -11
- package/packages/layout/src/Header.jsx +11 -11
- package/packages/layout/src/Layout.jsx +11 -11
- package/packages/layout/src/Sider.jsx +11 -11
- package/packages/list/index.js +21 -21
- package/packages/list/src/Item.jsx +11 -11
- package/packages/list/src/ItemMeta.jsx +11 -11
- package/packages/list/src/List.jsx +11 -11
- package/packages/locale-provider/index.js +12 -12
- package/packages/locale-provider/src/LocaleProvider.jsx +11 -11
- package/packages/map/index.js +9 -9
- package/packages/map/src/Map.vue +484 -484
- package/packages/map/src/popup-map.vue +53 -53
- package/packages/mentions/index.js +18 -18
- package/packages/mentions/src/Mentions.jsx +11 -11
- package/packages/mentions/src/Option.jsx +11 -11
- package/packages/menu/index.js +27 -27
- package/packages/menu/src/Divider.jsx +11 -11
- package/packages/menu/src/Item.jsx +11 -11
- package/packages/menu/src/ItemGroup.jsx +11 -11
- package/packages/menu/src/Menu.jsx +11 -11
- package/packages/menu/src/SubMenu.jsx +11 -11
- package/packages/message/index.js +8 -8
- package/packages/modal/index.js +10 -10
- package/packages/modal/src/Modal.js +7 -7
- package/packages/multi-chat/chat/addConference.vue +200 -200
- package/packages/multi-chat/chat/addMembers.vue +411 -411
- package/packages/multi-chat/chat/advancedFilter.vue +372 -372
- package/packages/multi-chat/chat/calling.vue +246 -246
- package/packages/multi-chat/chat/chatFooter.vue +1596 -1596
- package/packages/multi-chat/chat/chatHistory.vue +605 -605
- package/packages/multi-chat/chat/chatMain.vue +1486 -1486
- package/packages/multi-chat/chat/client/index.vue +149 -149
- package/packages/multi-chat/chat/delay.vue +177 -177
- package/packages/multi-chat/chat/evaluate.vue +343 -343
- package/packages/multi-chat/chat/messageRecord.vue +324 -324
- package/packages/multi-chat/chat/mixins/NoData.js +20 -20
- package/packages/multi-chat/chat/mixins/base.js +97 -97
- package/packages/multi-chat/chat/mixins/uniRTCAPI.js +80 -80
- package/packages/multi-chat/chat/mixins/viewerOptions.js +67 -67
- package/packages/multi-chat/chat/quickReply.vue +439 -439
- package/packages/multi-chat/chat/robot/index.vue +312 -312
- package/packages/multi-chat/chat/scrollList.vue +1238 -1238
- package/packages/multi-chat/chat/videoVoiceList.vue +348 -348
- package/packages/multi-chat/chat/voice.vue +431 -431
- package/packages/multi-chat/components/avatar.vue +113 -113
- package/packages/multi-chat/components/chat-tabs-header.vue +251 -251
- package/packages/multi-chat/components/classify-tabs.vue +185 -185
- package/packages/multi-chat/components/empty.vue +24 -24
- package/packages/multi-chat/components/modal-refuse-reason.vue +112 -112
- package/packages/multi-chat/components/modal-sip.vue +160 -160
- package/packages/multi-chat/components/modal-user-transfer.vue +98 -98
- package/packages/multi-chat/components/msg-describe.vue +138 -138
- package/packages/multi-chat/components/msg-picture.vue +68 -68
- package/packages/multi-chat/components/msg-prescription.vue +205 -205
- package/packages/multi-chat/components/read-record.vue +133 -133
- package/packages/multi-chat/components/read-status.vue +34 -34
- package/packages/multi-chat/components/user-status.vue +198 -198
- package/packages/multi-chat/index.js +7 -7
- package/packages/multi-chat/setting/authority/index.vue +156 -156
- package/packages/multi-chat/setting/authority/roleSetting.vue +204 -204
- package/packages/multi-chat/setting/baseInfo/index.vue +1316 -1316
- package/packages/multi-chat/setting/customerService/batchSelect.vue +403 -403
- package/packages/multi-chat/setting/customerService/index.vue +273 -273
- package/packages/multi-chat/setting/event/edit/condition.vue +128 -128
- package/packages/multi-chat/setting/event/edit/index.vue +437 -437
- package/packages/multi-chat/setting/event/edit/notice.vue +129 -129
- package/packages/multi-chat/setting/event/edit/strategy.vue +98 -98
- package/packages/multi-chat/setting/event/index.vue +249 -249
- package/packages/multi-chat/setting/index.vue +269 -269
- package/packages/multi-chat/setting/page.vue +14 -14
- package/packages/multi-chat/setting/sessionList/index.vue +412 -412
- package/packages/multi-chat/setting/sessionList/messageRecord.vue +372 -372
- package/packages/multi-chat/setting/userConfig/index.vue +124 -124
- package/packages/multi-chat/setting/worktime/index.vue +274 -274
- package/packages/multi-chat/store/actions.js +452 -452
- package/packages/multi-chat/store/getters.js +371 -371
- package/packages/multi-chat/store/helper.js +66 -66
- package/packages/multi-chat/store/index.js +50 -50
- package/packages/multi-chat/store/mutation.js +296 -296
- package/packages/multi-chat/store/state.js +117 -117
- package/packages/multi-chat/style/emoji.css +315 -315
- package/packages/multi-chat/style/message.mixin.less +38 -38
- package/packages/multi-chat/utils/chatSock.js +93 -93
- package/packages/multi-chat/utils/compressImage.js +115 -115
- package/packages/multi-chat/utils/emoji.json +68 -68
- package/packages/multi-chat/utils/index.js +259 -259
- package/packages/multi-chat/utils/observer-scroll.js +49 -49
- package/packages/multi-chat/utils/panelsetting.js +48 -48
- package/packages/multi-chat-client/index.js +7 -7
- package/packages/multi-chat-history/index.js +7 -7
- package/packages/multi-chat-record/index.js +7 -7
- package/packages/multi-chat-setting/index.js +7 -7
- package/packages/multi-chat-sip/index.js +6 -6
- package/packages/notification/index.js +8 -8
- package/packages/page-header/index.js +12 -12
- package/packages/page-header/src/PageHeader.jsx +11 -11
- package/packages/pagination/index.js +12 -12
- package/packages/pagination/src/Pagination.jsx +11 -11
- package/packages/popconfirm/index.js +12 -12
- package/packages/popconfirm/src/Popconfirm.jsx +11 -11
- package/packages/popover/index.js +12 -12
- package/packages/popover/src/Popover.jsx +11 -11
- package/packages/progress/index.js +12 -12
- package/packages/progress/src/Progress.jsx +11 -11
- package/packages/radio/index.js +33 -33
- package/packages/radio/src/Group.jsx +11 -11
- package/packages/radio/src/Radio.jsx +11 -11
- package/packages/radio/src/RadioButton.jsx +11 -11
- package/packages/radio/src/RadioImg/index.vue +124 -124
- package/packages/rate/index.js +12 -12
- package/packages/rate/src/Rate.jsx +11 -11
- package/packages/result/index.js +12 -12
- package/packages/result/src/Result.jsx +11 -11
- package/packages/row/index.js +12 -12
- package/packages/row/src/Row.jsx +11 -11
- package/packages/scale-container/index.js +9 -0
- package/packages/scale-container/src/ScaleContainer.vue +197 -0
- package/packages/scale-container/src/scale.png +0 -0
- package/packages/scale-view/NoData.vue +81 -81
- package/packages/scale-view/answerParse.vue +133 -133
- package/packages/scale-view/customList.vue +801 -801
- package/packages/scale-view/data.js +80 -80
- package/packages/scale-view/evaluateCountdown.vue +155 -155
- package/packages/scale-view/evaluatePage.vue +202 -202
- package/packages/scale-view/formitem/data.js +3991 -3991
- package/packages/scale-view/formitem/index.js +6 -6
- package/packages/scale-view/formitem/r-address.vue +238 -238
- package/packages/scale-view/formitem/r-choice.vue +726 -726
- package/packages/scale-view/formitem/r-input.vue +92 -92
- package/packages/scale-view/formitem/r-prompt.vue +52 -52
- package/packages/scale-view/formitem/r-time.vue +285 -285
- package/packages/scale-view/formitem/r-upload-custom-list.vue +242 -242
- package/packages/scale-view/formitem/r-upload.vue +287 -287
- package/packages/scale-view/formitem/text-over-tooltip/TextOverTooltip.vue +98 -98
- package/packages/scale-view/index.js +17 -17
- package/packages/scale-view/mixin/NoData.js +38 -38
- package/packages/scale-view/mixin/evaluate.js +146 -146
- package/packages/scale-view/mixin/index.js +337 -337
- package/packages/scale-view/mixin/judgeTypes.js +267 -267
- package/packages/scale-view/scaleView.vue +2010 -2010
- package/packages/select/index.js +27 -27
- package/packages/select/src/CustomSelect/index.vue +130 -130
- package/packages/select/src/OptGroup.jsx +11 -11
- package/packages/select/src/Option.jsx +11 -11
- package/packages/select/src/Select/Select.vue +231 -231
- package/packages/select/src/Select/index.js +12 -12
- package/packages/select/src/TableSelect/index.vue +514 -514
- package/packages/select-label/index.js +14 -14
- package/packages/select-label/label-classify.vue +129 -129
- package/packages/select-label/labelFormContent.vue +787 -787
- package/packages/select-label/select-label.vue +581 -581
- package/packages/select-person/index.js +10 -10
- package/packages/select-person/search-tree.vue +373 -373
- package/packages/select-person/select-person.vue +1696 -1696
- package/packages/shortcut-setter/index.js +12 -12
- package/packages/shortcut-setter/src/ShortcutSetter.vue +55 -55
- package/packages/shortcut-setter/src/ShortcutSetterItem.vue +84 -84
- package/packages/shortcut-setter/src/utils/index.js +63 -63
- package/packages/skeleton/index.js +12 -12
- package/packages/skeleton/src/Skeleton.jsx +11 -11
- package/packages/slider/index.js +12 -12
- package/packages/slider/src/Slider.jsx +11 -11
- package/packages/space/index.js +12 -12
- package/packages/space/src/Space.jsx +11 -11
- package/packages/spin/index.js +12 -12
- package/packages/spin/src/Spin.jsx +11 -11
- package/packages/statistic/index.js +18 -18
- package/packages/statistic/src/Countdown.jsx +11 -11
- package/packages/statistic/src/Statistic.jsx +11 -11
- package/packages/steps/index.js +18 -18
- package/packages/steps/src/Step.jsx +11 -11
- package/packages/steps/src/Steps.jsx +11 -11
- package/packages/switch/index.js +12 -12
- package/packages/switch/src/Switch.jsx +11 -11
- package/packages/table-filter/index.js +27 -27
- package/packages/table-filter/src/base-search-com/BaseSearch.vue +2572 -2572
- package/packages/table-filter/src/classification/Classification-com.vue +1756 -1756
- package/packages/table-filter/src/classification/search-class-name.vue +266 -266
- package/packages/table-filter/src/classification/search-professional-model.vue +680 -680
- package/packages/table-filter/src/components/TextOverTooltip.vue +107 -107
- package/packages/table-filter/src/components/age-com/index.vue +205 -205
- package/packages/table-filter/src/components/button-group/ButtonGroup.vue +162 -162
- package/packages/table-filter/src/components/button-icon/button-icon.js +33 -33
- package/packages/table-filter/src/components/button-icon/getBtnIcon.js +34 -34
- package/packages/table-filter/src/components/c-tree-select/tree-select.vue +336 -336
- package/packages/table-filter/src/components/drop-button/drop-button.vue +224 -224
- package/packages/table-filter/src/components/drop-button/head-btn-icon.js +33 -33
- package/packages/table-filter/src/components/drop-view/drop-view.vue +89 -89
- package/packages/table-filter/src/components/multi-select/multi-select.vue +227 -227
- package/packages/table-filter/src/components/out-quick-search/out-quick-search.vue +340 -340
- package/packages/table-filter/src/components/range-age/index.vue +172 -172
- package/packages/table-filter/src/components/search-condition/SearchCondition.vue +1897 -1897
- package/packages/table-filter/src/components/search-condition/fieldTypeList.js +169 -169
- package/packages/table-filter/src/components/search-filter/SearchFilter.vue +278 -278
- package/packages/table-filter/src/components/search-modal/set-classification.vue +310 -310
- package/packages/table-filter/src/components/table-modal/TableModal.vue +463 -463
- package/packages/table-filter/src/const/dataOptions.js +43 -43
- package/packages/table-filter/src/const/index.js +1 -1
- package/packages/table-filter/src/index.vue +584 -584
- package/packages/table-filter/src/mixins/mixins.js +694 -694
- package/packages/table-filter/src/mixins/tableSearchCon.js +128 -128
- package/packages/table-filter/src/mixins/wordBookutils.js +102 -102
- package/packages/table-filter/src/quick-search/QuickSearch.vue +2125 -2125
- package/packages/tabs/index.js +18 -18
- package/packages/tabs/src/TabPane.jsx +11 -11
- package/packages/tabs/src/Tabs.jsx +11 -11
- package/packages/tag/index.js +21 -21
- package/packages/tag/src/CheckableTag.jsx +11 -11
- package/packages/tag/src/Tag.jsx +11 -11
- package/packages/tag/src/TagGroup.vue +621 -621
- package/packages/time-picker/index.js +12 -12
- package/packages/time-picker/src/TimePicker.jsx +11 -11
- package/packages/timeline/index.js +14 -14
- package/packages/timeline/src/Item.jsx +11 -11
- package/packages/timeline/src/Timeline.jsx +11 -11
- package/packages/tooltip/index.js +12 -12
- package/packages/tooltip/src/Tooltip.jsx +11 -11
- package/packages/transfer/index.js +12 -12
- package/packages/transfer/src/Transfer.jsx +11 -11
- package/packages/tree/index.js +18 -18
- package/packages/tree/src/Tree.jsx +11 -11
- package/packages/tree/src/TreeNode.jsx +11 -11
- package/packages/tree-select/index.js +18 -18
- package/packages/tree-select/src/TreeNode.jsx +11 -11
- package/packages/tree-select/src/TreeSelect.jsx +11 -11
- package/packages/upload/chunk-upload/chunk-upload-new.vue +1001 -1001
- package/packages/upload/chunk-upload/vod-chunk-upload.vue +749 -749
- package/packages/upload/chunk-upload/vod-upload-modal.vue +100 -100
- package/packages/upload/index.js +12 -12
- package/packages/upload/src/Upload.jsx +11 -11
- package/packages/verification-code/SlideVerify.vue +306 -306
- package/packages/verification-code/index.js +17 -17
- package/packages/verification-code/verification-code.vue +147 -147
- package/src/assets/img/nodata.png +0 -0
- package/src/component/player-vod/index.vue +57 -57
- package/src/component/player-vod/player.vue +188 -188
- package/src/component/player-vod/video-list.vue +262 -262
- package/src/component/player-vod/video-modal.vue +128 -128
- package/src/component/select-options/index.vue +430 -0
- package/src/component/select-pages/index.vue +95 -74
- package/src/component/svg/index.vue +59 -59
- package/src/core/create.js +6 -6
- package/src/core/event.js +23 -23
- package/src/core/table-methods.js +444 -444
- package/src/directive/flexibleResize.js +151 -151
- package/src/directive/preventReClick.js +12 -12
- package/src/directive/scroll.js +230 -230
- package/src/global/variable.js +2 -2
- package/src/style/normalize.css +424 -424
- package/src/style/style.less +49 -49
- package/src/utils/UniRTCv2.js +626 -626
- package/src/utils/chatFetch.js +61 -61
- package/src/utils/clickoutside.js +75 -75
- package/src/utils/crypto.js +25 -25
- package/src/utils/index.js +81 -81
- package/src/utils/kty-sdk.js +582 -582
- package/src/utils/kty.min-1.0.0.js +14378 -14378
- package/src/utils/sip-device.js +79 -79
- package/src/utils/time-domain.js +193 -193
- package/src/utils/trtc.js +1 -1
- package/src/utils/utils-map.js +484 -484
- 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>
|