import{_ as E,b as G,r as y,ah as B,Z as R,e as T,f1 as I,o as c,c as C,v as p,x as h,p as o,q as r,P as $,n as x,N,y as D,t as w,S as b,d5 as U,f2 as q,l as z,k as F,j,m as A,a0 as Z,a1 as H}from"./index.8d733f79.js";import{E as J}from"./el-input-number.60463ef8.js";import"./index.28f6da25.js";const v=u=>(Z("data-v-31cdd62d"),u=u(),H(),u),K={class:"storage-config-container"},L={class:"page-title",style:{display:"block",color:"#fff"}},O={style:{margin:"0 8px"}},Q=v(()=>p("span",{style:{"margin-left":"8px"}},"GB",-1)),W=v(()=>p("span",{style:{"margin-left":"8px"}},"GB",-1)),X=v(()=>p("span",{style:{"margin-left":"8px"}},"GB",-1)),Y={key:2,style:{"margin-left":"8px"}},tt={key:3,style:{color:"red","font-size":"14px","margin-left":"8px",height:"30px","line-height":"30px"}},at={__name:"DataSaveRules",setup(u){const{t:d}=G(),M=y(),f=y(!1),g=y(12),a=B({storagePeriod:0,totalCapacity:0,remainingCapacity:0,lastMonthGrowth:0}),k=y([]),P={storagePeriod:[{required:!0,message:d("pleaseEnterDataStoragePeriod"),trigger:"blur"},{type:"number",min:12,max:120,message:d("pleaseEnter12To120Integer"),trigger:"blur"}]},_=R(()=>{let e=0,t=0;k.value.forEach(s=>{e+=s.coefficient*s.pointCount,t+=s.pointCount});const l=800+Math.floor(Math.max(0,t-500)/500)*200;return a.storagePeriod*30*e/1024+l});T(()=>{I().then(e=>{if(e.data){const t=e.data,l=t.retentionDays?t.retentionDays/30:12;a.storagePeriod=l,g.value=l,k.value=t.sensorPointCoefficients||[],a.remainingCapacity=t.thisMonthDiskRemainingCapacity/1024/1024/1024;const s=t.lastMonthDiskStartCapacity,n=t.thisMonthDiskStartCapacity;console.log("lastMonthCapacity:",s,"thisMonthCapacity:",n),s==null||n==null?(console.log("lastMonthCapacity or thisMonthCapacity is null"),a.lastMonthGrowth="-"):a.lastMonthGrowth=s-n<0?"-":(s-n)/1024/1024/1024;let m=t.lastMonthDiskTotalCapacity;t.lastMonthDiskTotalCapacity!=null&&t.thisMonthDiskTotalCapacity!=null&&t.lastMonthDiskTotalCapacity<t.thisMonthDiskTotalCapacity&&(f.value=!0,m=t.thisMonthDiskTotalCapacity),a.totalCapacity=m/1024/1024/1024}})});const S=async()=>{try{if(await M.value.validate(),_.value>a.totalCapacity){b.error(d("diskCapacityExceedsTotal"));return}await U.confirm(d("confirmStoragePeriodChange",{oldValue:g.value,newValue:a.storagePeriod}),d("confirmModification"),{type:"warning"}),g.value=a.storagePeriod,await q({retentionDays:a.storagePeriod*30,thisMonthDiskTotalCapacity:a.totalCapacity*1024*1024*1024}),b.success(d("configurationSaved"))}catch{console.log("\u53D6\u6D88\u4FDD\u5B58")}};return(e,t)=>{const l=J,s=z,n=F,m=j,V=A;return c(),C("div",K,[p("div",L,h(e.$t("dataStorageRulesSetting")),1),o(V,{"label-width":"140px",model:a,rules:P,ref_key:"formRef",ref:M},{default:r(()=>[o(n,{label:e.$t("dataStoragePeriod"),prop:"storagePeriod"},{default:r(()=>[o(l,{modelValue:a.storagePeriod,"onUpdate:modelValue":t[0]||(t[0]=i=>a.storagePeriod=i),min:12,max:120,precision:0,controls:!1,style:{width:"360px"}},null,8,["modelValue"]),p("span",O,h(e.$t("months")),1),o(s,{type:"primary",onClick:S},{default:r(()=>[$(h(e.$t("save")),1)]),_:1})]),_:1},8,["label"]),o(n,{label:e.$t("estimatedDiskCapacity")},{default:r(()=>[o(l,{"model-value":x(_),precision:1,controls:!1,readonly:"",style:{width:"360px"},class:N({"text-red":x(_)>a.totalCapacity})},null,8,["model-value","class"]),Q]),_:1},8,["label"]),o(n,{label:e.$t("totalDiskCapacity")},{default:r(()=>[o(l,{modelValue:a.totalCapacity,"onUpdate:modelValue":t[1]||(t[1]=i=>a.totalCapacity=i),precision:1,controls:!1,readonly:"",style:{width:"360px"}},null,8,["modelValue"]),W]),_:1},8,["label"]),o(n,{label:e.$t("currentRemainingCapacity")},{default:r(()=>[o(l,{modelValue:a.remainingCapacity,"onUpdate:modelValue":t[2]||(t[2]=i=>a.remainingCapacity=i),precision:1,controls:!1,readonly:"",style:{width:"360px"}},null,8,["modelValue"]),X]),_:1},8,["label"]),o(n,{label:e.$t("lastMonthDataGrowth")},{default:r(()=>[!f.value&&a.lastMonthGrowth!=="-"?(c(),D(l,{key:0,modelValue:a.lastMonthGrowth,"onUpdate:modelValue":t[3]||(t[3]=i=>a.lastMonthGrowth=i),precision:1,controls:!1,readonly:"",style:{width:"360px"}},null,8,["modelValue"])):(c(),D(m,{key:1,value:"-",readonly:"",style:{width:"360px"},"input-style":{textAlign:"center"}})),a.lastMonthGrowth!=="-"?(c(),C("span",Y,"GB")):w("",!0),f.value?(c(),C("div",tt,h(e.$t("diskExpandedCannotCalculate")),1)):w("",!0)]),_:1},8,["label"])]),_:1},8,["model"])])}}},st=E(at,[["__scopeId","data-v-31cdd62d"]]);export{st as default};
