import{M as e,P as a,K as s,am as r,_ as t}from"./utils-lib.js?v=1761009159";import{s as u,j as l,r as o,o as i,c as m,g as n,e as d,C as g,q as v,a6 as p,v as c,x as b,y as z}from"./base-lib.js?v=1761009159";import{aH as h}from"./validator.js?v=1761009159";import{u as N,v as q}from"./useStore8.js?v=1761009159";import{b as S,o as f,h as _,f as y}from"./form-item.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";import"./index106.js?v=1761009159";import"./column.js?v=1761009159";const w=l("FTP-CAPACITY-STORE",()=>{const e=o();return{capacityData:o({used:0,size:0,status:!1,alarmSize:5,alarmNum:1,alarmModel:[],module:[],option:{}}),capFtpInfo:e,useSize:o()}}),j=()=>u(w()),{rowData:x}=N(),{capacityData:I,useSize:E}=j();i({size:[{required:!0,message:"容量不能为空",trigger:["blur"]},{validator:(e,a,s)=>{Number.isInteger(1*I.value.size)?s():s(new Error("容量必须为整数"))},trigger:["blur","change"]}],alarmSize:[{required:!0,message:"触发告警大小不能为空",trigger:["blur"]},{validator:(e,a,s)=>{I.value.status?Number.isInteger(1*I.value.alarmNum)?s():s(new Error("触发告警大小必须为整数")):s()},trigger:["blur","change"]}],alarmNum:[{required:!0,message:"告警次数不能为空",trigger:["blur"]},{validator:(e,a,s)=>{I.value.status?Number.isInteger(1*I.value.alarmNum)?s():s(new Error("告警次数必须为整数")):s()},trigger:["blur","change"]}],module:[{required:!0,validator:(e,a,s)=>{I.value.status&&0===I.value.module.length?s(new Error("请选择告警方式")):s()},trigger:["blur","change"]}]});const M=()=>{const{quota:e}=x.value;let{quota_storage:a,quota_push:s}=e;a&&(I.value.used=a.used,I.value.size=a.size),s&&void 0!==s.module&&(I.value.status=s.status,I.value.alarmSize=s.size,I.value.alarmNum=s.push_count,I.value.module=s.module.split(",")),(()=>{if(0===I.value.size)return E.value="未配置",void(I.value.useSize=E.value);const e=1024*I.value.size*1024;if(I.value.size>0&&I.value.used>=e)return E.value="当前容量已用完",void(I.value.useSize=E.value);E.value=(I.value.used/1024/1024).toFixed(2)||0,I.value.useSize=E.value})()},C=async(s,r)=>{await r();const t=((e=I.value,a=x.value)=>{var s;const{path:r}=a;return{path:r,quota_type:"ftp",quota_push:{status:e.status,size:Number(e.alarmSize),push_count:Number(e.alarmNum),module:null==(s=e.module)?void 0:s.join(",")},quota_storage:{size:Number(e.size)}}})(s.value);if(t.quota_push.status&&0===t.quota_push.module.length)return e.error("请选择至少一种告警方式"),!1;const u=await a({loading:"正在提交，请稍候...",request:q({data:JSON.stringify(t)}),data:{status:Boolean,msg:String}});return u.status?e.success(u.msg):e.msg({message:u.msg,showClose:!0,dangerouslyUseHTMLString:!0,type:"error",customClass:"bt-message-error-html",duration:0}),u.status},B=()=>{I.value={used:0,size:0,status:!1,alarmSize:0,alarmNum:0,alarmModel:[],module:[],option:{}},x.value={}},F={class:"p-[2rem] container-dialog"},D=t(m({__name:"index",setup(e,{expose:a}){const{capacityData:t,useSize:u}=j(),{BtForm:l,submit:o}=s({data:t.value,options:e=>{const a={class:"!w-[220px]",clearable:!0};return n(()=>[S("当前已用容量","useSize",{attrs:{...a,disabled:!0},slots:r(u)?{append:()=>d("span",{class:"text-gray-500"},[g("MB")])}:{}}),S("当前容量配额","size",{attrs:{...a,type:"number",min:0},slots:{append:()=>d("span",{class:"text-gray-500"},[g("MB")])},rules:[{required:!0,message:"容量不能为空",trigger:["blur"]},{validator:(e,a,s)=>{Number.isInteger(1*t.value.size)?s():s(new Error("容量必须为整数"))},trigger:["blur","change"]}]}),f("设置告警","status",{}),...e.value.status?[S("触发告警大小","alarmSize",{attrs:{...a,type:"number",min:0},slots:{append:()=>d("span",{class:"text-gray-500"},[g("MB")])},rules:[{required:!0,message:"触发告警大小不能为空",trigger:["blur"]},{validator:(e,a,s)=>{t.value.status?Number.isInteger(1*t.value.alarmNum)?s():s(new Error("触发告警大小必须为整数")):s()},trigger:["blur","change"]}]}),S("触发次数","alarmNum",{attrs:{...a,type:"number",min:0},slots:{append:()=>d("span",{class:"text-gray-500"},[g("次")])},rules:[{required:!0,message:"告警次数不能为空",trigger:["blur"]},{validator:(e,a,s)=>{t.value.status?Number.isInteger(1*t.value.alarmNum)?s():s(new Error("告警次数必须为整数")):s()},trigger:["blur","change"]}]}),_("告警方式",()=>d(h,{class:"!w-[24rem]",modelValue:e.value.module,"onUpdate:modelValue":a=>e.value.module=a},null))]:[],y("",[{content:"需要XFS文件系统，且包含prjquota挂载参数才能使用"},{content:"fstab配置示例：/dev/vdc1 /data xfs defaults,prjquota 0 0"},{content:"配额容量：如需取消容量配额，请设为“0”"}])])},submit:C});return a({onConfirm:o}),v(M),p(B),(e,a)=>(c(),b("div",F,[d(z(l),{"label-width":"10rem"})]))}}),[["__scopeId","data-v-1aa5a60a"]]);export{D as default};
