|
|
const e="1d5204cb-27ec-4857-a7e9-1b258c6884eb",a="custom-input-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="1693910898822" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4004" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M122.368 165.888h778.24c-9.216 0-16.384-7.168-16.384-16.384v713.728c0-9.216 7.168-16.384 16.384-16.384h-778.24c9.216 0 16.384 7.168 16.384 16.384V150.016c0 8.192-6.656 15.872-16.384 15.872z m-32.768 684.544c0 26.112 20.992 47.104 47.104 47.104h750.08c26.112 0 47.104-20.992 47.104-47.104V162.304c0-26.112-20.992-47.104-47.104-47.104H136.704c-26.112 0-47.104 20.992-47.104 47.104v688.128z" p-id="4005" fill="#707070"></path><path d="M360.96 398.336h113.152v265.216h-37.888v37.888h151.552v-37.888h-37.888V398.336h113.152v38.4h38.4V322.56H322.56v114.176h38.4z" p-id="4006" fill="#707070"></path></svg>',l="svg",i="基础",o="常用",r=!1,u=!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 ","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,"inputClassName":"w-full","labelClassName":"w-8"}],"id":"u:9672575193ac","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","md":6},{"body":[{"type":"input-number","label":"透明","name":"opacity","id":"u:cf80f59d8d42","placeholder":"组件透明度","mode":"horizontal","size":"full","className":"m-b","keyboard":true,"step":0,"suffix":"","value":1,"inputClassName":"w-full","precision":2}],"id":"u:51ddf54ac749","md":6}],"gap":""},{"type":"grid","columns":[{"body":[{"type":"input-text","label":"内容","name":"content","id":"u:bea5a408f98f","mode":"horizontal","size":"full","inputControlClassName":"inputControlClassName-bea5a408f98f"}],"id":"u:afc37bde0156
"nodes": [ { "id": "0d0735ba-75d5-484d-8069-e6b8570a5135", "type": "custom-input-node", "x": 200, "y": 200, "text": { "value": "0.00", "x": 200, "y": 200 }, "properties": { "id": "0d0735ba-75d5-484d-8069-e6b8570a5135", "width": 200, "height": 20, "x": 200, "y": 200, "rotation": 0, "opacity": 1, "contentColor": "rgba(245, 166, 35, 1)", "showUnit": false, "fontSize": 12, "showDefaultValue": false, "valueColor": "rgba(245, 166, 35, 1)", "nodeAlias": "文本输入", "content": "0.00", "fontColor": "rgba(245, 166, 35, 1)", "fontFamily": "Microsoft Yahei", "dynamic": { "normalData": { "dataPoint": "", "compareType": "", "conditionVariables": [], "defaultValue": "", "unit": "" }, "eventsData": { "eventCombo": [ { "eventType": "change", "enable": false, "config": "{\\"globalInputParamsCalculated\\":[],\\"device\\":\\"\\",\\"command\\":\\"\\",\\"eventAction\\":\\"sendCommand\\",\\"dataPointParamsCalculate\\":\\"return [\\\\n {\\\\n key: \\\\\\"\\\\\\",\\\\n value: ''\\\\n }\\\\n]\\",\\"sendCommandMethod\\":\\"config\\",\\"inputParamsCalculate\\":\\"// console.log('deviceInfo', deviceInfo, 'command', command, 'event', event);\\\\n// 入参提示: deviceInfo -- 设备信息,command -- 指令信息, event -- 事件传参(当前部件所绑定的立即值,或当前部件经过计算后的自定义值), 入参计算。。。然后返回出参\\\\nconst condition = {\\\\n deviceName: deviceInfo.code,\\\\n attrCode: command.controlDeviceAttr,\\\\n value: event\\\\n}\\\\nreturn {\\\\n \\\\\\"condition\\\\\\": JSON.stringify(condition),\\\\n \\\\\\"controlId\\\\\\": command.id\\\\n}\\",\\"requestMethod\\":\\"post\\",\\"requestUrl\\":\\"/thing/device/control/control\\"}",
"users": "" } ] }, "uiData": { "dataPoint": "", "compareType": "", "conditionVariables": [ { "type": "boolean", "label": "真假", "name": "" } ] }, "animationData": { "animationCombo": [ { "dataPoint": "", "min": "", "max": "", "animationName": "旋转", "animationTime": 3 } ] }, "hiddenData": { "hiddenCombo": [ { "dataPoint": "", "min": "", "max": "", "showOrHiddenName": "隐藏" } ] } } } } ]}`,javascript:`// 文本节点
class CustomInputNode extends TextNode {}class CustomInputModel extends TextNodeModel { realValue = '' clearText = ''
initNodeData(data) { // 自定义组件,需最开始重置一下text 。
data.text = { value: "", x: data.x, y: data.y, }; super.initNodeData(data); this.editable = true; const txtUpdateHandler = (e) => { const { eventsData } = this.properties.dynamic || {}; const findChange = eventsData?.eventCombo.find( i => i.eventType === 'change'); const cacheToken = sessionStorage.getItem('v1@CacheToken'); if(!cacheToken) { return window.createLoginDialog(); } const tokenParsed = JSON.parse(cacheToken || '{}'); if (findChange.users && !findChange.users.includes(tokenParsed.userid)) { return messageFn('无用户权限') } if (e.id === this.properties.id) { if(e.value) { this.graphModel.eventCenter.emit('node:change', { data: this, e: e.value}); this.graphModel.textEditElement.setElementState(1); } } } this.graphModel.eventCenter.on("text:edited", txtUpdateHandler); }
getOutlineStyle() { const style = super.getOutlineStyle(); const { id, fontSize } = this.properties; const textEditElement = this.graphModel.textEditElement; if(textEditElement && textEditElement.id === id) { style.stroke = "transparent"; style.hover.stroke = 'transparent'; } else { style.stroke = "#00ffff"; style.hover.stroke = '#00ffff'; } const txtDom = document.getElementById(this.id); if(txtDom) { const txtNode = txtDom.querySelector('text'); if (txtNode) { const { width, height, x, y } = txtNode.getBBox(); style.width = width; style.height = height; style.x = x + width / 2 - this.width/2; style.y = y + height / 2; } } return style; }
getTextStyle() { const style = super.getTextStyle(); const { properties, text } = this;
style.color = properties.fontColor || style.color; const { uiData } = properties.dynamic || {}; if (uiData) { const realValue = window.resolveScadaNewValue(uiData.defaultValue) if (realValue !== '') { uiData.conditionVariables.forEach((item) => { if (item.type === 'rangeColor') { let from = item.from; let to = item.to; if (item.from >= item.to) { from = item.to; to = item.from; } if (item.color && Number(realValue) >= from && Number(realValue) <= to) { style.color = item.color } } else if (item.type === 'equal') { if(Number(realValue) === Number(item.value)) { style.color = item.color } } else if (item.type === 'boolean') { const trueFlags = ['true', true] const falseFlags = ['false', false] const truetrue = trueFlags.includes(item.value) && trueFlags.includes(realValue) const falsefalse = falseFlags.includes(item.value) && falseFlags.includes(realValue) if (truetrue || falsefalse) { style.color = item.color } } }) } }
style.fontSize = properties.fontSize || style.fontSize; style.fontFamily = properties.fontFamily || style.fontFamily; style.opacity = properties.opacity || 1; style.letterSpacing = properties.fontSpace || 0; const fontStyle = properties.fontStyle; if(fontStyle) { if (fontStyle.includes('bold')) { style.fontWeight = 'bolder'; } if(fontStyle.includes('italic')) { style.fontStyle = 'italic' } if (fontStyle.includes('underline,line-through')) { style.textDecoration = 'underline line-through' } else if (fontStyle.includes('line-through,underline')) { style.textDecoration = 'line-through underline' } else if (fontStyle.includes('underline')) { style.textDecoration = 'underline' } else if (fontStyle.includes('line-through')) { style.textDecoration = 'line-through' } } return style; }
setAttributes() { const { id, x, y, properties, text, width, height } = this; const { graphModel: { textEditElement } } = this; let textValue = properties.content || ''; if (textValue === id) return;
const { normalData, uiData } = properties.dynamic || {};
if (normalData) { const normalValue = window.resolveScadaNewValue(normalData.defaultValue) if (normalValue) { this.realValue = normalValue; if (!textEditElement) { textValue = normalValue } else { if(textEditElement.id === id) { return; } } } } if (uiData) { const realValue = window.resolveScadaNewValue(uiData.defaultValue) if (realValue !== '') { uiData.conditionVariables.forEach((item) => { if (item.type === 'equal') { if(Number(realValue) === Number(item.value)) { textValue = item.valueLabel; } } else if (item.type === 'boolean') { const trueFlags = ['true', true] const falseFlags = ['false', false] const truetrue = trueFlags.includes(item.value) && trueFlags.includes(realValue) const falsefalse = falseFlags.includes(item.value) && falseFlags.includes(realValue) if (truetrue || falsefalse) { textValue = item.valueLabel; } } }) } }
this.text = { ...this.text, x, y, value: textValue, } }}
lf.register({ type: 'custom-input-node', view: CustomInputNode, model: CustomInputModel})`,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};
|