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

263 lines
70 KiB

  1. const e="1d5204cb-27ec-4857-a7e9-1b258c6884eb",a="custom-input-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="1693910898822" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4004" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M122.368 165.888h778.24c-9.216 0-16.384-7.168-16.384-16.384v713.728c0-9.216 7.168-16.384 16.384-16.384h-778.24c9.216 0 16.384 7.168 16.384 16.384V150.016c0 8.192-6.656 15.872-16.384 15.872z m-32.768 684.544c0 26.112 20.992 47.104 47.104 47.104h750.08c26.112 0 47.104-20.992 47.104-47.104V162.304c0-26.112-20.992-47.104-47.104-47.104H136.704c-26.112 0-47.104 20.992-47.104 47.104v688.128z" p-id="4005" fill="#707070"></path><path d="M360.96 398.336h113.152v265.216h-37.888v37.888h151.552v-37.888h-37.888V398.336h113.152v38.4h38.4V322.56H322.56v114.176h38.4z" p-id="4006" fill="#707070"></path></svg>',l="svg",i="基础",o="常用",r=!1,u=!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: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":[{"body":[{"type":"input-text","label":"内容","name":"content","id":"u:bea5a408f98f","mode":"horizontal","size":"full","inputControlClassName":"inputControlClassName-bea5a408f98f"}],"id":"u:afc37bde0156
  2. "nodes": [
  3. {
  4. "id": "0d0735ba-75d5-484d-8069-e6b8570a5135",
  5. "type": "custom-input-node",
  6. "x": 200,
  7. "y": 200,
  8. "text": {
  9. "value": "0.00",
  10. "x": 200,
  11. "y": 200
  12. },
  13. "properties": {
  14. "id": "0d0735ba-75d5-484d-8069-e6b8570a5135",
  15. "width": 200,
  16. "height": 20,
  17. "x": 200,
  18. "y": 200,
  19. "rotation": 0,
  20. "opacity": 1,
  21. "contentColor": "rgba(245, 166, 35, 1)",
  22. "showUnit": false,
  23. "fontSize": 12,
  24. "showDefaultValue": false,
  25. "valueColor": "rgba(245, 166, 35, 1)",
  26. "nodeAlias": "文本输入",
  27. "content": "0.00",
  28. "fontColor": "rgba(245, 166, 35, 1)",
  29. "fontFamily": "Microsoft Yahei",
  30. "dynamic": {
  31. "normalData": {
  32. "dataPoint": "",
  33. "compareType": "",
  34. "conditionVariables": [],
  35. "defaultValue": "",
  36. "unit": ""
  37. },
  38. "eventsData": {
  39. "eventCombo": [
  40. {
  41. "eventType": "change",
  42. "enable": false,
  43. "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\\\\n}\\\\nreturn {\\\\n \\\\\\"condition\\\\\\": JSON.stringify(condition),\\\\n \\\\\\"controlId\\\\\\": command.id\\\\n}\\",\\"requestMethod\\":\\"post\\",\\"requestUrl\\":\\"/thing/device/control/control\\"}",
  44. "users": ""
  45. }
  46. ]
  47. },
  48. "uiData": {
  49. "dataPoint": "",
  50. "compareType": "",
  51. "conditionVariables": [
  52. {
  53. "type": "boolean",
  54. "label": "真假",
  55. "name": ""
  56. }
  57. ]
  58. },
  59. "animationData": {
  60. "animationCombo": [
  61. {
  62. "dataPoint": "",
  63. "min": "",
  64. "max": "",
  65. "animationName": "旋转",
  66. "animationTime": 3
  67. }
  68. ]
  69. },
  70. "hiddenData": {
  71. "hiddenCombo": [
  72. {
  73. "dataPoint": "",
  74. "min": "",
  75. "max": "",
  76. "showOrHiddenName": "隐藏"
  77. }
  78. ]
  79. }
  80. }
  81. }
  82. }
  83. ]
  84. }`,javascript:`// 文本节点
  85. class CustomInputNode extends TextNode {
  86. }
  87. class CustomInputModel extends TextNodeModel {
  88. realValue = ''
  89. clearText = ''
  90. initNodeData(data) {
  91. // 自定义组件,需最开始重置一下text 。
  92. data.text = {
  93. value: "",
  94. x: data.x,
  95. y: data.y,
  96. };
  97. super.initNodeData(data);
  98. this.editable = true;
  99. const txtUpdateHandler = (e) => {
  100. const { eventsData } = this.properties.dynamic || {};
  101. const findChange = eventsData?.eventCombo.find( i => i.eventType === 'change');
  102. const cacheToken = sessionStorage.getItem('v1@CacheToken');
  103. if(!cacheToken) {
  104. return window.createLoginDialog();
  105. }
  106. const tokenParsed = JSON.parse(cacheToken || '{}');
  107. if (findChange.users && !findChange.users.includes(tokenParsed.userid)) {
  108. return messageFn('无用户权限')
  109. }
  110. if (e.id === this.properties.id) {
  111. if(e.value) {
  112. this.graphModel.eventCenter.emit('node:change', { data: this, e: e.value});
  113. this.graphModel.textEditElement.setElementState(1);
  114. }
  115. }
  116. }
  117. this.graphModel.eventCenter.on("text:edited", txtUpdateHandler);
  118. }
  119. getOutlineStyle() {
  120. const style = super.getOutlineStyle();
  121. const { id, fontSize } = this.properties;
  122. const textEditElement = this.graphModel.textEditElement;
  123. if(textEditElement && textEditElement.id === id) {
  124. style.stroke = "transparent";
  125. style.hover.stroke = 'transparent';
  126. } else {
  127. style.stroke = "#00ffff";
  128. style.hover.stroke = '#00ffff';
  129. }
  130. const txtDom = document.getElementById(this.id);
  131. if(txtDom) {
  132. const txtNode = txtDom.querySelector('text');
  133. if (txtNode) {
  134. const { width, height, x, y } = txtNode.getBBox();
  135. style.width = width;
  136. style.height = height;
  137. style.x = x + width / 2 - this.width/2;
  138. style.y = y + height / 2;
  139. }
  140. }
  141. return style;
  142. }
  143. getTextStyle() {
  144. const style = super.getTextStyle();
  145. const { properties, text } = this;
  146. style.color = properties.fontColor || style.color;
  147. const { uiData } = properties.dynamic || {};
  148. if (uiData) {
  149. const realValue = window.resolveScadaNewValue(uiData.defaultValue)
  150. if (realValue !== '') {
  151. uiData.conditionVariables.forEach((item) => {
  152. if (item.type === 'rangeColor') {
  153. let from = item.from;
  154. let to = item.to;
  155. if (item.from >= item.to) {
  156. from = item.to;
  157. to = item.from;
  158. }
  159. if (item.color && Number(realValue) >= from && Number(realValue) <= to) {
  160. style.color = item.color
  161. }
  162. } else if (item.type === 'equal') {
  163. if(Number(realValue) === Number(item.value)) {
  164. style.color = item.color
  165. }
  166. } else if (item.type === 'boolean') {
  167. const trueFlags = ['true', true]
  168. const falseFlags = ['false', false]
  169. const truetrue = trueFlags.includes(item.value) && trueFlags.includes(realValue)
  170. const falsefalse = falseFlags.includes(item.value) && falseFlags.includes(realValue)
  171. if (truetrue || falsefalse) {
  172. style.color = item.color
  173. }
  174. }
  175. })
  176. }
  177. }
  178. style.fontSize = properties.fontSize || style.fontSize;
  179. style.fontFamily = properties.fontFamily || style.fontFamily;
  180. style.opacity = properties.opacity || 1;
  181. style.letterSpacing = properties.fontSpace || 0;
  182. const fontStyle = properties.fontStyle;
  183. if(fontStyle) {
  184. if (fontStyle.includes('bold')) {
  185. style.fontWeight = 'bolder';
  186. }
  187. if(fontStyle.includes('italic')) {
  188. style.fontStyle = 'italic'
  189. }
  190. if (fontStyle.includes('underline,line-through')) {
  191. style.textDecoration = 'underline line-through'
  192. } else if (fontStyle.includes('line-through,underline')) {
  193. style.textDecoration = 'line-through underline'
  194. } else if (fontStyle.includes('underline')) {
  195. style.textDecoration = 'underline'
  196. } else if (fontStyle.includes('line-through')) {
  197. style.textDecoration = 'line-through'
  198. }
  199. }
  200. return style;
  201. }
  202. setAttributes() {
  203. const { id, x, y, properties, text, width, height } = this;
  204. const { graphModel: { textEditElement } } = this;
  205. let textValue = properties.content || '';
  206. if (textValue === id) return;
  207. const { normalData, uiData } = properties.dynamic || {};
  208. if (normalData) {
  209. const normalValue = window.resolveScadaNewValue(normalData.defaultValue)
  210. if (normalValue) {
  211. this.realValue = normalValue;
  212. if (!textEditElement) {
  213. textValue = normalValue
  214. } else {
  215. if(textEditElement.id === id) {
  216. return;
  217. }
  218. }
  219. }
  220. }
  221. if (uiData) {
  222. const realValue = window.resolveScadaNewValue(uiData.defaultValue)
  223. if (realValue !== '') {
  224. uiData.conditionVariables.forEach((item) => {
  225. if (item.type === 'equal') {
  226. if(Number(realValue) === Number(item.value)) {
  227. textValue = item.valueLabel;
  228. }
  229. } else if (item.type === 'boolean') {
  230. const trueFlags = ['true', true]
  231. const falseFlags = ['false', false]
  232. const truetrue = trueFlags.includes(item.value) && trueFlags.includes(realValue)
  233. const falsefalse = falseFlags.includes(item.value) && falseFlags.includes(realValue)
  234. if (truetrue || falsefalse) {
  235. textValue = item.valueLabel;
  236. }
  237. }
  238. })
  239. }
  240. }
  241. this.text = {
  242. ...this.text,
  243. x,
  244. y,
  245. value: textValue,
  246. }
  247. }
  248. }
  249. lf.register({
  250. type: 'custom-input-node',
  251. view: CustomInputNode,
  252. model: CustomInputModel
  253. })`,css:"",fakeData:""},m={id:e,name:a,aliasName:t,image:n,imageType:l,groupName:i,groupType:o,isRemote:!1,isDefault:!0,sectionType:d,config:s,files:c};export{t as aliasName,s as config,m as default,c as files,i as groupName,o as groupType,e as id,n as image,l as imageType,u as isDefault,r as isRemote,a as name,d as sectionType};