1import{r as t,j as e}from"./index-1VVh9pK_.js";import{a as z,u as P,v as D,w as F}from"./portal-CPM6yy9L.js";const A=()=>{const[h,v]=t.useState([]),[b,w]=t.useState(0),[r,d]=t.useState(1),[u]=t.useState(10),[S,f]=t.useState(!1),[C,c]=t.useState(null),[a,i]=t.useState({clientId:0,subject:"",content:""}),[j,g]=t.useState(!1),[N,n]=t.useState(""),[o,k]=t.useState([]),[x,y]=t.useState("");t.useEffect(()=>{z({pageSize:500}).then(s=>{s.code===200&&k(s.rows??[])}).catch(()=>{})},[]);const m=t.useCallback(async()=>{f(!0);try{const s={pageNum:r,pageSize:u};x&&(s.clientId=x);const l=await P(s);l.code===200&&(v(l.rows??[]),w(l.total??0))}finally{f(!1)}},[r,u,x]);t.useEffect(()=>{m()},[m]);const I=()=>{i({clientId:o[0]?.id??0,subject:"",content:""}),n(""),c("send")},M=async()=>{if(!a.clientId){n("è¯·éæ©å®¢æ·");return}if(!a.subject){n("主é¢ä¸è½ä¸ºç©º");return}if(!a.content){n("å
容ä¸è½ä¸ºç©º");return}g(!0),n("");try{const s=await F(a);s.code===200?(c(null),m()):n(s.msg||"åé失败")}catch{n("ç½ç»é误")}finally{g(!1)}},E=async s=>{if(!confirm("确认å é¤è¯¥æ¶æ¯ï¼"))return;(await D(String(s))).code===200&&m()},L=s=>o.find(l=>l.id===s)?.companyName??`客æ·#${s}`,p=Math.ceil(b/u);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h1",{className:"text-lg font-bold text-slate-800",children:"æ¶æ¯ç®¡ç"}),e.jsxs("button",{onClick:I,className:"flex items-center gap-2 px-4 py-2 bg-red-600 text-white text-sm rounded-lg hover:bg-red-700",children:[e.jsx("i",{className:"ri-send-plane-line"}),"åéæ¶æ¯"]})]}),e.jsxs("div",{className:"bg-white rounded-xl shadow-sm border border-slate-100 px-4 py-3 flex items-center gap-3",children:[e.jsxs("select",{value:x,onChange:s=>{y(s.target.value),d(1)},className:"px-3 py-1.5 border border-slate-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-red-500",children:[e.jsx("option",{value:"",children:"å
¨é¨å®¢æ·"}),o.map(s=>e.jsx("option",{value:s.id,children:s.companyName},s.id))]}),e.jsx("button",{onClick:()=>{y(""),d(1)},className:"text-xs text-slate-400 hover:text-slate-600",children:"éç½®"})]}),e.jsxs("div",{className:"bg-white rounded-xl shadow-sm border border-slate-100 overflow-hidden",children:[e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-slate-50 border-b border-slate-100",children:e.jsx("tr",{children:["客æ·","å件人","主é¢","å
容æè¦","æ¶é´","æä½"].map(s=>e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-slate-500",children:s},s))})}),e.jsx("tbody",{className:"divide-y divide-slate-50",children:S?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"text-center py-12 text-slate-400",children:"å è½½ä¸..."})}):h.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"text-center py-12 text-slate-400",children:"ææ æ¶æ¯"})}):h.map(s=>e.jsxs("tr",{className:"hover:bg-slate-50",children:[e.jsx("td",{className:"px-4 py-3 text-xs font-medium text-slate-700",children:L(s.clientId)}),e.jsx("td",{className:"px-4 py-3 text-xs text-slate-500",children:s.from??"-"}),e.jsx("td",{className:"px-4 py-3 font-medium text-slate-800 max-w-[180px] truncate",children:s.subject}),e.jsx("td",{className:"px-4 py-3 text-xs text-slate-500 max-w-[220px] truncate",children:s.content}),e.jsx("td",{className:"px-4 py-3 text-xs text-slate-400",children:s.createTime?.slice(0,16)}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("button",{onClick:()=>E(s.id),className:"text-red-600 hover:text-red-700 text-xs",children:"å é¤"})})]},s.id))})]}),p>1&&e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t border-slate-100",children:[e.jsxs("span",{className:"text-xs text-slate-500",children:["å
± ",b," æ¡"]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{disabled:r===1,onClick:()=>d(s=>s-1),className:"px-3 py-1 text-xs border border-slate-200 rounded disabled:opacity-40 hover:bg-slate-50",children:"ä¸ä¸é¡µ"}),e.jsxs("span",{className:"px-3 py-1 text-xs text-slate-600",children:[r," / ",p]}),e.jsx("button",{disabled:r===p,onClick:()=>d(s=>s+1),className:"px-3 py-1 text-xs border border-slate-200 rounded disabled:opacity-40 hover:bg-slate-50",children:"ä¸ä¸é¡µ"})]})]})]}),C==="send"&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white rounded-xl shadow-xl w-full max-w-lg",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-slate-100",children:[e.jsx("h3",{className:"font-semibold text-slate-800",children:"åéæ¶æ¯ç»å®¢æ·"}),e.jsx("button",{onClick:()=>c(null),className:"text-slate-400 hover:text-slate-600",children:e.jsx("i",{className:"ri-close-line text-xl"})})]}),e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-slate-700 mb-1",children:"æ¶ä»¶å®¢æ·"}),e.jsxs("select",{value:a.clientId,onChange:s=>i(l=>({...l,clientId:Number(s.target.value)})),className:"w-full px-3 py-2 border border-slate-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-red-500",children:[e.jsx("option",{value:0,children:"è¯·éæ©å®¢æ·"}),o.map(s=>e.jsxs("option",{value:s.id,children:[s.companyName,s.contactName?` (${s.contactName})`:""]},s.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-slate-700 mb-1",children:"主é¢"}),e.jsx("input",{value:a.subject,onChange:s=>i(l=>({...l,subject:s.target.value})),className:"w-full px-3 py-2 border border-slate-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-red-500",placeholder:"æ¶æ¯ä¸»é¢"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-slate-700 mb-1",children:"å
容"}),e.jsx("textarea",{rows:5,value:a.content,onChange:s=>i(l=>({...l,content:s.target.value})),className:"w-full px-3 py-2 border border-slate-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-red-500 resize-none",placeholder:"æ¶æ¯å
容..."})]}),N&&e.jsx("p",{className:"text-sm text-red-600 bg-red-50 px-3 py-2 rounded-lg",children:N})]}),e.jsxs("div",{className:"flex justify-end gap-3 px-6 py-4 border-t border-slate-100",children:[e.jsx("button",{onClick:()=>c(null),className:"px-4 py-2 text-sm border border-slate-200 rounded-lg hover:bg-slate-50",children:"åæ¶"}),e.jsx("button",{onClick:M,disabled:j,className:"px-4 py-2 text-sm bg-red-600 text-white rounded-lg hover:bg-red-700 disabled:opacity-60",children:j?"åéä¸...":"åé"})]})]})})]})};export{A as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.