物管理前端
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.

376 lines
36 KiB

  1. const e="7e8fef9d-423e-42fc-87af-d6735bd8cca0",t="horizontal-elliptical-tank",a="水平2比1椭圆水箱",n=`<svg preserveAspectRatio="xMidYMid meet" viewBox="0 0 233 201" fill="none" xmlns="http://www.w3.org/2000/svg">
  2. <path fill-rule="evenodd" clip-rule="evenodd" d="M27.5 175.5C18.5 175.5 1.5 156.5 1.5 111.5C1.5 66.5 19.5 47.5 27.4999 47.5H205.5C213.5 47.5 231.5 66.5 231.5 111.5C231.5 156.5 214.5 175.5 205.5 175.5H27.5Z" fill="#6216FF" fill-opacity="0"/>
  3. <path class="tb-shape-fill" d="M0.5 111.5C0.5 134.119 4.77161 150.285 10.2371 160.835C12.969 166.108 16.01 169.998 18.9848 172.583C21.9415 175.152 24.9166 176.5 27.5 176.5V174.5C25.5834 174.5 23.0585 173.473 20.2965 171.073C17.5525 168.689 14.656 165.017 12.0129 159.915C6.72839 149.715 2.5 133.881 2.5 111.5H0.5ZM27.4999 46.5C25.1452 46.5 22.2907 47.8693 19.4004 50.4224C16.4803 53.0019 13.4107 56.8857 10.6165 62.1566C5.02539 72.7034 0.5 88.871 0.5 111.5H2.5C2.5 89.129 6.97461 73.2966 12.3835 63.0934C15.0893 57.9893 18.0197 54.3106 20.7245 51.9213C23.4592 49.5057 25.8546 48.5 27.4999 48.5V46.5ZM205.5 46.5H27.4999V48.5H205.5V46.5ZM232.5 111.5C232.5 88.871 227.975 72.7034 222.384 62.1566C219.589 56.8857 216.52 53.0019 213.6 50.4224C210.709 47.8693 207.855 46.5 205.5 46.5V48.5C207.145 48.5 209.541 49.5057 212.275 51.9213C214.98 54.3106 217.911 57.9893 220.616 63.0934C226.025 73.2966 230.5 89.129 230.5 111.5H232.5ZM205.5 176.5C208.083 176.5 211.058 175.152 214.015 172.583C216.99 169.998 220.031 166.108 222.763 160.835C228.228 150.285 232.5 134.119 232.5 111.5H230.5C230.5 133.881 226.272 149.715 220.987 159.915C218.344 165.017 215.447 168.689 212.704 171.073C209.942 173.473 207.417 174.5 205.5 174.5V176.5ZM27.5 176.5H205.5V174.5H27.5V176.5Z" fill="#242770"/>
  4. <mask id="mask0_3572_11071" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="4" y="50" width="225" height="123">
  5. <path fill-rule="evenodd" clip-rule="evenodd" d="M27.5 172.5C21.5 172.5 4.5 154.391 4.5 111.5C4.5 68.6094 21.5 50.5 27.4999 50.5H205.5C211.5 50.5 228.5 68.6094 228.5 111.5C228.5 154.391 211.5 172.5 205.5 172.5H27.5Z" fill="#F1F1F9"/>
  6. </mask>
  7. <g mask="url(#mask0_3572_11071)">
  8. <rect class="tb-liquid-fill tb-liquid" x="4.5" y="118.5" width="224" height="122" fill="#7A8BFF"/>
  9. <rect class="tb-liquid-surface tb-liquid" x="4.5" y="118.5" width="224" height="1" fill="#7A8BFF"/>
  10. <rect class="tb-liquid-surface" x="4.5" y="118.5" width="224" height="1" fill="white" fill-opacity="0.1"/>
  11. </g>
  12. <path class="tb-shape-stroke" d="M48.5 47.5C41.7084 69.7745 32.2001 126.559 48.5 175.5" stroke="#242770" stroke-width="2"/>
  13. <path class="tb-shape-stroke" d="M184.5 47.5C177.708 69.7745 168.2 126.559 184.5 175.5" stroke="#242770" stroke-width="2"/>
  14. <mask id="path-8-inside-1_3572_11071" fill="white">
  15. <path fill-rule="evenodd" clip-rule="evenodd" d="M131.5 30.5H102.5V48.5C102.5 50.1569 108.992 51.5 117 51.5C125.008 51.5 131.5 50.1569 131.5 48.5V30.5Z"/>
  16. </mask>
  17. <path fill-rule="evenodd" clip-rule="evenodd" d="M131.5 30.5H102.5V48.5C102.5 50.1569 108.992 51.5 117 51.5C125.008 51.5 131.5 50.1569 131.5 48.5V30.5Z"/>
  18. <path class="tb-shape-fill" d="M102.5 30.5V28.5H100.5V30.5H102.5ZM131.5 30.5H133.5V28.5H131.5V30.5ZM102.5 32.5H131.5V28.5H102.5V32.5ZM104.5 48.5V30.5H100.5V48.5H104.5ZM117 49.5C113.09 49.5 109.607 49.1707 107.152 48.6628C105.908 48.4055 105.034 48.1232 104.518 47.8712C104.257 47.7431 104.191 47.6721 104.217 47.6982C104.248 47.7304 104.5 48.0048 104.5 48.5H100.5C100.5 49.4095 100.954 50.0882 101.373 50.511C101.785 50.9277 102.289 51.2334 102.761 51.4643C103.713 51.9301 104.962 52.2943 106.342 52.5798C109.135 53.1577 112.902 53.5 117 53.5V49.5ZM129.5 48.5C129.5 48.0048 129.752 47.7304 129.783 47.6982C129.809 47.6721 129.743 47.7431 129.482 47.8712C128.966 48.1232 128.092 48.4055 126.848 48.6628C124.393 49.1707 120.91 49.5 117 49.5V53.5C121.098 53.5 124.865 53.1577 127.658 52.5798C129.038 52.2943 130.287 51.9301 131.239 51.4643C131.711 51.2334 132.215 50.9277 132.627 50.511C133.046 50.0882 133.5 49.4095 133.5 48.5H129.5ZM129.5 30.5V48.5H133.5V30.5H129.5Z" fill="#242770" mask="url(#path-8-inside-1_3572_11071)"/>
  19. <path class="tb-shape-stroke" d="M117 33.5C121.236 33.5 125.045 33.167 127.77 32.6395C129.141 32.3742 130.187 32.0692 130.866 31.7584C131.077 31.662 131.231 31.5742 131.341 31.5C131.231 31.4258 131.077 31.338 130.866 31.2416C130.187 30.9308 129.141 30.6258 127.77 30.3605C125.045 29.833 121.236 29.5 117 29.5C112.764 29.5 108.955 29.833 106.23 30.3605C104.859 30.6258 103.813 30.9308 103.134 31.2416C102.923 31.338 102.769 31.4258 102.659 31.5C102.769 31.5742 102.923 31.662 103.134 31.7584C103.813 32.0692 104.859 32.3742 106.23 32.6395C108.955 33.167 112.764 33.5 117 33.5Z" stroke="#242770" stroke-width="2"/>
  20. <path class="tb-shape-stroke" d="M117 30.5C121.236 30.5 125.045 30.167 127.77 29.6395C129.141 29.3742 130.187 29.0692 130.866 28.7584C131.077 28.662 131.231 28.5742 131.341 28.5C131.231 28.4258 131.077 28.338 130.866 28.2416C130.187 27.9308 129.141 27.6258 127.77 27.3605C125.045 26.833 121.236 26.5 117 26.5C112.764 26.5 108.955 26.833 106.23 27.3605C104.859 27.6258 103.813 27.9308 103.134 28.2416C102.923 28.338 102.769 28.4258 102.659 28.5C102.769 28.5742 102.923 28.662 103.134 28.7584C103.813 29.0692 104.859 29.3742 106.23 29.6395C108.955 30.167 112.764 30.5 117 30.5Z" stroke="#242770" stroke-width="2"/>
  21. </svg>
  22. `,l="svg",i="大屏",o="水位",u=!1,c=!0,s="时间",r=`{"type":"page","id":"u:270584784ce1","name":"page1","asideResizor":false,"style":{"boxShadow":" 0px 0px 0px 0px transparent"},"pullRefresh":{"disabled":true},"body":[{"type":"tabs","name":"tab","tabs":[{"title":"样式","icon":"fa fa-th-large","body":[{"type":"form","title":"","name":"basicPropForm","body":[{"type":"input-text","label":"名称","name":"nodeAlias","id":"u:6b126f0520cb","size":"full","mode":"horizontal","inputControlClassName":"w-100","className":"m-b"},{"type":"input-text","label":"ID&nbsp;&nbsp;&nbsp;&nbsp;","name":"id","id":"u:6232710ac003","size":"full","mode":"horizontal","inputControlClassName":"w-100","className":"m-b"},{"type":"grid","id":"u:c605398a724c","className":"m-b","columns":[{"body":[{"type":"input-number","label":"宽度","name":"width","keyboard":true,"id":"u:dcc0c21d16f6","step":1,"suffix":"px","placeholder":"组件左边距","size":"full","mode":"horizontal","className":"m-b","value":200,"labelAlign":"left","precision":2,"inputClassName":"w-full","labelClassName":"w-8"}],"id":"u:14cc19d6ffb0","md":6},{"body":[{"type":"input-number","label":"高度","name":"height","keyboard":true,"id":"u:cd6fdff9ca88","step":1,"suffix":"px","placeholder":"组件上边距","size":"full","mode":"horizontal","className":"m-b","value":200,"labelAlign":"left","precision":2,"inputClassName":"w-full","labelClassName":"w-8"}],"id":"u:4931801ca9b8","md":6}]},{"type":"grid","id":"u:da449a94908a","className":"m-b","columns":[{"body":[{"type":"input-number","label":"X 轴","name":"x","keyboard":true,"id":"u:29852d093d9d","step":1,"suffix":"px","placeholder":"组件左边距","size":"full","mode":"horizontal","className":"m-b","value":200,"labelAlign":"left","precision":2,"inputClassName":"w-full","labelClassName":"w-8"}],"id":"u:1b561d652acc","md":6},{"body":[{"type":"input-number","label":"Y 轴","name":"y","keyboard":true,"id":"u:dc8c1daed8ed","step":1,"suffix":"px","placeholder":"组件上边距","size":"full","mode":"horizontal","className":"m-b","value":200,"labelAlign":"left","precision":2,"inputClassName":"w-full","labelClassName":"w-8"}],"id":"u:9672575193ac","md":6}]},{"type":"grid","id":"u:a332a7bf83c1","className":"m-b","columns":[{"body":[{"type":"input-number","label":"旋转","name":"rotation","id":"u:f6a2dbb518f9","placeholder":"组件旋转角度","mode":"horizontal","size":"full","className":"","keyboard":true,"step":1,"suffix":"deg","value":0,"labelAlign":"left","inputClassName":"w-full"}],"id":"u:646cd98b7955","md":6},{"body":[{"type":"input-number","label":"透明","name":"opacity","id":"u:cf80f59d8d42","placeholder":"组件透明度","mode":"horizontal","size":"full","className":"m-b","keyboard":true,"step":0,"suffix":"","value":1,"inputClassName":"w-full","precision":2}],"id":"u:51ddf54ac749","md":6}],"gap":""},{"type":"grid","columns":[],"id":"u:235f153e5ad5","className":"m-b"},{"type":"grid","columns":[{"body":[{"type":"input-color","label":"描边颜色","name":"strokeColor","id":"u:7783b65d58a9","mode":"horizontal","format":"rgba","inputClassName":"w-full"},{"type":"input-color","label":"液体颜色","name":"liquidColor","id":"u:76fa4643d6bd","format":"rgba","mode":"horizontal","inputClassName":"w-full"},{"type":"switch","label":"显示值","option":"","name":"showValue","falseValue":false,"trueValue":true,"id":"u:b52d7cc4b201","value":false,"mode":"horizontal","className":"m-b"}],"id":"u:83905272eb76"}],"id":"u:19e1ffafeb70","className":"m-b"},{"type":"select","id":"u:678a2c313b7f","label":"值类型","name":"valueType","options":[{"label":"百分比","value":"ratio"},{"label":"常规值","value":"normal"}],"multiple":false,"mode":"horizontal","inputClassName":"w-full"},{"type":"grid","id":"u:94b0e20f05da","columns":[{"body":[{"type":"input-color","label":"值颜色","name":"valueColor","id":"u:9b5b55cac08a","format":"rgba","mode":"horizontal","value":"rgba(245, 166, 35, 1)","className":"m-b","inputClassName":"w-full"},{"type":"input-number","label":"值字体大小","name":"valueFontSize","keyboard":true,"id":"u:06950e120b0a","st
  23. "nodes": [
  24. {
  25. "id": "e248c735-6256-422f-836a-61c59d332b7a",
  26. "type": "horizontal-elliptical-tank",
  27. "x": 200,
  28. "y": 200,
  29. "text": {
  30. "value": "",
  31. "x": 200,
  32. "y": 200
  33. },
  34. "properties": {
  35. "id": "e248c735-6256-422f-836a-61c59d332b7a",
  36. "width": 200,
  37. "height": 200,
  38. "x": 200,
  39. "y": 200,
  40. "rotation": 0,
  41. "opacity": 1,
  42. "showValue": true,
  43. "valueColor": "rgba(74, 144, 226, 1)",
  44. "warnColor": "rgba(245, 166, 35, 1)",
  45. "seriousColor": "rgba(208, 2, 27, 1)",
  46. "showUnit": true,
  47. "unitColor": "rgba(74, 144, 226, 1)",
  48. "nodeAlias": "水平2比1椭圆水箱",
  49. "showDefaultValue": false,
  50. "fontSize": 12,
  51. "strokeColor": "#242770",
  52. "liquidColor": "#7A8BFF",
  53. "valueType": "ratio",
  54. "valueFontSize": 16,
  55. "maxValue": 100,
  56. "warnValue": 75,
  57. "seriousValue": 90,
  58. "unitFontSize": 12,
  59. "dynamic": {
  60. "normalData": {
  61. "dataPoint": "",
  62. "compareType": "",
  63. "conditionVariables": [],
  64. "defaultValue": "",
  65. "unit": ""
  66. }
  67. }
  68. }
  69. }
  70. ]
  71. }`,javascript:`const { createApp, createVNode, render } = Vue;
  72. const app = createApp({})
  73. const defaultVal = 62;
  74. const HorizontalEllipticalTank = {
  75. template: \`<div>
  76. <svg preserveAspectRatio="xMidYMid meet" viewBox="0 0 233 201" fill="none"
  77. xmlns="http://www.w3.org/2000/svg" style="stroke: none;">
  78. <path fill-rule="evenodd" clip-rule="evenodd" d="M27.5 175.5C18.5 175.5 1.5 156.5 1.5 111.5C1.5 66.5 19.5 47.5 27.4999 47.5H205.5C213.5 47.5 231.5 66.5 231.5 111.5C231.5 156.5 214.5 175.5 205.5 175.5H27.5Z" fill="#6216FF" fill-opacity="0"/>
  79. <path class="tb-shape-fill" d="M0.5 111.5C0.5 134.119 4.77161 150.285 10.2371 160.835C12.969 166.108 16.01 169.998 18.9848 172.583C21.9415 175.152 24.9166 176.5 27.5 176.5V174.5C25.5834 174.5 23.0585 173.473 20.2965 171.073C17.5525 168.689 14.656 165.017 12.0129 159.915C6.72839 149.715 2.5 133.881 2.5 111.5H0.5ZM27.4999 46.5C25.1452 46.5 22.2907 47.8693 19.4004 50.4224C16.4803 53.0019 13.4107 56.8857 10.6165 62.1566C5.02539 72.7034 0.5 88.871 0.5 111.5H2.5C2.5 89.129 6.97461 73.2966 12.3835 63.0934C15.0893 57.9893 18.0197 54.3106 20.7245 51.9213C23.4592 49.5057 25.8546 48.5 27.4999 48.5V46.5ZM205.5 46.5H27.4999V48.5H205.5V46.5ZM232.5 111.5C232.5 88.871 227.975 72.7034 222.384 62.1566C219.589 56.8857 216.52 53.0019 213.6 50.4224C210.709 47.8693 207.855 46.5 205.5 46.5V48.5C207.145 48.5 209.541 49.5057 212.275 51.9213C214.98 54.3106 217.911 57.9893 220.616 63.0934C226.025 73.2966 230.5 89.129 230.5 111.5H232.5ZM205.5 176.5C208.083 176.5 211.058 175.152 214.015 172.583C216.99 169.998 220.031 166.108 222.763 160.835C228.228 150.285 232.5 134.119 232.5 111.5H230.5C230.5 133.881 226.272 149.715 220.987 159.915C218.344 165.017 215.447 168.689 212.704 171.073C209.942 173.473 207.417 174.5 205.5 174.5V176.5ZM27.5 176.5H205.5V174.5H27.5V176.5Z" :fill="finalStrokeColor"/>
  80. <mask id="mask0_3572_11071" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="4" y="50" width="225" height="123">
  81. <path fill-rule="evenodd" clip-rule="evenodd" d="M27.5 172.5C21.5 172.5 4.5 154.391 4.5 111.5C4.5 68.6094 21.5 50.5 27.4999 50.5H205.5C211.5 50.5 228.5 68.6094 228.5 111.5C228.5 154.391 211.5 172.5 205.5 172.5H27.5Z" fill="#F1F1F9"/>
  82. </mask>
  83. <g mask="url(#mask0_3572_11071)">
  84. <g clip-path="url(#clip0_3572_11071)" :id="chartId" style="transform: translateY(42%); transition: all 0.35s ease-in-out;" >
  85. <rect class="tb-liquid-fill tb-liquid" x="4.5" y="118.5" width="224" height="122" :fill="finalLiquidColor"/>
  86. <rect class="tb-liquid-surface tb-liquid" x="4.5" y="118.5" width="224" height="1" :fill="finalLiquidColor"/>
  87. <rect class="tb-liquid-surface" x="4.5" y="118.5" width="224" height="1" fill="white" fill-opacity="0.1"/>
  88. </g>
  89. </g>
  90. <path class="tb-shape-stroke" d="M48.5 47.5C41.7084 69.7745 32.2001 126.559 48.5 175.5" :stroke="finalStrokeColor" stroke-width="2"/>
  91. <path class="tb-shape-stroke" d="M184.5 47.5C177.708 69.7745 168.2 126.559 184.5 175.5" :stroke="finalStrokeColor" stroke-width="2"/>
  92. <mask id="path-8-inside-1_3572_11071" fill="white">
  93. <path fill-rule="evenodd" clip-rule="evenodd" d="M131.5 30.5H102.5V48.5C102.5 50.1569 108.992 51.5 117 51.5C125.008 51.5 131.5 50.1569 131.5 48.5V30.5Z"/>
  94. </mask>
  95. <path fill-rule="evenodd" clip-rule="evenodd" d="M131.5 30.5H102.5V48.5C102.5 50.1569 108.992 51.5 117 51.5C125.008 51.5 131.5 50.1569 131.5 48.5V30.5Z"/>
  96. <path class="tb-shape-fill" d="M102.5 30.5V28.5H100.5V30.5H102.5ZM131.5 30.5H133.5V28.5H131.5V30.5ZM102.5 32.5H131.5V28.5H102.5V32.5ZM104.5 48.5V30.5H100.5V48.5H104.5ZM117 49.5C113.09 49.5 109.607 49.1707 107.152 48.6628C105.908 48.4055 105.034 48.1232 104.518 47.8712C104.257 47.7431 104.191 47.6721 104.217 47.6982C104.248 47.7304 104.5 48.0048 104.5 48.5H100.5C100.5 49.4095 100.954 50.0882 101.373 50.511C101.785 50.9277 102.289 51.2334 102.761 51.4643C103.713 51.9301 104.962 52.2943 106.342 52.5798C109.135 53.1577 112.902 53.5 117 53.5V49.5ZM129.5 48.5C129.5 48.0048 129.752 47.7304 129.783 47.6982C129.809 47.6721 129.743 47.7431 129.482 47.8712C128.966 48.1232 128.092 48.4055 126.848 48.6628C124.393 49.1707 120.91 49.5 117 49.5V53.5C121.098 53.5 124.865 53.1577 127.658 52.5798C129.038 52.2943 130.287 51.9301 131.239 51.4643C131.711 51.2334 132.215 50.9277 132.627 50.511C133.046 50.0882 133.5 49.4095 133.5 48.5H129.5ZM129.5 30.5V48.5H133.5V30.5H129.5Z" :fill="finalStrokeColor" mask="url(#path-8-inside-1_3572_11071)"/>
  97. <path class="tb-shape-stroke" d="M117 33.5C121.236 33.5 125.045 33.167 127.77 32.6395C129.141 32.3742 130.187 32.0692 130.866 31.7584C131.077 31.662 131.231 31.5742 131.341 31.5C131.231 31.4258 131.077 31.338 130.866 31.2416C130.187 30.9308 129.141 30.6258 127.77 30.3605C125.045 29.833 121.236 29.5 117 29.5C112.764 29.5 108.955 29.833 106.23 30.3605C104.859 30.6258 103.813 30.9308 103.134 31.2416C102.923 31.338 102.769 31.4258 102.659 31.5C102.769 31.5742 102.923 31.662 103.134 31.7584C103.813 32.0692 104.859 32.3742 106.23 32.6395C108.955 33.167 112.764 33.5 117 33.5Z" :stroke="finalStrokeColor" stroke-width="2"/>
  98. <path class="tb-shape-stroke" d="M117 30.5C121.236 30.5 125.045 30.167 127.77 29.6395C129.141 29.3742 130.187 29.0692 130.866 28.7584C131.077 28.662 131.231 28.5742 131.341 28.5C131.231 28.4258 131.077 28.338 130.866 28.2416C130.187 27.9308 129.141 27.6258 127.77 27.3605C125.045 26.833 121.236 26.5 117 26.5C112.764 26.5 108.955 26.833 106.23 27.3605C104.859 27.6258 103.813 27.9308 103.134 28.2416C102.923 28.338 102.769 28.4258 102.659 28.5C102.769 28.5742 102.923 28.662 103.134 28.7584C103.813 29.0692 104.859 29.3742 106.23 29.6395C108.955 30.167 112.764 30.5 117 30.5Z" :stroke="finalStrokeColor" stroke-width="2"/>
  99. </svg>
  100. <div :style="getTitleStyle">
  101. <div>
  102. <span :style="valueStyle">{{valueStr}}</span><span :style="unitStyle">{{unitStr}}</span>
  103. </div>
  104. </div>
  105. </div>
  106. \`,
  107. props: {
  108. chartId: {
  109. type: String,
  110. default: ''
  111. },
  112. currentData: {
  113. type: Number,
  114. default: 100
  115. },
  116. width: {
  117. type: Number,
  118. default: 350
  119. },
  120. height: {
  121. type: Number,
  122. default: 150
  123. },
  124. chartProps: {
  125. type: Object,
  126. default: () => { }
  127. },
  128. thingName: {
  129. type: String,
  130. default: ''
  131. },
  132. attr: {
  133. type: String,
  134. default: ''
  135. },
  136. unit: {
  137. type: String,
  138. default: ''
  139. },
  140. },
  141. computed: {
  142. getTitleStyle() {
  143. return {
  144. position: 'absolute',
  145. top: '0px',
  146. bottom: \`0px\`,
  147. width: '100%',
  148. zIndex: 100,
  149. display: 'flex',
  150. justifyContent: 'center',
  151. alignItems: 'center'
  152. }
  153. }
  154. },
  155. setup(props) {
  156. const { computed, ref, watch, toRefs, nextTick } = Vue;
  157. const { chartProps, currentData, thingName, attr, width, height } = toRefs(props);
  158. let valueStr = ref('');
  159. let unitStr = ref('');
  160. let finalLiquidColor = ref('#7A8BFF');
  161. let finalStrokeColor = ref("#242770");
  162. const updateChart = (realValue, properties) => {
  163. const { warnValue, seriousValue, maxValue, warnColor, seriousColor, showValue, valueType, showUnit, unit, liquidColor, strokeColor } = properties;
  164. const ratio = (realValue / maxValue * 100).toFixed(2);
  165. if (showValue) {
  166. if (valueType === 'ratio') {
  167. valueStr.value = ratio + ''
  168. showUnit && (unitStr.value = '%')
  169. } else {
  170. valueStr.value = realValue + ''
  171. showUnit && (unitStr.value = unit)
  172. }
  173. }
  174. finalLiquidColor.value = liquidColor;
  175. finalStrokeColor.value = strokeColor;
  176. if (seriousValue && realValue >= seriousValue) {
  177. finalLiquidColor.value = seriousColor
  178. } else if (warnValue && realValue >= warnValue) {
  179. finalLiquidColor.value = warnColor
  180. }
  181. setTimeout(() => {
  182. const tankNode = document.getElementById(props.chartId);
  183. const liquidLevel = Math.round(27 - (realValue / maxValue * 61));
  184. tankNode.style.transform = \`translateY(\${liquidLevel}%)\`;
  185. }, 50)
  186. }
  187. watch([currentData, chartProps], ([val, properties]) => {
  188. nextTick(() => {
  189. updateChart(val, properties)
  190. })
  191. }, {
  192. immediate: true,
  193. deep: true,
  194. })
  195. const valueStyle = computed(() => {
  196. return {
  197. color: chartProps.value.valueColor,
  198. fontSize: chartProps.value.valueFontSize + 'px'
  199. }
  200. })
  201. const unitStyle = computed(() => {
  202. return {
  203. color: chartProps.value.unitColor,
  204. fontSize: chartProps.value.unitFontSize + 'px',
  205. marginLeft: '3px'
  206. }
  207. })
  208. return {
  209. valueStyle,
  210. unitStyle,
  211. valueStr,
  212. unitStr,
  213. finalLiquidColor,
  214. finalStrokeColor,
  215. }
  216. }
  217. }
  218. class HorizontalEllipticalTankNode extends HtmlResize.view {
  219. realValue = defaultVal
  220. oldProperties = {}
  221. chartRendered = false
  222. instance = null
  223. setHtml(rootEl) {
  224. if (!rootEl) return;
  225. const { properties, width, height } = this.props.model;
  226. const { normalData } = properties.dynamic || {}
  227. let thingName = 'pressure';
  228. let attr = 'score';
  229. if (normalData && normalData.dataPoint) {
  230. const dataPointStrParsed = JSON.parse(normalData.dataPoint || '{}')
  231. const { deviceCode, dataPoint } = dataPointStrParsed;
  232. thingName = deviceCode;
  233. attr = dataPoint.split(',')[0];
  234. }
  235. if (this.instance) {
  236. // 实时数据不能推送一次就创建一次图表,可以在原有实例基础之上更改数据。
  237. Object.assign(this.instance.component.props, {
  238. name: properties.nodeAlias,
  239. chartId: \`liquidlevel-\${properties.id}\`,
  240. currentData: this.realValue,
  241. width,
  242. height,
  243. chartProps: properties,
  244. thingName,
  245. attr,
  246. })
  247. return
  248. }
  249. const el = document.createElement('div');
  250. rootEl.innerHTML = '';
  251. const instance = createVNode(HorizontalEllipticalTank, {
  252. name: properties.nodeAlias,
  253. chartId: \`liquidLevel-\${properties.id}\`,
  254. currentData: this.realValue,
  255. width,
  256. height,
  257. chartProps: properties,
  258. thingName,
  259. attr,
  260. })
  261. instance.appContext = app._context
  262. render(instance, el)
  263. rootEl.appendChild(el);
  264. this.instance = instance;
  265. }
  266. sameProps(properties) {
  267. const isSame = window._.isEqual(this.oldProperties, properties);
  268. if (isSame) return true;
  269. this.oldProperties = properties;
  270. return false
  271. }
  272. // 生命周期 支持重写内容, 但格式需一致
  273. shouldUpdate() {
  274. const { properties } = this.props.model;
  275. const { normalData } = properties.dynamic || {};
  276. if (normalData && !normalData.dataPoint && !normalData.defaultValue) {
  277. this.realValue = defaultVal;
  278. return true
  279. }
  280. if (normalData) {
  281. const { defaultValue } = normalData || {};
  282. if (defaultValue) {
  283. const realValue = window.resolveScadaNewValue(defaultValue)
  284. if (this.realValue !== Number(realValue)) {
  285. this.realValue = Number(realValue);
  286. return true;
  287. }
  288. }
  289. }
  290. const propertiesBack = window._.cloneDeep(properties);
  291. if (propertiesBack.dynamic.normalData) {
  292. const isSameProps = this.sameProps(propertiesBack);
  293. if (isSameProps && this.chartRendered) {
  294. return false
  295. } else {
  296. if (!this.chartRendered) {
  297. this.chartRendered = true
  298. return true
  299. }
  300. if (!isSameProps) {
  301. return true;
  302. }
  303. }
  304. }
  305. }
  306. updateHtml() {
  307. this.setHtml(this.rootEl);
  308. }
  309. componentDidMount() {
  310. // 防止拖动时候频繁渲染图表
  311. this.updateHtmlDebounced = window._.debounce(this.updateHtml.bind(this), 500);
  312. if (this.shouldUpdate()) {
  313. this.setHtml(this.rootEl);
  314. }
  315. }
  316. componentDidUpdate() {
  317. if (this.shouldUpdate()) {
  318. this.updateHtmlDebounced();
  319. }
  320. }
  321. }
  322. class HorizontalEllipticalTankModel extends HtmlResize.model {
  323. initNodeData(data) {
  324. // 自定义组件,需最开始重置一下text 。
  325. data.text = {
  326. value: "",
  327. x: data.x,
  328. y: data.y,
  329. };
  330. super.initNodeData(data);
  331. const { properties } = this;
  332. this.width = properties.width || 80;
  333. this.height = properties.height || 35;
  334. this.text.editable = false; // 不允许文本被编辑
  335. }
  336. setAttributes() {
  337. // 自定义组件需重置 text
  338. const { x, y, properties } = this;
  339. const { textHorizontalMove = 0, textVerticalMove = 0 } = properties;
  340. this.text = {
  341. ...this.text,
  342. x: x + textHorizontalMove,
  343. y: y + textVerticalMove,
  344. value: "",
  345. }
  346. }
  347. }
  348. lf.register({
  349. type: 'horizontal-elliptical-tank',
  350. view: HorizontalEllipticalTankNode,
  351. model: HorizontalEllipticalTankModel,
  352. })
  353. `,css:"",fakeData:""},p={id:e,name:t,aliasName:a,image:n,imageType:l,groupName:i,groupType:o,isRemote:!1,isDefault:!0,sectionType:s,config:r,files:d};export{a as aliasName,r as config,p as default,d as files,i as groupName,o as groupType,e as id,n as image,l as imageType,c as isDefault,u as isRemote,t as name,s as sectionType};