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

274 lines
72 KiB

  1. const e="65dcfc32-2dbf-4688-93f1-c441ce1faaf8",a="custom-image-node",t="图片",n='<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1685948569833" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2426" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M158.2 158.5h707.6c20.3 0 36.6 16.3 36.6 36.6v288.7c-36.6-28.5-105.7-73.2-158.6-73.2-77.3 0-146.4 178.9-231.8 178.9-65.1-4.1-154.5-77.3-256.2-65.1-40.7 8.1-97.6 73.2-134.2 122V195.1c0-20.4 16.3-36.6 36.6-36.6zM329 451.3c-32.5 0-61-12.2-81.3-32.5s-32.5-52.9-32.5-81.3c0-28.5 12.2-61 32.5-81.3 20.3-20.3 48.8-32.5 81.3-32.5 28.5 0 56.9 12.2 81.3 32.5 20.3 20.3 32.5 52.9 32.5 81.3 0 28.5-12.2 61-32.5 81.3-24.4 20.3-52.8 32.5-81.3 32.5z m557.1-345.7H137.9c-40.7 0-73.2 32.5-73.2 73.2v666.9c0 40.7 32.5 73.2 73.2 73.2h748.3c40.7 0 73.2-32.5 73.2-73.2V178.8c-0.1-40.7-32.6-73.2-73.3-73.2z m0 0" p-id="2427" fill="#707070"></path></svg>',i="svg",l="基础",o="常用",r=!1,m=!0,d="基础图形",s=`{"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:fc464664fb93","size":"full","mode":"horizontal","inputControlClassName":"w-100","className":"m-b"},{"type":"input-text","label":"ID&nbsp;&nbsp;&nbsp;&nbsp;","name":"id","id":"u:8a3fc64f07f6","size":"full","mode":"horizontal","inputControlClassName":"w-100","className":"m-b"},{"type":"grid","id":"u:1954dc15dd5b","className":"m-b","columns":[{"body":[{"type":"input-number","label":"宽度","name":"width","keyboard":true,"id":"u:656efdb758ad","step":1,"suffix":"px","placeholder":"组件宽度","size":"full","mode":"horizontal","className":"m-b","value":100,"labelClassName":"w-8","labelAlign":"left","precision":2,"inputClassName":"w-full"}],"id":"u:4274c47a4ef5","md":6},{"body":[{"type":"input-number","label":"高度","name":"height","keyboard":true,"id":"u:1ed6dcd98c1a","step":1,"suffix":"px","placeholder":"组件高度","size":"full","mode":"horizontal","className":"m-b","value":100,"labelAlign":"left","labelClassName":"w-8","precision":2,"inputClassName":"w-full"}],"id":"u:3e9d1e71a69f","md":6}]},{"type":"grid","id":"u:c605398a724c","className":"m-b","columns":[{"body":[{"type":"input-number","label":"X 轴","name":"x","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":"Y 轴","name":"y","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: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":"container","id":"u:26f912c2e955","className":"m-b","body":[{"type":"button","label":"素材库","onEvent":{"click":{"actions":[{"dialog":{"type":"dialog","title":"素材库","body":[{"type":"se
  2. "nodes": [
  3. {
  4. "id": "c04eb8bb-49d7-46c2-9804-15be1334b01f",
  5. "type": "custom-image-node",
  6. "x": 202,
  7. "y": 200,
  8. "text": {
  9. "value": "",
  10. "x": 202,
  11. "y": 200
  12. },
  13. "properties": {
  14. "id": "c04eb8bb-49d7-46c2-9804-15be1334b01f",
  15. "width": 100,
  16. "height": 100,
  17. "x": 202,
  18. "y": 200,
  19. "rotation": 0,
  20. "opacity": 1,
  21. "showHideContainChildren": false,
  22. "showDefaultValue": false,
  23. "showUnit": false,
  24. "strokeWidth": 1,
  25. "fontSize": 12,
  26. "borderDirection": "border",
  27. "nodeAlias": "图片",
  28. "href": "./defaultPic.svg",
  29. "dynamic": {
  30. "normalData": {
  31. "dataPoint": "",
  32. "compareType": "",
  33. "conditionVariables": [
  34. {
  35. "type": "rangeImage",
  36. "label": "范围/图片",
  37. "name": ""
  38. }
  39. ],
  40. "defaultValue": "[]",
  41. "unit": ""
  42. },
  43. "uiData": {
  44. "dataPoint": "",
  45. "compareType": "",
  46. "conditionVariables": [
  47. {
  48. "type": "rangeImage",
  49. "label": "范围/图片",
  50. "name": ""
  51. }
  52. ],
  53. "defaultValue": "[]"
  54. },
  55. "animationData": {
  56. "animationCombo": [
  57. {
  58. "min": "",
  59. "max": "",
  60. "animationName": "旋转",
  61. "defaultValue": "[]",
  62. "animationTime": 3,
  63. "dataPoint": ""
  64. },
  65. {
  66. "min": "",
  67. "max": "",
  68. "animationName": "闪烁",
  69. "defaultValue": "[]",
  70. "dataPoint": ""
  71. }
  72. ]
  73. },
  74. "hiddenData": {
  75. "hiddenCombo": [
  76. {
  77. "dataPoint": "",
  78. "min": "",
  79. "max": "",
  80. "showOrHiddenName": "隐藏",
  81. "defaultValue": "[]"
  82. },
  83. {
  84. "defaultValue": "[]",
  85. "showOrHiddenName": "显示",
  86. "dataPoint": ""
  87. }
  88. ]
  89. },
  90. "eventsData": {
  91. "eventCombo": [
  92. {
  93. "eventType": "click",
  94. "enable": false,
  95. "config": ""
  96. },
  97. {
  98. "eventType": "dblClick",
  99. "enable": false,
  100. "config": ""
  101. }
  102. ]
  103. }
  104. }
  105. }
  106. }
  107. ]
  108. }`,javascript:`const isLocal = window.location.origin.includes('localhost');
  109. const defaultPic = isLocal ? window.location.origin + '/defaultPic.svg' : window.location.origin + '/scada/defaultPic.svg';
  110. // 图片-基础节点
  111. class ImageModel extends RectResize.model {
  112. realValue = ''
  113. initNodeData(data) {
  114. // 自定义组件,需最开始重置一下text 。
  115. data.text = {
  116. value: "",
  117. x: data.x,
  118. y: data.y,
  119. };
  120. super.initNodeData(data)
  121. const { properties } = this;
  122. this.width = properties.width || 150;
  123. this.height = properties.height || 80;
  124. window.nodeEventsListeners(this);
  125. this.text.editable = false; // 不允许文本被编辑
  126. }
  127. setAttributes() {
  128. const { x, y, properties } = this;
  129. const { href, textHorizontalMove = 0, textVerticalMove = 0, dynamic } = properties;
  130. const { normalData } = dynamic || {};
  131. let textValue = properties.content || '';
  132. if (normalData) {
  133. const { defaultValue } = normalData || {}
  134. const realValue = window.resolveScadaNewValue(defaultValue);
  135. this.realValue = realValue;
  136. }
  137. const img = new Image()
  138. img.onerror = () => {
  139. properties.href = ''
  140. }
  141. img.src = href
  142. this.text = {
  143. ...this.text,
  144. x: x + textHorizontalMove,
  145. y: y + textVerticalMove,
  146. value: textValue,
  147. }
  148. }
  149. getNodeStyle() {
  150. const style = super.getNodeStyle();
  151. const { properties } = this;
  152. style.fill = properties.fill || style.fill;
  153. style.stroke = properties.strokeColor || style.stroke;
  154. style.strokeWidth = properties.strokeWidth || style.strokeWidth;
  155. style.opacity = properties.opacity || 1;
  156. return style;
  157. }
  158. getTextStyle() {
  159. const style = super.getTextStyle();
  160. const { properties } = this;
  161. style.color = properties.fontColor || style.color;
  162. style.fontSize = properties.fontSize || style.fontSize;
  163. const fontStyle = properties.fontStyle;
  164. if(fontStyle) {
  165. if (fontStyle.includes('bold')) {
  166. style.fontWeight = 'bolder';
  167. }
  168. if(fontStyle.includes('italic')) {
  169. style.fontStyle = 'italic'
  170. }
  171. if (fontStyle.includes('underline,line-through')) {
  172. style.textDecoration = 'underline line-through'
  173. } else if (fontStyle.includes('line-through,underline')) {
  174. style.textDecoration = 'line-through underline'
  175. } else if (fontStyle.includes('underline')) {
  176. style.textDecoration = 'underline'
  177. } else if (fontStyle.includes('line-through')) {
  178. style.textDecoration = 'line-through'
  179. }
  180. }
  181. return style;
  182. }
  183. getResizeOutlineStyle() {
  184. return {
  185. stroke: "#00ffff",
  186. strokeWidth: 1,
  187. strokeDasharray: "none",
  188. };
  189. }
  190. }
  191. class ImageNode extends RectResize.view {
  192. getImageHref(href) {
  193. return href;
  194. }
  195. getResizeShape() {
  196. const { x, y, width, height, properties } = this.props.model
  197. const finalWidth = width <= 10 ? 10 : width
  198. const finalHeight = height <= 10 ? 10 : height
  199. const { opacity, blinkAnimation } = properties;
  200. let href = this.getImageHref(properties.href || defaultPic.replace(null, ''))
  201. const { uiData } = properties.dynamic || {};
  202. if (uiData) {
  203. const realValue = window.resolveScadaNewValue(uiData.defaultValue)
  204. if(realValue !== '') {
  205. uiData.conditionVariables.forEach((item) => {
  206. if (item.type === 'rangeImage') {
  207. let from = item.from;
  208. let to = item.to;
  209. if (item.from >= item.to) {
  210. from = item.to;
  211. to = item.from;
  212. }
  213. if (item.imageUrl && Number(realValue) >= from && Number(realValue) <= to) {
  214. href = item.imageUrl;
  215. }
  216. } else if (item.type === 'booleanImage') {
  217. const trueFlags = ['true', true]
  218. const falseFlags = ['false', false]
  219. const truetrue = trueFlags.includes(item.value) && trueFlags.includes(realValue)
  220. const falsefalse = falseFlags.includes(item.value) && falseFlags.includes(realValue)
  221. if (truetrue || falsefalse) {
  222. href = item.imageUrl;
  223. }
  224. }
  225. })
  226. }
  227. }
  228. const finalX = x - 1 / 2 * finalWidth;
  229. const finalY = y - 1 / 2 * finalHeight
  230. const attrs = {
  231. x: finalX,
  232. y: finalY,
  233. width: finalWidth,
  234. height: finalHeight,
  235. href,
  236. opacity,
  237. className: blinkAnimation ? 'blinkAnim' : '',
  238. transformOrigin: \`\${finalX + finalWidth/2} \${finalY + finalHeight/2}\`,
  239. // 根据宽高缩放
  240. preserveAspectRatio: 'none meet'
  241. }
  242. return h('g', {}, [
  243. h('image', { ...attrs })
  244. ]
  245. );
  246. }
  247. }
  248. lf.register({
  249. type: 'custom-image-node',
  250. view: ImageNode,
  251. model: ImageModel
  252. })`,css:"",fakeData:` // 数据处理, 返回格式如下
  253. return {
  254. normalData: [],
  255. uiData: [],
  256. animationData: [[]], // 多级
  257. hiddenData: [[]], // 多级
  258. } `},u={id:e,name:a,aliasName:t,image:n,imageType:i,groupName:l,groupType:o,isRemote:!1,isDefault:!0,sectionType:d,config:s,files:c};export{t as aliasName,s as config,u as default,c as files,l as groupName,o as groupType,e as id,n as image,i as imageType,m as isDefault,r as isRemote,a as name,d as sectionType};