inl-ui 0.0.37 → 0.0.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (852) hide show
  1. package/.babelrc +3 -3
  2. package/README.md +27 -27
  3. package/conf/cp1.js +85 -85
  4. package/conf/rollup.config.ts +37 -37
  5. package/dist/index.js +1803 -2849
  6. package/dist/index.js.map +1 -1
  7. package/dist/src/api/alarm/alarmRecord.d.ts +95 -95
  8. package/dist/src/api/alarm/warningConfigure.d.ts +61 -61
  9. package/dist/src/api/auth/menuManager.d.ts +36 -36
  10. package/dist/src/api/auth/roleManager.d.ts +31 -31
  11. package/dist/src/api/auth/userManager.d.ts +48 -48
  12. package/dist/src/api/axios.d.ts +10 -10
  13. package/dist/src/api/boardScreen/powersupply.d.ts +8 -8
  14. package/dist/src/api/cardCenter.d.ts +43 -43
  15. package/dist/src/api/dataAnalysis.d.ts +4 -4
  16. package/dist/src/api/dataCenter.d.ts +32 -32
  17. package/dist/src/api/enumList.d.ts +7 -7
  18. package/dist/src/api/event.d.ts +4 -4
  19. package/dist/src/api/faceName.d.ts +7 -7
  20. package/dist/src/api/factory.d.ts +36 -36
  21. package/dist/src/api/fileManager.d.ts +4 -4
  22. package/dist/src/api/index.d.ts +2 -2
  23. package/dist/src/api/linkage.d.ts +30 -30
  24. package/dist/src/api/logManager.d.ts +15 -15
  25. package/dist/src/api/noticeCenter.d.ts +27 -27
  26. package/dist/src/api/noticeManager.d.ts +39 -39
  27. package/dist/src/api/org/depManager.d.ts +93 -93
  28. package/dist/src/api/org/postManager.d.ts +43 -43
  29. package/dist/src/api/org/teamManager.d.ts +51 -51
  30. package/dist/src/api/param.d.ts +36 -36
  31. package/dist/src/api/personalSetting.d.ts +20 -20
  32. package/dist/src/api/pressureFiltration/filterPressConfiguration.d.ts +23 -23
  33. package/dist/src/api/pressureFiltration/flowChart.d.ts +11 -11
  34. package/dist/src/api/pressureFiltration/pressureFiltrationHome.d.ts +31 -31
  35. package/dist/src/api/pressureFiltration/pressureFiltrationRecord.d.ts +23 -23
  36. package/dist/src/api/processDrawing.d.ts +35 -35
  37. package/dist/src/api/product.d.ts +29 -29
  38. package/dist/src/api/productionPlan.d.ts +4 -4
  39. package/dist/src/api/productionPlan_old.d.ts +4 -4
  40. package/dist/src/api/project.d.ts +21 -21
  41. package/dist/src/api/pss.d.ts +4 -4
  42. package/dist/src/api/rotation.d.ts +4 -4
  43. package/dist/src/api/setting.d.ts +4 -4
  44. package/dist/src/api/systemSetting.d.ts +24 -24
  45. package/dist/src/api/thingInstance.d.ts +42 -42
  46. package/dist/src/api/thingModel.d.ts +38 -38
  47. package/dist/src/api/tupu.d.ts +6 -6
  48. package/dist/src/api/video.d.ts +4 -4
  49. package/dist/src/api/workforceManager.d.ts +4 -4
  50. package/dist/src/components/changeTheme/index.d.ts +4 -4
  51. package/dist/src/components/headerMenu/index.d.ts +2 -2
  52. package/dist/src/components/headerMenuItem/index.d.ts +2 -2
  53. package/dist/src/components/headerMenuTitle/index.d.ts +2 -2
  54. package/dist/src/components/index.d.ts +2 -2
  55. package/dist/src/components/inputText.d.ts +22 -22
  56. package/dist/src/components/layoutContent/index.d.ts +10 -10
  57. package/dist/src/components/layoutNav/index.d.ts +2 -2
  58. package/dist/src/components/layoutSidebar/index.d.ts +2 -2
  59. package/dist/src/components/videoPlayer/index.d.ts +2 -2
  60. package/dist/src/components/videoPlayer/util/interface.d.ts +3 -3
  61. package/dist/src/components/videoPlayer/util/video.d.ts +64 -64
  62. package/dist/src/directives/focus.d.ts +6 -6
  63. package/dist/src/hooks/global.d.ts +5 -5
  64. package/dist/src/hooks/useMenuCode.d.ts +4 -4
  65. package/dist/src/hooks/userVModel.d.ts +1 -1
  66. package/dist/src/index.d.ts +27 -27
  67. package/dist/src/pageComponent/components/CommonTree.d.ts +73 -73
  68. package/dist/src/pageComponent/components/DynamicIcon.d.ts +14 -14
  69. package/dist/src/pageComponent/components/EditPasswordForm.d.ts +20 -20
  70. package/dist/src/pageComponent/components/IconSelect.d.ts +12 -12
  71. package/dist/src/pageComponent/components/Navbar.d.ts +14 -14
  72. package/dist/src/pageComponent/components/ProFormItem.d.ts +21 -21
  73. package/dist/src/pageComponent/components/SearchSelect.d.ts +62 -62
  74. package/dist/src/pageComponent/components/Sidebar.d.ts +23 -23
  75. package/dist/src/pageComponent/components/boardScreen/Card1Outer.d.ts +8 -8
  76. package/dist/src/pageComponent/components/boardScreen/Card2Outer.d.ts +8 -8
  77. package/dist/src/pageComponent/components/boardScreen/PopBox.d.ts +33 -33
  78. package/dist/src/pageComponent/components/boardScreen/PowerCut.d.ts +15 -15
  79. package/dist/src/pageComponent/components/boardScreen/PowerSupply.d.ts +15 -15
  80. package/dist/src/pageComponent/components/boardScreen/card2OuterTable.d.ts +6 -6
  81. package/dist/src/pageComponent/components/check-people.d.ts +31 -31
  82. package/dist/src/pageComponent/components/elcRoomHt/index.d.ts +8 -8
  83. package/dist/src/pageComponent/components/htModal/control.d.ts +8 -8
  84. package/dist/src/pageComponent/components/htModal/index.d.ts +14 -14
  85. package/dist/src/pageComponent/components/htModal/task.d.ts +2 -2
  86. package/dist/src/pageComponent/components/loginBox/index.d.ts +45 -45
  87. package/dist/src/pageComponent/components/noticeManager/addChannel.d.ts +8 -8
  88. package/dist/src/pageComponent/components/noticeManager/addNotice.d.ts +8 -8
  89. package/dist/src/pageComponent/components/noticeManager/addTemplate.d.ts +19 -19
  90. package/dist/src/pageComponent/components/noticeManager/noticeGrade.d.ts +6 -6
  91. package/dist/src/pageComponent/components/noticeManager/noticeMaintain.d.ts +6 -6
  92. package/dist/src/pageComponent/components/noticeManager/noticeTemplate.d.ts +6 -6
  93. package/dist/src/pageComponent/components/noticeManager/notificationDetails.d.ts +6 -6
  94. package/dist/src/pageComponent/components/noticeManager/sendDetails.d.ts +23 -23
  95. package/dist/src/pageComponent/components/pressureFiltration/alarmList.d.ts +21 -21
  96. package/dist/src/pageComponent/components/pressureFiltration/configuration.d.ts +31 -31
  97. package/dist/src/pageComponent/components/pressureFiltration/numberOfPlates.d.ts +21 -21
  98. package/dist/src/pageComponent/components/pressureFiltration/shiftChange.d.ts +23 -23
  99. package/dist/src/pageComponent/components/pss-cabinet/cabinetRender.d.ts +61 -61
  100. package/dist/src/pageComponent/components/user/userTable.d.ts +13 -13
  101. package/dist/src/pageComponent/components/user/userTree.d.ts +21 -21
  102. package/dist/src/pageComponent/components/video-play.d.ts +34 -34
  103. package/dist/src/pageComponent/config/systemConfig.d.ts +32 -32
  104. package/dist/src/pageComponent/hooks/cardTable.d.ts +26 -26
  105. package/dist/src/pageComponent/hooks/filters.d.ts +18 -18
  106. package/dist/src/pageComponent/hooks/global.d.ts +5 -5
  107. package/dist/src/pageComponent/hooks/manage-module/useModalForm.d.ts +5 -5
  108. package/dist/src/pageComponent/hooks/manage-module/useModalTitle.d.ts +6 -6
  109. package/dist/src/pageComponent/hooks/manage-module/useModalVisibleControl.d.ts +5 -5
  110. package/dist/src/pageComponent/hooks/screen.d.ts +5 -5
  111. package/dist/src/pageComponent/hooks/tabListConfig.d.ts +2 -2
  112. package/dist/src/pageComponent/hooks/toPreviewData.d.ts +4 -4
  113. package/dist/src/pageComponent/hooks/treeSearch.d.ts +2 -2
  114. package/dist/src/pageComponent/hooks/useBus.d.ts +6 -6
  115. package/dist/src/pageComponent/hooks/useMouse.d.ts +7 -7
  116. package/dist/src/pageComponent/hooks/useProxy.d.ts +4 -4
  117. package/dist/src/pageComponent/hooks/useTableList.d.ts +26 -26
  118. package/dist/src/pageComponent/hooks/useVModel.d.ts +1 -1
  119. package/dist/src/pageComponent/hooks/useWatchOnce.d.ts +2 -2
  120. package/dist/src/pageComponent/index.d.ts +2 -2
  121. package/dist/src/pageComponent/store/index.d.ts +32 -32
  122. package/dist/src/pageComponent/utils/base64.d.ts +14 -14
  123. package/dist/src/pageComponent/utils/filter.d.ts +18 -18
  124. package/dist/src/pageComponent/utils/format.d.ts +21 -21
  125. package/dist/src/pageComponent/utils/index.d.ts +5 -5
  126. package/dist/src/pageComponent/utils/is.d.ts +10 -10
  127. package/dist/src/pageComponent/utils/transform.d.ts +10 -10
  128. package/dist/src/pageComponent/utils/tree.d.ts +17 -17
  129. package/dist/src/pageComponent/utils/upload.d.ts +1 -1
  130. package/dist/src/pageComponent/utils/validation.d.ts +20 -20
  131. package/dist/src/pageComponent/views/alarms/add-warning-configure/form/basic-form.d.ts +18 -18
  132. package/dist/src/pageComponent/views/alarms/add-warning-configure/form/linkage-form.d.ts +18 -18
  133. package/dist/src/pageComponent/views/alarms/add-warning-configure/form/rule-form.d.ts +28 -28
  134. package/dist/src/pageComponent/views/alarms/add-warning-configure/index.d.ts +16 -16
  135. package/dist/src/pageComponent/views/alarms/alarmDetail/index.d.ts +2 -2
  136. package/dist/src/pageComponent/views/alarms/index.d.ts +2 -2
  137. package/dist/src/pageComponent/views/alarms/warning-configure/batch-import-dialog.d.ts +22 -22
  138. package/dist/src/pageComponent/views/alarms/warning-configure/configure-table.d.ts +12 -12
  139. package/dist/src/pageComponent/views/alarms/warning-configure/index.d.ts +15 -15
  140. package/dist/src/pageComponent/views/alarms/warning-configure/table-tool.d.ts +26 -26
  141. package/dist/src/pageComponent/views/alarms/warning-record/index.d.ts +15 -15
  142. package/dist/src/pageComponent/views/alarms/warning-record/query-filter.d.ts +24 -24
  143. package/dist/src/pageComponent/views/alarms/warning-record/record-table.d.ts +13 -13
  144. package/dist/src/pageComponent/views/boardScreen/index.d.ts +2 -2
  145. package/dist/src/pageComponent/views/boardScreen/room.d.ts +21 -21
  146. package/dist/src/pageComponent/views/boardScreen/tupu.d.ts +17 -17
  147. package/dist/src/pageComponent/views/card-center/cardWarehouse.d.ts +23 -23
  148. package/dist/src/pageComponent/views/card-center/components/cardDetail.d.ts +49 -49
  149. package/dist/src/pageComponent/views/card-center/components/editPage.d.ts +20 -20
  150. package/dist/src/pageComponent/views/card-center/components/pageDetail.d.ts +49 -49
  151. package/dist/src/pageComponent/views/card-center/components/selectCard.d.ts +3 -3
  152. package/dist/src/pageComponent/views/card-center/pageConfiguration.d.ts +25 -25
  153. package/dist/src/pageComponent/views/data-center/cardModal.d.ts +22 -22
  154. package/dist/src/pageComponent/views/data-center/cardSubscription.d.ts +14 -14
  155. package/dist/src/pageComponent/views/data-center/components/chart.d.ts +4 -4
  156. package/dist/src/pageComponent/views/data-center/components/groupModal.d.ts +53 -53
  157. package/dist/src/pageComponent/views/data-center/components/leftTree.d.ts +27 -27
  158. package/dist/src/pageComponent/views/data-center/components/searchHeader.d.ts +11 -11
  159. package/dist/src/pageComponent/views/data-center/components/table.d.ts +31 -31
  160. package/dist/src/pageComponent/views/data-center/dataAnalysis.d.ts +6 -6
  161. package/dist/src/pageComponent/views/data-center/userModal.d.ts +28 -28
  162. package/dist/src/pageComponent/views/elcRoom/index.d.ts +2 -2
  163. package/dist/src/pageComponent/views/factoryManage/index.d.ts +20 -20
  164. package/dist/src/pageComponent/views/fileManager/components/CreateFolder.d.ts +26 -26
  165. package/dist/src/pageComponent/views/fileManager/components/MoveToFolder.d.ts +37 -37
  166. package/dist/src/pageComponent/views/fileManager/components/Rename.d.ts +26 -26
  167. package/dist/src/pageComponent/views/fileManager/components/UploadFiles.d.ts +35 -35
  168. package/dist/src/pageComponent/views/fileManager/fileManager.d.ts +2 -2
  169. package/dist/src/pageComponent/views/fileManager/index.d.ts +3 -3
  170. package/dist/src/pageComponent/views/index.d.ts +2 -2
  171. package/dist/src/pageComponent/views/login/box.d.ts +72 -72
  172. package/dist/src/pageComponent/views/login/index.d.ts +2 -2
  173. package/dist/src/pageComponent/views/login/leftImg.d.ts +10 -10
  174. package/dist/src/pageComponent/views/login/top-title.d.ts +2 -2
  175. package/dist/src/pageComponent/views/pressureFiltration/feeding.d.ts +2 -2
  176. package/dist/src/pageComponent/views/pressureFiltration/pressureFiltrationHome.d.ts +2 -2
  177. package/dist/src/pageComponent/views/pressureFiltration/productionShiftReport.d.ts +2 -2
  178. package/dist/src/pageComponent/views/pressureFiltration/record.d.ts +2 -2
  179. package/dist/src/pageComponent/views/pressureFiltration/unloading.d.ts +2 -2
  180. package/dist/src/pageComponent/views/processDrawingConfiguration/components/EventForm.d.ts +20 -20
  181. package/dist/src/pageComponent/views/processDrawingConfiguration/components/addonAfter.d.ts +18 -18
  182. package/dist/src/pageComponent/views/processDrawingConfiguration/components/cardItem.d.ts +29 -29
  183. package/dist/src/pageComponent/views/processDrawingConfiguration/components/colorPicker.d.ts +16 -16
  184. package/dist/src/pageComponent/views/processDrawingConfiguration/components/flowList.d.ts +32 -32
  185. package/dist/src/pageComponent/views/processDrawingConfiguration/components/propertyForm.d.ts +30 -30
  186. package/dist/src/pageComponent/views/processDrawingConfiguration/components/propertyModal.d.ts +60 -60
  187. package/dist/src/pageComponent/views/processDrawingConfiguration/components/state.d.ts +50 -50
  188. package/dist/src/pageComponent/views/processDrawingConfiguration/components/styleForm.d.ts +26 -26
  189. package/dist/src/pageComponent/views/processDrawingConfiguration/editor/components/data.d.ts +15 -15
  190. package/dist/src/pageComponent/views/processDrawingConfiguration/editor/components/textarea.d.ts +10 -10
  191. package/dist/src/pageComponent/views/processDrawingConfiguration/editor/config.d.ts +38 -38
  192. package/dist/src/pageComponent/views/processDrawingConfiguration/editor/index.d.ts +27 -27
  193. package/dist/src/pageComponent/views/processDrawingConfiguration/editor/instanceSelector.d.ts +27 -27
  194. package/dist/src/pageComponent/views/processDrawingConfiguration/editor/mainContent.d.ts +25 -25
  195. package/dist/src/pageComponent/views/processDrawingConfiguration/editor/operationArea.d.ts +7 -7
  196. package/dist/src/pageComponent/views/processDrawingConfiguration/editor/previewModal.d.ts +25 -25
  197. package/dist/src/pageComponent/views/processDrawingConfiguration/editor/utils.d.ts +11 -11
  198. package/dist/src/pageComponent/views/processDrawingConfiguration/hooks/index.d.ts +3 -3
  199. package/dist/src/pageComponent/views/processDrawingConfiguration/hooks/useActiveWidget.d.ts +5367 -5367
  200. package/dist/src/pageComponent/views/processDrawingConfiguration/index.d.ts +14 -14
  201. package/dist/src/pageComponent/views/processDrawingConfiguration/previewModal.d.ts +2 -2
  202. package/dist/src/pageComponent/views/productManager/index.d.ts +18 -18
  203. package/dist/src/pageComponent/views/productManager/update.d.ts +20 -20
  204. package/dist/src/pageComponent/views/productManager/utils/emuns.d.ts +31 -31
  205. package/dist/src/pageComponent/views/productManager/utils/formRules.d.ts +5 -5
  206. package/dist/src/pageComponent/views/productManager/versionEdit/index.d.ts +12 -12
  207. package/dist/src/pageComponent/views/productManager/versionEdit/param.d.ts +10 -10
  208. package/dist/src/pageComponent/views/productionPlanManager/components/Plan.d.ts +46 -46
  209. package/dist/src/pageComponent/views/productionPlanManager/components/Plan_back.d.ts +27 -27
  210. package/dist/src/pageComponent/views/productionPlanManager/dayPCPlan.d.ts +3 -3
  211. package/dist/src/pageComponent/views/productionPlanManager/daySCPlan.d.ts +3 -3
  212. package/dist/src/pageComponent/views/productionPlanManager/dayWYPlan.d.ts +2 -2
  213. package/dist/src/pageComponent/views/productionPlanManager/monthPCPlan.d.ts +3 -3
  214. package/dist/src/pageComponent/views/productionPlanManager/productionPlanConfig.d.ts +3 -3
  215. package/dist/src/pageComponent/views/productionPlanManager/productionPlan_old.d.ts +3 -3
  216. package/dist/src/pageComponent/views/productionPlanManager/yearPCPlan.d.ts +3 -3
  217. package/dist/src/pageComponent/views/projectManager/components/commonForm.d.ts +99 -99
  218. package/dist/src/pageComponent/views/projectManager/detail.d.ts +16 -16
  219. package/dist/src/pageComponent/views/projectManager/hooks/useTable.d.ts +27 -27
  220. package/dist/src/pageComponent/views/projectManager/index.d.ts +28 -28
  221. package/dist/src/pageComponent/views/projectManager/utils/emuns.d.ts +31 -31
  222. package/dist/src/pageComponent/views/projectManager/utils/formRules.d.ts +20 -20
  223. package/dist/src/pageComponent/views/projectManager/utils/index.d.ts +11 -11
  224. package/dist/src/pageComponent/views/pss/components/ApproveOpinion.d.ts +57 -57
  225. package/dist/src/pageComponent/views/pss/components/Info.d.ts +52 -52
  226. package/dist/src/pageComponent/views/pss/components/NewOrder.d.ts +17 -17
  227. package/dist/src/pageComponent/views/pss/components/PerformOperation.d.ts +27 -27
  228. package/dist/src/pageComponent/views/pss/components/table.d.ts +14 -14
  229. package/dist/src/pageComponent/views/pss/index.d.ts +3 -3
  230. package/dist/src/pageComponent/views/pss/list.d.ts +3 -3
  231. package/dist/src/pageComponent/views/pss/utils/index.d.ts +4 -4
  232. package/dist/src/pageComponent/views/pssRecord/components/Info.d.ts +25 -25
  233. package/dist/src/pageComponent/views/pssRecord/index.d.ts +3 -3
  234. package/dist/src/pageComponent/views/systemManager/about/index.d.ts +6 -6
  235. package/dist/src/pageComponent/views/systemManager/aboutNew/index.d.ts +2 -2
  236. package/dist/src/pageComponent/views/systemManager/authManager/RoleManager/index.d.ts +10 -10
  237. package/dist/src/pageComponent/views/systemManager/authManager/RoleManager/updateRoleDialog.d.ts +38 -38
  238. package/dist/src/pageComponent/views/systemManager/authManager/menuManager/index.d.ts +14 -14
  239. package/dist/src/pageComponent/views/systemManager/authManager/menuManager/menuDetail.d.ts +10 -10
  240. package/dist/src/pageComponent/views/systemManager/authManager/menuManager/menuForm.d.ts +19 -19
  241. package/dist/src/pageComponent/views/systemManager/authManager/menuManager/menuSelectTree.d.ts +19 -19
  242. package/dist/src/pageComponent/views/systemManager/authManager/menuManager/updateMenuDialog.d.ts +30 -30
  243. package/dist/src/pageComponent/views/systemManager/authManager/menuManager/uploadJSONDialog.d.ts +27 -27
  244. package/dist/src/pageComponent/views/systemManager/authManager/userManager/index.d.ts +13 -13
  245. package/dist/src/pageComponent/views/systemManager/authManager/userManager/updateUserDialog.d.ts +41 -41
  246. package/dist/src/pageComponent/views/systemManager/authManager/userManager/userProfileDialog.d.ts +24 -24
  247. package/dist/src/pageComponent/views/systemManager/logManager/index.d.ts +6 -6
  248. package/dist/src/pageComponent/views/systemManager/noticeManager/noticeCenter.d.ts +3 -3
  249. package/dist/src/pageComponent/views/systemManager/noticeManager/noticeManager.d.ts +2 -2
  250. package/dist/src/pageComponent/views/systemManager/orgManager/depManager/batchImportModal.d.ts +20 -20
  251. package/dist/src/pageComponent/views/systemManager/orgManager/depManager/depTree.d.ts +10 -10
  252. package/dist/src/pageComponent/views/systemManager/orgManager/depManager/employeeTable.d.ts +20 -20
  253. package/dist/src/pageComponent/views/systemManager/orgManager/depManager/index.d.ts +18 -18
  254. package/dist/src/pageComponent/views/systemManager/orgManager/depManager/updateDepDialog.d.ts +49 -49
  255. package/dist/src/pageComponent/views/systemManager/orgManager/depManager/updateEmployeeDialog.d.ts +46 -46
  256. package/dist/src/pageComponent/views/systemManager/orgManager/depManagerCorp/depTree.d.ts +10 -10
  257. package/dist/src/pageComponent/views/systemManager/orgManager/depManagerCorp/employeeTable.d.ts +20 -20
  258. package/dist/src/pageComponent/views/systemManager/orgManager/depManagerCorp/index.d.ts +18 -18
  259. package/dist/src/pageComponent/views/systemManager/orgManager/depManagerCorp/updateDepDialog.d.ts +49 -49
  260. package/dist/src/pageComponent/views/systemManager/orgManager/depManagerCorp/updateEmployeeDialog.d.ts +46 -46
  261. package/dist/src/pageComponent/views/systemManager/orgManager/empManager.d.ts +2 -2
  262. package/dist/src/pageComponent/views/systemManager/orgManager/postManager/index.d.ts +10 -10
  263. package/dist/src/pageComponent/views/systemManager/orgManager/postManager/updatePostDialog.d.ts +49 -49
  264. package/dist/src/pageComponent/views/systemManager/orgManager/teamManager/index.d.ts +11 -11
  265. package/dist/src/pageComponent/views/systemManager/orgManager/teamManager/updateTeamDialog.d.ts +49 -49
  266. package/dist/src/pageComponent/views/systemManager/paramManager/collapseContainer.d.ts +23 -23
  267. package/dist/src/pageComponent/views/systemManager/paramManager/dynamicForm.d.ts +20 -20
  268. package/dist/src/pageComponent/views/systemManager/paramManager/index.d.ts +7 -7
  269. package/dist/src/pageComponent/views/systemManager/paramManager/tabItem.d.ts +20 -20
  270. package/dist/src/pageComponent/views/systemManager/personalSetting/index.d.ts +7 -7
  271. package/dist/src/pageComponent/views/systemManager/systemSetting/data.d.ts +87 -87
  272. package/dist/src/pageComponent/views/systemManager/systemSetting/index.d.ts +2 -2
  273. package/dist/src/pageComponent/views/thingInstance/component/addThing.d.ts +24 -24
  274. package/dist/src/pageComponent/views/thingInstance/component/baseItem.d.ts +2 -2
  275. package/dist/src/pageComponent/views/thingInstance/component/dynamicForm.d.ts +36 -36
  276. package/dist/src/pageComponent/views/thingInstance/component/editRelation.d.ts +6 -6
  277. package/dist/src/pageComponent/views/thingInstance/component/editThing.d.ts +33 -24
  278. package/dist/src/pageComponent/views/thingInstance/component/logicForm.d.ts +54 -54
  279. package/dist/src/pageComponent/views/thingInstance/component/thingDetail.d.ts +37 -28
  280. package/dist/src/pageComponent/views/thingInstance/data.d.ts +7 -7
  281. package/dist/src/pageComponent/views/thingInstance/hooks/filters.d.ts +17 -17
  282. package/dist/src/pageComponent/views/thingInstance/hooks/useTableList.d.ts +27 -27
  283. package/dist/src/pageComponent/views/thingInstance/hooks/useTreeSearch.d.ts +20 -20
  284. package/dist/src/pageComponent/views/thingInstance/index.d.ts +3 -3
  285. package/dist/src/pageComponent/views/thingInstance/modal.d.ts +2 -2
  286. package/dist/src/pageComponent/views/thingModel/component/detail.d.ts +15 -15
  287. package/dist/src/pageComponent/views/thingModel/component/tabAttr/index.d.ts +12 -12
  288. package/dist/src/pageComponent/views/thingModel/component/tabAttr/update.d.ts +3 -3
  289. package/dist/src/pageComponent/views/thingModel/component/tabRelation/index.d.ts +12 -12
  290. package/dist/src/pageComponent/views/thingModel/component/tabRelation/update.d.ts +22 -22
  291. package/dist/src/pageComponent/views/thingModel/component/update.d.ts +6 -6
  292. package/dist/src/pageComponent/views/thingModel/config.d.ts +104 -104
  293. package/dist/src/pageComponent/views/thingModel/hooks/useTableList.d.ts +27 -27
  294. package/dist/src/pageComponent/views/thingModel/hooks/useTreeSearch.d.ts +20 -20
  295. package/dist/src/pageComponent/views/thingModel/index.d.ts +3 -3
  296. package/dist/src/pageComponent/views/video/components/checkCamera.d.ts +40 -40
  297. package/dist/src/pageComponent/views/video/components/transfer.d.ts +22 -22
  298. package/dist/src/pageComponent/views/video/components/videoPlayer/index.d.ts +14 -14
  299. package/dist/src/pageComponent/views/video/components/videoPlayer/util/axios.d.ts +4 -4
  300. package/dist/src/pageComponent/views/video/components/videoPlayer/util/byUuid.d.ts +66 -66
  301. package/dist/src/pageComponent/views/video/components/videoPlayer/util/video.d.ts +64 -64
  302. package/dist/src/pageComponent/views/video/event/algorithmType.d.ts +3 -3
  303. package/dist/src/pageComponent/views/video/event/eventConfig.d.ts +3 -3
  304. package/dist/src/pageComponent/views/video/event/eventType.d.ts +3 -3
  305. package/dist/src/pageComponent/views/video/event/events.d.ts +3 -3
  306. package/dist/src/pageComponent/views/video/linkage/linkage.d.ts +3 -3
  307. package/dist/src/pageComponent/views/video/linkage/updateMode.d.ts +43 -43
  308. package/dist/src/pageComponent/views/video/play.d.ts +3 -3
  309. package/dist/src/pageComponent/views/video/preview/components/alarmLinkageModal.d.ts +26 -26
  310. package/dist/src/pageComponent/views/video/preview/components/followItem.d.ts +17 -17
  311. package/dist/src/pageComponent/views/video/preview/components/fullScreen.d.ts +4 -4
  312. package/dist/src/pageComponent/views/video/preview/components/treeItem.d.ts +20 -20
  313. package/dist/src/pageComponent/views/video/preview/preview.d.ts +3 -3
  314. package/dist/src/pageComponent/views/video/rotation/PlayVideos.d.ts +12 -12
  315. package/dist/src/pageComponent/views/video/rotation/rotation.d.ts +3 -3
  316. package/dist/src/pageComponent/views/video/sbgl/components/CheckDialog.d.ts +3 -3
  317. package/dist/src/pageComponent/views/video/sbgl/components/addGrouping.d.ts +17 -17
  318. package/dist/src/pageComponent/views/video/sbgl/group.d.ts +3 -3
  319. package/dist/src/pageComponent/views/video/sbgl/index.d.ts +2 -2
  320. package/dist/src/pageComponent/views/video/sbgl/nvr.d.ts +3 -3
  321. package/dist/src/pageComponent/views/video/sbgl/photo.d.ts +3 -3
  322. package/dist/src/pageComponent/views/video/setting/cameraPermission.d.ts +2 -2
  323. package/dist/src/pageComponent/views/video/setting/index.d.ts +2 -2
  324. package/dist/src/pageComponent/views/video/setting/system.d.ts +3 -3
  325. package/dist/src/pageComponent/views/video/utils/index.d.ts +3 -3
  326. package/dist/src/pageComponent/views/video/utils/validation.d.ts +3 -3
  327. package/dist/src/pageComponent/views/video/utils/video.d.ts +64 -64
  328. package/dist/src/pageComponent/views/video/utils/webSocket.d.ts +5 -5
  329. package/dist/src/pageComponent/views/workforceManager/workforcePlan/dayContent.d.ts +24 -24
  330. package/dist/src/pageComponent/views/workforceManager/workforcePlan/index.d.ts +3 -3
  331. package/dist/src/pageComponent/views/workforceManager/workforcePlan/mainTable.d.ts +38 -38
  332. package/dist/src/pageComponent/views/workforceManager/workforceRule/components/classManager.d.ts +3 -3
  333. package/dist/src/pageComponent/views/workforceManager/workforceRule/components/rule.d.ts +35 -35
  334. package/dist/src/pageComponent/views/workforceManager/workforceRule/components/{workforceRule.d.ts → workforceRuleComp.d.ts} +3 -2
  335. package/dist/src/pageComponent/views/workforceManager/workforceRule/index.d.ts +3 -2
  336. package/dist/src/tpInit/index.d.ts +7 -7
  337. package/dist/src/utils/className.d.ts +2 -2
  338. package/dist/src/utils/config.d.ts +4 -4
  339. package/dist/src/utils/getSlots.d.ts +3 -3
  340. package/dist/src/utils/index.d.ts +11 -11
  341. package/dist/src/utils/installComponent.d.ts +3 -3
  342. package/dist/src/utils/publicUtil/changeTheme.d.ts +5 -5
  343. package/dist/src/utils/publicUtil/index.d.ts +34 -34
  344. package/dist/src/utils/publicUtil/login/index.d.ts +21 -21
  345. package/dist/src/utils/publicUtil/message.d.ts +2 -2
  346. package/dist/src/utils/publicUtil/systemConfig.d.ts +5 -5
  347. package/dist/src/utils/route.d.ts +31 -31
  348. package/dist/style.css +10 -9
  349. package/dist/theme/index.js +70 -70
  350. package/dist/theme/scripts/dark-vars.js +21 -21
  351. package/dist/theme/scripts/default-vars.js +25 -25
  352. package/dist/theme/scripts/light-vars.js +22 -22
  353. package/dist/theme/style/color/bezierEasing.less +110 -110
  354. package/dist/theme/style/color/colorPalette.less +81 -81
  355. package/dist/theme/style/color/colors.less +162 -162
  356. package/dist/theme/style/color/tinyColor.less +1184 -1184
  357. package/dist/theme/style/compact.less +4 -4
  358. package/dist/theme/style/dark.less +4 -4
  359. package/dist/theme/style/default.less +4 -4
  360. package/dist/theme/style/index.less +2 -2
  361. package/dist/theme/style/index.tsx +2 -2
  362. package/dist/theme/style/themes/compact.less +295 -295
  363. package/dist/theme/style/themes/dark.less +790 -790
  364. package/dist/theme/style/themes/default.less +1067 -1067
  365. package/dist/theme/style/themes/index.less +7 -7
  366. package/dist/theme/style/themes/var-dark.less +313 -313
  367. package/dist/theme/style/themes/var-default.less +148 -148
  368. package/dist/theme/style/themes/variable.less +1122 -1122
  369. package/dist/theme/style/variable.less +4 -4
  370. package/package.json +54 -54
  371. package/src/api/alarm/alarmRecord.ts +138 -138
  372. package/src/api/alarm/warningConfigure.ts +146 -146
  373. package/src/api/auth/menuManager.ts +71 -71
  374. package/src/api/auth/roleManager.ts +58 -58
  375. package/src/api/auth/userManager.ts +78 -78
  376. package/src/api/axios.ts +112 -112
  377. package/src/api/boardScreen/powersupply.ts +28 -28
  378. package/src/api/cardCenter.ts +74 -74
  379. package/src/api/dataAnalysis.ts +64 -64
  380. package/src/api/dataCenter.ts +66 -66
  381. package/src/api/enumList.ts +23 -23
  382. package/src/api/event.ts +143 -143
  383. package/src/api/faceName.ts +6 -6
  384. package/src/api/factory.ts +129 -129
  385. package/src/api/fileManager.ts +120 -120
  386. package/src/api/index.ts +1 -1
  387. package/src/api/linkage.ts +54 -54
  388. package/src/api/logManager.ts +28 -28
  389. package/src/api/noticeCenter.ts +55 -55
  390. package/src/api/noticeManager.ts +76 -76
  391. package/src/api/org/depManager.ts +167 -167
  392. package/src/api/org/postManager.ts +76 -76
  393. package/src/api/org/teamManager.ts +90 -90
  394. package/src/api/param.ts +46 -46
  395. package/src/api/personalSetting.ts +33 -33
  396. package/src/api/pressureFiltration/filterPressConfiguration.ts +36 -36
  397. package/src/api/pressureFiltration/flowChart.ts +27 -27
  398. package/src/api/pressureFiltration/pressureFiltrationHome.ts +62 -62
  399. package/src/api/pressureFiltration/pressureFiltrationRecord.ts +54 -54
  400. package/src/api/processDrawing.ts +77 -77
  401. package/src/api/product.ts +109 -109
  402. package/src/api/productionPlan.ts +230 -230
  403. package/src/api/productionPlan_old.ts +134 -134
  404. package/src/api/project.ts +87 -87
  405. package/src/api/pss.ts +144 -144
  406. package/src/api/rotation.ts +47 -47
  407. package/src/api/setting.ts +40 -40
  408. package/src/api/systemSetting.ts +91 -91
  409. package/src/api/thingInstance.ts +132 -132
  410. package/src/api/thingModel.ts +135 -135
  411. package/src/api/tupu.ts +23 -23
  412. package/src/api/video.ts +168 -168
  413. package/src/api/workforceManager.ts +163 -163
  414. package/src/components/changeTheme/README.md +20 -20
  415. package/src/components/changeTheme/index.less +25 -25
  416. package/src/components/changeTheme/index.tsx +57 -57
  417. package/src/components/headerMenu/README.md +67 -67
  418. package/src/components/headerMenu/index.tsx +130 -130
  419. package/src/components/headerMenuItem/index.tsx +50 -50
  420. package/src/components/headerMenuTitle/index.tsx +32 -32
  421. package/src/components/index.ts +21 -21
  422. package/src/components/inputText.tsx +49 -49
  423. package/src/components/layoutContent/README.md +36 -36
  424. package/src/components/layoutContent/index.tsx +271 -271
  425. package/src/components/layoutContent/style.less +82 -80
  426. package/src/components/layoutNav/README.md +35 -35
  427. package/src/components/layoutNav/index.tsx +129 -129
  428. package/src/components/layoutNav/style.less +27 -27
  429. package/src/components/layoutSidebar/README.md +23 -23
  430. package/src/components/layoutSidebar/index.tsx +181 -181
  431. package/src/components/layoutSidebar/style.less +31 -31
  432. package/src/components/styles/index.less +119 -119
  433. package/src/components/videoPlayer/README.md +35 -35
  434. package/src/components/videoPlayer/index.tsx +128 -128
  435. package/src/components/videoPlayer/util/ZLMRTCClient.js +6839 -6839
  436. package/src/components/videoPlayer/util/interface.ts +3 -3
  437. package/src/components/videoPlayer/util/video.ts +250 -250
  438. package/src/directives/focus.ts +14 -14
  439. package/src/hooks/global.ts +11 -11
  440. package/src/hooks/useMenuCode.ts +26 -26
  441. package/src/hooks/userVModel.ts +19 -19
  442. package/src/index.ts +31 -31
  443. package/src/pageComponent/assets/img.d.ts +1 -1
  444. package/src/pageComponent/assets/styles/alarm/add-warning-configure.less +29 -29
  445. package/src/pageComponent/assets/styles/alarm/alarmDetail.less +18 -18
  446. package/src/pageComponent/assets/styles/alarm/check-people.less +52 -52
  447. package/src/pageComponent/assets/styles/alarm/index.less +6 -6
  448. package/src/pageComponent/assets/styles/alarm/video-play.less +22 -22
  449. package/src/pageComponent/assets/styles/alarm/warning-configure.less +7 -7
  450. package/src/pageComponent/assets/styles/alarm/warning-record.less +17 -17
  451. package/src/pageComponent/assets/styles/boardScreen/components/Card1Outer.less +76 -76
  452. package/src/pageComponent/assets/styles/boardScreen/components/Card2Outer.less +139 -139
  453. package/src/pageComponent/assets/styles/boardScreen/components/PopBox.less +83 -83
  454. package/src/pageComponent/assets/styles/boardScreen/index.less +57 -57
  455. package/src/pageComponent/assets/styles/boardScreen/room/index.less +205 -205
  456. package/src/pageComponent/assets/styles/boardScreen/room/mixin.less +19 -19
  457. package/src/pageComponent/assets/styles/boardScreen/tupu/index.less +19 -19
  458. package/src/pageComponent/assets/styles/card/index.less +196 -196
  459. package/src/pageComponent/assets/styles/constant/antd.less +1 -1
  460. package/src/pageComponent/assets/styles/data/index.less +58 -58
  461. package/src/pageComponent/assets/styles/htModal/control.less +20 -20
  462. package/src/pageComponent/assets/styles/htModal/index.less +8 -8
  463. package/src/pageComponent/assets/styles/htModal/task.less +24 -24
  464. package/src/pageComponent/assets/styles/index.less +90 -90
  465. package/src/pageComponent/assets/styles/login/login.less +190 -190
  466. package/src/pageComponent/assets/styles/login/loginBox.less +233 -233
  467. package/src/pageComponent/assets/styles/pressureFiltration/filterPressConfiguration.less +13 -13
  468. package/src/pageComponent/assets/styles/pressureFiltration/index.less +4 -4
  469. package/src/pageComponent/assets/styles/pressureFiltration/pressureFiltrationHome.less +112 -112
  470. package/src/pageComponent/assets/styles/pressureFiltration/pressureFiltrationRecord.less +15 -15
  471. package/src/pageComponent/assets/styles/pressureFiltration/shiftChange.less +13 -13
  472. package/src/pageComponent/assets/styles/processFlow/addonAfter.less +2 -2
  473. package/src/pageComponent/assets/styles/processFlow/colorPicker.less +24 -24
  474. package/src/pageComponent/assets/styles/processFlow/editor.less +198 -198
  475. package/src/pageComponent/assets/styles/processFlow/index.less +151 -151
  476. package/src/pageComponent/assets/styles/processFlow/operationArea.less +58 -58
  477. package/src/pageComponent/assets/styles/processFlow/preview.less +70 -70
  478. package/src/pageComponent/assets/styles/processFlow/processDrawingPreviewModal.less +10 -10
  479. package/src/pageComponent/assets/styles/systemManager/about.less +57 -57
  480. package/src/pageComponent/assets/styles/systemManager/aboutNew.less +98 -98
  481. package/src/pageComponent/assets/styles/systemManager/index.less +111 -103
  482. package/src/pageComponent/assets/styles/systemManager/menu-manager.less +69 -69
  483. package/src/pageComponent/assets/styles/systemManager/noticeManager/noticeCenter.less +6 -6
  484. package/src/pageComponent/assets/styles/systemManager/noticeManager/noticeMaintain.less +13 -13
  485. package/src/pageComponent/assets/styles/systemManager/noticeManager/noticeManager.less +13 -13
  486. package/src/pageComponent/assets/styles/systemManager/param-manager.less +47 -47
  487. package/src/pageComponent/assets/styles/systemManager/systemSetting.less +131 -131
  488. package/src/pageComponent/assets/styles/thingModel/factory.less +125 -125
  489. package/src/pageComponent/assets/zh-cn.js +134 -134
  490. package/src/pageComponent/components/CommonTree.tsx +402 -402
  491. package/src/pageComponent/components/DynamicIcon.tsx +27 -27
  492. package/src/pageComponent/components/EditPasswordForm.tsx +110 -110
  493. package/src/pageComponent/components/IconSelect.tsx +50 -50
  494. package/src/pageComponent/components/ProFormItem.tsx +197 -197
  495. package/src/pageComponent/components/SearchSelect.tsx +142 -142
  496. package/src/pageComponent/components/boardScreen/Card1Outer.tsx +29 -29
  497. package/src/pageComponent/components/boardScreen/Card2Outer.tsx +24 -24
  498. package/src/pageComponent/components/boardScreen/PopBox.tsx +141 -141
  499. package/src/pageComponent/components/boardScreen/PowerCut.tsx +104 -104
  500. package/src/pageComponent/components/boardScreen/PowerSupply.tsx +98 -98
  501. package/src/pageComponent/components/boardScreen/card2OuterTable.tsx +96 -96
  502. package/src/pageComponent/components/check-people.tsx +256 -256
  503. package/src/pageComponent/components/elcRoomHt/index.tsx +115 -115
  504. package/src/pageComponent/components/htModal/control.tsx +190 -190
  505. package/src/pageComponent/components/htModal/index.tsx +41 -41
  506. package/src/pageComponent/components/htModal/task.tsx +42 -42
  507. package/src/pageComponent/components/loginBox/README.md +21 -21
  508. package/src/pageComponent/components/loginBox/index.tsx +174 -174
  509. package/src/pageComponent/components/noticeManager/addChannel.tsx +103 -103
  510. package/src/pageComponent/components/noticeManager/addNotice.tsx +398 -398
  511. package/src/pageComponent/components/noticeManager/addTemplate.tsx +116 -116
  512. package/src/pageComponent/components/noticeManager/noticeGrade.tsx +150 -150
  513. package/src/pageComponent/components/noticeManager/noticeMaintain.tsx +32 -32
  514. package/src/pageComponent/components/noticeManager/noticeTemplate.tsx +268 -268
  515. package/src/pageComponent/components/noticeManager/notificationDetails.tsx +133 -133
  516. package/src/pageComponent/components/noticeManager/sendDetails.tsx +207 -207
  517. package/src/pageComponent/components/pressureFiltration/alarmList.tsx +35 -35
  518. package/src/pageComponent/components/pressureFiltration/configuration.tsx +155 -155
  519. package/src/pageComponent/components/pressureFiltration/numberOfPlates.tsx +32 -32
  520. package/src/pageComponent/components/pressureFiltration/shiftChange.tsx +91 -91
  521. package/src/pageComponent/components/pss-cabinet/README.md +1 -1
  522. package/src/pageComponent/components/pss-cabinet/cabinet.d.ts +43 -43
  523. package/src/pageComponent/components/pss-cabinet/cabinetRender.ts +540 -540
  524. package/src/pageComponent/components/user/userTable.tsx +157 -157
  525. package/src/pageComponent/components/user/userTree.tsx +266 -266
  526. package/src/pageComponent/components/video-play.tsx +83 -83
  527. package/src/pageComponent/config/htconfig.ts +32 -32
  528. package/src/pageComponent/config/systemConfig.ts +159 -159
  529. package/src/pageComponent/hooks/cardTable.ts +88 -88
  530. package/src/pageComponent/hooks/filters.ts +81 -81
  531. package/src/pageComponent/hooks/global.ts +11 -11
  532. package/src/pageComponent/hooks/manage-module/useModalForm.ts +44 -44
  533. package/src/pageComponent/hooks/manage-module/useModalTitle.ts +34 -34
  534. package/src/pageComponent/hooks/manage-module/useModalVisibleControl.ts +31 -31
  535. package/src/pageComponent/hooks/screen.ts +43 -43
  536. package/src/pageComponent/hooks/tabListConfig.ts +60 -60
  537. package/src/pageComponent/hooks/toPreviewData.ts +38 -38
  538. package/src/pageComponent/hooks/treeSearch.ts +151 -151
  539. package/src/pageComponent/hooks/useBus.ts +26 -26
  540. package/src/pageComponent/hooks/useMouse.ts +26 -26
  541. package/src/pageComponent/hooks/useProxy.ts +8 -8
  542. package/src/pageComponent/hooks/useTableList.ts +92 -92
  543. package/src/pageComponent/hooks/useVModel.ts +17 -17
  544. package/src/pageComponent/hooks/useWatchOnce.ts +12 -12
  545. package/src/pageComponent/index.ts +125 -125
  546. package/src/pageComponent/store/index.ts +86 -86
  547. package/src/pageComponent/utils/base64.ts +27 -27
  548. package/src/pageComponent/utils/filter.ts +152 -152
  549. package/src/pageComponent/utils/format.ts +95 -95
  550. package/src/pageComponent/utils/index.ts +71 -71
  551. package/src/pageComponent/utils/is.ts +30 -30
  552. package/src/pageComponent/utils/transform.ts +27 -27
  553. package/src/pageComponent/utils/tree.ts +83 -83
  554. package/src/pageComponent/utils/upload.ts +24 -24
  555. package/src/pageComponent/utils/validation.ts +26 -26
  556. package/src/pageComponent/views/alarms/add-warning-configure/form/basic-form.tsx +281 -281
  557. package/src/pageComponent/views/alarms/add-warning-configure/form/linkage-form.tsx +130 -130
  558. package/src/pageComponent/views/alarms/add-warning-configure/form/rule-form.tsx +347 -347
  559. package/src/pageComponent/views/alarms/add-warning-configure/index.tsx +221 -221
  560. package/src/pageComponent/views/alarms/alarmDetail/index.tsx +250 -250
  561. package/src/pageComponent/views/alarms/index.tsx +7 -7
  562. package/src/pageComponent/views/alarms/warning-configure/README.md +53 -53
  563. package/src/pageComponent/views/alarms/warning-configure/batch-import-dialog.tsx +123 -123
  564. package/src/pageComponent/views/alarms/warning-configure/configure-table.tsx +186 -186
  565. package/src/pageComponent/views/alarms/warning-configure/index.tsx +75 -75
  566. package/src/pageComponent/views/alarms/warning-configure/table-tool.tsx +57 -57
  567. package/src/pageComponent/views/alarms/warning-record/README.md +49 -49
  568. package/src/pageComponent/views/alarms/warning-record/index.tsx +80 -80
  569. package/src/pageComponent/views/alarms/warning-record/query-filter.tsx +129 -129
  570. package/src/pageComponent/views/alarms/warning-record/record-table.tsx +449 -449
  571. package/src/pageComponent/views/boardScreen/index.tsx +261 -261
  572. package/src/pageComponent/views/boardScreen/room.tsx +180 -180
  573. package/src/pageComponent/views/boardScreen/tupu.tsx +143 -143
  574. package/src/pageComponent/views/card-center/README.md +32 -32
  575. package/src/pageComponent/views/card-center/cardWarehouse.tsx +679 -679
  576. package/src/pageComponent/views/card-center/components/cardDetail.tsx +259 -259
  577. package/src/pageComponent/views/card-center/components/editPage.tsx +158 -158
  578. package/src/pageComponent/views/card-center/components/pageDetail.tsx +172 -172
  579. package/src/pageComponent/views/card-center/components/selectCard.tsx +101 -101
  580. package/src/pageComponent/views/card-center/less/editPage.less +119 -119
  581. package/src/pageComponent/views/card-center/less/selectCard.less +23 -23
  582. package/src/pageComponent/views/card-center/pageConfiguration.tsx +573 -573
  583. package/src/pageComponent/views/data-center/README.md +32 -32
  584. package/src/pageComponent/views/data-center/assets/less/dataAnalysis.less +175 -175
  585. package/src/pageComponent/views/data-center/cardModal.tsx +199 -199
  586. package/src/pageComponent/views/data-center/cardSubscription.tsx +322 -322
  587. package/src/pageComponent/views/data-center/components/chart.ts +81 -81
  588. package/src/pageComponent/views/data-center/components/groupModal.tsx +317 -317
  589. package/src/pageComponent/views/data-center/components/leftTree.tsx +171 -171
  590. package/src/pageComponent/views/data-center/components/searchHeader.tsx +173 -173
  591. package/src/pageComponent/views/data-center/components/table.tsx +51 -51
  592. package/src/pageComponent/views/data-center/dataAnalysis.tsx +532 -532
  593. package/src/pageComponent/views/data-center/userModal.tsx +120 -120
  594. package/src/pageComponent/views/elcRoom/index.tsx +106 -106
  595. package/src/pageComponent/views/factoryManage/index.tsx +675 -675
  596. package/src/pageComponent/views/fileManager/assets/less/components.less +50 -50
  597. package/src/pageComponent/views/fileManager/assets/less/index.less +281 -281
  598. package/src/pageComponent/views/fileManager/components/CreateFolder.tsx +111 -111
  599. package/src/pageComponent/views/fileManager/components/MoveToFolder.tsx +212 -212
  600. package/src/pageComponent/views/fileManager/components/Rename.tsx +115 -115
  601. package/src/pageComponent/views/fileManager/components/UploadFiles.tsx +148 -148
  602. package/src/pageComponent/views/fileManager/fileManager.tsx +769 -769
  603. package/src/pageComponent/views/fileManager/index.tsx +12 -12
  604. package/src/pageComponent/views/index.tsx +20 -20
  605. package/src/pageComponent/views/login/README.md +57 -57
  606. package/src/pageComponent/views/login/box.tsx +300 -300
  607. package/src/pageComponent/views/login/index.tsx +120 -120
  608. package/src/pageComponent/views/login/leftImg.tsx +23 -23
  609. package/src/pageComponent/views/login/top-title.tsx +12 -12
  610. package/src/pageComponent/views/pressureFiltration/feeding.tsx +69 -69
  611. package/src/pageComponent/views/pressureFiltration/pressureFiltrationHome.tsx +265 -265
  612. package/src/pageComponent/views/pressureFiltration/productionShiftReport.tsx +163 -163
  613. package/src/pageComponent/views/pressureFiltration/record.tsx +262 -262
  614. package/src/pageComponent/views/pressureFiltration/unloading.tsx +79 -79
  615. package/src/pageComponent/views/processDrawingConfiguration/README.md +30 -30
  616. package/src/pageComponent/views/processDrawingConfiguration/components/addonAfter.tsx +20 -20
  617. package/src/pageComponent/views/processDrawingConfiguration/components/cardItem.tsx +81 -81
  618. package/src/pageComponent/views/processDrawingConfiguration/components/colorPicker.tsx +59 -59
  619. package/src/pageComponent/views/processDrawingConfiguration/components/eventForm.tsx +43 -43
  620. package/src/pageComponent/views/processDrawingConfiguration/components/flowList.tsx +56 -56
  621. package/src/pageComponent/views/processDrawingConfiguration/components/propertyForm.tsx +94 -94
  622. package/src/pageComponent/views/processDrawingConfiguration/components/propertyModal.tsx +71 -71
  623. package/src/pageComponent/views/processDrawingConfiguration/components/state.tsx +139 -139
  624. package/src/pageComponent/views/processDrawingConfiguration/components/styleForm.tsx +199 -199
  625. package/src/pageComponent/views/processDrawingConfiguration/editor/components/data.tsx +192 -192
  626. package/src/pageComponent/views/processDrawingConfiguration/editor/components/textarea.tsx +9 -9
  627. package/src/pageComponent/views/processDrawingConfiguration/editor/config.ts +310 -310
  628. package/src/pageComponent/views/processDrawingConfiguration/editor/index.tsx +116 -116
  629. package/src/pageComponent/views/processDrawingConfiguration/editor/instanceSelector.tsx +190 -190
  630. package/src/pageComponent/views/processDrawingConfiguration/editor/mainContent.tsx +319 -319
  631. package/src/pageComponent/views/processDrawingConfiguration/editor/operationArea.tsx +449 -449
  632. package/src/pageComponent/views/processDrawingConfiguration/editor/previewModal.tsx +121 -121
  633. package/src/pageComponent/views/processDrawingConfiguration/editor/utils.ts +76 -76
  634. package/src/pageComponent/views/processDrawingConfiguration/editor-util/index.d.ts +98 -98
  635. package/src/pageComponent/views/processDrawingConfiguration/editor-util/index.js +2055 -2055
  636. package/src/pageComponent/views/processDrawingConfiguration/hooks/index.ts +152 -152
  637. package/src/pageComponent/views/processDrawingConfiguration/hooks/useActiveWidget.ts +34 -34
  638. package/src/pageComponent/views/processDrawingConfiguration/index.tsx +163 -163
  639. package/src/pageComponent/views/processDrawingConfiguration/previewModal.tsx +123 -123
  640. package/src/pageComponent/views/productManager/index.tsx +349 -349
  641. package/src/pageComponent/views/productManager/update.tsx +448 -448
  642. package/src/pageComponent/views/productManager/utils/emuns.ts +111 -111
  643. package/src/pageComponent/views/productManager/utils/formRules.ts +109 -109
  644. package/src/pageComponent/views/productManager/versionEdit/index.tsx +104 -104
  645. package/src/pageComponent/views/productManager/versionEdit/param.tsx +236 -236
  646. package/src/pageComponent/views/productionPlanManager/assets/components/Plan.less +140 -140
  647. package/src/pageComponent/views/productionPlanManager/assets/dayPCPlan.less +20 -20
  648. package/src/pageComponent/views/productionPlanManager/assets/daySCPlan.less +14 -14
  649. package/src/pageComponent/views/productionPlanManager/assets/monthPCPlan.less +22 -22
  650. package/src/pageComponent/views/productionPlanManager/assets/productionPlan.less +119 -111
  651. package/src/pageComponent/views/productionPlanManager/assets/yearPCPlan.less +86 -86
  652. package/src/pageComponent/views/productionPlanManager/components/Plan.tsx +802 -802
  653. package/src/pageComponent/views/productionPlanManager/components/Plan_back.tsx +353 -353
  654. package/src/pageComponent/views/productionPlanManager/dayPCPlan.tsx +175 -175
  655. package/src/pageComponent/views/productionPlanManager/daySCPlan.tsx +156 -156
  656. package/src/pageComponent/views/productionPlanManager/dayWYPlan.tsx +19 -19
  657. package/src/pageComponent/views/productionPlanManager/monthPCPlan.tsx +242 -242
  658. package/src/pageComponent/views/productionPlanManager/productionPlanConfig.tsx +559 -559
  659. package/src/pageComponent/views/productionPlanManager/productionPlan_old.tsx +434 -434
  660. package/src/pageComponent/views/productionPlanManager/yearPCPlan.tsx +536 -536
  661. package/src/pageComponent/views/projectManager/components/commonForm.tsx +207 -207
  662. package/src/pageComponent/views/projectManager/detail.tsx +463 -463
  663. package/src/pageComponent/views/projectManager/hooks/useTable.ts +96 -96
  664. package/src/pageComponent/views/projectManager/hooks/useTreeSearch.ts +231 -231
  665. package/src/pageComponent/views/projectManager/index.tsx +464 -464
  666. package/src/pageComponent/views/projectManager/less/index.less +19 -19
  667. package/src/pageComponent/views/projectManager/utils/emuns.ts +86 -86
  668. package/src/pageComponent/views/projectManager/utils/formRules.ts +342 -342
  669. package/src/pageComponent/views/projectManager/utils/index.ts +213 -213
  670. package/src/pageComponent/views/pss/assets/less/ApproveOpinion.less +18 -18
  671. package/src/pageComponent/views/pss/assets/less/NewOrder.less +95 -95
  672. package/src/pageComponent/views/pss/assets/less/PerformOperation.less +42 -42
  673. package/src/pageComponent/views/pss/assets/less/cus-table.less +330 -330
  674. package/src/pageComponent/views/pss/assets/less/index.less +476 -475
  675. package/src/pageComponent/views/pss/components/ApproveOpinion.tsx +171 -171
  676. package/src/pageComponent/views/pss/components/Info.tsx +506 -506
  677. package/src/pageComponent/views/pss/components/NewOrder.tsx +618 -618
  678. package/src/pageComponent/views/pss/components/PerformOperation.tsx +102 -102
  679. package/src/pageComponent/views/pss/components/table.tsx +840 -840
  680. package/src/pageComponent/views/pss/index.tsx +18 -18
  681. package/src/pageComponent/views/pss/list.tsx +65 -65
  682. package/src/pageComponent/views/pss/utils/index.ts +9 -9
  683. package/src/pageComponent/views/pssRecord/assets/index.less +258 -255
  684. package/src/pageComponent/views/pssRecord/components/Info.tsx +223 -223
  685. package/src/pageComponent/views/pssRecord/index.tsx +334 -334
  686. package/src/pageComponent/views/systemManager/about/README.md +37 -37
  687. package/src/pageComponent/views/systemManager/about/index.tsx +176 -176
  688. package/src/pageComponent/views/systemManager/aboutNew/README.md +26 -26
  689. package/src/pageComponent/views/systemManager/aboutNew/index.tsx +86 -86
  690. package/src/pageComponent/views/systemManager/authManager/menuManager/README.md +45 -45
  691. package/src/pageComponent/views/systemManager/authManager/menuManager/index.tsx +106 -106
  692. package/src/pageComponent/views/systemManager/authManager/menuManager/menuDetail.tsx +185 -185
  693. package/src/pageComponent/views/systemManager/authManager/menuManager/menuForm.tsx +284 -284
  694. package/src/pageComponent/views/systemManager/authManager/menuManager/menuSelectTree.tsx +129 -129
  695. package/src/pageComponent/views/systemManager/authManager/menuManager/updateMenuDialog.tsx +87 -87
  696. package/src/pageComponent/views/systemManager/authManager/menuManager/uploadJSONDialog.tsx +79 -79
  697. package/src/pageComponent/views/systemManager/authManager/roleManager/README.md +43 -43
  698. package/src/pageComponent/views/systemManager/authManager/roleManager/index.tsx +272 -272
  699. package/src/pageComponent/views/systemManager/authManager/roleManager/updateRoleDialog.tsx +192 -192
  700. package/src/pageComponent/views/systemManager/authManager/userManager/README.md +49 -49
  701. package/src/pageComponent/views/systemManager/authManager/userManager/index.tsx +308 -308
  702. package/src/pageComponent/views/systemManager/authManager/userManager/updateUserDialog.tsx +332 -332
  703. package/src/pageComponent/views/systemManager/authManager/userManager/userProfileDialog.tsx +107 -107
  704. package/src/pageComponent/views/systemManager/logManager/README.md +37 -37
  705. package/src/pageComponent/views/systemManager/noticeManager/noticeCenter.tsx +339 -339
  706. package/src/pageComponent/views/systemManager/noticeManager/noticeManager.tsx +177 -177
  707. package/src/pageComponent/views/systemManager/orgManager/depManager/README.md +60 -60
  708. package/src/pageComponent/views/systemManager/orgManager/depManager/batchImportModal.tsx +129 -129
  709. package/src/pageComponent/views/systemManager/orgManager/depManager/depTree.tsx +129 -129
  710. package/src/pageComponent/views/systemManager/orgManager/depManager/employeeTable.tsx +264 -264
  711. package/src/pageComponent/views/systemManager/orgManager/depManager/updateDepDialog.tsx +246 -246
  712. package/src/pageComponent/views/systemManager/orgManager/depManager/updateEmployeeDialog.tsx +327 -327
  713. package/src/pageComponent/views/systemManager/orgManager/depManagerCorp/README.md +60 -60
  714. package/src/pageComponent/views/systemManager/orgManager/depManagerCorp/depTree.tsx +188 -188
  715. package/src/pageComponent/views/systemManager/orgManager/depManagerCorp/employeeTable.tsx +253 -253
  716. package/src/pageComponent/views/systemManager/orgManager/depManagerCorp/updateDepDialog.tsx +362 -362
  717. package/src/pageComponent/views/systemManager/orgManager/depManagerCorp/updateEmployeeDialog.tsx +377 -377
  718. package/src/pageComponent/views/systemManager/orgManager/empManager.tsx +7 -7
  719. package/src/pageComponent/views/systemManager/orgManager/postManager/README.md +43 -43
  720. package/src/pageComponent/views/systemManager/orgManager/postManager/index.tsx +248 -248
  721. package/src/pageComponent/views/systemManager/orgManager/postManager/updatePostDialog.tsx +184 -184
  722. package/src/pageComponent/views/systemManager/orgManager/teamManager/README.md +47 -47
  723. package/src/pageComponent/views/systemManager/orgManager/teamManager/index.tsx +256 -256
  724. package/src/pageComponent/views/systemManager/orgManager/teamManager/updateTeamDialog.tsx +287 -287
  725. package/src/pageComponent/views/systemManager/paramManager/README.md +37 -37
  726. package/src/pageComponent/views/systemManager/paramManager/collapseContainer.tsx +54 -54
  727. package/src/pageComponent/views/systemManager/paramManager/dynamicForm.tsx +138 -138
  728. package/src/pageComponent/views/systemManager/paramManager/index.tsx +127 -127
  729. package/src/pageComponent/views/systemManager/paramManager/tabItem.tsx +175 -175
  730. package/src/pageComponent/views/systemManager/personalSetting/README.md +37 -37
  731. package/src/pageComponent/views/systemManager/systemSetting/README.md +39 -39
  732. package/src/pageComponent/views/systemManager/systemSetting/data.ts +133 -133
  733. package/src/pageComponent/views/systemManager/systemSetting/index.tsx +575 -575
  734. package/src/pageComponent/views/thingInstance/component/addThing.tsx +737 -732
  735. package/src/pageComponent/views/thingInstance/component/baseItem.tsx +7 -7
  736. package/src/pageComponent/views/thingInstance/component/dynamicForm.tsx +265 -265
  737. package/src/pageComponent/views/thingInstance/component/editRelation.tsx +415 -415
  738. package/src/pageComponent/views/thingInstance/component/editThing.tsx +985 -978
  739. package/src/pageComponent/views/thingInstance/component/logicForm.tsx +166 -166
  740. package/src/pageComponent/views/thingInstance/component/thingDetail.tsx +445 -437
  741. package/src/pageComponent/views/thingInstance/data.ts +63 -63
  742. package/src/pageComponent/views/thingInstance/hooks/filters.ts +110 -110
  743. package/src/pageComponent/views/thingInstance/hooks/useTableList.ts +92 -92
  744. package/src/pageComponent/views/thingInstance/hooks/useTreeSearch.ts +93 -93
  745. package/src/pageComponent/views/thingInstance/index.tsx +1174 -1169
  746. package/src/pageComponent/views/thingInstance/less/editThing.less +150 -150
  747. package/src/pageComponent/views/thingInstance/less/thingInstance.less +142 -142
  748. package/src/pageComponent/views/thingInstance/modal.tsx +121 -121
  749. package/src/pageComponent/views/thingModel/component/detail.tsx +286 -286
  750. package/src/pageComponent/views/thingModel/component/tabAttr/index.tsx +127 -127
  751. package/src/pageComponent/views/thingModel/component/tabAttr/update.tsx +408 -408
  752. package/src/pageComponent/views/thingModel/component/tabRelation/index.tsx +203 -203
  753. package/src/pageComponent/views/thingModel/component/tabRelation/update.tsx +278 -278
  754. package/src/pageComponent/views/thingModel/component/update.tsx +216 -216
  755. package/src/pageComponent/views/thingModel/config.ts +192 -192
  756. package/src/pageComponent/views/thingModel/hooks/useTableList.ts +91 -91
  757. package/src/pageComponent/views/thingModel/hooks/useTreeSearch.ts +93 -93
  758. package/src/pageComponent/views/thingModel/index.tsx +363 -363
  759. package/src/pageComponent/views/thingModel/less/thingModel.less +105 -105
  760. package/src/pageComponent/views/thingModel/less/thingModelDetail.less +142 -142
  761. package/src/pageComponent/views/video/README.md +81 -81
  762. package/src/pageComponent/views/video/assets/iconfont/demo.css +539 -539
  763. package/src/pageComponent/views/video/assets/iconfont/demo_index.html +487 -487
  764. package/src/pageComponent/views/video/assets/iconfont/iconfont.css +67 -67
  765. package/src/pageComponent/views/video/assets/iconfont/iconfont.json +100 -100
  766. package/src/pageComponent/views/video/assets/styles/const.less +1 -1
  767. package/src/pageComponent/views/video/assets/styles/constant/antd.less +1 -1
  768. package/src/pageComponent/views/video/assets/styles/home.less +96 -96
  769. package/src/pageComponent/views/video/assets/styles/index.less +27 -27
  770. package/src/pageComponent/views/video/assets/styles/lightColour.less +108 -108
  771. package/src/pageComponent/views/video/assets/styles/login.less +56 -56
  772. package/src/pageComponent/views/video/assets/styles/loginBox.less +51 -51
  773. package/src/pageComponent/views/video/assets/styles/play.less +66 -66
  774. package/src/pageComponent/views/video/assets/styles/reset.less +17 -17
  775. package/src/pageComponent/views/video/assets/styles/video/event.less +121 -121
  776. package/src/pageComponent/views/video/assets/styles/video/group.less +179 -179
  777. package/src/pageComponent/views/video/assets/styles/video/linkage.less +79 -79
  778. package/src/pageComponent/views/video/assets/styles/video/photo.less +119 -115
  779. package/src/pageComponent/views/video/assets/styles/video/preview.less +503 -483
  780. package/src/pageComponent/views/video/assets/styles/video/replay.less +84 -84
  781. package/src/pageComponent/views/video/assets/styles/video/rotation.less +155 -144
  782. package/src/pageComponent/views/video/assets/styles/video/setting.less +48 -48
  783. package/src/pageComponent/views/video/assets/zh-cn.js +133 -133
  784. package/src/pageComponent/views/video/components/checkCamera.tsx +130 -130
  785. package/src/pageComponent/views/video/components/transfer.tsx +474 -474
  786. package/src/pageComponent/views/video/components/videoPlayer/index.tsx +93 -93
  787. package/src/pageComponent/views/video/components/videoPlayer/util/ZLMRTCClient.js +6839 -6839
  788. package/src/pageComponent/views/video/components/videoPlayer/util/axios.ts +53 -53
  789. package/src/pageComponent/views/video/components/videoPlayer/util/byUuid.ts +77 -77
  790. package/src/pageComponent/views/video/components/videoPlayer/util/video.ts +252 -252
  791. package/src/pageComponent/views/video/event/algorithmType.tsx +257 -257
  792. package/src/pageComponent/views/video/event/eventConfig.tsx +399 -399
  793. package/src/pageComponent/views/video/event/eventType.tsx +304 -304
  794. package/src/pageComponent/views/video/event/events.tsx +562 -562
  795. package/src/pageComponent/views/video/linkage/linkage.tsx +220 -220
  796. package/src/pageComponent/views/video/linkage/updateMode.tsx +179 -179
  797. package/src/pageComponent/views/video/play.tsx +107 -107
  798. package/src/pageComponent/views/video/preview/components/alarmLinkageModal.tsx +62 -62
  799. package/src/pageComponent/views/video/preview/components/followItem.tsx +198 -194
  800. package/src/pageComponent/views/video/preview/components/fullScreen.tsx +63 -63
  801. package/src/pageComponent/views/video/preview/components/treeItem.tsx +333 -333
  802. package/src/pageComponent/views/video/preview/preview.tsx +816 -816
  803. package/src/pageComponent/views/video/rotation/PlayVideos.tsx +178 -178
  804. package/src/pageComponent/views/video/rotation/rotation.tsx +562 -555
  805. package/src/pageComponent/views/video/sbgl/components/CheckDialog.tsx +128 -128
  806. package/src/pageComponent/views/video/sbgl/components/addGrouping.tsx +71 -71
  807. package/src/pageComponent/views/video/sbgl/group.tsx +532 -532
  808. package/src/pageComponent/views/video/sbgl/index.tsx +8 -8
  809. package/src/pageComponent/views/video/sbgl/nvr.tsx +275 -275
  810. package/src/pageComponent/views/video/sbgl/photo.tsx +696 -696
  811. package/src/pageComponent/views/video/setting/cameraPermission.tsx +123 -123
  812. package/src/pageComponent/views/video/setting/index.tsx +9 -9
  813. package/src/pageComponent/views/video/setting/system.tsx +146 -146
  814. package/src/pageComponent/views/video/utils/ZLMRTCClient.js +6839 -6839
  815. package/src/pageComponent/views/video/utils/index.ts +22 -22
  816. package/src/pageComponent/views/video/utils/validation.ts +2 -2
  817. package/src/pageComponent/views/video/utils/video.ts +254 -254
  818. package/src/pageComponent/views/video/utils/webSocket.ts +115 -115
  819. package/src/pageComponent/views/workforceManager/workforcePlan/assets/workforcePlan.less +118 -113
  820. package/src/pageComponent/views/workforceManager/workforcePlan/dayContent.tsx +171 -171
  821. package/src/pageComponent/views/workforceManager/workforcePlan/index.tsx +241 -241
  822. package/src/pageComponent/views/workforceManager/workforcePlan/mainTable.tsx +333 -333
  823. package/src/pageComponent/views/workforceManager/workforceRule/assets/classManagerAndWorkforceRuleComp.less +23 -0
  824. package/src/pageComponent/views/workforceManager/workforceRule/assets/index.less +10 -0
  825. package/src/pageComponent/views/workforceManager/workforceRule/assets/rule.less +34 -34
  826. package/src/pageComponent/views/workforceManager/workforceRule/components/classManager.tsx +380 -380
  827. package/src/pageComponent/views/workforceManager/workforceRule/components/rule.tsx +706 -706
  828. package/src/pageComponent/views/workforceManager/workforceRule/components/{workforceRule.tsx → workforceRuleComp.tsx} +236 -234
  829. package/src/pageComponent/views/workforceManager/workforceRule/index.tsx +33 -30
  830. package/src/styles/index.less +1 -1
  831. package/src/tpInit/utils.ts +1 -1
  832. package/src/types/gl.d.ts +25 -25
  833. package/src/types/global.d.ts +41 -41
  834. package/src/types/ht/ht-widget.d.ts +11327 -11327
  835. package/src/types/ht/ht.d.ts +11410 -11410
  836. package/src/types/ht/index.d.ts +4 -4
  837. package/src/types/shims-vue.d.ts +1 -1
  838. package/src/utils/README.md +3 -3
  839. package/src/utils/className.ts +16 -16
  840. package/src/utils/config.ts +5 -5
  841. package/src/utils/getSlots.ts +18 -18
  842. package/src/utils/index.ts +8 -8
  843. package/src/utils/installComponent.ts +12 -12
  844. package/src/utils/publicUtil/README.md +41 -41
  845. package/src/utils/publicUtil/changeTheme.ts +32 -32
  846. package/src/utils/publicUtil/index.ts +25 -25
  847. package/src/utils/publicUtil/login/index.ts +108 -108
  848. package/src/utils/publicUtil/message.tsx +14 -14
  849. package/src/utils/publicUtil/systemConfig.ts +6 -6
  850. package/src/utils/route.ts +123 -123
  851. package/tsconfig.json +27 -27
  852. package/src/pageComponent/views/workforceManager/workforceRule/assets/classManager.less +0 -14
