import{I as w,r as O,F as x,W as C}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 S from"./TriggerWay.1703796278973.js";import{m as V,s as F}from"./scene.17037962789732.js";import{h as M}from"./system.1703796278973.js";import{d as q,k as f,v as B,w as I,l as g,o as R,c as T,a as m,b as l,u as o}from"./vue.1703796278973.js";const A=q({__name:"save",props:{data:{type:Object,default:()=>({})}},emits:["close"],setup(_,{emit:c}){const t=_,d=f(!1),v=M(),s=B({name:"",trigger:{type:"device"}}),u=f();I(()=>{Object.assign(s,t.data)});const y=g(()=>{var a;return(a=t.data)!=null&&a.id?"编辑":"新增"}),b=g(()=>{var a;return!!((a=t.data)!=null&&a.id)}),j=async()=>{var a;if(u.value){const e=await u.value.validateFields();let n={...e};t.data.id&&(n={...t.data,name:e.name}),d.value=!0;const r=t.data.id?await V(t.data.id,n):await F(n);if(d.value=!1,r.success){c("close");const p=((a=t.data)==null?void 0:a.id)||r.result.id;v.jumpPage("rule-engine/Scene/Save",{},{triggerType:e.trigger.type,id:p})}}};return(a,e)=>{const n=w,r=O,p=x,k=C;return R(),T(k,{visible:"",title:o(y),width:750,"confirm-loading":o(d),maskClosable:!1,onCancel:e[2]||(e[2]=i=>c("close")),onOk:j},{default:m(()=>[l(p,{layout:"vertical",name:"scene-save",ref_key:"formRef",ref:u,model:o(s)},{default:m(()=>[l(r,{name:"name",label:"名称",rules:[{required:!0,message:"请输入名称"},{max:64,message:"最多输入64个字符"}]},{default:m(()=>[l(n,{value:o(s).name,"onUpdate:value":e[0]||(e[0]=i=>o(s).name=i),placeholder:"请输入名称"},null,8,["value"])]),_:1}),l(r,{name:["trigger","type"],label:"触发方式",rules:[{required:!0,message:"请选择触发方式"}]},{default:m(()=>[l(S,{modelValue:o(s).trigger.type,"onUpdate:modelValue":e[1]||(e[1]=i=>o(s).trigger.type=i),disabled:o(b)},null,8,["modelValue","disabled"])]),_:1})]),_:1},8,["model"])]),_:1},8,["title","confirm-loading"])}}});export{A as _};
