import{j as e}from"./index-3808da28.js";import{d as w,r as i,C,y as d,H as u,B as n,P as z,T as b,E as I,Q as T,V as P,m as p}from"./vendor-61f0f29a.js";import{u as v}from"./useResource-9c541112.js";const B=()=>{const o=w(),[l,h]=i.useState({current:1,pageSize:10}),[x,m]=i.useState({field:"created_at",order:"descend"}),{resources:g,loading:f,total:c,fetchResources:s,deleteResource:y}=v(l,x,"supplier");i.useEffect(()=>{s()},[]);const j=(t,r,a)=>{h(t),m(a),s({current:t.current,pageSize:t.pageSize,field:a.field,order:a.order})},k=async t=>{try{await y(t),p.success("删除成功"),s()}catch(r){p.error("删除失败："+r.message)}},S=[{title:"供应商名称",dataIndex:["attributes","name"],key:"name",ellipsis:!0},{title:"联系人",dataIndex:["attributes","contact"],key:"contact"},{title:"电话",dataIndex:["attributes","phone"],key:"phone"},{title:"状态",dataIndex:["attributes","status"],key:"status",render:t=>e.jsx(u,{color:t==="active"?"green":"red",children:t==="active"?"启用":"禁用"})},{title:"创建日期",dataIndex:"created_at",key:"created_at",sorter:!0,width:180,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:"操作",key:"action",width:150,render:(t,r)=>e.jsxs(d,{size:0,children:[e.jsx(n,{size:"small",type:"link",icon:e.jsx(I,{}),onClick:()=>o(`/company/supplierInfo/${r.id}?edit=true`),children:"编辑"}),e.jsx(T,{title:"确定要删除这个供应商吗？",description:"删除后将无法恢复！",onConfirm:()=>k(r.id),okText:"确定",cancelText:"取消",okButtonProps:{danger:!0},children:e.jsx(n,{size:"small",type:"link",danger:!0,icon:e.jsx(P,{}),children:"删除"})})]})}];return e.jsx(C,{title:e.jsxs(d,{children:[e.jsx("span",{children:"供应商管理"}),e.jsxs(u,{color:"blue",children:[c," 个供应商"]})]}),className:"h-full w-full overflow-auto",extra:e.jsx(n,{type:"primary",icon:e.jsx(z,{}),onClick:()=>o("/company/supplierInfo"),children:"新增供应商"}),children:e.jsx(b,{columns:S,dataSource:g,rowKey:"id",loading:f,onChange:j,pagination:{...l,total:c,showSizeChanger:!0,showQuickJumper:!0,showTotal:t=>`共 ${t} 条记录`}})})};export{B as default};
//# sourceMappingURL=index-71676cce.js.map
