var e=(e,t,a)=>new Promise((s,l)=>{var n=e=>{try{i(a.next(e))}catch(t){l(t)}},r=e=>{try{i(a.throw(e))}catch(t){l(t)}},i=e=>e.done?s(e.value):Promise.resolve(e.value).then(n,r);i((a=a.apply(e,t)).next())});import{$ as t,V as a,W as s,aa as l,S as n,Z as r,I as i,_ as o,a7 as c,a6 as u,R as d}from"./vendor-element-CbJWrKZ5.js";import{q as p,bD as g,by as m,c as v,bG as f,r as x,a1 as b,R as y,t as h,v as _,A as w,M as k,K as j,u as z,E as C,F as D,D as R,H as S,J as I}from"./vendor-core-DQkwEQyE.js";import{T as A}from"./index-DPtIr8EG.js";import{a as P,c as T}from"./index-DITu3gCO.js";import{j as U,t as B}from"./agent-DNO7s3AB.js";const E={class:"agent-products-page"},H={class:"page-header"},M={class:"title"},$={class:"subtitle"},q={class:"table-operations mb-4"},F={class:"flex items-center gap-3"},G={class:"shrink-0"},J={class:"w-12 h-12 rounded bg-blue-50 text-blue-500 flex items-center justify-center font-bold text-lg"},K={key:1,class:"w-12 h-12 rounded bg-blue-50 text-blue-500 flex items-center justify-center font-bold text-lg select-none"},N={class:"flex flex-col gap-1 min-w-0"},V={class:"flex items-center gap-2 min-w-0"},W=["title"],Z=["onClick"],L={class:"flex items-center gap-2 text-xs"},O={class:"text-gray-500"},Q={class:"text-orange-500 font-medium"},X={class:"text-gray-500"},Y={class:"text-gray-700"},ee={class:"flex justify-end mt-4"},te=T(p({__name:"products",setup(p){const{t:T}=g(),{width:te}=f(),ae=m(),se=P(),le=v(()=>{var e;const t=(null==(e=se.info)?void 0:e.roles)||[];return!(t.includes("R_ADMIN")||t.includes("R_SUPER"))&&te.value<768}),ne=x(!1),re=x([]),ie=b({page:1,size:10,total:0}),oe=()=>e(null,null,function*(){ne.value=!0;try{const e=yield U({page:ie.page,size:ie.size});e&&(re.value=e.list,ie.total=e.total)}finally{ne.value=!1}}),ce=t=>{d.confirm(T("user.docking.cancelDistributeConfirm"),T("common.tip"),{confirmButtonText:T("common.confirm"),cancelButtonText:T("common.cancel"),type:"warning"}).then(()=>{(t=>{e(null,null,function*(){try{yield B(t.id,0),oe()}catch(e){}})})(t)}).catch(()=>{})};return y(()=>{oe()}),(e,d)=>{const p=t,g=l,m=n,v=s,f=r,x=a,b=c,y=u,P=o;return _(),h("div",E,[w("div",H,[w("div",M,j(z(T)("user.docking.productsTitle")),1),w("div",$,j(z(T)("user.docking.productsDesc")),1)]),k(y,{shadow:"hover"},{default:C(()=>[w("div",q,[k(p,{title:z(T)("user.docking.distributeHint"),type:"info","show-icon":"",closable:!1},null,8,["title"])]),D((_(),R(x,{data:re.value,style:{width:"100%"}},{default:C(()=>[k(v,{label:z(T)("user.docking.productInfo"),"min-width":"300"},{default:C(({row:e})=>[w("div",F,[w("div",G,[e.cover_image?(_(),R(g,{key:0,src:e.cover_image,class:"w-12 h-12 rounded object-cover border border-gray-100","preview-src-list":[e.cover_image],"preview-teleported":""},{error:C(()=>[w("div",J,j(e.name.charAt(0)),1)]),_:2},1032,["src","preview-src-list"])):(_(),h("div",K,j(e.name.charAt(0)),1))]),w("div",N,[w("div",V,[w("span",{class:"font-medium truncate text-gray-900 dark:text-gray-100 truncate",title:e.name},j(e.name),9,W),k(m,{content:"查看商品详情",placement:"top"},{default:C(()=>[w("div",{class:"i-ri-external-link-line shrink-0 text-sm text-blue-600 cursor-pointer hover:text-blue-500",onClick:t=>(e=>{const t=(null==e?void 0:e.uuid)||(null==e?void 0:e.id);if(!t)return;const a=ae.resolve(`/detail/${encodeURIComponent(String(t))}`);window.open(a.href,"_blank")})(e)},null,8,Z)]),_:2},1024)]),w("div",L,[w("span",O,[I(j(z(T)("user.agent.price"))+": ",1),w("span",Q,"¥"+j(e.price),1)]),d[2]||(d[2]=w("span",{class:"text-gray-300"},"|",-1)),w("span",X,[I(j(z(T)("user.agent.cost"))+": ",1),w("span",Y,"¥"+j(e.cost_price),1)])])])])]),_:1},8,["label"]),le.value?S("",!0):(_(),R(v,{key:0,label:z(T)("user.docking.distributeStatus"),width:"150"},{default:C(()=>[k(f,{type:"success",effect:"plain"},{default:C(()=>[I(j(z(T)("user.docking.distributing")),1)]),_:1})]),_:1},8,["label"])),k(v,{label:z(T)("common.action"),width:"70",fixed:"right"},{default:C(({row:e})=>[k(A,null,{default:C(()=>[k(z(i),{class:"text-red-500",onClick:t=>ce(e)},{default:C(()=>[I(j(z(T)("user.docking.cancelDistribute")),1)]),_:1},8,["onClick"])]),_:2},1024)]),_:1},8,["label"])]),_:1},8,["data"])),[[P,ne.value]]),w("div",ee,[k(b,{"current-page":ie.page,"onUpdate:currentPage":d[0]||(d[0]=e=>ie.page=e),"page-size":ie.size,"onUpdate:pageSize":d[1]||(d[1]=e=>ie.size=e),total:ie.total,layout:le.value?"prev, pager, next":"total, prev, pager, next",onCurrentChange:oe},null,8,["current-page","page-size","total","layout"])])]),_:1})])}}}),[["__scopeId","data-v-bc974400"]]);export{te as default};
