import{Ar as e,F as t,Jn as n,Kn as r,L as i,Lt as a,M as o,N as s,P as c,Qn as l,Zn as u,br as d,er as f,gr as p,lr as m,qn as h,sr as g}from"./index-MZ_Fxgyv.js";import{a as _}from"./VSelectionControl-kj1PYsfw.js";import{t as v}from"./VSpacer-KagoqJUL.js";import{t as y}from"./useSnackbar-D7YOfKok.js";import{t as b}from"./VChip-QWEdxHzy.js";import{t as x}from"./VDialog-DB3Ge-Ys.js";import{t as S}from"./VSelect-BhT1TyAm.js";import{t as C}from"./VDataTableServer-CdM7VY6J.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=f({__name:`RetriesPage`,setup(f){let k=y(),A=d(!1),j=d([]),M=d(0),N=d(1),P=d(null),F=d(!1),I=d(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 a.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 a.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 a.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 g(()=>z()),(a,d)=>(m(),h(_,{fluid:``,class:`pa-6`},{default:p(()=>[l(o,{elevation:`0`,border:``,rounded:`lg`},{default:p(()=>[l(c,{class:`d-flex align-center`},{default:p(()=>[d[5]||=u(` 重试队列 `,-1),l(v),l(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}),l(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":p(({item:t})=>[l(b,{color:U(t.status),size:`x-small`,variant:`tonal`,label:``,border:`current sm`},{default:p(()=>[u(e(W(t.status)),1)]),_:2},1032,[`color`])]),"item.operation":p(({item:t})=>[r(`span`,w,e(t.operation),1)]),"item.server_name":p(({item:t})=>[r(`span`,T,e(t.server_name||`—`),1)]),"item.retry_count":p(({item:t})=>[r(`span`,E,e(t.retry_count||0)+` / `+e(t.max_retries||3),1)]),"item.next_retry_at":p(({item:t})=>[r(`span`,D,e(t.next_retry_at||`—`),1)]),"item.created_at":p(({item:t})=>[r(`span`,O,e(t.created_at),1)]),"item.actions":p(({item:e})=>[e.status===`pending`||e.status===`failed`?(m(),h(i,{key:0,variant:`text`,size:`x-small`,color:`primary`,density:`compact`,onClick:t=>B(e)},{default:p(()=>[...d[6]||=[u(` 重试 `,-1)]]),_:1},8,[`onClick`])):n(``,!0),l(i,{variant:`text`,size:`x-small`,color:`error`,density:`compact`,onClick:t=>V(e)},{default:p(()=>[...d[7]||=[u(` 删除 `,-1)]]),_:1},8,[`onClick`])]),"no-data":p(()=>[...d[8]||=[r(`div`,{class:`text-center text-medium-emphasis py-6`},`暂无数据`,-1)]]),_:1},8,[`items`,`items-length`,`loading`,`page`])]),_:1}),l(x,{modelValue:F.value,"onUpdate:modelValue":d[4]||=e=>F.value=e,"max-width":`400`},{default:p(()=>[l(o,{border:``},{default:p(()=>[l(c,null,{default:p(()=>[...d[9]||=[u(`确认删除`,-1)]]),_:1}),l(s,null,{default:p(()=>[...d[10]||=[u(`确定要删除此重试任务吗？`,-1)]]),_:1}),l(t,null,{default:p(()=>[l(v),l(i,{variant:`text`,onClick:d[3]||=e=>F.value=!1},{default:p(()=>[...d[11]||=[u(`取消`,-1)]]),_:1}),l(i,{color:`error`,variant:`flat`,onClick:H},{default:p(()=>[...d[12]||=[u(`删除`,-1)]]),_:1})]),_:1})]),_:1})]),_:1},8,[`modelValue`])]),_:1}))}});export{k as default};