import{M as L,I as U,r as M,av as N,a5 as V,aw as $,a1 as z,k as J,aG as O,F as E}from"./index.17037962789732.js";import"./index.170379627897318.js";import"./index.170379627897319.js";import{_ as G}from"./index.vue_vue_type_script_setup_true_name_PermissionButton_lang.1703796278973.js";import"./index.170379627897314.js";import"./index.170379627897315.js";import"./index.1703796278973301.js";import"./index.170379627897316.js";import"./index.170379627897317.js";import"./index.170379627897327.js";import{d as H,g as K,u as Q,s as W}from"./configuration.1703796278973.js";import{q as X}from"./config.1703796278973.js";import{e as Y}from"./scene.17037962789732.js";import{a as Z}from"./comm.1703796278973.js";import{h as ee}from"./system.1703796278973.js";import{d as te,O as ae,k as p,s as oe,m as le,r as ne,o as c,c as C,a as r,z as f,b as n,u as o,x as se,F as re,h as ue,t as T,A as ie}from"./vue.1703796278973.js";import{a as me}from"./alarm.1703796278973.js";import{_ as pe}from"./_plugin-vue_export-helper.1703796278973.js";import"./index.17037962789733.js";import"./dayjs.min.1703796278973.js";import"./isArray.1703796278973.js";import"./editor.api.1703796278973.js";import"./preload-helper.1703796278973.js";import"./monaco.contribution.1703796278973.js";import"./index.170379627897320.js";import"./index.170379627897321.js";import"./permission.1703796278973.js";import"./index.170379627897332.js";import"./index.170379627897333.js";import"./index.170379627897334.js";import"./default.1703796278973.js";import"./consts.1703796278973.js";import"./404.1703796278973.js";const _e={style:{"text-align":"center","margin-top":"10px","font-size":"15px",width:"90%"}},de=["src"],ce=te({__name:"index",setup(fe){const m=ae();let v=p(!1);const j=me();let{configurationData:g}=oe(j);const y=()=>{var a,e;(a=m.query)!=null&&a.id&&H((e=m.query)==null?void 0:e.id).then(l=>{var t;l.status===200&&(s.value=l==null?void 0:l.result,g.value.current=l.result,Y({terms:[{terms:[{column:"id",termType:"alarm-bind-rule",value:(t=m.query)==null?void 0:t.id}],type:"and"}],sorts:[{name:"createTime",order:"desc"}]}).then(i=>{var d;i.status===200&&(v.value=!!((d=i.result.data)!=null&&d.length))}))})},w={name:[{required:!0,message:"请输入名称"},{max:64,message:"最多输入64个字符"}],targetType:[{required:!0,message:"请选择类型"}],level:[{required:!0,message:"请选择级别"}],description:[{max:200,message:"最多可输入200个字符"}]};let s=p({level:"",targetType:"",name:"",description:""}),x=p(),b=p(),_=p(!1);const h=p(),S=ee();(async()=>{let a=await K();a.status===200&&(x.value=a.result.map(e=>({label:e.name,value:e.id})))})(),(()=>{X().then(a=>{var e,l;a.status===200&&(b.value=(l=(e=a.result)==null?void 0:e.levels)==null?void 0:l.filter(t=>(t==null?void 0:t.level)&&(t==null?void 0:t.title)).map(t=>({label:t.title,value:t.level})))})})();const k=async()=>{_.value=!0,h.value.validate().then(async()=>{var e,l,t,i;const a=(e=m.query)!=null&&e.id?await Q(s.value):await W(s.value);a.status===200&&(L.success("操作成功,请配置关联的场景联动"),_.value=!1,(l=a.result)!=null&&l.id&&S.jumpPage("rule-engine/Alarm/Configuration/Save",{},{id:(t=a.result)==null?void 0:t.id}),(i=m.query)!=null&&i.id||(g.value.current=a.result))}).catch(a=>{_.value=!1,console.log(a)})};return y(),le(()=>{var a;return(a=m.query)==null?void 0:a.id},()=>{y()}),(a,e)=>{const l=U,t=M,i=N,d=V,B=$,F=z,A=J,P=O,R=G,D=E,I=ne("FullPage");return c(),C(I,null,{default:r(()=>[f("div",null,[n(D,{layout:"vertical",rules:w,model:o(s),ref_key:"formRef",ref:h},{default:r(()=>[n(B,{gutter:24},{default:r(()=>[n(i,{span:12},{default:r(()=>[n(t,{label:"名称",name:"name"},{default:r(()=>[n(l,{placeholder:"请输入名称",value:o(s).name,"onUpdate:value":e[0]||(e[0]=u=>o(s).name=u)},null,8,["value"])]),_:1})]),_:1}),n(i,{span:12},{default:r(()=>[n(t,{label:"类型",name:"targetType"},{default:r(()=>[n(d,{options:o(x),value:o(s).targetType,"onUpdate:value":e[1]||(e[1]=u=>o(s).targetType=u),disabled:o(v)},null,8,["options","value","disabled"])]),_:1})]),_:1})]),_:1}),n(t,{label:"级别",name:"level"},{default:r(()=>[n(A,{value:o(s).level,"onUpdate:value":e[2]||(e[2]=u=>o(s).level=u),class:"levelSelect"},{default:r(()=>[(c(!0),se(re,null,ue(o(b),(u,q)=>(c(),C(F,{key:q,value:u.value},{default:r(()=>[f("div",_e,[f("img",{src:o(Z)(`/alarm/alarm${q+1}.png`),style:{height:"40px"},alt:""},null,8,de),T(ie(u.label),1)])]),_:2},1032,["value"]))),128))]),_:1},8,["value"])]),_:1}),n(t,{label:"说明",name:"description"},{default:r(()=>[n(P,{value:o(s).description,"onUpdate:value":e[3]||(e[3]=u=>o(s).description=u),showCount:"",maxlength:200},null,8,["value"])]),_:1}),n(R,{type:"primary",loading:o(_),onClick:k,hasPermission:["rule-engine/Alarm/Configuration:add","rule-engine/Alarm/Configuration:update"]},{default:r(()=>[T("保存")]),_:1},8,["loading"])]),_:1},8,["model"])])]),_:1})}}});const Xe=pe(ce,[["__scopeId","data-v-c87b4fa2"]]);export{Xe as default};