@@ -1,2055 +1,2055 @@
1
- import { fabric } from "fabric";
2
- import { AlignGuidelines } from "fabric-guideline-plugin";
3
-
4
- const UUID = (n = 16) => {
5
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
6
- const r = (Math.random() * 16) | 0,
7
- v = c == "x" ? r : (r & 0x3) | 0x8;
8
- return v.toString(n);
9
- });
10
- };
11
-
12
- /**
13
- *
14
- * @param fileName string 文件全民
15
- * @returns
16
- */
17
- const FileList = ["jpg", "svg", "png"];
18
- function getExt(fileName) {
19
- let splits = fileName.split(".");
20
- return splits.pop();
21
- }
22
- function getFiles(files) {
23
- const useFile = [];
24
-
25
- for (let i in files) {
26
- if (!isNaN(i)) {
27
- const item = files[i];
28
- const fileExt = getExt(item.name);
29
- const has = FileList.indexOf(fileExt);
30
-
31
- if (has >= 0) {
32
- const url = windowPath(item);
33
- useFile.push({
34
- url,
35
- fileExt,
36
- file: item,
37
- });
38
- }
39
- }
40
- }
41
-
42
- return useFile;
43
- }
44
- /**
45
- *
46
- * @param file 文件类型File
47
- * @returns window url
48
- */
49
-
50
- function windowPath(file) {
51
- let imgPath = "";
52
-
53
- if (window.createObjectURL != undefined) {
54
- imgPath = window.createObjectURL(file);
55
- } else if (window.URL != undefined) {
56
- imgPath = window.URL.createObjectURL(file);
57
- } else if (window.webkitURL != undefined) {
58
- imgPath = window.webkitURL.createObjectURL(file);
59
- }
60
-
61
- return imgPath;
62
- }
63
-
64
- const computedZoomCoord = (x, y, canvas) => {
65
- const zoom = canvas.getZoom();
66
- let left = x;
67
- let top = y;
68
-
69
- if (canvas.viewportTransform) {
70
- left = (left - canvas.viewportTransform[4]) / zoom;
71
- top = (top - canvas.viewportTransform[5]) / zoom;
72
- }
73
-
74
- return {
75
- left,
76
- top,
77
- };
78
- };
79
- const computedZoomXY = (e, svg, canvas) => {
80
- const userX = e.offsetX - svg.width / 2;
81
- const userY = e.offsetY - svg.height / 2;
82
- return computedZoomCoord(userX, userY, canvas);
83
- };
84
- const getWindowInfo = (domId) => {
85
- let height, width, dom;
86
-
87
- if (domId && document.getElementById(domId)) {
88
- dom = document.getElementById(domId);
89
- }
90
-
91
- return () => {
92
- if (dom) {
93
- height = dom.clientHeight;
94
- width = dom.clientWidth;
95
- } else {
96
- height = document.body.clientHeight;
97
- width = document.body.clientWidth;
98
- }
99
-
100
- return {
101
- height,
102
- width,
103
- };
104
- };
105
- };
106
- const setInfo = (canvas, obj, info) => {
107
- obj.set(info);
108
- canvas.renderAll();
109
- };
110
- const createElementId = (id, className, el) => {
111
- const dom = document.createElement(el || "div");
112
- dom.id = id;
113
- dom.className = className;
114
- return dom;
115
- };
116
-
117
- var util = {
118
- UUID,
119
- computedZoomXY,
120
- getWindowInfo,
121
- file: {
122
- getExt,
123
- getFiles,
124
- },
125
- };
126
-
127
- const canvasChangeZoom = (canvas) => {
128
- canvas.on("mouse:wheel", (opt) => {
129
- const delta = opt.e.deltaY; // 滚轮,向上滚一下是 -100,向下滚一下是 100
130
-
131
- let zoom = canvas.getZoom(); // 获取画布当前缩放值
132
-
133
- zoom *= 0.999 ** delta;
134
- if (zoom > 20) zoom = 20; // 限制最大缩放级别
135
-
136
- if (zoom < 0.01) zoom = 0.01; // 限制最小缩放级别
137
-
138
- canvas.zoomToPoint(
139
- {
140
- // 关键点
141
- x: opt.e.offsetX,
142
- y: opt.e.offsetY,
143
- },
144
- zoom // 传入修改后的缩放级别
145
- );
146
- });
147
- };
148
-
149
- const event = {
150
- mouseDown(opt, canvas, kk) {
151
- let evt = opt.e;
152
-
153
- if (kk === true) {
154
- // 是否按住ctrl
155
- canvas.isMoveing = true; // isMoveing 是自定义的,开启移动状态
156
-
157
- canvas.lastPosX = evt.clientX; // lastPosX 是自定义的
158
-
159
- canvas.lastPosY = evt.clientY; // lastPosY 是自定义的
160
- }
161
- },
162
-
163
- mouseMove(opt, canvas) {
164
- if (canvas.isMoveing) {
165
- let evt = opt.e;
166
- let vpt = canvas.viewportTransform; // 聚焦视图的转换
167
-
168
- vpt[4] += evt.clientX - canvas.lastPosX;
169
- vpt[5] += evt.clientY - canvas.lastPosY;
170
- this.scale.setVpt(vpt[4], vpt[5], opt);
171
- canvas.requestRenderAll(); // 重新渲染
172
-
173
- canvas.lastPosX = evt.clientX;
174
- canvas.lastPosY = evt.clientY;
175
- }
176
- },
177
-
178
- mouseUp(opt, canvas) {
179
- canvas.setViewportTransform(canvas.viewportTransform); // 设置此画布实例的视口转换
180
-
181
- canvas.isMoveing = false; // 关闭移动状态
182
- },
183
- };
184
- function canvasMove(canvas) {
185
- let flag = false;
186
- window.addEventListener("keydown", (e) => {
187
- if (e.code === "Space") {
188
- flag = true;
189
- }
190
- });
191
- window.addEventListener("keyup", (e) => {
192
- flag = false;
193
- });
194
- canvas.on("mouse:down", (e) => {
195
- event.mouseDown(e, canvas, flag);
196
- });
197
- canvas.on("mouse:move", (e) => {
198
- event.mouseMove.bind(this)(e, canvas);
199
- });
200
- canvas.on("mouse:up", (e) => {
201
- event.mouseUp(e, canvas);
202
- });
203
- }
204
-
205
- const graphData = {
206
- triangle: {
207
- effectType: "triangle",
208
- },
209
- line: {
210
- effectType: "line",
211
- },
212
- shape: {
213
- effectType: "shape",
214
- outLines: [],
215
- inLines: [],
216
- },
217
- text: {
218
- effectType: "text",
219
- },
220
- default: {
221
- isCustomElement: true,
222
- effectType: "svg",
223
- outLines: [],
224
- inLines: [],
225
- },
226
- };
227
-
228
- const assign = (object, type) => {
229
- const preData = JSON.parse(JSON.stringify(graphData));
230
- const data =
231
- type && preData[type]
232
- ? Object.assign(preData.default, preData[type])
233
- : preData.default;
234
- return Object.assign(object, {
235
- id: UUID(),
236
- data,
237
- });
238
- };
239
-
240
- var addCustomElement = (canvas, obj, type) => {
241
- obj = assign(obj, type);
242
- canvas.add(obj);
243
- canvas.renderAll();
244
- return obj;
245
- };
246
-
247
- // 同步上传img
248
-
249
- const LoadImg = (that, canvas, useFile, e) => {
250
- const loadFile = new Promise(async (res, rej) => {
251
- const url = that.opt.uploadFile?.customFun
252
- ? await that.opt.uploadFile?.customFun(useFile.file)
253
- : useFile.url;
254
- fabric.Image.fromURL(url, (img) => {
255
- img.id = util.UUID();
256
- const { left, top } = util.computedZoomXY(e, img, canvas);
257
- addCustomElement(
258
- canvas,
259
- img.set({
260
- left,
261
- top,
262
- angle: 0,
263
- })
264
- );
265
- img.crossOrigin = "Anonymous";
266
- setTimeout(() => {
267
- res(img);
268
- }, 10);
269
- });
270
- });
271
- return loadFile;
272
- }; // 同步上传SVG
273
-
274
- const loadSvg = (canvas, useFile, e, callBack) => {
275
- const loadFile = new Promise((res, rej) => {
276
- const groupSvg = (objects, options) => {
277
- const svg = fabric.util.groupSVGElements(objects);
278
- const { left, top } = util.computedZoomXY(e, svg, canvas);
279
- svg.set({
280
- left,
281
- top,
282
- });
283
- addCustomElement(canvas, svg); // 自定义上传svg 参数
284
-
285
- callBack ? callBack(svg) : "";
286
- res(svg);
287
- };
288
-
289
- fabric.loadSVGFromURL(useFile.url, (objects, options) => {
290
- groupSvg(objects);
291
- });
292
- });
293
- return loadFile;
294
- }; // 同步上传文件
295
-
296
- const asyncLoadFile = (that, canvas, useFile, e) => {
297
- if (useFile.fileExt === "svg") {
298
- return loadSvg(canvas, useFile, e);
299
- }
300
-
301
- return LoadImg(that, canvas, useFile, e);
302
- }; // 上传文件
303
-
304
- const LoadFile = (that, canvas, Files, e) => {
305
- const { useFile, dropData } = Files;
306
- const promiseList = [];
307
-
308
- if (dropData) {
309
- const fileExt = getExt(dropData.url);
310
- promiseList.push(
311
- loadSvg(
312
- canvas,
313
- {
314
- fileExt,
315
- url: dropData.url,
316
- },
317
- e,
318
- dropData.callBack
319
- )
320
- );
321
- } else {
322
- for (let i of useFile) {
323
- promiseList.push(asyncLoadFile(that, canvas, i, e));
324
- }
325
- }
326
-
327
- return Promise.all(promiseList);
328
- };
329
-
330
- var onDrop = (that, canvas) => {
331
- canvas.on("drop", (e) => {
332
- const event = e.e;
333
- event.preventDefault();
334
- const dataTransfer = event.dataTransfer;
335
- const files = dataTransfer.files;
336
- const useFile = util.file.getFiles(files);
337
- const dropData = dataTransfer.getData("dropData");
338
- LoadFile(
339
- that,
340
- canvas,
341
- {
342
- useFile,
343
- dropData: dropData ? JSON.parse(dropData) : null,
344
- },
345
- event
346
- );
347
- });
348
- };
349
-
350
- var pointConfig = {
351
- pointRadius: 7,
352
- };
353
-
354
- const getObjById = (canvas, id) => {
355
- const res = canvas.getObjects().find((ele) => {
356
- return ele.id === id;
357
- });
358
- return res;
359
- }; // 添加入的锚点
360
-
361
- const getInsertIndex = (canvas, line, x, y) => {
362
- let index = 0;
363
- let distance; // 两点之前直线最短
364
-
365
- for (let i = 0; i <= line.points.length - 2; i++) {
366
- const point1 = line.points[i];
367
- const point2 = line.points[i + 1];
368
- const num =
369
- Math.sqrt(Math.pow(x - point1.x, 2) + Math.pow(y - point1.y, 2)) +
370
- Math.sqrt(Math.pow(x - point2.x, 2) + Math.pow(y - point2.y, 2)) -
371
- Math.sqrt(
372
- Math.pow(point1.x - point2.x, 2) + Math.pow(point1.y - point2.y, 2)
373
- );
374
-
375
- if (!distance || num < distance) {
376
- distance = num;
377
- index = i;
378
- }
379
- }
380
-
381
- return index + 1;
382
- };
383
- const updateLine = (instance, line) => {
384
- instance.canvas.remove(line);
385
- const newLine = instance.draw.path({
386
- path: line.points,
387
- pathOpt: {
388
- stroke: line.stroke,
389
- },
390
- });
391
- newLine.id = line.id;
392
- newLine.data = line.data;
393
- newLine.lockMovementX = true;
394
- newLine.lockMovementY = true;
395
- return newLine;
396
- };
397
-
398
- let _REMOVEEVENTSTATE = false;
399
- var remove = (canvas, opt) => {
400
- const dom = document.getElementById(opt.boxElement);
401
-
402
- const removeTriOfLine = (obj) => {
403
- const triangle = canvas
404
- .getObjects()
405
- .find((ele) => ele.data.lineId === obj.id);
406
- canvas.remove(triangle);
407
- };
408
-
409
- const removeRelevance = (obj) => {
410
- if (obj.data?.effectType === "line") {
411
- removeTriOfLine(obj);
412
- }
413
-
414
- if (obj.data?.effectType === "svg") {
415
- [...(obj.data.outLines || []), ...(obj.data.inLines || [])]?.forEach(
416
- (id) => {
417
- const line = getObjById(canvas, id);
418
- canvas.remove(line);
419
- removeTriOfLine(line);
420
- }
421
- );
422
- }
423
- };
424
-
425
- dom.addEventListener("mouseover", () => {
426
- _REMOVEEVENTSTATE = true;
427
- });
428
- dom.addEventListener("mouseout", () => {
429
- _REMOVEEVENTSTATE = false;
430
- });
431
- window.addEventListener("keydown", (e) => {
432
- const isToRemove =
433
- (e.code === "Backspace" || e.code === "Delete") && _REMOVEEVENTSTATE;
434
-
435
- if (isToRemove) {
436
- const activeObjects = canvas.getActiveObjects();
437
-
438
- for (let i of activeObjects) {
439
- canvas.remove(i);
440
- removeRelevance(i);
441
- }
442
-
443
- canvas.renderAll();
444
- }
445
- });
446
- };
447
-
448
- const getAngle = (a, b) => {
449
- let res;
450
-
451
- if (a.x < b.x && a.y > b.y) {
452
- res = (Math.atan((b.y - a.y) / (a.x - b.x)) / Math.PI) * 180;
453
- } else if (a.x > b.x && a.y > b.y) {
454
- res = (Math.atan((b.y - a.y) / (a.x - b.x)) / Math.PI) * 180 + 180;
455
- } else if (a.x > b.x && a.y < b.y) {
456
- res = (Math.atan((b.y - a.y) / (a.x - b.x)) / Math.PI) * 180 + 180;
457
- } else if (a.x < b.x && a.y < b.y) {
458
- res = (Math.atan((b.y - a.y) / (a.x - b.x)) / Math.PI) * 180;
459
- }
460
-
461
- return res;
462
- };
463
-
464
- const updateTriangle = (canvas, line) => {
465
- const oldTri = getObjById(canvas, line.data.triangleId);
466
- const tri = getTriangle(line);
467
- oldTri.left = tri.left;
468
- oldTri.top = tri.top;
469
- oldTri.set("fill", line.stroke);
470
- oldTri.rotate(tri.angle);
471
- oldTri.selectable = false;
472
- oldTri.lockMovementX = true;
473
- oldTri.lockMovementY = true;
474
- canvas.renderAll();
475
- };
476
- const getTriangle = (line) => {
477
- const begin = line.points[line.points.length - 2];
478
- const end = line.points[line.points.length - 1];
479
- const angle = (getAngle(begin, end) - 90) * -1;
480
- const t = new fabric.Triangle({
481
- centeredRotation: true,
482
- fill: line.stroke,
483
- left: end.x - 7.5,
484
- top: end.y - 7.5,
485
- hasControls: false,
486
- hasBorders: false,
487
- lockMovementX: true,
488
- lockMovementY: true,
489
- selectable: false,
490
- width: 15,
491
- height: 15,
492
- });
493
- t.rotate(angle);
494
- return t;
495
- };
496
-
497
- const createLine = (instance) => {
498
- let tempLine;
499
- let beginObj;
500
- const canvas = instance.canvas;
501
- window.addEventListener("keydown", (e) => {
502
- const isShift = e.code === "ShiftLeft" || e.code === "ShiftRight";
503
-
504
- if (isShift) {
505
- instance.canvas.keydown = "shift";
506
- }
507
- });
508
- window.addEventListener("keyup", (e) => {
509
- instance.canvas.keydown = undefined;
510
- });
511
- canvas.on("mouse:down:before", (e) => {
512
- if (e.target) {
513
- beginObj = e.target; // 线编辑状态点块
514
-
515
- if (
516
- beginObj &&
517
- instance.state === "createLine" &&
518
- beginObj.data.effectType !== "line" &&
519
- beginObj.data.effectType !== "point"
520
- ) {
521
- computedZoomCoord(e.pointer.x, e.pointer.y, canvas);
522
- const beginPoint = beginObj.getCenterPoint();
523
- const newLine = new fabric.Path(
524
- [
525
- ["M", beginPoint.x, beginPoint.y],
526
- ["L", beginPoint.x, beginPoint.y],
527
- ],
528
- {
529
- fill: "",
530
- stroke: "black",
531
- objectCaching: false,
532
- strokeWidth: 3,
533
- strokeDashArray:
534
- canvas.createLineType === "broken" ? [0, 0, 12] : undefined,
535
- perPixelTargetFind: true,
536
- lockMovementX: true,
537
- lockMovementY: true,
538
- }
539
- );
540
- tempLine = newLine;
541
- canvas.add(newLine);
542
- canvas.renderAll();
543
- }
544
- } else {
545
- beginObj = undefined;
546
- }
547
- });
548
- canvas.on("mouse:move", (e) => {
549
- e.target; // 线预览
550
-
551
- if (
552
- instance.state === "createLine" &&
553
- beginObj &&
554
- beginObj.data.effectType !== "line" &&
555
- beginObj.data.effectType !== "point"
556
- ) {
557
- const xy = computedZoomCoord(e.pointer.x, e.pointer.y, canvas);
558
- const path = tempLine.path;
559
- path[1][1] = xy.left;
560
- path[1][2] = xy.top;
561
- canvas.renderAll();
562
- }
563
- });
564
- canvas.on("mouse:up", (e) => {
565
- const endObj = e.currentTarget; // 新连线
566
-
567
- if (
568
- instance.state === "createLine" &&
569
- endObj &&
570
- endObj?.data.effectType !== "line" &&
571
- endObj?.data.effectType !== "point" &&
572
- beginObj &&
573
- beginObj?.data.effectType !== "line" &&
574
- beginObj?.data.effectType !== "point" &&
575
- beginObj !== endObj
576
- ) {
577
- const beginPoint = beginObj.getCenterPoint();
578
- const endPoint = endObj.getCenterPoint();
579
- const data = {
580
- from: beginObj.id,
581
- fromExcursionX: 0,
582
- fromExcursionY: 0,
583
- to: endObj.id,
584
- toExcursionX: 0,
585
- toExcursionY: 0,
586
- };
587
- const line = instance.draw.path({
588
- path: [beginPoint, endPoint],
589
- });
590
- line.data = { ...line.data, ...data }; // 箭头
591
-
592
- const tri = getTriangle(line);
593
- const triangle = addCustomElement(instance.canvas, tri, "triangle");
594
- line.data.triangleId = triangle.id;
595
- triangle.data.lineId = line.id;
596
- triangle.data.effectType = "triangle";
597
- beginObj.data.outLines.push(line.id);
598
- endObj.data.inLines.push(line.id);
599
- beginObj = undefined;
600
- instance.setState("");
601
- }
602
-
603
- if (tempLine) {
604
- canvas.remove(tempLine);
605
- }
606
-
607
- tempLine = undefined;
608
- beginObj = undefined;
609
- });
610
- };
611
-
612
- const lineEvent = (instance) => {
613
- createLine(instance);
614
- let tempLine; // 点下标
615
-
616
- let addPointIndex;
617
- let pointIndex;
618
- const canvas = instance.canvas; // 都干完刷新一下线
619
-
620
- canvas.on("after:render", (e) => {
621
- canvas.getObjects().forEach((obj) => {
622
- if (obj.data?.effectType === "line") {
623
- if (obj.data?.needUpate) {
624
- obj.controls = fabric.Object.prototype.controls;
625
- obj.hasControls = false;
626
- updateLine(instance, obj);
627
- obj.data.needUpate = undefined;
628
- }
629
- }
630
- });
631
- });
632
- let beginObj;
633
- canvas.on("mouse:down:before", (e) => {
634
- if (e.target) {
635
- beginObj = e.target;
636
- const xy = computedZoomCoord(e.pointer.x, e.pointer.y, canvas);
637
- const active = canvas.getActiveObject(); // 点击选中后的线创建折点或者移动折点
638
-
639
- if (
640
- beginObj &&
641
- beginObj.data?.effectType === "line" &&
642
- active?.id === beginObj.id
643
- ) {
644
- const line = beginObj;
645
- line.lockMovementX = true;
646
- line.lockMovementY = true;
647
- line.points.forEach((p, index) => {
648
- if (Math.abs(p.x - xy.left) < 5 && Math.abs(p.y - xy.top) < 5) {
649
- pointIndex = index;
650
- }
651
- }); // 拖动折点
652
-
653
- if (pointIndex !== undefined) {
654
- // 首尾折点
655
- if (pointIndex !== 0 && pointIndex !== line.points.length - 1) {
656
- pointIndex = undefined;
657
- }
658
-
659
- return;
660
- }
661
-
662
- addPointIndex = getInsertIndex(canvas, line, xy.left, xy.top);
663
- line.points.splice(addPointIndex, 0, {
664
- x: xy.left,
665
- y: xy.top,
666
- });
667
- }
668
- } else {
669
- beginObj = undefined;
670
- }
671
- });
672
- canvas.on("mouse:move", (e) => {
673
- const obj = e.target;
674
- const active = canvas.getActiveObject(); // 创建折点跟随
675
-
676
- if (
677
- addPointIndex &&
678
- beginObj?.data.effectType === "line" &&
679
- active?.id === beginObj.id
680
- ) {
681
- const line = beginObj;
682
- const xy = computedZoomCoord(e.pointer.x, e.pointer.y, canvas);
683
-
684
- if (instance.canvas.keydown === "shift");
685
-
686
- line.points[addPointIndex].x = xy.left;
687
- line.points[addPointIndex].y = xy.top;
688
- } // 移动块
689
-
690
- if (
691
- instance.state !== "createLine" &&
692
- beginObj &&
693
- beginObj.data &&
694
- beginObj.data?.effectType !== "line" &&
695
- beginObj.data?.effectType !== "point"
696
- ) {
697
- const beginPoint = beginObj.getCenterPoint();
698
- beginObj.data.outLines?.forEach((lineId) => {
699
- const line = getObjById(canvas, lineId);
700
- line.points[0].x = beginPoint.x + line.data.fromExcursionX;
701
- line.points[0].y = beginPoint.y + line.data.fromExcursionY;
702
- updateTriangle(canvas, line);
703
- line.data.needUpate = true;
704
- });
705
- beginObj.data.inLines?.forEach((lineId) => {
706
- const line = getObjById(canvas, lineId);
707
- line.points[line.points.length - 1].x =
708
- beginPoint.x + line.data.toExcursionX + pointConfig.pointRadius;
709
- line.points[line.points.length - 1].y =
710
- beginPoint.y + line.data.toExcursionY + pointConfig.pointRadius;
711
- updateTriangle(canvas, line);
712
- line.data.needUpate = true;
713
- });
714
- } // 移动点
715
-
716
- if (
717
- instance.state !== "createLine" &&
718
- beginObj &&
719
- beginObj.data?.effectType === "line" &&
720
- obj?.data?.effectType === "line"
721
- ) {
722
- updateTriangle(canvas, beginObj);
723
- }
724
- });
725
- canvas.on("mouse:up", (e) => {
726
- e.currentTarget;
727
-
728
- if (canvas.getActiveObjects().length > 1) {
729
- canvas.getActiveObject().set("lockMovementX", true);
730
- canvas.getActiveObject().set("lockMovementY", true);
731
- } // 移动点
732
-
733
- if (pointIndex !== undefined && beginObj?.data.effectType === "line") {
734
- const line = beginObj;
735
- const point1 = new fabric.Circle({
736
- radius: 3,
737
- left: line.points[0].x,
738
- top: line.points[0].y,
739
- });
740
- const point2 = new fabric.Circle({
741
- radius: 3,
742
- left: line.points[line.points.length - 1].x,
743
- top: line.points[line.points.length - 1].y,
744
- });
745
- let newParent;
746
- canvas.getObjects().forEach((obj) => {
747
- if (obj.data.effectType === "shape" || obj.data.effectType === "svg") {
748
- if (
749
- obj.intersectsWithObject(point1) &&
750
- obj.data.outLines.indexOf(line.id) === -1
751
- ) {
752
- newParent = {
753
- type: "start",
754
- obj,
755
- };
756
- }
757
-
758
- if (
759
- obj.intersectsWithObject(point2) &&
760
- obj.data.inLines.indexOf(line.id) === -1
761
- ) {
762
- newParent = {
763
- type: "end",
764
- obj,
765
- };
766
- }
767
- }
768
- }); // 连接到新块
769
-
770
- if (newParent) {
771
- const beginPoint = newParent.obj.getCenterPoint();
772
-
773
- if (newParent.type === "start") {
774
- const oldRect = getObjById(canvas, line.data.from);
775
- oldRect.data.outLines.splice(
776
- oldRect.data.outLines.indexOf(line.id),
777
- 1
778
- );
779
- line.data.from = newParent.obj.id;
780
- line.data.fromExcursionX = 0;
781
- line.data.fromExcursionY = 0;
782
- line.points[0].x = beginPoint.x;
783
- line.points[0].y = beginPoint.y;
784
- newParent.obj.data.outLines.push(line.id);
785
- line.data.needUpate = true;
786
- } else if (newParent.type === "end") {
787
- const oldRect = getObjById(canvas, line.data.to);
788
- oldRect.data.inLines.splice(oldRect.data.inLines.indexOf(line.id), 1);
789
- line.data.to = newParent.obj.id;
790
- line.data.toExcursionX = 0;
791
- line.data.toExcursionY = 0;
792
- line.points[line.points.length - 1].x = beginPoint.x;
793
- line.points[line.points.length - 1].y = beginPoint.y;
794
- newParent.obj.data.inLines.push(line.id);
795
- line.data.needUpate = true;
796
- }
797
- } else {
798
- if (pointIndex === 0) {
799
- const rect = getObjById(canvas, line.data.from);
800
- const rectPoint = rect.getCenterPoint();
801
- line.data.fromExcursionX = e.pointer.x - rectPoint.x;
802
- line.data.fromExcursionY = e.pointer.y - rectPoint.y;
803
- } else {
804
- const rect = getObjById(canvas, line.data.to);
805
- const rectPoint = rect.getCenterPoint();
806
- line.data.toExcursionX = e.pointer.x - rectPoint.x;
807
- line.data.toExcursionY = e.pointer.y - rectPoint.y;
808
- }
809
- }
810
- } // 新点
811
-
812
- if (beginObj?.data?.effectType === "line" && addPointIndex !== undefined) {
813
- const line = beginObj;
814
- line.data.needUpate = true;
815
- }
816
-
817
- if (tempLine) {
818
- canvas.remove(tempLine);
819
- }
820
-
821
- tempLine = undefined;
822
- beginObj = undefined;
823
- addPointIndex = undefined;
824
- pointIndex = undefined;
825
- });
826
- };
827
-
828
- const shapeEvent = (instance) => {
829
- const canvas = instance.canvas; // 点下标
830
-
831
- let point;
832
- canvas.on("mouse:down:before", (e) => {
833
- point = computedZoomCoord(e.pointer.x, e.pointer.y, canvas);
834
- });
835
- canvas.on("mouse:up", (e) => {
836
- const endPoint = computedZoomCoord(e.pointer.x, e.pointer.y, canvas);
837
-
838
- if (instance.state !== "createShape") {
839
- return;
840
- }
841
-
842
- const rect = new fabric.Rect({
843
- left: Math.min(point.left, endPoint.left),
844
- top: Math.min(point.top, endPoint.top),
845
- fill: instance.config.shape.fill,
846
- stroke: instance.config.shape.stroke,
847
- strokeWidth: 2,
848
- width: Math.abs(point.left - endPoint.left),
849
- height: Math.abs(point.top - endPoint.top),
850
- });
851
- addCustomElement(canvas, rect, "shape");
852
- instance.setState("");
853
- });
854
- };
855
-
856
- const textEvent = (instance) => {
857
- const canvas = instance.canvas; // 点下标
858
-
859
- let point;
860
- canvas.on("mouse:down:before", (e) => {
861
- point = computedZoomCoord(e.pointer.x, e.pointer.y, canvas);
862
- });
863
- canvas.on("mouse:up", (e) => {
864
- computedZoomCoord(e.pointer.x, e.pointer.y, canvas);
865
-
866
- if (instance.state !== "createText") {
867
- return;
868
- }
869
-
870
- var itext = new fabric.IText("我是文本", {
871
- left: point.left,
872
- top: point.top,
873
- editable: false,
874
- fill: "#354052",
875
- lockScalingX: true,
876
- lockScalingY: true,
877
- strokeWidth: 0,
878
- stroke: "#880E4F",
879
- });
880
- addCustomElement(canvas, itext, "text");
881
- instance.setState("");
882
- });
883
- };
884
-
885
- var lockMove = (canvas) => {
886
- let shiftKey = false;
887
- let altKey = false;
888
- canvas.on("mouse:down:before", (e) => {
889
- shiftKey = e.e.shiftKey;
890
- altKey = e.e.altKey;
891
-
892
- if (shiftKey && altKey && e.target) {
893
- // 锁定 Y轴移动
894
- e.target.lockMovementX = true;
895
- } else if (shiftKey && !altKey && e.target) {
896
- // 锁定X轴移动
897
- e.target.lockMovementY = true;
898
- }
899
- });
900
- canvas.on("mouse:up:before", (e) => {
901
- shiftKey = false;
902
- altKey = false;
903
-
904
- if (e.target) {
905
- // 解锁 Y轴移动
906
- e.target.lockMovementX = false; // 解锁 X轴移动
907
-
908
- e.target.lockMovementY = false;
909
- }
910
- });
911
- };
912
-
913
- function Event(canvas, opt) {
914
- // 拖动上传
915
- onDrop(this, canvas); // 缩放
916
-
917
- canvasChangeZoom(canvas); // 画布拖动
918
-
919
- canvasMove.bind(this)(canvas); // 删除方法
920
-
921
- remove(canvas, opt); // 辅助线
922
-
923
- const guideline = new AlignGuidelines({
924
- canvas,
925
- });
926
- guideline.init(); // 线相关事件
927
-
928
- lineEvent(this); // 创建矩形
929
-
930
- shapeEvent(this); // 创建文字
931
-
932
- textEvent(this);
933
-
934
- if (opt && opt.isPreview) {
935
- (function render() {
936
- canvas.renderAll();
937
- fabric.util.requestAnimFrame(render);
938
- })();
939
- } // cp Event
940
- // cp(canvas);
941
- // 锁定轴移动块
942
-
943
- lockMove(canvas);
944
- }
945
-
946
- var LineState;
947
-
948
- (function (LineState) {
949
- LineState["RAW_COAL"] = "#EA5858";
950
- LineState["CLEAN_COAL"] = "#22CC83";
951
- LineState["PRODUCT"] = "#22CC83";
952
- LineState["REJECT"] = "#6554C0";
953
- LineState["SLURRY"] = "#A52337";
954
- LineState["DILUTE_MEDIUM"] = "#9095A2";
955
- LineState["CORRECT_MEDIUM"] = "#354052";
956
- LineState["DENSE_MEDIUM"] = "#354052";
957
- LineState["MIDDLINGS"] = "#FF9214";
958
- LineState["SLIME"] = "#729918";
959
- LineState["CLARIFIED_WATER"] = " #1CDDEB";
960
- LineState["AIR"] = "#D439D4";
961
- })(LineState || (LineState = {}));
962
-
963
- var line = {
964
- fill: "transparent",
965
- stroke: "#354052",
966
- strokeWidth: 3,
967
- };
968
-
969
- var shape = {
970
- fill: "#f9fafb",
971
- stroke: "#DCE2ED",
972
- };
973
-
974
- var config = {
975
- line,
976
- shape,
977
- canvas: {
978
- bc: "transparent",
979
- },
980
- };
981
-
982
- const addControl = (poly) => {
983
- var lastControl = poly.points.length - 1;
984
- poly.cornerStyle = "circle";
985
- poly.cornerColor = "red";
986
- poly.controls = poly.points.reduce(function (acc, point, index) {
987
- acc["p" + index] = new fabric.Control({
988
- positionHandler: polygonPositionHandler,
989
- actionHandler: anchorWrapper(
990
- index > 0 ? index - 1 : lastControl,
991
- actionHandler
992
- ),
993
- actionName: "modifyPolygon",
994
- pointIndex: index,
995
- });
996
- return acc;
997
- }, {});
998
- }; // 返回控制点
999
-
1000
- function polygonPositionHandler(dim, finalMatrix, fabricObject) {
1001
- var x = fabricObject.points[this.pointIndex].x - fabricObject.pathOffset.x,
1002
- y = fabricObject.points[this.pointIndex].y - fabricObject.pathOffset.y;
1003
- return fabric.util.transformPoint(
1004
- {
1005
- x: x,
1006
- y: y,
1007
- },
1008
- fabric.util.multiplyTransformMatrices(
1009
- fabricObject.canvas.viewportTransform,
1010
- fabricObject.calcTransformMatrix()
1011
- )
1012
- );
1013
- }
1014
-
1015
- function getObjectSizeWithStroke(object) {
1016
- var stroke = new fabric.Point(
1017
- object.strokeUniform ? 1 / object.scaleX : 1,
1018
- object.strokeUniform ? 1 / object.scaleY : 1
1019
- ).multiply(object.strokeWidth);
1020
- return new fabric.Point(object.width + stroke.x, object.height + stroke.y);
1021
- } // define a function that will define what the control does
1022
- // this function will be called on every mouse move after a control has been
1023
- // clicked and is being dragged.
1024
- // The function receive as argument the mouse event, the current trasnform object
1025
- // and the current position in canvas coordinate
1026
- // transform.target is a reference to the current object being transformed,
1027
-
1028
- function actionHandler(eventData, transform, x, y) {
1029
- var polygon = transform.target,
1030
- currentControl = polygon.controls[polygon.__corner],
1031
- mouseLocalPosition = polygon.toLocalPoint(
1032
- new fabric.Point(x, y),
1033
- "center",
1034
- "center"
1035
- ),
1036
- polygonBaseSize = getObjectSizeWithStroke(polygon),
1037
- size = polygon._getTransformedDimensions(0, 0),
1038
- finalPointPosition = {
1039
- x:
1040
- (mouseLocalPosition.x * polygonBaseSize.x) / size.x +
1041
- polygon.pathOffset.x,
1042
- y:
1043
- (mouseLocalPosition.y * polygonBaseSize.y) / size.y +
1044
- polygon.pathOffset.y,
1045
- };
1046
-
1047
- polygon.points[currentControl.pointIndex] = finalPointPosition;
1048
- return true;
1049
- } // define a function that can keep the polygon in the same position when we change its
1050
- // width/height/top/left.
1051
-
1052
- function anchorWrapper(anchorIndex, fn) {
1053
- return function (eventData, transform, x, y) {
1054
- var fabricObject = transform.target,
1055
- absolutePoint = fabric.util.transformPoint(
1056
- {
1057
- x: fabricObject.points[anchorIndex].x - fabricObject.pathOffset.x,
1058
- y: fabricObject.points[anchorIndex].y - fabricObject.pathOffset.y,
1059
- },
1060
- fabricObject.calcTransformMatrix()
1061
- ),
1062
- actionPerformed = fn(eventData, transform, x, y);
1063
- fabricObject._setPositionDimensions({});
1064
- var polygonBaseSize = getObjectSizeWithStroke(fabricObject),
1065
- newX =
1066
- (fabricObject.points[anchorIndex].x - fabricObject.pathOffset.x) /
1067
- polygonBaseSize.x,
1068
- newY =
1069
- (fabricObject.points[anchorIndex].y - fabricObject.pathOffset.y) /
1070
- polygonBaseSize.y;
1071
-
1072
- fabricObject.setPositionByOrigin(absolutePoint, newX + 0.5, newY + 0.5);
1073
- return actionPerformed;
1074
- };
1075
- }
1076
-
1077
- const path = function (opt) {
1078
- if (!opt.pathOpt) {
1079
- opt.pathOpt = {
1080
- stroke: config.line.stroke,
1081
- strokeWidth: config.line.strokeWidth,
1082
- };
1083
- } else {
1084
- if (!opt.pathOpt?.stroke) opt.pathOpt.stroke = config.line.stroke;
1085
- if (!opt.pathOpt?.strokeWidth)
1086
- opt.pathOpt.strokeWidth = config.line.strokeWidth;
1087
- }
1088
-
1089
- const polyline = new fabric.Polyline(opt.path, {
1090
- ...opt.pathOpt,
1091
- fill: "transparent",
1092
- lockMovementX: true,
1093
- lockMovementY: true,
1094
- objectCaching: false,
1095
- hasBorders: false,
1096
- perPixelTargetFind: true,
1097
- });
1098
- addControl(polyline);
1099
- return addCustomElement(this.canvas, polyline, "line");
1100
- };
1101
-
1102
- const text = function (opt) {
1103
- const svg = getObjById(this.canvas, opt.parentId);
1104
- const newText = new fabric.IText(opt.name, {
1105
- editable: false,
1106
- fill: "black",
1107
- top: svg.top - 30,
1108
- left: svg.left,
1109
- lockScalingX: true,
1110
- lockScalingY: true,
1111
- ...opt.option,
1112
- });
1113
- return addCustomElement(this.canvas, newText, "text");
1114
- };
1115
-
1116
- function Draw() {
1117
- return {
1118
- path: path.bind(this),
1119
- text: text.bind(this),
1120
- };
1121
- }
1122
-
1123
- /**
1124
- * 线段动画 需优化obo运动
1125
- */
1126
-
1127
- class LineAnimate {
1128
- constructor(opt, canvas) {
1129
- this.lineAnimateList = opt;
1130
- this.canvas = canvas;
1131
- }
1132
-
1133
- canvas;
1134
- lineAnimateList;
1135
-
1136
- oboRun(speed) {}
1137
-
1138
- oboStop(speed) {}
1139
-
1140
- start(item) {
1141
- let index = 0;
1142
-
1143
- this.canvas._onObjectRemoved = (e) => {
1144
- if (item.object === e) item.cycle = false;
1145
- };
1146
-
1147
- item.object.set("stroke", LineState[item.state] || "black");
1148
-
1149
- const run = () => {
1150
- const speed = item.speed || 1;
1151
-
1152
- if (item.direction === "negative") {
1153
- index = speed;
1154
- } else {
1155
- index -= speed;
1156
- }
1157
-
1158
- item.object.animate(
1159
- {
1160
- strokeDashOffset: index,
1161
- },
1162
- {
1163
- duration: 60,
1164
- onComplete: () => {
1165
- if (item.cycle) {
1166
- run();
1167
- }
1168
- },
1169
- easing: (t, b, c, d) => {
1170
- return (c * t) / d + b;
1171
- },
1172
- }
1173
- );
1174
- };
1175
-
1176
- run();
1177
- } // 添加动画
1178
-
1179
- addLineAnimate(item) {
1180
- this.lineAnimateList.push(item);
1181
- this.start(item);
1182
- } // 启动所有动画
1183
-
1184
- startAll() {
1185
- for (let i of this.lineAnimateList) {
1186
- this.start(i);
1187
- }
1188
- } // 关闭所有动画
1189
-
1190
- stopAll() {
1191
- for (let i of this.lineAnimateList) {
1192
- i.cycle = false;
1193
- }
1194
-
1195
- this.lineAnimateList = [];
1196
- } // 关闭某个动画
1197
-
1198
- stop(item) {
1199
- item.cycle = false;
1200
-
1201
- for (let i = 0; i < this.lineAnimateList.length; i++) {
1202
- if (this.lineAnimateList[i].object === item.object) {
1203
- this.lineAnimateList.splice(1, i);
1204
- }
1205
- }
1206
- }
1207
- }
1208
-
1209
- var Alignparam;
1210
-
1211
- (function (Alignparam) {
1212
- Alignparam[(Alignparam["top"] = 0)] = "top";
1213
- Alignparam[(Alignparam["left"] = 1)] = "left";
1214
- Alignparam[(Alignparam["right"] = 2)] = "right";
1215
- Alignparam[(Alignparam["bottom"] = 3)] = "bottom";
1216
- Alignparam[(Alignparam["horizontal_center"] = 4)] = "horizontal_center";
1217
- Alignparam[(Alignparam["vertical_center"] = 5)] = "vertical_center";
1218
- Alignparam[(Alignparam["horizontal_distribution"] = 6)] =
1219
- "horizontal_distribution";
1220
- Alignparam[(Alignparam["vertical_distribution"] = 7)] =
1221
- "vertical_distribution";
1222
- })(Alignparam || (Alignparam = {}));
1223
-
1224
- var Levels;
1225
-
1226
- (function (Levels) {
1227
- Levels["top"] = "bringToFront";
1228
- Levels["bottom"] = "sendToBack";
1229
- Levels["before"] = "bringForward";
1230
- Levels["after"] = "sendBackwards";
1231
- })(Levels || (Levels = {}));
1232
-
1233
- /**
1234
- *
1235
- * @param canvas canvas
1236
- * @param alignparam 对齐方向
1237
- */
1238
- const fabricItemAlign = function (alignparam) {
1239
- const canvas = this.canvas;
1240
- const canvasObjectsGrop = canvas.getActiveObject();
1241
-
1242
- const getProperty = (cGrop = canvasObjectsGrop) => {
1243
- return {
1244
- gropObjs: cGrop._objects ?? [],
1245
- gropWidth: cGrop.width ?? 0,
1246
- gropHeight: cGrop.height ?? 0,
1247
- };
1248
- };
1249
-
1250
- if (canvas.getActiveObjects().length <= 1) return;
1251
- const { gropObjs, gropWidth, gropHeight } = getProperty();
1252
-
1253
- if (alignparam === 0) {
1254
- // 顶对齐
1255
- gropObjs.forEach((item) => {
1256
- // 顶对齐算法:top为零表示 依据选中框顶部对齐, left 为 选中点每一项的
1257
- item.set({
1258
- top: 0 - gropHeight * 0.5,
1259
- });
1260
- });
1261
- } // 左对齐
1262
-
1263
- if (alignparam === 1) {
1264
- gropObjs.forEach((item) => {
1265
- item.set({
1266
- left: 0 - gropWidth * 0.5,
1267
- });
1268
- });
1269
- } // 右对齐
1270
-
1271
- if (alignparam === 2) {
1272
- gropObjs.forEach((item) => {
1273
- item.set({
1274
- left: gropWidth - (item.width ?? 0) * item.scaleX - gropWidth * 0.5,
1275
- });
1276
- });
1277
- } // 底对齐
1278
-
1279
- if (alignparam === 3) {
1280
- gropObjs.forEach((item) => {
1281
- item.set({
1282
- top: gropHeight - (item.height ?? 0) * item.scaleY - gropHeight * 0.5,
1283
- });
1284
- });
1285
- } // 水平居中对齐
1286
-
1287
- if (alignparam === 4) {
1288
- gropObjs.forEach((item) => {
1289
- item.set({
1290
- top: 0 - (item.height ?? 0) * item.scaleY * 0.5,
1291
- });
1292
- });
1293
- } // 垂直居中对齐
1294
-
1295
- if (alignparam === 5) {
1296
- gropObjs.forEach((item) => {
1297
- item.set({
1298
- left: 0 - (item.width ?? 0) * item.scaleX * 0.5,
1299
- });
1300
- });
1301
- } // 水平分布对齐
1302
-
1303
- if (alignparam === 6) {
1304
- let groupWidth = gropWidth;
1305
- gropObjs.forEach((item) => {
1306
- groupWidth -= (item.width ?? 0) * item.scaleX;
1307
- });
1308
- const gap = groupWidth / (gropObjs.length - 1 || 1);
1309
- gropObjs.forEach((item, idx) => {
1310
- if (idx > 0) {
1311
- item.set({
1312
- left:
1313
- (gropObjs[idx - 1].left ?? 0) +
1314
- (gropObjs[idx - 1].width ?? 0) * gropObjs[idx - 1].scaleX +
1315
- gap,
1316
- });
1317
- } else {
1318
- item.set({
1319
- left: 0 - gropWidth / 2,
1320
- });
1321
- }
1322
- });
1323
- } // 垂直分布对齐
1324
-
1325
- if (alignparam === 7) {
1326
- let groupHeight = gropHeight;
1327
- gropObjs.forEach((item) => {
1328
- groupHeight -= (item.height ?? 0) * item.scaleY;
1329
- });
1330
- const gap = groupHeight / (gropObjs.length - 1 || 1);
1331
- gropObjs.forEach((item, idx) => {
1332
- if (idx > 0) {
1333
- item.set({
1334
- top:
1335
- (gropObjs[idx - 1].top ?? 0) +
1336
- (gropObjs[idx - 1].height ?? 0) * gropObjs[idx - 1].scaleY +
1337
- gap,
1338
- });
1339
- } else {
1340
- item.set({
1341
- top: 0 - gropHeight / 2,
1342
- });
1343
- }
1344
- });
1345
- } // 其他对齐规则拓展 ......
1346
-
1347
- canvas.renderAll(); // 重新渲染
1348
- };
1349
-
1350
- const setLevel = function (idOrEle, level) {
1351
- const canvas = this.canvas;
1352
- const obj =
1353
- typeof idOrEle === "string" ? getObjById(canvas, idOrEle) : idOrEle;
1354
- const fun = Levels[level];
1355
-
1356
- if (obj) {
1357
- obj[fun]();
1358
- }
1359
-
1360
- canvas.renderAll(); // 重新渲染
1361
-
1362
- return obj;
1363
- };
1364
-
1365
- function zoomToFitCanvas(canvas) {
1366
- //遍历所有对对象,获取最小坐标,最大坐标
1367
- const objects = canvas.getObjects();
1368
- let rect = objects[0].getBoundingRect();
1369
- let minX = rect.left;
1370
- let minY = rect.top;
1371
- let maxX = rect.left + rect.width;
1372
- let maxY = rect.top + rect.height;
1373
-
1374
- if (objects.length > 0) {
1375
- for (let i = 1; i < objects.length; i++) {
1376
- rect = objects[i].getBoundingRect();
1377
- minX = Math.min(minX, rect.left);
1378
- minY = Math.min(minY, rect.top);
1379
- maxX = Math.max(maxX, rect.left + rect.width);
1380
- maxY = Math.max(maxY, rect.top + rect.height);
1381
- }
1382
- } //计算平移坐标
1383
-
1384
- const panX = (maxX - minX - canvas.width) / 2 + minX;
1385
- const panY = (maxY - minY - canvas.height) / 2 + minY;
1386
- const { left, top } = computedZoomCoord(panX, panY, canvas); //开始平移
1387
-
1388
- canvas.absolutePan({
1389
- x: left,
1390
- y: top,
1391
- }); //计算缩放比例
1392
-
1393
- const zoom = Math.min(
1394
- canvas.width / (maxX - minX),
1395
- canvas.height / (maxY - minY)
1396
- ); //计算缩放中心
1397
-
1398
- const zoomPoint = new fabric.Point(canvas.width / 2, canvas.height / 2); //开始缩放
1399
-
1400
- canvas.zoomToPoint(zoomPoint, zoom * 0.8);
1401
- }
1402
-
1403
- class windowResize {
1404
- constructor(opt) {
1405
- this.opt = opt;
1406
- this.canvas = opt.canvas;
1407
- this.domInfo = getWindowInfo(opt.id);
1408
- this.init();
1409
- this.watchDivChange();
1410
- }
1411
-
1412
- opt;
1413
-
1414
- watchDivChange() {
1415
- const dom = document.getElementById(this.opt.id);
1416
- let tm;
1417
- const resizeObserver = new ResizeObserver((entries) => {
1418
- if (tm) clearTimeout(tm);
1419
- tm = setTimeout(() => {
1420
- this.todo();
1421
- }, 100);
1422
- });
1423
- resizeObserver.observe(dom);
1424
- }
1425
-
1426
- init() {
1427
- const { width, height } = this.domInfo();
1428
- this.canvas.setWidth(width);
1429
- this.canvas.setHeight(height);
1430
- }
1431
-
1432
- todo(cb) {
1433
- this.init();
1434
- const callBack = this.opt.cb || cb;
1435
- const { width, height } = this.domInfo();
1436
- callBack ? callBack(width, height, this.canvas) : "";
1437
- }
1438
-
1439
- canvas;
1440
- domInfo;
1441
- }
1442
-
1443
- function renderGrid(canvas) {
1444
- const width = canvas.width;
1445
- const height = canvas.height;
1446
- let line;
1447
- let rect = [];
1448
- let size = 20;
1449
-
1450
- for (let i = 0; i < Math.ceil(width / 20); ++i) {
1451
- rect[0] = i * size;
1452
- rect[1] = 0;
1453
- rect[2] = i * size;
1454
- rect[3] = height;
1455
- line = null;
1456
- line = new fabric.Line(rect, {
1457
- stroke: "#999",
1458
- opacity: 0.5,
1459
- });
1460
- line.rowName = "grid";
1461
- line.selectable = false;
1462
- canvas.add(line);
1463
- line.sendToBack();
1464
- }
1465
-
1466
- for (let i = 0; i < Math.ceil(height / 20); ++i) {
1467
- rect[0] = 0;
1468
- rect[1] = i * size;
1469
- rect[2] = width;
1470
- rect[3] = i * size;
1471
- line = null;
1472
- line = new fabric.Line(rect, {
1473
- stroke: "#999",
1474
- opacity: 0.5,
1475
- });
1476
- line.rowName = "grid";
1477
- line.selectable = false;
1478
- canvas.add(line);
1479
- line.sendToBack();
1480
- }
1481
-
1482
- canvas.renderAll();
1483
- }
1484
-
1485
- class Grid {
1486
- constructor(opt) {
1487
- this.opt = opt;
1488
- this.init();
1489
- }
1490
-
1491
- idName = "inl-tp-editor-grid";
1492
- idBoxName = "inl-tp-editor-grid-box";
1493
- renderState = false;
1494
-
1495
- init() {
1496
- this.resetOpt();
1497
- this.addElement();
1498
- }
1499
-
1500
- renderGrid() {
1501
- renderGrid(this.canvas);
1502
- }
1503
-
1504
- clearGrid() {
1505
- for (let i of this.canvas.getObjects()) {
1506
- if (i.rowName === "grid") {
1507
- this.canvas.remove(i);
1508
- }
1509
- }
1510
-
1511
- this.renderState = false;
1512
- }
1513
-
1514
- changeBackground(s, cb) {
1515
- this.canvas.setBackgroundColor(s, () => {
1516
- cb ? cb() : "";
1517
- this.canvas.renderAll();
1518
- });
1519
- }
1520
-
1521
- resetGrid() {
1522
- this.clearGrid();
1523
- this.renderGrid();
1524
- this.renderState = true;
1525
- }
1526
-
1527
- resetOpt() {}
1528
-
1529
- addElement() {
1530
- const boxDom = document.getElementById(this.opt.boxId);
1531
- const GridCanvasDom = createElementId(this.idName, this.idName, "canvas");
1532
- const GridCanvasBoxDom = createElementId(this.idBoxName, this.idBoxName);
1533
- GridCanvasBoxDom.appendChild(GridCanvasDom);
1534
- GridCanvasBoxDom.setAttribute(
1535
- "style",
1536
- `position:absolute; top: ${this.opt.scaleHd}px; left: ${this.opt.scaleHd}px; right: 0; bottom: 0; z-index: 0;`
1537
- );
1538
- boxDom.appendChild(GridCanvasBoxDom);
1539
- this.canvas = new fabric.Canvas(this.idName);
1540
- new windowResize({
1541
- canvas: this.canvas,
1542
- id: this.idBoxName,
1543
- cb: () => {
1544
- if (this.renderState) {
1545
- this.resetGrid();
1546
- }
1547
- },
1548
- });
1549
- }
1550
- }
1551
-
1552
- const mtipSvgCustomData = function () {
1553
- return {
1554
- data: this.data || {},
1555
- id: this.id,
1556
- };
1557
- };
1558
-
1559
- const resetFabric = () => {
1560
- const newList = [
1561
- "Line",
1562
- "Polyline",
1563
- "Triangle",
1564
- "Group",
1565
- "Rect",
1566
- "Point",
1567
- "Path",
1568
- "Circle",
1569
- "Textbox",
1570
- "Image",
1571
- "Text",
1572
- "IText",
1573
- ];
1574
-
1575
- for (let i of newList) {
1576
- fabric[i].prototype["toObject"] = (function (toObject) {
1577
- return function () {
1578
- return fabric.util.object.extend(
1579
- toObject.call(this),
1580
- mtipSvgCustomData.call(this)
1581
- );
1582
- };
1583
- })(fabric[i].prototype["toObject"]);
1584
- }
1585
- };
1586
-
1587
- function loadJsonString(s, cb) {
1588
- this.canvas.clear(); // 简单辨型
1589
-
1590
- const loadData = typeof s === "string" ? JSON.parse(s) : s;
1591
- this.canvas.loadFromJSON(loadData, (objeats) => {
1592
- this.canvas._objects.forEach((item, key) => {
1593
- if (this.opt.isPreview) {
1594
- item.selectable = false;
1595
- const isLine = item.data && item.data.effectType === "";
1596
- const triangle = item.data && item.data.effectType === "";
1597
-
1598
- if (isLine && triangle) {
1599
- this.setLevel(item, Levels.top);
1600
- }
1601
- } else {
1602
- if (item.data.effectType === "line") {
1603
- updateLine(this, item);
1604
- }
1605
- }
1606
- });
1607
-
1608
- cb ? cb() : "";
1609
- });
1610
- }
1611
-
1612
- class Scale {
1613
- constructor(opt) {
1614
- this.resetOpt(opt);
1615
- this.init();
1616
- }
1617
-
1618
- idxbx = "inl-editor-scale-x";
1619
- idybx = "inl-editor-scale-y";
1620
- idx = "inl-editor-scale-x-c";
1621
- idy = "inl-editor-scale-y-c"; // 标尺厚度
1622
-
1623
- scaleHou = 15;
1624
-
1625
- init() {
1626
- this.addElement();
1627
- this.createScaleCanvas();
1628
-
1629
- this._renderScale();
1630
- }
1631
-
1632
- resetOpt(opt) {
1633
- this.scaleHou = opt.scaleHou || 15;
1634
- const useOpt = Object.assign(
1635
- {},
1636
- {
1637
- width: this.scaleHou,
1638
- height: this.scaleHou,
1639
- bcoler: "#fff",
1640
- },
1641
- opt
1642
- );
1643
- this.opt = useOpt;
1644
- }
1645
-
1646
- renderAfter() {
1647
- this.scaleX.setBackgroundColor(this.opt.bcoler, () => {});
1648
- this.scaleY.setBackgroundColor(this.opt.bcoler, () => {});
1649
- } // 添加元素
1650
-
1651
- addElement() {
1652
- const boxDom = document.getElementById(this.opt.boxId);
1653
- boxDom.setAttribute("style", `position: relative; `);
1654
- const scaleX = createElementId("inl-editor-scale-x", "inl-editor-scale-x");
1655
- const scaleY = createElementId("inl-editor-scale-y", "inl-editor-scale-y");
1656
- const scaleCX = createElementId("inl-editor-scale-x-c", this.idx, "canvas");
1657
- const scaleCY = createElementId("inl-editor-scale-y-c", this.idy, "canvas");
1658
- scaleX.setAttribute(
1659
- "style",
1660
- `height: ${this.opt.height}px; position: absolute;z-index:1; top: 0; left:${this.opt.height}px; right:0; overflow:hidden;`
1661
- );
1662
- scaleY.setAttribute(
1663
- "style",
1664
- ` width: ${this.opt.width}px; position: absolute;z-index:1; top: ${this.opt.width}px; left: 0; bottom:0; overflow:hidden;`
1665
- );
1666
- boxDom.appendChild(scaleX);
1667
- boxDom.appendChild(scaleY);
1668
- scaleX.appendChild(scaleCX);
1669
- scaleY.appendChild(scaleCY);
1670
- }
1671
-
1672
- scaleX;
1673
- scaleY; // 创建刻度元素
1674
-
1675
- createScaleCanvas() {
1676
- const scaleX = new fabric.Canvas(this.idx);
1677
- const scaleY = new fabric.Canvas(this.idy);
1678
- this.scaleX = scaleX;
1679
- this.scaleY = scaleY;
1680
- new windowResize({
1681
- canvas: scaleX,
1682
- id: this.idxbx,
1683
- });
1684
- new windowResize({
1685
- canvas: scaleY,
1686
- id: this.idybx,
1687
- });
1688
- this.renderAfter();
1689
- return {
1690
- scaleX,
1691
- scaleY,
1692
- };
1693
- } // 渲染刻度
1694
-
1695
- _renderScale() {
1696
- const zoom = this.opt.drawCanvas.getZoom();
1697
- const cheight = this.opt.drawCanvas.getHeight();
1698
- const cwidth = this.opt.drawCanvas.getWidth();
1699
- this.opt.drawCanvas.viewportTransform[4];
1700
- this.opt.drawCanvas.viewportTransform[5];
1701
- const sl = this.scaleHou * 0.6;
1702
- const bl = this.scaleHou;
1703
- const xLength = cwidth * zoom * 0.6;
1704
- const yLength = cheight * zoom; // 先不做运动计算
1705
-
1706
- const createLineInfo = (i, isX) => {
1707
- const rect = [0, 0, 0, 0];
1708
- const val = i + 1;
1709
- const strokeWidth = val % 10 === 0 && i !== 0 ? 1 : 1;
1710
- const opacity = val % 10 === 0 && i !== 0 ? 1 : 1;
1711
- const text = new fabric.Text(val % 10 === 0 ? val + "" : "");
1712
- text.fontSize = 8;
1713
- text.fill = "#354052";
1714
-
1715
- if (isX) {
1716
- rect[0] = i * 10;
1717
- rect[1] = bl;
1718
- rect[2] = i * 10;
1719
- rect[3] = val % 10 ? sl : 0;
1720
- text.set({
1721
- top: -2,
1722
- left: rect[0] + 1,
1723
- });
1724
- } else {
1725
- rect[0] = val % 10 ? sl : 0;
1726
- rect[1] = i * 10;
1727
- rect[2] = bl;
1728
- rect[3] = i * 10;
1729
- text.set({
1730
- top: rect[3],
1731
- left: 0,
1732
- });
1733
- }
1734
-
1735
- const line = new fabric.Line(rect, {
1736
- stroke: "#F2F3F8",
1737
- strokeWidth,
1738
- opacity,
1739
- });
1740
- line.selectable = false;
1741
- return {
1742
- line,
1743
- text,
1744
- };
1745
- }; // x 轴
1746
-
1747
- for (let i = -xLength; i <= xLength; i++) {
1748
- const { line, text } = createLineInfo(i, true);
1749
- this.scaleX.add(line, text);
1750
- } // y轴
1751
-
1752
- for (let i = -yLength; i <= yLength; i++) {
1753
- const { line, text } = createLineInfo(i, false);
1754
- this.scaleY.add(line, text);
1755
- }
1756
-
1757
- this.scaleX.renderAll(); // 绘制网格尺
1758
- }
1759
-
1760
- renderScale(cb) {
1761
- this._renderScale();
1762
-
1763
- if (cb) {
1764
- cb();
1765
- }
1766
- }
1767
-
1768
- clear() {
1769
- this.scaleX.clear();
1770
- this.scaleY.clear();
1771
- }
1772
-
1773
- setVpt(x, y, evt) {
1774
- this.scaleX.viewportTransform[4] = x;
1775
- this.scaleY.viewportTransform[5] = y;
1776
- this.scaleX.renderAll();
1777
- this.scaleY.renderAll();
1778
- this.scaleX.lastPosX = evt.clientX;
1779
- this.scaleY.lastPosY = evt.clientY;
1780
- }
1781
-
1782
- move() {}
1783
- }
1784
-
1785
- const updateImg = (canvas, id, src) => {
1786
- const rect = getObjById(canvas, id);
1787
- fabric.loadSVGFromURL(
1788
- src || "/images/device/长皮带_2D_红.svg", // "/api/thing/v1/photo/thing4218B0244E0C4083B88E574F7F038C1E.svg",
1789
- (objects, options) => {
1790
- const svg = fabric.util.groupSVGElements(objects);
1791
- svg.id = rect.id;
1792
- svg.data = rect.data;
1793
- svg.top = rect.top;
1794
- svg.left = rect.left;
1795
- svg.angle = rect.angle;
1796
- canvas.remove(rect);
1797
- canvas.add(svg);
1798
- canvas.renderAll();
1799
- }
1800
- );
1801
- }; // 提供更新块上文字的方法
1802
-
1803
- const updateState = (canvas, id, value, isPropertyName) => {
1804
- const obj = getObjById(canvas, id);
1805
-
1806
- if (obj.text.indexOf(":") > -1) {
1807
- const arr = obj.text.split(":");
1808
- obj.text = isPropertyName ? `${arr[0]}:` : value;
1809
- } else {
1810
- obj.text = value;
1811
- }
1812
-
1813
- canvas.renderAll();
1814
- };
1815
-
1816
- class inlTpEditor {
1817
- constructor(opt) {
1818
- this.opt = opt;
1819
- this.config = { ...config, ...opt.config };
1820
- this.init();
1821
- }
1822
-
1823
- elementId = "inl-editor-canvas" + UUID(8);
1824
- enums = {
1825
- Alignparam,
1826
- LineState,
1827
- Levels,
1828
- };
1829
-
1830
- newCanvas() {
1831
- const canvasDomBox = createElementId(
1832
- this.elementId + "-box",
1833
- this.elementId + "-box"
1834
- );
1835
- const canvasDm = createElementId(this.elementId, this.elementId, "canvas");
1836
- const boxDom = document.getElementById(this.opt.boxElement);
1837
- canvasDomBox.setAttribute(
1838
- "style",
1839
- `position: absolute; top: ${this.opt.scaleHd || 15}px; left: ${
1840
- this.opt.scaleHd || 15
1841
- }px; right: 0; bottom: 0;z-index:1;`
1842
- );
1843
- canvasDomBox.appendChild(canvasDm);
1844
- boxDom.appendChild(canvasDomBox);
1845
- this.canvas = new fabric.Canvas(this.elementId, {
1846
- preserveObjectStacking: true,
1847
- ...this.opt.fConfig,
1848
- }); // 根据外部盒子控制 canvas大小
1849
-
1850
- new windowResize({
1851
- canvas: this.canvas,
1852
- id: this.opt.boxElement,
1853
- });
1854
- } // 所有包裹元素 刻度尺和canvas
1855
-
1856
- init() {
1857
- const opt = this.opt;
1858
- resetFabric();
1859
- this.newCanvas();
1860
- this.id = opt.id || util.UUID();
1861
-
1862
- if (this.opt.url) {
1863
- this.loadJsonString(this.opt.url, () => {
1864
- this.initEditorBackground();
1865
- });
1866
- } else {
1867
- this.canvas.setBackgroundColor(config.canvas.bc, () => {});
1868
- } // 注册事件
1869
-
1870
- this.injectEvent(); // 网格
1871
-
1872
- this.grid = new Grid({
1873
- boxId: this.opt.boxElement || "",
1874
- canvas: this.canvas,
1875
- scaleHd: this.opt.scaleHd || 15,
1876
- });
1877
-
1878
- if (!this.opt.isPreview) {
1879
- // 游标卡尺 刻度尺
1880
- this.scale = new Scale({
1881
- boxId: opt.boxElement,
1882
- drawCanvas: this.canvas,
1883
- scaleHou: this.opt.scaleHd || 15,
1884
- });
1885
- }
1886
- } // 编辑状态下初始化背景色
1887
-
1888
- initEditorBackground() {
1889
- const bc = this.canvas.backgroundColor || config.canvas.bc;
1890
-
1891
- if (bc) {
1892
- this.setBackground(bc);
1893
- this.canvas.setBackgroundColor(config.canvas.bc, () => {});
1894
- this.canvas.renderAll();
1895
- }
1896
- } // 修改背景色
1897
-
1898
- setBackground(s, cb) {
1899
- if (this.grid) {
1900
- this.grid.changeBackground(s, cb);
1901
- } else {
1902
- this.canvas.setBackgroundColor(s, () => {
1903
- cb ? cb() : "";
1904
- });
1905
- this.canvas.renderAll();
1906
- }
1907
- } // 获取背景色
1908
-
1909
- getBackground() {
1910
- if (this.grid) {
1911
- return this.grid.canvas.backgroundColor;
1912
- }
1913
-
1914
- return this.canvas.backgroundColor;
1915
- } // 显示隐藏grid
1916
-
1917
- changeGridVisibility() {
1918
- if (this.grid.renderState) {
1919
- this.grid.clearGrid();
1920
- } else {
1921
- this.grid.resetGrid();
1922
- }
1923
- }
1924
-
1925
- scale;
1926
- grid; // 设置颜色
1927
-
1928
- setLineColor(line, color) {
1929
- line.set("stroke", color);
1930
- const tri = getObjById(this.canvas, line.data.triangleId);
1931
- tri?.set("fill", color);
1932
- this.canvas.renderAll();
1933
- } // 设置新增状态
1934
-
1935
- setState(state) {
1936
- this.state = state;
1937
-
1938
- if (state === "createLine") {
1939
- this.canvas.selection = false;
1940
- this.canvas.getObjects().forEach((item) => {
1941
- item.selectable = false;
1942
- });
1943
-
1944
- if (this.canvas.getActiveObject()) {
1945
- this.canvas.getActiveObject().lockMovementX = true;
1946
- this.canvas.getActiveObject().lockMovementY = true;
1947
- }
1948
- } else if (state === "") {
1949
- this.canvas.selection = true;
1950
- this.canvas.getObjects().map((item) => {
1951
- if (item.data?.effectType !== "triangle") {
1952
- item.selectable = true;
1953
- }
1954
-
1955
- if (
1956
- item.data?.effectType !== "line" &&
1957
- item.data?.effectType !== "triangle"
1958
- ) {
1959
- item.lockMovementX = false;
1960
- item.lockMovementY = false;
1961
- }
1962
-
1963
- return item;
1964
- });
1965
- }
1966
- } // 合理化布局
1967
-
1968
- zoomToFitCanvas() {
1969
- zoomToFitCanvas(this.canvas);
1970
- } // 绘制方法
1971
-
1972
- draw = Draw.bind(this)(); // 更新设备图
1973
-
1974
- updateImg = updateImg; // 更新设备值
1975
-
1976
- updateState = updateState; // 居中对齐方法
1977
-
1978
- align = fabricItemAlign.bind(this); // 设置元素层级
1979
-
1980
- setLevel = setLevel.bind(this); // 注入方法
1981
-
1982
- injectEvent() {
1983
- // 注册事件
1984
- Event.bind(this)(this.canvas, {
1985
- boxElement: this.opt.boxElement,
1986
- isPreview: this.opt.isPreview,
1987
- });
1988
- } // 翻转元素方法
1989
-
1990
- flip = {
1991
- x: () => {
1992
- const object = this.canvas.getActiveObject();
1993
- const state = object.flipX;
1994
- setInfo(this.canvas, object, {
1995
- flipX: !state,
1996
- });
1997
- },
1998
- y: () => {
1999
- const object = this.canvas.getActiveObject();
2000
- const state = object.flipY;
2001
- setInfo(this.canvas, object, {
2002
- flipY: !state,
2003
- });
2004
- },
2005
- }; // to canvas 反序列化
2006
-
2007
- loadJsonString = loadJsonString.bind(this); // to json 序列化json
2008
-
2009
- toJson() {
2010
- if (this.grid) {
2011
- this.canvas.setBackgroundColor(
2012
- this.getBackground() || config.canvas.bc,
2013
- () => {}
2014
- );
2015
- }
2016
-
2017
- const json = JSON.stringify(this.canvas.toJSON());
2018
- this.canvas.setBackgroundColor(config.canvas.bc, () => {});
2019
- return json;
2020
- } // 工具
2021
-
2022
- util = util; // canvas 转图片
2023
-
2024
- toImg() {
2025
- if (this.grid) {
2026
- this.canvas.setBackgroundColor(
2027
- this.getBackground() || config.canvas.bc,
2028
- () => {}
2029
- );
2030
- }
2031
-
2032
- const img = this.canvas.toDataURL({
2033
- format: "image/png",
2034
- });
2035
- this.canvas.setBackgroundColor(config.canvas.bc, () => {});
2036
- return img;
2037
- } // 添加元素时触发
2038
-
2039
- onAddElement(callBack) {
2040
- this.canvas.on("object:added", (e) => {
2041
- callBack(e.target);
2042
- });
2043
- } // 当某个页面元素被删除时触发
2044
-
2045
- onElementRemove(callBack) {
2046
- this.canvas.on("object:removed", (e) => {
2047
- callBack(e.target);
2048
- });
2049
- } // 销毁 全局注销
2050
-
2051
- destroy() {}
2052
- }
2053
-
2054
- export { LineAnimate, inlTpEditor as default };
2055
- //# sourceMappingURL=index.js.map
1
+ import { fabric } from "fabric";
2
+ import { AlignGuidelines } from "fabric-guideline-plugin";
3
+
4
+ const UUID = (n = 16) => {
5
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
6
+ const r = (Math.random() * 16) | 0,
7
+ v = c == "x" ? r : (r & 0x3) | 0x8;
8
+ return v.toString(n);
9
+ });
10
+ };
11
+
12
+ /**
13
+ *
14
+ * @param fileName string 文件全民
15
+ * @returns
16
+ */
17
+ const FileList = ["jpg", "svg", "png"];
18
+ function getExt(fileName) {
19
+ let splits = fileName.split(".");
20
+ return splits.pop();
21
+ }
22
+ function getFiles(files) {
23
+ const useFile = [];
24
+
25
+ for (let i in files) {
26
+ if (!isNaN(i)) {
27
+ const item = files[i];
28
+ const fileExt = getExt(item.name);
29
+ const has = FileList.indexOf(fileExt);
30
+
31
+ if (has >= 0) {
32
+ const url = windowPath(item);
33
+ useFile.push({
34
+ url,
35
+ fileExt,
36
+ file: item,
37
+ });
38
+ }
39
+ }
40
+ }
41
+
42
+ return useFile;
43
+ }
44
+ /**
45
+ *
46
+ * @param file 文件类型File
47
+ * @returns window url
48
+ */
49
+
50
+ function windowPath(file) {
51
+ let imgPath = "";
52
+
53
+ if (window.createObjectURL != undefined) {
54
+ imgPath = window.createObjectURL(file);
55
+ } else if (window.URL != undefined) {
56
+ imgPath = window.URL.createObjectURL(file);
57
+ } else if (window.webkitURL != undefined) {
58
+ imgPath = window.webkitURL.createObjectURL(file);
59
+ }
60
+
61
+ return imgPath;
62
+ }
63
+
64
+ const computedZoomCoord = (x, y, canvas) => {
65
+ const zoom = canvas.getZoom();
66
+ let left = x;
67
+ let top = y;
68
+
69
+ if (canvas.viewportTransform) {
70
+ left = (left - canvas.viewportTransform[4]) / zoom;
71
+ top = (top - canvas.viewportTransform[5]) / zoom;
72
+ }
73
+
74
+ return {
75
+ left,
76
+ top,
77
+ };
78
+ };
79
+ const computedZoomXY = (e, svg, canvas) => {
80
+ const userX = e.offsetX - svg.width / 2;
81
+ const userY = e.offsetY - svg.height / 2;
82
+ return computedZoomCoord(userX, userY, canvas);
83
+ };
84
+ const getWindowInfo = (domId) => {
85
+ let height, width, dom;
86
+
87
+ if (domId && document.getElementById(domId)) {
88
+ dom = document.getElementById(domId);
89
+ }
90
+
91
+ return () => {
92
+ if (dom) {
93
+ height = dom.clientHeight;
94
+ width = dom.clientWidth;
95
+ } else {
96
+ height = document.body.clientHeight;
97
+ width = document.body.clientWidth;
98
+ }
99
+
100
+ return {
101
+ height,
102
+ width,
103
+ };
104
+ };
105
+ };
106
+ const setInfo = (canvas, obj, info) => {
107
+ obj.set(info);
108
+ canvas.renderAll();
109
+ };
110
+ const createElementId = (id, className, el) => {
111
+ const dom = document.createElement(el || "div");
112
+ dom.id = id;
113
+ dom.className = className;
114
+ return dom;
115
+ };
116
+
117
+ var util = {
118
+ UUID,
119
+ computedZoomXY,
120
+ getWindowInfo,
121
+ file: {
122
+ getExt,
123
+ getFiles,
124
+ },
125
+ };
126
+
127
+ const canvasChangeZoom = (canvas) => {
128
+ canvas.on("mouse:wheel", (opt) => {
129
+ const delta = opt.e.deltaY; // 滚轮,向上滚一下是 -100,向下滚一下是 100
130
+
131
+ let zoom = canvas.getZoom(); // 获取画布当前缩放值
132
+
133
+ zoom *= 0.999 ** delta;
134
+ if (zoom > 20) zoom = 20; // 限制最大缩放级别
135
+
136
+ if (zoom < 0.01) zoom = 0.01; // 限制最小缩放级别
137
+
138
+ canvas.zoomToPoint(
139
+ {
140
+ // 关键点
141
+ x: opt.e.offsetX,
142
+ y: opt.e.offsetY,
143
+ },
144
+ zoom // 传入修改后的缩放级别
145
+ );
146
+ });
147
+ };
148
+
149
+ const event = {
150
+ mouseDown(opt, canvas, kk) {
151
+ let evt = opt.e;
152
+
153
+ if (kk === true) {
154
+ // 是否按住ctrl
155
+ canvas.isMoveing = true; // isMoveing 是自定义的,开启移动状态
156
+
157
+ canvas.lastPosX = evt.clientX; // lastPosX 是自定义的
158
+
159
+ canvas.lastPosY = evt.clientY; // lastPosY 是自定义的
160
+ }
161
+ },
162
+
163
+ mouseMove(opt, canvas) {
164
+ if (canvas.isMoveing) {
165
+ let evt = opt.e;
166
+ let vpt = canvas.viewportTransform; // 聚焦视图的转换
167
+
168
+ vpt[4] += evt.clientX - canvas.lastPosX;
169
+ vpt[5] += evt.clientY - canvas.lastPosY;
170
+ this.scale.setVpt(vpt[4], vpt[5], opt);
171
+ canvas.requestRenderAll(); // 重新渲染
172
+
173
+ canvas.lastPosX = evt.clientX;
174
+ canvas.lastPosY = evt.clientY;
175
+ }
176
+ },
177
+
178
+ mouseUp(opt, canvas) {
179
+ canvas.setViewportTransform(canvas.viewportTransform); // 设置此画布实例的视口转换
180
+
181
+ canvas.isMoveing = false; // 关闭移动状态
182
+ },
183
+ };
184
+ function canvasMove(canvas) {
185
+ let flag = false;
186
+ window.addEventListener("keydown", (e) => {
187
+ if (e.code === "Space") {
188
+ flag = true;
189
+ }
190
+ });
191
+ window.addEventListener("keyup", (e) => {
192
+ flag = false;
193
+ });
194
+ canvas.on("mouse:down", (e) => {
195
+ event.mouseDown(e, canvas, flag);
196
+ });
197
+ canvas.on("mouse:move", (e) => {
198
+ event.mouseMove.bind(this)(e, canvas);
199
+ });
200
+ canvas.on("mouse:up", (e) => {
201
+ event.mouseUp(e, canvas);
202
+ });
203
+ }
204
+
205
+ const graphData = {
206
+ triangle: {
207
+ effectType: "triangle",
208
+ },
209
+ line: {
210
+ effectType: "line",
211
+ },
212
+ shape: {
213
+ effectType: "shape",
214
+ outLines: [],
215
+ inLines: [],
216
+ },
217
+ text: {
218
+ effectType: "text",
219
+ },
220
+ default: {
221
+ isCustomElement: true,
222
+ effectType: "svg",
223
+ outLines: [],
224
+ inLines: [],
225
+ },
226
+ };
227
+
228
+ const assign = (object, type) => {
229
+ const preData = JSON.parse(JSON.stringify(graphData));
230
+ const data =
231
+ type && preData[type]
232
+ ? Object.assign(preData.default, preData[type])
233
+ : preData.default;
234
+ return Object.assign(object, {
235
+ id: UUID(),
236
+ data,
237
+ });
238
+ };
239
+
240
+ var addCustomElement = (canvas, obj, type) => {
241
+ obj = assign(obj, type);
242
+ canvas.add(obj);
243
+ canvas.renderAll();
244
+ return obj;
245
+ };
246
+
247
+ // 同步上传img
248
+
249
+ const LoadImg = (that, canvas, useFile, e) => {
250
+ const loadFile = new Promise(async (res, rej) => {
251
+ const url = that.opt.uploadFile?.customFun
252
+ ? await that.opt.uploadFile?.customFun(useFile.file)
253
+ : useFile.url;
254
+ fabric.Image.fromURL(url, (img) => {
255
+ img.id = util.UUID();
256
+ const { left, top } = util.computedZoomXY(e, img, canvas);
257
+ addCustomElement(
258
+ canvas,
259
+ img.set({
260
+ left,
261
+ top,
262
+ angle: 0,
263
+ })
264
+ );
265
+ img.crossOrigin = "Anonymous";
266
+ setTimeout(() => {
267
+ res(img);
268
+ }, 10);
269
+ });
270
+ });
271
+ return loadFile;
272
+ }; // 同步上传SVG
273
+
274
+ const loadSvg = (canvas, useFile, e, callBack) => {
275
+ const loadFile = new Promise((res, rej) => {
276
+ const groupSvg = (objects, options) => {
277
+ const svg = fabric.util.groupSVGElements(objects);
278
+ const { left, top } = util.computedZoomXY(e, svg, canvas);
279
+ svg.set({
280
+ left,
281
+ top,
282
+ });
283
+ addCustomElement(canvas, svg); // 自定义上传svg 参数
284
+
285
+ callBack ? callBack(svg) : "";
286
+ res(svg);
287
+ };
288
+
289
+ fabric.loadSVGFromURL(useFile.url, (objects, options) => {
290
+ groupSvg(objects);
291
+ });
292
+ });
293
+ return loadFile;
294
+ }; // 同步上传文件
295
+
296
+ const asyncLoadFile = (that, canvas, useFile, e) => {
297
+ if (useFile.fileExt === "svg") {
298
+ return loadSvg(canvas, useFile, e);
299
+ }
300
+
301
+ return LoadImg(that, canvas, useFile, e);
302
+ }; // 上传文件
303
+
304
+ const LoadFile = (that, canvas, Files, e) => {
305
+ const { useFile, dropData } = Files;
306
+ const promiseList = [];
307
+
308
+ if (dropData) {
309
+ const fileExt = getExt(dropData.url);
310
+ promiseList.push(
311
+ loadSvg(
312
+ canvas,
313
+ {
314
+ fileExt,
315
+ url: dropData.url,
316
+ },
317
+ e,
318
+ dropData.callBack
319
+ )
320
+ );
321
+ } else {
322
+ for (let i of useFile) {
323
+ promiseList.push(asyncLoadFile(that, canvas, i, e));
324
+ }
325
+ }
326
+
327
+ return Promise.all(promiseList);
328
+ };
329
+
330
+ var onDrop = (that, canvas) => {
331
+ canvas.on("drop", (e) => {
332
+ const event = e.e;
333
+ event.preventDefault();
334
+ const dataTransfer = event.dataTransfer;
335
+ const files = dataTransfer.files;
336
+ const useFile = util.file.getFiles(files);
337
+ const dropData = dataTransfer.getData("dropData");
338
+ LoadFile(
339
+ that,
340
+ canvas,
341
+ {
342
+ useFile,
343
+ dropData: dropData ? JSON.parse(dropData) : null,
344
+ },
345
+ event
346
+ );
347
+ });
348
+ };
349
+
350
+ var pointConfig = {
351
+ pointRadius: 7,
352
+ };
353
+
354
+ const getObjById = (canvas, id) => {
355
+ const res = canvas.getObjects().find((ele) => {
356
+ return ele.id === id;
357
+ });
358
+ return res;
359
+ }; // 添加入的锚点
360
+
361
+ const getInsertIndex = (canvas, line, x, y) => {
362
+ let index = 0;
363
+ let distance; // 两点之前直线最短
364
+
365
+ for (let i = 0; i <= line.points.length - 2; i++) {
366
+ const point1 = line.points[i];
367
+ const point2 = line.points[i + 1];
368
+ const num =
369
+ Math.sqrt(Math.pow(x - point1.x, 2) + Math.pow(y - point1.y, 2)) +
370
+ Math.sqrt(Math.pow(x - point2.x, 2) + Math.pow(y - point2.y, 2)) -
371
+ Math.sqrt(
372
+ Math.pow(point1.x - point2.x, 2) + Math.pow(point1.y - point2.y, 2)
373
+ );
374
+
375
+ if (!distance || num < distance) {
376
+ distance = num;
377
+ index = i;
378
+ }
379
+ }
380
+
381
+ return index + 1;
382
+ };
383
+ const updateLine = (instance, line) => {
384
+ instance.canvas.remove(line);
385
+ const newLine = instance.draw.path({
386
+ path: line.points,
387
+ pathOpt: {
388
+ stroke: line.stroke,
389
+ },
390
+ });
391
+ newLine.id = line.id;
392
+ newLine.data = line.data;
393
+ newLine.lockMovementX = true;
394
+ newLine.lockMovementY = true;
395
+ return newLine;
396
+ };
397
+
398
+ let _REMOVEEVENTSTATE = false;
399
+ var remove = (canvas, opt) => {
400
+ const dom = document.getElementById(opt.boxElement);
401
+
402
+ const removeTriOfLine = (obj) => {
403
+ const triangle = canvas
404
+ .getObjects()
405
+ .find((ele) => ele.data.lineId === obj.id);
406
+ canvas.remove(triangle);
407
+ };
408
+
409
+ const removeRelevance = (obj) => {
410
+ if (obj.data?.effectType === "line") {
411
+ removeTriOfLine(obj);
412
+ }
413
+
414
+ if (obj.data?.effectType === "svg") {
415
+ [...(obj.data.outLines || []), ...(obj.data.inLines || [])]?.forEach(
416
+ (id) => {
417
+ const line = getObjById(canvas, id);
418
+ canvas.remove(line);
419
+ removeTriOfLine(line);
420
+ }
421
+ );
422
+ }
423
+ };
424
+
425
+ dom.addEventListener("mouseover", () => {
426
+ _REMOVEEVENTSTATE = true;
427
+ });
428
+ dom.addEventListener("mouseout", () => {
429
+ _REMOVEEVENTSTATE = false;
430
+ });
431
+ window.addEventListener("keydown", (e) => {
432
+ const isToRemove =
433
+ (e.code === "Backspace" || e.code === "Delete") && _REMOVEEVENTSTATE;
434
+
435
+ if (isToRemove) {
436
+ const activeObjects = canvas.getActiveObjects();
437
+
438
+ for (let i of activeObjects) {
439
+ canvas.remove(i);
440
+ removeRelevance(i);
441
+ }
442
+
443
+ canvas.renderAll();
444
+ }
445
+ });
446
+ };
447
+
448
+ const getAngle = (a, b) => {
449
+ let res;
450
+
451
+ if (a.x < b.x && a.y > b.y) {
452
+ res = (Math.atan((b.y - a.y) / (a.x - b.x)) / Math.PI) * 180;
453
+ } else if (a.x > b.x && a.y > b.y) {
454
+ res = (Math.atan((b.y - a.y) / (a.x - b.x)) / Math.PI) * 180 + 180;
455
+ } else if (a.x > b.x && a.y < b.y) {
456
+ res = (Math.atan((b.y - a.y) / (a.x - b.x)) / Math.PI) * 180 + 180;
457
+ } else if (a.x < b.x && a.y < b.y) {
458
+ res = (Math.atan((b.y - a.y) / (a.x - b.x)) / Math.PI) * 180;
459
+ }
460
+
461
+ return res;
462
+ };
463
+
464
+ const updateTriangle = (canvas, line) => {
465
+ const oldTri = getObjById(canvas, line.data.triangleId);
466
+ const tri = getTriangle(line);
467
+ oldTri.left = tri.left;
468
+ oldTri.top = tri.top;
469
+ oldTri.set("fill", line.stroke);
470
+ oldTri.rotate(tri.angle);
471
+ oldTri.selectable = false;
472
+ oldTri.lockMovementX = true;
473
+ oldTri.lockMovementY = true;
474
+ canvas.renderAll();
475
+ };
476
+ const getTriangle = (line) => {
477
+ const begin = line.points[line.points.length - 2];
478
+ const end = line.points[line.points.length - 1];
479
+ const angle = (getAngle(begin, end) - 90) * -1;
480
+ const t = new fabric.Triangle({
481
+ centeredRotation: true,
482
+ fill: line.stroke,
483
+ left: end.x - 7.5,
484
+ top: end.y - 7.5,
485
+ hasControls: false,
486
+ hasBorders: false,
487
+ lockMovementX: true,
488
+ lockMovementY: true,
489
+ selectable: false,
490
+ width: 15,
491
+ height: 15,
492
+ });
493
+ t.rotate(angle);
494
+ return t;
495
+ };
496
+
497
+ const createLine = (instance) => {
498
+ let tempLine;
499
+ let beginObj;
500
+ const canvas = instance.canvas;
501
+ window.addEventListener("keydown", (e) => {
502
+ const isShift = e.code === "ShiftLeft" || e.code === "ShiftRight";
503
+
504
+ if (isShift) {
505
+ instance.canvas.keydown = "shift";
506
+ }
507
+ });
508
+ window.addEventListener("keyup", (e) => {
509
+ instance.canvas.keydown = undefined;
510
+ });
511
+ canvas.on("mouse:down:before", (e) => {
512
+ if (e.target) {
513
+ beginObj = e.target; // 线编辑状态点块
514
+
515
+ if (
516
+ beginObj &&
517
+ instance.state === "createLine" &&
518
+ beginObj.data.effectType !== "line" &&
519
+ beginObj.data.effectType !== "point"
520
+ ) {
521
+ computedZoomCoord(e.pointer.x, e.pointer.y, canvas);
522
+ const beginPoint = beginObj.getCenterPoint();
523
+ const newLine = new fabric.Path(
524
+ [
525
+ ["M", beginPoint.x, beginPoint.y],
526
+ ["L", beginPoint.x, beginPoint.y],
527
+ ],
528
+ {
529
+ fill: "",
530
+ stroke: "black",
531
+ objectCaching: false,
532
+ strokeWidth: 3,
533
+ strokeDashArray:
534
+ canvas.createLineType === "broken" ? [0, 0, 12] : undefined,
535
+ perPixelTargetFind: true,
536
+ lockMovementX: true,
537
+ lockMovementY: true,
538
+ }
539
+ );
540
+ tempLine = newLine;
541
+ canvas.add(newLine);
542
+ canvas.renderAll();
543
+ }
544
+ } else {
545
+ beginObj = undefined;
546
+ }
547
+ });
548
+ canvas.on("mouse:move", (e) => {
549
+ e.target; // 线预览
550
+
551
+ if (
552
+ instance.state === "createLine" &&
553
+ beginObj &&
554
+ beginObj.data.effectType !== "line" &&
555
+ beginObj.data.effectType !== "point"
556
+ ) {
557
+ const xy = computedZoomCoord(e.pointer.x, e.pointer.y, canvas);
558
+ const path = tempLine.path;
559
+ path[1][1] = xy.left;
560
+ path[1][2] = xy.top;
561
+ canvas.renderAll();
562
+ }
563
+ });
564
+ canvas.on("mouse:up", (e) => {
565
+ const endObj = e.currentTarget; // 新连线
566
+
567
+ if (
568
+ instance.state === "createLine" &&
569
+ endObj &&
570
+ endObj?.data.effectType !== "line" &&
571
+ endObj?.data.effectType !== "point" &&
572
+ beginObj &&
573
+ beginObj?.data.effectType !== "line" &&
574
+ beginObj?.data.effectType !== "point" &&
575
+ beginObj !== endObj
576
+ ) {
577
+ const beginPoint = beginObj.getCenterPoint();
578
+ const endPoint = endObj.getCenterPoint();
579
+ const data = {
580
+ from: beginObj.id,
581
+ fromExcursionX: 0,
582
+ fromExcursionY: 0,
583
+ to: endObj.id,
584
+ toExcursionX: 0,
585
+ toExcursionY: 0,
586
+ };
587
+ const line = instance.draw.path({
588
+ path: [beginPoint, endPoint],
589
+ });
590
+ line.data = { ...line.data, ...data }; // 箭头
591
+
592
+ const tri = getTriangle(line);
593
+ const triangle = addCustomElement(instance.canvas, tri, "triangle");
594
+ line.data.triangleId = triangle.id;
595
+ triangle.data.lineId = line.id;
596
+ triangle.data.effectType = "triangle";
597
+ beginObj.data.outLines.push(line.id);
598
+ endObj.data.inLines.push(line.id);
599
+ beginObj = undefined;
600
+ instance.setState("");
601
+ }
602
+
603
+ if (tempLine) {
604
+ canvas.remove(tempLine);
605
+ }
606
+
607
+ tempLine = undefined;
608
+ beginObj = undefined;
609
+ });
610
+ };
611
+
612
+ const lineEvent = (instance) => {
613
+ createLine(instance);
614
+ let tempLine; // 点下标
615
+
616
+ let addPointIndex;
617
+ let pointIndex;
618
+ const canvas = instance.canvas; // 都干完刷新一下线
619
+
620
+ canvas.on("after:render", (e) => {
621
+ canvas.getObjects().forEach((obj) => {
622
+ if (obj.data?.effectType === "line") {
623
+ if (obj.data?.needUpate) {
624
+ obj.controls = fabric.Object.prototype.controls;
625
+ obj.hasControls = false;
626
+ updateLine(instance, obj);
627
+ obj.data.needUpate = undefined;
628
+ }
629
+ }
630
+ });
631
+ });
632
+ let beginObj;
633
+ canvas.on("mouse:down:before", (e) => {
634
+ if (e.target) {
635
+ beginObj = e.target;
636
+ const xy = computedZoomCoord(e.pointer.x, e.pointer.y, canvas);
637
+ const active = canvas.getActiveObject(); // 点击选中后的线创建折点或者移动折点
638
+
639
+ if (
640
+ beginObj &&
641
+ beginObj.data?.effectType === "line" &&
642
+ active?.id === beginObj.id
643
+ ) {
644
+ const line = beginObj;
645
+ line.lockMovementX = true;
646
+ line.lockMovementY = true;
647
+ line.points.forEach((p, index) => {
648
+ if (Math.abs(p.x - xy.left) < 5 && Math.abs(p.y - xy.top) < 5) {
649
+ pointIndex = index;
650
+ }
651
+ }); // 拖动折点
652
+
653
+ if (pointIndex !== undefined) {
654
+ // 首尾折点
655
+ if (pointIndex !== 0 && pointIndex !== line.points.length - 1) {
656
+ pointIndex = undefined;
657
+ }
658
+
659
+ return;
660
+ }
661
+
662
+ addPointIndex = getInsertIndex(canvas, line, xy.left, xy.top);
663
+ line.points.splice(addPointIndex, 0, {
664
+ x: xy.left,
665
+ y: xy.top,
666
+ });
667
+ }
668
+ } else {
669
+ beginObj = undefined;
670
+ }
671
+ });
672
+ canvas.on("mouse:move", (e) => {
673
+ const obj = e.target;
674
+ const active = canvas.getActiveObject(); // 创建折点跟随
675
+
676
+ if (
677
+ addPointIndex &&
678
+ beginObj?.data.effectType === "line" &&
679
+ active?.id === beginObj.id
680
+ ) {
681
+ const line = beginObj;
682
+ const xy = computedZoomCoord(e.pointer.x, e.pointer.y, canvas);
683
+
684
+ if (instance.canvas.keydown === "shift");
685
+
686
+ line.points[addPointIndex].x = xy.left;
687
+ line.points[addPointIndex].y = xy.top;
688
+ } // 移动块
689
+
690
+ if (
691
+ instance.state !== "createLine" &&
692
+ beginObj &&
693
+ beginObj.data &&
694
+ beginObj.data?.effectType !== "line" &&
695
+ beginObj.data?.effectType !== "point"
696
+ ) {
697
+ const beginPoint = beginObj.getCenterPoint();
698
+ beginObj.data.outLines?.forEach((lineId) => {
699
+ const line = getObjById(canvas, lineId);
700
+ line.points[0].x = beginPoint.x + line.data.fromExcursionX;
701
+ line.points[0].y = beginPoint.y + line.data.fromExcursionY;
702
+ updateTriangle(canvas, line);
703
+ line.data.needUpate = true;
704
+ });
705
+ beginObj.data.inLines?.forEach((lineId) => {
706
+ const line = getObjById(canvas, lineId);
707
+ line.points[line.points.length - 1].x =
708
+ beginPoint.x + line.data.toExcursionX + pointConfig.pointRadius;
709
+ line.points[line.points.length - 1].y =
710
+ beginPoint.y + line.data.toExcursionY + pointConfig.pointRadius;
711
+ updateTriangle(canvas, line);
712
+ line.data.needUpate = true;
713
+ });
714
+ } // 移动点
715
+
716
+ if (
717
+ instance.state !== "createLine" &&
718
+ beginObj &&
719
+ beginObj.data?.effectType === "line" &&
720
+ obj?.data?.effectType === "line"
721
+ ) {
722
+ updateTriangle(canvas, beginObj);
723
+ }
724
+ });
725
+ canvas.on("mouse:up", (e) => {
726
+ e.currentTarget;
727
+
728
+ if (canvas.getActiveObjects().length > 1) {
729
+ canvas.getActiveObject().set("lockMovementX", true);
730
+ canvas.getActiveObject().set("lockMovementY", true);
731
+ } // 移动点
732
+
733
+ if (pointIndex !== undefined && beginObj?.data.effectType === "line") {
734
+ const line = beginObj;
735
+ const point1 = new fabric.Circle({
736
+ radius: 3,
737
+ left: line.points[0].x,
738
+ top: line.points[0].y,
739
+ });
740
+ const point2 = new fabric.Circle({
741
+ radius: 3,
742
+ left: line.points[line.points.length - 1].x,
743
+ top: line.points[line.points.length - 1].y,
744
+ });
745
+ let newParent;
746
+ canvas.getObjects().forEach((obj) => {
747
+ if (obj.data.effectType === "shape" || obj.data.effectType === "svg") {
748
+ if (
749
+ obj.intersectsWithObject(point1) &&
750
+ obj.data.outLines.indexOf(line.id) === -1
751
+ ) {
752
+ newParent = {
753
+ type: "start",
754
+ obj,
755
+ };
756
+ }
757
+
758
+ if (
759
+ obj.intersectsWithObject(point2) &&
760
+ obj.data.inLines.indexOf(line.id) === -1
761
+ ) {
762
+ newParent = {
763
+ type: "end",
764
+ obj,
765
+ };
766
+ }
767
+ }
768
+ }); // 连接到新块
769
+
770
+ if (newParent) {
771
+ const beginPoint = newParent.obj.getCenterPoint();
772
+
773
+ if (newParent.type === "start") {
774
+ const oldRect = getObjById(canvas, line.data.from);
775
+ oldRect.data.outLines.splice(
776
+ oldRect.data.outLines.indexOf(line.id),
777
+ 1
778
+ );
779
+ line.data.from = newParent.obj.id;
780
+ line.data.fromExcursionX = 0;
781
+ line.data.fromExcursionY = 0;
782
+ line.points[0].x = beginPoint.x;
783
+ line.points[0].y = beginPoint.y;
784
+ newParent.obj.data.outLines.push(line.id);
785
+ line.data.needUpate = true;
786
+ } else if (newParent.type === "end") {
787
+ const oldRect = getObjById(canvas, line.data.to);
788
+ oldRect.data.inLines.splice(oldRect.data.inLines.indexOf(line.id), 1);
789
+ line.data.to = newParent.obj.id;
790
+ line.data.toExcursionX = 0;
791
+ line.data.toExcursionY = 0;
792
+ line.points[line.points.length - 1].x = beginPoint.x;
793
+ line.points[line.points.length - 1].y = beginPoint.y;
794
+ newParent.obj.data.inLines.push(line.id);
795
+ line.data.needUpate = true;
796
+ }
797
+ } else {
798
+ if (pointIndex === 0) {
799
+ const rect = getObjById(canvas, line.data.from);
800
+ const rectPoint = rect.getCenterPoint();
801
+ line.data.fromExcursionX = e.pointer.x - rectPoint.x;
802
+ line.data.fromExcursionY = e.pointer.y - rectPoint.y;
803
+ } else {
804
+ const rect = getObjById(canvas, line.data.to);
805
+ const rectPoint = rect.getCenterPoint();
806
+ line.data.toExcursionX = e.pointer.x - rectPoint.x;
807
+ line.data.toExcursionY = e.pointer.y - rectPoint.y;
808
+ }
809
+ }
810
+ } // 新点
811
+
812
+ if (beginObj?.data?.effectType === "line" && addPointIndex !== undefined) {
813
+ const line = beginObj;
814
+ line.data.needUpate = true;
815
+ }
816
+
817
+ if (tempLine) {
818
+ canvas.remove(tempLine);
819
+ }
820
+
821
+ tempLine = undefined;
822
+ beginObj = undefined;
823
+ addPointIndex = undefined;
824
+ pointIndex = undefined;
825
+ });
826
+ };
827
+
828
+ const shapeEvent = (instance) => {
829
+ const canvas = instance.canvas; // 点下标
830
+
831
+ let point;
832
+ canvas.on("mouse:down:before", (e) => {
833
+ point = computedZoomCoord(e.pointer.x, e.pointer.y, canvas);
834
+ });
835
+ canvas.on("mouse:up", (e) => {
836
+ const endPoint = computedZoomCoord(e.pointer.x, e.pointer.y, canvas);
837
+
838
+ if (instance.state !== "createShape") {
839
+ return;
840
+ }
841
+
842
+ const rect = new fabric.Rect({
843
+ left: Math.min(point.left, endPoint.left),
844
+ top: Math.min(point.top, endPoint.top),
845
+ fill: instance.config.shape.fill,
846
+ stroke: instance.config.shape.stroke,
847
+ strokeWidth: 2,
848
+ width: Math.abs(point.left - endPoint.left),
849
+ height: Math.abs(point.top - endPoint.top),
850
+ });
851
+ addCustomElement(canvas, rect, "shape");
852
+ instance.setState("");
853
+ });
854
+ };
855
+
856
+ const textEvent = (instance) => {
857
+ const canvas = instance.canvas; // 点下标
858
+
859
+ let point;
860
+ canvas.on("mouse:down:before", (e) => {
861
+ point = computedZoomCoord(e.pointer.x, e.pointer.y, canvas);
862
+ });
863
+ canvas.on("mouse:up", (e) => {
864
+ computedZoomCoord(e.pointer.x, e.pointer.y, canvas);
865
+
866
+ if (instance.state !== "createText") {
867
+ return;
868
+ }
869
+
870
+ var itext = new fabric.IText("我是文本", {
871
+ left: point.left,
872
+ top: point.top,
873
+ editable: false,
874
+ fill: "#354052",
875
+ lockScalingX: true,
876
+ lockScalingY: true,
877
+ strokeWidth: 0,
878
+ stroke: "#880E4F",
879
+ });
880
+ addCustomElement(canvas, itext, "text");
881
+ instance.setState("");
882
+ });
883
+ };
884
+
885
+ var lockMove = (canvas) => {
886
+ let shiftKey = false;
887
+ let altKey = false;
888
+ canvas.on("mouse:down:before", (e) => {
889
+ shiftKey = e.e.shiftKey;
890
+ altKey = e.e.altKey;
891
+
892
+ if (shiftKey && altKey && e.target) {
893
+ // 锁定 Y轴移动
894
+ e.target.lockMovementX = true;
895
+ } else if (shiftKey && !altKey && e.target) {
896
+ // 锁定X轴移动
897
+ e.target.lockMovementY = true;
898
+ }
899
+ });
900
+ canvas.on("mouse:up:before", (e) => {
901
+ shiftKey = false;
902
+ altKey = false;
903
+
904
+ if (e.target) {
905
+ // 解锁 Y轴移动
906
+ e.target.lockMovementX = false; // 解锁 X轴移动
907
+
908
+ e.target.lockMovementY = false;
909
+ }
910
+ });
911
+ };
912
+
913
+ function Event(canvas, opt) {
914
+ // 拖动上传
915
+ onDrop(this, canvas); // 缩放
916
+
917
+ canvasChangeZoom(canvas); // 画布拖动
918
+
919
+ canvasMove.bind(this)(canvas); // 删除方法
920
+
921
+ remove(canvas, opt); // 辅助线
922
+
923
+ const guideline = new AlignGuidelines({
924
+ canvas,
925
+ });
926
+ guideline.init(); // 线相关事件
927
+
928
+ lineEvent(this); // 创建矩形
929
+
930
+ shapeEvent(this); // 创建文字
931
+
932
+ textEvent(this);
933
+
934
+ if (opt && opt.isPreview) {
935
+ (function render() {
936
+ canvas.renderAll();
937
+ fabric.util.requestAnimFrame(render);
938
+ })();
939
+ } // cp Event
940
+ // cp(canvas);
941
+ // 锁定轴移动块
942
+
943
+ lockMove(canvas);
944
+ }
945
+
946
+ var LineState;
947
+
948
+ (function (LineState) {
949
+ LineState["RAW_COAL"] = "#EA5858";
950
+ LineState["CLEAN_COAL"] = "#22CC83";
951
+ LineState["PRODUCT"] = "#22CC83";
952
+ LineState["REJECT"] = "#6554C0";
953
+ LineState["SLURRY"] = "#A52337";
954
+ LineState["DILUTE_MEDIUM"] = "#9095A2";
955
+ LineState["CORRECT_MEDIUM"] = "#354052";
956
+ LineState["DENSE_MEDIUM"] = "#354052";
957
+ LineState["MIDDLINGS"] = "#FF9214";
958
+ LineState["SLIME"] = "#729918";
959
+ LineState["CLARIFIED_WATER"] = " #1CDDEB";
960
+ LineState["AIR"] = "#D439D4";
961
+ })(LineState || (LineState = {}));
962
+
963
+ var line = {
964
+ fill: "transparent",
965
+ stroke: "#354052",
966
+ strokeWidth: 3,
967
+ };
968
+
969
+ var shape = {
970
+ fill: "#f9fafb",
971
+ stroke: "#DCE2ED",
972
+ };
973
+
974
+ var config = {
975
+ line,
976
+ shape,
977
+ canvas: {
978
+ bc: "transparent",
979
+ },
980
+ };
981
+
982
+ const addControl = (poly) => {
983
+ var lastControl = poly.points.length - 1;
984
+ poly.cornerStyle = "circle";
985
+ poly.cornerColor = "red";
986
+ poly.controls = poly.points.reduce(function (acc, point, index) {
987
+ acc["p" + index] = new fabric.Control({
988
+ positionHandler: polygonPositionHandler,
989
+ actionHandler: anchorWrapper(
990
+ index > 0 ? index - 1 : lastControl,
991
+ actionHandler
992
+ ),
993
+ actionName: "modifyPolygon",
994
+ pointIndex: index,
995
+ });
996
+ return acc;
997
+ }, {});
998
+ }; // 返回控制点
999
+
1000
+ function polygonPositionHandler(dim, finalMatrix, fabricObject) {
1001
+ var x = fabricObject.points[this.pointIndex].x - fabricObject.pathOffset.x,
1002
+ y = fabricObject.points[this.pointIndex].y - fabricObject.pathOffset.y;
1003
+ return fabric.util.transformPoint(
1004
+ {
1005
+ x: x,
1006
+ y: y,
1007
+ },
1008
+ fabric.util.multiplyTransformMatrices(
1009
+ fabricObject.canvas.viewportTransform,
1010
+ fabricObject.calcTransformMatrix()
1011
+ )
1012
+ );
1013
+ }
1014
+
1015
+ function getObjectSizeWithStroke(object) {
1016
+ var stroke = new fabric.Point(
1017
+ object.strokeUniform ? 1 / object.scaleX : 1,
1018
+ object.strokeUniform ? 1 / object.scaleY : 1
1019
+ ).multiply(object.strokeWidth);
1020
+ return new fabric.Point(object.width + stroke.x, object.height + stroke.y);
1021
+ } // define a function that will define what the control does
1022
+ // this function will be called on every mouse move after a control has been
1023
+ // clicked and is being dragged.
1024
+ // The function receive as argument the mouse event, the current trasnform object
1025
+ // and the current position in canvas coordinate
1026
+ // transform.target is a reference to the current object being transformed,
1027
+
1028
+ function actionHandler(eventData, transform, x, y) {
1029
+ var polygon = transform.target,
1030
+ currentControl = polygon.controls[polygon.__corner],
1031
+ mouseLocalPosition = polygon.toLocalPoint(
1032
+ new fabric.Point(x, y),
1033
+ "center",
1034
+ "center"
1035
+ ),
1036
+ polygonBaseSize = getObjectSizeWithStroke(polygon),
1037
+ size = polygon._getTransformedDimensions(0, 0),
1038
+ finalPointPosition = {
1039
+ x:
1040
+ (mouseLocalPosition.x * polygonBaseSize.x) / size.x +
1041
+ polygon.pathOffset.x,
1042
+ y:
1043
+ (mouseLocalPosition.y * polygonBaseSize.y) / size.y +
1044
+ polygon.pathOffset.y,
1045
+ };
1046
+
1047
+ polygon.points[currentControl.pointIndex] = finalPointPosition;
1048
+ return true;
1049
+ } // define a function that can keep the polygon in the same position when we change its
1050
+ // width/height/top/left.
1051
+
1052
+ function anchorWrapper(anchorIndex, fn) {
1053
+ return function (eventData, transform, x, y) {
1054
+ var fabricObject = transform.target,
1055
+ absolutePoint = fabric.util.transformPoint(
1056
+ {
1057
+ x: fabricObject.points[anchorIndex].x - fabricObject.pathOffset.x,
1058
+ y: fabricObject.points[anchorIndex].y - fabricObject.pathOffset.y,
1059
+ },
1060
+ fabricObject.calcTransformMatrix()
1061
+ ),
1062
+ actionPerformed = fn(eventData, transform, x, y);
1063
+ fabricObject._setPositionDimensions({});
1064
+ var polygonBaseSize = getObjectSizeWithStroke(fabricObject),
1065
+ newX =
1066
+ (fabricObject.points[anchorIndex].x - fabricObject.pathOffset.x) /
1067
+ polygonBaseSize.x,
1068
+ newY =
1069
+ (fabricObject.points[anchorIndex].y - fabricObject.pathOffset.y) /
1070
+ polygonBaseSize.y;
1071
+
1072
+ fabricObject.setPositionByOrigin(absolutePoint, newX + 0.5, newY + 0.5);
1073
+ return actionPerformed;
1074
+ };
1075
+ }
1076
+
1077
+ const path = function (opt) {
1078
+ if (!opt.pathOpt) {
1079
+ opt.pathOpt = {
1080
+ stroke: config.line.stroke,
1081
+ strokeWidth: config.line.strokeWidth,
1082
+ };
1083
+ } else {
1084
+ if (!opt.pathOpt?.stroke) opt.pathOpt.stroke = config.line.stroke;
1085
+ if (!opt.pathOpt?.strokeWidth)
1086
+ opt.pathOpt.strokeWidth = config.line.strokeWidth;
1087
+ }
1088
+
1089
+ const polyline = new fabric.Polyline(opt.path, {
1090
+ ...opt.pathOpt,
1091
+ fill: "transparent",
1092
+ lockMovementX: true,
1093
+ lockMovementY: true,
1094
+ objectCaching: false,
1095
+ hasBorders: false,
1096
+ perPixelTargetFind: true,
1097
+ });
1098
+ addControl(polyline);
1099
+ return addCustomElement(this.canvas, polyline, "line");
1100
+ };
1101
+
1102
+ const text = function (opt) {
1103
+ const svg = getObjById(this.canvas, opt.parentId);
1104
+ const newText = new fabric.IText(opt.name, {
1105
+ editable: false,
1106
+ fill: "black",
1107
+ top: svg.top - 30,
1108
+ left: svg.left,
1109
+ lockScalingX: true,
1110
+ lockScalingY: true,
1111
+ ...opt.option,
1112
+ });
1113
+ return addCustomElement(this.canvas, newText, "text");
1114
+ };
1115
+
1116
+ function Draw() {
1117
+ return {
1118
+ path: path.bind(this),
1119
+ text: text.bind(this),
1120
+ };
1121
+ }
1122
+
1123
+ /**
1124
+ * 线段动画 需优化obo运动
1125
+ */
1126
+
1127
+ class LineAnimate {
1128
+ constructor(opt, canvas) {
1129
+ this.lineAnimateList = opt;
1130
+ this.canvas = canvas;
1131
+ }
1132
+
1133
+ canvas;
1134
+ lineAnimateList;
1135
+
1136
+ oboRun(speed) {}
1137
+
1138
+ oboStop(speed) {}
1139
+
1140
+ start(item) {
1141
+ let index = 0;
1142
+
1143
+ this.canvas._onObjectRemoved = (e) => {
1144
+ if (item.object === e) item.cycle = false;
1145
+ };
1146
+
1147
+ item.object.set("stroke", LineState[item.state] || "black");
1148
+
1149
+ const run = () => {
1150
+ const speed = item.speed || 1;
1151
+
1152
+ if (item.direction === "negative") {
1153
+ index = speed;
1154
+ } else {
1155
+ index -= speed;
1156
+ }
1157
+
1158
+ item.object.animate(
1159
+ {
1160
+ strokeDashOffset: index,
1161
+ },
1162
+ {
1163
+ duration: 60,
1164
+ onComplete: () => {
1165
+ if (item.cycle) {
1166
+ run();
1167
+ }
1168
+ },
1169
+ easing: (t, b, c, d) => {
1170
+ return (c * t) / d + b;
1171
+ },
1172
+ }
1173
+ );
1174
+ };
1175
+
1176
+ run();
1177
+ } // 添加动画
1178
+
1179
+ addLineAnimate(item) {
1180
+ this.lineAnimateList.push(item);
1181
+ this.start(item);
1182
+ } // 启动所有动画
1183
+
1184
+ startAll() {
1185
+ for (let i of this.lineAnimateList) {
1186
+ this.start(i);
1187
+ }
1188
+ } // 关闭所有动画
1189
+
1190
+ stopAll() {
1191
+ for (let i of this.lineAnimateList) {
1192
+ i.cycle = false;
1193
+ }
1194
+
1195
+ this.lineAnimateList = [];
1196
+ } // 关闭某个动画
1197
+
1198
+ stop(item) {
1199
+ item.cycle = false;
1200
+
1201
+ for (let i = 0; i < this.lineAnimateList.length; i++) {
1202
+ if (this.lineAnimateList[i].object === item.object) {
1203
+ this.lineAnimateList.splice(1, i);
1204
+ }
1205
+ }
1206
+ }
1207
+ }
1208
+
1209
+ var Alignparam;
1210
+
1211
+ (function (Alignparam) {
1212
+ Alignparam[(Alignparam["top"] = 0)] = "top";
1213
+ Alignparam[(Alignparam["left"] = 1)] = "left";
1214
+ Alignparam[(Alignparam["right"] = 2)] = "right";
1215
+ Alignparam[(Alignparam["bottom"] = 3)] = "bottom";
1216
+ Alignparam[(Alignparam["horizontal_center"] = 4)] = "horizontal_center";
1217
+ Alignparam[(Alignparam["vertical_center"] = 5)] = "vertical_center";
1218
+ Alignparam[(Alignparam["horizontal_distribution"] = 6)] =
1219
+ "horizontal_distribution";
1220
+ Alignparam[(Alignparam["vertical_distribution"] = 7)] =
1221
+ "vertical_distribution";
1222
+ })(Alignparam || (Alignparam = {}));
1223
+
1224
+ var Levels;
1225
+
1226
+ (function (Levels) {
1227
+ Levels["top"] = "bringToFront";
1228
+ Levels["bottom"] = "sendToBack";
1229
+ Levels["before"] = "bringForward";
1230
+ Levels["after"] = "sendBackwards";
1231
+ })(Levels || (Levels = {}));
1232
+
1233
+ /**
1234
+ *
1235
+ * @param canvas canvas
1236
+ * @param alignparam 对齐方向
1237
+ */
1238
+ const fabricItemAlign = function (alignparam) {
1239
+ const canvas = this.canvas;
1240
+ const canvasObjectsGrop = canvas.getActiveObject();
1241
+
1242
+ const getProperty = (cGrop = canvasObjectsGrop) => {
1243
+ return {
1244
+ gropObjs: cGrop._objects ?? [],
1245
+ gropWidth: cGrop.width ?? 0,
1246
+ gropHeight: cGrop.height ?? 0,
1247
+ };
1248
+ };
1249
+
1250
+ if (canvas.getActiveObjects().length <= 1) return;
1251
+ const { gropObjs, gropWidth, gropHeight } = getProperty();
1252
+
1253
+ if (alignparam === 0) {
1254
+ // 顶对齐
1255
+ gropObjs.forEach((item) => {
1256
+ // 顶对齐算法:top为零表示 依据选中框顶部对齐, left 为 选中点每一项的
1257
+ item.set({
1258
+ top: 0 - gropHeight * 0.5,
1259
+ });
1260
+ });
1261
+ } // 左对齐
1262
+
1263
+ if (alignparam === 1) {
1264
+ gropObjs.forEach((item) => {
1265
+ item.set({
1266
+ left: 0 - gropWidth * 0.5,
1267
+ });
1268
+ });
1269
+ } // 右对齐
1270
+
1271
+ if (alignparam === 2) {
1272
+ gropObjs.forEach((item) => {
1273
+ item.set({
1274
+ left: gropWidth - (item.width ?? 0) * item.scaleX - gropWidth * 0.5,
1275
+ });
1276
+ });
1277
+ } // 底对齐
1278
+
1279
+ if (alignparam === 3) {
1280
+ gropObjs.forEach((item) => {
1281
+ item.set({
1282
+ top: gropHeight - (item.height ?? 0) * item.scaleY - gropHeight * 0.5,
1283
+ });
1284
+ });
1285
+ } // 水平居中对齐
1286
+
1287
+ if (alignparam === 4) {
1288
+ gropObjs.forEach((item) => {
1289
+ item.set({
1290
+ top: 0 - (item.height ?? 0) * item.scaleY * 0.5,
1291
+ });
1292
+ });
1293
+ } // 垂直居中对齐
1294
+
1295
+ if (alignparam === 5) {
1296
+ gropObjs.forEach((item) => {
1297
+ item.set({
1298
+ left: 0 - (item.width ?? 0) * item.scaleX * 0.5,
1299
+ });
1300
+ });
1301
+ } // 水平分布对齐
1302
+
1303
+ if (alignparam === 6) {
1304
+ let groupWidth = gropWidth;
1305
+ gropObjs.forEach((item) => {
1306
+ groupWidth -= (item.width ?? 0) * item.scaleX;
1307
+ });
1308
+ const gap = groupWidth / (gropObjs.length - 1 || 1);
1309
+ gropObjs.forEach((item, idx) => {
1310
+ if (idx > 0) {
1311
+ item.set({
1312
+ left:
1313
+ (gropObjs[idx - 1].left ?? 0) +
1314
+ (gropObjs[idx - 1].width ?? 0) * gropObjs[idx - 1].scaleX +
1315
+ gap,
1316
+ });
1317
+ } else {
1318
+ item.set({
1319
+ left: 0 - gropWidth / 2,
1320
+ });
1321
+ }
1322
+ });
1323
+ } // 垂直分布对齐
1324
+
1325
+ if (alignparam === 7) {
1326
+ let groupHeight = gropHeight;
1327
+ gropObjs.forEach((item) => {
1328
+ groupHeight -= (item.height ?? 0) * item.scaleY;
1329
+ });
1330
+ const gap = groupHeight / (gropObjs.length - 1 || 1);
1331
+ gropObjs.forEach((item, idx) => {
1332
+ if (idx > 0) {
1333
+ item.set({
1334
+ top:
1335
+ (gropObjs[idx - 1].top ?? 0) +
1336
+ (gropObjs[idx - 1].height ?? 0) * gropObjs[idx - 1].scaleY +
1337
+ gap,
1338
+ });
1339
+ } else {
1340
+ item.set({
1341
+ top: 0 - gropHeight / 2,
1342
+ });
1343
+ }
1344
+ });
1345
+ } // 其他对齐规则拓展 ......
1346
+
1347
+ canvas.renderAll(); // 重新渲染
1348
+ };
1349
+
1350
+ const setLevel = function (idOrEle, level) {
1351
+ const canvas = this.canvas;
1352
+ const obj =
1353
+ typeof idOrEle === "string" ? getObjById(canvas, idOrEle) : idOrEle;
1354
+ const fun = Levels[level];
1355
+
1356
+ if (obj) {
1357
+ obj[fun]();
1358
+ }
1359
+
1360
+ canvas.renderAll(); // 重新渲染
1361
+
1362
+ return obj;
1363
+ };
1364
+
1365
+ function zoomToFitCanvas(canvas) {
1366
+ //遍历所有对对象,获取最小坐标,最大坐标
1367
+ const objects = canvas.getObjects();
1368
+ let rect = objects[0].getBoundingRect();
1369
+ let minX = rect.left;
1370
+ let minY = rect.top;
1371
+ let maxX = rect.left + rect.width;
1372
+ let maxY = rect.top + rect.height;
1373
+
1374
+ if (objects.length > 0) {
1375
+ for (let i = 1; i < objects.length; i++) {
1376
+ rect = objects[i].getBoundingRect();
1377
+ minX = Math.min(minX, rect.left);
1378
+ minY = Math.min(minY, rect.top);
1379
+ maxX = Math.max(maxX, rect.left + rect.width);
1380
+ maxY = Math.max(maxY, rect.top + rect.height);
1381
+ }
1382
+ } //计算平移坐标
1383
+
1384
+ const panX = (maxX - minX - canvas.width) / 2 + minX;
1385
+ const panY = (maxY - minY - canvas.height) / 2 + minY;
1386
+ const { left, top } = computedZoomCoord(panX, panY, canvas); //开始平移
1387
+
1388
+ canvas.absolutePan({
1389
+ x: left,
1390
+ y: top,
1391
+ }); //计算缩放比例
1392
+
1393
+ const zoom = Math.min(
1394
+ canvas.width / (maxX - minX),
1395
+ canvas.height / (maxY - minY)
1396
+ ); //计算缩放中心
1397
+
1398
+ const zoomPoint = new fabric.Point(canvas.width / 2, canvas.height / 2); //开始缩放
1399
+
1400
+ canvas.zoomToPoint(zoomPoint, zoom * 0.8);
1401
+ }
1402
+
1403
+ class windowResize {
1404
+ constructor(opt) {
1405
+ this.opt = opt;
1406
+ this.canvas = opt.canvas;
1407
+ this.domInfo = getWindowInfo(opt.id);
1408
+ this.init();
1409
+ this.watchDivChange();
1410
+ }
1411
+
1412
+ opt;
1413
+
1414
+ watchDivChange() {
1415
+ const dom = document.getElementById(this.opt.id);
1416
+ let tm;
1417
+ const resizeObserver = new ResizeObserver((entries) => {
1418
+ if (tm) clearTimeout(tm);
1419
+ tm = setTimeout(() => {
1420
+ this.todo();
1421
+ }, 100);
1422
+ });
1423
+ resizeObserver.observe(dom);
1424
+ }
1425
+
1426
+ init() {
1427
+ const { width, height } = this.domInfo();
1428
+ this.canvas.setWidth(width);
1429
+ this.canvas.setHeight(height);
1430
+ }
1431
+
1432
+ todo(cb) {
1433
+ this.init();
1434
+ const callBack = this.opt.cb || cb;
1435
+ const { width, height } = this.domInfo();
1436
+ callBack ? callBack(width, height, this.canvas) : "";
1437
+ }
1438
+
1439
+ canvas;
1440
+ domInfo;
1441
+ }
1442
+
1443
+ function renderGrid(canvas) {
1444
+ const width = canvas.width;
1445
+ const height = canvas.height;
1446
+ let line;
1447
+ let rect = [];
1448
+ let size = 20;
1449
+
1450
+ for (let i = 0; i < Math.ceil(width / 20); ++i) {
1451
+ rect[0] = i * size;
1452
+ rect[1] = 0;
1453
+ rect[2] = i * size;
1454
+ rect[3] = height;
1455
+ line = null;
1456
+ line = new fabric.Line(rect, {
1457
+ stroke: "#999",
1458
+ opacity: 0.5,
1459
+ });
1460
+ line.rowName = "grid";
1461
+ line.selectable = false;
1462
+ canvas.add(line);
1463
+ line.sendToBack();
1464
+ }
1465
+
1466
+ for (let i = 0; i < Math.ceil(height / 20); ++i) {
1467
+ rect[0] = 0;
1468
+ rect[1] = i * size;
1469
+ rect[2] = width;
1470
+ rect[3] = i * size;
1471
+ line = null;
1472
+ line = new fabric.Line(rect, {
1473
+ stroke: "#999",
1474
+ opacity: 0.5,
1475
+ });
1476
+ line.rowName = "grid";
1477
+ line.selectable = false;
1478
+ canvas.add(line);
1479
+ line.sendToBack();
1480
+ }
1481
+
1482
+ canvas.renderAll();
1483
+ }
1484
+
1485
+ class Grid {
1486
+ constructor(opt) {
1487
+ this.opt = opt;
1488
+ this.init();
1489
+ }
1490
+
1491
+ idName = "inl-tp-editor-grid";
1492
+ idBoxName = "inl-tp-editor-grid-box";
1493
+ renderState = false;
1494
+
1495
+ init() {
1496
+ this.resetOpt();
1497
+ this.addElement();
1498
+ }
1499
+
1500
+ renderGrid() {
1501
+ renderGrid(this.canvas);
1502
+ }
1503
+
1504
+ clearGrid() {
1505
+ for (let i of this.canvas.getObjects()) {
1506
+ if (i.rowName === "grid") {
1507
+ this.canvas.remove(i);
1508
+ }
1509
+ }
1510
+
1511
+ this.renderState = false;
1512
+ }
1513
+
1514
+ changeBackground(s, cb) {
1515
+ this.canvas.setBackgroundColor(s, () => {
1516
+ cb ? cb() : "";
1517
+ this.canvas.renderAll();
1518
+ });
1519
+ }
1520
+
1521
+ resetGrid() {
1522
+ this.clearGrid();
1523
+ this.renderGrid();
1524
+ this.renderState = true;
1525
+ }
1526
+
1527
+ resetOpt() {}
1528
+
1529
+ addElement() {
1530
+ const boxDom = document.getElementById(this.opt.boxId);
1531
+ const GridCanvasDom = createElementId(this.idName, this.idName, "canvas");
1532
+ const GridCanvasBoxDom = createElementId(this.idBoxName, this.idBoxName);
1533
+ GridCanvasBoxDom.appendChild(GridCanvasDom);
1534
+ GridCanvasBoxDom.setAttribute(
1535
+ "style",
1536
+ `position:absolute; top: ${this.opt.scaleHd}px; left: ${this.opt.scaleHd}px; right: 0; bottom: 0; z-index: 0;`
1537
+ );
1538
+ boxDom.appendChild(GridCanvasBoxDom);
1539
+ this.canvas = new fabric.Canvas(this.idName);
1540
+ new windowResize({
1541
+ canvas: this.canvas,
1542
+ id: this.idBoxName,
1543
+ cb: () => {
1544
+ if (this.renderState) {
1545
+ this.resetGrid();
1546
+ }
1547
+ },
1548
+ });
1549
+ }
1550
+ }
1551
+
1552
+ const mtipSvgCustomData = function () {
1553
+ return {
1554
+ data: this.data || {},
1555
+ id: this.id,
1556
+ };
1557
+ };
1558
+
1559
+ const resetFabric = () => {
1560
+ const newList = [
1561
+ "Line",
1562
+ "Polyline",
1563
+ "Triangle",
1564
+ "Group",
1565
+ "Rect",
1566
+ "Point",
1567
+ "Path",
1568
+ "Circle",
1569
+ "Textbox",
1570
+ "Image",
1571
+ "Text",
1572
+ "IText",
1573
+ ];
1574
+
1575
+ for (let i of newList) {
1576
+ fabric[i].prototype["toObject"] = (function (toObject) {
1577
+ return function () {
1578
+ return fabric.util.object.extend(
1579
+ toObject.call(this),
1580
+ mtipSvgCustomData.call(this)
1581
+ );
1582
+ };
1583
+ })(fabric[i].prototype["toObject"]);
1584
+ }
1585
+ };
1586
+
1587
+ function loadJsonString(s, cb) {
1588
+ this.canvas.clear(); // 简单辨型
1589
+
1590
+ const loadData = typeof s === "string" ? JSON.parse(s) : s;
1591
+ this.canvas.loadFromJSON(loadData, (objeats) => {
1592
+ this.canvas._objects.forEach((item, key) => {
1593
+ if (this.opt.isPreview) {
1594
+ item.selectable = false;
1595
+ const isLine = item.data && item.data.effectType === "";
1596
+ const triangle = item.data && item.data.effectType === "";
1597
+
1598
+ if (isLine && triangle) {
1599
+ this.setLevel(item, Levels.top);
1600
+ }
1601
+ } else {
1602
+ if (item.data.effectType === "line") {
1603
+ updateLine(this, item);
1604
+ }
1605
+ }
1606
+ });
1607
+
1608
+ cb ? cb() : "";
1609
+ });
1610
+ }
1611
+
1612
+ class Scale {
1613
+ constructor(opt) {
1614
+ this.resetOpt(opt);
1615
+ this.init();
1616
+ }
1617
+
1618
+ idxbx = "inl-editor-scale-x";
1619
+ idybx = "inl-editor-scale-y";
1620
+ idx = "inl-editor-scale-x-c";
1621
+ idy = "inl-editor-scale-y-c"; // 标尺厚度
1622
+
1623
+ scaleHou = 15;
1624
+
1625
+ init() {
1626
+ this.addElement();
1627
+ this.createScaleCanvas();
1628
+
1629
+ this._renderScale();
1630
+ }
1631
+
1632
+ resetOpt(opt) {
1633
+ this.scaleHou = opt.scaleHou || 15;
1634
+ const useOpt = Object.assign(
1635
+ {},
1636
+ {
1637
+ width: this.scaleHou,
1638
+ height: this.scaleHou,
1639
+ bcoler: "#fff",
1640
+ },
1641
+ opt
1642
+ );
1643
+ this.opt = useOpt;
1644
+ }
1645
+
1646
+ renderAfter() {
1647
+ this.scaleX.setBackgroundColor(this.opt.bcoler, () => {});
1648
+ this.scaleY.setBackgroundColor(this.opt.bcoler, () => {});
1649
+ } // 添加元素
1650
+
1651
+ addElement() {
1652
+ const boxDom = document.getElementById(this.opt.boxId);
1653
+ boxDom.setAttribute("style", `position: relative; `);
1654
+ const scaleX = createElementId("inl-editor-scale-x", "inl-editor-scale-x");
1655
+ const scaleY = createElementId("inl-editor-scale-y", "inl-editor-scale-y");
1656
+ const scaleCX = createElementId("inl-editor-scale-x-c", this.idx, "canvas");
1657
+ const scaleCY = createElementId("inl-editor-scale-y-c", this.idy, "canvas");
1658
+ scaleX.setAttribute(
1659
+ "style",
1660
+ `height: ${this.opt.height}px; position: absolute;z-index:1; top: 0; left:${this.opt.height}px; right:0; overflow:hidden;`
1661
+ );
1662
+ scaleY.setAttribute(
1663
+ "style",
1664
+ ` width: ${this.opt.width}px; position: absolute;z-index:1; top: ${this.opt.width}px; left: 0; bottom:0; overflow:hidden;`
1665
+ );
1666
+ boxDom.appendChild(scaleX);
1667
+ boxDom.appendChild(scaleY);
1668
+ scaleX.appendChild(scaleCX);
1669
+ scaleY.appendChild(scaleCY);
1670
+ }
1671
+
1672
+ scaleX;
1673
+ scaleY; // 创建刻度元素
1674
+
1675
+ createScaleCanvas() {
1676
+ const scaleX = new fabric.Canvas(this.idx);
1677
+ const scaleY = new fabric.Canvas(this.idy);
1678
+ this.scaleX = scaleX;
1679
+ this.scaleY = scaleY;
1680
+ new windowResize({
1681
+ canvas: scaleX,
1682
+ id: this.idxbx,
1683
+ });
1684
+ new windowResize({
1685
+ canvas: scaleY,
1686
+ id: this.idybx,
1687
+ });
1688
+ this.renderAfter();
1689
+ return {
1690
+ scaleX,
1691
+ scaleY,
1692
+ };
1693
+ } // 渲染刻度
1694
+
1695
+ _renderScale() {
1696
+ const zoom = this.opt.drawCanvas.getZoom();
1697
+ const cheight = this.opt.drawCanvas.getHeight();
1698
+ const cwidth = this.opt.drawCanvas.getWidth();
1699
+ this.opt.drawCanvas.viewportTransform[4];
1700
+ this.opt.drawCanvas.viewportTransform[5];
1701
+ const sl = this.scaleHou * 0.6;
1702
+ const bl = this.scaleHou;
1703
+ const xLength = cwidth * zoom * 0.6;
1704
+ const yLength = cheight * zoom; // 先不做运动计算
1705
+
1706
+ const createLineInfo = (i, isX) => {
1707
+ const rect = [0, 0, 0, 0];
1708
+ const val = i + 1;
1709
+ const strokeWidth = val % 10 === 0 && i !== 0 ? 1 : 1;
1710
+ const opacity = val % 10 === 0 && i !== 0 ? 1 : 1;
1711
+ const text = new fabric.Text(val % 10 === 0 ? val + "" : "");
1712
+ text.fontSize = 8;
1713
+ text.fill = "#354052";
1714
+
1715
+ if (isX) {
1716
+ rect[0] = i * 10;
1717
+ rect[1] = bl;
1718
+ rect[2] = i * 10;
1719
+ rect[3] = val % 10 ? sl : 0;
1720
+ text.set({
1721
+ top: -2,
1722
+ left: rect[0] + 1,
1723
+ });
1724
+ } else {
1725
+ rect[0] = val % 10 ? sl : 0;
1726
+ rect[1] = i * 10;
1727
+ rect[2] = bl;
1728
+ rect[3] = i * 10;
1729
+ text.set({
1730
+ top: rect[3],
1731
+ left: 0,
1732
+ });
1733
+ }
1734
+
1735
+ const line = new fabric.Line(rect, {
1736
+ stroke: "#F2F3F8",
1737
+ strokeWidth,
1738
+ opacity,
1739
+ });
1740
+ line.selectable = false;
1741
+ return {
1742
+ line,
1743
+ text,
1744
+ };
1745
+ }; // x 轴
1746
+
1747
+ for (let i = -xLength; i <= xLength; i++) {
1748
+ const { line, text } = createLineInfo(i, true);
1749
+ this.scaleX.add(line, text);
1750
+ } // y轴
1751
+
1752
+ for (let i = -yLength; i <= yLength; i++) {
1753
+ const { line, text } = createLineInfo(i, false);
1754
+ this.scaleY.add(line, text);
1755
+ }
1756
+
1757
+ this.scaleX.renderAll(); // 绘制网格尺
1758
+ }
1759
+
1760
+ renderScale(cb) {
1761
+ this._renderScale();
1762
+
1763
+ if (cb) {
1764
+ cb();
1765
+ }
1766
+ }
1767
+
1768
+ clear() {
1769
+ this.scaleX.clear();
1770
+ this.scaleY.clear();
1771
+ }
1772
+
1773
+ setVpt(x, y, evt) {
1774
+ this.scaleX.viewportTransform[4] = x;
1775
+ this.scaleY.viewportTransform[5] = y;
1776
+ this.scaleX.renderAll();
1777
+ this.scaleY.renderAll();
1778
+ this.scaleX.lastPosX = evt.clientX;
1779
+ this.scaleY.lastPosY = evt.clientY;
1780
+ }
1781
+
1782
+ move() {}
1783
+ }
1784
+
1785
+ const updateImg = (canvas, id, src) => {
1786
+ const rect = getObjById(canvas, id);
1787
+ fabric.loadSVGFromURL(
1788
+ src || "/images/device/长皮带_2D_红.svg", // "/api/thing/v1/photo/thing4218B0244E0C4083B88E574F7F038C1E.svg",
1789
+ (objects, options) => {
1790
+ const svg = fabric.util.groupSVGElements(objects);
1791
+ svg.id = rect.id;
1792
+ svg.data = rect.data;
1793
+ svg.top = rect.top;
1794
+ svg.left = rect.left;
1795
+ svg.angle = rect.angle;
1796
+ canvas.remove(rect);
1797
+ canvas.add(svg);
1798
+ canvas.renderAll();
1799
+ }
1800
+ );
1801
+ }; // 提供更新块上文字的方法
1802
+
1803
+ const updateState = (canvas, id, value, isPropertyName) => {
1804
+ const obj = getObjById(canvas, id);
1805
+
1806
+ if (obj.text.indexOf(":") > -1) {
1807
+ const arr = obj.text.split(":");
1808
+ obj.text = isPropertyName ? `${arr[0]}:` : value;
1809
+ } else {
1810
+ obj.text = value;
1811
+ }
1812
+
1813
+ canvas.renderAll();
1814
+ };
1815
+
1816
+ class inlTpEditor {
1817
+ constructor(opt) {
1818
+ this.opt = opt;
1819
+ this.config = { ...config, ...opt.config };
1820
+ this.init();
1821
+ }
1822
+
1823
+ elementId = "inl-editor-canvas" + UUID(8);
1824
+ enums = {
1825
+ Alignparam,
1826
+ LineState,
1827
+ Levels,
1828
+ };
1829
+
1830
+ newCanvas() {
1831
+ const canvasDomBox = createElementId(
1832
+ this.elementId + "-box",
1833
+ this.elementId + "-box"
1834
+ );
1835
+ const canvasDm = createElementId(this.elementId, this.elementId, "canvas");
1836
+ const boxDom = document.getElementById(this.opt.boxElement);
1837
+ canvasDomBox.setAttribute(
1838
+ "style",
1839
+ `position: absolute; top: ${this.opt.scaleHd || 15}px; left: ${
1840
+ this.opt.scaleHd || 15
1841
+ }px; right: 0; bottom: 0;z-index:1;`
1842
+ );
1843
+ canvasDomBox.appendChild(canvasDm);
1844
+ boxDom.appendChild(canvasDomBox);
1845
+ this.canvas = new fabric.Canvas(this.elementId, {
1846
+ preserveObjectStacking: true,
1847
+ ...this.opt.fConfig,
1848
+ }); // 根据外部盒子控制 canvas大小
1849
+
1850
+ new windowResize({
1851
+ canvas: this.canvas,
1852
+ id: this.opt.boxElement,
1853
+ });
1854
+ } // 所有包裹元素 刻度尺和canvas
1855
+
1856
+ init() {
1857
+ const opt = this.opt;
1858
+ resetFabric();
1859
+ this.newCanvas();
1860
+ this.id = opt.id || util.UUID();
1861
+
1862
+ if (this.opt.url) {
1863
+ this.loadJsonString(this.opt.url, () => {
1864
+ this.initEditorBackground();
1865
+ });
1866
+ } else {
1867
+ this.canvas.setBackgroundColor(config.canvas.bc, () => {});
1868
+ } // 注册事件
1869
+
1870
+ this.injectEvent(); // 网格
1871
+
1872
+ this.grid = new Grid({
1873
+ boxId: this.opt.boxElement || "",
1874
+ canvas: this.canvas,
1875
+ scaleHd: this.opt.scaleHd || 15,
1876
+ });
1877
+
1878
+ if (!this.opt.isPreview) {
1879
+ // 游标卡尺 刻度尺
1880
+ this.scale = new Scale({
1881
+ boxId: opt.boxElement,
1882
+ drawCanvas: this.canvas,
1883
+ scaleHou: this.opt.scaleHd || 15,
1884
+ });
1885
+ }
1886
+ } // 编辑状态下初始化背景色
1887
+
1888
+ initEditorBackground() {
1889
+ const bc = this.canvas.backgroundColor || config.canvas.bc;
1890
+
1891
+ if (bc) {
1892
+ this.setBackground(bc);
1893
+ this.canvas.setBackgroundColor(config.canvas.bc, () => {});
1894
+ this.canvas.renderAll();
1895
+ }
1896
+ } // 修改背景色
1897
+
1898
+ setBackground(s, cb) {
1899
+ if (this.grid) {
1900
+ this.grid.changeBackground(s, cb);
1901
+ } else {
1902
+ this.canvas.setBackgroundColor(s, () => {
1903
+ cb ? cb() : "";
1904
+ });
1905
+ this.canvas.renderAll();
1906
+ }
1907
+ } // 获取背景色
1908
+
1909
+ getBackground() {
1910
+ if (this.grid) {
1911
+ return this.grid.canvas.backgroundColor;
1912
+ }
1913
+
1914
+ return this.canvas.backgroundColor;
1915
+ } // 显示隐藏grid
1916
+
1917
+ changeGridVisibility() {
1918
+ if (this.grid.renderState) {
1919
+ this.grid.clearGrid();
1920
+ } else {
1921
+ this.grid.resetGrid();
1922
+ }
1923
+ }
1924
+
1925
+ scale;
1926
+ grid; // 设置颜色
1927
+
1928
+ setLineColor(line, color) {
1929
+ line.set("stroke", color);
1930
+ const tri = getObjById(this.canvas, line.data.triangleId);
1931
+ tri?.set("fill", color);
1932
+ this.canvas.renderAll();
1933
+ } // 设置新增状态
1934
+
1935
+ setState(state) {
1936
+ this.state = state;
1937
+
1938
+ if (state === "createLine") {
1939
+ this.canvas.selection = false;
1940
+ this.canvas.getObjects().forEach((item) => {
1941
+ item.selectable = false;
1942
+ });
1943
+
1944
+ if (this.canvas.getActiveObject()) {
1945
+ this.canvas.getActiveObject().lockMovementX = true;
1946
+ this.canvas.getActiveObject().lockMovementY = true;
1947
+ }
1948
+ } else if (state === "") {
1949
+ this.canvas.selection = true;
1950
+ this.canvas.getObjects().map((item) => {
1951
+ if (item.data?.effectType !== "triangle") {
1952
+ item.selectable = true;
1953
+ }
1954
+
1955
+ if (
1956
+ item.data?.effectType !== "line" &&
1957
+ item.data?.effectType !== "triangle"
1958
+ ) {
1959
+ item.lockMovementX = false;
1960
+ item.lockMovementY = false;
1961
+ }
1962
+
1963
+ return item;
1964
+ });
1965
+ }
1966
+ } // 合理化布局
1967
+
1968
+ zoomToFitCanvas() {
1969
+ zoomToFitCanvas(this.canvas);
1970
+ } // 绘制方法
1971
+
1972
+ draw = Draw.bind(this)(); // 更新设备图
1973
+
1974
+ updateImg = updateImg; // 更新设备值
1975
+
1976
+ updateState = updateState; // 居中对齐方法
1977
+
1978
+ align = fabricItemAlign.bind(this); // 设置元素层级
1979
+
1980
+ setLevel = setLevel.bind(this); // 注入方法
1981
+
1982
+ injectEvent() {
1983
+ // 注册事件
1984
+ Event.bind(this)(this.canvas, {
1985
+ boxElement: this.opt.boxElement,
1986
+ isPreview: this.opt.isPreview,
1987
+ });
1988
+ } // 翻转元素方法
1989
+
1990
+ flip = {
1991
+ x: () => {
1992
+ const object = this.canvas.getActiveObject();
1993
+ const state = object.flipX;
1994
+ setInfo(this.canvas, object, {
1995
+ flipX: !state,
1996
+ });
1997
+ },
1998
+ y: () => {
1999
+ const object = this.canvas.getActiveObject();
2000
+ const state = object.flipY;
2001
+ setInfo(this.canvas, object, {
2002
+ flipY: !state,
2003
+ });
2004
+ },
2005
+ }; // to canvas 反序列化
2006
+
2007
+ loadJsonString = loadJsonString.bind(this); // to json 序列化json
2008
+
2009
+ toJson() {
2010
+ if (this.grid) {
2011
+ this.canvas.setBackgroundColor(
2012
+ this.getBackground() || config.canvas.bc,
2013
+ () => {}
2014
+ );
2015
+ }
2016
+
2017
+ const json = JSON.stringify(this.canvas.toJSON());
2018
+ this.canvas.setBackgroundColor(config.canvas.bc, () => {});
2019
+ return json;
2020
+ } // 工具
2021
+
2022
+ util = util; // canvas 转图片
2023
+
2024
+ toImg() {
2025
+ if (this.grid) {
2026
+ this.canvas.setBackgroundColor(
2027
+ this.getBackground() || config.canvas.bc,
2028
+ () => {}
2029
+ );
2030
+ }
2031
+
2032
+ const img = this.canvas.toDataURL({
2033
+ format: "image/png",
2034
+ });
2035
+ this.canvas.setBackgroundColor(config.canvas.bc, () => {});
2036
+ return img;
2037
+ } // 添加元素时触发
2038
+
2039
+ onAddElement(callBack) {
2040
+ this.canvas.on("object:added", (e) => {
2041
+ callBack(e.target);
2042
+ });
2043
+ } // 当某个页面元素被删除时触发
2044
+
2045
+ onElementRemove(callBack) {
2046
+ this.canvas.on("object:removed", (e) => {
2047
+ callBack(e.target);
2048
+ });
2049
+ } // 销毁 全局注销
2050
+
2051
+ destroy() {}
2052
+ }
2053
+
2054
+ export { LineAnimate, inlTpEditor as default };
2055
+ //# sourceMappingURL=index.js.map