Files
aiops/backend/static/assets/CloudBilling-C3BHo3kq.js
T
Logan.Li f45e203e21 refactor(frontend): P1-P2 架构统一 — utils/hooks/api 模块化
P1:
- utils/storage.ts、theme.ts、validate.ts + index 统一出口
- request/store/useTheme 接入 storage;清零 confirm/alert
- PipelineManager、TerminalAuditTab 拆分子模块(<700行红线)

P2:
- api/monitor、api/deploy 子目录化
- hooks/api 扩展:servers/pipelines/alerts/audit/sessionCommands
- PipelineManager、AuditOperationsTab 接入 TanStack Query
2026-06-26 00:18:14 +08:00

2 lines
33 KiB
JavaScript

import{i as ve,j as e,r as c,D as X,a as Y,b as Z,c as ee,d as se,e as le,B as m,L as R,t as p,f as Ne,J as H}from"./index-HuRw9UhJ.js";import{I as j}from"./input-C9Xfv8um.js";import{L as r}from"./label-DvRDtaMA.js";import{C as T,a as V}from"./card-B2Wqa0sK.js";import{B as fe}from"./badge-CeS-g-Od.js";import{S as oe}from"./switch--ZaqVsRJ.js";import{S as w,a as S,b as k,c as _,d as x}from"./select-KDzbUQs3.js";import{b as h}from"./cloud-sEaHmpLm.js";import{S as be}from"./stat-strip-CVviXwc6.js";import{R as q}from"./refresh-cw-CSycAyA2.js";import{P as J}from"./plus-BVwIGPvl.js";import{P as G}from"./pencil-BZ7zX3m0.js";import{T as K}from"./trash-2-Cf9-88KL.js";import"./index-DwvHXNyF.js";import"./chevron-up-GXrRy2ul.js";const De=[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]],ye=ve("wallet",De),v={aliyun:"阿里云",tencent:"腾讯云",aws:"AWS",huawei:"华为云",azure:"Azure"},O={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 Re({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 we({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(w,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:100:15",value:o.provider,onValueChange:l=>i({...o,provider:l}),children:[e.jsx(S,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:101:17",className:"mt-1",children:e.jsx(k,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:101:49"})}),e.jsx(_,{"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(R,{"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 Se({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(w,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:95:15",value:o.provider||"all",onValueChange:l=>i({...o,provider:l==="all"?"":l}),children:[e.jsx(S,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:96:17",className:"mt-1",children:e.jsx(k,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:96:49"})}),e.jsxs(_,{"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(w,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:107:15",value:o.metric,onValueChange:l=>i({...o,metric:l}),children:[e.jsx(S,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:108:17",className:"mt-1",children:e.jsx(k,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:108:49"})}),e.jsxs(_,{"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(w,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:119:15",value:o.operator,onValueChange:l=>i({...o,operator:l}),children:[e.jsx(S,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:120:17",className:"mt-1",children:e.jsx(k,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:120:49"})}),e.jsxs(_,{"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(R,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:142:28",className:"h-4 w-4 mr-1 animate-spin"}),"保存"]})]})]})})}function We(){const d=Ne(),[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(""),[L,ne]=c.useState(""),[P,ae]=c.useState([]),[ie,I]=c.useState(!0),[de,F]=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),L&&(s.end_date=L);const u=await h.list(s);y(u.list||[])}catch(s){p.error("加载账单失败",{description:s.message})}finally{f(!1)}},[z,E,L]),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),F(!0)},xe=s=>{M(s),F(!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:166:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:167:7",className:"flex items-center justify-between",children:[e.jsx("h2",{"code-path":"src/components/cloud/CloudBilling.tsx:168:9",className:"text-lg font-semibold text-slate-100",children:"云账单管理"}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:169:9",className:"flex items-center gap-2",children:[e.jsxs(m,{"code-path":"src/components/cloud/CloudBilling.tsx:170:11",variant:"outline",size:"sm",onClick:()=>{N(),n==="records"&&b(),n==="alerts"&&D()},children:[e.jsx(q,{"code-path":"src/components/cloud/CloudBilling.tsx:171:13",className:"h-4 w-4 mr-1"}),"刷新"]}),n==="records"&&e.jsxs(m,{"code-path":"src/components/cloud/CloudBilling.tsx:174:13",size:"sm",onClick:me,children:[e.jsx(J,{"code-path":"src/components/cloud/CloudBilling.tsx:175:15",className:"h-4 w-4 mr-1"}),"记录成本"]}),n==="alerts"&&e.jsxs(m,{"code-path":"src/components/cloud/CloudBilling.tsx:179:13",size:"sm",onClick:he,children:[e.jsx(J,{"code-path":"src/components/cloud/CloudBilling.tsx:180:15",className:"h-4 w-4 mr-1"}),"添加规则"]})]})]}),e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:186: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:192: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:207:9",className:"space-y-4",children:i?e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:209:13",className:"flex items-center justify-center py-20 text-slate-500",children:[e.jsx(R,{"code-path":"src/components/cloud/CloudBilling.tsx:209:84",className:"h-6 w-6 animate-spin mr-2"}),"加载中..."]}):a?e.jsxs(e.Fragment,{children:[e.jsx(be,{"code-path":"src/components/cloud/CloudBilling.tsx:212: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:222: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:223:19",className:"flex items-center gap-2 mb-3",children:[e.jsx(H,{"code-path":"src/components/cloud/CloudBilling.tsx:224:21",className:"h-4 w-4 text-amber-400"}),e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:225:21",className:"text-sm font-medium text-amber-300",children:"成本预警"})]}),e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:227:19",className:"space-y-2",children:a.alerts.map((s,u)=>e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:229:23",className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:230:25",className:"flex items-center gap-2",children:[e.jsx(fe,{"code-path":"src/components/cloud/CloudBilling.tsx:231: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:232:27",className:"text-slate-400",children:[s.provider," · ",s.metric==="daily"?"日":"月","成本"]})]}),e.jsxs("span",{"code-path":"src/components/cloud/CloudBilling.tsx:236:25",className:"text-slate-300",children:["当前 ",e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:237:30",className:"text-amber-300 font-medium",children:g(s.current)})," ",s.operator," ","阈值 ",e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:239:30",className:"text-red-400 font-medium",children:g(s.threshold)})]})]},u))})]}),e.jsx(T,{"code-path":"src/components/cloud/CloudBilling.tsx:247:15",className:"bg-slate-900/50 border-slate-800",children:e.jsxs(V,{"code-path":"src/components/cloud/CloudBilling.tsx:248:17",className:"pt-4",children:[e.jsx("h3",{"code-path":"src/components/cloud/CloudBilling.tsx:249:19",className:"text-sm font-medium text-slate-200 mb-4",children:"近 30 天成本趋势"}),e.jsx(Re,{"code-path":"src/components/cloud/CloudBilling.tsx:250:19",data:a.month_trend||[]})]})}),e.jsx(T,{"code-path":"src/components/cloud/CloudBilling.tsx:254:15",className:"bg-slate-900/50 border-slate-800",children:e.jsxs(V,{"code-path":"src/components/cloud/CloudBilling.tsx:255:17",className:"pt-4",children:[e.jsx("h3",{"code-path":"src/components/cloud/CloudBilling.tsx:256: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:258:21",className:"text-sm text-slate-500 py-8 text-center",children:"暂无数据"}):e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:260:21",className:"space-y-3",children:[e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:261: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:263:27",className:`${O[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:273: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:275:27",className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:276:29",className:"flex items-center gap-2",children:[e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:277:31",className:`w-3 h-3 rounded ${O[s.provider]||"bg-slate-600"}`}),e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:278:31",className:"text-slate-300",children:v[s.provider]||s.provider})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:280:29",className:"text-right",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:281:31",className:"text-slate-200 font-medium",children:g(s.cost)}),e.jsxs("span",{"code-path":"src/components/cloud/CloudBilling.tsx:282: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:297:9",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:298:11",className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:299:13",children:[e.jsx(r,{"code-path":"src/components/cloud/CloudBilling.tsx:300:15",className:"text-xs text-slate-400 mb-1",children:"厂商"}),e.jsxs(w,{"code-path":"src/components/cloud/CloudBilling.tsx:301:15",value:z||"all",onValueChange:s=>te(s==="all"?"":s),children:[e.jsx(S,{"code-path":"src/components/cloud/CloudBilling.tsx:302:17",className:"w-32 h-9",children:e.jsx(k,{"code-path":"src/components/cloud/CloudBilling.tsx:302:53"})}),e.jsxs(_,{"code-path":"src/components/cloud/CloudBilling.tsx:303:17",children:[e.jsx(x,{"code-path":"src/components/cloud/CloudBilling.tsx:304:19",value:"all",children:"全部"}),Object.entries(v).map(([s,u])=>e.jsx(x,{"code-path":"src/components/cloud/CloudBilling.tsx:306:21",value:s,children:u},s))]})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:311:13",children:[e.jsx(r,{"code-path":"src/components/cloud/CloudBilling.tsx:312:15",className:"text-xs text-slate-400 mb-1",children:"开始日期"}),e.jsx(j,{"code-path":"src/components/cloud/CloudBilling.tsx:313: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:315:13",children:[e.jsx(r,{"code-path":"src/components/cloud/CloudBilling.tsx:316:15",className:"text-xs text-slate-400 mb-1",children:"结束日期"}),e.jsx(j,{"code-path":"src/components/cloud/CloudBilling.tsx:317:15",type:"date",className:"w-40 h-9",value:L,onChange:s=>ne(s.target.value)})]}),e.jsxs(m,{"code-path":"src/components/cloud/CloudBilling.tsx:319:13",variant:"outline",size:"sm",onClick:b,children:[e.jsx(q,{"code-path":"src/components/cloud/CloudBilling.tsx:320:15",className:"h-4 w-4 mr-1"}),"查询"]})]}),l?e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:325:13",className:"flex items-center justify-center py-20 text-slate-500",children:[e.jsx(R,{"code-path":"src/components/cloud/CloudBilling.tsx:325:84",className:"h-6 w-6 animate-spin mr-2"}),"加载中..."]}):C.length===0?e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:327:13",className:"py-20 text-center text-slate-500",children:[e.jsx(ye,{"code-path":"src/components/cloud/CloudBilling.tsx:328:15",className:"h-12 w-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{"code-path":"src/components/cloud/CloudBilling.tsx:329:15",className:"text-sm",children:"暂无成本记录"})]}):e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:332:13",className:"overflow-x-auto rounded-lg border border-slate-800",children:e.jsxs("table",{"code-path":"src/components/cloud/CloudBilling.tsx:333:15",className:"w-full text-sm",children:[e.jsx("thead",{"code-path":"src/components/cloud/CloudBilling.tsx:334:17",className:"bg-slate-900/80 text-slate-400",children:e.jsxs("tr",{"code-path":"src/components/cloud/CloudBilling.tsx:335:19",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-left 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-left font-medium",children:"账号"}),e.jsx("th",{"code-path":"src/components/cloud/CloudBilling.tsx:341:21",className:"px-4 py-2.5 text-right font-medium",children:"费用"}),e.jsx("th",{"code-path":"src/components/cloud/CloudBilling.tsx:342:21",className:"px-4 py-2.5 text-left font-medium",children:"说明"}),e.jsx("th",{"code-path":"src/components/cloud/CloudBilling.tsx:343:21",className:"px-4 py-2.5 text-center font-medium",children:"操作"})]})}),e.jsx("tbody",{"code-path":"src/components/cloud/CloudBilling.tsx:346:17",children:C.map(s=>e.jsxs("tr",{"code-path":"src/components/cloud/CloudBilling.tsx:348:21",className:"border-t border-slate-800 hover:bg-slate-800/30",children:[e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:349:23",className:"px-4 py-2.5 text-slate-300",children:s.billing_date}),e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:350:23",className:"px-4 py-2.5",children:e.jsxs("span",{"code-path":"src/components/cloud/CloudBilling.tsx:351:25",className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:352:27",className:`w-2 h-2 rounded-full ${O[s.provider]||"bg-slate-500"}`}),v[s.provider]||s.provider]})}),e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:356:23",className:"px-4 py-2.5 text-slate-400",children:s.service||"-"}),e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:357:23",className:"px-4 py-2.5 text-slate-400",children:s.region||"-"}),e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:358:23",className:"px-4 py-2.5 text-slate-400",children:s.account_name||"-"}),e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:359: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:360: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:361:23",className:"px-4 py-2.5",children:e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:362:25",className:"flex items-center justify-center gap-1",children:[e.jsx(m,{"code-path":"src/components/cloud/CloudBilling.tsx:363:27",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>xe(s),children:e.jsx(G,{"code-path":"src/components/cloud/CloudBilling.tsx:364:29",className:"h-3.5 w-3.5"})}),e.jsx(m,{"code-path":"src/components/cloud/CloudBilling.tsx:366: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:367:29",className:"h-3.5 w-3.5"})})]})})]},s.id))})]})})]}),n==="alerts"&&e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:381:9",className:"space-y-3",children:ie?e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:383:13",className:"flex items-center justify-center py-20 text-slate-500",children:[e.jsx(R,{"code-path":"src/components/cloud/CloudBilling.tsx:383:84",className:"h-6 w-6 animate-spin mr-2"}),"加载中..."]}):P.length===0?e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:385:13",className:"py-20 text-center text-slate-500",children:[e.jsx(H,{"code-path":"src/components/cloud/CloudBilling.tsx:386:15",className:"h-12 w-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{"code-path":"src/components/cloud/CloudBilling.tsx:387:15",className:"text-sm",children:"暂无预警规则"})]}):e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:390:13",className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:P.map(s=>e.jsx(T,{"code-path":"src/components/cloud/CloudBilling.tsx:392:17",className:"bg-slate-900/50 border-slate-800",children:e.jsxs(V,{"code-path":"src/components/cloud/CloudBilling.tsx:393:19",className:"pt-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:394:21",className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:395:23",className:"flex items-center gap-2",children:[e.jsx(H,{"code-path":"src/components/cloud/CloudBilling.tsx:396:25",className:`h-4 w-4 ${s.enabled?"text-amber-400":"text-slate-600"}`}),e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:397:25",className:"text-sm font-medium text-slate-200",children:s.name})]}),e.jsx(oe,{"code-path":"src/components/cloud/CloudBilling.tsx:399:23",checked:s.enabled,onCheckedChange:()=>Ce(s.id)})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:401:21",className:"grid grid-cols-2 gap-2 text-sm",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:402:23",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:403:25",className:"text-slate-500",children:"厂商"}),e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:404: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:406:23",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:407:25",className:"text-slate-500",children:"指标"}),e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:408:25",className:"ml-2 text-slate-300",children:s.metric==="daily"?"日成本":"月累计"})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:410:23",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:411:25",className:"text-slate-500",children:"阈值"}),e.jsxs("span",{"code-path":"src/components/cloud/CloudBilling.tsx:412: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:415:25",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:416:27",className:"text-slate-500",children:"最后触发"}),e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:417: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:421:21",className:"flex justify-end gap-1 mt-3",children:[e.jsx(m,{"code-path":"src/components/cloud/CloudBilling.tsx:422:23",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>ge(s),children:e.jsx(G,{"code-path":"src/components/cloud/CloudBilling.tsx:423:25",className:"h-3.5 w-3.5"})}),e.jsx(m,{"code-path":"src/components/cloud/CloudBilling.tsx:425: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:426:25",className:"h-3.5 w-3.5"})})]})]})},s.id))})}),e.jsx(we,{"code-path":"src/components/cloud/CloudBilling.tsx:437:7",open:de,onOpenChange:F,editingRecord:re,onSuccess:()=>{b(),N()}}),e.jsx(Se,{"code-path":"src/components/cloud/CloudBilling.tsx:443:7",open:pe,onOpenChange:$,editingRule:ue,onSuccess:()=>{D(),N()}})]})}export{We as CloudBilling};