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

1 lines
3.4 KiB

import{d as x,c as f,B as b,G as c,p as h,I as y,o as $,b as p,e as C,q as w,n as g}from"./index-bVOhw2NF.js";let d=!1;function V(t,{emit:a}){let n=t.options.text,i="",s="",u="";if(t.options.textFormat==="val"){const{values:e}=t.datasets;if(e&&e.length>0){const{val:o}=e[0];n=o}}else if(t.options.textFormat==="val unit"){const{values:e}=t.datasets;if(e&&e.length>0){const{val:o,unit:l}=e[0];n=o,i=l}}else if(t.options.textFormat==="name val unit"){const{info:e,values:o}=t.datasets;if(e&&o&&o.length>0){const{val:l,unit:r,attrKey:v,thingCode:m}=o[0];s=e[m].attrs[v].name,n=l,i=r}}else if(t.options.textFormat==="attrKey val unit"){const{values:e}=t.datasets;if(e&&e.length>0){const{val:o,unit:l,attrKey:r}=e[0];u=r,n=o,i=l}}if(d)return null;if(typeof n=="number"&&t.options.valueNumberConfig&&(t.options.wanFormat&&(n=n/1e4),t.options.valueDecimal&&(n=n.toFixed(t.options.valueDecimal))),t.options.inputingText){const e=t.options["justify-content"],o=e==="start"?"left":e==="end"?"right":"center";return c("input",{class:"val-widget",style:{"border-color":t.options.textEditable?"#1890ff":"transparent",color:t.options.valueColor||t.options.color||"#1890ff","background-color":"transparent",outline:"none",width:"100%",height:"100%","text-align":o,"letter-spacing":`${t.options["letter-spacing"]}px`},value:n,onFocus:()=>{d=!0},onBlur:l=>{t.options.text=l.target.value,a("changeValue",l.target.value),d=!1}},[])}return c("div",{},[s?`${s} `:null,u?`${u} `:null,c("span",{class:"val-widget",contenteditable:t.options.textEditable,style:{"border-color":t.options.textEditable?"#1890ff":"transparent",color:t.options.valueColor||t.options.color||"#1890ff"},onFocus:()=>{d=!0},onBlur:e=>{a("changeValue",e.target.textContent),d=!1}},n),i?` ${i}`:null])}const k=x({name:"EsText",components:{ValWidget:V},props:{options:{type:Object,default:()=>({})},datasets:{type:[String,Boolean,Number,Array,Object],default:""},eventData:{type:[String,Boolean,Number],default:""}},emits:["blurInput","updateValue","update:eventData"],setup(t,{emit:a}){const n=f(()=>({width:"100%",height:"100%",display:"flex",flexDirection:"row",justifyContent:`${t.options["justify-content"]}`,alignItems:"center"})),i=f(()=>({color:`${t.options.color||"#1890ff"}`,fontSize:`${t.options["font-size"]}px`,fontWeight:`${t.options["font-weight"]}`,fontFamily:`${t.options["font-family"]}`,padding:`${t.options.paddingY}px ${t.options.paddingX}px`,"writing-mode":`${t.options["writing-mode"]}`,letterSpacing:`${t.options["letter-spacing"]}px`,border:`${t.options["border-width"]}px solid ${t.options["border-color"]||"transparent"}`,borderRadius:`${t.options["border-radius"]}px`,backgroundColor:`${t.options["background-color"]||"transparent"}`,width:t.options.inputingText?"100%":"auto",height:t.options.inputingText?"100%":"auto"})),s=()=>{t.options.link&&window.open(t.options.link,"_blank")};function u(e){a("blurInput"),a("update:eventData",e),a("updateValue",e)}return{...b(t.options),textContainerStyle:n,textStyle:i,clickHandle:s,changeValue:u}}});function F(t,a,n,i,s,u){const e=y("ValWidget");return $(),p("div",{class:"es-text",style:g(t.textContainerStyle)},[C("div",{class:"es-text-content",style:g(t.textStyle),onClick:a[0]||(a[0]=(...o)=>t.clickHandle&&t.clickHandle(...o))},[w(e,{options:t.options,datasets:t.datasets,"event-data":t.eventData,onChangeValue:t.changeValue},null,8,["options","datasets","event-data","onChangeValue"])],4)],4)}const j=h(k,[["render",F],["__scopeId","data-v-27bdfa16"]]);export{j as default};