import{b as D,r as p,ah as O,aH as H,n as o,o as c,c as _,p as r,q as n,v as P,P as x,x as k,y as I,F as L,A as C,t as E,s as j,cr as G,ee as z,S as v,E as J,i as K,k as Q,aE as W,c6 as X,m as Y,l as Z,bv as ee,bH as te,D as ae}from"./index.8d733f79.js";import{t as oe}from"./index.26573f78.js";import{v as le}from"./setValue.1d09ba51.js";import"./el-text.54dc8292.js";import"./deviceTree.170dfbd9.js";import"./searchStore.0c98fb50.js";const re={"element-loading-background":"rgba(0,0,0,0.4)"},ne={key:0,style:{width:"360px",height:"260px"}},pe={__name:"exportModal",setup(se,{expose:V}){const{t:i}=D(),{proxy:b}=ae(),s=p(!1),e=O({factoryId:"",nodeIds:[],alarmTypeList:["abs"]}),w=[{name:i("absAlarm"),identifier:"abs"},{name:i("changeRateAlarm"),identifier:"roc"},{name:i("trendAlarm"),identifier:"trend"},{name:i("divideBandAlarm"),identifier:"freq"}],F={factoryId:[{required:!0,message:""}],nodeIds:[{required:!0,message:""}],alarmTypeList:[{required:!0,message:""}]},m=p(!1),y=p([]),f=p([]),S=()=>{s.value=!0,e.factoryId="",f.value=[],T()};async function T(){const d=await G();y.value=d.data}const B=async()=>{z([e.factoryId]).then(d=>{f.value=d.data})},R=()=>{var a;if(console.log("submit!",e),!e.factoryId){v.error("\u8BF7\u5148\u9009\u62E9\u5DE5\u5382");return}if(e.nodeIds=((a=b.$refs.treeSearchRef)==null?void 0:a.getCheckedFn())||[],!e.nodeIds.length){v.error("\u8BF7\u9009\u62E9\u6570\u636E\u8BBE\u5907\u8303\u56F4");return}if(!e.alarmTypeList.length){v.error("\u8BF7\u9009\u62E9\u62A5\u8B66\u7C7B\u578B");return}m.value=!0;const d=y.value.find(u=>u.id===e.factoryId).name;le(e).then(u=>{m.value=!1,s.value=!1,b.$modal.msgSuccess(i("exportSuccess"));const g=new Blob([u]),l=document.createElement("a");l.href=URL.createObjectURL(g),l.download=`${d}-\u62A5\u8B66\u9608\u503C\u6570\u636E\u6E05\u5355.xlsx`,l.style.display="none",document.body.appendChild(l),l.click(),l.remove()}).catch(()=>{m.value=!1,s.value=!1})};return V({showModal:S}),(d,a)=>{const u=J,g=K,l=Q,A=oe,N=W,U=X,$=Y,h=Z,q=ee,M=te;return H((c(),_("div",re,[r(q,{title:"\u5BFC\u51FA\u6570\u636E\u6E05\u5355",modelValue:o(s),"onUpdate:modelValue":a[3]||(a[3]=t=>j(s)?s.value=t:null),width:"600","align-center":!0,"close-on-click-modal":!1,class:"exportConfig_dialog"},{footer:n(()=>[P("div",null,[r(h,{onClick:a[2]||(a[2]=t=>s.value=!1)},{default:n(()=>[x(k(d.$t("cancel")),1)]),_:1}),r(h,{type:"primary",onClick:R},{default:n(()=>[x(k(d.$t("confirm")),1)]),_:1})])]),default:n(()=>[o(s)?(c(),I($,{key:0,ref:"ruleFormRef",model:o(e),rules:F},{default:n(()=>[r(l,{label:"\u5DE5\u5382\u9009\u62E9",prop:"factoryId","label-width":"105px"},{default:n(()=>[r(g,{modelValue:o(e).factoryId,"onUpdate:modelValue":a[0]||(a[0]=t=>o(e).factoryId=t),filterable:"",style:{width:"360px"},onChange:B,teleported:!1},{default:n(()=>[(c(!0),_(L,null,C(o(y),t=>(c(),I(u,{key:t.id,label:t.name,value:t.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),r(l,{label:"\u6570\u636E\u8303\u56F4\u6E05\u5355",prop:"nodeIds"},{default:n(()=>[o(f).length?(c(),_("div",ne,[r(A,{showCheckbox:"",ref:"treeSearchRef",treeList:o(f),factorySelect:!0},null,8,["treeList"])])):E("",!0)]),_:1}),r(l,{label:"\u62A5\u8B66\u7C7B\u578B",prop:"alarmTypeList",style:{"margin-bottom":"10px"}},{default:n(()=>[r(U,{modelValue:o(e).alarmTypeList,"onUpdate:modelValue":a[1]||(a[1]=t=>o(e).alarmTypeList=t)},{default:n(()=>[(c(),_(L,null,C(w,t=>r(N,{key:t.identifier,value:t.identifier,label:t.name},null,8,["value","label"])),64))]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["model"])):E("",!0)]),_:1},8,["modelValue"])])),[[M,o(m),void 0,{fullscreen:!0,lock:!0}]])}}};export{pe as default};
