2 lines
33 KiB
JavaScript
2 lines
33 KiB
JavaScript
import{j as e,r as c}from"./vendor-codemirror-C7mXSpXt.js";import{D as X,a as Y,b as Z,c as ee,d as se,e as le,B as m,t as p,f as ve}from"./index-BZzvNKfa.js";import{I as j}from"./input-D7JNe8Xd.js";import{L as r}from"./label-Bj0mNUAM.js";import{C as H,a as T}from"./card-B1TdHH8z.js";import{B as Ne}from"./badge-IN84WXM6.js";import{S as oe}from"./switch-Ds1Doipu.js";import{S as R,a as w,b as S,c as k,d as x}from"./select-BFGszUub.js";import{b as h}from"./billing-Cc58vPzR.js";import{S as fe}from"./stat-strip-D5jCLXat.js";import{L as _,R as q,P as G,t as O,aB as be,d as J,T as K}from"./vendor-icons-DIDdqO_o.js";import"./index-CYARH0Cq.js";const v={aliyun:"阿里云",tencent:"腾讯云",aws:"AWS",huawei:"华为云",azure:"Azure"},V={aliyun:"bg-orange-500",tencent:"bg-blue-500",aws:"bg-amber-500",huawei:"bg-red-500",azure:"bg-sky-500"};function g(d){return`¥${d.toLocaleString("zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2})}`}function De({data:d}){if(d.length===0)return e.jsx("p",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:54:12",className:"text-sm text-slate-500 py-8 text-center",children:"暂无数据"});const n=Math.max(...d.map(a=>a.cost),1),t=d.slice(-30);return e.jsxs("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:60:5",children:[e.jsx("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:61:7",className:"flex items-end gap-0.5 h-40",children:t.map((a,o)=>{const i=Math.max(a.cost/n*100,2);return e.jsxs("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:65:13",className:"flex-1 group relative",style:{height:"100%"},children:[e.jsx("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:70:15",className:"absolute bottom-0 w-full rounded-t-sm bg-gradient-to-t from-blue-600/60 to-blue-400/80 group-hover:from-blue-500 group-hover:to-blue-300 transition-colors",style:{height:`${i}%`}}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:74:15",className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 hidden group-hover:block whitespace-nowrap text-xs bg-slate-800 text-slate-200 px-2 py-1 rounded border border-slate-700 z-10",children:[a.date,": ",g(a.cost)]})]},o)})}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:81:7",className:"flex justify-between mt-2 text-xs text-slate-500",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:82:9",children:t[0]?.date}),e.jsx("span",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:83:9",children:t[t.length-1]?.date})]})]})}const Q={provider:"aliyun",billing_date:"",cost:"",service:"",region:"",account_name:"",description:""};function ye({open:d,onOpenChange:n,editingRecord:t,onSuccess:a}){const[o,i]=c.useState(Q),[B,C]=c.useState(!1);c.useEffect(()=>{d&&i(t?{provider:t.provider,billing_date:t.billing_date,cost:t.cost,service:t.service||"",region:t.region||"",account_name:t.account_name||"",description:t.description||""}:{...Q,billing_date:new Date().toISOString().slice(0,10)})},[d,t]);const y=async()=>{if(!o.provider||!o.billing_date||!o.cost){p.error("请填写必填字段");return}C(!0);try{const l={...o,cost:parseFloat(o.cost)};t?(await h.remove(t.id),await h.create(l)):await h.create(l),n(!1),a(),p("保存成功")}catch(l){p.error("保存失败",{description:l.message})}finally{C(!1)}};return e.jsx(X,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:90:5",open:d,onOpenChange:n,children:e.jsxs(Y,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:91:7",className:"max-w-md",children:[e.jsxs(Z,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:92:9",children:[e.jsx(ee,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:93:11",children:t?"编辑成本记录":"记录成本"}),e.jsx(se,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:94:11",children:"记录一条每日云资源成本"})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:96:9",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:97:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:98:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:99:15",className:"text-sm text-slate-300",children:"厂商 *"}),e.jsxs(R,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:100:15",value:o.provider,onValueChange:l=>i({...o,provider:l}),children:[e.jsx(w,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:101:17",className:"mt-1",children:e.jsx(S,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:101:49"})}),e.jsx(k,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:102:17",children:Object.entries(v).map(([l,f])=>e.jsx(x,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:104:21",value:l,children:f},l))})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:109:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:110:15",className:"text-sm text-slate-300",children:"日期 *"}),e.jsx(j,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:111:15",type:"date",className:"mt-1",value:o.billing_date,onChange:l=>i({...o,billing_date:l.target.value})})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:114:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:115:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:116:15",className:"text-sm text-slate-300",children:"费用(元) *"}),e.jsx(j,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:117:15",type:"number",step:"0.01",className:"mt-1",placeholder:"0.00",value:o.cost,onChange:l=>i({...o,cost:l.target.value})})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:119:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:120:15",className:"text-sm text-slate-300",children:"服务"}),e.jsx(j,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:121:15",className:"mt-1",placeholder:"ECS, RDS...",value:o.service,onChange:l=>i({...o,service:l.target.value})})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:124:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:125:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:126:15",className:"text-sm text-slate-300",children:"区域"}),e.jsx(j,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:127:15",className:"mt-1",placeholder:"cn-hangzhou",value:o.region,onChange:l=>i({...o,region:l.target.value})})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:129:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:130:15",className:"text-sm text-slate-300",children:"账号名称"}),e.jsx(j,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:131:15",className:"mt-1",placeholder:"主账号",value:o.account_name,onChange:l=>i({...o,account_name:l.target.value})})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:134:11",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:135:13",className:"text-sm text-slate-300",children:"备注"}),e.jsx(j,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:136:13",className:"mt-1",placeholder:"可选",value:o.description,onChange:l=>i({...o,description:l.target.value})})]})]}),e.jsxs(le,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:139:9",children:[e.jsx(m,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:140:11",variant:"outline",onClick:()=>n(!1),children:"取消"}),e.jsxs(m,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:141:11",onClick:y,disabled:B,children:[B&&e.jsx(_,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:142:28",className:"h-4 w-4 mr-1 animate-spin"}),"保存"]})]})]})})}const U={name:"",provider:"",metric:"daily",threshold:"",operator:">",enabled:!0};function Re({open:d,onOpenChange:n,editingRule:t,onSuccess:a}){const[o,i]=c.useState(U),[B,C]=c.useState(!1);c.useEffect(()=>{d&&i(t?{name:t.name,provider:t.provider||"",metric:t.metric||"daily",threshold:t.threshold,operator:t.operator||">",enabled:t.enabled}:{...U})},[d,t]);const y=async()=>{if(!o.name||!o.threshold){p.error("请填写规则名称和阈值");return}C(!0);try{const l={...o,threshold:parseFloat(o.threshold)};t?await h.updateAlertRule(t.id,l):await h.createAlertRule(l),n(!1),a(),p("保存成功")}catch(l){p.error("保存失败",{description:l.message})}finally{C(!1)}};return e.jsx(X,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:81:5",open:d,onOpenChange:n,children:e.jsxs(Y,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:82:7",className:"max-w-md",children:[e.jsxs(Z,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:83:9",children:[e.jsx(ee,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:84:11",children:t?"编辑预警规则":"添加预警规则"}),e.jsx(se,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:85:11",children:"设置成本阈值,超标时自动预警"})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRuleDialog.tsx:87:9",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/BillingRuleDialog.tsx:88:11",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:89:13",className:"text-sm text-slate-300",children:"规则名称 *"}),e.jsx(j,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:90:13",className:"mt-1",placeholder:"如:日成本超 500 元预警",value:o.name,onChange:l=>i({...o,name:l.target.value})})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRuleDialog.tsx:92:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/BillingRuleDialog.tsx:93:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:94:15",className:"text-sm text-slate-300",children:"厂商"}),e.jsxs(R,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:95:15",value:o.provider||"all",onValueChange:l=>i({...o,provider:l==="all"?"":l}),children:[e.jsx(w,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:96:17",className:"mt-1",children:e.jsx(S,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:96:49"})}),e.jsxs(k,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:97:17",children:[e.jsx(x,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:98:19",value:"all",children:"全部厂商"}),Object.entries(v).map(([l,f])=>e.jsx(x,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:100:21",value:l,children:f},l))]})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRuleDialog.tsx:105:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:106:15",className:"text-sm text-slate-300",children:"指标"}),e.jsxs(R,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:107:15",value:o.metric,onValueChange:l=>i({...o,metric:l}),children:[e.jsx(w,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:108:17",className:"mt-1",children:e.jsx(S,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:108:49"})}),e.jsxs(k,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:109:17",children:[e.jsx(x,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:110:19",value:"daily",children:"日成本"}),e.jsx(x,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:111:19",value:"monthly",children:"月累计"})]})]})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRuleDialog.tsx:116:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/BillingRuleDialog.tsx:117:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:118:15",className:"text-sm text-slate-300",children:"比较"}),e.jsxs(R,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:119:15",value:o.operator,onValueChange:l=>i({...o,operator:l}),children:[e.jsx(w,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:120:17",className:"mt-1",children:e.jsx(S,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:120:49"})}),e.jsxs(k,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:121:17",children:[e.jsx(x,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:122:19",value:">",children:"大于 >"}),e.jsx(x,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:123:19",value:">=",children:"大于等于 ≥"}),e.jsx(x,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:124:19",value:"<",children:"小于 <"}),e.jsx(x,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:125:19",value:"<=",children:"小于等于 ≤"})]})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRuleDialog.tsx:129:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:130:15",className:"text-sm text-slate-300",children:"阈值(元) *"}),e.jsx(j,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:131:15",type:"number",step:"0.01",className:"mt-1",placeholder:"500.00",value:o.threshold,onChange:l=>i({...o,threshold:l.target.value})})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRuleDialog.tsx:134:11",className:"flex items-center gap-2",children:[e.jsx(oe,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:135:13",checked:o.enabled,onCheckedChange:l=>i({...o,enabled:l})}),e.jsx(r,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:136:13",className:"text-sm text-slate-300",children:"启用"})]})]}),e.jsxs(le,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:139:9",children:[e.jsx(m,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:140:11",variant:"outline",onClick:()=>n(!1),children:"取消"}),e.jsxs(m,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:141:11",onClick:y,disabled:B,children:[B&&e.jsx(_,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:142:28",className:"h-4 w-4 mr-1 animate-spin"}),"保存"]})]})]})})}function Oe(){const d=ve(),[n,t]=c.useState("overview"),[a,o]=c.useState(null),[i,B]=c.useState(!0),[C,y]=c.useState([]),[l,f]=c.useState(!0),[z,te]=c.useState(""),[E,ce]=c.useState(""),[F,ne]=c.useState(""),[P,ae]=c.useState([]),[ie,I]=c.useState(!0),[de,L]=c.useState(!1),[re,M]=c.useState(null),[pe,$]=c.useState(!1),[ue,W]=c.useState(null),N=c.useCallback(async()=>{B(!0);try{const s=await h.getStats();o(s)}catch(s){p.error("加载统计失败",{description:s.message})}finally{B(!1)}},[]),b=c.useCallback(async()=>{f(!0);try{const s={};z&&(s.provider=z),E&&(s.start_date=E),F&&(s.end_date=F);const u=await h.list(s);y(u.list||[])}catch(s){p.error("加载账单失败",{description:s.message})}finally{f(!1)}},[z,E,F]),D=c.useCallback(async()=>{I(!0);try{const s=await h.listAlertRules();ae(s.list||[])}catch(s){p.error("加载预警规则失败",{description:s.message})}finally{I(!1)}},[]);c.useEffect(()=>{N()},[N]),c.useEffect(()=>{n==="records"&&b()},[n,b]),c.useEffect(()=>{n==="alerts"&&D()},[n,D]);const me=()=>{M(null),L(!0)},xe=s=>{M(s),L(!0)},he=()=>{W(null),$(!0)},ge=s=>{W(s),$(!0)},je=async s=>{if(await d({title:"删除账单记录",description:"确定删除这条成本记录?",variant:"destructive"}))try{await h.remove(s),b(),N(),p("删除成功")}catch(A){p.error("删除失败",{description:A.message})}},Be=async s=>{if(await d({title:"删除预警规则",description:"确定删除此预警规则?",variant:"destructive"}))try{await h.deleteAlertRule(s),D(),p("删除成功")}catch(A){p.error("删除失败",{description:A.message})}},Ce=async s=>{try{await h.toggleAlertRule(s),D(),N()}catch(u){p.error("操作失败",{description:u.message})}};return e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:163:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:164:7",className:"flex items-center justify-between",children:[e.jsx("h2",{"code-path":"src/components/cloud/CloudBilling.tsx:165:9",className:"text-lg font-semibold text-slate-100",children:"云账单管理"}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:166:9",className:"flex items-center gap-2",children:[e.jsxs(m,{"code-path":"src/components/cloud/CloudBilling.tsx:167:11",variant:"outline",size:"sm",onClick:()=>{N(),n==="records"&&b(),n==="alerts"&&D()},children:[e.jsx(q,{"code-path":"src/components/cloud/CloudBilling.tsx:168:13",className:"h-4 w-4 mr-1"}),"刷新"]}),n==="records"&&e.jsxs(m,{"code-path":"src/components/cloud/CloudBilling.tsx:171:13",size:"sm",onClick:me,children:[e.jsx(G,{"code-path":"src/components/cloud/CloudBilling.tsx:172:15",className:"h-4 w-4 mr-1"}),"记录成本"]}),n==="alerts"&&e.jsxs(m,{"code-path":"src/components/cloud/CloudBilling.tsx:176:13",size:"sm",onClick:he,children:[e.jsx(G,{"code-path":"src/components/cloud/CloudBilling.tsx:177:15",className:"h-4 w-4 mr-1"}),"添加规则"]})]})]}),e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:183:7",className:"flex gap-1 border-b border-slate-800",children:[{key:"overview",label:"概览统计"},{key:"records",label:"成本记录"},{key:"alerts",label:"预警规则"}].map(s=>e.jsx("button",{"code-path":"src/components/cloud/CloudBilling.tsx:189:11",onClick:()=>t(s.key),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${n===s.key?"text-blue-400 border-blue-400":"text-slate-400 border-transparent hover:text-slate-200"}`,children:s.label},s.key))}),n==="overview"&&e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:204:9",className:"space-y-4",children:i?e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:206:13",className:"flex items-center justify-center py-20 text-slate-500",children:[e.jsx(_,{"code-path":"src/components/cloud/CloudBilling.tsx:206:84",className:"h-6 w-6 animate-spin mr-2"}),"加载中..."]}):a?e.jsxs(e.Fragment,{children:[e.jsx(fe,{"code-path":"src/components/cloud/CloudBilling.tsx:209:15",items:[{label:"今日",value:g(a.today_cost||0),color:"blue"},{label:"本月",value:g(a.month_cost||0),color:"amber"},{label:"年度",value:g(a.year_cost||0),color:"purple"},{label:"预警",value:`${a.alerts?.length||0} 条`,color:a.alerts?.length>0?"red":"muted"}]}),a.alerts?.length>0&&e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:219:17",className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:220:19",className:"flex items-center gap-2 mb-3",children:[e.jsx(O,{"code-path":"src/components/cloud/CloudBilling.tsx:221:21",className:"h-4 w-4 text-amber-400"}),e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:222:21",className:"text-sm font-medium text-amber-300",children:"成本预警"})]}),e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:224:19",className:"space-y-2",children:a.alerts.map((s,u)=>e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:226:23",className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:227:25",className:"flex items-center gap-2",children:[e.jsx(Ne,{"code-path":"src/components/cloud/CloudBilling.tsx:228:27",variant:"outline",className:"border-amber-500/50 text-amber-300",children:s.rule_name}),e.jsxs("span",{"code-path":"src/components/cloud/CloudBilling.tsx:229:27",className:"text-slate-400",children:[s.provider," · ",s.metric==="daily"?"日":"月","成本"]})]}),e.jsxs("span",{"code-path":"src/components/cloud/CloudBilling.tsx:233:25",className:"text-slate-300",children:["当前 ",e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:234:30",className:"text-amber-300 font-medium",children:g(s.current)})," ",s.operator," ","阈值 ",e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:236:30",className:"text-red-400 font-medium",children:g(s.threshold)})]})]},u))})]}),e.jsx(H,{"code-path":"src/components/cloud/CloudBilling.tsx:244:15",className:"bg-slate-900/50 border-slate-800",children:e.jsxs(T,{"code-path":"src/components/cloud/CloudBilling.tsx:245:17",className:"pt-4",children:[e.jsx("h3",{"code-path":"src/components/cloud/CloudBilling.tsx:246:19",className:"text-sm font-medium text-slate-200 mb-4",children:"近 30 天成本趋势"}),e.jsx(De,{"code-path":"src/components/cloud/CloudBilling.tsx:247:19",data:a.month_trend||[]})]})}),e.jsx(H,{"code-path":"src/components/cloud/CloudBilling.tsx:251:15",className:"bg-slate-900/50 border-slate-800",children:e.jsxs(T,{"code-path":"src/components/cloud/CloudBilling.tsx:252:17",className:"pt-4",children:[e.jsx("h3",{"code-path":"src/components/cloud/CloudBilling.tsx:253:19",className:"text-sm font-medium text-slate-200 mb-4",children:"本月厂商成本分布"}),(a.provider_dist||[]).length===0?e.jsx("p",{"code-path":"src/components/cloud/CloudBilling.tsx:255:21",className:"text-sm text-slate-500 py-8 text-center",children:"暂无数据"}):e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:257:21",className:"space-y-3",children:[e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:258:23",className:"flex h-8 rounded-lg overflow-hidden",children:a.provider_dist.map((s,u)=>e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:260:27",className:`${V[s.provider]||"bg-slate-600"} flex items-center justify-center text-xs text-white font-medium`,style:{width:`${s.percent}%`},title:`${v[s.provider]||s.provider}: ${g(s.cost)} (${s.percent.toFixed(1)}%)`,children:s.percent>8?v[s.provider]||s.provider:""},u))}),e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:270:23",className:"grid grid-cols-2 md:grid-cols-3 gap-2",children:a.provider_dist.map((s,u)=>e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:272:27",className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:273:29",className:"flex items-center gap-2",children:[e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:274:31",className:`w-3 h-3 rounded ${V[s.provider]||"bg-slate-600"}`}),e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:275:31",className:"text-slate-300",children:v[s.provider]||s.provider})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:277:29",className:"text-right",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:278:31",className:"text-slate-200 font-medium",children:g(s.cost)}),e.jsxs("span",{"code-path":"src/components/cloud/CloudBilling.tsx:279:31",className:"text-slate-500 ml-2",children:[s.percent.toFixed(1),"%"]})]})]},u))})]})]})})]}):null}),n==="records"&&e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:294:9",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:295:11",className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:296:13",children:[e.jsx(r,{"code-path":"src/components/cloud/CloudBilling.tsx:297:15",className:"text-xs text-slate-400 mb-1",children:"厂商"}),e.jsxs(R,{"code-path":"src/components/cloud/CloudBilling.tsx:298:15",value:z||"all",onValueChange:s=>te(s==="all"?"":s),children:[e.jsx(w,{"code-path":"src/components/cloud/CloudBilling.tsx:299:17",className:"w-32 h-9",children:e.jsx(S,{"code-path":"src/components/cloud/CloudBilling.tsx:299:53"})}),e.jsxs(k,{"code-path":"src/components/cloud/CloudBilling.tsx:300:17",children:[e.jsx(x,{"code-path":"src/components/cloud/CloudBilling.tsx:301:19",value:"all",children:"全部"}),Object.entries(v).map(([s,u])=>e.jsx(x,{"code-path":"src/components/cloud/CloudBilling.tsx:303:21",value:s,children:u},s))]})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:308:13",children:[e.jsx(r,{"code-path":"src/components/cloud/CloudBilling.tsx:309:15",className:"text-xs text-slate-400 mb-1",children:"开始日期"}),e.jsx(j,{"code-path":"src/components/cloud/CloudBilling.tsx:310:15",type:"date",className:"w-40 h-9",value:E,onChange:s=>ce(s.target.value)})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:312:13",children:[e.jsx(r,{"code-path":"src/components/cloud/CloudBilling.tsx:313:15",className:"text-xs text-slate-400 mb-1",children:"结束日期"}),e.jsx(j,{"code-path":"src/components/cloud/CloudBilling.tsx:314:15",type:"date",className:"w-40 h-9",value:F,onChange:s=>ne(s.target.value)})]}),e.jsxs(m,{"code-path":"src/components/cloud/CloudBilling.tsx:316:13",variant:"outline",size:"sm",onClick:b,children:[e.jsx(q,{"code-path":"src/components/cloud/CloudBilling.tsx:317:15",className:"h-4 w-4 mr-1"}),"查询"]})]}),l?e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:322:13",className:"flex items-center justify-center py-20 text-slate-500",children:[e.jsx(_,{"code-path":"src/components/cloud/CloudBilling.tsx:322:84",className:"h-6 w-6 animate-spin mr-2"}),"加载中..."]}):C.length===0?e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:324:13",className:"py-20 text-center text-slate-500",children:[e.jsx(be,{"code-path":"src/components/cloud/CloudBilling.tsx:325:15",className:"h-12 w-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{"code-path":"src/components/cloud/CloudBilling.tsx:326:15",className:"text-sm",children:"暂无成本记录"})]}):e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:329:13",className:"overflow-x-auto rounded-lg border border-slate-800",children:e.jsxs("table",{"code-path":"src/components/cloud/CloudBilling.tsx:330:15",className:"w-full text-sm",children:[e.jsx("thead",{"code-path":"src/components/cloud/CloudBilling.tsx:331:17",className:"bg-slate-900/80 text-slate-400",children:e.jsxs("tr",{"code-path":"src/components/cloud/CloudBilling.tsx:332:19",children:[e.jsx("th",{"code-path":"src/components/cloud/CloudBilling.tsx:333:21",className:"px-4 py-2.5 text-left font-medium",children:"日期"}),e.jsx("th",{"code-path":"src/components/cloud/CloudBilling.tsx:334:21",className:"px-4 py-2.5 text-left font-medium",children:"厂商"}),e.jsx("th",{"code-path":"src/components/cloud/CloudBilling.tsx:335:21",className:"px-4 py-2.5 text-left font-medium",children:"服务"}),e.jsx("th",{"code-path":"src/components/cloud/CloudBilling.tsx:336:21",className:"px-4 py-2.5 text-left font-medium",children:"区域"}),e.jsx("th",{"code-path":"src/components/cloud/CloudBilling.tsx:337:21",className:"px-4 py-2.5 text-left font-medium",children:"账号"}),e.jsx("th",{"code-path":"src/components/cloud/CloudBilling.tsx:338:21",className:"px-4 py-2.5 text-right font-medium",children:"费用"}),e.jsx("th",{"code-path":"src/components/cloud/CloudBilling.tsx:339:21",className:"px-4 py-2.5 text-left font-medium",children:"说明"}),e.jsx("th",{"code-path":"src/components/cloud/CloudBilling.tsx:340:21",className:"px-4 py-2.5 text-center font-medium",children:"操作"})]})}),e.jsx("tbody",{"code-path":"src/components/cloud/CloudBilling.tsx:343:17",children:C.map(s=>e.jsxs("tr",{"code-path":"src/components/cloud/CloudBilling.tsx:345:21",className:"border-t border-slate-800 hover:bg-slate-800/30",children:[e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:346:23",className:"px-4 py-2.5 text-slate-300",children:s.billing_date}),e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:347:23",className:"px-4 py-2.5",children:e.jsxs("span",{"code-path":"src/components/cloud/CloudBilling.tsx:348:25",className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:349:27",className:`w-2 h-2 rounded-full ${V[s.provider]||"bg-slate-500"}`}),v[s.provider]||s.provider]})}),e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:353:23",className:"px-4 py-2.5 text-slate-400",children:s.service||"-"}),e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:354:23",className:"px-4 py-2.5 text-slate-400",children:s.region||"-"}),e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:355:23",className:"px-4 py-2.5 text-slate-400",children:s.account_name||"-"}),e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:356:23",className:"px-4 py-2.5 text-right text-slate-200 font-medium",children:g(s.cost)}),e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:357:23",className:"px-4 py-2.5 text-slate-500 max-w-xs truncate",children:s.description||"-"}),e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:358:23",className:"px-4 py-2.5",children:e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:359:25",className:"flex items-center justify-center gap-1",children:[e.jsx(m,{"code-path":"src/components/cloud/CloudBilling.tsx:360:27",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>xe(s),children:e.jsx(J,{"code-path":"src/components/cloud/CloudBilling.tsx:361:29",className:"h-3.5 w-3.5"})}),e.jsx(m,{"code-path":"src/components/cloud/CloudBilling.tsx:363:27",variant:"ghost",size:"icon",className:"h-7 w-7 text-red-400 hover:text-red-300",onClick:()=>je(s.id),children:e.jsx(K,{"code-path":"src/components/cloud/CloudBilling.tsx:364:29",className:"h-3.5 w-3.5"})})]})})]},s.id))})]})})]}),n==="alerts"&&e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:378:9",className:"space-y-3",children:ie?e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:380:13",className:"flex items-center justify-center py-20 text-slate-500",children:[e.jsx(_,{"code-path":"src/components/cloud/CloudBilling.tsx:380:84",className:"h-6 w-6 animate-spin mr-2"}),"加载中..."]}):P.length===0?e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:382:13",className:"py-20 text-center text-slate-500",children:[e.jsx(O,{"code-path":"src/components/cloud/CloudBilling.tsx:383:15",className:"h-12 w-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{"code-path":"src/components/cloud/CloudBilling.tsx:384:15",className:"text-sm",children:"暂无预警规则"})]}):e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:387:13",className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:P.map(s=>e.jsx(H,{"code-path":"src/components/cloud/CloudBilling.tsx:389:17",className:"bg-slate-900/50 border-slate-800",children:e.jsxs(T,{"code-path":"src/components/cloud/CloudBilling.tsx:390:19",className:"pt-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:391:21",className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:392:23",className:"flex items-center gap-2",children:[e.jsx(O,{"code-path":"src/components/cloud/CloudBilling.tsx:393:25",className:`h-4 w-4 ${s.enabled?"text-amber-400":"text-slate-600"}`}),e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:394:25",className:"text-sm font-medium text-slate-200",children:s.name})]}),e.jsx(oe,{"code-path":"src/components/cloud/CloudBilling.tsx:396:23",checked:s.enabled,onCheckedChange:()=>Ce(s.id)})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:398:21",className:"grid grid-cols-2 gap-2 text-sm",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:399:23",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:400:25",className:"text-slate-500",children:"厂商"}),e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:401:25",className:"ml-2 text-slate-300",children:s.provider?v[s.provider]||s.provider:"全部"})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:403:23",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:404:25",className:"text-slate-500",children:"指标"}),e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:405:25",className:"ml-2 text-slate-300",children:s.metric==="daily"?"日成本":"月累计"})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:407:23",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:408:25",className:"text-slate-500",children:"阈值"}),e.jsxs("span",{"code-path":"src/components/cloud/CloudBilling.tsx:409:25",className:"ml-2 text-amber-300 font-medium",children:[s.operator," ",g(s.threshold)]})]}),s.last_triggered&&e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:412:25",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:413:27",className:"text-slate-500",children:"最后触发"}),e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:414:27",className:"ml-2 text-slate-400",children:new Date(s.last_triggered).toLocaleString("zh-CN")})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:418:21",className:"flex justify-end gap-1 mt-3",children:[e.jsx(m,{"code-path":"src/components/cloud/CloudBilling.tsx:419:23",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>ge(s),children:e.jsx(J,{"code-path":"src/components/cloud/CloudBilling.tsx:420:25",className:"h-3.5 w-3.5"})}),e.jsx(m,{"code-path":"src/components/cloud/CloudBilling.tsx:422:23",variant:"ghost",size:"icon",className:"h-7 w-7 text-red-400 hover:text-red-300",onClick:()=>Be(s.id),children:e.jsx(K,{"code-path":"src/components/cloud/CloudBilling.tsx:423:25",className:"h-3.5 w-3.5"})})]})]})},s.id))})}),e.jsx(ye,{"code-path":"src/components/cloud/CloudBilling.tsx:434:7",open:de,onOpenChange:L,editingRecord:re,onSuccess:()=>{b(),N()}}),e.jsx(Re,{"code-path":"src/components/cloud/CloudBilling.tsx:440:7",open:pe,onOpenChange:$,editingRule:ue,onSuccess:()=>{D(),N()}})]})}export{Oe as CloudBilling};
|