import{j as e}from"./index-3808da28.js";import{d as C,r as o,C as S,y as d,H as w,B as a,P as z,T,a5 as E,E as N,Q as P,V as R,m as u}from"./vendor-61f0f29a.js";import{u as b}from"./useResource-9c541112.js";const v=()=>{const r=C(),[l,h]=o.useState({current:1,pageSize:10}),[x,m]=o.useState({field:"created_at",order:"descend"}),{resources:p,loading:g,total:c,fetchResources:i,deleteResource:k}=b(l,x,"task");o.useEffect(()=>{i()},[]);const j=(t,s,n)=>{h(t),m(n),i({current:t.current,pageSize:t.pageSize,field:n.field,order:n.order})},f=async t=>{try{await k(t),u.success("删除成功"),i()}catch(s){u.error("删除失败："+s.message)}},y=[{title:"任务名称",dataIndex:["attributes","taskName"],key:"taskName",ellipsis:!0},{title:"创建日期",dataIndex:"created_at",key:"created_at",sorter:!0,render:t=>e.jsx("span",{children:new Date(t).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})})},{title:"操作",width:250,key:"action",render:(t,s)=>e.jsxs(d,{size:0,children:[e.jsx(a,{size:"small",type:"link",icon:e.jsx(E,{}),onClick:()=>r(`/resource/task/edit/${s.id}`),children:"查看"}),e.jsx(a,{size:"small",type:"link",icon:e.jsx(N,{}),onClick:()=>r(`/resource/task/edit/${s.id}?edit=true`),children:"编辑"}),e.jsx(P,{title:"确定要删除这个任务吗？",description:"删除后将无法恢复！",onConfirm:()=>f(s.id),okText:"确定",cancelText:"取消",okButtonProps:{danger:!0},children:e.jsx(a,{size:"small",type:"link",danger:!0,icon:e.jsx(R,{}),children:"删除"})})]})}];return e.jsx(S,{title:e.jsxs(d,{children:[e.jsx("span",{children:"任务管理"}),e.jsxs(w,{color:"blue",children:[c," 个任务"]})]}),className:"h-full w-full overflow-auto",extra:e.jsx(a,{type:"primary",icon:e.jsx(z,{}),onClick:()=>r("/resource/task/edit"),children:"新增任务"}),children:e.jsx(T,{columns:y,dataSource:p,rowKey:"id",loading:g,onChange:j,pagination:{...l,total:c,showSizeChanger:!0,showQuickJumper:!0,showTotal:t=>`共 ${t} 条记录`}})})};export{v as default};
//# sourceMappingURL=index-b33c2304.js.map
