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

426 lines
40 KiB

  1. const e="9baa74d2-12dd-4ca2-af3d-e328c34ec042",a="custom-tab-node",t="Tab 列表",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="1700615796607" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="10653" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M758.216 745.72H249.184c-44.008 0-79.816-35.808-79.816-79.816V279.712c0-44.008 35.808-79.816 79.816-79.816h439.496v127.872c0 8.912 5.168 15.12 9.792 15.12h139.56v323.016c0 44.008-35.808 79.816-79.816 79.816zM249.184 230.288a49.472 49.472 0 0 0-49.416 49.424v386.192a49.48 49.48 0 0 0 49.416 49.424h509.032a49.48 49.48 0 0 0 49.424-49.424V373.28H698.472c-22.16 0-40.184-20.408-40.184-45.504V230.288H249.184z" fill="#FF0031" p-id="10654"></path><path d="M834.232 278.352c0 6.44-4.304 11.656-9.608 11.656h-75.68c-5.304 0-9.608-5.216-9.608-11.656v-69.64c0-6.44 4.304-11.656 9.608-11.656h75.68c5.304 0 9.608 5.216 9.608 11.656v69.64z" fill="#D6072E" p-id="10655"></path><path d="M316.528 617.808V464.88h-54.616v-31.136h146.272v31.136h-54.496v152.928h-37.16zM579.072 617.808H538.64l-16.072-41.816h-73.576l-15.192 41.816h-39.424l71.688-184.064h39.304l73.704 184.064z m-68.432-72.824l-25.36-68.304-24.856 68.304h50.216zM598.904 433.744h73.568c14.568 0 25.432 0.608 32.584 1.824s13.552 3.744 19.208 7.592c5.648 3.848 10.352 8.976 14.128 15.384 3.768 6.4 5.648 13.584 5.648 21.528 0 8.624-2.32 16.528-6.968 23.728A43.2 43.2 0 0 1 718.176 520c11.216 3.256 19.832 8.832 25.864 16.696 6.024 7.864 9.04 17.12 9.04 27.752a54.808 54.808 0 0 1-5.832 24.424c-3.896 7.904-9.208 14.224-15.944 18.952-6.744 4.736-15.048 7.64-24.92 8.728-6.2 0.672-21.144 1.096-44.832 1.256h-62.648V433.744z m37.168 30.632v42.56h24.352c14.488 0 23.488-0.2 27-0.624 6.36-0.76 11.36-2.952 15-6.592s5.464-8.432 5.464-14.376c0-5.688-1.568-10.32-4.704-13.872-3.144-3.552-7.808-5.712-14-6.464-3.688-0.416-14.272-0.632-31.768-0.632h-21.344z m0 73.2v49.208h34.4c13.392 0 21.888-0.376 25.496-1.128 5.52-1.008 10.024-3.456 13.496-7.344 3.48-3.896 5.208-9.112 5.208-15.632 0-5.52-1.336-10.208-4.016-14.064s-6.552-6.656-11.616-8.416-16.048-2.632-32.952-2.632h-30.016z" p-id="10656"></path></svg>',l="svg",i="基础",o="常用",c=!1,u=!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: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:1b561d652a
  2. "nodes": [
  3. {
  4. "id": "533ecd8e-2be2-4715-85fb-50b5fa9cedcf",
  5. "type": "custom-tab-node",
  6. "x": 200,
  7. "y": 200,
  8. "text": {
  9. "value": "",
  10. "x": 200,
  11. "y": 200
  12. },
  13. "properties": {
  14. "id": "533ecd8e-2be2-4715-85fb-50b5fa9cedcf",
  15. "width": 150,
  16. "height": 42,
  17. "x": 200,
  18. "y": 200,
  19. "rotation": 0,
  20. "opacity": 1,
  21. "borderRadius": 4,
  22. "tabMargin": 0,
  23. "unselectedFontColor": "rgba(255, 255, 255, 1)",
  24. "unselectedBorderColor": "",
  25. "unselectedBack": "rgba(155, 155, 155, 1)",
  26. "unselectedBackImg": "",
  27. "unselectedFontSize": 12,
  28. "unselectedBorderWidth": 1,
  29. "unselectedBorderRadius": 0,
  30. "selectedFontColor": "rgba(255, 255, 255, 1)",
  31. "selectedBorderColor": "",
  32. "selectedBack": "rgba(74, 144, 226, 1)",
  33. "selectedBackImg": "",
  34. "selectedFontSize": 12,
  35. "selectedBorderWidth": 1,
  36. "selectedBorderRadius": 0,
  37. "fontSize": 12,
  38. "nodeAlias": "Tab 列表",
  39. "showDefaultValue": false,
  40. "showUnit": false,
  41. "valueColor": "rgba(245, 166, 35, 1)",
  42. "tabBackground": "",
  43. "dynamic": {
  44. "normalData": {
  45. "dataPoint": "",
  46. "compareType": "",
  47. "conditionVariables": [],
  48. "defaultValue": "",
  49. "unit": "",
  50. "dataFilterFn": "return datas",
  51. "defaultOptions": [
  52. {
  53. "label": "电",
  54. "value": "A29"
  55. },
  56. {
  57. "label": "水",
  58. "value": "B2"
  59. }
  60. ]
  61. },
  62. "eventsData": {
  63. "eventCombo": [
  64. {
  65. "eventType": "change",
  66. "enable": false,
  67. "config": "",
  68. "customEventHandler": false,
  69. "targetParamsType": "entitys",
  70. "targetParamsEntitys": "list",
  71. "targetParamsAttrsKeysEntitys": "keys"
  72. }
  73. ]
  74. }
  75. }
  76. }
  77. }
  78. ]
  79. }`,javascript:`const { createApp, createVNode, render } = Vue;
  80. const app = createApp({})
  81. const Tab = {
  82. template: \`<div :style="getStyle">
  83. <div v-for="(item,index) in myRadioList" :key="item.value" :style="getTabStyle(item, unselectedFontColor, unselectedBorderColor, unselectedBack, unselectedBackImg, unselectedFontSize,
  84. unselectedBorderWidth, selectedFontColor, selectedBorderColor, selectedBack, selectedBackImg, selectedFontSize,
  85. selectedBorderWidth, tabMargin, unselectedBorderRadius, selectedBorderRadius, index, myRadioList)" @click="clickHandler(item)">{{item.label}}</div>
  86. </div>\`,
  87. props: {
  88. realValue: {
  89. type: String,
  90. default: ''
  91. },
  92. radioList: {
  93. type: Array,
  94. default: () => []
  95. },
  96. fontColor: {
  97. type: String,
  98. default: '#ffffff'
  99. },
  100. fontSize: {
  101. type: Number,
  102. default: 14
  103. },
  104. fontFamily: {
  105. type: String,
  106. default: '宋体'
  107. },
  108. fontStyle: {
  109. type: String,
  110. default: 'normal'
  111. },
  112. width: {
  113. type: Number,
  114. default: 80
  115. },
  116. height: {
  117. type: Number,
  118. default: 35
  119. },
  120. unselectedFontColor: {
  121. type: String,
  122. default: 'rgba(255, 255, 255, 1)'
  123. },
  124. borderRadius: {
  125. type: Number,
  126. default: 2
  127. },
  128. unselectedBorderColor: {
  129. type: String,
  130. default: 'rgba(176, 174, 174, 1)'
  131. },
  132. unselectedBack: {
  133. type: String,
  134. default: 'rgba(176, 174, 174, 1)'
  135. },
  136. unselectedBackImg: {
  137. type: String,
  138. default: ''
  139. },
  140. unselectedFontSize: {
  141. type: Number,
  142. default: 12
  143. },
  144. unselectedBorderWidth: {
  145. type: Number,
  146. default: 1
  147. },
  148. selectedFontColor: {
  149. type: String,
  150. default: 'rgba(255, 255, 255, 1)'
  151. },
  152. selectedBorderColor: {
  153. type: String,
  154. default: 'rgba(74, 144, 226, 1)'
  155. },
  156. selectedBack: {
  157. type: String,
  158. default: 'rgba(74, 144, 226, 1)'
  159. },
  160. selectedBackImg: {
  161. type: String,
  162. default: ''
  163. },
  164. selectedFontSize: {
  165. type: Number,
  166. default: 12
  167. },
  168. selectedBorderWidth: {
  169. type: Number,
  170. default: 1
  171. },
  172. tabMargin: {
  173. type: Number,
  174. default: 0
  175. },
  176. unselectedBorderRadius: {
  177. type: Number,
  178. default: 0
  179. },
  180. selectedBorderRadius: {
  181. type: Number,
  182. default: 0
  183. },
  184. tabBackground: {
  185. type: String,
  186. default: ''
  187. }
  188. },
  189. emits: ["change"],
  190. computed: {
  191. getStyle() {
  192. const { width, height, borderRadius, tabBackground } = this;
  193. return {
  194. width: width + 'px',
  195. height: height + 'px',
  196. display: 'flex',
  197. "flex-direction": width > height ? "row" : "column",
  198. "justify-content": "flex-start",
  199. "align-items": "center",
  200. 'border-radius': borderRadius + 'px',
  201. 'background': tabBackground,
  202. 'background-size': 'cover',
  203. 'overflow': 'hidden'
  204. }
  205. },
  206. getTabStyle: () => (item, unselectedFontColor, unselectedBorderColor, unselectedBack, unselectedBackImg, unselectedFontSize,
  207. unselectedBorderWidth, selectedFontColor, selectedBorderColor, selectedBack, selectedBackImg, selectedFontSize,
  208. selectedBorderWidth, tabMargin, unselectedBorderRadius, selectedBorderRadius, index, myRadioList) => {
  209. if (item.checked !== 'checked') {
  210. return {
  211. color: unselectedFontColor,
  212. 'font-size': unselectedFontSize + 'px',
  213. 'border-style': "solid",
  214. 'border-width': unselectedBorderWidth + 'px',
  215. 'border-color': unselectedBorderColor,
  216. 'background-color': unselectedBack,
  217. 'background-image': unselectedBackImg ? "url(" + unselectedBackImg + ")" : 'none',
  218. 'background-size': '100% 100%',
  219. 'display': 'flex',
  220. 'justify-content': 'center',
  221. 'align-items': 'center',
  222. 'flex': '1',
  223. 'height': \`calc(100% - \${unselectedBorderWidth * 2}px)\`,
  224. 'width': '100%',
  225. 'cursor': 'pointer',
  226. 'margin-right': tabMargin + 'px',
  227. 'border-radius': unselectedBorderRadius + 'px'
  228. }
  229. } else {
  230. const borderStyle = {}
  231. const length = myRadioList.length;
  232. if (index === 0) {
  233. borderStyle['border-right-width'] = 0;
  234. } else if (index === length - 1) {
  235. borderStyle['border-left-width'] = 0;
  236. } else {
  237. borderStyle['border-left-width'] = 0;
  238. borderStyle['border-right-width'] = 0;
  239. }
  240. return {
  241. color: selectedFontColor,
  242. 'font-size': selectedFontSize + 'px',
  243. 'border-style': "solid",
  244. 'border-width': selectedBorderWidth + 'px',
  245. 'border-color': selectedBorderColor,
  246. 'background-color': selectedBack,
  247. 'background-image': selectedBackImg ? "url(" + selectedBackImg + ")" : 'none',
  248. 'background-size': '100% 100%',
  249. 'display': 'flex',
  250. 'justify-content': 'center',
  251. 'align-items': 'center',
  252. 'flex': '1',
  253. 'height': \`calc(100% - \${selectedBorderWidth * 2}px)\`,
  254. 'width': '100%',
  255. 'cursor': 'pointer',
  256. 'margin-right': tabMargin + 'px',
  257. 'border-radius': selectedBorderRadius + 'px',
  258. ...borderStyle
  259. }
  260. }
  261. }
  262. },
  263. setup(props, { emit }) {
  264. const { ref, watch } = Vue
  265. const myRadioList = ref([])
  266. const clickHandler = (item) => {
  267. myRadioList.value.forEach((el) => {
  268. if (el.value === item.value) {
  269. el.checked = 'checked';
  270. } else {
  271. el.checked = false
  272. }
  273. })
  274. emit("change", item.value);
  275. }
  276. watch(() => props.radioList, (val) => {
  277. myRadioList.value = val
  278. }, {
  279. immediate: true,
  280. })
  281. watch(() => props.realValue, (val) => {
  282. if (val) {
  283. myRadioList.value.forEach((el) => {
  284. if (el.value === String(val)) {
  285. el.checked = 'checked';
  286. } else {
  287. el.checked = false
  288. }
  289. })
  290. }
  291. }, {
  292. immediate: true,
  293. })
  294. return {
  295. clickHandler,
  296. myRadioList
  297. }
  298. }
  299. }
  300. class CustomTabNode extends HtmlResize.view {
  301. oldProperties = {}
  302. setHtml(rootEl) {
  303. const { properties, width, height, } = this.props.model;
  304. const { fontColor, fontSize, fontFamily, fontStyle,
  305. unselectedFontColor, unselectedBorderColor, unselectedBack, unselectedBackImg, unselectedFontSize,
  306. unselectedBorderWidth, selectedFontColor, selectedBorderColor, selectedBack, selectedBackImg, selectedFontSize,
  307. selectedBorderWidth, borderRadius, tabMargin, unselectedBorderRadius, selectedBorderRadius, tabBackground
  308. } = properties;
  309. const { model, graphModel } = this.props;
  310. const el = document.createElement('div');
  311. rootEl.innerHTML = '';
  312. const { normalData } = properties.dynamic || {};
  313. const { defaultOptions } = normalData || {};
  314. let list = [];
  315. if (defaultOptions) {
  316. let opts = []
  317. if (typeof defaultOptions !== 'string') {
  318. opts = defaultOptions
  319. } else {
  320. opts = JSON.parse(defaultOptions);
  321. }
  322. list = window._.cloneDeep(opts).map((el, index) => {
  323. if (index === 0) {
  324. el.checked = 'checked'
  325. } else {
  326. el.checked = false
  327. }
  328. return el;
  329. })
  330. }
  331. let realValue = "";
  332. if (normalData) {
  333. realValue = window.resolveScadaNewValue(normalData.defaultValue);
  334. }
  335. const changeHandler = (e) => {
  336. graphModel.eventCenter.emit("node:change", {
  337. data: this.props.model,
  338. e,
  339. });
  340. }
  341. if (list[0]) {
  342. setTimeout(() => {
  343. changeHandler(list[0].value);
  344. }, 100)
  345. }
  346. const instance = createVNode(Tab, {
  347. realValue,
  348. radioList: list,
  349. fontColor,
  350. fontSize, fontFamily, fontStyle, width, height,
  351. unselectedFontColor, unselectedBorderColor, unselectedBack, unselectedBackImg, unselectedFontSize,
  352. unselectedBorderWidth, selectedFontColor, selectedBorderColor, selectedBack, selectedBackImg, selectedFontSize,
  353. selectedBorderWidth, borderRadius, tabMargin, unselectedBorderRadius, selectedBorderRadius, tabBackground,
  354. onChange: changeHandler
  355. })
  356. instance.appContext = app._context
  357. render(instance, el)
  358. rootEl.appendChild(el);
  359. }
  360. sameProps(properties) {
  361. const isSame = window._.isEqual(this.oldProperties, properties);
  362. if (isSame) return true;
  363. this.oldProperties = properties;
  364. return false
  365. }
  366. // 生命周期 支持重写内容, 但格式需一致
  367. shouldUpdate() {
  368. const { properties } = this.props.model;
  369. const propertiesBack = window._.cloneDeep(properties);
  370. // 由于事件change 会给properties 增加一个 event 属性(见目录scadaDashboard/Diagram/useDynamicEventsHandler),会引发属性的改变,导致组件重渲染。
  371. delete propertiesBack.event;
  372. if (this.sameProps(propertiesBack)) {
  373. return false
  374. }
  375. return true;
  376. }
  377. }
  378. class CustomTabModel extends HtmlResize.model {
  379. initNodeData(data) {
  380. // 自定义组件,需最开始重置一下text 。
  381. data.text = {
  382. value: "",
  383. x: data.x,
  384. y: data.y,
  385. };
  386. super.initNodeData(data);
  387. const { properties } = this;
  388. this.width = properties.width || 80;
  389. this.height = properties.height || 35;
  390. }
  391. setAttributes() {
  392. // 自定义组件需重置 text
  393. const { x, y, properties } = this;
  394. const { textHorizontalMove = 0, textVerticalMove = 0 } = properties;
  395. this.text = {
  396. ...this.text,
  397. x: x + textHorizontalMove,
  398. y: y + textVerticalMove,
  399. value: "",
  400. }
  401. }
  402. }
  403. lf.register({
  404. type: 'custom-tab-node',
  405. view: CustomTabNode,
  406. model: CustomTabModel,
  407. })
  408. `,css:"",fakeData:""},m={id:e,name:a,aliasName:t,image:n,imageType:l,groupName:i,groupType:o,isRemote:!1,isDefault:!0,sectionType:s,config:d,files:r};export{t as aliasName,d as config,m as default,r as files,i as groupName,o as groupType,e as id,n as image,l as imageType,u as isDefault,c as isRemote,a as name,s as sectionType};