2 lines
31 KiB
JavaScript
2 lines
31 KiB
JavaScript
import{j as e,b as U,r as a}from"./react-vendor-C_od1ZSF.js";import{i as ee,I as te,X as H,J as ae,R as W,N as le,O as X,m as K,E as re,v as ne,V as ie,F as ce,d as de,c as oe,r as xe}from"./icons-vendor-ThcsWkZG.js";import{D as me,h as ue,a as he,E as ge,F as pe,G as be,H as ye,I as je,J as fe}from"./index-DK02p8DH.js";import{f as Y}from"./dateTime-DDi7rqpW.js";const ve=[{key:"all",label:"全部"},{key:"processing",label:"处理中"},{key:"shipped",label:"已发货"},{key:"pending_ship",label:"待发货"},{key:"completed",label:"已完成"},{key:"cancelled",label:"已取消"},{key:"refunding",label:"退款中"}],Ne=s=>{const r=typeof s=="object"&&s!==null?s:{},m=Array.isArray(r.results)?r.results:[];return{total:Number(r.total||0),success_count:Number(r.success_count||0),failed_count:Number(r.failed_count||0),results:m.map(we)}},we=s=>{const r=typeof s=="object"&&s!==null?s:{};return{order_id:String(r.order_id||"unknown"),success:r.success===!0,message:String(r.message||"")}},_e=s=>(s==null?void 0:s.results.filter(ke))||[],ke=s=>!s.success,Ce=(s,r)=>s!==null&&!r,Se=s=>{if(!s)return"请选择订单文件";const r=s.name.toLowerCase().split(".").pop()||"";return["xlsx","csv","tsv","json"].includes(r)?"":"仅支持 .xlsx、.csv、.tsv、.json 格式"},q=(s,r)=>s===r,Ie=(s,r)=>s instanceof Error&&s.message?s.message:r,Ee=({filter:s,onFilterChange:r,accountFilter:m,onAccountFilterChange:p,accounts:j,accountName:x,searchText:b,onSearchChange:N})=>{const E=n=>r(n.currentTarget.dataset.status||"all"),S=n=>p(n.target.value),f=n=>N(n.target.value);return e.jsxs("div",{className:"p-4 border-b border-gray-50 flex flex-col md:flex-row gap-4 justify-between items-center bg-surface-muted",children:[e.jsx("div",{className:"flex gap-1 p-1 bg-gray-200/50 rounded-xl overflow-x-auto max-w-full",children:ve.map(n=>e.jsx("button",{"data-status":n.key,onClick:E,className:`px-5 py-2 rounded-lg text-sm font-bold transition-all whitespace-nowrap ${s===n.key?"bg-white text-black shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:n.label},n.key))}),e.jsxs("div",{className:"flex w-full md:w-auto flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(ee,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{"aria-label":"按账号筛选订单",value:m,onChange:S,className:"ios-input pl-10 pr-9 py-2.5 rounded-xl w-full sm:w-56 bg-white border-none shadow-sm",children:[e.jsx("option",{value:"",children:"全部账号"}),j.map(n=>e.jsx("option",{value:n.id,children:x(n.id)},n.id))]})]}),e.jsxs("div",{className:"relative group",children:[e.jsx(te,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 group-focus-within:text-brand transition-colors"}),e.jsx("input",{type:"text",placeholder:"搜索订单号/商品/买家...",value:b,onChange:f,className:"ios-input pl-10 pr-4 py-2.5 rounded-xl w-64 bg-white border-none shadow-sm focus:ring-0"})]})]})]})},Oe=s=>{const r=x=>{var b;s.setImportFile(((b=x.target.files)==null?void 0:b[0])||null)},m=()=>s.closeImportModal(),p=()=>void s.handleImportOrders(),j=()=>void s.handleRetryImport();return s.showImportModal?U.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"插入订单"}),e.jsx("button",{onClick:m,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(H,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"选择Excel文件"}),e.jsx("input",{type:"file",accept:".xlsx,.csv,.tsv,.json",onChange:r,className:"w-full ios-input px-4 py-3 rounded-xl text-sm"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"支持 .xlsx、.csv、.tsv、.json 格式"})]}),s.importFile&&e.jsx("div",{className:"p-3 bg-blue-50 rounded-xl",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"w-4 h-4 text-blue-600"}),e.jsx("span",{className:"text-sm font-medium text-blue-900",children:s.importFile.name})]})}),s.importError&&e.jsxs("div",{className:"rounded-xl bg-red-50 border border-red-100 p-3 text-sm text-red-700 flex items-center justify-between gap-3",children:[e.jsx("span",{children:s.importError}),e.jsx("button",{type:"button",onClick:j,disabled:s.importing||!s.importFile,className:"font-bold whitespace-nowrap",children:"重试"})]}),s.importResult&&s.importResult.failed_count>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-xl bg-amber-50 border border-amber-100 p-3 text-sm font-bold text-amber-800",children:["导入完成:成功 ",s.importResult.success_count," 条,失败 ",s.importResult.failed_count," 条"]}),e.jsx("div",{className:"max-h-64 overflow-y-auto rounded-xl border border-gray-100",children:e.jsxs("table",{className:"w-full text-left text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-gray-50 text-gray-500",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2",children:"订单ID"}),e.jsx("th",{className:"px-3 py-2",children:"失败原因"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100",children:_e(s.importResult).map((x,b)=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 font-mono",children:x.order_id}),e.jsx("td",{className:"px-3 py-2 text-red-600",children:x.message||"导入失败"})]},`${x.order_id}-${b}`))})]})})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:m,className:"flex-1 px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:"取消"}),e.jsx("button",{onClick:p,disabled:!s.importFile||s.importing,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:s.importing?"正在导入…":"导入订单"})]})})]})}),document.body):null},Me=(s={pageSize:20})=>{const[r,m]=a.useState([]),[p,j]=a.useState([]),[x,b]=a.useState([]),[N,E]=a.useState("all"),[S,f]=a.useState(""),[n,d]=a.useState(""),[F,$]=a.useState(""),[I,w]=a.useState(1),[_,A]=a.useState(1),[O,i]=a.useState(!1),y=a.useRef(0),u=a.useRef(null),M=a.useRef(null),R=a.useCallback(async()=>{var h;const c=++y.current;(h=u.current)==null||h.abort();const o=new AbortController;u.current=o,i(!0);try{const k=await me(S||void 0,N,I,s.pageSize,F,{signal:o.signal});if(!q(c,y.current))return;m(k.data),A(k.total_pages)}catch(k){q(c,y.current)&&!o.signal.aborted&&console.error("加载订单失败:",k)}finally{q(c,y.current)&&i(!1)}},[S,F,N,s.pageSize,I]);a.useEffect(()=>{const c=window.setTimeout(()=>{w(1),$(n.trim())},300);return(()=>window.clearTimeout(c))},[n]),a.useEffect(()=>(R(),(()=>{var c;y.current+=1,(c=u.current)==null||c.abort()})),[R]),a.useEffect(()=>{var o;const c=new AbortController;return(o=M.current)==null||o.abort(),M.current=c,Promise.all([ue({signal:c.signal}),he(void 0,{signal:c.signal})]).then(([h,k])=>{c.signal.aborted||(b(h),j(k))}).catch(h=>{c.signal.aborted||console.error("加载订单辅助数据失败:",h)}),(()=>c.abort())},[]);const v=a.useMemo(()=>new Map(x.map(c=>[c.id,c])),[x]),P=a.useMemo(()=>{const c={};return p.forEach(o=>{o.item_id&&(c[`${o.cookie_id}:${o.item_id}`]=o.item_title||o.item_id)}),c},[p]),G=a.useCallback(c=>{const o=v.get(c),h=(o==null?void 0:o.remark)||(o==null?void 0:o.nickname);return h?`${h} · ${c.slice(0,6)}`:`账号 ${c.slice(0,8)}`},[v]),V=a.useCallback(c=>{const o=v.get(c);return(o==null?void 0:o.remark)||(o==null?void 0:o.nickname)||"未命名账号"},[v]),z=a.useCallback((c,o,h)=>{if(h!=null&&h.trim())return h;const k=P[`${c}:${o}`];if(k)return k;const C=p.find(T=>{if(!h||!T.item_title)return!1;const B=h.toLowerCase(),L=T.item_title.toLowerCase();return L.includes(B)||B.includes(L)});return(C==null?void 0:C.item_title)||"未知商品"},[P,p]);return{orders:r,items:p,accounts:x,filter:N,setFilter:E,accountFilter:S,setAccountFilter:f,searchText:n,setSearchText:d,page:I,setPage:w,totalPages:_,loading:O,loadOrders:R,accountName:G,accountNickname:V,getItemNameById:z}},Fe=s=>{const[r,m]=a.useState(!1),[p,j]=a.useState(null),[x,b]=a.useState(null),[N,E]=a.useState(!1),[S,f]=a.useState(""),n=a.useRef(0),d=a.useRef(null),F=a.useCallback(()=>{j(null),b(null),f(""),m(!0)},[]),$=a.useCallback(()=>{var _;n.current+=1,(_=d.current)==null||_.abort(),E(!1),m(!1),j(null),b(null),f("")},[]),I=a.useCallback(async()=>{var y;if(!Ce(p,N))return;const _=p;if(!_)return;const A=Se(_);if(A){f(A);return}const O=++n.current;(y=d.current)==null||y.abort();const i=new AbortController;d.current=i,E(!0),b(null),f("");try{const u=new FormData;u.append("file",_);const M=Ne(await ge(u,{signal:i.signal}));if(!q(O,n.current))return;b(M),j(null),await s(),M.failed_count===0&&q(O,n.current)&&(alert(`订单导入成功,共 ${M.success_count} 条`),m(!1),b(null))}catch(u){q(O,n.current)&&!i.signal.aborted&&f(Ie(u,"导入失败,请检查文件格式"))}finally{q(O,n.current)&&E(!1)}},[p,N,s]),w=a.useCallback(async()=>{await I()},[I]);return{showImportModal:r,importFile:p,setImportFile:j,importResult:x,importing:N,importError:S,openImportModal:F,closeImportModal:$,handleImportOrders:I,handleRetryImport:w}},Q=(s,r)=>s instanceof Error?s.message:r,Re=({orders:s,page:r,accountFilter:m,filter:p,setPage:j,loadOrders:x})=>{const[b,N]=a.useState(!1),[E,S]=a.useState(null),[f,n]=a.useState(!1),[d,F]=a.useState(null),[$,I]=a.useState(!1),[w,_]=a.useState(""),[A,O]=a.useState(!1),[i,y]=a.useState(null),[u,M]=a.useState(null),[R,v]=a.useState(null),P=a.useCallback(async()=>{try{const l=await pe(m||void 0,p);await x(),l.message&&alert(l.message)}catch(l){console.error("同步订单失败:",l),alert(Q(l,"同步失败,请重试"))}},[m,p,x]),G=a.useCallback(l=>{_(l),y(null),I(!0)},[]),V=a.useCallback(async l=>{var g;O(!0),y(null);try{const D=(g=(await be([w],l)).results)==null?void 0:g[0];D!=null&&D.success?(y({success:!0,message:D.message}),x()):y({success:!1,message:(D==null?void 0:D.message)||"发货失败"})}catch(J){y({success:!1,message:Q(J,"请求失败")})}finally{O(!1)}},[x,w]),z=a.useCallback(l=>{S(l),N(!0)},[]),c=a.useCallback(l=>{F({...l}),n(!0)},[]),o=a.useCallback(l=>{F(g=>g&&{...g,...l})},[]),h=a.useCallback(async()=>{if(d!=null&&d.order_id)try{const l={};d.status!==void 0&&(l.order_status=d.status),d.buyer_id!==void 0&&(l.buyer_id=d.buyer_id),d.amount!==void 0&&(l.amount=d.amount),d.receiver_name!==void 0&&(l.receiver_name=d.receiver_name),d.receiver_phone!==void 0&&(l.receiver_phone=d.receiver_phone),d.receiver_address!==void 0&&(l.receiver_address=d.receiver_address),d.item_id!==void 0&&(l.item_id=d.item_id),d.quantity!==void 0&&(l.quantity=d.quantity),d.item_title!==void 0&&(l.item_title=d.item_title),await ye(d.order_id,l),n(!1),F(null),await x()}catch(l){console.error("更新订单失败:",l),alert("更新失败,请重试")}},[d,x]),k=a.useCallback(async l=>{M(l);try{const g=await je(l);g.success?await x():alert(g.message||"同步失败")}catch(g){console.error("同步订单失败:",g),alert(Q(g,"同步失败,请重试"))}finally{M(null)}},[x]),C=a.useCallback(async l=>{if(confirm("确认删除该订单吗?删除后无法恢复。")){v(l);try{await fe(l),s.length===1&&r>1?j(g=>g-1):await x()}catch(g){console.error("删除订单失败:",g),alert(Q(g,"删除失败,请重试")),await x()}finally{v(null)}}},[x,s.length,r,j]),T=a.useCallback(()=>N(!1),[]),B=a.useCallback(()=>n(!1),[]),L=a.useCallback(()=>{I(!1),y(null)},[]);return{showDetailModal:b,selectedOrder:E,showEditModal:f,editingOrder:d,showShipModal:$,shipOrderId:w,shipLoading:A,shipResult:i,syncingOrderId:u,deletingOrderId:R,handleSync:P,handleShip:G,executeShip:V,handleViewDetail:z,handleEdit:c,handleSaveEdit:h,updateEditingOrder:o,handleSyncSingle:k,handleDelete:C,closeDetailModal:T,closeEditModal:B,closeShipModal:L}},Z=({status:s})=>{const r={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-brand text-white",shipped:"bg-blue-100 text-blue-700",completed:"bg-green-100 text-green-700",cancelled:"bg-gray-100 text-gray-500",refunding:"bg-red-100 text-red-600",unknown:"bg-gray-100 text-gray-500"},m={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中",unknown:"未知"};return e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${r[s]||r.cancelled}`,children:m[s]||s})},Pe=()=>{const s=Me(),r=Fe(s.loadOrders),{orders:m,accounts:p,filter:j,setFilter:x,accountFilter:b,setAccountFilter:N,searchText:E,setSearchText:S,page:f,setPage:n,totalPages:d,loading:F,loadOrders:$,accountName:I,accountNickname:w,getItemNameById:_}=s,A=Re({orders:m,page:f,accountFilter:b,filter:j,setPage:n,loadOrders:$}),{showDetailModal:O,selectedOrder:i,showEditModal:y,editingOrder:u,showShipModal:M,shipLoading:R,shipResult:v,syncingOrderId:P,deletingOrderId:G,handleSync:V,handleShip:z,executeShip:c,handleViewDetail:o,handleEdit:h,handleSaveEdit:k,updateEditingOrder:C,handleSyncSingle:T,handleDelete:B,closeDetailModal:L,closeEditModal:l,closeShipModal:g}=A,J=t=>{x(t),n(1),S("")},D=t=>{N(t),n(1)},se=t=>{S(t),n(1)};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"订单中心"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"查看所有闲鱼交易记录与状态。"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:$,className:"p-3 rounded-2xl bg-white border border-gray-100 text-gray-600 hover:bg-gray-50 hover:text-black transition-colors shadow-sm",children:e.jsx(W,{className:`w-5 h-5 ${F?"animate-spin":""}`})}),e.jsxs("button",{onClick:r.openImportModal,className:"px-5 py-3 rounded-2xl font-bold bg-gray-900 text-white hover:bg-gray-800 transition-colors text-sm flex items-center gap-2 shadow-lg",children:[e.jsx(le,{className:"w-4 h-4"}),"插入订单"]}),e.jsxs("button",{onClick:V,className:"ios-btn-primary px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 text-sm flex items-center gap-2",children:[e.jsx(X,{className:"w-5 h-5"}),"一键同步订单"]})]})]}),e.jsxs("div",{className:"ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white",children:[e.jsx(Ee,{filter:j,onFilterChange:J,accountFilter:b,onAccountFilterChange:D,accounts:p,accountName:I,searchText:E,onSearchChange:se}),e.jsx("div",{className:"overflow-x-auto min-h-[400px]",children:e.jsxs("table",{className:"w-full text-left border-collapse table-fixed",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50",children:[e.jsx("th",{className:"px-6 py-5",style:{width:"28%"},children:"订单信息"}),e.jsx("th",{className:"px-6 py-5",style:{width:"26%"},children:"买家信息"}),e.jsx("th",{className:"px-6 py-5",style:{width:"11%"},children:"实付金额"}),e.jsx("th",{className:"px-6 py-5",style:{width:"13%"},children:"当前状态"}),e.jsx("th",{className:"px-6 py-5 text-right",style:{width:"22%"},children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:m.map(t=>e.jsxs("tr",{className:"hover:bg-warning-50/50 transition-colors group",children:[e.jsx("td",{className:"px-6 py-5",children:e.jsxs("div",{className:"flex items-center gap-5",children:[e.jsx("div",{className:"w-14 h-14 rounded-xl bg-gray-100 overflow-hidden shadow-sm border border-gray-100 flex-shrink-0",children:t.item_image?e.jsx("img",{src:t.item_image,alt:"",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-gray-300",children:e.jsx(K,{})})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 line-clamp-1 text-sm",children:_(t.cookie_id,t.item_id,t.item_title)}),e.jsxs("div",{className:"mt-1 flex w-fit min-w-0 max-w-full items-center gap-1 rounded-md bg-blue-50 px-2 py-1 text-[10px] font-extrabold text-blue-700",title:w(t.cookie_id),children:[e.jsx(ee,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate whitespace-nowrap",children:w(t.cookie_id)})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-1 font-medium",children:["订单ID: ",t.order_id]}),e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["数量: ",t.quantity," • ",Y(t.created_at)]})]})]})}),e.jsx("td",{className:"px-6 py-5",children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("div",{className:"text-xs text-gray-500",children:"买家ID"}),e.jsx("div",{className:"text-sm font-bold text-gray-800",children:t.buyer_id}),t.receiver_name&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"收货人"}),e.jsx("div",{className:"text-xs text-gray-600",children:t.receiver_name})]}),t.receiver_phone&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"联系电话"}),e.jsx("div",{className:"text-xs text-gray-600 font-mono",children:t.receiver_phone})]}),t.receiver_address&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"收货地址"}),e.jsx("div",{className:"text-xs text-gray-600 line-clamp-1",children:t.receiver_address})]})]})}),e.jsx("td",{className:"px-6 py-5 text-base font-extrabold text-gray-900 font-feature-settings-tnum",children:t.amount?`¥${t.amount}`:e.jsx("span",{className:"text-xs text-amber-600 font-bold",children:"待获取"})}),e.jsx("td",{className:"px-6 py-5",children:e.jsx(Z,{status:t.status})}),e.jsxs("td",{className:"px-6 py-5 text-right",children:[t.status==="pending_ship"&&e.jsx("button",{onClick:(()=>z(t.order_id)),className:"mr-2 text-white bg-black hover:bg-gray-800 shadow-lg shadow-gray-200 text-xs font-bold px-3 py-2 rounded-xl transition-all active:scale-95",children:"立即发货"}),e.jsx("a",{href:`https://www.goofish.com/order-detail?orderId=${t.order_id}&role=seller`,target:"_blank",rel:"noopener noreferrer",className:"mr-2 inline-flex text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看闲鱼详情",children:e.jsx(re,{className:"w-4 h-4"})}),e.jsx("button",{onClick:(()=>o(t)),className:"mr-2 text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看详情",children:e.jsx(ne,{className:"w-4 h-4"})}),e.jsx("button",{onClick:(()=>h(t)),className:"mr-2 text-gray-400 hover:text-black p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"编辑订单",children:e.jsx(ie,{className:"w-4 h-4"})}),e.jsx("button",{onClick:(()=>T(t.order_id)),disabled:P===t.order_id,className:"mr-2 text-gray-400 hover:text-green-600 p-2 rounded-xl hover:bg-green-50 transition-colors disabled:opacity-50",title:"同步订单",children:e.jsx(W,{className:`w-4 h-4 ${P===t.order_id?"animate-spin":""}`})}),e.jsx("button",{onClick:(()=>B(t.order_id)),disabled:G===t.order_id,className:"text-gray-400 hover:text-red-500 p-2 rounded-xl hover:bg-red-50 transition-colors disabled:opacity-50",title:"删除订单",children:e.jsx(ce,{className:"w-4 h-4"})})]})]},t.id))})]})}),e.jsxs("div",{className:"p-4 border-t border-gray-50 flex items-center justify-between bg-white",children:[e.jsxs("div",{className:"text-sm text-gray-500 font-medium pl-2",children:["第 ",f," 页 / 共 ",d," 页"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{disabled:f<=1,onClick:(()=>n(t=>t-1)),"aria-label":"上一页",className:"p-2.5 rounded-xl bg-gray-50 hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed text-gray-600 transition-colors",children:e.jsx(de,{className:"w-5 h-5"})}),e.jsx("button",{disabled:f>=d,onClick:(()=>n(t=>t+1)),"aria-label":"下一页",className:"p-2.5 rounded-xl bg-gray-50 hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed text-gray-600 transition-colors",children:e.jsx(oe,{className:"w-5 h-5"})})]})]})]}),O&&i&&U.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"订单详情"}),e.jsx("button",{onClick:L,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(H,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-gray-800",children:"订单信息"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 p-4 bg-gray-50 rounded-xl",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"订单号"}),e.jsx("div",{className:"font-mono text-sm font-bold text-gray-900",children:i.order_id})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"所属账号"}),e.jsx("div",{className:"truncate whitespace-nowrap text-sm font-bold text-blue-700",title:w(i.cookie_id),children:w(i.cookie_id)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"状态"}),e.jsx(Z,{status:i.status})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"实付金额"}),e.jsx("div",{className:"text-lg font-extrabold text-gray-900",children:i.amount?`¥${i.amount}`:"待获取"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"数量"}),e.jsx("div",{className:"font-bold text-gray-900",children:i.quantity})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"创建时间"}),e.jsx("div",{className:"text-sm font-medium text-gray-700",children:Y(i.created_at)})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-gray-800",children:"商品信息"}),e.jsxs("div",{className:"p-4 bg-gray-50 rounded-xl flex items-center gap-4",children:[i.item_image&&e.jsx("img",{src:i.item_image,alt:"",className:"w-20 h-20 rounded-xl object-cover border border-gray-200"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-bold text-gray-900 mb-1",children:_(i.cookie_id,i.item_id,i.item_title)}),e.jsxs("div",{className:"text-sm text-gray-500",children:["商品ID: ",i.item_id]}),i.item_price&&e.jsxs("div",{className:"text-sm text-gray-500 mt-1",children:["标价: ¥",i.item_price]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-gray-800",children:"买家信息"}),e.jsxs("div",{className:"p-4 bg-gray-50 rounded-xl space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"买家ID"}),e.jsx("div",{className:"font-bold text-gray-900",children:i.buyer_id})]}),i.receiver_name&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"收货人"}),e.jsx("div",{className:"font-medium text-gray-700",children:i.receiver_name})]}),i.receiver_phone&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"联系电话"}),e.jsx("div",{className:"font-mono text-sm text-gray-700",children:i.receiver_phone})]}),i.receiver_address&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"收货地址"}),e.jsx("div",{className:"text-sm text-gray-700",children:i.receiver_address})]})]})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:L,className:"flex-1 px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:"关闭"}),i.status==="pending_ship"&&e.jsx("button",{onClick:(()=>{L(),z(i.order_id)}),className:"flex-1 px-6 py-3 rounded-xl ios-btn-primary font-bold shadow-lg shadow-blue-200",children:"立即发货"})]})})]})}),document.body),e.jsx(Oe,{...r}),M&&U.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"480px"},children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"立即发货"}),e.jsx("button",{onClick:g,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(H,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-4",children:[e.jsx("p",{className:"text-sm text-gray-600",children:"请选择发货方式:"}),e.jsx("button",{onClick:(()=>c("status_only")),disabled:R,className:"w-full text-left p-4 rounded-xl border-2 border-gray-200 hover:border-gray-400 hover:bg-gray-50 transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-blue-100 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(X,{className:"w-5 h-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm",children:"仅修改闲鱼发货状态"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 leading-relaxed",children:'不实际扣除或发送卡券,仅在闲鱼平台将订单标记为"已发货"。 适用于已经给客户发过货、只是忘记在闲鱼修改状态的情况。'})]})]})}),e.jsx("button",{onClick:(()=>c("full_delivery")),disabled:R,className:"w-full text-left p-4 rounded-xl border-2 border-gray-200 hover:border-brand hover:bg-blue-50 transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-blue-100 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(K,{className:"w-5 h-5 text-blue-700"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm",children:"完整发货(匹配卡券并发送)"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 leading-relaxed",children:"自动匹配发货规则、获取卡券、发送卡券信息给买家,并修改发货状态。 适用于订单既没有发送卡券给买家、也没有修改发货状态的情况。"})]})]})}),R&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-3",children:[e.jsx(W,{className:"w-4 h-4 animate-spin text-gray-500"}),e.jsx("span",{className:"text-sm text-gray-500",children:"正在处理中..."})]}),v&&e.jsxs("div",{className:`p-3 rounded-xl text-sm ${v.success?"bg-green-50 text-green-800":"bg-red-50 text-red-800"}`,children:[v.success?"✓ ":"✗ ",v.message]})]}),e.jsx("div",{className:"modal-footer",children:e.jsx("button",{onClick:g,className:"w-full px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:v!=null&&v.success?"完成":"取消"})})]})}),document.body),y&&u&&U.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"编辑订单"}),e.jsx("button",{onClick:l,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(H,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"订单号"}),e.jsx("input",{type:"text",value:u.order_id,disabled:!0,className:"w-full ios-input px-4 py-3 rounded-xl bg-gray-50 text-gray-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"订单状态"}),e.jsxs("select",{value:u.status,onChange:(t=>C({status:t.target.value})),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"processing",children:"处理中"}),e.jsx("option",{value:"pending_ship",children:"待发货"}),e.jsx("option",{value:"shipped",children:"已发货"}),e.jsx("option",{value:"completed",children:"已完成"}),e.jsx("option",{value:"cancelled",children:"已取消"}),e.jsx("option",{value:"refunding",children:"退款中"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"买家ID"}),e.jsx("input",{type:"text",value:u.buyer_id,onChange:(t=>C({buyer_id:t.target.value})),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"实付金额"}),e.jsx("input",{type:"number",value:u.amount,onChange:(t=>C({amount:t.target.value})),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"收货人"}),e.jsx("input",{type:"text",value:u.receiver_name||"",onChange:(t=>C({receiver_name:t.target.value})),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"联系电话"}),e.jsx("input",{type:"text",value:u.receiver_phone||"",onChange:(t=>C({receiver_phone:t.target.value})),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"收货地址"}),e.jsx("textarea",{value:u.receiver_address||"",onChange:(t=>C({receiver_address:t.target.value})),rows:2,className:"w-full ios-input px-4 py-3 rounded-xl resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"商品标题"}),e.jsx("input",{type:"text",value:u.item_title||"",onChange:(t=>C({item_title:t.target.value})),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:l,className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:k,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(xe,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body)]})};export{Pe as default};
|