import{a5 as B,J as q,r as x,o as i,c as p,v as h,y as v,q as o,P as f,x as _,t as y,p as r,F as C,A as E,n as T,l as J,cp as F,E as R,i as j,cq as P,D as z}from"./index.8d733f79.js";import{E as G}from"./el-input-number.60463ef8.js";import{m as H,n as K}from"./setValue.1d09ba51.js";import"./index.28f6da25.js";const M={style:{"margin-bottom":"20px"}},Q=B({name:"deviceContent"}),le=Object.assign(Q,{setup(W,{expose:V}){const{proxy:s}=z(),g=q.session.getJSON("userInfo").userLevel!==0,t=x([]);let u;const L=[{desc:"\u7EDD\u5BF9\u503C\u62A5\u8B66",key:"abs"},{desc:"\u53D8\u5316\u7387\u62A5\u8B66",key:"roc"},{desc:"\u8D8B\u52BF\u62A5\u8B66",key:"trend"},{desc:"\u5206\u9891\u6BB5\u62A5\u8B66",key:"freq"}],$=[{desc:"\u6307\u6807\u7EA7",key:2},{desc:"\u6D4B\u70B9\u7EA7",key:1},{desc:"\u8BBE\u5907\u7EA7",key:0}],w=()=>{K({deviceId:u}).then(e=>{t.value=e.data})},D=()=>{if(t.value.length===4){s.$modal.msgError("\u65B0\u589E\u6761\u6570\u5DF2\u8FBE\u4E0A\u9650");return}t.value.push({alarmTypeList:[],intervalLevel:null,intervalTime:null})},I=e=>{s.$modal.confirm("\u662F\u5426\u786E\u8BA4\u5220\u9664?").then(()=>{t.value=t.value.filter(a=>a!==e)}).catch(()=>{})},N=()=>{if(m("intervalTime")){s.$modal.msgError("\u8BF7\u8F93\u5165\u63D0\u793A\u95F4\u9694\uFF08min\uFF09");return}if(m("alarmTypeList")){s.$modal.msgError("\u8BF7\u9009\u62E9\u62A5\u8B66\u7C7B\u578B");return}if(m("intervalLevel")){s.$modal.msgError("\u8BF7\u9009\u62E9\u9002\u7528\u7C7B\u578B\u5FC5\u586B");return}if(A("alarmTypeList")){s.$modal.msgError("\u62A5\u8B66\u7C7B\u578B\u4E0D\u80FD\u91CD\u590D\u9009\u62E9");return}const e={deviceId:u,informIntervalConfigCommands:t.value};H(e).then(a=>{a.code===200&&s.$modal.msgSuccess(a.msg)})},A=e=>{const a=[];return t.value.forEach(c=>{a.push(...c[e])}),a.length!==[...new Set(a)].length},m=e=>t.value.some(a=>a[e]===null||JSON.stringify(a[e])==="[]");function O(e){u=e.deviceId,w()}return V({initData:O}),(e,a)=>{const c=J,S=G,d=F,k=R,b=j,U=P;return i(),p("div",null,[h("div",M,[g?(i(),v(c,{key:0,type:"primary",onClick:D},{default:o(()=>[f(_(e.$t("add")),1)]),_:1})):y("",!0),g?(i(),v(c,{key:1,type:"primary",onClick:N},{default:o(()=>[f(_(e.$t("save")),1)]),_:1})):y("",!0)]),h("div",null,[r(U,{data:T(t)},{default:o(()=>[r(d,{prop:"intervalTime",label:"\u63D0\u793A\u95F4\u9694\uFF08min\uFF09"},{default:o(n=>[r(S,{modelValue:n.row.intervalTime,"onUpdate:modelValue":l=>n.row.intervalTime=l,precision:0,max:99999,min:1,controls:!1},null,8,["modelValue","onUpdate:modelValue"])]),_:1}),r(d,{prop:"alarmTypeList",label:"\u62A5\u8B66\u7C7B\u578B"},{default:o(n=>[r(b,{modelValue:n.row.alarmTypeList,"onUpdate:modelValue":l=>n.row.alarmTypeList=l,multiple:"",placeholder:"\u8BF7\u9009\u62E9\u62A5\u8B66\u7C7B\u578B",style:{width:"80%"}},{default:o(()=>[(i(),p(C,null,E(L,l=>r(k,{key:l.key,label:l.desc,value:l.key},null,8,["label","value"])),64))]),_:2},1032,["modelValue","onUpdate:modelValue"])]),_:1}),r(d,{prop:"intervalLevel",label:"\u9002\u7528\u7C7B\u578B"},{default:o(n=>[r(b,{modelValue:n.row.intervalLevel,"onUpdate:modelValue":l=>n.row.intervalLevel=l,placeholder:"\u8BF7\u9009\u62E9\u9002\u7528\u7C7B\u578B"},{default:o(()=>[(i(),p(C,null,E($,l=>r(k,{key:l.key,label:l.desc,value:l.key},null,8,["label","value"])),64))]),_:2},1032,["modelValue","onUpdate:modelValue"])]),_:1}),r(d,{label:e.$t("action")},{default:o(n=>[T(t).length>1?(i(),v(c,{key:0,link:"",type:"danger",onClick:l=>I(n.row)},{default:o(()=>[f(_(e.$t("delete")),1)]),_:2},1032,["onClick"])):y("",!0)]),_:1},8,["label"])]),_:1},8,["data"])])])}}});export{le as default};
