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