import{e as M,r as v,d as T,M as j,P as l,a3 as i,a4 as s,a7 as x,ab as h,A as p,f as S,B as F,I,H as r,a9 as P}from"./vue-bf422dc1.js";import{r as k,u as L}from"./index-c2dd6a24.js";import{p as q}from"./global-0d825ba6.js";import{_ as H}from"./search.vue_vue_type_script_setup_true_lang-13f11264.js";import{T as U,L as E,S as G,j as J,b as O,M as $}from"./ui-ba7aaa7e.js";import"./libs-51817cd7.js";import"./plugins-ca970193.js";import"./others-9f318174.js";import"./echarts-bf9d612c.js";import"./icons-a8498fb6.js";function Q(o){return k.post({url:"/adminapi/goods/goods/list",params:o})}function W(o){return k.post({url:"/adminapi/goods/goods/del",params:o})}function X(o){return k.post({url:"/adminapi/goods/goods/freeze",params:o})}function Y(o){return k.post({url:"/adminapi/goods/goods/status",params:o})}const Z=[{colKey:"id",title:"ID",ellipsis:!0},{colKey:"username",title:"商户账号",ellipsis:!0},{colKey:"name",title:"商品名称",ellipsis:!0},{colKey:"price",title:"商品价格",ellipsis:!0},{colKey:"freeze",title:"冻结"},{colKey:"operate",title:"操作",ellipsis:!0}],ee={class:"category-header c-flex"},te={class:"l"},pe=M({__name:"index",setup(o){const m=v(),f=v(!1),D=T(()=>f.value?"收起搜索":"展开搜索"),n=v({defaultPageSize:20,total:0,defaultCurrent:1}),y=v([]),_=async(e={})=>{m.value={...e};const{data:a}=await Q({page:n.value.defaultCurrent,limit:n.value.defaultPageSize,...m.value});y.value=a.list,n.value={defaultPageSize:a.limit,total:a.total,defaultCurrent:a.page}};_();const K=e=>{n.value.defaultCurrent=e.current,n.value.defaultPageSize=e.pageSize,_(m.value)},R=L(),w=T(()=>({offsetTop:R.isUseTabsRouter?48:0,container:`.${q}-layout`})),C=async(e,a,c)=>{const d=await e(c!==void 0?{id:a,val:c}:{id:a});if(d.code===1){$.success(d.msg),_(m.value);return}$.error(d.msg)},b=(e,a=0)=>C(W,e,a),B=e=>C(X,e),N=e=>C(Y,e);return(e,a)=>{const c=U,u=E,d=G,V=J,A=O,g=j("perms");return l(),i(A,{title:"商品管理",class:"basic-container",bordered:!1},{actions:s(()=>[x("a",{href:"javascript:void(0)",onClick:a[0]||(a[0]=t=>f.value=!f.value)},h(D.value),1)]),default:s(()=>[x("div",ee,[x("div",te,[p(S(H,{ref:"searchFormRef",onSuccess:_},null,512),[[F,f.value]])])]),S(V,{data:y.value,columns:I(Z),"row-key":"id","expand-on-row-click":!1,hover:y.value.length>0,pagination:n.value,"header-affixed-top":w.value,"table-layout":"auto","max-height":"100%",onPageChange:K},{status:s(({row:t})=>[t.status===1?(l(),i(c,{key:0,theme:"success"},{default:s(()=>[r("启用")]),_:1})):(l(),i(c,{key:1,theme:"danger"},{default:s(()=>[r("禁用")]),_:1}))]),freeze:s(({row:t})=>[t.delete_at==null?p((l(),i(u,{key:0,theme:"primary",size:"small",onClick:z=>B(t.id)},{default:s(()=>[r(h(t.is_freeze===1?"解冻":"冻结"),1)]),_:2},1032,["onClick"])),[[g,["adminapi/goods/goods/freeze"]]]):P("",!0)]),operate:s(({row:t})=>[S(d,null,{default:s(()=>[t.delete_at==null?p((l(),i(u,{key:0,theme:"primary",size:"small",onClick:z=>N(t.id)},{default:s(()=>[r(h(t.status===1?"下架":"上架"),1)]),_:2},1032,["onClick"])),[[g,["adminapi/goods/goods/status"]]]):P("",!0),p((l(),i(u,{theme:"danger",size:"small",onClick:z=>b(t.id,0)},{default:s(()=>[r(h(t.delete_at?"恢复":"放回收站"),1)]),_:2},1032,["onClick"])),[[g,["adminapi/goods/goods/del"]]]),p((l(),i(u,{theme:"danger",size:"small",onClick:z=>b(t.id,1)},{default:s(()=>[r(" 删除 ")]),_:2},1032,["onClick"])),[[g,["adminapi/goods/goods/del"]]])]),_:2},1024)]),_:1},8,["data","columns","hover","pagination","header-affixed-top"])]),_:1})}}});export{pe as default};
