Files
aiot-platform-ui/apps/web-antd/dist/js/property-selector-CTk4gO41.js

2 lines
6.5 KiB
JavaScript
Raw Normal View History

2026-03-25 16:05:53 +08:00
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{bQ as P,az as R,an as w,ay as G,aL as $,ac as j}from"./bootstrap-Cs_ukuUC.js";import{m as U,b9 as S,aa as L,ce 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-BQSou8bA.js";import{g as H}from"./index-DbH-Y0NA.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:z(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 z(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,nul