PageSourceSearch

https://fozl.sg/assets/page-CW_kS8iC.js

js fozl.sg collected 2026-10-07 15:21:47 UTC 6,660 bytes, 1 lines download raw bytes

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.