2 lines
30 KiB
JavaScript
2 lines
30 KiB
JavaScript
import{j as e,b as G,r as a}from"./react-vendor-C_od1ZSF.js";import{D as oe,h as xe,a as me,E as ue,F as he,G as ge,H as pe,I as be,J as ye}from"./index-C-ovCGmt.js";import{i as ee,I as fe,X as J,J as je,R as V,N as ve,O as X,m as K,E as Ne,v as we,V as _e,F as ke,d as Ce,c as Se,r as Oe}from"./icons-vendor-ThcsWkZG.js";import{f as Y}from"./dateTime-DDi7rqpW.js";const Ie=[{key:"all",label:"全部"},{key:"processing",label:"处理中"},{key:"shipped",label:"已发货"},{key:"pending_ship",label:"待发货"},{key:"completed",label:"已完成"},{key:"cancelled",label:"已取消"},{key:"refunding",label:"退款中"}],Fe=t=>{const c=typeof t=="object"&&t!==null?t:{},x=Array.isArray(c.results)?c.results:[];return{total:Number(c.total||0),success_count:Number(c.success_count||0),failed_count:Number(c.failed_count||0),results:x.map(Re)}},Re=t=>{const c=typeof t=="object"&&t!==null?t:{};return{order_id:String(c.order_id||"unknown"),success:c.success===!0,message:String(c.message||"")}},Ee=t=>(t==null?void 0:t.results.filter(Me))||[],Me=t=>!t.success,De=(t,c)=>t!==null&&!c,$e=t=>{if(!t)return"请选择订单文件";const c=t.name.toLowerCase().split(".").pop()||"";return["xlsx","csv","tsv","json"].includes(c)?"":"仅支持 .xlsx、.csv、.tsv、.json 格式"},D=(t,c)=>t===c,Ae=(t,c)=>t instanceof Error&&t.message?t.message:c,Pe=({filter:t,onFilterChange:c,accountFilter:x,onAccountFilterChange:g,accounts:f,accountName:p,searchText:m,onSearchChange:v})=>{const C=i=>c(i.currentTarget.dataset.status||"all"),k=i=>g(i.target.value),b=i=>v(i.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:Ie.map(i=>e.jsx("button",{"data-status":i.key,onClick:C,className:`px-5 py-2 rounded-lg text-sm font-bold transition-all whitespace-nowrap ${t===i.key?"bg-white text-black shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:i.label},i.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:x,onChange:k,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:"全部账号"}),f.map(i=>e.jsx("option",{value:i.id,children:p(i.id)},i.id))]})]}),e.jsxs("div",{className:"relative group",children:[e.jsx(fe,{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:m,onChange:b,className:"ios-input pl-10 pr-4 py-2.5 rounded-xl w-64 bg-white border-none shadow-sm focus:ring-0"})]})]})]})},Le=t=>{const c=p=>{var m;t.setImportFile(((m=p.target.files)==null?void 0:m[0])||null)},x=()=>t.closeImportModal(),g=()=>void t.handleImportOrders(),f=()=>void t.handleRetryImport();return t.showImportModal?G.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:x,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(J,{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:c,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 格式"})]}),t.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(je,{className:"w-4 h-4 text-blue-600"}),e.jsx("span",{className:"text-sm font-medium text-blue-900",children:t.importFile.name})]})}),t.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:t.importError}),e.jsx("button",{type:"button",onClick:f,disabled:t.importing||!t.importFile,className:"font-bold whitespace-nowrap",children:"重试"})]}),t.importResult&&t.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:["导入完成:成功 ",t.importResult.success_count," 条,失败 ",t.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:Ee(t.importResult).map((p,m)=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 font-mono",children:p.order_id}),e.jsx("td",{className:"px-3 py-2 text-red-600",children:p.message||"导入失败"})]},`${p.order_id}-${m}`))})]})})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:x,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:g,disabled:!t.importFile||t.importing,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:t.importing?"正在导入…":"导入订单"})]})})]})}),document.body):null},qe=(t={pageSize:20})=>{const[c,x]=a.useState([]),[g,f]=a.useState([]),[p,m]=a.useState([]),[v,C]=a.useState("all"),[k,b]=a.useState(""),[i,I]=a.useState(""),[$,N]=a.useState(""),[S,O]=a.useState(1),[w,A]=a.useState(1),[_,F]=a.useState(!1),j=a.useRef(0),r=a.useRef(null),R=a.useRef(null),l=a.useCallback(async()=>{var o;const n=++j.current;(o=r.current)==null||o.abort();const d=new AbortController;r.current=d,F(!0);try{const u=await oe(k||void 0,v,S,t.pageSize,$,{signal:d.signal});if(!D(n,j.current))return;x(u.data),A(u.total_pages)}catch(u){D(n,j.current)&&!d.signal.aborted&&console.error("加载订单失败:",u)}finally{D(n,j.current)&&F(!1)}},[k,$,v,t.pageSize,S]);a.useEffect(()=>{const n=window.setTimeout(()=>{O(1),N(i.trim())},300);return(()=>window.clearTimeout(n))},[i]),a.useEffect(()=>(l(),(()=>{var n;j.current+=1,(n=r.current)==null||n.abort()})),[l]),a.useEffect(()=>{var d;const n=new AbortController;return(d=R.current)==null||d.abort(),R.current=n,Promise.all([xe({signal:n.signal}),me(void 0,{signal:n.signal})]).then(([o,u])=>{n.signal.aborted||(m(o),f(u))}).catch(o=>{n.signal.aborted||console.error("加载订单辅助数据失败:",o)}),(()=>n.abort())},[]);const y=a.useMemo(()=>new Map(p.map(n=>[n.id,n])),[p]),T=a.useMemo(()=>{const n={};return g.forEach(d=>{d.item_id&&(n[`${d.cookie_id}:${d.item_id}`]=d.item_title||d.item_id)}),n},[g]),L=a.useCallback(n=>{const d=y.get(n),o=(d==null?void 0:d.remark)||(d==null?void 0:d.nickname);return o?`${o} · ${n.slice(0,6)}`:`账号 ${n.slice(0,8)}`},[y]),Q=a.useCallback(n=>{const d=y.get(n);return(d==null?void 0:d.remark)||(d==null?void 0:d.nickname)||"未命名账号"},[y]),U=a.useCallback((n,d,o)=>{if(o!=null&&o.trim())return o;const u=T[`${n}:${d}`];if(u)return u;const P=g.find(q=>{if(!o||!q.item_title)return!1;const B=o.toLowerCase(),z=q.item_title.toLowerCase();return z.includes(B)||B.includes(z)});return(P==null?void 0:P.item_title)||"未知商品"},[T,g]);return{orders:c,items:g,accounts:p,filter:v,setFilter:C,accountFilter:k,setAccountFilter:b,searchText:i,setSearchText:I,page:S,setPage:O,totalPages:w,loading:_,loadOrders:l,accountName:L,accountNickname:Q,getItemNameById:U}},ze=t=>{const[c,x]=a.useState(!1),[g,f]=a.useState(null),[p,m]=a.useState(null),[v,C]=a.useState(!1),[k,b]=a.useState(""),i=a.useRef(0),I=a.useRef(null),$=a.useCallback(()=>{f(null),m(null),b(""),x(!0)},[]),N=a.useCallback(()=>{var w;i.current+=1,(w=I.current)==null||w.abort(),C(!1),x(!1),f(null),m(null),b("")},[]),S=a.useCallback(async()=>{var j;if(!De(g,v))return;const w=g;if(!w)return;const A=$e(w);if(A){b(A);return}const _=++i.current;(j=I.current)==null||j.abort();const F=new AbortController;I.current=F,C(!0),m(null),b("");try{const r=new FormData;r.append("file",w);const R=Fe(await ue(r,{signal:F.signal}));if(!D(_,i.current))return;m(R),f(null),await t(),R.failed_count===0&&D(_,i.current)&&(alert(`订单导入成功,共 ${R.success_count} 条`),x(!1),m(null))}catch(r){D(_,i.current)&&!F.signal.aborted&&b(Ae(r,"导入失败,请检查文件格式"))}finally{D(_,i.current)&&C(!1)}},[g,v,t]),O=a.useCallback(async()=>{await S()},[S]);return{showImportModal:c,importFile:g,setImportFile:f,importResult:p,importing:v,importError:k,openImportModal:$,closeImportModal:N,handleImportOrders:S,handleRetryImport:O}},Z=({status:t})=>{const c={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"},x={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中",unknown:"未知"};return e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${c[t]||c.cancelled}`,children:x[t]||t})},Qe=()=>{const t=qe(),c=ze(t.loadOrders),{orders:x,accounts:g,filter:f,setFilter:p,accountFilter:m,setAccountFilter:v,searchText:C,setSearchText:k,page:b,setPage:i,totalPages:I,loading:$,loadOrders:N,accountName:S,accountNickname:O,getItemNameById:w}=t,[A,_]=a.useState(!1),[F,j]=a.useState(!1),[r,R]=a.useState(null),[l,y]=a.useState(null),[T,L]=a.useState(!1),[Q,U]=a.useState(""),[n,d]=a.useState(!1),[o,u]=a.useState(null),[P,q]=a.useState(null),[B,z]=a.useState(null),se=s=>{p(s),i(1),k("")},te=s=>{v(s),i(1)},ae=s=>{k(s),i(1)},le=async()=>{try{const s=await he(m||void 0,f);await N(),s!=null&&s.message&&alert(s.message)}catch(s){console.error("同步订单失败:",s),alert((s==null?void 0:s.message)||"同步失败,请重试")}},H=s=>{U(s),u(null),L(!0)},W=async s=>{var h;d(!0),u(null);try{const E=await be([Q],s),M=(h=E==null?void 0:E.results)==null?void 0:h[0];M!=null&&M.success?(u({success:!0,message:M.message}),N()):u({success:!1,message:(M==null?void 0:M.message)||"发货失败"})}catch(E){u({success:!1,message:(E==null?void 0:E.message)||"请求失败"})}finally{d(!1)}},re=s=>{R(s),_(!0)},ne=s=>{y({...s}),j(!0)},ie=async()=>{if(!(!l||!l.order_id))try{const s={};l.status!==void 0&&(s.order_status=l.status),l.buyer_id!==void 0&&(s.buyer_id=l.buyer_id),l.amount!==void 0&&(s.amount=l.amount),l.receiver_name!==void 0&&(s.receiver_name=l.receiver_name),l.receiver_phone!==void 0&&(s.receiver_phone=l.receiver_phone),l.receiver_address!==void 0&&(s.receiver_address=l.receiver_address),l.item_id!==void 0&&(s.item_id=l.item_id),l.quantity!==void 0&&(s.quantity=l.quantity),l.item_title!==void 0&&(s.item_title=l.item_title),await ye(l.order_id,s),j(!1),y(null),N()}catch(s){console.error("更新订单失败:",s),alert("更新失败,请重试")}},ce=async s=>{q(s);try{const h=await ge(s);h.success?await N():alert(h.message||"同步失败")}catch(h){console.error("同步订单失败:",h),alert((h==null?void 0:h.message)||"同步失败,请重试")}finally{q(null)}},de=async s=>{if(confirm("确认删除该订单吗?删除后无法恢复。")){z(s);try{await pe(s),x.length===1&&b>1?i(h=>h-1):await N()}catch(h){console.error("删除订单失败:",h),alert((h==null?void 0:h.message)||"删除失败,请重试"),await N()}finally{z(null)}}};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:N,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(V,{className:`w-5 h-5 ${$?"animate-spin":""}`})}),e.jsxs("button",{onClick:c.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(ve,{className:"w-4 h-4"}),"插入订单"]}),e.jsxs("button",{onClick:le,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(Pe,{filter:f,onFilterChange:se,accountFilter:m,onAccountFilterChange:te,accounts:g,accountName:S,searchText:C,onSearchChange:ae}),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:x.map(s=>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:s.item_image?e.jsx("img",{src:s.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:w(s.cookie_id,s.item_id,s.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:O(s.cookie_id),children:[e.jsx(ee,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate whitespace-nowrap",children:O(s.cookie_id)})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-1 font-medium",children:["订单ID: ",s.order_id]}),e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["数量: ",s.quantity," • ",Y(s.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:s.buyer_id}),s.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:s.receiver_name})]}),s.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:s.receiver_phone})]}),s.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:s.receiver_address})]})]})}),e.jsx("td",{className:"px-6 py-5 text-base font-extrabold text-gray-900 font-feature-settings-tnum",children:s.amount?`¥${s.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:s.status})}),e.jsxs("td",{className:"px-6 py-5 text-right",children:[s.status==="pending_ship"&&e.jsx("button",{onClick:(()=>H(s.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=${s.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(Ne,{className:"w-4 h-4"})}),e.jsx("button",{onClick:(()=>re(s)),className:"mr-2 text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看详情",children:e.jsx(we,{className:"w-4 h-4"})}),e.jsx("button",{onClick:(()=>ne(s)),className:"mr-2 text-gray-400 hover:text-black p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"编辑订单",children:e.jsx(_e,{className:"w-4 h-4"})}),e.jsx("button",{onClick:(()=>ce(s.order_id)),disabled:P===s.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(V,{className:`w-4 h-4 ${P===s.order_id?"animate-spin":""}`})}),e.jsx("button",{onClick:(()=>de(s.order_id)),disabled:B===s.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(ke,{className:"w-4 h-4"})})]})]},s.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:["第 ",b," 页 / 共 ",I," 页"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{disabled:b<=1,onClick:(()=>i(s=>s-1)),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(Ce,{className:"w-5 h-5"})}),e.jsx("button",{disabled:b>=I,onClick:(()=>i(s=>s+1)),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(Se,{className:"w-5 h-5"})})]})]})]}),A&&r&&G.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:(()=>_(!1)),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(J,{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:r.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:O(r.cookie_id),children:O(r.cookie_id)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"状态"}),e.jsx(Z,{status:r.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:r.amount?`¥${r.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:r.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(r.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:[r.item_image&&e.jsx("img",{src:r.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:w(r.cookie_id,r.item_id,r.item_title)}),e.jsxs("div",{className:"text-sm text-gray-500",children:["商品ID: ",r.item_id]}),r.item_price&&e.jsxs("div",{className:"text-sm text-gray-500 mt-1",children:["标价: ¥",r.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:r.buyer_id})]}),r.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:r.receiver_name})]}),r.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:r.receiver_phone})]}),r.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:r.receiver_address})]})]})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:(()=>_(!1)),className:"flex-1 px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:"关闭"}),r.status==="pending_ship"&&e.jsx("button",{onClick:(()=>{_(!1),H(r.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(Le,{...c}),T&&G.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:(()=>{L(!1),u(null)}),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(J,{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:(()=>W("status_only")),disabled:n,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:(()=>W("full_delivery")),disabled:n,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:"自动匹配发货规则、获取卡券、发送卡券信息给买家,并修改发货状态。 适用于订单既没有发送卡券给买家、也没有修改发货状态的情况。"})]})]})}),n&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-3",children:[e.jsx(V,{className:"w-4 h-4 animate-spin text-gray-500"}),e.jsx("span",{className:"text-sm text-gray-500",children:"正在处理中..."})]}),o&&e.jsxs("div",{className:`p-3 rounded-xl text-sm ${o.success?"bg-green-50 text-green-800":"bg-red-50 text-red-800"}`,children:[o.success?"✓ ":"✗ ",o.message]})]}),e.jsx("div",{className:"modal-footer",children:e.jsx("button",{onClick:(()=>{L(!1),u(null)}),className:"w-full px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:o!=null&&o.success?"完成":"取消"})})]})}),document.body),F&&l&&G.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:(()=>j(!1)),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(J,{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:l.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:l.status,onChange:(s=>y({...l,status:s.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:l.buyer_id,onChange:(s=>y({...l,buyer_id:s.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:l.amount,onChange:(s=>y({...l,amount:s.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:l.receiver_name||"",onChange:(s=>y({...l,receiver_name:s.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:l.receiver_phone||"",onChange:(s=>y({...l,receiver_phone:s.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:l.receiver_address||"",onChange:(s=>y({...l,receiver_address:s.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:l.item_title||"",onChange:(s=>y({...l,item_title:s.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:(()=>j(!1)),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:ie,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Oe,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body)]})};export{Qe as default};
|