2 lines
6.5 KiB
JavaScript
2 lines
6.5 KiB
JavaScript
var I=(h,E,r)=>new Promise((_,x)=>{var T=d=>{try{m(r.next(d))}catch(s){x(s)}},n=d=>{try{m(r.throw(d))}catch(s){x(s)}},m=d=>d.done?_(d.value):Promise.resolve(d.value).then(T,n);m((r=r.apply(h,E)).next())});import{bT as P,aL as R,an as w,ay as $,bi as j,ac as z}from"./bootstrap-DsjPfOC_.js";import{m as U,b9 as S,aa as L,cd as J,w as C,ad as u,b2 as o,j as g,ab as V,ac as y,bJ as f,I as M,bb as N,u as l,ae as i,bp as p,ai as O,aJ as F}from"../jse/index-index-CO0ZsLf2.js";import{g as H}from"./index-xuHdvnW9.js";import{s as b,T as k,a as c,t as A,u as K,v as Q,c as W,g as X}from"./constants-B5TthjFC.js";const Z={class:"gap-8px flex items-center"},ee={class:"py-2px flex w-full items-center justify-between"},te={class:"text-14px font-500 flex-1 truncate text-primary"},ae={class:"property-detail-content"},se={class:"gap-8px mb-12px flex items-center"},ie={class:"text-14px font-500 text-primary"},le={class:"space-y-8px ml-24px"},re={class:"gap-8px flex items-start"},ne={class:"text-12px flex-1 text-primary"},oe={key:0,class:"gap-8px flex items-start"},pe={class:"text-12px flex-1 text-primary"},de={key:1,class:"gap-8px flex items-start"},ue={class:"text-12px flex-1 text-primary"},ce={key:2,class:"gap-8px flex items-start"},xe={class:"text-12px flex-1 text-primary"},fe={key:3,class:"gap-8px flex items-start"},me={class:"text-12px flex-1 text-primary"},ye={key:4,class:"gap-8px flex items-start"},ve={class:"text-12px flex-1 text-primary"},ge={key:5,class:"gap-8px flex items-start"},Te={class:"text-12px flex-1 text-primary"},_e=U({name:"PropertySelector",__name:"property-selector",props:{deviceId:{},modelValue:{},productId:{},triggerType:{}},emits:["update:modelValue","change"],setup(h,{emit:E}){const r=h,_=E,x=J(r,"modelValue",_),T=S(!1),n=S([]),m=S(null),d=L(()=>{const t=[];return r.triggerType===b.DEVICE_PROPERTY_POST&&t.push({label:k.PROPERTY,options:n.value.filter(e=>e.type===c.PROPERTY)}),r.triggerType===b.DEVICE_EVENT_POST&&t.push({label:k.EVENT,options:n.value.filter(e=>e.type===c.EVENT)}),r.triggerType===b.DEVICE_SERVICE_INVOKE&&t.push({label:k.SERVICE,options:n.value.filter(e=>e.type===c.SERVICE)}),t.filter(e=>e.options.length>0)}),s=L(()=>n.value.find(t=>t.identifier===x.value));function D(t){const e=n.value.find(a=>a.identifier===t);e&&_("change",{type:e.dataType,config:e})}function B(){return I(this,null,function*(){if(!r.productId){m.value=null,n.value=[];return}T.value=!0;try{const t=yield H(r.productId);t?(m.value=t,q()):(console.error("获取物模型TSL失败: 返回数据为空"),n.value=[])}catch(t){console.error("获取物模型TSL失败:",t),n.value=[]}finally{T.value=!1}})}function q(){const t=m.value,e=[];if(!t){n.value=e;return}t.properties&&Array.isArray(t.properties)&&t.properties.forEach(a=>{e.push({identifier:a.identifier,name:a.name,description:a.description,dataType:a.dataType,type:c.PROPERTY,accessMode:a.accessMode,required:a.required,unit:Y(a),range:G(a),property:a})}),t.events&&Array.isArray(t.events)&&t.events.forEach(a=>{e.push({identifier:a.identifier,name:a.name,description:a.description,dataType:"struct",type:c.EVENT,eventType:a.type,required:a.required,outputParams:a.outputParams,event:a})}),t.services&&Array.isArray(t.services)&&t.services.forEach(a=>{e.push({identifier:a.identifier,name:a.name,description:a.description,dataType:"struct",type:c.SERVICE,callType:a.callType,required:a.required,inputParams:a.inputParams,outputParams:a.outputParams,service:a})}),n.value=e}function Y(t){if(t&&t.dataSpecs&&t.dataSpecs.unit)return t.dataSpecs.unit}function G(t){if(t){if(t.dataSpecs){const e=t.dataSpecs;if(e.min!==void 0&&e.max!==void 0)return`${e.min}~${e.max}`}if(t.dataSpecsList&&Array.isArray(t.dataSpecsList))return t.dataSpecsList.map(e=>`${e.name}(${e.value})`).join(", ")}}return C(()=>r.productId,()=>{B()},{immediate:!0}),C(()=>r.triggerType,()=>{x.value=""}),(t,e)=>(o(),u("div",Z,[g(l(P),{modelValue:l(x),"onUpdate:modelValue":e[0]||(e[0]=a=>F(x)?x.value=a:null),placeholder:"请选择监控项",filterable:"",clearable:"",onChange:D,class:"!w-150px",loading:T.value},{default:f(()=>[(o(!0),u(M,null,N(d.value,a=>(o(),V(l(P).OptionGroup,{key:a.label,label:a.label},{default:f(()=>[(o(!0),u(M,null,N(a.options,v=>(o(),V(l(P).Option,{key:v.identifier,label:v.name,value:v.identifier},{default:f(()=>[i("div",ee,[i("span",te,p(v.name),1),g(l(R),{type:l(A)(v.dataType),size:"small",class:"ml-8px flex-shrink-0"},{default:f(()=>[O(p(v.identifier),1)]),_:2},1032,["type"])])]),_:2},1032,["label","value"]))),128))]),_:2},1032,["label"]))),128))]),_:1},8,["modelValue","loading"]),s.value?(o(),V(l(j),{key:0,placement:"rightTop",width:350,trigger:"click","show-arrow":!0,offset:8,"popper-class":"property-detail-popover"},{reference:f(()=>[g(l($),{type:"primary",text:"",circle:"",size:"small",class:"flex-shrink-0",title:"查看属性详情"},{default:f(()=>[g(l(w),{icon:"ep:info-filled"})]),_:1})]),default:f(()=>[i("div",ae,[i("div",se,[g(l(w),{icon:"ep:info-filled",class:"text-16px text-info"}),i("span",ie,p(s.value.name),1),g(l(R),{type:l(A)(s.value.dataType),size:"small"},{default:f(()=>[O(p(l(K)(s.value.dataType)),1)]),_:1},8,["type"])]),i("div",le,[i("div",re,[e[1]||(e[1]=i("span",{class:"text-12px min-w-60px flex-shrink-0 text-secondary"}," 标识符: ",-1)),i("span",ne,p(s.value.identifier),1)]),s.value.description?(o(),u("div",oe,[e[2]||(e[2]=i("span",{class:"text-12px min-w-60px flex-shrink-0 text-secondary"}," 描述: ",-1)),i("span",pe,p(s.value.description),1)])):y("",!0),s.value.unit?(o(),u("div",de,[e[3]||(e[3]=i("span",{class:"text-12px min-w-60px flex-shrink-0 text-secondary"}," 单位: ",-1)),i("span",ue,p(s.value.unit),1)])):y("",!0),s.value.range?(o(),u("div",ce,[e[4]||(e[4]=i("span",{class:"text-12px min-w-60px flex-shrink-0 text-secondary"}," 取值范围: ",-1)),i("span",xe,p(s.value.range),1)])):y("",!0),s.value.type===l(c).PROPERTY&&s.value.accessMode?(o(),u("div",fe,[e[5]||(e[5]=i("span",{class:"text-12px min-w-60px flex-shrink-0 text-secondary"}," 访问模式: ",-1)),i("span",me,p(l(Q)(s.value.accessMode)),1)])):y("",!0),s.value.type===l(c).EVENT&&s.value.eventType?(o(),u("div",ye,[e[6]||(e[6]=i("span",{class:"text-12px min-w-60px flex-shrink-0 text-secondary"}," 事件类型: ",-1)),i("span",ve,p(l(W)(s.value.eventType)),1)])):y("",!0),s.value.type===l(c).SERVICE&&s.value.callType?(o(),u("div",ge,[e[7]||(e[7]=i("span",{class:"text-12px min-w-60px flex-shrink-0 text-secondary"}," 调用类型: ",-1)),i("span",Te,p(l(X)(s.value.callType)),1)])):y("",!0)])])]),_:1})):y("",!0)]))}}),be=z(_e,[["__scopeId","data-v-faf2d945"]]);export{be as default};
|