import{c as e,s as a,r as t,o as l,q as s,v as o,x as r,e as i,B as n,y as d,C as m,aD as u,T as c,aS as p,ab as f,a9 as v}from"./base-lib.js?v=1761009159";import{_ as y}from"./validator.js?v=1761009159";import{P as b,T as _,k as g,b as h}from"./utils-lib.js?v=1761009159";import{g as j}from"./useStore10.js?v=1761009159";import{L as w,M as x}from"./ssl.js?v=1761009159";import{r as V}from"./useMethod10.js?v=1761009159";import{u as D}from"./useStore11.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";import"./index106.js?v=1761009159";import"./column.js?v=1761009159";const N={class:"p-2rem"},q=e({__name:"index",props:{compData:{default:()=>({isMulti:!1})}},emits:["close"],setup(e,{expose:q,emit:T}){const A=e,M=T,R=h(),{refs:{tabActive:U,isRefreshDomainList:E}}=j(),{activeTabs:I,sslIsRefresh:S,testIsRefresh:k,encryptIsRefresh:C,otherIsRefresh:L}=a(D()),$=t(),B=t(!1),H=l({domain:"",title:"",cycle:30,allSsl:!1,total:2,sender:[]}),P=t({cycle:[{required:!0,message:"请输入剩余天数",trigger:"blur"},{validator:(e,a,t)=>{/^[1-9]\d*$/.test(a)?t():t(new Error("请输入大于0的正整数"))},trigger:["blur","change"]}],total:[{required:!0,message:"请输入总发送上线",trigger:"blur"},{validator:(e,a,t)=>{/^\d+$/.test(a)?t():t(new Error("请输入大于等于0的正整数"))},trigger:["blur","change"]}],sender:[{required:!0,message:"请选择通知方式",trigger:"blur"},{validator:(e,a,t)=>{0===a.length?t(new Error("请选择通知方式")):t()},trigger:["blur","change"]}]});return s(()=>{var e;"domain"===U.value?H.domain=A.compData.domain:(null==(e=A.compData)?void 0:e.isMulti)?(H.title=A.compData.data.map(e=>e.title).join(","),H.domain=A.compData.data.map(e=>!e.domainName||Array.isArray(e.domainName)&&0===e.domainName.length?"":Array.isArray(e.domainName)?e.domainName.join(","):e.domainName).filter(e=>""!==e).join(",")):(H.title=A.compData.title,H.domain=A.compData.domainName.join(",")),b({request:_(),success:({data:e})=>{const a=e.data.find(e=>e.id===A.compData.report_id);a&&(H.sender=a.sender,H.cycle=a.task_data.cycle,H.total=a.number_rule.total)}})}),q({onConfirm:async()=>{var e,a,t;try{if(!(await $.value.validate()))return;if(B.value=!0,null==(e=A.compData)?void 0:e.isMulti){const e=[],a=R.load("正在批量设置告警...");for(const t of A.compData.data)try{const a={cycle:H.cycle,total:H.total,sender:H.sender.join(","),ssl_id:t.ssl_id},l=await x(a);e.push({name:t.title,status:l.status})}catch(l){e.push({name:t.title,status:!1})}a.close();V({resultData:e,resultTitle:"设置告警",resultColumn:[{label:"名称",prop:"name"},{label:"结果",render:e=>{const a=e.status?"设置成功":"设置失败",t=e.status?"text-primary":"text-danger";return u("span",{class:t},a)}}]});const s={ssl:()=>S.value=!0,test:()=>k.value=!0,encrypt:()=>C.value=!0,other:()=>L.value=!0};null==(t=s[I.value])||t.call(s),M("close")}else{let e={cycle:H.cycle,total:H.total,sender:H.sender.join(",")};"domain"===U.value?e.domain=H.domain:e.ssl_id=A.compData.ssl_id;const t="domain"===U.value?await w(e):await x(e);if(R.request(t),t.status){if("domain"===U.value)E.value=!0;else{const e={ssl:()=>S.value=!0,test:()=>k.value=!0,encrypt:()=>C.value=!0,other:()=>L.value=!0};null==(a=e[I.value])||a.call(e)}M("close")}}}catch(s){}finally{B.value=!1}}}),(e,a)=>{const t=c,l=p,s=f,u=g,b=y,_=v;return o(),r("div",N,[i(_,{ref_key:"sslExpire",ref:$,disabled:d(B),rules:d(P),model:d(H),"label-width":"100px"},{default:n(()=>[i(s,{label:"域名"},{default:n(()=>[i(l,{content:d(H).domain,placement:"top","popper-class":"!max-w-[300px]"},{default:n(()=>[i(t,{class:"!w-[28rem]",modelValue:d(H).domain,"onUpdate:modelValue":a[0]||(a[0]=e=>d(H).domain=e),disabled:""},null,8,["modelValue"])]),_:1},8,["content"])]),_:1}),i(s,{label:"证书"},{default:n(()=>[i(l,{content:d(H).title,placement:"top","popper-class":"!max-w-[300px]"},{default:n(()=>[i(t,{class:"!w-[28rem]",modelValue:d(H).title,"onUpdate:modelValue":a[1]||(a[1]=e=>d(H).title=e),disabled:""},null,8,["modelValue"])]),_:1},8,["content"])]),_:1}),i(s,{label:"剩余天数",prop:"cycle"},{default:n(()=>[i(u,{modelValue:d(H).cycle,"onUpdate:modelValue":a[2]||(a[2]=e=>d(H).cycle=e),width:"14rem",textType:"天",min:"1",type:"number"},{append:n(()=>a[5]||(a[5]=[m(" 天 ",-1)])),_:1},8,["modelValue"])]),_:1}),i(s,{label:"总发送上限",prop:"total"},{default:n(()=>[i(u,{modelValue:d(H).total,"onUpdate:modelValue":a[3]||(a[3]=e=>d(H).total=e),width:"14rem",textType:"次",min:"0",type:"number"},{append:n(()=>a[6]||(a[6]=[m(" 次 ",-1)])),_:1},8,["modelValue"])]),_:1}),i(s,{label:"通知方式",prop:"sender"},{default:n(()=>[i(b,{modelValue:d(H).sender,"onUpdate:modelValue":a[4]||(a[4]=e=>d(H).sender=e),limit:["sms"],class:"!w-[28rem]"},null,8,["modelValue"])]),_:1})]),_:1},8,["disabled","rules","model"])])}}});export{q as default};
