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{a8 as t,a2 as a,a3 as s,ah as l,$ as n,a6 as r,R as i,a7 as o,af as c,ae as u,_ as d}from"./vendor-element-C6D3GHVC.js";import{t as p,bG as g,bA as m,c as v,bL as f,r as x,a3 as b,S as h,v as y,x as w,B as _,O as k,L as j,u as z,F as C,G as D,E as I,I as R,K as S,bD as A}from"./vendor-core-B-NFAs71.js";import{T as P}from"./index-7yqO2wM9.js";import{a as T}from"./index-BhVZTysP.js";import{j as U,t as B}from"./agent-C7ZCha77.js";const E={class:"agent-products-page"},G={class:"page-header"},L={class:"title"},$={class:"subtitle"},F={class:"table-operations mb-4"},H={class:"flex items-center gap-3"},K={class:"shrink-0"},M={class:"w-12 h-12 rounded bg-blue-50 text-blue-500 flex items-center justify-center font-bold text-lg"},N={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"},O={class:"flex flex-col gap-1 min-w-0"},Z={class:"flex items-center gap-2 min-w-0"},q=["title"],J=["onClick"],Q={class:"flex items-center gap-2 text-xs"},V={class:"text-gray-500"},W={class:"text-orange-500 font-medium"},X={class:"text-gray-500"},Y={class:"text-gray-700"},ee={class:"flex justify-end mt-4"},te=A(p({__name:"products",setup(p){const{t:A}=g(),{width:te}=f(),ae=m(),se=T(),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(A("user.docking.cancelDistributeConfirm"),A("common.tip"),{confirmButtonText:A("common.confirm"),cancelButtonText:A("common.cancel"),type:"warning"}).then(()=>{(t=>{e(null,null,function*(){try{yield B(t.id,0),oe()}catch(e){}})})(t)}).catch(()=>{})};return h(()=>{oe()}),(e,d)=>{const p=t,g=l,m=n,v=s,f=r,x=a,b=c,h=u,T=o;return w(),y("div",E,[_("div",G,[_("div",L,j(z(A)("user.docking.productsTitle")),1),_("div",$,j(z(A)("user.docking.productsDesc")),1)]),k(h,{shadow:"hover"},{default:C(()=>[_("div",F,[k(p,{title:z(A)("user.docking.distributeHint"),type:"info","show-icon":"",closable:!1},null,8,["title"])]),D((w(),I(x,{data:re.value,style:{width:"100%"}},{default:C(()=>[k(v,{label:z(A)("user.docking.productInfo"),"min-width":"300"},{default:C(({row:e})=>[_("div",H,[_("div",K,[e.cover_image?(w(),I(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(()=>[_("div",M,j(e.name.charAt(0)),1)]),_:2},1032,["src","preview-src-list"])):(w(),y("div",N,j(e.name.charAt(0)),1))]),_("div",O,[_("div",Z,[_("span",{class:"font-medium truncate text-gray-900 dark:text-gray-100 truncate",title:e.name},j(e.name),9,q),k(m,{content:"查看商品详情",placement:"top"},{default:C(()=>[_("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,J)]),_:2},1024)]),_("div",Q,[_("span",V,[S(j(z(A)("user.agent.price"))+": ",1),_("span",W,"¥"+j(e.price),1)]),d[2]||(d[2]=_("span",{class:"text-gray-300"},"|",-1)),_("span",X,[S(j(z(A)("user.agent.cost"))+": ",1),_("span",Y,"¥"+j(e.cost_price),1)])])])])]),_:1},8,["label"]),le.value?R("",!0):(w(),I(v,{key:0,label:z(A)("user.docking.distributeStatus"),width:"150"},{default:C(()=>[k(f,{type:"success",effect:"plain"},{default:C(()=>[S(j(z(A)("user.docking.distributing")),1)]),_:1})]),_:1},8,["label"])),k(v,{label:z(A)("common.action"),width:"70",fixed:"right"},{default:C(({row:e})=>[k(P,null,{default:C(()=>[k(z(i),{class:"text-red-500",onClick:t=>ce(e)},{default:C(()=>[S(j(z(A)("user.docking.cancelDistribute")),1)]),_:1},8,["onClick"])]),_:2},1024)]),_:1},8,["label"])]),_:1},8,["data"])),[[T,ne.value]]),_("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};
