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

311 lines
32 KiB

  1. const e="d34d1c46-24d7-49fe-8ce5-8fec1a2080c7",t="custom-time-show",a="时间显示",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="1693817420118" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4151" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M513.875209 140.210345a30.16195 30.16195 0 0 0-1.875721 0c-16.58063-0.521886-30.467919 12.504802-30.982641 29.094642-0.030699 0.62831-0.030699 1.258667 0 1.888v310.537616H233.156736c-17.125029 0-30.982642 13.871939-30.982642 30.982641 0 17.110703 13.857613 30.982642 30.982642 30.982642h278.842752c16.58063 0.521886 30.467919-12.504802 30.982642-29.094642 0.030699-0.62831 0.030699-1.258667 0-1.888V171.192987c0.5137-16.58984-12.496615-30.460756-29.106921-30.982642zM316.816111 274.147824l-43.388183-43.809785-43.38716 43.809785 43.38716 43.808761zM223.868185 723.67191l43.388183 42.940998 43.38716-42.940998-43.38716-42.973743zM481.016847 821.824371h61.965283v61.965284h-61.965283zM821.823859 481.017358h61.965284v61.965284h-61.965284z" fill="#707070" p-id="4152"></path><path d="M511.999488 16.280802c-273.789667 0-495.719198 221.941811-495.719198 495.719198s221.930555 495.719198 495.719198 495.719198 495.719198-221.941811 495.719199-495.719198C1007.295038 238.391459 785.607006 16.690124 511.999488 16.280802z m0 929.474136c-239.569284 0-433.754938-194.197934-433.754938-433.754938S272.430204 78.245062 511.999488 78.245062s433.754938 194.197934 433.754938 433.754938c-0.363274 239.406578-194.337103 433.396781-433.754938 433.754938z" fill="#707070" p-id="4153"></path><path d="M691.692057 721.999828l43.387159 43.808762 43.38716-43.808762-43.38716-43.809785zM700.980607 272.598538l43.38716 42.972721 40.271192-42.972721-40.271192-42.971697z" fill="#707070" p-id="4154"></path></svg>',l="svg",o="基础",i="常用",u=!1,c=!0,s="时间",d=`{"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: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",
  2. "nodes": [
  3. {
  4. "id": "a931aee0-87f3-43f5-9891-995e0b1f7757",
  5. "type": "custom-time-show",
  6. "x": 200,
  7. "y": 200,
  8. "text": {
  9. "value": "",
  10. "x": 200,
  11. "y": 200
  12. },
  13. "properties": {
  14. "id": "a931aee0-87f3-43f5-9891-995e0b1f7757",
  15. "width": 200,
  16. "height": 20,
  17. "x": 200,
  18. "y": 200,
  19. "rotation": 0,
  20. "opacity": 1,
  21. "strokeWidth": 1,
  22. "showDayOfWeek": false,
  23. "formatType": "YYYY年MM月DD日 dddd HH:mm:ss",
  24. "shadowOnTop": false,
  25. "fontSize": 12,
  26. "hourMinuteSecondStyle": "// return {\\r\\n// float: 'right',\\r\\n// display: 'inline',\\r\\n// height: '100%',\\r\\n// fontSize: '25px',\\r\\n// marginLeft: '15px',\\r\\n// color: '#ffffff',\\r\\n// fontFamily: 'Impact',\\r\\n// }",
  27. "nodeAlias": "时间显示",
  28. "lineHeight": 20,
  29. "fill": "rgba(74, 144, 226, 1)",
  30. "dynamic": {
  31. "uiData": {
  32. "dataPoint": "",
  33. "compareType": "",
  34. "conditionVariables": []
  35. }
  36. }
  37. }
  38. }
  39. ]
  40. }`,javascript:`
  41. const { createApp, createVNode, render } = Vue;
  42. const app = createApp({})
  43. const Button = {
  44. template: '<div :style="getStyle" :class="{timesshow: true, shadowOnTop: shadowOnTop}">{{ currentTime }}<span v-if="hourMinuteSecondStyleRet" :style="hourMinuteSecondStyleRet"> {{hourMinuteSecond}}</span></div>',
  45. props: {
  46. fontColor: {
  47. type: String,
  48. default: '#ffffff'
  49. },
  50. fontSize: {
  51. type: Number,
  52. default: 14
  53. },
  54. fontFamily: {
  55. type: String,
  56. default: '宋体'
  57. },
  58. fontStyle: {
  59. type: String,
  60. default: 'normal'
  61. },
  62. width: {
  63. type: Number,
  64. default: 80
  65. },
  66. height: {
  67. type: Number,
  68. default: 18
  69. },
  70. lineHeight: {
  71. type: Number,
  72. default: 18,
  73. },
  74. backgroundColor: {
  75. type: String,
  76. default: '#1890ff',
  77. },
  78. strokeColor: {
  79. type: String,
  80. default: '#1890ff',
  81. },
  82. strokeWidth: {
  83. type: Number,
  84. default: 1,
  85. },
  86. opacity: {
  87. type: Number,
  88. default: 1,
  89. },
  90. realValue: {
  91. type: [String, Number],
  92. default: ''
  93. },
  94. showDayOfWeek: {
  95. type: Boolean,
  96. default: false
  97. },
  98. formatType: {
  99. type: String,
  100. default: 'YYYY-MM-DD HH:mm:ss',
  101. },
  102. hourMinuteSecondStyle: {
  103. type: String,
  104. default: '',
  105. },
  106. shadowOnTop: {
  107. type: Boolean,
  108. default: false
  109. }
  110. },
  111. computed: {
  112. getStyle() {
  113. const { fontColor, fontSize, fontFamily, fontStyle, width, height, lineHeight, backgroundColor, strokeColor, strokeWidth, opacity } = this
  114. const style = {}
  115. if (fontStyle) {
  116. if (fontStyle.includes('bold')) {
  117. style.fontWeight = 'bolder';
  118. }
  119. if (fontStyle.includes('italic')) {
  120. style.fontStyle = 'italic'
  121. }
  122. if (fontStyle.includes('underline,line-through')) {
  123. style.textDecoration = 'underline line-through'
  124. } else if (fontStyle.includes('line-through,underline')) {
  125. style.textDecoration = 'line-through underline'
  126. } else if (fontStyle.includes('underline')) {
  127. style.textDecoration = 'underline'
  128. } else if (fontStyle.includes('line-through')) {
  129. style.textDecoration = 'line-through'
  130. }
  131. }
  132. return {
  133. color: fontColor,
  134. "font-size": parseInt(fontSize) + 'px',
  135. "font-family": fontFamily,
  136. "font-style": style.fontStyle,
  137. "font-weight": style.fontWeight,
  138. "text-decoration": style.textDecoration,
  139. width: parseInt(width) - parseInt(strokeWidth) * 2 + 'px',
  140. height: parseInt(height) - parseInt(strokeWidth) * 2 + 'px',
  141. lineHeight: parseInt(lineHeight) - parseInt(strokeWidth) * 2 + 'px',
  142. "text-align": 'center',
  143. 'background-color': backgroundColor,
  144. "border-radius": '2px',
  145. "box-shadow": "0 2px 0 rgba(0, 0, 0, 0.45)",
  146. "border-color": strokeColor,
  147. "border-style": "solid",
  148. "border-width": parseInt(strokeWidth) + 'px',
  149. "opacity": opacity,
  150. }
  151. }
  152. },
  153. setup(props) {
  154. const { ref, onMounted, computed } = Vue
  155. let currentTime = ref('');
  156. let hourMinuteSecond = ref('');
  157. onMounted(() => {
  158. let type = props.formatType;
  159. if (props.hourMinuteSecondStyle) {
  160. type = type.replace(' HH:mm:ss', '');
  161. }
  162. const date = window.dayjs(new Date());
  163. currentTime.value = date.format(type);
  164. if (props.hourMinuteSecondStyle) {
  165. hourMinuteSecond.value = date.format("HH:mm:ss");
  166. }
  167. setInterval(() => {
  168. const date2 = window.dayjs(new Date());
  169. currentTime.value = date2.format(type);
  170. if (props.hourMinuteSecondStyle) {
  171. hourMinuteSecond.value = date2.format("HH:mm:ss");
  172. }
  173. }, 1000)
  174. })
  175. const hourMinuteSecondStyleRet = computed(() => {
  176. if (props.hourMinuteSecondStyle) {
  177. const stylesStr = props.hourMinuteSecondStyle;
  178. const fn = new Function('', stylesStr);
  179. const styleObj = fn();
  180. return {
  181. lineHeight: props.height + 'px',
  182. ...styleObj,
  183. };
  184. } else {
  185. return null
  186. }
  187. })
  188. return {
  189. currentTime,
  190. hourMinuteSecond,
  191. hourMinuteSecondStyleRet
  192. }
  193. }
  194. }
  195. class CustomTimeShowNode extends HtmlResize.view {
  196. setHtml(rootEl) {
  197. const { graphModel } = this.props;
  198. const { properties, width, height, } = this.props.model;
  199. const { content, fontColor, fontSize, fontFamily, fontStyle, lineHeight, fill,
  200. strokeColor, strokeWidth, opacity, showDayOfWeek, formatType, hourMinuteSecondStyle, shadowOnTop } = properties;
  201. const { model } = this.props;
  202. const el = document.createElement('div');
  203. rootEl.innerHTML = '';
  204. const { uiData } = properties.dynamic || {};
  205. let fillColor = fill
  206. let fontC = fontColor
  207. let realValue = ''
  208. if (uiData) {
  209. realValue = window.resolveScadaNewValue(uiData.defaultValue)
  210. if (realValue !== '') {
  211. uiData.conditionVariables.forEach((item) => {
  212. if (item.type === 'rangeColor') {
  213. let from = item.from;
  214. let to = item.to;
  215. if (item.from >= item.to) {
  216. from = item.to;
  217. to = item.from;
  218. }
  219. if (item.backColor && Number(realValue) >= from && Number(realValue) <= to) {
  220. fillColor = item.backColor
  221. }
  222. if (item.fontColor && Number(realValue) >= from && Number(realValue) <= to) {
  223. fontC = item.fontColor
  224. }
  225. } else if (item.type === 'equal') {
  226. if (Number(realValue) === Number(item.value)) {
  227. item.backColor && (fillColor = item.backColor);
  228. item.fontColor && (fontC = item.fontColor);
  229. dynamicName = item.valueLabel;
  230. }
  231. } else if (item.type === 'boolean') {
  232. if (realValue === 'true' || realValue === true) {
  233. item.backColor && (fillColor = item.backColor);
  234. item.fontColor && (fontC = item.fontColor);
  235. dynamicName = item.valueLabel;
  236. }
  237. }
  238. })
  239. }
  240. }
  241. const instance = createVNode(Button, {
  242. fontColor: fontC,
  243. fontSize, fontFamily, fontStyle, width, height, lineHeight,
  244. backgroundColor: fillColor,
  245. strokeColor, strokeWidth,
  246. opacity,
  247. realValue,
  248. showDayOfWeek,
  249. formatType,
  250. hourMinuteSecondStyle,
  251. shadowOnTop
  252. })
  253. instance.appContext = app._context
  254. render(instance, el)
  255. rootEl.appendChild(el);
  256. }
  257. }
  258. class CustomTimeShowModel extends HtmlResize.model {
  259. initNodeData(data) {
  260. // 自定义组件,需最开始重置一下text 。
  261. data.text = {
  262. value: "",
  263. x: data.x,
  264. y: data.y,
  265. };
  266. super.initNodeData(data);
  267. const { properties } = this;
  268. this.width = properties.width || 80;
  269. this.height = properties.height || 35;
  270. this.text.editable = false; // 不允许文本被编辑
  271. }
  272. setAttributes() {
  273. // 自定义组件需重置 text
  274. const { x, y, properties } = this;
  275. const { textHorizontalMove = 0, textVerticalMove = 0 } = properties;
  276. this.text = {
  277. ...this.text,
  278. x: x + textHorizontalMove,
  279. y: y + textVerticalMove,
  280. value: "",
  281. }
  282. }
  283. }
  284. lf.register({
  285. type: 'custom-time-show',
  286. view: CustomTimeShowNode,
  287. model: CustomTimeShowModel,
  288. })
  289. `,css:`.timesshow.shadowOnTop:after {\r
  290. content: '';\r
  291. display: inline-block;\r
  292. height: 12px;\r
  293. position: absolute;\r
  294. top: 50%;\r
  295. right: 0;\r
  296. left: 0;\r
  297. margin-top: -6px;\r
  298. background: linear-gradient(0deg, rgba(0, 0, 0, 0.35) 0%, rgba(0, 0, 0, 0) 100%);\r
  299. background-size: cover;\r
  300. z-index: 100;\r
  301. }`,fakeData:""},m={id:e,name:t,aliasName:a,image:n,imageType:l,groupName:o,groupType:i,isRemote:!1,isDefault:!0,sectionType:s,config:d,files:r};export{a as aliasName,d as config,m as default,r as files,o as groupName,i as groupType,e as id,n as image,l as imageType,c as isDefault,u as isRemote,t as name,s as sectionType};