import{I as y}from"./index-33689e3e.js";import{d as F,K as G,y as N,b6 as q,ac as g,h as r,a as I,c as b,b as a,m as J,e as t,G as K,J as i,g as L,aq as h,aK as M,aL as O,X,Y,Z,at as A,a4 as H,au as Q,_ as W,av as $,aC as ee}from"./index-3ac32eb9.js";const te={name:"ServiceDistribute"},le=F({...te,props:{currentIotId:{type:String}},setup(w){const D=L(),p=w,o=G({loading:!1,serviceType:0,formData:{iotId:p.currentIotId,projectId:"",productId:"",deviceId:"",inParameter:{command:"",parameter:""},serviceType:0},reciveData:{code:"",content:""},rules:{command:[{required:!0,message:"请输入命令字",trigger:"blur"}],parameter:[{required:!0,message:"请输入参数",trigger:"blur"}]}}),{loading:x,serviceType:f,formData:d,reciveData:m,rules:E}=h(o);function P(l){l===0?o.formData.serviceType=0:o.formData.serviceType=1}async function R(){D.value.validate(async l=>{l&&(o.loading=!0,y(o.formData).then(e=>{console.log(e),o.reciveData.code=e.code,o.reciveData.content=e.message,o.loading=!1}))})}async function k(){y({iotId:p.currentIotId,projectId:"",productId:"",deviceId:"",inParameter:{command:"ResetSystem",parameter:""},serviceType:0}).then(l=>{console.log(l),o.reciveData.code=l.code,o.reciveData.content=l.message})}async function z(){y({iotId:p.currentIotId,projectId:"",productId:"",deviceId:"",inParameter:{command:"GetSystemTime",parameter:""},serviceType:0}).then(l=>{console.log(l),o.reciveData.code=l.code,o.reciveData.content=JSON.parse(l.data.outParameter).params.content})}return N(()=>{}),(l,e)=>{const V=M,S=O,u=X,c=Y,C=Z,s=A,U=H,_=Q,v=W,j=$,T=q("hasPerm"),B=ee;return g((I(),b(j,{shadow:"always","body-style":{padding:"20px"}},{header:a(()=>[J("div",null,[t(S,{modelValue:r(f),"onUpdate:modelValue":e[0]||(e[0]=n=>K(f)?f.value=n:null),class:"ml-4",onChange:P},{default:a(()=>[t(V,{label:0,size:"large"},{default:a(()=>[...e[5]||(e[5]=[i("命令服务",-1)])]),_:1}),t(V,{label:1,size:"large"},{default:a(()=>[...e[6]||(e[6]=[i("参数服务",-1)])]),_:1})]),_:1},8,["modelValue"])])]),default:a(()=>[t(_,{gutter:20},{default:a(()=>[t(s,{span:12,offset:0},{default:a(()=>[t(_,{gutter:20},{default:a(()=>[t(s,{span:23,offset:0},{default:a(()=>[t(C,{ref_key:"distributeFormRef",ref:D,"label-position":"top","label-width":"80px",model:r(d),inline:!1},{default:a(()=>[t(c,{label:"命令字（Control）",prop:"command"},{default:a(()=>[t(u,{modelValue:r(d).inParameter.command,"onUpdate:modelValue":e[1]||(e[1]=n=>r(d).inParameter.command=n)},null,8,["modelValue"])]),_:1}),t(c,{label:"参数（parameter）",prop:"parameter"},{default:a(()=>[t(u,{modelValue:r(d).inParameter.parameter,"onUpdate:modelValue":e[2]||(e[2]=n=>r(d).inParameter.parameter=n),type:"textarea",rows:5,resize:"none"},null,8,["modelValue"])]),_:1})]),_:1},8,["model"])]),_:1}),t(s,{span:1,offset:0,class:"flex justify-center items-center"},{default:a(()=>[t(U,{direction:"vertical",style:{height:"100%"}})]),_:1})]),_:1})]),_:1}),t(s,{span:12,offset:0},{default:a(()=>[t(C,{ref:"form",rules:r(E),"label-width":"80px",inline:!1,"label-position":"top"},{default:a(()=>[t(c,{label:"返回编码（Code）"},{default:a(()=>[t(u,{modelValue:r(m).code,"onUpdate:modelValue":e[3]||(e[3]=n=>r(m).code=n),disabled:!0},null,8,["modelValue"])]),_:1}),t(c,{label:"返回信息（Content）"},{default:a(()=>[t(u,{modelValue:r(m).content,"onUpdate:modelValue":e[4]||(e[4]=n=>r(m).content=n),type:"textarea",resize:"none",rows:5,disabled:!0},null,8,["modelValue"])]),_:1})]),_:1},8,["rules"])]),_:1})]),_:1}),t(_,{gutter:20},{default:a(()=>[t(s,{span:24,offset:0},{default:a(()=>[g((I(),b(v,{type:"primary",size:"default",onClick:R},{default:a(()=>[...e[7]||(e[7]=[i("发送服务",-1)])]),_:1})),[[T,["sys:device:edit"]]]),g((I(),b(v,{type:"primary",size:"default",onClick:k},{default:a(()=>[...e[8]||(e[8]=[i("设备重启",-1)])]),_:1})),[[T,["sys:device:edit"]]]),t(v,{type:"primary",size:"default",onClick:z},{default:a(()=>[...e[9]||(e[9]=[i("获取设备时间",-1)])]),_:1})]),_:1})]),_:1})]),_:1})),[[B,r(x)]])}}});export{le as _};
