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

752 lines
43 KiB

  1. const e="5a72da54-c053-4e8d-8880-6e5453b16fc9",n="custom-select-node",t="下拉选择框",o='<?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="1696993298055" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1446" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M992.65 373.55H31.35V101.88c0-34.57 28.12-62.69 62.69-62.69h835.92c34.57 0 62.69 28.12 62.69 62.69v271.67zM73.14 331.76h877.71V101.88c0-11.52-9.37-20.9-20.9-20.9H94.04c-11.52 0-20.9 9.38-20.9 20.9v229.88zM929.96 984.82H94.04c-34.57 0-62.69-28.12-62.69-62.69V441.47h961.31v480.65c-0.01 34.57-28.13 62.7-62.7 62.7zM73.14 483.27v438.86c0 11.53 9.38 20.9 20.9 20.9h835.92c11.53 0 20.9-9.37 20.9-20.9V483.27H73.14z" fill="#707070" p-id="1447"></path><path d="M825.47 269.06c-6.57 0-12.78-3.09-16.71-8.36l-62.69-83.59c-6.94-9.23-5.06-22.34 4.18-29.26 9.22-6.97 22.33-5.05 29.24 4.17l45.98 61.31 45.98-61.31c6.92-9.2 20.04-11.12 29.24-4.17 9.24 6.92 11.12 20.02 4.18 29.26l-62.69 83.59a20.862 20.862 0 0 1-16.71 8.36zM522.45 227.27H188.08c-11.54 0-20.9-9.36-20.9-20.9s9.36-20.9 20.9-20.9h334.37c11.55 0 20.9 9.36 20.9 20.9s-9.35 20.9-20.9 20.9zM658.29 629.55H156.73c-11.54 0-20.9-9.35-20.9-20.9s9.36-20.9 20.9-20.9h501.55c11.55 0 20.9 9.35 20.9 20.9s-9.34 20.9-20.89 20.9zM867.27 838.53H156.73c-11.54 0-20.9-9.35-20.9-20.9s9.36-20.9 20.9-20.9h710.53c11.55 0 20.9 9.35 20.9 20.9s-9.34 20.9-20.89 20.9z" fill="#707070" p-id="1448"></path></svg>',l="svg",a="动态",s="表单控件",p=!1,c=!0,i="时间",r=`{"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: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","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
  2. "nodes": [
  3. {
  4. "id": "183806b2-ccf3-473f-821a-1b3c0b8e4df4",
  5. "type": "custom-select-node",
  6. "x": 200,
  7. "y": 200,
  8. "text": {
  9. "value": "",
  10. "x": 200,
  11. "y": 200
  12. },
  13. "properties": {
  14. "id": "183806b2-ccf3-473f-821a-1b3c0b8e4df4",
  15. "width": 120,
  16. "height": 30,
  17. "x": 200,
  18. "y": 200,
  19. "rotation": 0,
  20. "strokeWidth": 1,
  21. "placeholder": "请选择",
  22. "dropdownStrokeWidth": 1,
  23. "fontSize": 14,
  24. "showText": false,
  25. "nodeAlias": "下拉选择框",
  26. "opacity": 1,
  27. "showDefaultValue": false,
  28. "showUnit": false,
  29. "fontColor": "rgba(255, 255, 255, 1)",
  30. "fontFamily": "Microsoft Yahei",
  31. "fontStyle": "",
  32. "fill": "rgba(74, 144, 226, 1)",
  33. "strokeColor": "rgba(74, 144, 226, 1)",
  34. "dropdownFill": "rgba(255, 255, 255, 0)",
  35. "dropdownStrokeColor": "rgba(74, 144, 226, 1)",
  36. "dropdownFontColor": "rgba(40, 131, 238, 1)",
  37. "triangleColor": "rgba(255, 255, 255, 1)",
  38. "dropdownHoverFontColor": "rgba(255, 255, 255, 1)",
  39. "dropdownHoverFill": "rgba(74, 144, 226, 1)",
  40. "background": "",
  41. "borderRadius": 2,
  42. "dynamic": {
  43. "normalData": {
  44. "dataPoint": "/v1/entity/list?templateMark=0",
  45. "compareType": "",
  46. "conditionVariables": [],
  47. "defaultValue": [],
  48. "unit": "",
  49. "requestMethod": "get",
  50. "dataFilterFn": "return datas.map(i => ({\\r\\n label: i.entityName,\\r\\n value: i.entityId,\\r\\n}))",
  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. "targetParams": "nearest-day",
  68. "targetParamsType": "entitys",
  69. "targetParamsAttrsType": "all",
  70. "targetParamsAttrsKeysEntitys": "keys",
  71. "targetParamsTimesType": "nearest",
  72. "targetParamsEntitys": "list",
  73. "apiId": "",
  74. "moreOperation": ""
  75. }
  76. ]
  77. }
  78. }
  79. }
  80. }
  81. ]
  82. }`,javascript:`
  83. const { createApp, createVNode, render } = Vue;
  84. const app = createApp({})
  85. const defaultOptions = [
  86. {
  87. label: 'AA',
  88. value: 'a'
  89. },
  90. {
  91. label: 'BB',
  92. value: 'b'
  93. }
  94. ]
  95. const Options = {
  96. template: \`
  97. <div v-show="showDropdown" :id="id" :style="dropdownStyle" class="scada-select-dropdown" :class="{showdrop: showDropdown}">
  98. <div v-if="options.length === 0" :style="selectOptionStyle" class="scada-select-dropdown-option">暂无数据</div>
  99. <div v-for="item in options" :key="item.value" :data-key="item.value" :style="selectOptionStyle(item)" @click="selectOption(item)" class="scada-select-dropdown-option" @mousemove="(e) => handleMove(e, item.label)">{{ item.label }}</div>
  100. </div>
  101. \`,
  102. props: {
  103. id: {
  104. type: String,
  105. default: ''
  106. },
  107. showDropdown: {
  108. type: Boolean,
  109. default: false
  110. },
  111. options: {
  112. type: Array,
  113. default: []
  114. },
  115. selects: {
  116. type: Object,
  117. default: {
  118. label: '请选择',
  119. value: '-'
  120. }
  121. },
  122. fontColor: {
  123. type: String,
  124. default: '#ffffff'
  125. },
  126. fontSize: {
  127. type: Number,
  128. default: 14
  129. },
  130. fontFamily: {
  131. type: String,
  132. default: '宋体'
  133. },
  134. fontStyle: {
  135. type: String,
  136. default: 'normal'
  137. },
  138. width: {
  139. type: Number,
  140. default: 60
  141. },
  142. height: {
  143. type: Number,
  144. default: 34
  145. },
  146. lineHeight: {
  147. type: Number,
  148. default: 34,
  149. },
  150. strokeWidth: {
  151. type: Number,
  152. default: 2,
  153. },
  154. borderColor: {
  155. type: String,
  156. default: '#1890ff'
  157. },
  158. backgroundColor: {
  159. type: String,
  160. default: '#1890ff',
  161. },
  162. hoverFontColor: {
  163. type: String,
  164. default: '#ffffff'
  165. },
  166. hoverFillColor: {
  167. type: String,
  168. default: '#1890ff'
  169. }
  170. },
  171. emits: ['selected'],
  172. setup(props, { emit }) {
  173. const { ref, computed, nextTick, onMounted, onUnmounted } = Vue
  174. const selects = ref({
  175. label: '请选择',
  176. value: '-'
  177. });
  178. const dropdownStyle = computed(() => {
  179. const realWidth = parseInt(props.width);
  180. return \`
  181. width: \${realWidth - props.strokeWidth * 2}px;
  182. height: 0px;
  183. max-height: 350px;
  184. overflow-y: auto;
  185. border-width: \${props.strokeWidth}px;
  186. border-style: solid;
  187. border-radius: 2px;
  188. border-color:\${props.borderColor};
  189. border-bottom: 1 solid \${props.borderColor};
  190. box-shadow: 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 9px 28px 8px rgba(0, 0, 0, 0.05);
  191. transition: height ease-in-out 0.2s;
  192. \`
  193. })
  194. const selectOptionStyle = computed(() => (option) => {
  195. const isSelected = props.selects.value === option.value;
  196. const backColor = isSelected ? props.hoverFillColor : props.backgroundColor;
  197. const fontColor = isSelected ? props.hoverFontColor : props.fontColor;
  198. return \`
  199. display: block;
  200. font-size: 12px;
  201. width: 100%;
  202. height: 30px;
  203. line-height: 30px;
  204. text-align: center;
  205. color: \${fontColor};
  206. background-color: \${backColor};
  207. padding: 0 5px;
  208. box-sizing: border-box;
  209. cursor: pointer;
  210. overflow: hidden;
  211. text-overflow: ellipsis;
  212. white-space: nowrap;
  213. \`
  214. })
  215. const selectOption = (ev) => {
  216. selects.value = ev
  217. emit('selected', selects.value)
  218. }
  219. const defaultSelect = () => {
  220. selects.value = {
  221. label: '请选择',
  222. value: '-'
  223. }
  224. emit('selected', selects.value)
  225. }
  226. const moveHandler = (e) => {
  227. const target = e.target ;
  228. const insideDropdown = target.closest('.scada-select-dropdown');
  229. if(!insideDropdown) {
  230. const tooltip = document.querySelector('.scada-select-dropdown-tooltip');
  231. if(tooltip) {
  232. tooltip.remove();
  233. }
  234. }
  235. }
  236. const handleMove= window._.debounce(function (e, label) {
  237. const x = e.pageX;
  238. const y = e.pageY;
  239. const offsetWidth = e.target.offsetWidth;
  240. const scrollWidth = e.target.scrollWidth;
  241. if (offsetWidth < scrollWidth) {
  242. const tooltip = document.querySelector('.scada-select-dropdown-tooltip');
  243. if (!tooltip) {
  244. const span = document.createElement('span');
  245. span.className = 'scada-select-dropdown-tooltip';
  246. span.innerHTML = label;
  247. span.style.top = y + 10 + 'px';
  248. span.style.left = x + 15 + 'px';
  249. document.body.appendChild(span);
  250. } else {
  251. tooltip.innerHTML = label;
  252. tooltip.style.top = y + 10 + 'px';
  253. tooltip.style.left = x + 15 + 'px';
  254. }
  255. } else {
  256. const tooltip = document.querySelector('.scada-select-dropdown-tooltip');
  257. tooltip && tooltip.remove();
  258. }
  259. }, 200)
  260. onMounted(() => {
  261. nextTick(() => {
  262. const optionDoms = Array.from(document.querySelectorAll('.scada-select-dropdown-option'));
  263. optionDoms.forEach((opt) => {
  264. opt.mouseoverFn = () => {
  265. opt.style.color = props.hoverFontColor;
  266. opt.style.backgroundColor = props.hoverFillColor;
  267. }
  268. opt.mouseleaveFn = () => {
  269. const dataKey = opt.dataset.key;
  270. if (dataKey !== props.selects.value) {
  271. opt.style.color = props.fontColor;
  272. opt.style.backgroundColor = props.backgroundColor;
  273. } else {
  274. opt.style.color = props.hoverFontColor;
  275. opt.style.backgroundColor = props.hoverFillColor;
  276. }
  277. }
  278. opt.addEventListener('mouseover', opt.mouseoverFn);
  279. opt.addEventListener('mouseleave', opt.mouseleaveFn);
  280. })
  281. const dropdownDom = document.getElementById(props.id);
  282. const dropdown = document.querySelector('.scada-select-dropdown-option');
  283. if (dropdownDom) {
  284. setTimeout(()=> {
  285. dropdownDom.style.height = props.options.length * dropdown.offsetHeight + 'px';
  286. }, 0)
  287. }
  288. });
  289. document.body.addEventListener('mousemove', moveHandler)
  290. })
  291. onUnmounted(() => {
  292. const optionDoms = Array.from(document.querySelectorAll('.scada-select-dropdown-option'));
  293. optionDoms.forEach((opt) => {
  294. opt.removeEventListener('mouseover', opt.mouseoverFn);
  295. opt.removeEventListener('mouseleave', opt.mouseleaveFn);
  296. });
  297. document.body.removeEventListener('mousemove', moveHandler)
  298. })
  299. return {
  300. selects,
  301. dropdownStyle,
  302. selectOptionStyle,
  303. selectOption,
  304. defaultSelect,
  305. handleMove,
  306. }
  307. }
  308. }
  309. const Select = {
  310. template: \`<div :id="nodeId" class="custom-select-node" :style="cssOuter" @click="clickHandler">
  311. <div :style="cssInner">{{selects.label }}</div>
  312. <div style="position: absolute; top: 0; right: 0; bottom: 0; width: 25px;display: flex;align-items: center">
  313. <div v-if="showDropdown" :style=" triangleupStyle"></div>
  314. <div v-else="!showDropdown" :style="triangledownStyle"></div>
  315. </div>
  316. </div>\`,
  317. props: {
  318. selects: {
  319. type: Object,
  320. default: {
  321. label: '请选择',
  322. value: '-'
  323. }
  324. },
  325. showDropdown: {
  326. type: Boolean,
  327. default: false
  328. },
  329. nodeId: {
  330. type: String,
  331. default: ''
  332. },
  333. fontColor: {
  334. type: String,
  335. default: '#ffffff'
  336. },
  337. fontSize: {
  338. type: Number,
  339. default: 14
  340. },
  341. fontFamily: {
  342. type: String,
  343. default: '宋体'
  344. },
  345. fontStyle: {
  346. type: String,
  347. default: 'normal'
  348. },
  349. width: {
  350. type: Number,
  351. default: 60
  352. },
  353. height: {
  354. type: Number,
  355. default: 34
  356. },
  357. lineHeight: {
  358. type: Number,
  359. default: 34,
  360. },
  361. strokeWidth: {
  362. type: Number,
  363. default: 1,
  364. },
  365. borderColor: {
  366. type: String,
  367. default: '#1890ff'
  368. },
  369. triangleColor: {
  370. type: String,
  371. default: '#ffffff'
  372. },
  373. backgroundColor: {
  374. type: String,
  375. default: '#1890ff',
  376. },
  377. background: {
  378. type: String,
  379. default: 'none',
  380. },
  381. borderRadius: {
  382. type: Number,
  383. default: 2
  384. }
  385. },
  386. emits: ["showHideSelect"],
  387. setup(props, { emit }) {
  388. const { ref, toRefs, computed, watch, onMounted, onUnmounted } = Vue
  389. const { width, height, defaultValue } = toRefs(props)
  390. const realWidth = parseInt(width.value);
  391. const realHeight = parseInt(height.value);
  392. const cssOuter = computed(() => {
  393. const borderWidths = props.strokeWidth * 2;
  394. let back = props.background;
  395. if (back !== 'none' && !back.includes('url')) {
  396. back = \`url(\${back})\`
  397. }
  398. return \`
  399. position: relative;
  400. border-width: \${props.strokeWidth}px;
  401. border-style: solid;
  402. width: \${realWidth - borderWidths}px;
  403. height: \${realHeight - borderWidths}px;
  404. line-height: \${realHeight - borderWidths}px;
  405. border-radius: \${props.borderRadius}px;
  406. border-color:\${props.borderColor};
  407. background-color:\${props.backgroundColor};
  408. background-image: \${back};
  409. background-size: 100% 100%;\`
  410. })
  411. const cssInner = computed(() => {
  412. const fontStyle = props.fontStyle;
  413. const style = {}
  414. if (fontStyle) {
  415. if (fontStyle.includes('bold')) {
  416. style.fontWeight = 'bolder';
  417. }
  418. if (fontStyle.includes('italic')) {
  419. style.fontStyle = 'italic'
  420. }
  421. if (fontStyle.includes('underline,line-through')) {
  422. style.textDecoration = 'underline line-through'
  423. } else if (fontStyle.includes('line-through,underline')) {
  424. style.textDecoration = 'line-through underline'
  425. } else if (fontStyle.includes('underline')) {
  426. style.textDecoration = 'underline'
  427. } else if (fontStyle.includes('line-through')) {
  428. style.textDecoration = 'line-through'
  429. }
  430. }
  431. return \`
  432. width: 100%;
  433. height: 100%;
  434. color: \${props.fontColor};
  435. font-size: \${props.fontSize}px;
  436. text-align: left;
  437. padding: 0px 25px 0px 15px;
  438. box-sizing: border-box;
  439. font-family: \${props.fontFamily};
  440. font-style: \${style.fontStyle};
  441. font-weight: \${style.fontWeight};
  442. text-decoration: \${style.textDecoration};
  443. overflow: hidden;
  444. white-space: nowrap;
  445. text-overflow: ellipsis;
  446. \`;
  447. })
  448. const triangledownStyle = computed(() => {
  449. const h = props.height;
  450. return \`
  451. width: 0;
  452. height: 0;
  453. border-left: \${(h / 3) / 2}px solid transparent;
  454. border-right: \${(h / 3) / 2}px solid transparent;
  455. border-top: \${h / 3}px solid \${props.triangleColor};
  456. \`
  457. })
  458. const triangleupStyle = computed(() => {
  459. const h = props.height;
  460. return \`
  461. width: 0;
  462. height: 0;
  463. border-left: \${(h / 3) / 2}px solid transparent;
  464. border-right: \${(h / 3) / 2}px solid transparent;
  465. border-bottom: \${h / 3}px solid \${props.triangleColor};
  466. \`
  467. })
  468. const clickHandler = (visible) => {
  469. const dropdowns = Array.from(document.querySelectorAll('.scada-select-dropdown'));
  470. dropdowns.forEach((drop) => {
  471. drop.remove()
  472. });
  473. const selectNode = document.getElementById(props.nodeId);
  474. if (selectNode) {
  475. const { left, top, width, height } = selectNode.getBoundingClientRect();
  476. emit('showHideSelect', {
  477. visible,
  478. left,
  479. top,
  480. width,
  481. height,
  482. })
  483. }
  484. }
  485. const listenerDocClick = function (e) {
  486. // 点击空白处消失下拉框
  487. const clickOnDropdown = e.target.closest('.scada-select-dropdown')
  488. const selectNode = e.target.closest(".custom-select-node")
  489. if (!clickOnDropdown && !selectNode) {
  490. clickHandler(false)
  491. }
  492. }
  493. onMounted(() => {
  494. document.addEventListener('click', listenerDocClick, true)
  495. })
  496. onUnmounted(() => {
  497. document.removeEventListener('click', listenerDocClick, true)
  498. })
  499. return {
  500. cssOuter,
  501. cssInner,
  502. clickHandler,
  503. triangledownStyle,
  504. triangleupStyle,
  505. }
  506. }
  507. }
  508. class CustomSelectNode extends HtmlResize.view {
  509. clickTime = ''
  510. oldProperties = '{}'
  511. setHtml(rootEl) {
  512. const { graphModel } = this.props;
  513. const { properties, width, height, } = this.props.model;
  514. const { fontColor, fontSize, fontFamily, fontStyle, strokeWidth, lineHeight, fill, strokeColor,
  515. dropdownFill, dropdownStrokeColor, dropdownFontColor, triangleColor, background, placeholder, borderRadius, dropdownStrokeWidth } = properties;
  516. const { normalData } = properties.dynamic || {};
  517. const { model } = this.props;
  518. const el = document.createElement('div');
  519. rootEl.innerHTML = '';
  520. let dropdownInst = null;
  521. let instance = null;
  522. let show = false;
  523. const dropdowns = Array.from(document.querySelectorAll('.scada-select-dropdown'));
  524. dropdowns.forEach((drop) => {
  525. drop.remove()
  526. });
  527. const selectedHandler = (selects) => {
  528. if (instance) {
  529. instance.component.props.selects = selects;
  530. if (dropdownInst) {
  531. show = false;
  532. instance.component.props.showDropdown = false;
  533. if (dropdownInst) {
  534. dropdownInst.component.props.showDropdown = false;
  535. }
  536. const selectNode = document.getElementById(\`select-\${properties.id}\`);
  537. if (selectNode) {
  538. document.body.removeChild(selectNode)
  539. }
  540. }
  541. graphModel.eventCenter.emit("node:change", {
  542. data: model,
  543. e: selects,
  544. });
  545. }
  546. }
  547. const showHideHandler = ({ visible, left, top, width, height }) => {
  548. if (visible !== undefined && visible === false) {
  549. show = visible;
  550. instance.component.props.showDropdown = false;
  551. if (dropdownInst) {
  552. dropdownInst.component.props.showDropdown = false;
  553. }
  554. return;
  555. }
  556. if (!show) {
  557. show = true;
  558. instance.component.props.showDropdown = true;
  559. const dropdownEl = document.createElement('div');
  560. dropdownEl.setAttribute('id', \`select-\${properties.id}\`)
  561. dropdownEl.setAttribute('style', \`position: fixed; left: \${left}px; top: \${top + height - 2}px; z-index: 8888\`);
  562. let opts = [];
  563. if (normalData && normalData.defaultOptions) {
  564. if (typeof normalData.defaultOptions !== 'string') {
  565. opts = normalData.defaultOptions
  566. } else {
  567. opts = JSON.parse(normalData.defaultOptions);
  568. }
  569. }
  570. dropdownInst = createVNode(Options, {
  571. showDropdown: true,
  572. id: \`dropdown-\${properties.id}\`,
  573. fontColor: dropdownFontColor,
  574. fontSize, fontFamily, fontStyle, width, height, lineHeight,
  575. backgroundColor: dropdownFill,
  576. borderColor: dropdownStrokeColor,
  577. hoverFontColor: properties.dropdownHoverFontColor,
  578. hoverFillColor: properties.dropdownHoverFill,
  579. strokeWidth: dropdownStrokeWidth,
  580. options: opts,
  581. selects: instance.component.props.selects,
  582. onSelected: selectedHandler
  583. })
  584. dropdownInst.appContext = app._context
  585. render(dropdownInst, dropdownEl)
  586. document.body.appendChild(dropdownEl);
  587. } else {
  588. show = false;
  589. instance.component.props.showDropdown = false;
  590. if (dropdownInst) {
  591. dropdownInst.component.props.showDropdown = false;
  592. }
  593. const selectNode = document.getElementById(\`select-\${properties.id}\`);
  594. if (selectNode) {
  595. document.body.removeChild(selectNode)
  596. }
  597. }
  598. }
  599. instance = createVNode(Select, {
  600. selects: properties.event || {
  601. label: placeholder,
  602. value: '-'
  603. },
  604. showDropdown: show,
  605. nodeId: \`select-input-\${properties.id}\`,
  606. fontColor,
  607. fontSize, fontFamily, fontStyle, width, height, lineHeight,
  608. backgroundColor: fill,
  609. borderColor: strokeColor,
  610. triangleColor,
  611. strokeWidth,
  612. defaultValue: '',
  613. background,
  614. borderRadius,
  615. onShowHideSelect: showHideHandler
  616. })
  617. instance.appContext = app._context
  618. render(instance, el)
  619. rootEl.appendChild(el);
  620. }
  621. sameProps(properties) {
  622. const isSame = window._.isEqual(JSON.parse(this.oldProperties), properties);
  623. if (isSame) return true;
  624. this.oldProperties = JSON.stringify(properties);
  625. return false
  626. }
  627. shouldUpdate() {
  628. const { properties } = this.props.model;
  629. const propertiesBack = window._.cloneDeep(properties);
  630. if (this.sameProps(propertiesBack)) {
  631. return false
  632. }
  633. return true;
  634. }
  635. componentDidMount() {
  636. if (this.shouldUpdate) {
  637. this.setHtml(this.rootEl);
  638. }
  639. const { properties } = this.props.model;
  640. const { graphModel, model } = this.props;
  641. if (properties.event) {
  642. setTimeout(() => {
  643. graphModel.eventCenter.emit("node:change", {
  644. data: model,
  645. e: properties.event,
  646. });
  647. }, 1000)
  648. }
  649. }
  650. componentWillUnmount() {
  651. const dropdowns = Array.from(document.querySelectorAll('.scada-select-dropdown'));
  652. dropdowns.forEach((drop) => {
  653. drop.remove()
  654. });
  655. }
  656. }
  657. class CustomSelectModel extends HtmlResize.model {
  658. initNodeData(data) {
  659. // 自定义组件,需最开始重置一下text 。
  660. data.text = {
  661. value: "",
  662. x: data.x,
  663. y: data.y,
  664. };
  665. super.initNodeData(data);
  666. const { properties } = this;
  667. this.width = properties.width || 100;
  668. this.height = properties.height || 35;
  669. this.text.editable = false; // 不允许文本被编辑
  670. }
  671. setAttributes() {
  672. // 自定义组件需重置 text
  673. const { x, y, properties } = this;
  674. const { textHorizontalMove = 0, textVerticalMove = 0 } = properties;
  675. this.text = {
  676. ...this.text,
  677. x: x + textHorizontalMove,
  678. y: y + textVerticalMove,
  679. value: "",
  680. }
  681. }
  682. }
  683. lf.register({
  684. type: 'custom-select-node',
  685. view: CustomSelectNode,
  686. model: CustomSelectModel,
  687. })
  688. `,css:`.scada-select-dropdown::-webkit-scrollbar {/*滚动条整体样式*/\r
  689. width: 0px; /*高宽分别对应横竖滚动条的尺寸*/\r
  690. height: 0px;\r
  691. }\r
  692. .scada-select-dropdown::-webkit-scrollbar-thumb {/*滚动条里面小方块*/\r
  693. border-radius: 0px;\r
  694. background: transparent;\r
  695. }\r
  696. .scada-select-dropdown::-webkit-scrollbar-track {/*滚动条里面轨道*/\r
  697. box-shadow: inset 0 0 1px transparent;\r
  698. border-radius: 1px;\r
  699. background: transparent;\r
  700. }\r
  701. .scada-select-dropdown-tooltip {\r
  702. position: absolute;\r
  703. display: inline-block;\r
  704. background-color: rgba(0,0,0,0.65);\r
  705. color: #ffffff;\r
  706. font-size: 12px;\r
  707. padding: 5px 5px;\r
  708. max-width: 120px;\r
  709. max-height: 120px;\r
  710. overflow-y: auto;\r
  711. z-index: 8888;\r
  712. transition: all 0.2s;\r
  713. }`,fakeData:""},u={id:e,name:n,aliasName:t,image:o,imageType:l,groupName:a,groupType:s,isRemote:!1,isDefault:!0,sectionType:i,config:r,files:d};export{t as aliasName,r as config,u as default,d as files,a as groupName,s as groupType,e as id,o as image,l as imageType,c as isDefault,p as isRemote,n as name,i as sectionType};