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

703 lines
60 KiB

  1. const e="e74e3f4e-d737-4440-88ca-b1adaaa97d4d",n="custom-progress-guage",t="进度仪表图",a='<?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="1695784641645" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6357" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M512 260.266667l42.666667 262.4c0 21.333333-19.2 36.266667-42.666667 36.266666s-42.666667-17.066667-42.666667-36.266666" fill="#4C64FE" p-id="6358"></path><path d="M488.533333 85.333333C264.533333 98.133333 85.333333 285.866667 85.333333 509.866667c0 155.733333 81.066667 290.133333 204.8 364.8 23.466667 14.933333 51.2-2.133333 51.2-29.866667V832c0-14.933333-6.4-29.866667-19.2-38.4-34.133333-23.466667-64-51.2-87.466666-85.333333 23.466667-8.533333 36.266667-34.133333 27.733333-57.6-8.533333-25.6-34.133333-38.4-59.733333-32l-12.8 6.4c-14.933333-40.533333-21.333333-85.333333-19.2-132.266667 2.133333-32 8.533333-64 19.2-91.733333 10.666667 8.533333 27.733333 10.666667 42.666666 6.4 25.6-8.533333 38.4-34.133333 32-59.733334-4.266667-14.933333-17.066667-25.6-29.866666-29.866666 53.333333-76.8 136.533333-130.133333 232.533333-142.933334 0 4.266667 0 8.533333 2.133333 12.8 8.533333 25.6 34.133333 38.4 59.733334 32 19.2-6.4 32-23.466667 34.133333-44.8 98.133333 12.8 183.466667 70.4 236.8 149.333334-14.933333 12.8-23.466667 32-17.066667 51.2 8.533333 23.466667 32 38.4 57.6 32 10.666667 32 17.066667 68.266667 17.066667 104.533333 0 40.533333-6.4 76.8-19.2 113.066667-10.666667-6.4-25.6-10.666667-40.533333-6.4-25.6 8.533333-38.4 34.133333-32 59.733333 4.266667 14.933333 14.933333 23.466667 27.733333 29.866667-23.466667 34.133333-55.466667 64-89.6 87.466666-12.8 8.533333-19.2 21.333333-19.2 36.266667v12.8c0 27.733333 29.866667 44.8 55.466667 29.866667 121.6-74.666667 200.533333-209.066667 200.533333-362.666667C938.666667 268.8 733.866667 72.533333 488.533333 85.333333z" fill="#4C64FE" opacity=".6" p-id="6359"></path><path d="M661.333333 142.933333c0-19.2-12.8-36.266667-29.866666-40.533333-44.8-12.8-93.866667-19.2-142.933334-17.066667C264.533333 98.133333 85.333333 285.866667 85.333333 509.866667c0 155.733333 81.066667 290.133333 204.8 364.8 23.466667 14.933333 51.2-2.133333 51.2-29.866667V832c0-14.933333-6.4-29.866667-19.2-38.4-34.133333-23.466667-64-51.2-87.466666-85.333333-34.133333-40.533333-44.8-83.2-44.8-83.2-14.933333-40.533333-21.333333-85.333333-19.2-132.266667 2.133333-32 8.533333-64 19.2-91.733333 0 0 8.533333-40.533333 44.8-83.2 53.333333-76.8 136.533333-130.133333 232.533333-142.933334 0 0 49.066667-10.666667 96 0 14.933333 2.133333 29.866667 4.266667 44.8 8.533334 27.733333 8.533333 53.333333-10.666667 53.333333-40.533334z" fill="#4C64FE" p-id="6360"></path></svg>',i="svg",l="动态",o="图表组件",u=!1,c=!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":"组件
  2. "nodes": [
  3. {
  4. "id": "2d10edaf-edb8-40ef-927b-bf4fee5718a4",
  5. "type": "custom-progress-guage",
  6. "x": 200,
  7. "y": 200,
  8. "text": {
  9. "value": "",
  10. "x": 200,
  11. "y": 200
  12. },
  13. "properties": {
  14. "id": "2d10edaf-edb8-40ef-927b-bf4fee5718a4",
  15. "width": 200,
  16. "height": 200,
  17. "x": 200,
  18. "y": 200,
  19. "rotation": 0,
  20. "opacity": 1,
  21. "grid": {
  22. "show": false
  23. },
  24. "range": {
  25. "endAngle": -270,
  26. "startAngle": 90,
  27. "min": 0,
  28. "splitNumber": 12,
  29. "max": 240,
  30. "warnValue": 1000
  31. },
  32. "pointer": {
  33. "show": false,
  34. "itemStyle": {
  35. "color": "#b8e986"
  36. }
  37. },
  38. "axisLine": {
  39. "show": false,
  40. "roundCap": false,
  41. "lineStyle": {
  42. "color": [
  43. {
  44. "ratio": "0",
  45. "color": "#00FFFF"
  46. },
  47. {
  48. "ratio": "1",
  49. "color": "rgba(80, 227, 194, 1)"
  50. }
  51. ],
  52. "width": 2
  53. }
  54. },
  55. "axisTick": {
  56. "show": false
  57. },
  58. "splitLine": {
  59. "show": true,
  60. "length": 12,
  61. "lineStyle": {
  62. "color": "rgba(80, 227, 194, 1)",
  63. "width": 1
  64. },
  65. "distance": 0
  66. },
  67. "axisLabel": {
  68. "show": false
  69. },
  70. "title": {
  71. "show": true,
  72. "color": ""
  73. },
  74. "nextNewLine": false,
  75. "innerCircleLine": {
  76. "show": false,
  77. "color": "#0CD3DB",
  78. "backColor": "rgba(0,255,255,0.05)"
  79. },
  80. "innerCircle": {
  81. "show": true,
  82. "borderColor": "rgba(80, 227, 194, 1)",
  83. "backColor": "rgba(0,255,255,0.05)"
  84. },
  85. "outerCircleLine": {
  86. "show": true,
  87. "color": "rgba(80, 227, 194, 1)"
  88. },
  89. "codeConfig": "return option",
  90. "progress": {
  91. "show": false,
  92. "roundCap": false
  93. },
  94. "nodeAlias": "进度仪表图",
  95. "showDefaultValue": false,
  96. "showUnit": false,
  97. "fontSize": 0,
  98. "itemStyle": {
  99. "color": "rgba(80, 227, 194, 1)"
  100. },
  101. "unit": {
  102. "fontSize": 12,
  103. "color": "rgba(80, 227, 194, 1)"
  104. },
  105. "valueConfig": {
  106. "color": "rgba(80, 227, 194, 1)",
  107. "fontSize": 14
  108. },
  109. "dynamic": {
  110. "normalData": {
  111. "dataPoint": "",
  112. "compareType": "",
  113. "conditionVariables": [],
  114. "defaultValue": "",
  115. "unit": ""
  116. }
  117. }
  118. }
  119. }
  120. ]
  121. }`,javascript:`const { createApp, createVNode, render } = Vue;
  122. const app = createApp({})
  123. const defaultVal = 50
  124. // 获取圆上面某点的坐标(x0, y0表示坐标,r半径,angle角度)
  125. function getCirlPoint(x0, y0, r, angle) {
  126. let x1 = x0 + r * Math.cos(angle * Math.PI / 180)
  127. let y1 = y0 + r * Math.sin(angle * Math.PI / 180)
  128. return {
  129. x: x1,
  130. y: y1
  131. }
  132. }
  133. const ProgressGauge = {
  134. template: '<div :id="chartId" :style="getStyle"></div>',
  135. props: {
  136. chartId: {
  137. type: String,
  138. default: ''
  139. },
  140. currentData: {
  141. type: Number,
  142. default: 100
  143. },
  144. width: {
  145. type: Number,
  146. default: 350
  147. },
  148. height: {
  149. type: Number,
  150. default: 150
  151. },
  152. chartProps: {
  153. type: Object,
  154. default: () => { }
  155. },
  156. thingName: {
  157. type: String,
  158. default: ''
  159. },
  160. attr: {
  161. type: String,
  162. default: ''
  163. },
  164. unit: {
  165. type: String,
  166. default: ''
  167. },
  168. },
  169. computed: {
  170. getStyle() {
  171. return {
  172. width: \`\${this.width}px\`,
  173. height: \`\${this.height}px\`
  174. }
  175. }
  176. },
  177. setup(props) {
  178. const { onMounted, nextTick, toRefs, watch } = Vue;
  179. const { chartProps, currentData, thingName, attr, width, height } = toRefs(props);
  180. let intervalInst = null;
  181. let myChart = null;
  182. const initChart = (data, pros) => {
  183. // 基于准备好的dom,初始化echarts实例
  184. const dom = document.getElementById(props.chartId);
  185. if (dom) {
  186. if (!myChart) {
  187. myChart = echarts.init(dom);
  188. }
  189. // 由于实时推送时候不会重复创建实例,但是需更新画布大小。
  190. myChart.resize({
  191. width: width.value,
  192. height: height.value,
  193. })
  194. if (data != null) {
  195. const { grid, codeConfig, range, progress, pointer, axisLine, axisTick, splitLine, nextNewLine,
  196. axisLabel, itemStyle, title, valueConfig, unit, outerCircleLine, innerCircleLine, innerCircle } = pros;
  197. // 指定图表的配置项和数据
  198. // 轴线底色拼装
  199. // 发现图表一直渲染的情况。就要注意图表数据多层对象嵌套的引用问题。
  200. const newAxisLine = window._.cloneDeep(axisLine);
  201. const Colors = []
  202. const oldColor = newAxisLine.lineStyle.color
  203. if (oldColor && oldColor.length > 0) {
  204. oldColor.forEach((item) => {
  205. Colors.push([item.ratio, item.color])
  206. })
  207. newAxisLine.lineStyle.color = Colors;
  208. } else if (oldColor && oldColor.length === 0) {
  209. delete newAxisLine.lineStyle.color
  210. }
  211. let angle = 0;//角度,用来做简单的动画效果的
  212. let biggerDigit = +data > 10000
  213. let value = biggerDigit ? (+data/10000).toFixed(2) : +data.toFixed(2);
  214. const valueColor = valueConfig && (valueConfig.color || title.color);
  215. const valueSize = valueConfig && (valueConfig.fontSize || title.fontSize);
  216. const valueWeight = valueConfig && (valueConfig.fontWeight || 'normal');
  217. const unitColor = unit && (unit.color || title.color);
  218. const unitSize = unit && (unit.fontSize || title.fontSize);
  219. const unitWeight = unit && (unit.fontWeight || 'normal');
  220. const textFormat = nextNewLine ? '{a|' + value + (biggerDigit ? '万' : '') + '}\\r\\n{c|' + props.unit + '}' : '{a|' + value + '}{c|' + props.unit + '}';
  221. const isWarning = (value || 0) > range.warnValue;
  222. splitLine.lineStyle.color = isWarning ? "#A59136" : splitLine.lineStyle.color;
  223. var option = {
  224. grid,
  225. title: {
  226. ...title,
  227. text: textFormat,
  228. x: 'center',
  229. y: 'center',
  230. textStyle: {
  231. rich: {
  232. a: {
  233. fontSize: valueSize,
  234. color: isWarning ? "#F0D048" : valueColor,
  235. fontWeight: valueWeight,
  236. align: 'center'
  237. },
  238. c: {
  239. fontSize: unitSize,
  240. color: isWarning ? "#F0D048" : unitColor,
  241. fontWeight: unitWeight,
  242. align: 'center'
  243. }
  244. }
  245. }
  246. },
  247. series: [
  248. {
  249. name: 'innerProgressCircle',
  250. type: 'pie',
  251. radius: ['83%', '70%'],
  252. silent: true,
  253. startAngle: 90,
  254. z: 0,
  255. zlevel: 0,
  256. label: {
  257. normal: {
  258. position: "center",
  259. }
  260. },
  261. data: [{
  262. value: value,
  263. name: "",
  264. itemStyle: {
  265. normal: {
  266. color: { // 完成的圆环的颜色
  267. colorStops: [{
  268. offset: 0,
  269. color: isWarning ? "#F0D048" : newAxisLine.lineStyle.color[0][1] // 0% 处的颜色
  270. }, {
  271. offset: 1,
  272. color: isWarning ? "#F0D048" : newAxisLine.lineStyle.color[1][1] // 100% 处的颜色
  273. }]
  274. },
  275. }
  276. }
  277. },
  278. {
  279. value: range.max - value,
  280. name: "",
  281. label: {
  282. normal: {
  283. show: false
  284. }
  285. },
  286. itemStyle: {
  287. normal: {
  288. color: "transparent"
  289. }
  290. }
  291. }
  292. ]
  293. },
  294. {
  295. name: "progressGuage",
  296. type: "gauge",
  297. radius: "83%",
  298. startAngle: 90,
  299. endAngle: -270,
  300. center: ['50%', '50%'],
  301. ...range,
  302. progress,
  303. pointer,
  304. axisLine: newAxisLine,
  305. axisTick,
  306. splitLine,
  307. axisLabel,
  308. itemStyle,
  309. hoverAnimation: true,
  310. detail: {
  311. show: false
  312. },
  313. data: [{
  314. value: value,
  315. name: ""
  316. }]
  317. },
  318. ]
  319. };
  320. if (outerCircleLine.show) {
  321. option.series.push({
  322. type: 'pie',
  323. name: 'outerCircleLine',
  324. radius: ['95%', '90%'],
  325. hoverAnimation: false,
  326. itemStyle: {
  327. normal: {
  328. color: isWarning ? "#A59136" : outerCircleLine.color
  329. }
  330. },
  331. label: {
  332. show: false
  333. },
  334. data: [100]
  335. })
  336. }
  337. if (innerCircleLine.show) {
  338. option.series.push(...[
  339. {
  340. name: "ring5",
  341. type: 'custom',
  342. coordinateSystem: "none",
  343. renderItem: function (params, api) {
  344. return {
  345. type: 'arc',
  346. shape: {
  347. cx: api.getWidth() / 2,
  348. cy: api.getHeight() / 2,
  349. r: Math.min(api.getWidth(), api.getHeight()) / 2 * 0.83,
  350. startAngle: (0 + angle) * Math.PI / 180,
  351. endAngle: (90 + angle) * Math.PI / 180
  352. },
  353. style: {
  354. stroke: isWarning ? "#A59136" : innerCircleLine.color,
  355. fill: "transparent",
  356. lineWidth: 1.5
  357. },
  358. silent: true
  359. };
  360. },
  361. data: [0]
  362. }, {
  363. name: "ring5",
  364. type: 'custom',
  365. coordinateSystem: "none",
  366. renderItem: function (params, api) {
  367. return {
  368. type: 'arc',
  369. shape: {
  370. cx: api.getWidth() / 2,
  371. cy: api.getHeight() / 2,
  372. r: Math.min(api.getWidth(), api.getHeight()) / 2 * 0.83,
  373. startAngle: (180 + angle) * Math.PI / 180,
  374. endAngle: (270 + angle) * Math.PI / 180
  375. },
  376. style: {
  377. stroke: isWarning ? "#A59136" : innerCircleLine.color,
  378. fill: "transparent",
  379. lineWidth: 1.5
  380. },
  381. silent: true
  382. };
  383. },
  384. data: [0]
  385. }, {
  386. name: "ring5",
  387. type: 'custom',
  388. coordinateSystem: "none",
  389. renderItem: function (params, api) {
  390. return {
  391. type: 'arc',
  392. shape: {
  393. cx: api.getWidth() / 2,
  394. cy: api.getHeight() / 2,
  395. r: Math.min(api.getWidth(), api.getHeight()) / 2 * 0.83,
  396. startAngle: (270 + -angle) * Math.PI / 180,
  397. endAngle: (40 + -angle) * Math.PI / 180
  398. },
  399. style: {
  400. stroke: isWarning ? "#A59136" : innerCircleLine.color,
  401. fill: "transparent",
  402. lineWidth: 1.5
  403. },
  404. silent: true
  405. };
  406. },
  407. data: [0]
  408. }, {
  409. name: "ring5",
  410. type: 'custom',
  411. coordinateSystem: "none",
  412. renderItem: function (params, api) {
  413. return {
  414. type: 'arc',
  415. shape: {
  416. cx: api.getWidth() / 2,
  417. cy: api.getHeight() / 2,
  418. r: Math.min(api.getWidth(), api.getHeight()) / 2 * 0.83,
  419. startAngle: (90 + -angle) * Math.PI / 180,
  420. endAngle: (220 + -angle) * Math.PI / 180
  421. },
  422. style: {
  423. stroke: isWarning ? "#A59136" : innerCircleLine.color,
  424. fill: "transparent",
  425. lineWidth: 1.5
  426. },
  427. silent: true
  428. };
  429. },
  430. data: [0]
  431. }, {
  432. name: "ring5",
  433. type: 'custom',
  434. coordinateSystem: "none",
  435. renderItem: function (params, api) {
  436. let x0 = api.getWidth() / 2;
  437. let y0 = api.getHeight() / 2;
  438. let r = Math.min(api.getWidth(), api.getHeight()) / 2 * 0.83;
  439. let point = getCirlPoint(x0, y0, r, (90 + -angle))
  440. return {
  441. type: 'circle',
  442. shape: {
  443. cx: point.x,
  444. cy: point.y,
  445. r: 4
  446. },
  447. style: {
  448. stroke: isWarning ? "#A59136" : innerCircleLine.color,
  449. fill: "#0CD3DB"
  450. },
  451. silent: true
  452. };
  453. },
  454. data: [0]
  455. }, {
  456. name: "ring5", //绿点
  457. type: 'custom',
  458. coordinateSystem: "none",
  459. renderItem: function (params, api) {
  460. let x0 = api.getWidth() / 2;
  461. let y0 = api.getHeight() / 2;
  462. let r = Math.min(api.getWidth(), api.getHeight()) / 2 * 0.83;
  463. let point = getCirlPoint(x0, y0, r, (270 + -angle))
  464. return {
  465. type: 'circle',
  466. shape: {
  467. cx: point.x,
  468. cy: point.y,
  469. r: 4
  470. },
  471. style: {
  472. stroke: isWarning ? "#A59136" : innerCircleLine.color, //绿
  473. fill: innerCircleLine.color,
  474. },
  475. silent: true
  476. };
  477. },
  478. data: [0]
  479. }
  480. ])
  481. }
  482. if (innerCircle.show) {
  483. option.series.push({
  484. type: 'pie',
  485. name: 'innerCircle',
  486. radius: [0, '83%'],
  487. hoverAnimation: false,
  488. animation: false,
  489. itemStyle: {
  490. normal: {
  491. shadowBlur: 20,
  492. shadowColor: '#000',
  493. color: isWarning ? "transparent" : innerCircle.backColor,
  494. borderWidth: 1,
  495. borderColor: isWarning ? "#A59136" : innerCircle.borderColor
  496. }
  497. },
  498. label: {
  499. show: false
  500. },
  501. data: [100]
  502. })
  503. }
  504. const func = new Function('option', 'datas', codeConfig);
  505. const opt = func(window._.cloneDeep(option), data);
  506. // console.log('opt', opt);
  507. // 使用刚指定的配置项和数据显示图表。
  508. myChart.setOption(opt);
  509. function draw() {
  510. angle = angle + 3
  511. myChart.setOption(opt, true)
  512. //window.requestAnimationFrame(draw);
  513. }
  514. if (intervalInst) {
  515. clearInterval(intervalInst);
  516. }
  517. intervalInst = setInterval(function () {
  518. //用setInterval做动画感觉有问题
  519. draw()
  520. }, 100);
  521. }
  522. }
  523. }
  524. watch([currentData, chartProps], ([val, pros]) => {
  525. nextTick(() => {
  526. initChart(val, pros)
  527. })
  528. }, {
  529. immediate: true,
  530. deep: true,
  531. })
  532. }
  533. }
  534. class CustomProgressGuageNode extends HtmlResize.view {
  535. realValue = defaultVal
  536. oldProperties = {}
  537. chartRendered = false
  538. instance = null
  539. setHtml(rootEl) {
  540. if (!rootEl) return;
  541. const { properties, width, height } = this.props.model;
  542. const { normalData } = properties.dynamic || {}
  543. let thingName = 'pressure';
  544. let attr = 'score';
  545. if (normalData && normalData.dataPoint) {
  546. const dataPointStrParsed = JSON.parse(normalData.dataPoint || '{}')
  547. const { deviceCode, dataPoint } = dataPointStrParsed;
  548. thingName = deviceCode;
  549. attr = dataPoint.split(',')[0];
  550. }
  551. if (this.instance) {
  552. // 实时数据不能推送一次就创建一次图表,可以在原有实例基础之上更改数据。
  553. Object.assign(this.instance.component.props, {
  554. name: properties.nodeAlias,
  555. chartId: \`gauge-\${properties.id}\`,
  556. currentData: this.realValue,
  557. width,
  558. height,
  559. chartProps: properties,
  560. thingName,
  561. attr,
  562. unit: normalData.unit || 'km/h'
  563. })
  564. return
  565. }
  566. const el = document.createElement('div');
  567. rootEl.innerHTML = '';
  568. const instance = createVNode(ProgressGauge, {
  569. name: properties.nodeAlias,
  570. chartId: \`gauge-\${properties.id}\`,
  571. currentData: this.realValue,
  572. width,
  573. height,
  574. chartProps: properties,
  575. thingName,
  576. attr,
  577. unit: normalData.unit || 'km/h'
  578. })
  579. instance.appContext = app._context
  580. render(instance, el)
  581. rootEl.appendChild(el);
  582. this.instance = instance;
  583. }
  584. sameProps(properties) {
  585. const isSame = window._.isEqual(this.oldProperties, properties);
  586. if (isSame) return true;
  587. this.oldProperties = properties;
  588. return false
  589. }
  590. // 生命周期 支持重写内容, 但格式需一致
  591. shouldUpdate() {
  592. const { properties } = this.props.model;
  593. const { normalData } = properties.dynamic || {};
  594. if (normalData && !normalData.dataPoint && !normalData.defaultValue) {
  595. this.realValue = defaultVal;
  596. return true
  597. }
  598. if (normalData) {
  599. const { defaultValue } = normalData || {};
  600. if (defaultValue) {
  601. const realValue = window.resolveScadaNewValue(defaultValue)
  602. if (this.realValue !== Number(realValue)) {
  603. this.realValue = Number(realValue);
  604. return true;
  605. }
  606. }
  607. }
  608. const propertiesBack = window._.cloneDeep(properties);
  609. if (propertiesBack.dynamic.normalData) {
  610. const isSameProps = this.sameProps(propertiesBack);
  611. if (isSameProps && this.chartRendered) {
  612. return false
  613. } else {
  614. if (!this.chartRendered) {
  615. this.chartRendered = true
  616. return true
  617. }
  618. if (!isSameProps) {
  619. return true;
  620. }
  621. }
  622. }
  623. }
  624. updateHtml() {
  625. this.setHtml(this.rootEl);
  626. }
  627. componentDidMount() {
  628. // 防止拖动时候频繁渲染图表
  629. this.updateHtmlDebounced = window._.debounce(this.updateHtml.bind(this), 500);
  630. if (this.shouldUpdate()) {
  631. this.setHtml(this.rootEl);
  632. }
  633. }
  634. componentDidUpdate() {
  635. if (this.shouldUpdate()) {
  636. this.updateHtmlDebounced();
  637. }
  638. }
  639. }
  640. class CustomProgressGaugeModel extends HtmlResize.model {
  641. initNodeData(data) {
  642. // 自定义组件,需最开始重���一下text 。
  643. data.text = {
  644. value: "",
  645. x: data.x,
  646. y: data.y,
  647. };
  648. super.initNodeData(data);
  649. const { properties } = this;
  650. this.width = properties.width || 80;
  651. this.height = properties.height || 35;
  652. this.text.editable = false; // 不允许文本被编辑
  653. }
  654. setAttributes() {
  655. // 自定义组件需重置 text
  656. const { x, y, properties } = this;
  657. const { textHorizontalMove = 0, textVerticalMove = 0 } = properties;
  658. this.text = {
  659. ...this.text,
  660. x: x + textHorizontalMove,
  661. y: y + textVerticalMove,
  662. value: "",
  663. }
  664. }
  665. }
  666. lf.register({
  667. type: 'custom-progress-guage',
  668. view: CustomProgressGuageNode,
  669. model: CustomProgressGaugeModel,
  670. })`,css:"",fakeData:""},p={id:e,name:n,aliasName:t,image:a,imageType:i,groupName:l,groupType:o,isRemote:!1,isDefault:!0,sectionType:d,config:s,files:r};export{t as aliasName,s as config,p as default,r as files,l as groupName,o as groupType,e as id,a as image,i as imageType,c as isDefault,u as isRemote,n as name,d as sectionType};