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

292 lines
74 KiB

  1. const e="a8f59ba7-5e3d-4447-a87b-3ceb02a0e6b0",a="custom-text-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="1688095457552" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2314" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M692.2597343921661 882.78857421875H331.711297750473v-30.689996480941772a563.3140236139297 563.3140236139297 0 0 1 48.088091611862176-14.83154296875c16.200274229049683-4.278552532196046 33.656305074691765-7.757592201232912 52.39561200141907-10.638445615768433v-630.340576171875h-136.73552870750427l-57.244107127189636 151.53810381889343H211.2339789867401c-2.1675199270248413-14.118209481239319-3.9642512798309326-30.233752727508545-5.419161915779114-48.23148250579833-1.4541864395141602-17.939794063568115-2.6809751987457275-36.30831241607666-3.7933409214019784-55.10410666465761-1.1123657226562498-18.59736442565918-1.9683659076690674-37.078857421875-2.6527315378189087-55.019375681877136C198.6264432668686 171.53063368797297 198.2563788890838 155.35860311985022 198.2563788890838 141.21142578125h627.4886906147003c0 14.147177338600159-0.3997564315795899 30.090361833572388-1.1123657226562498 47.689059376716614-0.7415771484374999 17.655909061431885-1.6547888517379765 35.852792859077454-2.766430377960205 54.56313192844391s-2.139276266098023 37.078857421875-3.251641988754273 55.10410666465761c-1.0841220617294314 17.998453974723816-2.7099430561065674 34.48406159877777-4.9064308404922485 49.28736090660096h-28.408053517341607l-56.75889551639557-151.53810381889343H592.8891206979752V826.6850764751434c18.71033906936645 3.5659432411193848 36.22285723686218 7.07395076751709 52.366644144058235 10.638445615768433 16.229242086410522 3.508731722831726 31.85957372188568 8.415162563323973 47.00469374656678 14.83154296875v30.633509159088135z" p-id="2315" fill="#707070"></path></svg>',l="svg",i="基础",o="常用",r=!1,u=!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: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,"
  2. "nodes": [
  3. {
  4. "id": "bced9918-f81e-4ecd-8e2f-99dcc376e670",
  5. "type": "custom-text-node",
  6. "x": 200,
  7. "y": 200,
  8. "text": {
  9. "value": "测试文本",
  10. "x": 200,
  11. "y": 200
  12. },
  13. "properties": {
  14. "id": "bced9918-f81e-4ecd-8e2f-99dcc376e670",
  15. "width": 303,
  16. "height": 38,
  17. "x": 200,
  18. "y": 200,
  19. "rotation": 0,
  20. "opacity": 1,
  21. "showDefaultValue": false,
  22. "showUnit": false,
  23. "valueColor": "",
  24. "valueDecimal": 4,
  25. "valueFormatWan": false,
  26. "fontSize": 12,
  27. "fontSpace": 0,
  28. "strokeWidth": 1,
  29. "nodeAlias": "文本",
  30. "fill": "",
  31. "content": "测试文本",
  32. "fontColor": "rgba(245, 166, 35, 1)",
  33. "fontFamily": "Microsoft Yahei",
  34. "fontStyle": "",
  35. "textShadow": "",
  36. "gradientFontColor": "",
  37. "textAnchor": "start",
  38. "dynamic": {
  39. "normalData": {
  40. "dataPoint": "",
  41. "compareType": "",
  42. "conditionVariables": [],
  43. "defaultValue": "",
  44. "unit": ""
  45. },
  46. "eventsData": {
  47. "eventCombo": [
  48. {
  49. "eventType": "click",
  50. "enable": false,
  51. "config": ""
  52. }
  53. ]
  54. },
  55. "uiData": {
  56. "dataPoint": "",
  57. "compareType": "",
  58. "conditionVariables": [
  59. {
  60. "type": "equal",
  61. "label": "相等",
  62. "name": ""
  63. }
  64. ]
  65. },
  66. "animationData": {
  67. "animationCombo": [
  68. {
  69. "dataPoint": "",
  70. "min": "",
  71. "max": "",
  72. "animationName": "旋转"
  73. }
  74. ]
  75. },
  76. "hiddenData": {
  77. "hiddenCombo": [
  78. {
  79. "dataPoint": "",
  80. "min": "",
  81. "max": "",
  82. "showOrHiddenName": "隐藏"
  83. }
  84. ]
  85. }
  86. }
  87. }
  88. }
  89. ]
  90. }`,javascript:`// 文本节点
  91. class CustomTextNode extends TextNode {
  92. }
  93. class CustomTextModel extends TextNodeModel {
  94. realValue = ''
  95. initNodeData(data) {
  96. // 自定义组件,需最开始重置一下text 。
  97. data.text = {
  98. value: "",
  99. x: data.x,
  100. y: data.y,
  101. };
  102. super.initNodeData(data);
  103. this.editable = false;
  104. window.nodeEventsListeners(this);
  105. }
  106. getOutlineStyle() {
  107. const style = super.getOutlineStyle();
  108. const { id, fontSize } = this.properties;
  109. const textEditElement = this.graphModel.textEditElement;
  110. if(textEditElement && textEditElement.id === id) {
  111. style.stroke = "transparent";
  112. style.hover.stroke = 'transparent';
  113. } else {
  114. style.stroke = "#00ffff";
  115. style.hover.stroke = '#00ffff';
  116. }
  117. const txtDom = document.getElementById(this.id);
  118. if(txtDom) {
  119. const txtNode = txtDom.querySelector('text');
  120. if (txtNode) {
  121. const { width, height, x, y } = txtNode.getBBox();
  122. style.width = width;
  123. style.height = height;
  124. style.x = x + width / 2 - this.width/2;
  125. style.y = y + height / 2;
  126. }
  127. }
  128. return style;
  129. }
  130. getTextStyle() {
  131. const style = super.getTextStyle();
  132. const { properties, text } = this;
  133. const { showDefaultValue, showUnit, fontSize, content } = properties;
  134. style.color = properties.fontColor || style.color;
  135. if(properties.gradientFontColor) {
  136. const gradientId = \`gradidentFont-\${properties.id}\`;
  137. const existID = document.getElementById(gradientId);
  138. const graph = document.querySelector('.lf-canvas-overlay');
  139. if (existID) {
  140. existID.parentNode.remove();
  141. }
  142. const gradientDef = window.generateSVGGradient(properties.gradientFontColor, gradientId);
  143. graph && graph.prepend(gradientDef);
  144. style.fill = \`url(#\${gradientId})\`;
  145. }
  146. const { uiData, normalData } = properties.dynamic || {};
  147. if (uiData) {
  148. const realValue = window.resolveScadaNewValue(uiData.defaultValue)
  149. if (realValue !== '') {
  150. uiData.conditionVariables.forEach((item) => {
  151. if (item.type === 'rangeColor') {
  152. let from = item.from;
  153. let to = item.to;
  154. if (item.from >= item.to) {
  155. from = item.to;
  156. to = item.from;
  157. }
  158. if (Number(realValue) >= from && Number(realValue) <= to) {
  159. style.color = item.color;
  160. if(item.gradientFontColor) {
  161. const gradientId = \`gradidentFont-\${properties.id}\`;
  162. const existID = document.getElementById(gradientId);
  163. const graph = document.querySelector('.lf-canvas-overlay');
  164. if (existID) {
  165. existID.parentNode.remove();
  166. }
  167. const gradientDef = window.generateSVGGradient(item.gradientFontColor, gradientId);
  168. graph && graph.prepend(gradientDef);
  169. style.fill = \`url(#\${gradientId})\`;
  170. }
  171. }
  172. } else if (item.type === 'equal') {
  173. if(Number(realValue) === Number(item.value)) {
  174. style.color = item.color;
  175. if(item.gradientFontColor) {
  176. const gradientId = \`gradidentFont-\${properties.id}\`;
  177. const existID = document.getElementById(gradientId);
  178. const graph = document.querySelector('.lf-canvas-overlay');
  179. if (existID) {
  180. existID.parentNode.remove();
  181. }
  182. const gradientDef = window.generateSVGGradient(item.gradientFontColor, gradientId);
  183. graph && graph.prepend(gradientDef);
  184. style.fill = \`url(#\${gradientId})\`;
  185. }
  186. }
  187. } else if (item.type === 'boolean') {
  188. const trueFlags = ['true', true]
  189. const falseFlags = ['false', false]
  190. const truetrue = trueFlags.includes(item.value) && trueFlags.includes(realValue)
  191. const falsefalse = falseFlags.includes(item.value) && falseFlags.includes(realValue)
  192. if (truetrue || falsefalse) {
  193. style.color = item.color;
  194. if(item.gradientFontColor) {
  195. const gradientId = \`gradidentFont-\${properties.id}\`;
  196. const existID = document.getElementById(gradientId);
  197. const graph = document.querySelector('.lf-canvas-overlay');
  198. if (existID) {
  199. existID.parentNode.remove();
  200. }
  201. const gradientDef = window.generateSVGGradient(item.gradientFontColor, gradientId);
  202. graph && graph.prepend(gradientDef);
  203. style.fill = \`url(#\${gradientId})\`;
  204. }
  205. }
  206. }
  207. })
  208. }
  209. }
  210. style.fontSize = properties.fontSize || style.fontSize;
  211. style.fontFamily = properties.fontFamily || style.fontFamily;
  212. style.opacity = properties.opacity || 1;
  213. style.letterSpacing = properties.fontSpace || 0;
  214. style.textAnchor = properties.textAnchor || 'start';
  215. if(properties.textShadow) {
  216. style.style = \`text-shadow: \${properties.textShadow}\`;
  217. }
  218. const fontStyle = properties.fontStyle;
  219. if(fontStyle) {
  220. if (fontStyle.includes('bold')) {
  221. style.fontWeight = 'bolder';
  222. }
  223. if(fontStyle.includes('italic')) {
  224. style.fontStyle = 'italic'
  225. }
  226. if (fontStyle.includes('underline,line-through')) {
  227. style.textDecoration = 'underline line-through'
  228. } else if (fontStyle.includes('line-through,underline')) {
  229. style.textDecoration = 'line-through underline'
  230. } else if (fontStyle.includes('underline')) {
  231. style.textDecoration = 'underline'
  232. } else if (fontStyle.includes('line-through')) {
  233. style.textDecoration = 'line-through'
  234. }
  235. }
  236. return style;
  237. }
  238. setAttributes() {
  239. const { id, x, y, properties, text, width, height } = this;
  240. let textValue = properties.content || '';
  241. if (textValue === id) return;
  242. const { normalData, uiData } = properties.dynamic || {};
  243. if (normalData) {
  244. const normalValue = window.resolveScadaNewValue(normalData.defaultValue)
  245. if (normalValue) {
  246. this.realValue = normalValue;
  247. }
  248. }
  249. if (uiData) {
  250. const realValue = window.resolveScadaNewValue(uiData.defaultValue)
  251. if (realValue !== '') {
  252. uiData.conditionVariables.forEach((item) => {
  253. if (item.type === 'equal') {
  254. if(Number(realValue) === Number(item.value)) {
  255. textValue = item.valueLabel;
  256. }
  257. } else if (item.type === 'boolean') {
  258. const trueFlags = ['true', true]
  259. const falseFlags = ['false', false]
  260. const truetrue = trueFlags.includes(item.value) && trueFlags.includes(realValue)
  261. const falsefalse = falseFlags.includes(item.value) && falseFlags.includes(realValue)
  262. if (truetrue || falsefalse) {
  263. textValue = item.valueLabel;
  264. }
  265. }
  266. })
  267. }
  268. }
  269. this.text = {
  270. ...this.text,
  271. x,
  272. y,
  273. value: textValue,
  274. }
  275. }
  276. }
  277. lf.register({
  278. type: 'custom-text-node',
  279. view: CustomTextNode,
  280. model: CustomTextModel
  281. })`,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};