import{$n as e,F as t,Jn as n,L as r,Lt as i,M as a,N as o,P as s,Qn as c,Yn as l,_r as u,cr as d,jr as f,qn as p,tr as m,ur as h,xr as g}from"./index-sU2w4nsC.js";import{a as _}from"./VSelectionControl-YyHMUlWs.js";import{t as v}from"./VSpacer-UD5g6Z4d.js";import{t as y}from"./useSnackbar-D7YOfKok.js";import{t as b}from"./VChip-DPtB1uCr.js";import{t as x}from"./VDialog-hjwCU5f6.js";import{t as S}from"./VSelect-DURnzbT5.js";import{t as C}from"./VDataTableServer-CuRc0ZvC.js";var w={class:`font-weight-medium`},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=g(!1),j=g([]),M=g(0),N=g(1),P=g(null),F=g(!1),I=g(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`}];async function z(){A.value=!0;try{let e=await i.getList(`/retries/`,{page:N.value,per_page:20,status:P.value||void 0});j.value=e.items,M.value=e.total}catch{j.value=[]}finally{A.value=!1}}async function B(e){try{await i.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 i.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}return d(()=>z()),(i,d)=>(h(),n(_,{fluid:``,class:`pa-6`},{default:u(()=>[e(a,{elevation:`0`,border:``,rounded:`lg`},{default:u(()=>[e(s,{class:`d-flex align-center`},{default:u(()=>[d[5]||=c(` 重试队列 `,-1),e(v),e(S,{modelValue:P.value,"onUpdate:modelValue":[d[0]||=e=>P.value=e,d[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}),e(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":d[2]||=e=>{N.value=e,z()}},{"item.status":u(({item:t})=>[e(b,{color:U(t.status),size:`x-small`,variant:`tonal`,label:``,border:`current sm`},{default:u(()=>[c(f(W(t.status)),1)]),_:2},1032,[`color`])]),"item.operation":u(({item:e})=>[p(`span`,w,f(e.operation),1)]),"item.server_name":u(({item:e})=>[p(`span`,T,f(e.server_name||`—`),1)]),"item.retry_count":u(({item:e})=>[p(`span`,E,f(e.retry_count||0)+` / `+f(e.max_retries||3),1)]),"item.next_retry_at":u(({item:e})=>[p(`span`,D,f(e.next_retry_at||`—`),1)]),"item.created_at":u(({item:e})=>[p(`span`,O,f(e.created_at),1)]),"item.actions":u(({item:t})=>[t.status===`pending`||t.status===`failed`?(h(),n(r,{key:0,variant:`text`,size:`x-small`,color:`primary`,density:`compact`,onClick:e=>B(t)},{default:u(()=>[...d[6]||=[c(` 重试 `,-1)]]),_:1},8,[`onClick`])):l(``,!0),e(r,{variant:`text`,size:`x-small`,color:`error`,density:`compact`,onClick:e=>V(t)},{default:u(()=>[...d[7]||=[c(` 删除 `,-1)]]),_:1},8,[`onClick`])]),"no-data":u(()=>[...d[8]||=[p(`div`,{class:`text-center text-medium-emphasis py-6`},`暂无数据`,-1)]]),_:1},8,[`items`,`items-length`,`loading`,`page`])]),_:1}),e(x,{modelValue:F.value,"onUpdate:modelValue":d[4]||=e=>F.value=e,"max-width":`400`},{default:u(()=>[e(a,{border:``},{default:u(()=>[e(s,null,{default:u(()=>[...d[9]||=[c(`确认删除`,-1)]]),_:1}),e(o,null,{default:u(()=>[...d[10]||=[c(`确定要删除此重试任务吗？`,-1)]]),_:1}),e(t,null,{default:u(()=>[e(v),e(r,{variant:`text`,onClick:d[3]||=e=>F.value=!1},{default:u(()=>[...d[11]||=[c(`取消`,-1)]]),_:1}),e(r,{color:`error`,variant:`flat`,onClick:H},{default:u(()=>[...d[12]||=[c(`删除`,-1)]]),_:1})]),_:1})]),_:1})]),_:1},8,[`modelValue`])]),_:1}))}});export{k as default};