import{$n as e,F as t,I as n,N as r,P as i,R as a,Rt as o,Vr as s,ar as c,er as l,gr as u,ir as d,jr as f,mr as p,sr as m,tr as h,wr as g}from"./index-DW8vg_xD.js";import{a as _}from"./VSelectionControl-CdAOzjIY.js";import{t as v}from"./VSpacer-Dy3oUHX7.js";import{t as y}from"./useSnackbar-D7YOfKok.js";import{t as b}from"./VChip-B2MXBDps.js";import{t as x}from"./VDialog-CIRFmEyC.js";import{t as S}from"./VSelect-Cq6ghD60.js";import{t as C}from"./VDataTableServer-BDSBbzBA.js";var w={class:`font-weight-medium text-truncate d-inline-block`,style:{"max-width":`240px`}},T={class:`text-medium-emphasis`},E={class:`text-medium-emphasis`},D={class:`text-caption text-medium-emphasis`},O={class:`text-caption text-medium-emphasis`},k=m({__name:`RetriesPage`,setup(m){let k=y(),A=f(!1),j=f([]),M=f(0),N=f(1),P=f(null),F=f(!1),I=f(null),L=[{label:`待重试`,value:`pending`},{label:`重试中`,value:`retrying`},{label:`成功`,value:`success`},{label:`失败`,value:`failed`}],R=[{title:`状态`,key:`status`,width:100},{title:`任务`,key:`operation`},{title:`服务器`,key:`server_name`},{title:`次数`,key:`retry_count`,width:100},{title:`下次重试`,key:`next_retry_at`,width:140},{title:`创建时间`,key:`created_at`,width:160},{title:``,key:`actions`,width:120,align:`end`,sortable:!1}];async function z(){A.value=!0;try{let e=(await o.getList(`/retries/`,{limit:200})).items||[];P.value&&(e=e.filter(e=>e.status===P.value)),M.value=e.length;let t=(N.value-1)*20;j.value=e.slice(t,t+20)}catch(e){j.value=[],M.value=0,k(e instanceof Error?e.message:`加载重试队列失败`,`error`)}finally{A.value=!1}}async function B(e){try{await o.post(`/retries/${e.id}/retry`),z(),k(`重试已触发`)}catch(e){k(e.message||`操作失败`,`error`)}}function V(e){I.value=e.id,F.value=!0}async function H(){if(I.value)try{await o.delete(`/retries/${I.value}`),F.value=!1,z(),k(`已删除`)}catch(e){k(e.message||`删除失败`,`error`)}}function U(e){return e===`success`?`success`:e===`failed`?`error`:e===`retrying`?`warning`:`info`}function W(e){return e===`pending`?`待重试`:e===`retrying`?`重试中`:e===`success`?`成功`:e===`failed`?`失败`:e}function G(e){return e.source_path&&e.target_path?`${e.source_path} → ${e.target_path}`:e.source_path||e.target_path||`文件推送`}return p(()=>z()),(o,f)=>(u(),l(_,{fluid:``,class:`pa-6`},{default:g(()=>[c(r,{elevation:`0`,border:``,rounded:`lg`},{default:g(()=>[c(t,{class:`d-flex align-center text-h6`},{default:g(()=>[f[5]||=d(` 重试队列 `,-1),c(v),c(S,{modelValue:P.value,"onUpdate:modelValue":[f[0]||=e=>P.value=e,f[1]||=e=>{N.value=1,z()}],items:L,"item-title":`label`,"item-value":`value`,label:`状态筛选`,variant:`outlined`,density:`compact`,"hide-details":``,style:{"max-width":`160px`},clearable:``},null,8,[`modelValue`])]),_:1}),c(C,{items:j.value,headers:R,"items-length":M.value,loading:A.value,page:N.value,"items-per-page":20,hover:``,density:`comfortable`,"onUpdate:page":f[2]||=e=>{N.value=e,z()}},{"item.status":g(({item:e})=>[c(b,{color:U(e.status),size:`x-small`,variant:`tonal`,label:``,border:`sm`},{default:g(()=>[d(s(W(e.status)),1)]),_:2},1032,[`color`])]),"item.operation":g(({item:t})=>[e(`span`,w,s(G(t)),1)]),"item.server_name":g(({item:t})=>[e(`span`,T,s(t.server_name||`—`),1)]),"item.retry_count":g(({item:t})=>[e(`span`,E,s(t.retry_count||0)+` / `+s(t.max_retries||3),1)]),"item.next_retry_at":g(({item:t})=>[e(`span`,D,s(t.next_retry_at||`—`),1)]),"item.created_at":g(({item:t})=>[e(`span`,O,s(t.created_at),1)]),"item.actions":g(({item:e})=>[e.status===`pending`||e.status===`failed`?(u(),l(a,{key:0,variant:`text`,size:`x-small`,color:`primary`,density:`compact`,onClick:t=>B(e)},{default:g(()=>[...f[6]||=[d(` 重试 `,-1)]]),_:1},8,[`onClick`])):h(``,!0),c(a,{variant:`text`,size:`x-small`,color:`error`,density:`compact`,onClick:t=>V(e)},{default:g(()=>[...f[7]||=[d(` 删除 `,-1)]]),_:1},8,[`onClick`])]),"no-data":g(()=>[...f[8]||=[e(`div`,{class:`text-center text-medium-emphasis py-6`},`暂无数据`,-1)]]),_:1},8,[`items`,`items-length`,`loading`,`page`])]),_:1}),c(x,{modelValue:F.value,"onUpdate:modelValue":f[4]||=e=>F.value=e,"max-width":`400`},{default:g(()=>[c(r,{border:``},{default:g(()=>[c(t,null,{default:g(()=>[...f[9]||=[d(`确认删除`,-1)]]),_:1}),c(i,null,{default:g(()=>[...f[10]||=[d(`确定要删除此重试任务吗？`,-1)]]),_:1}),c(n,null,{default:g(()=>[c(v),c(a,{variant:`text`,onClick:f[3]||=e=>F.value=!1},{default:g(()=>[...f[11]||=[d(`取消`,-1)]]),_:1}),c(a,{color:`error`,variant:`flat`,onClick:H},{default:g(()=>[...f[12]||=[d(`删除`,-1)]]),_:1})]),_:1})]),_:1})]),_:1},8,[`modelValue`])]),_:1}))}});export{k as default};