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