import{_ as U,i as Y,G as E,q,s as G,a4 as L,bx as K,c as i,d as c,h as b,x as H,f as A,g as t,w as g,j as R,t as f,F as S,y as J,m as M,e as $,n as O,by as Q,bz as W,bA as X,K as Z,bB as ee}from"./index-BV0H45HW.js";import"./index-Cls4hH_L.js";import"./index-BtHEBb5f.js";import{B as te}from"./index-CBHeC2k-.js";import{E as se}from"./index-BtVQ9BrO.js";import{C as ae}from"./index-B7M1Z4gS.js";import{T as oe}from"./index-Bhp-rQj1.js";import{g as ne,A as le}from"./constant-CIpX6aJ1.js";import{D as ce}from"./index-BEBlKc1d.js";import"./use-id-B-gQUfBT.js";const re={key:0,class:"button-container"},ie={key:1,class:"tools"},de={class:"item-title"},me={key:0,class:"van-badge van-badge--top-left van-badge--dot van-badge--fixed"},fe={key:2},ue={class:"van-dialog__message van-dialog__message--has-title"},ge={key:0,class:"suggestion"},pe={key:0},_e={key:1},he={__name:"index",setup(ye){const n=Y.global.t;let v=E("getAlarms"),p=E("alarmList"),e=q({show:!1,loading:!0,feedItem:{}});const w=ne(le);async function V(s){var a,l,d;if(e.show=!0,e.feedItem=s,s.choices.length>0){if(!s.result)e.feedItem.confirmButtonText=(a=s.choices[0])==null?void 0:a.choice,e.feedItem.cancelButtonText=(l=s.choices[1])==null?void 0:l.choice;else{let r=s.choices;e.feedItem.resultText=(d=r.find(m=>m.index===s.feedback))==null?void 0:d.choice,console.error("state.feedItem.resultText ",r,s.feedback)}return}}let u;async function N(s){var l,d,r,m,x,k;if(((l=e.feedItem)==null?void 0:l.type)==1){if((d=e.feedItem)!=null&&d.isRead){e.show=!1,e.feedItem={};return}await W({alarmId:e.feedItem.id,timestamp:e.feedItem.timestamp}),v()}if((r=e.feedItem)!=null&&r.result){e.show=!1,e.feedItem={};return}const a={alarmId:(m=e.feedItem)==null?void 0:m.id};((k=(x=e.feedItem)==null?void 0:x.choices)==null?void 0:k.length)>0?a.choiceIndex=s==="confirm"?e.feedItem.choices[0].index:e.feedItem.choices[1].index:a.choiceIndex=1;try{const{code:_}=await X(a);u=T({type:"success",message:n("messagetranslate.processSuccess")}),e.show=!1,e.feedItem={},v()}catch(_){console.error(n("messagetranslate.processFailed"),_)}}const T=s=>{const{type:a,message:l}=s;Z({type:a,message:l,position:"bottom",className:"bottom-notify"})};async function B(){if(p.value.length!==0)try{const{code:s}=await Q();u=T({type:"success",message:n("messagetranslate.clearSuccess")}),v()}catch(s){console.error(n("messagetranslate.clearFailed"),s)}}async function z(){if(p.value.length!==0)try{const{code:s}=await ee();u=T({type:"success",message:n("messagetranslate.markAllAsReadSuccess")}),v()}catch(s){console.error(n("messagetranslate.markAllAsReadFailed"),s)}}function P(s){if(!s)return"-";let a=s.split("T")[0],l=s.split("T")[1].split(".")[0],[d,r,m]=a.split("-");return`${r}/${m} ${l}`}function j(){L.on("clear-alarm",B)}return j(),G(()=>{u==null||u.close(),L.off("clear-alarm",B)}),(s,a)=>{var _,D,F;const l=te,d=oe,r=ae,m=se,x=ce,k=K("loading");return c(),i(S,null,[t(p).length>0?(c(),i("div",re,[A(l,{type:"default",icon:"passed",gray:"",onClick:z},{default:g(()=>[R(f(t(n)("messagetranslate.markAllAsRead")),1)]),_:1}),A(l,{type:"default",icon:"delete-o",gray:"",onClick:B},{default:g(()=>[R(f(t(n)("messagetranslate.clearAll")),1)]),_:1})])):b("",!0),t(p).length?H((c(),i("div",ie,[(c(!0),i(S,null,J(t(p),o=>{var h,y,I;return c(),M(r,{key:o.id,onClick:C=>V(o),style:O({background:(h=t(w).get(o.level))==null?void 0:h.background,color:(y=t(w).get(o.level))==null?void 0:y.color}),"is-link":"",label:P(o.timestamp),icon:(I=t(w).get(o.level))==null?void 0:I.icon},{title:g(()=>[$("div",de,[$("span",null,f(o.title||"-"),1),o.isRead?b("",!0):(c(),i("i",me))])]),value:g(()=>[o.type!=1&&!o.result?(c(),M(d,{key:0,type:"primary",size:"medium"},{default:g(()=>[R(f(t(n)("messagetranslate.pending")),1)]),_:1})):b("",!0)]),_:2},1032,["onClick","style","label","icon"])}),128))])),[[k,t(e).loading]]):(c(),i("div",fe,[A(m,{description:t(n)("messagetranslate.noData")},null,8,["description"])])),A(x,{show:t(e).show,"onUpdate:show":a[0]||(a[0]=o=>t(e).show=o),title:`${t(n)("messagetranslate.warning")}：${t(e).feedItem.alarmCode||"-"}`,message:t(e).feedItem.title,cancelButtonText:t(e).feedItem.cancelButtonText,confirmButtonText:t(e).feedItem.confirmButtonText,onCancel:a[1]||(a[1]=o=>N("cancel")),onConfirm:a[2]||(a[2]=o=>N("confirm")),"show-cancel-button":((D=(_=t(e).feedItem)==null?void 0:_.choices)==null?void 0:D.length)>0&&!((F=t(e).feedItem)!=null&&F.result)},{default:g(()=>{var o,h,y,I,C;return[$("div",ue,f(t(e).feedItem.title),1),((o=t(e).feedItem)==null?void 0:o.type)!==1&&((y=(h=t(e).feedItem)==null?void 0:h.choices)==null?void 0:y.length)>0?(c(),i("div",ge,[(I=t(e).feedItem)!=null&&I.result?(c(),i("p",_e,f(t(n)("messagetranslate.result"))+f((C=t(e).feedItem)==null?void 0:C.resultText),1)):(c(),i("p",pe,f(t(n)("messagetranslate.suggestion")),1))])):b("",!0)]}),_:1},8,["show","title","message","cancelButtonText","confirmButtonText","show-cancel-button"])],64)}}},Re=U(he,[["__scopeId","data-v-2e255e64"]]);export{Re as default};
