import{d as S,O as N,k as _,v as O,r as U,o as y,c as B,a as l,z as i,b as n,u as a,t as D,x as L,A as b,B as P,G as q,H as A}from"./vue.1703796278973.js";import{M as G,Y as z,I as J,r as E,aG as H,F as Q,W}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{R as Y,M as $,I as K,a as X}from"./rules.1703796278973.js";import Z from"./UploadFile.17037962789732.js";import{v as ee,u as ae,b as te}from"./plugin.17037962789733.js";import{_ as oe}from"./_plugin-vue_export-helper.1703796278973.js";const ne={deviceGateway:"设备接入网关",thingsManager:"物管理"},I=s=>(q("data-v-a7475f60"),s=s(),A(),s),se={key:0,class:"file-detail"},le=I(()=>i("span",null,"插件类型：",-1)),ie={class:"file-detail-item"},de=I(()=>i("span",null,"版本：",-1)),re={class:"file-detail-item"},ce=S({name:"PluginSave"}),ue=S({...ce,props:{data:{type:Object,default:()=>({})}},emits:["cancel","ok"],setup(s,{emit:f}){const o=s,w=N(),p=_();_(o.data.type);const m=_(!1),h=async(r,t)=>{if(!o.data.id&&t){const c=await ee(t);if(c.success&&c.result&&!c.result.passed)return Promise.reject("ID重复")}return Promise.resolve()},x=[Y("插件名称"),...$],j=[...K,{validator:h,trigger:"blur"}],e=O({id:o.data.id,name:o.data.name,description:o.data.description,type:o.data.type,provider:o.data.provider||"jar",version:o.data.version,filename:o.data.filename,configuration:o.data.configuration||{}}),C=r=>{e.type=r.type.value,e.filename=r.filename,e.configuration.location=r.accessUrl},k=async()=>{if(await p.value.validate()){m.value=!0;const t=o.data.id?await ae(e).catch(()=>{}):await te(e).catch(()=>{});if(m.value=!1,t.success){if(G.success("操作成功！"),w.query.save&&window.onTabSaveSuccess){window.onTabSaveSuccess(t),setTimeout(()=>window.close(),300);return}f("ok"),p.value.resetFields()}}},M=()=>{f("cancel")};return(r,t)=>{var g;const c=U("AIcon"),R=z,v=J,u=E,T=H,V=Q,F=W;return y(),B(F,{maskClosable:!1,visible:!0,title:(g=s.data)!=null&&g.id?"编辑":"新增",confirmLoading:a(m),onOk:k,onCancel:M,width:"650px"},{default:l(()=>[i("div",null,[n(V,{layout:"vertical",ref_key:"formRef",ref:p,model:a(e)},{default:l(()=>[n(u,{name:"id",rules:j},{label:l(()=>[i("span",null,[D(" 插件ID "),n(R,{title:"若不填写，系统将自动生成唯一ID"},{default:l(()=>[n(c,{type:"QuestionCircleOutlined",style:{"margin-left":"2px"}})]),_:1})])]),default:l(()=>[n(v,{value:a(e).id,"onUpdate:value":t[0]||(t[0]=d=>a(e).id=d),disabled:!!s.data.id},null,8,["value","disabled"])]),_:1}),n(u,{label:"插件名称",name:"name",rules:x},{default:l(()=>[n(v,{value:a(e).name,"onUpdate:value":t[1]||(t[1]=d=>a(e).name=d)},null,8,["value"])]),_:1}),n(u,{label:"文件",name:"version",rules:[{required:!0,message:"请上传文件"}]},{default:l(()=>[n(Z,{modelValue:a(e).version,"onUpdate:modelValue":t[2]||(t[2]=d=>a(e).version=d),onChange:C,fileName:s.data.filename},null,8,["modelValue","fileName"])]),_:1}),a(e).version?(y(),L("div",se,[i("div",null,[le,i("span",ie,b(a(ne)[a(e).type]),1)]),i("div",null,[de,i("span",re,b(a(e).version),1)])])):P("",!0),n(u,{label:"说明",name:"describe",rules:a(X)},{default:l(()=>[n(T,{value:a(e).description,"onUpdate:value":t[3]||(t[3]=d=>a(e).description=d),placeholder:"请输入说明",showCount:"",maxlength:200},null,8,["value"])]),_:1},8,["rules"])]),_:1},8,["model"])])]),_:1},8,["title","confirmLoading"])}}});const pe=oe(ue,[["__scopeId","data-v-a7475f60"]]),xe=Object.freeze(Object.defineProperty({__proto__:null,default:pe},Symbol.toStringTag,{value:"Module"}));export{pe as S,ne as T,xe as a};
