PageSourceSearch

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

js fozl.sg collected 2026-10-07 15:21:48 UTC 7,558 bytes, 1 lines download raw bytes

1import{r as l,j as e}from"./index-1VVh9pK_.js";import{a as B,x as F,y as R,z as A,A as T}from"./portal-CPM6yy9L.js";const M=t=>{if(!t)return"";const i=Number(t);return isNaN(i)?t:i<1024?`${i} B`:i<1024*1024?`${(i/1024).toFixed(1)} KB`:`${(i/1024/1024).toFixed(1)} MB`},O=t=>t?t.includes("pdf")?"ri-file-pdf-line":t.includes("image")?"ri-image-line":t.includes("word")||t.includes("document")?"ri-file-word-line":t.includes("excel")||t.includes("sheet")?"ri-file-excel-line":t.includes("zip")||t.includes("rar")?"ri-file-zip-line":"ri-file-text-line":"ri-file-line",_=()=>{const[t,i]=l.useState([]),[g,k]=l.useState(0),[r,u]=l.useState(1),[m]=l.useState(10),[D,y]=l.useState(!1),[f,I]=l.useState([]),[c,U]=l.useState(""),[v,w]=l.useState(!1),[p,h]=l.useState(0),[b,E]=l.useState(""),[z,o]=l.useState(!1),[S,C]=l.useState(null),j=l.useRef(null);l.useEffect(()=>{B({pageSize:500}).then(s=>{s.code===200&&I(s.rows??[])}).catch(()=>{})},[]);const x=l.useCallback(async()=>{y(!0);try{const s={pageNum:r,pageSize:m};c&&(s.clientId=c);const a=await F(s);a.code===200&&(i(a.rows??[]),k(a.total??0))}finally{y(!1)}},[r,m,c]);l.useEffect(()=>{x()},[x]);const L=async s=>{const a=s.target.files?.[0];if(a){w(!0),h(0);try{const n=new FormData;n.append("file",a),b&&n.append("clientId",b);const d=await T(n,h);d.code===200?(o(!1),x(),alert("上传成功")):alert(d.msg||"上传失败")}catch(n){n?.code==="ECONNABORTED"||n?.message?.includes("timeout")?alert("上传超时,请检查网络或稍后重试"):alert("上传失败:"+(n?.message||"未知错误"))}finally{w(!1),h(0),j.current&&(j.current.value="")}}},P=async s=>{C(s.id);try{const a=await R(s.id),n=a.data;if(a.code===200&&n){const d=document.createElement("a");d.href=n,d.download=s.name,d.target="_blank",d.click()}}catch{}finally{C(null)}},$=async s=>{if(!confirm("确认删除该文件?"))return;(await A(String(s))).code===200&&x()},N=Math.ceil(g/m);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:()=>o(!0),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-upload-2-line"}),"上传文件"]})]}),e.jsx("div",{className:"flex gap-3",children:e.jsxs("select",{value:c,onChange:s=>{U(s.target.value),u(1)},className:"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:"",children:"全部客户"}),f.map(s=>e.jsx("option",{value:s.id,children:s.companyName},s.id))]})}),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:D?e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"text-center py-12 text-slate-400",children:"加载中..."})}):t.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"text-center py-12 text-slate-400",children:"暂无文件"})}):t.map(s=>e.jsxs("tr",{className:"hover:bg-slate-50",children:[e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("i",{className:`${O(s.type)} text-red-500`}),e.jsx("span",{className:"font-medium text-slate-800 max-w-[200px] truncate",children:s.name})]})}),e.jsx("td",{className:"px-4 py-3 text-xs text-slate-500",children:f.find(a=>a.id===s.clientId)?.companyName||e.jsx("span",{className:"text-slate-300",children:"—"})}),e.jsx("td",{className:"px-4 py-3 text-xs text-slate-400",children:s.type||"—"}),e.jsx("td",{className:"px-4 py-3 text-xs text-slate-400",children:M(s.size)}),e.jsx("td",{className:"px-4 py-3 text-xs text-slate-400",children:s.uploader||"—"}),e.jsx("td",{className:"px-4 py-3 text-xs text-slate-400",children:s.uploadTime?.slice(0,10)||"—"}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>P(s),disabled:S===s.id,className:"text-blue-600 hover:text-blue-700 text-xs disabled:opacity-40",children:S===s.id?"获取中...":"下载"}),e.jsx("button",{onClick:()=>$(s.id),className:"text-red-600 hover:text-red-700 text-xs",children:"删除"})]})})]},s.id))})]}),N>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:["共 ",g," 条"]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{disabled:r===1,onClick:()=>u(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," / ",N]}),e.jsx("button",{disabled:r===N,onClick:()=>u(s=>s+1),className:"px-3 py-1 text-xs border border-slate-200 rounded disabled:opacity-40 hover:bg-slate-50",children:"下一页"})]})]})]}),z&&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-md",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:()=>o(!1),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:b,onChange:s=>E(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:"",children:"公共(所有客户可见)"}),f.map(s=>e.jsx("option",{value:s.id,children:s.companyName},s.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-slate-700 mb-1",children:"选择文件"}),e.jsx("input",{ref:j,type:"file",onChange:L,disabled:v,className:"w-full text-sm text-slate-600 file:mr-4 file:py-2 file:px-4 file:rounded-lg file:border-0 file:text-sm file:font-medium file:bg-red-50 file:text-red-600 hover:file:bg-red-100 disabled:opacity-50"})]}),v&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-xs text-slate-500",children:[e.jsx("span",{children:"上传中,请勿关闭..."}),e.jsxs("span",{children:[p,"%"]})]}),e.jsx("div",{className:"w-full bg-slate-100 rounded-full h-2",children:e.jsx("div",{className:"bg-red-500 h-2 rounded-full transition-all duration-300",style:{width:`${p}%`}})}),p===100&&e.jsx("p",{className:"text-xs text-slate-400 text-center",children:"文件已传输,等待服务器处理..."})]})]}),e.jsx("div",{className:"flex justify-end px-6 py-4 border-t border-slate-100",children:e.jsx("button",{onClick:()=>o(!1),className:"px-4 py-2 text-sm border border-slate-200 rounded-lg hover:bg-slate-50",children:"取消"})})]})})]})};export{_ 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.