import{d as C,k as c,O as F,p as P,m as E,o as m,c as i,a as n,b as t,u as e,B as _,t as k}from"./vue.1703796278973.js";import{I as G,r as W,av as $,a5 as z,a6 as A,cE as H,k as K,aG as Q,aw as X,F as Y,W as Z}from"./index.17037962789732.js";import"./index.170379627897337.js";import"./index.170379627897315.js";import"./index.170379627897318.js";import"./index.170379627897319.js";import"./index.170379627897314.js";import"./index.1703796278973301.js";import"./index.170379627897325.js";import"./index.170379627897316.js";import"./index.170379627897317.js";import"./index.170379627897327.js";import{q as ee,f as ae}from"./firmware.1703796278973.js";import oe from"./SelectDevices.1703796278973.js";const te=C({name:"TaskPage"}),ge=C({...te,props:{data:{type:Object,default:()=>{}}},emits:["change"],setup(f,{emit:v}){const g=f,y=c(),w=F(),b=c(!1),x=c([]),I=w.query.id,S=w.query.productId,d=g.data.view,a=c({name:"",mode:void 0,responseTimeoutSeconds:"",timeoutSeconds:"",releaseType:"all",deviceId:void 0,description:""}),j={name:[{required:!0,message:"请输入任务名称"},{max:64,message:"最多可输入64个字符"}],mode:[{required:!0,message:"请选择推送方式"}],responseTimeoutSeconds:[{required:!0,message:"请输入响应超时时间"}],timeoutSeconds:[{required:!0,message:"请输入升级超时时间"}],releaseType:[{required:!0}],deviceId:[{required:!0,message:"请选择设备"}],description:[{max:200,message:"最多可输入200个字符"}]},q=(s,o)=>o.label.toLowerCase().indexOf(s.toLowerCase())>=0,O=async()=>{var p;const s=await((p=y.value)==null?void 0:p.validate());b.value=!0;const o=await ae({...s,firmwareId:I,productId:S});b.value=!1,o.success&&v("change",!0)},U=()=>d?v("change",!1):O(),V=()=>{v("change",!1)},R=()=>{a.value.deviceId=void 0};return P(()=>{ee({paging:!1,terms:[{column:"state",value:1}],sorts:[{name:"createTime",order:"desc"}]}).then(s=>{x.value=s.result.map(o=>({value:o.id,label:o.name}))})}),E(()=>g.data,s=>{s.id&&(a.value={...s,mode:s.mode.value,releaseType:s!=null&&s.deviceId?"part":"all"})},{immediate:!0,deep:!0}),(s,o)=>{const p=G,r=W,u=$,J=z,h=A,T=H,N=K,B=Q,L=X,M=Y,D=Z;return m(),i(D,{title:f.data.id?"查看":"新增任务","ok-text":"确认","cancel-text":"取消",visible:!0,width:"700px","confirm-loading":e(b),onCancel:V,onOk:U},{default:n(()=>[t(M,{class:"form",layout:"vertical",model:e(a),name:"basic",autocomplete:"off",ref_key:"formRef",ref:y,rules:j},{default:n(()=>[t(L,{gutter:[24,0]},{default:n(()=>[t(u,{span:24},{default:n(()=>[t(r,{label:"任务名称",name:"name"},{default:n(()=>[t(p,{placeholder:"请输入任务名称",value:e(a).name,"onUpdate:value":o[0]||(o[0]=l=>e(a).name=l),disabled:e(d)},null,8,["value","disabled"])]),_:1})]),_:1}),t(u,{span:24},{default:n(()=>[t(r,{label:"推送方式",name:"mode"},{default:n(()=>[t(J,{value:e(a).mode,"onUpdate:value":o[1]||(o[1]=l=>e(a).mode=l),options:[{label:"平台推送",value:"push"},{label:"设备拉取",value:"pull"}],placeholder:"请选择推送方式",allowClear:"","show-search":"","filter-option":q,onChange:s.changeMode,disabled:e(d)},null,8,["value","onChange","disabled"])]),_:1})]),_:1}),e(a).mode==="push"?(m(),i(u,{key:0,span:12},{default:n(()=>[t(r,{label:"响应超时时间",name:"responseTimeoutSeconds"},{default:n(()=>[t(h,{placeholder:"请输入响应超时时间(秒)",style:{width:"100%"},min:1,max:99999,disabled:e(d),value:e(a).responseTimeoutSeconds,"onUpdate:value":o[2]||(o[2]=l=>e(a).responseTimeoutSeconds=l)},null,8,["disabled","value"])]),_:1})]),_:1})):_("",!0),e(a).mode==="push"||e(a).mode==="pull"?(m(),i(u,{key:1,span:e(a).mode==="push"?12:24},{default:n(()=>[t(r,{label:"升级超时时间",name:"timeoutSeconds"},{default:n(()=>[t(h,{placeholder:"请输入升级超时时间(秒)",style:{width:"100%"},min:1,max:99999,disabled:e(d),value:e(a).timeoutSeconds,"onUpdate:value":o[3]||(o[3]=l=>e(a).timeoutSeconds=l)},null,8,["disabled","value"])]),_:1})]),_:1},8,["span"])):_("",!0),e(a).mode?(m(),i(u,{key:2,span:12},{default:n(()=>[t(r,{label:"升级设备",name:"releaseType"},{default:n(()=>[t(N,{value:e(a).releaseType,"onUpdate:value":o[4]||(o[4]=l=>e(a).releaseType=l),"button-style":"solid",onChange:R,disabled:e(d)},{default:n(()=>[t(T,{value:"all"},{default:n(()=>[k("所有设备")]),_:1}),t(T,{value:"part"},{default:n(()=>[k("选择设备")]),_:1})]),_:1},8,["value","disabled"])]),_:1})]),_:1})):_("",!0),e(a).releaseType==="part"?(m(),i(u,{key:3,span:12},{default:n(()=>[t(r,{label:"选择设备",name:"deviceId"},{default:n(()=>[t(oe,{modelValue:e(a).deviceId,"onUpdate:modelValue":o[5]||(o[5]=l=>e(a).deviceId=l),data:f.data},null,8,["modelValue","data"])]),_:1})]),_:1})):_("",!0),t(u,{span:24},{default:n(()=>[t(r,{label:"说明",name:"description"},{default:n(()=>[t(B,{placeholder:"请输入说明",value:e(a).description,"onUpdate:value":o[6]||(o[6]=l=>e(a).description=l),maxlength:200,rows:3,showCount:"",disabled:e(d)},null,8,["value","disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["model"])]),_:1},8,["title","confirm-loading"])}}});export{ge as _};
