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

214 lines
67 KiB

  1. const e="1111",a="custom-rect-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='1681696286752' class='icon' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' p-id='6732' xmlns:xlink='http://www.w3.org/1999/xlink' width='200' height='200'><path d='M938.666667 955.733333H85.333333a17.066667 17.066667 0 0 1-17.066666-17.066666V85.333333a17.066667 17.066667 0 0 1 17.066666-17.066666h853.333334a17.066667 17.066667 0 0 1 17.066666 17.066666v853.333334a17.066667 17.066667 0 0 1-17.066666 17.066666zM102.4 921.6h819.2V102.4H102.4v819.2z' p-id='6733' fill='#707070'></path></svg>",i="svg",l="基础",o="基础图形",r=!1,m=!0,d="基础图形",s=`{"id":"u:270584784ce1","type":"page","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: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":"grid","columns":[{"body":[{"type":"input-color","label":"填充","name":"fill","id":"u:0d19ed3e2bdc","placeholder":"","mode":"horizontal","size":"full","className":"m-b","format":"rgba","inputClassName":"w-full"}],"id":"u:facc5c90e990","md":6},{"body":[{"type":"input-color","label":"描边","name":"strokeColor","id":"u:89afff5fd00d","placeholder":"","mode":"horizontal","size":"full","className":"m-b","format":"rgba","inputClassName":"w-full"}],"id":"u:7c903d9d40ab","md":6}],"id":"u:457970dd35bf","className":"m-b
  2. "nodes": [
  3. {
  4. "id": "1",
  5. "type": "custom-rect-node",
  6. "x": 200,
  7. "y": 200,
  8. "text": {
  9. "value": "",
  10. "x": 200,
  11. "y": 200
  12. },
  13. "properties": {
  14. "id": "1",
  15. "width": 100,
  16. "height": 100,
  17. "x": 200,
  18. "y": 200,
  19. "rotation": 0,
  20. "opacity": 1,
  21. "strokeWidth": 1,
  22. "showDefaultValue": false,
  23. "showUnit": false,
  24. "fontSize": 12,
  25. "borderDirection": "border",
  26. "nodeAlias": "方形矩形",
  27. "borderWidth": 1,
  28. "borderTopLeftRadius": 1,
  29. "borderStyle": "solid",
  30. "backgroundColor": "",
  31. "backgroundRepeat": "repeat-x",
  32. "content": "",
  33. "dynamic": {
  34. "normalData": {
  35. "dataPoint": "",
  36. "compareType": "",
  37. "conditionVariables": [
  38. {
  39. "type": "rangeImage",
  40. "label": "范围/图片",
  41. "name": "",
  42. "imageUrl": ""
  43. }
  44. ],
  45. "defaultValue": "[{ \\"val\\": 0.00 }]",
  46. "unit": ""
  47. },
  48. "eventsData": {
  49. "eventCombo": [
  50. {
  51. "eventType": "click",
  52. "enable": false,
  53. "config": "{\\"globalInputParamsCalculated\\":[],\\"device\\":\\"\\",\\"command\\":\\"\\",\\"eventAction\\":\\"sendCommand\\",\\"dataPointParamsCalculate\\":\\"return [\\\\n {\\\\n key: \\\\\\"\\\\\\",\\\\n value: ''\\\\n }\\\\n]\\",\\"sendCommandMethod\\":\\"config\\",\\"inputParamsCalculate\\":\\"// console.log('deviceInfo', deviceInfo, 'command', command, 'event', event);\\\\n// 入参提示: deviceInfo -- 设备信息,command -- 指令信息, event -- 事件传参(当前部件所绑定的立即值,或当前部件经过计算后的自定义值), 入参计算。。。然后返回出参\\\\nconst condition = {\\\\n deviceName: deviceInfo.code,\\\\n attrCode: command.controlDeviceAttr,\\\\n value: event == 0 ? 1 : event == 1 ? 0 : event\\\\n}\\\\nreturn {\\\\n \\\\\\"condition\\\\\\": JSON.stringify(condition),\\\\n \\\\\\"controlId\\\\\\": command.id\\\\n}\\",\\"requestMethod\\":\\"post\\",\\"requestUrl\\":\\"/thing/device/control/control\\"}"
  54. }
  55. ]
  56. },
  57. "uiData": {
  58. "dataPoint": "",
  59. "compareType": "",
  60. "conditionVariables": []
  61. },
  62. "animationData": {
  63. "animationCombo": [
  64. {
  65. "min": "",
  66. "max": "",
  67. "animationName": "旋转",
  68. "animationTime": 3
  69. }
  70. ]
  71. },
  72. "hiddenData": {
  73. "hiddenCombo": [
  74. {
  75. "dataPoint": "",
  76. "min": "",
  77. "max": "",
  78. "showOrHiddenName": "隐藏"
  79. }
  80. ]
  81. }
  82. }
  83. }
  84. }
  85. ]
  86. }`,javascript:`
  87. class CustomRectNodeView extends RectResize.view { }
  88. class CustomRectNodeModel extends RectResize.model {
  89. realValue = ''
  90. initNodeData(data) {
  91. super.initNodeData(data);
  92. const { properties } = this;
  93. this.width = properties.width || 150;
  94. this.height = properties.height || 80;
  95. this.text.editable = false; // 不允许文本被编辑
  96. window.nodeEventsListeners(this);
  97. }
  98. setAttributes() {
  99. const { x, y, properties } = this;
  100. const { textHorizontalMove = 0, textVerticalMove = 0, dynamic } = properties;
  101. const { normalData } = dynamic || {};
  102. let textValue = properties.content || '';
  103. if (normalData) {
  104. const { defaultValue } = normalData || {}
  105. const realValue = window.resolveScadaNewValue(defaultValue)
  106. this.realValue = realValue
  107. const { showDefaultValue, showUnit } = properties
  108. if (showDefaultValue) {
  109. textValue += ' ' + realValue
  110. }
  111. if (showUnit) {
  112. textValue += ' ' + normalData.unit
  113. }
  114. };
  115. this.text = {
  116. ...this.text,
  117. x: x + textHorizontalMove,
  118. y: y + textVerticalMove,
  119. value: textValue,
  120. }
  121. }
  122. getNodeStyle() {
  123. const style = super.getNodeStyle();
  124. const { properties } = this;
  125. style.fill = properties.fill || style.fill;
  126. const { uiData } = properties.dynamic;
  127. if (uiData) {
  128. const realValue = window.resolveScadaNewValue(uiData.defaultValue)
  129. uiData.conditionVariables.forEach((item) => {
  130. if (item.type === 'rangeColor') {
  131. let from = item.from;
  132. let to = item.to;
  133. if (item.from >= item.to) {
  134. from = item.to;
  135. to = item.from;
  136. }
  137. if (item.color && Number(realValue) >= from && Number(realValue) <= to) {
  138. style.fill = item.color
  139. }
  140. }
  141. if (item.type === 'rangeImage') {
  142. let from = item.from;
  143. let to = item.to;
  144. if (item.from >= item.to) {
  145. from = item.to;
  146. to = item.from;
  147. }
  148. if (item.imageUrl && Number(realValue) >= from && Number(realValue) <= to) {
  149. const href = item.imageUrl;
  150. const id = properties.id;
  151. window.createSvgPattern(id, href, properties.width, properties.height);
  152. setTimeout(() => {
  153. style.fill = \`url(#{id})\`;
  154. }, 1000)
  155. }
  156. }
  157. })
  158. }
  159. style.stroke = properties.strokeColor || style.stroke;
  160. style.strokeWidth = properties.strokeWidth || style.strokeWidth;
  161. style.opacity = properties.opacity || 1;
  162. return style;
  163. }
  164. getTextStyle() {
  165. const style = super.getTextStyle();
  166. const { properties } = this;
  167. style.color = properties.fontColor || style.color;
  168. style.fontSize = properties.fontSize || style.fontSize;
  169. const fontStyle = properties.fontStyle;
  170. if (fontStyle) {
  171. if (fontStyle.includes('bold')) {
  172. style.fontWeight = 'bolder';
  173. }
  174. if (fontStyle.includes('italic')) {
  175. style.fontStyle = 'italic'
  176. }
  177. if (fontStyle.includes('underline,line-through')) {
  178. style.textDecoration = 'underline line-through'
  179. } else if (fontStyle.includes('line-through,underline')) {
  180. style.textDecoration = 'line-through underline'
  181. } else if (fontStyle.includes('underline')) {
  182. style.textDecoration = 'underline'
  183. } else if (fontStyle.includes('line-through')) {
  184. style.textDecoration = 'line-through'
  185. }
  186. }
  187. return style;
  188. }
  189. getResizeOutlineStyle() {
  190. return {
  191. stroke: "#00ffff",
  192. strokeWidth: 1,
  193. strokeDasharray: "none",
  194. };
  195. }
  196. }
  197. lf.register({
  198. type: 'custom-rect-node',
  199. view: CustomRectNodeView,
  200. model: CustomRectNodeModel,
  201. })
  202. `,css:""},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};