3 lines
52 KiB
JavaScript
3 lines
52 KiB
JavaScript
import{r as a,j as e,b as ue}from"./react-vendor-C_od1ZSF.js";import{Q as Oe,R as ee,S as lt,T as it,U as rt,V as nt,W as ct,X as dt,Y as ot,Z as xt,_ as mt,$ as ht,a0 as ut,a as Ae,a1 as Fe,h as pt}from"./index-DK02p8DH.js";import{a3 as gt,i as Me,R as Ne,N as Re,a4 as ve,a5 as pe,V as bt,F as yt,B as ft,a6 as Ee,a7 as jt,a8 as Nt,A as vt,S as wt,X as re,r as _t,a9 as $e,I as De}from"./icons-vendor-ThcsWkZG.js";const Ue="ydisks-amap-js-api",kt="c9b68d4ce9a2a97f22a4a439404488ca";let ne=null;const Ct=()=>kt,It=()=>window.AMap?Promise.resolve(window.AMap):ne||(ne=new Promise((s,c)=>{const x=document.getElementById(Ue),d=x||document.createElement("script"),m=()=>{window.__ydisksAmapLoaded=void 0,window.clearTimeout(P)},g=()=>{window.AMap?(m(),s(window.AMap)):(m(),c(new Error("高德地图 API 加载完成但未找到 AMap 对象")))},P=window.setTimeout(()=>{m(),c(new Error("高德地图 API 加载超时,请检查网络或 VITE_AMAP_JS_KEY 配置"))},15e3);window.__ydisksAmapLoaded=g,d.id=Ue,d.async=!0,d.src=`https://webapi.amap.com/maps?v=2.0&key=${encodeURIComponent(Ct())}&plugin=AMap.PlaceSearch&callback=__ydisksAmapLoaded`,d.onerror=()=>{m(),c(new Error("高德地图 API 加载失败,请检查网络或 VITE_AMAP_JS_KEY 配置"))},x||document.head.appendChild(d)}).catch(s=>{throw ne=null,s}),ne),ge=s=>Number.isFinite(s)&&s!==0,St=s=>{var m,g;const c=Number((m=s.location)==null?void 0:m.lng),x=Number((g=s.location)==null?void 0:g.lat),d={area:String(s.adname||"").trim(),city:String(s.cityname||"").trim(),division_id:String(s.adcode||"").trim(),longitude:c,latitude:x,poi_id:String(s.id||"").trim(),poi_name:String(s.name||"").trim(),province:String(s.pname||"").trim()};return!d.division_id||!d.province||!d.city||!d.poi_id||!d.poi_name||!ge(c)||!ge(x)||c<-180||c>180||x<-90||x>90?null:d},Pt=async(s,c)=>{if(!ge(s)||!ge(c)||s<-180||s>180||c<-90||c>90)throw new Error("经纬度无效");const x=await It();return new Promise((d,m)=>{new x.PlaceSearch({extensions:"all",pageSize:10}).searchNearBy("",[s,c],1e3,(P,f)=>{var w;if(P!=="complete"){if(P==="no_data"){d([]);return}m(new Error("高德地图附近地址查询失败,请稍后重试"));return}const A=(((w=f==null?void 0:f.poiList)==null?void 0:w.pois)||[]).map(St).filter(K=>K!==null);d(A)})})},Bt=s=>s.find(c=>c.status==="running"||c.status==="canceling"),_e=s=>s==="running"||s==="canceling",Lt=s=>!!(s!=null&&s.preview_id&&Number(s.valid||0)>0),At=s=>!!(s!=null&&s.id&&Number(s.retryable||0)>0&&!_e(s.status)),Ft=(s,c)=>s===c,qe=s=>{switch(s){case"preview":return"待确认";case"pending":return"等待中";case"running":return"发布中";case"canceling":return"正在安全取消";case"success":return"成功";case"failed":return"失败";case"completed":return"已完成";case"partially_failed":return"部分失败";case"canceled":return"已取消";default:return s||"-"}},Te=s=>{switch(s){case"success":case"completed":return"bg-emerald-50 text-emerald-700 border-emerald-100";case"partially_failed":case"failed":return"bg-red-50 text-red-700 border-red-100";case"running":return"bg-blue-50 text-blue-700 border-blue-100";case"canceled":return"bg-gray-100 text-gray-600 border-gray-200";default:return"bg-amber-50 text-amber-700 border-amber-100"}},Mt=s=>{const[c,x]=a.useState(!1),[d,m]=a.useState("upload"),[g,P]=a.useState(null),[f,A]=a.useState(null),[w,K]=a.useState(""),[O,Z]=a.useState(!1),[E,J]=a.useState({catId:"",catName:"",channelCatId:"",tbCatId:""}),[y,N]=a.useState(null),[n,_]=a.useState(null),[I,$]=a.useState(null),[V,D]=a.useState([]),[U,B]=a.useState(null),[q,p]=a.useState(!1),k=a.useRef(!1),o=a.useRef(0),F=a.useCallback(async()=>{m("upload"),N(null),_(null),P(null),A(null),K(""),J({catId:"",catName:"",channelCatId:"",tbCatId:""}),D([]),B(null),x(!0),p(!0);try{const r=await Oe(20),h=Bt(r);if(h!=null&&h.id){const S=await ee(h.id);$(S),_(S),m(["running","canceling"].includes(S.status)?"running":"done")}}catch(r){console.error("恢复最近批量铺货任务失败:",r)}finally{p(!1)}},[]),u=a.useCallback(async()=>{const r=w.trim();if(!s.selectedAccount){alert("请先选择默认发布账号");return}if(!r){alert("请输入类目关键词");return}Z(!0);try{const S=(await lt(s.selectedAccount,r)).category;J({catId:S.cat_id,catName:S.cat_name,channelCatId:S.channel_cat_id,tbCatId:S.tb_cat_id||""})}catch(h){console.error("获取推荐类目失败:",h),alert((h==null?void 0:h.message)||"没有匹配到类目,请换一个更具体的关键词")}finally{Z(!1)}},[w,s.selectedAccount]),M=a.useCallback(async()=>{if(I!=null&&I.id){p(!0),x(!0);try{const r=await ee(I.id);_(r),m(["running","canceling"].includes(r.status)?"running":"done")}catch(r){console.error("加载最近批量铺货结果失败:",r)}finally{p(!1)}}},[I==null?void 0:I.id]),te=a.useCallback(async()=>{if(!g){alert("请先上传商品表格");return}if(!s.selectedAccount){alert("请先选择默认发布账号");return}p(!0);try{const r=await it({file:g,imagesZip:f,defaultCookieId:s.selectedAccount,fallbackCategory:E,location:U||void 0});N(r),_(null),m("preview")}catch(r){console.error("批量铺货预检失败:",r),alert((r==null?void 0:r.message)||"预检失败,请检查表格和图片 zip")}finally{p(!1)}},[E,g,f,U,s.selectedAccount]),W=a.useCallback(async()=>{if(y!=null&&y.preview_id){if(!Lt(y)){alert("没有可发布的商品行");return}p(!0);try{const r=await rt(y.preview_id),h=await ee(r.batch_id||y.preview_id);_(h),$(h),m(h.status==="running"?"running":"done")}catch(r){console.error("启动批量铺货失败:",r),alert((r==null?void 0:r.message)||"启动发布任务失败")}finally{p(!1)}}},[y]),Y=a.useCallback(async()=>{if(n!=null&&n.id&&confirm("确认取消当前批量铺货任务吗?正在发布的单个商品可能会继续完成。")){p(!0);try{const r=await nt(n.id),h=await ee(n.id);_(h),m((r==null?void 0:r.status)==="canceling"||h.status==="canceling"?"running":"done")}catch(r){alert((r==null?void 0:r.message)||"取消失败")}finally{p(!1)}}},[n==null?void 0:n.id]),X=a.useCallback(async()=>{const r=y==null?void 0:y.preview_id;if(r&&d==="preview")try{await ct(r)}catch(h){console.error("清理批量铺货预检失败:",h)}N(null),m("upload")},[d,y==null?void 0:y.preview_id]),Q=a.useCallback(async()=>{await X(),x(!1)},[X]),se=a.useCallback(async()=>{if(!(!(n!=null&&n.id)||!At(n))){p(!0);try{await dt(n.id),_(await ee(n.id)),m("running")}catch(r){alert((r==null?void 0:r.message)||"重试失败")}finally{p(!1)}}},[n]);return a.useEffect(()=>{if(!c||!(n!=null&&n.id)||!_e(n.status))return;const r=++o.current,h=async()=>{if(!k.current){k.current=!0;try{const T=await ee(n.id);if(!Ft(r,o.current))return;_(T),$(T),_e(T.status)||(m("done"),await Promise.all([s.loadItems(),s.loadShippingRules()]))}catch(T){console.error("刷新批量铺货进度失败:",T)}finally{k.current=!1}}},S=window.setInterval(()=>void h(),3e3);return(()=>{window.clearInterval(S),o.current+=1})},[n==null?void 0:n.id,n==null?void 0:n.status,s.loadItems,s.loadShippingRules,c]),{showBatchModal:c,setShowBatchModal:x,batchLoading:q,batchPhase:d,setBatchPhase:m,batchFile:g,setBatchFile:P,batchImagesZip:f,setBatchImagesZip:A,batchCategoryKeyword:w,setBatchCategoryKeyword:K,batchCategoryLoading:O,batchFallbackCategory:E,setBatchFallbackCategory:J,batchPreview:y,setBatchPreview:N,batchDetail:n,setBatchDetail:_,recentBatch:I,setRecentBatch:$,batchLocations:V,batchLocation:U,setBatchLocations:D,setBatchLocation:B,openBatchModal:F,handleRecommendBatchCategory:u,openRecentBatchResult:M,handlePreviewBatch:te,handleStartBatch:W,handleCancelBatch:Y,abandonBatchPreview:X,closeBatchModal:Q,handleRetryBatchFailed:se}},ze=()=>({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""}),Ke=(s="")=>({cookie_id:s,title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),we=(s,c)=>{if(s instanceof Error)return s.message;const x=typeof s=="object"&&s!==null&&"message"in s?s.message:void 0;return typeof x=="string"?x:c},Rt=({selectedAccount:s,setSelectedAccount:c,setItems:x,loadItems:d,loadShippingRules:m,onConfigureDelivery:g,setBatchLocations:P,setBatchLocation:f})=>{const[A,w]=a.useState(!1),[K,O]=a.useState(!1),[Z,E]=a.useState(!1),[J,y]=a.useState(!1),[N,n]=a.useState(!1),[_,I]=a.useState(!1),[$,V]=a.useState([]),[D,U]=a.useState(null),[B,q]=a.useState(null),[p,k]=a.useState({}),[o,F]=a.useState(ze),[u,M]=a.useState(Ke),[te,W]=a.useState([]);a.useEffect(()=>{if(!N||u.images.length===0){W([]);return}const l=u.images.map((j,C)=>({key:j.name+C,url:URL.createObjectURL(j)}));return W(l),(()=>l.forEach(j=>URL.revokeObjectURL(j.url)))},[u.images,N]);const Y=a.useCallback(async()=>{if(!s)return alert("请先选择账号");w(!0);try{const l=await ot(s);await d(),alert((l==null?void 0:l.message)||"商品同步完成")}catch(l){console.error("同步商品失败:",l),alert(we(l,"同步失败,请重试"))}finally{w(!1)}},[d,s]),X=a.useCallback(l=>{q(l),k({...l}),E(!0)},[]),Q=a.useCallback(async()=>{if(B)try{await xt(B.cookie_id,B.item_id,{item_title:p.item_title||"",item_description:p.item_description||"",item_category:p.item_category||"",item_price:p.item_price||"",item_detail:p.item_detail||B.item_detail||""}),await d(),await m(),E(!1),q(null)}catch(l){console.error("更新商品失败:",l),alert("更新失败,请重试")}},[p,d,m,B]),se=a.useCallback(async l=>{if(confirm(`确认删除商品"${l.item_title}"吗?`))try{await mt(l.cookie_id,l.item_id),x(j=>j.filter(C=>!(C.cookie_id===l.cookie_id&&C.item_id===l.item_id)))}catch(j){console.error("删除商品失败:",j),alert("删除失败,请重试")}},[x]),ce=a.useCallback(async()=>{try{if(!o.cookie_id||!o.item_id){alert("请选择账号并填写商品ID");return}await ht(o.cookie_id,{item_id:o.item_id,item_title:o.item_title,item_price:o.item_price,item_detail:o.item_image?JSON.stringify({item_image:o.item_image}):""}),await d(),y(!1),F(ze())}catch(l){console.error("添加商品失败:",l),alert("添加失败,请重试")}},[o,d]),r=a.useCallback(async()=>{if(!u.cookie_id)return alert("请选择发布账号");if(!u.title.trim())return alert("请填写商品标题");if(!u.price.trim())return alert("请填写商品价格");if(!u.quantity||Number(u.quantity)<=0)return alert("库存数量必须大于 0");if(u.images.length===0)return alert("至少上传 1 张商品图片");if(u.postage_mode==="fixed"&&!u.postage.trim())return alert("请填写一口价邮费");O(!0);try{const l=await ut({...u,location:D||void 0});if(await d(),n(!1),M(Ke(s||"")),V([]),U(null),l!=null&&l.item_id){const j={id:l.item_id,cookie_id:u.cookie_id,item_id:l.item_id,item_title:l.item_title||u.title,item_price:l.item_price||u.price,item_image:l.item_image};g(j),alert("商品发布成功,ID: "+l.item_id+",已为你打开发货规则配置")}else alert("商品发布成功")}catch(l){console.error("发布商品失败:",l);const j=l==null?void 0:l.payload;if((j==null?void 0:j.code)==="stock_permission_missing"){alert("发布失败:该账号没有库存发布权限,无法按库存数量发布商品。请换账号或先在闲鱼确认库存能力。");return}alert(we(l,"发布失败,请重试"))}finally{O(!1)}},[d,g,u,D,s]),h=a.useCallback(()=>{const C=[["账号ID","标题","描述","价格","原价","库存","邮费模式","邮费","图片","类目ID","类目名称","频道类目ID","淘宝类目ID","付款发货启用","付款发货内容","评价赠品启用","评价赠品内容","求评价启用","求评价等待小时","求评价文案","求评价最多次数"],...[["","会员组合包自动发货","下单后发送主卡和附赠卡。","19.90","29.90","10","free","","images/bundle-1.jpg;images/bundle-2.jpg","","","","","是","101:1;102:1","是","201:1;202:2","是","72","亲,满意的话麻烦给个评价,谢谢~","1"],["","普通商品","仅发布商品,不创建自动化规则。","49.90","","10","fixed","8.00","https://example.com/product.jpg","","","","","否","","否","","否","","",""]]].map(ye=>ye.map(fe=>`"${String(fe).replace(/"/g,'""')}"`).join(",")).join(`
|
||
`),L=new Blob(["\uFEFF"+C],{type:"text/csv;charset=utf-8"}),de=URL.createObjectURL(L),H=document.createElement("a");H.href=de,H.download="批量铺货模板.csv",document.body.appendChild(H),H.click(),H.remove(),URL.revokeObjectURL(de)},[]),S=a.useCallback(()=>{F(l=>({...l,cookie_id:s||l.cookie_id})),y(!0)},[s]),T=a.useCallback(()=>{M(l=>({...l,cookie_id:s||l.cookie_id})),n(!0)},[s]),be=a.useCallback(async l=>{if(!(l?s:u.cookie_id))return alert("请先选择发布账号");if(!navigator.geolocation)return alert("当前浏览器不支持定位");I(!0),navigator.geolocation.getCurrentPosition(async C=>{try{const L=await Pt(C.coords.longitude,C.coords.latitude);if(!L.length)throw new Error("当前位置附近没有可用的高德发货地,请稍后重试");l?(P(L),f(L[0])):(V(L),U(L[0]))}catch(L){alert(we(L,"获取发货地失败"))}finally{I(!1)}},C=>{I(!1),alert(C.code===C.PERMISSION_DENIED?"定位权限被拒绝,请在浏览器设置中允许定位":"无法获取当前位置,请稍后重试")},{enableHighAccuracy:!0,timeout:15e3,maximumAge:6e4})},[u.cookie_id,s,f,P]);return{selectedAccount:s,setSelectedAccount:c,loading:A,publishing:K,showEditModal:Z,setShowEditModal:E,showAddModal:J,setShowAddModal:y,showPublishModal:N,setShowPublishModal:n,locationLoading:_,publishLocations:$,setPublishLocations:V,publishLocation:D,setPublishLocation:U,selectedItem:B,editForm:p,setEditForm:k,addForm:o,setAddForm:F,publishForm:u,setPublishForm:M,publishImagePreviews:te,handleSync:Y,handleEdit:X,handleSaveEdit:Q,handleDelete:se,handleAddItem:ce,handlePublishItem:r,downloadPublishTemplate:h,openAddModal:S,openPublishModal:T,locateForPublish:be}},Et=({phase:s})=>{const c=[["upload","1 上传"],["preview","2 预检"],["running","3 发布"],["done","4 结果"]];return e.jsx("div",{className:"grid grid-cols-4 gap-2",children:c.map(([x,d])=>e.jsx("div",{className:`rounded-xl px-3 py-2 text-center text-xs font-extrabold border ${s===x?"bg-blue-600 text-white border-blue-600":"bg-gray-50 text-gray-500 border-gray-100"}`,children:d},x))})},$t=s=>{const c=String(s||"").trim();return c?/^[¥¥]/.test(c)?c:`¥${c}`:"-"},Tt=({onConfigureDelivery:s})=>{const[c,x]=a.useState([]),[d,m]=a.useState([]),[g,P]=a.useState([]),[f,A]=a.useState(""),[w,K]=a.useState(""),O=a.useCallback(async()=>{const t=await Ae();x(t)},[]),Z=a.useCallback(async()=>{m(await Fe())},[]),E=Mt({selectedAccount:f,loadItems:O,loadShippingRules:Z}),{showBatchModal:J,setShowBatchModal:y,batchLoading:N,batchPhase:n,batchFile:_,setBatchFile:I,batchImagesZip:$,setBatchImagesZip:V,batchCategoryKeyword:D,setBatchCategoryKeyword:U,batchCategoryLoading:B,batchFallbackCategory:q,setBatchFallbackCategory:p,batchPreview:k,batchDetail:o,recentBatch:F,setRecentBatch:u,batchLocations:M,batchLocation:te,setBatchLocations:W,setBatchLocation:Y,openBatchModal:X,handleRecommendBatchCategory:Q,openRecentBatchResult:se,handlePreviewBatch:ce,handleStartBatch:r,handleCancelBatch:h,abandonBatchPreview:S,closeBatchModal:T,handleRetryBatchFailed:be}=E,l=Rt({selectedAccount:f,setSelectedAccount:A,setItems:x,loadItems:O,loadShippingRules:Z,onConfigureDelivery:s,setBatchLocations:W,setBatchLocation:Y}),{loading:j,publishing:C,showEditModal:L,setShowEditModal:de,showAddModal:H,setShowAddModal:ye,showPublishModal:fe,setShowPublishModal:Ze,locationLoading:oe,publishLocations:xe,setPublishLocations:Ge,publishLocation:Je,setPublishLocation:ke,selectedItem:Ce,editForm:G,setEditForm:me,addForm:R,setAddForm:ae,publishForm:b,setPublishForm:z,publishImagePreviews:Ie,handleSync:Ve,handleEdit:We,handleSaveEdit:Ye,handleDelete:Xe,handleAddItem:He,handlePublishItem:Qe,downloadPublishTemplate:et,openAddModal:tt,openPublishModal:st,locateForPublish:Se}=l;a.useEffect(()=>{Promise.all([pt(),Ae(),Fe(),Oe(20)]).then(([t,i,v,ie])=>{P(t),x(i),m(v);const he=ie.find(je=>["running","canceling"].includes(je.status))||ie.find(je=>je.status!=="preview");u(he||null)}).catch(t=>console.error("加载商品配置失败:",t))},[]);const at=t=>d.filter(i=>i.cookie_id===t.cookie_id&&i.item_id===t.item_id).length>0?d.filter(i=>i.cookie_id===t.cookie_id&&i.item_id===t.item_id):d.filter(i=>i.cookie_id===t.cookie_id&&!i.item_id),Pe=a.useMemo(()=>new Map(g.map(t=>[t.id,t])),[g]),Be=a.useMemo(()=>w?c.filter(t=>t.cookie_id===w):c,[w,c]),le=t=>{const i=Pe.get(t),v=(i==null?void 0:i.remark)||(i==null?void 0:i.nickname);return v?`${v} · ${t.slice(0,6)}`:`账号 ${t.slice(0,8)}`},Le=t=>{const i=Pe.get(t);return(i==null?void 0:i.remark)||(i==null?void 0:i.nickname)||"未命名账号"};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row xl:justify-between xl:items-center gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold text-gray-900",children:"商品管理"}),e.jsx("p",{className:"text-gray-500 mt-2 text-sm",children:"监控并管理所有账号下的闲鱼商品。"})]}),e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-account-filter",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"商品列表筛选"}),e.jsxs("div",{className:"relative",children:[e.jsx(gt,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-account-filter","aria-label":"按账号筛选商品列表",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:w,onChange:(t=>K(t.target.value)),children:[e.jsx("option",{value:"",children:"全部账号"}),g.map(t=>e.jsx("option",{value:t.id,children:le(t.id)},t.id))]})]})]}),e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-sync-account",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"同步商品账号"}),e.jsxs("div",{className:"relative",children:[e.jsx(Me,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-sync-account","aria-label":"选择要同步商品的账号",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:f,onChange:(t=>A(t.target.value)),children:[e.jsx("option",{value:"",children:"请选择账号"}),g.map(t=>e.jsx("option",{value:t.id,children:le(t.id)},t.id))]})]})]}),e.jsxs("button",{onClick:Ve,disabled:j||!f,className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:[e.jsx(Ne,{className:`w-4 h-4 ${j?"animate-spin":""}`}),"同步商品"]}),e.jsxs("button",{onClick:tt,className:"px-5 py-3 rounded-2xl font-bold bg-gray-900 text-white hover:bg-gray-800 transition-colors flex items-center gap-2 shadow-lg",children:[e.jsx(Re,{className:"w-4 h-4"}),"添加商品"]}),e.jsxs("button",{onClick:st,className:"px-5 py-3 rounded-2xl font-bold bg-emerald-500 text-white hover:bg-emerald-600 transition-colors flex items-center gap-2 shadow-lg shadow-emerald-100",children:[e.jsx(ve,{className:"w-4 h-4"}),"发布商品"]}),e.jsxs("button",{onClick:(()=>void X()),className:"px-5 py-3 rounded-2xl font-bold bg-brand text-white hover:bg-brand-highlight transition-colors flex items-center gap-2 shadow-lg shadow-blue-100",children:[e.jsx(pe,{className:"w-4 h-4"}),F&&["running","canceling"].includes(F.status)?"继续批量任务":"批量铺货"]}),F&&!["running","canceling"].includes(F.status)&&e.jsx("button",{onClick:(()=>void se()),className:"px-4 py-3 rounded-2xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"最近批次结果"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4",children:[Be.map(t=>{const i=at(t),v=i.length>0;return e.jsxs("div",{className:"ios-card p-3 rounded-2xl hover:shadow-lg transition-all group relative flex flex-col",children:[e.jsxs("div",{className:"absolute top-2 right-2 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity z-10",children:[e.jsx("button",{onClick:(()=>We(t)),className:"p-1.5 bg-white/90 backdrop-blur rounded-lg shadow-md text-gray-600 hover:bg-brand hover:text-white transition-colors",title:"编辑",children:e.jsx(bt,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:(()=>Xe(t)),className:"p-1.5 bg-white/90 backdrop-blur rounded-lg shadow-md hover:bg-red-100 text-red-500 transition-colors",title:"删除",children:e.jsx(yt,{className:"w-3.5 h-3.5"})})]}),e.jsxs("div",{className:"aspect-square bg-gray-100 rounded-xl mb-2.5 overflow-hidden relative",children:[t.item_image?e.jsx("img",{src:t.item_image,alt:"",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-gray-300",children:e.jsx(ft,{className:"w-8 h-8"})}),e.jsx("div",{className:"absolute top-1.5 left-1.5 bg-black/50 backdrop-blur-md text-white text-[10px] font-bold px-1.5 py-0.5 rounded-md",children:$t(t.item_price)})]}),e.jsx("h3",{className:"font-bold text-gray-900 line-clamp-2 text-xs mb-1.5 h-8 leading-4",children:t.item_title}),e.jsxs("div",{className:"mb-2 inline-flex min-w-0 max-w-full items-center gap-1 self-start rounded-md bg-blue-50 px-2 py-1 text-[10px] font-extrabold text-blue-700",title:Le(t.cookie_id),children:[e.jsx(Me,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate whitespace-nowrap",children:Le(t.cookie_id)})]}),e.jsxs("div",{className:"flex justify-between items-center text-[10px] text-gray-500 mb-2",children:[e.jsxs("span",{className:"bg-gray-100 px-1.5 py-0.5 rounded truncate max-w-[80px]",children:["ID: ",t.item_id]}),e.jsxs("span",{className:`inline-flex items-center gap-1 font-bold ${v?"text-emerald-600":"text-amber-600"}`,children:[v?e.jsx(Ee,{className:"w-3 h-3"}):e.jsx(jt,{className:"w-3 h-3"}),v?`${i.length} 规则`:"未配置"]})]}),e.jsx("div",{className:"space-y-2 mt-auto",children:e.jsxs("button",{onClick:(()=>s(t)),className:`w-full flex items-center justify-between gap-1 px-2.5 py-2 rounded-lg text-[11px] font-extrabold transition-all ${v?"bg-gray-900 text-white hover:bg-black":"bg-brand text-white hover:bg-brand-highlight shadow-md shadow-blue-100"}`,children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Nt,{className:"w-3.5 h-3.5"}),v?"查看发货规则":"关联发货规则"]}),e.jsx(vt,{className:"w-3.5 h-3.5"})]})})]},`${t.cookie_id}-${t.item_id}`)}),Be.length===0&&e.jsxs("div",{className:"col-span-full py-20 text-center text-gray-400",children:[e.jsx(wt,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),w?"该账号暂无商品数据":"暂无商品数据,请选择账号进行同步"]})]}),L&&Ce&&ue.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"560px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"编辑商品"}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["ID: ",Ce.item_id]})]}),e.jsx("button",{onClick:(()=>de(!1)),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:e.jsx(re,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-4",children:[e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"商品标题",value:G.item_title||"",onChange:(t=>me({...G,item_title:t.target.value}))}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"价格",value:G.item_price||"",onChange:(t=>me({...G,item_price:t.target.value}))}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"分类",value:G.item_category||"",onChange:(t=>me({...G,item_category:t.target.value}))}),e.jsx("textarea",{className:"w-full ios-input px-4 py-3 rounded-xl h-28 resize-none",placeholder:"描述",value:G.item_description||"",onChange:(t=>me({...G,item_description:t.target.value}))})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{onClick:Ye,className:"w-full ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(_t,{className:"w-4 h-4"}),"保存"]})})]})}),document.body),H&&ue.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"720px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"添加商品"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"手动建立商品与自动发货规则的关联"})]}),e.jsx("button",{onClick:(()=>ye(!1)),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(re,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"所属账号"}),e.jsxs("select",{className:"w-full ios-input px-4 py-3 rounded-xl",value:R.cookie_id,onChange:(t=>ae({...R,cookie_id:t.target.value})),children:[e.jsx("option",{value:"",children:"选择账号"}),g.map(t=>e.jsx("option",{value:t.id,children:le(t.id)},t.id))]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品 ID"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"输入闲鱼商品 ID",value:R.item_id,onChange:(t=>ae({...R,item_id:t.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品价格"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如 99.00",value:R.item_price,onChange:(t=>ae({...R,item_price:t.target.value}))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品标题"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"输入商品标题",value:R.item_title,onChange:(t=>ae({...R,item_title:t.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"图片 URL"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"https://...",value:R.item_image,onChange:(t=>ae({...R,item_image:t.target.value}))})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{onClick:He,className:"w-full ios-btn-primary px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Re,{className:"w-4 h-4"}),"添加商品"]})})]})}),document.body),fe&&ue.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"820px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"发布商品到闲鱼"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"普通单规格发布;库存数量会写入闲鱼发布参数,用于判断账号库存能力。"})]}),e.jsx("button",{onClick:(()=>Ze(!1)),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(re,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsx("div",{className:"rounded-2xl border border-amber-200 bg-amber-50 p-4 text-sm text-amber-800 leading-6",children:"发布时必须填写库存。若账号没有库存发布能力,后端会返回明确的“库存权限不足”错误,不会误报为普通发布失败。"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"发布账号"}),e.jsxs("select",{className:"w-full ios-input px-4 py-3 rounded-xl",value:b.cookie_id,onChange:(t=>{z({...b,cookie_id:t.target.value}),Ge([]),ke(null)}),children:[e.jsx("option",{value:"",children:"选择账号"}),g.map(t=>e.jsx("option",{value:t.id,children:le(t.id)},t.id))]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品标题"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如:会员月卡自动发货",value:b.title,onChange:(t=>z({...b,title:t.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"库存数量"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",type:"number",min:"1",placeholder:"必须大于 0",value:b.quantity,onChange:(t=>z({...b,quantity:t.target.value}))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品描述"}),e.jsx("textarea",{className:"w-full ios-input px-4 py-3 rounded-xl h-28 resize-none",placeholder:"描述会用于自动识别类目;留空时使用标题",value:b.description,onChange:(t=>z({...b,description:t.target.value}))})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"售价"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"99.00",value:b.price,onChange:(t=>z({...b,price:t.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"原价(可选)"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"129.00",value:b.original_price,onChange:(t=>z({...b,original_price:t.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"运费方式"}),e.jsxs("select",{className:"w-full ios-input px-4 py-3 rounded-xl",value:b.postage_mode,onChange:(t=>z({...b,postage_mode:t.target.value})),children:[e.jsx("option",{value:"free",children:"包邮"}),e.jsx("option",{value:"distance",children:"按距离计费"}),e.jsx("option",{value:"fixed",children:"一口价邮费"}),e.jsx("option",{value:"none",children:"无需邮寄"})]})]})]}),b.postage_mode==="fixed"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"一口价邮费"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如 8.00",value:b.postage,onChange:(t=>z({...b,postage:t.target.value}))})]}),e.jsxs("div",{className:"rounded-2xl border border-sky-200 bg-sky-50 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"发货地(可选)"}),e.jsx("p",{className:"mt-1 text-xs text-sky-800",children:"虚拟商品无需发货地;发布失败时可再定位并作为补充信息提交。"})]}),e.jsxs("button",{type:"button",disabled:oe||!b.cookie_id,onClick:(()=>void Se(!1)),className:"ios-btn-primary flex items-center gap-2 rounded-xl px-4 py-2 text-sm font-bold disabled:opacity-50",children:[e.jsx($e,{className:"h-4 w-4"}),oe?"定位中...":"获取当前位置"]})]}),xe.length>0&&e.jsx("select",{className:"w-full ios-input rounded-xl bg-white px-4 py-3",value:String(Math.max(0,xe.indexOf(Je))),onChange:(t=>ke(xe[Number(t.target.value)]||null)),children:xe.map((t,i)=>e.jsx("option",{value:String(i),children:[t.province,t.city,t.area,t.poi_name].filter(Boolean).join(" ")},`${t.division_id}-${t.poi_id}-${i}`))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品图片(1-9 张)"}),e.jsxs("label",{className:"flex min-h-[120px] cursor-pointer flex-col items-center justify-center rounded-2xl border-2 border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center hover:border-emerald-300 hover:bg-emerald-50/50 transition-colors",children:[e.jsx(pe,{className:"w-8 h-8 text-emerald-600 mb-2"}),e.jsx("span",{className:"text-sm font-bold text-gray-800",children:"选择图片"}),e.jsx("span",{className:"text-xs text-gray-500 mt-1",children:b.images.length?"已选择 "+b.images.length+" 张":"支持 JPG / PNG / GIF"}),e.jsx("input",{className:"hidden",type:"file",accept:"image/*",multiple:!0,onChange:(t=>z({...b,images:Array.from(t.target.files||[]).slice(0,9)}))})]}),Ie.length>0&&e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-3",children:Ie.map(t=>e.jsx("div",{className:"aspect-square rounded-xl bg-gray-100 overflow-hidden border border-gray-100",children:e.jsx("img",{src:t.url,alt:"",className:"w-full h-full object-cover"})},t.key))})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{disabled:C,onClick:Qe,className:"w-full bg-emerald-500 hover:bg-emerald-600 disabled:opacity-60 text-white px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(ve,{className:"w-4 h-4"}),C?"正在发布...":"发布到闲鱼"]})})]})}),document.body),J&&ue.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"980px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"批量铺货"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"上传商品表格和图片 zip,先预检,再逐条发布到闲鱼。"})]}),e.jsx("button",{onClick:(()=>void T()),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(re,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsx(Et,{phase:n}),n==="upload"&&e.jsxs("div",{className:"space-y-5",children:[e.jsx("div",{className:"rounded-2xl border border-blue-100 bg-blue-50 p-4 text-sm text-blue-900 leading-6",children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-extrabold",children:"先下载模板,再按字段填写。"}),e.jsxs("div",{children:["图片字段写 zip 内相对路径,多个图片用英文分号分隔,例如 ",e.jsx("span",{className:"font-mono font-bold",children:"images/a.jpg;images/b.jpg"}),"。也支持直接填写图片 URL。"]})]}),e.jsx("button",{type:"button",onClick:et,className:"shrink-0 rounded-xl bg-blue-600 px-4 py-2 text-sm font-extrabold text-white hover:bg-blue-700",children:"下载CSV模板"})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"默认发布账号"}),e.jsxs("select",{className:"w-full ios-input px-4 py-3 rounded-xl",value:f,onChange:(t=>{A(t.target.value),W([]),Y(null)}),children:[e.jsx("option",{value:"",children:"选择账号"}),g.map(t=>e.jsx("option",{value:t.id,children:le(t.id)},t.id))]}),e.jsx("p",{className:"text-xs text-gray-500",children:"表格中“账号ID”为空时,会使用这里选择的账号。"})]}),e.jsxs("div",{className:"rounded-xl border border-amber-200 bg-amber-50/70 p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm font-extrabold text-gray-900",children:["默认类目 ",e.jsx("span",{className:"font-medium text-gray-500",children:"(可为空)"})]}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-amber-800",children:"填写后优先使用该类目;留空时由闲鱼根据每件商品自动识别。仍无法识别时,系统最终使用“电子资料”兜底。"})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsxs("label",{className:"relative flex-1",children:[e.jsx("span",{className:"sr-only",children:"类目关键词"}),e.jsx(De,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx("input",{className:"w-full ios-input rounded-xl bg-white py-2.5 pl-10 pr-3",placeholder:"输入关键词,例如:课程资料、设计素材",value:D,onChange:(t=>U(t.target.value)),onKeyDown:(t=>{t.key==="Enter"&&(t.preventDefault(),Q())})})]}),e.jsxs("button",{type:"button",disabled:!f||!D.trim()||B,onClick:(()=>void Q()),className:"ios-btn-primary flex min-h-[42px] items-center justify-center gap-2 rounded-xl px-4 text-sm font-bold disabled:opacity-50",children:[e.jsx(De,{className:"h-4 w-4"}),B?"匹配中...":"获取类目"]})]}),q.catId?e.jsxs("div",{className:"flex min-h-[46px] items-center justify-between gap-3 border-t border-amber-200 pt-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-bold text-gray-900",children:[e.jsx(Ee,{className:"h-4 w-4 shrink-0 text-emerald-600"}),e.jsx("span",{className:"truncate",children:q.catName})]}),e.jsxs("div",{className:"mt-1 font-mono text-xs text-gray-500",children:["类目 ",q.catId," · 频道 ",q.channelCatId]})]}),e.jsx("button",{type:"button",title:"清除默认类目",onClick:(()=>p({catId:"",catName:"",channelCatId:"",tbCatId:""})),className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-gray-500 hover:bg-white hover:text-gray-900",children:e.jsx(re,{className:"h-4 w-4"})})]}):null]}),e.jsxs("div",{className:"rounded-xl border border-sky-200 bg-sky-50 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"批次发货地(可选)"}),e.jsx("p",{className:"mt-1 text-xs text-sky-800",children:"虚拟商品可留空;填写后整个批次使用同一个发货地,并随任务保存用于恢复和重试。"})]}),e.jsxs("button",{type:"button",disabled:oe||!f,onClick:(()=>void Se(!0)),className:"ios-btn-primary flex items-center gap-2 rounded-xl px-4 py-2 text-sm font-bold disabled:opacity-50",children:[e.jsx($e,{className:"h-4 w-4"}),oe?"定位中...":"获取当前位置"]})]}),M.length>0&&e.jsx("select",{className:"w-full ios-input rounded-xl bg-white px-4 py-3",value:String(Math.max(0,M.indexOf(te))),onChange:(t=>Y(M[Number(t.target.value)]||null)),children:M.map((t,i)=>e.jsx("option",{value:String(i),children:[t.province,t.city,t.area,t.poi_name].filter(Boolean).join(" ")},`${t.division_id}-${t.poi_id}-${i}`))})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("label",{className:"flex min-h-[150px] cursor-pointer flex-col items-center justify-center rounded-2xl border-2 border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center hover:border-blue-300 hover:bg-blue-50 transition-colors",children:[e.jsx(pe,{className:"w-9 h-9 text-blue-600 mb-3"}),e.jsx("span",{className:"text-sm font-extrabold text-gray-900",children:"上传商品表格"}),e.jsx("span",{className:"text-xs text-gray-500 mt-1",children:_?_.name:"支持 .xlsx / .csv / .tsv"}),e.jsx("input",{className:"hidden",type:"file",accept:".xlsx,.csv,.tsv",onChange:(t=>{var i;return I(((i=t.target.files)==null?void 0:i[0])||null)})})]}),e.jsxs("label",{className:"flex min-h-[150px] cursor-pointer flex-col items-center justify-center rounded-2xl border-2 border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center hover:border-emerald-300 hover:bg-emerald-50 transition-colors",children:[e.jsx(pe,{className:"w-9 h-9 text-emerald-600 mb-3"}),e.jsx("span",{className:"text-sm font-extrabold text-gray-900",children:"上传图片 zip(可选)"}),e.jsx("span",{className:"text-xs text-gray-500 mt-1",children:$?$.name:"表格图片字段使用 zip 内相对路径"}),e.jsx("input",{className:"hidden",type:"file",accept:".zip",onChange:(t=>{var i;return V(((i=t.target.files)==null?void 0:i[0])||null)})})]})]}),e.jsxs("div",{className:"rounded-2xl bg-gray-50 border border-gray-100 p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"字段说明"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"照着下面的“什么时候填写”处理即可。预检发现问题时,会指出具体哪一行需要修改。"})]}),e.jsxs("div",{className:"rounded-xl border border-blue-100 bg-blue-50 p-4 text-xs text-blue-950",children:[e.jsx("div",{className:"text-sm font-extrabold",children:"“付款后发送的卡密”怎么填"}),e.jsxs("div",{className:"mt-3 grid grid-cols-1 gap-3 lg:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg bg-white/80 p-3",children:[e.jsx("code",{className:"font-bold text-blue-700",children:"101"}),e.jsx("p",{className:"mt-1 leading-5",children:"从卡密组 101 立即发送 1 份。卡密组 ID 可以在“卡密库存”页面查看。"})]}),e.jsxs("div",{className:"rounded-lg bg-white/80 p-3",children:[e.jsx("code",{className:"font-bold text-blue-700",children:"101:2"}),e.jsx("p",{className:"mt-1 leading-5",children:"每购买 1 件,就从卡密组 101 发送 2 份。买家购买 3 件时会发送 6 份。"})]}),e.jsxs("div",{className:"rounded-lg bg-white/80 p-3",children:[e.jsx("code",{className:"font-bold text-blue-700",children:"101:1:0;102:2:3"}),e.jsx("p",{className:"mt-1 leading-5",children:"先立即发送卡密组 101 的 1 份,再等待 3 秒发送卡密组 102 的 2 份。"})]})]}),e.jsxs("p",{className:"mt-3 leading-5 text-blue-800",children:["每一组依次写“卡密组 ID : 每件发送几份 : 等待几秒”。份数不写时按 1 份处理,等待时间不写时立即发送。需要发送多种卡密时,用英文分号 ",e.jsx("code",{className:"font-bold",children:";"})," 隔开。"]})]}),e.jsx("div",{className:"overflow-x-auto rounded-xl border border-gray-100 bg-white",children:e.jsxs("table",{className:"w-full text-left text-xs",children:[e.jsx("thead",{className:"bg-gray-50 text-gray-500",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2",children:"字段"}),e.jsx("th",{className:"px-3 py-2",children:"什么时候填写"}),e.jsx("th",{className:"px-3 py-2",children:"填写方法"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50 text-gray-700",children:[["账号ID","需要覆盖默认账号时填写","上方默认发布账号为必选;本列留空时使用默认账号,填写后仅覆盖当前行"],["标题","每个商品都要填","填写买家能看到的商品标题"],["描述","可以留空","留空时会使用商品标题作为描述"],["价格","每个商品都要填","只填数字,例如 19.90"],["原价","可以留空","需要展示划线原价时填写,例如 29.90"],["库存","可以留空","留空按 1 件处理;填写时必须大于 0"],["邮费模式","可以留空","留空表示包邮;包邮填 free,固定邮费填 fixed"],["邮费","邮费模式填 fixed 时填写","只填数字,例如 8.00"],["图片","每个商品都要填","填写 zip 内图片路径或图片网址;多张图片用英文分号隔开"],["类目ID","需要指定当前行默认类目时填写","必须和“类目名称、频道类目ID”同时填写;优先于自动识别"],["类目名称","填写了“类目ID”时必填","填写该 ID 对应的准确类目名称"],["频道类目ID","覆盖类目时必填","必须填写闲鱼返回的准确频道类目 ID"],["淘宝类目ID","按闲鱼返回填写","“电子资料”无淘宝类目 ID,保持为空"],["付款发货启用","需要付款后自动发货时填写","填“是”表示开启;不需要时填“否”或留空"],["付款发货内容","“付款发货启用”填“是”时填写","从“卡密库存”页面取得卡密组 ID,按上方示例填写"],["评价赠品启用","需要评价赠品时填写","填“是”表示开启;不需要时填“否”或留空"],["评价赠品内容","“评价赠品启用”填“是”时填写","格式和付款发货内容相同,也可以同时发送多个卡密组"],["求评价启用","需要自动求评价时填写","填“是”表示开启;不需要时填“否”或留空"],["求评价等待小时","“求评价启用”填“是”时填写","填写等待小时数;留空按 72 小时处理"],["求评价文案","“求评价启用”填“是”时填写","填写要发送给买家的求评价消息"],["求评价最多次数","可以留空","留空只提醒 1 次"]].map(([t,i,v])=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 font-bold text-gray-900 whitespace-nowrap",children:t}),e.jsx("td",{className:`px-3 py-2 min-w-[210px] font-bold ${i==="每个商品都要填"?"text-red-600":i==="可以留空"?"text-gray-500":"text-amber-700"}`,children:i}),e.jsx("td",{className:"px-3 py-2 min-w-[260px]",children:v})]},t))})]})})]})]}),n==="preview"&&k&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"rounded-2xl bg-gray-50 p-4 border border-gray-100",children:[e.jsx("div",{className:"text-xs font-bold text-gray-500",children:"总行数"}),e.jsx("div",{className:"text-2xl font-extrabold text-gray-900 mt-1",children:k.total})]}),e.jsxs("div",{className:"rounded-2xl bg-emerald-50 p-4 border border-emerald-100",children:[e.jsx("div",{className:"text-xs font-bold text-emerald-700",children:"可发布"}),e.jsx("div",{className:"text-2xl font-extrabold text-emerald-700 mt-1",children:k.valid})]}),e.jsxs("div",{className:"rounded-2xl bg-red-50 p-4 border border-red-100",children:[e.jsx("div",{className:"text-xs font-bold text-red-700",children:"有问题"}),e.jsx("div",{className:"text-2xl font-extrabold text-red-700 mt-1",children:k.invalid})]})]}),e.jsx("div",{className:"max-h-[380px] overflow-y-auto rounded-2xl border border-gray-100",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{className:"sticky top-0 bg-white text-xs text-gray-400 border-b border-gray-100",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3",children:"行号"}),e.jsx("th",{className:"px-4 py-3",children:"状态"}),e.jsx("th",{className:"px-4 py-3",children:"标题"}),e.jsx("th",{className:"px-4 py-3",children:"价格/库存"}),e.jsx("th",{className:"px-4 py-3",children:"类目策略"}),e.jsx("th",{className:"px-4 py-3",children:"图片"}),e.jsx("th",{className:"px-4 py-3",children:"问题"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:k.rows.map(t=>{var i,v,ie,he;return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:t.row_no}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`inline-flex px-2 py-1 rounded-lg border text-xs font-extrabold ${t.valid?"bg-emerald-50 text-emerald-700 border-emerald-100":"bg-red-50 text-red-700 border-red-100"}`,children:t.valid?"可发布":"需修正"})}),e.jsx("td",{className:"px-4 py-3 font-bold text-gray-900 max-w-[240px] truncate",children:t.title||"-"}),e.jsxs("td",{className:"px-4 py-3 text-gray-600",children:["¥",t.price||"-"," / ",t.quantity||1]}),e.jsxs("td",{className:"px-4 py-3 text-xs text-gray-600 min-w-[150px]",children:[e.jsx("div",{className:"font-bold text-gray-800",children:((i=t.category)==null?void 0:i.cat_name)||"自动识别"}),e.jsx("div",{className:"font-mono text-gray-400",children:((v=t.category)==null?void 0:v.cat_id)||"失败后使用电子资料"})]}),e.jsxs("td",{className:"px-4 py-3 text-gray-600",children:[((ie=t.images)==null?void 0:ie.length)||0," 张"]}),e.jsx("td",{className:"px-4 py-3 text-red-600 text-xs max-w-[280px]",children:((he=t.errors)==null?void 0:he.join(";"))||"-"})]},t.row_no)})})]})})]}),(n==="running"||n==="done")&&o&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[e.jsxs("div",{className:`rounded-2xl p-4 border ${Te(o.status)}`,children:[e.jsx("div",{className:"text-xs font-bold opacity-70",children:"任务状态"}),e.jsx("div",{className:"text-xl font-extrabold mt-1",children:qe(o.status)})]}),e.jsxs("div",{className:"rounded-2xl bg-gray-50 p-4 border border-gray-100",children:[e.jsx("div",{className:"text-xs font-bold text-gray-500",children:"总数"}),e.jsx("div",{className:"text-xl font-extrabold text-gray-900 mt-1",children:o.total})]}),e.jsxs("div",{className:"rounded-2xl bg-emerald-50 p-4 border border-emerald-100",children:[e.jsx("div",{className:"text-xs font-bold text-emerald-700",children:"成功"}),e.jsx("div",{className:"text-xl font-extrabold text-emerald-700 mt-1",children:o.success})]}),e.jsxs("div",{className:"rounded-2xl bg-red-50 p-4 border border-red-100",children:[e.jsx("div",{className:"text-xs font-bold text-red-700",children:"失败"}),e.jsx("div",{className:"text-xl font-extrabold text-red-700 mt-1",children:o.failed})]}),e.jsxs("div",{className:"rounded-2xl bg-blue-50 p-4 border border-blue-100",children:[e.jsx("div",{className:"text-xs font-bold text-blue-700",children:"等待"}),e.jsx("div",{className:"text-xl font-extrabold text-blue-700 mt-1",children:o.pending})]})]}),e.jsx("div",{className:"max-h-[420px] overflow-y-auto rounded-2xl border border-gray-100",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{className:"sticky top-0 bg-white text-xs text-gray-400 border-b border-gray-100",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3",children:"行号"}),e.jsx("th",{className:"px-4 py-3",children:"状态"}),e.jsx("th",{className:"px-4 py-3",children:"标题"}),e.jsx("th",{className:"px-4 py-3",children:"类目策略"}),e.jsx("th",{className:"px-4 py-3",children:"商品ID"}),e.jsx("th",{className:"px-4 py-3",children:"错误原因"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:o.rows.map(t=>{var i,v;return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:t.row_no}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`inline-flex px-2 py-1 rounded-lg border text-xs font-extrabold ${Te(t.status)}`,children:qe(t.status)})}),e.jsx("td",{className:"px-4 py-3 font-bold text-gray-900 max-w-[260px] truncate",children:t.title}),e.jsxs("td",{className:"px-4 py-3 text-xs text-gray-600 min-w-[150px]",children:[e.jsx("div",{className:"font-bold text-gray-800",children:((i=t.category)==null?void 0:i.cat_name)||"自动识别"}),e.jsx("div",{className:"font-mono text-gray-400",children:((v=t.category)==null?void 0:v.cat_id)||"失败后使用电子资料"})]}),e.jsx("td",{className:"px-4 py-3 text-xs font-mono",children:t.item_url?e.jsx("a",{href:t.item_url,target:"_blank",rel:"noreferrer",className:"text-blue-600 hover:underline",children:t.item_id}):t.item_id||"-"}),e.jsx("td",{className:"px-4 py-3 text-red-600 text-xs max-w-[340px]",children:t.error_message||"-"})]},t.id)})})]})})]})]}),e.jsxs("div",{className:"modal-footer",children:[n==="upload"&&e.jsxs("button",{disabled:N||!_||!f,onClick:ce,className:"w-full ios-btn-primary px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2 disabled:opacity-50",children:[e.jsx(Ne,{className:`w-4 h-4 ${N?"animate-spin":""}`}),N?"正在预检...":"开始预检"]}),n==="preview"&&k&&e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{disabled:N,onClick:(()=>void S()),className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold",children:"返回修改"}),e.jsxs("button",{disabled:N||k.valid<=0,onClick:r,className:"flex-1 ios-btn-primary px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2 disabled:opacity-50",children:[e.jsx(ve,{className:"w-4 h-4"}),N?"启动中...":`确认发布 ${k.valid} 个商品`]})]}),(n==="running"||n==="done")&&o&&e.jsxs("div",{className:"flex gap-3 w-full",children:[o.status==="running"?e.jsx("button",{disabled:N,onClick:h,className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-900 text-white hover:bg-black font-bold",children:"取消任务"}):o.status==="canceling"?e.jsx("button",{disabled:!0,className:"flex-1 px-6 py-3.5 rounded-xl bg-amber-100 text-amber-800 font-bold",children:"正在保存远端结果并安全取消…"}):e.jsx("button",{onClick:(()=>window.open(`/api/v1/items/publish-batches/${o.id}/result.csv`,"_blank")),className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-900 text-white hover:bg-black font-bold",children:"下载结果"}),o.retryable>0&&!["running","canceling"].includes(o.status)&&e.jsxs("button",{disabled:N,onClick:be,className:"flex-1 ios-btn-primary px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Ne,{className:`w-4 h-4 ${N?"animate-spin":""}`}),"重试失败项"]}),!["running","canceling"].includes(o.status)&&e.jsx("button",{onClick:(()=>{y(!1),O(),Z()}),className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold",children:"完成"})]})]})]})}),document.body)]})};export{Tt as default};
|