物管理前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
3.2 KiB

  1. var animationHandler = (lfInstance, nodeId) => {
  2. const nodeData = lfInstance.getNodeDataById(nodeId)
  3. if (!nodeData) {
  4. return;
  5. }
  6. const { dynamic } = nodeData.properties
  7. if (dynamic) {
  8. const { animationData } = dynamic
  9. const { animationCombo } = animationData || {}
  10. if (animationCombo) {
  11. animationCombo.forEach((anim) => {
  12. if (anim.dataPoint && anim.animationName === '旋转') {
  13. const defaultValue = window.resolveScadaNewValue(anim.defaultValue || '[]')
  14. // 必须是最新值
  15. if (defaultValue === '') {
  16. lfInstance.setProperties(nodeData.id, {
  17. rotateAnimation: false,
  18. animationTime: anim.animationTime,
  19. })
  20. return
  21. }
  22. if (anim.min === '' || anim.max === '') {
  23. lfInstance.setProperties(nodeData.id, {
  24. rotateAnimation: false,
  25. animationTime: anim.animationTime,
  26. })
  27. return
  28. }
  29. if (Number(defaultValue) >= Number(anim.min) && defaultValue <= Number(anim.max)) {
  30. // 数据点在一定范围内旋转
  31. lfInstance.setProperties(nodeData.id, {
  32. rotateAnimation: true,
  33. animationTime: anim.animationTime,
  34. })
  35. }
  36. else {
  37. lfInstance.setProperties(nodeData.id, {
  38. rotateAnimation: false,
  39. animationTime: anim.animationTime,
  40. })
  41. }
  42. } else if (anim.dataPoint && anim.animationName === '闪烁') {
  43. const defaultValue = (window).resolveScadaNewValue(anim.defaultValue || '[]')
  44. // 必须是最新值
  45. if (defaultValue === '') {
  46. lfInstance.setProperties(nodeData.id, {
  47. blinkAnimation: false,
  48. })
  49. return
  50. }
  51. if (anim.min === '' || anim.max === '') {
  52. lfInstance.setProperties(nodeData.id, {
  53. blinkAnimation: false,
  54. })
  55. return
  56. }
  57. if (Number(defaultValue) >= Number(anim.min) && defaultValue <= Number(anim.max)) {
  58. // 数据点在一定范围内闪烁
  59. lfInstance.setProperties(nodeData.id, {
  60. blinkAnimation: true,
  61. })
  62. }
  63. else {
  64. lfInstance.setProperties(nodeData.id, {
  65. blinkAnimation: false,
  66. })
  67. }
  68. } else if (!anim.dataPoint && anim.animationName === '旋转') {
  69. // 清除动画绑定
  70. lfInstance.setProperties(nodeData.id, {
  71. rotateAnimation: false,
  72. })
  73. }
  74. else if (!anim.dataPoint && anim.animationName === '闪烁') {
  75. // 清除动画绑定
  76. lfInstance.setProperties(nodeData.id, {
  77. blinkAnimation: false,
  78. })
  79. }
  80. })
  81. const hasRotate = animationCombo.find((anim) => anim.animationName === '旋转')
  82. const hasBlink = animationCombo.find((anim) => anim.animationName === '闪烁')
  83. if (!hasRotate) {
  84. lfInstance.setProperties(nodeData.id, {
  85. rotateAnimation: false,
  86. })
  87. }
  88. if (!hasBlink) {
  89. lfInstance.setProperties(nodeData.id, {
  90. blinkAnimation: false,
  91. })
  92. }
  93. }
  94. }
  95. }