import{n as e,t}from"./useSnackbar-BFeYjAzp.js";import{Er as n,I as r,Or as i,Sr as a,Tr as o,Vr as s,Zr as c,_ as l,br as u,di as d,en as f,hi as p,ii as m,qt as h,xr as g,y as _}from"./index-BKLG6eUi.js";import{t as v}from"./usePageActivateRefresh-BXQgZGHS.js";import{n as y}from"./dataTable-esDY4cOk.js";import{S as b,_ as x,b as S,v as C}from"./VTextField-Bs8XQAKI.js";import{t as w}from"./VSelect-Dy70bHJm.js";import{t as T}from"./VDataTableServer-GLUwxaQu.js";import{t as E}from"./VDialog-CfMJJXmK.js";import{t as D}from"./usePageAutoRefresh-DiikOfci.js";var O={class:`font-weight-medium text-truncate d-inline-block`,style:{"max-width":`240px`}},k={class:`text-medium-emphasis`},A={class:`text-medium-emphasis`},j={class:`text-caption text-medium-emphasis`},M={class:`text-caption text-medium-emphasis`},N=i({name:`RetriesPage`,__name:`RetriesPage`,setup(i){let N=t(),P=m(!1),F=m([]),I=m(0),L=m(1),R=m(null),z=m(!1),B=m(null),V=[{label:`待重试`,value:`pending`},{label:`重试中`,value:`retrying`},{label:`成功`,value:`success`},{label:`失败`,value:`failed`}],H=y([{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 U(e=!1){e||(P.value=!0);try{let e=(await f.getList(`/retries/`,{limit:200})).items||[];R.value&&(e=e.filter(e=>e.status===R.value)),I.value=e.length;let t=(L.value-1)*20;F.value=e.slice(t,t+20)}catch(t){e||(F.value=[],I.value=0,N(t instanceof Error?t.message:`加载重试队列失败`,`error`))}finally{e||(P.value=!1)}}async function W(e){try{await f.post(`/retries/${e.id}/retry`),U(),N(`重试已触发`)}catch(e){N(e.message||`操作失败`,`error`)}}function G(e){B.value=e.id,z.value=!0}async function K(){if(B.value)try{await f.delete(`/retries/${B.value}`),z.value=!1,U(),N(`已删除`)}catch(e){N(e.message||`删除失败`,`error`)}}function q(e){return e===`success`?`success`:e===`failed`?`error`:e===`retrying`?`warning`:`info`}function J(e){return e===`pending`?`待重试`:e===`retrying`?`重试中`:e===`success`?`成功`:e===`failed`?`失败`:e}function Y(e){return e.source_path&&e.target_path?`${e.source_path} → ${e.target_path}`:e.source_path||e.target_path||`文件推送`}return D(()=>U(!0),15e3),v(e=>U(e)),(t,i)=>(s(),g(e,{fluid:``,class:`pa-6`},{default:c(()=>[n(x,{elevation:`0`,border:``,rounded:`lg`},{default:c(()=>[n(S,{class:`d-flex align-center text-h6`},{default:c(()=>[i[5]||=o(` 重试队列 `,-1),n(l),n(w,{modelValue:R.value,"onUpdate:modelValue":[i[0]||=e=>R.value=e,i[1]||=e=>{L.value=1,U()}],items:V,"item-title":`label`,"item-value":`value`,label:`状态筛选`,variant:`outlined`,density:`compact`,"hide-details":``,style:{"max-width":`160px`},clearable:``},null,8,[`modelValue`])]),_:1}),n(T,{items:F.value,headers:d(H),"items-length":I.value,loading:P.value,page:L.value,"items-per-page":20,hover:``,density:`comfortable`,"onUpdate:page":i[2]||=e=>{L.value=e,U()}},{"item.status":c(({item:e})=>[n(_,{color:q(e.status),size:`x-small`,variant:`tonal`,label:``,border:`sm`},{default:c(()=>[o(p(J(e.status)),1)]),_:2},1032,[`color`])]),"item.operation":c(({item:e})=>[u(`span`,O,p(Y(e)),1)]),"item.server_name":c(({item:e})=>[u(`span`,k,p(e.server_name||`—`),1)]),"item.retry_count":c(({item:e})=>[u(`span`,A,p(e.retry_count||0)+` / `+p(e.max_retries||3),1)]),"item.next_retry_at":c(({item:e})=>[u(`span`,j,p(d(h)(e.next_retry_at)),1)]),"item.created_at":c(({item:e})=>[u(`span`,M,p(d(h)(e.created_at)),1)]),"item.actions":c(({item:e})=>[e.status===`pending`||e.status===`failed`?(s(),g(r,{key:0,variant:`text`,size:`x-small`,color:`primary`,density:`compact`,onClick:t=>W(e)},{default:c(()=>[...i[6]||=[o(` 重试 `,-1)]]),_:1},8,[`onClick`])):a(``,!0),n(r,{variant:`text`,size:`x-small`,color:`error`,density:`compact`,onClick:t=>G(e)},{default:c(()=>[...i[7]||=[o(` 删除 `,-1)]]),_:1},8,[`onClick`])]),"no-data":c(()=>[...i[8]||=[u(`div`,{class:`text-center text-medium-emphasis py-6`},`暂无数据`,-1)]]),_:1},8,[`items`,`headers`,`items-length`,`loading`,`page`])]),_:1}),n(E,{modelValue:z.value,"onUpdate:modelValue":i[4]||=e=>z.value=e,"max-width":`400`},{default:c(()=>[n(x,{border:``},{default:c(()=>[n(S,null,{default:c(()=>[...i[9]||=[o(`确认删除`,-1)]]),_:1}),n(C,null,{default:c(()=>[...i[10]||=[o(`确定要删除此重试任务吗？`,-1)]]),_:1}),n(b,null,{default:c(()=>[n(l),n(r,{variant:`text`,onClick:i[3]||=e=>z.value=!1},{default:c(()=>[...i[11]||=[o(`取消`,-1)]]),_:1}),n(r,{color:`error`,variant:`flat`,onClick:K},{default:c(()=>[...i[12]||=[o(`删除`,-1)]]),_:1})]),_:1})]),_:1})]),_:1},8,[`modelValue`])]),_:1}))}});export{N as default};