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.
377 lines
50 KiB
377 lines
50 KiB
const e="6a4f3583-cfab-4569-8739-e33302568b48",a="custom-button-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="1688107204717" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9101" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M883.3 745H142.7c-41.9 0-76-34.1-76-76V351.6c0-41.9 34.1-76 76-76h740.6c41.9 0 76 34.1 76 76V669c0 41.9-34.1 76-76 76zM142.7 321.8c-16.4 0-29.8 13.3-29.8 29.8V669c0 16.4 13.3 29.8 29.8 29.8h740.6c16.4 0 29.8-13.3 29.8-29.8V351.6c0-16.4-13.3-29.8-29.8-29.8H142.7z" fill="#707070" p-id="9102"></path><path d="M191.3 576c-10.1 0-13.9 0.1-19.6 0.4 0.8-5.7 1.1-10.2 1.1-19.4v-72.4c0-7-0.3-12.7-1.1-19 6.7 0.4 8.6 0.4 19.4 0.4h34.7c21.4 0 34 10.3 34 27.8 0 8.1-2.6 14.4-7.7 18.9-2.9 2.5-5.3 3.8-10.7 5.8 6.5 1.5 9.9 3 13.8 6.4 5.7 5 8.6 12.2 8.6 20.9 0 19-13.5 30.3-36.5 30.3h-36z m30.6-67.6c7 0 11.4-4.1 11.4-10.6s-4.1-10.2-11.6-10.2h-23v20.8h23.2z m-23.2 45.8H223c8.3 0 13.4-4.6 13.4-12.4 0-7.7-5-12.2-13.5-12.2h-24.2v24.6zM384.9 465.9c-0.8 5.7-1.1 10.4-1.1 20v45.5c0 30.2-18.1 47.2-50 47.2-16.4 0-29.8-4.6-37.7-13-7.7-8.2-11.6-19.7-11.6-34.5v-45.2c0-9.1-0.3-14.9-1.1-20H312c-0.8 4.9-1.1 10.2-1.1 20v45.5c0 16.7 7.5 24.6 23 24.6 15.9 0 23.4-7.9 23.4-24.6v-45.5c0-9.9-0.3-14-1.1-20h28.7zM464.1 556c0 7.9 0.3 13.8 1.1 20H436c0.8-6.2 1.1-11.6 1.1-20v-66.7h-15.6c-8.3 0-10.6 0.1-20 0.9V465c4.4 0.5 11.6 0.9 19.7 0.9H479c9.3 0 14.5-0.3 20.6-0.9v25.3c-6-0.7-11.1-0.9-20.6-0.9h-14.9V556zM572.9 556c0 7.9 0.3 13.8 1.1 20h-29.2c0.8-6.2 1.1-11.6 1.1-20v-66.7h-15.6c-8.3 0-10.6 0.1-20 0.9V465c4.4 0.5 11.6 0.9 19.7 0.9h57.9c9.3 0 14.5-0.3 20.6-0.9v25.3c-6-0.7-11.1-0.9-20.6-0.9H573V556zM728.7 520.4c0 34.9-21.3 58.1-53.4 58.1-32.4 0-53.3-22.6-53.3-57.7 0-34.9 20.9-57.3 53.4-57.3 32.6 0 53.3 22.3 53.3 56.9z m-27.5 0.3c0-21.4-9.8-34.4-25.8-34.4-16.1 0-26.1 13.1-26.1 34.4 0 21.6 9.9 34.9 26.1 34.9 16 0 25.8-13.2 25.8-34.9zM811.8 520c3.8 5.7 6.3 9.9 9.5 15.7-0.5-6.1-0.8-12.2-0.8-19.6V486c0-8.7-0.3-14-1.1-20.1h28.2c-0.8 6-1.1 11.5-1.1 20.1v70.2c0 8.1 0.4 14.2 1.1 19.7h-29c-2.4-5-5.4-9.9-9.9-16.8l-24.5-36.9c-3.6-5.3-5.8-9.3-9.5-16.3 0.7 6 0.9 13.2 0.9 19.7v29.6c0 9.1 0.3 14.9 1.1 20.6h-28.2c0.8-5.2 1.1-11 1.1-20.8v-69.6c0-7.7-0.3-13.6-1.1-19.7h28.7c1.3 3.6 4.2 8.9 9.4 16.5l25.2 37.8z" fill="#707070" p-id="9103"></path></svg>',l="svg",o="基础",i="常用",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: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","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-color","label":"填充","name":"fill","id":"u:0d19ed3e2bdc","placeholder":"","mode":"horizontal","size":"full","className":"m-b","format":"rgba","inputClassName":"w-full"}],"id":"u:facc5c90e990","md":6},{"body":[{"type":"input-color","label":"描边","name":"strokeColor","id":"u:89afff5fd00d","placeholder":"","mode":"horizontal","size":"full","className":"m-b","format":"rgba","inputClassName":"w-full"}],"id":"u:7c903d9d40ab","md":6}],"id":"u:457970dd35bf","className":"m-b"},{"type":"grid","columns":[{"body":[{"type":"input-number","label":"边宽","name":"strokeWidth","id":"u:8dcf62d3dab5","placeholder":"描边宽度","mode":"horizontal","size":"full","className":"m-b","keyboard":true,"step":1,"value":1,"suffix":"px","inputClassName":"w-full"}],"id":"u:d701217b85ef","md":6},{"body":[{"type":"input-text","label":"内容","name":"content","id":"u:bea5a408f98f","mode":"horizontal","size":"full","inputControlClassName":"inputControlClassName-bea5a408f98f"}],"id":"u:afc37bde0156","md":6}],"id":"u:235f153e5ad5","className":"m-b"},{"type":"input-number","label":"边框圆角","name":"borderRadius","keyboard":true,"id":"u:eaf3965368f9","step":1,"mode":"horizontal","inputClassName":"w-full","suffix":"px"},{"type":"input-text","label":"背景","name":"background","id":"u:b1bba6906785","editorState":"default","mode":"horizontal"},{"type":"select","label":"背景尺寸","name":"backgroundSize","options":[{"label":"覆盖","value":"cover"},{"label":"包含","value":"contain"},{"label":"宽高撑满","value":"100% 100%"}],"id":"u:29aebfca7bf3","multiple":false,"mode":"horizontal","inputClassName":"w-full"},{"type":"input-text","label":"按钮阴影","name":"boxShadow","id":"u:3f5b1a8f5cc4","editorState":"default","mode":"horizontal"},{"type":"fieldset","id":"u:2a93d8eee7a9","className":"","title":"字体","collapsable":true,"body":[{"type":"container","id":"u:1606d0ad8360","body":[{"type":"select","id":"u:6f3470628b86","label":"字体类型","name":"fontFamily","mode":"horizontal","horizontal":{"leftFixed":"sm"},"size":"lg","options":[{},{"label":"宋体","value":"SimSun"},{"label":"微软雅黑","value":"Microsoft Yahei"},{"label":"苹方","value":"PingFang SC"},{"label":"Andale Mono","value":"andale mono,monospace"},{"label":"Arial","value":"arial,helvetica,sans-serif"},{"label":"Arial Black","value":"arial black,sans-serif"},{"label":"Book Antiqua","value":"book antiqua,palatino,serif"},{"label":"Comic Sans MS","value":"comic sans ms,sans-serif"},{"label":"Courier New","value":"courier new,courier,monospace"},{"label":"Georgia","value":"georgia,palatino,serif"},{"label":"Helvetica Neue","value":"Helvetica Neue"},{"label":"Helvetica","value":"helvetica,arial,sans-serif"},{"label":"Impact","value":"impact,sans-serif"},{"label":"Symbol","value":"symbol"},{"label":"Tahoma","value":"tahoma,arial,helvetica,sans-serif"},{"label":"Terminal","value":"terminal,monaco,monospace"},{"label":"Times New Roman","value":"times new roman,times,serif"},{"label":"Trebuchet MS","value":"trebuchet ms,geneva,sans-serif"},{"label":"Verdana","value":"verdana,geneva,sans-serif"}],"multiple":false,"className":"m-b","menuTpl":"<span style=font-family:\${value}>\${label}</span>","inputClassName":""},{"type":"input-color","label":"字体","name":"fontColor","id":"u:f398c821eda1","mode":"horizontal","size":"lg","className":"m-b","format":"rgba","placeholder":"字体颜色","horizontal":{"leftFixed":"sm"},"inputClassName":""},{"type":"input-number","id":"u:0063eed6ed66","label":"字体大小","name":"fontSize","min":12,"step":1,"mode":"horizontal","horizontal":{"leftFixed":"sm"},"className":"m-b","keyboard":true,"displayMode":"enhance","value":12,"max":100},{"type":"checkboxes","id":"u:b34f4c274416","className":"custom-checkbox-style m-b","label":"文字样式","name":"fontStyle","options":[{"label":"fa-bold fa","value":"bold"},{"label":"fa-italic fa","value":"italic"},{"label":"fa-underline fa","value":"underline"},{"label":"fa fa-strikethrough","value":"line-through"}],"checkAll":false,"joinValues":true,"mode":"horizontal","horizontal":{"leftFixed":"sm"},"optionType":"button","menuTpl":"<span class='text-lg \${label}'></span>","inputClassName":"","multiple":true},{"type":"checkboxes","label":"文字位置","name":"fontAlign","multiple":false,"options":[{"label":"fa fa-align-left","value":"left"},{"label":"fa fa-align-center","value":"center"},{"label":"fa fa-align-right","value":"right"},{"label":"fa fa-align-justify","value":"justify"}],"id":"u:7e80e906ea14","checkAll":false,"joinValues":true,"mode":"horizontal","horizontal":{"leftFixed":"sm"},"optionType":"button","menuTpl":"<span class='text-lg \${label}'></span>","inputClassName":"","className":"custom-checkbox-style m-b"},{"type":"input-number","label":"文字行高","name":"lineHeight","keyboard":true,"id":"u:0063eed6ed66","step":1,"mode":"horizontal","horizontal":{"leftFixed":"sm"},"displayMode":"enhance","className":"m-b"}],"style":{"position":"static","display":"block"},"wrapperBody":false}],"bodyClassName":"m-b"}],"id":"u:a5ebe5f02407","submitText":"","onEvent":{"change":{"weight":0,"actions":[]}},"debug":false,"mode":"normal","panelClassName":"p","labelAlign":"left","className":"","wrapWithPanel":true}],"id":"u:c309ae58472c","className":"p-none no-border"},{"title":"交互","icon":"fa fa-calendar-minus-o","body":[{"type":"service","body":[{"type":"collapse","key":"2","header":"数据/外观","body":[{"type":"service","id":"u:6cb6d200ede2","data":{"dataPoint":"","compareType":"","conditionVariables":[]},"body":[{"type":"input-text","label":"数据点","name":"dataPoint","id":"uiDataPoint","multiple":false,"mode":"horizontal","size":"full","onEvent":{"focus":{"weight":0,"actions":[{"actionType":"dialog","dialog":{"type":"dialog","title":"请配置需要绑定的数据点","body":[{"type":"tabs","tabs":[{"title":"常规数据点","body":[{"type":"form","title":"","body":[{"type":"select","label":"数据源","name":"dataSource","id":"u:c273f087b8ed","multiple":false,"mode":"horizontal","size":"md","source":"\${apiDtoList || thingApiDTOList}","labelField":"name","valueField":"id","onEvent":{"change":{"actions":[{"actionType":"reload","componentId":"u:1cdb908c23a8"},{"actionType":"custom","script":"if (!event.data.value) { doAction({'actionType': 'setValue', 'componentId': 'u:1cdb908c23a8', 'args': {'value': ''} });\\r\\n doAction({'actionType': 'setValue', 'componentId': 'u:8147daea685d', 'args': {'value': ''} }); }"}]}},"clearable":true,"horizontal":{"leftFixed":"sm"},"actionType":"change","target":"u:1cdb908c23a8"},{"type":"combo","label":"设备属性","name":"deviceAttrs","id":"u:98559a2dd514","multiple":false,"mode":"horizontal","size":"full","horizontal":{"leftFixed":"sm"},"items":[{"type":"input-table","label":false,"id":"u:41dfc35c368c","name":"table","strictMode":false,"needConfirm":false,"addable":true,"removable":true,"columns":[{"type":"input-text","label":"序号","id":"u:434e22030bc6","name":"num","size":"sm","mode":"horizontal","quickEdit":{"mode":"popOver","id":"u:c6a294f5c93a"},"horizontal":{"left":2,"right":10},"placeholder":"例:A/B/C/AA/BB","width":200},{"type":"select","name":"devices","id":"u:1cdb908c23a8","label":"设备","multiple":false,"mode":"horizontal","quickEdit":true,"size":"sm","source":{"url":"/thing/v2/api/telemetryById?id=\${dataSource}","method":"get","messages":{},"headers":{"token":"\${myToken}","tenantCode":"\${myTenantCode}","companyId":"\${myCompanyId}"},"adaptor":"if (payload && payload.data && payload.data.result) {console.log('payload.data.result', payload.data.result); \\r\\n const list = []\\r\\n const devices = payload.data.result.info \\r\\n for (const key in devices) {\\r\\n const device_info = devices[key] \\r\\n list.push({\\r\\n label: device_info.entityName,\\r\\n value: device_info.entityId,\\r\\n deviceCode: device_info.entityCode,\\r\\n deviceInfo: device_info,\\r\\n attrs: device_info.attrs })\\r\\n }\\r\\n payload.data = list;\\r\\n return payload\\r\\n}","sendOn":"this.dataSource"},"onEvent":{"change":{"actions":[{"actionType":"custom","script":"if (!event.data.value) { doAction({'actionType': 'setValue', 'componentId': 'u:8147daea685d', 'args': {'value': ''} }); }"}]}},"responseData":{"&":"$$","list":"\${items}"},"clearable":true,"horizontal":{"left":2,"right":10},"checkAll":false},{"type":"select","name":"dataPoint","id":"u:8147daea685d","label":"数据点","multiple":false,"quickEdit":true,"mode":"horizontal","size":"sm","source":{"url":"/thing/v2/api/callDict?id=\${dataSource}&entityId=\${devices}","method":"get","messages":{},"headers":{"token":"\${myToken}","tenantCode":"\${myTenantCode}","companyId":"\${myCompanyId}"},"sendOn":"this.dataSource && this.devices","adaptor":"const list = payload.data.map(item => {\\r\\n item.dictName = item.dictName + ' - ' + item.dictCode\\r\\n return item\\r\\n})\\r\\npayload.data = list;\\r\\nreturn payload"},"labelField":"dictName","valueField":"dictCode","checkAll":false,"horizontal":{"left":2,"right":10},"overlay":{"width":"350px"},"searchable":true}]}],"strictMode":true,"syncFields":[],"tabsMode":false,"canAccessSuperData":true,"inputClassName":"w-full","className":"m-b-sm"},{"type":"checkbox","label":"数据处理","name":"enableDataHandle","id":"u:034ca60f2135","mode":"horizontal","horizontal":{"leftFixed":"normal"},"option":""},{"type":"combo","id":"u:a06125153fa6","name":"calcRules","label":"计算规则","mode":"horizontal","visibleOn":"this.enableDataHandle","multiple":true,"items":[{"name":"formular","label":"计算公式","type":"input-text","id":"u:318a7f0c6449","placeholder":"例: (A + B) / C","width":"50%","size":"full"},{"name":"resultAttr","label":"计算结果属性","type":"input-text","id":"u:1e6e491ccbaa","placeholder":"例:A8、B、C...","width":"50%"}],"strictMode":true,"syncFields":[],"hidden":false,"inputClassName":"w-full","multiLine":false,"className":"calcRules"},{"type":"input-text","label":"唯一数据点","name":"uniquePoint","id":"u:3b257b599c19","mode":"horizontal","visibleOn":"this.enableDataHandle","labelRemark":{"icon":"fa fa-question-circle","trigger":["hover"],"className":"Remark--warning","placement":"top","title":"场景:","content":"当有数据处理,并且只需绑定一个数据点作为 【实时/立即/最新数据】时,请填写所需数据点的序号或计算结果属性。"},"inputControlClassName":"m-b"}],"id":"u:51f0e51abd7c","data":{"attrs":[],"deviceCode":"\${deviceCode || ''}","devices":"\${devices || ''}","dataPoint":"\${dataPoint || ''}","dataSource":"\${dataSource || ''}","deviceAttrs":"\${deviceAttrs || []}"},"submitText":"","onEvent":{"inited":{"actions":{"actionType":"custom","script":"if(event.data.devices && event.data.dataPoint && event.data.deviceAttrs.length === 0) { const dataPoints = event.data.dataPoint.split(','); const newDeviceAttrs = dataPoints.map((point, idx) => ({ num: String.fromCharCode(65+idx), devices: event.data.devices, dataPoint: point }) ); doAction({ 'actionType': 'setValue', 'componentId': 'u:51f0e51abd7c', 'args': { value: {deviceAttrs: { table: newDeviceAttrs } }} }); }"}}}}],"id":"u:5505e7ef7cab"},{"title":"虚拟变量","body":[{"type":"tpl","tpl":"暂时无虚拟变量可配置","wrapperComponent":"","inline":false,"id":"u:722592249b31"}],"id":"u:b739cc6a6ed7"}],"id":"u:3b446450d643"}],"showCloseButton":true,"showErrorMsg":true,"showLoading":true,"id":"u:f46c2439c983","data":{"&":"\${dataPoint | toJson}","apiDtoList":"\${thingApiDTOList}","myToken":"\${myToken}","myTenantCode":"\${myTenantCode}","myCompanyId":"\${myCompanyId}"},"onEvent":{"confirm":{"actions":[{"actionType":"custom","script":"const tableData = event.data.deviceAttrs.table; let devices = ''; let dataPoint = ''; if(tableData) { tableData.forEach(item => { devices += (item.devices + ',');dataPoint += (item.dataPoint + ','); });}; if(tableData && tableData.length > 0) { devices = devices.substring(0, devices.length - 1); dataPoint = dataPoint.substring(0, dataPoint.length - 1); const newValue = {...event.data, devices: devices, dataPoint: dataPoint, dataSource: event.data.dataSource} ; doAction({ 'componentId': 'uiDataPoint', 'actionType': 'setValue', 'args': { value: JSON.stringify(newValue) } }) } else {doAction({ 'componentId': 'uiDataPoint', 'actionType': 'setValue', 'args': { value: JSON.stringify(event.data) } }) };"}]}},"closeOnEsc":false,"size":"lg"}}]}},"className":"w-full m-b-sm","inputClassName":"w-full","clearable":true,"editorState":"default"},{"type":"combo","name":"conditionVariables","label":"","value":[{"type":"equal"}],"multiLine":false,"multiple":true,"typeSwitchable":false,"conditions":[{"label":"相等","test":"this.type === \\"equal\\"","scaffold":{"type":"equal","label":"相等","name":""},"items":[{"label":"标签","name":"valueLabel","type":"input-text","id":"u:6f9362ce0efb"},{"label":"数值","name":"value","type":"input-text","id":"u:32b3714b545b"},{"label":"字体","name":"fontColor","type":"input-color","id":"u:5148d38928d9","format":"rgba","inputClassName":"myColorPick","static":false,"placeholder":"选择颜色"},{"label":"背景色","name":"backColor","type":"input-color","id":"u:5148d38928d9","format":"rgba","inputClassName":"myColorPick","static":false,"placeholder":"选择颜色"},{"label":"背景图片","name":"background","type":"input-text","placeholder":"输入背景链接","id":"u:f5d9ca3df814"}]},{"label":"真假","test":"this.type === \\"boolean\\"","scaffold":{"type":"boolean","label":"真假","name":""},"items":[{"label":"标签","name":"valueLabel","type":"input-text","id":"u:6f9362ce0efb"},{"label":"真假","name":"value","type":"input-text","id":"u:32b3714b545b","placeholder":"true/false"},{"label":"字体","name":"fontColor","type":"input-color","id":"u:5148d38928d9","format":"rgba","inputClassName":"myColorPick","static":false,"placeholder":"选择颜色"},{"label":"背景色","name":"backColor","type":"input-color","id":"u:5148d38928d9","format":"rgba","inputClassName":"myColorPick","static":false,"placeholder":"选择颜色"},{"label":"背景图片","name":"background","type":"input-text","placeholder":"输入背景链接","id":"u:f5d9ca3df814"}]},{"label":"范围/颜色","test":"this.type === \\"rangeColor\\"","scaffold":{"type":"rangeColor","label":"范围/颜色","name":""},"items":[{"label":"起始","name":"from","type":"input-number","precision":2,"id":"u:6f9362ce0efb"},{"label":"结束","name":"to","type":"input-number","precision":2,"id":"u:32b3714b545b"},{"label":"字体","name":"fontColor","type":"input-color","id":"u:5148d38928d9","format":"rgba","inputClassName":"myColorPick","static":false,"placeholder":"选择颜色"},{"label":"背景色","name":"backColor","type":"input-color","id":"u:5148d38928d9","format":"rgba","inputClassName":"myColorPick","static":false,"placeholder":"选择颜色"},{"label":"背景图片","name":"background","type":"input-text","placeholder":"输入背景链接","id":"u:f5d9ca3df814"}]}],"id":"u:c92fdccb153e","deleteBtn":{"type":"icon","icon":"fa fa-trash","id":"u:4d4df8658829"}}],"name":"uiService","className":"p-none"}],"id":"u:7c5fc82d356f","headingClassName":"p-sm b-b b-light bg-white","className":"m-b r-3x","bodyClassName":"p-none"},{"type":"collapse","key":"2","header":"事件","body":[{"type":"service","id":"u:4ec2acc50405","body":[{"type":"combo","label":"","name":"eventCombo","multiple":true,"addable":true,"removable":true,"removableMode":"icon","addBtn":{"label":"新增","icon":"fa fa-plus","level":"primary","size":"sm","id":"u:ae1b0a0c0f55"},"items":[{"type":"select","name":"eventType","placeholder":"选择事件","options":[{"label":"单击","value":"click"},{"label":"双击","value":"dblClick"}],"id":"u:a7b44847011a","label":"名称"},{"type":"input-text","name":"config","placeholder":"事件配置","id":"u:d491386a95c2","onEvent":{"focus":{"actions":[{"actionType":"dialog","dialog":{"title":"设置事件","data":{"comboIndex":"\${index}","&":"\${config | toJson}","nodesList":"\${graphDataList}","apiDtoList":"\${thingApiDTOList}","myToken":"\${myToken}","myTenantCode":"\${myTenantCode}","myCompanyId":"\${myCompanyId}","evType":"\${eventType}"},"body":[{"type":"form","title":"表单","body":[{"type":"radios","label":"事件行为","name":"eventAction","options":[{"label":"打开链接","value":"openLink"},{"label":"打开弹窗","value":"openDialog"},{"label":"下发指令","value":"sendCommand"},{"label":"显示隐藏","value":"showHide"}],"mode":"horizontal","horizontal":{"leftFixed":"sm"},"id":"u:9e7f1220367f","value":"openLink"},{"type":"input-text","label":"链接地址","name":"linkAddress","mode":"horizontal","horizontal":{"leftFixed":"sm"},"inputClassName":"w-full","id":"u:c5bda965ed3c","size":"full","visibleOn":"data.eventAction === 'openLink'"},{"type":"combo","label":"参数","name":"dataPointTable","id":"dataPointTable","addable":true,"strictMode":true,"removable":true,"horizontal":{"leftFixed":"sm"},"multiple":true,"removableMode":"icon","addBtn":{"label":"新增","icon":"fa fa-plus","level":"primary","size":"sm","id":"u:bf2f6c98dbff"},"items":[{"type":"input-text","name":"dataPoint","id":"u:1eb050ec98d3","label":"","multiple":false,"size":"full","onEvent":{"focus":{"weight":0,"actions":[{"actionType":"dialog","dialog":{"type":"dialog","title":"请配置需要绑定的数据点","body":[{"type":"tabs","tabs":[{"title":"常规数据点","body":[{"type":"form","title":"","body":[{"type":"select","label":"数据源","name":"dataSource","id":"u:c273f087b8ed","multiple":false,"mode":"horizontal","size":"md","source":"\${apiDtoList || thingApiDTOList}","labelField":"name","valueField":"id","onEvent":{"change":{"actions":[{"actionType":"reload","componentId":"u:1cdb908c23a8"},{"actionType":"custom","script":"if (!event.data.value) { doAction({'actionType': 'setValue', 'componentId': 'u:1cdb908c23a8', 'args': {'value': ''} });\\r\\n doAction({'actionType': 'setValue', 'componentId': 'u:8147daea685d', 'args': {'value': ''} }); }"}]}},"clearable":true,"horizontal":{"left":2,"right":10},"actionType":"change","target":"u:1cdb908c23a8"},{"type":"select","label":"设备","name":"devices","id":"u:1cdb908c23a8","multiple":false,"mode":"horizontal","size":"md","source":{"url":"/thing/v2/api/telemetryById?id=\${dataSource}","method":"get","messages":{},"headers":{"token":"\${myToken}","tenantCode":"\${myTenantCode}","companyId":"\${myCompanyId}"},"adaptor":"if (payload && payload.data && payload.data.result) {console.log('payload.data.result', payload.data.result); \\r\\n const list = []\\r\\n const devices = payload.data.result.info \\r\\n for (const key in devices) {\\r\\n const device_info = devices[key] \\r\\n list.push({\\r\\n label: device_info.entityName,\\r\\n value: device_info.entityId,\\r\\n deviceCode: device_info.entityCode,\\r\\n deviceInfo: device_info,\\r\\n attrs: device_info.attrs })\\r\\n }\\r\\n payload.data = list;\\r\\n return payload\\r\\n}","sendOn":"this.dataSource"},"onEvent":{"change":{"actions":[{"actionType":"custom","script":"const selectedItems = event.data.selectedItems;\\r\\n if(selectedItems) { doAction({actionType: 'setValue', componentId: 'u:51f0e51abd7c', args: { value: { attrs: selectedItems.attrs, deviceCode: selectedItems.deviceCode } } }); }"},{"actionType":"custom","script":"if (!event.data.value) { doAction({'actionType': 'setValue', 'componentId': 'u:8147daea685d', 'args': {'value': ''} }); }"}]}},"responseData":{"&":"$$","list":"\${items}"},"clearable":true,"horizontal":{"left":2,"right":10}},{"type":"select","label":"数据点","name":"dataPoint","id":"u:8147daea685d","multiple":true,"mode":"horizontal","size":"md","source":{"url":"/thing/v2/api/callDict?id=\${dataSource}&entityId=\${devices}","method":"get","messages":{},"headers":{"token":"\${myToken}","tenantCode":"\${myTenantCode}","companyId":"\${myCompanyId}"},"sendOn":"this.dataSource && this.devices","adaptor":"const list = payload.data.map(item => {\\r\\n item.dictName = item.dictName + ' - ' + item.dictCode\\r\\n return item\\r\\n})\\r\\npayload.data = list;\\r\\nreturn payload"},"labelField":"dictName","valueField":"dictCode","checkAll":false,"horizontal":{"left":2,"right":10},"overlay":{"width":"350px"},"searchable":true}],"id":"u:51f0e51abd7c","data":{"attrs":[],"deviceCode":"\${deviceCode || ''}"},"submitText":""}],"id":"u:5505e7ef7cab"},{"title":"虚拟变量","body":[{"type":"tpl","tpl":"暂时无虚拟变量可配置","wrapperComponent":"","inline":false,"id":"u:722592249b31"}],"id":"u:b739cc6a6ed7"}],"id":"u:3b446450d643"}],"showCloseButton":true,"showErrorMsg":true,"showLoading":true,"id":"u:f46c2439c983","data":{"&":"\${dataPoint | toJson}","apiDtoList":"\${thingApiDTOList}","myToken":"\${myToken}","myTenantCode":"\${myTenantCode}","myCompanyId":"\${myCompanyId}","dataPointTableIndex":"\${index}"},"onEvent":{"confirm":{"actions":[{"componentId":"dataPointTable","actionType":"setValue","args":{"value":{"dataPoint":"\${event.data | json}"},"index":"\${index}"}}]}}}}]}},"horizontal":{"left":1,"right":11}}],"syncFields":[],"mode":"horizontal","visibleOn":"data.eventAction === 'openLink'"},{"type":"editor","label":"参数计算","name":"dataPointParamsCalculate","id":"u:4d5e749b7f42","visibleOn":"data.eventAction === 'openLink'","className":"text-left m-b-xs","inputClassName":"w-full","language":"javascript","value":"return [\\n {\\n key: \\"\\",\\n value: ''\\n }\\n]"},{"type":"radios","label":"打开方式","name":"openMethod","id":"u:eec4f8737fe8","options":[{"label":"打开新页面","value":"openNewPage"},{"label":"打开到本页","value":"openLocalPage"}],"horizontal":{"leftFixed":"sm"},"mode":"horizontal","visibleOn":"data.eventAction === 'openLink'"},{"type":"radios","label":"下发指令方式","name":"sendCommandMethod","hiddenOn":"data.eventAction !== 'sendCommand'","id":"u:82d9feb7609d","options":[{"label":"配置","value":"config"},{"label":"代码","value":"codes"}],"value":"config"},{"type":"select","label":"选择设备","clearable":"true","name":"selectDevice","id":"u:891bca3a0150","hiddenOn":"data.eventAction !== 'sendCommand'","inputClassName":"w-full","multiple":false,"mode":"horizontal","size":"full","source":{"url":"/thing/device/control/list/device","method":"get","messages":{},"headers":{"token":"\${myToken}","tenantCode":"\${myTenantCode}","companyId":"\${myCompanyId}"}},"labelField":"name","valueField":"id","onEvent":{"change":{"actions":[{"componentId":"u:a13b61f23669","actionType":"custom","script":"const select = event.data.selectedItems; \\r\\n doAction({'componentId': 'u:a13b61f23669', 'actionType': 'setValue', 'args': { 'value': { 'device': select }} })"}]}}},{"type":"select","id":"u:42026703278d","label":"选择指令","clearable":"true","name":"selectCommand","hiddenOn":"data.eventAction !== 'sendCommand'","multiple":false,"mode":"horizontal","size":"full","source":{"url":"/thing/device/control/list/\${selectDevice}","method":"get","messages":{},"headers":{"token":"\${myToken}","tenantCode":"\${myTenantCode}","companyId":"\${myCompanyId}"},"sendOn":"this.selectDevice"},"labelField":"name","valueField":"id","inputClassName":"w-full","onEvent":{"change":{"actions":[{"componentId":"u:a13b61f23669","actionType":"custom","script":"const select = event.data.selectedItems; \\r\\n doAction({'componentId': 'u:a13b61f23669', 'actionType': 'setValue', 'args': { 'value': { 'command': select }} })"}]}}},{"type":"tpl","id":"u:f0e9dbf83675","hiddenOn":"data.eventAction !== 'sendCommand'","className":"mx-20 text-left","tpl":"function (deviceInfo, command, event){","inline":true,"wrapperComponent":""},{"type":"editor","id":"u:14d8542a2066","hiddenOn":"data.eventAction !== 'sendCommand'","className":"text-left m-b-xs","label":"入参","name":"inputParamsCalculate","inputClassName":"w-full","language":"javascript","onEvent":{"blur":{"actions":[{"actionType":"custom","script":"const func = new Function('paramsList', 'command', event.data.value);\\n const newParams = func(event.data.__super.inputParamsTable || [], event.data.__super.selectCommand);\\n doAction({actionType: 'setValue', componentId: 'u:a13b61f23669', args: { value: { globalInputParamsCalculated: newParams } } });"}]}},"value":"// console.log('deviceInfo', deviceInfo, 'command', command, 'event', event);\\n// 入参提示: deviceInfo -- 设备信息,command -- 指令信息, event -- 事件传参(当前部件所绑定的立即值,或当前部件经过计算后的自定义值), 入参计算。。。然后返回出参\\nreturn {\\n \\"condition\\": \\"\\",\\n \\"controlId\\": command.id,\\n \\"event\\": event\\n}"},{"type":"grid","id":"u:68833f10e2bf","columns":[{"body":[{"type":"select","label":"请求地址","name":"requestMethod","options":[{"label":"get","value":"get"},{"label":"post","value":"post"},{"label":"put","value":"put"},{"label":"delete","value":"delete"}],"id":"u:7c48788db8af","multiple":false,"hiddenOn":"data.eventAction !== 'sendCommand'","visibleOn":"data.sendCommandMethod === 'config'","mode":"horizontal","size":"full","inputClassName":"w-full","value":"post"}],"id":"u:d9d274b50340"},{"body":[{"type":"input-text","label":false,"name":"requestUrl","id":"u:841b001e3bcd","size":"full","placeholder":"请输入请求地址","hiddenOn":"data.eventAction !== 'sendCommand'","visibleOn":"data.sendCommandMethod === 'config'","value":"/thing/device/control/control"}],"id":"u:c8fab8bb0860"},{"body":[{"type":"input-number","label":"","name":"requestIntervalNumber","keyboard":true,"id":"u:69a53fa6dc9f","step":1,"mode":"inline","placeholder":"请求间隔","hiddenOn":"data.eventAction !== 'sendCommand'","visibleOn":"data.sendCommandMethod === 'config'"},{"type":"select","label":"","name":"requestIntervalUnit","options":[{"label":"秒","value":"second"},{"label":"分","value":"minute"},{"label":"时","value":"hour"},{"label":"天","value":"day"}],"id":"u:69f93c61c28b","multiple":false,"mode":"inline","hiddenOn":"data.eventAction !== 'sendCommand'","visibleOn":"data.sendCommandMethod === 'config'"}],"id":"u:1827f27e041b"}]},{"type":"grid","id":"u:208413b258dc","className":"m-b","columns":[]},{"type":"tpl","id":"u:931d6b4e0374","hiddenOn":"data.eventAction !== 'sendCommand'","className":"mx-20 text-left","visibleOn":"data.sendCommandMethod === 'codes'","tpl":"function (context, service, command, event ){","inline":true,"wrapperComponent":""},{"type":"editor","id":"u:52152e74a360","hiddenOn":"data.eventAction !== 'sendCommand'","className":"text-left","visibleOn":"data.sendCommandMethod === 'codes'","label":"下发指令","name":"commandContent","inputClassName":"w-full","language":"javascript","labelRemark":{"icon":"fa fa-question-circle","trigger":["hover"],"className":"Remark--warning","placement":"top","title":"函数入参为:","content":"'context': logicflow 上下文实例; \\n 'service': axios 请求实例;"}},{"type":"tpl","id":"u:2bb06db3ddd9","hiddenOn":"data.eventAction !== 'sendCommand'","className":"mx-20 text-left","tpl":"}","inline":true,"wrapperComponent":"","visibleOn":"data.sendCommandMethod === 'codes'"},{"type":"input-text","label":"弹框标题","name":"dialogTitle","id":"u:efa5bfe4e760","hiddenOn":"data.eventAction !== 'openDialog'"},{"type":"input-text","label":"弹框内容","name":"dialogContent","id":"u:e1ee364f3318","hiddenOn":"data.eventAction !== 'openDialog'"},{"type":"list-select","label":"指令下一步","name":"commandNext","id":"u:158bf05d1e6b","multiple":true,"options":[{"label":"显示隐藏","value":"showOrHide"}],"hiddenOn":"data.eventAction !== 'sendCommand'","joinValues":false},{"type":"grid","id":"u:f9985214eb9e","columns":[{"body":[{"type":"editor","name":"showHideNewValue","id":"u:9f2d894d8fc6","mode":"horizontal","label":false,"placeholder":"返回计算后的组件显示和隐藏, 格式为: return { '组件id xxxxx-xxx-xxx': 'show' / 'hide' } 或 return { '组件id xxxxx-xxx-xxx': e ? 'show' : 'hide' } , e为事件值。","size":"full","language":"javascript","inputControlClassName":"w-full","remark":{"icon":"fa fa-question-circle","trigger":["hover"],"className":"Remark--warning","placement":"top"},"description":"","visibleOn":"data.eventAction === 'showHide'","className":"w-full","inputClassName":"w-full","value":""}],"id":"u:52e0c15d0c8f"}],"className":"m-b"},{"type":"list-select","label":"复制组件ID","name":"allComponentList","id":"u:77a71866967a","mode":"horizontal","visibleOn":"data.eventAction === 'showHide'","multiple":false,"source":"\${nodesList || graphDataList}","onEvent":{"change":{"actions":[{"actionType":"copy","args":{"content":"\${event.data.value}"}}]}}},{"type":"grid","id":"u:7e8dfba20aee","columns":[]}],"id":"u:a13b61f23669","name":"eventsForm","className":"text-left","data":{"globalInputParamsCalculated":[],"device":"\${device}","command":"\${command}"}}],"onEvent":{"confirm":{"actions":[{"componentId":"u:364496dd313b","actionType":"custom","script":"const evType = event.data.eventType || event.data.__super.evType; \\r\\n const index = event.data.__index | event.data.__super.comboIndex; \\r\\n doAction({'componentId': 'u:364496dd313b', 'actionType': 'setValue', 'args': { 'index': index, 'value': { 'config': JSON.stringify(event.data), 'eventType': evType }} })"}]}},"showCloseButton":true,"showErrorMsg":true,"showLoading":true,"id":"u:57f536c19373","size":"lg","type":"dialog","bodyClassName":"setting-events-dialog","name":"settingEventsDialog"}}]}},"label":"动作","editorState":"default"},{"type":"checkBox","id":"u:79dadbc61f74","name":"enable","label":"启用"},{"type":"select","label":"用户","name":"users","id":"u:18f4db277518","multiple":true,"source":{"url":"/thing/sys/tenant/user","method":"get","headers":{"token":"\${myToken}","tenantCode":"\${myTenantCode}","companyId":"\${myCompanyId}"}},"labelField":"realName","valueField":"id","checkAll":false,"clearable":true}],"id":"u:364496dd313b","deleteBtn":{"type":"icon","icon":"fa fa-trash","id":"u:6d4a75088bc2","className":"border-none"}}],"data":{"eventCombo":[{"eventType":"click","enable":false,"config":""},{"eventType":"dblClick","enable":false,"config":""}]},"name":"eventsService"}],"id":"u:14834e895716","headingClassName":"p-sm bg-white b-b b-light","className":"m-b r-3x","bodyClassName":"p-none"}],"id":"u:3eb6b9a42dcb","name":"dynamicService"}],"id":"u:043251c106af","className":"p-sm"},{"title":"脚本解析","icon":"fa fa-star","body":[{"type":"flex","id":"u:edef8e21c1e3","justify":"flex-end","items":[{"type":"button","id":"u:f6d8d837a48d","label":"导入","onEvent":{"click":{"actions":[]}},"icon":"fa fa-download","level":"primary","className":"mr-2"},{"type":"button","id":"u:23f988f98a28","label":"保存","onEvent":{"click":{"actions":[{"actionType":"setValue","componentId":"u:6dc2a126004a","args":{"value":{"save":true}}}]}},"icon":"fa fa-save"}]},{"type":"service","id":"u:6dc2a126004a","body":[{"type":"tpl","id":"u:c77724a2f3b3","tpl":"function (context, service, nodeId) {","inline":true,"wrapperComponent":"","style":{"fontFamily":"","fontSize":16}},{"type":"editor","label":"","name":"script","id":"u:55ceb80e58a7","language":"javascript","size":"xxl","className":"m-b-none","onEvent":{"focus":{"actions":[{"actionType":"setValue","componentId":"u:6dc2a126004a","args":{"value":{"save":false}}}]}},"description":"参数提示:\\n1. context 是整个看板上下文,可以获取看板所有元素节点和连线节点,也可以访问 context.globalDatas 获取全局socket 数据。 \\n2. service 是 Ajax 请求服务。\\n3. nodeId 是节点 id . \\n4. 如果返回一个函数,则可以当socket 数据更新时,调用此函数,此函数入参分别是 context, service, nodeId, globalDatas ;,以满足多样化的业务需求。"},{"type":"tpl","tpl":"}","inline":true,"wrapperComponent":"","id":"u:fa21aebb859b","style":{"fontFamily":"","fontSize":16}}],"name":"scriptService","data":{"script":"","save":false},"className":"text-left"}],"id":"u:dc8d331cbe5e"}],"id":"u:178107498966","tabsMode":"radio","className":"p-none w-full","contentClassName":"p-none"}],"className":""}`,c={jsPlugin:'[{"url":"./logicflow/core.umd.js","isModule":false,"disabled":true},{"url":"./logicflow/extensionLib/NodeResize.js","isModule":false,"disabled":true}]',json:`{
|
|
"nodes": [
|
|
{
|
|
"id": "294b013f-14d3-429e-a078-048da5f0261e",
|
|
"type": "custom-button-node",
|
|
"x": 200,
|
|
"y": 200,
|
|
"text": {
|
|
"value": "测试按钮",
|
|
"x": 200,
|
|
"y": 200
|
|
},
|
|
"properties": {
|
|
"id": "294b013f-14d3-429e-a078-048da5f0261e",
|
|
"width": 80,
|
|
"height": 35,
|
|
"x": 200,
|
|
"y": 200,
|
|
"rotation": 0,
|
|
"opacity": 1,
|
|
"strokeWidth": 1,
|
|
"fontSize": 14,
|
|
"boxShadow": "0 2px 0 rgba(0, 0, 0, 0.45)",
|
|
"nodeAlias": "按钮",
|
|
"fontColor": "#ffffff",
|
|
"strokeColor": "",
|
|
"content": "测试按钮",
|
|
"lineHeight": 35,
|
|
"fontStyle": "",
|
|
"fill": "rgb(24, 144, 255)",
|
|
"background": "",
|
|
"borderRadius": 6,
|
|
"backgroundSize": "100% 100%",
|
|
"dynamic": {
|
|
"normalData": {
|
|
"dataPoint": "",
|
|
"compareType": "",
|
|
"conditionVariables": [],
|
|
"defaultValue": "",
|
|
"unit": ""
|
|
},
|
|
"eventsData": {
|
|
"eventCombo": [
|
|
{
|
|
"eventType": "click",
|
|
"config": "{\\"globalInputParamsCalculated\\":[],\\"eventAction\\":\\"sendCommand\\",\\"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 == 0 ? 1 : event == 1 ? 0 : 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": "equal",
|
|
"label": "相等",
|
|
"name": ""
|
|
}
|
|
]
|
|
},
|
|
"animationData": {
|
|
"animationCombo": [
|
|
{
|
|
"dataPoint": "",
|
|
"min": "",
|
|
"max": "",
|
|
"animationName": "旋转",
|
|
"animationTime": 3
|
|
}
|
|
]
|
|
},
|
|
"hiddenData": {
|
|
"hiddenCombo": [
|
|
{
|
|
"dataPoint": "",
|
|
"min": "",
|
|
"max": "",
|
|
"showOrHiddenName": "隐藏"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}`,javascript:`
|
|
|
|
const { createApp, createVNode, render } = Vue;
|
|
const app = createApp({})
|
|
const Button = {
|
|
template: '<div :style="getStyle" @click="clickHandler" @dblclick="dblClickHandler">{{name}}</div>',
|
|
props: {
|
|
name: {
|
|
type: String,
|
|
default: '按钮11'
|
|
},
|
|
fontColor: {
|
|
type: String,
|
|
default: '#ffffff'
|
|
},
|
|
fontSize: {
|
|
type: Number,
|
|
default: 14
|
|
},
|
|
fontFamily: {
|
|
type: String,
|
|
default: '宋体'
|
|
},
|
|
fontStyle: {
|
|
type: String,
|
|
default: 'normal'
|
|
},
|
|
width: {
|
|
type: Number,
|
|
default: 80
|
|
},
|
|
height: {
|
|
type: Number,
|
|
default: 35
|
|
},
|
|
lineHeight: {
|
|
type: Number,
|
|
default: 35,
|
|
},
|
|
backgroundColor: {
|
|
type: String,
|
|
default: '#1890ff',
|
|
},
|
|
strokeColor: {
|
|
type: String,
|
|
default: '#1890ff',
|
|
},
|
|
strokeWidth: {
|
|
type: Number,
|
|
default: 1,
|
|
},
|
|
opacity: {
|
|
type: Number,
|
|
default: 1,
|
|
},
|
|
background: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
backgroundSize: {
|
|
type: String,
|
|
default: '100% 100%',
|
|
},
|
|
boxShadow: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
borderRadius: {
|
|
type: Number,
|
|
default: 6,
|
|
},
|
|
realValue: {
|
|
type: [String, Number],
|
|
default: ''
|
|
}
|
|
},
|
|
computed: {
|
|
getStyle () {
|
|
const { fontColor, fontSize, fontFamily, fontStyle, width, height, lineHeight, backgroundColor,strokeColor,strokeWidth, opacity, background, backgroundSize, boxShadow, borderRadius } = this
|
|
const style = {}
|
|
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'
|
|
}
|
|
}
|
|
let back = background;
|
|
if (back && !back.includes('url')) {
|
|
back = \`url(\${back})\`
|
|
}
|
|
return {
|
|
color: fontColor,
|
|
"font-size": parseInt(fontSize) + 'px',
|
|
"font-family": fontFamily,
|
|
"font-style": style.fontStyle,
|
|
"font-weight": style.fontWeight,
|
|
"text-decoration": style.textDecoration,
|
|
width: parseInt(width) - parseInt(strokeWidth) * 2 + 'px',
|
|
height: parseInt(height) - parseInt(strokeWidth) * 2 + 'px',
|
|
lineHeight: parseInt(lineHeight) - parseInt(strokeWidth) * 2 + 'px',
|
|
"text-align": 'center',
|
|
'background': backgroundColor || back,
|
|
'background-size': backgroundSize,
|
|
"border-radius": borderRadius + 'px',
|
|
"box-shadow": boxShadow,
|
|
"border-color": strokeColor,
|
|
"border-style": "solid",
|
|
"border-width": parseInt(strokeWidth) + 'px',
|
|
"opacity": opacity,
|
|
cursor: 'pointer'
|
|
}
|
|
}
|
|
},
|
|
emits: ['click', 'dblClick'],
|
|
setup(props, { emit } ) {
|
|
const {ref, toRefs, computed, watch} = Vue
|
|
const { realValue } = toRefs(props);
|
|
const clickHandler = () => {
|
|
emit('click', realValue.value)
|
|
}
|
|
const dblClickHandler = () => {
|
|
emit('dblClick', realValue.value)
|
|
}
|
|
return {
|
|
clickHandler,
|
|
dblClickHandler,
|
|
}
|
|
}
|
|
}
|
|
|
|
class CustomButtonNode extends HtmlResize.view {
|
|
clickTime = ''
|
|
|
|
setHtml(rootEl) {
|
|
const { graphModel } = this.props;
|
|
const { properties, width, height, } = this.props.model;
|
|
const { content, fontColor, fontSize, fontFamily, fontStyle, lineHeight, fill, strokeColor,strokeWidth, opacity, background, boxShadow, borderRadius } = properties;
|
|
const { model } = this.props;
|
|
const el = document.createElement('div');
|
|
rootEl.innerHTML = '';
|
|
|
|
const { uiData, eventsData } = properties.dynamic || {};
|
|
|
|
const findClick = eventsData?.eventCombo.find( i => i.eventType === 'click');
|
|
|
|
const clickHandler = (e) => {
|
|
if(uiData.dataPoint && findClick && findClick.enable) {
|
|
const now = new Date().getTime();
|
|
if (this.clickTime) {
|
|
if (now - this.clickTime <= 10000) {
|
|
messageFn('10秒之内不能重复触发')
|
|
return;
|
|
}
|
|
}
|
|
this.clickTime = now;
|
|
}
|
|
const cacheToken = sessionStorage.getItem('v1@CacheToken');
|
|
if(!cacheToken) {
|
|
return window.createLoginDialog();
|
|
}
|
|
const tokenParsed = JSON.parse(cacheToken || '{}');
|
|
if (findClick.users && !findClick.users.includes(tokenParsed.userid)) {
|
|
return messageFn('无用户权限')
|
|
}
|
|
graphModel.eventCenter.emit("myNode:click", {
|
|
data: this.props.model,
|
|
e,
|
|
});
|
|
}
|
|
|
|
const dblClickHandler = (e) => {
|
|
graphModel.eventCenter.emit("myNode:dbclick", {
|
|
data: this.props.model,
|
|
e,
|
|
});
|
|
}
|
|
|
|
let dynamicBack = background;
|
|
let dynamicName = content
|
|
let fillColor = fill
|
|
let fontC = fontColor
|
|
let realValue = ''
|
|
if (uiData) {
|
|
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.backColor && Number(realValue) >= from && Number(realValue) <= to) {
|
|
fillColor = item.backColor
|
|
}
|
|
if (item.fontColor && Number(realValue) >= from && Number(realValue) <= to) {
|
|
fontC = item.fontColor
|
|
}
|
|
if (item.background && Number(realValue) >= from && Number(realValue) <= to) {
|
|
dynamicBack = item.background
|
|
}
|
|
} else if (item.type === 'equal') {
|
|
if(Number(realValue) === Number(item.value)) {
|
|
item.backColor && (fillColor = item.backColor);
|
|
item.fontColor && (fontC = item.fontColor);
|
|
dynamicName = item.valueLabel;
|
|
item.background && (dynamicBack = item.background);
|
|
}
|
|
} 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) {
|
|
item.backColor && (fillColor = item.backColor);
|
|
item.fontColor && (fontC = item.fontColor);
|
|
dynamicName = item.valueLabel;
|
|
item.background && (dynamicBack = item.background);
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
const instance = createVNode(Button, {
|
|
name: dynamicName,
|
|
fontColor: fontC,
|
|
fontSize, fontFamily, fontStyle,width, height, lineHeight,
|
|
backgroundColor: fillColor,
|
|
strokeColor,strokeWidth,
|
|
opacity,
|
|
background: dynamicBack,
|
|
boxShadow,
|
|
borderRadius,
|
|
realValue,
|
|
onClick: clickHandler,
|
|
onDblClick: dblClickHandler,
|
|
})
|
|
instance.appContext = app._context
|
|
render(instance, el)
|
|
rootEl.appendChild(el);
|
|
}
|
|
}
|
|
|
|
class CustomButtonModel extends HtmlResize.model {
|
|
initNodeData(data) {
|
|
// 自定义组件,需最开始重置一下text 。
|
|
data.text = {
|
|
value: "",
|
|
x: data.x,
|
|
y: data.y,
|
|
};
|
|
super.initNodeData(data);
|
|
const { properties } = this;
|
|
this.width = properties.width || 80;
|
|
this.height = properties.height || 35;
|
|
this.text.editable = false; // 不允许文本被编辑
|
|
}
|
|
|
|
setAttributes() {
|
|
// 自定义组件需重置 text
|
|
const { x, y, properties } = this;
|
|
const { textHorizontalMove = 0, textVerticalMove = 0 } = properties;
|
|
this.text = {
|
|
...this.text,
|
|
x: x + textHorizontalMove,
|
|
y: y + textVerticalMove,
|
|
value: "",
|
|
}
|
|
}
|
|
}
|
|
|
|
lf.register({
|
|
type: 'custom-button-node',
|
|
view: CustomButtonNode,
|
|
model: CustomButtonModel,
|
|
})
|
|
|
|
`,css:"",fakeData:""},m={id:e,name:a,aliasName:t,image:n,imageType:l,groupName:o,groupType:i,isRemote:!1,isDefault:!0,sectionType:d,config:s,files:c};export{t as aliasName,s as config,m as default,c as files,o as groupName,i as groupType,e as id,n as image,l as imageType,u as isDefault,r as isRemote,a as name,d as sectionType};
|